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

Commit 019a52b4 authored by Adrian Roos's avatar Adrian Roos
Browse files

WM: implicitly exclude all edges for pre-Q immersive sticky apps

Bug: 135522625
Test: atest DisplayContentTests
Change-Id: Ibe6c2c6d269b15c2e79ac0241b93e42c44a167c9
Exempt-From-Owner-Approval: TBR
parent 5924e5ee
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2312,6 +2312,7 @@ package android.provider {
  }

  public static interface DeviceConfig.WindowManager {
    field public static final String KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE = "system_gestures_excluded_by_pre_q_sticky_immersive";
    field public static final String KEY_SYSTEM_GESTURE_EXCLUSION_LIMIT_DP = "system_gesture_exclusion_limit_dp";
  }

+11 −0
Original line number Diff line number Diff line
@@ -325,6 +325,17 @@ public final class DeviceConfig {
         */
        @TestApi
        String KEY_SYSTEM_GESTURE_EXCLUSION_LIMIT_DP = "system_gesture_exclusion_limit_dp";

        /**
         * Key for controlling whether system gestures are implicitly excluded by windows requesting
         * sticky immersive mode from apps that are targeting an SDK prior to Q.
         *
         * @see android.provider.DeviceConfig#NAMESPACE_WINDOW_MANAGER
         * @hide
         */
        @TestApi
        String KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE =
                "system_gestures_excluded_by_pre_q_sticky_immersive";
    }

    private static final Object sLock = new Object();
+11 −7
Original line number Diff line number Diff line
@@ -5158,6 +5158,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            w.getTouchableRegion(touchableRegion);
            touchableRegion.op(unhandled, Op.INTERSECT);

            if (w.isImplicitlyExcludingAllSystemGestures()) {
                local.set(touchableRegion);
            } else {
                rectListToRegion(w.getSystemGestureExclusion(), local);

                // Transform to display coordinates
@@ -5167,6 +5170,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

                // A window can only exclude system gestures where it is actually touchable
                local.op(touchableRegion, Op.INTERSECT);
            }

            // Apply restriction if necessary.
            if (needsGestureExclusionRestrictions(w, mLastDispatchedSystemUiVisibility)) {
+11 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.os.Process.SYSTEM_UID;
import static android.os.Process.myPid;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.provider.DeviceConfig.WindowManager.KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE;
import static android.provider.DeviceConfig.WindowManager.KEY_SYSTEM_GESTURE_EXCLUSION_LIMIT_DP;
import static android.provider.Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -844,6 +845,7 @@ public class WindowManagerService extends IWindowManager.Stub
    boolean mWindowsChanged = false;

    int mSystemGestureExclusionLimitDp;
    boolean mSystemGestureExcludedByPreQStickyImmersive;

    public interface WindowChangeListener {
        public void windowsChanged();
@@ -1142,13 +1144,21 @@ public class WindowManagerService extends IWindowManager.Stub
        mSystemGestureExclusionLimitDp = Math.max(MIN_GESTURE_EXCLUSION_LIMIT_DP,
                DeviceConfig.getInt(DeviceConfig.NAMESPACE_WINDOW_MANAGER,
                        KEY_SYSTEM_GESTURE_EXCLUSION_LIMIT_DP, 0));
        mSystemGestureExcludedByPreQStickyImmersive =
                DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_WINDOW_MANAGER,
                        KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE, false);
        DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_WINDOW_MANAGER,
                new HandlerExecutor(mH), properties -> {
                    synchronized (mGlobalLock) {
                        final int exclusionLimitDp = Math.max(MIN_GESTURE_EXCLUSION_LIMIT_DP,
                                properties.getInt(KEY_SYSTEM_GESTURE_EXCLUSION_LIMIT_DP, 0));
                        if (mSystemGestureExclusionLimitDp != exclusionLimitDp) {
                        final boolean excludedByPreQSticky = DeviceConfig.getBoolean(
                                DeviceConfig.NAMESPACE_WINDOW_MANAGER,
                                KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE, false);
                        if (mSystemGestureExcludedByPreQStickyImmersive != excludedByPreQSticky
                                || mSystemGestureExclusionLimitDp != exclusionLimitDp) {
                            mSystemGestureExclusionLimitDp = exclusionLimitDp;
                            mSystemGestureExcludedByPreQStickyImmersive = excludedByPreQSticky;
                            mRoot.forAllDisplays(DisplayContent::updateSystemGestureExclusionLimit);
                        }
                    }
+12 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import static android.os.PowerManager.DRAW_WAKE_LOCK;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.SurfaceControl.Transaction;
import static android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
import static android.view.View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT;
import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME;
import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION;
@@ -155,6 +157,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Binder;
import android.os.Build;
import android.os.Debug;
import android.os.IBinder;
import android.os.PowerManager;
@@ -657,6 +660,15 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return true;
    }

    boolean isImplicitlyExcludingAllSystemGestures() {
        final int immersiveStickyFlags =
                SYSTEM_UI_FLAG_HIDE_NAVIGATION | SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        final boolean immersiveSticky =
                (mSystemUiVisibility & immersiveStickyFlags) == immersiveStickyFlags;
        return immersiveSticky && mWmService.mSystemGestureExcludedByPreQStickyImmersive
                && mAppToken != null && mAppToken.mTargetSdk < Build.VERSION_CODES.Q;
    }

    interface PowerManagerWrapper {
        void wakeUp(long time, @WakeReason int reason, String details);

Loading