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

Commit 97ba024f authored by Marin Shalamanov's avatar Marin Shalamanov
Browse files

Add TestApi to always select the app requested display mode

The added test API is used to ignore all votes in
DisplayModeDirector app votes. This way only the app
requested display mode will be picked. The API will be
used for testing app mode switch requests.

Bug: 159113268
Bug: 158316271
Test: m
Change-Id: I257636ae2a6ed74044e71e49a99024682c3a92c5
parent 82bc48af
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package android {
    field public static final String MANAGE_ROLLBACKS = "android.permission.MANAGE_ROLLBACKS";
    field public static final String NETWORK_SETTINGS = "android.permission.NETWORK_SETTINGS";
    field public static final String NETWORK_STACK = "android.permission.NETWORK_STACK";
    field public static final String OVERRIDE_DISPLAY_MODE_REQUESTS = "android.permission.OVERRIDE_DISPLAY_MODE_REQUESTS";
    field public static final String READ_CELL_BROADCASTS = "android.permission.READ_CELL_BROADCASTS";
    field public static final String READ_PRIVILEGED_PHONE_STATE = "android.permission.READ_PRIVILEGED_PHONE_STATE";
    field public static final String REMOVE_TASKS = "android.permission.REMOVE_TASKS";
@@ -1304,6 +1305,8 @@ package android.hardware.display {
    method public android.graphics.Point getStableDisplaySize();
    method public boolean isMinimalPostProcessingRequested(int);
    method @RequiresPermission(android.Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS) public void setBrightnessConfiguration(android.hardware.display.BrightnessConfiguration);
    method @RequiresPermission(android.Manifest.permission.OVERRIDE_DISPLAY_MODE_REQUESTS) public void setShouldAlwaysRespectAppRequestedMode(boolean);
    method @RequiresPermission(android.Manifest.permission.OVERRIDE_DISPLAY_MODE_REQUESTS) public boolean shouldAlwaysRespectAppRequestedMode();
    field public static final int VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS = 512; // 0x200
    field public static final int VIRTUAL_DISPLAY_FLAG_TRUSTED = 1024; // 0x400
  }
+24 −0
Original line number Diff line number Diff line
@@ -840,6 +840,30 @@ public final class DisplayManager {
        return mGlobal.getMinimumBrightnessCurve();
    }

    /**
     * When enabled the app requested mode is always selected regardless of user settings and
     * policies for low brightness, low battery, etc.
     *
     * @hide
     */
    @TestApi
    @RequiresPermission(Manifest.permission.OVERRIDE_DISPLAY_MODE_REQUESTS)
    public void setShouldAlwaysRespectAppRequestedMode(boolean enabled) {
        mGlobal.setShouldAlwaysRespectAppRequestedMode(enabled);
    }

    /**
     * Returns whether we are running in a mode which always selects the app requested display mode
     * and ignores user settings and policies for low brightness, low battery etc.
     *
     * @hide
     */
    @TestApi
    @RequiresPermission(Manifest.permission.OVERRIDE_DISPLAY_MODE_REQUESTS)
    public boolean shouldAlwaysRespectAppRequestedMode() {
        return mGlobal.shouldAlwaysRespectAppRequestedMode();
    }

    /**
     * Listens for changes in available display devices.
     */
+26 −0
Original line number Diff line number Diff line
@@ -699,6 +699,32 @@ public final class DisplayManagerGlobal {
        }
    }

    /**
     * When enabled the app requested display resolution and refresh rate is always selected
     * in DisplayModeDirector regardless of user settings and policies for low brightness, low
     * battery etc.
     */
    public void setShouldAlwaysRespectAppRequestedMode(boolean enabled) {
        try {
            mDm.setShouldAlwaysRespectAppRequestedMode(enabled);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * Returns whether DisplayModeDirector is running in a mode which always selects the app
     * requested display mode and ignores user settings and policies for low brightness, low
     * battery etc.
     */
    public boolean shouldAlwaysRespectAppRequestedMode() {
        try {
            return mDm.shouldAlwaysRespectAppRequestedMode();
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }

    private final class DisplayManagerCallback extends IDisplayManagerCallback.Stub {
        @Override
        public void onDisplayEvent(int displayId, int event) {
+6 −0
Original line number Diff line number Diff line
@@ -128,4 +128,10 @@ interface IDisplayManager {
    // The wide gamut color space is returned from composition pipeline
    // based on hardware capability.
    int getPreferredWideGamutColorSpaceId();

    // When enabled the app requested display resolution and refresh rate is always selected
    // in DisplayModeDirector regardless of user settings and policies for low brightness, low
    // battery etc.
    void setShouldAlwaysRespectAppRequestedMode(boolean enabled);
    boolean shouldAlwaysRespectAppRequestedMode();
}
+8 −0
Original line number Diff line number Diff line
@@ -3910,6 +3910,14 @@
    <permission android:name="android.permission.CONTROL_DISPLAY_BRIGHTNESS"
        android:protectionLevel="signature" />

    <!-- Allows an application to override the display mode requests
         so the app requested mode will be selected and user settings and display
         policies will be ignored.
         @hide
         @TestApi -->
    <permission android:name="android.permission.OVERRIDE_DISPLAY_MODE_REQUESTS"
                android:protectionLevel="signature" />

    <!-- @SystemApi Allows an application to control VPN.
         <p>Not for use by third-party applications.</p>
         @hide -->
Loading