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.data.repository 18 19 import android.telephony.CarrierConfigManager 20 import android.telephony.SubscriptionManager 21 import com.android.settingslib.SignalIcon.MobileIconGroup 22 import com.android.settingslib.mobile.MobileMappings 23 import com.android.settingslib.mobile.MobileMappings.Config 24 import com.android.systemui.statusbar.pipeline.mobile.data.model.MobileConnectivityModel 25 import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionModel 26 import kotlinx.coroutines.flow.Flow 27 import kotlinx.coroutines.flow.StateFlow 28 29 /** 30 * Repo for monitoring the complete active subscription info list, to be consumed and filtered based 31 * on various policy 32 */ 33 interface MobileConnectionsRepository { 34 /** Observable list of current mobile subscriptions */ 35 val subscriptions: StateFlow<List<SubscriptionModel>> 36 37 /** 38 * Observable for the subscriptionId of the current mobile data connection. Null if we don't 39 * have a valid subscription id 40 */ 41 val activeMobileDataSubscriptionId: StateFlow<Int?> 42 43 /** Repo that tracks the current [activeMobileDataSubscriptionId] */ 44 val activeMobileDataRepository: StateFlow<MobileConnectionRepository?> 45 46 /** 47 * Observable event for when the active data sim switches but the group stays the same. E.g., 48 * CBRS switching would trigger this 49 */ 50 val activeSubChangedInGroupEvent: Flow<Unit> 51 52 /** Tracks [SubscriptionManager.getDefaultDataSubscriptionId] */ 53 val defaultDataSubId: StateFlow<Int> 54 55 /** The current connectivity status for the default mobile network connection */ 56 val defaultMobileNetworkConnectivity: StateFlow<MobileConnectivityModel> 57 58 /** Get or create a repository for the line of service for the given subscription ID */ getRepoForSubIdnull59 fun getRepoForSubId(subId: Int): MobileConnectionRepository 60 61 /** 62 * [Config] is an object that tracks relevant configuration flags for a given subscription ID. 63 * In the case of [MobileMappings], it's hard-coded to check the default data subscription's 64 * config, so this will apply to every icon that we care about. 65 * 66 * Relevant bits in the config are things like 67 * [CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL] 68 * 69 * This flow will produce whenever the default data subscription or the carrier config changes. 70 */ 71 val defaultDataSubRatConfig: StateFlow<Config> 72 73 /** The icon mapping from network type to [MobileIconGroup] for the default subscription */ 74 val defaultMobileIconMapping: Flow<Map<String, MobileIconGroup>> 75 76 /** Fallback [MobileIconGroup] in the case where there is no icon in the mapping */ 77 val defaultMobileIconGroup: Flow<MobileIconGroup> 78 } 79