Do not depend on task activities decrementing with finish.
It is possible for a task to be cleared when a single activity is
finished. For example, if only task overlays are present after an
activity is removed, the task can be cleared under certain
conditions. As a result, we can not rely on only a single activity
being removed from a task when it is finished.
This changelist addresses this issue by caching the list of actvities
under a task that will not be modified as activities are finished.
Change-Id: Id3b0813deebd0bc31b2ff7ae7f69a2833dcb0a61
Fixes: 64291682
Test: atest FrameworksServicesTests:com.android.server.am.ActivityStackTests#testFinishDisabledPackageActivities
Test: atest FrameworksServicesTests:com.android.server.am.ActivityStackTests#testHandleAppDied
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index 6f6e0d9..8174f40 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -2002,7 +2002,7 @@
} else if (intent != null) {
sb.append(" I=");
sb.append(intent.getComponent().flattenToShortString());
- } else if (affinityIntent != null) {
+ } else if (affinityIntent != null && affinityIntent.getComponent() != null) {
sb.append(" aI=");
sb.append(affinityIntent.getComponent().flattenToShortString());
} else {