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

Commit 46d3d6d3 authored by Justin Klaassen's avatar Justin Klaassen Committed by android-build-merger
Browse files

Remove experimental twilight-based automatic brightness

am: 614f40ea

Change-Id: I1b0ec1645f38892adb894900b3b3725fc0b23452
parents 0eea1cf7 614f40ea
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -213,9 +213,6 @@ public abstract class DisplayManagerInternal {
        public int dozeScreenBrightness;
        public int dozeScreenState;

        // If true, use twilight to affect the brightness.
        public boolean useTwilight;

        public DisplayPowerRequest() {
            policy = POLICY_BRIGHT;
            useProximitySensor = false;
@@ -251,7 +248,6 @@ public abstract class DisplayManagerInternal {
            boostScreenBrightness = other.boostScreenBrightness;
            dozeScreenBrightness = other.dozeScreenBrightness;
            dozeScreenState = other.dozeScreenState;
            useTwilight = other.useTwilight;
        }

        @Override
@@ -272,8 +268,7 @@ public abstract class DisplayManagerInternal {
                    && lowPowerMode == other.lowPowerMode
                    && boostScreenBrightness == other.boostScreenBrightness
                    && dozeScreenBrightness == other.dozeScreenBrightness
                    && dozeScreenState == other.dozeScreenState
                    && useTwilight == other.useTwilight;
                    && dozeScreenState == other.dozeScreenState;
        }

        @Override
@@ -293,8 +288,7 @@ public abstract class DisplayManagerInternal {
                    + ", lowPowerMode=" + lowPowerMode
                    + ", boostScreenBrightness=" + boostScreenBrightness
                    + ", dozeScreenBrightness=" + dozeScreenBrightness
                    + ", dozeScreenState=" + Display.stateToString(dozeScreenState)
                    + ", useTwilight=" + useTwilight;
                    + ", dozeScreenState=" + Display.stateToString(dozeScreenState);
        }

        public static String policyToString(int policy) {
+0 −9
Original line number Diff line number Diff line
@@ -501,15 +501,6 @@ public final class PowerManager {
                com.android.internal.R.integer.config_screenBrightnessForVrSettingDefault);
    }

    /**
     * Returns true if the twilight service should be used to adjust screen brightness
     * policy.  This setting is experimental and disabled by default.
     * @hide
     */
    public static boolean useTwilightAdjustmentFeature() {
        return SystemProperties.getBoolean("persist.power.usetwilightadj", false);
    }

    /**
     * Creates a new wake lock with the specified level and flags.
     * <p>
+0 −6
Original line number Diff line number Diff line
@@ -6288,12 +6288,6 @@ public final class Settings {
         */
        public static final String NIGHT_DISPLAY_CUSTOM_END_TIME = "night_display_custom_end_time";

        /**
         * Whether brightness should automatically adjust based on twilight state.
         * @hide
         */
        public static final String BRIGHTNESS_USE_TWILIGHT = "brightness_use_twilight";

        /**
         * Names of the service components that the current user has explicitly allowed to
         * be a VR mode listener, separated by ':'.
+1 −46
Original line number Diff line number Diff line
@@ -18,9 +18,6 @@ package com.android.server.display;

import com.android.server.EventLogTags;
import com.android.server.LocalServices;
import com.android.server.twilight.TwilightListener;
import com.android.server.twilight.TwilightManager;
import com.android.server.twilight.TwilightState;

import android.annotation.Nullable;
import android.hardware.Sensor;
@@ -55,9 +52,6 @@ class AutomaticBrightnessController {
    // non-zero, which in turn ensures that the total weight is non-zero.
    private static final long AMBIENT_LIGHT_PREDICTION_TIME_MILLIS = 100;

    // Specifies the maximum magnitude of the time of day adjustment.
    private static final float TWILIGHT_ADJUSTMENT_MAX_GAMMA = 1f;

    // Debounce for sampling user-initiated changes in display brightness to ensure
    // the user is satisfied with the result before storing the sample.
    private static final int BRIGHTNESS_ADJUSTMENT_SAMPLE_DEBOUNCE_MILLIS = 10000;
@@ -74,9 +68,6 @@ class AutomaticBrightnessController {
    // The light sensor, or null if not available or needed.
    private final Sensor mLightSensor;

    // The twilight service.
    private final TwilightManager mTwilight;

    // The auto-brightness spline adjustment.
    // The brightness values have been scaled to a range of 0..1.
    private final Spline mScreenAutoBrightnessSpline;
@@ -194,8 +185,6 @@ class AutomaticBrightnessController {
    private int mBrightnessAdjustmentSampleOldBrightness;
    private float mBrightnessAdjustmentSampleOldGamma;

    private boolean mUseTwilight;

    public AutomaticBrightnessController(Callbacks callbacks, Looper looper,
            SensorManager sensorManager, Spline autoBrightnessSpline, int lightSensorWarmUpTime,
            int brightnessMin, int brightnessMax, float dozeScaleFactor,
@@ -205,7 +194,6 @@ class AutomaticBrightnessController {
            boolean activeDozeLightSensor, boolean useNewSensorSamplesForDoze,
            LuxLevels luxLevels) {
        mCallbacks = callbacks;
        mTwilight = LocalServices.getService(TwilightManager.class);
        mSensorManager = sensorManager;
        mScreenAutoBrightnessSpline = autoBrightnessSpline;
        mScreenBrightnessRangeMinimum = brightnessMin;
@@ -244,7 +232,7 @@ class AutomaticBrightnessController {
    }

    public void configure(boolean enable, float adjustment, boolean dozing,
            boolean userInitiatedChange, boolean useTwilight) {
            boolean userInitiatedChange) {
        // While dozing, the application processor may be suspended which will prevent us from
        // receiving new information from the light sensor. On some devices, we may be able to
        // switch to a wake-up light sensor instead but for now we will simply disable the sensor
@@ -264,7 +252,6 @@ class AutomaticBrightnessController {
        mDozing = dozing;
        boolean changed = setLightSensorEnabled(enableSensor);
        changed |= setScreenAutoBrightnessAdjustment(adjustment);
        changed |= setUseTwilight(useTwilight);
        if (changed) {
            updateAutoBrightness(false /*sendUpdate*/);
        }
