1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.statusbar.pipeline.mobile.ui.binder 18 19 import android.view.View 20 import androidx.lifecycle.Lifecycle 21 import androidx.lifecycle.repeatOnLifecycle 22 import com.android.systemui.lifecycle.repeatWhenAttached 23 import com.android.systemui.statusbar.phone.ui.IconManager 24 import com.android.systemui.statusbar.pipeline.mobile.ui.MobileUiAdapter 25 import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.MobileIconsViewModel 26 import kotlinx.coroutines.launch 27 28 object MobileIconsBinder { 29 /** 30 * Start this ViewModel collecting on the list of mobile subscriptions in the scope of [view] 31 * which is passed in and managed by [IconManager]. Once the subscription list flow starts 32 * collecting, [MobileUiAdapter] will send updates to the icon manager. 33 */ 34 @JvmStatic bindnull35 fun bind(view: View, viewModel: MobileIconsViewModel) { 36 view.repeatWhenAttached { 37 repeatOnLifecycle(Lifecycle.State.STARTED) { 38 launch { 39 viewModel.subscriptionIdsFlow.collect { 40 // TODO(b/249790733): This is an empty collect, because [MobileUiAdapter] 41 // sets up a side-effect in this flow to trigger the methods on 42 // [StatusBarIconController] which allows for this pipeline to be a data 43 // source for the mobile icons. 44 } 45 } 46 } 47 } 48 } 49 } 50