Merge "Fixed an issue where a user could't go to the locked shade from dozing" into sc-v2-dev am: 5c3d8bc297

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16631031

Change-Id: Id6d1a993dd6ff0bc7aa78cd8380f44c354f61db9
This commit is contained in:
Selim Cinek
2022-01-14 20:49:54 +00:00
committed by Automerger Merge Worker
6 changed files with 49 additions and 15 deletions

View File

@@ -138,6 +138,7 @@ public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observe
}
setWakefulness(WAKEFULNESS_AWAKE);
dispatch(Observer::onFinishedWakingUp);
dispatch(Observer::onPostFinishedWakingUp);
}
public void dispatchStartedGoingToSleep(@PowerManager.GoToSleepReason int pmSleepReason) {
@@ -236,6 +237,12 @@ public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observe
public interface Observer {
default void onStartedWakingUp() {}
default void onFinishedWakingUp() {}
/**
* Called after the finished waking up call, ensuring it's after all the other listeners,
* reacting to {@link #onFinishedWakingUp()}
*/
default void onPostFinishedWakingUp() {}
default void onStartedGoingToSleep() {}
default void onFinishedGoingToSleep() {}
}

View File

@@ -7,7 +7,6 @@ import android.animation.ValueAnimator
import android.content.Context
import android.content.res.Configuration
import android.os.SystemClock
import android.util.DisplayMetrics
import android.util.IndentingPrintWriter
import android.util.MathUtils
import android.view.MotionEvent
@@ -24,6 +23,7 @@ import com.android.systemui.classifier.Classifier
import com.android.systemui.classifier.FalsingCollector
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.media.MediaHierarchyManager
import com.android.systemui.plugins.ActivityStarter.OnDismissAction
import com.android.systemui.plugins.FalsingManager
@@ -64,6 +64,7 @@ class LockscreenShadeTransitionController @Inject constructor(
private val scrimController: ScrimController,
private val depthController: NotificationShadeDepthController,
private val context: Context,
wakefulnessLifecycle: WakefulnessLifecycle,
configurationController: ConfigurationController,
falsingManager: FalsingManager,
dumpManager: DumpManager,
@@ -119,6 +120,12 @@ class LockscreenShadeTransitionController @Inject constructor(
*/
private var nextHideKeyguardNeedsNoAnimation = false
/**
* Are we currently waking up to the shade locked
*/
var isWakingToShadeLocked: Boolean = false
private set
/**
* The distance until we're showing the notifications when pulsing
*/
@@ -160,6 +167,13 @@ class LockscreenShadeTransitionController @Inject constructor(
}
}
})
wakefulnessLifecycle.addObserver(object : WakefulnessLifecycle.Observer {
override fun onPostFinishedWakingUp() {
// when finishing waking up, the UnlockedScreenOffAnimation has another attempt
// to reset keyguard. Let's do it in post
isWakingToShadeLocked = false
}
})
}
private fun updateResources() {
@@ -488,6 +502,10 @@ class LockscreenShadeTransitionController @Inject constructor(
draggedDownEntry = entry
} else {
logger.logGoingToLockedShade(animationHandler != null)
if (statusBarStateController.isDozing) {
// Make sure we don't go back to keyguard immediately again after waking up
isWakingToShadeLocked = true
}
statusBarStateController.setState(StatusBarState.SHADE_LOCKED)
// This call needs to be after updating the shade state since otherwise
// the scrimstate resets too early
@@ -598,6 +616,7 @@ class LockscreenShadeTransitionController @Inject constructor(
it.println("dragDownAmount: $dragDownAmount")
it.println("isDragDownAnywhereEnabled: $isDragDownAnywhereEnabled")
it.println("isFalsingCheckNeeded: $isFalsingCheckNeeded")
it.println("isWakingToShadeLocked: $isWakingToShadeLocked")
it.println("hasPendingHandlerOnKeyguardDismiss: " +
"${animationHandlerOnKeyguardDismiss != null}")
}

View File

@@ -107,8 +107,6 @@ constructor(
private var mDraggedFarEnough: Boolean = false
private var mStartingChild: ExpandableView? = null
private var mPulsing: Boolean = false
var isWakingToShadeLocked: Boolean = false
private set
private var velocityTracker: VelocityTracker? = null
@@ -235,7 +233,6 @@ constructor(
mStartingChild = null
}
if (statusBarStateController.isDozing) {
isWakingToShadeLocked = true
wakeUpCoordinator.willWakeUp = true
mPowerManager!!.wakeUp(SystemClock.uptimeMillis(), WAKE_REASON_GESTURE,
"com.android.systemui:PULSEDRAG")
@@ -333,10 +330,6 @@ constructor(
mPulsing = pulsing
}
fun onStartedWakingUp() {
isWakingToShadeLocked = false
}
override fun dump(fd: FileDescriptor, pw: PrintWriter, args: Array<out String>) {
IndentingPrintWriter(pw, " ").let {
it.println("PulseExpansionHandler:")
@@ -344,7 +337,6 @@ constructor(
it.println("isExpanding: $isExpanding")
it.println("leavingLockscreen: $leavingLockscreen")
it.println("mPulsing: $mPulsing")
it.println("isWakingToShadeLocked: $isWakingToShadeLocked")
it.println("qsExpanded: $qsExpanded")
it.println("bouncerShowing: $bouncerShowing")
}

View File

@@ -2965,7 +2965,7 @@ public class StatusBar extends SystemUI implements
mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
if (mUserSwitcherController != null && mUserSwitcherController.useFullscreenUserSwitcher()) {
mStatusBarStateController.setState(StatusBarState.FULLSCREEN_USER_SWITCHER);
} else if (!mPulseExpansionHandler.isWakingToShadeLocked()) {
} else if (!mLockscreenShadeTransitionController.isWakingToShadeLocked()) {
mStatusBarStateController.setState(StatusBarState.KEYGUARD);
}
updatePanelExpansionForKeyguard();
@@ -3570,7 +3570,6 @@ public class StatusBar extends SystemUI implements
// once we fully woke up.
updateRevealEffect(true /* wakingUp */);
updateNotificationPanelTouchState();
mPulseExpansionHandler.onStartedWakingUp();
// If we are waking up during the screen off animation, we should undo making the
// expanded visible (we did that so the LightRevealScrim would be visible).

View File

@@ -80,6 +80,7 @@ public class WakefulnessLifecycleTest extends SysuiTestCase {
assertEquals(WakefulnessLifecycle.WAKEFULNESS_AWAKE, mWakefulness.getWakefulness());
verify(mWakefulnessObserver).onFinishedWakingUp();
verify(mWakefulnessObserver).onPostFinishedWakingUp();
}
@Test

View File

@@ -4,13 +4,12 @@ import android.test.suitebuilder.annotation.SmallTest
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.testing.TestableLooper.RunWithLooper
import android.util.DisplayMetrics
import com.android.systemui.ExpandHelper
import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.classifier.FalsingCollector
import com.android.systemui.dump.DumpManager
import com.android.systemui.log.LogBuffer
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.media.MediaHierarchyManager
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.plugins.qs.QS
@@ -64,12 +63,11 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() {
@Mock lateinit var lockScreenUserManager: NotificationLockscreenUserManager
@Mock lateinit var falsingCollector: FalsingCollector
@Mock lateinit var ambientState: AmbientState
@Mock lateinit var displayMetrics: DisplayMetrics
@Mock lateinit var wakefulnessLifecycle: WakefulnessLifecycle
@Mock lateinit var mediaHierarchyManager: MediaHierarchyManager
@Mock lateinit var scrimController: ScrimController
@Mock lateinit var configurationController: ConfigurationController
@Mock lateinit var falsingManager: FalsingManager
@Mock lateinit var buffer: LogBuffer
@Mock lateinit var notificationPanelController: NotificationPanelViewController
@Mock lateinit var nsslController: NotificationStackScrollLayoutController
@Mock lateinit var depthController: NotificationShadeDepthController
@@ -98,6 +96,7 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() {
mediaHierarchyManager = mediaHierarchyManager,
scrimController = scrimController,
depthController = depthController,
wakefulnessLifecycle = wakefulnessLifecycle,
context = context,
configurationController = configurationController,
falsingManager = falsingManager,
@@ -147,6 +146,23 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() {
verify(statusbarStateController).setState(StatusBarState.SHADE_LOCKED)
}
@Test
fun testWakingToShadeLockedWhenDozing() {
whenever(statusbarStateController.isDozing).thenReturn(true)
transitionController.goToLockedShade(null)
verify(statusbarStateController).setState(StatusBarState.SHADE_LOCKED)
assertTrue("Not waking to shade locked", transitionController.isWakingToShadeLocked)
}
@Test
fun testNotWakingToShadeLockedWhenNotDozing() {
whenever(statusbarStateController.isDozing).thenReturn(false)
transitionController.goToLockedShade(null)
verify(statusbarStateController).setState(StatusBarState.SHADE_LOCKED)
assertFalse("Waking to shade locked when not dozing",
transitionController.isWakingToShadeLocked)
}
@Test
fun testGoToLockedShadeOnlyOnKeyguard() {
whenever(statusbarStateController.state).thenReturn(StatusBarState.SHADE_LOCKED)