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

Commit e80e47f8 authored by Tiger Huang's avatar Tiger Huang
Browse files

Enable privileged apps to set unrestricted gesture exclusion

System UI won't need to check if the gesture blocking activity is
running or not every time a task changes.

Bug: 229048429
Test: atest DisplayContentTests PermissionPolicyTest
Change-Id: I5a72121c8b20b172ea5c1d060960ce14a7420aa9
parent 0869abd8
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -2366,6 +2366,14 @@ public interface WindowManager extends ViewManager {
        @RequiresPermission(permission.INTERNAL_SYSTEM_WINDOW)
        public static final int SYSTEM_FLAG_SHOW_FOR_ALL_USERS = 0x00000010;

        /**
         * Flag to allow this window to have unrestricted gesture exclusion.
         *
         * @see View#setSystemGestureExclusionRects(List)
         * @hide
         */
        public static final int PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION = 0x00000020;

        /**
         * Never animate position changes of the window.
         *
@@ -2586,6 +2594,7 @@ public interface WindowManager extends ViewManager {
                PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED,
                PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS,
                SYSTEM_FLAG_SHOW_FOR_ALL_USERS,
                PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION,
                PRIVATE_FLAG_NO_MOVE_ANIMATION,
                PRIVATE_FLAG_COMPATIBLE_WINDOW,
                PRIVATE_FLAG_SYSTEM_ERROR,
@@ -2632,6 +2641,10 @@ public interface WindowManager extends ViewManager {
                        mask = SYSTEM_FLAG_SHOW_FOR_ALL_USERS,
                        equals = SYSTEM_FLAG_SHOW_FOR_ALL_USERS,
                        name = "SHOW_FOR_ALL_USERS"),
                @ViewDebug.FlagToString(
                        mask = PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION,
                        equals = PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION,
                        name = "UNRESTRICTED_GESTURE_EXCLUSION"),
                @ViewDebug.FlagToString(
                        mask = PRIVATE_FLAG_NO_MOVE_ANIMATION,
                        equals = PRIVATE_FLAG_NO_MOVE_ANIMATION,
+7 −0
Original line number Diff line number Diff line
@@ -6498,6 +6498,13 @@
    <permission android:name="android.permission.SET_UNRESTRICTED_KEEP_CLEAR_AREAS"
                android:protectionLevel="signature|privileged" />

    <!-- Allows an app to set gesture exclusion without restrictions on the vertical extent of the
         exclusions (see {@link android.view.View#setSystemGestureExclusionRects}).
         @hide
    -->
    <permission android:name="android.permission.SET_UNRESTRICTED_GESTURE_EXCLUSION"
                android:protectionLevel="signature|privileged|recents" />

    <!-- @SystemApi Allows TV input apps and TV apps to use TIS extension interfaces for
         domain-specific features.
         <p>Protection level: signature|privileged|vendorPrivileged
+4 −1
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE;
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
@@ -5573,11 +5574,13 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    private static boolean needsGestureExclusionRestrictions(WindowState win,
            boolean ignoreRequest) {
        final int type = win.mAttrs.type;
        final int privateFlags = win.mAttrs.privateFlags;
        final boolean stickyHideNav =
                !win.getRequestedVisibility(ITYPE_NAVIGATION_BAR)
                        && win.mAttrs.insetsFlags.behavior == BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
        return (!stickyHideNav || ignoreRequest) && type != TYPE_INPUT_METHOD
                && type != TYPE_NOTIFICATION_SHADE && win.getActivityType() != ACTIVITY_TYPE_HOME;
                && type != TYPE_NOTIFICATION_SHADE && win.getActivityType() != ACTIVITY_TYPE_HOME
                && (privateFlags & PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION) == 0;
    }

    /**
+5 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_M
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_INTERCEPT_GLOBAL_DRAG_AND_DROP;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
@@ -974,6 +975,10 @@ public class DisplayPolicy {
            }
        }

        if (!win.mSession.mCanSetUnrestrictedGestureExclusion) {
            attrs.privateFlags &= ~PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION;
        }

        // Check if alternate bars positions were updated.
        if (mStatusBarAlt == win) {
            mStatusBarAltPosition = getAltBarPosition(attrs);
+5 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.wm;
import static android.Manifest.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import static android.Manifest.permission.HIDE_OVERLAY_WINDOWS;
import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;
import static android.Manifest.permission.SET_UNRESTRICTED_GESTURE_EXCLUSION;
import static android.Manifest.permission.SET_UNRESTRICTED_KEEP_CLEAR_AREAS;
import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
import static android.Manifest.permission.SYSTEM_APPLICATION_OVERLAY;
@@ -109,6 +110,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {

    final boolean mCanCreateSystemApplicationOverlay;
    final boolean mCanHideNonSystemOverlayWindows;
    final boolean mCanSetUnrestrictedGestureExclusion;
    private AlertWindowNotification mAlertWindowNotification;
    private boolean mShowingAlertWindowNotificationAllowed;
    private boolean mClientDead = false;
@@ -139,6 +141,9 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
        mSetsUnrestrictedKeepClearAreas =
                service.mContext.checkCallingOrSelfPermission(SET_UNRESTRICTED_KEEP_CLEAR_AREAS)
                        == PERMISSION_GRANTED;
        mCanSetUnrestrictedGestureExclusion =
                service.mContext.checkCallingOrSelfPermission(SET_UNRESTRICTED_GESTURE_EXCLUSION)
                        == PERMISSION_GRANTED;
        mShowingAlertWindowNotificationAllowed = mService.mShowAlertWindowNotifications;
        mDragDropController = mService.mDragDropController;
        StringBuilder sb = new StringBuilder();
Loading