From 4c4013805bd9ec08c583d9a8ba24f5122b2c39b4 Mon Sep 17 00:00:00 2001 From: Bryce Lee Date: Tue, 13 Mar 2018 19:23:03 -0700 Subject: [PATCH] Check if last resumed activity is null before resuming. Previous implementation did not encounter this issue as the resumed activity was simply assigned to the stack member variable. Since we now rely on a callback from the activity record, we must check to see if the record is null before invoking #setState on it. Test: atest CtsAutoFillServiceTestCases:android.autofillservice.cts.SessionLifecycleTest#testDatasetVisibleWhileAutofilledAppIsLifecycled Bug: 74604879 Change-Id: Icead81d44a826260145f72549a9caa0fb62d6af3 --- services/core/java/com/android/server/am/ActivityStack.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index 2d7520eacafaa..934ae58daf4d7 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -2707,9 +2707,12 @@ class ActivityStack extends ConfigurationContai if (DEBUG_STATES) Slog.v(TAG_STATES, "Resume failed; resetting state to " + lastState + ": " + next); next.setState(lastState, "resumeTopActivityInnerLocked"); - if (lastStack != null) { + + // lastResumedActivity being non-null implies there is a lastStack present. + if (lastResumedActivity != null) { lastResumedActivity.setState(RESUMED, "resumeTopActivityInnerLocked"); } + Slog.i(TAG, "Restarting because process died: " + next); if (!next.hasBeenLaunched) { next.hasBeenLaunched = true;