Loading src/java/com/android/internal/telephony/satellite/SatelliteController.java +77 −30 Original line number Diff line number Diff line Loading @@ -318,9 +318,23 @@ public class SatelliteController extends Handler { private int mEnforcedEmergencyCallToSatelliteHandoverType = INVALID_EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE; private int mDelayInSendingEventDisplayEmergencyMessage = 0; private boolean mCarrierSatelliteEnabled; @NonNull private SharedPreferences mSharedPreferences = null; /** * Key : Subscription ID, Value: {@code true} if the EntitlementStatus is enabled, * {@code false} otherwise. */ @GuardedBy("mSupportedSatelliteServicesLock") private SparseBooleanArray mSatelliteEntitlementStatusPerCarrier = new SparseBooleanArray(); /** Key Subscription ID, value : PLMN allowed list from entitlement. */ @GuardedBy("mSupportedSatelliteServicesLock") private SparseArray<List<String>> mEntitlementPlmnListPerCarrier = new SparseArray<>(); /** * Key : Subscription ID, Value : If there is an entitlementPlmnList, use it. Otherwise, use the * carrierPlmnList. */ @GuardedBy("mSupportedSatelliteServicesLock") private final SparseArray<List<String>> mMergedPlmnListPerCarrier = new SparseArray<>(); /** * @return The singleton instance of SatelliteController. */ Loading Loading @@ -2334,11 +2348,7 @@ public class SatelliteController extends Handler { return new ArrayList<>(); } synchronized (mSupportedSatelliteServicesLock) { if (mSatelliteServicesSupportedByCarriers.containsKey(subId)) { return new ArrayList<>(mSatelliteServicesSupportedByCarriers.get(subId).keySet()); } else { return new ArrayList<>(); } return mMergedPlmnListPerCarrier.get(subId, new ArrayList<>()).stream().toList(); } } Loading Loading @@ -2480,22 +2490,21 @@ public class SatelliteController extends Handler { } /** * Update the satellite EntitlementStatus and PlmnAllowedList after receiving the HTTP response * from the satellite entitlement server. * If the satellite service is enabled then trigger internal satellite enabled for carrier, * otherwise trigger internal satellite disabled for carrier. * To use the satellite service, update the EntitlementStatus and the PlmnAllowedList after * receiving the satellite configuration from the entitlement server. If satellite * entitlement is enabled, enable satellite for the carrier. Otherwise, disable satellite. * * @param subId subId * @param entitlementEnabled {@code true} Satellite service enabled * @param allowedPlmnList plmn allowed list to use the satellite service * @param callback callback for accept */ public void updateSatelliteEntitlementStatus(int subId, boolean satelliteEnabled, List<String> plmnAllowed, IIntegerConsumer callback) { public void onSatelliteEntitlementStatusUpdated(int subId, boolean entitlementEnabled, List<String> allowedPlmnList, @Nullable IIntegerConsumer callback) { if (!mFeatureFlags.carrierEnabledSatelliteFlag()) { return; } if (mCarrierSatelliteEnabled != satelliteEnabled) { logd("update the carrier satellite enabled to " + satelliteEnabled); mCarrierSatelliteEnabled = satelliteEnabled; } if (callback == null) { callback = new IIntegerConsumer.Stub() { @Override Loading @@ -2505,7 +2514,19 @@ public class SatelliteController extends Handler { }; } if (mCarrierSatelliteEnabled) { synchronized (mSupportedSatelliteServicesLock) { if (mSatelliteEntitlementStatusPerCarrier.get(subId, false) != entitlementEnabled) { logd("update the carrier satellite enabled to " + entitlementEnabled); mSatelliteEntitlementStatusPerCarrier.put(subId, entitlementEnabled); } mMergedPlmnListPerCarrier.remove(subId); mEntitlementPlmnListPerCarrier.put(subId, allowedPlmnList); updatePlmnListPerCarrier(subId); configureSatellitePlmnForCarrier(subId); // TODO b/322143408 store entitlement status in telephony db. if (mSatelliteEntitlementStatusPerCarrier.get(subId, false)) { removeSatelliteAttachRestrictionForCarrier(subId, SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT, callback); } else { Loading @@ -2513,6 +2534,7 @@ public class SatelliteController extends Handler { SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT, callback); } } } /** * If we have not successfully queried the satellite modem for its satellite service support, Loading Loading @@ -3021,13 +3043,8 @@ public class SatelliteController extends Handler { return; } synchronized (mSupportedSatelliteServicesLock) { List<String> carrierPlmnList; if (mSatelliteServicesSupportedByCarriers.containsKey(subId)) { carrierPlmnList = mSatelliteServicesSupportedByCarriers.get(subId).keySet().stream().toList(); } else { carrierPlmnList = new ArrayList<>(); } List<String> carrierPlmnList = mMergedPlmnListPerCarrier.get(subId, new ArrayList<>()).stream().toList(); int slotId = SubscriptionManager.getSlotIndex(subId); mSatelliteModemInterface.setSatellitePlmn(slotId, carrierPlmnList, SatelliteServiceUtils.mergeStrLists( Loading @@ -3050,6 +3067,7 @@ public class SatelliteController extends Handler { synchronized (mSupportedSatelliteServicesLock) { mSatelliteServicesSupportedByCarriers.clear(); mMergedPlmnListPerCarrier.clear(); int[] activeSubIds = mSubscriptionManagerService.getActiveSubIdList(true); if (activeSubIds != null) { for (int subId : activeSubIds) { Loading @@ -3062,10 +3080,37 @@ public class SatelliteController extends Handler { } } /** * If the entitlementPlmnList exist then used it. * Otherwise, If the carrierPlmnList exist then used it. */ private void updatePlmnListPerCarrier(int subId) { synchronized (mSupportedSatelliteServicesLock) { List<String> carrierPlmnList, entitlementPlmnList; entitlementPlmnList = mEntitlementPlmnListPerCarrier.get(subId, new ArrayList<>()).stream().toList(); if (!entitlementPlmnList.isEmpty()) { mMergedPlmnListPerCarrier.put(subId, entitlementPlmnList); logd("update it using entitlementPlmnList=" + entitlementPlmnList); return; } if (mSatelliteServicesSupportedByCarriers.containsKey(subId)) { carrierPlmnList = mSatelliteServicesSupportedByCarriers.get(subId).keySet().stream().toList(); } else { carrierPlmnList = new ArrayList<>(); } mMergedPlmnListPerCarrier.put(subId, carrierPlmnList); logd("update it using carrierPlmnList=" + carrierPlmnList); } } private void updateSupportedSatelliteServices(int subId) { synchronized (mSupportedSatelliteServicesLock) { mSatelliteServicesSupportedByCarriers.put( subId, readSupportedSatelliteServicesFromCarrierConfig(subId)); updatePlmnListPerCarrier(subId); } } Loading Loading @@ -3116,6 +3161,8 @@ public class SatelliteController extends Handler { } updateCarrierConfig(subId); // TODO b/322143408 read the telephony db to get the entitlementStatus and update the // restriction updateSupportedSatelliteServicesForActiveSubscriptions(); configureSatellitePlmnForCarrier(subId); Loading tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java +211 −4 Original line number Diff line number Diff line Loading @@ -112,6 +112,8 @@ import android.telephony.satellite.SatelliteManager.SatelliteException; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.util.Pair; import android.util.SparseArray; import android.util.SparseBooleanArray; import com.android.internal.R; import com.android.internal.telephony.IIntegerConsumer; Loading Loading @@ -2612,12 +2614,14 @@ public class SatelliteControllerTest extends TelephonyTest { @Test public void testSatelliteCommunicationRestrictionForEntitlement() throws Exception { logd("testSatelliteCommunicationRestrictionForEntitlement"); when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(true); mCarrierConfigBundle.putBoolean(CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, true); replaceInstance(SatelliteController.class, "mCarrierSatelliteEnabled", mSatelliteControllerUT, false); SparseBooleanArray satelliteEnabledPerCarrier = new SparseBooleanArray(); replaceInstance(SatelliteController.class, "mSatelliteEntitlementStatusPerCarrier", mSatelliteControllerUT, satelliteEnabledPerCarrier); mIIntegerConsumerResults.clear(); reset(mMockSatelliteModemInterface); Loading @@ -2632,7 +2636,7 @@ public class SatelliteControllerTest extends TelephonyTest { // Verify call the requestSetSatelliteEnabledForCarrier to enable the satellite when // satellite service is enabled by entitlement server. mSatelliteControllerUT.updateSatelliteEntitlementStatus(SUB_ID, true, new ArrayList<>(), mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, true, new ArrayList<>(), mIIntegerConsumer); processAllMessages(); Loading @@ -2652,7 +2656,7 @@ public class SatelliteControllerTest extends TelephonyTest { doReturn(mIsSatelliteServiceSupported) .when(mMockSatelliteModemInterface).isSatelliteServiceSupported(); setUpResponseForRequestSetSatelliteEnabledForCarrier(false, SATELLITE_RESULT_SUCCESS); mSatelliteControllerUT.updateSatelliteEntitlementStatus(SUB_ID, false, new ArrayList<>(), mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, false, new ArrayList<>(), mIIntegerConsumer); processAllMessages(); Loading @@ -2662,6 +2666,209 @@ public class SatelliteControllerTest extends TelephonyTest { .requestSetSatelliteEnabledForCarrier(anyInt(), eq(false), any(Message.class)); } @Test public void testPassSatellitePlmnToModemAfterUpdateSatelliteEntitlementStatus() throws Exception { logd("testPassSatellitePlmnToModemAfterUpdateSatelliteEntitlementStatus"); when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(true); replaceInstance(SatelliteController.class, "mMergedPlmnListPerCarrier", mSatelliteControllerUT, new SparseArray<>()); List<String> overlayConfigPlmnList = new ArrayList<>(); replaceInstance(SatelliteController.class, "mSatellitePlmnListFromOverlayConfig", mSatelliteControllerUT, overlayConfigPlmnList); // If the PlmnListPerCarrier and the overlay config plmn list are empty verify passing to // the modem. List<String> entitlementPlmnList = new ArrayList<>(); mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, false, entitlementPlmnList, mIIntegerConsumer); List<String> plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier( SUB_ID); List<String> allSatellitePlmnList = SatelliteServiceUtils.mergeStrLists( plmnListPerCarrier, overlayConfigPlmnList); assertEquals(new ArrayList<>(), plmnListPerCarrier); assertEquals(new ArrayList<>(), allSatellitePlmnList); verify(mMockSatelliteModemInterface, times(1)).setSatellitePlmn(anyInt(), eq(plmnListPerCarrier), eq(allSatellitePlmnList), any(Message.class)); // If the PlmnListPerCarrier and the overlay config plmn list are exist verify passing // the modem. entitlementPlmnList = Arrays.stream(new String[]{"00101", "00102", "00103"}).toList(); overlayConfigPlmnList = Arrays.stream(new String[]{"00101", "00102", "00104"}).toList(); replaceInstance(SatelliteController.class, "mSatellitePlmnListFromOverlayConfig", mSatelliteControllerUT, overlayConfigPlmnList); mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, true, entitlementPlmnList, mIIntegerConsumer); plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier(SUB_ID); allSatellitePlmnList = SatelliteServiceUtils.mergeStrLists( plmnListPerCarrier, overlayConfigPlmnList); assertEquals(entitlementPlmnList, plmnListPerCarrier); verify(mMockSatelliteModemInterface, times(1)).setSatellitePlmn(anyInt(), eq(plmnListPerCarrier), eq(allSatellitePlmnList), any(Message.class)); // If the PlmnListPerCarrier and the overlay config plmn list are exist verify passing // the modem. reset(mMockSatelliteModemInterface); entitlementPlmnList = Arrays.stream(new String[]{"00101", "00102", "00103"}).toList(); Map<Integer, Map<String, Set<Integer>>> satelliteServicesSupportedByCarriers = new HashMap<>(); 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))); plmnAndService.put(carrierConfigPlmnList.get(1), new HashSet<>(Arrays.asList(3))); satelliteServicesSupportedByCarriers.put(SUB_ID, plmnAndService); replaceInstance(SatelliteController.class, "mSatelliteServicesSupportedByCarriers", mSatelliteControllerUT, satelliteServicesSupportedByCarriers); overlayConfigPlmnList = Arrays.stream(new String[]{"00101", "00102", "00104"}).toList(); replaceInstance(SatelliteController.class, "mSatellitePlmnListFromOverlayConfig", mSatelliteControllerUT, overlayConfigPlmnList); List<String> mergedPlmnList = entitlementPlmnList; mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, true, entitlementPlmnList, mIIntegerConsumer); plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier(SUB_ID); allSatellitePlmnList = SatelliteServiceUtils.mergeStrLists( plmnListPerCarrier, overlayConfigPlmnList); assertEquals(mergedPlmnList, plmnListPerCarrier); verify(mMockSatelliteModemInterface, times(1)).setSatellitePlmn(anyInt(), eq(plmnListPerCarrier), eq(allSatellitePlmnList), any(Message.class)); } @Test public void testUpdatePlmnListPerCarrier() throws Exception { logd("testUpdatePlmnListPerCarrier"); when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(true); replaceInstance(SatelliteController.class, "mMergedPlmnListPerCarrier", mSatelliteControllerUT, new SparseArray<>()); replaceInstance(SatelliteController.class, "mSatelliteServicesSupportedByCarriers", mSatelliteControllerUT, new HashMap<>()); SparseArray<List<String>> entitlementPlmnListPerCarrier = new SparseArray<>(); replaceInstance(SatelliteController.class, "mEntitlementPlmnListPerCarrier", mSatelliteControllerUT, entitlementPlmnListPerCarrier); // If the carrier config and the entitlement plmn list are empty, verify whether an empty // list is returned. mCarrierConfigBundle.putPersistableBundle(CarrierConfigManager .KEY_CARRIER_SUPPORTED_SATELLITE_SERVICES_PER_PROVIDER_BUNDLE, new PersistableBundle()); for (Pair<Executor, CarrierConfigManager.CarrierConfigChangeListener> pair : mCarrierConfigChangedListenerList) { pair.first.execute(() -> pair.second.onCarrierConfigChanged( /*slotIndex*/ 0, /*subId*/ SUB_ID, /*carrierId*/ 0, /*specificCarrierId*/ 0) ); } processAllMessages(); List<String> plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier( SUB_ID); assertEquals(new ArrayList<>(), plmnListPerCarrier); // If the carrier config list is empty and the entitlement plmn list is exists, verify // whether the entitlement list is returned. entitlementPlmnListPerCarrier.clear(); List<String> entitlementPlmnList = Arrays.asList("00101", "00102", "00104"); entitlementPlmnListPerCarrier.put(SUB_ID, entitlementPlmnList); List<String> expectedPlmnListPerCarrier = entitlementPlmnList; for (Pair<Executor, CarrierConfigManager.CarrierConfigChangeListener> pair : mCarrierConfigChangedListenerList) { pair.first.execute(() -> pair.second.onCarrierConfigChanged( /*slotIndex*/ 0, /*subId*/ SUB_ID, /*carrierId*/ 0, /*specificCarrierId*/ 0) ); } processAllMessages(); plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier(SUB_ID); assertEquals(expectedPlmnListPerCarrier, plmnListPerCarrier); // If the carrier config list is exists and the entitlement plmn list is empty, verify // whether the carrier config list is returned. entitlementPlmnListPerCarrier.clear(); entitlementPlmnList = new ArrayList<>(); entitlementPlmnListPerCarrier.put(SUB_ID, entitlementPlmnList); mCarrierConfigBundle.putBoolean(CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, true); PersistableBundle carrierSupportedSatelliteServicesPerProvider = new PersistableBundle(); List<String> carrierConfigPlmnList = Arrays.asList("00102", "00103", "00105"); carrierSupportedSatelliteServicesPerProvider.putIntArray( carrierConfigPlmnList.get(0), new int[]{2}); carrierSupportedSatelliteServicesPerProvider.putIntArray( carrierConfigPlmnList.get(1), new int[]{1, 3}); carrierSupportedSatelliteServicesPerProvider.putIntArray( carrierConfigPlmnList.get(2), new int[]{2}); mCarrierConfigBundle.putPersistableBundle(CarrierConfigManager .KEY_CARRIER_SUPPORTED_SATELLITE_SERVICES_PER_PROVIDER_BUNDLE, carrierSupportedSatelliteServicesPerProvider); for (Pair<Executor, CarrierConfigManager.CarrierConfigChangeListener> pair : mCarrierConfigChangedListenerList) { pair.first.execute(() -> pair.second.onCarrierConfigChanged( /*slotIndex*/ 0, /*subId*/ SUB_ID, /*carrierId*/ 0, /*specificCarrierId*/ 0) ); } processAllMessages(); expectedPlmnListPerCarrier = carrierConfigPlmnList; plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier(SUB_ID); assertEquals(expectedPlmnListPerCarrier.stream().sorted().toList(), plmnListPerCarrier.stream().sorted().toList()); // If the carrier config and the entitlement plmn list are exist, verify whether the // entitlement list is returned. entitlementPlmnList = Arrays.asList("00101", "00102", "00104"); entitlementPlmnListPerCarrier.put(SUB_ID, entitlementPlmnList); for (Pair<Executor, CarrierConfigManager.CarrierConfigChangeListener> pair : mCarrierConfigChangedListenerList) { pair.first.execute(() -> pair.second.onCarrierConfigChanged( /*slotIndex*/ 0, /*subId*/ SUB_ID, /*carrierId*/ 0, /*specificCarrierId*/ 0) ); } processAllMessages(); expectedPlmnListPerCarrier = entitlementPlmnList; plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier( SUB_ID); assertEquals(expectedPlmnListPerCarrier.stream().sorted().toList(), plmnListPerCarrier.stream().sorted().toList()); } @Test public void testEntitlementStatus() throws Exception { logd("testEntitlementStatus"); when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(true); SparseBooleanArray satelliteEnabledPerCarrier = new SparseBooleanArray(); replaceInstance(SatelliteController.class, "mSatelliteEntitlementStatusPerCarrier", mSatelliteControllerUT, satelliteEnabledPerCarrier); // Change SUB_ID's EntitlementStatus to true mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, true, new ArrayList<>(), mIIntegerConsumer); assertEquals(true, satelliteEnabledPerCarrier.get(SUB_ID)); assertEquals(false, satelliteEnabledPerCarrier.get(SUB_ID1)); // Change SUB_ID1's EntitlementStatus to true mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID1, true, new ArrayList<>(), mIIntegerConsumer); assertEquals(true, satelliteEnabledPerCarrier.get(SUB_ID)); assertEquals(true, satelliteEnabledPerCarrier.get(SUB_ID1)); // Change SUB_ID's EntitlementStatus to false mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, false, new ArrayList<>(), mIIntegerConsumer); assertEquals(false, satelliteEnabledPerCarrier.get(SUB_ID)); assertEquals(true, satelliteEnabledPerCarrier.get(SUB_ID1)); } private void resetSatelliteControllerUTEnabledState() { logd("resetSatelliteControllerUTEnabledState"); setUpResponseForRequestIsSatelliteSupported(false, SATELLITE_RESULT_RADIO_NOT_AVAILABLE); Loading Loading
src/java/com/android/internal/telephony/satellite/SatelliteController.java +77 −30 Original line number Diff line number Diff line Loading @@ -318,9 +318,23 @@ public class SatelliteController extends Handler { private int mEnforcedEmergencyCallToSatelliteHandoverType = INVALID_EMERGENCY_CALL_TO_SATELLITE_HANDOVER_TYPE; private int mDelayInSendingEventDisplayEmergencyMessage = 0; private boolean mCarrierSatelliteEnabled; @NonNull private SharedPreferences mSharedPreferences = null; /** * Key : Subscription ID, Value: {@code true} if the EntitlementStatus is enabled, * {@code false} otherwise. */ @GuardedBy("mSupportedSatelliteServicesLock") private SparseBooleanArray mSatelliteEntitlementStatusPerCarrier = new SparseBooleanArray(); /** Key Subscription ID, value : PLMN allowed list from entitlement. */ @GuardedBy("mSupportedSatelliteServicesLock") private SparseArray<List<String>> mEntitlementPlmnListPerCarrier = new SparseArray<>(); /** * Key : Subscription ID, Value : If there is an entitlementPlmnList, use it. Otherwise, use the * carrierPlmnList. */ @GuardedBy("mSupportedSatelliteServicesLock") private final SparseArray<List<String>> mMergedPlmnListPerCarrier = new SparseArray<>(); /** * @return The singleton instance of SatelliteController. */ Loading Loading @@ -2334,11 +2348,7 @@ public class SatelliteController extends Handler { return new ArrayList<>(); } synchronized (mSupportedSatelliteServicesLock) { if (mSatelliteServicesSupportedByCarriers.containsKey(subId)) { return new ArrayList<>(mSatelliteServicesSupportedByCarriers.get(subId).keySet()); } else { return new ArrayList<>(); } return mMergedPlmnListPerCarrier.get(subId, new ArrayList<>()).stream().toList(); } } Loading Loading @@ -2480,22 +2490,21 @@ public class SatelliteController extends Handler { } /** * Update the satellite EntitlementStatus and PlmnAllowedList after receiving the HTTP response * from the satellite entitlement server. * If the satellite service is enabled then trigger internal satellite enabled for carrier, * otherwise trigger internal satellite disabled for carrier. * To use the satellite service, update the EntitlementStatus and the PlmnAllowedList after * receiving the satellite configuration from the entitlement server. If satellite * entitlement is enabled, enable satellite for the carrier. Otherwise, disable satellite. * * @param subId subId * @param entitlementEnabled {@code true} Satellite service enabled * @param allowedPlmnList plmn allowed list to use the satellite service * @param callback callback for accept */ public void updateSatelliteEntitlementStatus(int subId, boolean satelliteEnabled, List<String> plmnAllowed, IIntegerConsumer callback) { public void onSatelliteEntitlementStatusUpdated(int subId, boolean entitlementEnabled, List<String> allowedPlmnList, @Nullable IIntegerConsumer callback) { if (!mFeatureFlags.carrierEnabledSatelliteFlag()) { return; } if (mCarrierSatelliteEnabled != satelliteEnabled) { logd("update the carrier satellite enabled to " + satelliteEnabled); mCarrierSatelliteEnabled = satelliteEnabled; } if (callback == null) { callback = new IIntegerConsumer.Stub() { @Override Loading @@ -2505,7 +2514,19 @@ public class SatelliteController extends Handler { }; } if (mCarrierSatelliteEnabled) { synchronized (mSupportedSatelliteServicesLock) { if (mSatelliteEntitlementStatusPerCarrier.get(subId, false) != entitlementEnabled) { logd("update the carrier satellite enabled to " + entitlementEnabled); mSatelliteEntitlementStatusPerCarrier.put(subId, entitlementEnabled); } mMergedPlmnListPerCarrier.remove(subId); mEntitlementPlmnListPerCarrier.put(subId, allowedPlmnList); updatePlmnListPerCarrier(subId); configureSatellitePlmnForCarrier(subId); // TODO b/322143408 store entitlement status in telephony db. if (mSatelliteEntitlementStatusPerCarrier.get(subId, false)) { removeSatelliteAttachRestrictionForCarrier(subId, SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT, callback); } else { Loading @@ -2513,6 +2534,7 @@ public class SatelliteController extends Handler { SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT, callback); } } } /** * If we have not successfully queried the satellite modem for its satellite service support, Loading Loading @@ -3021,13 +3043,8 @@ public class SatelliteController extends Handler { return; } synchronized (mSupportedSatelliteServicesLock) { List<String> carrierPlmnList; if (mSatelliteServicesSupportedByCarriers.containsKey(subId)) { carrierPlmnList = mSatelliteServicesSupportedByCarriers.get(subId).keySet().stream().toList(); } else { carrierPlmnList = new ArrayList<>(); } List<String> carrierPlmnList = mMergedPlmnListPerCarrier.get(subId, new ArrayList<>()).stream().toList(); int slotId = SubscriptionManager.getSlotIndex(subId); mSatelliteModemInterface.setSatellitePlmn(slotId, carrierPlmnList, SatelliteServiceUtils.mergeStrLists( Loading @@ -3050,6 +3067,7 @@ public class SatelliteController extends Handler { synchronized (mSupportedSatelliteServicesLock) { mSatelliteServicesSupportedByCarriers.clear(); mMergedPlmnListPerCarrier.clear(); int[] activeSubIds = mSubscriptionManagerService.getActiveSubIdList(true); if (activeSubIds != null) { for (int subId : activeSubIds) { Loading @@ -3062,10 +3080,37 @@ public class SatelliteController extends Handler { } } /** * If the entitlementPlmnList exist then used it. * Otherwise, If the carrierPlmnList exist then used it. */ private void updatePlmnListPerCarrier(int subId) { synchronized (mSupportedSatelliteServicesLock) { List<String> carrierPlmnList, entitlementPlmnList; entitlementPlmnList = mEntitlementPlmnListPerCarrier.get(subId, new ArrayList<>()).stream().toList(); if (!entitlementPlmnList.isEmpty()) { mMergedPlmnListPerCarrier.put(subId, entitlementPlmnList); logd("update it using entitlementPlmnList=" + entitlementPlmnList); return; } if (mSatelliteServicesSupportedByCarriers.containsKey(subId)) { carrierPlmnList = mSatelliteServicesSupportedByCarriers.get(subId).keySet().stream().toList(); } else { carrierPlmnList = new ArrayList<>(); } mMergedPlmnListPerCarrier.put(subId, carrierPlmnList); logd("update it using carrierPlmnList=" + carrierPlmnList); } } private void updateSupportedSatelliteServices(int subId) { synchronized (mSupportedSatelliteServicesLock) { mSatelliteServicesSupportedByCarriers.put( subId, readSupportedSatelliteServicesFromCarrierConfig(subId)); updatePlmnListPerCarrier(subId); } } Loading Loading @@ -3116,6 +3161,8 @@ public class SatelliteController extends Handler { } updateCarrierConfig(subId); // TODO b/322143408 read the telephony db to get the entitlementStatus and update the // restriction updateSupportedSatelliteServicesForActiveSubscriptions(); configureSatellitePlmnForCarrier(subId); Loading
tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java +211 −4 Original line number Diff line number Diff line Loading @@ -112,6 +112,8 @@ import android.telephony.satellite.SatelliteManager.SatelliteException; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.util.Pair; import android.util.SparseArray; import android.util.SparseBooleanArray; import com.android.internal.R; import com.android.internal.telephony.IIntegerConsumer; Loading Loading @@ -2612,12 +2614,14 @@ public class SatelliteControllerTest extends TelephonyTest { @Test public void testSatelliteCommunicationRestrictionForEntitlement() throws Exception { logd("testSatelliteCommunicationRestrictionForEntitlement"); when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(true); mCarrierConfigBundle.putBoolean(CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, true); replaceInstance(SatelliteController.class, "mCarrierSatelliteEnabled", mSatelliteControllerUT, false); SparseBooleanArray satelliteEnabledPerCarrier = new SparseBooleanArray(); replaceInstance(SatelliteController.class, "mSatelliteEntitlementStatusPerCarrier", mSatelliteControllerUT, satelliteEnabledPerCarrier); mIIntegerConsumerResults.clear(); reset(mMockSatelliteModemInterface); Loading @@ -2632,7 +2636,7 @@ public class SatelliteControllerTest extends TelephonyTest { // Verify call the requestSetSatelliteEnabledForCarrier to enable the satellite when // satellite service is enabled by entitlement server. mSatelliteControllerUT.updateSatelliteEntitlementStatus(SUB_ID, true, new ArrayList<>(), mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, true, new ArrayList<>(), mIIntegerConsumer); processAllMessages(); Loading @@ -2652,7 +2656,7 @@ public class SatelliteControllerTest extends TelephonyTest { doReturn(mIsSatelliteServiceSupported) .when(mMockSatelliteModemInterface).isSatelliteServiceSupported(); setUpResponseForRequestSetSatelliteEnabledForCarrier(false, SATELLITE_RESULT_SUCCESS); mSatelliteControllerUT.updateSatelliteEntitlementStatus(SUB_ID, false, new ArrayList<>(), mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, false, new ArrayList<>(), mIIntegerConsumer); processAllMessages(); Loading @@ -2662,6 +2666,209 @@ public class SatelliteControllerTest extends TelephonyTest { .requestSetSatelliteEnabledForCarrier(anyInt(), eq(false), any(Message.class)); } @Test public void testPassSatellitePlmnToModemAfterUpdateSatelliteEntitlementStatus() throws Exception { logd("testPassSatellitePlmnToModemAfterUpdateSatelliteEntitlementStatus"); when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(true); replaceInstance(SatelliteController.class, "mMergedPlmnListPerCarrier", mSatelliteControllerUT, new SparseArray<>()); List<String> overlayConfigPlmnList = new ArrayList<>(); replaceInstance(SatelliteController.class, "mSatellitePlmnListFromOverlayConfig", mSatelliteControllerUT, overlayConfigPlmnList); // If the PlmnListPerCarrier and the overlay config plmn list are empty verify passing to // the modem. List<String> entitlementPlmnList = new ArrayList<>(); mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, false, entitlementPlmnList, mIIntegerConsumer); List<String> plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier( SUB_ID); List<String> allSatellitePlmnList = SatelliteServiceUtils.mergeStrLists( plmnListPerCarrier, overlayConfigPlmnList); assertEquals(new ArrayList<>(), plmnListPerCarrier); assertEquals(new ArrayList<>(), allSatellitePlmnList); verify(mMockSatelliteModemInterface, times(1)).setSatellitePlmn(anyInt(), eq(plmnListPerCarrier), eq(allSatellitePlmnList), any(Message.class)); // If the PlmnListPerCarrier and the overlay config plmn list are exist verify passing // the modem. entitlementPlmnList = Arrays.stream(new String[]{"00101", "00102", "00103"}).toList(); overlayConfigPlmnList = Arrays.stream(new String[]{"00101", "00102", "00104"}).toList(); replaceInstance(SatelliteController.class, "mSatellitePlmnListFromOverlayConfig", mSatelliteControllerUT, overlayConfigPlmnList); mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, true, entitlementPlmnList, mIIntegerConsumer); plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier(SUB_ID); allSatellitePlmnList = SatelliteServiceUtils.mergeStrLists( plmnListPerCarrier, overlayConfigPlmnList); assertEquals(entitlementPlmnList, plmnListPerCarrier); verify(mMockSatelliteModemInterface, times(1)).setSatellitePlmn(anyInt(), eq(plmnListPerCarrier), eq(allSatellitePlmnList), any(Message.class)); // If the PlmnListPerCarrier and the overlay config plmn list are exist verify passing // the modem. reset(mMockSatelliteModemInterface); entitlementPlmnList = Arrays.stream(new String[]{"00101", "00102", "00103"}).toList(); Map<Integer, Map<String, Set<Integer>>> satelliteServicesSupportedByCarriers = new HashMap<>(); 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))); plmnAndService.put(carrierConfigPlmnList.get(1), new HashSet<>(Arrays.asList(3))); satelliteServicesSupportedByCarriers.put(SUB_ID, plmnAndService); replaceInstance(SatelliteController.class, "mSatelliteServicesSupportedByCarriers", mSatelliteControllerUT, satelliteServicesSupportedByCarriers); overlayConfigPlmnList = Arrays.stream(new String[]{"00101", "00102", "00104"}).toList(); replaceInstance(SatelliteController.class, "mSatellitePlmnListFromOverlayConfig", mSatelliteControllerUT, overlayConfigPlmnList); List<String> mergedPlmnList = entitlementPlmnList; mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, true, entitlementPlmnList, mIIntegerConsumer); plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier(SUB_ID); allSatellitePlmnList = SatelliteServiceUtils.mergeStrLists( plmnListPerCarrier, overlayConfigPlmnList); assertEquals(mergedPlmnList, plmnListPerCarrier); verify(mMockSatelliteModemInterface, times(1)).setSatellitePlmn(anyInt(), eq(plmnListPerCarrier), eq(allSatellitePlmnList), any(Message.class)); } @Test public void testUpdatePlmnListPerCarrier() throws Exception { logd("testUpdatePlmnListPerCarrier"); when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(true); replaceInstance(SatelliteController.class, "mMergedPlmnListPerCarrier", mSatelliteControllerUT, new SparseArray<>()); replaceInstance(SatelliteController.class, "mSatelliteServicesSupportedByCarriers", mSatelliteControllerUT, new HashMap<>()); SparseArray<List<String>> entitlementPlmnListPerCarrier = new SparseArray<>(); replaceInstance(SatelliteController.class, "mEntitlementPlmnListPerCarrier", mSatelliteControllerUT, entitlementPlmnListPerCarrier); // If the carrier config and the entitlement plmn list are empty, verify whether an empty // list is returned. mCarrierConfigBundle.putPersistableBundle(CarrierConfigManager .KEY_CARRIER_SUPPORTED_SATELLITE_SERVICES_PER_PROVIDER_BUNDLE, new PersistableBundle()); for (Pair<Executor, CarrierConfigManager.CarrierConfigChangeListener> pair : mCarrierConfigChangedListenerList) { pair.first.execute(() -> pair.second.onCarrierConfigChanged( /*slotIndex*/ 0, /*subId*/ SUB_ID, /*carrierId*/ 0, /*specificCarrierId*/ 0) ); } processAllMessages(); List<String> plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier( SUB_ID); assertEquals(new ArrayList<>(), plmnListPerCarrier); // If the carrier config list is empty and the entitlement plmn list is exists, verify // whether the entitlement list is returned. entitlementPlmnListPerCarrier.clear(); List<String> entitlementPlmnList = Arrays.asList("00101", "00102", "00104"); entitlementPlmnListPerCarrier.put(SUB_ID, entitlementPlmnList); List<String> expectedPlmnListPerCarrier = entitlementPlmnList; for (Pair<Executor, CarrierConfigManager.CarrierConfigChangeListener> pair : mCarrierConfigChangedListenerList) { pair.first.execute(() -> pair.second.onCarrierConfigChanged( /*slotIndex*/ 0, /*subId*/ SUB_ID, /*carrierId*/ 0, /*specificCarrierId*/ 0) ); } processAllMessages(); plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier(SUB_ID); assertEquals(expectedPlmnListPerCarrier, plmnListPerCarrier); // If the carrier config list is exists and the entitlement plmn list is empty, verify // whether the carrier config list is returned. entitlementPlmnListPerCarrier.clear(); entitlementPlmnList = new ArrayList<>(); entitlementPlmnListPerCarrier.put(SUB_ID, entitlementPlmnList); mCarrierConfigBundle.putBoolean(CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, true); PersistableBundle carrierSupportedSatelliteServicesPerProvider = new PersistableBundle(); List<String> carrierConfigPlmnList = Arrays.asList("00102", "00103", "00105"); carrierSupportedSatelliteServicesPerProvider.putIntArray( carrierConfigPlmnList.get(0), new int[]{2}); carrierSupportedSatelliteServicesPerProvider.putIntArray( carrierConfigPlmnList.get(1), new int[]{1, 3}); carrierSupportedSatelliteServicesPerProvider.putIntArray( carrierConfigPlmnList.get(2), new int[]{2}); mCarrierConfigBundle.putPersistableBundle(CarrierConfigManager .KEY_CARRIER_SUPPORTED_SATELLITE_SERVICES_PER_PROVIDER_BUNDLE, carrierSupportedSatelliteServicesPerProvider); for (Pair<Executor, CarrierConfigManager.CarrierConfigChangeListener> pair : mCarrierConfigChangedListenerList) { pair.first.execute(() -> pair.second.onCarrierConfigChanged( /*slotIndex*/ 0, /*subId*/ SUB_ID, /*carrierId*/ 0, /*specificCarrierId*/ 0) ); } processAllMessages(); expectedPlmnListPerCarrier = carrierConfigPlmnList; plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier(SUB_ID); assertEquals(expectedPlmnListPerCarrier.stream().sorted().toList(), plmnListPerCarrier.stream().sorted().toList()); // If the carrier config and the entitlement plmn list are exist, verify whether the // entitlement list is returned. entitlementPlmnList = Arrays.asList("00101", "00102", "00104"); entitlementPlmnListPerCarrier.put(SUB_ID, entitlementPlmnList); for (Pair<Executor, CarrierConfigManager.CarrierConfigChangeListener> pair : mCarrierConfigChangedListenerList) { pair.first.execute(() -> pair.second.onCarrierConfigChanged( /*slotIndex*/ 0, /*subId*/ SUB_ID, /*carrierId*/ 0, /*specificCarrierId*/ 0) ); } processAllMessages(); expectedPlmnListPerCarrier = entitlementPlmnList; plmnListPerCarrier = mSatelliteControllerUT.getAllSatellitePlmnsForCarrier( SUB_ID); assertEquals(expectedPlmnListPerCarrier.stream().sorted().toList(), plmnListPerCarrier.stream().sorted().toList()); } @Test public void testEntitlementStatus() throws Exception { logd("testEntitlementStatus"); when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(true); SparseBooleanArray satelliteEnabledPerCarrier = new SparseBooleanArray(); replaceInstance(SatelliteController.class, "mSatelliteEntitlementStatusPerCarrier", mSatelliteControllerUT, satelliteEnabledPerCarrier); // Change SUB_ID's EntitlementStatus to true mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, true, new ArrayList<>(), mIIntegerConsumer); assertEquals(true, satelliteEnabledPerCarrier.get(SUB_ID)); assertEquals(false, satelliteEnabledPerCarrier.get(SUB_ID1)); // Change SUB_ID1's EntitlementStatus to true mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID1, true, new ArrayList<>(), mIIntegerConsumer); assertEquals(true, satelliteEnabledPerCarrier.get(SUB_ID)); assertEquals(true, satelliteEnabledPerCarrier.get(SUB_ID1)); // Change SUB_ID's EntitlementStatus to false mSatelliteControllerUT.onSatelliteEntitlementStatusUpdated(SUB_ID, false, new ArrayList<>(), mIIntegerConsumer); assertEquals(false, satelliteEnabledPerCarrier.get(SUB_ID)); assertEquals(true, satelliteEnabledPerCarrier.get(SUB_ID1)); } private void resetSatelliteControllerUTEnabledState() { logd("resetSatelliteControllerUTEnabledState"); setUpResponseForRequestIsSatelliteSupported(false, SATELLITE_RESULT_RADIO_NOT_AVAILABLE); Loading