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

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

Merge "Fall back to normal brightness preset" into main

parents 46400ba3 94f53bdf
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -624,10 +624,10 @@ public class AutomaticBrightnessController {
        pw.println("  Current mode="
                + autoBrightnessModeToString(mCurrentBrightnessMapper.getMode()));

        pw.println();
        for (int i = 0; i < mBrightnessMappingStrategyMap.size(); i++) {
            pw.println();
            pw.println("  Mapper for mode "
                    + autoBrightnessModeToString(mBrightnessMappingStrategyMap.keyAt(i)) + "=");
                    + autoBrightnessModeToString(mBrightnessMappingStrategyMap.keyAt(i)) + ":");
            mBrightnessMappingStrategyMap.valueAt(i).dump(pw,
                    mBrightnessRangeController.getNormalBrightnessMax());
        }
@@ -1159,7 +1159,7 @@ public class AutomaticBrightnessController {
        if (mCurrentBrightnessMapper.getMode() == mode) {
            return;
        }
        Slog.i(TAG, "Switching to mode " + mode);
        Slog.i(TAG, "Switching to mode " + autoBrightnessModeToString(mode));
        if (mode == AUTO_BRIGHTNESS_MODE_IDLE
                || mCurrentBrightnessMapper.getMode() == AUTO_BRIGHTNESS_MODE_IDLE) {
            switchModeAndShortTermModels(mode);
+16 −2
Original line number Diff line number Diff line
@@ -165,8 +165,15 @@ public class DisplayBrightnessMappingConfig {
     */
    public float[] getLuxArray(@AutomaticBrightnessController.AutomaticBrightnessMode int mode,
            int preset) {
        return mBrightnessLevelsLuxMap.get(
        float[] luxArray = mBrightnessLevelsLuxMap.get(
                autoBrightnessModeToString(mode) + "_" + autoBrightnessPresetToString(preset));
        if (luxArray != null) {
            return luxArray;
        }

        // No array for this preset, fall back to the normal preset
        return mBrightnessLevelsLuxMap.get(autoBrightnessModeToString(mode) + "_"
                + AutoBrightnessSettingName.normal.getRawName());
    }

    /**
@@ -184,8 +191,15 @@ public class DisplayBrightnessMappingConfig {
     */
    public float[] getBrightnessArray(
            @AutomaticBrightnessController.AutomaticBrightnessMode int mode, int preset) {
        return mBrightnessLevelsMap.get(
        float[] brightnessArray = mBrightnessLevelsMap.get(
                autoBrightnessModeToString(mode) + "_" + autoBrightnessPresetToString(preset));
        if (brightnessArray != null) {
            return brightnessArray;
        }

        // No array for this preset, fall back to the normal preset
        return mBrightnessLevelsMap.get(autoBrightnessModeToString(mode) + "_"
                + AutoBrightnessSettingName.normal.getRawName());
    }

    @Override
+3 −0
Original line number Diff line number Diff line
@@ -625,6 +625,9 @@

    If no mode is specified, the mapping will be used for the default mode.
    If no setting is specified, the mapping will be used for the normal brightness setting.

    If no mapping is defined for one of the settings, the mapping for the normal setting will be
    used as a fallback.
    -->
    <xs:complexType name="luxToBrightnessMapping">
        <xs:element name="map" type="nonNegativeFloatToFloatMap">
+10 −0
Original line number Diff line number Diff line
@@ -824,6 +824,16 @@ public final class DisplayDeviceConfigTest {
                mDisplayDeviceConfig.getAutoBrightnessBrighteningLevels(
                        AUTO_BRIGHTNESS_MODE_DOZE,
                        Settings.System.SCREEN_BRIGHTNESS_AUTOMATIC_BRIGHT), SMALL_DELTA);

        // Should fall back to the normal preset
        assertArrayEquals(new float[]{0.0f, 95},
                mDisplayDeviceConfig.getAutoBrightnessBrighteningLevelsLux(
                        AUTO_BRIGHTNESS_MODE_DOZE,
                        Settings.System.SCREEN_BRIGHTNESS_AUTOMATIC_DIM), ZERO_DELTA);
        assertArrayEquals(new float[]{0.35f, 0.45f},
                mDisplayDeviceConfig.getAutoBrightnessBrighteningLevels(
                        AUTO_BRIGHTNESS_MODE_DOZE,
                        Settings.System.SCREEN_BRIGHTNESS_AUTOMATIC_DIM), SMALL_DELTA);
    }

    @Test