Prevent potential NPE of checking task drawn for logger

The place is only called from:
1. notifyActivityLaunched (more likely)
   The activity must be launched successfully so ideally its
   task shouldn't be null.
2. notifyVisibilityChanged
   The only caller (setVisibility) has checked non-null
   parent (task).

Still add a simple check for the unknown case.

Bug: 189540136
Test: ActivityMetricsLaunchObserverTests
Change-Id: Iae4a3ad1ae35f1a206d5cf47c7e41e0013aa5077
This commit is contained in:
Riddle Hsu
2021-05-31 12:40:07 +08:00
parent 0a40c03eb1
commit 7fe18ea17d

View File

@@ -790,7 +790,7 @@ class ActivityMetricsLogger {
// window drawn event should report later to complete the transition. Otherwise all
// activities in this task may be finished, invisible or drawn, so the transition event
// should be cancelled.
if (t.forAllActivities(
if (t != null && t.forAllActivities(
a -> a.mVisibleRequested && !a.isReportedDrawn() && !a.finishing)) {
return;
}