summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhihai Xu <zhihaixu@google.com>2012-11-29 12:45:09 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2012-11-29 12:45:09 -0800
commitaaa453dbbdd9307ddc8fbd32e7f3c1e673e02b83 (patch)
treee7cf7d652a10549c7cb25ef95717bc9d2a4d93f2
parent878da6532836ec09f6d27e8f5af79444c79e78b6 (diff)
parent2c7dac19dd2cab68587cd129b45ad593f7bfdc44 (diff)
downloadframeworks_base-aaa453dbbdd9307ddc8fbd32e7f3c1e673e02b83.zip
frameworks_base-aaa453dbbdd9307ddc8fbd32e7f3c1e673e02b83.tar.gz
frameworks_base-aaa453dbbdd9307ddc8fbd32e7f3c1e673e02b83.tar.bz2
am 2c7dac19: am e3f7c452: Merge "Settings shows it is connected to A2DP, though the device is not actually connected" into jb-mr1.1-dev
* commit '2c7dac19dd2cab68587cd129b45ad593f7bfdc44': Settings shows it is connected to A2DP, though the device is not actually connected
-rwxr-xr-xservices/java/com/android/server/BluetoothManagerService.java37
1 files changed, 31 insertions, 6 deletions
diff --git a/services/java/com/android/server/BluetoothManagerService.java b/services/java/com/android/server/BluetoothManagerService.java
index 851c03c..ea91875 100755
--- a/services/java/com/android/server/BluetoothManagerService.java
+++ b/services/java/com/android/server/BluetoothManagerService.java
@@ -775,8 +775,18 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
// Send BT state broadcast to update
// the BT icon correctly
- bluetoothStateChangeHandler(BluetoothAdapter.STATE_ON,
- BluetoothAdapter.STATE_TURNING_OFF);
+ if ((mState == BluetoothAdapter.STATE_TURNING_ON) ||
+ (mState == BluetoothAdapter.STATE_ON)) {
+ bluetoothStateChangeHandler(BluetoothAdapter.STATE_ON,
+ BluetoothAdapter.STATE_TURNING_OFF);
+ mState = BluetoothAdapter.STATE_TURNING_OFF;
+ }
+ if (mState == BluetoothAdapter.STATE_TURNING_OFF) {
+ bluetoothStateChangeHandler(BluetoothAdapter.STATE_TURNING_OFF,
+ BluetoothAdapter.STATE_OFF);
+ }
+
+ mHandler.removeMessages(MESSAGE_BLUETOOTH_STATE_CHANGE);
mState = BluetoothAdapter.STATE_OFF;
}
break;
@@ -820,20 +830,33 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
}
}
}
- mHandler.removeMessages(MESSAGE_BLUETOOTH_STATE_CHANGE);
+
+ if (mState == BluetoothAdapter.STATE_TURNING_OFF) {
+ // MESSAGE_USER_SWITCHED happened right after MESSAGE_ENABLE
+ bluetoothStateChangeHandler(mState, BluetoothAdapter.STATE_OFF);
+ mState = BluetoothAdapter.STATE_OFF;
+ }
+ if (mState == BluetoothAdapter.STATE_OFF) {
+ bluetoothStateChangeHandler(mState, BluetoothAdapter.STATE_TURNING_ON);
+ mState = BluetoothAdapter.STATE_TURNING_ON;
+ }
waitForOnOff(true, false);
- bluetoothStateChangeHandler(mState, BluetoothAdapter.STATE_ON);
+ if (mState == BluetoothAdapter.STATE_TURNING_ON) {
+ bluetoothStateChangeHandler(mState, BluetoothAdapter.STATE_ON);
+ }
// disable
handleDisable(false);
+ // Pbap service need receive STATE_TURNING_OFF intent to close
+ bluetoothStateChangeHandler(BluetoothAdapter.STATE_ON,
+ BluetoothAdapter.STATE_TURNING_OFF);
waitForOnOff(false, true);
- bluetoothStateChangeHandler(BluetoothAdapter.STATE_ON,
+ bluetoothStateChangeHandler(BluetoothAdapter.STATE_TURNING_OFF,
BluetoothAdapter.STATE_OFF);
- mState = BluetoothAdapter.STATE_OFF;
sendBluetoothServiceDownCallback();
synchronized (mConnection) {
if (mBluetooth != null) {
@@ -844,6 +867,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
}
SystemClock.sleep(100);
+ mHandler.removeMessages(MESSAGE_BLUETOOTH_STATE_CHANGE);
+ mState = BluetoothAdapter.STATE_OFF;
// enable
handleEnable(false, mQuietEnable);
} else if (mBinding || mBluetooth != null) {