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
This commit is contained in:
@@ -90,14 +90,6 @@ public class DozeScrimController implements StateListener {
|
||||
public void onCancelled() {
|
||||
pulseFinished();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to timeout wallpaper or not.
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldTimeoutWallpaper() {
|
||||
return mPulseReason == DozeEvent.PULSE_REASON_DOCKING;
|
||||
}
|
||||
};
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -233,10 +233,6 @@ public final class DozeServiceHost implements DozeHost {
|
||||
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 @@ public final class DozeServiceHost implements DozeHost {
|
||||
callback.onPulseFinished();
|
||||
mStatusBar.updateNotificationPanelTouchState();
|
||||
mScrimController.setWakeLockScreenSensorActive(false);
|
||||
if (mStatusBarWindow != null) {
|
||||
mStatusBarWindowViewController.suppressWakeUpGesture(false);
|
||||
}
|
||||
setPulsing(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ import com.android.systemui.Dumpable;
|
||||
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 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
|
||||
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 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
|
||||
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 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
|
||||
// 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 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
|
||||
|
||||
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 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mState == ScrimState.PULSING
|
||||
&& mCallback != null && mCallback.shouldTimeoutWallpaper()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -520,8 +520,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
|
||||
* 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 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
|
||||
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 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
|
||||
|
||||
default void onCancelled() {
|
||||
}
|
||||
/** Returns whether to timeout wallpaper or not. */
|
||||
default boolean shouldTimeoutWallpaper() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.phone;
|
||||
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 @@ public enum ScrimState {
|
||||
@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 @@ public enum ScrimState {
|
||||
ScrimView mScrimForBubble;
|
||||
|
||||
DozeParameters mDozeParameters;
|
||||
DockManager mDockManager;
|
||||
boolean mDisplayRequiresBlanking;
|
||||
boolean mWallpaperSupportsAmbientMode;
|
||||
boolean mHasBackdrop;
|
||||
@@ -267,12 +270,13 @@ public enum ScrimState {
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.view.ViewStub;
|
||||
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 @@ public class StatusBarWindowViewController {
|
||||
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 @@ public class StatusBarWindowViewController {
|
||||
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 @@ public class StatusBarWindowViewController {
|
||||
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 @@ public class StatusBarWindowViewController {
|
||||
|
||||
@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 @@ public class StatusBarWindowViewController {
|
||||
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 @@ public class StatusBarWindowViewController {
|
||||
private final CommandQueue mCommandQueue;
|
||||
private final SuperStatusBarViewFactory mSuperStatusBarViewFactory;
|
||||
private final StatusBarWindowView mView;
|
||||
private final DockManager mDockManager;
|
||||
|
||||
@Inject
|
||||
public Builder(
|
||||
@@ -513,7 +513,8 @@ public class StatusBarWindowViewController {
|
||||
DozeLog dozeLog,
|
||||
DozeParameters dozeParameters,
|
||||
CommandQueue commandQueue,
|
||||
SuperStatusBarViewFactory superStatusBarViewFactory) {
|
||||
SuperStatusBarViewFactory superStatusBarViewFactory,
|
||||
DockManager dockManager) {
|
||||
mInjectionInflationController = injectionInflationController;
|
||||
mCoordinator = coordinator;
|
||||
mPulseExpansionHandler = pulseExpansionHandler;
|
||||
@@ -530,8 +531,8 @@ public class StatusBarWindowViewController {
|
||||
mDozeParameters = dozeParameters;
|
||||
mCommandQueue = commandQueue;
|
||||
mSuperStatusBarViewFactory = superStatusBarViewFactory;
|
||||
|
||||
mView = mSuperStatusBarViewFactory.getStatusBarWindowView();
|
||||
mDockManager = dockManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -563,7 +564,8 @@ public class StatusBarWindowViewController {
|
||||
mStatusBarStateController,
|
||||
mDozeLog,
|
||||
mDozeParameters,
|
||||
mCommandQueue);
|
||||
mCommandQueue,
|
||||
mDockManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,26 +158,6 @@ public class DozeServiceHostTest extends SysuiTestCase {
|
||||
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<>(
|
||||
|
||||
@@ -50,6 +50,7 @@ import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
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 @@ public class ScrimControllerTest extends SysuiTestCase {
|
||||
KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
@Mock
|
||||
private SysuiColorExtractor mSysuiColorExtractor;
|
||||
@Mock
|
||||
private DockManager mDockManager;
|
||||
|
||||
|
||||
private static class AnimatorListener implements Animator.AnimatorListener {
|
||||
@@ -210,10 +213,13 @@ public class ScrimControllerTest extends SysuiTestCase {
|
||||
|
||||
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);
|
||||
@@ -371,6 +377,45 @@ public class ScrimControllerTest extends SysuiTestCase {
|
||||
mScrimController.setAodFrontScrimAlpha(0f);
|
||||
}
|
||||
|
||||
@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
|
||||
@@ -714,38 +759,6 @@ public class ScrimControllerTest extends SysuiTestCase {
|
||||
verify(mAlarmManager).cancel(any(AlarmManager.OnAlarmListener.class));
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
@@ -29,6 +29,7 @@ import androidx.test.filters.SmallTest;
|
||||
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 @@ public class StatusBarWindowViewTest extends SysuiTestCase {
|
||||
@Mock private DozeLog mDozeLog;
|
||||
@Mock private DozeParameters mDozeParameters;
|
||||
@Mock private SuperStatusBarViewFactory mSuperStatusBarViewFactory;
|
||||
@Mock private DockManager mDockManager;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -85,6 +87,7 @@ public class StatusBarWindowViewTest extends SysuiTestCase {
|
||||
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 @@ public class StatusBarWindowViewTest extends SysuiTestCase {
|
||||
mDozeLog,
|
||||
mDozeParameters,
|
||||
new CommandQueue(mContext),
|
||||
mSuperStatusBarViewFactory)
|
||||
mSuperStatusBarViewFactory,
|
||||
mDockManager)
|
||||
.setShadeController(mShadeController)
|
||||
.build();
|
||||
mController.setService(mStatusBar);
|
||||
|
||||
Reference in New Issue
Block a user