Merge "Enable remote transition animations to append to the finish transaction" into sc-v2-dev am: ffac171d4d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14683057 Change-Id: Id991c8b4bd5155592978c18b66184c4fcae5e7d1
This commit is contained in:
@@ -16,14 +16,18 @@
|
|||||||
|
|
||||||
package android.window;
|
package android.window;
|
||||||
|
|
||||||
|
import android.view.SurfaceControl;
|
||||||
import android.window.WindowContainerTransaction;
|
import android.window.WindowContainerTransaction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to be invoked by the controlling process when a remote transition has finished.
|
* Interface to be invoked by the controlling process when a remote transition has finished.
|
||||||
*
|
*
|
||||||
* @see IRemoteTransition
|
* @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}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
interface IRemoteTransitionFinishedCallback {
|
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() {
|
IRemoteTransitionFinishedCallback cb = new IRemoteTransitionFinishedCallback.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onTransitionFinished(WindowContainerTransaction wct) {
|
public void onTransitionFinished(WindowContainerTransaction wct,
|
||||||
|
SurfaceControl.Transaction sct) {
|
||||||
if (mRemote.asBinder() != null) {
|
if (mRemote.asBinder() != null) {
|
||||||
mRemote.asBinder().unlinkToDeath(remoteDied, 0 /* flags */);
|
mRemote.asBinder().unlinkToDeath(remoteDied, 0 /* flags */);
|
||||||
}
|
}
|
||||||
mMainExecutor.execute(
|
mMainExecutor.execute(() -> {
|
||||||
() -> finishCallback.onTransitionFinished(wct, null /* wctCB */));
|
if (sct != null) {
|
||||||
|
finishTransaction.merge(sct);
|
||||||
|
}
|
||||||
|
finishCallback.onTransitionFinished(wct, null /* wctCB */);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
@@ -103,7 +108,8 @@ public class OneShotRemoteHandler implements Transitions.TransitionHandler {
|
|||||||
|
|
||||||
IRemoteTransitionFinishedCallback cb = new IRemoteTransitionFinishedCallback.Stub() {
|
IRemoteTransitionFinishedCallback cb = new IRemoteTransitionFinishedCallback.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onTransitionFinished(WindowContainerTransaction wct) {
|
public void onTransitionFinished(WindowContainerTransaction wct,
|
||||||
|
SurfaceControl.Transaction sct) {
|
||||||
mMainExecutor.execute(
|
mMainExecutor.execute(
|
||||||
() -> finishCallback.onTransitionFinished(wct, null /* wctCB */));
|
() -> finishCallback.onTransitionFinished(wct, null /* wctCB */));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,11 +133,15 @@ public class RemoteTransitionHandler implements Transitions.TransitionHandler {
|
|||||||
};
|
};
|
||||||
IRemoteTransitionFinishedCallback cb = new IRemoteTransitionFinishedCallback.Stub() {
|
IRemoteTransitionFinishedCallback cb = new IRemoteTransitionFinishedCallback.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onTransitionFinished(WindowContainerTransaction wct) {
|
public void onTransitionFinished(WindowContainerTransaction wct,
|
||||||
|
SurfaceControl.Transaction sct) {
|
||||||
if (remote.asBinder() != null) {
|
if (remote.asBinder() != null) {
|
||||||
remote.asBinder().unlinkToDeath(remoteDied, 0 /* flags */);
|
remote.asBinder().unlinkToDeath(remoteDied, 0 /* flags */);
|
||||||
}
|
}
|
||||||
mMainExecutor.execute(() -> {
|
mMainExecutor.execute(() -> {
|
||||||
|
if (sct != null) {
|
||||||
|
finishTransaction.merge(sct);
|
||||||
|
}
|
||||||
mRequestedRemotes.remove(transition);
|
mRequestedRemotes.remove(transition);
|
||||||
finishCallback.onTransitionFinished(wct, null /* wctCB */);
|
finishCallback.onTransitionFinished(wct, null /* wctCB */);
|
||||||
});
|
});
|
||||||
@@ -171,7 +175,8 @@ public class RemoteTransitionHandler implements Transitions.TransitionHandler {
|
|||||||
|
|
||||||
IRemoteTransitionFinishedCallback cb = new IRemoteTransitionFinishedCallback.Stub() {
|
IRemoteTransitionFinishedCallback cb = new IRemoteTransitionFinishedCallback.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onTransitionFinished(WindowContainerTransaction wct) {
|
public void onTransitionFinished(WindowContainerTransaction wct,
|
||||||
|
SurfaceControl.Transaction sct) {
|
||||||
mMainExecutor.execute(() -> {
|
mMainExecutor.execute(() -> {
|
||||||
if (!mRequestedRemotes.containsKey(mergeTarget)) {
|
if (!mRequestedRemotes.containsKey(mergeTarget)) {
|
||||||
Log.e(TAG, "Merged transition finished after it's mergeTarget (the "
|
Log.e(TAG, "Merged transition finished after it's mergeTarget (the "
|
||||||
|
|||||||
@@ -346,7 +346,7 @@ public class SplitTransitionTests extends ShellTestCase {
|
|||||||
IRemoteTransitionFinishedCallback finishCallback)
|
IRemoteTransitionFinishedCallback finishCallback)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
mCalled = true;
|
mCalled = true;
|
||||||
finishCallback.onTransitionFinished(mRemoteFinishWCT);
|
finishCallback.onTransitionFinished(mRemoteFinishWCT, null /* sct */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ public class ShellTransitionTests {
|
|||||||
SurfaceControl.Transaction t,
|
SurfaceControl.Transaction t,
|
||||||
IRemoteTransitionFinishedCallback finishCallback) throws RemoteException {
|
IRemoteTransitionFinishedCallback finishCallback) throws RemoteException {
|
||||||
remoteCalled[0] = true;
|
remoteCalled[0] = true;
|
||||||
finishCallback.onTransitionFinished(remoteFinishWCT);
|
finishCallback.onTransitionFinished(remoteFinishWCT, null /* sct */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -287,7 +287,7 @@ public class ShellTransitionTests {
|
|||||||
SurfaceControl.Transaction t,
|
SurfaceControl.Transaction t,
|
||||||
IRemoteTransitionFinishedCallback finishCallback) throws RemoteException {
|
IRemoteTransitionFinishedCallback finishCallback) throws RemoteException {
|
||||||
remoteCalled[0] = true;
|
remoteCalled[0] = true;
|
||||||
finishCallback.onTransitionFinished(null /* wct */);
|
finishCallback.onTransitionFinished(null /* wct */, null /* sct */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -334,7 +334,7 @@ public class ShellTransitionTests {
|
|||||||
SurfaceControl.Transaction t,
|
SurfaceControl.Transaction t,
|
||||||
IRemoteTransitionFinishedCallback finishCallback) throws RemoteException {
|
IRemoteTransitionFinishedCallback finishCallback) throws RemoteException {
|
||||||
remoteCalled[0] = true;
|
remoteCalled[0] = true;
|
||||||
finishCallback.onTransitionFinished(remoteFinishWCT);
|
finishCallback.onTransitionFinished(remoteFinishWCT, null /* sct */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ public class RemoteAnimationAdapterCompat {
|
|||||||
t.remove(leashMap.valueAt(i));
|
t.remove(leashMap.valueAt(i));
|
||||||
}
|
}
|
||||||
t.apply();
|
t.apply();
|
||||||
finishCallback.onTransitionFinished(null /* wct */);
|
finishCallback.onTransitionFinished(null /* wct */, null /* sct */);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e("ActivityOptionsCompat", "Failed to call app controlled animation"
|
Log.e("ActivityOptionsCompat", "Failed to call app controlled animation"
|
||||||
+ " finished callback", e);
|
+ " finished callback", e);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class RemoteTransitionCompat implements Parcelable {
|
|||||||
IRemoteTransitionFinishedCallback finishedCallback) {
|
IRemoteTransitionFinishedCallback finishedCallback) {
|
||||||
final Runnable finishAdapter = () -> {
|
final Runnable finishAdapter = () -> {
|
||||||
try {
|
try {
|
||||||
finishedCallback.onTransitionFinished(null /* wct */);
|
finishedCallback.onTransitionFinished(null /* wct */, null /* sct */);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Failed to call transition finished callback", e);
|
Log.e(TAG, "Failed to call transition finished callback", e);
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ public class RemoteTransitionCompat implements Parcelable {
|
|||||||
IRemoteTransitionFinishedCallback finishedCallback) {
|
IRemoteTransitionFinishedCallback finishedCallback) {
|
||||||
final Runnable finishAdapter = () -> {
|
final Runnable finishAdapter = () -> {
|
||||||
try {
|
try {
|
||||||
finishedCallback.onTransitionFinished(null /* wct */);
|
finishedCallback.onTransitionFinished(null /* wct */, null /* sct */);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Failed to call transition finished callback", e);
|
Log.e(TAG, "Failed to call transition finished callback", e);
|
||||||
}
|
}
|
||||||
@@ -120,6 +120,7 @@ public class RemoteTransitionCompat implements Parcelable {
|
|||||||
// This transition is for opening recents, so recents is on-top. We want to draw
|
// 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
|
// the current going-away task on top of recents, though, so move it to front
|
||||||
WindowContainerToken pausingTask = null;
|
WindowContainerToken pausingTask = null;
|
||||||
|
SurfaceControl pausingLeash = null;
|
||||||
for (int i = info.getChanges().size() - 1; i >= 0; --i) {
|
for (int i = info.getChanges().size() - 1; i >= 0; --i) {
|
||||||
final TransitionInfo.Change change = info.getChanges().get(i);
|
final TransitionInfo.Change change = info.getChanges().get(i);
|
||||||
if (change.getMode() == TRANSIT_CLOSE || change.getMode() == TRANSIT_TO_BACK) {
|
if (change.getMode() == TRANSIT_CLOSE || change.getMode() == TRANSIT_TO_BACK) {
|
||||||
@@ -148,7 +149,7 @@ public class RemoteTransitionCompat implements Parcelable {
|
|||||||
if (!mergeTarget.equals(mToken)) return;
|
if (!mergeTarget.equals(mToken)) return;
|
||||||
if (!mRecentsSession.merge(info, t, recents)) return;
|
if (!mRecentsSession.merge(info, t, recents)) return;
|
||||||
try {
|
try {
|
||||||
finishedCallback.onTransitionFinished(null /* wct */);
|
finishedCallback.onTransitionFinished(null /* wct */, null /* sct */);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Error merging transition.", e);
|
Log.e(TAG, "Error merging transition.", e);
|
||||||
}
|
}
|
||||||
@@ -266,10 +267,13 @@ public class RemoteTransitionCompat implements Parcelable {
|
|||||||
try {
|
try {
|
||||||
if (!toHome && mPausingTask != null && mOpeningLeash == null) {
|
if (!toHome && mPausingTask != null && mOpeningLeash == null) {
|
||||||
// The gesture went back to opening the app rather than continuing with
|
// 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();
|
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||||
wct.reorder(mPausingTask, true /* onTop */);
|
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 {
|
} else {
|
||||||
if (mOpeningLeash != null) {
|
if (mOpeningLeash != null) {
|
||||||
// TODO: the launcher animation should handle this
|
// TODO: the launcher animation should handle this
|
||||||
@@ -278,7 +282,7 @@ public class RemoteTransitionCompat implements Parcelable {
|
|||||||
t.setAlpha(mOpeningLeash, 1.f);
|
t.setAlpha(mOpeningLeash, 1.f);
|
||||||
t.apply();
|
t.apply();
|
||||||
}
|
}
|
||||||
mFinishCB.onTransitionFinished(null /* wct */);
|
mFinishCB.onTransitionFinished(null /* wct */, null /* sct */);
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e("RemoteTransitionCompat", "Failed to call animation finish callback", e);
|
Log.e("RemoteTransitionCompat", "Failed to call animation finish callback", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user