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

Commit fb7eb2e6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "PiP: Update DisplayInfo and movement bounds if display is different."

parents c6ac5e15 17b79c09
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -118,6 +118,13 @@ public class PipBoundsHandler {
        mDisplayLayout.set(newDisplayLayout);
        mDisplayLayout.set(newDisplayLayout);
    }
    }


    /**
     * Get the current saved display info.
     */
    public DisplayInfo getDisplayInfo() {
        return mDisplayInfo;
    }

    /**
    /**
     * Update the Min edge size for {@link PipSnapAlgorithm} to calculate corresponding bounds
     * Update the Min edge size for {@link PipSnapAlgorithm} to calculate corresponding bounds
     * @param minEdgeSize
     * @param minEdgeSize
+16 −0
Original line number Original line Diff line number Diff line
@@ -79,6 +79,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Objects;
import java.util.Optional;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Consumer;
import java.util.function.IntConsumer;


/**
/**
 * Manages PiP tasks such as resize and offset.
 * Manages PiP tasks such as resize and offset.
@@ -248,6 +249,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
    private PipSurfaceTransactionHelper.SurfaceControlTransactionFactory
    private PipSurfaceTransactionHelper.SurfaceControlTransactionFactory
            mSurfaceControlTransactionFactory;
            mSurfaceControlTransactionFactory;
    private PictureInPictureParams mPictureInPictureParams;
    private PictureInPictureParams mPictureInPictureParams;
    private IntConsumer mOnDisplayIdChangeCallback;


    /**
    /**
     * If set to {@code true}, the entering animation will be skipped and we will wait for
     * If set to {@code true}, the entering animation will be skipped and we will wait for
@@ -314,6 +316,13 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        mPipTransitionCallbacks.add(callback);
        mPipTransitionCallbacks.add(callback);
    }
    }


    /**
     * Registers a callback when a display change has been detected when we enter PiP.
     */
    public void registerOnDisplayIdChangeCallback(IntConsumer onDisplayIdChangeCallback) {
        mOnDisplayIdChangeCallback = onDisplayIdChangeCallback;
    }

    /**
    /**
     * Sets the preferred animation type for one time.
     * Sets the preferred animation type for one time.
     * This is typically used to set the animation type to
     * This is typically used to set the animation type to
@@ -477,6 +486,13 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        mPipUiEventLoggerLogger.setTaskInfo(mTaskInfo);
        mPipUiEventLoggerLogger.setTaskInfo(mTaskInfo);
        mPipUiEventLoggerLogger.log(PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_ENTER);
        mPipUiEventLoggerLogger.log(PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_ENTER);


        // If the displayId of the task is different than what PipBoundsHandler has, then update
        // it. This is possible if we entered PiP on an external display.
        if (info.displayId != mPipBoundsHandler.getDisplayInfo().displayId
                && mOnDisplayIdChangeCallback != null) {
            mOnDisplayIdChangeCallback.accept(info.displayId);
        }

        if (mShouldIgnoreEnteringPipTransition) {
        if (mShouldIgnoreEnteringPipTransition) {
            // Animation has been finished together with Recents, directly apply the sync
            // Animation has been finished together with Recents, directly apply the sync
            // transaction to PiP here.
            // transaction to PiP here.
+8 −0
Original line number Original line Diff line number Diff line
@@ -228,6 +228,14 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
        mPipBoundsState = pipBoundsState;
        mPipBoundsState = pipBoundsState;
        mPipTaskOrganizer = pipTaskOrganizer;
        mPipTaskOrganizer = pipTaskOrganizer;
        mPipTaskOrganizer.registerPipTransitionCallback(this);
        mPipTaskOrganizer.registerPipTransitionCallback(this);
        mPipTaskOrganizer.registerOnDisplayIdChangeCallback((int displayId) -> {
            final DisplayInfo newDisplayInfo = new DisplayInfo();
            displayController.getDisplay(displayId).getDisplayInfo(newDisplayInfo);
            mPipBoundsHandler.onDisplayInfoChanged(newDisplayInfo);
            updateMovementBounds(null /* toBounds */, false /* fromRotation */,
                    false /* fromImeAdjustment */, false /* fromShelfAdustment */,
                    null /* wct */);
        });
        mMediaController = pipMediaController;
        mMediaController = pipMediaController;
        mMenuController = pipMenuActivityController;
        mMenuController = pipMenuActivityController;
        mTouchHandler = pipTouchHandler;
        mTouchHandler = pipTouchHandler;