summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author lijilou <lijilou@xiaomi.corp-partner.google.com> 2024-12-02 16:54:58 +0800
committer lijilou <lijilou@xiaomi.corp-partner.google.com> 2024-12-05 14:28:26 +0800
commit92c98a7d50c754a32e416356e981d7fd239455c7 (patch)
tree93b8fbdb5d3dd22f6ec9ee2da4e25c04d3c9e2a8
parent1adb0dbc95b74059058a26c01800db9603038409 (diff)
ATMS: fix the NPE problem in case the dream activity fails to start.
When start the dream activity: Firstly, the activityrecord of the dream activity is first created in the executeRequest method, and the task of the activityrecord is empty at this time. Secondly, the startActivityInner method is called to create or get the task, but before calling the setNewTask method, there may be some startup failures, so the task of the activityrecord is still empty at this time. Finally, our solution is to determine the result of launching the activity. Test: OEM monkey test Flag: EXEMPT bugfix Bug: 381804032 Change-Id: Id7b78f2403580d752609b43fcb24a084b8a91818
-rw-r--r--services/core/java/com/android/server/wm/ActivityTaskManagerService.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index cfd5300417b4..66ed0dae53f5 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -1535,7 +1535,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
final ActivityRecord[] outActivity = new ActivityRecord[1];
- getActivityStartController().obtainStarter(intent, "dream")
+ final int res = getActivityStartController()
+ .obtainStarter(intent, "dream")
.setCallingUid(callingUid)
.setCallingPid(callingPid)
.setCallingPackage(intent.getPackage())
@@ -1549,9 +1550,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
.execute();
final ActivityRecord started = outActivity[0];
- final IAppTask appTask = started == null ? null :
- new AppTaskImpl(this, started.getTask().mTaskId, callingUid);
- return appTask;
+ if (started == null || !ActivityManager.isStartResultSuccessful(res)) {
+ // start the dream activity failed.
+ return null;
+ }
+ return new AppTaskImpl(this, started.getTask().mTaskId, callingUid);
}
}