Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ac92463 authored by Evan Laird's avatar Evan Laird
Browse files

Create a MobileStatusTrackerFactory

Enables injecting the MobileStatusTracker via a factory class.

Test: atest SystemUITests
Bug: 238425913
Change-Id: I38f76a746631dcfb2459dcc82c7fdebc9b5d2c09
parent 615f42de
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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);
    }

+7 −0
Original line number Diff line number Diff line
@@ -43,6 +43,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,
@@ -54,6 +60,7 @@ internal class MobileSignalControllerFactory @Inject constructor(
            subscriptionDefaults,
            receiverLooper,
            carrierConfigTracker,
            mobileTrackerFactory,
            featureFlags,
        )
    }
+42 −0
Original line number Diff line number Diff line
/*
 * 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)
    }
}