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

Commit 33721b16 authored by Hakjun Choi's avatar Hakjun Choi
Browse files

Add default capabilities when allowed plmn is not listed in carrier config

In case the entitlement server provides PLMN list and they are not in the list of carrier config, capabilities for those PLMNs will be empty.
Therefore default capabilities in the key KEY_SATELLITE_DEFAULT_SERVICES_FOR_ENTITLEMENT_PLMNS_INT_ARRAY contains will be added as default capabilities for entitlement provided PLMNs.

Bug: 332811510
Test: atest SatelliteControllerTest
    manually test as below sequence
    1. connect SatelliteTestApp, SatelliteEntitlementTestServerApp
    2. check getAvailableServices from TestSatelliteWrapper in SatelliteTestApp
    2. override carrierconfig with PLMN of current SIM as in allowed list of entitlement server, with the test values.
    3. turn on and off APM
    4. check again getAvailabeService and verify test values are reflected.

Change-Id: Ia48d7d917218a59bab78eadc59726d8f08853941
parent 473f734d
Loading
Loading
Loading
Loading
+41 −22
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.provider.Settings.ACTION_SATELLITE_SETTING;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_SUPPORTED_SATELLITE_SERVICES_PER_PROVIDER_BUNDLE;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_CONNECTION_HYSTERESIS_SEC_INT;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_ROAMING_SATELLITE_DEFAULT_SERVICES_INT_ARRAY;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL;
import static android.telephony.SubscriptionManager.SATELLITE_ATTACH_ENABLED_FOR_CARRIER;
import static android.telephony.SubscriptionManager.SATELLITE_ENTITLEMENT_STATUS;
@@ -135,6 +136,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
import java.util.stream.Collectors;

