Loading src/java/com/android/internal/telephony/satellite/SatelliteController.java +54 −27 Original line number Diff line number Diff line Loading @@ -480,14 +480,17 @@ public class SatelliteController extends Handler { private Map<String, Boolean> mProvisionedSubscriberId = new HashMap<>(); // key : subscriberId, value : subId @GuardedBy("mSatelliteTokenProvisionedLock") private Map<String, Integer> mSubscriberIdPerSub = new HashMap<>(); @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) protected Map<String, Integer> mSubscriberIdPerSub = new HashMap<>(); // key : priority, low value is high, value : List<SubscriptionInfo> @GuardedBy("mSatelliteTokenProvisionedLock") private Map<Integer, List<SubscriptionInfo>> mSubsInfoListPerPriority = new HashMap<>(); @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) protected Map<Integer, List<SubscriptionInfo>> mSubsInfoListPerPriority = new HashMap<>(); // The last ICC ID that framework configured to modem. @GuardedBy("mSatelliteTokenProvisionedLock") private String mLastConfiguredIccId; @NonNull private final Object mSatelliteTokenProvisionedLock = new Object(); @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) @NonNull protected final Object mSatelliteTokenProvisionedLock = new Object(); private long mWaitTimeForSatelliteEnablingResponse; private long mDemoPointingAlignedDurationMillis; private long mDemoPointingNotAlignedDurationMillis; Loading Loading @@ -523,6 +526,7 @@ public class SatelliteController extends Handler { private final Object mIsWifiConnectedLock = new Object(); @GuardedBy("mIsWifiConnectedLock") private boolean mIsWifiConnected = false; private boolean mHasSentBroadcast = false; private BroadcastReceiver mDefaultSmsSubscriptionChangedBroadcastReceiver = new BroadcastReceiver() { @Override Loading Loading @@ -5674,19 +5678,23 @@ public class SatelliteController extends Handler { * 3. Among active carrier eSOS profiles user selected(default SMS SIM) eSOS profile will be * the highest priority. */ private void evaluateESOSProfilesPrioritization() { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) protected void evaluateESOSProfilesPrioritization() { if (!mFeatureFlags.carrierRoamingNbIotNtn()) { plogd("evaluateESOSProfilesPrioritization: Flag CarrierRoamingNbIotNtn is disabled"); return; } boolean isChanged = false; List<SubscriptionInfo> allSubInfos = mSubscriptionManagerService.getAllSubInfoList( mContext.getOpPackageName(), mContext.getAttributionTag()); // Key : priority - lower value has higher priority; Value : List<SubscriptionInfo> Map<Integer, List<SubscriptionInfo>> newSubsInfoListPerPriority = new HashMap<>(); synchronized (mSatelliteTokenProvisionedLock) { for (SubscriptionInfo info : allSubInfos) { int subId = info.getSubscriptionId(); boolean isActive = info.isActive(); boolean isDefaultSmsSubId = mSubscriptionManagerService.getDefaultSmsSubId() == subId; boolean isDefaultSmsSubId = mSubscriptionManagerService.getDefaultSmsSubId() == subId; boolean isNtnOnly = info.isOnlyNonTerrestrialNetwork(); boolean isESOSSupported = info.isSatelliteESOSSupported(); if (!isNtnOnly && !isESOSSupported) { Loading @@ -5703,24 +5711,42 @@ public class SatelliteController extends Handler { plogw("evaluateESOSProfilesPrioritization: Got -1 keyPriority for subId=" + info.getSubscriptionId()); } Pair<String, Integer> subscriberIdPair = getSubscriberIdAndType(info); String newSubscriberId = subscriberIdPair.first; Optional<String> oldSubscriberId = mSubscriberIdPerSub.entrySet().stream() .filter(entry -> entry.getValue().equals(subId)) .map(Map.Entry::getKey).findFirst(); if (oldSubscriberId.isPresent() && !newSubscriberId.equals(oldSubscriberId.get())) { mSubscriberIdPerSub.remove(oldSubscriberId.get()); mProvisionedSubscriberId.remove(oldSubscriberId.get()); logd("Old phone number is removed: id = " + subId); isChanged = true; } } } if (newSubsInfoListPerPriority.size() == 0) { if (!mHasSentBroadcast && newSubsInfoListPerPriority.size() == 0) { logd("evaluateESOSProfilesPrioritization: no satellite subscription available"); return; } // If priority has changed, send broadcast for provisioned ESOS subs IDs synchronized (mSatelliteTokenProvisionedLock) { if (isPriorityChanged(mSubsInfoListPerPriority, newSubsInfoListPerPriority)) { if (isPriorityChanged(mSubsInfoListPerPriority, newSubsInfoListPerPriority) || isChanged) { mSubsInfoListPerPriority = newSubsInfoListPerPriority; sendBroadCastForProvisionedESOSSubs(); mHasSentBroadcast = true; } } } // The subscriberId for ntnOnly SIMs is the Iccid, whereas for ESOS supported SIMs, the // subscriberId is the Imsi prefix 6 digit + phone number. /** * The subscriberId for ntnOnly SIMs is the Iccid, whereas for ESOS supported SIMs, * the subscriberId is the Imsi prefix 6 digit + phone number. * */ private Pair<String, Integer> getSubscriberIdAndType(SubscriptionInfo info) { String subscriberId = ""; @SatelliteSubscriberInfo.SubscriberIdType int subscriberIdType = Loading Loading @@ -5796,7 +5822,8 @@ public class SatelliteController extends Handler { logd("sendBroadCaseToProvisionedESOSSubs" + intent); } private String getStringFromOverlayConfig(int resourceId) { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) protected String getStringFromOverlayConfig(int resourceId) { String name; try { name = mContext.getResources().getString(resourceId); Loading tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java +152 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import static com.android.internal.telephony.satellite.SatelliteController.SATEL import static com.android.internal.telephony.satellite.SatelliteController.SATELLITE_MODE_ENABLED_TRUE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; Loading Loading @@ -101,6 +102,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Resources; import android.os.AsyncResult; Loading Loading @@ -174,6 +176,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.Executor; import java.util.concurrent.Semaphore; Loading Loading @@ -4398,6 +4401,135 @@ public class SatelliteControllerTest extends TelephonyTest { return list; } @Test public void testCheckForSubscriberIdChange_noChanged() { when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true); String imsi = "012345"; String oldMsisdn = "1234567890"; String newMsisdn = "1234567890"; List<SubscriptionInfo> allSubInfos = new ArrayList<>(); Optional<String> getSubscriberId; SubscriptionInfo mMockSubscriptionInfo = Mockito.mock(SubscriptionInfo.class); SubscriptionInfoInternal subInfoInternal = new SubscriptionInfoInternal.Builder().setCarrierId(0) .setImsi(imsi).build(); when(mMockSubscriptionInfo.getSubscriptionId()).thenReturn(SUB_ID); allSubInfos.add(mMockSubscriptionInfo); doReturn(" ").when(mContext).getOpPackageName(); doReturn(" ").when(mContext).getAttributionTag(); when(mMockSubscriptionManagerService.getAllSubInfoList(anyString(), anyString())) .thenReturn(allSubInfos); when(mMockSubscriptionInfo.isSatelliteESOSSupported()).thenReturn(true); when(mMockSubscriptionManagerService.getSubscriptionInfoInternal(SUB_ID)) .thenReturn(subInfoInternal); try { Field field = SatelliteController.class.getDeclaredField("mInjectSubscriptionManager"); field.setAccessible(true); field.set(mSatelliteControllerUT, mSubscriptionManager); } catch (Exception e) { loge("Exception InjectSubscriptionManager e: " + e); } when(mSubscriptionManager.getPhoneNumber(SUB_ID)).thenReturn(newMsisdn); when(mMockSubscriptionInfo.isOnlyNonTerrestrialNetwork()).thenReturn(false); mSatelliteControllerUT.subscriberIdPerSub().put(imsi + oldMsisdn, SUB_ID); getSubscriberId = mSatelliteControllerUT.subscriberIdPerSub().entrySet().stream() .filter(entry -> entry.getValue().equals(SUB_ID)) .map(Map.Entry::getKey).findFirst(); assertEquals(imsi + newMsisdn, getSubscriberId.get()); setComponentName(); mSatelliteControllerUT.subsInfoListPerPriority().computeIfAbsent( getKeyPriority(mMockSubscriptionInfo), k -> new ArrayList<>()) .add(mMockSubscriptionInfo); mSatelliteControllerUT.evaluateESOSProfilesPrioritizationTest(); // Verify that broadcast has not been sent. verify(mContext, times(0)).sendBroadcast(any(Intent.class)); } @Test public void testCheckForSubscriberIdChange_changed() { when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true); List<SubscriptionInfo> allSubInfos = new ArrayList<>(); String imsi = "012345"; String oldMsisdn = "1234567890"; String newMsisdn = "4567891234"; Optional<String> getSubscriberId; SubscriptionInfo mMockSubscriptionInfo = Mockito.mock(SubscriptionInfo.class); SubscriptionInfoInternal subInfoInternal = new SubscriptionInfoInternal.Builder().setCarrierId(0).setImsi(imsi).build(); when(mMockSubscriptionInfo.getSubscriptionId()).thenReturn(SUB_ID); allSubInfos.add(mMockSubscriptionInfo); doReturn(" ").when(mContext).getOpPackageName(); doReturn(" ").when(mContext).getAttributionTag(); when(mMockSubscriptionManagerService.getAllSubInfoList(anyString(), anyString())) .thenReturn(allSubInfos); when(mMockSubscriptionInfo.isSatelliteESOSSupported()).thenReturn(true); when(mMockSubscriptionManagerService.getSubscriptionInfoInternal(SUB_ID)) .thenReturn(subInfoInternal); try { Field field = SatelliteController.class.getDeclaredField("mInjectSubscriptionManager"); field.setAccessible(true); field.set(mSatelliteControllerUT, mSubscriptionManager); } catch (Exception e) { loge("Exception InjectSubscriptionManager e: " + e); } when(mSubscriptionManager.getPhoneNumber(SUB_ID)).thenReturn(newMsisdn); when(mMockSubscriptionInfo.isOnlyNonTerrestrialNetwork()).thenReturn(false); mSatelliteControllerUT.subscriberIdPerSub().put(imsi + oldMsisdn, SUB_ID); getSubscriberId = mSatelliteControllerUT.subscriberIdPerSub().entrySet().stream() .filter(entry -> entry.getValue().equals(SUB_ID)) .map(Map.Entry::getKey).findFirst(); assertNotEquals(imsi + newMsisdn, getSubscriberId.get()); setComponentName(); mSatelliteControllerUT.subsInfoListPerPriority().computeIfAbsent( getKeyPriority(mMockSubscriptionInfo), k -> new ArrayList<>()) .add(mMockSubscriptionInfo); mSatelliteControllerUT.evaluateESOSProfilesPrioritizationTest(); // Verify that broadcast has been sent. verify(mContext, times(1)).sendBroadcast(any(Intent.class)); } private void setComponentName() { when(mSatelliteControllerUT.getStringFromOverlayConfigTest( R.string.config_satellite_gateway_service_package)) .thenReturn("com.example.package"); when(mSatelliteControllerUT.getStringFromOverlayConfigTest( R.string.config_satellite_carrier_roaming_esos_provisioned_class)) .thenReturn("com.example.class"); when(mSatelliteControllerUT.getStringFromOverlayConfigTest( R.string.config_satellite_carrier_roaming_esos_provisioned_intent_action)) .thenReturn("com.example.action"); } private int getKeyPriority(SubscriptionInfo mMockSubscriptionInfo) { boolean isActive = mMockSubscriptionInfo.isActive(); boolean isNtnOnly = mMockSubscriptionInfo.isOnlyNonTerrestrialNetwork(); boolean isESOSSupported = mMockSubscriptionInfo.isSatelliteESOSSupported(); int keyPriority; if (isESOSSupported && isActive) { keyPriority = 1; } else if (isNtnOnly) { keyPriority = 2; } else if (isESOSSupported) { keyPriority = 3; } else { keyPriority = -1; } return keyPriority; } private void resetSatelliteControllerUTEnabledState() { logd("resetSatelliteControllerUTEnabledState"); setUpResponseForRequestIsSatelliteSupported(false, SATELLITE_RESULT_RADIO_NOT_AVAILABLE); Loading Loading @@ -5182,5 +5314,25 @@ public class SatelliteControllerTest extends TelephonyTest { public boolean isWaitForCellularModemOffTimerStarted() { return hasMessages(EVENT_WAIT_FOR_CELLULAR_MODEM_OFF_TIMED_OUT); } public Map<String, Integer> subscriberIdPerSub() { synchronized (mSatelliteTokenProvisionedLock) { return mSubscriberIdPerSub; } } public Map<Integer, List<SubscriptionInfo>> subsInfoListPerPriority() { synchronized (mSatelliteTokenProvisionedLock) { return mSubsInfoListPerPriority; } } public void evaluateESOSProfilesPrioritizationTest() { evaluateESOSProfilesPrioritization(); } public String getStringFromOverlayConfigTest(int resourceId) { return getStringFromOverlayConfig(resourceId); } } } Loading
src/java/com/android/internal/telephony/satellite/SatelliteController.java +54 −27 Original line number Diff line number Diff line Loading @@ -480,14 +480,17 @@ public class SatelliteController extends Handler { private Map<String, Boolean> mProvisionedSubscriberId = new HashMap<>(); // key : subscriberId, value : subId @GuardedBy("mSatelliteTokenProvisionedLock") private Map<String, Integer> mSubscriberIdPerSub = new HashMap<>(); @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) protected Map<String, Integer> mSubscriberIdPerSub = new HashMap<>(); // key : priority, low value is high, value : List<SubscriptionInfo> @GuardedBy("mSatelliteTokenProvisionedLock") private Map<Integer, List<SubscriptionInfo>> mSubsInfoListPerPriority = new HashMap<>(); @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) protected Map<Integer, List<SubscriptionInfo>> mSubsInfoListPerPriority = new HashMap<>(); // The last ICC ID that framework configured to modem. @GuardedBy("mSatelliteTokenProvisionedLock") private String mLastConfiguredIccId; @NonNull private final Object mSatelliteTokenProvisionedLock = new Object(); @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) @NonNull protected final Object mSatelliteTokenProvisionedLock = new Object(); private long mWaitTimeForSatelliteEnablingResponse; private long mDemoPointingAlignedDurationMillis; private long mDemoPointingNotAlignedDurationMillis; Loading Loading @@ -523,6 +526,7 @@ public class SatelliteController extends Handler { private final Object mIsWifiConnectedLock = new Object(); @GuardedBy("mIsWifiConnectedLock") private boolean mIsWifiConnected = false; private boolean mHasSentBroadcast = false; private BroadcastReceiver mDefaultSmsSubscriptionChangedBroadcastReceiver = new BroadcastReceiver() { @Override Loading Loading @@ -5674,19 +5678,23 @@ public class SatelliteController extends Handler { * 3. Among active carrier eSOS profiles user selected(default SMS SIM) eSOS profile will be * the highest priority. */ private void evaluateESOSProfilesPrioritization() { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) protected void evaluateESOSProfilesPrioritization() { if (!mFeatureFlags.carrierRoamingNbIotNtn()) { plogd("evaluateESOSProfilesPrioritization: Flag CarrierRoamingNbIotNtn is disabled"); return; } boolean isChanged = false; List<SubscriptionInfo> allSubInfos = mSubscriptionManagerService.getAllSubInfoList( mContext.getOpPackageName(), mContext.getAttributionTag()); // Key : priority - lower value has higher priority; Value : List<SubscriptionInfo> Map<Integer, List<SubscriptionInfo>> newSubsInfoListPerPriority = new HashMap<>(); synchronized (mSatelliteTokenProvisionedLock) { for (SubscriptionInfo info : allSubInfos) { int subId = info.getSubscriptionId(); boolean isActive = info.isActive(); boolean isDefaultSmsSubId = mSubscriptionManagerService.getDefaultSmsSubId() == subId; boolean isDefaultSmsSubId = mSubscriptionManagerService.getDefaultSmsSubId() == subId; boolean isNtnOnly = info.isOnlyNonTerrestrialNetwork(); boolean isESOSSupported = info.isSatelliteESOSSupported(); if (!isNtnOnly && !isESOSSupported) { Loading @@ -5703,24 +5711,42 @@ public class SatelliteController extends Handler { plogw("evaluateESOSProfilesPrioritization: Got -1 keyPriority for subId=" + info.getSubscriptionId()); } Pair<String, Integer> subscriberIdPair = getSubscriberIdAndType(info); String newSubscriberId = subscriberIdPair.first; Optional<String> oldSubscriberId = mSubscriberIdPerSub.entrySet().stream() .filter(entry -> entry.getValue().equals(subId)) .map(Map.Entry::getKey).findFirst(); if (oldSubscriberId.isPresent() && !newSubscriberId.equals(oldSubscriberId.get())) { mSubscriberIdPerSub.remove(oldSubscriberId.get()); mProvisionedSubscriberId.remove(oldSubscriberId.get()); logd("Old phone number is removed: id = " + subId); isChanged = true; } } } if (newSubsInfoListPerPriority.size() == 0) { if (!mHasSentBroadcast && newSubsInfoListPerPriority.size() == 0) { logd("evaluateESOSProfilesPrioritization: no satellite subscription available"); return; } // If priority has changed, send broadcast for provisioned ESOS subs IDs synchronized (mSatelliteTokenProvisionedLock) { if (isPriorityChanged(mSubsInfoListPerPriority, newSubsInfoListPerPriority)) { if (isPriorityChanged(mSubsInfoListPerPriority, newSubsInfoListPerPriority) || isChanged) { mSubsInfoListPerPriority = newSubsInfoListPerPriority; sendBroadCastForProvisionedESOSSubs(); mHasSentBroadcast = true; } } } // The subscriberId for ntnOnly SIMs is the Iccid, whereas for ESOS supported SIMs, the // subscriberId is the Imsi prefix 6 digit + phone number. /** * The subscriberId for ntnOnly SIMs is the Iccid, whereas for ESOS supported SIMs, * the subscriberId is the Imsi prefix 6 digit + phone number. * */ private Pair<String, Integer> getSubscriberIdAndType(SubscriptionInfo info) { String subscriberId = ""; @SatelliteSubscriberInfo.SubscriberIdType int subscriberIdType = Loading Loading @@ -5796,7 +5822,8 @@ public class SatelliteController extends Handler { logd("sendBroadCaseToProvisionedESOSSubs" + intent); } private String getStringFromOverlayConfig(int resourceId) { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) protected String getStringFromOverlayConfig(int resourceId) { String name; try { name = mContext.getResources().getString(resourceId); Loading
tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java +152 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import static com.android.internal.telephony.satellite.SatelliteController.SATEL import static com.android.internal.telephony.satellite.SatelliteController.SATELLITE_MODE_ENABLED_TRUE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; Loading Loading @@ -101,6 +102,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Resources; import android.os.AsyncResult; Loading Loading @@ -174,6 +176,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.Executor; import java.util.concurrent.Semaphore; Loading Loading @@ -4398,6 +4401,135 @@ public class SatelliteControllerTest extends TelephonyTest { return list; } @Test public void testCheckForSubscriberIdChange_noChanged() { when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true); String imsi = "012345"; String oldMsisdn = "1234567890"; String newMsisdn = "1234567890"; List<SubscriptionInfo> allSubInfos = new ArrayList<>(); Optional<String> getSubscriberId; SubscriptionInfo mMockSubscriptionInfo = Mockito.mock(SubscriptionInfo.class); SubscriptionInfoInternal subInfoInternal = new SubscriptionInfoInternal.Builder().setCarrierId(0) .setImsi(imsi).build(); when(mMockSubscriptionInfo.getSubscriptionId()).thenReturn(SUB_ID); allSubInfos.add(mMockSubscriptionInfo); doReturn(" ").when(mContext).getOpPackageName(); doReturn(" ").when(mContext).getAttributionTag(); when(mMockSubscriptionManagerService.getAllSubInfoList(anyString(), anyString())) .thenReturn(allSubInfos); when(mMockSubscriptionInfo.isSatelliteESOSSupported()).thenReturn(true); when(mMockSubscriptionManagerService.getSubscriptionInfoInternal(SUB_ID)) .thenReturn(subInfoInternal); try { Field field = SatelliteController.class.getDeclaredField("mInjectSubscriptionManager"); field.setAccessible(true); field.set(mSatelliteControllerUT, mSubscriptionManager); } catch (Exception e) { loge("Exception InjectSubscriptionManager e: " + e); } when(mSubscriptionManager.getPhoneNumber(SUB_ID)).thenReturn(newMsisdn); when(mMockSubscriptionInfo.isOnlyNonTerrestrialNetwork()).thenReturn(false); mSatelliteControllerUT.subscriberIdPerSub().put(imsi + oldMsisdn, SUB_ID); getSubscriberId = mSatelliteControllerUT.subscriberIdPerSub().entrySet().stream() .filter(entry -> entry.getValue().equals(SUB_ID)) .map(Map.Entry::getKey).findFirst(); assertEquals(imsi + newMsisdn, getSubscriberId.get()); setComponentName(); mSatelliteControllerUT.subsInfoListPerPriority().computeIfAbsent( getKeyPriority(mMockSubscriptionInfo), k -> new ArrayList<>()) .add(mMockSubscriptionInfo); mSatelliteControllerUT.evaluateESOSProfilesPrioritizationTest(); // Verify that broadcast has not been sent. verify(mContext, times(0)).sendBroadcast(any(Intent.class)); } @Test public void testCheckForSubscriberIdChange_changed() { when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true); List<SubscriptionInfo> allSubInfos = new ArrayList<>(); String imsi = "012345"; String oldMsisdn = "1234567890"; String newMsisdn = "4567891234"; Optional<String> getSubscriberId; SubscriptionInfo mMockSubscriptionInfo = Mockito.mock(SubscriptionInfo.class); SubscriptionInfoInternal subInfoInternal = new SubscriptionInfoInternal.Builder().setCarrierId(0).setImsi(imsi).build(); when(mMockSubscriptionInfo.getSubscriptionId()).thenReturn(SUB_ID); allSubInfos.add(mMockSubscriptionInfo); doReturn(" ").when(mContext).getOpPackageName(); doReturn(" ").when(mContext).getAttributionTag(); when(mMockSubscriptionManagerService.getAllSubInfoList(anyString(), anyString())) .thenReturn(allSubInfos); when(mMockSubscriptionInfo.isSatelliteESOSSupported()).thenReturn(true); when(mMockSubscriptionManagerService.getSubscriptionInfoInternal(SUB_ID)) .thenReturn(subInfoInternal); try { Field field = SatelliteController.class.getDeclaredField("mInjectSubscriptionManager"); field.setAccessible(true); field.set(mSatelliteControllerUT, mSubscriptionManager); } catch (Exception e) { loge("Exception InjectSubscriptionManager e: " + e); } when(mSubscriptionManager.getPhoneNumber(SUB_ID)).thenReturn(newMsisdn); when(mMockSubscriptionInfo.isOnlyNonTerrestrialNetwork()).thenReturn(false); mSatelliteControllerUT.subscriberIdPerSub().put(imsi + oldMsisdn, SUB_ID); getSubscriberId = mSatelliteControllerUT.subscriberIdPerSub().entrySet().stream() .filter(entry -> entry.getValue().equals(SUB_ID)) .map(Map.Entry::getKey).findFirst(); assertNotEquals(imsi + newMsisdn, getSubscriberId.get()); setComponentName(); mSatelliteControllerUT.subsInfoListPerPriority().computeIfAbsent( getKeyPriority(mMockSubscriptionInfo), k -> new ArrayList<>()) .add(mMockSubscriptionInfo); mSatelliteControllerUT.evaluateESOSProfilesPrioritizationTest(); // Verify that broadcast has been sent. verify(mContext, times(1)).sendBroadcast(any(Intent.class)); } private void setComponentName() { when(mSatelliteControllerUT.getStringFromOverlayConfigTest( R.string.config_satellite_gateway_service_package)) .thenReturn("com.example.package"); when(mSatelliteControllerUT.getStringFromOverlayConfigTest( R.string.config_satellite_carrier_roaming_esos_provisioned_class)) .thenReturn("com.example.class"); when(mSatelliteControllerUT.getStringFromOverlayConfigTest( R.string.config_satellite_carrier_roaming_esos_provisioned_intent_action)) .thenReturn("com.example.action"); } private int getKeyPriority(SubscriptionInfo mMockSubscriptionInfo) { boolean isActive = mMockSubscriptionInfo.isActive(); boolean isNtnOnly = mMockSubscriptionInfo.isOnlyNonTerrestrialNetwork(); boolean isESOSSupported = mMockSubscriptionInfo.isSatelliteESOSSupported(); int keyPriority; if (isESOSSupported && isActive) { keyPriority = 1; } else if (isNtnOnly) { keyPriority = 2; } else if (isESOSSupported) { keyPriority = 3; } else { keyPriority = -1; } return keyPriority; } private void resetSatelliteControllerUTEnabledState() { logd("resetSatelliteControllerUTEnabledState"); setUpResponseForRequestIsSatelliteSupported(false, SATELLITE_RESULT_RADIO_NOT_AVAILABLE); Loading Loading @@ -5182,5 +5314,25 @@ public class SatelliteControllerTest extends TelephonyTest { public boolean isWaitForCellularModemOffTimerStarted() { return hasMessages(EVENT_WAIT_FOR_CELLULAR_MODEM_OFF_TIMED_OUT); } public Map<String, Integer> subscriberIdPerSub() { synchronized (mSatelliteTokenProvisionedLock) { return mSubscriberIdPerSub; } } public Map<Integer, List<SubscriptionInfo>> subsInfoListPerPriority() { synchronized (mSatelliteTokenProvisionedLock) { return mSubsInfoListPerPriority; } } public void evaluateESOSProfilesPrioritizationTest() { evaluateESOSProfilesPrioritization(); } public String getStringFromOverlayConfigTest(int resourceId) { return getStringFromOverlayConfig(resourceId); } } }