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

Commit 0359ec8f authored by Anton Potapov's avatar Anton Potapov Committed by Android (Google) Code Review
Browse files

Merge "Show media output header when calling" into main

parents f747d863 3ab98d39
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -16,9 +16,9 @@

package com.android.systemui.volume.panel.component.mediaoutput

import com.android.systemui.volume.panel.component.mediaoutput.domain.MediaOutputAvailabilityCriteria
import com.android.systemui.volume.panel.component.mediaoutput.ui.composable.MediaOutputComponent
import com.android.systemui.volume.panel.component.shared.model.VolumePanelComponents
import com.android.systemui.volume.panel.domain.AlwaysAvailableCriteria
import com.android.systemui.volume.panel.domain.ComponentAvailabilityCriteria
import com.android.systemui.volume.panel.shared.model.VolumePanelUiComponent
import dagger.Binds
@@ -39,6 +39,6 @@ interface MediaOutputModule {
    @IntoMap
    @StringKey(VolumePanelComponents.MEDIA_OUTPUT)
    fun bindComponentAvailabilityCriteria(
        criteria: MediaOutputAvailabilityCriteria
        criteria: AlwaysAvailableCriteria
    ): ComponentAvailabilityCriteria
}
+0 −82
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.volume.panel.component.mediaoutput.domain

import android.media.AudioManager
import android.testing.TestableLooper.RunWithLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.kosmos.testScope
import com.android.systemui.testKosmos
import com.android.systemui.volume.data.repository.audioRepository
import com.android.systemui.volume.domain.interactor.audioModeInteractor
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@RunWith(AndroidJUnit4::class)
@RunWithLooper(setAsMainLooper = true)
class MediaOutputAvailabilityCriteriaTest : SysuiTestCase() {

    private val kosmos = testKosmos()

    private lateinit var underTest: MediaOutputAvailabilityCriteria

    @Before
    fun setup() {
        underTest =
            MediaOutputAvailabilityCriteria(
                kosmos.audioModeInteractor,
            )
    }

    @Test
    fun notInCall_isAvailable_true() {
        with(kosmos) {
            testScope.runTest {
                audioRepository.setMode(AudioManager.MODE_NORMAL)

                val isAvailable by collectLastValue(underTest.isAvailable())
                runCurrent()

                assertThat(isAvailable).isTrue()
            }
        }
    }

    @Test
    fun inCall_isAvailable_false() {
        with(kosmos) {
            testScope.runTest {
                audioRepository.setMode(AudioManager.MODE_IN_CALL)

                val isAvailable by collectLastValue(underTest.isAvailable())
                runCurrent()

                assertThat(isAvailable).isFalse()
            }
        }
    }
}
+5 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.systemui.testKosmos
import com.android.systemui.volume.localMediaController
import com.android.systemui.volume.mediaControllerRepository
import com.android.systemui.volume.mediaOutputInteractor
import com.android.systemui.volume.panel.shared.model.filterData
import com.android.systemui.volume.remoteMediaController
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -67,7 +68,8 @@ class MediaDeviceSessionInteractorTest : SysuiTestCase() {
    fun playbackInfo_returnsPlaybackInfo() {
        with(kosmos) {
            testScope.runTest {
                val session by collectLastValue(mediaOutputInteractor.defaultActiveMediaSession)
                val session by
                    collectLastValue(mediaOutputInteractor.defaultActiveMediaSession.filterData())
                runCurrent()
                val info by collectLastValue(underTest.playbackInfo(session!!))
                runCurrent()
@@ -81,7 +83,8 @@ class MediaDeviceSessionInteractorTest : SysuiTestCase() {
    fun playbackState_returnsPlaybackState() {
        with(kosmos) {
            testScope.runTest {
                val session by collectLastValue(mediaOutputInteractor.defaultActiveMediaSession)
                val session by
                    collectLastValue(mediaOutputInteractor.defaultActiveMediaSession.filterData())
                runCurrent()
                val state by collectLastValue(underTest.playbackState(session!!))
                runCurrent()
+4 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import com.android.systemui.res.R
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.android.systemui.volume.domain.interactor.audioModeInteractor
import com.android.systemui.volume.domain.interactor.audioOutputInteractor
import com.android.systemui.volume.localMediaController
import com.android.systemui.volume.localMediaRepository
import com.android.systemui.volume.mediaControllerRepository
@@ -64,6 +66,8 @@ class MediaOutputViewModelTest : SysuiTestCase() {
                    testScope.backgroundScope,
                    mediaOutputActionsInteractor,
                    mediaDeviceSessionInteractor,
                    audioOutputInteractor,
                    audioModeInteractor,
                    mediaOutputInteractor,
                    uiEventLogger,
                )
+4 −1
Original line number Diff line number Diff line
@@ -1634,12 +1634,15 @@
    <!-- Hint for accessibility. A stream name is a parameter. For example: double tap to unmute media [CHAR_LIMIT=NONE] -->
    <string name="volume_panel_hint_unmute">unmute %s</string>

    <!-- Title with application label for media output settings. [CHAR LIMIT=20] -->
    <!-- Title with application label for media output settings when there is media playing. [CHAR LIMIT=20] -->
    <string name="media_output_label_title">Playing <xliff:g id="label" example="Music Player">%s</xliff:g> on</string>

    <!-- Title for media output settings without media is playing. [CHAR LIMIT=20] -->
    <string name="media_output_title_without_playing">Audio will play on</string>

    <!-- Title for media output settings when there is an ongoing call in progress. [CHAR LIMIT=20] -->
    <string name="media_output_title_ongoing_call">Calling on</string>

    <!-- Name of special SystemUI debug settings -->
    <string name="system_ui_tuner">System UI Tuner</string>

Loading