summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJason Monk <jmonk@google.com>2015-05-27 10:20:37 -0400
committerJason Monk <jmonk@google.com>2015-05-28 10:19:09 -0400
commita7d92b6fdec6b4f572144611b768022e6a654736 (patch)
tree7ef2995da8671bb8f3ea0dc3bc4f5bf6dea0cace /packages
parent373816ef1f7ab9954889ed02a6b2b39fe4aa4f44 (diff)
downloadframeworks_base-a7d92b6fdec6b4f572144611b768022e6a654736.zip
frameworks_base-a7d92b6fdec6b4f572144611b768022e6a654736.tar.gz
frameworks_base-a7d92b6fdec6b4f572144611b768022e6a654736.tar.bz2
Cache bluetooth connection state from callback
Bug: 21444506 Change-Id: Idebcc1974fdd7551645d10eea4e30d9e1133556b
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java29
3 files changed, 24 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
index ed954bb..abce31f 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
@@ -149,9 +149,10 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
private final BluetoothController.Callback mCallback = new BluetoothController.Callback() {
@Override
- public void onBluetoothStateChange(boolean enabled, boolean connecting) {
+ public void onBluetoothStateChange(boolean enabled) {
refreshState();
}
+
@Override
public void onBluetoothDevicesChanged() {
mUiHandler.post(new Runnable() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java
index cbe4c4d..8fa9c7e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java
@@ -35,7 +35,7 @@ public interface BluetoothController {
void disconnect(CachedBluetoothDevice device);
public interface Callback {
- void onBluetoothStateChange(boolean enabled, boolean connecting);
+ void onBluetoothStateChange(boolean enabled);
void onBluetoothDevicesChanged();
}
}
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 ed98a15..3cc9297 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java
@@ -41,7 +41,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
private final LocalBluetoothManager mLocalBluetoothManager;
private boolean mEnabled;
- private boolean mConnecting;
+ private int mConnectionState = BluetoothAdapter.STATE_DISCONNECTED;
private CachedBluetoothDevice mLastDevice;
private final H mHandler = new H();
@@ -63,7 +63,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
return;
}
pw.print(" mEnabled="); pw.println(mEnabled);
- pw.print(" mConnecting="); pw.println(mConnecting);
+ pw.print(" mConnectionState="); pw.println(stateToString(mConnectionState));
pw.print(" mLastDevice="); pw.println(mLastDevice);
pw.print(" mCallbacks.size="); pw.println(mCallbacks.size());
pw.println(" Bluetooth Devices:");
@@ -73,10 +73,25 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
}
}
+ private static String stateToString(int state) {
+ switch (state) {
+ case BluetoothAdapter.STATE_CONNECTED:
+ return "CONNECTED";
+ case BluetoothAdapter.STATE_CONNECTING:
+ return "CONNECTING";
+ case BluetoothAdapter.STATE_DISCONNECTED:
+ return "DISCONNECTED";
+ case BluetoothAdapter.STATE_DISCONNECTING:
+ return "DISCONNECTING";
+ }
+ return "UNKNOWN(" + state + ")";
+ }
+
private String getDeviceString(CachedBluetoothDevice device) {
return device.getName() + " " + device.getBondState() + " " + device.isConnected();
}
+ @Override
public void addStateChangedCallback(Callback cb) {
mCallbacks.add(cb);
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
@@ -94,14 +109,12 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
@Override
public boolean isBluetoothConnected() {
- return mLocalBluetoothManager != null
- && mLocalBluetoothManager.getBluetoothAdapter().getConnectionState()
- == BluetoothAdapter.STATE_CONNECTED;
+ return mConnectionState == BluetoothAdapter.STATE_CONNECTED;
}
@Override
public boolean isBluetoothConnecting() {
- return mConnecting;
+ return mConnectionState == BluetoothAdapter.STATE_CONNECTING;
}
@Override
@@ -190,7 +203,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
@Override
public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
- mConnecting = state == BluetoothAdapter.STATE_CONNECTING;
+ mConnectionState = state;
mLastDevice = cachedDevice;
updateConnected();
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
@@ -225,7 +238,7 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
}
private void fireStateChange(BluetoothController.Callback cb) {
- cb.onBluetoothStateChange(mEnabled, mConnecting);
+ cb.onBluetoothStateChange(mEnabled);
}
}
}