/**
 * Satellite controller is the backend service of
@@ -2574,8 +2576,23 @@ public class SatelliteController extends Handler {
                loge("getSupportedSatelliteServices: mSatelliteServicesSupportedByCarriers does "
                        + "not contain key subId=" + subId);
            }

            /* Returns default capabilities when carrier config does not contain service
               capabilities for the given plmn */
            PersistableBundle config = getPersistableBundle(subId);
            int [] defaultCapabilities = config.getIntArray(
                    KEY_CARRIER_ROAMING_SATELLITE_DEFAULT_SERVICES_INT_ARRAY);
            if (defaultCapabilities == null) {
                logd("getSupportedSatelliteServices: defaultCapabilities is null");
                return new ArrayList<>();
            }
            List<Integer> capabilitiesList = Arrays.stream(
                    defaultCapabilities).boxed().collect(Collectors.toList());
            logd("getSupportedSatelliteServices: subId=" + subId
                    + ", supportedServices does not contain key plmn=" + plmn
                    + ", return default values " + capabilitiesList);
            return capabilitiesList;
        }
    }

    /**
@@ -3447,7 +3464,8 @@ public class SatelliteController extends Handler {
                }
            }

            if (mSatelliteServicesSupportedByCarriers.containsKey(subId)) {
            if (mSatelliteServicesSupportedByCarriers.containsKey(subId)
                    && mSatelliteServicesSupportedByCarriers.get(subId) != null) {
                carrierPlmnList =
                        mSatelliteServicesSupportedByCarriers.get(subId).keySet().stream().toList();
                logd("mMergedPlmnListPerCarrier is updated by carrier config");
@@ -3502,24 +3520,19 @@ public class SatelliteController extends Handler {

    @NonNull
    private Map<String, Set<Integer>> readSupportedSatelliteServicesFromCarrierConfig(int subId) {
        synchronized (mCarrierConfigArrayLock) {
            PersistableBundle config = mCarrierConfigArray.get(subId);
            if (config == null) {
                config = getConfigForSubId(subId);
                mCarrierConfigArray.put(subId, config);
            }
        PersistableBundle config = getPersistableBundle(subId);
        return SatelliteServiceUtils.parseSupportedSatelliteServices(
                config.getPersistableBundle(
                        KEY_CARRIER_SUPPORTED_SATELLITE_SERVICES_PER_PROVIDER_BUNDLE));
    }
    }

    @NonNull private PersistableBundle getConfigForSubId(int subId) {
        PersistableBundle config = mCarrierConfigManager.getConfigForSubId(subId,
                KEY_CARRIER_SUPPORTED_SATELLITE_SERVICES_PER_PROVIDER_BUNDLE,
                KEY_SATELLITE_ATTACH_SUPPORTED_BOOL,
                KEY_SATELLITE_CONNECTION_HYSTERESIS_SEC_INT,
                KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL);
                KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL,
                KEY_CARRIER_ROAMING_SATELLITE_DEFAULT_SERVICES_INT_ARRAY);
        if (config == null || config.isEmpty()) {
            config = CarrierConfigManager.getDefaultConfig();
        }
@@ -3952,16 +3965,10 @@ public class SatelliteController extends Handler {
    }

    private long getSatelliteConnectionHysteresisTimeMillis(int subId) {
        synchronized (mCarrierConfigArrayLock) {
            PersistableBundle config = mCarrierConfigArray.get(subId);
            if (config == null) {
                config = getConfigForSubId(subId);
                mCarrierConfigArray.put(subId, config);
            }
        PersistableBundle config = getPersistableBundle(subId);
        return (config.getInt(
                KEY_SATELLITE_CONNECTION_HYSTERESIS_SEC_INT) * 1000L);
    }
    }

    private void persistOemEnabledSatelliteProvisionStatus(boolean isProvisioned) {
        synchronized (mSatelliteViaOemProvisionLock) {
@@ -4302,6 +4309,18 @@ public class SatelliteController extends Handler {
                notificationBuilder.build(), UserHandle.ALL);
    }

    @NonNull
    private PersistableBundle getPersistableBundle(int subId) {
        synchronized (mCarrierConfigArrayLock) {
            PersistableBundle config = mCarrierConfigArray.get(subId);
            if (config == null) {
                config = getConfigForSubId(subId);
                mCarrierConfigArray.put(subId, config);
            }
            return config;
        }
    }

    private static void logd(@NonNull String log) {
        Rlog.d(TAG, log);
    }
+74 −4
Original line number Diff line number Diff line
@@ -1656,7 +1656,7 @@ public class SatelliteControllerTest extends TelephonyTest {
    }

    @Test
    public void testSupportedSatelliteServices() {
    public void testSupportedSatelliteServices() throws Exception {
        when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(false);
        List<String> satellitePlmnList = mSatelliteControllerUT.getSatellitePlmnsForCarrier(
                SUB_ID);
@@ -1670,6 +1670,7 @@ public class SatelliteControllerTest extends TelephonyTest {
                R.array.config_satellite_providers, satelliteProviderStrArray);
        int[] expectedSupportedServices2 = {2};
        int[] expectedSupportedServices3 = {1, 3};
        int[] defaultSupportedServices = {5, 6};
        PersistableBundle carrierSupportedSatelliteServicesPerProvider = new PersistableBundle();
        carrierSupportedSatelliteServicesPerProvider.putIntArray(
                "00102", expectedSupportedServices2);
@@ -1679,6 +1680,9 @@ public class SatelliteControllerTest extends TelephonyTest {
        mCarrierConfigBundle.putPersistableBundle(CarrierConfigManager
                        .KEY_CARRIER_SUPPORTED_SATELLITE_SERVICES_PER_PROVIDER_BUNDLE,
                carrierSupportedSatelliteServicesPerProvider);
        mCarrierConfigBundle.putIntArray(
                CarrierConfigManager.KEY_CARRIER_ROAMING_SATELLITE_DEFAULT_SERVICES_INT_ARRAY,
                defaultSupportedServices);
        TestSatelliteController testSatelliteController =
                new TestSatelliteController(mContext, Looper.myLooper(), mFeatureFlags);

@@ -1688,6 +1692,9 @@ public class SatelliteControllerTest extends TelephonyTest {
                testSatelliteController.getSupportedSatelliteServices(SUB_ID, "00101");
        assertTrue(supportedSatelliteServices.isEmpty());

        // Add entitlement provided PLMNs.
        setEntitlementPlmnList(testSatelliteController, SUB_ID,
                Arrays.asList("00102", "00104", "00105"));
        // Carrier config changed with carrierEnabledSatelliteFlag disabled
        for (Pair<Executor, CarrierConfigManager.CarrierConfigChangeListener> pair
                : mCarrierConfigChangedListenerList) {
@@ -1703,6 +1710,12 @@ public class SatelliteControllerTest extends TelephonyTest {
        supportedSatelliteServices =
                testSatelliteController.getSupportedSatelliteServices(SUB_ID, "00103");
        assertTrue(supportedSatelliteServices.isEmpty());
        supportedSatelliteServices =
                testSatelliteController.getSupportedSatelliteServices(SUB_ID, "00104");
        assertTrue(supportedSatelliteServices.isEmpty());
        supportedSatelliteServices =
                testSatelliteController.getSupportedSatelliteServices(SUB_ID, "00105");
        assertTrue(supportedSatelliteServices.isEmpty());

        // Trigger carrier config changed with carrierEnabledSatelliteFlag enabled
        when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(true);
@@ -1721,6 +1734,7 @@ public class SatelliteControllerTest extends TelephonyTest {
                expectedSupportedSatellitePlmns, satellitePlmnList.stream().toArray()));
        supportedSatelliteServices =
                mSatelliteControllerUT.getSupportedSatelliteServices(SUB_ID, "00102");
        // "00101" should return carrier config assigned value, though it is in allowed list.
        assertTrue(Arrays.equals(expectedSupportedServices2,
                supportedSatelliteServices.stream()
                        .mapToInt(Integer::intValue)
@@ -1731,6 +1745,19 @@ public class SatelliteControllerTest extends TelephonyTest {
                supportedSatelliteServices.stream()
                        .mapToInt(Integer::intValue)
                        .toArray()));
        // "00104", and "00105" should return default supported service.
        supportedSatelliteServices =
                testSatelliteController.getSupportedSatelliteServices(SUB_ID, "00104");
        assertTrue(Arrays.equals(defaultSupportedServices,
                supportedSatelliteServices.stream()
                        .mapToInt(Integer::intValue)
                        .toArray()));
        supportedSatelliteServices =
                testSatelliteController.getSupportedSatelliteServices(SUB_ID, "00105");
        assertTrue(Arrays.equals(defaultSupportedServices,
                supportedSatelliteServices.stream()
                        .mapToInt(Integer::intValue)
                        .toArray()));

        // Subscriptions changed
        int[] newActiveSubIds = {SUB_ID1};
@@ -1745,13 +1772,32 @@ public class SatelliteControllerTest extends TelephonyTest {

        satellitePlmnList = testSatelliteController.getSatellitePlmnsForCarrier(SUB_ID);
        assertTrue(satellitePlmnList.isEmpty());
        // "00102" and "00103" should return default supported service for SUB_ID.
        supportedSatelliteServices =
                testSatelliteController.getSupportedSatelliteServices(SUB_ID, "00102");
        assertTrue(supportedSatelliteServices.isEmpty());
        assertTrue(Arrays.equals(defaultSupportedServices,
                supportedSatelliteServices.stream()
                        .mapToInt(Integer::intValue)
                        .toArray()));
        supportedSatelliteServices =
                testSatelliteController.getSupportedSatelliteServices(SUB_ID, "00103");
        assertTrue(supportedSatelliteServices.isEmpty());

        assertTrue(Arrays.equals(defaultSupportedServices,
                supportedSatelliteServices.stream()
                        .mapToInt(Integer::intValue)
                        .toArray()));
        // "00104", and "00105" should return default supported service for SUB_ID.
        supportedSatelliteServices =
                testSatelliteController.getSupportedSatelliteServices(SUB_ID, "00104");
        assertTrue(Arrays.equals(defaultSupportedServices,
                supportedSatelliteServices.stream()
                        .mapToInt(Integer::intValue)
                        .toArray()));
        supportedSatelliteServices =
                testSatelliteController.getSupportedSatelliteServices(SUB_ID, "00105");
        assertTrue(Arrays.equals(defaultSupportedServices,
                supportedSatelliteServices.stream()
                        .mapToInt(Integer::intValue)
                        .toArray()));

        supportedSatelliteServices =
                testSatelliteController.getSupportedSatelliteServices(SUB_ID1, "00102");
@@ -1767,6 +1813,19 @@ public class SatelliteControllerTest extends TelephonyTest {
                supportedSatelliteServices.stream()
                        .mapToInt(Integer::intValue)
                        .toArray()));
        /* "00104", and "00105" should return default supported service. */
        supportedSatelliteServices =
                testSatelliteController.getSupportedSatelliteServices(SUB_ID1, "00104");
        assertTrue(Arrays.equals(defaultSupportedServices,
                supportedSatelliteServices.stream()
                        .mapToInt(Integer::intValue)
                        .toArray()));
        supportedSatelliteServices =
                testSatelliteController.getSupportedSatelliteServices(SUB_ID1, "00105");
        assertTrue(Arrays.equals(defaultSupportedServices,
                supportedSatelliteServices.stream()
                        .mapToInt(Integer::intValue)
                        .toArray()));
    }

    @Test
@@ -2864,6 +2923,17 @@ public class SatelliteControllerTest extends TelephonyTest {
                mSatelliteControllerUT, entitlementPlmnListPerCarrier);
    }

    private void setEntitlementPlmnList(SatelliteController targetClass, int subId,
            List<String> plmnList) throws Exception {
        SparseArray<List<String>> entitlementPlmnListPerCarrier = new SparseArray<>();
        if (!plmnList.isEmpty()) {
            entitlementPlmnListPerCarrier.clear();
            entitlementPlmnListPerCarrier.put(subId, plmnList);
        }
        replaceInstance(SatelliteController.class, "mEntitlementPlmnListPerCarrier",
                targetClass, entitlementPlmnListPerCarrier);
    }

    private void setConfigDataPlmnList(List<String> plmnList) {
        doReturn(plmnList).when(mMockConfig).getAllSatellitePlmnsForCarrier(anyInt());
        doReturn(mMockConfig).when(mMockConfigParser).getConfig();