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

Commit 6daa83b7 authored by Beth Thibodeau's avatar Beth Thibodeau
Browse files

Remove recommendation code from media pipeline

This includes
- onSmartspaceMediaDataLoaded/Removed callback methods
- params in onMediaDataLoaded that were only relevant with recommendations
- SmartspaceMediaData et al
- And renaming has*MediaOrRecommendation methods

Bug: 382680767
Flag: EXEMPT refactor - unused code
Test: play media with and without scene container flag enabled
Test: atest SystemUITests:com.android.systemui.media.controls
Test: atest SystemUITests:com.android.systemui.qs
Change-Id: I7c0107cb8941876840467a1c9f9e526229ec7e29
parent b4ce5172
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -57,11 +57,11 @@ class CommunalMediaRepositoryImplTest : SysuiTestCase() {
    }

    @Test
    fun hasAnyMediaOrRecommendation_defaultsToFalse() =
    fun hasAnyMedia_defaultsToFalse() =
        testScope.runTest {
            val mediaModel = collectLastValue(underTest.mediaModel)
            runCurrent()
            assertThat(mediaModel()?.hasAnyMediaOrRecommendation).isFalse()
            assertThat(mediaModel()?.hasAnyMedia).isFalse()
        }

    @Test
@@ -75,16 +75,16 @@ class CommunalMediaRepositoryImplTest : SysuiTestCase() {
            // Initial value is false.
            val mediaModel = collectLastValue(underTest.mediaModel)
            runCurrent()
            assertThat(mediaModel()?.hasAnyMediaOrRecommendation).isFalse()
            assertThat(mediaModel()?.hasAnyMedia).isFalse()

            // Change to media available and notify the listener.
            whenever(mediaDataManager.hasAnyMediaOrRecommendation()).thenReturn(true)
            whenever(mediaDataManager.hasAnyMedia()).thenReturn(true)
            whenever(mediaData.createdTimestampMillis).thenReturn(1234L)
            mediaDataListenerCaptor.firstValue.onMediaDataLoaded("key", null, mediaData)
            runCurrent()

            // Media active now returns true.
            assertThat(mediaModel()?.hasAnyMediaOrRecommendation).isTrue()
            assertThat(mediaModel()?.hasAnyMedia).isTrue()
            assertThat(mediaModel()?.createdTimestampMillis).isEqualTo(1234L)
        }

