summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorNitin Arora <niarora@codeaurora.org>2015-04-29 12:35:03 -0700
committerAndre Eisenbach <eisenbach@google.com>2015-05-06 22:24:23 -0700
commitbdfaa7f566a0fbe59dfc6bc14cd9d4d92b9259fa (patch)
tree4ef090909c68cc7eae82e295c2605eaa421756b6 /services
parent9132c5ab0746f56909ed5630a6e93c9fadefabd0 (diff)
downloadframeworks_base-bdfaa7f566a0fbe59dfc6bc14cd9d4d92b9259fa.zip
frameworks_base-bdfaa7f566a0fbe59dfc6bc14cd9d4d92b9259fa.tar.gz
frameworks_base-bdfaa7f566a0fbe59dfc6bc14cd9d4d92b9259fa.tar.bz2
Bluetooth: Ensure Bluetooth interface handle is valid
This change adds null checks to Bluetooth interface handle to prevent using null references when BluetoothService is not up. Also removed the callbacks for the intermediate state removed for now as they are not being used. Change-Id: I0e72ff4da467a8bcf5a4e5ac48d8558e7f308c7e
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/BluetoothManagerService.java29
1 files changed, 12 insertions, 17 deletions
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java
index 1019faa..32b91d2 100644
--- a/services/core/java/com/android/server/BluetoothManagerService.java
+++ b/services/core/java/com/android/server/BluetoothManagerService.java
@@ -512,7 +512,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
private void onBluetoothGattServiceUp() {
if (DBG) Log.d(TAG,"BluetoothGatt Service is Up");
try{
- if (isBleAppPresent() == false && mBluetooth.getState() == BluetoothAdapter.STATE_BLE_ON) {
+ if (isBleAppPresent() == false && mBluetooth != null
+ && mBluetooth.getState() == BluetoothAdapter.STATE_BLE_ON) {
mBluetooth.onLeServiceUp();
// waive WRITE_SECURE_SETTINGS permission check
@@ -531,32 +532,26 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
*/
private void sendBrEdrDownCallback() {
if (DBG) Log.d(TAG,"Calling sendBrEdrDownCallback callbacks");
- int n = mCallbacks.beginBroadcast();
+
+ if(mBluetooth == null) {
+ Log.w(TAG, "Bluetooth handle is null");
+ return;
+ }
if (isBleAppPresent() == false) {
try {
mBluetooth.onBrEdrDown();
} catch(RemoteException e) {
- Log.e(TAG,"Unable to call onBrEdrDown", e);
+ Log.e(TAG, "Call to onBrEdrDown() failed.", e);
}
- }
- else{//need to stay at BLE ON. disconnect all Gatt connections
+ } else {
+ // Need to stay at BLE ON. Disconnect all Gatt connections
try{
- mBluetoothGatt.unregAll();//disconnectAll();
+ mBluetoothGatt.unregAll();
} catch(RemoteException e) {
- Log.e(TAG,"Unable to disconn all", e);
- }
- }
-
- Log.d(TAG,"Broadcasting onBrEdrDown() to " + n + " receivers.");
- for (int i=0; i <n; i++) {
- try {
- mCallbacks.getBroadcastItem(i).onBrEdrDown();
- } catch (RemoteException e) {
- Log.e(TAG, "Unable to call sendBrEdrDownCallback() on callback #" + i, e);
+ Log.e(TAG, "Unable to disconnect all apps.", e);
}
}
- mCallbacks.finishBroadcast();
}
/** @hide*/