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 package com.android.systemui.statusbar.connectivity
17 
18 import android.content.Context
19 import android.os.Looper
20 import android.telephony.SubscriptionInfo
21 import android.telephony.TelephonyManager
22 import com.android.settingslib.mobile.MobileMappings
23 import com.android.settingslib.mobile.MobileStatusTracker
24 import com.android.systemui.dagger.SysUISingleton
25 import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxy
26 import com.android.systemui.util.CarrierConfigTracker
27 import javax.inject.Inject
28 
29 /**
30  * Factory to make MobileSignalController injectable
31  */
32 @SysUISingleton
33 internal class MobileSignalControllerFactory @Inject constructor(
34     val context: Context,
35     val callbackHandler: CallbackHandler,
36     val carrierConfigTracker: CarrierConfigTracker,
37     val mobileMappings: MobileMappingsProxy,
38 ) {
createMobileSignalControllernull39     fun createMobileSignalController(
40         config: MobileMappings.Config,
41         hasMobileData: Boolean,
42         phone: TelephonyManager,
43         networkController: NetworkControllerImpl,
44         subscriptionInfo: SubscriptionInfo,
45         subscriptionDefaults: MobileStatusTracker.SubscriptionDefaults,
46         receiverLooper: Looper,
47     ): MobileSignalController {
48         val mobileTrackerFactory = MobileStatusTrackerFactory(
49             phone,
50             receiverLooper,
51             subscriptionInfo,
52             subscriptionDefaults)
53 
54         return MobileSignalController(
55             context,
56             config,
57             hasMobileData,
58             phone,
59             callbackHandler,
60             networkController,
61             mobileMappings,
62             subscriptionInfo,
63             subscriptionDefaults,
64             receiverLooper,
65             carrierConfigTracker,
66             mobileTrackerFactory,
67         )
68     }
69 }
70