Do not reference TaskRecord's intent without checking for null.
It is possible for a TaskRecord's intent to be set to null. We should
always check this before referencing it.
Change-Id: Id0dd18dc694549c348f1cd7d2dfe02915c1c7f92
Fixes: 77457970
Test: atest FrameworksServicesTests:com.android.server.am.TaskRecordTests#testReturnsToHomeStack
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index 0e418ad..1cd1dd6 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -203,7 +203,8 @@
String rootAffinity; // Initial base affinity, or null; does not change from initial root.
final IVoiceInteractionSession voiceSession; // Voice interaction session driving task
final IVoiceInteractor voiceInteractor; // Associated interactor to provide to app
- Intent intent; // The original intent that started the task.
+ Intent intent; // The original intent that started the task. Note that this value can
+ // be null.
Intent affinityIntent; // Intent of affinity-moved activity that started this task.
int effectiveUid; // The current effective uid of the identity of this task.
ComponentName origActivity; // The non-alias activity component of the intent.
@@ -897,12 +898,12 @@
// the real activity that will be launched not the alias, so we need to use an intent with
// the component name pointing to the real activity not the alias in the activity record.
intent.setComponent(r.realActivity);
- return this.intent.filterEquals(intent);
+ return intent.filterEquals(this.intent);
}
boolean returnsToHomeStack() {
final int returnHomeFlags = FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME;
- return (intent.getFlags() & returnHomeFlags) == returnHomeFlags;
+ return intent != null && (intent.getFlags() & returnHomeFlags) == returnHomeFlags;
}
void setPrevAffiliate(TaskRecord prevAffiliate) {
@@ -2165,9 +2166,11 @@
out.endTag(null, TAG_AFFINITYINTENT);
}
- out.startTag(null, TAG_INTENT);
- intent.saveToXml(out);
- out.endTag(null, TAG_INTENT);
+ if (intent != null) {
+ out.startTag(null, TAG_INTENT);
+ intent.saveToXml(out);
+ out.endTag(null, TAG_INTENT);
+ }
final ArrayList<ActivityRecord> activities = mActivities;
final int numActivities = activities.size();