From e859a82468af8824d996e66e9440e7bc08eb8d02 Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Mon, 19 Apr 2021 13:13:06 -0500 Subject: [PATCH] Add null checks for notification shelf Fixes: 185751571 Test: manual Change-Id: I30ab2b75ba7b87036325fe2a4685f041e8aa01bf --- .../stack/StackScrollAlgorithm.java | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java index 3e1a7816c2b2d..6cacec71db39a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java @@ -272,13 +272,15 @@ public class StackScrollAlgorithm { currentY += mGapHeight; } - // Save index of first view in the shelf - final float shelfStart = ambientState.getStackEndHeight() - - ambientState.getShelf().getIntrinsicHeight(); - if (currentY >= shelfStart - && !(view instanceof FooterView) - && state.firstViewInShelf == null) { - state.firstViewInShelf = view; + if (ambientState.getShelf() != null) { + // Save index of first view in the shelf + final float shelfStart = ambientState.getStackEndHeight() + - ambientState.getShelf().getIntrinsicHeight(); + if (currentY >= shelfStart + && !(view instanceof FooterView) + && state.firstViewInShelf == null) { + state.firstViewInShelf = view; + } } // Record y position when fully expanded @@ -298,10 +300,14 @@ public class StackScrollAlgorithm { float sectionEnd = state.expansionData.get(sectionEndView).fullyExpandedY + sectionEndView.getIntrinsicHeight(); - // If we show the shelf, trim section end to shelf start - // This means section end > start for views in the shelf - if (state.firstViewInShelf != null && sectionEnd > shelfStart) { - sectionEnd = shelfStart; + if (ambientState.getShelf() != null) { + // If we show the shelf, trim section end to shelf start + // This means section end > start for views in the shelf + final float shelfStart = ambientState.getStackEndHeight() + - ambientState.getShelf().getIntrinsicHeight(); + if (state.firstViewInShelf != null && sectionEnd > shelfStart) { + sectionEnd = shelfStart; + } } // Update section bounds of every view in the previous section @@ -460,7 +466,7 @@ public class StackScrollAlgorithm { && i >= algorithmState.visibleChildren.indexOf( algorithmState.firstViewInShelf) && !(view instanceof FooterView); - } else { + } else if (ambientState.getShelf() != null) { // When pulsing (incoming notification on AOD), innerHeight is 0; clamp all // to shelf start, thereby hiding all notifications (except the first one, which we // later unhide in updatePulsingState)