Revert^2 "Create a MobileStatusTrackerFactory"

Enables injecting the MobileStatusTracker via a factory class.

Test: atest SystemUITests
Bug: 238425913

d611126474130e657ab8f70e91c861a40b80f86c

Change-Id: Iafd9bfcd7e8346350e1a861920957bb600c15a4e
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileSignalController.java
index 9d8667a..f3dedc4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileSignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileSignalController.java
@@ -96,7 +96,7 @@
     private int mLastWlanLevel;
     private int mLastWlanCrossSimLevel;
     @VisibleForTesting
-    MobileStatusTracker mMobileStatusTracker;
+    final MobileStatusTracker mMobileStatusTracker;
 
     // Save the previous STATUS_HISTORY_SIZE states for logging.
     private final String[] mMobileStatusHistory = new String[STATUS_HISTORY_SIZE];
@@ -192,6 +192,7 @@
             SubscriptionDefaults defaults,
             Looper receiverLooper,
             CarrierConfigTracker carrierConfigTracker,
+            MobileStatusTrackerFactory mobileStatusTrackerFactory,
             FeatureFlags featureFlags
     ) {
         super("MobileSignalController(" + info.getSubscriptionId() + ")", context,
@@ -224,8 +225,7 @@
             }
         };
         mImsMmTelManager = ImsMmTelManager.createForSubscriptionId(info.getSubscriptionId());
-        mMobileStatusTracker = new MobileStatusTracker(mPhone, receiverLooper,
-                info, mDefaults, mMobileCallback);
+        mMobileStatusTracker = mobileStatusTrackerFactory.createTracker(mMobileCallback);
         mProviderModelBehavior = featureFlags.isEnabled(Flags.COMBINED_STATUS_BAR_SIGNAL_ICONS);
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileSignalControllerFactory.kt b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileSignalControllerFactory.kt
index 3615521..5033a78 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileSignalControllerFactory.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileSignalControllerFactory.kt
@@ -45,6 +45,12 @@
         subscriptionDefaults: MobileStatusTracker.SubscriptionDefaults,
         receiverLooper: Looper // TODO: no!
     ): MobileSignalController {
+        val mobileTrackerFactory = MobileStatusTrackerFactory(
+            phone,
+            receiverLooper,
+            subscriptionInfo,
+            subscriptionDefaults)
+
         return MobileSignalController(
             context,
             config,
@@ -56,6 +62,7 @@
             subscriptionDefaults,
             receiverLooper,
             carrierConfigTracker,
+            mobileTrackerFactory,
             featureFlags,
         )
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileStatusTrackerFactory.kt b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileStatusTrackerFactory.kt
new file mode 100644
index 0000000..a4c1a198
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileStatusTrackerFactory.kt
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.systemui.statusbar.connectivity
+
+import android.os.Looper
+import android.telephony.SubscriptionInfo
+import android.telephony.TelephonyManager
+import com.android.settingslib.mobile.MobileStatusTracker
+
+/**
+ * Factory for [MobileStatusTracker], which lives in SettingsLib
+ */
+class MobileStatusTrackerFactory (
+    val phone: TelephonyManager,
+    val receiverLooper: Looper,
+    val info: SubscriptionInfo,
+    val defaults: MobileStatusTracker.SubscriptionDefaults,
+) {
+    fun createTracker(
+        callback: MobileStatusTracker.Callback
+    ): MobileStatusTracker {
+        return MobileStatusTracker(
+            phone,
+            receiverLooper,
+            info,
+            defaults,
+            callback)
+    }
+}