@@ -97,20 +97,20 @@ class CommunalMediaRepositoryImplTest : SysuiTestCase() {
            verify(mediaDataManager).addListener(mediaDataListenerCaptor.capture())

            // Change to media available and notify the listener.
            whenever(mediaDataManager.hasAnyMediaOrRecommendation()).thenReturn(true)
            whenever(mediaDataManager.hasAnyMedia()).thenReturn(true)
            mediaDataListenerCaptor.firstValue.onMediaDataLoaded("key", null, mediaData)
            runCurrent()

            // Media active now returns true.
            val mediaModel = collectLastValue(underTest.mediaModel)
            assertThat(mediaModel()?.hasAnyMediaOrRecommendation).isTrue()
            assertThat(mediaModel()?.hasAnyMedia).isTrue()

            // Change to media unavailable and notify the listener.
            whenever(mediaDataManager.hasAnyMediaOrRecommendation()).thenReturn(false)
            whenever(mediaDataManager.hasAnyMedia()).thenReturn(false)
            mediaDataListenerCaptor.firstValue.onMediaDataRemoved("key", false)
            runCurrent()

            // Media active now returns false.
            assertThat(mediaModel()?.hasAnyMediaOrRecommendation).isFalse()
            assertThat(mediaModel()?.hasAnyMedia).isFalse()
        }
}
+6 −16
Original line number Diff line number Diff line
@@ -54,20 +54,19 @@ class MediaCarouselInteractorTest : SysuiTestCase() {
    @Test
    fun addUserMediaEntry_activeThenInactivate() =
        testScope.runTest {
            val hasActiveMediaOrRecommendation by
                collectLastValue(underTest.hasActiveMediaOrRecommendation)
            val hasActiveMedia by collectLastValue(underTest.hasActiveMedia)

            val userMedia = MediaData(active = true)

            mediaFilterRepository.addSelectedUserMediaEntry(userMedia)

            assertThat(hasActiveMediaOrRecommendation).isTrue()
            assertThat(hasActiveMedia).isTrue()
            assertThat(underTest.hasActiveMedia()).isTrue()
            assertThat(underTest.hasAnyMedia()).isTrue()

            mediaFilterRepository.addSelectedUserMediaEntry(userMedia.copy(active = false))

            assertThat(hasActiveMediaOrRecommendation).isFalse()
            assertThat(hasActiveMedia).isFalse()
            assertThat(underTest.hasActiveMedia()).isFalse()
            assertThat(underTest.hasAnyMedia()).isTrue()
        }
@@ -75,8 +74,7 @@ class MediaCarouselInteractorTest : SysuiTestCase() {
    @Test
    fun addInactiveUserMediaEntry_thenRemove() =
        testScope.runTest {
            val hasActiveMediaOrRecommendation by
                collectLastValue(underTest.hasActiveMediaOrRecommendation)
            val hasActiveMedia by collectLastValue(underTest.hasActiveMedia)

            val userMedia = MediaData(active = false)
            val instanceId = userMedia.instanceId
@@ -84,7 +82,7 @@ class MediaCarouselInteractorTest : SysuiTestCase() {
            mediaFilterRepository.addSelectedUserMediaEntry(userMedia)
            mediaFilterRepository.addMediaDataLoadingState(MediaDataLoadingModel.Loaded(instanceId))

            assertThat(hasActiveMediaOrRecommendation).isFalse()
            assertThat(hasActiveMedia).isFalse()
            assertThat(underTest.hasActiveMedia()).isFalse()
            assertThat(underTest.hasAnyMedia()).isTrue()

@@ -94,7 +92,7 @@ class MediaCarouselInteractorTest : SysuiTestCase() {
                MediaDataLoadingModel.Removed(instanceId)
            )

            assertThat(hasActiveMediaOrRecommendation).isFalse()
            assertThat(hasActiveMedia).isFalse()
            assertThat(underTest.hasActiveMedia()).isFalse()
            assertThat(underTest.hasAnyMedia()).isFalse()
        }
@@ -103,15 +101,7 @@ class MediaCarouselInteractorTest : SysuiTestCase() {
    fun hasAnyMedia_noMediaSet_returnsFalse() =
        testScope.runTest { assertThat(underTest.hasAnyMedia()).isFalse() }

    @Test
    fun hasAnyMediaOrRecommendation_noMediaSet_returnsFalse() =
        testScope.runTest { assertThat(underTest.hasAnyMediaOrRecommendation.value).isFalse() }

    @Test
    fun hasActiveMedia_noMediaSet_returnsFalse() =
        testScope.runTest { assertThat(underTest.hasActiveMedia()).isFalse() }

    @Test
    fun hasActiveMediaOrRecommendation_nothingSet_returnsFalse() =
        testScope.runTest { assertThat(underTest.hasActiveMediaOrRecommendation.value).isFalse() }
}
+22 −44
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.systemui.media.controls.domain.pipeline;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.eq;
@@ -86,11 +85,9 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
    @Test
    public void eventNotEmittedWithoutDevice() {
        // WHEN data source emits an event without device data
        mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
                0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
        mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */);
        // THEN an event isn't emitted
        verify(mListener, never()).onMediaDataLoaded(eq(KEY), any(), any(), anyBoolean(),
                anyInt(), anyBoolean());
        verify(mListener, never()).onMediaDataLoaded(eq(KEY), any(), any(), anyBoolean());
    }

    @Test
@@ -98,8 +95,7 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
        // WHEN device source emits an event without media data
        mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
        // THEN an event isn't emitted
        verify(mListener, never()).onMediaDataLoaded(eq(KEY), any(), any(), anyBoolean(),
                anyInt(), anyBoolean());
        verify(mListener, never()).onMediaDataLoaded(eq(KEY), any(), any(), anyBoolean());
    }

    @Test
@@ -107,95 +103,80 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
        // GIVEN that a device event has already been received
        mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
        // WHEN media event is received
        mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
                0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
        mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */);
        // THEN the listener receives a combined event
        ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
        verify(mListener).onMediaDataLoaded(eq(KEY), any(), captor.capture(), anyBoolean(),
                anyInt(), anyBoolean());
        verify(mListener).onMediaDataLoaded(eq(KEY), any(), captor.capture(), anyBoolean());
        assertThat(captor.getValue().getDevice()).isNotNull();
    }

    @Test
    public void emitEventAfterMediaFirst() {
        // GIVEN that media event has already been received
        mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
                0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
        mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */);
        // WHEN device event is received
        mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
        // THEN the listener receives a combined event
        ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
        verify(mListener).onMediaDataLoaded(eq(KEY), any(), captor.capture(), anyBoolean(),
                anyInt(), anyBoolean());
        verify(mListener).onMediaDataLoaded(eq(KEY), any(), captor.capture(), anyBoolean());
        assertThat(captor.getValue().getDevice()).isNotNull();
    }

    @Test
    public void migrateKeyMediaFirst() {
        // GIVEN that media and device info has already been received
        mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
                0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
        mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */);
        mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
        reset(mListener);
        // WHEN a key migration event is received
        mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */,
                0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
        mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */);
        // THEN the listener receives a combined event
        ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
        verify(mListener).onMediaDataLoaded(eq(KEY), eq(OLD_KEY), captor.capture(), anyBoolean(),
                anyInt(), anyBoolean());
        verify(mListener).onMediaDataLoaded(eq(KEY), eq(OLD_KEY), captor.capture(), anyBoolean());
        assertThat(captor.getValue().getDevice()).isNotNull();
    }

    @Test
    public void migrateKeyDeviceFirst() {
        // GIVEN that media and device info has already been received
        mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
                0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
        mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */);
        mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
        reset(mListener);
        // WHEN a key migration event is received
        mManager.onMediaDeviceChanged(KEY, OLD_KEY, mDeviceData);
        // THEN the listener receives a combined event
        ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
        verify(mListener).onMediaDataLoaded(eq(KEY), eq(OLD_KEY), captor.capture(), anyBoolean(),
                anyInt(), anyBoolean());
        verify(mListener).onMediaDataLoaded(eq(KEY), eq(OLD_KEY), captor.capture(), anyBoolean());
        assertThat(captor.getValue().getDevice()).isNotNull();
    }

    @Test
    public void migrateKeyMediaAfter() {
        // GIVEN that media and device info has already been received
        mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
                0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
        mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */);
        mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
        mManager.onMediaDeviceChanged(KEY, OLD_KEY, mDeviceData);
        reset(mListener);
        // WHEN a second key migration event is received for media
        mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */,
                0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
        mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */);
        // THEN the key has already been migrated
        ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
        verify(mListener).onMediaDataLoaded(eq(KEY), eq(KEY), captor.capture(), anyBoolean(),
                anyInt(), anyBoolean());
        verify(mListener).onMediaDataLoaded(eq(KEY), eq(KEY), captor.capture(), anyBoolean());
        assertThat(captor.getValue().getDevice()).isNotNull();
    }

    @Test
    public void migrateKeyDeviceAfter() {
        // GIVEN that media and device info has already been received
        mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
                0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
        mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */);
        mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
        mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */,
                0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
        mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */);
        reset(mListener);
        // WHEN a second key migration event is received for the device
        mManager.onMediaDeviceChanged(KEY, OLD_KEY, mDeviceData);
        // THEN the key has already be migrated
        ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
        verify(mListener).onMediaDataLoaded(eq(KEY), eq(KEY), captor.capture(), anyBoolean(),
                anyInt(), anyBoolean());
        verify(mListener).onMediaDataLoaded(eq(KEY), eq(KEY), captor.capture(), anyBoolean());
        assertThat(captor.getValue().getDevice()).isNotNull();
    }

