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

Commit eb0a7dee authored by Kazuki Takise's avatar Kazuki Takise
Browse files

Only dispatch onPipUiStateChanged when it's not finishing

ATMS#onPictureInPictureUiStateChanged() checks the existence of
ActivityRecord before dispatching the callback, but if the
activity finishes itself, the client-side instance might be
invalid already at this point.

Bug: 325986364
Test: atest ActivityLifecyclePipTests#testDestroyPip
Change-Id: I5eb6503cb0bf3132ef4fa87360f9e45842435ad0
parent 5b476f04
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -102,6 +102,9 @@ import static com.android.server.wm.ActivityInterceptorCallback.MAINLINE_FIRST_O
import static com.android.server.wm.ActivityInterceptorCallback.MAINLINE_LAST_ORDERED_ID;
import static com.android.server.wm.ActivityInterceptorCallback.SYSTEM_FIRST_ORDERED_ID;
import static com.android.server.wm.ActivityInterceptorCallback.SYSTEM_LAST_ORDERED_ID;
import static com.android.server.wm.ActivityRecord.State.DESTROYED;
import static com.android.server.wm.ActivityRecord.State.DESTROYING;
import static com.android.server.wm.ActivityRecord.State.FINISHING;
import static com.android.server.wm.ActivityRecord.State.PAUSING;
import static com.android.server.wm.ActivityRecord.State.RESUMED;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_ACTIVITY_STARTS;
@@ -4167,7 +4170,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            task = mRootWindowContainer.getDefaultTaskDisplayArea().getRootTask(
                    t -> t.isActivityTypeStandard());
        }
        if (task != null && task.getTopMostActivity() != null) {
        if (task != null && task.getTopMostActivity() != null
                && !task.getTopMostActivity().isState(FINISHING, DESTROYING, DESTROYED)) {
            mWindowManager.mAtmService.mActivityClientController.onPictureInPictureUiStateChanged(
                    task.getTopMostActivity(), pipState);
        }