Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileIconBinder.kt +7 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle import com.android.settingslib.graph.SignalDrawable import com.android.systemui.R import com.android.systemui.common.ui.binder.ContentDescriptionViewBinder import com.android.systemui.common.ui.binder.IconViewBinder import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.statusbar.StatusBarIconView Loading Loading @@ -97,6 +98,12 @@ object MobileIconBinder { } } launch { viewModel.contentDescription.distinctUntilChanged().collect { ContentDescriptionViewBinder.bind(it, view) } } // Set the network type icon launch { viewModel.networkTypeIcon.distinctUntilChanged().collect { dataTypeId -> Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt +20 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH_NONE import com.android.settingslib.graph.SignalDrawable import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon Loading Loading @@ -43,6 +45,7 @@ interface MobileIconViewModelCommon { val subscriptionId: Int /** An int consumable by [SignalDrawable] for display */ val iconId: Flow<Int> val contentDescription: Flow<ContentDescription> val roaming: Flow<Boolean> /** The RAT icon (LTE, 3G, 5G, etc) to be displayed. Null if we shouldn't show anything */ val networkTypeIcon: Flow<Icon?> Loading Loading @@ -102,6 +105,23 @@ constructor( .stateIn(scope, SharingStarted.WhileSubscribed(), initial) } override val contentDescription: Flow<ContentDescription> = run { val initial = ContentDescription.Resource(PHONE_SIGNAL_STRENGTH_NONE) combine( iconInteractor.level, iconInteractor.isInService, ) { level, isInService -> val resId = when { isInService -> PHONE_SIGNAL_STRENGTH[level] else -> PHONE_SIGNAL_STRENGTH_NONE } ContentDescription.Resource(resId) } .distinctUntilChanged() .stateIn(scope, SharingStarted.WhileSubscribed(), initial) } private val showNetworkTypeIcon: Flow<Boolean> = combine( iconInteractor.isDataConnected, Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt +35 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel import androidx.test.filters.SmallTest import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH_NONE import com.android.settingslib.graph.SignalDrawable import com.android.settingslib.mobile.TelephonyIcons.THREE_G import com.android.systemui.SysuiTestCase Loading Loading @@ -121,6 +123,39 @@ class MobileIconViewModelTest : SysuiTestCase() { job.cancel() } @Test fun contentDescription_notInService_usesNoPhone() = testScope.runTest { var latest: ContentDescription? = null val job = underTest.contentDescription.onEach { latest = it }.launchIn(this) interactor.isInService.value = false assertThat((latest as ContentDescription.Resource).res) .isEqualTo(PHONE_SIGNAL_STRENGTH_NONE) job.cancel() } @Test fun contentDescription_inService_usesLevel() = testScope.runTest { var latest: ContentDescription? = null val job = underTest.contentDescription.onEach { latest = it }.launchIn(this) interactor.isInService.value = true interactor.level.value = 2 assertThat((latest as ContentDescription.Resource).res) .isEqualTo(PHONE_SIGNAL_STRENGTH[2]) interactor.level.value = 0 assertThat((latest as ContentDescription.Resource).res) .isEqualTo(PHONE_SIGNAL_STRENGTH[0]) job.cancel() } @Test fun networkType_dataEnabled_groupIsRepresented() = testScope.runTest { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileIconBinder.kt +7 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle import com.android.settingslib.graph.SignalDrawable import com.android.systemui.R import com.android.systemui.common.ui.binder.ContentDescriptionViewBinder import com.android.systemui.common.ui.binder.IconViewBinder import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.statusbar.StatusBarIconView Loading Loading @@ -97,6 +98,12 @@ object MobileIconBinder { } } launch { viewModel.contentDescription.distinctUntilChanged().collect { ContentDescriptionViewBinder.bind(it, view) } } // Set the network type icon launch { viewModel.networkTypeIcon.distinctUntilChanged().collect { dataTypeId -> Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt +20 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH_NONE import com.android.settingslib.graph.SignalDrawable import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon Loading Loading @@ -43,6 +45,7 @@ interface MobileIconViewModelCommon { val subscriptionId: Int /** An int consumable by [SignalDrawable] for display */ val iconId: Flow<Int> val contentDescription: Flow<ContentDescription> val roaming: Flow<Boolean> /** The RAT icon (LTE, 3G, 5G, etc) to be displayed. Null if we shouldn't show anything */ val networkTypeIcon: Flow<Icon?> Loading Loading @@ -102,6 +105,23 @@ constructor( .stateIn(scope, SharingStarted.WhileSubscribed(), initial) } override val contentDescription: Flow<ContentDescription> = run { val initial = ContentDescription.Resource(PHONE_SIGNAL_STRENGTH_NONE) combine( iconInteractor.level, iconInteractor.isInService, ) { level, isInService -> val resId = when { isInService -> PHONE_SIGNAL_STRENGTH[level] else -> PHONE_SIGNAL_STRENGTH_NONE } ContentDescription.Resource(resId) } .distinctUntilChanged() .stateIn(scope, SharingStarted.WhileSubscribed(), initial) } private val showNetworkTypeIcon: Flow<Boolean> = combine( iconInteractor.isDataConnected, Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt +35 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel import androidx.test.filters.SmallTest import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH_NONE import com.android.settingslib.graph.SignalDrawable import com.android.settingslib.mobile.TelephonyIcons.THREE_G import com.android.systemui.SysuiTestCase Loading Loading @@ -121,6 +123,39 @@ class MobileIconViewModelTest : SysuiTestCase() { job.cancel() } @Test fun contentDescription_notInService_usesNoPhone() = testScope.runTest { var latest: ContentDescription? = null val job = underTest.contentDescription.onEach { latest = it }.launchIn(this) interactor.isInService.value = false assertThat((latest as ContentDescription.Resource).res) .isEqualTo(PHONE_SIGNAL_STRENGTH_NONE) job.cancel() } @Test fun contentDescription_inService_usesLevel() = testScope.runTest { var latest: ContentDescription? = null val job = underTest.contentDescription.onEach { latest = it }.launchIn(this) interactor.isInService.value = true interactor.level.value = 2 assertThat((latest as ContentDescription.Resource).res) .isEqualTo(PHONE_SIGNAL_STRENGTH[2]) interactor.level.value = 0 assertThat((latest as ContentDescription.Resource).res) .isEqualTo(PHONE_SIGNAL_STRENGTH[0]) job.cancel() } @Test fun networkType_dataEnabled_groupIsRepresented() = testScope.runTest { Loading