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.TelephonyDisplayInfo
20 import com.android.settingslib.SignalIcon.MobileIconGroup
21 import com.android.settingslib.mobile.MobileMappings.Config
22 import com.android.settingslib.mobile.TelephonyIcons
23 
24 class FakeMobileMappingsProxy : MobileMappingsProxy {
25     // The old [NetworkControllerDataTest] infra requires us to be able to use the real
26     // impl sometimes
27     var useRealImpl = false
28 
29     private var realImpl = MobileMappingsProxyImpl()
30     private var iconMap = mapOf<String, MobileIconGroup>()
31     private var defaultIcons = TelephonyIcons.THREE_G
32 
setIconMapnull33     fun setIconMap(map: Map<String, MobileIconGroup>) {
34         iconMap = map
35     }
mapIconSetsnull36     override fun mapIconSets(config: Config): Map<String, MobileIconGroup> {
37         if (useRealImpl) {
38             return realImpl.mapIconSets(config)
39         }
40         return iconMap
41     }
getIconMapnull42     fun getIconMap() = iconMap
43 
44     fun setDefaultIcons(group: MobileIconGroup) {
45         defaultIcons = group
46     }
getDefaultIconsnull47     override fun getDefaultIcons(config: Config): MobileIconGroup {
48         if (useRealImpl) {
49             return realImpl.getDefaultIcons(config)
50         }
51         return defaultIcons
52     }
53 
54     /** This is only used in the old pipeline, use the real impl always */
getIconKeynull55     override fun getIconKey(displayInfo: TelephonyDisplayInfo): String {
56         return realImpl.getIconKey(displayInfo)
57     }
58 
getDefaultIconsnull59     fun getDefaultIcons(): MobileIconGroup = defaultIcons
60 
61     override fun toIconKey(networkType: Int): String {
62         if (useRealImpl) {
63             return realImpl.toIconKeyOverride(networkType)
64         }
65         return networkType.toString()
66     }
67 
toIconKeyOverridenull68     override fun toIconKeyOverride(networkType: Int): String {
69         if (useRealImpl) {
70             return realImpl.toIconKeyOverride(networkType)
71         }
72         return toIconKey(networkType) + "_override"
73     }
74 }
75