Fixed issue with getting Bluetooth adapter's name and airplane mode
Change-Id: I18b632223574aa41b09ba30de8e35417fad86cbe
diff --git a/services/java/com/android/server/BluetoothManagerService.java b/services/java/com/android/server/BluetoothManagerService.java
index c2fb685..56487fe 100644
--- a/services/java/com/android/server/BluetoothManagerService.java
+++ b/services/java/com/android/server/BluetoothManagerService.java
@@ -124,6 +124,7 @@
mCallbacks = new ArrayList<IBluetoothManagerCallback>();
mStateChangeCallbacks = new ArrayList<IBluetoothStateChangeCallback>();
IntentFilter mFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
+ mFilter.addAction(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED);
registerForAirplaneMode(mFilter);
mContext.registerReceiver(mReceiver, mFilter);
boolean airplaneModeOn = isAirplaneModeOn();
@@ -294,6 +295,7 @@
}
if (!isConnected()) mBinding = true;
}
+
Message msg = mHandler.obtainMessage(MESSAGE_ENABLE);
msg.arg1=1; //persist
mHandler.sendMessage(msg);
@@ -342,12 +344,30 @@
public String getAddress() {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH ADMIN permission");
+ synchronized(mConnection) {
+ if (mBluetooth != null) {
+ try {
+ return mBluetooth.getAddress();
+ } catch (RemoteException e) {
+ Log.e(TAG, "getAddress(): Unable to retrieve address remotely..Returning cached address",e);
+ }
+ }
+ }
return mAddress;
}
public String getName() {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH ADMIN permission");
+ synchronized(mConnection) {
+ if (mBluetooth != null) {
+ try {
+ return mBluetooth.getName();
+ } catch (RemoteException e) {
+ Log.e(TAG, "getName(): Unable to retrieve name remotely..Returning cached name",e);
+ }
+ }
+ }
return mName;
}