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

Commit 2befe0b8 authored by jorgegil@google.com's avatar jorgegil@google.com
Browse files

Use updated source rect hint in PIP exit animation

This change does a couple of things:
1. Make sure to use the latest sourceRectHint when starting the exit
animation.
2. Remove deferral of the call to ITaskOrg#onTaskInfoChanged from
ATM#setPipParams so that the updated rect hint can be received in
PipTaskOrganizer without waiting for WindowContainer#prepareSurfaces
to be called.

Bug: 167447693
Test: exit animation performs uncrop and scale using new rect
provided by test app after re-layout on exit PIP

Change-Id: I2a2be39f65adf5ee88f3351950d6707e8e53f089
parent 4a11c440
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -406,9 +406,13 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
                @Override
                public void onTransactionReady(int id, SurfaceControl.Transaction t) {
                    t.apply();
                    scheduleAnimateResizePip(mPipBoundsState.getBounds(),
                            destinationBounds, getValidSourceHintRect(mTaskInfo, destinationBounds),
                            direction, animationDurationMs, null /* updateBoundsCallback */);
                    // Make sure to grab the latest source hint rect as it could have been updated
                    // right after applying the windowing mode change.
                    final Rect sourceHintRect = getValidSourceHintRect(mPictureInPictureParams,
                            destinationBounds);
                    scheduleAnimateResizePip(mPipBoundsState.getBounds(), destinationBounds,
                            sourceHintRect, direction, animationDurationMs,
                            null /* updateBoundsCallback */);
                    mState = State.EXITING_PIP;
                }
            });
@@ -503,7 +507,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        final Rect currentBounds = mTaskInfo.configuration.windowConfiguration.getBounds();

        if (mOneShotAnimationType == ANIM_TYPE_BOUNDS) {
            final Rect sourceHintRect = getValidSourceHintRect(info, currentBounds);
            final Rect sourceHintRect = getValidSourceHintRect(info.pictureInPictureParams,
                    currentBounds);
            scheduleAnimateResizePip(currentBounds, destinationBounds, sourceHintRect,
                    TRANSITION_DIRECTION_TO_PIP, mEnterExitAnimationDuration,
                    null /* updateBoundsCallback */);
@@ -520,10 +525,10 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
     * Returns the source hint rect if it is valid (if provided and is contained by the current
     * task bounds).
     */
    private Rect getValidSourceHintRect(ActivityManager.RunningTaskInfo info, Rect sourceBounds) {
        final Rect sourceHintRect = info.pictureInPictureParams != null
                && info.pictureInPictureParams.hasSourceBoundsHint()
                ? info.pictureInPictureParams.getSourceRectHint()
    private Rect getValidSourceHintRect(PictureInPictureParams params, Rect sourceBounds) {
        final Rect sourceHintRect = params != null
                && params.hasSourceBoundsHint()
                ? params.getSourceRectHint()
                : null;
        if (sourceHintRect != null && sourceBounds.contains(sourceHintRect)) {
            return sourceHintRect;
+21 −22
Original line number Diff line number Diff line
@@ -162,17 +162,18 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
                return;
            }
            ProtoLog.v(WM_DEBUG_WINDOW_ORGANIZER, "Task info changed taskId=%d", task.mTaskId);
            mDeferTaskOrgCallbacksConsumer.accept(() -> {
            if (!task.isOrganized()) {
                // This is safe to ignore if the task is no longer organized
                return;
            }
            try {
                // Purposely notify of task info change immediately instead of deferring (like
                // appear and vanish) to allow info changes (such as new PIP params) to flow
                // without waiting.
                mTaskOrganizer.onTaskInfoChanged(taskInfo);
            } catch (RemoteException e) {
                Slog.e(TAG, "Exception sending onTaskInfoChanged callback", e);
            }
            });
        }

        void onBackPressedOnTaskRoot(Task task) {
@@ -183,7 +184,6 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
                // by the organizer that don't receive that signal
                return;
            }
            mDeferTaskOrgCallbacksConsumer.accept(() -> {
            if (!task.isOrganized()) {
                // This is safe to ignore if the task is no longer organized
                return;
@@ -193,7 +193,6 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
            } catch (Exception e) {
                Slog.e(TAG, "Exception sending onBackPressedOnTaskRoot callback", e);
            }
            });
        }
    }