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

Commit 6bce5f2a authored by Thomas Nguyen's avatar Thomas Nguyen
Browse files

Add TelephonyCountryDetector class

Bug: 313773568
Test: SMS, MMS, call with live network.
atest TelephonyCountryDetectorTest LocaleTrackerTest ServiceStateTrackerTest

Change-Id: Ieabdd2dd0185175e9f1e1b6e97d4453c5e2881bc
parent a5281200
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@ import android.util.LocalLog;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.MccTable.MccMnc;
import com.android.internal.telephony.MccTable.MccMnc;
import com.android.internal.telephony.flags.FeatureFlags;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.IndentingPrintWriter;
import com.android.telephony.Rlog;
import com.android.telephony.Rlog;
@@ -154,6 +155,8 @@ public class LocaleTracker extends Handler {
    @Nullable
    @Nullable
    private String mCurrentCountryIso;
    private String mCurrentCountryIso;


    @NonNull private final FeatureFlags mFeatureFlags;

    /** The country override for testing purposes */
    /** The country override for testing purposes */
    @Nullable
    @Nullable
    private String mCountryOverride;
    private String mCountryOverride;
@@ -244,12 +247,14 @@ public class LocaleTracker extends Handler {
     * @param nitzStateMachine NITZ state machine
     * @param nitzStateMachine NITZ state machine
     * @param looper The looper message handler
     * @param looper The looper message handler
     */
     */
    public LocaleTracker(Phone phone, NitzStateMachine nitzStateMachine, Looper looper)  {
    public LocaleTracker(Phone phone, NitzStateMachine nitzStateMachine, Looper looper,
            FeatureFlags featureFlags)  {
        super(looper);
        super(looper);
        mPhone = phone;
        mPhone = phone;
        mNitzStateMachine = nitzStateMachine;
        mNitzStateMachine = nitzStateMachine;
        mSimState = TelephonyManager.SIM_STATE_UNKNOWN;
        mSimState = TelephonyManager.SIM_STATE_UNKNOWN;
        mTag = LocaleTracker.class.getSimpleName() + "-" + mPhone.getPhoneId();
        mTag = LocaleTracker.class.getSimpleName() + "-" + mPhone.getPhoneId();
        mFeatureFlags = featureFlags;


        final IntentFilter filter = new IntentFilter();
        final IntentFilter filter = new IntentFilter();
        filter.addAction(TelephonyManager.ACTION_SIM_CARD_STATE_CHANGED);
        filter.addAction(TelephonyManager.ACTION_SIM_CARD_STATE_CHANGED);
@@ -560,6 +565,10 @@ public class LocaleTracker extends Handler {
                TelephonyProperties.operator_iso_country(newProp);
                TelephonyProperties.operator_iso_country(newProp);
            }
            }


            if (mFeatureFlags.oemEnabledSatelliteFlag()) {
                TelephonyCountryDetector.getInstance(mPhone.getContext())
                        .onNetworkCountryCodeChanged(mPhone, countryIso);
            }
            Intent intent = new Intent(TelephonyManager.ACTION_NETWORK_COUNTRY_CHANGED);
            Intent intent = new Intent(TelephonyManager.ACTION_NETWORK_COUNTRY_CHANGED);
            intent.putExtra(TelephonyManager.EXTRA_NETWORK_COUNTRY, countryIso);
            intent.putExtra(TelephonyManager.EXTRA_NETWORK_COUNTRY, countryIso);
            intent.putExtra(TelephonyManager.EXTRA_LAST_KNOWN_NETWORK_COUNTRY,
            intent.putExtra(TelephonyManager.EXTRA_LAST_KNOWN_NETWORK_COUNTRY,
+1 −1
Original line number Original line Diff line number Diff line
@@ -681,7 +681,7 @@ public class ServiceStateTracker extends Handler {
        }
        }
        mLocaleTracker = TelephonyComponentFactory.getInstance()
        mLocaleTracker = TelephonyComponentFactory.getInstance()
                .inject(LocaleTracker.class.getName())
                .inject(LocaleTracker.class.getName())
                .makeLocaleTracker(mPhone, mNitzState, getLooper());
                .makeLocaleTracker(mPhone, mNitzState, getLooper(), featureFlags);


        mCi.registerForImsNetworkStateChanged(this, EVENT_IMS_STATE_CHANGED, null);
        mCi.registerForImsNetworkStateChanged(this, EVENT_IMS_STATE_CHANGED, null);
        mCi.registerForRadioStateChanged(this, EVENT_RADIO_STATE_CHANGED, null);
        mCi.registerForRadioStateChanged(this, EVENT_RADIO_STATE_CHANGED, null);
+2 −2
Original line number Original line Diff line number Diff line
@@ -469,8 +469,8 @@ public class TelephonyComponentFactory {
    }
    }


    public LocaleTracker makeLocaleTracker(Phone phone, NitzStateMachine nitzStateMachine,
    public LocaleTracker makeLocaleTracker(Phone phone, NitzStateMachine nitzStateMachine,
                                           Looper looper) {
                                           Looper looper, @NonNull FeatureFlags featureFlags) {
        return new LocaleTracker(phone, nitzStateMachine, looper);
        return new LocaleTracker(phone, nitzStateMachine, looper, featureFlags);
    }
    }


    public Phone makePhone(Context context, CommandsInterface ci, PhoneNotifier notifier,
    public Phone makePhone(Context context, CommandsInterface ci, PhoneNotifier notifier,
Loading