Avoid making post state to RESUMED for a PAUSING activity
Make sure the client post execution lifecycle state to RESUMED
only if the activity was RESUMED while delivering new intent.
Bug: 135715788
Test: making skype calls
Test: atest ActivityThreadTest
Change-Id: I1e3054e1d1611aecf6ddf6d482abf2cb3ebdf9a4
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 0faea61..371a943 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -1616,8 +1616,11 @@
try {
ArrayList<ReferrerIntent> ar = new ArrayList<>(1);
ar.add(rintent);
+ // Making sure the client state is RESUMED after transaction completed and doing
+ // so only if activity is currently RESUMED. Otherwise, client may have extra
+ // life-cycle calls to RESUMED (and PAUSED later).
mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
- NewIntentItem.obtain(ar));
+ NewIntentItem.obtain(ar, mState == RESUMED));
unsent = false;
} catch (RemoteException e) {
Slog.w(TAG, "Exception thrown sending new intent to " + this, e);
diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java
index 30e866b..6bed462 100644
--- a/services/core/java/com/android/server/wm/ActivityStack.java
+++ b/services/core/java/com/android/server/wm/ActivityStack.java
@@ -2964,7 +2964,8 @@
}
if (next.newIntents != null) {
- transaction.addCallback(NewIntentItem.obtain(next.newIntents));
+ transaction.addCallback(
+ NewIntentItem.obtain(next.newIntents, true /* resume */));
}
// Well the app will no longer be stopped.