@@ -209,8 +190,7 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {

    @Test
    public void mediaDataRemovedAfterMediaEvent() {
        mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
                0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
        mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */);
        mManager.onMediaDataRemoved(KEY, false);
        verify(mListener).onMediaDataRemoved(eq(KEY), eq(false));
    }
@@ -225,15 +205,13 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
    @Test
    public void mediaDataKeyUpdated() {
        // GIVEN that device and media events have already been received
        mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
                0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
        mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */);
        mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
        // WHEN the key is changed
        mManager.onMediaDataLoaded("NEW_KEY", KEY, mMediaData, true /* immediately */,
                0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
        mManager.onMediaDataLoaded("NEW_KEY", KEY, mMediaData, true /* immediately */);
        // THEN the listener gets a load event with the correct keys
        ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
        verify(mListener).onMediaDataLoaded(
                eq("NEW_KEY"), any(), captor.capture(), anyBoolean(), anyInt(), anyBoolean());
                eq("NEW_KEY"), any(), captor.capture(), anyBoolean());
    }
}
+0 −123
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.media.controls.shared

import android.app.smartspace.SmartspaceAction
import android.graphics.drawable.Icon
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.InstanceId
import com.android.systemui.SysuiTestCase
import com.android.systemui.media.controls.shared.model.NUM_REQUIRED_RECOMMENDATIONS
import com.android.systemui.media.controls.shared.model.SmartspaceMediaData
import com.android.systemui.res.R
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
class SmartspaceMediaDataTest : SysuiTestCase() {

