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

Commit a7ff5cbe authored by Hakjun Choi's avatar Hakjun Choi Committed by Android (Google) Code Review
Browse files

Merge "Add default capabilities when allowed plmn is not listed in carrier config" into 24D1-dev

parents 7b1a3bd6 33721b16
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;
@@ -136,6 +137,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
@@ -2575,8 +2577,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;
        }
    }

    /**
@@ -3477,7 +3494,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: "
@@ -3533,24 +3551,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();
        }
@@ -3983,16 +3996,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) {
@@ -4333,6 +4340,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
@@ -2904,6 +2963,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();