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

Commit 2277bc53 authored by Galia Peycheva's avatar Galia Peycheva
Browse files

Add SystemApi USE_UNRESTRICTED_KEEP_CLEAR_AREAS

Normal applications should have restrictions on how big/many keep-clear
areas they can set. This is to prevent malicious apps from misusing the
API and causing unexpected effects (like the Pip moving unexpectedly or
too much around the screen).

System apps, however, can be trusted to set any keep-clear areas.

In this CL we introduce a new permission to allow system apps to set
unrestricted keep-clear areas. We send two lists to Shell - one with
restricted, the other one with unrestricted keep-clear areas. When
moving floating windows away, the Shell can decide to always take into
account unrestricted keep-clear areas and be more restrictive about the
restricted ones.

Bug: 209578131
Bug: 209577354
Test: atest CtsWindowManagerDeviceTestCases:KeepClearRectsTests
Test: atest WindowStateTests
Test: atest DisplayContentTests

Change-Id: I68804c50fb81173b0795cf30dd71ea91abd02229
parent 78f3eb7a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -301,6 +301,7 @@ package android {
    field public static final String SET_POINTER_SPEED = "android.permission.SET_POINTER_SPEED";
    field public static final String SET_SCREEN_COMPATIBILITY = "android.permission.SET_SCREEN_COMPATIBILITY";
    field public static final String SET_SYSTEM_AUDIO_CAPTION = "android.permission.SET_SYSTEM_AUDIO_CAPTION";
    field public static final String SET_UNRESTRICTED_KEEP_CLEAR_AREAS = "android.permission.SET_UNRESTRICTED_KEEP_CLEAR_AREAS";
    field public static final String SET_VOLUME_KEY_LONG_PRESS_LISTENER = "android.permission.SET_VOLUME_KEY_LONG_PRESS_LISTENER";
    field public static final String SET_WALLPAPER_COMPONENT = "android.permission.SET_WALLPAPER_COMPONENT";
    field public static final String SET_WALLPAPER_DIM_AMOUNT = "android.permission.SET_WALLPAPER_DIM_AMOUNT";
+1 −1
Original line number Diff line number Diff line
@@ -63,5 +63,5 @@ oneway interface IDisplayWindowListener {
    /**
     * Called when the keep clear ares on a display have changed.
     */
    void onKeepClearAreasChanged(int displayId, in List<Rect> keepClearAreas);
    void onKeepClearAreasChanged(int displayId, in List<Rect> restricted, in List<Rect> unrestricted);
}
+9 −0
Original line number Diff line number Diff line
@@ -6262,6 +6262,15 @@
    <permission android:name="android.permission.BIND_AMBIENT_CONTEXT_DETECTION_SERVICE"
                android:protectionLevel="signature" />

    <!-- @SystemApi Allows an app to set keep-clear areas without restrictions on the size or
        number of keep-clear areas (see {@link android.view.View#setPreferKeepClearRects}).
        When the system arranges floating windows onscreen, it might decide to ignore keep-clear
        areas from windows, whose owner does not have this permission.
        @hide
    -->
    <permission android:name="android.permission.SET_UNRESTRICTED_KEEP_CLEAR_AREAS"
                android:protectionLevel="signature|privileged" />

    <!-- Attribution for Geofencing service. -->
    <attribution android:tag="GeofencingService" android:label="@string/geofencing_service"/>
    <!-- Attribution for Country Detector. -->
+9 −5
Original line number Diff line number Diff line
@@ -245,7 +245,8 @@ public class DisplayController {
        }
    }

    private void onKeepClearAreasChanged(int displayId, List<Rect> keepClearAreas) {
    private void onKeepClearAreasChanged(int displayId, List<Rect> restricted,
            List<Rect> unrestricted) {
        synchronized (mDisplays) {
            if (mDisplays.get(displayId) == null || getDisplay(displayId) == null) {
                Slog.w(TAG, "Skipping onKeepClearAreasChanged on unknown"
@@ -253,7 +254,8 @@ public class DisplayController {
                return;
            }
            for (int i = mDisplayChangedListeners.size() - 1; i >= 0; --i) {
                mDisplayChangedListeners.get(i).onKeepClearAreasChanged(displayId, keepClearAreas);
                mDisplayChangedListeners.get(i)
                    .onKeepClearAreasChanged(displayId, restricted, unrestricted);
            }
        }
    }
@@ -318,9 +320,10 @@ public class DisplayController {
        }

        @Override
        public void onKeepClearAreasChanged(int displayId, List<Rect> keepClearAreas) {
        public void onKeepClearAreasChanged(int displayId, List<Rect> restricted,
                List<Rect> unrestricted) {
            mMainExecutor.execute(() -> {
                DisplayController.this.onKeepClearAreasChanged(displayId, keepClearAreas);
                DisplayController.this.onKeepClearAreasChanged(displayId, restricted, unrestricted);
            });
        }
    }
@@ -361,6 +364,7 @@ public class DisplayController {
        /**
         * Called when keep-clear areas on a display have changed.
         */
        default void onKeepClearAreasChanged(int displayId, List<Rect> keepClearAreas) {}
        default void onKeepClearAreasChanged(int displayId, List<Rect> restricted,
                List<Rect> unrestricted) {}
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -308,7 +308,8 @@ public class CameraServiceProxy extends SystemService
        public void onFixedRotationFinished(int displayId) { }

        @Override
        public void onKeepClearAreasChanged(int displayId, List<Rect> keepClearArea) { }
        public void onKeepClearAreasChanged(int displayId, List<Rect> restricted,
                List<Rect> unrestricted) { }
    }


Loading