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

Commit 12ab6ca0 authored by Aishwarya Mallampati's avatar Aishwarya Mallampati Committed by Android (Google) Code Review
Browse files

Merge "Change HashMap to ConcurrentHashMap." into main

parents 90a100db 5f6be8d6
Loading
Loading
Loading
Loading
+84 −98
Original line number Diff line number Diff line
@@ -432,6 +432,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
@@ -529,6 +531,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")
@@ -537,12 +553,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;
@@ -567,6 +577,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 */
@@ -586,19 +602,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<>();
@@ -638,15 +641,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)
@@ -4454,7 +4448,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);
@@ -4471,7 +4464,6 @@ public class SatelliteController extends Handler {
                        + " key subId=" + subId);
            }
        }
        }

        /* Returns default capabilities when carrier config does not contain service capabilities
         for the given plmn */
@@ -4758,12 +4750,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<>();
    }
@@ -6017,7 +6007,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);
@@ -6043,7 +6032,6 @@ public class SatelliteController extends Handler {
        updatePlmnListPerCarrier(subId);
        plogd("updateSupportedSatelliteServices using carrier config");
    }
    }

    @NonNull
    private int getMaxAllowedDataModeDeviceConfigOverlay() {
@@ -6878,7 +6866,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
@@ -6908,7 +6895,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) {