Add the ability to end pulsing immediately
If a HUN is immediately cancelled after posting, make sure the Doze pulsing state can correctly exit so that the device isn't stuck pulsing in screen on. Test: manually (hardcode) a notification to immediately stop pulsing after its been requested to pulse. observe that AoD eventually exits the pulsing state. Test: atest DozeTriggersTest DozeServiceHostTest Fixes: 221601821 Change-Id: Ibf349f97edbb54a9eb36eb4d33175867d7cf7b13
This commit is contained in:
@@ -32,6 +32,18 @@ public interface DozeHost {
|
||||
boolean isPulsingBlocked();
|
||||
boolean isProvisioned();
|
||||
|
||||
/**
|
||||
* Whether there's a pulse that's been requested but hasn't started transitioning to pulsing
|
||||
* states yet.
|
||||
*/
|
||||
boolean isPulsePending();
|
||||
|
||||
/**
|
||||
* @param isPulsePending whether a pulse has been requested but hasn't started transitioning
|
||||
* to the pulse state yet
|
||||
*/
|
||||
void setPulsePending(boolean isPulsePending);
|
||||
|
||||
/**
|
||||
* Makes a current pulse last for twice as long.
|
||||
* @param reason why we're extending it.
|
||||
|
||||
@@ -280,8 +280,8 @@ public class DozeLog implements Dumpable {
|
||||
/**
|
||||
* Appends pulse dropped event to logs
|
||||
*/
|
||||
public void tracePulseDropped(boolean pulsePending, DozeMachine.State state, boolean blocked) {
|
||||
mLogger.logPulseDropped(pulsePending, state, blocked);
|
||||
public void tracePulseDropped(String from, DozeMachine.State state) {
|
||||
mLogger.logPulseDropped(from, state);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,6 +291,13 @@ public class DozeLog implements Dumpable {
|
||||
mLogger.logSensorEventDropped(sensorEvent, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends pulsing event to logs.
|
||||
*/
|
||||
public void tracePulseEvent(String pulseEvent, boolean dozing, int pulseReason) {
|
||||
mLogger.logPulseEvent(pulseEvent, dozing, DozeLog.reasonToString(pulseReason));
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends pulse dropped event to logs
|
||||
* @param reason why the pulse was dropped
|
||||
|
||||
@@ -224,13 +224,12 @@ class DozeLogger @Inject constructor(
|
||||
})
|
||||
}
|
||||
|
||||
fun logPulseDropped(pulsePending: Boolean, state: DozeMachine.State, blocked: Boolean) {
|
||||
fun logPulseDropped(from: String, state: DozeMachine.State) {
|
||||
buffer.log(TAG, INFO, {
|
||||
bool1 = pulsePending
|
||||
str1 = state.name
|
||||
bool2 = blocked
|
||||
str1 = from
|
||||
str2 = state.name
|
||||
}, {
|
||||
"Pulse dropped, pulsePending=$bool1 state=$str1 blocked=$bool2"
|
||||
"Pulse dropped, cannot pulse from=$str1 state=$str2"
|
||||
})
|
||||
}
|
||||
|
||||
@@ -243,6 +242,16 @@ class DozeLogger @Inject constructor(
|
||||
})
|
||||
}
|
||||
|
||||
fun logPulseEvent(pulseEvent: String, dozing: Boolean, pulseReason: String) {
|
||||
buffer.log(TAG, DEBUG, {
|
||||
str1 = pulseEvent
|
||||
bool1 = dozing
|
||||
str2 = pulseReason
|
||||
}, {
|
||||
"Pulse-$str1 dozing=$bool1 pulseReason=$str2"
|
||||
})
|
||||
}
|
||||
|
||||
fun logPulseDropped(reason: String) {
|
||||
buffer.log(TAG, INFO, {
|
||||
str1 = reason
|
||||
|
||||
@@ -102,7 +102,6 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
private final UiEventLogger mUiEventLogger;
|
||||
|
||||
private long mNotificationPulseTime;
|
||||
private boolean mPulsePending;
|
||||
private Runnable mAodInterruptRunnable;
|
||||
|
||||
/** see {@link #onProximityFar} prox for callback */
|
||||
@@ -303,8 +302,8 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
null /* onPulseSuppressedListener */);
|
||||
}
|
||||
} else {
|
||||
proximityCheckThenCall((result) -> {
|
||||
if (result != null && result) {
|
||||
proximityCheckThenCall((isNear) -> {
|
||||
if (isNear != null && isNear) {
|
||||
// In pocket, drop event.
|
||||
mDozeLog.traceSensorEventDropped(pulseReason, "prox reporting near");
|
||||
return;
|
||||
@@ -410,8 +409,8 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
sWakeDisplaySensorState = wake;
|
||||
|
||||
if (wake) {
|
||||
proximityCheckThenCall((result) -> {
|
||||
if (result != null && result) {
|
||||
proximityCheckThenCall((isNear) -> {
|
||||
if (isNear != null && isNear) {
|
||||
// In pocket, drop event.
|
||||
return;
|
||||
}
|
||||
@@ -537,24 +536,44 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mPulsePending || !mAllowPulseTriggers || !canPulse()) {
|
||||
if (mAllowPulseTriggers) {
|
||||
mDozeLog.tracePulseDropped(mPulsePending, dozeState, mDozeHost.isPulsingBlocked());
|
||||
if (!mAllowPulseTriggers || mDozeHost.isPulsePending() || !canPulse()) {
|
||||
if (!mAllowPulseTriggers) {
|
||||
mDozeLog.tracePulseDropped("requestPulse - !mAllowPulseTriggers");
|
||||
} else if (mDozeHost.isPulsePending()) {
|
||||
mDozeLog.tracePulseDropped("requestPulse - pulsePending");
|
||||
} else if (!canPulse()) {
|
||||
mDozeLog.tracePulseDropped("requestPulse", dozeState);
|
||||
}
|
||||
runIfNotNull(onPulseSuppressedListener);
|
||||
return;
|
||||
}
|
||||
|
||||
mPulsePending = true;
|
||||
proximityCheckThenCall((result) -> {
|
||||
if (result != null && result) {
|
||||
mDozeHost.setPulsePending(true);
|
||||
proximityCheckThenCall((isNear) -> {
|
||||
if (isNear != null && isNear) {
|
||||
// in pocket, abort pulse
|
||||
mDozeLog.tracePulseDropped("inPocket");
|
||||
mPulsePending = false;
|
||||
mDozeLog.tracePulseDropped("requestPulse - inPocket");
|
||||
mDozeHost.setPulsePending(false);
|
||||
runIfNotNull(onPulseSuppressedListener);
|
||||
} else {
|
||||
// not in pocket, continue pulsing
|
||||
continuePulseRequest(reason);
|
||||
final boolean isPulsePending = mDozeHost.isPulsePending();
|
||||
mDozeHost.setPulsePending(false);
|
||||
if (!isPulsePending || mDozeHost.isPulsingBlocked() || !canPulse()) {
|
||||
if (!isPulsePending) {
|
||||
mDozeLog.tracePulseDropped("continuePulseRequest - pulse no longer"
|
||||
+ " pending, pulse was cancelled before it could start"
|
||||
+ " transitioning to pulsing state.");
|
||||
} else if (mDozeHost.isPulsingBlocked()) {
|
||||
mDozeLog.tracePulseDropped("continuePulseRequest - pulsingBlocked");
|
||||
} else if (!canPulse()) {
|
||||
mDozeLog.tracePulseDropped("continuePulseRequest", mMachine.getState());
|
||||
}
|
||||
runIfNotNull(onPulseSuppressedListener);
|
||||
return;
|
||||
}
|
||||
|
||||
mMachine.requestPulse(reason);
|
||||
}
|
||||
}, !mDozeParameters.getProxCheckBeforePulse() || performedProxCheck, reason);
|
||||
|
||||
@@ -569,16 +588,6 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
|| mMachine.getState() == DozeMachine.State.DOZE_AOD_DOCKED;
|
||||
}
|
||||
|
||||
private void continuePulseRequest(int reason) {
|
||||
mPulsePending = false;
|
||||
if (mDozeHost.isPulsingBlocked() || !canPulse()) {
|
||||
mDozeLog.tracePulseDropped(mPulsePending, mMachine.getState(),
|
||||
mDozeHost.isPulsingBlocked());
|
||||
return;
|
||||
}
|
||||
mMachine.requestPulse(reason);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private InstanceId getKeyguardSessionId() {
|
||||
return mSessionTracker.getSessionId(SESSION_KEYGUARD);
|
||||
@@ -591,7 +600,7 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
pw.print(" notificationPulseTime=");
|
||||
pw.println(Formatter.formatShortElapsedTime(mContext, mNotificationPulseTime));
|
||||
|
||||
pw.println(" pulsePending=" + mPulsePending);
|
||||
pw.println(" DozeHost#isPulsePending=" + mDozeHost.isPulsePending());
|
||||
pw.println("DozeSensors:");
|
||||
IndentingPrintWriter idpw = new IndentingPrintWriter(pw);
|
||||
idpw.increaseIndent();
|
||||
|
||||
@@ -43,7 +43,7 @@ public class LogModule {
|
||||
@SysUISingleton
|
||||
@DozeLog
|
||||
public static LogBuffer provideDozeLogBuffer(LogBufferFactory factory) {
|
||||
return factory.create("DozeLog", 100);
|
||||
return factory.create("DozeLog", 120);
|
||||
}
|
||||
|
||||
/** Provides a logging buffer for all logs related to the data layer of notifications. */
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.systemui.statusbar.phone;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
@@ -34,9 +33,6 @@ import javax.inject.Inject;
|
||||
*/
|
||||
@SysUISingleton
|
||||
public class DozeScrimController implements StateListener {
|
||||
private static final String TAG = "DozeScrimController";
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
|
||||
private final DozeLog mDozeLog;
|
||||
private final DozeParameters mDozeParameters;
|
||||
private final Handler mHandler = new Handler();
|
||||
@@ -44,28 +40,26 @@ public class DozeScrimController implements StateListener {
|
||||
private boolean mDozing;
|
||||
private DozeHost.PulseCallback mPulseCallback;
|
||||
private int mPulseReason;
|
||||
private boolean mFullyPulsing;
|
||||
|
||||
private final ScrimController.Callback mScrimCallback = new ScrimController.Callback() {
|
||||
@Override
|
||||
public void onDisplayBlanked() {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Pulse in, mDozing=" + mDozing + " mPulseReason="
|
||||
+ DozeLog.reasonToString(mPulseReason));
|
||||
}
|
||||
if (!mDozing) {
|
||||
mDozeLog.tracePulseDropped("onDisplayBlanked - not dozing");
|
||||
return;
|
||||
}
|
||||
|
||||
// Signal that the pulse is ready to turn the screen on and draw.
|
||||
pulseStarted();
|
||||
if (mPulseCallback != null) {
|
||||
// Signal that the pulse is ready to turn the screen on and draw.
|
||||
mDozeLog.tracePulseStart(mPulseReason);
|
||||
mPulseCallback.onPulseStarted();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinished() {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Pulse in finished, mDozing=" + mDozing);
|
||||
}
|
||||
mDozeLog.tracePulseEvent("scrimCallback-onFinished", mDozing, mPulseReason);
|
||||
|
||||
if (!mDozing) {
|
||||
return;
|
||||
}
|
||||
@@ -78,7 +72,6 @@ public class DozeScrimController implements StateListener {
|
||||
mHandler.postDelayed(mPulseOutExtended,
|
||||
mDozeParameters.getPulseVisibleDurationExtended());
|
||||
}
|
||||
mFullyPulsing = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,19 +111,14 @@ public class DozeScrimController implements StateListener {
|
||||
}
|
||||
|
||||
if (!mDozing || mPulseCallback != null) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Pulse suppressed. Dozing: " + mDozeParameters + " had callback? "
|
||||
+ (mPulseCallback != null));
|
||||
}
|
||||
// Pulse suppressed.
|
||||
callback.onPulseFinished();
|
||||
if (!mDozing) {
|
||||
mDozeLog.tracePulseDropped("device isn't dozing");
|
||||
mDozeLog.tracePulseDropped("pulse - device isn't dozing");
|
||||
} else {
|
||||
mDozeLog.tracePulseDropped("already has pulse callback mPulseCallback="
|
||||
mDozeLog.tracePulseDropped("pulse - already has pulse callback mPulseCallback="
|
||||
+ mPulseCallback);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -141,9 +129,7 @@ public class DozeScrimController implements StateListener {
|
||||
}
|
||||
|
||||
public void pulseOutNow() {
|
||||
if (mPulseCallback != null && mFullyPulsing) {
|
||||
mPulseOut.run();
|
||||
}
|
||||
mPulseOut.run();
|
||||
}
|
||||
|
||||
public boolean isPulsing() {
|
||||
@@ -168,24 +154,16 @@ public class DozeScrimController implements StateListener {
|
||||
|
||||
private void cancelPulsing() {
|
||||
if (mPulseCallback != null) {
|
||||
if (DEBUG) Log.d(TAG, "Cancel pulsing");
|
||||
mFullyPulsing = false;
|
||||
mDozeLog.tracePulseEvent("cancel", mDozing, mPulseReason);
|
||||
mHandler.removeCallbacks(mPulseOut);
|
||||
mHandler.removeCallbacks(mPulseOutExtended);
|
||||
pulseFinished();
|
||||
}
|
||||
}
|
||||
|
||||
private void pulseStarted() {
|
||||
mDozeLog.tracePulseStart(mPulseReason);
|
||||
if (mPulseCallback != null) {
|
||||
mPulseCallback.onPulseStarted();
|
||||
}
|
||||
}
|
||||
|
||||
private void pulseFinished() {
|
||||
mDozeLog.tracePulseFinish();
|
||||
if (mPulseCallback != null) {
|
||||
mDozeLog.tracePulseFinish();
|
||||
mPulseCallback.onPulseFinished();
|
||||
mPulseCallback = null;
|
||||
}
|
||||
@@ -202,10 +180,9 @@ public class DozeScrimController implements StateListener {
|
||||
private final Runnable mPulseOut = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mFullyPulsing = false;
|
||||
mHandler.removeCallbacks(mPulseOut);
|
||||
mHandler.removeCallbacks(mPulseOutExtended);
|
||||
if (DEBUG) Log.d(TAG, "Pulse out, mDozing=" + mDozing);
|
||||
mDozeLog.tracePulseEvent("out", mDozing, mPulseReason);
|
||||
if (!mDozing) return;
|
||||
pulseFinished();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import com.android.systemui.dagger.SysUISingleton;
|
||||
import com.android.systemui.doze.DozeHost;
|
||||
import com.android.systemui.doze.DozeLog;
|
||||
import com.android.systemui.doze.DozeReceiver;
|
||||
import com.android.systemui.keyguard.KeyguardViewMediator;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
import com.android.systemui.shade.NotificationPanelViewController;
|
||||
import com.android.systemui.shade.NotificationShadeWindowViewController;
|
||||
@@ -48,6 +47,7 @@ import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
import com.android.systemui.statusbar.policy.BatteryController;
|
||||
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
||||
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
|
||||
import com.android.systemui.util.Assert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -80,7 +80,6 @@ public final class DozeServiceHost implements DozeHost {
|
||||
private final BatteryController mBatteryController;
|
||||
private final ScrimController mScrimController;
|
||||
private final Lazy<BiometricUnlockController> mBiometricUnlockControllerLazy;
|
||||
private final KeyguardViewMediator mKeyguardViewMediator;
|
||||
private final Lazy<AssistManager> mAssistManagerLazy;
|
||||
private final DozeScrimController mDozeScrimController;
|
||||
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
@@ -95,6 +94,7 @@ public final class DozeServiceHost implements DozeHost {
|
||||
private View mAmbientIndicationContainer;
|
||||
private CentralSurfaces mCentralSurfaces;
|
||||
private boolean mAlwaysOnSuppressed;
|
||||
private boolean mPulsePending;
|
||||
|
||||
@Inject
|
||||
public DozeServiceHost(DozeLog dozeLog, PowerManager powerManager,
|
||||
@@ -104,7 +104,6 @@ public final class DozeServiceHost implements DozeHost {
|
||||
HeadsUpManagerPhone headsUpManagerPhone, BatteryController batteryController,
|
||||
ScrimController scrimController,
|
||||
Lazy<BiometricUnlockController> biometricUnlockControllerLazy,
|
||||
KeyguardViewMediator keyguardViewMediator,
|
||||
Lazy<AssistManager> assistManagerLazy,
|
||||
DozeScrimController dozeScrimController, KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||
PulseExpansionHandler pulseExpansionHandler,
|
||||
@@ -122,7 +121,6 @@ public final class DozeServiceHost implements DozeHost {
|
||||
mBatteryController = batteryController;
|
||||
mScrimController = scrimController;
|
||||
mBiometricUnlockControllerLazy = biometricUnlockControllerLazy;
|
||||
mKeyguardViewMediator = keyguardViewMediator;
|
||||
mAssistManagerLazy = assistManagerLazy;
|
||||
mDozeScrimController = dozeScrimController;
|
||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||
@@ -131,6 +129,7 @@ public final class DozeServiceHost implements DozeHost {
|
||||
mNotificationWakeUpCoordinator = notificationWakeUpCoordinator;
|
||||
mAuthController = authController;
|
||||
mNotificationIconAreaController = notificationIconAreaController;
|
||||
mHeadsUpManagerPhone.addListener(mOnHeadsUpChangedListener);
|
||||
}
|
||||
|
||||
// TODO: we should try to not pass status bar in here if we can avoid it.
|
||||
@@ -246,7 +245,7 @@ public final class DozeServiceHost implements DozeHost {
|
||||
mDozeScrimController.pulse(new PulseCallback() {
|
||||
@Override
|
||||
public void onPulseStarted() {
|
||||
callback.onPulseStarted();
|
||||
callback.onPulseStarted(); // requestState(DozeMachine.State.DOZE_PULSING)
|
||||
mCentralSurfaces.updateNotificationPanelTouchState();
|
||||
setPulsing(true);
|
||||
}
|
||||
@@ -254,7 +253,7 @@ public final class DozeServiceHost implements DozeHost {
|
||||
@Override
|
||||
public void onPulseFinished() {
|
||||
mPulsing = false;
|
||||
callback.onPulseFinished();
|
||||
callback.onPulseFinished(); // requestState(DozeMachine.State.DOZE_PULSE_DONE)
|
||||
mCentralSurfaces.updateNotificationPanelTouchState();
|
||||
mScrimController.setWakeLockScreenSensorActive(false);
|
||||
setPulsing(false);
|
||||
@@ -338,9 +337,8 @@ public final class DozeServiceHost implements DozeHost {
|
||||
|
||||
@Override
|
||||
public void stopPulsing() {
|
||||
if (mDozeScrimController.isPulsing()) {
|
||||
mDozeScrimController.pulseOutNow();
|
||||
}
|
||||
setPulsePending(false); // prevent any pending pulses from continuing
|
||||
mDozeScrimController.pulseOutNow();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -451,6 +449,16 @@ public final class DozeServiceHost implements DozeHost {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPulsePending() {
|
||||
return mPulsePending;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPulsePending(boolean isPulsePending) {
|
||||
mPulsePending = isPulsePending;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether always-on-display is being suppressed. This does not affect wakeup gestures like
|
||||
* pickup and tap.
|
||||
@@ -458,4 +466,22 @@ public final class DozeServiceHost implements DozeHost {
|
||||
public boolean isAlwaysOnSuppressed() {
|
||||
return mAlwaysOnSuppressed;
|
||||
}
|
||||
|
||||
final OnHeadsUpChangedListener mOnHeadsUpChangedListener = new OnHeadsUpChangedListener() {
|
||||
@Override
|
||||
public void onHeadsUpStateChanged(NotificationEntry entry, boolean isHeadsUp) {
|
||||
if (mStatusBarStateController.isDozing() && isHeadsUp) {
|
||||
entry.setPulseSuppressed(false);
|
||||
fireNotificationPulse(entry);
|
||||
if (isPulsing()) {
|
||||
mDozeScrimController.cancelPendingPulseTimeout();
|
||||
}
|
||||
}
|
||||
if (!isHeadsUp && !mHeadsUpManagerPhone.hasNotifications()) {
|
||||
// There are no longer any notifications to show. We should end the
|
||||
// pulse now.
|
||||
stopPulsing();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ import com.android.systemui.shade.NotificationPanelViewController;
|
||||
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
||||
import com.android.systemui.statusbar.NotificationShadeWindowController;
|
||||
import com.android.systemui.statusbar.StatusBarState;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
import com.android.systemui.statusbar.notification.init.NotificationsController;
|
||||
import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent;
|
||||
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
|
||||
import com.android.systemui.statusbar.window.StatusBarWindowController;
|
||||
@@ -41,9 +39,6 @@ public class StatusBarHeadsUpChangeListener implements OnHeadsUpChangedListener
|
||||
private final HeadsUpManagerPhone mHeadsUpManager;
|
||||
private final StatusBarStateController mStatusBarStateController;
|
||||
private final NotificationRemoteInputManager mNotificationRemoteInputManager;
|
||||
private final NotificationsController mNotificationsController;
|
||||
private final DozeServiceHost mDozeServiceHost;
|
||||
private final DozeScrimController mDozeScrimController;
|
||||
|
||||
@Inject
|
||||
StatusBarHeadsUpChangeListener(
|
||||
@@ -53,10 +48,7 @@ public class StatusBarHeadsUpChangeListener implements OnHeadsUpChangedListener
|
||||
KeyguardBypassController keyguardBypassController,
|
||||
HeadsUpManagerPhone headsUpManager,
|
||||
StatusBarStateController statusBarStateController,
|
||||
NotificationRemoteInputManager notificationRemoteInputManager,
|
||||
NotificationsController notificationsController,
|
||||
DozeServiceHost dozeServiceHost,
|
||||
DozeScrimController dozeScrimController) {
|
||||
NotificationRemoteInputManager notificationRemoteInputManager) {
|
||||
|
||||
mNotificationShadeWindowController = notificationShadeWindowController;
|
||||
mStatusBarWindowController = statusBarWindowController;
|
||||
@@ -65,9 +57,6 @@ public class StatusBarHeadsUpChangeListener implements OnHeadsUpChangedListener
|
||||
mHeadsUpManager = headsUpManager;
|
||||
mStatusBarStateController = statusBarStateController;
|
||||
mNotificationRemoteInputManager = notificationRemoteInputManager;
|
||||
mNotificationsController = notificationsController;
|
||||
mDozeServiceHost = dozeServiceHost;
|
||||
mDozeScrimController = dozeScrimController;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,20 +106,4 @@ public class StatusBarHeadsUpChangeListener implements OnHeadsUpChangedListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeadsUpStateChanged(NotificationEntry entry, boolean isHeadsUp) {
|
||||
if (mStatusBarStateController.isDozing() && isHeadsUp) {
|
||||
entry.setPulseSuppressed(false);
|
||||
mDozeServiceHost.fireNotificationPulse(entry);
|
||||
if (mDozeServiceHost.isPulsing()) {
|
||||
mDozeScrimController.cancelPendingPulseTimeout();
|
||||
}
|
||||
}
|
||||
if (!isHeadsUp && !mHeadsUpManager.hasNotifications()) {
|
||||
// There are no longer any notifications to show. We should end the
|
||||
//pulse now.
|
||||
mDozeScrimController.pulseOutNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +144,12 @@ public class DozeTriggersTest extends SysuiTestCase {
|
||||
mTriggers.transitionTo(DozeMachine.State.INITIALIZED, DozeMachine.State.DOZE);
|
||||
clearInvocations(mMachine);
|
||||
|
||||
ArgumentCaptor<Boolean> boolCaptor = ArgumentCaptor.forClass(Boolean.class);
|
||||
doAnswer(invocation ->
|
||||
when(mHost.isPulsePending()).thenReturn(boolCaptor.getValue())
|
||||
).when(mHost).setPulsePending(boolCaptor.capture());
|
||||
|
||||
when(mHost.isPulsingBlocked()).thenReturn(false);
|
||||
mProximitySensor.setLastEvent(new ThresholdSensorEvent(true, 1));
|
||||
captor.getValue().onNotificationAlerted(null /* pulseSuppressedListener */);
|
||||
mProximitySensor.alertListeners();
|
||||
@@ -159,6 +165,29 @@ public class DozeTriggersTest extends SysuiTestCase {
|
||||
verify(mMachine).requestPulse(anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnNotification_noPulseIfPulseIsNotPendingAnymore() {
|
||||
when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE);
|
||||
ArgumentCaptor<DozeHost.Callback> captor = ArgumentCaptor.forClass(DozeHost.Callback.class);
|
||||
doAnswer(invocation -> null).when(mHost).addCallback(captor.capture());
|
||||
|
||||
mTriggers.transitionTo(UNINITIALIZED, DozeMachine.State.INITIALIZED);
|
||||
mTriggers.transitionTo(DozeMachine.State.INITIALIZED, DozeMachine.State.DOZE);
|
||||
clearInvocations(mMachine);
|
||||
when(mHost.isPulsingBlocked()).thenReturn(false);
|
||||
|
||||
// GIVEN pulsePending = false
|
||||
when(mHost.isPulsePending()).thenReturn(false);
|
||||
|
||||
// WHEN prox check returns FAR
|
||||
mProximitySensor.setLastEvent(new ThresholdSensorEvent(false, 2));
|
||||
captor.getValue().onNotificationAlerted(null /* pulseSuppressedListener */);
|
||||
mProximitySensor.alertListeners();
|
||||
|
||||
// THEN don't request pulse because the pending pulse was abandoned early
|
||||
verify(mMachine, never()).requestPulse(anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransitionTo_disablesAndEnablesTouchSensors() {
|
||||
when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE);
|
||||
@@ -237,6 +266,11 @@ public class DozeTriggersTest extends SysuiTestCase {
|
||||
when(mSessionTracker.getSessionId(StatusBarManager.SESSION_KEYGUARD))
|
||||
.thenReturn(keyguardSessionId);
|
||||
|
||||
ArgumentCaptor<Boolean> boolCaptor = ArgumentCaptor.forClass(Boolean.class);
|
||||
doAnswer(invocation ->
|
||||
when(mHost.isPulsePending()).thenReturn(boolCaptor.getValue())
|
||||
).when(mHost).setPulsePending(boolCaptor.capture());
|
||||
|
||||
// WHEN quick pick up is triggered
|
||||
mTriggers.onSensor(DozeLog.REASON_SENSOR_QUICK_PICKUP, 100, 100, null);
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ import com.android.systemui.assist.AssistManager;
|
||||
import com.android.systemui.biometrics.AuthController;
|
||||
import com.android.systemui.doze.DozeHost;
|
||||
import com.android.systemui.doze.DozeLog;
|
||||
import com.android.systemui.keyguard.KeyguardViewMediator;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
import com.android.systemui.shade.NotificationPanelViewController;
|
||||
import com.android.systemui.shade.NotificationShadeWindowViewController;
|
||||
@@ -73,7 +72,6 @@ public class DozeServiceHostTest extends SysuiTestCase {
|
||||
@Mock private HeadsUpManagerPhone mHeadsUpManager;
|
||||
@Mock private ScrimController mScrimController;
|
||||
@Mock private DozeScrimController mDozeScrimController;
|
||||
@Mock private KeyguardViewMediator mKeyguardViewMediator;
|
||||
@Mock private StatusBarStateControllerImpl mStatusBarStateController;
|
||||
@Mock private BatteryController mBatteryController;
|
||||
@Mock private DeviceProvisionedController mDeviceProvisionedController;
|
||||
@@ -101,7 +99,7 @@ public class DozeServiceHostTest extends SysuiTestCase {
|
||||
mDozeServiceHost = new DozeServiceHost(mDozeLog, mPowerManager, mWakefullnessLifecycle,
|
||||
mStatusBarStateController, mDeviceProvisionedController, mHeadsUpManager,
|
||||
mBatteryController, mScrimController, () -> mBiometricUnlockController,
|
||||
mKeyguardViewMediator, () -> mAssistManager, mDozeScrimController,
|
||||
() -> mAssistManager, mDozeScrimController,
|
||||
mKeyguardUpdateMonitor, mPulseExpansionHandler,
|
||||
mNotificationShadeWindowController, mNotificationWakeUpCoordinator,
|
||||
mAuthController, mNotificationIconAreaController);
|
||||
@@ -132,19 +130,11 @@ public class DozeServiceHostTest extends SysuiTestCase {
|
||||
verify(mStatusBarStateController).setIsDozing(eq(false));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPulseWhileDozing_updatesScrimController() {
|
||||
mCentralSurfaces.setBarStateForTest(StatusBarState.KEYGUARD);
|
||||
mCentralSurfaces.showKeyguardImpl();
|
||||
|
||||
// Keep track of callback to be able to stop the pulse
|
||||
// DozeHost.PulseCallback[] pulseCallback = new DozeHost.PulseCallback[1];
|
||||
// doAnswer(invocation -> {
|
||||
// pulseCallback[0] = invocation.getArgument(0);
|
||||
// return null;
|
||||
// }).when(mDozeScrimController).pulse(any(), anyInt());
|
||||
|
||||
// Starting a pulse should change the scrim controller to the pulsing state
|
||||
mDozeServiceHost.pulseWhileDozing(new DozeHost.PulseCallback() {
|
||||
@Override
|
||||
@@ -210,4 +200,17 @@ public class DozeServiceHostTest extends SysuiTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStopPulsing_setPendingPulseToFalse() {
|
||||
// GIVEN a pending pulse
|
||||
mDozeServiceHost.setPulsePending(true);
|
||||
|
||||
// WHEN pulsing is stopped
|
||||
mDozeServiceHost.stopPulsing();
|
||||
|
||||
// THEN isPendingPulse=false, pulseOutNow is called
|
||||
assertFalse(mDozeServiceHost.isPulsePending());
|
||||
verify(mDozeScrimController).pulseOutNow();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user