Merge "Fixes autoEnterPip transition from landscape" into sc-dev

This commit is contained in:
Hongwei Wang
2021-02-25 19:50:01 +00:00
committed by Android (Google) Code Review
3 changed files with 45 additions and 7 deletions

View File

@@ -50,6 +50,7 @@ import com.android.internal.R;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
/** /**
* Contains information about the layout-properties of a display. This refers to internal layout * Contains information about the layout-properties of a display. This refers to internal layout
@@ -82,6 +83,31 @@ public class DisplayLayout {
private boolean mHasStatusBar = false; private boolean mHasStatusBar = false;
private int mNavBarFrameHeight = 0; private int mNavBarFrameHeight = 0;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof DisplayLayout)) return false;
final DisplayLayout other = (DisplayLayout) o;
return mUiMode == other.mUiMode
&& mWidth == other.mWidth
&& mHeight == other.mHeight
&& Objects.equals(mCutout, other.mCutout)
&& mRotation == other.mRotation
&& mDensityDpi == other.mDensityDpi
&& Objects.equals(mNonDecorInsets, other.mNonDecorInsets)
&& Objects.equals(mStableInsets, other.mStableInsets)
&& mHasNavigationBar == other.mHasNavigationBar
&& mHasStatusBar == other.mHasStatusBar
&& mNavBarFrameHeight == other.mNavBarFrameHeight;
}
@Override
public int hashCode() {
return Objects.hash(mUiMode, mWidth, mHeight, mCutout, mRotation, mDensityDpi,
mNonDecorInsets, mStableInsets, mHasNavigationBar, mHasStatusBar,
mNavBarFrameHeight);
}
/** /**
* Create empty layout. * Create empty layout.
*/ */

View File

@@ -90,15 +90,15 @@ public class PipAnimationController {
private final PipSurfaceTransactionHelper mSurfaceTransactionHelper; private final PipSurfaceTransactionHelper mSurfaceTransactionHelper;
private PipTransitionAnimator mCurrentAnimator; private final ThreadLocal<AnimationHandler> mSfAnimationHandlerThreadLocal =
private ThreadLocal<AnimationHandler> mSfAnimationHandlerThreadLocal =
ThreadLocal.withInitial(() -> { ThreadLocal.withInitial(() -> {
AnimationHandler handler = new AnimationHandler(); AnimationHandler handler = new AnimationHandler();
handler.setProvider(new SfVsyncFrameCallbackProvider()); handler.setProvider(new SfVsyncFrameCallbackProvider());
return handler; return handler;
}); });
private PipTransitionAnimator mCurrentAnimator;
public PipAnimationController(PipSurfaceTransactionHelper helper) { public PipAnimationController(PipSurfaceTransactionHelper helper) {
mSurfaceTransactionHelper = helper; mSurfaceTransactionHelper = helper;
} }
@@ -268,6 +268,7 @@ public class PipAnimationController {
if (mPipAnimationCallback != null) { if (mPipAnimationCallback != null) {
mPipAnimationCallback.onPipAnimationEnd(mTaskInfo, tx, this); mPipAnimationCallback.onPipAnimationEnd(mTaskInfo, tx, this);
} }
mTransitionDirection = TRANSITION_DIRECTION_NONE;
} }
@Override @Override
@@ -275,6 +276,7 @@ public class PipAnimationController {
if (mPipAnimationCallback != null) { if (mPipAnimationCallback != null) {
mPipAnimationCallback.onPipAnimationCancel(mTaskInfo, this); mPipAnimationCallback.onPipAnimationCancel(mTaskInfo, this);
} }
mTransitionDirection = TRANSITION_DIRECTION_NONE;
} }
@Override public void onAnimationRepeat(Animator animation) {} @Override public void onAnimationRepeat(Animator animation) {}

View File

@@ -65,6 +65,7 @@ import com.android.wm.shell.pip.PipTransitionController;
import com.android.wm.shell.pip.PipUtils; import com.android.wm.shell.pip.PipUtils;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.Objects;
import java.util.function.Consumer; import java.util.function.Consumer;
/** /**
@@ -101,9 +102,12 @@ public class PipController implements PipTransitionController.PipTransitionCallb
*/ */
private final DisplayChangeController.OnDisplayChangingListener mRotationController = ( private final DisplayChangeController.OnDisplayChangingListener mRotationController = (
int displayId, int fromRotation, int toRotation, WindowContainerTransaction t) -> { int displayId, int fromRotation, int toRotation, WindowContainerTransaction t) -> {
if (!mPipTaskOrganizer.isInPip() || mPipTaskOrganizer.isDeferringEnterPipAnimation()) { if (!mPipTaskOrganizer.isInPip()
// Skip if we aren't in PIP or haven't actually entered PIP yet. We still need to update || mPipBoundsState.getDisplayLayout().rotation() == toRotation
// the display layout in the bounds handler in this case. || mPipTaskOrganizer.isDeferringEnterPipAnimation()) {
// Skip if the same rotation has been set or we aren't in PIP or haven't actually
// entered PIP yet. We still need to update the display layout in the bounds handler
// in this case.
onDisplayRotationChangedNotInPip(mContext, toRotation); onDisplayRotationChangedNotInPip(mContext, toRotation);
// do not forget to update the movement bounds as well. // do not forget to update the movement bounds as well.
updateMovementBounds(mPipBoundsState.getNormalBounds(), true /* fromRotation */, updateMovementBounds(mPipBoundsState.getNormalBounds(), true /* fromRotation */,
@@ -378,6 +382,9 @@ public class PipController implements PipTransitionController.PipTransitionCallb
} }
private void onDisplayChanged(DisplayLayout layout, boolean saveRestoreSnapFraction) { private void onDisplayChanged(DisplayLayout layout, boolean saveRestoreSnapFraction) {
if (Objects.equals(layout, mPipBoundsState.getDisplayLayout())) {
return;
}
Runnable updateDisplayLayout = () -> { Runnable updateDisplayLayout = () -> {
mPipBoundsState.setDisplayLayout(layout); mPipBoundsState.setDisplayLayout(layout);
updateMovementBounds(null /* toBounds */, updateMovementBounds(null /* toBounds */,
@@ -476,8 +483,11 @@ public class PipController implements PipTransitionController.PipTransitionCallb
int launcherRotation, int shelfHeight) { int launcherRotation, int shelfHeight) {
setShelfHeightLocked(shelfHeight > 0 /* visible */, shelfHeight); setShelfHeightLocked(shelfHeight > 0 /* visible */, shelfHeight);
onDisplayRotationChangedNotInPip(mContext, launcherRotation); onDisplayRotationChangedNotInPip(mContext, launcherRotation);
return mPipTaskOrganizer.startSwipePipToHome(componentName, activityInfo, final Rect entryBounds = mPipTaskOrganizer.startSwipePipToHome(componentName, activityInfo,
pictureInPictureParams); pictureInPictureParams);
// sync mPipBoundsState with the newly calculated bounds.
mPipBoundsState.setNormalBounds(entryBounds);
return entryBounds;
} }
private void stopSwipePipToHome(ComponentName componentName, Rect destinationBounds) { private void stopSwipePipToHome(ComponentName componentName, Rect destinationBounds) {