LS sensor should wake-up the wallpaper

Change-Id: Ic383fa003667cec91a3c6b49b7354813e7ee8728
Fixes: 123535182
Test: manual
Test: atest DozeWallpaperStateTest
This commit is contained in:
Lucas Dupin
2019-01-28 14:31:40 -08:00
parent 7343460cd0
commit 023d727a9c
5 changed files with 33 additions and 12 deletions

View File

@@ -71,7 +71,7 @@ public class DozeFactory {
new DozeScreenState(wrappedService, handler, params, wakeLock),
createDozeScreenBrightness(context, wrappedService, sensorManager, host, params,
handler),
new DozeWallpaperState(context),
new DozeWallpaperState(context, machine),
new DozeDockHandler(context, machine, host, config, handler, dockManager)
});

View File

@@ -37,17 +37,20 @@ public class DozeWallpaperState implements DozeMachine.Part {
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private final IWallpaperManager mWallpaperManagerService;
private boolean mIsAmbientMode;
private final DozeParameters mDozeParameters;
private final DozeMachine mMachine;
private boolean mIsAmbientMode;
public DozeWallpaperState(Context context) {
this(IWallpaperManager.Stub.asInterface(
public DozeWallpaperState(Context context, DozeMachine machine) {
this(machine, IWallpaperManager.Stub.asInterface(
ServiceManager.getService(Context.WALLPAPER_SERVICE)),
DozeParameters.getInstance(context));
}
@VisibleForTesting
DozeWallpaperState(IWallpaperManager wallpaperManagerService, DozeParameters parameters) {
DozeWallpaperState(DozeMachine machine, IWallpaperManager wallpaperManagerService,
DozeParameters parameters) {
mMachine = machine;
mWallpaperManagerService = wallpaperManagerService;
mDozeParameters = parameters;
}
@@ -61,10 +64,13 @@ public class DozeWallpaperState implements DozeMachine.Part {
case DOZE_AOD_PAUSING:
case DOZE_AOD_PAUSED:
case DOZE_REQUEST_PULSE:
case DOZE_PULSING:
case DOZE_PULSE_DONE:
isAmbientMode = true;
break;
case DOZE_PULSING:
isAmbientMode =
mMachine.getPulseReason() != DozeLog.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN;
break;
default:
isAmbientMode = false;
}

View File

@@ -272,9 +272,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
// AOD wallpapers should fade away after a while.
// Docking pulses may take a long time, wallpapers should also fade away after a while.
if (mWallpaperSupportsAmbientMode && (
mDozeParameters.getAlwaysOn() && mState == ScrimState.AOD
|| mState == ScrimState.PULSING && mCallback != null)) {
if (mWallpaperSupportsAmbientMode && mDozeParameters.getAlwaysOn()
&& mState == ScrimState.AOD) {
if (!mWallpaperVisibilityTimedOut) {
mTimeTicker.schedule(mDozeParameters.getWallpaperAodDuration(),
AlarmTimeout.MODE_IGNORE_IF_SCHEDULED);

View File

@@ -128,7 +128,8 @@ public enum ScrimState {
public void prepare(ScrimState previousState) {
mCurrentInFrontAlpha = 0f;
if (mPulseReason == DozeLog.PULSE_REASON_NOTIFICATION
|| mPulseReason == DozeLog.PULSE_REASON_DOCKING) {
|| mPulseReason == DozeLog.PULSE_REASON_DOCKING
|| mPulseReason == DozeLog.PULSE_REASON_INTENT) {
mCurrentBehindAlpha = previousState.getBehindAlpha();
mCurrentBehindTint = Color.BLACK;
} else {

View File

@@ -44,11 +44,12 @@ public class DozeWallpaperStateTest extends SysuiTestCase {
private DozeWallpaperState mDozeWallpaperState;
@Mock IWallpaperManager mIWallpaperManager;
@Mock DozeParameters mDozeParameters;
@Mock DozeMachine mMachine;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mDozeWallpaperState = new DozeWallpaperState(mIWallpaperManager, mDozeParameters);
mDozeWallpaperState = new DozeWallpaperState(mMachine, mIWallpaperManager, mDozeParameters);
}
@Test
@@ -108,14 +109,28 @@ public class DozeWallpaperStateTest extends SysuiTestCase {
}
@Test
public void testTransitionTo_pulseIsAmbientMode() throws RemoteException {
public void testTransitionTo_notificationPulseIsAmbientMode() throws RemoteException {
when(mMachine.getPulseReason()).thenReturn(DozeLog.PULSE_REASON_NOTIFICATION);
mDozeWallpaperState.transitionTo(DozeMachine.State.DOZE_REQUEST_PULSE,
DozeMachine.State.DOZE_PULSING);
verify(mIWallpaperManager).setInAmbientMode(eq(true), eq(0L));
}
@Test
public void testTransitionTo_wakeFromPulseIsNotAmbientMode() throws RemoteException {
when(mMachine.getPulseReason()).thenReturn(DozeLog.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN);
mDozeWallpaperState.transitionTo(DozeMachine.State.DOZE_AOD,
DozeMachine.State.DOZE_REQUEST_PULSE);
reset(mIWallpaperManager);
mDozeWallpaperState.transitionTo(DozeMachine.State.DOZE_REQUEST_PULSE,
DozeMachine.State.DOZE_PULSING);
verify(mIWallpaperManager).setInAmbientMode(eq(false), anyLong());
}
@Test
public void testTransitionTo_animatesWhenWakingUpFromPulse() throws RemoteException {
when(mMachine.getPulseReason()).thenReturn(DozeLog.PULSE_REASON_NOTIFICATION);
mDozeWallpaperState.transitionTo(DozeMachine.State.DOZE_REQUEST_PULSE,
DozeMachine.State.DOZE_PULSING);
reset(mIWallpaperManager);