Merge changes I93374f42,I0a1ae320 into sc-v2-dev
* changes: Apply screen off brightness clamp when going to sleep. Improve brightness handling during screen off timeout.
This commit is contained in:
@@ -1388,6 +1388,12 @@
|
|||||||
<integer name="config_screenBrightnessDim">10</integer>
|
<integer name="config_screenBrightnessDim">10</integer>
|
||||||
<item name="config_screenBrightnessDimFloat" format="float" type="dimen">0.05</item>
|
<item name="config_screenBrightnessDimFloat" format="float" type="dimen">0.05</item>
|
||||||
|
|
||||||
|
<!-- If the screen brightness is already set at or below config_screenBrightnessDim, and the
|
||||||
|
user activity timeout expires, we still want to dim the screen slightly to indicate that
|
||||||
|
the device is about to go to sleep. The screen will dim by this amount in that case.
|
||||||
|
-->
|
||||||
|
<item name="config_screenBrightnessMinimumDimAmountFloat" format="float" type="dimen">0.04</item>
|
||||||
|
|
||||||
<!-- Minimum allowable screen brightness to use in a very dark room.
|
<!-- Minimum allowable screen brightness to use in a very dark room.
|
||||||
This value sets the floor for the darkest possible auto-brightness
|
This value sets the floor for the darkest possible auto-brightness
|
||||||
adjustment. It is expected to be somewhat less than the first entry in
|
adjustment. It is expected to be somewhat less than the first entry in
|
||||||
|
|||||||
@@ -2040,6 +2040,7 @@
|
|||||||
<java-symbol type="dimen" name="config_screenBrightnessSettingDefaultFloat" />
|
<java-symbol type="dimen" name="config_screenBrightnessSettingDefaultFloat" />
|
||||||
<java-symbol type="dimen" name="config_screenBrightnessDozeFloat" />
|
<java-symbol type="dimen" name="config_screenBrightnessDozeFloat" />
|
||||||
<java-symbol type="dimen" name="config_screenBrightnessDimFloat" />
|
<java-symbol type="dimen" name="config_screenBrightnessDimFloat" />
|
||||||
|
<java-symbol type="dimen" name="config_screenBrightnessMinimumDimAmountFloat" />
|
||||||
<java-symbol type="integer" name="config_screenBrightnessDark" />
|
<java-symbol type="integer" name="config_screenBrightnessDark" />
|
||||||
<java-symbol type="integer" name="config_screenBrightnessDim" />
|
<java-symbol type="integer" name="config_screenBrightnessDim" />
|
||||||
<java-symbol type="integer" name="config_screenBrightnessDoze" />
|
<java-symbol type="integer" name="config_screenBrightnessDoze" />
|
||||||
|
|||||||
@@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
package com.android.systemui.doze;
|
package com.android.systemui.doze;
|
||||||
|
|
||||||
|
import static android.os.PowerManager.GO_TO_SLEEP_REASON_TIMEOUT;
|
||||||
|
|
||||||
|
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -31,11 +35,13 @@ import android.os.UserHandle;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.IndentingPrintWriter;
|
import android.util.IndentingPrintWriter;
|
||||||
|
|
||||||
|
import com.android.internal.R;
|
||||||
import com.android.systemui.doze.dagger.BrightnessSensor;
|
import com.android.systemui.doze.dagger.BrightnessSensor;
|
||||||
import com.android.systemui.doze.dagger.DozeScope;
|
import com.android.systemui.doze.dagger.DozeScope;
|
||||||
import com.android.systemui.doze.dagger.WrappedService;
|
import com.android.systemui.doze.dagger.WrappedService;
|
||||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||||
import com.android.systemui.statusbar.phone.DozeParameters;
|
import com.android.systemui.statusbar.phone.DozeParameters;
|
||||||
|
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;
|
||||||
import com.android.systemui.statusbar.policy.DevicePostureController;
|
import com.android.systemui.statusbar.policy.DevicePostureController;
|
||||||
import com.android.systemui.util.sensors.AsyncSensorManager;
|
import com.android.systemui.util.sensors.AsyncSensorManager;
|
||||||
|
|
||||||
@@ -57,6 +63,12 @@ public class DozeScreenBrightness extends BroadcastReceiver implements DozeMachi
|
|||||||
"com.android.systemui.doze.AOD_BRIGHTNESS";
|
"com.android.systemui.doze.AOD_BRIGHTNESS";
|
||||||
protected static final String BRIGHTNESS_BUCKET = "brightness_bucket";
|
protected static final String BRIGHTNESS_BUCKET = "brightness_bucket";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Just before the screen times out from user inactivity, DisplayPowerController dims the screen
|
||||||
|
* brightness to the lower of {@link #mScreenBrightnessDim}, or the current brightness minus
|
||||||
|
* this amount.
|
||||||
|
*/
|
||||||
|
private final float mScreenBrightnessMinimumDimAmountFloat;
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final DozeMachine.Service mDozeService;
|
private final DozeMachine.Service mDozeService;
|
||||||
private final DozeHost mDozeHost;
|
private final DozeHost mDozeHost;
|
||||||
@@ -87,6 +99,8 @@ public class DozeScreenBrightness extends BroadcastReceiver implements DozeMachi
|
|||||||
*/
|
*/
|
||||||
private int mDebugBrightnessBucket = -1;
|
private int mDebugBrightnessBucket = -1;
|
||||||
|
|
||||||
|
private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DozeScreenBrightness(
|
public DozeScreenBrightness(
|
||||||
Context context,
|
Context context,
|
||||||
@@ -98,8 +112,8 @@ public class DozeScreenBrightness extends BroadcastReceiver implements DozeMachi
|
|||||||
WakefulnessLifecycle wakefulnessLifecycle,
|
WakefulnessLifecycle wakefulnessLifecycle,
|
||||||
DozeParameters dozeParameters,
|
DozeParameters dozeParameters,
|
||||||
DevicePostureController devicePostureController,
|
DevicePostureController devicePostureController,
|
||||||
DozeLog dozeLog
|
DozeLog dozeLog,
|
||||||
) {
|
UnlockedScreenOffAnimationController unlockedScreenOffAnimationController) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mDozeService = service;
|
mDozeService = service;
|
||||||
mSensorManager = sensorManager;
|
mSensorManager = sensorManager;
|
||||||
@@ -111,6 +125,10 @@ public class DozeScreenBrightness extends BroadcastReceiver implements DozeMachi
|
|||||||
mDozeHost = host;
|
mDozeHost = host;
|
||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
mDozeLog = dozeLog;
|
mDozeLog = dozeLog;
|
||||||
|
mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
|
||||||
|
|
||||||
|
mScreenBrightnessMinimumDimAmountFloat = context.getResources().getFloat(
|
||||||
|
R.dimen.config_screenBrightnessMinimumDimAmountFloat);
|
||||||
|
|
||||||
mDefaultDozeBrightness = alwaysOnDisplayPolicy.defaultDozeBrightness;
|
mDefaultDozeBrightness = alwaysOnDisplayPolicy.defaultDozeBrightness;
|
||||||
mScreenBrightnessDim = alwaysOnDisplayPolicy.dimBrightness;
|
mScreenBrightnessDim = alwaysOnDisplayPolicy.dimBrightness;
|
||||||
@@ -163,14 +181,15 @@ public class DozeScreenBrightness extends BroadcastReceiver implements DozeMachi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBrightnessAndReady(boolean force) {
|
public void updateBrightnessAndReady(boolean force) {
|
||||||
if (force || mRegistered || mDebugBrightnessBucket != -1) {
|
if (force || mRegistered || mDebugBrightnessBucket != -1) {
|
||||||
int sensorValue = mDebugBrightnessBucket == -1
|
int sensorValue = mDebugBrightnessBucket == -1
|
||||||
? mLastSensorValue : mDebugBrightnessBucket;
|
? mLastSensorValue : mDebugBrightnessBucket;
|
||||||
int brightness = computeBrightness(sensorValue);
|
int brightness = computeBrightness(sensorValue);
|
||||||
boolean brightnessReady = brightness > 0;
|
boolean brightnessReady = brightness > 0;
|
||||||
if (brightnessReady) {
|
if (brightnessReady) {
|
||||||
mDozeService.setDozeScreenBrightness(clampToUserSetting(brightness));
|
mDozeService.setDozeScreenBrightness(
|
||||||
|
clampToDimBrightnessForScreenOff(clampToUserSetting(brightness)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int scrimOpacity = -1;
|
int scrimOpacity = -1;
|
||||||
@@ -243,13 +262,24 @@ public class DozeScreenBrightness extends BroadcastReceiver implements DozeMachi
|
|||||||
/**
|
/**
|
||||||
* Clamp the brightness to the dim brightness value used by PowerManagerService just before the
|
* Clamp the brightness to the dim brightness value used by PowerManagerService just before the
|
||||||
* device times out and goes to sleep, if we are sleeping from a timeout. This ensures that we
|
* device times out and goes to sleep, if we are sleeping from a timeout. This ensures that we
|
||||||
* don't raise the brightness back to the user setting before playing the screen off animation.
|
* don't raise the brightness back to the user setting before or during the screen off
|
||||||
|
* animation.
|
||||||
*/
|
*/
|
||||||
private int clampToDimBrightnessForScreenOff(int brightness) {
|
private int clampToDimBrightnessForScreenOff(int brightness) {
|
||||||
if (mDozeParameters.shouldControlUnlockedScreenOff()
|
final boolean screenTurningOff =
|
||||||
&& mWakefulnessLifecycle.getLastSleepReason()
|
mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()
|
||||||
== PowerManager.GO_TO_SLEEP_REASON_TIMEOUT) {
|
|| mWakefulnessLifecycle.getWakefulness() == WAKEFULNESS_GOING_TO_SLEEP;
|
||||||
return Math.min(mScreenBrightnessDim, brightness);
|
if (screenTurningOff
|
||||||
|
&& mWakefulnessLifecycle.getLastSleepReason() == GO_TO_SLEEP_REASON_TIMEOUT) {
|
||||||
|
return Math.max(
|
||||||
|
PowerManager.BRIGHTNESS_OFF,
|
||||||
|
// Use the lower of either the dim brightness, or the current brightness reduced
|
||||||
|
// by the minimum dim amount. This is the same logic used in
|
||||||
|
// DisplayPowerController#updatePowerState to apply a minimum dim amount.
|
||||||
|
Math.min(
|
||||||
|
brightness - (int) Math.floor(
|
||||||
|
mScreenBrightnessMinimumDimAmountFloat * 255),
|
||||||
|
mScreenBrightnessDim));
|
||||||
} else {
|
} else {
|
||||||
return brightness;
|
return brightness;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ public class DozeScreenState implements DozeMachine.Part {
|
|||||||
private final Provider<UdfpsController> mUdfpsControllerProvider;
|
private final Provider<UdfpsController> mUdfpsControllerProvider;
|
||||||
@Nullable private UdfpsController mUdfpsController;
|
@Nullable private UdfpsController mUdfpsController;
|
||||||
private final DozeLog mDozeLog;
|
private final DozeLog mDozeLog;
|
||||||
|
private final DozeScreenBrightness mDozeScreenBrightness;
|
||||||
|
|
||||||
private int mPendingScreenState = Display.STATE_UNKNOWN;
|
private int mPendingScreenState = Display.STATE_UNKNOWN;
|
||||||
private SettableWakeLock mWakeLock;
|
private SettableWakeLock mWakeLock;
|
||||||
@@ -90,7 +91,8 @@ public class DozeScreenState implements DozeMachine.Part {
|
|||||||
WakeLock wakeLock,
|
WakeLock wakeLock,
|
||||||
AuthController authController,
|
AuthController authController,
|
||||||
Provider<UdfpsController> udfpsControllerProvider,
|
Provider<UdfpsController> udfpsControllerProvider,
|
||||||
DozeLog dozeLog) {
|
DozeLog dozeLog,
|
||||||
|
DozeScreenBrightness dozeScreenBrightness) {
|
||||||
mDozeService = service;
|
mDozeService = service;
|
||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
mParameters = parameters;
|
mParameters = parameters;
|
||||||
@@ -99,6 +101,7 @@ public class DozeScreenState implements DozeMachine.Part {
|
|||||||
mAuthController = authController;
|
mAuthController = authController;
|
||||||
mUdfpsControllerProvider = udfpsControllerProvider;
|
mUdfpsControllerProvider = udfpsControllerProvider;
|
||||||
mDozeLog = dozeLog;
|
mDozeLog = dozeLog;
|
||||||
|
mDozeScreenBrightness = dozeScreenBrightness;
|
||||||
|
|
||||||
updateUdfpsController();
|
updateUdfpsController();
|
||||||
if (mUdfpsController == null) {
|
if (mUdfpsController == null) {
|
||||||
@@ -209,6 +212,12 @@ public class DozeScreenState implements DozeMachine.Part {
|
|||||||
if (screenState != Display.STATE_UNKNOWN) {
|
if (screenState != Display.STATE_UNKNOWN) {
|
||||||
if (DEBUG) Log.d(TAG, "setDozeScreenState(" + screenState + ")");
|
if (DEBUG) Log.d(TAG, "setDozeScreenState(" + screenState + ")");
|
||||||
mDozeService.setDozeScreenState(screenState);
|
mDozeService.setDozeScreenState(screenState);
|
||||||
|
if (screenState == Display.STATE_DOZE) {
|
||||||
|
// If we're entering doze, update the doze screen brightness. We might have been
|
||||||
|
// clamping it to the dim brightness during the screen off animation, and we should
|
||||||
|
// now change it to the brightness we actually want according to the sensor.
|
||||||
|
mDozeScreenBrightness.updateBrightnessAndReady(false /* force */);
|
||||||
|
}
|
||||||
mPendingScreenState = Display.STATE_UNKNOWN;
|
mPendingScreenState = Display.STATE_UNKNOWN;
|
||||||
mWakeLock.setAcquired(false);
|
mWakeLock.setAcquired(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import com.android.systemui.SysuiTestCase;
|
|||||||
import com.android.systemui.dock.DockManager;
|
import com.android.systemui.dock.DockManager;
|
||||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||||
import com.android.systemui.statusbar.phone.DozeParameters;
|
import com.android.systemui.statusbar.phone.DozeParameters;
|
||||||
|
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;
|
||||||
import com.android.systemui.statusbar.policy.DevicePostureController;
|
import com.android.systemui.statusbar.policy.DevicePostureController;
|
||||||
import com.android.systemui.util.concurrency.FakeExecutor;
|
import com.android.systemui.util.concurrency.FakeExecutor;
|
||||||
import com.android.systemui.util.concurrency.FakeThreadFactory;
|
import com.android.systemui.util.concurrency.FakeThreadFactory;
|
||||||
@@ -93,6 +94,8 @@ public class DozeScreenBrightnessTest extends SysuiTestCase {
|
|||||||
DevicePostureController mDevicePostureController;
|
DevicePostureController mDevicePostureController;
|
||||||
@Mock
|
@Mock
|
||||||
DozeLog mDozeLog;
|
DozeLog mDozeLog;
|
||||||
|
@Mock
|
||||||
|
private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
|
||||||
private FakeExecutor mFakeExecutor = new FakeExecutor(new FakeSystemClock());
|
private FakeExecutor mFakeExecutor = new FakeExecutor(new FakeSystemClock());
|
||||||
private FakeThreadFactory mFakeThreadFactory = new FakeThreadFactory(mFakeExecutor);
|
private FakeThreadFactory mFakeThreadFactory = new FakeThreadFactory(mFakeExecutor);
|
||||||
|
|
||||||
@@ -130,7 +133,8 @@ public class DozeScreenBrightnessTest extends SysuiTestCase {
|
|||||||
mWakefulnessLifecycle,
|
mWakefulnessLifecycle,
|
||||||
mDozeParameters,
|
mDozeParameters,
|
||||||
mDevicePostureController,
|
mDevicePostureController,
|
||||||
mDozeLog);
|
mDozeLog,
|
||||||
|
mUnlockedScreenOffAnimationController);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -236,7 +240,8 @@ public class DozeScreenBrightnessTest extends SysuiTestCase {
|
|||||||
mWakefulnessLifecycle,
|
mWakefulnessLifecycle,
|
||||||
mDozeParameters,
|
mDozeParameters,
|
||||||
mDevicePostureController,
|
mDevicePostureController,
|
||||||
mDozeLog);
|
mDozeLog,
|
||||||
|
mUnlockedScreenOffAnimationController);
|
||||||
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
||||||
mScreen.transitionTo(INITIALIZED, DOZE);
|
mScreen.transitionTo(INITIALIZED, DOZE);
|
||||||
reset(mDozeHost);
|
reset(mDozeHost);
|
||||||
@@ -273,7 +278,8 @@ public class DozeScreenBrightnessTest extends SysuiTestCase {
|
|||||||
mWakefulnessLifecycle,
|
mWakefulnessLifecycle,
|
||||||
mDozeParameters,
|
mDozeParameters,
|
||||||
mDevicePostureController,
|
mDevicePostureController,
|
||||||
mDozeLog);
|
mDozeLog,
|
||||||
|
mUnlockedScreenOffAnimationController);
|
||||||
|
|
||||||
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
||||||
mScreen.transitionTo(INITIALIZED, DOZE_AOD);
|
mScreen.transitionTo(INITIALIZED, DOZE_AOD);
|
||||||
@@ -304,7 +310,8 @@ public class DozeScreenBrightnessTest extends SysuiTestCase {
|
|||||||
mWakefulnessLifecycle,
|
mWakefulnessLifecycle,
|
||||||
mDozeParameters,
|
mDozeParameters,
|
||||||
mDevicePostureController,
|
mDevicePostureController,
|
||||||
mDozeLog);
|
mDozeLog,
|
||||||
|
mUnlockedScreenOffAnimationController);
|
||||||
|
|
||||||
// GIVEN the device is in AOD
|
// GIVEN the device is in AOD
|
||||||
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
||||||
@@ -342,7 +349,8 @@ public class DozeScreenBrightnessTest extends SysuiTestCase {
|
|||||||
mWakefulnessLifecycle,
|
mWakefulnessLifecycle,
|
||||||
mDozeParameters,
|
mDozeParameters,
|
||||||
mDevicePostureController,
|
mDevicePostureController,
|
||||||
mDozeLog);
|
mDozeLog,
|
||||||
|
mUnlockedScreenOffAnimationController);
|
||||||
|
|
||||||
// GIVEN device is in AOD
|
// GIVEN device is in AOD
|
||||||
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
||||||
@@ -384,7 +392,8 @@ public class DozeScreenBrightnessTest extends SysuiTestCase {
|
|||||||
mWakefulnessLifecycle,
|
mWakefulnessLifecycle,
|
||||||
mDozeParameters,
|
mDozeParameters,
|
||||||
mDevicePostureController,
|
mDevicePostureController,
|
||||||
mDozeLog);
|
mDozeLog,
|
||||||
|
mUnlockedScreenOffAnimationController);
|
||||||
verify(mDevicePostureController).addCallback(postureCallbackCaptor.capture());
|
verify(mDevicePostureController).addCallback(postureCallbackCaptor.capture());
|
||||||
|
|
||||||
// GIVEN device is in AOD
|
// GIVEN device is in AOD
|
||||||
@@ -466,24 +475,26 @@ public class DozeScreenBrightnessTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void transitionToDoze_duringScreenOff_afterTimeout_clampsToDim() {
|
public void transitionToDoze_duringUnlockedScreenOff_afterTimeout_clampsToDim() {
|
||||||
when(mWakefulnessLifecycle.getLastSleepReason()).thenReturn(
|
when(mWakefulnessLifecycle.getLastSleepReason()).thenReturn(
|
||||||
PowerManager.GO_TO_SLEEP_REASON_TIMEOUT);
|
PowerManager.GO_TO_SLEEP_REASON_TIMEOUT);
|
||||||
when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(true);
|
when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(true);
|
||||||
|
when(mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()).thenReturn(true);
|
||||||
|
|
||||||
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
||||||
mScreen.transitionTo(INITIALIZED, DOZE);
|
mScreen.transitionTo(INITIALIZED, DOZE);
|
||||||
|
|
||||||
// If we're dozing after a timeout, and playing the unlocked screen animation, we should
|
// If we're dozing after a timeout, and playing the unlocked screen animation, we should
|
||||||
// stay at dim brightness, because the screen dims just before timeout.
|
// stay at or below dim brightness, because the screen dims just before timeout.
|
||||||
assertEquals(mServiceFake.screenBrightness, DIM_BRIGHTNESS);
|
assertTrue(mServiceFake.screenBrightness <= DIM_BRIGHTNESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void transitionToDoze_duringScreenOff_notAfterTimeout_doesNotClampToDim() {
|
public void transitionToDoze_duringUnlockedScreenOff_notAfterTimeout_doesNotClampToDim() {
|
||||||
when(mWakefulnessLifecycle.getLastSleepReason()).thenReturn(
|
when(mWakefulnessLifecycle.getLastSleepReason()).thenReturn(
|
||||||
PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON);
|
PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON);
|
||||||
when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(true);
|
when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(true);
|
||||||
|
when(mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()).thenReturn(true);
|
||||||
|
|
||||||
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
||||||
mScreen.transitionTo(INITIALIZED, DOZE);
|
mScreen.transitionTo(INITIALIZED, DOZE);
|
||||||
@@ -494,10 +505,11 @@ public class DozeScreenBrightnessTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void transitionToDoze_duringScreenOff_afterTimeout_noScreenOff_doesNotClampToDim() {
|
public void transitionToDoze_duringUnlockedScreenOff_afterTimeout_noScreenOff_doesNotClampToDim() {
|
||||||
when(mWakefulnessLifecycle.getLastSleepReason()).thenReturn(
|
when(mWakefulnessLifecycle.getLastSleepReason()).thenReturn(
|
||||||
PowerManager.GO_TO_SLEEP_REASON_TIMEOUT);
|
PowerManager.GO_TO_SLEEP_REASON_TIMEOUT);
|
||||||
when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(false);
|
when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(false);
|
||||||
|
when(mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()).thenReturn(false);
|
||||||
|
|
||||||
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
||||||
mScreen.transitionTo(INITIALIZED, DOZE);
|
mScreen.transitionTo(INITIALIZED, DOZE);
|
||||||
@@ -506,6 +518,36 @@ public class DozeScreenBrightnessTest extends SysuiTestCase {
|
|||||||
assertEquals(mServiceFake.screenBrightness, DEFAULT_BRIGHTNESS);
|
assertEquals(mServiceFake.screenBrightness, DEFAULT_BRIGHTNESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void transitionToDoze_duringLockedScreenOff_afterTimeout_clampsToDim() {
|
||||||
|
when(mWakefulnessLifecycle.getLastSleepReason()).thenReturn(
|
||||||
|
PowerManager.GO_TO_SLEEP_REASON_TIMEOUT);
|
||||||
|
when(mWakefulnessLifecycle.getWakefulness()).thenReturn(
|
||||||
|
WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP);
|
||||||
|
when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(false);
|
||||||
|
when(mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()).thenReturn(false);
|
||||||
|
|
||||||
|
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
||||||
|
mScreen.transitionTo(INITIALIZED, DOZE);
|
||||||
|
|
||||||
|
assertTrue(mServiceFake.screenBrightness <= DIM_BRIGHTNESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void transitionToDoze_duringLockedScreenOff_notAfterTimeout_doesNotClampToDim() {
|
||||||
|
when(mWakefulnessLifecycle.getLastSleepReason()).thenReturn(
|
||||||
|
PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON);
|
||||||
|
when(mWakefulnessLifecycle.getWakefulness()).thenReturn(
|
||||||
|
WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP);
|
||||||
|
when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(false);
|
||||||
|
when(mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()).thenReturn(false);
|
||||||
|
|
||||||
|
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
||||||
|
mScreen.transitionTo(INITIALIZED, DOZE);
|
||||||
|
|
||||||
|
assertEquals(mServiceFake.screenBrightness, DEFAULT_BRIGHTNESS);
|
||||||
|
}
|
||||||
|
|
||||||
private void waitForSensorManager() {
|
private void waitForSensorManager() {
|
||||||
mFakeExecutor.runAllReady();
|
mFakeExecutor.runAllReady();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ public class DozeScreenStateTest extends SysuiTestCase {
|
|||||||
private UdfpsController mUdfpsController;
|
private UdfpsController mUdfpsController;
|
||||||
@Mock
|
@Mock
|
||||||
private DozeLog mDozeLog;
|
private DozeLog mDozeLog;
|
||||||
|
@Mock
|
||||||
|
private DozeScreenBrightness mDozeScreenBrightness;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@@ -96,7 +98,8 @@ public class DozeScreenStateTest extends SysuiTestCase {
|
|||||||
mHandlerFake = new FakeHandler(Looper.getMainLooper());
|
mHandlerFake = new FakeHandler(Looper.getMainLooper());
|
||||||
mWakeLock = new WakeLockFake();
|
mWakeLock = new WakeLockFake();
|
||||||
mScreen = new DozeScreenState(mServiceFake, mHandlerFake, mDozeHost, mDozeParameters,
|
mScreen = new DozeScreenState(mServiceFake, mHandlerFake, mDozeHost, mDozeParameters,
|
||||||
mWakeLock, mAuthController, mUdfpsControllerProvider, mDozeLog);
|
mWakeLock, mAuthController, mUdfpsControllerProvider, mDozeLog,
|
||||||
|
mDozeScreenBrightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -108,8 +108,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
// screen state returns. Playing the animation can also be somewhat slow.
|
// screen state returns. Playing the animation can also be somewhat slow.
|
||||||
private static final boolean USE_COLOR_FADE_ON_ANIMATION = false;
|
private static final boolean USE_COLOR_FADE_ON_ANIMATION = false;
|
||||||
|
|
||||||
// The minimum reduction in brightness when dimmed.
|
|
||||||
private static final float SCREEN_DIM_MINIMUM_REDUCTION_FLOAT = 0.04f;
|
|
||||||
private static final float SCREEN_ANIMATION_RATE_MINIMUM = 0.0f;
|
private static final float SCREEN_ANIMATION_RATE_MINIMUM = 0.0f;
|
||||||
|
|
||||||
private static final int COLOR_FADE_ON_ANIMATION_DURATION_MILLIS = 250;
|
private static final int COLOR_FADE_ON_ANIMATION_DURATION_MILLIS = 250;
|
||||||
@@ -200,6 +198,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
// The dim screen brightness.
|
// The dim screen brightness.
|
||||||
private final float mScreenBrightnessDimConfig;
|
private final float mScreenBrightnessDimConfig;
|
||||||
|
|
||||||
|
// The minimum dim amount to use if the screen brightness is already below
|
||||||
|
// mScreenBrightnessDimConfig.
|
||||||
|
private final float mScreenBrightnessMinimumDimAmount;
|
||||||
|
|
||||||
private final float mScreenBrightnessDefault;
|
private final float mScreenBrightnessDefault;
|
||||||
|
|
||||||
// The minimum allowed brightness while in VR.
|
// The minimum allowed brightness while in VR.
|
||||||
@@ -485,6 +487,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
pm.getBrightnessConstraint(PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DOZE));
|
pm.getBrightnessConstraint(PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DOZE));
|
||||||
mScreenBrightnessDimConfig = clampAbsoluteBrightness(
|
mScreenBrightnessDimConfig = clampAbsoluteBrightness(
|
||||||
pm.getBrightnessConstraint(PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DIM));
|
pm.getBrightnessConstraint(PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DIM));
|
||||||
|
mScreenBrightnessMinimumDimAmount = resources.getFloat(
|
||||||
|
com.android.internal.R.dimen.config_screenBrightnessMinimumDimAmountFloat);
|
||||||
|
|
||||||
|
|
||||||
// NORMAL SCREEN SETTINGS
|
// NORMAL SCREEN SETTINGS
|
||||||
mScreenBrightnessDefault = clampAbsoluteBrightness(
|
mScreenBrightnessDefault = clampAbsoluteBrightness(
|
||||||
@@ -1284,7 +1289,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
if (mPowerRequest.policy == DisplayPowerRequest.POLICY_DIM) {
|
if (mPowerRequest.policy == DisplayPowerRequest.POLICY_DIM) {
|
||||||
if (brightnessState > PowerManager.BRIGHTNESS_MIN) {
|
if (brightnessState > PowerManager.BRIGHTNESS_MIN) {
|
||||||
brightnessState = Math.max(
|
brightnessState = Math.max(
|
||||||
Math.min(brightnessState - SCREEN_DIM_MINIMUM_REDUCTION_FLOAT,
|
Math.min(brightnessState - mScreenBrightnessMinimumDimAmount,
|
||||||
mScreenBrightnessDimConfig),
|
mScreenBrightnessDimConfig),
|
||||||
PowerManager.BRIGHTNESS_MIN);
|
PowerManager.BRIGHTNESS_MIN);
|
||||||
mBrightnessReasonTemp.addModifier(BrightnessReason.MODIFIER_DIMMED);
|
mBrightnessReasonTemp.addModifier(BrightnessReason.MODIFIER_DIMMED);
|
||||||
|
|||||||
Reference in New Issue
Block a user