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

Commit f05aa68f authored by Robert Snoeberger's avatar Robert Snoeberger
Browse files

Disable output switcher in resumption controls

Bug: 159229758
Test: manual - Play Spotify, reboot, look at player. Check that output
switcher is disabled.
Test: manual - Play Spotify, dismiss app, look at player. Check that
output switcher is disabled

Change-Id: I2ca75b7c0c0a198ca827395ea3fc9f5c586553e6
parent f07d289b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import javax.inject.Inject;
 */
public class MediaControlPanel {
    private static final String TAG = "MediaControlPanel";
    private static final float DISABLED_ALPHA = 0.38f;

    // Button IDs for QS controls
    static final int[] ACTION_IDS = {
@@ -276,6 +277,11 @@ public class MediaControlPanel {
        mViewHolder.getSeamless().setVisibility(seamlessVisibility);
        expandedSet.setVisibility(seamlessId, seamlessVisibility);
        collapsedSet.setVisibility(seamlessId, seamlessVisibility);
        final float seamlessAlpha = data.getResumption() ? DISABLED_ALPHA : 1.0f;
        expandedSet.setAlpha(seamlessId, seamlessAlpha);
        collapsedSet.setAlpha(seamlessId, seamlessAlpha);
        // Disable clicking on output switcher for resumption controls.
        mViewHolder.getSeamless().setEnabled(!data.getResumption());
        if (showFallback) {
            iconView.setImageDrawable(null);
            deviceName.setText(null);
+5 −0
Original line number Diff line number Diff line
@@ -80,6 +80,11 @@ data class MediaData(
     * Action that should be performed to restart a non active session.
     */
    var resumeAction: Runnable?,
    /**
     * Indicates that this player is a resumption player (ie. It only shows a play actions which
     * will start the app and start playing).
     */
    var resumption: Boolean = false,
    /**
     * Notification key for cancelling a media player after a timeout (when not using resumption.)
     */
+2 −2
Original line number Diff line number Diff line
@@ -323,7 +323,7 @@ class MediaDataManager(
            onMediaDataLoaded(packageName, null, MediaData(true, bgColor, appName,
                    null, desc.subtitle, desc.title, artworkIcon, listOf(mediaAction), listOf(0),
                    packageName, token, appIntent, device = null, active = false,
                    resumeAction = resumeAction, notificationKey = packageName,
                    resumeAction = resumeAction, resumption = true, notificationKey = packageName,
                    hasCheckedForResume = true))
        }
    }
@@ -542,7 +542,7 @@ class MediaDataManager(
            val data = mediaEntries.remove(key)!!
            val resumeAction = getResumeMediaAction(data.resumeAction!!)
            val updated = data.copy(token = null, actions = listOf(resumeAction),
                actionsToShowInCompact = listOf(0), active = false)
                    actionsToShowInCompact = listOf(0), active = false, resumption = true)
            mediaEntries.put(data.packageName, updated)
            // Notify listeners of "new" controls
            val listenersCopy = listeners.toSet()
+11 −0
Original line number Diff line number Diff line
@@ -242,4 +242,15 @@ public class MediaControlPanelTest : SysuiTestCase() {
        assertThat(seamlessText.getText()).isEqualTo(context.getResources().getString(
                com.android.internal.R.string.ext_media_seamless_action))
    }

    @Test
    fun bindDeviceResumptionPlayer() {
        player.attach(holder)
        val state = MediaData(true, BG_COLOR, APP, null, ARTIST, TITLE, null, emptyList(),
                emptyList(), PACKAGE, session.getSessionToken(), null, device, true, null,
                resumption = true)
        player.bind(state)
        assertThat(seamlessText.getText()).isEqualTo(DEVICE_NAME)
        assertThat(seamless.isEnabled()).isFalse()
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -79,8 +79,8 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
        mManager.addListener(mListener);

        mMediaData = new MediaData(true, BG_COLOR, APP, null, ARTIST, TITLE, null,
                new ArrayList<>(), new ArrayList<>(), PACKAGE, null, null, null, true, null, KEY,
                false);
                new ArrayList<>(), new ArrayList<>(), PACKAGE, null, null, null, true, null, false,
                KEY, false);
        mDeviceData = new MediaDeviceData(true, null, DEVICE_NAME);
    }

Loading