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

Commit 1c22d5e1 authored by Robert Horvath's avatar Robert Horvath Committed by Jacqueline Bronger
Browse files

Change TV PiP enter/exit transitions

TV PiP enters/exits with an alpha animation with slight zoom.

Bug: 228071323
Test: manual
Change-Id: I9de1e2d229d3e0a2793c5900b47394e875414d98
parent b7c89a1b
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2023 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<resources>
    <integer name="config_tvPipEnterFadeOutDuration">500</integer>
    <integer name="config_tvPipEnterFadeInDuration">1500</integer>
    <integer name="config_tvPipExitFadeOutDuration">500</integer>
    <integer name="config_tvPipExitFadeInDuration">500</integer>
</resources>
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -258,7 +258,7 @@ public class PipBoundsState {
            ActivityTaskManager.getService().onPictureInPictureStateChanged(
                    new PictureInPictureUiState(stashedState != STASH_TYPE_NONE /* isStashed */)
            );
        } catch (RemoteException e) {
        } catch (RemoteException | IllegalStateException e) {
            ProtoLog.e(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                    "%s: Unable to set alert PiP state change.", TAG);
        }
+18 −17
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.content.Context;
import android.os.Handler;
import android.os.SystemClock;

import androidx.annotation.NonNull;

import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.WindowManagerShellWrapper;
import com.android.wm.shell.common.DisplayController;
@@ -41,7 +43,6 @@ import com.android.wm.shell.pip.PipAnimationController;
import com.android.wm.shell.pip.PipParamsChangedForwarder;
import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
import com.android.wm.shell.pip.PipTaskOrganizer;
import com.android.wm.shell.pip.PipTransitionController;
import com.android.wm.shell.pip.PipTransitionState;
import com.android.wm.shell.pip.tv.TvPipBoundsAlgorithm;
import com.android.wm.shell.pip.tv.TvPipBoundsController;
@@ -78,11 +79,12 @@ public abstract class TvPipModule {
            PipDisplayLayoutState pipDisplayLayoutState,
            TvPipBoundsAlgorithm tvPipBoundsAlgorithm,
            TvPipBoundsController tvPipBoundsController,
            PipTransitionState pipTransitionState,
            PipAppOpsListener pipAppOpsListener,
            PipTaskOrganizer pipTaskOrganizer,
            TvPipMenuController tvPipMenuController,
            PipMediaController pipMediaController,
            PipTransitionController pipTransitionController,
            TvPipTransition tvPipTransition,
            TvPipNotificationController tvPipNotificationController,
            TaskStackListenerImpl taskStackListener,
            PipParamsChangedForwarder pipParamsChangedForwarder,
@@ -99,9 +101,10 @@ public abstract class TvPipModule {
                        pipDisplayLayoutState,
                        tvPipBoundsAlgorithm,
                        tvPipBoundsController,
                        pipTransitionState,
                        pipAppOpsListener,
                        pipTaskOrganizer,
                        pipTransitionController,
                        tvPipTransition,
                        tvPipMenuController,
                        pipMediaController,
                        tvPipNotificationController,
@@ -151,25 +154,23 @@ public abstract class TvPipModule {
        return new LegacySizeSpecSource(context, pipDisplayLayoutState);
    }

    // Handler needed for loadDrawableAsync() in PipControlsViewController
    @WMSingleton
    @Provides
    static PipTransitionController provideTvPipTransition(
    static TvPipTransition provideTvPipTransition(
            Context context,
            ShellInit shellInit,
            ShellTaskOrganizer shellTaskOrganizer,
            Transitions transitions,
            @NonNull ShellInit shellInit,
            @NonNull ShellTaskOrganizer shellTaskOrganizer,
            @NonNull Transitions transitions,
            TvPipBoundsState tvPipBoundsState,
            PipDisplayLayoutState pipDisplayLayoutState,
            PipTransitionState pipTransitionState,
            TvPipMenuController pipMenuController,
            TvPipMenuController tvPipMenuController,
            TvPipBoundsAlgorithm tvPipBoundsAlgorithm,
            PipTransitionState pipTransitionState,
            PipAnimationController pipAnimationController,
            PipSurfaceTransactionHelper pipSurfaceTransactionHelper) {
            PipSurfaceTransactionHelper pipSurfaceTransactionHelper,
            PipDisplayLayoutState pipDisplayLayoutState) {
        return new TvPipTransition(context, shellInit, shellTaskOrganizer, transitions,
                tvPipBoundsState, pipDisplayLayoutState, pipTransitionState, pipMenuController,
                tvPipBoundsAlgorithm, pipAnimationController, pipSurfaceTransactionHelper,
                Optional.empty());
                tvPipBoundsState, tvPipMenuController, tvPipBoundsAlgorithm, pipTransitionState,
                pipAnimationController, pipSurfaceTransactionHelper, pipDisplayLayoutState);
    }

    @WMSingleton
@@ -207,7 +208,7 @@ public abstract class TvPipModule {
            PipTransitionState pipTransitionState,
            TvPipBoundsAlgorithm tvPipBoundsAlgorithm,
            PipAnimationController pipAnimationController,
            PipTransitionController pipTransitionController,
            TvPipTransition tvPipTransition,
            PipParamsChangedForwarder pipParamsChangedForwarder,
            PipSurfaceTransactionHelper pipSurfaceTransactionHelper,
            Optional<SplitScreenController> splitScreenControllerOptional,
@@ -217,7 +218,7 @@ public abstract class TvPipModule {
        return new TvPipTaskOrganizer(context,
                syncTransactionQueue, pipTransitionState, tvPipBoundsState, pipDisplayLayoutState,
                tvPipBoundsAlgorithm, tvPipMenuController, pipAnimationController,
                pipSurfaceTransactionHelper, pipTransitionController, pipParamsChangedForwarder,
                pipSurfaceTransactionHelper, tvPipTransition, pipParamsChangedForwarder,
                splitScreenControllerOptional, displayController, pipUiEventLogger,
                shellTaskOrganizer, mainExecutor);
    }
+21 −1
Original line number Diff line number Diff line
@@ -81,15 +81,35 @@ public class PipSurfaceTransactionHelper {
     */
    public PipSurfaceTransactionHelper scale(SurfaceControl.Transaction tx, SurfaceControl leash,
            Rect sourceBounds, Rect destinationBounds) {
        mTmpDestinationRectF.set(destinationBounds);
        return scale(tx, leash, sourceBounds, mTmpDestinationRectF, 0 /* degrees */);
    }

    /**
     * Operates the scale (setMatrix) on a given transaction and leash
     * @return same {@link PipSurfaceTransactionHelper} instance for method chaining
     */
    public PipSurfaceTransactionHelper scale(SurfaceControl.Transaction tx, SurfaceControl leash,
            Rect sourceBounds, RectF destinationBounds) {
        return scale(tx, leash, sourceBounds, destinationBounds, 0 /* degrees */);
    }

    /**
     * Operates the scale (setMatrix) on a given transaction and leash, along with a rotation.
     * Operates the scale (setMatrix) on a given transaction and leash
     * @return same {@link PipSurfaceTransactionHelper} instance for method chaining
     */
    public PipSurfaceTransactionHelper scale(SurfaceControl.Transaction tx, SurfaceControl leash,
            Rect sourceBounds, Rect destinationBounds, float degrees) {
        mTmpDestinationRectF.set(destinationBounds);
        return scale(tx, leash, sourceBounds, mTmpDestinationRectF, degrees);
    }

    /**
     * Operates the scale (setMatrix) on a given transaction and leash, along with a rotation.
     * @return same {@link PipSurfaceTransactionHelper} instance for method chaining
     */
    public PipSurfaceTransactionHelper scale(SurfaceControl.Transaction tx, SurfaceControl leash,
            Rect sourceBounds, RectF destinationBounds, float degrees) {
        mTmpSourceRectF.set(sourceBounds);
        // We want the matrix to position the surface relative to the screen coordinates so offset
        // the source to 0,0
+8 −4
Original line number Diff line number Diff line
@@ -292,9 +292,9 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
    // changed RunningTaskInfo when it finishes.
    private ActivityManager.RunningTaskInfo mDeferredTaskInfo;
    private WindowContainerToken mToken;
    private SurfaceControl mLeash;
    protected SurfaceControl mLeash;
    protected PipTransitionState mPipTransitionState;
    private PipSurfaceTransactionHelper.SurfaceControlTransactionFactory
    protected PipSurfaceTransactionHelper.SurfaceControlTransactionFactory
            mSurfaceControlTransactionFactory;
    protected PictureInPictureParams mPictureInPictureParams;
    private IntConsumer mOnDisplayIdChangeCallback;
@@ -968,7 +968,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
            return;
        }

        cancelCurrentAnimator();
        cancelAnimationOnTaskVanished();
        onExitPipFinished(info);

        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
@@ -976,6 +976,10 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        }
    }

    protected void cancelAnimationOnTaskVanished() {
        cancelCurrentAnimator();
    }

    @Override
    public void onTaskInfoChanged(ActivityManager.RunningTaskInfo info) {
        Objects.requireNonNull(mToken, "onTaskInfoChanged requires valid existing mToken");
@@ -1095,7 +1099,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
    }

    /** Called when exiting PIP transition is finished to do the state cleanup. */
    void onExitPipFinished(TaskInfo info) {
    public void onExitPipFinished(TaskInfo info) {
        ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                "onExitPipFinished: %s, state=%s leash=%s",
                info.topActivity, mPipTransitionState, mLeash);
Loading