From fd3b4a8c6940ad48c0137e76d4aa39adacd5720e Mon Sep 17 00:00:00 2001 From: Jacky Kao Date: Mon, 30 Mar 2020 15:22:54 +0800 Subject: [PATCH] Fix more windows at framework on system gesture mode When the mode of navigation bar is system gesture mode, there is a navigation bar inset existing, but the application can not touch this region due to all touch events from this region received by launcher. We need to account this region with unaccount space to avoid the windows which could not be touched passing to A11y framework. Bug: 142022890 Test: a11y CTS & unit tests Change-Id: If87e1f5b840daa93f78c4b4955ed98633b654928 --- .../server/wm/AccessibilityController.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java index 68224b59a2871..75d6a090bd3d9 100644 --- a/services/core/java/com/android/server/wm/AccessibilityController.java +++ b/services/core/java/com/android/server/wm/AccessibilityController.java @@ -16,6 +16,7 @@ package com.android.server.wm; +import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY; @@ -48,6 +49,7 @@ import android.util.Slog; import android.util.SparseArray; import android.util.TypedValue; import android.view.Display; +import android.view.InsetsState; import android.view.MagnificationSpec; import android.view.Surface; import android.view.Surface.OutOfResourcesException; @@ -1203,6 +1205,17 @@ final class AccessibilityController { updateUnaccountedSpace(windowState, regionInScreen, unaccountedSpace, skipRemainingWindowsForTasks); focusedWindowAdded |= windowState.isFocused(); + } else if (isUntouchableNavigationBar(windowState)) { + // If this widow is navigation bar without touchable region, accounting the + // region of navigation bar inset because all touch events from this region + // would be received by launcher, i.e. this region is a un-touchable one + // for the application. + final InsetsState insetsState = + dc.getInsetsStateController().getRawInsetsState(); + final Rect displayFrame = + insetsState.getSource(ITYPE_NAVIGATION_BAR).getFrame(); + unaccountedSpace.op(displayFrame, unaccountedSpace, + Region.Op.REVERSE_DIFFERENCE); } if (unaccountedSpace.isEmpty() && focusedWindowAdded) { @@ -1281,6 +1294,18 @@ final class AccessibilityController { return false; } + private boolean isUntouchableNavigationBar(WindowState windowState) { + if (windowState.mAttrs.type != WindowManager.LayoutParams.TYPE_NAVIGATION_BAR) { + return false; + } + + // Gets the touchable region. + Region touchableRegion = mTempRegion1; + windowState.getTouchableRegion(touchableRegion); + + return touchableRegion.isEmpty(); + } + private void updateUnaccountedSpace(WindowState windowState, Region regionInScreen, Region unaccountedSpace, HashSet skipRemainingWindowsForTasks) { if (windowState.mAttrs.type