From 30c75471492ec7862ab7fbd56358a75178e0ed52 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Fri, 18 May 2018 12:57:47 -0700 Subject: [PATCH] Pulse state should always show ambient wallpaper Otherwise wallpaper wouldn't be set to AOD when the device pulses and always on is off. Bug: 78606979 Test: manual Test: atest packages/SystemUI/tests/src/com/android/systemui/doze/DozeWallpaperStateTest.java Change-Id: Ic40c18252cd6cb06ff6fd0d79ec3f1de16a1add5 --- .../src/com/android/systemui/doze/DozeFactory.java | 2 +- .../android/systemui/doze/DozeWallpaperState.java | 21 +++++++--------- .../systemui/doze/DozeWallpaperStateTest.java | 28 +++++++++++++++++++--- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java b/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java index e9d78d9b4fdf..e2047bf89833 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java @@ -69,7 +69,7 @@ public class DozeFactory { new DozeScreenState(wrappedService, handler, params, wakeLock), createDozeScreenBrightness(context, wrappedService, sensorManager, host, params, handler), - new DozeWallpaperState(context, params) + new DozeWallpaperState(context) }); return machine; diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeWallpaperState.java b/packages/SystemUI/src/com/android/systemui/doze/DozeWallpaperState.java index 9d110fb74d86..47f86fed7e69 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeWallpaperState.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeWallpaperState.java @@ -38,40 +38,33 @@ public class DozeWallpaperState implements DozeMachine.Part { private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private final IWallpaperManager mWallpaperManagerService; - private boolean mKeyguardVisible; private boolean mIsAmbientMode; private final DozeParameters mDozeParameters; - public DozeWallpaperState(Context context, DozeParameters dozeParameters) { + public DozeWallpaperState(Context context) { this(IWallpaperManager.Stub.asInterface( ServiceManager.getService(Context.WALLPAPER_SERVICE)), - dozeParameters, KeyguardUpdateMonitor.getInstance(context)); + DozeParameters.getInstance(context)); } @VisibleForTesting - DozeWallpaperState(IWallpaperManager wallpaperManagerService, DozeParameters parameters, - KeyguardUpdateMonitor keyguardUpdateMonitor) { + DozeWallpaperState(IWallpaperManager wallpaperManagerService, DozeParameters parameters) { mWallpaperManagerService = wallpaperManagerService; mDozeParameters = parameters; - keyguardUpdateMonitor.registerCallback(new KeyguardUpdateMonitorCallback() { - @Override - public void onKeyguardVisibilityChanged(boolean showing) { - mKeyguardVisible = showing; - } - }); } @Override public void transitionTo(DozeMachine.State oldState, DozeMachine.State newState) { final boolean isAmbientMode; switch (newState) { + case DOZE: case DOZE_AOD: case DOZE_AOD_PAUSING: case DOZE_AOD_PAUSED: case DOZE_REQUEST_PULSE: case DOZE_PULSING: case DOZE_PULSE_DONE: - isAmbientMode = mDozeParameters.getAlwaysOn(); + isAmbientMode = true; break; default: isAmbientMode = false; @@ -81,7 +74,9 @@ public class DozeWallpaperState implements DozeMachine.Part { if (isAmbientMode) { animated = mDozeParameters.shouldControlScreenOff(); } else { - animated = !mDozeParameters.getDisplayNeedsBlanking(); + boolean wakingUpFromPulse = oldState == DozeMachine.State.DOZE_PULSING + && newState == DozeMachine.State.FINISH; + animated = !mDozeParameters.getDisplayNeedsBlanking() || wakingUpFromPulse; } if (isAmbientMode != mIsAmbientMode) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeWallpaperStateTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeWallpaperStateTest.java index 5c80bb5ded9d..6ac44628b52f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeWallpaperStateTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeWallpaperStateTest.java @@ -45,13 +45,11 @@ public class DozeWallpaperStateTest extends SysuiTestCase { private DozeWallpaperState mDozeWallpaperState; @Mock IWallpaperManager mIWallpaperManager; @Mock DozeParameters mDozeParameters; - @Mock KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Before public void setUp() { MockitoAnnotations.initMocks(this); - mDozeWallpaperState = new DozeWallpaperState(mIWallpaperManager, mDozeParameters, - mKeyguardUpdateMonitor); + mDozeWallpaperState = new DozeWallpaperState(mIWallpaperManager, mDozeParameters); } @Test @@ -100,4 +98,28 @@ public class DozeWallpaperStateTest extends SysuiTestCase { mDozeWallpaperState.transitionTo(DozeMachine.State.DOZE_AOD, DozeMachine.State.FINISH); 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)); + } } -- 2.11.0