Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9cda33d6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Avoid refreshing the media output dialog UI while dismissing." into...

Merge "Avoid refreshing the media output dialog UI while dismissing." into udc-dev am: 04c08fe3 am: c772aaf5

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23710325



Change-Id: Iea02229ce1d4ec962d11702b95ac4afebf10a028
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 3d9c2f7b c772aaf5
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
    private WallpaperColors mWallpaperColors;
    private boolean mShouldLaunchLeBroadcastDialog;
    private boolean mIsLeBroadcastCallbackRegistered;
    private boolean mDismissing;

    MediaOutputBaseAdapter mAdapter;

@@ -265,13 +266,22 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
        mDevicesRecyclerView.setHasFixedSize(false);
        // Init bottom buttons
        mDoneButton.setOnClickListener(v -> dismiss());
        mStopButton.setOnClickListener(v -> {
            mMediaOutputController.releaseSession();
            dismiss();
        });
        mStopButton.setOnClickListener(v -> onStopButtonClick());
        mAppButton.setOnClickListener(mMediaOutputController::tryToLaunchMediaApplication);
        mMediaMetadataSectionLayout.setOnClickListener(
                mMediaOutputController::tryToLaunchMediaApplication);

        mDismissing = false;
    }

    @Override
    public void dismiss() {
        // TODO(287191450): remove this once expensive binder calls are removed from refresh().
        // Due to these binder calls on the UI thread, calling refresh() during dismissal causes
        // significant frame drops for the dismissal animation. Since the dialog is going away
        // anyway, we use this state to turn refresh() into a no-op.
        mDismissing = true;
        super.dismiss();
    }

    @Override
@@ -299,7 +309,9 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
    }

    void refresh(boolean deviceSetChanged) {
        if (mMediaOutputController.isRefreshing()) {
        // TODO(287191450): remove binder calls in this method from the UI thread.
        // If the dialog is going away or is already refreshing, do nothing.
        if (mDismissing || mMediaOutputController.isRefreshing()) {
            return;
        }
        mMediaOutputController.setRefreshing(true);