From bf796d87777e998cc284b8634e9cfdcd371e63f8 Mon Sep 17 00:00:00 2001 From: Ajay Panicker Date: Fri, 11 Mar 2016 13:47:20 -0800 Subject: [PATCH] Get adapter name and address on boot Bug: 25836009 Change-Id: I6fe68b116fcd736cd5736be68c97af3052351b33 --- .../android/server/BluetoothManagerService.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index e241a4aa99263..799a763845d24 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -761,6 +761,11 @@ class BluetoothManagerService extends IBluetoothManager.Stub { if (mEnableExternal && isBluetoothPersistedStateOnBluetooth()) { if (DBG) Slog.d(TAG, "Auto-enabling Bluetooth."); sendEnableMsg(mQuietEnableExternal); + } else if (!isNameAndAddressSet()) { + if (DBG) Slog.d(TAG, "Getting adapter name and address"); + enable(); + waitForOnOff(true, false); + disable(true); } } @@ -1001,6 +1006,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { } } } + // mAddress is accessed from outside. // It is alright without a lock. Here, bluetooth is off, no other thread is // changing mAddress @@ -1181,6 +1187,15 @@ class BluetoothManagerService extends IBluetoothManager.Stub { Slog.e(TAG,"Unable to call configHciSnoopLog", e); } + if (!isNameAndAddressSet()) { + try { + storeNameAndAddress(mBluetooth.getName(), + mBluetooth.getAddress()); + } catch (RemoteException re) { + Slog.e(TAG, "Unable to grab names", re); + } + } + //Register callback object try { mBluetooth.registerCallback(mBluetoothCallback);