    private val icon: Icon = Icon.createWithResource(context, R.drawable.ic_media_play)

    @Test
    fun getValidRecommendations_onlyReturnsRecsWithIcons() {
        val withIcon1 = SmartspaceAction.Builder("id", "title").setIcon(icon).build()
        val withIcon2 = SmartspaceAction.Builder("id", "title").setIcon(icon).build()
        val withoutIcon1 = SmartspaceAction.Builder("id", "title").setIcon(null).build()
        val withoutIcon2 = SmartspaceAction.Builder("id", "title").setIcon(null).build()
        val recommendations = listOf(withIcon1, withoutIcon1, withIcon2, withoutIcon2)

        val data = DEFAULT_DATA.copy(recommendations = recommendations)

        assertThat(data.getValidRecommendations()).isEqualTo(listOf(withIcon1, withIcon2))
    }

    @Test
    fun isValid_emptyList_returnsFalse() {
        val data = DEFAULT_DATA.copy(recommendations = listOf())

        assertThat(data.isValid()).isFalse()
    }

    @Test
    fun isValid_tooFewRecs_returnsFalse() {
        val data =
            DEFAULT_DATA.copy(
                recommendations =
                    listOf(SmartspaceAction.Builder("id", "title").setIcon(icon).build())
            )

        assertThat(data.isValid()).isFalse()
    }

    @Test
    fun isValid_tooFewRecsWithIcons_returnsFalse() {
        val recommendations = mutableListOf<SmartspaceAction>()
        // Add one fewer recommendation w/ icon than the number required
        for (i in 1 until NUM_REQUIRED_RECOMMENDATIONS) {
            recommendations.add(SmartspaceAction.Builder("id", "title").setIcon(icon).build())
        }
        for (i in 1 until 3) {
            recommendations.add(SmartspaceAction.Builder("id", "title").setIcon(null).build())
        }

        val data = DEFAULT_DATA.copy(recommendations = recommendations)

        assertThat(data.isValid()).isFalse()
    }

