From ebf423466cff0b2db08d322dbf9772e9b1a3bbf1 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Thu, 13 Jul 2017 15:46:10 +0200 Subject: [PATCH] Fixed a bug where an incoming call wasn't launching When the lockscreen isn't showing, but aod is, an incomming call would not launch its fullscreen intent but show up in AOD1. In addition was the display completely messed up and overlapping other parts of the AOD screen. Test: receive call while in AOD but not locked Change-Id: Icc3e989167e72289ddcd0a62064526db9004cdc2 Fixes: 62402251 --- .../systemui/statusbar/NotificationShelf.java | 7 +-- .../systemui/statusbar/phone/StatusBar.java | 3 ++ .../statusbar/stack/AmbientState.java | 54 +++++++++++++++++-- .../stack/NotificationStackScrollLayout.java | 14 ++--- .../statusbar/stack/StackScrollAlgorithm.java | 6 +-- 5 files changed, 65 insertions(+), 19 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index a601028546184..e5f68ad60089d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -298,7 +298,8 @@ public class NotificationShelf extends ActivatableNotificationView implements private void updateNotificationClipHeight(ExpandableNotificationRow row, float notificationClipEnd) { float viewEnd = row.getTranslationY() + row.getActualHeight(); - boolean isPinned = row.isPinned() || row.isHeadsUpAnimatingAway(); + boolean isPinned = (row.isPinned() || row.isHeadsUpAnimatingAway()) + && !mAmbientState.isDozingAndNotPulsing(row); if (viewEnd > notificationClipEnd && (mAmbientState.isShadeExpanded() || !isPinned)) { int clipBottomAmount = (int) (viewEnd - notificationClipEnd); @@ -450,7 +451,7 @@ public class NotificationShelf extends ActivatableNotificationView implements ? fullTransitionAmount : transitionAmount; iconState.clampedAppearAmount = clampedAmount; - float contentTransformationAmount = !row.isAboveShelf() + float contentTransformationAmount = !mAmbientState.isAboveShelf(row) && (isLastChild || iconState.translateContent) ? iconTransitionAmount : 0.0f; @@ -519,7 +520,7 @@ public class NotificationShelf extends ActivatableNotificationView implements iconState.scaleY = 1.0f; iconState.hidden = false; } - if (row.isAboveShelf() || (!row.isInShelf() && (isLastChild && row.areGutsExposed() + if (mAmbientState.isAboveShelf(row) || (!row.isInShelf() && (isLastChild && row.areGutsExposed() || row.getTranslationZ() > mAmbientState.getBaseZHeight()))) { iconState.hidden = true; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 20c2ad66ec588..1a8e1a2a6cc28 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -7233,6 +7233,9 @@ public class StatusBar extends SystemUI implements DemoMode, if (mAccessibilityManager.isTouchExplorationEnabled()) { if (DEBUG) Log.d(TAG, "No peeking: accessible fullscreen: " + sbn.getKey()); return false; + } else if (mDozing) { + // We never want heads up when we are dozing. + return false; } else { // we only allow head-up on the lockscreen if it doesn't have a fullscreen intent return !mStatusBarKeyguardViewManager.isShowing() diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java index ba1e7c2d86c52..4d8da441c0395 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java @@ -21,11 +21,15 @@ import android.view.View; import com.android.systemui.R; import com.android.systemui.statusbar.ActivatableNotificationView; +import com.android.systemui.statusbar.ExpandableNotificationRow; +import com.android.systemui.statusbar.ExpandableView; +import com.android.systemui.statusbar.NotificationData; import com.android.systemui.statusbar.NotificationShelf; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.policy.HeadsUpManager; import java.util.ArrayList; +import java.util.Collection; /** * A global state to track all input states for the algorithm. @@ -59,7 +63,7 @@ public class AmbientState { private boolean mPanelTracking; private boolean mExpansionChanging; private boolean mPanelFullWidth; - private boolean mHasPulsingNotifications; + private Collection mPulsing; private boolean mUnlockHintRunning; private boolean mQsCustomizerShowing; private int mIntrinsicPadding; @@ -290,11 +294,23 @@ public class AmbientState { } public boolean hasPulsingNotifications() { - return mHasPulsingNotifications; + return mPulsing != null; } - public void setHasPulsingNotifications(boolean hasPulsing) { - mHasPulsingNotifications = hasPulsing; + public void setPulsing(Collection hasPulsing) { + mPulsing = hasPulsing; + } + + public boolean isPulsing(NotificationData.Entry entry) { + if (mPulsing == null) { + return false; + } + for (HeadsUpManager.HeadsUpEntry e : mPulsing) { + if (e.entry == entry) { + return true; + } + } + return false; } public boolean isPanelTracking() { @@ -332,4 +348,34 @@ public class AmbientState { public int getIntrinsicPadding() { return mIntrinsicPadding; } + + /** + * Similar to the normal is above shelf logic but doesn't allow it to be above in AOD1. + * + * @param expandableView the view to check + */ + public boolean isAboveShelf(ExpandableView expandableView) { + if (!(expandableView instanceof ExpandableNotificationRow)) { + return expandableView.isAboveShelf(); + } + ExpandableNotificationRow row = (ExpandableNotificationRow) expandableView; + return row.isAboveShelf() && !isDozingAndNotPulsing(row); + } + + /** + * @return whether a view is dozing and not pulsing right now + */ + public boolean isDozingAndNotPulsing(ExpandableView view) { + if (view instanceof ExpandableNotificationRow) { + return isDozingAndNotPulsing((ExpandableNotificationRow) view); + } + return false; + } + + /** + * @return whether a row is dozing and not pulsing right now + */ + public boolean isDozingAndNotPulsing(ExpandableNotificationRow row) { + return isDark() && !isPulsing(row.getEntry()); + } } 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 74523e28c4602..00973911ac0d0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -805,7 +805,7 @@ public class NotificationStackScrollLayout extends ViewGroup */ private float getAppearStartPosition() { if (mTrackingHeadsUp && mFirstVisibleBackgroundChild != null) { - if (mFirstVisibleBackgroundChild.isAboveShelf()) { + if (mAmbientState.isAboveShelf(mFirstVisibleBackgroundChild)) { // If we ever expanded beyond the first notification, it's allowed to merge into // the shelf return mFirstVisibleBackgroundChild.getPinnedHeadsUpHeight(); @@ -823,7 +823,8 @@ public class NotificationStackScrollLayout extends ViewGroup int notGoneChildCount = getNotGoneChildCount(); if (mEmptyShadeView.getVisibility() == GONE && notGoneChildCount != 0) { int minNotificationsForShelf = 1; - if (mTrackingHeadsUp || mHeadsUpManager.hasPinnedHeadsUp()) { + if (mTrackingHeadsUp + || (mHeadsUpManager.hasPinnedHeadsUp() && !mAmbientState.isDark())) { appearPosition = mHeadsUpManager.getTopHeadsUpPinnedHeight(); minNotificationsForShelf = 2; } else { @@ -2008,12 +2009,7 @@ public class NotificationStackScrollLayout extends ViewGroup } private boolean isPulsing(NotificationData.Entry entry) { - for (HeadsUpManager.HeadsUpEntry e : mPulsing) { - if (e.entry == entry) { - return true; - } - } - return false; + return mAmbientState.isPulsing(entry); } public boolean hasPulsingNotifications() { @@ -4148,7 +4144,7 @@ public class NotificationStackScrollLayout extends ViewGroup return; } mPulsing = pulsing; - mAmbientState.setHasPulsingNotifications(hasPulsingNotifications()); + mAmbientState.setPulsing(pulsing); updateNotificationAnimationStates(); updateContentHeight(); notifyHeightChangeListener(mShelf); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java index 8235bc7dde07d..f4197a3496ea2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java @@ -413,7 +413,7 @@ public class StackScrollAlgorithm { if (mIsExpanded) { // Ensure that the heads up is always visible even when scrolled off clampHunToTop(ambientState, row, childState); - if (i == 0 && row.isAboveShelf()) { + if (i == 0 && ambientState.isAboveShelf(row)) { // the first hun can't get off screen. clampHunToMaxTranslation(ambientState, row, childState); childState.hidden = false; @@ -515,7 +515,7 @@ public class StackScrollAlgorithm { ExpandableViewState childViewState = resultState.getViewStateForView(child); int zDistanceBetweenElements = ambientState.getZDistanceBetweenElements(); float baseZ = ambientState.getBaseZHeight(); - if (child.mustStayOnScreen() + if (child.mustStayOnScreen() && !ambientState.isDozingAndNotPulsing(child) && childViewState.yTranslation < ambientState.getTopPadding() + ambientState.getStackTranslation()) { if (childrenOnTop != 0.0f) { @@ -527,7 +527,7 @@ public class StackScrollAlgorithm { } childViewState.zTranslation = baseZ + childrenOnTop * zDistanceBetweenElements; - } else if (i == 0 && child.isAboveShelf()) { + } else if (i == 0 && ambientState.isAboveShelf(child)) { // In case this is a new view that has never been measured before, we don't want to // elevate if we are currently expanded more then the notification int shelfHeight = ambientState.getShelf().getIntrinsicHeight();