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

Commit ea039a80 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Start all visible running activities when attaching app

This fixes an issue where a translucent activity was on top of a
normal activity in the same process. Now, when reopening the
translucent activity after the process has been killed we only
used to start the very top activity, leaving the normal activity
in destroyed state. However, we make the activity visible already
so in window manager we are waiting for it but a window is never
added to it.

This fixes the issue by starting all activities that are visible
and running once the app is attached.

Test: go/wm-smoke
Test: Have app with translucent activity on top of normal
activity, kill app via shell, navigate back to app via recents.
Observe no excessive delay.

Change-Id: I444b7064b8e2e878fac5fa9ac8b36e0e2fe248bc
Fixes: 33269100
parent 27eb322e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -659,6 +659,13 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        return topRunningActivityLocked(false /* focusableOnly */);
    }

    void getAllRunningVisibleActivitiesLocked(ArrayList<ActivityRecord> outActivities) {
        outActivities.clear();
        for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
            mTaskHistory.get(taskNdx).getAllRunningVisibleActivitiesLocked(outActivities);
        }
    }

    private ActivityRecord topRunningActivityLocked(boolean focusableOnly) {
        for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
            ActivityRecord r = mTaskHistory.get(taskNdx).topRunningActivityLocked();
+12 −6
Original line number Diff line number Diff line
@@ -457,6 +457,8 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D

    final ActivityMetricsLogger mActivityMetricsLogger;

    private final ArrayList<ActivityRecord> mTmpActivityList = new ArrayList<>();

    @Override
    protected int getChildCount() {
        return mActivityDisplays.size();
@@ -964,17 +966,21 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
                if (!isFocusedStack(stack)) {
                    continue;
                }
                ActivityRecord hr = stack.topRunningActivityLocked();
                if (hr != null) {
                    if (hr.app == null && app.uid == hr.info.applicationInfo.uid
                            && processName.equals(hr.processName)) {
                stack.getAllRunningVisibleActivitiesLocked(mTmpActivityList);
                final ActivityRecord top = stack.topRunningActivityLocked();
                final int size = mTmpActivityList.size();
                for (int i = 0; i < size; i++) {
                    final ActivityRecord activity = mTmpActivityList.get(i);
                    if (activity.app == null && app.uid == activity.info.applicationInfo.uid
                            && processName.equals(activity.processName)) {
                        try {
                            if (realStartActivityLocked(hr, app, true, true)) {
                            if (realStartActivityLocked(activity, app,
                                    top == activity /* andResume */, true /* checkConfig */)) {
                                didSomething = true;
                            }
                        } catch (RemoteException e) {
                            Slog.w(TAG, "Exception in new application when starting activity "
                                  + hr.intent.getComponent().flattenToShortString(), e);
                                    + top.intent.getComponent().flattenToShortString(), e);
                            throw e;
                        }
                    }
+11 −0
Original line number Diff line number Diff line
@@ -1160,6 +1160,17 @@ final class TaskRecord extends ConfigurationContainer implements TaskWindowConta
        return null;
    }

    void getAllRunningVisibleActivitiesLocked(ArrayList<ActivityRecord> outActivities) {
        if (mStack != null) {
            for (int activityNdx = mActivities.size() - 1; activityNdx >= 0; --activityNdx) {
                ActivityRecord r = mActivities.get(activityNdx);
                if (!r.finishing && r.okToShowLocked() && r.visible) {
                    outActivities.add(r);
                }
            }
        }
    }

    ActivityRecord topRunningActivityWithStartingWindowLocked() {
        if (mStack != null) {
            for (int activityNdx = mActivities.size() - 1; activityNdx >= 0; --activityNdx) {