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

Commit 352aa3d1 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Remove host activity association when removing EmbeddedWindow

The common steps to destroy an activity is first to remove its window
and then the activity record. So if EmbeddedWindow is removed when
removing the window, onActivityRemoved won't be able to match.

If an ActivityRecord is removed, its window will also be removed.
So it can simply clean the host records when removing EmbeddedWindow.

Bug: 296535363
Test: Launch "Wallpaper & style" from home several times.
  > adb shell dumpsys activity p | grep -A2 "Remote Activities"
  The output should only show one record per owner process.
  And then remove the task from recents.
  > adb shell dumpsys activity p | grep "Remote Activities"
  The output should be empty.
Change-Id: Iebe96417ed5be1832995ad7649408c28e6c0f58c
parent 558f38ac
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -4364,7 +4364,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // Reset the last saved PiP snap fraction on removal.
        mDisplayContent.mPinnedTaskController.onActivityHidden(mActivityComponent);
        mDisplayContent.onRunningActivityChanged();
        mWmService.mEmbeddedWindowController.onActivityRemoved(this);
        mRemovingFromDisplay = false;
    }

+7 −13
Original line number Diff line number Diff line
@@ -135,19 +135,6 @@ class EmbeddedWindowController {
        return mWindowsByWindowToken.get(windowToken);
    }

    void onActivityRemoved(ActivityRecord activityRecord) {
        for (int i = mWindows.size() - 1; i >= 0; i--) {
            final EmbeddedWindow window = mWindows.valueAt(i);
            if (window.mHostActivityRecord == activityRecord) {
                final WindowProcessController processController =
                        mAtmService.getProcessController(window.mOwnerPid, window.mOwnerUid);
                if (processController != null) {
                    processController.removeHostActivity(activityRecord);
                }
            }
        }
    }

    static class EmbeddedWindow implements InputTarget {
        final IWindow mClient;
        @Nullable final WindowState mHostWindowState;
@@ -230,6 +217,13 @@ class EmbeddedWindowController {
                mInputChannel.dispose();
                mInputChannel = null;
            }
            if (mHostActivityRecord != null) {
                final WindowProcessController wpc =
                        mWmService.mAtmService.getProcessController(mOwnerPid, mOwnerUid);
                if (wpc != null) {
                    wpc.removeHostActivity(mHostActivityRecord);
                }
            }
        }

        @Override