Merge "TS43 Entitlement enhancement for Allowed Services" into main
diff --git a/assets/google_us_san_mtv_sat_s2.dat b/assets/google_us_san_mtv_sat_s2.dat
new file mode 100644
index 0000000..26516010
--- /dev/null
+++ b/assets/google_us_san_mtv_sat_s2.dat
Binary files differ
diff --git a/assets/satellite_access_config.json b/assets/satellite_access_config.json
new file mode 100644
index 0000000..4f9f853
--- /dev/null
+++ b/assets/satellite_access_config.json
@@ -0,0 +1,140 @@
+{
+ "access_control_configs": [
+ {
+ "config_id": 0,
+ "satellite_infos": [
+ {
+ "satellite_id": "0db0312f-d73f-444d-b99b-a893dfb42edf",
+ "satellite_position": {
+ "longitude": -150.3,
+ "altitude": 35786000
+ },
+ "bands": [
+ 259,
+ 260
+ ],
+ "earfcn_ranges": [
+ {
+ "start_earfcn": 3000,
+ "end_earfcn": 4300
+ }
+ ]
+ }
+ ],
+ "tag_ids": [
+ 6,
+ 7,
+ 8
+ ]
+ },
+ {
+ "config_id": 1,
+ "satellite_infos": [
+ {
+ "satellite_id": "1dec24f8-9223-4196-ad7a-a03002db7af7",
+ "satellite_position": {
+ "longitude": 15.5,
+ "altitude": 35786000
+ },
+ "bands": [
+ 257,
+ 258
+ ],
+ "earfcn_ranges": [
+ {
+ "start_earfcn": 3200,
+ "end_earfcn": 3200
+ }
+ ]
+ }
+ ],
+ "tag_ids": [
+ 9,
+ 10,
+ 11
+ ]
+ },
+ {
+ "config_id": 2,
+ "satellite_infos": [
+ {
+ "satellite_id": "f60cb479-d85b-4f4e-b050-cc428f5eb4a4",
+ "satellite_position": {
+ "longitude": -150,
+ "altitude": 35786000
+ },
+ "bands": [
+ 259,
+ 260
+ ],
+ "earfcn_ranges": [
+ {
+ "start_earfcn": 3300,
+ "end_earfcn": 3400
+ }
+ ]
+ }
+ ],
+ "tag_ids": [
+ 12,
+ 13,
+ 14
+ ]
+ },
+ {
+ "config_id": 3,
+ "satellite_infos": [
+ {
+ "satellite_id": "c5837d96-9585-46aa-8dd0-a974583737fb",
+ "satellite_position": {
+ "longitude": -155,
+ "altitude": 35786000
+ },
+ "bands": [
+ 261,
+ 262
+ ],
+ "earfcn_ranges": [
+ {
+ "start_earfcn": 3500,
+ "end_earfcn": 3600
+ }
+ ]
+ }
+ ],
+ "tag_ids": [
+ 15,
+ 16,
+ 17
+ ]
+ }
+ ,
+ {
+ "config_id": 4,
+ "satellite_infos": [
+ {
+ "satellite_id": "6ef2a128-0477-4271-895f-dc4a221d2b23",
+ "satellite_position": {
+ "longitude": -66,
+ "altitude": 35786000
+ },
+ "bands": [
+ 263,
+ 264
+ ],
+ "earfcn_ranges": [
+ {
+ "start_earfcn": 3700,
+ "end_earfcn": 3800
+ }
+ ]
+ }
+ ],
+ "tag_ids": [
+ 18,
+ 19,
+ 20
+ ]
+ }
+ ]
+}
diff --git a/res/values-ky/strings.xml b/res/values-ky/strings.xml
index a7054f9..60bbe0a 100644
--- a/res/values-ky/strings.xml
+++ b/res/values-ky/strings.xml
@@ -86,8 +86,8 @@
<string name="voicemail_notifications_preference_title" msgid="7829238858063382977">"Билдирмелер"</string>
<string name="cell_broadcast_settings" msgid="8135324242541809924">"Өзгөчө кырдаал тууралуу кулактандыруу"</string>
<string name="call_settings" msgid="3677282690157603818">"Чалуу параметрлери"</string>
- <string name="additional_gsm_call_settings" msgid="1561980168685658846">"Кошумча жөндөөлөр"</string>
- <string name="additional_gsm_call_settings_with_label" msgid="7973920539979524908">"Кошумча жөндөөлөр (<xliff:g id="SUBSCRIPTIONLABEL">%s</xliff:g>)"</string>
+ <string name="additional_gsm_call_settings" msgid="1561980168685658846">"Кошумча параметрлер"</string>
+ <string name="additional_gsm_call_settings_with_label" msgid="7973920539979524908">"Кошумча параметрлер (<xliff:g id="SUBSCRIPTIONLABEL">%s</xliff:g>)"</string>
<string name="sum_gsm_call_settings" msgid="7964692601608878138">"GSM менен гана чалуунун кошумча параметрлери"</string>
<string name="additional_cdma_call_settings" msgid="2178016561980611304">"Кошумча CDMA чалуунун параметрлери"</string>
<string name="sum_cdma_call_settings" msgid="3185825305136993636">"CDMA менен гана чалуунун кошумча параметрлери"</string>
diff --git a/src/com/android/phone/EventLogTags.logtags b/src/com/android/phone/EventLogTags.logtags
index 474a01c..f7654af 100644
--- a/src/com/android/phone/EventLogTags.logtags
+++ b/src/com/android/phone/EventLogTags.logtags
@@ -1,4 +1,4 @@
-# See system/core/logcat/event.logtags for a description of the format of this file.
+# See system/logging/logcat/event.logtags for a description of the format of this file.
option java_package com.android.phone;
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 0afb24f..27a9101 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -26,6 +26,9 @@
import static android.telephony.satellite.SatelliteManager.KEY_SATELLITE_COMMUNICATION_ALLOWED;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_ACCESS_BARRED;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SUCCESS;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_DISALLOWED_REASON_NOT_PROVISIONED;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_DISALLOWED_REASON_NOT_SUPPORTED;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_DISALLOWED_REASON_UNSUPPORTED_DEFAULT_MSG_APP;
import static com.android.internal.telephony.PhoneConstants.PHONE_TYPE_CDMA;
import static com.android.internal.telephony.PhoneConstants.PHONE_TYPE_GSM;
@@ -13228,6 +13231,15 @@
result.accept(resultCode);
return;
}
+ List<Integer> disallowedReasons =
+ mSatelliteAccessController.getSatelliteDisallowedReasons();
+ if (disallowedReasons.stream().anyMatch(r ->
+ (r == SATELLITE_DISALLOWED_REASON_UNSUPPORTED_DEFAULT_MSG_APP
+ || r == SATELLITE_DISALLOWED_REASON_NOT_PROVISIONED
+ || r == SATELLITE_DISALLOWED_REASON_NOT_SUPPORTED))) {
+ result.accept(SATELLITE_RESULT_ACCESS_BARRED);
+ return;
+ }
if (isAllowed) {
ResultReceiver resultReceiver = new ResultReceiver(mMainThreadHandler) {
@Override
@@ -14363,12 +14375,13 @@
*/
public boolean setSatelliteAccessControlOverlayConfigs(boolean reset, boolean isAllowed,
String s2CellFile, long locationFreshDurationNanos,
- List<String> satelliteCountryCodes) {
+ List<String> satelliteCountryCodes, String satelliteAccessConfigurationFile) {
Log.d(LOG_TAG, "setSatelliteAccessControlOverlayConfigs: reset=" + reset
+ ", isAllowed" + isAllowed + ", s2CellFile=" + s2CellFile
+ ", locationFreshDurationNanos=" + locationFreshDurationNanos
+ ", satelliteCountryCodes=" + ((satelliteCountryCodes != null)
- ? String.join(", ", satelliteCountryCodes) : null));
+ ? String.join(", ", satelliteCountryCodes) : null)
+ + ", satelliteAccessConfigurationFile=" + satelliteAccessConfigurationFile);
TelephonyPermissions.enforceShellOnly(
Binder.getCallingUid(), "setSatelliteAccessControlOverlayConfigs");
TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
@@ -14377,7 +14390,8 @@
final long identity = Binder.clearCallingIdentity();
try {
return mSatelliteAccessController.setSatelliteAccessControlOverlayConfigs(reset,
- isAllowed, s2CellFile, locationFreshDurationNanos, satelliteCountryCodes);
+ isAllowed, s2CellFile, locationFreshDurationNanos, satelliteCountryCodes,
+ satelliteAccessConfigurationFile);
} finally {
Binder.restoreCallingIdentity(identity);
}
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index 93ac55e..cd6a369 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -3593,9 +3593,11 @@
String s2CellFile = null;
long locationFreshDurationNanos = 0;
List<String> satelliteCountryCodes = null;
+ String satelliteAccessConfigurationFile = null;
String opt;
while ((opt = getNextOption()) != null) {
+ Log.d(LOG_TAG, "handleSetSatelliteAccessControlOverlayConfigs: opt=" + opt);
switch (opt) {
case "-r": {
reset = true;
@@ -3618,16 +3620,22 @@
satelliteCountryCodes = Arrays.asList(countryCodeStr.split(","));
break;
}
+ case "-g": {
+ satelliteAccessConfigurationFile = getNextArgRequired();
+ break;
+ }
}
}
Log.d(LOG_TAG, "handleSetSatelliteAccessControlOverlayConfigs: reset=" + reset
+ ", isAllowed=" + isAllowed + ", s2CellFile=" + s2CellFile
+ ", locationFreshDurationNanos=" + locationFreshDurationNanos
- + ", satelliteCountryCodes=" + satelliteCountryCodes);
+ + ", satelliteCountryCodes=" + satelliteCountryCodes
+ + ", satelliteAccessConfigurationFile=" + satelliteAccessConfigurationFile);
try {
boolean result = mInterface.setSatelliteAccessControlOverlayConfigs(reset, isAllowed,
- s2CellFile, locationFreshDurationNanos, satelliteCountryCodes);
+ s2CellFile, locationFreshDurationNanos, satelliteCountryCodes,
+ satelliteAccessConfigurationFile);
if (VDBG) {
Log.v(LOG_TAG, "setSatelliteAccessControlOverlayConfigs result =" + result);
}
diff --git a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
index f17377c..9618f7a 100644
--- a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
+++ b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
@@ -285,6 +285,8 @@
private boolean mOverriddenIsSatelliteAllowAccessControl;
@Nullable
private File mOverriddenSatelliteS2CellFile;
+ @Nullable
+ private String mOverriddenSatelliteConfigurationFileName;
private long mOverriddenLocationFreshDurationNanos;
@GuardedBy("mLock")
@@ -331,7 +333,12 @@
/** These are used for CTS test */
private Path mCtsSatS2FilePath = null;
+ private Path mCtsSatelliteAccessConfigurationFilePath = null;
protected static final String GOOGLE_US_SAN_SAT_S2_FILE_NAME = "google_us_san_sat_s2.dat";
+ protected static final String GOOGLE_US_SAN_SAT_MTV_S2_FILE_NAME =
+ "google_us_san_mtv_sat_s2.dat";
+ protected static final String SATELLITE_ACCESS_CONFIG_FILE_NAME =
+ "satellite_access_config.json";
/** These are for config updater config data */
private static final String SATELLITE_ACCESS_CONTROL_DATA_DIR = "satellite_access_control";
@@ -465,6 +472,7 @@
mControllerMetricsStats = ControllerMetricsStats.getInstance();
mAccessControllerMetricsStats = AccessControllerMetricsStats.getInstance();
initSharedPreferences(context);
+ checkSharedPreference();
loadOverlayConfigs(context);
// loadConfigUpdaterConfigs has to be called after loadOverlayConfigs
// since config updater config has higher priority and thus can override overlay config
@@ -614,8 +622,8 @@
mNewRegionalConfigId = null;
}
}
- updateRegionalConfigId();
}
+ updateRegionalConfigId();
}
}
@@ -759,7 +767,8 @@
*/
public boolean setSatelliteAccessControlOverlayConfigs(boolean reset, boolean isAllowed,
@Nullable String s2CellFile, long locationFreshDurationNanos,
- @Nullable List<String> satelliteCountryCodes) {
+ @Nullable List<String> satelliteCountryCodes,
+ @Nullable String satelliteConfigurationFile) {
if (!isMockModemAllowed()) {
plogd("setSatelliteAccessControllerOverlayConfigs: mock modem is not allowed");
return false;
@@ -768,7 +777,8 @@
+ ", isAllowed" + isAllowed + ", s2CellFile=" + s2CellFile
+ ", locationFreshDurationNanos=" + locationFreshDurationNanos
+ ", satelliteCountryCodes=" + ((satelliteCountryCodes != null)
- ? String.join(", ", satelliteCountryCodes) : null));
+ ? String.join(", ", satelliteCountryCodes) : null)
+ + ", satelliteConfigurationFile=" + satelliteConfigurationFile);
synchronized (mLock) {
if (reset) {
mIsOverlayConfigOverridden = false;
@@ -784,9 +794,25 @@
+ " does not exist");
mOverriddenSatelliteS2CellFile = null;
}
+ mCachedAccessRestrictionMap.clear();
} else {
mOverriddenSatelliteS2CellFile = null;
}
+ if (!TextUtils.isEmpty(satelliteConfigurationFile)) {
+ File overriddenSatelliteConfigurationFile = getTestSatelliteConfiguration(
+ satelliteConfigurationFile);
+ if (overriddenSatelliteConfigurationFile.exists()) {
+ mOverriddenSatelliteConfigurationFileName =
+ overriddenSatelliteConfigurationFile.getAbsolutePath();
+ } else {
+ plogd("The overriding file "
+ + overriddenSatelliteConfigurationFile.getAbsolutePath()
+ + " does not exist");
+ mOverriddenSatelliteConfigurationFileName = null;
+ }
+ } else {
+ mOverriddenSatelliteConfigurationFileName = null;
+ }
mOverriddenLocationFreshDurationNanos = locationFreshDurationNanos;
if (satelliteCountryCodes != null) {
mOverriddenSatelliteCountryCodes = satelliteCountryCodes;
@@ -824,8 +850,9 @@
protected File getTestSatelliteS2File(String fileName) {
plogd("getTestSatelliteS2File: fileName=" + fileName);
- if (TextUtils.equals(fileName, GOOGLE_US_SAN_SAT_S2_FILE_NAME)) {
- mCtsSatS2FilePath = copyTestSatS2FileToPhoneDirectory(GOOGLE_US_SAN_SAT_S2_FILE_NAME);
+ if (TextUtils.equals(fileName, GOOGLE_US_SAN_SAT_S2_FILE_NAME)
+ || TextUtils.equals(fileName, GOOGLE_US_SAN_SAT_MTV_S2_FILE_NAME)) {
+ mCtsSatS2FilePath = copyTestAssetFileToPhoneDirectory(fileName);
if (mCtsSatS2FilePath != null) {
return mCtsSatS2FilePath.toFile();
} else {
@@ -835,8 +862,21 @@
return new File(fileName);
}
+ protected File getTestSatelliteConfiguration(String fileName) {
+ plogd("getTestSatelliteConfiguration: fileName=" + fileName);
+ if (TextUtils.equals(fileName, SATELLITE_ACCESS_CONFIG_FILE_NAME)) {
+ mCtsSatelliteAccessConfigurationFilePath = copyTestAssetFileToPhoneDirectory(fileName);
+ if (mCtsSatelliteAccessConfigurationFilePath != null) {
+ return mCtsSatelliteAccessConfigurationFilePath.toFile();
+ } else {
+ ploge("getTestSatelliteConfiguration: mCtsSatelliteConfigurationFilePath is null");
+ }
+ }
+ return new File(fileName);
+ }
+
@Nullable
- private static Path copyTestSatS2FileToPhoneDirectory(String sourceFileName) {
+ private static Path copyTestAssetFileToPhoneDirectory(String sourceFileName) {
PhoneGlobals phoneGlobals = PhoneGlobals.getInstance();
File ctsFile = phoneGlobals.getDir("cts", Context.MODE_PRIVATE);
if (!ctsFile.exists()) {
@@ -844,26 +884,26 @@
}
Path targetDir = ctsFile.toPath();
- Path targetSatS2FilePath = targetDir.resolve(sourceFileName);
+ Path targetFilePath = targetDir.resolve(sourceFileName);
try {
var assetManager = phoneGlobals.getAssets();
if (assetManager == null) {
- loge("copyTestSatS2FileToPhoneDirectory: no assets");
+ loge("copyTestAssetFileToPhoneDirectory: no assets");
return null;
}
InputStream inputStream = assetManager.open(sourceFileName);
if (inputStream == null) {
- loge("copyTestSatS2FileToPhoneDirectory: Resource=" + sourceFileName
+ loge("copyTestAssetFileToPhoneDirectory: Resource=" + sourceFileName
+ " not found");
return null;
} else {
- Files.copy(inputStream, targetSatS2FilePath, StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(inputStream, targetFilePath, StandardCopyOption.REPLACE_EXISTING);
}
} catch (IOException ex) {
- loge("copyTestSatS2FileToPhoneDirectory: ex=" + ex);
+ loge("copyTestAssetFileToPhoneDirectory: ex=" + ex);
return null;
}
- return targetSatS2FilePath;
+ return targetFilePath;
}
@Nullable
@@ -1128,8 +1168,16 @@
}
protected void loadSatelliteAccessConfigurationFromDeviceConfig() {
- String satelliteConfigurationFileName =
- getSatelliteConfigurationFileNameFromOverlayConfig(mContext);
+ logd("loadSatelliteAccessConfigurationFromDeviceConfig:");
+ String satelliteConfigurationFileName;
+ synchronized (mLock) {
+ if (mIsOverlayConfigOverridden && mOverriddenSatelliteConfigurationFileName != null) {
+ satelliteConfigurationFileName = mOverriddenSatelliteConfigurationFileName;
+ } else {
+ satelliteConfigurationFileName = getSatelliteConfigurationFileNameFromOverlayConfig(
+ mContext);
+ }
+ }
loadSatelliteAccessConfigurationFromFile(satelliteConfigurationFileName);
}
@@ -1442,7 +1490,11 @@
logd("mSatelliteDisallowedReasons:"
+ String.join(", ", mSatelliteDisallowedReasons.toString()));
notifySatelliteDisallowedReasonsChanged();
- if (mFeatureFlags.carrierRoamingNbIotNtn() && mNotifySatelliteAvailabilityEnabled) {
+ int subId = mSatelliteController.getSelectedSatelliteSubId();
+ int carrierRoamingNtnConnectType =
+ mSatelliteController.getCarrierRoamingNtnConnectType(subId);
+ if (mSatelliteController.isSatelliteSystemNotificationsEnabled(
+ carrierRoamingNtnConnectType)) {
showSatelliteSystemNotification();
}
}
@@ -1491,6 +1543,24 @@
mSharedPreferences.edit().putBoolean(key, notified).apply();
}
+ private void checkSharedPreference() {
+ String[] keys = {
+ CONFIG_UPDATER_SATELLITE_IS_ALLOW_ACCESS_CONTROL_KEY,
+ LATEST_SATELLITE_COMMUNICATION_ALLOWED_KEY,
+ KEY_AVAILABLE_NOTIFICATION_SHOWN,
+ KEY_UNAVAILABLE_NOTIFICATION_SHOWN
+ };
+ // An Exception may occur if the initial value is set to HashSet while attempting to obtain
+ // a boolean value. If an exception occurs, the SharedPreferences will be removed with Keys.
+ Arrays.stream(keys).forEach(key -> {
+ try {
+ mSharedPreferences.getBoolean(key, false);
+ } catch (ClassCastException e) {
+ mSharedPreferences.edit().remove(key).apply();
+ }
+ });
+ }
+
/**
* Telephony-internal logic to verify if satellite access is restricted at the current
* location.
diff --git a/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java b/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
index a47095d..315184e 100644
--- a/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
+++ b/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
@@ -65,6 +65,7 @@
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -234,6 +235,7 @@
@Mock
private ConcurrentHashMap<IBinder, ISatelliteCommunicationAllowedStateCallback>
mSatelliteCommunicationAllowedStateCallbackMap;
+ private SatelliteInfo mSatelliteInfo;
private TestableLooper mTestableLooper;
private Phone[] mPhones;
@@ -422,6 +424,13 @@
mMockApplicationInfo.targetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
when(mMockPackageManager.getApplicationInfo(anyString(), anyInt()))
.thenReturn(mMockApplicationInfo);
+
+ mSatelliteInfo = new SatelliteInfo(
+ UUID.randomUUID(),
+ new SatellitePosition(10, 15),
+ new ArrayList<>(Arrays.asList(5, 30)),
+ new ArrayList<>(Arrays.asList(new EarfcnRange(0, 250))));
+
mSatelliteAccessControllerUT = new TestSatelliteAccessController(mMockContext,
mMockFeatureFlags, mTestableLooper.getLooper(), mMockLocationManager,
mMockTelecomManager, mMockSatelliteOnDeviceAccessController, mMockSatS2File);
@@ -658,7 +667,7 @@
Parcel satelliteAccessconfigParcel = Parcel.obtain();
List<SatelliteInfo> satelliteInfoList = new ArrayList<>();
- satelliteInfoList.add(mock(SatelliteInfo.class));
+ satelliteInfoList.add(mSatelliteInfo);
satelliteAccessconfigParcel.writeTypedList(satelliteInfoList);
List<Integer> tagIds = new ArrayList<>(List.of(1, 2));
@@ -1476,7 +1485,7 @@
// These APIs are executed during loadRemoteConfigs
verify(mMockSharedPreferences, times(1)).getStringSet(anyString(), any());
- verify(mMockSharedPreferences, times(1)).getBoolean(anyString(), anyBoolean());
+ verify(mMockSharedPreferences, times(5)).getBoolean(anyString(), anyBoolean());
// satelliteConfig is null
SatelliteConfigParser spyConfigParser =
@@ -1847,22 +1856,18 @@
int[] expectedBandsArray = IntStream.concat(
IntStream.concat(Arrays.stream(bands1), Arrays.stream(bands2)),
Arrays.stream(bands3)).toArray();
- int[] actualBandsArray = IntStream.range(0, systemSelectionSpecifier.getBands().size()).map(
- systemSelectionSpecifier.getBands()::get).toArray();
+ int[] actualBandsArray = systemSelectionSpecifier.getBands();
assertArrayEquals(expectedBandsArray, actualBandsArray);
int[] expectedEarfcnsArray = {300, 301, 310, 311, 320, 321, 330, 331, 340, 341, 350, 351};
- int[] actualEarfcnsArray = IntStream.range(0,
- systemSelectionSpecifier.getEarfcns().size()).map(
- systemSelectionSpecifier.getEarfcns()::get).toArray();
+ int[] actualEarfcnsArray = systemSelectionSpecifier.getEarfcns();
assertArrayEquals(expectedEarfcnsArray, actualEarfcnsArray);
SatelliteInfo[] expectedSatelliteInfos = {satelliteInfo1, satelliteInfo2, satelliteInfo3};
- assertArrayEquals(expectedSatelliteInfos, systemSelectionSpecifier.getSatelliteInfos());
+ assertArrayEquals(expectedSatelliteInfos,
+ systemSelectionSpecifier.getSatelliteInfos().toArray(new SatelliteInfo[0]));
- int[] actualTagIdArray = IntStream.range(0,
- systemSelectionSpecifier.getTagIds().size()).map(
- systemSelectionSpecifier.getTagIds()::get).toArray();
+ int[] actualTagIdArray = systemSelectionSpecifier.getTagIds();
assertArrayEquals(tagIds, actualTagIdArray);
// Verify backward compatibility when there is valid data for default regional config ID
@@ -1884,20 +1889,16 @@
// Data will be same with default regional config ID
// Verify the fields value of given systemSelectionSpecifier matched with expected.
- actualBandsArray = IntStream.range(0, systemSelectionSpecifier.getBands().size()).map(
- systemSelectionSpecifier.getBands()::get).toArray();
+ actualBandsArray = systemSelectionSpecifier.getBands();
assertArrayEquals(expectedBandsArray, actualBandsArray);
- actualEarfcnsArray = IntStream.range(0,
- systemSelectionSpecifier.getEarfcns().size()).map(
- systemSelectionSpecifier.getEarfcns()::get).toArray();
+ actualEarfcnsArray = systemSelectionSpecifier.getEarfcns();
assertArrayEquals(expectedEarfcnsArray, actualEarfcnsArray);
- assertArrayEquals(expectedSatelliteInfos, systemSelectionSpecifier.getSatelliteInfos());
+ assertArrayEquals(expectedSatelliteInfos,
+ systemSelectionSpecifier.getSatelliteInfos().toArray(new SatelliteInfo[0]));
- actualTagIdArray = IntStream.range(0,
- systemSelectionSpecifier.getTagIds().size()).map(
- systemSelectionSpecifier.getTagIds()::get).toArray();
+ actualTagIdArray = systemSelectionSpecifier.getTagIds();
assertArrayEquals(tagIds, actualTagIdArray);
mSatelliteAccessControllerUT.resetSatelliteAccessConfigMap();
@@ -1984,25 +1985,22 @@
expectedBandList.addAll(bandList2);
expectedBandList.addAll(bandList3);
- List<Integer> actualBandList = IntStream.range(0,
- systemSelectionSpecifier.getBands().size()).map(
- systemSelectionSpecifier.getBands()::get).boxed().toList();
+ List<Integer> actualBandList = Arrays.stream(systemSelectionSpecifier.getBands()).boxed()
+ .collect(Collectors.toList());
assertEquals(expectedBandList, actualBandList);
List<Integer> expectedEarfcnList = new ArrayList<>(
List.of(300, 301, 310, 311, 320, 321, 330, 331, 340, 341, 350, 351));
- List<Integer> actualEarfcnList = IntStream.range(0,
- systemSelectionSpecifier.getEarfcns().size()).map(
- systemSelectionSpecifier.getEarfcns()::get).boxed().toList();
+ List<Integer> actualEarfcnList = Arrays.stream(systemSelectionSpecifier.getEarfcns())
+ .boxed().collect(Collectors.toList());
assertEquals(expectedEarfcnList, actualEarfcnList);
- assertEquals(satelliteInfo1, systemSelectionSpecifier.getSatelliteInfos()[0]);
- assertEquals(satelliteInfo2, systemSelectionSpecifier.getSatelliteInfos()[1]);
- assertEquals(satelliteInfo3, systemSelectionSpecifier.getSatelliteInfos()[2]);
+ assertEquals(satelliteInfo1, systemSelectionSpecifier.getSatelliteInfos().get(0));
+ assertEquals(satelliteInfo2, systemSelectionSpecifier.getSatelliteInfos().get(1));
+ assertEquals(satelliteInfo3, systemSelectionSpecifier.getSatelliteInfos().get(2));
- List<Integer> actualTagIdList = IntStream.range(0,
- systemSelectionSpecifier.getTagIds().size()).map(
- systemSelectionSpecifier.getTagIds()::get).boxed().toList();
+ List<Integer> actualTagIdList = Arrays.stream(systemSelectionSpecifier.getTagIds()).boxed()
+ .collect(Collectors.toList());
assertEquals(tagIdList, actualTagIdList);
// Create satelliteAccessConfiguration with empty list of SatelliteInfo.
@@ -2026,20 +2024,34 @@
systemSelectionSpecifier = capturedList.getFirst();
// Verify the fields value of given systemSelectionSpecifier matched with expected.
- assertEquals(0, systemSelectionSpecifier.getBands().size());
- assertEquals(0, systemSelectionSpecifier.getEarfcns().size());
+ assertEquals(0, systemSelectionSpecifier.getBands().length);
+ assertEquals(0, systemSelectionSpecifier.getEarfcns().length);
SatelliteInfo[] expectedSatelliteInfoArray = new SatelliteInfo[0];
- assertArrayEquals(expectedSatelliteInfoArray, systemSelectionSpecifier.getSatelliteInfos());
+ assertArrayEquals(expectedSatelliteInfoArray,
+ systemSelectionSpecifier.getSatelliteInfos().toArray(new SatelliteInfo[0]));
- actualTagIdList = IntStream.range(0,
- systemSelectionSpecifier.getTagIds().size()).map(
- systemSelectionSpecifier.getTagIds()::get).boxed().toList();
+ actualTagIdList = Arrays.stream(systemSelectionSpecifier.getTagIds()).boxed().collect(
+ Collectors.toList());
assertEquals(tagIdList, actualTagIdList);
mSatelliteAccessControllerUT.resetSatelliteAccessConfigMap();
}
+ @Test
+ public void testCheckSharedPreferenceException() {
+ doReturn(mMockSharedPreferencesEditor).when(mMockSharedPreferencesEditor)
+ .remove(anyString());
+ doThrow(new ClassCastException()).when(mMockSharedPreferences)
+ .getBoolean(anyString(), eq(false));
+
+ mSatelliteAccessControllerUT = new TestSatelliteAccessController(mMockContext,
+ mMockFeatureFlags, mTestableLooper.getLooper(), mMockLocationManager,
+ mMockTelecomManager, mMockSatelliteOnDeviceAccessController, mMockSatS2File);
+
+ verify(mMockSharedPreferencesEditor, times(4)).remove(anyString());
+ }
+
private void sendSatelliteCommunicationAllowedEvent() {
Pair<Integer, ResultReceiver> requestPair =
new Pair<>(DEFAULT_SUBSCRIPTION_ID,