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

Commit 5f6be8d6 authored by Aishwarya Mallampati's avatar Aishwarya Mallampati
Browse files

Change HashMap to ConcurrentHashMap.

Following variables are changed to ConcurrentHashMap:
- mSatelliteServicesSupportedByCarriersFromConfig
- mCarrierRoamingSatelliteSessionStatsMap
- mSatModeCapabilitiesForCarrierRoaming
- mProvisionedSubscriberId
- mSubscriberIdPerSub

Bug: 409584433
Test: 417808605
Test: atest
Flag: com.android.internal.telephony.flags.satellite_improve_multi_thread_design
Change-Id: I45f26f3743c0d63cb6d47ed11d7eb0985e45f36a
parent 508b5dc6
Loading
Loading
Loading
Loading
+84 −98
Original line number Diff line number Diff line
@@ -431,6 +431,8 @@ public class SatelliteController extends Handler {
    private AtomicLong mSatelliteEmergencyModeDurationMillis = new AtomicLong(0);
    private AtomicLong mSessionStartTimeStamp = new AtomicLong(0);
    private AtomicLong mSessionProcessingTimeStamp = new AtomicLong(0);
    private static AtomicLong sNextSatelliteEnableRequestId = new AtomicLong(0);
    private static AtomicLong sNextSystemSelectionChannelsUpdateRequestId = new AtomicLong(0);
    /**
     * This is used for testing only. When mEnforcedEmergencyCallToSatelliteHandoverType is valid,
     * Telephony will ignore the IMS registration status and cellular availability, and always send
@@ -528,6 +530,20 @@ public class SatelliteController extends Handler {
            mSelectedNbIotSatelliteSubscriptionChangedListeners = new ConcurrentHashMap<>();
    protected ConcurrentHashMap<String, Integer> mResultReceiverCountPerMethodMap =
            new ConcurrentHashMap<>();
    /** Key: subId, value: (key: PLMN, value: set of
     * {@link android.telephony.NetworkRegistrationInfo.ServiceType})
     */
    @NonNull private final ConcurrentHashMap<Integer, Map<String, Set<Integer>>>
            mSatelliteServicesSupportedByCarriersFromConfig = new ConcurrentHashMap<>();
    @NonNull private final ConcurrentHashMap<Integer, CarrierRoamingSatelliteSessionStats>
            mCarrierRoamingSatelliteSessionStatsMap = new ConcurrentHashMap<>();
    /**
     * Key: Subscription ID; Value: set of
     * {@link android.telephony.NetworkRegistrationInfo.ServiceType}
     */
    @NonNull private final ConcurrentHashMap<Integer, List<Integer>>
            mSatModeCapabilitiesForCarrierRoaming = new ConcurrentHashMap<>();


    private final Object mSatelliteCapabilitiesLock = new Object();
    @GuardedBy("mSatelliteCapabilitiesLock")
@@ -536,12 +552,6 @@ public class SatelliteController extends Handler {
    @GuardedBy("mNtnSignalsStrengthLock")
    private NtnSignalStrength mNtnSignalStrength =
            new NtnSignalStrength(NTN_SIGNAL_STRENGTH_NONE);
    /** Key: subId, value: (key: PLMN, value: set of
     * {@link android.telephony.NetworkRegistrationInfo.ServiceType})
     */
    @GuardedBy("mSupportedSatelliteServicesLock")
    @NonNull private final Map<Integer, Map<String, Set<Integer>>>
            mSatelliteServicesSupportedByCarriersFromConfig = new HashMap<>();
    @NonNull private final Object mSupportedSatelliteServicesLock = new Object();
    @NonNull private final List<String> mSatellitePlmnListFromOverlayConfig;
    @NonNull private final CarrierConfigManager mCarrierConfigManager;
@@ -566,6 +576,12 @@ public class SatelliteController extends Handler {
     */
    @NonNull private final ConcurrentHashMap<Integer, Map<String, Set<Integer>>>
            mRegionalSatelliteEarfcns = new ConcurrentHashMap<>();
    // key : subscriberId, value : provisioned or not.
    private ConcurrentHashMap<String, Boolean> mProvisionedSubscriberId = new ConcurrentHashMap<>();
    // key : subscriberId, value : subId
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected ConcurrentHashMap<String, Integer> mSubscriberIdPerSub = new ConcurrentHashMap<>();

    @NonNull private final FeatureFlags mFeatureFlags;
    @NonNull private final Object mSatelliteConnectedLock = new Object();
    /** Key: Subscription ID; Value: Last satellite connected time */
@@ -585,19 +601,6 @@ public class SatelliteController extends Handler {

    @GuardedBy("mSatelliteConnectedLock")
    @NonNull private final SparseBooleanArray mInitialized = new SparseBooleanArray();

    @GuardedBy("mSatelliteConnectedLock")
    @NonNull private final Map<Integer, CarrierRoamingSatelliteSessionStats>
            mCarrierRoamingSatelliteSessionStatsMap = new HashMap<>();

    /**
     * Key: Subscription ID; Value: set of
     * {@link android.telephony.NetworkRegistrationInfo.ServiceType}
     */
    @GuardedBy("mSatelliteConnectedLock")
    @NonNull private final Map<Integer, List<Integer>>
            mSatModeCapabilitiesForCarrierRoaming = new HashMap<>();

    @GuardedBy("mSatelliteConnectedLock")
    private SparseArray<NtnSignalStrength> mLastNotifiedCarrierRoamingNtnSignalStrength =
            new SparseArray<>();
@@ -637,15 +640,6 @@ public class SatelliteController extends Handler {
    @GuardedBy("mSupportedSatelliteServicesLock")
    SparseArray<Map<String, Integer>> mEntitlementVoiceServicePolicyMapPerCarrier =
            new SparseArray<>();
    private static AtomicLong sNextSatelliteEnableRequestId = new AtomicLong(0);
    private static AtomicLong sNextSystemSelectionChannelsUpdateRequestId = new AtomicLong(0);
    // key : subscriberId, value : provisioned or not.
    @GuardedBy("mSatelliteTokenProvisionedLock")
    private Map<String, Boolean> mProvisionedSubscriberId = new HashMap<>();
    // key : subscriberId, value : subId
    @GuardedBy("mSatelliteTokenProvisionedLock")
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected Map<String, Integer> mSubscriberIdPerSub = new HashMap<>();
    // key : priority, low value is high, value : List<SubscriptionInfo>
    @GuardedBy("mSatelliteTokenProvisionedLock")
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
@@ -4447,7 +4441,6 @@ public class SatelliteController extends Handler {
     */
    private List<Integer> getSatelliteSupportedServicesFromConfig(int subId, String plmn) {
        if (plmn != null && !plmn.isEmpty()) {
            synchronized (mSupportedSatelliteServicesLock) {
            if (mSatelliteServicesSupportedByCarriersFromConfig.containsKey(subId)) {
                Map<String, Set<Integer>> supportedServices =
                        mSatelliteServicesSupportedByCarriersFromConfig.get(subId);
@@ -4464,7 +4457,6 @@ public class SatelliteController extends Handler {
                        + " key subId=" + subId);
            }
        }
        }

        /* Returns default capabilities when carrier config does not contain service capabilities
         for the given plmn */
@@ -4751,12 +4743,10 @@ public class SatelliteController extends Handler {
     */
    @NonNull
    public List<Integer> getCapabilitiesForCarrierRoamingSatelliteMode(Phone phone) {
        synchronized (mSatelliteConnectedLock) {
        int subId = phone.getSubId();
        if (mSatModeCapabilitiesForCarrierRoaming.containsKey(subId)) {
            return mSatModeCapabilitiesForCarrierRoaming.get(subId);
        }
        }

        return new ArrayList<>();
    }
@@ -6010,7 +6000,6 @@ public class SatelliteController extends Handler {

    private void updateSupportedSatelliteServices(int subId) {
        plogd("updateSupportedSatelliteServices with subId " + subId);
        synchronized (mSupportedSatelliteServicesLock) {
        SatelliteConfig satelliteConfig = getSatelliteConfig();

        TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
@@ -6036,7 +6025,6 @@ public class SatelliteController extends Handler {
        updatePlmnListPerCarrier(subId);
        plogd("updateSupportedSatelliteServices using carrier config");
    }
    }

    @NonNull
    private int getMaxAllowedDataModeDeviceConfigOverlay() {
@@ -6871,7 +6859,6 @@ public class SatelliteController extends Handler {
            plogd("logCarrierRoamingSatelliteSessionStats: return, demo mode is enabled");
            return;
        }
        synchronized (mSatelliteConnectedLock) {
        int subId = phone.getSubId();
        if (!lastNotifiedNtnMode && currNtnMode) {
            // Log satellite session start
@@ -6901,7 +6888,6 @@ public class SatelliteController extends Handler {
            mCarrierRoamingSatelliteControllerStats.onSessionEnd(subId);
        }
    }
    }

    private void evaluateCarrierRoamingNtnEligibilityChange() {
        if (!mFeatureFlags.carrierRoamingNbIotNtn()) {
+10 −11
Original line number Diff line number Diff line
@@ -3036,8 +3036,8 @@ public class SatelliteControllerTest extends TelephonyTest {
        // are available and the barred plmn list is empty, verify passing to the modem.
        reset(mMockSatelliteModemInterface);
        reset(mPhone);
        Map<Integer, Map<String, Set<Integer>>>
                satelliteServicesSupportedByCarriers = new HashMap<>();
        ConcurrentHashMap<Integer, Map<String, Set<Integer>>>
                satelliteServicesSupportedByCarriers = new ConcurrentHashMap<>();
        List<String> carrierConfigPlmnList = Arrays.stream(new String[]{"00105", "00106"}).toList();
        Map<String, Set<Integer>> plmnAndService = new HashMap<>();
        plmnAndService.put(carrierConfigPlmnList.get(0), new HashSet<>(Arrays.asList(3, 5)));
@@ -3161,7 +3161,7 @@ public class SatelliteControllerTest extends TelephonyTest {
                mSatelliteControllerUT, new SparseArray<>());
        replaceInstance(SatelliteController.class,
                "mSatelliteServicesSupportedByCarriersFromConfig",
                mSatelliteControllerUT, new HashMap<>());
                mSatelliteControllerUT, new ConcurrentHashMap<>());
        List<Integer> servicesPerPlmn;

        // verify whether an empty list is returned with conditions below
@@ -3425,7 +3425,7 @@ public class SatelliteControllerTest extends TelephonyTest {
                mSatelliteControllerUT, new SparseArray<>());
        replaceInstance(SatelliteController.class,
                "mSatelliteServicesSupportedByCarriersFromConfig",
                mSatelliteControllerUT, new HashMap<>());
                mSatelliteControllerUT, new ConcurrentHashMap<>());
        mCarrierConfigBundle.putBoolean(CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL,
                true);
        mCarrierConfigBundle.putBoolean(
@@ -4734,11 +4734,11 @@ public class SatelliteControllerTest extends TelephonyTest {
        Field provisionedSubscriberIdField = SatelliteController.class.getDeclaredField(
                "mProvisionedSubscriberId");
        provisionedSubscriberIdField.setAccessible(true);
        provisionedSubscriberIdField.set(mSatelliteControllerUT, new HashMap<>());
        provisionedSubscriberIdField.set(mSatelliteControllerUT, new ConcurrentHashMap<>());
        Field subscriberIdPerSubField = SatelliteController.class.getDeclaredField(
                "mSubscriberIdPerSub");
        subscriberIdPerSubField.setAccessible(true);
        subscriberIdPerSubField.set(mSatelliteControllerUT, new HashMap<>());
        subscriberIdPerSubField.set(mSatelliteControllerUT, new ConcurrentHashMap<>());
        Field lastConfiguredIccIdField = SatelliteController.class.getDeclaredField(
                "mLastConfiguredIccId");
        lastConfiguredIccIdField.setAccessible(true);
@@ -4887,7 +4887,7 @@ public class SatelliteControllerTest extends TelephonyTest {
        Field provisionedSubscriberIdField = SatelliteController.class.getDeclaredField(
                "mProvisionedSubscriberId");
        provisionedSubscriberIdField.setAccessible(true);
        Map<String, Boolean> testProvisionedSubscriberId = new HashMap<>();;
        ConcurrentHashMap<String, Boolean> testProvisionedSubscriberId = new ConcurrentHashMap<>();
        testProvisionedSubscriberId.put(carrierSubscriberId, true);
        testProvisionedSubscriberId.put(oemSubscriberId, true);
        provisionedSubscriberIdField.set(mSatelliteControllerUT, testProvisionedSubscriberId);
@@ -6227,11 +6227,10 @@ public class SatelliteControllerTest extends TelephonyTest {
            return hasMessages(EVENT_WAIT_FOR_CELLULAR_MODEM_OFF_TIMED_OUT);
        }

        public Map<String, Integer> subscriberIdPerSub() {
            synchronized (mSatelliteTokenProvisionedLock) {
        /** Return subscriberId for each subscription map. */
        public ConcurrentHashMap<String, Integer> subscriberIdPerSub() {
            return mSubscriberIdPerSub;
        }
        }

        public Map<Integer, List<SubscriptionInfo>> subsInfoListPerPriority() {
            synchronized (mSatelliteTokenProvisionedLock) {