From 3f8dd35901707ee6e0c36b41be413a52b9e1c66a Mon Sep 17 00:00:00 2001 From: Alison Cichowlas Date: Thu, 9 Mar 2023 16:04:02 -0500 Subject: [PATCH] Volume: Hide dialog when motion cancelled, as well as when finished. Speculative fix for issue where sometimes volume dialog does not ever dismiss. Logs show that VolumeDialogImpl.dismissH is being called, and the VolumeDialogImpl dump shows that the dialog thinks it is not showing. I think that these animations are getting cancelled, leaving mIsAnimatingDismiss true with no active dismiss animation running (normally it is reset to false during the animation's end action). mIsAnimatingDismiss then prevents the creation of another dismiss animation, leaving the dialog stranded. Test: existing Volume tests pass, no repro available for bug Bug: 232606092 Change-Id: If6dbccf52de6452ce57d872de40037d5080d8ef0 --- .../systemui/volume/VolumeDialogImpl.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java index 1cfcf8cbbdcb5..2892ee3c7643e 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java @@ -1398,7 +1398,11 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, @Override public void onAnimationCancel(@NonNull Animator animation) { mInteractionJankMonitor.cancel(CUJ_VOLUME_CONTROL); - Log.d(TAG, "onAnimationCancel"); + Log.i(TAG, "onAnimationCancel"); + + // We can only have one animation listener for cancel, so the jank listener should + // also call for cleanup. + finishDismiss(); } @Override @@ -1490,12 +1494,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, .setDuration(mDialogHideAnimationDurationMs) .setInterpolator(new SystemUIInterpolators.LogAccelerateInterpolator()) .withEndAction(() -> mHandler.postDelayed(() -> { - mController.notifyVisible(false); - mDialog.dismiss(); - tryToRemoveCaptionsTooltip(); - mIsAnimatingDismiss = false; - - hideRingerDrawer(); + finishDismiss(); }, 50)); if (!shouldSlideInVolumeTray()) animator.translationX(mDialogView.getWidth() / 2.0f); animator.setListener(getJankListener(getDialogView(), TYPE_DISMISS, @@ -1510,6 +1509,18 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, Trace.endSection(); } + /** + * Clean up and hide volume dialog. Called when animation is finished/cancelled. + */ + private void finishDismiss() { + mController.notifyVisible(false); + mDialog.dismiss(); + tryToRemoveCaptionsTooltip(); + mIsAnimatingDismiss = false; + + hideRingerDrawer(); + } + private boolean showActiveStreamOnly() { return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK) || mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION);