Merge "More SurfaceAnimator lifetime fixes." into qt-dev

am: ed5d40cf26

Change-Id: Iea26915848f87f0c905491abb6aaa5968c84ca94
This commit is contained in:
Rob Carr
2019-04-15 13:11:40 -07:00
committed by android-build-merger
2 changed files with 13 additions and 5 deletions

View File

@@ -41,7 +41,7 @@ class Dimmer {
private static final int DEFAULT_DIM_ANIM_DURATION = 200;
private class DimAnimatable implements SurfaceAnimator.Animatable {
private final SurfaceControl mDimLayer;
private SurfaceControl mDimLayer;
private DimAnimatable(SurfaceControl dimLayer) {
mDimLayer = dimLayer;
@@ -100,6 +100,11 @@ class Dimmer {
// See getSurfaceWidth() above for explanation.
return mHost.getSurfaceHeight();
}
void removeSurface() {
getPendingTransaction().remove(mDimLayer);
mDimLayer = null;
}
}
@VisibleForTesting
@@ -129,8 +134,7 @@ class Dimmer {
final DimAnimatable dimAnimatable = new DimAnimatable(dimLayer);
mSurfaceAnimator = new SurfaceAnimator(dimAnimatable, () -> {
if (!mDimming) {
dimAnimatable.getPendingTransaction().remove(mDimLayer);
mDimLayer = null;
dimAnimatable.removeSurface();
}
}, mHost.mWmService);
}

View File

@@ -286,8 +286,12 @@ class SurfaceAnimator {
final boolean destroy = mLeash != null && surface != null && parent != null;
if (destroy) {
if (DEBUG_ANIM) Slog.i(TAG, "Reparenting to original parent");
t.reparent(surface, parent);
scheduleAnim = true;
// We shouldn't really need these isValid checks but we do
// b/130364451
if (surface.isValid() && parent.isValid()) {
t.reparent(surface, parent);
scheduleAnim = true;
}
}
mService.mAnimationTransferMap.remove(mAnimation);
if (mLeash != null && destroyLeash) {