Merge "Fix pip surface properties during keyguard exit" into udc-dev

This commit is contained in:
Evan Rosky
2023-05-15 23:00:27 +00:00
committed by Android (Google) Code Review
3 changed files with 49 additions and 4 deletions

View File

@@ -1015,6 +1015,16 @@ public class PipTransition extends PipTransitionController {
mPipOrganizer.onExitPipFinished(prevPipTaskChange.getTaskInfo());
}
@Override
public boolean syncPipSurfaceState(@NonNull TransitionInfo info,
@NonNull SurfaceControl.Transaction startTransaction,
@NonNull SurfaceControl.Transaction finishTransaction) {
final TransitionInfo.Change pipChange = findCurrentPipTaskChange(info);
if (pipChange == null) return false;
updatePipForUnhandledTransition(pipChange, startTransaction, finishTransaction);
return true;
}
private void updatePipForUnhandledTransition(@NonNull TransitionInfo.Change pipChange,
@NonNull SurfaceControl.Transaction startTransaction,
@NonNull SurfaceControl.Transaction finishTransaction) {
@@ -1025,10 +1035,12 @@ public class PipTransition extends PipTransitionController {
final boolean isInPip = mPipTransitionState.isInPip();
mSurfaceTransactionHelper
.crop(startTransaction, leash, destBounds)
.round(startTransaction, leash, isInPip);
.round(startTransaction, leash, isInPip)
.shadow(startTransaction, leash, isInPip);
mSurfaceTransactionHelper
.crop(finishTransaction, leash, destBounds)
.round(finishTransaction, leash, isInPip);
.round(finishTransaction, leash, isInPip)
.shadow(finishTransaction, leash, isInPip);
}
/** Hides and shows the existing PIP during fixed rotation transition of other activities. */

View File

@@ -240,6 +240,18 @@ public abstract class PipTransitionController implements Transitions.TransitionH
@NonNull final Transitions.TransitionFinishCallback finishCallback) {
}
/**
* Applies the proper surface states (rounded corners/shadows) to pip surfaces in `info`.
* This is intended to be used when PiP is part of another animation but isn't, itself,
* animating (eg. unlocking).
* @return `true` if there was a pip in `info`.
*/
public boolean syncPipSurfaceState(@NonNull TransitionInfo info,
@NonNull SurfaceControl.Transaction startTransaction,
@NonNull SurfaceControl.Transaction finishTransaction) {
return false;
}
/** End the currently-playing PiP animation. */
public void end() {
}

View File

@@ -304,8 +304,8 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
return animateRecentsDuringSplit(mixed, info, startTransaction, finishTransaction,
finishCallback);
} else if (mixed.mType == MixedTransition.TYPE_KEYGUARD) {
return mKeyguardHandler.startAnimation(
transition, info, startTransaction, finishTransaction, finishCallback);
return animateKeyguard(mixed, info, startTransaction, finishTransaction,
finishCallback);
} else {
mActiveTransitions.remove(mixed);
throw new IllegalStateException("Starting mixed animation without a known mixed type? "
@@ -557,6 +557,27 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
return handled;
}
private boolean animateKeyguard(@NonNull final MixedTransition mixed,
@NonNull TransitionInfo info,
@NonNull SurfaceControl.Transaction startTransaction,
@NonNull SurfaceControl.Transaction finishTransaction,
@NonNull Transitions.TransitionFinishCallback finishCallback) {
boolean consumed = mKeyguardHandler.startAnimation(
mixed.mTransition, info, startTransaction, finishTransaction, finishCallback);
if (!consumed) {
return false;
}
// Sync pip state.
if (mPipHandler != null) {
// We don't know when to apply `startTransaction` so use a separate transaction here.
// This should be fine because these surface properties are independent.
final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
mPipHandler.syncPipSurfaceState(info, t, finishTransaction);
t.apply();
}
return true;
}
@Override
public void mergeAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info,
@NonNull SurfaceControl.Transaction t, @NonNull IBinder mergeTarget,