Merge "Update SysUI to use new PowerManager WakeReasons" into tm-qpr-dev am: 9af26b35ea
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20794573 Change-Id: I0dc94de9d3bc138e9bb887a1a698554904c9874c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -884,7 +884,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
Assert.isMainThread();
|
||||
if (mWakeOnFingerprintAcquiredStart && acquireInfo == FINGERPRINT_ACQUIRED_START) {
|
||||
mPowerManager.wakeUp(
|
||||
SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
|
||||
SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_BIOMETRIC,
|
||||
"com.android.systemui.keyguard:FINGERPRINT_ACQUIRED_START");
|
||||
}
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
|
||||
@@ -16,7 +16,14 @@
|
||||
|
||||
package com.android.systemui.doze;
|
||||
|
||||
import static android.os.PowerManager.WAKE_REASON_BIOMETRIC;
|
||||
import static android.os.PowerManager.WAKE_REASON_GESTURE;
|
||||
import static android.os.PowerManager.WAKE_REASON_LIFT;
|
||||
import static android.os.PowerManager.WAKE_REASON_PLUGGED_IN;
|
||||
import static android.os.PowerManager.WAKE_REASON_TAP;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.os.PowerManager;
|
||||
import android.util.TimeUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -511,6 +518,25 @@ public class DozeLog implements Dumpable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts {@link Reason} to {@link PowerManager.WakeReason}.
|
||||
*/
|
||||
public static @PowerManager.WakeReason int getPowerManagerWakeReason(@Reason int wakeReason) {
|
||||
switch (wakeReason) {
|
||||
case REASON_SENSOR_DOUBLE_TAP:
|
||||
case REASON_SENSOR_TAP:
|
||||
return WAKE_REASON_TAP;
|
||||
case REASON_SENSOR_PICKUP:
|
||||
return WAKE_REASON_LIFT;
|
||||
case REASON_SENSOR_UDFPS_LONG_PRESS:
|
||||
return WAKE_REASON_BIOMETRIC;
|
||||
case PULSE_REASON_DOCKING:
|
||||
return WAKE_REASON_PLUGGED_IN;
|
||||
default:
|
||||
return WAKE_REASON_GESTURE;
|
||||
}
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({PULSE_REASON_NONE, PULSE_REASON_INTENT, PULSE_REASON_NOTIFICATION,
|
||||
PULSE_REASON_SENSOR_SIGMOTION, REASON_SENSOR_PICKUP, REASON_SENSOR_DOUBLE_TAP,
|
||||
|
||||
@@ -116,8 +116,8 @@ public class DozeService extends DreamService
|
||||
|
||||
@Override
|
||||
public void requestWakeUp(@DozeLog.Reason int reason) {
|
||||
PowerManager pm = getSystemService(PowerManager.class);
|
||||
pm.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
|
||||
final PowerManager pm = getSystemService(PowerManager.class);
|
||||
pm.wakeUp(SystemClock.uptimeMillis(), DozeLog.getPowerManagerWakeReason(reason),
|
||||
"com.android.systemui:NODOZE " + DozeLog.reasonToString(reason));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.systemui.shade;
|
||||
import android.app.StatusBarManager;
|
||||
import android.media.AudioManager;
|
||||
import android.media.session.MediaSessionLegacyHelper;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.view.GestureDetector;
|
||||
@@ -238,7 +239,9 @@ public class NotificationShadeWindowViewController {
|
||||
() -> mService.wakeUpIfDozing(
|
||||
SystemClock.uptimeMillis(),
|
||||
mView,
|
||||
"LOCK_ICON_TOUCH"));
|
||||
"LOCK_ICON_TOUCH",
|
||||
PowerManager.WAKE_REASON_GESTURE)
|
||||
);
|
||||
|
||||
// In case we start outside of the view bounds (below the status bar), we need to
|
||||
// dispatch
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.systemui.shade
|
||||
|
||||
import android.hardware.display.AmbientDisplayConfiguration
|
||||
import android.os.PowerManager
|
||||
import android.os.SystemClock
|
||||
import android.os.UserHandle
|
||||
import android.provider.Settings
|
||||
@@ -89,7 +90,8 @@ class PulsingGestureListener @Inject constructor(
|
||||
centralSurfaces.wakeUpIfDozing(
|
||||
SystemClock.uptimeMillis(),
|
||||
notificationShadeWindowView,
|
||||
"PULSING_SINGLE_TAP"
|
||||
"PULSING_SINGLE_TAP",
|
||||
PowerManager.WAKE_REASON_TAP
|
||||
)
|
||||
}
|
||||
return true
|
||||
@@ -114,7 +116,9 @@ class PulsingGestureListener @Inject constructor(
|
||||
centralSurfaces.wakeUpIfDozing(
|
||||
SystemClock.uptimeMillis(),
|
||||
notificationShadeWindowView,
|
||||
"PULSING_DOUBLE_TAP")
|
||||
"PULSING_DOUBLE_TAP",
|
||||
PowerManager.WAKE_REASON_TAP
|
||||
)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.animation.AnimatorListenerAdapter
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.os.PowerManager
|
||||
import android.os.SystemClock
|
||||
import android.util.IndentingPrintWriter
|
||||
import android.util.MathUtils
|
||||
@@ -272,7 +273,12 @@ class LockscreenShadeTransitionController @Inject constructor(
|
||||
// Bind the click listener of the shelf to go to the full shade
|
||||
notificationShelfController.setOnClickListener {
|
||||
if (statusBarStateController.state == StatusBarState.KEYGUARD) {
|
||||
centralSurfaces.wakeUpIfDozing(SystemClock.uptimeMillis(), it, "SHADE_CLICK")
|
||||
centralSurfaces.wakeUpIfDozing(
|
||||
SystemClock.uptimeMillis(),
|
||||
it,
|
||||
"SHADE_CLICK",
|
||||
PowerManager.WAKE_REASON_GESTURE,
|
||||
)
|
||||
goToLockedShade(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.app.RemoteInput;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.PowerManager;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemClock;
|
||||
@@ -64,6 +65,8 @@ import com.android.systemui.statusbar.policy.RemoteInputView;
|
||||
import com.android.systemui.util.DumpUtilsKt;
|
||||
import com.android.systemui.util.ListenerSet;
|
||||
|
||||
import dagger.Lazy;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -71,8 +74,6 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import dagger.Lazy;
|
||||
|
||||
/**
|
||||
* Class for handling remote input state over a set of notifications. This class handles things
|
||||
* like keeping notifications temporarily that were cancelled as a response to a remote input
|
||||
@@ -120,7 +121,8 @@ public class NotificationRemoteInputManager implements Dumpable {
|
||||
View view, PendingIntent pendingIntent, RemoteViews.RemoteResponse response) {
|
||||
mCentralSurfacesOptionalLazy.get().ifPresent(
|
||||
centralSurfaces -> centralSurfaces.wakeUpIfDozing(
|
||||
SystemClock.uptimeMillis(), view, "NOTIFICATION_CLICK"));
|
||||
SystemClock.uptimeMillis(), view, "NOTIFICATION_CLICK",
|
||||
PowerManager.WAKE_REASON_GESTURE));
|
||||
|
||||
final NotificationEntry entry = getNotificationForParent(view.getParent());
|
||||
mLogger.logInitialClick(entry, pendingIntent);
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.os.PowerManager
|
||||
import android.os.PowerManager.WAKE_REASON_GESTURE
|
||||
import android.os.SystemClock
|
||||
import android.util.IndentingPrintWriter
|
||||
import android.view.MotionEvent
|
||||
@@ -249,7 +248,7 @@ constructor(
|
||||
}
|
||||
if (statusBarStateController.isDozing) {
|
||||
wakeUpCoordinator.willWakeUp = true
|
||||
mPowerManager!!.wakeUp(SystemClock.uptimeMillis(), WAKE_REASON_GESTURE,
|
||||
mPowerManager!!.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
|
||||
"com.android.systemui:PULSEDRAG")
|
||||
}
|
||||
lockscreenShadeTransitionController.goToLockedShade(startingChild,
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.android.systemui.statusbar.notification;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.util.Log;
|
||||
@@ -70,7 +71,8 @@ public final class NotificationClicker implements View.OnClickListener {
|
||||
}
|
||||
|
||||
mCentralSurfacesOptional.ifPresent(centralSurfaces -> centralSurfaces.wakeUpIfDozing(
|
||||
SystemClock.uptimeMillis(), v, "NOTIFICATION_CLICK"));
|
||||
SystemClock.uptimeMillis(), v, "NOTIFICATION_CLICK",
|
||||
PowerManager.WAKE_REASON_GESTURE));
|
||||
|
||||
final ExpandableNotificationRow row = (ExpandableNotificationRow) v;
|
||||
final NotificationEntry entry = row.getEntry();
|
||||
|
||||
@@ -429,7 +429,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
|
||||
Runnable wakeUp = ()-> {
|
||||
if (!wasDeviceInteractive || mUpdateMonitor.isDreaming()) {
|
||||
mLogger.i("bio wakelock: Authenticated, waking up...");
|
||||
mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
|
||||
mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_BIOMETRIC,
|
||||
"android.policy:BIOMETRIC");
|
||||
}
|
||||
Trace.beginSection("release wake-and-unlock");
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.UserHandle;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.view.KeyEvent;
|
||||
@@ -203,7 +204,10 @@ public interface CentralSurfaces extends Dumpable, ActivityStarter, LifecycleOwn
|
||||
@Override
|
||||
Lifecycle getLifecycle();
|
||||
|
||||
void wakeUpIfDozing(long time, View where, String why);
|
||||
/**
|
||||
* Wakes up the device if the device was dozing.
|
||||
*/
|
||||
void wakeUpIfDozing(long time, View where, String why, @PowerManager.WakeReason int wakeReason);
|
||||
|
||||
NotificationShadeWindowView getNotificationShadeWindowView();
|
||||
|
||||
|
||||
@@ -899,8 +899,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
|
||||
mKeyguardIndicationController.init();
|
||||
|
||||
mColorExtractor.addOnColorsChangedListener(mOnColorsChangedListener);
|
||||
mStatusBarStateController.addCallback(mStateListener,
|
||||
SysuiStatusBarStateController.RANK_STATUS_BAR);
|
||||
|
||||
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
|
||||
|
||||
@@ -1519,10 +1517,11 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
|
||||
* @param why the reason for the wake up
|
||||
*/
|
||||
@Override
|
||||
public void wakeUpIfDozing(long time, View where, String why) {
|
||||
public void wakeUpIfDozing(long time, View where, String why,
|
||||
@PowerManager.WakeReason int wakeReason) {
|
||||
if (mDozing && mScreenOffAnimationController.allowWakeUpIfDozing()) {
|
||||
mPowerManager.wakeUp(
|
||||
time, PowerManager.WAKE_REASON_GESTURE, "com.android.systemui:" + why);
|
||||
time, wakeReason, "com.android.systemui:" + why);
|
||||
mWakeUpComingFromTouch = true;
|
||||
mFalsingCollector.onScreenOnFromTouch();
|
||||
}
|
||||
@@ -1599,6 +1598,8 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
|
||||
|
||||
protected void startKeyguard() {
|
||||
Trace.beginSection("CentralSurfaces#startKeyguard");
|
||||
mStatusBarStateController.addCallback(mStateListener,
|
||||
SysuiStatusBarStateController.RANK_STATUS_BAR);
|
||||
mBiometricUnlockController = mBiometricUnlockControllerLazy.get();
|
||||
mBiometricUnlockController.addBiometricModeListener(
|
||||
new BiometricUnlockController.BiometricModeListener() {
|
||||
@@ -3380,7 +3381,8 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
|
||||
mStatusBarHideIconsForBouncerManager.setBouncerShowingAndTriggerUpdate(bouncerShowing);
|
||||
mCommandQueue.recomputeDisableFlags(mDisplayId, true /* animate */);
|
||||
if (mBouncerShowing) {
|
||||
wakeUpIfDozing(SystemClock.uptimeMillis(), null, "BOUNCER_VISIBLE");
|
||||
wakeUpIfDozing(SystemClock.uptimeMillis(), null, "BOUNCER_VISIBLE",
|
||||
PowerManager.WAKE_REASON_GESTURE);
|
||||
}
|
||||
updateScrimController();
|
||||
if (!mBouncerShowing) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import static com.android.systemui.statusbar.phone.CentralSurfaces.MULTIUSER_DEB
|
||||
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.os.PowerManager;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemClock;
|
||||
@@ -270,7 +271,8 @@ class StatusBarNotificationPresenter implements NotificationPresenter,
|
||||
boolean nowExpanded) {
|
||||
mHeadsUpManager.setExpanded(clickedEntry, nowExpanded);
|
||||
mCentralSurfaces.wakeUpIfDozing(
|
||||
SystemClock.uptimeMillis(), clickedView, "NOTIFICATION_CLICK");
|
||||
SystemClock.uptimeMillis(), clickedView, "NOTIFICATION_CLICK",
|
||||
PowerManager.WAKE_REASON_GESTURE);
|
||||
if (nowExpanded) {
|
||||
if (mStatusBarStateController.getState() == StatusBarState.KEYGUARD) {
|
||||
mShadeTransitionController.goToLockedShade(clickedEntry.getRow());
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.provider.Settings.Secure.DOZE_DOUBLE_TAP_GESTURE
|
||||
import android.provider.Settings.Secure.DOZE_TAP_SCREEN_GESTURE
|
||||
import android.testing.AndroidTestingRunner
|
||||
import android.testing.TestableLooper.RunWithLooper
|
||||
import android.os.PowerManager
|
||||
import android.view.MotionEvent
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.systemui.SysuiTestCase
|
||||
@@ -36,9 +37,9 @@ import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentCaptor
|
||||
import org.mockito.ArgumentMatchers.any
|
||||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.mockito.ArgumentMatchers.anyLong
|
||||
import org.mockito.ArgumentMatchers.anyObject
|
||||
import org.mockito.ArgumentMatchers.anyString
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.never
|
||||
@@ -106,7 +107,8 @@ class PulsingGestureListenerTest : SysuiTestCase() {
|
||||
underTest.onSingleTapUp(upEv)
|
||||
|
||||
// THEN wake up device if dozing
|
||||
verify(centralSurfaces).wakeUpIfDozing(anyLong(), anyObject(), anyString())
|
||||
verify(centralSurfaces).wakeUpIfDozing(
|
||||
anyLong(), any(), anyString(), eq(PowerManager.WAKE_REASON_TAP))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -125,7 +127,8 @@ class PulsingGestureListenerTest : SysuiTestCase() {
|
||||
underTest.onDoubleTapEvent(upEv)
|
||||
|
||||
// THEN wake up device if dozing
|
||||
verify(centralSurfaces).wakeUpIfDozing(anyLong(), anyObject(), anyString())
|
||||
verify(centralSurfaces).wakeUpIfDozing(
|
||||
anyLong(), any(), anyString(), eq(PowerManager.WAKE_REASON_TAP))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -156,7 +159,8 @@ class PulsingGestureListenerTest : SysuiTestCase() {
|
||||
underTest.onSingleTapUp(upEv)
|
||||
|
||||
// THEN the device doesn't wake up
|
||||
verify(centralSurfaces, never()).wakeUpIfDozing(anyLong(), anyObject(), anyString())
|
||||
verify(centralSurfaces, never()).wakeUpIfDozing(
|
||||
anyLong(), any(), anyString(), anyInt())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -203,7 +207,8 @@ class PulsingGestureListenerTest : SysuiTestCase() {
|
||||
underTest.onDoubleTapEvent(upEv)
|
||||
|
||||
// THEN the device doesn't wake up
|
||||
verify(centralSurfaces, never()).wakeUpIfDozing(anyLong(), anyObject(), anyString())
|
||||
verify(centralSurfaces, never()).wakeUpIfDozing(
|
||||
anyLong(), any(), anyString(), anyInt())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -222,7 +227,8 @@ class PulsingGestureListenerTest : SysuiTestCase() {
|
||||
underTest.onSingleTapUp(upEv)
|
||||
|
||||
// THEN the device doesn't wake up
|
||||
verify(centralSurfaces, never()).wakeUpIfDozing(anyLong(), anyObject(), anyString())
|
||||
verify(centralSurfaces, never()).wakeUpIfDozing(
|
||||
anyLong(), any(), anyString(), anyInt())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -241,7 +247,8 @@ class PulsingGestureListenerTest : SysuiTestCase() {
|
||||
underTest.onDoubleTapEvent(upEv)
|
||||
|
||||
// THEN the device doesn't wake up
|
||||
verify(centralSurfaces, never()).wakeUpIfDozing(anyLong(), anyObject(), anyString())
|
||||
verify(centralSurfaces, never()).wakeUpIfDozing(
|
||||
anyLong(), any(), anyString(), anyInt())
|
||||
}
|
||||
|
||||
fun updateSettings() {
|
||||
|
||||
@@ -31,6 +31,7 @@ import static junit.framework.TestCase.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.clearInvocations;
|
||||
@@ -176,6 +177,8 @@ import com.android.systemui.volume.VolumeComponent;
|
||||
import com.android.wm.shell.bubbles.Bubbles;
|
||||
import com.android.wm.shell.startingsurface.StartingSurface;
|
||||
|
||||
import dagger.Lazy;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -188,8 +191,6 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Optional;
|
||||
|
||||
import dagger.Lazy;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@RunWithLooper(setAsMainLooper = true)
|
||||
@@ -304,6 +305,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
|
||||
@Mock private ViewRootImpl mViewRootImpl;
|
||||
@Mock private WindowOnBackInvokedDispatcher mOnBackInvokedDispatcher;
|
||||
@Captor private ArgumentCaptor<OnBackInvokedCallback> mOnBackInvokedCallback;
|
||||
@Mock IPowerManager mPowerManagerService;
|
||||
|
||||
private ShadeController mShadeController;
|
||||
private final FakeSystemClock mFakeSystemClock = new FakeSystemClock();
|
||||
@@ -317,9 +319,8 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
|
||||
public void setup() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
IPowerManager powerManagerService = mock(IPowerManager.class);
|
||||
IThermalService thermalService = mock(IThermalService.class);
|
||||
mPowerManager = new PowerManager(mContext, powerManagerService, thermalService,
|
||||
mPowerManager = new PowerManager(mContext, mPowerManagerService, thermalService,
|
||||
Handler.createAsync(Looper.myLooper()));
|
||||
|
||||
mNotificationInterruptStateProvider =
|
||||
@@ -361,7 +362,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
|
||||
when(mStackScrollerController.getView()).thenReturn(mStackScroller);
|
||||
when(mStackScroller.generateLayoutParams(any())).thenReturn(new LayoutParams(0, 0));
|
||||
when(mNotificationPanelView.getLayoutParams()).thenReturn(new LayoutParams(0, 0));
|
||||
when(powerManagerService.isInteractive()).thenReturn(true);
|
||||
when(mPowerManagerService.isInteractive()).thenReturn(true);
|
||||
when(mStackScroller.getActivatedChild()).thenReturn(null);
|
||||
|
||||
doAnswer(invocation -> {
|
||||
@@ -1186,6 +1187,34 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
|
||||
verify(mStatusBarStateController).setState(SHADE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dozing_wakeUp() throws RemoteException {
|
||||
// GIVEN can wakeup when dozing & is dozing
|
||||
when(mScreenOffAnimationController.allowWakeUpIfDozing()).thenReturn(true);
|
||||
setDozing(true);
|
||||
|
||||
// WHEN wakeup is requested
|
||||
final int wakeReason = PowerManager.WAKE_REASON_TAP;
|
||||
mCentralSurfaces.wakeUpIfDozing(0, null, "", wakeReason);
|
||||
|
||||
// THEN power manager receives wakeup
|
||||
verify(mPowerManagerService).wakeUp(eq(0L), eq(wakeReason), anyString(), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notDozing_noWakeUp() throws RemoteException {
|
||||
// GIVEN can wakeup when dozing and NOT dozing
|
||||
when(mScreenOffAnimationController.allowWakeUpIfDozing()).thenReturn(true);
|
||||
setDozing(false);
|
||||
|
||||
// WHEN wakeup is requested
|
||||
final int wakeReason = PowerManager.WAKE_REASON_TAP;
|
||||
mCentralSurfaces.wakeUpIfDozing(0, null, "", wakeReason);
|
||||
|
||||
// THEN power manager receives wakeup
|
||||
verify(mPowerManagerService, never()).wakeUp(anyLong(), anyInt(), anyString(), anyString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the appropriate mocks and then calls {@link CentralSurfacesImpl#updateIsKeyguard}
|
||||
* to reconfigure the keyguard to reflect the requested showing/occluded states.
|
||||
@@ -1222,6 +1251,13 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
|
||||
states);
|
||||
}
|
||||
|
||||
private void setDozing(boolean isDozing) {
|
||||
ArgumentCaptor<StatusBarStateController.StateListener> callbackCaptor =
|
||||
ArgumentCaptor.forClass(StatusBarStateController.StateListener.class);
|
||||
verify(mStatusBarStateController).addCallback(callbackCaptor.capture(), anyInt());
|
||||
callbackCaptor.getValue().onDozingChanged(isDozing);
|
||||
}
|
||||
|
||||
public static class TestableNotificationInterruptStateProviderImpl extends
|
||||
NotificationInterruptStateProviderImpl {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user