Add a "show touches" option for demos and presentations.
Bug: 4569045
Change-Id: I8726ea292dd7def790a5e40d7d7e58968974f896
diff --git a/services/java/com/android/server/wm/InputManager.java b/services/java/com/android/server/wm/InputManager.java
index c8b18c8..60333a3 100644
--- a/services/java/com/android/server/wm/InputManager.java
+++ b/services/java/com/android/server/wm/InputManager.java
@@ -94,6 +94,7 @@
private static native boolean nativeTransferTouchFocus(InputChannel fromChannel,
InputChannel toChannel);
private static native void nativeSetPointerSpeed(int speed);
+ private static native void nativeSetShowTouches(boolean enabled);
private static native String nativeDump();
private static native void nativeMonitor();
@@ -147,7 +148,10 @@
nativeStart();
registerPointerSpeedSettingObserver();
+ registerShowTouchesSettingObserver();
+
updatePointerSpeedFromSettings();
+ updateShowTouchesFromSettings();
}
public void setDisplaySize(int displayId, int width, int height,
@@ -454,6 +458,32 @@
return speed;
}
+ public void updateShowTouchesFromSettings() {
+ int setting = getShowTouchesSetting(0);
+ nativeSetShowTouches(setting != 0);
+ }
+
+ private void registerShowTouchesSettingObserver() {
+ mContext.getContentResolver().registerContentObserver(
+ Settings.System.getUriFor(Settings.System.SHOW_TOUCHES), true,
+ new ContentObserver(mWindowManagerService.mH) {
+ @Override
+ public void onChange(boolean selfChange) {
+ updateShowTouchesFromSettings();
+ }
+ });
+ }
+
+ private int getShowTouchesSetting(int defaultValue) {
+ int result = defaultValue;
+ try {
+ result = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.SHOW_TOUCHES);
+ } catch (SettingNotFoundException snfe) {
+ }
+ return result;
+ }
+
public void dump(PrintWriter pw) {
String dumpStr = nativeDump();
if (dumpStr != null) {