diff options
| author | 2020-04-07 19:54:55 +0800 | |
|---|---|---|
| committer | 2020-04-14 19:21:19 +0800 | |
| commit | 504058e13b0930fe1b06a96f7baea4663ebf27a7 (patch) | |
| tree | 778ebebfc25de74fbd4a5e0700e61531c7e6aa34 | |
| parent | b0bf3e94fadfd043678390061b931ca6f1369a68 (diff) | |
Fix hardly triggering A11y shortcut via gesture when zoom in
When the navigation mode is gestural, users can use two fingers
swipe up from bottom to trigger A11y shortcut. However, it has conflict
with scrlloing gesture of magnification. We count the navigation bar
inset into nonmagnificationReigion in such situation. If the UI is
in immersive mode, the nagivation bar is invsibile, so it won't
counted.
Bug: 145775653
Test: manual test:
1. Enable gesture navigation mode.
2. Zoom in the screen via gesture.
3. Turn off magnification via gesture.
Change-Id: I388397d9fb3713987beb44a1611270bf0d944c66
| -rw-r--r-- | services/core/java/com/android/server/wm/AccessibilityController.java | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java index 75d6a090bd3d..4fe58433ddb6 100644 --- a/services/core/java/com/android/server/wm/AccessibilityController.java +++ b/services/core/java/com/android/server/wm/AccessibilityController.java @@ -674,6 +674,15 @@ final class AccessibilityController { availableBounds.op(windowBounds, Region.Op.DIFFERENCE); } + // If the navigation bar window doesn't have touchable region, count + // navigation bar insets into nonMagnifiedBounds. It happens when + // navigation mode is gestural. + if (isUntouchableNavigationBar(windowState, mTempRegion3)) { + final Rect navBarInsets = getNavBarInsets(mDisplayContent); + nonMagnifiedBounds.op(navBarInsets, Region.Op.UNION); + availableBounds.op(navBarInsets, Region.Op.DIFFERENCE); + } + // Count letterbox into nonMagnifiedBounds if (windowState.isLetterboxedForDisplayCutoutLw()) { Region letterboxBounds = getLetterboxBounds(windowState); @@ -1091,6 +1100,24 @@ final class AccessibilityController { } } + static boolean isUntouchableNavigationBar(WindowState windowState, + Region touchableRegion) { + if (windowState.mAttrs.type != WindowManager.LayoutParams.TYPE_NAVIGATION_BAR) { + return false; + } + + // Gets the touchable region. + windowState.getTouchableRegion(touchableRegion); + + return touchableRegion.isEmpty(); + } + + static Rect getNavBarInsets(DisplayContent displayContent) { + final InsetsState insetsState = + displayContent.getInsetsStateController().getRawInsetsState(); + return insetsState.getSource(ITYPE_NAVIGATION_BAR).getFrame(); + } + /** * This class encapsulates the functionality related to computing the windows * reported for accessibility purposes. These windows are all windows a sighted @@ -1205,16 +1232,12 @@ final class AccessibilityController { updateUnaccountedSpace(windowState, regionInScreen, unaccountedSpace, skipRemainingWindowsForTasks); focusedWindowAdded |= windowState.isFocused(); - } else if (isUntouchableNavigationBar(windowState)) { + } else if (isUntouchableNavigationBar(windowState, mTempRegion1)) { // 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, + unaccountedSpace.op(getNavBarInsets(dc), unaccountedSpace, Region.Op.REVERSE_DIFFERENCE); } @@ -1294,18 +1317,6 @@ 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<Integer> skipRemainingWindowsForTasks) { if (windowState.mAttrs.type |