Report dead activities as paused to stats.
Also tell stats about pause before dispatching to remote side.
Change-Id: I975d0fba65515fa768127792d5aa7976df2ba2d3
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index a37ee96..5a2e88a 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2528,10 +2528,6 @@
}
}
- void reportResumedActivityLocked(ActivityRecord r) {
- updateUsageStats(r, true);
- }
-
private void dispatchProcessesChanged() {
int N;
synchronized (this) {
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index c1208cf..c6ce90d 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -788,9 +788,9 @@
EventLog.writeEvent(EventLogTags.AM_PAUSE_ACTIVITY,
prev.userId, System.identityHashCode(prev),
prev.shortComponentName);
+ mService.updateUsageStats(prev, false);
prev.app.thread.schedulePauseActivity(prev.appToken, prev.finishing,
userLeaving, prev.configChangeFlags);
- mService.updateUsageStats(prev, false);
} catch (Exception e) {
// Ignore exception, if process died other code will cleanup.
Slog.w(TAG, "Exception thrown during pause", e);
@@ -2883,6 +2883,9 @@
r.userId, System.identityHashCode(r),
r.task.taskId, r.shortComponentName,
"proc died without state saved");
+ if (r.state == ActivityState.RESUMED) {
+ mService.updateUsageStats(r, false);
+ }
}
removeActivityFromHistoryLocked(r);
diff --git a/services/java/com/android/server/am/ActivityStackSupervisor.java b/services/java/com/android/server/am/ActivityStackSupervisor.java
index 82944a9..ab9aa36 100644
--- a/services/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/java/com/android/server/am/ActivityStackSupervisor.java
@@ -1921,7 +1921,7 @@
boolean reportResumedActivityLocked(ActivityRecord r) {
final ActivityStack stack = r.task.stack;
if (isFrontStack(stack)) {
- mService.reportResumedActivityLocked(r);
+ mService.updateUsageStats(r, true);
mService.setFocusedActivityLocked(r);
}
if (allResumedActivitiesComplete()) {