diff options
author | Sai Aitharaju <saia@codeaurora.org> | 2014-11-14 16:54:35 +0530 |
---|---|---|
committer | Sai Aitharaju <saia@codeaurora.org> | 2014-11-20 15:46:23 +0530 |
commit | 7f2df1893c4ff15b16faa1611bfc1879b180092e (patch) | |
tree | d3fbd1f0e8173ff8c043144ae5ee02aa49d10b02 /src/com/android/bluetooth/hdp/HealthService.java | |
parent | 087a6cf7a9bf66d7789c9901cc111451b466d57b (diff) | |
download | android_packages_apps_Bluetooth-7f2df1893c4ff15b16faa1611bfc1879b180092e.tar.gz android_packages_apps_Bluetooth-7f2df1893c4ff15b16faa1611bfc1879b180092e.tar.bz2 android_packages_apps_Bluetooth-7f2df1893c4ff15b16faa1611bfc1879b180092e.zip |
Bluetooth App: Fix to resolve Klocwork issues in Bluetooth App
When Klocwork is run in Bluetooth App code space,we see many
Null pointer exceptions which were resolved by this fix.
CRs-fixed: 760114
Change-Id: I0c12a5ce37243695a839d0f976917da27d7fa989
Diffstat (limited to 'src/com/android/bluetooth/hdp/HealthService.java')
-rw-r--r-- | src/com/android/bluetooth/hdp/HealthService.java | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/com/android/bluetooth/hdp/HealthService.java b/src/com/android/bluetooth/hdp/HealthService.java index 21846c677..01e3f4121 100644 --- a/src/com/android/bluetooth/hdp/HealthService.java +++ b/src/com/android/bluetooth/hdp/HealthService.java @@ -189,7 +189,12 @@ public class HealthService extends ProfileService { { BluetoothHealthAppConfiguration appConfig = (BluetoothHealthAppConfiguration) msg.obj; - int appId = (mApps.get(appConfig)).mAppId; + AppInfo appInfo = mApps.get(appConfig); + if (appInfo == null) { + Log.e(TAG, "No AppInfo found for AppConfig: " + appConfig); + break; + } + int appId = appInfo.mAppId; if (!unregisterHealthAppNative(appId)) { Log.e(TAG, "Failed to unregister application: id: " + appId); callStatusCallback(appConfig, @@ -201,7 +206,12 @@ public class HealthService extends ProfileService { { HealthChannel chan = (HealthChannel) msg.obj; byte[] devAddr = Utils.getByteAddress(chan.mDevice); - int appId = (mApps.get(chan.mConfig)).mAppId; + AppInfo appInfo = mApps.get(chan.mConfig); + if (appInfo == null) { + Log.e(TAG, "No AppInfo found for AppConfig: " + chan.mConfig); + break; + } + int appId = appInfo.mAppId; chan.mChannelId = connectChannelNative(devAddr, appId); if (chan.mChannelId == -1) { callHealthChannelCallback(chan.mConfig, chan.mDevice, @@ -241,6 +251,10 @@ public class HealthService extends ProfileService { regStatus == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS) { //unlink to death once app is unregistered AppInfo appInfo = mApps.get(appConfig); + if (appInfo == null){ + Log.e(TAG, "No AppInfo found for AppConfig " + appConfig); + break; + } appInfo.cleanup(); mApps.remove(appConfig); } @@ -254,7 +268,7 @@ public class HealthService extends ProfileService { findAppConfigByAppId(channelStateEvent.mAppId); int newState; newState = convertHalChannelState(channelStateEvent.mState); - if (newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED && + if (newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED || appConfig == null) { Log.e(TAG,"Disconnected for non existing app"); break; @@ -512,9 +526,15 @@ public class HealthService extends ProfileService { private void callStatusCallback(BluetoothHealthAppConfiguration config, int status) { if (VDBG) log ("Health Device Application: " + config + " State Change: status:" + status); - IBluetoothHealthCallback callback = (mApps.get(config)).mCallback; + AppInfo appInfo = mApps.get(config); + if (appInfo == null) { + Log.e(TAG, " No AppInfo found for AppConfig " + config); + return; + } + IBluetoothHealthCallback callback = appInfo.mCallback; if (callback == null) { Log.e(TAG, "Callback object null"); + return; } try { @@ -604,8 +624,12 @@ public class HealthService extends ProfileService { Log.e(TAG, "Exception while duping: " + e); } } - - IBluetoothHealthCallback callback = (mApps.get(config)).mCallback; + AppInfo appInfo = mApps.get(config); + if (appInfo == null) { + Log.e(TAG, "No AppInfo found for AppConfig " + config); + return; + } + IBluetoothHealthCallback callback = appInfo.mCallback; if (callback == null) { Log.e(TAG, "No callback found for config: " + config); return; |