Skip to content

Commit 45a25bc

Browse files
author
Dianne Hackborn
committed
Fix issue #6745498: Cannot view consecutive event details from agenda view
- There was a long-standing bug when using FLAG_ACTIVITY_REORDER_TO_FRONT where we could find and use an activity that is currently finishing. - There was a recently introduced bug where activities being destroyed would not be removed from the history stack at the time they are done being destroyed, allowing the above bug to be exposed. - Removing a task would not kill any processes associated with the app that had a different name from the app itself. Change-Id: I4401ab6d348a69e1ac4fb8f719d2c69d5a78e567
1 parent 9e608c1 commit 45a25bc

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5704,12 +5704,19 @@ private void cleanUpRemovedTaskLocked(TaskRecord tr, int flags) {
57045704

57055705
if (killProcesses) {
57065706
// Find any running processes associated with this app.
5707+
final String pkg = component.getPackageName();
57075708
ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>();
5708-
SparseArray<ProcessRecord> appProcs
5709-
= mProcessNames.getMap().get(component.getPackageName());
5710-
if (appProcs != null) {
5711-
for (int i=0; i<appProcs.size(); i++) {
5712-
procs.add(appProcs.valueAt(i));
5709+
HashMap<String, SparseArray<ProcessRecord>> pmap = mProcessNames.getMap();
5710+
for (SparseArray<ProcessRecord> uids : pmap.values()) {
5711+
for (int i=0; i<uids.size(); i++) {
5712+
ProcessRecord proc = uids.valueAt(i);
5713+
if (proc.userId != tr.userId) {
5714+
continue;
5715+
}
5716+
if (!proc.pkgList.contains(pkg)) {
5717+
continue;
5718+
}
5719+
procs.add(proc);
57135720
}
57145721
}
57155722

@@ -5720,6 +5727,7 @@ private void cleanUpRemovedTaskLocked(TaskRecord tr, int flags) {
57205727
Slog.i(TAG, "Killing " + pr.toShortString() + ": remove task");
57215728
EventLog.writeEvent(EventLogTags.AM_KILL, pr.pid,
57225729
pr.processName, pr.setAdj, "remove task");
5730+
pr.killedBackground = true;
57235731
Process.killProcessQuiet(pr.pid);
57245732
} else {
57255733
pr.waitingToKill = "remove task";
@@ -14634,6 +14642,7 @@ private final boolean updateOomAdjLocked(
1463414642
Slog.i(TAG, "Killing " + app.toShortString() + ": " + app.waitingToKill);
1463514643
EventLog.writeEvent(EventLogTags.AM_KILL, app.pid,
1463614644
app.processName, app.setAdj, app.waitingToKill);
14645+
app.killedBackground = true;
1463714646
Process.killProcessQuiet(app.pid);
1463814647
success = false;
1463914648
} else {

services/java/com/android/server/am/ActivityStack.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,9 @@ private final int findActivityInHistoryLocked(ActivityRecord r, int task) {
23472347
while (i > 0) {
23482348
i--;
23492349
ActivityRecord candidate = mHistory.get(i);
2350+
if (candidate.finishing) {
2351+
continue;
2352+
}
23502353
if (candidate.task.taskId != task) {
23512354
break;
23522355
}
@@ -4057,7 +4060,7 @@ final void activityDestroyed(IBinder token) {
40574060
int index = indexOfActivityLocked(r);
40584061
if (index >= 0) {
40594062
if (r.state == ActivityState.DESTROYING) {
4060-
cleanUpActivityLocked(r, true, true);
4063+
cleanUpActivityLocked(r, true, false);
40614064
removeActivityFromHistoryLocked(r);
40624065
}
40634066
}

0 commit comments

Comments
 (0)