diff options
| author | 2018-12-05 18:15:35 -0800 | |
|---|---|---|
| committer | 2018-12-05 18:19:52 -0800 | |
| commit | 48c0ed0844f137e89cd2285ff7aa55a8963f5197 (patch) | |
| tree | fa58381db7b9e38e81dcc2e91c990a276362acfc | |
| parent | 6f5ea0c11a79087dd1fa7c50dd77ff93a06aac05 (diff) | |
Fix NPE when trying to access task before AppWindowToken attach to one
This is a race condition. While create AppWindowToken, before attach to
a task container.addChild(), accessing task attached to the token will
cause an NPE. The root cause can be fixed after we unifying Task and
TaskRecord. Just post a temporary solution here to avoid crash.
Bug: 120197396
Test: go/wm-smoke
Change-Id: I37008c16546e02358d9f88d1c9fd544002357137
| -rw-r--r-- | services/core/java/com/android/server/wm/ActivityRecord.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 255a003bb542..09fce79bbcaf 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -1086,6 +1086,12 @@ final class ActivityRecord extends ConfigurationContainer { Slog.w(TAG_WM, "Attempted to set icon of non-existing app token: " + appToken); return false; } + if (mAppWindowToken.getTask() == null) { + // Can be removed after unification of Task and TaskRecord. + Slog.w(TAG_WM, "Attempted to start a window to an app token not having attached to any" + + " task: " + appToken); + return false; + } return mAppWindowToken.addStartingWindow(pkg, theme, compatInfo, nonLocalizedLabel, labelRes, icon, logo, windowFlags, transferFrom, newTask, taskSwitch, processRunning, allowTaskSnapshot, activityCreated, fromRecents); |