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

Commit 6af2931a authored by Kriti Dang's avatar Kriti Dang
Browse files

APIs for HDR output control

New APIs are added to DisplayManager to set/get HDR conversion
properties. The setter is protected by a new permission.

Bug: 251168516
Test: atest HdrConversionTest
Change-Id: I644ee747b669612f78413117e4f8617dccf88f41
parent d94c28e1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -49502,6 +49502,7 @@ package android.view {
    field public static final int HDR_TYPE_HDR10 = 2; // 0x2
    field public static final int HDR_TYPE_HDR10_PLUS = 4; // 0x4
    field public static final int HDR_TYPE_HLG = 3; // 0x3
    field public static final int HDR_TYPE_INVALID = -1; // 0xffffffff
    field public static final float INVALID_LUMINANCE = -1.0f;
  }
+17 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ package android {
    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 MANAGE_TOAST_RATE_LIMITING = "android.permission.MANAGE_TOAST_RATE_LIMITING";
    field public static final String MODIFY_HDR_CONVERSION_MODE = "android.permission.MODIFY_HDR_CONVERSION_MODE";
    field public static final String MODIFY_REFRESH_RATE_SWITCHING_TYPE = "android.permission.MODIFY_REFRESH_RATE_SWITCHING_TYPE";
    field public static final String MODIFY_USER_PREFERRED_DISPLAY_MODE = "android.permission.MODIFY_USER_PREFERRED_DISPLAY_MODE";
    field public static final String NETWORK_SETTINGS = "android.permission.NETWORK_SETTINGS";
@@ -1332,11 +1333,14 @@ package android.hardware.display {
    method public boolean areUserDisabledHdrTypesAllowed();
    method @RequiresPermission(android.Manifest.permission.MODIFY_USER_PREFERRED_DISPLAY_MODE) public void clearGlobalUserPreferredDisplayMode();
    method @Nullable public android.view.Display.Mode getGlobalUserPreferredDisplayMode();
    method @NonNull public android.hardware.display.HdrConversionMode getHdrConversionMode();
    method @NonNull public int[] getSupportedHdrOutputTypes();
    method @NonNull public int[] getUserDisabledHdrTypes();
    method public boolean isMinimalPostProcessingRequested(int);
    method @RequiresPermission(android.Manifest.permission.ACCESS_SURFACE_FLINGER) public void overrideHdrTypes(int, @NonNull int[]);
    method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setAreUserDisabledHdrTypesAllowed(boolean);
    method @RequiresPermission(android.Manifest.permission.MODIFY_USER_PREFERRED_DISPLAY_MODE) public void setGlobalUserPreferredDisplayMode(@NonNull android.view.Display.Mode);
    method @RequiresPermission(android.Manifest.permission.MODIFY_HDR_CONVERSION_MODE) public void setHdrConversionMode(@NonNull android.hardware.display.HdrConversionMode);
    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.WRITE_SECURE_SETTINGS) public void setUserDisabledHdrTypes(@NonNull int[]);
@@ -1349,6 +1353,19 @@ package android.hardware.display {
    field public static final int VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS = 512; // 0x200
  }

  public final class HdrConversionMode implements android.os.Parcelable {
    ctor public HdrConversionMode(int, int);
    ctor public HdrConversionMode(int);
    method public int describeContents();
    method public int getConversionMode();
    method public int getPreferredHdrOutputType();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.display.HdrConversionMode> CREATOR;
    field public static final int HDR_CONVERSION_FORCE = 3; // 0x3
    field public static final int HDR_CONVERSION_PASSTHROUGH = 1; // 0x1
    field public static final int HDR_CONVERSION_SYSTEM = 2; // 0x2
  }

}

package android.hardware.fingerprint {
+48 −0
Original line number Diff line number Diff line
@@ -1300,6 +1300,54 @@ public final class DisplayManager {
        return mGlobal.getUserPreferredDisplayMode(Display.INVALID_DISPLAY);
    }

    /**
     * Sets the HDR conversion mode for the device.
     *
     * @param hdrConversionMode The {@link HdrConversionMode} to set.
     * Note, {@code HdrConversionMode.preferredHdrOutputType} is only applicable when
     * {@code HdrConversionMode.conversionMode} is {@link HdrConversionMode#HDR_CONVERSION_FORCE}.
     *
     * @throws IllegalArgumentException if hdrConversionMode.preferredHdrOutputType is not set
     * when hdrConversionMode.conversionMode is {@link HdrConversionMode#HDR_CONVERSION_FORCE}.
     * @throws IllegalArgumentException if hdrConversionMode.preferredHdrOutputType is set but
     * hdrConversionMode.conversionMode is not {@link HdrConversionMode#HDR_CONVERSION_FORCE}.
     *
     * @see #getHdrConversionMode
     * @see #getSupportedHdrOutputTypes
     * @hide
     */
    @TestApi
    @RequiresPermission(Manifest.permission.MODIFY_HDR_CONVERSION_MODE)
    public void setHdrConversionMode(@NonNull HdrConversionMode hdrConversionMode) {
        mGlobal.setHdrConversionMode(hdrConversionMode);
    }

    /**
     * Returns the {@link HdrConversionMode} of the device, which is set by the user.
     *
     * @see #setHdrConversionMode
     * @see #getSupportedHdrOutputTypes
     * @hide
     */
    @TestApi
    @NonNull
    public HdrConversionMode getHdrConversionMode() {
        return mGlobal.getHdrConversionMode();
    }

    /**
     * Returns the HDR output types supported by the device.
     *
     * @see #getHdrConversionMode
     * @see #setHdrConversionMode
     * @hide
     */
    @TestApi
    @NonNull
    public @HdrType int[] getSupportedHdrOutputTypes() {
        return mGlobal.getSupportedHdrOutputTypes();
    }

    /**
     * When enabled the app requested mode is always selected regardless of user settings and
     * policies for low brightness, low battery, etc.
+33 −0
Original line number Diff line number Diff line
@@ -978,6 +978,39 @@ public final class DisplayManagerGlobal {
        }
    }

    /**
     * Sets the {@link HdrConversionMode} for the device.
     */
    public void setHdrConversionMode(@NonNull HdrConversionMode hdrConversionMode) {
        try {
            mDm.setHdrConversionMode(hdrConversionMode);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * Returns the {@link HdrConversionMode} of the device.
     */
    public HdrConversionMode getHdrConversionMode() {
        try {
            return mDm.getHdrConversionMode();
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * Returns the HDR output types supported by the device.
     */
    public @HdrType int[] getSupportedHdrOutputTypes() {
        try {
            return mDm.getSupportedHdrOutputTypes();
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * 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
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.display;

parcelable HdrConversionMode;
 No newline at end of file
Loading