Merge "Fix flicker with remote animations"
This commit is contained in:
committed by
Android (Google) Code Review
commit
3270ae05d4
@@ -96,13 +96,17 @@ class RemoteAnimationController {
|
||||
// Scale the timeout with the animator scale the controlling app is using.
|
||||
mHandler.postDelayed(mTimeoutRunnable,
|
||||
(long) (TIMEOUT_MS * mService.getCurrentAnimatorScale()));
|
||||
try {
|
||||
mRemoteAnimationAdapter.getRunner().onAnimationStart(createAnimations(),
|
||||
mFinishedCallback);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Failed to start remote animation", e);
|
||||
onAnimationFinished();
|
||||
}
|
||||
|
||||
final RemoteAnimationTarget[] animations = createAnimations();
|
||||
mService.mAnimator.addAfterPrepareSurfacesRunnable(() -> {
|
||||
try {
|
||||
mRemoteAnimationAdapter.getRunner().onAnimationStart(animations,
|
||||
mFinishedCallback);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Failed to start remote animation", e);
|
||||
onAnimationFinished();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private RemoteAnimationTarget[] createAnimations() {
|
||||
|
||||
@@ -588,6 +588,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
|
||||
"<<< CLOSE TRANSACTION performLayoutAndPlaceSurfaces");
|
||||
}
|
||||
|
||||
mService.mAnimator.executeAfterPrepareSurfacesRunnables();
|
||||
|
||||
final WindowSurfacePlacer surfacePlacer = mService.mWindowPlacerLocked;
|
||||
|
||||
// If we are ready to perform an app transition, check through all of the app tokens to be
|
||||
|
||||
@@ -92,6 +92,7 @@ public class WindowAnimator {
|
||||
* executed and the corresponding transaction is closed and applied.
|
||||
*/
|
||||
private final ArrayList<Runnable> mAfterPrepareSurfacesRunnables = new ArrayList<>();
|
||||
private boolean mInExecuteAfterPrepareSurfacesRunnables;
|
||||
|
||||
WindowAnimator(final WindowManagerService service) {
|
||||
mService = service;
|
||||
@@ -426,11 +427,24 @@ public class WindowAnimator {
|
||||
* the corresponding transaction is closed and applied.
|
||||
*/
|
||||
void addAfterPrepareSurfacesRunnable(Runnable r) {
|
||||
// If runnables are already being handled in executeAfterPrepareSurfacesRunnable, then just
|
||||
// immediately execute the runnable passed in.
|
||||
if (mInExecuteAfterPrepareSurfacesRunnables) {
|
||||
r.run();
|
||||
return;
|
||||
}
|
||||
|
||||
mAfterPrepareSurfacesRunnables.add(r);
|
||||
scheduleAnimation();
|
||||
}
|
||||
|
||||
private void executeAfterPrepareSurfacesRunnables() {
|
||||
void executeAfterPrepareSurfacesRunnables() {
|
||||
|
||||
// Don't even think about to start recursing!
|
||||
if (mInExecuteAfterPrepareSurfacesRunnables) {
|
||||
return;
|
||||
}
|
||||
mInExecuteAfterPrepareSurfacesRunnables = true;
|
||||
|
||||
// Traverse in order they were added.
|
||||
final int size = mAfterPrepareSurfacesRunnables.size();
|
||||
@@ -438,5 +452,6 @@ public class WindowAnimator {
|
||||
mAfterPrepareSurfacesRunnables.get(i).run();
|
||||
}
|
||||
mAfterPrepareSurfacesRunnables.clear();
|
||||
mInExecuteAfterPrepareSurfacesRunnables = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user