Remove experimental twilight-based automatic brightness
Bug: 31602449 Test: verified adaptive brightness no longer varies with twilight with "brightness_use_twilight" set to "1". Change-Id: I6b5f7310020b2128c2b292414a205b6052270a0a
This commit is contained in:
@@ -230,9 +230,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;
|
||||
@@ -268,7 +265,6 @@ public abstract class DisplayManagerInternal {
|
||||
boostScreenBrightness = other.boostScreenBrightness;
|
||||
dozeScreenBrightness = other.dozeScreenBrightness;
|
||||
dozeScreenState = other.dozeScreenState;
|
||||
useTwilight = other.useTwilight;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -289,8 +285,7 @@ public abstract class DisplayManagerInternal {
|
||||
&& lowPowerMode == other.lowPowerMode
|
||||
&& boostScreenBrightness == other.boostScreenBrightness
|
||||
&& dozeScreenBrightness == other.dozeScreenBrightness
|
||||
&& dozeScreenState == other.dozeScreenState
|
||||
&& useTwilight == other.useTwilight;
|
||||
&& dozeScreenState == other.dozeScreenState;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -310,8 +305,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) {
|
||||
|
||||
@@ -507,15 +507,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>
|
||||
|
||||
@@ -6720,12 +6720,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 ':'.
|
||||
|
||||
@@ -392,7 +392,6 @@ public class SettingsTest {
|
||||
Settings.Secure.BACKUP_PROVISIONED,
|
||||
Settings.Secure.BACKUP_TRANSPORT,
|
||||
Settings.Secure.BLUETOOTH_HCI_LOG,
|
||||
Settings.Secure.BRIGHTNESS_USE_TWILIGHT, // Candidate for backup?
|
||||
Settings.Secure.CARRIER_APPS_HANDLED,
|
||||
Settings.Secure.COMPLETED_CATEGORY_PREFIX,
|
||||
Settings.Secure.CONNECTIVITY_RELEASE_PENDING_INTENT_DELAY_MS,
|
||||
|
||||
@@ -1398,9 +1398,6 @@ class SettingsProtoDumpUtil {
|
||||
dumpSetting(s, p,
|
||||
Settings.Secure.NIGHT_DISPLAY_CUSTOM_END_TIME,
|
||||
SecureSettingsProto.NIGHT_DISPLAY_CUSTOM_END_TIME);
|
||||
dumpSetting(s, p,
|
||||
Settings.Secure.BRIGHTNESS_USE_TWILIGHT,
|
||||
SecureSettingsProto.BRIGHTNESS_USE_TWILIGHT);
|
||||
dumpSetting(s, p,
|
||||
Settings.Secure.ENABLED_VR_LISTENERS,
|
||||
SecureSettingsProto.ENABLED_VR_LISTENERS);
|
||||
|
||||
@@ -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;
|
||||
@@ -186,8 +177,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,
|
||||
@@ -196,7 +185,6 @@ class AutomaticBrightnessController {
|
||||
int ambientLightHorizon, float autoBrightnessAdjustmentMaxGamma,
|
||||
HysteresisLevels dynamicHysteresis) {
|
||||
mCallbacks = callbacks;
|
||||
mTwilight = LocalServices.getService(TwilightManager.class);
|
||||
mSensorManager = sensorManager;
|
||||
mScreenAutoBrightnessSpline = autoBrightnessSpline;
|
||||
mScreenBrightnessRangeMinimum = brightnessMin;
|
||||
@@ -233,7 +221,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
|
||||
@@ -242,7 +230,6 @@ class AutomaticBrightnessController {
|
||||
mDozing = dozing;
|
||||
boolean changed = setLightSensorEnabled(enable && !dozing);
|
||||
changed |= setScreenAutoBrightnessAdjustment(adjustment);
|
||||
changed |= setUseTwilight(useTwilight);
|
||||
if (changed) {
|
||||
updateAutoBrightness(false /*sendUpdate*/);
|
||||
}
|
||||
@@ -251,17 +238,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:");
|
||||
@@ -276,7 +252,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);
|
||||
@@ -522,19 +497,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);
|
||||
@@ -649,13 +611,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();
|
||||
|
||||
@@ -642,7 +642,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.
|
||||
|
||||
@@ -517,9 +517,6 @@ public final class PowerManagerService extends SystemService
|
||||
private final ArrayList<PowerManagerInternal.LowPowerModeListener> mLowPowerModeListeners
|
||||
= new ArrayList<PowerManagerInternal.LowPowerModeListener>();
|
||||
|
||||
// True if brightness should be affected by twilight.
|
||||
private boolean mBrightnessUseTwilight;
|
||||
|
||||
// True if we are currently in VR Mode.
|
||||
private boolean mIsVrModeEnabled;
|
||||
|
||||
@@ -735,9 +732,6 @@ public final class PowerManagerService extends SystemService
|
||||
resolver.registerContentObserver(Settings.Secure.getUriFor(
|
||||
Settings.Secure.DOUBLE_TAP_TO_WAKE),
|
||||
false, mSettingsObserver, UserHandle.USER_ALL);
|
||||
resolver.registerContentObserver(Settings.Secure.getUriFor(
|
||||
Secure.BRIGHTNESS_USE_TWILIGHT),
|
||||
false, mSettingsObserver, UserHandle.USER_ALL);
|
||||
IVrManager vrManager =
|
||||
(IVrManager) getBinderService(VrManagerService.VR_MANAGER_BINDER_SERVICE);
|
||||
if (vrManager != null) {
|
||||
@@ -878,9 +872,6 @@ public final class PowerManagerService extends SystemService
|
||||
Settings.System.SCREEN_BRIGHTNESS_MODE,
|
||||
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, UserHandle.USER_CURRENT);
|
||||
|
||||
mBrightnessUseTwilight = Settings.Secure.getIntForUser(resolver,
|
||||
Secure.BRIGHTNESS_USE_TWILIGHT, 0, UserHandle.USER_CURRENT) != 0;
|
||||
|
||||
final boolean lowPowerModeEnabled = Settings.Global.getInt(resolver,
|
||||
Settings.Global.LOW_POWER_MODE, 0) != 0;
|
||||
final boolean autoLowPowerModeConfigured = Settings.Global.getInt(resolver,
|
||||
@@ -2254,7 +2245,6 @@ public final class PowerManagerService extends SystemService
|
||||
mDisplayPowerRequest.useProximitySensor = shouldUseProximitySensorLocked();
|
||||
mDisplayPowerRequest.lowPowerMode = mLowPowerModeEnabled;
|
||||
mDisplayPowerRequest.boostScreenBrightness = shouldBoostScreenBrightness();
|
||||
mDisplayPowerRequest.useTwilight = mBrightnessUseTwilight;
|
||||
|
||||
if (mDisplayPowerRequest.policy == DisplayPowerRequest.POLICY_DOZE) {
|
||||
mDisplayPowerRequest.dozeScreenState = mDozeScreenStateOverrideFromDreamManager;
|
||||
|
||||
Reference in New Issue
Block a user