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.SubscriptionModel 25 import kotlinx.coroutines.flow.Flow 26 import kotlinx.coroutines.flow.StateFlow 27 28 /** 29 * Repo for monitoring the complete active subscription info list, to be consumed and filtered based 30 * on various policy 31 */ 32 interface MobileConnectionsRepository { 33 /** Observable list of current mobile subscriptions */ 34 val subscriptions: StateFlow<List<SubscriptionModel>> 35 36 /** 37 * Observable for the subscriptionId of the current mobile data connection. Null if we don't 38 * have a valid subscription id 39 */ 40 val activeMobileDataSubscriptionId: StateFlow<Int?> 41 42 /** Repo that tracks the current [activeMobileDataSubscriptionId] */ 43 val activeMobileDataRepository: StateFlow<MobileConnectionRepository?> 44 45 /** 46 * Observable event for when the active data sim switches but the group stays the same. E.g., 47 * CBRS switching would trigger this 48 */ 49 val activeSubChangedInGroupEvent: Flow<Unit> 50 51 /** Tracks [SubscriptionManager.getDefaultDataSubscriptionId] */ 52 val defaultDataSubId: StateFlow<Int> 53 54 /** 55 * True if the default network connection is a mobile-like connection and false otherwise. 56 * 57 * This is typically shown by having [android.net.NetworkCapabilities.TRANSPORT_CELLULAR], but 58 * there are edge cases (like carrier merged wifi) that could also result in the default 59 * connection being mobile-like. 60 */ 61 val mobileIsDefault: StateFlow<Boolean> 62 63 /** 64 * True if the device currently has a carrier merged connection. 65 * 66 * See [CarrierMergedConnectionRepository] for more info. 67 */ 68 val hasCarrierMergedConnection: Flow<Boolean> 69 70 /** True if the default network connection is validated and false otherwise. */ 71 val defaultConnectionIsValidated: StateFlow<Boolean> 72 73 /** Get or create a repository for the line of service for the given subscription ID */ 74 fun getRepoForSubId(subId: Int): MobileConnectionRepository 75 76 /** 77 * [Config] is an object that tracks relevant configuration flags for a given subscription ID. 78 * In the case of [MobileMappings], it's hard-coded to check the default data subscription's 79 * config, so this will apply to every icon that we care about. 80 * 81 * Relevant bits in the config are things like 82 * [CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL] 83 * 84 * This flow will produce whenever the default data subscription or the carrier config changes. 85 */ 86 val defaultDataSubRatConfig: StateFlow<Config> 87 88 /** The icon mapping from network type to [MobileIconGroup] for the default subscription */ 89 val defaultMobileIconMapping: Flow<Map<String, MobileIconGroup>> 90 91 /** Fallback [MobileIconGroup] in the case where there is no icon in the mapping */ 92 val defaultMobileIconGroup: Flow<MobileIconGroup> 93 } 94