Cleanup on aborting auto-enter-pip

Note that this change does not fix the bug listed here. This is to
ensure WMShell can cleanup its internal state when the bug happens to
avoid further confusions in WMShell.

Bug: 283177443
Test: adb shell dumpsys activity service SystemUIService WMShell
Test: go/winscope and check the SF/WM dump
Change-Id: I3804d57458a20f6a1c41963a704fae8bb28f0392
This commit is contained in:
Hongwei Wang
2023-05-18 11:27:12 -07:00
parent b02d5b38ac
commit 1c64f9fbad
3 changed files with 40 additions and 6 deletions

View File

@@ -56,28 +56,36 @@ interface IPip {
oneway void stopSwipePipToHome(int taskId, in ComponentName componentName,
in Rect destinationBounds, in SurfaceControl overlay) = 2;
/**
* Notifies the swiping Activity to PiP onto home transition is aborted
*
* @param taskId the Task id that the Activity and overlay are currently in.
* @param componentName ComponentName represents the Activity
*/
oneway void abortSwipePipToHome(int taskId, in ComponentName componentName) = 3;
/**
* Sets listener to get pinned stack animation callbacks.
*/
oneway void setPipAnimationListener(IPipAnimationListener listener) = 3;
oneway void setPipAnimationListener(IPipAnimationListener listener) = 4;
/**
* Sets the shelf height and visibility.
*/
oneway void setShelfHeight(boolean visible, int shelfHeight) = 4;
oneway void setShelfHeight(boolean visible, int shelfHeight) = 5;
/**
* Sets the next pip animation type to be the alpha animation.
*/
oneway void setPipAnimationTypeToAlpha() = 5;
oneway void setPipAnimationTypeToAlpha() = 6;
/**
* Sets the height and visibility of the Launcher keep clear area.
*/
oneway void setLauncherKeepClearAreaHeight(boolean visible, int height) = 6;
oneway void setLauncherKeepClearAreaHeight(boolean visible, int height) = 7;
/**
* Sets the app icon size in pixel used by Launcher
*/
oneway void setLauncherAppIconSize(int iconSizePx) = 7;
oneway void setLauncherAppIconSize(int iconSizePx) = 8;
}

View File

@@ -462,13 +462,29 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
// to the actual Task surface now.
// PipTransition is responsible to fade it out and cleanup when finishing the enter PIP
// transition.
final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
final SurfaceControl.Transaction t = mSurfaceControlTransactionFactory.getTransaction();
mTaskOrganizer.reparentChildSurfaceToTask(taskId, overlay, t);
t.setLayer(overlay, Integer.MAX_VALUE);
t.apply();
}
}
/**
* Callback when launcher aborts swipe-pip-to-home operation.
*/
public void abortSwipePipToHome(int taskId, ComponentName componentName) {
if (!mPipTransitionState.getInSwipePipToHomeTransition()) {
return;
}
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"Abort swipe-pip-to-home for %s", componentName);
sendOnPipTransitionCancelled(TRANSITION_DIRECTION_TO_PIP);
// Cleanup internal states
mPipTransitionState.setInSwipePipToHomeTransition(false);
mPictureInPictureParams = null;
mPipTransitionState.setTransitionState(PipTransitionState.UNDEFINED);
}
public ActivityManager.RunningTaskInfo getTaskInfo() {
return mTaskInfo;
}

View File

@@ -1017,6 +1017,10 @@ public class PipController implements PipTransitionController.PipTransitionCallb
mPipTaskOrganizer.stopSwipePipToHome(taskId, componentName, destinationBounds, overlay);
}
private void abortSwipePipToHome(int taskId, ComponentName componentName) {
mPipTaskOrganizer.abortSwipePipToHome(taskId, componentName);
}
private String getTransitionTag(int direction) {
switch (direction) {
case TRANSITION_DIRECTION_TO_PIP:
@@ -1312,6 +1316,12 @@ public class PipController implements PipTransitionController.PipTransitionCallb
taskId, componentName, destinationBounds, overlay));
}
@Override
public void abortSwipePipToHome(int taskId, ComponentName componentName) {
executeRemoteCallWithTaskPermission(mController, "abortSwipePipToHome",
(controller) -> controller.abortSwipePipToHome(taskId, componentName));
}
@Override
public void setShelfHeight(boolean visible, int height) {
executeRemoteCallWithTaskPermission(mController, "setShelfHeight",