summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPriti Aghera <paghera@broadcom.com>2013-04-04 18:05:09 -0700
committerMatthew Xie <mattx@google.com>2013-04-23 18:57:42 -0700
commit8629665794ef845e945595040e4cf1ea2fa508d3 (patch)
treed0c4eb96ecb41366fbb3d5ecec3bbdef5df3c831 /src
parentdb367aa803836ca5b80da6b07ea2ef8a4b0ca1d2 (diff)
downloadandroid_packages_apps_Bluetooth-8629665794ef845e945595040e4cf1ea2fa508d3.tar.gz
android_packages_apps_Bluetooth-8629665794ef845e945595040e4cf1ea2fa508d3.tar.bz2
android_packages_apps_Bluetooth-8629665794ef845e945595040e4cf1ea2fa508d3.zip
HDP Single SDP fix
Modified the stack logic to create single SDP record for all register call. bug 8656462 Change-Id: If06193aecbe7555e6b1402275ee243fcd672c812
Diffstat (limited to 'src')
-rw-r--r--[-rwxr-xr-x]src/com/android/bluetooth/hdp/HealthService.java41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/com/android/bluetooth/hdp/HealthService.java b/src/com/android/bluetooth/hdp/HealthService.java
index 291310be8..b418dcb0f 100755..100644
--- a/src/com/android/bluetooth/hdp/HealthService.java
+++ b/src/com/android/bluetooth/hdp/HealthService.java
@@ -43,6 +43,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -55,7 +56,8 @@ import java.util.NoSuchElementException;
* @hide
*/
public class HealthService extends ProfileService {
- private static final boolean DBG = false;
+ private static final boolean DBG = true;
+ private static final boolean VDBG = false;
private static final String TAG="HealthService";
private List<HealthChannel> mHealthChannels;
@@ -108,14 +110,15 @@ public class HealthService extends ProfileService {
}
private void cleanupApps(){
- for (Entry<BluetoothHealthAppConfiguration, AppInfo> entry : mApps.entrySet()) {
- try{
- AppInfo appInfo = entry.getValue();
- appInfo.cleanup();
- mApps.remove(entry.getKey());
- }catch(Exception e){
- Log.e(TAG,"Failed to cleanup appInfo for appid ="+entry.getKey());
- }
+ Iterator <Map.Entry<BluetoothHealthAppConfiguration,AppInfo>>it
+ = mApps.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry<BluetoothHealthAppConfiguration,AppInfo> entry = it.next();
+ AppInfo appInfo = entry.getValue();
+ if (appInfo != null)
+ appInfo.cleanup();
+ it.remove();
}
}
protected boolean cleanup() {
@@ -144,6 +147,7 @@ public class HealthService extends ProfileService {
@Override
public void handleMessage(Message msg) {
+ if (DBG) log("HealthService Handler msg: " + msg.what);
switch (msg.what) {
case MESSAGE_REGISTER_APPLICATION:
{
@@ -153,7 +157,7 @@ public class HealthService extends ProfileService {
if (appInfo == null) break;
int halRole = convertRoleToHal(appConfig.getRole());
int halChannelType = convertChannelTypeToHal(appConfig.getChannelType());
- if (DBG) log("register datatype: " + appConfig.getDataType() + " role: " +
+ if (VDBG) log("register datatype: " + appConfig.getDataType() + " role: " +
halRole + " name: " + appConfig.getName() + " channeltype: " +
halChannelType);
int appId = registerHealthAppNative(appConfig.getDataType(), halRole,
@@ -237,17 +241,24 @@ public class HealthService extends ProfileService {
appInfo.cleanup();
mApps.remove(appConfig);
}
- }
+ }
break;
case MESSAGE_CHANNEL_STATE_CALLBACK:
{
ChannelStateEvent channelStateEvent = (ChannelStateEvent) msg.obj;
HealthChannel chan = findChannelById(channelStateEvent.mChannelId);
+ BluetoothHealthAppConfiguration appConfig =
+ findAppConfigByAppId(channelStateEvent.mAppId);
int newState;
+ newState = convertHalChannelState(channelStateEvent.mState);
+ if (newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED &&
+ appConfig == null) {
+ Log.e(TAG,"Disconnected for non existing app");
+ break;
+ }
if (chan == null) {
// incoming connection
- BluetoothHealthAppConfiguration appConfig =
- findAppConfigByAppId(channelStateEvent.mAppId);
+
BluetoothDevice device = getDevice(channelStateEvent.mAddr);
chan = new HealthChannel(device, appConfig, appConfig.getChannelType());
chan.mChannelId = channelStateEvent.mChannelId;
@@ -289,7 +300,7 @@ public class HealthService extends ProfileService {
}
public void binderDied() {
- Log.d(TAG,"Binder is dead.");
+ if (DBG) Log.d(TAG,"Binder is dead.");
mService.unregisterAppConfiguration(mConfig);
}
@@ -497,7 +508,7 @@ public class HealthService extends ProfileService {
}
private void callStatusCallback(BluetoothHealthAppConfiguration config, int status) {
- if (DBG) log ("Health Device Application: " + config + " State Change: status:" + status);
+ if (VDBG) log ("Health Device Application: " + config + " State Change: status:" + status);
IBluetoothHealthCallback callback = (mApps.get(config)).mCallback;
if (callback == null) {
Log.e(TAG, "Callback object null");