From a3341ae060694effccb7febf3672fe315216a19b Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Thu, 9 May 2019 17:41:01 -0700 Subject: [PATCH] PointerLocation: move showing exclusion rects behind flag Fixes: 131810593 Test: Enable "show pointer location" in developer setting, verify no pink overlays Change-Id: I258466af07edfc5bc7f36b348564a81fed2cb2b4 --- .../internal/widget/PointerLocationView.java | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/core/java/com/android/internal/widget/PointerLocationView.java b/core/java/com/android/internal/widget/PointerLocationView.java index 3881093f55402..9084f625f9cb0 100644 --- a/core/java/com/android/internal/widget/PointerLocationView.java +++ b/core/java/com/android/internal/widget/PointerLocationView.java @@ -26,6 +26,7 @@ import android.graphics.RectF; import android.graphics.Region; import android.hardware.input.InputManager; import android.hardware.input.InputManager.InputDeviceListener; +import android.os.Handler; import android.os.RemoteException; import android.os.SystemProperties; import android.util.Log; @@ -745,11 +746,16 @@ public class PointerLocationView extends View implements InputDeviceListener, super.onAttachedToWindow(); mIm.registerInputDeviceListener(this, getHandler()); - try { - WindowManagerGlobal.getWindowManagerService().registerSystemGestureExclusionListener( - mSystemGestureExclusionListener, mContext.getDisplayId()); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); + if (shouldShowSystemGestureExclusion()) { + try { + WindowManagerGlobal.getWindowManagerService() + .registerSystemGestureExclusionListener(mSystemGestureExclusionListener, + mContext.getDisplayId()); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } else { + mSystemGestureExclusion.setEmpty(); } logInputDevices(); } @@ -798,6 +804,10 @@ public class PointerLocationView extends View implements InputDeviceListener, } } + private static boolean shouldShowSystemGestureExclusion() { + return SystemProperties.getBoolean("debug.pointerlocation.showexclusion", false); + } + // HACK // A quick and dirty string builder implementation optimized for GC. // Using String.format causes the application grind to a halt when @@ -920,11 +930,14 @@ public class PointerLocationView extends View implements InputDeviceListener, @Override public void onSystemGestureExclusionChanged(int displayId, Region systemGestureExclusion) { Region exclusion = Region.obtain(systemGestureExclusion); - getHandler().post(() -> { - mSystemGestureExclusion.set(exclusion); - exclusion.recycle(); - invalidate(); - }); + Handler handler = getHandler(); + if (handler != null) { + handler.post(() -> { + mSystemGestureExclusion.set(exclusion); + exclusion.recycle(); + invalidate(); + }); + } } }; }