    @Test
    fun isValid_enoughRecsWithIcons_returnsTrue() {
        val recommendations = mutableListOf<SmartspaceAction>()
        // Add the number of required recommendations
        for (i in 0 until NUM_REQUIRED_RECOMMENDATIONS) {
            recommendations.add(SmartspaceAction.Builder("id", "title").setIcon(icon).build())
        }

        val data = DEFAULT_DATA.copy(recommendations = recommendations)

        assertThat(data.isValid()).isTrue()
    }

    @Test
    fun isValid_manyRecsWithIcons_returnsTrue() {
        val recommendations = mutableListOf<SmartspaceAction>()
        // Add more than enough recommendations
        for (i in 0 until NUM_REQUIRED_RECOMMENDATIONS + 3) {
            recommendations.add(SmartspaceAction.Builder("id", "title").setIcon(icon).build())
        }

        val data = DEFAULT_DATA.copy(recommendations = recommendations)

        assertThat(data.isValid()).isTrue()
    }
}

private val DEFAULT_DATA =
    SmartspaceMediaData(
        targetId = "INVALID",
        isActive = false,
        packageName = "INVALID",
        cardAction = null,
        recommendations = emptyList(),
        dismissIntent = null,
        headphoneConnectionTimeMillis = 0,
        instanceId = InstanceId.fakeInstanceId(-1),
        expiryTimeMs = 0,
    )
+7 −14
Original line number Diff line number Diff line
@@ -80,13 +80,11 @@ public class MediaDreamSentinelTest extends SysuiTestCase {
        final MediaDataManager.Listener listener = captureMediaDataListener();

        when(mMediaDataManager.hasActiveMedia()).thenReturn(false);
        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */ true,
                /* receivedSmartspaceCardLatency= */ 0, /* isSsReactived= */ false);
        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */ true);
        verify(mDreamOverlayStateController, never()).addComplication(any());

        when(mMediaDataManager.hasActiveMedia()).thenReturn(true);
        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */true,
                /* receivedSmartspaceCardLatency= */0, /* isSsReactived= */ false);
        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */true);
        verify(mDreamOverlayStateController).addComplication(eq(mMediaEntryComplication));
        verify(mDreamOverlayStateController, never()).addComplication(
                not(eq(mMediaEntryComplication)));
@@ -101,8 +99,7 @@ public class MediaDreamSentinelTest extends SysuiTestCase {
        final MediaDataManager.Listener listener = captureMediaDataListener();

        when(mMediaDataManager.hasActiveMedia()).thenReturn(true);
        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */true,
                /* receivedSmartspaceCardLatency= */0, /* isSsReactived= */ false);
        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */true);

        listener.onMediaDataRemoved(mKey, false);
        verify(mDreamOverlayStateController, never()).removeComplication(any());
@@ -121,17 +118,14 @@ public class MediaDreamSentinelTest extends SysuiTestCase {
        final MediaDataManager.Listener listener = captureMediaDataListener();

        when(mMediaDataManager.hasActiveMedia()).thenReturn(true);
        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */true,
                /* receivedSmartspaceCardLatency= */0, /* isSsReactived= */ false);
        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */true);
        verify(mDreamOverlayStateController, never()).removeComplication(any());

        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */true,
                /* receivedSmartspaceCardLatency= */0, /* isSsReactived= */ false);
        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */true);
        verify(mDreamOverlayStateController, never()).removeComplication(any());

        when(mMediaDataManager.hasActiveMedia()).thenReturn(false);
        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */true,
                /* receivedSmartspaceCardLatency= */0, /* isSsReactived= */ false);
        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */true);
        verify(mDreamOverlayStateController).removeComplication(eq(mMediaEntryComplication));
    }

@@ -146,8 +140,7 @@ public class MediaDreamSentinelTest extends SysuiTestCase {

        final MediaDataManager.Listener listener = captureMediaDataListener();
        when(mMediaDataManager.hasActiveMedia()).thenReturn(true);
        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */true,
                /* receivedSmartspaceCardLatency= */0, /* isSsReactived= */ false);
        listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */true);
        verify(mDreamOverlayStateController, never()).addComplication(any());
    }

Loading