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

Commit 22a6767a authored by Piotr Wilczyński's avatar Piotr Wilczyński Committed by Android (Google) Code Review
Browse files

Merge "HDR brightness setting" into main

parents 9a5663fe 62ee8fb3
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -9605,6 +9605,23 @@ public final class Settings {
         */
        public static final String EM_VALUE =
                "em_value";
        /**
         * Setting that specifies whether High Dynamic Range brightness is enabled.
         *
         * @hide
         */
        public static final String HDR_BRIGHTNESS_ENABLED =
                "hdr_brightness_enabled";
        /**
         * Setting that specifies the intensity of the High Dynamic Range brightness. The range is
         * [0, 1], which is which is used to scale the HDR/SDR ratio.
         *
         * @hide
         */
        public static final String HDR_BRIGHTNESS_BOOST_LEVEL =
                "hdr_brightness_boost_level";
        /**
         * List of the enabled print services.
         *
+2 −0
Original line number Diff line number Diff line
@@ -313,5 +313,7 @@ public class SecureSettings {
        Settings.Secure.SELECTED_SPELL_CHECKER,
        // SELECTED_SPELL_CHECKER_SUBTYPE needs to be restored after SELECTED_SPELL_CHECKER
        Settings.Secure.SELECTED_SPELL_CHECKER_SUBTYPE,
        Settings.Secure.HDR_BRIGHTNESS_ENABLED,
        Settings.Secure.HDR_BRIGHTNESS_BOOST_LEVEL,
    };
}
+2 −0
Original line number Diff line number Diff line
@@ -491,5 +491,7 @@ public class SecureSettingsValidators {
        VALIDATORS.put(Secure.SELECTED_SPELL_CHECKER_SUBTYPE, ANY_INTEGER_VALIDATOR);
        VALIDATORS.put(Secure.PACK_THEME_FEATURE_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.SUGGESTED_THEME_FEATURE_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.HDR_BRIGHTNESS_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.HDR_BRIGHTNESS_BOOST_LEVEL, new InclusiveFloatRangeValidator(0, 1));
    }
}
+8 −4
Original line number Diff line number Diff line
@@ -1222,9 +1222,11 @@ public class DisplayDeviceConfig {
     *
     * @return the HDR brightness or BRIGHTNESS_INVALID when no mapping exists.
     */
    public float getHdrBrightnessFromSdr(float brightness, float maxDesiredHdrSdrRatio) {
    public float getHdrBrightnessFromSdr(float brightness, float maxDesiredHdrSdrRatio,
            float ratioScaleFactor) {
        Spline sdrToHdrSpline = mHbmData != null ? mHbmData.sdrToHdrRatioSpline : null;
        return getHdrBrightnessFromSdr(brightness, maxDesiredHdrSdrRatio, sdrToHdrSpline);
        return getHdrBrightnessFromSdr(brightness, maxDesiredHdrSdrRatio, ratioScaleFactor,
                sdrToHdrSpline);
    }

    /**
@@ -1235,7 +1237,7 @@ public class DisplayDeviceConfig {
     * @return the HDR brightness or BRIGHTNESS_INVALID when no mapping exists.
     */
    public float getHdrBrightnessFromSdr(float brightness, float maxDesiredHdrSdrRatio,
            @Nullable Spline sdrToHdrSpline) {
            float ratioScaleFactor, @Nullable Spline sdrToHdrSpline) {
        if (sdrToHdrSpline == null) {
            return PowerManager.BRIGHTNESS_INVALID;
        }
@@ -1246,7 +1248,9 @@ public class DisplayDeviceConfig {
            return PowerManager.BRIGHTNESS_INVALID;
        }

        float ratio = Math.min(sdrToHdrSpline.interpolate(nits), maxDesiredHdrSdrRatio);
        float rawRatio = sdrToHdrSpline.interpolate(nits);
        float scaledRatio = (rawRatio - 1) * ratioScaleFactor + 1;
        float ratio = Math.min(scaledRatio, maxDesiredHdrSdrRatio);
        float hdrNits = nits * ratio;
        if (getNitsToBacklightSpline() == null) {
            return PowerManager.BRIGHTNESS_INVALID;
+4 −2
Original line number Diff line number Diff line
@@ -2082,9 +2082,11 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        final DisplayDeviceInfo info = mDisplayDevice.getDisplayDeviceInfoLocked();
        return mInjector.getHighBrightnessModeController(mHandler, info.width, info.height,
                displayToken, displayUniqueId, PowerManager.BRIGHTNESS_MIN,
                PowerManager.BRIGHTNESS_MAX, hbmData, (sdrBrightness, maxDesiredHdrSdrRatio) ->
                PowerManager.BRIGHTNESS_MAX, hbmData,
                (sdrBrightness, maxDesiredHdrSdrRatio, ratioScaleFactor) ->
                        mDisplayDeviceConfig.getHdrBrightnessFromSdr(sdrBrightness,
                                maxDesiredHdrSdrRatio), modeChangeCallback, hbmMetadata, mContext);
                                maxDesiredHdrSdrRatio, ratioScaleFactor), modeChangeCallback,
                hbmMetadata, mContext);
    }

    private void blockScreenOn() {
Loading