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

Commit 15e0776f authored by Shaowei Shen's avatar Shaowei Shen Committed by Automerger Merge Worker
Browse files

Merge changes from topic "presubmit-am-ce228227dd884d36b260736a830a50cf" into...

Merge changes from topic "presubmit-am-ce228227dd884d36b260736a830a50cf" into sc-v2-dev-plus-aosp am: 72ab33e7

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

Change-Id: I62f7e4633f9d2d7fe6bd047f9ce6299eb5a7adf1
parents 1fbbe994 72ab33e7
Loading
Loading
Loading
Loading
+11 −1
Original line number Original line Diff line number Diff line
@@ -153,6 +153,10 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements


    @VisibleForTesting
    @VisibleForTesting
    void refresh() {
    void refresh() {
        refresh(false);
    }

    void refresh(boolean deviceSetChanged) {
        // Update header icon
        // Update header icon
        final int iconRes = getHeaderIconRes();
        final int iconRes = getHeaderIconRes();
        final IconCompat iconCompat = getHeaderIcon();
        final IconCompat iconCompat = getHeaderIcon();
@@ -190,7 +194,8 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
        }
        }
        if (!mAdapter.isDragging() && !mAdapter.isAnimating()) {
        if (!mAdapter.isDragging() && !mAdapter.isAnimating()) {
            int currentActivePosition = mAdapter.getCurrentActivePosition();
            int currentActivePosition = mAdapter.getCurrentActivePosition();
            if (currentActivePosition >= 0 && currentActivePosition < mAdapter.getItemCount()) {
            if (!deviceSetChanged && currentActivePosition >= 0
                    && currentActivePosition < mAdapter.getItemCount()) {
                mAdapter.notifyItemChanged(currentActivePosition);
                mAdapter.notifyItemChanged(currentActivePosition);
            } else {
            } else {
                mAdapter.notifyDataSetChanged();
                mAdapter.notifyDataSetChanged();
@@ -231,6 +236,11 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
        mMainThreadHandler.post(() -> refresh());
        mMainThreadHandler.post(() -> refresh());
    }
    }


    @Override
    public void onDeviceListChanged() {
        mMainThreadHandler.post(() -> refresh(true));
    }

    @Override
    @Override
    public void dismissDialog() {
    public void dismissDialog() {
        dismiss();
        dismiss();
+7 −2
Original line number Original line Diff line number Diff line
@@ -171,7 +171,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback {
    @Override
    @Override
    public void onDeviceListUpdate(List<MediaDevice> devices) {
    public void onDeviceListUpdate(List<MediaDevice> devices) {
        buildMediaDevices(devices);
        buildMediaDevices(devices);
        mCallback.onRouteChanged();
        mCallback.onDeviceListChanged();
    }
    }


    @Override
    @Override
@@ -570,10 +570,15 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback {
        void onMediaStoppedOrPaused();
        void onMediaStoppedOrPaused();


        /**
        /**
         * Override to handle the device updating.
         * Override to handle the device status or attributes updating.
         */
         */
        void onRouteChanged();
        void onRouteChanged();


        /**
         * Override to handle the devices set updating.
         */
        void onDeviceListChanged();

        /**
        /**
         * Override to dismiss dialog.
         * Override to dismiss dialog.
         */
         */
+1 −1
Original line number Original line Diff line number Diff line
@@ -201,7 +201,7 @@ public class MediaOutputControllerTest extends SysuiTestCase {


        assertThat(devices.containsAll(mMediaDevices)).isTrue();
        assertThat(devices.containsAll(mMediaDevices)).isTrue();
        assertThat(devices.size()).isEqualTo(mMediaDevices.size());
        assertThat(devices.size()).isEqualTo(mMediaDevices.size());
        verify(mCb).onRouteChanged();
        verify(mCb).onDeviceListChanged();
    }
    }


    @Test
    @Test