summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/statusbar
diff options
context:
space:
mode:
authorJason Monk <jmonk@google.com>2015-08-06 16:32:18 -0400
committerJason Monk <jmonk@google.com>2015-08-06 16:43:59 -0400
commit7036436014f6fcc6d586c77d93c21c9fb8b0ac51 (patch)
treee1f157881663f970ce22fa0cb82593bf9ec15ef3 /packages/SystemUI/src/com/android/systemui/statusbar
parentd5a6df6d228036258d616245502c1a4f85ba4b2e (diff)
downloadframeworks_base-7036436014f6fcc6d586c77d93c21c9fb8b0ac51.zip
frameworks_base-7036436014f6fcc6d586c77d93c21c9fb8b0ac51.tar.gz
frameworks_base-7036436014f6fcc6d586c77d93c21c9fb8b0ac51.tar.bz2
Use BluetoothController for status bar icon status
Bug: 22819904 Change-Id: I6ca11c57431f8e930a47144090158363175a3b99
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java40
2 files changed, 23 insertions, 19 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 86755d1..5c0c118 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -603,7 +603,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
// Lastly, call to the icon policy to install/update all the icons.
mIconPolicy = new PhoneStatusBarPolicy(mContext, mCastController, mHotspotController,
- mUserInfoController);
+ mUserInfoController, mBluetoothController);
mIconPolicy.setCurrentUserSetup(mUserSetup);
mSettingsObserver.onChange(false); // set up
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
index 53dae5c..540b9d0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -21,7 +21,6 @@ import android.app.AlarmManager;
import android.app.AlarmManager.AlarmClockInfo;
import android.app.IUserSwitchObserver;
import android.app.StatusBarManager;
-import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -41,6 +40,8 @@ import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.systemui.R;
import com.android.systemui.qs.tiles.DndTile;
+import com.android.systemui.statusbar.policy.BluetoothController;
+import com.android.systemui.statusbar.policy.BluetoothController.Callback;
import com.android.systemui.statusbar.policy.CastController;
import com.android.systemui.statusbar.policy.CastController.CastDevice;
import com.android.systemui.statusbar.policy.HotspotController;
@@ -51,7 +52,7 @@ import com.android.systemui.statusbar.policy.UserInfoController;
* bar at boot time. It goes through the normal API for icons, even though it probably
* strictly doesn't need to.
*/
-public class PhoneStatusBarPolicy {
+public class PhoneStatusBarPolicy implements Callback {
private static final String TAG = "PhoneStatusBarPolicy";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -82,12 +83,11 @@ public class PhoneStatusBarPolicy {
private int mZen;
- private boolean mBluetoothEnabled = false;
-
private boolean mManagedProfileFocused = false;
private boolean mManagedProfileIconVisible = true;
private boolean mKeyguardVisible = true;
+ private BluetoothController mBluetooth;
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
@@ -96,10 +96,6 @@ public class PhoneStatusBarPolicy {
if (action.equals(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)) {
updateAlarm();
}
- else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) ||
- action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
- updateBluetooth();
- }
else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) ||
action.equals(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION)) {
updateVolumeZen();
@@ -114,10 +110,12 @@ public class PhoneStatusBarPolicy {
};
public PhoneStatusBarPolicy(Context context, CastController cast, HotspotController hotspot,
- UserInfoController userInfoController) {
+ UserInfoController userInfoController, BluetoothController bluetooth) {
mContext = context;
mCast = cast;
mHotspot = hotspot;
+ mBluetooth = bluetooth;
+ mBluetooth.addStateChangedCallback(this);
mService = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE);
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
mUserInfoController = userInfoController;
@@ -127,8 +125,6 @@ public class PhoneStatusBarPolicy {
filter.addAction(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED);
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
filter.addAction(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION);
- filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
- filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED);
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
@@ -275,23 +271,31 @@ public class PhoneStatusBarPolicy {
updateAlarm();
}
+ @Override
+ public void onBluetoothDevicesChanged() {
+ updateBluetooth();
+ }
+
+ @Override
+ public void onBluetoothStateChange(boolean enabled) {
+ updateBluetooth();
+ }
+
private final void updateBluetooth() {
- BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
int iconId = R.drawable.stat_sys_data_bluetooth;
String contentDescription =
mContext.getString(R.string.accessibility_quick_settings_bluetooth_on);
- if (adapter != null) {
- mBluetoothEnabled = (adapter.getState() == BluetoothAdapter.STATE_ON);
- if (adapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED) {
+ boolean bluetoothEnabled = false;
+ if (mBluetooth != null) {
+ bluetoothEnabled = mBluetooth.isBluetoothEnabled();
+ if (mBluetooth.isBluetoothConnected()) {
iconId = R.drawable.stat_sys_data_bluetooth_connected;
contentDescription = mContext.getString(R.string.accessibility_bluetooth_connected);
}
- } else {
- mBluetoothEnabled = false;
}
mService.setIcon(SLOT_BLUETOOTH, iconId, 0, contentDescription);
- mService.setIconVisibility(SLOT_BLUETOOTH, mBluetoothEnabled);
+ mService.setIconVisibility(SLOT_BLUETOOTH, bluetoothEnabled);
}
private final void updateTTY(Intent intent) {