From e7ff7be645bce83218c35a059b03fa6f23ddb4ed Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Tue, 17 Sep 2019 11:19:53 -0400 Subject: [PATCH] Avoid going to SHADE_LOCKED when already in SHADE It's not possible for the device to go to SHADE_LOCKED after you're already unlocked, still it's possible that it would happen. Added an extra condition to avoid it, and logs to catch the regression if it happens again. Fixes: 139259891 Test: pull down notification while authenticating Change-Id: I5c2b81906fa444dfd07d040b81a527245d4130e6 --- .../android/systemui/statusbar/PulseExpansionHandler.kt | 7 +++++-- .../systemui/statusbar/StatusBarStateControllerImpl.java | 6 ++++++ .../statusbar/phone/NotificationPanelViewTest.java | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt index 276afa7a3a94d..a70dc7c0ec5d1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt @@ -33,6 +33,7 @@ import com.android.systemui.Gefingerpoken import com.android.systemui.Interpolators import com.android.systemui.R import com.android.systemui.plugins.FalsingManager +import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.notification.row.ExpandableView @@ -56,7 +57,8 @@ constructor( private val wakeUpCoordinator: NotificationWakeUpCoordinator, private val bypassController: KeyguardBypassController, private val headsUpManager: HeadsUpManagerPhone, - private val roundnessManager: NotificationRoundnessManager + private val roundnessManager: NotificationRoundnessManager, + private val statusBarStateController: StatusBarStateController ) : Gefingerpoken { companion object { private val RUBBERBAND_FACTOR_STATIC = 0.25f @@ -188,7 +190,8 @@ constructor( MotionEvent.ACTION_MOVE -> updateExpansionHeight(moveDistance) MotionEvent.ACTION_UP -> { velocityTracker!!.computeCurrentVelocity(1000 /* units */) - val canExpand = moveDistance > 0 && velocityTracker!!.getYVelocity() > -1000 + val canExpand = moveDistance > 0 && velocityTracker!!.getYVelocity() > -1000 && + statusBarStateController.state != StatusBarState.SHADE if (!mFalsingManager.isUnlockingDisabled && !isFalseTouch && canExpand) { finishExpansion() } else { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java index f0eeb046bc44e..abf29c47e803b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java @@ -20,6 +20,7 @@ import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.text.format.DateFormat; import android.util.FloatProperty; +import android.util.Log; import android.view.View; import android.view.animation.Interpolator; @@ -136,6 +137,11 @@ public class StatusBarStateControllerImpl implements SysuiStatusBarStateControll // Record the to-be mState and mLastState recordHistoricalState(state, mState); + // b/139259891 + if (mState == StatusBarState.SHADE && state == StatusBarState.SHADE_LOCKED) { + Log.e(TAG, "Invalid state transition: SHADE -> SHADE_LOCKED", new Throwable()); + } + synchronized (mListeners) { for (RankedListener rl : new ArrayList<>(mListeners)) { rl.mListener.onStatePreChange(mState, state); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java index 0334d49ce9dfb..f94779d6d5cad 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java @@ -129,7 +129,7 @@ public class NotificationPanelViewTest extends SysuiTestCase { mKeyguardBypassController); PulseExpansionHandler expansionHandler = new PulseExpansionHandler(mContext, coordinator, mKeyguardBypassController, mHeadsUpManager, - mock(NotificationRoundnessManager.class)); + mock(NotificationRoundnessManager.class), mStatusBarStateController); mNotificationPanelView = new TestableNotificationPanelView(coordinator, expansionHandler, mKeyguardBypassController); mNotificationPanelView.setHeadsUpManager(mHeadsUpManager);