From 134e1cb862afc0b4bcceff96010e035a5a3912e4 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Wed, 16 May 2018 17:04:29 +0200 Subject: [PATCH] ScreenDecor: Set touchable region in windows coordinate space Also restricts the region to the frame of the view. This is important for double cutouts, would go to the wrong view, and having a touchable region spanning the entire screen breaks some a11y services. Change-Id: I824e5fb9b2f2e765ee9b6da4fcaf2c6840d8f51d Fixes: 79533418 Test: turn on double cutout emulation; adb shell dumpsys window ScreenDecor, verify touchable region for each decor looks right. --- .../src/com/android/systemui/ScreenDecorations.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java index 8d32e4db6d214..139215a029956 100644 --- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java +++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java @@ -554,7 +554,18 @@ public class ScreenDecorations extends SystemUI implements Tunable { return null; } - return mInfo.displayCutout.getBounds(); + View rootView = getRootView(); + Region cutoutBounds = mInfo.displayCutout.getBounds(); + + // Transform to window's coordinate space + rootView.getLocationOnScreen(mLocation); + cutoutBounds.translate(-mLocation[0], -mLocation[1]); + + // Intersect with window's frame + cutoutBounds.op(rootView.getLeft(), rootView.getTop(), rootView.getRight(), + rootView.getBottom(), Region.Op.INTERSECT); + + return cutoutBounds; } } }