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

Commit 9d2841f4 authored by Thomas Nguyen's avatar Thomas Nguyen
Browse files

Prioritize carrier config over device config for satellite supported services

Bug: 287504843
Test: SMS, MMS, call with live network.
atest com.android.internal.telephony.ServiceStateTrackerTest
atest com.android.internal.telephony.satellite.NTNCapabilityResolverTest
atest com.android.internal.telephony.satellite.SatelliteControllerTest
atest com.android.internal.telephony.satellite.SatelliteSOSMessageRecommenderTest
atest android.telephony.cts.CarrierConfigManagerTest

Change-Id: Ifc78610b2680aaa3f5593af1813bf97916c748b0
parent 59469e84
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public class NtnCapabilityResolver {
    public static void resolveNtnCapability(
            @NonNull NetworkRegistrationInfo networkRegistrationInfo, int subId) {
        SatelliteController satelliteController = SatelliteController.getInstance();
        List<String> satellitePlmnList = satelliteController.getSatellitePlmnList();
        List<String> satellitePlmnList = satelliteController.getSatellitePlmnList(subId);
        String registeredPlmn = networkRegistrationInfo.getRegisteredPlmn();
        for (String satellitePlmn : satellitePlmnList) {
            if (TextUtils.equals(satellitePlmn, registeredPlmn)) {
+19 −20
Original line number Diff line number Diff line
@@ -227,7 +227,6 @@ public class SatelliteController extends Handler {
    @NonNull private final Object mCarrierConfigArrayLock = new Object();
    @GuardedBy("mCarrierConfigArrayLock")
    @NonNull private final SparseArray<PersistableBundle> mCarrierConfigArray = new SparseArray<>();
    @NonNull private final List<String> mSatellitePlmnList;

    /**
     * @return The singleton instance of SatelliteController.
@@ -319,8 +318,6 @@ public class SatelliteController extends Handler {
        }

        mSatelliteServicesSupportedByProviders = readSupportedSatelliteServicesFromOverlayConfig();
        mSatellitePlmnList =
                mSatelliteServicesSupportedByProviders.keySet().stream().toList();
        updateSupportedSatelliteServicesForActiveSubscriptions();
        mCarrierConfigChangeListener =
                (slotIndex, subId, carrierId, specificCarrierId) ->
@@ -1947,11 +1944,18 @@ public class SatelliteController extends Handler {
    }

    /**
     * @param subId Subscription ID.
     * @return The list of satellite PLMNs used for connecting to satellite networks.
     */
    @NonNull
    public List<String> getSatellitePlmnList() {
        return new ArrayList<>(mSatellitePlmnList);
    public List<String> getSatellitePlmnList(int subId) {
        synchronized (mSupportedSatelliteServicesLock) {
            if (mSupportedSatelliteServices.containsKey(subId)) {
                return new ArrayList<>(mSupportedSatelliteServices.get(subId).keySet());
            } else {
                return new ArrayList<>();
            }
        }
    }

    /**
@@ -2393,23 +2397,17 @@ public class SatelliteController extends Handler {

    private void configureSatellitePlmn() {
        logd("configureSatellitePlmn()");
        if (mSatellitePlmnList != null && !mSatellitePlmnList.isEmpty()) {
            Message onCompleted = obtainMessage(
                    EVENT_SET_ROAMING_PLMN_INFO_DONE, mSatellitePlmnList);
        Phone[] phones = PhoneFactory.getPhones();
        for (Phone phone : phones) {
            if (phone != null) {
                    // TODO : This command should be sent to only phone/modem whose carrier
                    //        supports satellite - next task
                    phone.setSatellitePlmn(onCompleted, mSatellitePlmnList);
                List<String> satellitePlmns = getSatellitePlmnList(phone.getSubId());
                phone.setSatellitePlmn(
                        obtainMessage(EVENT_SET_ROAMING_PLMN_INFO_DONE), satellitePlmns);
                logd("phone[" + phone.getPhoneId() + "].setSatellitePlmn()");
            } else {
                loge("configureSatellitePlmn: No phone object");
            }
        }
        } else {
            logd("mSatellitePlmnList is empty");
        }
    }

    private void handleSetRoamingPlmnInfoDoneEvent(Message msg) {
@@ -2486,6 +2484,7 @@ public class SatelliteController extends Handler {

        updateCarrierConfig(subId);
        updateSupportedSatelliteServicesForActiveSubscriptions();
        configureSatellitePlmn();
    }

    private void updateCarrierConfig(int subId) {
+19 −10
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.internal.telephony.satellite;
import static android.telephony.NetworkRegistrationInfo.FIRST_SERVICE_TYPE;
import static android.telephony.NetworkRegistrationInfo.LAST_SERVICE_TYPE;

import static java.util.stream.Collectors.joining;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
@@ -316,6 +318,9 @@ public class SatelliteServiceUtils {
                        }
                    }
                }
                logd("parseSupportedSatelliteServices: plmn=" + plmn + ", supportedServicesSet="
                        + supportedServicesSet.stream().map(String::valueOf).collect(
                                joining(",")));
                supportedServicesMap.put(plmn, supportedServicesSet);
            } else {
                loge("parseSupportedSatelliteServices: invalid format input, "
@@ -353,17 +358,18 @@ public class SatelliteServiceUtils {
                            + " for plmn=" + plmn);
                }
            }
            logd("parseSupportedSatelliteServices: plmn=" + plmn + ", supportedServicesSet="
                    + supportedServicesSet.stream().map(String::valueOf).collect(
                            joining(",")));
            supportedServicesMap.put(plmn, supportedServicesSet);
        }
        return supportedServicesMap;
    }

    /**
     * For the PLMN that exists in both {@code providerSupportedServices} and
     * {@code carrierSupportedServices}, the supported services will be the intersection of the two
     * sets. For the PLMN that is present in {@code providerSupportedServices} but not in
     * {@code carrierSupportedServices}, the provider supported services will be used. The rest
     * will not be used.
     * For the PLMN that exists in {@code carrierSupportedServices}, the carrier supported services
     * will be used. For the PLMN that is present in {@code providerSupportedServices} but not in
     * {@code carrierSupportedServices}, the provider supported services will be used.
     *
     * @param providerSupportedServices Satellite provider supported satellite services.
     * @param carrierSupportedServices Carrier supported satellite services.
@@ -379,12 +385,15 @@ public class SatelliteServiceUtils {
                    carrierSupportedServices) {
        Map<String, Set<Integer>> supportedServicesMap = new HashMap<>();
        for (Map.Entry<String, Set<Integer>> entry : providerSupportedServices.entrySet()) {
            Set<Integer> supportedServices = new HashSet<>(entry.getValue());
            if (carrierSupportedServices.containsKey(entry.getKey())) {
                supportedServices.retainAll(carrierSupportedServices.get(entry.getKey()));
            if (!entry.getValue().isEmpty()) {
                supportedServicesMap.put(entry.getKey(), entry.getValue());
            }
        }
            if (!supportedServices.isEmpty()) {
                supportedServicesMap.put(entry.getKey(), supportedServices);
        for (Map.Entry<String, Set<Integer>> entry : carrierSupportedServices.entrySet()) {
            if (entry.getValue().isEmpty()) {
                supportedServicesMap.remove(entry.getKey());
            } else {
                supportedServicesMap.put(entry.getKey(), entry.getValue());
            }
        }
        return supportedServicesMap;
+2 −2
Original line number Diff line number Diff line
@@ -258,7 +258,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        mSatelliteController = Mockito.mock(SatelliteController.class);
        replaceInstance(SatelliteController.class, "sInstance", null,
                mSatelliteController);
        doReturn(new ArrayList<>()).when(mSatelliteController).getSatellitePlmnList();
        doReturn(new ArrayList<>()).when(mSatelliteController).getSatellitePlmnList(anyInt());

        mContextFixture.putResource(R.string.kg_text_message_separator, " \u2014 ");

@@ -3261,7 +3261,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        CellIdentityGsm cellIdentity =
                new CellIdentityGsm(0, 1, 900, 5, "101", "23", "test", "tst",
                        Collections.emptyList());
        doReturn(Arrays.asList("10123")).when(mSatelliteController).getSatellitePlmnList();
        doReturn(Arrays.asList("10123")).when(mSatelliteController).getSatellitePlmnList(anyInt());
        doReturn(satelliteSupportedServiceList).when(mSatelliteController)
                .getSupportedSatelliteServices(sst.mSubId, "10123");

+2 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;

import android.annotation.NonNull;
@@ -75,7 +76,7 @@ public class NtnCapabilityResolverTest extends TelephonyTest {
        replaceInstance(SatelliteController.class, "sInstance", null,
                mMockSatelliteController);
        doReturn(Arrays.asList(SATELLITE_PLMN_ARRAY))
                .when(mMockSatelliteController).getSatellitePlmnList();
                .when(mMockSatelliteController).getSatellitePlmnList(anyInt());
        doReturn(mSatelliteSupportedServiceList).when(mMockSatelliteController)
                .getSupportedSatelliteServices(SUB_ID, SATELLITE_PLMN);
    }
Loading