Fetch the Bluetooth name and address without enabling the whole stack
After factory reset and first bootup, fetching the Bluetooth device name and address is now done without explicitly enabling/disabling the whole Bluetooth stack. Apparently, enabling/disabling the whole stack during th first bootup was somehow holding the kernel wakelock without releasing it. Also, disable debug log messages for class BluetoothManagerService. Bug: 21949364 Change-Id: Iffc14f7969d05c1456159d1f4246c53fb5df0f7a
This commit is contained in:
@@ -61,7 +61,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
class BluetoothManagerService extends IBluetoothManager.Stub {
|
class BluetoothManagerService extends IBluetoothManager.Stub {
|
||||||
private static final String TAG = "BluetoothManagerService";
|
private static final String TAG = "BluetoothManagerService";
|
||||||
private static final boolean DBG = true;
|
private static final boolean DBG = false;
|
||||||
|
|
||||||
private static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN;
|
private static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN;
|
||||||
private static final String BLUETOOTH_PERM = android.Manifest.permission.BLUETOOTH;
|
private static final String BLUETOOTH_PERM = android.Manifest.permission.BLUETOOTH;
|
||||||
@@ -227,21 +227,23 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Intent.ACTION_USER_SWITCHED.equals(action)) {
|
} else if (Intent.ACTION_USER_SWITCHED.equals(action)) {
|
||||||
|
if (DBG) Log.d(TAG, "Bluetooth user switched");
|
||||||
mHandler.sendMessage(mHandler.obtainMessage(MESSAGE_USER_SWITCHED,
|
mHandler.sendMessage(mHandler.obtainMessage(MESSAGE_USER_SWITCHED,
|
||||||
intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0), 0));
|
intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0), 0));
|
||||||
} else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
|
} else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
|
||||||
|
if (DBG) Log.d(TAG, "Bluetooth boot completed");
|
||||||
synchronized(mReceiver) {
|
synchronized(mReceiver) {
|
||||||
if (mEnableExternal && isBluetoothPersistedStateOnBluetooth()) {
|
if (mEnableExternal && isBluetoothPersistedStateOnBluetooth()) {
|
||||||
//Enable
|
//Enable
|
||||||
if (DBG) Log.d(TAG, "Auto-enabling Bluetooth.");
|
if (DBG) Log.d(TAG, "Auto-enabling Bluetooth.");
|
||||||
sendEnableMsg(mQuietEnableExternal);
|
sendEnableMsg(mQuietEnableExternal);
|
||||||
}
|
}
|
||||||
}
|
if (!isNameAndAddressSet()) {
|
||||||
|
// Sync the Bluetooth name and address from the
|
||||||
if (!isNameAndAddressSet()) {
|
// Bluetooth Adapter
|
||||||
// Sync the Bluetooth name and address from the Bluetooth Adapter
|
if (DBG) Log.d(TAG, "Retrieving Bluetooth Adapter name and address...");
|
||||||
if (DBG) Log.d(TAG,"Retrieving Bluetooth Adapter name and address...");
|
getNameAndAddress();
|
||||||
getNameAndAddress();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1099,7 +1101,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
boolean unbind = false;
|
boolean unbind = false;
|
||||||
if (DBG) Log.d(TAG,"MESSAGE_SAVE_NAME_AND_ADDRESS");
|
if (DBG) Log.d(TAG,"MESSAGE_SAVE_NAME_AND_ADDRESS");
|
||||||
synchronized(mConnection) {
|
synchronized(mConnection) {
|
||||||
if (!mEnable && mBluetooth != null) {
|
if (!mEnable && mBluetooth != null && !mConnection.isGetNameAddressOnly()) {
|
||||||
try {
|
try {
|
||||||
mBluetooth.enable();
|
mBluetooth.enable();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -1107,7 +1109,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mBluetooth != null) waitForOnOff(true, false);
|
if (mBluetooth != null && !mConnection.isGetNameAddressOnly()) waitForOnOff(true, false);
|
||||||
synchronized(mConnection) {
|
synchronized(mConnection) {
|
||||||
if (mBluetooth != null) {
|
if (mBluetooth != null) {
|
||||||
String name = null;
|
String name = null;
|
||||||
@@ -1137,7 +1139,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mEnable) {
|
if (!mEnable && !mConnection.isGetNameAddressOnly()) {
|
||||||
try {
|
try {
|
||||||
mBluetooth.disable();
|
mBluetooth.disable();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -1152,7 +1154,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
mHandler.sendMessage(getMsg);
|
mHandler.sendMessage(getMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mEnable && mBluetooth != null) waitForOnOff(false, true);
|
if (!mEnable && mBluetooth != null && !mConnection.isGetNameAddressOnly()) {
|
||||||
|
waitForOnOff(false, true);
|
||||||
|
}
|
||||||
if (unbind) {
|
if (unbind) {
|
||||||
unbindAndFinish();
|
unbindAndFinish();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user