Add support PIP for One UI 5.1 core (#4028)
This commit is contained in:
@@ -1561,9 +1561,10 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, Q extends
|
||||
? mRecentsAnimationTargets
|
||||
.findTask(mGestureState.getTopRunningTaskId())
|
||||
: null;
|
||||
var taskInfo = mGestureState.getRunningTask().mAllCachedTasks.get(0);
|
||||
final ArrayList<IBinder> cookies = Utilities.ATLEAST_S && runningTaskTarget != null
|
||||
&& runningTaskTarget.taskInfo != null
|
||||
? runningTaskTarget.taskInfo.launchCookies
|
||||
&& taskInfo != null
|
||||
? taskInfo.launchCookies
|
||||
: new ArrayList<>();
|
||||
boolean isTranslucent = runningTaskTarget != null && runningTaskTarget.isTranslucent;
|
||||
boolean hasValidLeash = runningTaskTarget != null
|
||||
@@ -1573,8 +1574,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, Q extends
|
||||
&& hasValidLeash
|
||||
&& Utilities.ATLEAST_T
|
||||
&& runningTaskTarget.allowEnterPip
|
||||
&& runningTaskTarget.taskInfo.pictureInPictureParams != null
|
||||
&& runningTaskTarget.taskInfo.pictureInPictureParams.isAutoEnterEnabled();
|
||||
&& taskInfo.pictureInPictureParams != null
|
||||
&& taskInfo.pictureInPictureParams.isAutoEnterEnabled();
|
||||
HomeAnimationFactory homeAnimFactory = createHomeAnimationFactory(cookies, duration, isTranslucent,
|
||||
appCanEnterPip,
|
||||
runningTaskTarget);
|
||||
@@ -1597,6 +1598,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, Q extends
|
||||
mRecentsAnimationController.screenshotTask(taskId));
|
||||
});
|
||||
|
||||
if (mSwipePipToHomeAnimator == null) return;
|
||||
|
||||
// let SystemUi reparent the overlay leash as soon as possible
|
||||
SystemUiProxy.INSTANCE.get(mContext).stopSwipePipToHome(
|
||||
mSwipePipToHomeAnimator.getTaskId(),
|
||||
@@ -1715,7 +1718,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, Q extends
|
||||
private SwipePipToHomeAnimator createWindowAnimationToPip(HomeAnimationFactory homeAnimFactory,
|
||||
RemoteAnimationTarget runningTaskTarget, float startProgress) {
|
||||
// Directly animate the app to PiP (picture-in-picture) mode
|
||||
final ActivityManager.RunningTaskInfo taskInfo = runningTaskTarget.taskInfo;
|
||||
final ActivityManager.RunningTaskInfo taskInfo = mGestureState.getRunningTask().mAllCachedTasks.get(0);
|
||||
final RecentsOrientedState orientationState = mRemoteTargetHandles[0].getTaskViewSimulator()
|
||||
.getOrientationState();
|
||||
final int windowRotation = calculateWindowRotation(runningTaskTarget, orientationState);
|
||||
@@ -1731,11 +1734,13 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, Q extends
|
||||
windowToHomePositionMap.mapRect(startRect);
|
||||
|
||||
final Rect hotseatKeepClearArea = getKeepClearAreaForHotseat();
|
||||
if (taskInfo == null) return null;
|
||||
final Rect destinationBounds = SystemUiProxy.INSTANCE.get(mContext)
|
||||
.startSwipePipToHome(taskInfo.topActivity,
|
||||
taskInfo.topActivityInfo,
|
||||
runningTaskTarget.taskInfo.pictureInPictureParams,
|
||||
taskInfo.pictureInPictureParams,
|
||||
homeRotation,
|
||||
mDp.hotseatBarSizePx,
|
||||
hotseatKeepClearArea);
|
||||
if (destinationBounds == null) {
|
||||
// No destination bounds returned from SystemUI, bail early.
|
||||
@@ -1759,7 +1764,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, Q extends
|
||||
.setAppIconSizePx(mDp.iconSizePx)
|
||||
.setLeash(runningTaskTarget.leash)
|
||||
.setSourceRectHint(
|
||||
runningTaskTarget.taskInfo.pictureInPictureParams.getSourceRectHint())
|
||||
taskInfo.pictureInPictureParams.getSourceRectHint())
|
||||
.setAppBounds(appBounds)
|
||||
.setHomeToWindowPositionMap(homeToWindowPositionMap)
|
||||
.setStartBounds(startRect)
|
||||
@@ -2214,7 +2219,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, Q extends
|
||||
* This should happen before {@link #finishRecentsControllerToHome(Runnable)}.
|
||||
*/
|
||||
private void maybeFinishSwipePipToHome() {
|
||||
if (mIsSwipingPipToHome && mSwipePipToHomeAnimators[0] != null) {
|
||||
if (mIsSwipingPipToHome && mSwipePipToHomeAnimators[0] != null && mRecentsAnimationController != null) {
|
||||
|
||||
mRecentsAnimationController.setFinishTaskTransaction(
|
||||
mSwipePipToHomeAnimator.getTaskId(),
|
||||
mSwipePipToHomeAnimator.getFinishTransaction(),
|
||||
|
||||
@@ -83,6 +83,7 @@ import com.android.wm.shell.desktopmode.IDesktopMode;
|
||||
import com.android.wm.shell.desktopmode.IDesktopTaskListener;
|
||||
import com.android.wm.shell.draganddrop.IDragAndDrop;
|
||||
import com.android.wm.shell.onehanded.IOneHanded;
|
||||
import com.android.wm.shell.pip.PipData;
|
||||
import com.android.wm.shell.pip.IPip;
|
||||
import com.android.wm.shell.pip.IPipAnimationListener;
|
||||
import com.android.wm.shell.recents.IRecentTasks;
|
||||
@@ -625,14 +626,19 @@ public class SystemUiProxy implements ISystemUiProxy {
|
||||
*/
|
||||
@Nullable
|
||||
public Rect startSwipePipToHome(ComponentName componentName, ActivityInfo activityInfo,
|
||||
PictureInPictureParams pictureInPictureParams, int launcherRotation,
|
||||
PictureInPictureParams pictureInPictureParams, int launcherRotation, int hotseatBarSize,
|
||||
Rect hotseatKeepClearArea) {
|
||||
if (mPip != null) {
|
||||
try {
|
||||
return mPip.startSwipePipToHome(componentName, activityInfo,
|
||||
pictureInPictureParams, launcherRotation, hotseatKeepClearArea);
|
||||
pictureInPictureParams, launcherRotation, new PipData(hotseatBarSize));
|
||||
} catch (Throwable e) {
|
||||
Log.w(TAG, "Failed call startSwipePipToHome", e);
|
||||
try {
|
||||
return mPip.startSwipePipToHome(componentName, activityInfo,
|
||||
pictureInPictureParams, launcherRotation, new PipData(hotseatKeepClearArea));
|
||||
} catch (Throwable t) {
|
||||
Log.w(TAG, "Failed call startSwipePipToHome", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user