Merge "Remove experimental twilight-based automatic brightness" into nyc-mr2-dev

This commit is contained in:
TreeHugger Robot
2017-02-06 23:21:01 +00:00
committed by Android (Google) Code Review
6 changed files with 4 additions and 80 deletions

View File

@@ -213,9 +213,6 @@ public abstract class DisplayManagerInternal {
public int dozeScreenBrightness; public int dozeScreenBrightness;
public int dozeScreenState; public int dozeScreenState;
// If true, use twilight to affect the brightness.
public boolean useTwilight;
public DisplayPowerRequest() { public DisplayPowerRequest() {
policy = POLICY_BRIGHT; policy = POLICY_BRIGHT;
useProximitySensor = false; useProximitySensor = false;
@@ -251,7 +248,6 @@ public abstract class DisplayManagerInternal {
boostScreenBrightness = other.boostScreenBrightness; boostScreenBrightness = other.boostScreenBrightness;
dozeScreenBrightness = other.dozeScreenBrightness; dozeScreenBrightness = other.dozeScreenBrightness;
dozeScreenState = other.dozeScreenState; dozeScreenState = other.dozeScreenState;
useTwilight = other.useTwilight;
} }
@Override @Override
@@ -272,8 +268,7 @@ public abstract class DisplayManagerInternal {
&& lowPowerMode == other.lowPowerMode && lowPowerMode == other.lowPowerMode
&& boostScreenBrightness == other.boostScreenBrightness && boostScreenBrightness == other.boostScreenBrightness
&& dozeScreenBrightness == other.dozeScreenBrightness && dozeScreenBrightness == other.dozeScreenBrightness
&& dozeScreenState == other.dozeScreenState && dozeScreenState == other.dozeScreenState;
&& useTwilight == other.useTwilight;
} }
@Override @Override
@@ -293,8 +288,7 @@ public abstract class DisplayManagerInternal {
+ ", lowPowerMode=" + lowPowerMode + ", lowPowerMode=" + lowPowerMode
+ ", boostScreenBrightness=" + boostScreenBrightness + ", boostScreenBrightness=" + boostScreenBrightness
+ ", dozeScreenBrightness=" + dozeScreenBrightness + ", dozeScreenBrightness=" + dozeScreenBrightness
+ ", dozeScreenState=" + Display.stateToString(dozeScreenState) + ", dozeScreenState=" + Display.stateToString(dozeScreenState);
+ ", useTwilight=" + useTwilight;
} }
public static String policyToString(int policy) { public static String policyToString(int policy) {

View File

@@ -501,15 +501,6 @@ public final class PowerManager {
com.android.internal.R.integer.config_screenBrightnessForVrSettingDefault); 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. * Creates a new wake lock with the specified level and flags.
* <p> * <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"; 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 * Names of the service components that the current user has explicitly allowed to
* be a VR mode listener, separated by ':'. * 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.EventLogTags;
import com.android.server.LocalServices; 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.annotation.Nullable;
import android.hardware.Sensor; import android.hardware.Sensor;
@@ -55,9 +52,6 @@ class AutomaticBrightnessController {
// non-zero, which in turn ensures that the total weight is non-zero. // non-zero, which in turn ensures that the total weight is non-zero.
private static final long AMBIENT_LIGHT_PREDICTION_TIME_MILLIS = 100; 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 // Debounce for sampling user-initiated changes in display brightness to ensure
// the user is satisfied with the result before storing the sample. // the user is satisfied with the result before storing the sample.
private static final int BRIGHTNESS_ADJUSTMENT_SAMPLE_DEBOUNCE_MILLIS = 10000; 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. // The light sensor, or null if not available or needed.
private final Sensor mLightSensor; private final Sensor mLightSensor;
// The twilight service.
private final TwilightManager mTwilight;
// The auto-brightness spline adjustment. // The auto-brightness spline adjustment.
// The brightness values have been scaled to a range of 0..1. // The brightness values have been scaled to a range of 0..1.
private final Spline mScreenAutoBrightnessSpline; private final Spline mScreenAutoBrightnessSpline;
@@ -194,8 +185,6 @@ class AutomaticBrightnessController {
private int mBrightnessAdjustmentSampleOldBrightness; private int mBrightnessAdjustmentSampleOldBrightness;
private float mBrightnessAdjustmentSampleOldGamma; private float mBrightnessAdjustmentSampleOldGamma;
private boolean mUseTwilight;
public AutomaticBrightnessController(Callbacks callbacks, Looper looper, public AutomaticBrightnessController(Callbacks callbacks, Looper looper,
SensorManager sensorManager, Spline autoBrightnessSpline, int lightSensorWarmUpTime, SensorManager sensorManager, Spline autoBrightnessSpline, int lightSensorWarmUpTime,
int brightnessMin, int brightnessMax, float dozeScaleFactor, int brightnessMin, int brightnessMax, float dozeScaleFactor,
@@ -205,7 +194,6 @@ class AutomaticBrightnessController {
boolean activeDozeLightSensor, boolean useNewSensorSamplesForDoze, boolean activeDozeLightSensor, boolean useNewSensorSamplesForDoze,
LuxLevels luxLevels) { LuxLevels luxLevels) {
mCallbacks = callbacks; mCallbacks = callbacks;
mTwilight = LocalServices.getService(TwilightManager.class);
mSensorManager = sensorManager; mSensorManager = sensorManager;
mScreenAutoBrightnessSpline = autoBrightnessSpline; mScreenAutoBrightnessSpline = autoBrightnessSpline;
mScreenBrightnessRangeMinimum = brightnessMin; mScreenBrightnessRangeMinimum = brightnessMin;
@@ -244,7 +232,7 @@ class AutomaticBrightnessController {
} }
public void configure(boolean enable, float adjustment, boolean dozing, 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 // 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 // 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 // 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; mDozing = dozing;
boolean changed = setLightSensorEnabled(enableSensor); boolean changed = setLightSensorEnabled(enableSensor);
changed |= setScreenAutoBrightnessAdjustment(adjustment); changed |= setScreenAutoBrightnessAdjustment(adjustment);
changed |= setUseTwilight(useTwilight);
if (changed) { if (changed) {
updateAutoBrightness(false /*sendUpdate*/); 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) { public void dump(PrintWriter pw) {
pw.println(); pw.println();
pw.println("Automatic Brightness Controller Configuration:"); pw.println("Automatic Brightness Controller Configuration:");
@@ -298,7 +274,6 @@ class AutomaticBrightnessController {
pw.println(); pw.println();
pw.println("Automatic Brightness Controller State:"); pw.println("Automatic Brightness Controller State:");
pw.println(" mLightSensor=" + mLightSensor); pw.println(" mLightSensor=" + mLightSensor);
pw.println(" mTwilight.getLastTwilightState()=" + mTwilight.getLastTwilightState());
pw.println(" mLightSensorEnabled=" + mLightSensorEnabled); pw.println(" mLightSensorEnabled=" + mLightSensorEnabled);
pw.println(" mLightSensorEnableTime=" + TimeUtils.formatUptime(mLightSensorEnableTime)); pw.println(" mLightSensorEnableTime=" + TimeUtils.formatUptime(mLightSensorEnableTime));
pw.println(" mAmbientLux=" + mAmbientLux); 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) { if (gamma != 1.0f) {
final float in = value; final float in = value;
value = MathUtils.pow(value, gamma); 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. */ /** Callbacks to request updates to the display's power state. */
interface Callbacks { interface Callbacks {
void updateBrightness(); void updateBrightness();

View File

@@ -657,7 +657,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
&& mPowerRequest.brightnessSetByUser; && mPowerRequest.brightnessSetByUser;
mAutomaticBrightnessController.configure(autoBrightnessEnabled, mAutomaticBrightnessController.configure(autoBrightnessEnabled,
mPowerRequest.screenAutoBrightnessAdjustment, state != Display.STATE_ON, mPowerRequest.screenAutoBrightnessAdjustment, state != Display.STATE_ON,
userInitiatedChange, mPowerRequest.useTwilight); userInitiatedChange);
} }
// Apply brightness boost. // Apply brightness boost.

View File

@@ -504,9 +504,6 @@ public final class PowerManagerService extends SystemService
private final ArrayList<PowerManagerInternal.LowPowerModeListener> mLowPowerModeListeners private final ArrayList<PowerManagerInternal.LowPowerModeListener> mLowPowerModeListeners
= new ArrayList<PowerManagerInternal.LowPowerModeListener>(); = new ArrayList<PowerManagerInternal.LowPowerModeListener>();
// True if brightness should be affected by twilight.
private boolean mBrightnessUseTwilight;
// True if we are currently in VR Mode. // True if we are currently in VR Mode.
private boolean mIsVrModeEnabled; private boolean mIsVrModeEnabled;
@@ -677,9 +674,6 @@ public final class PowerManagerService extends SystemService
resolver.registerContentObserver(Settings.Secure.getUriFor( resolver.registerContentObserver(Settings.Secure.getUriFor(
Settings.Secure.DOUBLE_TAP_TO_WAKE), Settings.Secure.DOUBLE_TAP_TO_WAKE),
false, mSettingsObserver, UserHandle.USER_ALL); false, mSettingsObserver, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.Secure.getUriFor(
Secure.BRIGHTNESS_USE_TWILIGHT),
false, mSettingsObserver, UserHandle.USER_ALL);
IVrManager vrManager = IVrManager vrManager =
(IVrManager) getBinderService(VrManagerService.VR_MANAGER_BINDER_SERVICE); (IVrManager) getBinderService(VrManagerService.VR_MANAGER_BINDER_SERVICE);
if (vrManager != null) { if (vrManager != null) {
@@ -801,9 +795,6 @@ public final class PowerManagerService extends SystemService
Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, UserHandle.USER_CURRENT); 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, final boolean lowPowerModeEnabled = Settings.Global.getInt(resolver,
Settings.Global.LOW_POWER_MODE, 0) != 0; Settings.Global.LOW_POWER_MODE, 0) != 0;
final boolean autoLowPowerModeConfigured = Settings.Global.getInt(resolver, final boolean autoLowPowerModeConfigured = Settings.Global.getInt(resolver,
@@ -2154,7 +2145,6 @@ public final class PowerManagerService extends SystemService
mDisplayPowerRequest.useProximitySensor = shouldUseProximitySensorLocked(); mDisplayPowerRequest.useProximitySensor = shouldUseProximitySensorLocked();
mDisplayPowerRequest.lowPowerMode = mLowPowerModeEnabled; mDisplayPowerRequest.lowPowerMode = mLowPowerModeEnabled;
mDisplayPowerRequest.boostScreenBrightness = shouldBoostScreenBrightness(); mDisplayPowerRequest.boostScreenBrightness = shouldBoostScreenBrightness();
mDisplayPowerRequest.useTwilight = mBrightnessUseTwilight;
if (mDisplayPowerRequest.policy == DisplayPowerRequest.POLICY_DOZE) { if (mDisplayPowerRequest.policy == DisplayPowerRequest.POLICY_DOZE) {
mDisplayPowerRequest.dozeScreenState = mDozeScreenStateOverrideFromDreamManager; mDisplayPowerRequest.dozeScreenState = mDozeScreenStateOverrideFromDreamManager;