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.util 18 19 import android.telephony.Annotation.NetworkType 20 import android.telephony.TelephonyDisplayInfo 21 import com.android.settingslib.SignalIcon.MobileIconGroup 22 import com.android.settingslib.mobile.MobileMappings 23 import com.android.settingslib.mobile.MobileMappings.Config 24 import javax.inject.Inject 25 26 /** 27 * [MobileMappings] owns the logic on creating the map from [TelephonyDisplayInfo] to 28 * [MobileIconGroup]. It creates that hash map and also manages the creation of lookup keys. This 29 * interface allows us to proxy those calls to the static java methods in SettingsLib and also fake 30 * them out in tests 31 */ 32 interface MobileMappingsProxy { mapIconSetsnull33 fun mapIconSets(config: Config): Map<String, MobileIconGroup> 34 fun getDefaultIcons(config: Config): MobileIconGroup 35 fun getIconKey(displayInfo: TelephonyDisplayInfo): String 36 fun toIconKey(@NetworkType networkType: Int): String 37 fun toIconKeyOverride(@NetworkType networkType: Int): String 38 } 39 40 /** Injectable wrapper class for [MobileMappings] */ 41 class MobileMappingsProxyImpl @Inject constructor() : MobileMappingsProxy { 42 override fun mapIconSets(config: Config): Map<String, MobileIconGroup> = 43 MobileMappings.mapIconSets(config) 44 45 override fun getDefaultIcons(config: Config): MobileIconGroup = 46 MobileMappings.getDefaultIcons(config) 47 48 override fun getIconKey(displayInfo: TelephonyDisplayInfo): String = 49 MobileMappings.getIconKey(displayInfo) 50 51 override fun toIconKey(@NetworkType networkType: Int): String = 52 MobileMappings.toIconKey(networkType) 53 54 override fun toIconKeyOverride(networkType: Int): String = 55 MobileMappings.toDisplayIconKey(networkType) 56 } 57