From 5b1591abd19c2379d3796b3db023fbffc1be740a Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Mon, 3 Jul 2017 17:05:01 +0200 Subject: [PATCH] Fixed an issue where a notification could stay userlocked With the fingerprint gesture a user could get a notification into a state where it remained userlocked. We're now not only cancelling the expand helper when the shade is collapsed but also clearing all userlocked flags. Test: runtest systemui Change-Id: Ibf0b29375242daf627ec9b5233a8720a9c01dbf6 Fixes: 63055586 --- .../com/android/systemui/ExpandHelper.java | 26 ++++++++++++++-- .../stack/NotificationStackScrollLayout.java | 31 ++++++++++++++----- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java index 7fed3e81682e1..377fab549a7e0 100644 --- a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java +++ b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java @@ -545,6 +545,16 @@ public class ExpandHelper implements Gefingerpoken { */ @VisibleForTesting void finishExpanding(boolean forceAbort, float velocity) { + finishExpanding(forceAbort, velocity, true /* allowAnimation */); + } + + /** + * Finish the current expand motion + * @param forceAbort whether the expansion should be forcefully aborted and returned to the old + * state + * @param velocity the velocity this was expanded/ collapsed with + */ + private void finishExpanding(boolean forceAbort, float velocity, boolean allowAnimation) { if (!mExpanding) return; if (DEBUG) Log.d(TAG, "scale in finishing on view: " + mResizedView); @@ -568,7 +578,7 @@ public class ExpandHelper implements Gefingerpoken { mCallback.expansionStateChanged(false); int naturalHeight = mScaler.getNaturalHeight(); float targetHeight = nowExpanded ? naturalHeight : mSmallSize; - if (targetHeight != currentHeight && mEnabled) { + if (targetHeight != currentHeight && mEnabled && allowAnimation) { mScaleAnimation.setFloatValues(targetHeight); mScaleAnimation.setupStartValues(); final View scaledView = mResizedView; @@ -621,11 +631,23 @@ public class ExpandHelper implements Gefingerpoken { mResizedView = null; } + /** + * Use this to abort any pending expansions in progress and force that there will be no + * animations. + */ + public void cancelImmediately() { + cancel(false /* allowAnimation */); + } + /** * Use this to abort any pending expansions in progress. */ public void cancel() { - finishExpanding(true /* forceAbort */, 0f /* velocity */); + cancel(true /* allowAnimation */); + } + + private void cancel(boolean allowAnimation) { + finishExpanding(true /* forceAbort */, 0f /* velocity */, allowAnimation); clearView(); // reset the gesture detector diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index cbd315b940f3c..8c0a55670e87d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -3358,15 +3358,29 @@ public class NotificationStackScrollLayout extends ViewGroup if (!mIsExpanded) { setOwnScrollY(0); mStatusBar.resetUserExpandedStates(); + clearTemporaryViews(); + clearUserLockedViews(); + } + } - // lets make sure nothing is in the overlay / transient anymore - clearTemporaryViews(this); - for (int i = 0; i < getChildCount(); i++) { - ExpandableView child = (ExpandableView) getChildAt(i); - if (child instanceof ExpandableNotificationRow) { - ExpandableNotificationRow row = (ExpandableNotificationRow) child; - clearTemporaryViews(row.getChildrenContainer()); - } + private void clearUserLockedViews() { + for (int i = 0; i < getChildCount(); i++) { + ExpandableView child = (ExpandableView) getChildAt(i); + if (child instanceof ExpandableNotificationRow) { + ExpandableNotificationRow row = (ExpandableNotificationRow) child; + row.setUserLocked(false); + } + } + } + + private void clearTemporaryViews() { + // lets make sure nothing is in the overlay / transient anymore + clearTemporaryViews(this); + for (int i = 0; i < getChildCount(); i++) { + ExpandableView child = (ExpandableView) getChildAt(i); + if (child instanceof ExpandableNotificationRow) { + ExpandableNotificationRow row = (ExpandableNotificationRow) child; + clearTemporaryViews(row.getChildrenContainer()); } } } @@ -3401,6 +3415,7 @@ public class NotificationStackScrollLayout extends ViewGroup if (changed) { if (!mIsExpanded) { mGroupManager.collapseAllGroups(); + mExpandHelper.cancelImmediately(); } updateNotificationAnimationStates(); updateChronometers();