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

Commit b3da0bdb authored by Thomas Nguyen's avatar Thomas Nguyen Committed by Android (Google) Code Review
Browse files

Merge "Update setSatellitePlmn and guard carrier code with feature flag" into main

parents 6351a314 7244a1e5
Loading
Loading
Loading
Loading
+55 −28
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ import com.android.internal.telephony.subscription.SubscriptionManagerService;
import com.android.internal.util.FunctionalUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -223,11 +224,10 @@ public class SatelliteController extends Handler {
     * {@link android.telephony.NetworkRegistrationInfo.ServiceType})
     */
    @GuardedBy("mSupportedSatelliteServicesLock")
    @NonNull private final Map<Integer, Map<String, Set<Integer>>> mSupportedSatelliteServices =
            new HashMap<>();
    @NonNull private final Map<Integer, Map<String, Set<Integer>>>
            mSatelliteServicesSupportedByCarriers = new HashMap<>();
    @NonNull private final Object mSupportedSatelliteServicesLock = new Object();
    /** Key: PLMN, value: set of {@link android.telephony.NetworkRegistrationInfo.ServiceType} */
    @NonNull private final Map<String, Set<Integer>> mSatelliteServicesSupportedByProviders;
    @NonNull private final List<String> mSatellitePlmnListFromOverlayConfig;
    @NonNull private final CarrierConfigManager mCarrierConfigManager;
    @NonNull private final CarrierConfigManager.CarrierConfigChangeListener
            mCarrierConfigChangeListener;
@@ -331,7 +331,7 @@ public class SatelliteController extends Handler {
                    false, satelliteModeRadiosContentObserver);
        }

        mSatelliteServicesSupportedByProviders = readSupportedSatelliteServicesFromOverlayConfig();
        mSatellitePlmnListFromOverlayConfig = readSatellitePlmnsFromOverlayConfig();
        updateSupportedSatelliteServicesForActiveSubscriptions();
        mCarrierConfigChangeListener =
                (slotIndex, subId, carrierId, specificCarrierId) ->
