Update handler callback to support clean-up aborted transitions
Update onTransitionConsumed callback so TransitionHandler can perform clean-up operations when the handling transition got aborted. Bug: 236814471 Test: atest WMShellUnitTests Change-Id: Iaac49ecacb5670716d1ffde86bc895f9743d3657
This commit is contained in:
@@ -315,7 +315,7 @@ public class PipTransition extends PipTransitionController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionMerged(@NonNull IBinder transition) {
|
||||
public void onTransitionConsumed(@NonNull IBinder transition, boolean aborted) {
|
||||
if (transition != mExitTransition) {
|
||||
return;
|
||||
}
|
||||
@@ -328,7 +328,7 @@ public class PipTransition extends PipTransitionController {
|
||||
}
|
||||
// Unset exitTransition AFTER cancel so that finishResize knows we are merging.
|
||||
mExitTransition = null;
|
||||
if (!cancelled) return;
|
||||
if (!cancelled || aborted) return;
|
||||
final ActivityManager.RunningTaskInfo taskInfo = mPipOrganizer.getTaskInfo();
|
||||
if (taskInfo != null) {
|
||||
startExpandAnimation(taskInfo, mPipOrganizer.getSurfaceControl(),
|
||||
|
||||
@@ -246,7 +246,9 @@ class SplitScreenTransitions {
|
||||
return true;
|
||||
}
|
||||
|
||||
void onTransitionMerged(@NonNull IBinder transition) {
|
||||
void onTransitionConsumed(@NonNull IBinder transition, boolean aborted) {
|
||||
if (aborted) return;
|
||||
|
||||
// Once a pending enter transition got merged, make sure to append the reset of finishing
|
||||
// operations to the finish transition.
|
||||
if (transition == mPendingEnter) {
|
||||
|
||||
@@ -1534,8 +1534,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionMerged(@NonNull IBinder transition) {
|
||||
mSplitTransitions.onTransitionMerged(transition);
|
||||
public void onTransitionConsumed(@NonNull IBinder transition, boolean aborted) {
|
||||
mSplitTransitions.onTransitionConsumed(transition, aborted);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -274,7 +274,7 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionMerged(@NonNull IBinder transition) {
|
||||
public void onTransitionConsumed(@NonNull IBinder transition, boolean aborted) {
|
||||
MixedTransition mixed = null;
|
||||
for (int i = mActiveTransitions.size() - 1; i >= 0; --i) {
|
||||
if (mActiveTransitions.get(i).mTransition != transition) continue;
|
||||
@@ -283,7 +283,7 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler {
|
||||
}
|
||||
if (mixed == null) return;
|
||||
if (mixed.mType == MixedTransition.TYPE_ENTER_PIP_FROM_SPLIT) {
|
||||
mPipHandler.onTransitionMerged(transition);
|
||||
mPipHandler.onTransitionConsumed(transition, aborted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class RemoteTransitionHandler implements Transitions.TransitionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionMerged(@NonNull IBinder transition) {
|
||||
public void onTransitionConsumed(@NonNull IBinder transition, boolean aborted) {
|
||||
mRequestedRemotes.remove(transition);
|
||||
}
|
||||
|
||||
|
||||
@@ -516,15 +516,20 @@ public class Transitions implements RemoteCallable<Transitions> {
|
||||
active.mMerged = true;
|
||||
active.mAborted = abort;
|
||||
if (active.mHandler != null) {
|
||||
active.mHandler.onTransitionMerged(active.mToken);
|
||||
active.mHandler.onTransitionConsumed(active.mToken, abort);
|
||||
}
|
||||
return;
|
||||
}
|
||||
mActiveTransitions.get(activeIdx).mAborted = abort;
|
||||
final ActiveTransition active = mActiveTransitions.get(activeIdx);
|
||||
active.mAborted = abort;
|
||||
if (active.mAborted && active.mHandler != null) {
|
||||
// Notifies to clean-up the aborted transition.
|
||||
active.mHandler.onTransitionConsumed(transition, true /* aborted */);
|
||||
}
|
||||
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS,
|
||||
"Transition animation finished (abort=%b), notifying core %s", abort, transition);
|
||||
// Merge all relevant transactions together
|
||||
SurfaceControl.Transaction fullFinish = mActiveTransitions.get(activeIdx).mFinishT;
|
||||
SurfaceControl.Transaction fullFinish = active.mFinishT;
|
||||
for (int iA = activeIdx + 1; iA < mActiveTransitions.size(); ++iA) {
|
||||
final ActiveTransition toMerge = mActiveTransitions.get(iA);
|
||||
if (!toMerge.mMerged) break;
|
||||
@@ -553,6 +558,10 @@ public class Transitions implements RemoteCallable<Transitions> {
|
||||
while (mActiveTransitions.size() > activeIdx
|
||||
&& mActiveTransitions.get(activeIdx).mAborted) {
|
||||
ActiveTransition aborted = mActiveTransitions.remove(activeIdx);
|
||||
// Notifies to clean-up the aborted transition.
|
||||
if (aborted.mHandler != null) {
|
||||
aborted.mHandler.onTransitionConsumed(transition, true /* aborted */);
|
||||
}
|
||||
mOrganizer.finishTransition(aborted.mToken, null /* wct */, null /* wctCB */);
|
||||
}
|
||||
if (mActiveTransitions.size() <= activeIdx) {
|
||||
@@ -735,9 +744,10 @@ public class Transitions implements RemoteCallable<Transitions> {
|
||||
|
||||
/**
|
||||
* Called when a transition which was already "claimed" by this handler has been merged
|
||||
* into another animation. Gives this handler a chance to clean-up any expectations.
|
||||
* into another animation or has been aborted. Gives this handler a chance to clean-up any
|
||||
* expectations.
|
||||
*/
|
||||
default void onTransitionMerged(@NonNull IBinder transition) { }
|
||||
default void onTransitionConsumed(@NonNull IBinder transition, boolean aborted) { }
|
||||
|
||||
/**
|
||||
* Sets transition animation scale settings value to handler.
|
||||
|
||||
Reference in New Issue
Block a user