From 41e7e6edc74e27235f6057def04dd9a6e18f3a8a Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Fri, 19 Jul 2019 11:47:58 -0700 Subject: Fixed a crash with the headsUpManager Since the headsUpManager is calling out in various places to its listeners, the callbacks may query the headsupmanager in an internally inconsistent state, such that the pinned mode is true but there is no topEntry. Let's add a null-check for safety here. Bug: 137804505 Test: atest SystemUITests Change-Id: Ibae76b555ca51ccf676228b034a614d59a8b4e8e --- .../com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java index 1d0d231424d1..595c1acaf56d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java @@ -301,12 +301,15 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, } public Region calculateTouchableRegion() { - if (!hasPinnedHeadsUp()) { + NotificationEntry topEntry = getTopEntry(); + // This call could be made in an inconsistent state while the pinnedMode hasn't been + // updated yet, but callbacks leading out of the headsUp manager, querying it. Let's + // therefore also check if the topEntry is null. + if (!hasPinnedHeadsUp() || topEntry == null) { mTouchableRegion.set(0, 0, mStatusBarWindowView.getWidth(), mStatusBarHeight); updateRegionForNotch(mTouchableRegion); } else { - NotificationEntry topEntry = getTopEntry(); if (topEntry.isChildInGroup()) { final NotificationEntry groupSummary = mGroupManager.getGroupSummary(topEntry.notification); -- cgit v1.2.3-59-g8ed1b