Pass current PIP bounds to #updateReentryBounds.
When PIP exits, we attempt to save the current bounds so we know what bounds to be used on PIP re-entry. This uses PipTaskOrganizer#getLastReportedBounds, but this is not accessed in a synchornized banner; it is possible that by the time it is accessed, it is changed by something else (for example, PIP Animation). At the time of #onPipTransitionStarted, just save the current PIP bounds and pass it down. Bug: 160721096 Test: Multiple re-entry of PIP result in the same bounds Change-Id: I27a1ad3a2257333c9afedf13520f44406d07cd68
This commit is contained in:
@@ -454,10 +454,11 @@ public class PipTaskOrganizer extends TaskOrganizer implements
|
||||
|
||||
private void sendOnPipTransitionStarted(
|
||||
@PipAnimationController.TransitionDirection int direction) {
|
||||
final Rect pipBounds = new Rect(mLastReportedBounds);
|
||||
runOnMainHandler(() -> {
|
||||
for (int i = mPipTransitionCallbacks.size() - 1; i >= 0; i--) {
|
||||
final PipTransitionCallback callback = mPipTransitionCallbacks.get(i);
|
||||
callback.onPipTransitionStarted(mTaskInfo.baseActivity, direction);
|
||||
callback.onPipTransitionStarted(mTaskInfo.baseActivity, direction, pipBounds);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -973,7 +974,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements
|
||||
/**
|
||||
* Callback when the pip transition is started.
|
||||
*/
|
||||
void onPipTransitionStarted(ComponentName activity, int direction);
|
||||
void onPipTransitionStarted(ComponentName activity, int direction, Rect pipBounds);
|
||||
|
||||
/**
|
||||
* Callback when the pip transition is finished.
|
||||
|
||||
@@ -373,10 +373,10 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPipTransitionStarted(ComponentName activity, int direction) {
|
||||
public void onPipTransitionStarted(ComponentName activity, int direction, Rect pipBounds) {
|
||||
if (isOutPipDirection(direction)) {
|
||||
// Exiting PIP, save the reentry bounds to restore to when re-entering.
|
||||
updateReentryBounds();
|
||||
updateReentryBounds(pipBounds);
|
||||
mPipBoundsHandler.onSaveReentryBounds(activity, mReentryBounds);
|
||||
}
|
||||
// Disable touches while the animation is running
|
||||
@@ -393,15 +393,13 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
/**
|
||||
* Update the bounds used to save the re-entry size and snap fraction when exiting PIP.
|
||||
*/
|
||||
public void updateReentryBounds() {
|
||||
public void updateReentryBounds(Rect bounds) {
|
||||
// On phones, the expansion animation that happens on pip tap before restoring
|
||||
// to fullscreen makes it so that the last reported bounds are the expanded
|
||||
// bounds. We want to restore to the unexpanded bounds when re-entering pip,
|
||||
// so we use the bounds before expansion (normal) instead of the reported
|
||||
// bounds.
|
||||
Rect reentryBounds = mTouchHandler.getNormalBounds();
|
||||
// Apply the snap fraction of the current bounds to the normal bounds.
|
||||
final Rect bounds = mPipTaskOrganizer.getLastReportedBounds();
|
||||
float snapFraction = mPipBoundsHandler.getSnapFraction(bounds);
|
||||
mPipBoundsHandler.applySnapFraction(reentryBounds, snapFraction);
|
||||
mReentryBounds.set(reentryBounds);
|
||||
|
||||
@@ -154,7 +154,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
|
||||
private final PipTaskOrganizer.PipTransitionCallback mPipTransitionCallback =
|
||||
new PipTaskOrganizer.PipTransitionCallback() {
|
||||
@Override
|
||||
public void onPipTransitionStarted(ComponentName activity, int direction) {}
|
||||
public void onPipTransitionStarted(ComponentName activity, int direction, Rect pipBounds) {}
|
||||
|
||||
@Override
|
||||
public void onPipTransitionFinished(ComponentName activity, int direction) {
|
||||
|
||||
@@ -663,7 +663,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onPipTransitionStarted(ComponentName activity, int direction) { }
|
||||
public void onPipTransitionStarted(ComponentName activity, int direction, Rect pipBounds) { }
|
||||
|
||||
@Override
|
||||
public void onPipTransitionFinished(ComponentName activity, int direction) {
|
||||
|
||||
Reference in New Issue
Block a user