Use DockManager to check whether it's docking or not
Instead of using pulsing reason to verity if it's docking, using
DockManager's API to unbind the check from doze pulsing.
Bug: 140915138, 136070077
Test: atest SystemUITests
Change-Id: I9f52e00042c7c9a665034e094c0744adaa93ef89
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeScrimController.java
index 1ecc489..afaa593 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeScrimController.java
@@ -90,14 +90,6 @@
public void onCancelled() {
pulseFinished();
}
-
- /**
- * Whether to timeout wallpaper or not.
- */
- @Override
- public boolean shouldTimeoutWallpaper() {
- return mPulseReason == DozeEvent.PULSE_REASON_DOCKING;
- }
};
@Inject
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java
index a1af5e8..6aee194 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java
@@ -233,10 +233,6 @@
mScrimController.setWakeLockScreenSensorActive(true);
}
- if (reason == DozeEvent.PULSE_REASON_DOCKING && mStatusBarWindow != null) {
- mStatusBarWindowViewController.suppressWakeUpGesture(true);
- }
-
boolean passiveAuthInterrupt = reason == DozeEvent.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN
&& mWakeLockScreenPerformsAuth;
// Set the state to pulsing, so ScrimController will know what to do once we ask it to
@@ -257,9 +253,6 @@
callback.onPulseFinished();
mStatusBar.updateNotificationPanelTouchState();
mScrimController.setWakeLockScreenSensorActive(false);
- if (mStatusBarWindow != null) {
- mStatusBarWindowViewController.suppressWakeUpGesture(false);
- }
setPulsing(false);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index f21a9a2..1454e25 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -46,6 +46,7 @@
import com.android.systemui.R;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dagger.qualifiers.MainResources;
+import com.android.systemui.dock.DockManager;
import com.android.systemui.statusbar.ScrimView;
import com.android.systemui.statusbar.notification.stack.ViewState;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -136,6 +137,7 @@
private final KeyguardStateController mKeyguardStateController;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final DozeParameters mDozeParameters;
+ private final DockManager mDockManager;
private final AlarmTimeout mTimeTicker;
private final KeyguardVisibilityCallback mKeyguardVisibilityCallback;
private final Handler mHandler;
@@ -192,7 +194,8 @@
AlarmManager alarmManager, KeyguardStateController keyguardStateController,
@MainResources Resources resources,
DelayedWakeLock.Builder delayedWakeLockBuilder, Handler handler,
- KeyguardUpdateMonitor keyguardUpdateMonitor, SysuiColorExtractor sysuiColorExtractor) {
+ KeyguardUpdateMonitor keyguardUpdateMonitor, SysuiColorExtractor sysuiColorExtractor,
+ DockManager dockManager) {
mScrimStateListener = lightBarController::setScrimState;
@@ -209,6 +212,7 @@
// to make sure that text on top of it is legible.
mScrimBehindAlpha = mScrimBehindAlphaResValue;
mDozeParameters = dozeParameters;
+ mDockManager = dockManager;
keyguardStateController.addCallback(new KeyguardStateController.Callback() {
@Override
public void onKeyguardFadingAwayChanged() {
@@ -234,7 +238,8 @@
final ScrimState[] states = ScrimState.values();
for (int i = 0; i < states.length; i++) {
- states[i].init(mScrimInFront, mScrimBehind, mScrimForBubble, mDozeParameters);
+ states[i].init(mScrimInFront, mScrimBehind, mScrimForBubble, mDozeParameters,
+ mDockManager);
states[i].setScrimBehindAlphaKeyguard(mScrimBehindAlphaKeyguard);
}
@@ -359,11 +364,6 @@
return true;
}
- if (mState == ScrimState.PULSING
- && mCallback != null && mCallback.shouldTimeoutWallpaper()) {
- return true;
- }
-
return false;
}
@@ -520,8 +520,7 @@
* device is dozing when the light sensor is on.
*/
public void setAodFrontScrimAlpha(float alpha) {
- if (((mState == ScrimState.AOD && mDozeParameters.getAlwaysOn())
- || mState == ScrimState.PULSING) && mInFrontAlpha != alpha) {
+ if (mInFrontAlpha != alpha && shouldUpdateFrontScrimAlpha()) {
mInFrontAlpha = alpha;
updateScrims();
}
@@ -530,6 +529,19 @@
mState.PULSING.setAodFrontScrimAlpha(alpha);
}
+ private boolean shouldUpdateFrontScrimAlpha() {
+ if (mState == ScrimState.AOD
+ && (mDozeParameters.getAlwaysOn() || mDockManager.isDocked())) {
+ return true;
+ }
+
+ if (mState == ScrimState.PULSING) {
+ return true;
+ }
+
+ return false;
+ }
+
/**
* If the lock screen sensor is active.
*/
@@ -1022,10 +1034,6 @@
default void onCancelled() {
}
- /** Returns whether to timeout wallpaper or not. */
- default boolean shouldTimeoutWallpaper() {
- return false;
- }
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java
index 13055ff..40f8d58 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java
@@ -19,6 +19,7 @@
import android.graphics.Color;
import android.os.Trace;
+import com.android.systemui.dock.DockManager;
import com.android.systemui.statusbar.ScrimView;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
@@ -128,10 +129,11 @@
@Override
public void prepare(ScrimState previousState) {
final boolean alwaysOnEnabled = mDozeParameters.getAlwaysOn();
+ final boolean isDocked = mDockManager.isDocked();
mBlankScreen = mDisplayRequiresBlanking;
mFrontTint = Color.BLACK;
- mFrontAlpha = alwaysOnEnabled ? mAodFrontScrimAlpha : 1f;
+ mFrontAlpha = (alwaysOnEnabled || isDocked) ? mAodFrontScrimAlpha : 1f;
mBehindTint = Color.BLACK;
mBehindAlpha = ScrimController.TRANSPARENT;
@@ -258,6 +260,7 @@
ScrimView mScrimForBubble;
DozeParameters mDozeParameters;
+ DockManager mDockManager;
boolean mDisplayRequiresBlanking;
boolean mWallpaperSupportsAmbientMode;
boolean mHasBackdrop;
@@ -267,12 +270,13 @@
long mKeyguardFadingAwayDuration;
public void init(ScrimView scrimInFront, ScrimView scrimBehind, ScrimView scrimForBubble,
- DozeParameters dozeParameters) {
+ DozeParameters dozeParameters, DockManager dockManager) {
mScrimInFront = scrimInFront;
mScrimBehind = scrimBehind;
mScrimForBubble = scrimForBubble;
mDozeParameters = dozeParameters;
+ mDockManager = dockManager;
mDisplayRequiresBlanking = dozeParameters.getDisplayNeedsBlanking();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowViewController.java
index f716443..c1328ec 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowViewController.java
@@ -35,6 +35,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.ExpandHelper;
import com.android.systemui.R;
+import com.android.systemui.dock.DockManager;
import com.android.systemui.doze.DozeLog;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -75,10 +76,10 @@
private PhoneStatusBarView mStatusBarView;
private StatusBar mService;
private DragDownHelper mDragDownHelper;
- private boolean mSuppressingWakeUpGesture;
private boolean mDoubleTapEnabled;
private boolean mSingleTapEnabled;
private boolean mExpandingBelowNotch;
+ private final DockManager mDockManager;
private StatusBarWindowViewController(
StatusBarWindowView view,
@@ -97,9 +98,11 @@
SysuiStatusBarStateController statusBarStateController,
DozeLog dozeLog,
DozeParameters dozeParameters,
- CommandQueue commandQueue) {
+ CommandQueue commandQueue,
+ DockManager dockManager) {
mView = view;
mFalsingManager = falsingManager;
+ mDockManager = dockManager;
// TODO: create controller for NotificationPanelView
NotificationPanelView notificationPanelView = new NotificationPanelView(
@@ -158,7 +161,7 @@
new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
- if (mSingleTapEnabled && !mSuppressingWakeUpGesture) {
+ if (mSingleTapEnabled && !mDockManager.isDocked()) {
mService.wakeUpIfDozing(
SystemClock.uptimeMillis(), mView, "SINGLE_TAP");
return true;
@@ -243,7 +246,7 @@
@Override
public boolean shouldInterceptTouchEvent(MotionEvent ev) {
- if (mService.isDozing() && !mService.isPulsing()) {
+ if (mService.isDozing() && !mService.isPulsing() && !mDockManager.isDocked()) {
// Capture all touch events in always-on.
return true;
}
@@ -445,10 +448,6 @@
mDragDownHelper = dragDownHelper;
}
- public void suppressWakeUpGesture(boolean suppress) {
- mSuppressingWakeUpGesture = suppress;
- }
-
/**
* When we're launching an affordance, like double pressing power to open camera.
*/
@@ -495,6 +494,7 @@
private final CommandQueue mCommandQueue;
private final SuperStatusBarViewFactory mSuperStatusBarViewFactory;
private final StatusBarWindowView mView;
+ private final DockManager mDockManager;
@Inject
public Builder(
@@ -513,7 +513,8 @@
DozeLog dozeLog,
DozeParameters dozeParameters,
CommandQueue commandQueue,
- SuperStatusBarViewFactory superStatusBarViewFactory) {
+ SuperStatusBarViewFactory superStatusBarViewFactory,
+ DockManager dockManager) {
mInjectionInflationController = injectionInflationController;
mCoordinator = coordinator;
mPulseExpansionHandler = pulseExpansionHandler;
@@ -530,8 +531,8 @@
mDozeParameters = dozeParameters;
mCommandQueue = commandQueue;
mSuperStatusBarViewFactory = superStatusBarViewFactory;
-
mView = mSuperStatusBarViewFactory.getStatusBarWindowView();
+ mDockManager = dockManager;
}
/**
@@ -563,7 +564,8 @@
mStatusBarStateController,
mDozeLog,
mDozeParameters,
- mCommandQueue);
+ mCommandQueue,
+ mDockManager);
}
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java
index 5af1e14..105dbad 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java
@@ -158,26 +158,6 @@
verify(mStatusBar).updateScrimController();
}
-
- @Test
- public void testPulseWhileDozingWithDockingReason_suppressWakeUpGesture() {
- // Keep track of callback to be able to stop the pulse
- final DozeHost.PulseCallback[] pulseCallback = new DozeHost.PulseCallback[1];
- doAnswer(invocation -> {
- pulseCallback[0] = invocation.getArgument(0);
- return null;
- }).when(mDozeScrimController).pulse(any(), anyInt());
-
- // Starting a pulse while docking should suppress wakeup gesture
- mDozeServiceHost.pulseWhileDozing(mock(DozeHost.PulseCallback.class),
- DozeEvent.PULSE_REASON_DOCKING);
- verify(mStatusBarWindowViewController).suppressWakeUpGesture(eq(true));
-
- // Ending a pulse should restore wakeup gesture
- pulseCallback[0].onPulseFinished();
- verify(mStatusBarWindowViewController).suppressWakeUpGesture(eq(false));
- }
-
@Test
public void testPulseWhileDozing_notifyAuthInterrupt() {
HashSet<Integer> reasonsWantingAuth = new HashSet<>(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
index 85c247e..4d6ff1f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
@@ -50,6 +50,7 @@
import com.android.systemui.DejankUtils;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.colorextraction.SysuiColorExtractor;
+import com.android.systemui.dock.DockManager;
import com.android.systemui.statusbar.ScrimView;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.wakelock.DelayedWakeLock;
@@ -101,6 +102,8 @@
KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock
private SysuiColorExtractor mSysuiColorExtractor;
+ @Mock
+ private DockManager mDockManager;
private static class AnimatorListener implements Animator.AnimatorListener {
@@ -210,10 +213,13 @@
when(mSysuiColorExtractor.getNeutralColors()).thenReturn(new GradientColors());
+ when(mDockManager.isDocked()).thenReturn(false);
+
mScrimController = new ScrimController(mLightBarController,
mDozeParamenters, mAlarmManager, mKeyguardStateController,
mResources, mDelayedWakeLockBuilder,
- new FakeHandler(mLooper.getLooper()), mKeyguardUpdateMonitor, mSysuiColorExtractor);
+ new FakeHandler(mLooper.getLooper()), mKeyguardUpdateMonitor, mSysuiColorExtractor,
+ mDockManager);
mScrimController.setScrimVisibleListener(visible -> mScrimVisibility = visible);
mScrimController.attachViews(mScrimBehind, mScrimInFront, mScrimForBubble);
mScrimController.setAnimatorListener(mAnimatorListener);
@@ -372,6 +378,45 @@
}
@Test
+ public void transitionToAod_afterDocked_ignoresAlwaysOnAndUpdatesFrontAlpha() {
+ // Assert that setting the AOD front scrim alpha doesn't take effect in a non-AOD state.
+ mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.setAodFrontScrimAlpha(0.5f);
+ finishAnimationsImmediately();
+
+ assertScrimAlpha(TRANSPARENT /* front */,
+ SEMI_TRANSPARENT /* back */,
+ TRANSPARENT /* bubble */);
+
+ // ... and doesn't take effect when disabled always_on
+ mAlwaysOnEnabled = false;
+ mScrimController.transitionTo(ScrimState.AOD);
+ finishAnimationsImmediately();
+ assertScrimAlpha(OPAQUE /* front */,
+ OPAQUE /* back */,
+ TRANSPARENT /* bubble */);
+
+ // ... but will take effect after docked
+ when(mDockManager.isDocked()).thenReturn(true);
+ mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.setAodFrontScrimAlpha(0.5f);
+ mScrimController.transitionTo(ScrimState.AOD);
+
+ assertScrimAlpha(SEMI_TRANSPARENT /* front */,
+ OPAQUE /* back */,
+ TRANSPARENT /* bubble */);
+
+ // ... and that if we set it while we're in AOD, it does take immediate effect after docked.
+ mScrimController.setAodFrontScrimAlpha(1f);
+ assertScrimAlpha(OPAQUE /* front */,
+ OPAQUE /* back */,
+ TRANSPARENT /* bubble */);
+
+ // Reset value since enums are static.
+ mScrimController.setAodFrontScrimAlpha(0f);
+ }
+
+ @Test
public void transitionToPulsing_withFrontAlphaUpdates() {
// Pre-condition
// Need to go to AoD first because PULSING doesn't change
@@ -715,38 +760,6 @@
}
@Test
- public void transitionToPulsing_withTimeoutWallpaperCallback_willHideWallpaper() {
- mScrimController.setWallpaperSupportsAmbientMode(true);
-
- mScrimController.transitionTo(ScrimState.PULSING, new ScrimController.Callback() {
- @Override
- public boolean shouldTimeoutWallpaper() {
- return true;
- }
- });
-
- verify(mAlarmManager).setExact(anyInt(), anyLong(), any(), any(), any());
- }
-
- @Test
- public void transitionToPulsing_withDefaultCallback_wontHideWallpaper() {
- mScrimController.setWallpaperSupportsAmbientMode(true);
-
- mScrimController.transitionTo(ScrimState.PULSING, new ScrimController.Callback() {});
-
- verify(mAlarmManager, never()).setExact(anyInt(), anyLong(), any(), any(), any());
- }
-
- @Test
- public void transitionToPulsing_withoutCallback_wontHideWallpaper() {
- mScrimController.setWallpaperSupportsAmbientMode(true);
-
- mScrimController.transitionTo(ScrimState.PULSING);
-
- verify(mAlarmManager, never()).setExact(anyInt(), anyLong(), any(), any(), any());
- }
-
- @Test
public void testConservesExpansionOpacityAfterTransition() {
mScrimController.transitionTo(ScrimState.UNLOCKED);
mScrimController.setPanelExpansion(0.5f);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarWindowViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarWindowViewTest.java
index bf81325..4d4e9ae 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarWindowViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarWindowViewTest.java
@@ -29,6 +29,7 @@
import com.android.systemui.SystemUIFactory;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.classifier.FalsingManagerFake;
+import com.android.systemui.dock.DockManager;
import com.android.systemui.doze.DozeLog;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.statusbar.CommandQueue;
@@ -74,6 +75,7 @@
@Mock private DozeLog mDozeLog;
@Mock private DozeParameters mDozeParameters;
@Mock private SuperStatusBarViewFactory mSuperStatusBarViewFactory;
+ @Mock private DockManager mDockManager;
@Before
public void setUp() {
@@ -85,6 +87,7 @@
mDependency.injectTestDependency(ShadeController.class, mShadeController);
when(mSuperStatusBarViewFactory.getStatusBarWindowView()).thenReturn(mView);
+ when(mDockManager.isDocked()).thenReturn(false);
mController = new StatusBarWindowViewController.Builder(
new InjectionInflationController(
@@ -103,7 +106,8 @@
mDozeLog,
mDozeParameters,
new CommandQueue(mContext),
- mSuperStatusBarViewFactory)
+ mSuperStatusBarViewFactory,
+ mDockManager)
.setShadeController(mShadeController)
.build();
mController.setService(mStatusBar);