Add contentDescription to status bar alarm
Test: turn on talkback; tap alarm; listen
Bug: 66964503
Change-Id: If416e7f96de0873dd6e920c7dcf6f23f88ce2204
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 420c517..f4ebff2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -52,6 +52,7 @@
import android.service.notification.StatusBarNotification;
import android.service.notification.ZenModeConfig;
import android.telecom.TelecomManager;
+import android.text.format.DateFormat;
import android.util.ArraySet;
import android.util.Log;
import android.util.Pair;
@@ -89,6 +90,7 @@
import com.android.systemui.util.NotificationChannels;
import java.util.List;
+import java.util.Locale;
/**
* This class contains all of the policy about which icons are installed in the status
@@ -121,7 +123,7 @@
private final Handler mHandler = new Handler();
private final CastController mCast;
private final HotspotController mHotspot;
- private final NextAlarmController mNextAlarm;
+ private final NextAlarmController mNextAlarmController;
private final AlarmManager mAlarmManager;
private final UserInfoController mUserInfoController;
private final UserManager mUserManager;
@@ -147,6 +149,7 @@
private boolean mManagedProfileIconVisible = false;
private BluetoothController mBluetooth;
+ private AlarmManager.AlarmClockInfo mNextAlarm;
public PhoneStatusBarPolicy(Context context, StatusBarIconController iconController) {
mContext = context;
@@ -154,7 +157,7 @@
mCast = Dependency.get(CastController.class);
mHotspot = Dependency.get(HotspotController.class);
mBluetooth = Dependency.get(BluetoothController.class);
- mNextAlarm = Dependency.get(NextAlarmController.class);
+ mNextAlarmController = Dependency.get(NextAlarmController.class);
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
mUserInfoController = Dependency.get(UserInfoController.class);
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
@@ -242,7 +245,7 @@
mZenController.addCallback(this);
mCast.addCallback(mCastCallback);
mHotspot.addCallback(mHotspotCallback);
- mNextAlarm.addCallback(mNextAlarmCallback);
+ mNextAlarmController.addCallback(mNextAlarmCallback);
mDataSaver.addCallback(this);
mKeyguardMonitor.addCallback(this);
mLocationController.addCallback(this);
@@ -270,7 +273,7 @@
mZenController.removeCallback(this);
mCast.removeCallback(mCastCallback);
mHotspot.removeCallback(mHotspotCallback);
- mNextAlarm.removeCallback(mNextAlarmCallback);
+ mNextAlarmController.removeCallback(mNextAlarmCallback);
mDataSaver.removeCallback(this);
mKeyguardMonitor.removeCallback(this);
mLocationController.removeCallback(this);
@@ -313,10 +316,29 @@
int zen = mZenController.getZen();
final boolean zenNone = zen == Global.ZEN_MODE_NO_INTERRUPTIONS;
mIconController.setIcon(mSlotAlarmClock, zenNone ? R.drawable.stat_sys_alarm_dim
- : R.drawable.stat_sys_alarm, null);
+ : R.drawable.stat_sys_alarm, buildAlarmContentDescription());
mIconController.setIconVisibility(mSlotAlarmClock, mCurrentUserSetup && hasAlarm);
}
+ private String buildAlarmContentDescription() {
+ if (mNextAlarm == null) {
+ return mContext.getString(R.string.status_bar_alarm);
+ }
+ return formatNextAlarm(mNextAlarm, mContext);
+ }
+
+ private static String formatNextAlarm(AlarmManager.AlarmClockInfo info, Context context) {
+ if (info == null) {
+ return "";
+ }
+ String skeleton = DateFormat.is24HourFormat(
+ context, ActivityManager.getCurrentUser()) ? "EHm" : "Ehma";
+ String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
+ String dateString = DateFormat.format(pattern, info.getTriggerTime()).toString();
+
+ return context.getString(R.string.accessibility_quick_settings_alarm, dateString);
+ }
+
private final void updateSimState(Intent intent) {
String stateExtra = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE);
if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) {
@@ -688,6 +710,7 @@
new NextAlarmController.NextAlarmChangeCallback() {
@Override
public void onNextAlarmChanged(AlarmManager.AlarmClockInfo nextAlarm) {
+ mNextAlarm = nextAlarm;
updateAlarm();
}
};