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

Commit 9da2d403 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix swiping away recents to always kill processes.

This would only kill processes if there were activities associated
with the recent task; now it always kills processes.

Always fix some debug output.

Change-Id: Iccda19ba0a20823347b06c13b450587283d28284
parent 5108b1b3
Loading
Loading
Loading
Loading
+11 −8
Original line number Original line Diff line number Diff line
@@ -5443,15 +5443,16 @@ public final class ActivityManagerService extends ActivityManagerNative
                    "removeSubTask()");
                    "removeSubTask()");
            long ident = Binder.clearCallingIdentity();
            long ident = Binder.clearCallingIdentity();
            try {
            try {
                return mMainStack.removeTaskActivitiesLocked(taskId, subTaskIndex) != null;
                return mMainStack.removeTaskActivitiesLocked(taskId, subTaskIndex,
                        true) != null;
            } finally {
            } finally {
                Binder.restoreCallingIdentity(ident);
                Binder.restoreCallingIdentity(ident);
            }
            }
        }
        }
    }
    }
    private void cleanUpRemovedTaskLocked(ActivityRecord root, boolean killProcesses) {
    private void cleanUpRemovedTaskLocked(TaskRecord tr, int flags) {
        TaskRecord tr = root.task;
        final boolean killProcesses = (flags&ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0;
        Intent baseIntent = new Intent(
        Intent baseIntent = new Intent(
                tr.intent != null ? tr.intent : tr.affinityIntent);
                tr.intent != null ? tr.intent : tr.affinityIntent);
        ComponentName component = baseIntent.getComponent();
        ComponentName component = baseIntent.getComponent();
@@ -5462,7 +5463,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        // Find any running services associated with this app.
        // Find any running services associated with this app.
        ArrayList<ServiceRecord> services = new ArrayList<ServiceRecord>();
        ArrayList<ServiceRecord> services = new ArrayList<ServiceRecord>();
        for (ServiceRecord sr : mServiceMap.getAllServices(root.userId)) {
        for (ServiceRecord sr : mServiceMap.getAllServices(tr.userId)) {
            if (sr.packageName.equals(component.getPackageName())) {
            if (sr.packageName.equals(component.getPackageName())) {
                services.add(sr);
                services.add(sr);
            }
            }
@@ -5517,11 +5518,11 @@ public final class ActivityManagerService extends ActivityManagerNative
                    "removeTask()");
                    "removeTask()");
            long ident = Binder.clearCallingIdentity();
            long ident = Binder.clearCallingIdentity();
            try {
            try {
                ActivityRecord r = mMainStack.removeTaskActivitiesLocked(taskId, -1);
                ActivityRecord r = mMainStack.removeTaskActivitiesLocked(taskId, -1,
                        false);
                if (r != null) {
                if (r != null) {
                    mRecentTasks.remove(r.task);
                    mRecentTasks.remove(r.task);
                    cleanUpRemovedTaskLocked(r,
                    cleanUpRemovedTaskLocked(r.task, flags);
                            (flags&ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0);
                    return true;
                    return true;
                } else {
                } else {
                    TaskRecord tr = null;
                    TaskRecord tr = null;
@@ -5539,6 +5540,8 @@ public final class ActivityManagerService extends ActivityManagerNative
                            // Caller is just removing a recent task that is
                            // Caller is just removing a recent task that is
                            // not actively running.  That is easy!
                            // not actively running.  That is easy!
                            mRecentTasks.remove(i);
                            mRecentTasks.remove(i);
                            cleanUpRemovedTaskLocked(tr, flags);
                            return true;
                        } else {
                        } else {
                            Slog.w(TAG, "removeTask: task " + taskId
                            Slog.w(TAG, "removeTask: task " + taskId
                                    + " does not have activities to remove, "
                                    + " does not have activities to remove, "
@@ -9360,7 +9363,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    boolean dumpProvidersLocked(FileDescriptor fd, PrintWriter pw, String[] args,
    boolean dumpProvidersLocked(FileDescriptor fd, PrintWriter pw, String[] args,
            int opti, boolean dumpAll, String dumpPackage) {
            int opti, boolean dumpAll, String dumpPackage) {
        boolean needSep = false;
        boolean needSep = true;
        ItemMatcher matcher = new ItemMatcher();
        ItemMatcher matcher = new ItemMatcher();
        matcher.build(args, opti);
        matcher.build(args, opti);
+8 −3
Original line number Original line Diff line number Diff line
@@ -4011,10 +4011,13 @@ final class ActivityStack {
        return info;
        return info;
    }
    }


    public ActivityRecord removeTaskActivitiesLocked(int taskId, int subTaskIndex) {
    public ActivityRecord removeTaskActivitiesLocked(int taskId, int subTaskIndex,
            boolean taskRequired) {
        TaskAccessInfo info = getTaskAccessInfoLocked(taskId, false);
        TaskAccessInfo info = getTaskAccessInfoLocked(taskId, false);
        if (info.root == null) {
        if (info.root == null) {
            if (taskRequired) {
                Slog.w(TAG, "removeTaskLocked: unknown taskId " + taskId);
                Slog.w(TAG, "removeTaskLocked: unknown taskId " + taskId);
            }
            return null;
            return null;
        }
        }


@@ -4025,7 +4028,9 @@ final class ActivityStack {
        }
        }


        if (subTaskIndex >= info.subtasks.size()) {
        if (subTaskIndex >= info.subtasks.size()) {
            if (taskRequired) {
                Slog.w(TAG, "removeTaskLocked: unknown subTaskIndex " + subTaskIndex);
                Slog.w(TAG, "removeTaskLocked: unknown subTaskIndex " + subTaskIndex);
            }
            return null;
            return null;
        }
        }


+1 −1
Original line number Original line Diff line number Diff line
@@ -157,7 +157,7 @@ class ContentProviderRecord extends ContentProviderHolder {
        sb.append("ContentProviderRecord{");
        sb.append("ContentProviderRecord{");
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        sb.append(' ');
        sb.append(' ');
        sb.append(info.name);
        sb.append(name.flattenToShortString());
        sb.append('}');
        sb.append('}');
        return stringName = sb.toString();
        return stringName = sb.toString();
    }
    }
+14 −10
Original line number Original line Diff line number Diff line
@@ -183,16 +183,20 @@ public class ProviderMap {
                r.dump(pw, "    ");
                r.dump(pw, "    ");
            } else {
            } else {
                pw.print("  * ");
                pw.print("  * ");
                pw.print(r.name.toShortString());
                pw.println(r);
                /*
                if (r.proc != null) {
                if (r.app != null) {
                    pw.print("    proc=");
                    pw.println(":");
                    pw.println(r.proc);
                    pw.print("      ");
                }
                    pw.println(r.app);
                if (r.launchingApp != null) {
                } else {
                    pw.print("    launchingApp=");
                    pw.println();
                    pw.println(r.launchingApp);
                }
                if (r.clients.size() > 0 || r.externalProcessNoHandleCount > 0) {
                    pw.print("    "); pw.print(r.clients.size());
                            pw.print(" clients, "); pw.print(r.externalProcessNoHandleCount);
                            pw.println(" external handles");
                }
                }
                */
            }
            }
        }
        }
    }
    }
+1 −1

File changed.

Contains only whitespace changes.