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

Commit f1e23163 authored by Hyosun Kim's avatar Hyosun Kim
Browse files

If the country of the plmn connected to the satellite does not match the...

If the country of the plmn connected to the satellite does not match the country of the sim card plmn,  then update the is_ntn_roaming_in_home_country to true.
If the country of the plmn connected to the satellite match the country of the sim card plmn,  then update the is_ntn_roaming_in_home_country to false.

Bug: 339111754
Test: atest SatelliteControllerTest
Test: manual test b/339111754#comment37

Change-Id: Iafd4aebdd8cb0045ce0e815dac540948eb41731c
parent 24b82d67
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4195,7 +4195,7 @@ public class SatelliteController extends Handler {
                        sessionStats.onSignalStrength(phone);
                        if (!mWasSatelliteConnectedViaCarrier.get(subId)) {
                            // Log satellite connection start
                            sessionStats.onConnectionStart();
                            sessionStats.onConnectionStart(phone);
                        }
                    }

@@ -4266,7 +4266,7 @@ public class SatelliteController extends Handler {
                // Log satellite session start
                CarrierRoamingSatelliteSessionStats sessionStats =
                        CarrierRoamingSatelliteSessionStats.getInstance(subId);
                sessionStats.onSessionStart(phone.getCarrierId());
                sessionStats.onSessionStart(phone.getCarrierId(), phone);
                mCarrierRoamingSatelliteSessionStatsMap.put(subId, sessionStats);
            } else if (lastNotifiedNtnMode && !currNtnMode) {
                // Log satellite session end
+48 −3
Original line number Diff line number Diff line
@@ -20,13 +20,18 @@ import android.annotation.NonNull;
import android.telephony.CellInfo;
import android.telephony.CellSignalStrength;
import android.telephony.CellSignalStrengthLte;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.util.SparseArray;

import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.metrics.SatelliteStats;
import com.android.internal.telephony.subscription.SubscriptionInfoInternal;
import com.android.internal.telephony.subscription.SubscriptionManagerService;

import java.util.ArrayList;
import java.util.Collections;
@@ -36,6 +41,7 @@ public class CarrierRoamingSatelliteSessionStats {
    private static final String TAG = CarrierRoamingSatelliteSessionStats.class.getSimpleName();
    private static final SparseArray<CarrierRoamingSatelliteSessionStats>
            sCarrierRoamingSatelliteSessionStats = new SparseArray<>();
    @NonNull private final SubscriptionManagerService mSubscriptionManagerService;
    private int mCarrierId;
    private boolean mIsNtnRoamingInHomeCountry;
    private int mCountOfIncomingSms;
@@ -53,6 +59,7 @@ public class CarrierRoamingSatelliteSessionStats {
    public CarrierRoamingSatelliteSessionStats(int subId) {
        logd("Create new CarrierRoamingSatelliteSessionStats. subId=" + subId);
        initializeParams();
        mSubscriptionManagerService = SubscriptionManagerService.getInstance();
    }

    /** Gets a CarrierRoamingSatelliteSessionStats instance. */
@@ -67,21 +74,24 @@ public class CarrierRoamingSatelliteSessionStats {
    }

    /** Log carrier roaming satellite session start */
    public void onSessionStart(int carrierId) {
    public void onSessionStart(int carrierId, Phone phone) {
        mCarrierId = carrierId;
        mSessionStartTimeSec = getCurrentTimeInSec();
        onConnectionStart();
        mIsNtnRoamingInHomeCountry = false;
        onConnectionStart(phone);
    }

    /** Log carrier roaming satellite connection start */
    public void onConnectionStart() {
    public void onConnectionStart(Phone phone) {
        mConnectionStartTimeList.add(getCurrentTime());
        updateNtnRoamingInHomeCountry(phone);
    }

    /** Log carrier roaming satellite session end */
    public void onSessionEnd() {
        onConnectionEnd();
        reportMetrics();
        mIsNtnRoamingInHomeCountry = false;
    }

    /** Log carrier roaming satellite connection end */
@@ -292,6 +302,41 @@ public class CarrierRoamingSatelliteSessionStats {
        return mSessionStartTimeSec != 0;
    }

    private void updateNtnRoamingInHomeCountry(Phone phone) {
        int subId = phone.getSubId();
        ServiceState serviceState = phone.getServiceState();
        if (serviceState == null) {
            logd("ServiceState is null");
            return;
        }

        String satelliteRegisteredPlmn = "";
        for (NetworkRegistrationInfo nri
                : serviceState.getNetworkRegistrationInfoList()) {
            if (nri.isNonTerrestrialNetwork()) {
                satelliteRegisteredPlmn = nri.getRegisteredPlmn();
            }
        }

        SubscriptionInfoInternal subscriptionInfoInternal =
                mSubscriptionManagerService.getSubscriptionInfoInternal(subId);
        if (subscriptionInfoInternal == null) {
            logd("SubscriptionInfoInternal is null");
            return;
        }
        String simCountry = MccTable.countryCodeForMcc(subscriptionInfoInternal.getMcc());
        String satelliteRegisteredCountry = MccTable.countryCodeForMcc(
                satelliteRegisteredPlmn.substring(0, 3));
        if (simCountry.equalsIgnoreCase(satelliteRegisteredCountry)) {
            mIsNtnRoamingInHomeCountry = false;
        } else {
            // If device is connected to roaming non-terrestrial network, update to true.
            mIsNtnRoamingInHomeCountry = true;
        }
        logd("updateNtnRoamingInHomeCountry: mIsNtnRoamingInHomeCountry="
                + mIsNtnRoamingInHomeCountry);
    }

    private void logd(@NonNull String log) {
        Log.d(TAG, log);
    }