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

Commit e254d4eb authored by Louis Chang's avatar Louis Chang Committed by Automerger Merge Worker
Browse files

Merge "Continue the pausing process after automatically entering pip" into...

Merge "Continue the pausing process after automatically entering pip" into sc-v2-dev am: 0234494d am: eab1e2c0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16000210

Change-Id: I793dc344d02ce217ac739f65416372011f29dd2e
parents f4fb946f eab1e2c0
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -3422,9 +3422,15 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                final List<RemoteAction> actions = r.pictureInPictureArgs.getActions();
                mRootWindowContainer.moveActivityToPinnedRootTask(
                        r, "enterPictureInPictureMode");
                final Task rootTask = r.getRootTask();
                rootTask.setPictureInPictureAspectRatio(aspectRatio);
                rootTask.setPictureInPictureActions(actions);
                final Task task = r.getTask();
                task.setPictureInPictureAspectRatio(aspectRatio);
                task.setPictureInPictureActions(actions);

                // Continue the pausing process after entering pip.
                if (task.getPausingActivity() == r) {
                    task.schedulePauseActivity(r, false /* userLeaving */,
                            false /* pauseImmediately */, "auto-pip");
                }
            }
        };

+21 −17
Original line number Diff line number Diff line
@@ -1428,23 +1428,8 @@ class TaskFragment extends WindowContainer<WindowContainer> {
                        + "directly: %s", prev);

                didAutoPip = mAtmService.enterPictureInPictureMode(prev, prev.pictureInPictureArgs);
                mPausingActivity = null;
            } else {
                ProtoLog.v(WM_DEBUG_STATES, "Enqueueing pending pause: %s", prev);
                try {
                    EventLogTags.writeWmPauseActivity(prev.mUserId, System.identityHashCode(prev),
                            prev.shortComponentName, "userLeaving=" + userLeaving, reason);

                    mAtmService.getLifecycleManager().scheduleTransaction(prev.app.getThread(),
                            prev.appToken, PauseActivityItem.obtain(prev.finishing, userLeaving,
                                    prev.configChangeFlags, pauseImmediately));
                } catch (Exception e) {
                    // Ignore exception, if process died other code will cleanup.
                    Slog.w(TAG, "Exception thrown during pause", e);
                    mPausingActivity = null;
                    mLastPausedActivity = null;
                    mTaskSupervisor.mNoHistoryActivities.remove(prev);
                }
                schedulePauseActivity(prev, userLeaving, pauseImmediately, reason);
            }
        } else {
            mPausingActivity = null;
@@ -1459,7 +1444,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
        }

        // If already entered PIP mode, no need to keep pausing.
        if (mPausingActivity != null && !didAutoPip) {
        if (mPausingActivity != null) {
            // Have the window manager pause its key dispatching until the new
            // activity has started.  If we're pausing the activity just because
            // the screen is being turned off and the UI is sleeping, don't interrupt
@@ -1494,6 +1479,25 @@ class TaskFragment extends WindowContainer<WindowContainer> {
        }
    }

    void schedulePauseActivity(ActivityRecord prev, boolean userLeaving,
            boolean pauseImmediately, String reason) {
        ProtoLog.v(WM_DEBUG_STATES, "Enqueueing pending pause: %s", prev);
        try {
            EventLogTags.writeWmPauseActivity(prev.mUserId, System.identityHashCode(prev),
                    prev.shortComponentName, "userLeaving=" + userLeaving, reason);

            mAtmService.getLifecycleManager().scheduleTransaction(prev.app.getThread(),
                    prev.appToken, PauseActivityItem.obtain(prev.finishing, userLeaving,
                            prev.configChangeFlags, pauseImmediately));
        } catch (Exception e) {
            // Ignore exception, if process died other code will cleanup.
            Slog.w(TAG, "Exception thrown during pause", e);
            mPausingActivity = null;
            mLastPausedActivity = null;
            mTaskSupervisor.mNoHistoryActivities.remove(prev);
        }
    }

    @VisibleForTesting
    void completePause(boolean resumeNext, ActivityRecord resuming) {
        // Complete the pausing process of a pausing activity, so it doesn't make sense to