diff options
author | 2025-05-06 16:27:15 +0000 | |
---|---|---|
committer | 2025-05-07 13:46:02 -0700 | |
commit | 0a93c66b9d3d6337d7ed99c4cfd29ebe9a5bf850 (patch) | |
tree | 29629a89f180adf16860dc35f114a464b257c3ee | |
parent | 6f7e004afc19bcc268f862140f755f53c90da8af (diff) |
Use all satellite plmn list in isSatellitePlmn()
Bug: 415139661
Test: atest SatelliteControllerTest SatelliteSOSMessageRecommenderTest
Flag: EXEMPT bugfix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:6ae905b27f1c0647d1aca13431a3cbce994782f4)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:c5b6966d60ceae44a74e31f7bf2c24909daad915)
Merged-In: Ied17b1004e0254ce99c93251061f4617c3f06526
Change-Id: Ied17b1004e0254ce99c93251061f4617c3f06526
5 files changed, 56 insertions, 13 deletions
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteController.java b/src/java/com/android/internal/telephony/satellite/SatelliteController.java index a39ba91bda..76897630fc 100644 --- a/src/java/com/android/internal/telephony/satellite/SatelliteController.java +++ b/src/java/com/android/internal/telephony/satellite/SatelliteController.java @@ -365,6 +365,7 @@ public class SatelliteController extends Handler { private boolean mDisableNFCOnSatelliteEnabled = false; private boolean mDisableUWBOnSatelliteEnabled = false; private boolean mDisableWifiOnSatelliteEnabled = false; + private AtomicBoolean mIgnorePlmnListFromStorage = new AtomicBoolean(false); private final Object mSatelliteEnabledRequestLock = new Object(); /* This variable is used to store the first enable request that framework has received in the @@ -5421,7 +5422,8 @@ public class SatelliteController extends Handler { obtainMessage(EVENT_SET_SATELLITE_PLMN_INFO_DONE)); } - private Set<String> getAllPlmnSet() { + @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) + protected Set<String> getAllPlmnSet() { Set<String> allPlmnSetFromSubInfo = new HashSet<>(); int[] activeSubIdArray = mSubscriptionManagerService.getActiveSubIdList(true); for (int activeSubId : activeSubIdArray) { @@ -5430,6 +5432,12 @@ public class SatelliteController extends Handler { } allPlmnSetFromSubInfo.addAll(mSatellitePlmnListFromOverlayConfig); + if (mIgnorePlmnListFromStorage.get()) { + // Do not use PLMN list from storage + plogd("getAllPlmnList: allPlmnSetFromSubInfo=" + allPlmnSetFromSubInfo); + return allPlmnSetFromSubInfo; + } + Set<String> allPlmnListFromStorage = getCarrierRoamingNtnAllSatellitePlmnSetFromStorage(); if (!allPlmnListFromStorage.containsAll(allPlmnSetFromSubInfo)) { allPlmnListFromStorage.addAll(allPlmnSetFromSubInfo); @@ -9322,4 +9330,17 @@ public class SatelliteController extends Handler { return getSatelliteDataServicePolicyForPlmn(subId, ""); } + + /** + * This API can be used by only CTS to make the function {@link #getAllPlmnSet()} to exclude the + * PLMN list from storage from the returned result. + * + * @param enabled Whether to enable boolean config. + * @return {@code true} if the value is set successfully, {@code false} otherwise. + */ + public boolean setSatelliteIgnorePlmnListFromStorage(boolean enabled) { + plogd("setSatelliteIgnorePlmnListFromStorage - " + enabled); + mIgnorePlmnListFromStorage.set(enabled); + return true; + } } diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteServiceUtils.java b/src/java/com/android/internal/telephony/satellite/SatelliteServiceUtils.java index a6581398e0..fd47c16ee1 100644 --- a/src/java/com/android/internal/telephony/satellite/SatelliteServiceUtils.java +++ b/src/java/com/android/internal/telephony/satellite/SatelliteServiceUtils.java @@ -60,6 +60,7 @@ import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.subscription.SubscriptionManagerService; import com.android.internal.telephony.util.TelephonyUtils; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -556,8 +557,8 @@ public class SatelliteServiceUtils { /** Check whether device is connected to satellite PLMN */ public static boolean isSatellitePlmn(int subId, @NonNull ServiceState serviceState) { - List<String> satellitePlmnList = - SatelliteController.getInstance().getSatellitePlmnsForCarrier(subId); + List<String> satellitePlmnList = new ArrayList<>( + SatelliteController.getInstance().getAllPlmnSet()); if (satellitePlmnList.isEmpty()) { logd("isSatellitePlmn: satellitePlmnList is empty"); return false; @@ -567,12 +568,12 @@ public class SatelliteServiceUtils { serviceState.getNetworkRegistrationInfoListForTransportType( AccessNetworkConstants.TRANSPORT_TYPE_WWAN)) { String registeredPlmn = nri.getRegisteredPlmn(); - if (TextUtils.isEmpty(registeredPlmn)) { - logd("isSatellitePlmn: registeredPlmn is empty"); + String mccmnc = getMccMnc(nri); + if (TextUtils.isEmpty(registeredPlmn) && TextUtils.isEmpty(mccmnc)) { + logd("isSatellitePlmn: registeredPlmn and cell plmn are empty"); continue; } - String mccmnc = getMccMnc(nri); for (String satellitePlmn : satellitePlmnList) { if (TextUtils.equals(satellitePlmn, registeredPlmn) || TextUtils.equals(satellitePlmn, mccmnc)) { diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java index 60cd83bcd9..7bdb3d2372 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java @@ -248,6 +248,8 @@ public class SatelliteControllerTest extends TelephonyTest { (int) TimeUnit.SECONDS.toMillis(60); private static final int TEST_WAIT_FOR_CELLULAR_MODEM_OFF_TIMEOUT_MILLIS = (int) TimeUnit.SECONDS.toMillis(60); + private static final Set<String> TEST_ALL_SATELLITE_PLMN_SET = new HashSet<>( + Arrays.asList("310830", "313210")); private static final String SATELLITE_PLMN = "00103"; @@ -262,7 +264,7 @@ public class SatelliteControllerTest extends TelephonyTest { private SubscriptionInfo testSubscriptionInfo; private SubscriptionInfo testSubscriptionInfo2; - @Mock private SatelliteController mMockSatelliteController; + @Mock private TestSatelliteController mMockSatelliteController; @Mock private DatagramController mMockDatagramController; @Mock private SatelliteModemInterface mMockSatelliteModemInterface; @Mock private SatelliteSessionController mMockSatelliteSessionController; @@ -729,6 +731,7 @@ public class SatelliteControllerTest extends TelephonyTest { doReturn(mSubscriptionInfo).when(mMockSubscriptionManagerService).getSubscriptionInfo( anyInt()); doReturn("").when(mSubscriptionInfo).getIccId(); + doReturn(TEST_ALL_SATELLITE_PLMN_SET).when(mMockSatelliteController).getAllPlmnSet(); } @After @@ -5911,7 +5914,7 @@ public class SatelliteControllerTest extends TelephonyTest { } } - private class TestSatelliteController extends SatelliteController { + public class TestSatelliteController extends SatelliteController { public boolean setSettingsKeyForSatelliteModeCalled = false; public boolean allRadiosDisabled = true; public long elapsedRealtime = 0; @@ -5930,7 +5933,7 @@ public class SatelliteControllerTest extends TelephonyTest { private boolean mLocationServiceEnabled = true; - TestSatelliteController( + public TestSatelliteController( Context context, Looper looper, @NonNull FeatureFlags featureFlags) { super(context, looper, featureFlags); logd("Constructing TestSatelliteController"); @@ -6073,6 +6076,11 @@ public class SatelliteControllerTest extends TelephonyTest { } } + @Override + protected Set<String> getAllPlmnSet() { + return super.getAllPlmnSet(); + } + public boolean isRadioOn() { synchronized (mIsRadioOnLock) { return mIsRadioOn; diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommenderTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommenderTest.java index 6592c4c657..ed709fc009 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommenderTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommenderTest.java @@ -31,6 +31,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; @@ -88,6 +89,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -122,6 +124,8 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest { private static final String DEFAULT_SATELLITE_SOS_HANDOVER_CLASS = "android.com.vendor.message.SosHandoverApp"; private static final String DEFAULT_T911_HANDOVER_INTENT_ACTION = Intent.ACTION_SENDTO; + private static final Set<String> TEST_ALL_SATELLITE_PLMN_SET = new HashSet<>( + Arrays.asList("310830", "313210")); private TestSatelliteController mTestSatelliteController; private TestImsManager mTestImsManager; @Mock @@ -139,6 +143,7 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest { @Mock private SatelliteStats mMockSatelliteStats; @Mock private SubscriptionManagerService mMockSubscriptionManagerService; + @Mock private SatelliteControllerTest.TestSatelliteController mMockSatelliteController; @Before public void setUp() throws Exception { @@ -183,6 +188,8 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest { mMockSatelliteStats); replaceInstance(SubscriptionManagerService.class, "sInstance", null, mMockSubscriptionManagerService); + replaceInstance(SatelliteController.class, "sInstance", null, + mMockSatelliteController); doNothing().when(mMockSatelliteStats).onSatelliteSosMessageRecommender( any(SatelliteStats.SatelliteSosMessageRecommenderParams.class)); mTestSatelliteController.setSatelliteConnectedViaCarrierWithinHysteresisTime( @@ -194,6 +201,7 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest { .setId(SUB_ID1).setOnlyNonTerrestrialNetwork(true).build(); when(mMockSubscriptionManagerService.getSubscriptionInfo(eq(SUB_ID1))) .thenReturn(subscriptionInfo); + doReturn(TEST_ALL_SATELLITE_PLMN_SET).when(mMockSatelliteController).getAllPlmnSet(); } @After diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteServiceUtilsTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteServiceUtilsTest.java index 9185dcec24..c27103ab38 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteServiceUtilsTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteServiceUtilsTest.java @@ -43,6 +43,7 @@ import org.mockito.MockitoAnnotations; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -55,6 +56,8 @@ public class SatelliteServiceUtilsTest extends TelephonyTest { private static final int SUB_ID1 = 1; @Mock private ServiceState mServiceState2; + @Mock SatelliteControllerTest.TestSatelliteController mMockSatelliteController; + @Before public void setUp() throws Exception { super.setUp(getClass().getSimpleName()); @@ -68,6 +71,8 @@ public class SatelliteServiceUtilsTest extends TelephonyTest { when(mPhone2.getServiceState()).thenReturn(mServiceState2); when(mPhone2.getSubId()).thenReturn(SUB_ID1); when(mPhone2.getPhoneId()).thenReturn(1); + replaceInstance(SatelliteController.class, "sInstance", null, + mMockSatelliteController); } @After @@ -182,8 +187,8 @@ public class SatelliteServiceUtilsTest extends TelephonyTest { public void testIsSatellitePlmn() { int subId = 1; - when(mSatelliteController.getSatellitePlmnsForCarrier(eq(subId))) - .thenReturn(new ArrayList<>()); + when(mMockSatelliteController.getAllPlmnSet()) + .thenReturn(new HashSet<>(new ArrayList<>())); assertFalse(SatelliteServiceUtils.isSatellitePlmn(subId, mServiceState)); // registered PLMN is null @@ -196,8 +201,8 @@ public class SatelliteServiceUtilsTest extends TelephonyTest { assertFalse(SatelliteServiceUtils.isSatellitePlmn(subId, mServiceState)); // cell identity is null - when(mSatelliteController.getSatellitePlmnsForCarrier(eq(subId))).thenReturn( - List.of("120260")); + when(mMockSatelliteController.getAllPlmnSet()).thenReturn( + new HashSet<>(List.of("120260"))); nri = new NetworkRegistrationInfo.Builder() .setRegisteredPlmn("123456") .setCellIdentity(null) |