Update status bar icon policy for volume + zen.
Only show vibrate in the volume slot, create a separate slot
for zen.
Bug:15831713
Change-Id: I9d23a2d370bc6f98be3bdc98c2990bbea6643ce7
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 186b618..fa8e1a6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -39,20 +39,18 @@
*/
public class PhoneStatusBarPolicy {
private static final String TAG = "PhoneStatusBarPolicy";
-
- // message codes for the handler
- private static final int EVENT_BATTERY_CLOSE = 4;
-
- private static final int AM_PM_STYLE_NORMAL = 0;
- private static final int AM_PM_STYLE_SMALL = 1;
- private static final int AM_PM_STYLE_GONE = 2;
-
- private static final int AM_PM_STYLE = AM_PM_STYLE_GONE;
-
- private static final int INET_CONDITION_THRESHOLD = 50;
+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static final boolean SHOW_SYNC_ICON = false;
+ private static final String SLOT_SYNC_ACTIVE = "sync_active";
+ private static final String SLOT_BLUETOOTH = "bluetooth";
+ private static final String SLOT_TTY = "tty";
+ private static final String SLOT_ZEN = "zen";
+ private static final String SLOT_VOLUME = "volume";
+ private static final String SLOT_CDMA_ERI = "cdma_eri";
+ private static final String SLOT_ALARM_CLOCK = "alarm_clock";
+
private final Context mContext;
private final StatusBarManager mService;
private final Handler mHandler = new Handler();
@@ -61,24 +59,13 @@
// to get broadcasts that it *is* there.
IccCardConstants.State mSimState = IccCardConstants.State.READY;
- // ringer volume
+ private boolean mZenVisible;
private boolean mVolumeVisible;
- // zen mode
private int mZen;
- // bluetooth device status
private boolean mBluetoothEnabled = false;
- private int mLastWifiSignalLevel = -1;
- private boolean mIsWifiConnected = false;
-
- // state of inet connection - 0 not connected, 100 connected
- private int mInetCondition = 0;
-
- // sync state
- // If sync is active the SyncActive icon is displayed. If sync is not active but
- // sync is failing the SyncFailing icon is displayed. Otherwise neither are displayed.
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
@@ -95,7 +82,7 @@
updateBluetooth(intent);
}
else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
- updateVolume();
+ updateVolumeZen();
}
else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
updateSimState(intent);
@@ -122,12 +109,12 @@
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
// TTY status
- mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0, null);
- mService.setIconVisibility("tty", false);
+ mService.setIcon(SLOT_TTY, R.drawable.stat_sys_tty_mode, 0, null);
+ mService.setIconVisibility(SLOT_TTY, false);
// Cdma Roaming Indicator, ERI
- mService.setIcon("cdma_eri", R.drawable.stat_sys_roaming_cdma_0, 0, null);
- mService.setIconVisibility("cdma_eri", false);
+ mService.setIcon(SLOT_CDMA_ERI, R.drawable.stat_sys_roaming_cdma_0, 0, null);
+ mService.setIconVisibility(SLOT_CDMA_ERI, false);
// bluetooth status
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
@@ -138,38 +125,42 @@
bluetoothIcon = R.drawable.stat_sys_data_bluetooth_connected;
}
}
- mService.setIcon("bluetooth", bluetoothIcon, 0, null);
- mService.setIconVisibility("bluetooth", mBluetoothEnabled);
+ mService.setIcon(SLOT_BLUETOOTH, bluetoothIcon, 0, null);
+ mService.setIconVisibility(SLOT_BLUETOOTH, mBluetoothEnabled);
// Alarm clock
- mService.setIcon("alarm_clock", R.drawable.stat_sys_alarm, 0, null);
- mService.setIconVisibility("alarm_clock", false);
+ mService.setIcon(SLOT_ALARM_CLOCK, R.drawable.stat_sys_alarm, 0, null);
+ mService.setIconVisibility(SLOT_ALARM_CLOCK, false);
// Sync state
- mService.setIcon("sync_active", R.drawable.stat_sys_sync, 0, null);
- mService.setIconVisibility("sync_active", false);
+ mService.setIcon(SLOT_SYNC_ACTIVE, R.drawable.stat_sys_sync, 0, null);
+ mService.setIconVisibility(SLOT_SYNC_ACTIVE, false);
// "sync_failing" is obsolete: b/1297963
+ // zen
+ mService.setIcon(SLOT_ZEN, R.drawable.stat_sys_zen_important, 0, null);
+ mService.setIconVisibility(SLOT_ZEN, false);
+
// volume
- mService.setIcon("volume", R.drawable.stat_sys_ringer_silent, 0, null);
- mService.setIconVisibility("volume", false);
- updateVolume();
+ mService.setIcon(SLOT_VOLUME, R.drawable.stat_sys_ringer_silent, 0, null);
+ mService.setIconVisibility(SLOT_VOLUME, false);
+ updateVolumeZen();
}
public void setZenMode(int zen) {
mZen = zen;
- updateVolume();
+ updateVolumeZen();
}
private final void updateAlarm(Intent intent) {
boolean alarmSet = intent.getBooleanExtra("alarmSet", false);
- mService.setIconVisibility("alarm_clock", alarmSet);
+ mService.setIconVisibility(SLOT_ALARM_CLOCK, alarmSet);
}
private final void updateSyncState(Intent intent) {
if (!SHOW_SYNC_ICON) return;
boolean isActive = intent.getBooleanExtra("active", false);
- mService.setIconVisibility("sync_active", isActive);
+ mService.setIconVisibility(SLOT_SYNC_ACTIVE, isActive);
}
private final void updateSimState(Intent intent) {
@@ -200,32 +191,48 @@
}
}
- private final void updateVolume() {
+ private final void updateVolumeZen() {
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
- final int ringerMode = audioManager.getRingerMode();
- int iconId = 0;
- String contentDescription = null;
- boolean visible = false;
- if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
- visible = true;
- iconId = R.drawable.stat_sys_ringer_silent;
- contentDescription = mContext.getString(R.string.accessibility_ringer_silent);
+
+ boolean zenVisible = false;
+ int zenIconId = 0;
+ String zenDescription = null;
+
+ boolean volumeVisible = false;
+ int volumeIconId = 0;
+ String volumeDescription = null;
+
+ if (mZen == Global.ZEN_MODE_NO_INTERRUPTIONS) {
+ zenVisible = true;
+ zenIconId = R.drawable.stat_sys_zen_none;
+ zenDescription = mContext.getString(R.string.zen_no_interruptions);
} else if (mZen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) {
- visible = true;
- iconId = R.drawable.stat_sys_zen_important;
- contentDescription = mContext.getString(R.string.zen_important_interruptions);
- } else if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
- visible = true;
- iconId = R.drawable.stat_sys_ringer_vibrate;
- contentDescription = mContext.getString(R.string.accessibility_ringer_vibrate);
+ zenVisible = true;
+ zenIconId = R.drawable.stat_sys_zen_important;
+ zenDescription = mContext.getString(R.string.zen_important_interruptions);
}
- if (visible) {
- mService.setIcon("volume", iconId, 0, contentDescription);
+ if (mZen != Global.ZEN_MODE_NO_INTERRUPTIONS &&
+ audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) {
+ volumeVisible = true;
+ volumeIconId = R.drawable.stat_sys_ringer_vibrate;
+ volumeDescription = mContext.getString(R.string.accessibility_ringer_vibrate);
}
- if (visible != mVolumeVisible) {
- mService.setIconVisibility("volume", visible);
- mVolumeVisible = visible;
+
+ if (zenVisible) {
+ mService.setIcon(SLOT_ZEN, zenIconId, 0, zenDescription);
+ }
+ if (zenVisible != mZenVisible) {
+ mService.setIconVisibility(SLOT_ZEN, zenVisible);
+ mZenVisible = zenVisible;
+ }
+
+ if (volumeVisible) {
+ mService.setIcon(SLOT_VOLUME, volumeIconId, 0, volumeDescription);
+ }
+ if (volumeVisible != mVolumeVisible) {
+ mService.setIconVisibility(SLOT_VOLUME, volumeVisible);
+ mVolumeVisible = volumeVisible;
}
}
@@ -250,26 +257,25 @@
return;
}
- mService.setIcon("bluetooth", iconId, 0, contentDescription);
- mService.setIconVisibility("bluetooth", mBluetoothEnabled);
+ mService.setIcon(SLOT_BLUETOOTH, iconId, 0, contentDescription);
+ mService.setIconVisibility(SLOT_BLUETOOTH, mBluetoothEnabled);
}
private final void updateTTY(Intent intent) {
- final String action = intent.getAction();
final boolean enabled = intent.getBooleanExtra(TtyIntent.TTY_ENABLED, false);
- if (false) Log.v(TAG, "updateTTY: enabled: " + enabled);
+ if (DEBUG) Log.v(TAG, "updateTTY: enabled: " + enabled);
if (enabled) {
// TTY is on
- if (false) Log.v(TAG, "updateTTY: set TTY on");
- mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0,
+ if (DEBUG) Log.v(TAG, "updateTTY: set TTY on");
+ mService.setIcon(SLOT_TTY, R.drawable.stat_sys_tty_mode, 0,
mContext.getString(R.string.accessibility_tty_enabled));
- mService.setIconVisibility("tty", true);
+ mService.setIconVisibility(SLOT_TTY, true);
} else {
// TTY is off
- if (false) Log.v(TAG, "updateTTY: set TTY off");
- mService.setIconVisibility("tty", false);
+ if (DEBUG) Log.v(TAG, "updateTTY: set TTY off");
+ mService.setIconVisibility(SLOT_TTY, false);
}
}
}