Revert^2 "Create a MobileStatusTrackerFactory"

Enables injecting the MobileStatusTracker via a factory class.

Test: atest SystemUITests
Bug: 238425913

d611126474

Change-Id: Iafd9bfcd7e8346350e1a861920957bb600c15a4e
This commit is contained in:
Evan Laird
2022-07-29 03:33:00 +00:00
parent 080af92a91
commit 14b52cb783
3 changed files with 52 additions and 3 deletions

View File

@@ -96,7 +96,7 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
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 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
SubscriptionDefaults defaults,
Looper receiverLooper,
CarrierConfigTracker carrierConfigTracker,
MobileStatusTrackerFactory mobileStatusTrackerFactory,
FeatureFlags featureFlags
) {
super("MobileSignalController(" + info.getSubscriptionId() + ")", context,
@@ -224,8 +225,7 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
}
};
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);
}

View File

@@ -45,6 +45,12 @@ internal class MobileSignalControllerFactory @Inject constructor(
subscriptionDefaults: MobileStatusTracker.SubscriptionDefaults,
receiverLooper: Looper // TODO: no!
): MobileSignalController {
val mobileTrackerFactory = MobileStatusTrackerFactory(
phone,
receiverLooper,
subscriptionInfo,
subscriptionDefaults)
return MobileSignalController(
context,
config,
@@ -56,6 +62,7 @@ internal class MobileSignalControllerFactory @Inject constructor(
subscriptionDefaults,
receiverLooper,
carrierConfigTracker,
mobileTrackerFactory,
featureFlags,
)
}

View File

@@ -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)
}
}