Merge "Fix surface release race when using Shell Transitions" into sc-dev
This commit is contained in:
@@ -25,6 +25,7 @@ import static android.view.WindowManager.TRANSIT_TO_FRONT;
|
||||
import static android.view.WindowManager.TransitionOldType;
|
||||
import static android.window.TransitionInfo.FLAG_IS_WALLPAPER;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
@@ -241,10 +242,16 @@ public class RemoteAnimationAdapterCompat {
|
||||
|
||||
final Runnable animationFinishedCallback = new Runnable() {
|
||||
@Override
|
||||
@SuppressLint("NewApi")
|
||||
public void run() {
|
||||
try {
|
||||
counterLauncher.cleanUp(info.getRootLeash());
|
||||
counterWallpaper.cleanUp(info.getRootLeash());
|
||||
// Release surface references now. This is apparently to free GPU
|
||||
// memory while doing quick operations (eg. during CTS).
|
||||
for (int i = 0; i < info.getChanges().size(); ++i) {
|
||||
info.getChanges().get(i).getLeash().release();
|
||||
}
|
||||
finishCallback.onTransitionFinished(null /* wct */);
|
||||
} catch (RemoteException e) {
|
||||
Log.e("ActivityOptionsCompat", "Failed to call app controlled animation"
|
||||
|
||||
@@ -24,6 +24,7 @@ import static android.view.WindowManager.TRANSIT_TO_FRONT;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Rect;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcelable;
|
||||
@@ -127,7 +128,7 @@ public class RemoteTransitionCompat implements Parcelable {
|
||||
}
|
||||
t.apply();
|
||||
final RecentsAnimationControllerCompat wrapControl =
|
||||
new RecentsControllerWrap(controller, finishedCallback, pausingTask);
|
||||
new RecentsControllerWrap(controller, info, finishedCallback, pausingTask);
|
||||
recents.onAnimationStart(wrapControl, apps, wallpapers, new Rect(0, 0, 0, 0),
|
||||
new Rect());
|
||||
}
|
||||
@@ -161,10 +162,12 @@ public class RemoteTransitionCompat implements Parcelable {
|
||||
private final RecentsAnimationControllerCompat mWrapped;
|
||||
private final IRemoteTransitionFinishedCallback mFinishCB;
|
||||
private final WindowContainerToken mPausingTask;
|
||||
private final TransitionInfo mInfo;
|
||||
|
||||
RecentsControllerWrap(RecentsAnimationControllerCompat wrapped,
|
||||
RecentsControllerWrap(RecentsAnimationControllerCompat wrapped, TransitionInfo info,
|
||||
IRemoteTransitionFinishedCallback finishCB, WindowContainerToken pausingTask) {
|
||||
mWrapped = wrapped;
|
||||
mInfo = info;
|
||||
mFinishCB = finishCB;
|
||||
mPausingTask = pausingTask;
|
||||
}
|
||||
@@ -192,7 +195,9 @@ public class RemoteTransitionCompat implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void finish(boolean toHome, boolean sendUserLeaveHint) {
|
||||
@Override
|
||||
@SuppressLint("NewApi")
|
||||
public void finish(boolean toHome, boolean sendUserLeaveHint) {
|
||||
try {
|
||||
if (!toHome && mPausingTask != null) {
|
||||
// The gesture went back to opening the app rather than continuing with
|
||||
@@ -207,6 +212,11 @@ public class RemoteTransitionCompat implements Parcelable {
|
||||
Log.e("RemoteTransitionCompat", "Failed to call animation finish callback", e);
|
||||
}
|
||||
if (mWrapped != null) mWrapped.finish(toHome, sendUserLeaveHint);
|
||||
// Release surface references now. This is apparently to free GPU
|
||||
// memory while doing quick operations (eg. during CTS).
|
||||
for (int i = 0; i < mInfo.getChanges().size(); ++i) {
|
||||
mInfo.getChanges().get(i).getLeash().release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot) {
|
||||
|
||||
Reference in New Issue
Block a user