summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff DeCew <jeffdq@google.com> 2021-05-10 21:12:29 -0400
committer Jeff DeCew <jeffdq@google.com> 2021-06-08 16:52:32 -0400
commit042fb825609027aaccf135e0353befacba18887c (patch)
tree15d9979e790a3963384975ab46319c496d2103b3
parente054e5445b158fbb3370a36f9b7e430077fde60e (diff)
Fix lockscreen notification + media counting.
Background: A regression was introduced when something about the MediaHeaderView's visibility was changed, which caused that view to be counted when showing notifications but not when counting how many should be shown. That regression caused b/188000471 which was fixed by ag/I93b4b6039eb812619787744f893fe1924e1afc4d. However, that fix only addressed half the problem, as it resulted in the media player always being shown, regardless of the hard-coded notification max. This change brings the logic of these two methods in line with each other, so that the number of notifications shown *includes* the media player, but ensures that a zero-heignt media player is not treated as a notification (similar to how any GONE views are ignored). Fixes: 189102584 Test: manual Change-Id: Ic7447941593f08ed504f3870af5a72d2628a043e
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java37
2 files changed, 26 insertions, 17 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index 9390c81a847b..2c2a17001326 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -2097,11 +2097,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
if (height != 0) {
height += mPaddingBetweenElements;
}
- height += calculateGapHeight(previousView, expandableView, numShownItems);
+ float gapHeight = calculateGapHeight(previousView, expandableView, numShownNotifs);
+ height += gapHeight;
height += viewHeight;
numShownItems++;
- if (!(expandableView instanceof MediaHeaderView)) {
+ if (viewHeight > 0 || !(expandableView instanceof MediaHeaderView)) {
+ // Only count the media as a notification if it has a positive height.
numShownNotifs++;
}
previousView = expandableView;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
index 32b3e51076d3..8808f5fc0301 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -139,6 +139,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.notification.stack.AmbientState;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
+import com.android.systemui.statusbar.notification.stack.MediaHeaderView;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
@@ -1329,21 +1330,27 @@ public class NotificationPanelViewController extends PanelViewController {
ExpandableView previousView = null;
for (int i = 0; i < mNotificationStackScrollLayoutController.getChildCount(); i++) {
ExpandableView child = mNotificationStackScrollLayoutController.getChildAt(i);
- if (!(child instanceof ExpandableNotificationRow)) {
- continue;
- }
- ExpandableNotificationRow row = (ExpandableNotificationRow) child;
- boolean
- suppressedSummary =
- mGroupManager != null && mGroupManager.isSummaryOfSuppressedGroup(
- row.getEntry().getSbn());
- if (suppressedSummary) {
- continue;
- }
- if (!canShowViewOnLockscreen(child)) {
- continue;
- }
- if (row.isRemoved()) {
+ if (child instanceof ExpandableNotificationRow) {
+ ExpandableNotificationRow row = (ExpandableNotificationRow) child;
+ boolean suppressedSummary = mGroupManager != null
+ && mGroupManager.isSummaryOfSuppressedGroup(row.getEntry().getSbn());
+ if (suppressedSummary) {
+ continue;
+ }
+ if (!canShowViewOnLockscreen(child)) {
+ continue;
+ }
+ if (row.isRemoved()) {
+ continue;
+ }
+ } else if (child instanceof MediaHeaderView) {
+ if (child.getVisibility() == GONE) {
+ continue;
+ }
+ if (child.getIntrinsicHeight() == 0) {
+ continue;
+ }
+ } else {
continue;
}
availableSpace -= child.getMinHeight(true /* ignoreTemporaryStates */);