SystemUI demo mode.
Control the status bar visuals via a simple intent protocol.
Useful for comprehensive visual testing reachable assets
and the various bar modes.
Protected behind a global system setting. To enable:
adb shell settings put global sysui_demo_allowed 1
Remove obsolete sync failing asset, and tighten up
BluetoothController to represent reality.
Bug:10502089
Change-Id: I28443af3d6b22fcb7b367ef70e1d95fc23ebd407
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
index 93fb14f..8ced1c9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.format.DateFormat;
@@ -28,6 +29,8 @@
import android.util.AttributeSet;
import android.widget.TextView;
+import com.android.systemui.DemoMode;
+
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
@@ -38,7 +41,7 @@
/**
* Digital clock for the status bar.
*/
-public class Clock extends TextView {
+public class Clock extends TextView implements DemoMode {
private boolean mAttached;
private Calendar mCalendar;
private String mClockFormatString;
@@ -121,6 +124,7 @@
};
final void updateClock() {
+ if (mDemoMode) return;
mCalendar.setTimeInMillis(System.currentTimeMillis());
setText(getSmallTime());
}
@@ -196,5 +200,29 @@
return result;
}
+
+ private boolean mDemoMode;
+
+ @Override
+ public void dispatchDemoCommand(String command, Bundle args) {
+ if (!mDemoMode && command.equals(COMMAND_ENTER)) {
+ mDemoMode = true;
+ } else if (mDemoMode && command.equals(COMMAND_EXIT)) {
+ mDemoMode = false;
+ updateClock();
+ } else if (mDemoMode && command.equals(COMMAND_CLOCK)) {
+ String millis = args.getString("millis");
+ String hhmm = args.getString("hhmm");
+ if (millis != null) {
+ mCalendar.setTimeInMillis(Long.parseLong(millis));
+ } else if (hhmm != null && hhmm.length() == 4) {
+ int hh = Integer.parseInt(hhmm.substring(0, 2));
+ int mm = Integer.parseInt(hhmm.substring(2));
+ mCalendar.set(Calendar.HOUR, hh);
+ mCalendar.set(Calendar.MINUTE, mm);
+ }
+ setText(getSmallTime());
+ }
+ }
}