@@ -1899,6 +1899,10 @@ public class SatelliteController extends Handler {
            @NonNull IIntegerConsumer callback) {
        if (DBG) logd("addSatelliteAttachRestrictionForCarrier(" + subId + ", " + reason + ")");
        Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept);
        if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
            result.accept(SatelliteManager.SATELLITE_RESULT_REQUEST_NOT_SUPPORTED);
            return;
        }

        synchronized (mIsSatelliteEnabledLock) {
            if (mSatelliteAttachRestrictionForCarrierArray.getOrDefault(
@@ -1930,8 +1934,13 @@ public class SatelliteController extends Handler {
    public void removeSatelliteAttachRestrictionForCarrier(int subId,
            @SatelliteManager.SatelliteCommunicationRestrictionReason int reason,
            @NonNull IIntegerConsumer callback) {
        Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept);
        if (DBG) logd("removeSatelliteAttachRestrictionForCarrier(" + subId + ", " + reason + ")");
        Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept);
        if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
            result.accept(SatelliteManager.SATELLITE_RESULT_REQUEST_NOT_SUPPORTED);
            return;
        }

        synchronized (mIsSatelliteEnabledLock) {
            if (mSatelliteAttachRestrictionForCarrierArray.getOrDefault(
                    subId, Collections.emptySet()).isEmpty()
@@ -1956,7 +1965,10 @@ public class SatelliteController extends Handler {
     *
     * @return Set of reasons for disallowing satellite attach for carrier.
     */
    public @NonNull Set<Integer> getSatelliteAttachRestrictionReasonsForCarrier(int subId) {
    @NonNull public Set<Integer> getSatelliteAttachRestrictionReasonsForCarrier(int subId) {
        if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
            return new HashSet<>();
        }
        synchronized (mIsSatelliteEnabledLock) {
            Set<Integer> resultSet =
                    mSatelliteAttachRestrictionForCarrierArray.get(subId);
@@ -2100,8 +2112,8 @@ public class SatelliteController extends Handler {
    @NonNull
    public List<String> getSatellitePlmnList(int subId) {
        synchronized (mSupportedSatelliteServicesLock) {
            if (mSupportedSatelliteServices.containsKey(subId)) {
                return new ArrayList<>(mSupportedSatelliteServices.get(subId).keySet());
            if (mSatelliteServicesSupportedByCarriers.containsKey(subId)) {
                return new ArrayList<>(mSatelliteServicesSupportedByCarriers.get(subId).keySet());
            } else {
                return new ArrayList<>();
            }
@@ -2117,9 +2129,9 @@ public class SatelliteController extends Handler {
    @NonNull
    public List<Integer> getSupportedSatelliteServices(int subId, String plmn) {
        synchronized (mSupportedSatelliteServicesLock) {
            if (mSupportedSatelliteServices.containsKey(subId)) {
            if (mSatelliteServicesSupportedByCarriers.containsKey(subId)) {
                Map<String, Set<Integer>> supportedServices =
                        mSupportedSatelliteServices.get(subId);
                        mSatelliteServicesSupportedByCarriers.get(subId);
                if (supportedServices != null && supportedServices.containsKey(plmn)) {
                    return new ArrayList<>(supportedServices.get(plmn));
                } else {
@@ -2127,8 +2139,8 @@ public class SatelliteController extends Handler {
                            + "does not contain key plmn=" + plmn);
                }
            } else {
                loge("getSupportedSatelliteServices: mSupportedSatelliteServices does contain key"
                        + " subId=" + subId);
                loge("getSupportedSatelliteServices: mSatelliteServicesSupportedByCarriers does "
                        + "not contain key subId=" + subId);
            }
            return new ArrayList<>();
        }
@@ -2590,11 +2602,22 @@ public class SatelliteController extends Handler {
    }

    private void configureSatellitePlmnForCarrier(int subId) {
        logd("configureSatellitePlmnForCarrier()");
        List<String> satellitePlmnList = getSatellitePlmnList(subId);
        if (!satellitePlmnList.isEmpty()) {
        logd("configureSatellitePlmnForCarrier");
        if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
            return;
        }
        synchronized (mSupportedSatelliteServicesLock) {
            List<String> carrierPlmnList;
            if (mSatelliteServicesSupportedByCarriers.containsKey(subId)) {
                carrierPlmnList =
                        mSatelliteServicesSupportedByCarriers.get(subId).keySet().stream().toList();
            } else {
                carrierPlmnList = new ArrayList<>();
            }
            int slotId = SubscriptionManager.getSlotIndex(subId);
            mSatelliteModemInterface.setSatellitePlmn(slotId, satellitePlmnList,
            mSatelliteModemInterface.setSatellitePlmn(slotId, carrierPlmnList,
                    SatelliteServiceUtils.mergeStrLists(
                            carrierPlmnList, mSatellitePlmnListFromOverlayConfig),
                    obtainMessage(EVENT_SET_SATELLITE_PLMN_INFO_DONE));
        }
    }
@@ -2605,8 +2628,12 @@ public class SatelliteController extends Handler {
    }

    private void updateSupportedSatelliteServicesForActiveSubscriptions() {
        if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
            return;
        }

        synchronized (mSupportedSatelliteServicesLock) {
            mSupportedSatelliteServices.clear();
            mSatelliteServicesSupportedByCarriers.clear();
            int[] activeSubIds = mSubscriptionManagerService.getActiveSubIdList(true);
            if (activeSubIds != null) {
                for (int subId : activeSubIds) {
@@ -2620,21 +2647,21 @@ public class SatelliteController extends Handler {
    }

    private void updateSupportedSatelliteServices(int subId) {
        Map<String, Set<Integer>> carrierSupportedSatelliteServicesPerPlmn =
                readSupportedSatelliteServicesFromCarrierConfig(subId);
        synchronized (mSupportedSatelliteServicesLock) {
            mSupportedSatelliteServices.put(subId,
                    SatelliteServiceUtils.mergeSupportedSatelliteServices(
                            mSatelliteServicesSupportedByProviders,
                            carrierSupportedSatelliteServicesPerPlmn));
            mSatelliteServicesSupportedByCarriers.put(
                    subId, readSupportedSatelliteServicesFromCarrierConfig(subId));
        }
    }

    @NonNull
    private Map<String, Set<Integer>> readSupportedSatelliteServicesFromOverlayConfig() {
        String[] supportedServices = readStringArrayFromOverlayConfig(
                R.array.config_satellite_services_supported_by_providers);
        return SatelliteServiceUtils.parseSupportedSatelliteServices(supportedServices);
    private List<String> readSatellitePlmnsFromOverlayConfig() {
        if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
            return new ArrayList<>();
        }

        String[] devicePlmns = readStringArrayFromOverlayConfig(
                R.array.config_satellite_providers);
        return Arrays.stream(devicePlmns).toList();
    }

    @NonNull
+9 −5
Original line number Diff line number Diff line
@@ -1039,15 +1039,19 @@ public class SatelliteModemInterface {
     *
     * @param simSlot Indicates the SIM slot to which this API will be applied. The modem will use
     *                this information to determine the relevant carrier.
     * @param plmnList The list of roaming PLMN used for connecting to satellite networks.
     * @param carrierPlmnList The list of roaming PLMN used for connecting to satellite networks
     *                        supported by user subscription.
     * @param allSatellitePlmnList Modem should use the allSatellitePlmnList to identify satellite
     *                             PLMNs that are not supported by the carrier and make sure not to
     *                             attach to them.
     * @param message The result receiver that returns whether the modem has
     *                successfully set the satellite PLMN
     */
    public void setSatellitePlmn(@NonNull int simSlot, @NonNull List<String> plmnList,
            @NonNull Message message) {
    public void setSatellitePlmn(@NonNull int simSlot, @NonNull List<String> carrierPlmnList,
            @NonNull List<String> allSatellitePlmnList, @NonNull Message message) {
        if (mSatelliteService != null) {
            try {
                mSatelliteService.setSatellitePlmn(simSlot, plmnList,
                mSatelliteService.setSatellitePlmn(simSlot, carrierPlmnList, allSatellitePlmnList,
                        new IIntegerConsumer.Stub() {
                            @Override
                            public void accept(int result) {
+7 −83
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.internal.telephony.subscription.SubscriptionManagerService;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@@ -277,61 +278,6 @@ public class SatelliteServiceUtils {
        return SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
    }

    /**
     * Expected format of each input string in the array: "PLMN_1:service_1,service_2,..."
     *
     * @return The map of supported services with key: PLMN, value: set of services supported by
     * the PLMN.
     */
    @NonNull
    @NetworkRegistrationInfo.ServiceType
    public static Map<String, Set<Integer>> parseSupportedSatelliteServices(
            String[] supportedSatelliteServicesStrArray) {
        Map<String, Set<Integer>> supportedServicesMap = new HashMap<>();
        if (supportedSatelliteServicesStrArray == null
                || supportedSatelliteServicesStrArray.length == 0) {
            return supportedServicesMap;
        }

        for (String supportedServicesPerPlmnStr : supportedSatelliteServicesStrArray) {
            String[] pairOfPlmnAndsupportedServicesStr =
                    supportedServicesPerPlmnStr.split(":");
            if (pairOfPlmnAndsupportedServicesStr != null
                    && (pairOfPlmnAndsupportedServicesStr.length == 1
                    || pairOfPlmnAndsupportedServicesStr.length == 2)) {
                String plmn = pairOfPlmnAndsupportedServicesStr[0];
                Set<Integer> supportedServicesSet = new HashSet<>();
                if (pairOfPlmnAndsupportedServicesStr.length == 2) {
                    String[] supportedServicesStrArray =
                            pairOfPlmnAndsupportedServicesStr[1].split(",");
                    for (String service : supportedServicesStrArray) {
                        try {
                            int serviceType = Integer.parseInt(service);
                            if (isServiceTypeValid(serviceType)) {
                                supportedServicesSet.add(serviceType);
                            } else {
                                loge("parseSupportedSatelliteServices: invalid serviceType="
                                        + serviceType);
                            }
                        } catch (NumberFormatException e) {
                            loge("parseSupportedSatelliteServices: supportedServicesPerPlmnStr="
                                    + supportedServicesPerPlmnStr + ", service=" + service
                                    + ", e=" + e);
                        }
                    }
                }
                logd("parseSupportedSatelliteServices: plmn=" + plmn + ", supportedServicesSet="
                        + supportedServicesSet.stream().map(String::valueOf).collect(
                                joining(",")));
                supportedServicesMap.put(plmn, supportedServicesSet);
            } else {
                loge("parseSupportedSatelliteServices: invalid format input, "
                        + "supportedServicesPerPlmnStr=" + supportedServicesPerPlmnStr);
            }
        }
        return supportedServicesMap;
    }

    /**
     * Expected format of the input dictionary bundle is:
     * <ul>
@@ -369,36 +315,14 @@ public class SatelliteServiceUtils {
    }

    /**
     * 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.
     * @return The supported satellite services by the device for the corresponding carrier and the
     * satellite provider.
     * Merge two string lists into one such that the result list does not have any duplicate items.
     */
    @NonNull
    @NetworkRegistrationInfo.ServiceType
    public static Map<String, Set<Integer>> mergeSupportedSatelliteServices(
            @NonNull @NetworkRegistrationInfo.ServiceType Map<String, Set<Integer>>
                    providerSupportedServices,
            @NonNull @NetworkRegistrationInfo.ServiceType Map<String, Set<Integer>>
                    carrierSupportedServices) {
        Map<String, Set<Integer>> supportedServicesMap = new HashMap<>();
        for (Map.Entry<String, Set<Integer>> entry : providerSupportedServices.entrySet()) {
            if (!entry.getValue().isEmpty()) {
                supportedServicesMap.put(entry.getKey(), entry.getValue());
            }
        }
        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;
    public static List<String> mergeStrLists(List<String> strList1, List<String> strList2) {
        Set<String> mergedStrSet = new HashSet<>();
        mergedStrSet.addAll(strList1);
        mergedStrSet.addAll(strList2);
        return mergedStrSet.stream().toList();
    }

    private static boolean isServiceTypeValid(int serviceType) {
+1 −1
Original line number Diff line number Diff line
@@ -3994,7 +3994,7 @@ public class SubscriptionManagerService extends ISub.Stub {
            return false;
        }

        final int id = R.string.config_satellite_esim_identifier;
        final int id = R.string.config_satellite_sim_identifier;
        String overlayMccMnc = null;
        try {
            overlayMccMnc = mContext.getResources().getString(id);
+172 −72

File changed.

Preview size limit exceeded, changes collapsed.

Loading