Fix for activity manager crash due to null task
Use top.task instead of mStartActivity.task, since in case of reusing
top without starting, the latter will not be set.
bug: 28059153
Change-Id: I91ec59203ca9ae650ad1d14fb9a42985a539d597
diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java
index 771d5b2..6fba8c8 100644
--- a/services/core/java/com/android/server/am/ActivityStarter.java
+++ b/services/core/java/com/android/server/am/ActivityStarter.java
@@ -986,8 +986,12 @@
}
top.deliverNewIntentLocked(
mCallingUid, mStartActivity.intent, mStartActivity.launchedFromPackage);
- mSupervisor.handleNonResizableTaskIfNeeded(mStartActivity.task,
- preferredLaunchStackId, topStack.mStackId);
+
+ // Don't use mStartActivity.task to show the toast. We're not starting a new activity
+ // but reusing 'top'. Fields in mStartActivity may not be fully initialized.
+ mSupervisor.handleNonResizableTaskIfNeeded(
+ top.task, preferredLaunchStackId, topStack.mStackId);
+
return START_DELIVERED_TO_TOP;
}