Enable remote transition animations to append to the finish transaction
Adds a parameter to the IRemoteTransitionFinishedCallback. This
transaction will be merged into the finish transaction before it is
applied. This is needed by transitions like live-tile recents where
the end-state of the transition is altered during the "animation".
Bug: 172695387
Test: open app, swipe up to overview, resume that same app, screen
shouldn't turn black anymore.
Change-Id: I6fa1e22288ce087ad17fdfc950a8419e6ba61a47
This commit is contained in:
@@ -16,14 +16,18 @@
|
||||
|
||||
package android.window;
|
||||
|
||||
import android.view.SurfaceControl;
|
||||
import android.window.WindowContainerTransaction;
|
||||
|
||||
/**
|
||||
* Interface to be invoked by the controlling process when a remote transition has finished.
|
||||
*
|
||||
* @see IRemoteTransition
|
||||
* @param wct An optional WindowContainerTransaction to apply before the transition finished.
|
||||
* @param sct An optional Surface Transaction that is added to the end of the finish/cleanup
|
||||
* transaction. This is applied by shell.Transitions (before submitting the wct).
|
||||
* {@hide}
|
||||
*/
|
||||
interface IRemoteTransitionFinishedCallback {
|
||||
void onTransitionFinished(in WindowContainerTransaction wct);
|
||||
void onTransitionFinished(in WindowContainerTransaction wct, in SurfaceControl.Transaction sct);
|
||||
}
|
||||
|
||||
@@ -71,12 +71,17 @@ public class OneShotRemoteHandler implements Transitions.TransitionHandler {
|
||||
};
|
||||
IRemoteTransitionFinishedCallback cb = new IRemoteTransitionFinishedCallback.Stub() {
|
||||
@Override
|
||||
public void onTransitionFinished(WindowContainerTransaction wct) {
|
||||
public void onTransitionFinished(WindowContainerTransaction wct,
|
||||
SurfaceControl.Transaction sct) {
|
||||
if (mRemote.asBinder() != null) {
|
||||
mRemote.asBinder().unlinkToDeath(remoteDied, 0 /* flags */);
|
||||
}
|
||||
mMainExecutor.execute(
|
||||
() -> finishCallback.onTransitionFinished(wct, null /* wctCB */));
|
||||
mMainExecutor.execute(() -> {
|
||||
if (sct != null) {
|
||||
finishTransaction.merge(sct);
|
||||
}
|
||||
finishCallback.onTransitionFinished(wct, null /* wctCB */);
|
||||
});
|
||||
}
|
||||
};
|
||||
try {
|
||||
@@ -103,7 +108,8 @@ public class OneShotRemoteHandler implements Transitions.TransitionHandler {
|
||||
|
||||
IRemoteTransitionFinishedCallback cb = new IRemoteTransitionFinishedCallback.Stub() {
|
||||
@Override
|
||||
public void onTransitionFinished(WindowContainerTransaction wct) {
|
||||
public void onTransitionFinished(WindowContainerTransaction wct,
|
||||
SurfaceControl.Transaction sct) {
|
||||
mMainExecutor.execute(
|
||||
() -> finishCallback.onTransitionFinished(wct, null /* wctCB */));
|
||||
}
|
||||
|
||||
@@ -133,11 +133,15 @@ public class RemoteTransitionHandler implements Transitions.TransitionHandler {
|
||||
};
|
||||
IRemoteTransitionFinishedCallback cb = new IRemoteTransitionFinishedCallback.Stub() {
|
||||
@Override
|
||||
public void onTransitionFinished(WindowContainerTransaction wct) {
|
||||
public void onTransitionFinished(WindowContainerTransaction wct,
|
||||
SurfaceControl.Transaction sct) {
|
||||
if (remote.asBinder() != null) {
|
||||
remote.asBinder().unlinkToDeath(remoteDied, 0 /* flags */);
|
||||
}
|
||||
mMainExecutor.execute(() -> {
|
||||
if (sct != null) {
|
||||
finishTransaction.merge(sct);
|
||||
}
|
||||
mRequestedRemotes.remove(transition);
|
||||
finishCallback.onTransitionFinished(wct, null /* wctCB */);
|
||||
});
|
||||
@@ -171,7 +175,8 @@ public class RemoteTransitionHandler implements Transitions.TransitionHandler {
|
||||
|
||||
IRemoteTransitionFinishedCallback cb = new IRemoteTransitionFinishedCallback.Stub() {
|
||||
@Override
|
||||
public void onTransitionFinished(WindowContainerTransaction wct) {
|
||||
public void onTransitionFinished(WindowContainerTransaction wct,
|
||||
SurfaceControl.Transaction sct) {
|
||||
mMainExecutor.execute(() -> {
|
||||
if (!mRequestedRemotes.containsKey(mergeTarget)) {
|
||||
Log.e(TAG, "Merged transition finished after it's mergeTarget (the "
|
||||
|
||||
@@ -346,7 +346,7 @@ public class SplitTransitionTests extends ShellTestCase {
|
||||
IRemoteTransitionFinishedCallback finishCallback)
|
||||
throws RemoteException {
|
||||
mCalled = true;
|
||||
finishCallback.onTransitionFinished(mRemoteFinishWCT);
|
||||
finishCallback.onTransitionFinished(mRemoteFinishWCT, null /* sct */);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -213,7 +213,7 @@ public class ShellTransitionTests {
|
||||
SurfaceControl.Transaction t,
|
||||
IRemoteTransitionFinishedCallback finishCallback) throws RemoteException {
|
||||
remoteCalled[0] = true;
|
||||
finishCallback.onTransitionFinished(remoteFinishWCT);
|
||||
finishCallback.onTransitionFinished(remoteFinishWCT, null /* sct */);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -287,7 +287,7 @@ public class ShellTransitionTests {
|
||||
SurfaceControl.Transaction t,
|
||||
IRemoteTransitionFinishedCallback finishCallback) throws RemoteException {
|
||||
remoteCalled[0] = true;
|
||||
finishCallback.onTransitionFinished(null /* wct */);
|
||||
finishCallback.onTransitionFinished(null /* wct */, null /* sct */);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -334,7 +334,7 @@ public class ShellTransitionTests {
|
||||
SurfaceControl.Transaction t,
|
||||
IRemoteTransitionFinishedCallback finishCallback) throws RemoteException {
|
||||
remoteCalled[0] = true;
|
||||
finishCallback.onTransitionFinished(remoteFinishWCT);
|
||||
finishCallback.onTransitionFinished(remoteFinishWCT, null /* sct */);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -260,7 +260,7 @@ public class RemoteAnimationAdapterCompat {
|
||||
t.remove(leashMap.valueAt(i));
|
||||
}
|
||||
t.apply();
|
||||
finishCallback.onTransitionFinished(null /* wct */);
|
||||
finishCallback.onTransitionFinished(null /* wct */, null /* sct */);
|
||||
} catch (RemoteException e) {
|
||||
Log.e("ActivityOptionsCompat", "Failed to call app controlled animation"
|
||||
+ " finished callback", e);
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RemoteTransitionCompat implements Parcelable {
|
||||
IRemoteTransitionFinishedCallback finishedCallback) {
|
||||
final Runnable finishAdapter = () -> {
|
||||
try {
|
||||
finishedCallback.onTransitionFinished(null /* wct */);
|
||||
finishedCallback.onTransitionFinished(null /* wct */, null /* sct */);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to call transition finished callback", e);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class RemoteTransitionCompat implements Parcelable {
|
||||
IRemoteTransitionFinishedCallback finishedCallback) {
|
||||
final Runnable finishAdapter = () -> {
|
||||
try {
|
||||
finishedCallback.onTransitionFinished(null /* wct */);
|
||||
finishedCallback.onTransitionFinished(null /* wct */, null /* sct */);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to call transition finished callback", e);
|
||||
}
|
||||
@@ -119,6 +119,7 @@ public class RemoteTransitionCompat implements Parcelable {
|
||||
// This transition is for opening recents, so recents is on-top. We want to draw
|
||||
// the current going-away task on top of recents, though, so move it to front
|
||||
WindowContainerToken pausingTask = null;
|
||||
SurfaceControl pausingLeash = null;
|
||||
for (int i = info.getChanges().size() - 1; i >= 0; --i) {
|
||||
final TransitionInfo.Change change = info.getChanges().get(i);
|
||||
if (change.getMode() == TRANSIT_CLOSE || change.getMode() == TRANSIT_TO_BACK) {
|
||||
@@ -147,7 +148,7 @@ public class RemoteTransitionCompat implements Parcelable {
|
||||
if (!mergeTarget.equals(mToken)) return;
|
||||
if (!mRecentsSession.merge(info, t, recents)) return;
|
||||
try {
|
||||
finishedCallback.onTransitionFinished(null /* wct */);
|
||||
finishedCallback.onTransitionFinished(null /* wct */, null /* sct */);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error merging transition.", e);
|
||||
}
|
||||
@@ -263,10 +264,13 @@ public class RemoteTransitionCompat implements Parcelable {
|
||||
try {
|
||||
if (!toHome && mPausingTask != null && mOpeningLeash == null) {
|
||||
// The gesture went back to opening the app rather than continuing with
|
||||
// recents, so end the transition by moving the app back to the top.
|
||||
// recents, so end the transition by moving the app back to the top (and also
|
||||
// re-showing it's task).
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
wct.reorder(mPausingTask, true /* onTop */);
|
||||
mFinishCB.onTransitionFinished(wct);
|
||||
final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
|
||||
t.show(mInfo.getChange(mPausingTask).getLeash());
|
||||
mFinishCB.onTransitionFinished(wct, t);
|
||||
} else {
|
||||
if (mOpeningLeash != null) {
|
||||
// TODO: the launcher animation should handle this
|
||||
@@ -275,7 +279,7 @@ public class RemoteTransitionCompat implements Parcelable {
|
||||
t.setAlpha(mOpeningLeash, 1.f);
|
||||
t.apply();
|
||||
}
|
||||
mFinishCB.onTransitionFinished(null /* wct */);
|
||||
mFinishCB.onTransitionFinished(null /* wct */, null /* sct */);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e("RemoteTransitionCompat", "Failed to call animation finish callback", e);
|
||||
|
||||
Reference in New Issue
Block a user