From 909705601e94ffb4f4bfa4b48fa9e50f8302636a Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Fri, 19 Jun 2015 10:04:49 -0400 Subject: [PATCH] Try to keep connection state more up to date It seems that connection state isn't always correct, make sure we update it every time a device changes state, so that we don't stay connected while no device is connected. Bug: 21896051 Change-Id: I5aa398f33a916609742e22ce5affd4211ed0a626 --- .../statusbar/policy/BluetoothControllerImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java index 3cc92978d3935..daa84ad80ccf5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java @@ -154,6 +154,12 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa } private void updateConnected() { + // Make sure our connection state is up to date. + int state = mLocalBluetoothManager.getBluetoothAdapter().getConnectionState(); + if (state != mConnectionState) { + mConnectionState = state; + mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED); + } if (mLastDevice != null && mLastDevice.isConnected()) { // Our current device is still valid. return; @@ -203,9 +209,9 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa @Override public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) { - mConnectionState = state; mLastDevice = cachedDevice; updateConnected(); + mConnectionState = state; mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED); }