From f95803f19da52c616d32075535d40196997e344e Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Wed, 9 Mar 2022 15:14:13 -0500 Subject: [PATCH] Log NPE in QSAnimator Not sure how this could happen but we may be trying to create an animator for an empty page, resulting in a null animator. In that case, instead Log the failure so we can track it better. Test: build Bug: 223632036 Change-Id: Ic8ba88ea8c392c7c9d1fccfd8c5be623db303c61 --- .../src/com/android/systemui/qs/QSAnimator.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java index d1b569f7f438c..4640205c82f5b 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java @@ -241,7 +241,13 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha private void addNonFirstPageAnimators(int page) { Pair pair = createSecondaryPageAnimators(page); - mNonFirstPageQSAnimators.put(page, pair); + if (pair != null) { + // pair is null in one of two cases: + // * mPagedTileLayout is null, meaning we are still setting up. + // * the page has no tiles + // In either case, don't add the animators to the map. + mNonFirstPageQSAnimators.put(page, pair); + } } @Override @@ -518,6 +524,13 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha SideLabelTileLayout qqsLayout = (SideLabelTileLayout) mQuickQsPanel.getTileLayout(); View view = mQs.getView(); List specs = mPagedLayout.getSpecsForPage(page); + if (specs.isEmpty()) { + // specs should not be empty in a valid secondary page, as we scrolled to it. + // We may crash later on because there's a null animator. + specs = mQsPanelController.getHost().mTileSpecs; + Log.e(TAG, "Trying to create animators for empty page " + page + ". Tiles: " + specs); + // return null; + } int row = -1; int lastTileTop = -1;