diff options
| author | 2020-03-05 13:31:01 -0800 | |
|---|---|---|
| committer | 2020-03-05 22:05:59 +0000 | |
| commit | ed48db3d8782a29d92a8410b312698038ce33f75 (patch) | |
| tree | 76cf737ee4a83903a7053e320a431bff1395d8e4 | |
| parent | 062f7a09c96f41ea4d8cfe79087f92f7d00f907e (diff) | |
InsetSourceConsumer: Ensure we release Leash when finished.
SurfaceControl resources may be heavy weight, and so we explicitly
release them when finished. Specifically, we need to fix this to
keep the CloseGuard from complaining in strict-mode.
Bug: 150805473
Test: Existing tests pass
Change-Id: Ie3c609f79a953374a4d336465676cdc312679f93
| -rw-r--r-- | core/java/android/view/InsetsSourceConsumer.java | 33 | ||||
| -rw-r--r-- | core/java/android/view/InsetsSourceControl.java | 6 |
2 files changed, 24 insertions, 15 deletions
diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java index 92ac4259c349..f07f1ce186fe 100644 --- a/core/java/android/view/InsetsSourceConsumer.java +++ b/core/java/android/view/InsetsSourceConsumer.java @@ -87,6 +87,7 @@ public class InsetsSourceConsumer { if (mSourceControl == control) { return; } + final InsetsSourceControl lastControl = mSourceControl; mSourceControl = control; // We are loosing control @@ -97,25 +98,27 @@ public class InsetsSourceConsumer { mState.getSource(getType()).setVisible( mController.getLastDispatchedState().getSource(getType()).isVisible()); applyLocalVisibilityOverride(); - return; - } - - // We are gaining control, and need to run an animation since previous state didn't match - if (mRequestedVisible != mState.getSource(mType).isVisible()) { - if (mRequestedVisible) { - showTypes[0] |= toPublicType(getType()); + } else { + // We are gaining control, and need to run an animation since previous state + // didn't match + if (mRequestedVisible != mState.getSource(mType).isVisible()) { + if (mRequestedVisible) { + showTypes[0] |= toPublicType(getType()); + } else { + hideTypes[0] |= toPublicType(getType()); + } } else { - hideTypes[0] |= toPublicType(getType()); + // We are gaining control, but don't need to run an animation. + // However make sure that the leash visibility is still up to date. + if (applyLocalVisibilityOverride()) { + mController.notifyVisibilityChanged(); + } + applyHiddenToControl(); } - return; } - - // We are gaining control, but don't need to run an animation. However make sure that the - // leash visibility is still up to date. - if (applyLocalVisibilityOverride()) { - mController.notifyVisibilityChanged(); + if (lastControl != null) { + lastControl.release(); } - applyHiddenToControl(); } @VisibleForTesting diff --git a/core/java/android/view/InsetsSourceControl.java b/core/java/android/view/InsetsSourceControl.java index 7be3e6a42475..29ba56a5fbb9 100644 --- a/core/java/android/view/InsetsSourceControl.java +++ b/core/java/android/view/InsetsSourceControl.java @@ -94,6 +94,12 @@ public class InsetsSourceControl implements Parcelable { dest.writeParcelable(mSurfacePosition, 0 /* flags*/); } + public void release() { + if (mLeash != null) { + mLeash.release(); + } + } + public static final @android.annotation.NonNull Creator<InsetsSourceControl> CREATOR = new Creator<InsetsSourceControl>() { public InsetsSourceControl createFromParcel(Parcel in) { |