Merge "InsetSourceConsumer: Ensure we release Leash when finished." into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-05 23:52:44 +00:00
committed by Android (Google) Code Review
2 changed files with 24 additions and 15 deletions

View File

@@ -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

View File

@@ -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) {