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

Commit 94a83470 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add TestApi for setRefreshRateSwitchingType"

parents 00c21aa6 019f990c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android {
    field public static final String MANAGE_CRATES = "android.permission.MANAGE_CRATES";
    field public static final String MANAGE_NOTIFICATION_LISTENERS = "android.permission.MANAGE_NOTIFICATION_LISTENERS";
    field public static final String MANAGE_ROLLBACKS = "android.permission.MANAGE_ROLLBACKS";
    field public static final String MODIFY_REFRESH_RATE_SWITCHING_TYPE = "android.permission.MODIFY_REFRESH_RATE_SWITCHING_TYPE";
    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";
@@ -743,9 +744,14 @@ package android.hardware.display {
  }

  public final class DisplayManager {
    method @RequiresPermission(android.Manifest.permission.MODIFY_REFRESH_RATE_SWITCHING_TYPE) public int getRefreshRateSwitchingType();
    method public boolean isMinimalPostProcessingRequested(int);
    method @RequiresPermission(android.Manifest.permission.MODIFY_REFRESH_RATE_SWITCHING_TYPE) public void setRefreshRateSwitchingType(int);
    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 SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS = 2; // 0x2
    field public static final int SWITCHING_TYPE_NONE = 0; // 0x0
    field public static final int SWITCHING_TYPE_WITHIN_GROUPS = 1; // 0x1
    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
  }
+61 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.hardware.display;
import static android.view.Display.DEFAULT_DISPLAY;

import android.Manifest;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -38,9 +39,12 @@ import android.util.SparseArray;
import android.view.Display;
import android.view.Surface;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;


/**
 * Manages the properties of attached displays.
 */
@@ -336,6 +340,40 @@ public final class DisplayManager {
     */
    public static final int VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP = 1 << 11;


    /** @hide */
    @IntDef(prefix = {"SWITCHING_TYPE_"}, value = {
            SWITCHING_TYPE_NONE,
            SWITCHING_TYPE_WITHIN_GROUPS,
            SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface SwitchingType {}

    /**
     * No mode switching will happen.
     * @hide
     */
    @TestApi
    public static final int SWITCHING_TYPE_NONE = 0;

    /**
     * Allow only refresh rate switching between modes in the same configuration group. This way
     * only switches without visual interruptions for the user will be allowed.
     * @hide
     */
    @TestApi
    public static final int SWITCHING_TYPE_WITHIN_GROUPS = 1;

    /**
     * Allow refresh rate switching between all refresh rates even if the switch with have visual
     * interruptions for the user.
     * @hide
     */
    @TestApi
    public static final int SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS = 2;


    /** @hide */
    public DisplayManager(Context context) {
        mContext = context;
@@ -874,6 +912,29 @@ public final class DisplayManager {
        return mGlobal.shouldAlwaysRespectAppRequestedMode();
    }

    /**
     * Sets the refresh rate switching type.
     * This matches {@link android.provider.Settings.Secure.MATCH_CONTENT_FRAME_RATE}
     *
     * @hide
     */
    @TestApi
    @RequiresPermission(Manifest.permission.MODIFY_REFRESH_RATE_SWITCHING_TYPE)
    public void setRefreshRateSwitchingType(@SwitchingType int newValue) {
        mGlobal.setRefreshRateSwitchingType(newValue);
    }

    /**
     * Returns the refresh rate switching type.
     *
     * @hide
     */
    @TestApi
    @RequiresPermission(Manifest.permission.MODIFY_REFRESH_RATE_SWITCHING_TYPE)
    @SwitchingType public int getRefreshRateSwitchingType() {
        return mGlobal.getRefreshRateSwitchingType();
    }

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

    /**
     * Sets the refresh rate switching type.
     *
     * @hide
     */
    public void setRefreshRateSwitchingType(@DisplayManager.SwitchingType int newValue) {
        try {
            mDm.setRefreshRateSwitchingType(newValue);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * Returns the refresh rate switching type.
     *
     * @hide
     */
    @DisplayManager.SwitchingType
    public int getRefreshRateSwitchingType() {
        try {
            return mDm.getRefreshRateSwitchingType();
        } 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
@@ -134,4 +134,10 @@ interface IDisplayManager {
    // battery etc.
    void setShouldAlwaysRespectAppRequestedMode(boolean enabled);
    boolean shouldAlwaysRespectAppRequestedMode();

    // Sets the refresh rate switching type.
    void setRefreshRateSwitchingType(int newValue);

    // Returns the refresh rate switching type.
    int getRefreshRateSwitchingType();
}
+7 −0
Original line number Diff line number Diff line
@@ -4047,6 +4047,13 @@
    <permission android:name="android.permission.OVERRIDE_DISPLAY_MODE_REQUESTS"
                android:protectionLevel="signature" />

    <!-- Allows an application to modify the refresh rate switching type. This
         matches Setting.Secure.MATCH_CONTENT_FRAME_RATE.
         @hide
         @TestApi -->
    <permission android:name="android.permission.MODIFY_REFRESH_RATE_SWITCHING_TYPE"
                android:protectionLevel="signature" />

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