Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd3b4a8c authored by Jacky Kao's avatar Jacky Kao
Browse files

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
parent e0c12903
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -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<Integer> skipRemainingWindowsForTasks) {
            if (windowState.mAttrs.type