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

Commit a1a91b0c authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Indicate PiP animation type from Launcher to SysUI

Also, need callback from SysUI to Launcher once the pip animation is
started to keep back compatibility.

Bug: 146594635
Test: manually
Merged-In: I617a17fd5f6049d9f1d49f9f834623a2bb49f6ca
Change-Id: I617a17fd5f6049d9f1d49f9f834623a2bb49f6ca
parent 98e48454
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -332,6 +332,8 @@ public class FallbackSwipeHandler extends BaseSwipeUpHandler<RecentsActivity, Fa
                    // Send a home intent to clear the task stack
                    // Send a home intent to clear the task stack
                    mContext.startActivity(mGestureState.getHomeIntent());
                    mContext.startActivity(mGestureState.getHomeIntent());
                } else {
                } else {
                    // Notify swipe-to-home (recents animation) is finished
                    SystemUiProxy.INSTANCE.get(mContext).notifySwipeToHomeFinished();
                    mRecentsAnimationController.finish(true, () -> {
                    mRecentsAnimationController.finish(true, () -> {
                        if (!mTouchedHomeDuringTransition) {
                        if (!mTouchedHomeDuringTransition) {
                            // If the user hasn't interacted with the screen during the transition,
                            // If the user hasn't interacted with the screen during the transition,
+2 −0
Original line number Original line Diff line number Diff line
@@ -699,6 +699,8 @@ public class LauncherSwipeHandler<T extends BaseDraggingActivity>
        switch (mGestureState.getEndTarget()) {
        switch (mGestureState.getEndTarget()) {
            case HOME:
            case HOME:
                mStateCallback.setState(STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT);
                mStateCallback.setState(STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT);
                // Notify swipe-to-home (recents animation) is finished
                SystemUiProxy.INSTANCE.get(mContext).notifySwipeToHomeFinished();
                break;
                break;
            case RECENTS:
            case RECENTS:
                mStateCallback.setState(STATE_SCALED_CONTROLLER_RECENTS | STATE_CAPTURE_SCREENSHOT
                mStateCallback.setState(STATE_SCALED_CONTROLLER_RECENTS | STATE_CAPTURE_SCREENSHOT
+9 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.quickstep.views;
package com.android.quickstep.views;


import static androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS;
import static androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS;

import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS;
import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS;
import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS;
import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
@@ -105,11 +106,13 @@ import com.android.quickstep.RecentsAnimationController;
import com.android.quickstep.RecentsAnimationTargets;
import com.android.quickstep.RecentsAnimationTargets;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.RecentsModel.TaskVisualsChangeListener;
import com.android.quickstep.RecentsModel.TaskVisualsChangeListener;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.TaskThumbnailCache;
import com.android.quickstep.TaskThumbnailCache;
import com.android.quickstep.TaskUtils;
import com.android.quickstep.TaskUtils;
import com.android.quickstep.ViewUtils;
import com.android.quickstep.ViewUtils;
import com.android.quickstep.util.AppWindowAnimationHelper;
import com.android.quickstep.util.AppWindowAnimationHelper;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.util.LayoutUtils;
import com.android.systemui.shared.recents.IPinnedStackAnimationListener;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -261,7 +264,10 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
                }
                }
            });
            });
        }
        }
    };


    private final IPinnedStackAnimationListener mIPinnedStackAnimationListener =
            new IPinnedStackAnimationListener.Stub() {
        @Override
        @Override
        public void onPinnedStackAnimationStarted() {
        public void onPinnedStackAnimationStarted() {
            // Needed for activities that auto-enter PiP, which will not trigger a remote
            // Needed for activities that auto-enter PiP, which will not trigger a remote
@@ -443,6 +449,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        mSyncTransactionApplier = new SyncRtSurfaceTransactionApplierCompat(this);
        mSyncTransactionApplier = new SyncRtSurfaceTransactionApplierCompat(this);
        RecentsModel.INSTANCE.get(getContext()).addThumbnailChangeListener(this);
        RecentsModel.INSTANCE.get(getContext()).addThumbnailChangeListener(this);
        mIdp.addOnChangeListener(this);
        mIdp.addOnChangeListener(this);
        SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener(
                mIPinnedStackAnimationListener);
    }
    }


    @Override
    @Override
@@ -455,6 +463,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        mSyncTransactionApplier = null;
        mSyncTransactionApplier = null;
        RecentsModel.INSTANCE.get(getContext()).removeThumbnailChangeListener(this);
        RecentsModel.INSTANCE.get(getContext()).removeThumbnailChangeListener(this);
        mIdp.removeOnChangeListener(this);
        mIdp.removeOnChangeListener(this);
        SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener(null);
    }
    }


    @Override
    @Override
+30 −3
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import android.util.Log;
import android.view.MotionEvent;
import android.view.MotionEvent;


import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.systemui.shared.recents.IPinnedStackAnimationListener;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;


/**
/**
@@ -268,9 +269,7 @@ public class SystemUiProxy implements ISystemUiProxy {
        }
        }
    }
    }


    /**
    @Override
     * See SharedApiCompat#setShelfHeight()
     */
    public void setShelfHeight(boolean visible, int shelfHeight) {
    public void setShelfHeight(boolean visible, int shelfHeight) {
        boolean changed = visible != mLastShelfVisible || shelfHeight != mLastShelfHeight;
        boolean changed = visible != mLastShelfVisible || shelfHeight != mLastShelfHeight;
        if (mSystemUiProxy != null && changed) {
        if (mSystemUiProxy != null && changed) {
@@ -306,4 +305,32 @@ public class SystemUiProxy implements ISystemUiProxy {
            }
            }
        }
        }
    }
    }

    /**
     * Notifies that swipe-to-home action is finished.
     */
    @Override
    public void notifySwipeToHomeFinished() {
        if (mSystemUiProxy != null) {
            try {
                mSystemUiProxy.notifySwipeToHomeFinished();
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call setPinnedStackAnimationType", e);
            }
        }
    }

    /**
     * Sets listener to get pinned stack animation callbacks.
     */
    @Override
    public void setPinnedStackAnimationListener(IPinnedStackAnimationListener listener) {
        if (mSystemUiProxy != null) {
            try {
                mSystemUiProxy.setPinnedStackAnimationListener(listener);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call setPinnedStackAnimationListener", e);
            }
        }
    }
}
}