Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63acea6a authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "When removing a task, also kill its processes."

parents f03712bf 8894cc5e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -496,7 +496,7 @@ public class RecentsPanelView extends RelativeLayout
        // the task.
        final ActivityManager am = (ActivityManager)
                mContext.getSystemService(Context.ACTIVITY_SERVICE);
        am.removeTask(ad.taskId, 0);
        am.removeTask(ad.taskId, ActivityManager.REMOVE_TASK_KILL_PROCESS);
    }

    public void handleLongPress(View selectedView) {
+27 −27
Original line number Diff line number Diff line
@@ -5171,7 +5171,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    private void removeTaskProcessesLocked(ActivityRecord root) {
    private void cleanUpRemovedTaskLocked(ActivityRecord root, boolean killProcesses) {
        TaskRecord tr = root.task;
        Intent baseIntent = new Intent(
                tr.intent != null ? tr.intent : tr.affinityIntent);
@@ -5194,6 +5194,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            ServiceRecord sr = services.get(i);
            if (sr.startRequested) {
                if ((sr.serviceInfo.flags&ServiceInfo.FLAG_STOP_WITH_TASK) != 0) {
                    Slog.i(TAG, "Stopping service " + sr.shortName + ": remove task");
                    stopServiceLocked(sr);
                } else {
                    sr.pendingStarts.add(new ServiceRecord.StartItem(sr, true,
@@ -5205,6 +5206,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            }
        }
        if (killProcesses) {
            // Find any running processes associated with this app.
            ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>();
            SparseArray<ProcessRecord> appProcs
@@ -5219,7 +5221,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            for (int i=0; i<procs.size(); i++) {
                ProcessRecord pr = procs.get(i);
                if (pr.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) {
                Slog.i(TAG, "Killing " + pr + ": remove task");
                    Slog.i(TAG, "Killing " + pr.toShortString() + ": remove task");
                    EventLog.writeEvent(EventLogTags.AM_KILL, pr.pid,
                            pr.processName, pr.setAdj, "remove task");
                    Process.killProcessQuiet(pr.pid);
@@ -5228,6 +5230,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                }
            }
        }
    }
    public boolean removeTask(int taskId, int flags) {
        synchronized (this) {
@@ -5238,11 +5241,8 @@ public final class ActivityManagerService extends ActivityManagerNative
                ActivityRecord r = mMainStack.removeTaskActivitiesLocked(taskId, -1);
                if (r != null) {
                    mRecentTasks.remove(r.task);
                    if ((flags&ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0) {
                        removeTaskProcessesLocked(r);
                    }
                    cleanUpRemovedTaskLocked(r,
                            (flags&ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0);
                    return true;
                }
            } finally {
@@ -13169,7 +13169,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                        + " to " + app.curSchedGroup);
                if (app.waitingToKill != null &&
                        app.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) {
                    Slog.i(TAG, "Killing " + app + ": " + app.waitingToKill);
                    Slog.i(TAG, "Killing " + app.toShortString() + ": " + app.waitingToKill);
                    EventLog.writeEvent(EventLogTags.AM_KILL, app.pid,
                            app.processName, app.setAdj, app.waitingToKill);
                    Process.killProcessQuiet(app.pid);