@@ -273,17 +260,6 @@ class AutomaticBrightnessController {
        }
    }

    private boolean setUseTwilight(boolean useTwilight) {
        if (mUseTwilight == useTwilight) return false;
        if (useTwilight) {
            mTwilight.registerListener(mTwilightListener, mHandler);
        } else {
            mTwilight.unregisterListener(mTwilightListener);
        }
        mUseTwilight = useTwilight;
        return true;
    }

    public void dump(PrintWriter pw) {
        pw.println();
        pw.println("Automatic Brightness Controller Configuration:");
@@ -298,7 +274,6 @@ class AutomaticBrightnessController {
        pw.println();
        pw.println("Automatic Brightness Controller State:");
        pw.println("  mLightSensor=" + mLightSensor);
        pw.println("  mTwilight.getLastTwilightState()=" + mTwilight.getLastTwilightState());
        pw.println("  mLightSensorEnabled=" + mLightSensorEnabled);
        pw.println("  mLightSensorEnableTime=" + TimeUtils.formatUptime(mLightSensorEnableTime));
        pw.println("  mAmbientLux=" + mAmbientLux);
@@ -558,19 +533,6 @@ class AutomaticBrightnessController {
            }
        }

        if (mUseTwilight) {
            TwilightState state = mTwilight.getLastTwilightState();
            if (state != null && state.isNight()) {
                final long duration = state.sunriseTimeMillis() - state.sunsetTimeMillis();
                final long progress = System.currentTimeMillis() - state.sunsetTimeMillis();
                final float amount = (float) Math.pow(2.0 * progress / duration - 1.0, 2.0);
                gamma *= 1 + amount * TWILIGHT_ADJUSTMENT_MAX_GAMMA;
                if (DEBUG) {
                    Slog.d(TAG, "updateAutoBrightness: twilight amount=" + amount);
                }
            }
        }

        if (gamma != 1.0f) {
            final float in = value;
            value = MathUtils.pow(value, gamma);
@@ -691,13 +653,6 @@ class AutomaticBrightnessController {
        }
    };

    private final TwilightListener mTwilightListener = new TwilightListener() {
        @Override
        public void onTwilightStateChanged(@Nullable TwilightState state) {
            updateAutoBrightness(true /*sendUpdate*/);
        }
    };

    /** Callbacks to request updates to the display's power state. */
    interface Callbacks {
        void updateBrightness();
+1 −1
Original line number Diff line number Diff line
@@ -657,7 +657,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                    && mPowerRequest.brightnessSetByUser;
            mAutomaticBrightnessController.configure(autoBrightnessEnabled,
                    mPowerRequest.screenAutoBrightnessAdjustment, state != Display.STATE_ON,
                    userInitiatedChange, mPowerRequest.useTwilight);
                    userInitiatedChange);
        }

        // Apply brightness boost.
Loading