Remove experimental twilight-based automatic brightness

Bug: 31602449
Test: verified adaptive brightness no longer varies with twilight with
"brightness_use_twilight" set to "1".

Merged-In: I6b5f7310020b2128c2b292414a205b6052270a0a
Change-Id: Ife9bf6d0f76df791cb7e6a22505d9f551da19731
This commit is contained in:
Justin Klaassen
2017-02-02 09:02:35 -08:00
parent c01308a03c
commit 614f40ea01
6 changed files with 4 additions and 80 deletions

View File

@@ -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) {

View File

@@ -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>

View File

@@ -6272,12 +6272,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 ':'.

View File

@@ -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();

View File

@@ -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.

View File

@@ -504,9 +504,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;
@@ -677,9 +674,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) {
@@ -801,9 +795,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,
@@ -2154,7 +2145,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;