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

Commit 7a1a3a0c authored by Rachit Jain's avatar Rachit Jain
Browse files

Background crashed apps are not removed from WM hierarchy

- In Automotive portrait UI, there can be multiple tasks inside a root
  task as well. Instead of checking for all the root tasks, check for
all leaf tasks.
- When some non visible activity crashes in the background, the activity
  record is not updated and is not removed from the WM hierarchy.

Bug: 327676365

Test: m
Test: Open NDO application -> Put car in driving mode -> Crash the NDO
app. The process with its ActivityRecord should be removed.

Change-Id: Ie27dc106d938bf84ce22148e7cabceb8f13e35d9
parent 45b07080
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -2341,7 +2341,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
    }

    /**
     * Finish the topmost activities in all root tasks that belong to the crashed app.
     * Finish the topmost activities in all leaf tasks that belong to the crashed app.
     *
     * @param app    The app that crashed.
     * @param reason Reason to perform this action.
@@ -2352,14 +2352,14 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
    Task finishTopCrashedActivities(WindowProcessController app, String reason) {
        Task focusedRootTask = getTopDisplayFocusedRootTask();
        final Task[] finishedTask = new Task[1];
        forAllRootTasks(rootTask -> {
        forAllLeafTasks(leafTask -> {
            final boolean recordTopOrVisible = finishedTask[0] == null
                    && (focusedRootTask == rootTask || rootTask.isVisibleRequested());
            final Task t = rootTask.finishTopCrashedActivityLocked(app, reason);
                    && (focusedRootTask == leafTask.getRootTask() || leafTask.isVisibleRequested());
            final Task t = leafTask.finishTopCrashedActivityLocked(app, reason);
            if (recordTopOrVisible) {
                finishedTask[0] = t;
            }
        });
        }, true);
        return finishedTask[0];
    }