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

Commit f833ba91 authored by David Stevens's avatar David Stevens
Browse files

Update DisplayContent tap exclude region on window resize

Bug: 64841677
Test: android.server.cts.ActivityManagerDisplayTests
Test: #testLaunchExternalDisplayActivityWhilePrimaryOff
Change-Id: I9c512cef707975f2fcb8a6febc4b89b47fda2dcc
parent 595987e6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2173,8 +2173,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight);
            pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth);
            pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight);
            pw.println(subPrefix + "deferred=" + mDeferredRemoval
            pw.print(subPrefix + "deferred=" + mDeferredRemoval
                    + " mLayoutNeeded=" + mLayoutNeeded);
            pw.println(" mTouchExcludeRegion=" + mTouchExcludeRegion);

        pw.println();
        pw.println(prefix + "Application tokens in top down Z order:");
+39 −9
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.os.RemoteException;
import android.os.SystemClock;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.ArraySet;
import android.util.EventLog;
import android.util.Slog;
import android.util.SparseIntArray;
@@ -664,15 +665,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
                    defaultDisplay.pendingLayoutChanges);
        }

        for (i = mService.mResizingWindows.size() - 1; i >= 0; i--) {
            WindowState win = mService.mResizingWindows.get(i);
            if (win.mAppFreezing) {
                // Don't remove this window until rotation has completed.
                continue;
            }
            win.reportResized();
            mService.mResizingWindows.remove(i);
        }
        final ArraySet<DisplayContent> touchExcludeRegionUpdateDisplays = handleResizingWindows();

        if (DEBUG_ORIENTATION && mService.mDisplayFrozen) Slog.v(TAG,
                "With display frozen, orientationChangeComplete=" + mOrientationChangeComplete);
@@ -814,6 +807,16 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
            mService.mInputMonitor.updateInputWindowsLw(false /*force*/);
        }
        mService.setFocusTaskRegionLocked(null);
        if (touchExcludeRegionUpdateDisplays != null) {
            final DisplayContent focusedDc = mService.mFocusedApp != null
                    ? mService.mFocusedApp.getDisplayContent() : null;
            for (DisplayContent dc : touchExcludeRegionUpdateDisplays) {
                // The focused DisplayContent was recalcuated in setFocusTaskRegionLocked
                if (focusedDc != dc) {
                    dc.setTouchExcludeRegion(null /* focusedTask */);
                }
            }
        }

        // Check to see if we are now in a state where the screen should
        // be enabled, because the window obscured flags have changed.
@@ -864,6 +867,33 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
        mService.mDisplayManagerInternal.performTraversalInTransactionFromWindowManager();
    }

    /**
     * Handles resizing windows during surface placement.
     *
     * @return A set of any DisplayContent whose touch exclude region needs to be recalculated due
     *         to a tap-exclude window resizing, or null if no such DisplayContents were found.
     */
    private ArraySet<DisplayContent> handleResizingWindows() {
        ArraySet<DisplayContent> touchExcludeRegionUpdateSet = null;
        for (int i = mService.mResizingWindows.size() - 1; i >= 0; i--) {
            WindowState win = mService.mResizingWindows.get(i);
            if (win.mAppFreezing) {
                // Don't remove this window until rotation has completed.
                continue;
            }
            win.reportResized();
            mService.mResizingWindows.remove(i);
            if (WindowManagerService.excludeWindowTypeFromTapOutTask(win.mAttrs.type)) {
                final DisplayContent dc = win.getDisplayContent();
                if (touchExcludeRegionUpdateSet == null) {
                    touchExcludeRegionUpdateSet = new ArraySet<>();
                }
                touchExcludeRegionUpdateSet.add(dc);
            }
        }
        return touchExcludeRegionUpdateSet;
    }

    /**
     * @param w WindowState this method is applied to.
     * @param obscured True if there is a window on top of this obscuring the display.