Merge "Pulse state should always show ambient wallpaper" into pi-dev
am: 52ecba88d1
Change-Id: I9dfcdf1c70fc3ee2059cc5e9312458bcfa07f0a4
This commit is contained in:
@@ -69,7 +69,7 @@ public class DozeFactory {
|
|||||||
new DozeScreenState(wrappedService, handler, params, wakeLock),
|
new DozeScreenState(wrappedService, handler, params, wakeLock),
|
||||||
createDozeScreenBrightness(context, wrappedService, sensorManager, host, params,
|
createDozeScreenBrightness(context, wrappedService, sensorManager, host, params,
|
||||||
handler),
|
handler),
|
||||||
new DozeWallpaperState(context, params)
|
new DozeWallpaperState(context)
|
||||||
});
|
});
|
||||||
|
|
||||||
return machine;
|
return machine;
|
||||||
|
|||||||
@@ -38,40 +38,33 @@ public class DozeWallpaperState implements DozeMachine.Part {
|
|||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
|
||||||
private final IWallpaperManager mWallpaperManagerService;
|
private final IWallpaperManager mWallpaperManagerService;
|
||||||
private boolean mKeyguardVisible;
|
|
||||||
private boolean mIsAmbientMode;
|
private boolean mIsAmbientMode;
|
||||||
private final DozeParameters mDozeParameters;
|
private final DozeParameters mDozeParameters;
|
||||||
|
|
||||||
public DozeWallpaperState(Context context, DozeParameters dozeParameters) {
|
public DozeWallpaperState(Context context) {
|
||||||
this(IWallpaperManager.Stub.asInterface(
|
this(IWallpaperManager.Stub.asInterface(
|
||||||
ServiceManager.getService(Context.WALLPAPER_SERVICE)),
|
ServiceManager.getService(Context.WALLPAPER_SERVICE)),
|
||||||
dozeParameters, KeyguardUpdateMonitor.getInstance(context));
|
DozeParameters.getInstance(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
DozeWallpaperState(IWallpaperManager wallpaperManagerService, DozeParameters parameters,
|
DozeWallpaperState(IWallpaperManager wallpaperManagerService, DozeParameters parameters) {
|
||||||
KeyguardUpdateMonitor keyguardUpdateMonitor) {
|
|
||||||
mWallpaperManagerService = wallpaperManagerService;
|
mWallpaperManagerService = wallpaperManagerService;
|
||||||
mDozeParameters = parameters;
|
mDozeParameters = parameters;
|
||||||
keyguardUpdateMonitor.registerCallback(new KeyguardUpdateMonitorCallback() {
|
|
||||||
@Override
|
|
||||||
public void onKeyguardVisibilityChanged(boolean showing) {
|
|
||||||
mKeyguardVisible = showing;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transitionTo(DozeMachine.State oldState, DozeMachine.State newState) {
|
public void transitionTo(DozeMachine.State oldState, DozeMachine.State newState) {
|
||||||
final boolean isAmbientMode;
|
final boolean isAmbientMode;
|
||||||
switch (newState) {
|
switch (newState) {
|
||||||
|
case DOZE:
|
||||||
case DOZE_AOD:
|
case DOZE_AOD:
|
||||||
case DOZE_AOD_PAUSING:
|
case DOZE_AOD_PAUSING:
|
||||||
case DOZE_AOD_PAUSED:
|
case DOZE_AOD_PAUSED:
|
||||||
case DOZE_REQUEST_PULSE:
|
case DOZE_REQUEST_PULSE:
|
||||||
case DOZE_PULSING:
|
case DOZE_PULSING:
|
||||||
case DOZE_PULSE_DONE:
|
case DOZE_PULSE_DONE:
|
||||||
isAmbientMode = mDozeParameters.getAlwaysOn();
|
isAmbientMode = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
isAmbientMode = false;
|
isAmbientMode = false;
|
||||||
@@ -81,7 +74,9 @@ public class DozeWallpaperState implements DozeMachine.Part {
|
|||||||
if (isAmbientMode) {
|
if (isAmbientMode) {
|
||||||
animated = mDozeParameters.shouldControlScreenOff();
|
animated = mDozeParameters.shouldControlScreenOff();
|
||||||
} else {
|
} else {
|
||||||
animated = !mDozeParameters.getDisplayNeedsBlanking();
|
boolean wakingUpFromPulse = oldState == DozeMachine.State.DOZE_PULSING
|
||||||
|
&& newState == DozeMachine.State.FINISH;
|
||||||
|
animated = !mDozeParameters.getDisplayNeedsBlanking() || wakingUpFromPulse;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAmbientMode != mIsAmbientMode) {
|
if (isAmbientMode != mIsAmbientMode) {
|
||||||
|
|||||||
@@ -45,13 +45,11 @@ public class DozeWallpaperStateTest extends SysuiTestCase {
|
|||||||
private DozeWallpaperState mDozeWallpaperState;
|
private DozeWallpaperState mDozeWallpaperState;
|
||||||
@Mock IWallpaperManager mIWallpaperManager;
|
@Mock IWallpaperManager mIWallpaperManager;
|
||||||
@Mock DozeParameters mDozeParameters;
|
@Mock DozeParameters mDozeParameters;
|
||||||
@Mock KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mDozeWallpaperState = new DozeWallpaperState(mIWallpaperManager, mDozeParameters,
|
mDozeWallpaperState = new DozeWallpaperState(mIWallpaperManager, mDozeParameters);
|
||||||
mKeyguardUpdateMonitor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -100,4 +98,28 @@ public class DozeWallpaperStateTest extends SysuiTestCase {
|
|||||||
mDozeWallpaperState.transitionTo(DozeMachine.State.DOZE_AOD, DozeMachine.State.FINISH);
|
mDozeWallpaperState.transitionTo(DozeMachine.State.DOZE_AOD, DozeMachine.State.FINISH);
|
||||||
verify(mIWallpaperManager).setInAmbientMode(eq(false), eq(false));
|
verify(mIWallpaperManager).setInAmbientMode(eq(false), eq(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTransitionTo_requestPulseIsAmbientMode() throws RemoteException {
|
||||||
|
mDozeWallpaperState.transitionTo(DozeMachine.State.DOZE,
|
||||||
|
DozeMachine.State.DOZE_REQUEST_PULSE);
|
||||||
|
verify(mIWallpaperManager).setInAmbientMode(eq(true), eq(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTransitionTo_pulseIsAmbientMode() throws RemoteException {
|
||||||
|
mDozeWallpaperState.transitionTo(DozeMachine.State.DOZE_REQUEST_PULSE,
|
||||||
|
DozeMachine.State.DOZE_PULSING);
|
||||||
|
verify(mIWallpaperManager).setInAmbientMode(eq(true), eq(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTransitionTo_animatesWhenWakingUpFromPulse() throws RemoteException {
|
||||||
|
mDozeWallpaperState.transitionTo(DozeMachine.State.DOZE_REQUEST_PULSE,
|
||||||
|
DozeMachine.State.DOZE_PULSING);
|
||||||
|
reset(mIWallpaperManager);
|
||||||
|
mDozeWallpaperState.transitionTo(DozeMachine.State.DOZE_PULSING,
|
||||||
|
DozeMachine.State.FINISH);
|
||||||
|
verify(mIWallpaperManager).setInAmbientMode(eq(false), eq(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user