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

Commit 573fe5e6 authored by Oleg Petšjonkin's avatar Oleg Petšjonkin Committed by Android (Google) Code Review
Browse files

Merge "Removing BrightnessThrottler" into main

parents a4d22287 61833dec
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import com.android.internal.display.BrightnessSynchronizer;
import com.android.internal.os.BackgroundThread;
import com.android.server.EventLogTags;
import com.android.server.display.brightness.BrightnessEvent;
import com.android.server.display.brightness.clamper.BrightnessClamperController;
import com.android.server.display.config.HysteresisLevels;
import com.android.server.display.feature.DisplayManagerFlags;

@@ -265,7 +266,7 @@ public class AutomaticBrightnessController {
    private final BrightnessRangeController mBrightnessRangeController;

    // Throttles (caps) maximum allowed brightness
    private final BrightnessThrottler mBrightnessThrottler;
    private final BrightnessClamperController mBrightnessClamperController;
    private boolean mIsBrightnessThrottled;

    // Context-sensitive brightness configurations require keeping track of the foreground app's
@@ -299,7 +300,7 @@ public class AutomaticBrightnessController {
            HysteresisLevels ambientBrightnessThresholdsIdle,
            HysteresisLevels screenBrightnessThresholdsIdle, Context context,
            BrightnessRangeController brightnessModeController,
            BrightnessThrottler brightnessThrottler, int ambientLightHorizonShort,
            BrightnessClamperController clamperController, int ambientLightHorizonShort,
            int ambientLightHorizonLong, float userLux, float userNits,
            DisplayManagerFlags displayManagerFlags) {
        this(new Injector(), callbacks, looper, sensorManager, lightSensor,
@@ -310,7 +311,7 @@ public class AutomaticBrightnessController {
                resetAmbientLuxAfterWarmUpConfig, ambientBrightnessThresholds,
                screenBrightnessThresholds, ambientBrightnessThresholdsIdle,
                screenBrightnessThresholdsIdle, context, brightnessModeController,
                brightnessThrottler, ambientLightHorizonShort, ambientLightHorizonLong, userLux,
                clamperController, ambientLightHorizonShort, ambientLightHorizonLong, userLux,
                userNits, displayManagerFlags
        );
    }
@@ -328,7 +329,7 @@ public class AutomaticBrightnessController {
            HysteresisLevels ambientBrightnessThresholdsIdle,
            HysteresisLevels screenBrightnessThresholdsIdle, Context context,
            BrightnessRangeController brightnessRangeController,
            BrightnessThrottler brightnessThrottler, int ambientLightHorizonShort,
            BrightnessClamperController clamperController, int ambientLightHorizonShort,
            int ambientLightHorizonLong, float userLux, float userNits,
            DisplayManagerFlags displayManagerFlags) {
        mInjector = injector;
@@ -374,7 +375,7 @@ public class AutomaticBrightnessController {
        mForegroundAppCategory = ApplicationInfo.CATEGORY_UNDEFINED;
        mPendingForegroundAppCategory = ApplicationInfo.CATEGORY_UNDEFINED;
        mBrightnessRangeController = brightnessRangeController;
        mBrightnessThrottler = brightnessThrottler;
        mBrightnessClamperController = clamperController;
        mBrightnessMappingStrategyMap = brightnessMappingStrategyMap;
        mDisplayManagerFlags = displayManagerFlags;

@@ -472,9 +473,10 @@ public class AutomaticBrightnessController {
        }
        changed |= setLightSensorEnabled(enable);

        if (mIsBrightnessThrottled != mBrightnessThrottler.isThrottled()) {
        boolean isBrightnessThrottled = mBrightnessClamperController.isThrottled();
        if (mIsBrightnessThrottled != isBrightnessThrottled) {
            // Maximum brightness has changed, so recalculate display brightness.
            mIsBrightnessThrottled = mBrightnessThrottler.isThrottled();
            mIsBrightnessThrottled = isBrightnessThrottled;
            changed = true;
        }

@@ -1038,10 +1040,9 @@ public class AutomaticBrightnessController {

    // Clamps values with float range [0.0-1.0]
    private float clampScreenBrightness(float value) {
        final float minBrightness = Math.min(mBrightnessRangeController.getCurrentBrightnessMin(),
                mBrightnessThrottler.getBrightnessCap());
        final float minBrightness = mBrightnessRangeController.getCurrentBrightnessMin();
        final float maxBrightness = Math.min(mBrightnessRangeController.getCurrentBrightnessMax(),
                mBrightnessThrottler.getBrightnessCap());
                mBrightnessClamperController.getMaxBrightness());
        return MathUtils.constrain(value, minBrightness, maxBrightness);
    }

+0 −476

File deleted.

Preview size limit exceeded, changes collapsed.

+7 −49

File changed.

Preview size limit exceeded, changes collapsed.

+19 −3
Original line number Diff line number Diff line
@@ -195,6 +195,19 @@ public class BrightnessClamperController {
        mModifiers.forEach(BrightnessStateModifier::stop);
    }

    /**
     * returns max allowed brightness.
     * TODO(b/387452517): introduce constrainBrightness method
     */
    public float getMaxBrightness() {
        return mModifiersAggregatedState.mMaxBrightness;
    }

    public boolean isThrottled() {
        return mModifiersAggregatedState.mMaxBrightnessReason
                != BrightnessInfo.BRIGHTNESS_MAX_REASON_NONE;
    }


    // Called in DisplayControllerHandler
    private void recalculateModifiersState() {
@@ -306,7 +319,7 @@ public class BrightnessClamperController {
            BrightnessWearBedtimeModeModifier.WearBedtimeModeData {
        @NonNull
        private final String mUniqueDisplayId;
        @NonNull
        @Nullable
        private final String mThermalThrottlingDataId;
        @NonNull
        private final String mPowerThrottlingDataId;
@@ -322,7 +335,7 @@ public class BrightnessClamperController {
        final int mDisplayId;

        public DisplayDeviceData(@NonNull String uniqueDisplayId,
                @NonNull String thermalThrottlingDataId,
                @Nullable String thermalThrottlingDataId,
                @NonNull String powerThrottlingDataId,
                @NonNull DisplayDeviceConfig displayDeviceConfig,
                int width,
@@ -345,7 +358,7 @@ public class BrightnessClamperController {
            return mUniqueDisplayId;
        }

        @NonNull
        @Nullable
        @Override
        public String getThermalThrottlingDataId() {
            return mThermalThrottlingDataId;
@@ -354,6 +367,9 @@ public class BrightnessClamperController {
        @Nullable
        @Override
        public ThermalBrightnessThrottlingData getThermalBrightnessThrottlingData() {
            if (mThermalThrottlingDataId == null) {
                return null;
            }
            return mDisplayDeviceConfig.getThermalBrightnessThrottlingDataMapByThrottlingId().get(
                    mThermalThrottlingDataId);
        }
+1 −1
Original line number Diff line number Diff line
@@ -347,7 +347,7 @@ class BrightnessThermalModifier implements BrightnessStateModifier,
        @NonNull
        String getUniqueDisplayId();

        @NonNull
        @Nullable
        String getThermalThrottlingDataId();

        @Nullable
Loading