Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileIconBinder.kt +98 −83 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.widget.ImageView import android.widget.Space import androidx.core.view.isVisible import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle import com.android.settingslib.graph.SignalDrawable import com.android.systemui.R Loading Loading @@ -64,7 +65,7 @@ object MobileIconBinder { val roamingSpace = view.requireViewById<Space>(R.id.mobile_roaming_space) val dotView = view.requireViewById<StatusBarIconView>(R.id.status_bar_dot) view.isVisible = true view.isVisible = viewModel.isVisible.value iconView.isVisible = true // TODO(b/238425913): We should log this visibility state. Loading @@ -77,6 +78,28 @@ object MobileIconBinder { var isCollecting = false view.repeatWhenAttached { lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.CREATED) { // isVisible controls the visibility state of the outer group, and thus it needs // to run in the CREATED lifecycle so it can continue to watch while invisible // See (b/291031862) for details launch { viewModel.isVisible.collect { isVisible -> viewModel.verboseLogger?.logBinderReceivedVisibility( view, viewModel.subscriptionId, isVisible ) view.isVisible = isVisible // [StatusIconContainer] can get out of sync sometimes. Make sure to // request another layout when this changes. view.requestLayout() } } } } lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { logger.logCollectionStarted(view, viewModel) isCollecting = true Loading @@ -100,17 +123,6 @@ object MobileIconBinder { } } launch { viewModel.isVisible.collect { isVisible -> viewModel.verboseLogger?.logBinderReceivedVisibility( view, viewModel.subscriptionId, isVisible ) view.isVisible = isVisible } } // Set the icon for the triangle launch { viewModel.icon.distinctUntilChanged().collect { icon -> Loading Loading @@ -156,7 +168,9 @@ object MobileIconBinder { launch { viewModel.activityOutVisible.collect { activityOut.isVisible = it } } launch { viewModel.activityContainerVisible.collect { activityContainer.isVisible = it } viewModel.activityContainerVisible.collect { activityContainer.isVisible = it } } // Set the tint Loading @@ -182,6 +196,7 @@ object MobileIconBinder { } } } } return object : ModernStatusBarViewBinding { override fun getShouldIconBeVisible(): Boolean { Loading packages/SystemUI/tests/src/com/android/systemui/shade/carrier/ShadeCarrierGroupControllerTest.java +10 −2 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import com.android.systemui.statusbar.pipeline.mobile.ui.MobileViewLogger; import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.MobileIconsViewModel; import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.ShadeCarrierGroupMobileIconViewModel; import com.android.systemui.util.CarrierConfigTracker; import com.android.systemui.util.kotlin.FlowProviderKt; import com.android.systemui.utils.leaks.LeakCheckedTest; import com.android.systemui.utils.os.FakeHandler; Loading @@ -72,6 +73,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import kotlinx.coroutines.flow.MutableStateFlow; @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper @SmallTest Loading Loading @@ -105,7 +108,8 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest { private ShadeCarrier mShadeCarrier3; private TestableLooper mTestableLooper; @Mock private ShadeCarrierGroupController.OnSingleCarrierChangedListener mOnSingleCarrierChangedListener; private ShadeCarrierGroupController.OnSingleCarrierChangedListener mOnSingleCarrierChangedListener; @Mock private MobileUiAdapter mMobileUiAdapter; @Mock Loading @@ -119,6 +123,9 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest { @Mock private StatusBarPipelineFlags mStatusBarPipelineFlags; private final MutableStateFlow<Boolean> mIsVisibleFlow = FlowProviderKt.getMutableStateFlow(true); private FakeSlotIndexResolver mSlotIndexResolver; private ClickListenerTextView mNoCarrierTextView; Loading Loading @@ -181,6 +188,7 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest { when(mStatusBarPipelineFlags.useNewShadeCarrierGroupMobileIcons()).thenReturn(true); when(mMobileContextProvider.getMobileContextForSub(anyInt(), any())).thenReturn(mContext); when(mMobileIconsViewModel.getLogger()).thenReturn(mMobileViewLogger); when(mShadeCarrierGroupMobileIconViewModel.isVisible()).thenReturn(mIsVisibleFlow); when(mMobileIconsViewModel.viewModelForSub(anyInt(), any())) .thenReturn(mShadeCarrierGroupMobileIconViewModel); } Loading packages/SystemUI/tests/src/com/android/systemui/util/kotlin/FlowProvider.kt 0 → 100644 +22 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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.util.kotlin import kotlinx.coroutines.flow.MutableStateFlow /** Wrapper for flow constructors that can be retrieved from java tests */ fun <T> getMutableStateFlow(value: T): MutableStateFlow<T> = MutableStateFlow(value) Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileIconBinder.kt +98 −83 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.widget.ImageView import android.widget.Space import androidx.core.view.isVisible import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle import com.android.settingslib.graph.SignalDrawable import com.android.systemui.R Loading Loading @@ -64,7 +65,7 @@ object MobileIconBinder { val roamingSpace = view.requireViewById<Space>(R.id.mobile_roaming_space) val dotView = view.requireViewById<StatusBarIconView>(R.id.status_bar_dot) view.isVisible = true view.isVisible = viewModel.isVisible.value iconView.isVisible = true // TODO(b/238425913): We should log this visibility state. Loading @@ -77,6 +78,28 @@ object MobileIconBinder { var isCollecting = false view.repeatWhenAttached { lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.CREATED) { // isVisible controls the visibility state of the outer group, and thus it needs // to run in the CREATED lifecycle so it can continue to watch while invisible // See (b/291031862) for details launch { viewModel.isVisible.collect { isVisible -> viewModel.verboseLogger?.logBinderReceivedVisibility( view, viewModel.subscriptionId, isVisible ) view.isVisible = isVisible // [StatusIconContainer] can get out of sync sometimes. Make sure to // request another layout when this changes. view.requestLayout() } } } } lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { logger.logCollectionStarted(view, viewModel) isCollecting = true Loading @@ -100,17 +123,6 @@ object MobileIconBinder { } } launch { viewModel.isVisible.collect { isVisible -> viewModel.verboseLogger?.logBinderReceivedVisibility( view, viewModel.subscriptionId, isVisible ) view.isVisible = isVisible } } // Set the icon for the triangle launch { viewModel.icon.distinctUntilChanged().collect { icon -> Loading Loading @@ -156,7 +168,9 @@ object MobileIconBinder { launch { viewModel.activityOutVisible.collect { activityOut.isVisible = it } } launch { viewModel.activityContainerVisible.collect { activityContainer.isVisible = it } viewModel.activityContainerVisible.collect { activityContainer.isVisible = it } } // Set the tint Loading @@ -182,6 +196,7 @@ object MobileIconBinder { } } } } return object : ModernStatusBarViewBinding { override fun getShouldIconBeVisible(): Boolean { Loading
packages/SystemUI/tests/src/com/android/systemui/shade/carrier/ShadeCarrierGroupControllerTest.java +10 −2 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import com.android.systemui.statusbar.pipeline.mobile.ui.MobileViewLogger; import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.MobileIconsViewModel; import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.ShadeCarrierGroupMobileIconViewModel; import com.android.systemui.util.CarrierConfigTracker; import com.android.systemui.util.kotlin.FlowProviderKt; import com.android.systemui.utils.leaks.LeakCheckedTest; import com.android.systemui.utils.os.FakeHandler; Loading @@ -72,6 +73,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import kotlinx.coroutines.flow.MutableStateFlow; @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper @SmallTest Loading Loading @@ -105,7 +108,8 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest { private ShadeCarrier mShadeCarrier3; private TestableLooper mTestableLooper; @Mock private ShadeCarrierGroupController.OnSingleCarrierChangedListener mOnSingleCarrierChangedListener; private ShadeCarrierGroupController.OnSingleCarrierChangedListener mOnSingleCarrierChangedListener; @Mock private MobileUiAdapter mMobileUiAdapter; @Mock Loading @@ -119,6 +123,9 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest { @Mock private StatusBarPipelineFlags mStatusBarPipelineFlags; private final MutableStateFlow<Boolean> mIsVisibleFlow = FlowProviderKt.getMutableStateFlow(true); private FakeSlotIndexResolver mSlotIndexResolver; private ClickListenerTextView mNoCarrierTextView; Loading Loading @@ -181,6 +188,7 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest { when(mStatusBarPipelineFlags.useNewShadeCarrierGroupMobileIcons()).thenReturn(true); when(mMobileContextProvider.getMobileContextForSub(anyInt(), any())).thenReturn(mContext); when(mMobileIconsViewModel.getLogger()).thenReturn(mMobileViewLogger); when(mShadeCarrierGroupMobileIconViewModel.isVisible()).thenReturn(mIsVisibleFlow); when(mMobileIconsViewModel.viewModelForSub(anyInt(), any())) .thenReturn(mShadeCarrierGroupMobileIconViewModel); } Loading
packages/SystemUI/tests/src/com/android/systemui/util/kotlin/FlowProvider.kt 0 → 100644 +22 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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.util.kotlin import kotlinx.coroutines.flow.MutableStateFlow /** Wrapper for flow constructors that can be retrieved from java tests */ fun <T> getMutableStateFlow(value: T): MutableStateFlow<T> = MutableStateFlow(value)