Merge "Add reason to exit the emergency callback mode" into main
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index 3c7b321..4fb96a2 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -878,7 +878,9 @@
+ (isManualSelection ? selectedNetworkOperatorName : ""));
}
- if (isManualSelection) {
+ if (isManualSelection
+ && isSubscriptionVisibleToUser(
+ mSubscriptionManager.getActiveSubscriptionInfo(subId))) {
mSelectedNetworkOperatorName.put(subId, selectedNetworkOperatorName);
shouldShowNotification(serviceState, subId);
} else {
@@ -934,7 +936,9 @@
+ (isManualSelection ? selectedNetworkOperatorName : ""));
}
- if (isManualSelection) {
+ if (isManualSelection
+ && isSubscriptionVisibleToUser(
+ mSubscriptionManager.getActiveSubscriptionInfo(subId))) {
mSelectedNetworkOperatorName.put(subId, selectedNetworkOperatorName);
shouldShowNotification(serviceState, subId);
} else {
@@ -949,6 +953,12 @@
}
}
+ // TODO(b/261916533) This should be handled by SubscriptionManager#isSubscriptionVisible(),
+ // but that method doesn't support system callers, so here we are.
+ private boolean isSubscriptionVisibleToUser(SubscriptionInfo subInfo) {
+ return subInfo != null && (!subInfo.isOpportunistic() || subInfo.getGroupUuid() == null);
+ }
+
private void dismissNetworkSelectionNotification(int subId) {
if (mSelectedUnavailableNotify.get(subId, false)) {
cancelNetworkSelection(subId);
diff --git a/src/com/android/phone/satellite/accesscontrol/S2RangeSatelliteOnDeviceAccessController.java b/src/com/android/phone/satellite/accesscontrol/S2RangeSatelliteOnDeviceAccessController.java
index 4490460..c5ecfd9 100644
--- a/src/com/android/phone/satellite/accesscontrol/S2RangeSatelliteOnDeviceAccessController.java
+++ b/src/com/android/phone/satellite/accesscontrol/S2RangeSatelliteOnDeviceAccessController.java
@@ -15,11 +15,17 @@
*/
package com.android.phone.satellite.accesscontrol;
+import static com.android.phone.satellite.accesscontrol.SatelliteAccessController.DEFAULT_REGIONAL_SATELLITE_CONFIG_ID;
+
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.telephony.Rlog;
+import com.android.internal.telephony.flags.FeatureFlags;
import com.android.storage.s2.S2LevelRange;
+
import com.android.telephony.sats2range.read.SatS2RangeFileReader;
+import com.android.telephony.sats2range.read.SuffixTableRange;
import com.google.common.geometry.S2CellId;
import com.google.common.geometry.S2LatLng;
@@ -36,31 +42,42 @@
private static final String TAG = "S2RangeSatelliteOnDeviceAccessController";
private static final boolean DBG = false;
- @NonNull private final SatS2RangeFileReader mSatS2RangeFileReader;
+ @NonNull
+ private final SatS2RangeFileReader mSatS2RangeFileReader;
private final int mS2Level;
+ /** Feature flags to control behavior and errors. */
+ @NonNull
+ private final FeatureFlags mFeatureFlags;
+
private S2RangeSatelliteOnDeviceAccessController(
- @NonNull SatS2RangeFileReader satS2RangeFileReader, int s2Level) {
+ @NonNull SatS2RangeFileReader satS2RangeFileReader,
+ int s2Level,
+ @NonNull FeatureFlags featureFlags) {
mSatS2RangeFileReader = Objects.requireNonNull(satS2RangeFileReader);
mS2Level = s2Level;
+ mFeatureFlags = featureFlags;
}
/**
* Returns a new {@link S2RangeSatelliteOnDeviceAccessController} using the specified data file.
*
* @param file The input file that contains the S2-range-based access restriction information.
- * @throws IOException in the event of a problem while reading the underlying file.
+ * @throws IOException in the event of a problem while reading the underlying file.
* @throws IllegalArgumentException if either the S2 level defined by
- * {@code config_oem_enabled_satellite_s2cell_level} or the satellite access allow defined by
- * {@code config_oem_enabled_satellite_access_allow} does not match the values included in the
- * header of the input file.
+ * {@code config_oem_enabled_satellite_s2cell_level} or the
+ * satellite access allow defined by
+ * {@code config_oem_enabled_satellite_access_allow} does not
+ * match the values included in the
+ * header of the input file.
*/
public static S2RangeSatelliteOnDeviceAccessController create(
- @NonNull File file) throws IOException, IllegalArgumentException {
+ @NonNull File file, FeatureFlags featureFlags)
+ throws IOException, IllegalArgumentException {
SatS2RangeFileReader reader = SatS2RangeFileReader.open(file);
int s2Level = reader.getS2Level();
- return new S2RangeSatelliteOnDeviceAccessController(reader, s2Level);
+ return new S2RangeSatelliteOnDeviceAccessController(reader, s2Level, featureFlags);
}
public static LocationToken createLocationTokenForLatLng(
@@ -84,7 +101,7 @@
}
private boolean isSatCommunicationAllowedAtLocation(long s2CellId) throws IOException {
- S2LevelRange entry = mSatS2RangeFileReader.findEntryByCellId(s2CellId);
+ SuffixTableRange entry = mSatS2RangeFileReader.findEntryByCellId(s2CellId);
if (mSatS2RangeFileReader.isAllowedList()) {
// The file contains an allowed list of S2 cells. Thus, satellite is allowed if an
// entry is found
@@ -158,4 +175,21 @@
return Objects.hash(mS2CellId);
}
}
+
+ @Override
+ @Nullable
+ public Integer getRegionalConfigIdForLocation(LocationToken locationToken)
+ throws IOException {
+ if (!mFeatureFlags.carrierRoamingNbIotNtn()) {
+ logd("getAccessControlConfigIdForLocation: carrierRoamingNbIotNtn is disabled");
+ return null;
+ }
+
+ if (!isSatCommunicationAllowedAtLocation(locationToken)) {
+ logd("getRegionalConfigIdForLocation: isSatCommunicationAllowedAtLocation is false");
+ return null;
+ }
+
+ return DEFAULT_REGIONAL_SATELLITE_CONFIG_ID;
+ }
}
diff --git a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
index 227cbc6..c720917 100644
--- a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
+++ b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
@@ -145,6 +145,8 @@
protected static final int EVENT_COUNTRY_CODE_CHANGED = 5;
protected static final int EVENT_LOCATION_SETTINGS_ENABLED = 6;
+ public static final int DEFAULT_REGIONAL_SATELLITE_CONFIG_ID = 0;
+
private static SatelliteAccessController sInstance;
/** Feature flags to control behavior and errors. */
@@ -209,6 +211,9 @@
@GuardedBy("mLock")
@Nullable
private Location mFreshLastKnownLocation = null;
+ @GuardedBy("mLock")
+ @Nullable
+ private Integer mRegionalConfigId = null;
/** These are used for CTS test */
private Path mCtsSatS2FilePath = null;
@@ -611,7 +616,7 @@
private boolean isS2CellFileValid(@NonNull File s2CellFile) {
try {
SatelliteOnDeviceAccessController satelliteOnDeviceAccessController =
- SatelliteOnDeviceAccessController.create(s2CellFile);
+ SatelliteOnDeviceAccessController.create(s2CellFile, mFeatureFlags);
int s2Level = satelliteOnDeviceAccessController.getS2Level();
if (s2Level < MIN_S2_LEVEL || s2Level > MAX_S2_LEVEL) {
ploge("isS2CellFileValid: invalid s2 level = " + s2Level);
@@ -1374,7 +1379,7 @@
}
}
- private void checkSatelliteAccessRestrictionForLocation(@NonNull Location location) {
+ protected void checkSatelliteAccessRestrictionForLocation(@NonNull Location location) {
synchronized (mLock) {
try {
SatelliteOnDeviceAccessController.LocationToken locationToken =
@@ -1393,8 +1398,18 @@
false);
return;
}
- satelliteAllowed = mSatelliteOnDeviceAccessController
- .isSatCommunicationAllowedAtLocation(locationToken);
+
+ if (mFeatureFlags.carrierRoamingNbIotNtn()) {
+ synchronized (mLock) {
+ mRegionalConfigId = mSatelliteOnDeviceAccessController
+ .getRegionalConfigIdForLocation(locationToken);
+ plogd("mRegionalConfigId is " + mRegionalConfigId);
+ satelliteAllowed = (mRegionalConfigId != null);
+ }
+ } else {
+ satelliteAllowed = mSatelliteOnDeviceAccessController
+ .isSatCommunicationAllowedAtLocation(locationToken);
+ }
updateCachedAccessRestrictionMap(locationToken, satelliteAllowed);
}
mAccessControllerMetricsStats.setOnDeviceLookupTime(mOnDeviceLookupStartTimeMillis);
@@ -1582,7 +1597,8 @@
try {
mSatelliteOnDeviceAccessController =
- SatelliteOnDeviceAccessController.create(getSatelliteS2CellFile());
+ SatelliteOnDeviceAccessController.create(
+ getSatelliteS2CellFile(), mFeatureFlags);
restartKeepOnDeviceAccessControllerResourcesTimer();
mS2Level = mSatelliteOnDeviceAccessController.getS2Level();
plogd("mS2Level=" + mS2Level);
@@ -2025,7 +2041,7 @@
/**
* This API can be used only for test purpose to override the carrier roaming Ntn eligibility
*
- * @param state to update Ntn Eligibility.
+ * @param state to update Ntn Eligibility.
* @param resetRequired to reset the overridden flag in satellite controller.
* @return {@code true} if the shell command is successful, {@code false} otherwise.
*/
diff --git a/src/com/android/phone/satellite/accesscontrol/SatelliteOnDeviceAccessController.java b/src/com/android/phone/satellite/accesscontrol/SatelliteOnDeviceAccessController.java
index 520699f..2d7cf96 100644
--- a/src/com/android/phone/satellite/accesscontrol/SatelliteOnDeviceAccessController.java
+++ b/src/com/android/phone/satellite/accesscontrol/SatelliteOnDeviceAccessController.java
@@ -16,6 +16,9 @@
package com.android.phone.satellite.accesscontrol;
import android.annotation.NonNull;
+import android.annotation.Nullable;
+
+import com.android.internal.telephony.flags.FeatureFlags;
import java.io.Closeable;
import java.io.File;
@@ -34,13 +37,15 @@
* but at the cost of some memory, or close it immediately after a single use.
*
* @param file The input file that contains the location-based access restriction information.
- * @throws IOException in the unlikely event of errors when reading underlying file(s)
+ * @throws IOException in the unlikely event of errors when reading underlying
+ * file(s)
* @throws IllegalArgumentException if the input file format does not match the format defined
- * by the device overlay configs.
+ * by the device overlay configs.
*/
public static SatelliteOnDeviceAccessController create(
- @NonNull File file) throws IOException, IllegalArgumentException {
- return S2RangeSatelliteOnDeviceAccessController.create(file);
+ @NonNull File file, @NonNull FeatureFlags featureFlags)
+ throws IOException, IllegalArgumentException {
+ return S2RangeSatelliteOnDeviceAccessController.create(file, featureFlags);
}
/**
@@ -83,4 +88,14 @@
/** This will print out the location information */
public abstract String toPiiString();
}
+
+ /**
+ * Returns an unsigned integer if a regional access control config ID is found for the current
+ * location, {@code null} otherwise.
+ *
+ * @throws IOException in the unlikely event of errors when reading the underlying file
+ */
+ @Nullable
+ public abstract Integer getRegionalConfigIdForLocation(LocationToken locationToken)
+ throws IOException;
}
diff --git a/tests/src/com/android/phone/NotificationMgrTest.java b/tests/src/com/android/phone/NotificationMgrTest.java
index 98c6a4a..2b0ff94 100644
--- a/tests/src/com/android/phone/NotificationMgrTest.java
+++ b/tests/src/com/android/phone/NotificationMgrTest.java
@@ -59,6 +59,7 @@
import android.content.pm.ApplicationInfo;
import android.content.res.Resources;
import android.os.Build;
+import android.os.ParcelUuid;
import android.os.PersistableBundle;
import android.os.SystemClock;
import android.os.UserHandle;
@@ -409,6 +410,35 @@
}
@Test
+ public void testUpdateNetworkSelection_opportunisticSubscription_notificationNotSent()
+ throws Exception {
+ prepareResourcesForNetworkSelection();
+ when(mSubscriptionManager.getActiveSubscriptionInfo(eq(TEST_SUB_ID))).thenReturn(
+ mSubscriptionInfo);
+
+ when(mTelephonyManager.isManualNetworkSelectionAllowed()).thenReturn(true);
+ PersistableBundle config = new PersistableBundle();
+ config.putBoolean(CarrierConfigManager.KEY_OPERATOR_SELECTION_EXPAND_BOOL, true);
+ config.putBoolean(CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL, false);
+ config.putBoolean(CarrierConfigManager.KEY_CSP_ENABLED_BOOL, false);
+ config.putBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL, true);
+ when(mCarrierConfigManager.getConfigForSubId(TEST_SUB_ID)).thenReturn(config);
+
+ when(mSubscriptionInfo.isOpportunistic()).thenReturn(true);
+ when(mSubscriptionInfo.getGroupUuid()).thenReturn(
+ ParcelUuid.fromString("5be5c5f3-3412-452e-86a0-6f18558ae8c8"));
+
+ mNotificationMgr.updateNetworkSelection(ServiceState.STATE_OUT_OF_SERVICE, TEST_SUB_ID);
+ try {
+ Thread.sleep(10000);
+ } catch (InterruptedException ignored) {
+ }
+ mNotificationMgr.updateNetworkSelection(ServiceState.STATE_OUT_OF_SERVICE, TEST_SUB_ID);
+
+ verify(mNotificationManager, never()).notify(any(), anyInt(), any());
+ }
+
+ @Test
public void testUpdateNetworkSelection_worldMode_userSetLTE_notificationNotSent() {
prepareResourcesForNetworkSelection();
@@ -632,6 +662,8 @@
when(mApp.getString(R.string.mobile_network_settings_class)).thenReturn(
MOBILE_NETWORK_SELECTION_CLASS);
when(mSubscriptionManager.isActiveSubId(anyInt())).thenReturn(true);
+ when(mSubscriptionManager.getActiveSubscriptionInfo(eq(TEST_SUB_ID))).thenReturn(
+ mSubscriptionInfo);
}
private void moveTimeForward(long seconds) {
diff --git a/tests/src/com/android/phone/satellite/accesscontrol/S2RangeSatelliteOnDeviceAccessControllerTest.java b/tests/src/com/android/phone/satellite/accesscontrol/S2RangeSatelliteOnDeviceAccessControllerTest.java
index 16a256d..678d069 100644
--- a/tests/src/com/android/phone/satellite/accesscontrol/S2RangeSatelliteOnDeviceAccessControllerTest.java
+++ b/tests/src/com/android/phone/satellite/accesscontrol/S2RangeSatelliteOnDeviceAccessControllerTest.java
@@ -16,13 +16,22 @@
package com.android.phone.satellite.accesscontrol;
+import static com.android.phone.satellite.accesscontrol.SatelliteAccessController.DEFAULT_REGIONAL_SATELLITE_CONFIG_ID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doReturn;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import com.android.internal.telephony.flags.FeatureFlags;
import com.android.storage.s2.S2LevelRange;
+
import com.android.telephony.sats2range.read.SatS2RangeFileFormat;
+import com.android.telephony.sats2range.read.SuffixTableRange;
import com.android.telephony.sats2range.utils.TestUtils;
import com.android.telephony.sats2range.write.SatS2RangeFileWriter;
@@ -33,6 +42,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.io.File;
@@ -44,6 +54,9 @@
public class S2RangeSatelliteOnDeviceAccessControllerTest {
private File mFile;
+ @Mock
+ private FeatureFlags mMockFeatureFlags;
+
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
@@ -79,7 +92,7 @@
// Validate the output block file
SatelliteOnDeviceAccessController accessController = null;
try {
- accessController = SatelliteOnDeviceAccessController.create(mFile);
+ accessController = SatelliteOnDeviceAccessController.create(mFile, mMockFeatureFlags);
int s2Level = accessController.getS2Level();
// Verify an edge cell of range 1 not in the output file
@@ -88,9 +101,23 @@
SatelliteOnDeviceAccessController.LocationToken locationToken =
SatelliteOnDeviceAccessController.createLocationTokenForLatLng(
s2LatLng.latDegrees(), s2LatLng.lngDegrees(), s2Level);
+
+ // Verify if the return value is null, when the carrierRoamingNbIotNtn is disabled.
+ doReturn(false).when(mMockFeatureFlags).carrierRoamingNbIotNtn();
+ assertNull(accessController.getRegionalConfigIdForLocation(locationToken));
+
+ doReturn(true).when(mMockFeatureFlags).carrierRoamingNbIotNtn();
boolean isAllowed = accessController.isSatCommunicationAllowedAtLocation(locationToken);
assertTrue(isAllowed != isAllowedList);
+ Integer configId = accessController.getRegionalConfigIdForLocation(locationToken);
+ if (isAllowedList) {
+ assertNull(configId);
+ } else {
+ assertNotNull(configId);
+ assertEquals(DEFAULT_REGIONAL_SATELLITE_CONFIG_ID, (int) configId);
+ }
+
// Verify cells in range1 present in the output file
for (int suffix = 1000; suffix < 2000; suffix++) {
s2CellId = new S2CellId(TestUtils.createCellId(fileFormat, 1, 1000, suffix));
@@ -98,9 +125,17 @@
// Lookup using location token
locationToken = SatelliteOnDeviceAccessController.createLocationTokenForLatLng(
- s2LatLng.latDegrees(), s2LatLng.lngDegrees(), s2Level);
+ s2LatLng.latDegrees(), s2LatLng.lngDegrees(), s2Level);
isAllowed = accessController.isSatCommunicationAllowedAtLocation(locationToken);
assertTrue(isAllowed == isAllowedList);
+
+ configId = accessController.getRegionalConfigIdForLocation(locationToken);
+ if (isAllowedList) {
+ assertNotNull(configId);
+ assertEquals(DEFAULT_REGIONAL_SATELLITE_CONFIG_ID, (int) configId);
+ } else {
+ assertNull(configId);
+ }
}
// Verify the middle cell not in the output file
@@ -111,6 +146,14 @@
isAllowed = accessController.isSatCommunicationAllowedAtLocation(locationToken);
assertTrue(isAllowed != isAllowedList);
+ configId = accessController.getRegionalConfigIdForLocation(locationToken);
+ if (isAllowedList) {
+ assertNull(configId);
+ } else {
+ assertNotNull(configId);
+ assertEquals(DEFAULT_REGIONAL_SATELLITE_CONFIG_ID, (int) configId);
+ }
+
// Verify cells in range2 present in the output file
for (int suffix = 2001; suffix < 3000; suffix++) {
s2CellId = new S2CellId(TestUtils.createCellId(fileFormat, 1, 1000, suffix));
@@ -119,6 +162,14 @@
s2LatLng.latDegrees(), s2LatLng.lngDegrees(), s2Level);
isAllowed = accessController.isSatCommunicationAllowedAtLocation(locationToken);
assertTrue(isAllowed == isAllowedList);
+
+ configId = accessController.getRegionalConfigIdForLocation(locationToken);
+ if (isAllowedList) {
+ assertNotNull(configId);
+ assertEquals(DEFAULT_REGIONAL_SATELLITE_CONFIG_ID, (int) configId);
+ } else {
+ assertNull(configId);
+ }
}
// Verify an edge cell of range 2 not in the output file
@@ -129,6 +180,14 @@
isAllowed = accessController.isSatCommunicationAllowedAtLocation(locationToken);
assertTrue(isAllowed != isAllowedList);
+ configId = accessController.getRegionalConfigIdForLocation(locationToken);
+ if (isAllowedList) {
+ assertNull(configId);
+ } else {
+ assertNotNull(configId);
+ assertEquals(DEFAULT_REGIONAL_SATELLITE_CONFIG_ID, (int) configId);
+ }
+
// Verify an edge cell of range 3 not in the output file
s2CellId = new S2CellId(TestUtils.createCellId(fileFormat, 1, 1001, 999));
s2LatLng = s2CellId.toLatLng();
@@ -137,6 +196,14 @@
isAllowed = accessController.isSatCommunicationAllowedAtLocation(locationToken);
assertTrue(isAllowed != isAllowedList);
+ configId = accessController.getRegionalConfigIdForLocation(locationToken);
+ if (isAllowedList) {
+ assertNull(configId);
+ } else {
+ assertNotNull(configId);
+ assertEquals(DEFAULT_REGIONAL_SATELLITE_CONFIG_ID, (int) configId);
+ }
+
// Verify cells in range1 present in the output file
for (int suffix = 1000; suffix < 2000; suffix++) {
s2CellId = new S2CellId(TestUtils.createCellId(fileFormat, 1, 1001, suffix));
@@ -145,6 +212,14 @@
s2LatLng.latDegrees(), s2LatLng.lngDegrees(), s2Level);
isAllowed = accessController.isSatCommunicationAllowedAtLocation(locationToken);
assertTrue(isAllowed == isAllowedList);
+
+ configId = accessController.getRegionalConfigIdForLocation(locationToken);
+ if (isAllowedList) {
+ assertNotNull(configId);
+ assertEquals(DEFAULT_REGIONAL_SATELLITE_CONFIG_ID, (int) configId);
+ } else {
+ assertNull(configId);
+ }
}
// Verify an edge cell of range 3 not in the output file
@@ -154,6 +229,15 @@
s2LatLng.latDegrees(), s2LatLng.lngDegrees(), s2Level);
isAllowed = accessController.isSatCommunicationAllowedAtLocation(locationToken);
assertTrue(isAllowed != isAllowedList);
+
+ configId = accessController.getRegionalConfigIdForLocation(locationToken);
+ if (isAllowedList) {
+ assertNull(configId);
+ } else {
+ assertNotNull(configId);
+ assertEquals(DEFAULT_REGIONAL_SATELLITE_CONFIG_ID, (int) configId);
+ }
+
} catch (Exception ex) {
fail("Unexpected exception when validating the output ex=" + ex);
} finally {
@@ -166,24 +250,24 @@
private SatS2RangeFileFormat createSatS2File(
File file, boolean isAllowedList) throws Exception {
SatS2RangeFileFormat fileFormat;
- S2LevelRange range1, range2, range3;
+ SuffixTableRange range1, range2, range3;
try (SatS2RangeFileWriter satS2RangeFileWriter = SatS2RangeFileWriter.open(
file, TestUtils.createS2RangeFileFormat(isAllowedList))) {
fileFormat = satS2RangeFileWriter.getFileFormat();
// Two ranges that share a prefix.
- range1 = new S2LevelRange(
+ range1 = new SuffixTableRange(
TestUtils.createCellId(fileFormat, 1, 1000, 1000),
TestUtils.createCellId(fileFormat, 1, 1000, 2000));
- range2 = new S2LevelRange(
+ range2 = new SuffixTableRange(
TestUtils.createCellId(fileFormat, 1, 1000, 2001),
TestUtils.createCellId(fileFormat, 1, 1000, 3000));
// This range has a different prefix, so will be in a different suffix table.
- range3 = new S2LevelRange(
+ range3 = new SuffixTableRange(
TestUtils.createCellId(fileFormat, 1, 1001, 1000),
TestUtils.createCellId(fileFormat, 1, 1001, 2000));
- List<S2LevelRange> ranges = new ArrayList<>();
+ List<SuffixTableRange> ranges = new ArrayList<>();
ranges.add(range1);
ranges.add(range2);
ranges.add(range3);
diff --git a/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java b/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
index 5650703..971f87a 100644
--- a/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
+++ b/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
@@ -29,6 +29,7 @@
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SUCCESS;
import static com.android.phone.satellite.accesscontrol.SatelliteAccessController.ALLOWED_STATE_CACHE_VALID_DURATION_NANOS;
+import static com.android.phone.satellite.accesscontrol.SatelliteAccessController.DEFAULT_REGIONAL_SATELLITE_CONFIG_ID;
import static com.android.phone.satellite.accesscontrol.SatelliteAccessController.EVENT_COUNTRY_CODE_CHANGED;
import static com.android.phone.satellite.accesscontrol.SatelliteAccessController.CMD_IS_SATELLITE_COMMUNICATION_ALLOWED;
import static com.android.phone.satellite.accesscontrol.SatelliteAccessController.DEFAULT_DELAY_MINUTES_BEFORE_VALIDATING_POSSIBLE_CHANGE_IN_ALLOWED_REGION;
@@ -319,8 +320,9 @@
when(mMockLocation0.getLongitude()).thenReturn(0.0);
when(mMockLocation1.getLatitude()).thenReturn(1.0);
when(mMockLocation1.getLongitude()).thenReturn(1.0);
- when(mMockSatelliteOnDeviceAccessController.isSatCommunicationAllowedAtLocation(
- any(SatelliteOnDeviceAccessController.LocationToken.class))).thenReturn(true);
+ when(mMockSatelliteOnDeviceAccessController.getRegionalConfigIdForLocation(
+ any(SatelliteOnDeviceAccessController.LocationToken.class)))
+ .thenReturn(DEFAULT_REGIONAL_SATELLITE_CONFIG_ID);
when(mMockContext.getSharedPreferences(anyString(), anyInt())).thenReturn(
mMockSharedPreferences);
@@ -339,6 +341,7 @@
when(mMockFeatureFlags.satellitePersistentLogging()).thenReturn(true);
when(mMockFeatureFlags.geofenceEnhancementForBetterUx()).thenReturn(true);
when(mMockFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(true);
+ when(mMockFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);
mSatelliteAccessControllerUT = new TestSatelliteAccessController(mMockContext,
mMockFeatureFlags, mLooper, mMockLocationManager, mMockTelecomManager,
@@ -488,8 +491,9 @@
setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
setUpResponseForRequestIsSatelliteProvisioned(true, SATELLITE_RESULT_SUCCESS);
doReturn(true).when(mMockLocationManager).isLocationEnabled();
- when(mMockSatelliteOnDeviceAccessController.isSatCommunicationAllowedAtLocation(
- any(SatelliteOnDeviceAccessController.LocationToken.class))).thenReturn(true);
+ when(mMockSatelliteOnDeviceAccessController.getRegionalConfigIdForLocation(
+ any(SatelliteOnDeviceAccessController.LocationToken.class)))
+ .thenReturn(DEFAULT_REGIONAL_SATELLITE_CONFIG_ID);
replaceInstance(SatelliteAccessController.class, "mCachedAccessRestrictionMap",
mSatelliteAccessControllerUT, mMockCachedAccessRestrictionMap);
doReturn(true).when(mMockCachedAccessRestrictionMap).containsKey(any());
@@ -725,7 +729,7 @@
mTestableLooper.processAllMessages();
assertTrue(
mSatelliteAccessControllerUT.isKeepOnDeviceAccessControllerResourcesTimerStarted());
- verify(mMockSatelliteOnDeviceAccessController).isSatCommunicationAllowedAtLocation(
+ verify(mMockSatelliteOnDeviceAccessController).getRegionalConfigIdForLocation(
any(SatelliteOnDeviceAccessController.LocationToken.class));
assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(
mSatelliteAllowedSemaphore, 1));
@@ -770,7 +774,7 @@
sendLocationRequestResult(mMockLocation0);
assertFalse(mSatelliteAccessControllerUT.isWaitForCurrentLocationTimerStarted());
// The LocationToken should be already in the cache
- verify(mMockSatelliteOnDeviceAccessController, never()).isSatCommunicationAllowedAtLocation(
+ verify(mMockSatelliteOnDeviceAccessController, never()).getRegionalConfigIdForLocation(
any(SatelliteOnDeviceAccessController.LocationToken.class));
assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(
mSatelliteAllowedSemaphore, 1));
@@ -802,7 +806,7 @@
mSatelliteAccessControllerUT.getWaitForCurrentLocationTimeoutMillis());
mTestableLooper.processAllMessages();
assertFalse(mSatelliteAccessControllerUT.isWaitForCurrentLocationTimerStarted());
- verify(mMockSatelliteOnDeviceAccessController, never()).isSatCommunicationAllowedAtLocation(
+ verify(mMockSatelliteOnDeviceAccessController, never()).getRegionalConfigIdForLocation(
any(SatelliteOnDeviceAccessController.LocationToken.class));
assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(
mSatelliteAllowedSemaphore, 1));
@@ -828,7 +832,7 @@
verify(mMockLocationManager, never()).getCurrentLocation(anyString(),
any(LocationRequest.class), any(CancellationSignal.class), any(Executor.class),
any(Consumer.class));
- verify(mMockSatelliteOnDeviceAccessController, never()).isSatCommunicationAllowedAtLocation(
+ verify(mMockSatelliteOnDeviceAccessController, never()).getRegionalConfigIdForLocation(
any(SatelliteOnDeviceAccessController.LocationToken.class));
assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(
mSatelliteAllowedSemaphore, 1));
@@ -979,7 +983,7 @@
assertNull(mCountryDetectorObjCaptor.getValue());
// Normal case that invokes
- // mMockSatelliteOnDeviceAccessController.isSatCommunicationAllowedAtLocation
+ // mMockSatelliteOnDeviceAccessController.getRegionalConfigIdForLocation
clearInvocations(mMockSatelliteOnDeviceAccessController);
setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
setUpResponseForRequestIsSatelliteProvisioned(true, SATELLITE_RESULT_SUCCESS);
@@ -987,14 +991,14 @@
mSatelliteAccessControllerUT.elapsedRealtimeNanos = TEST_LOCATION_FRESH_DURATION_NANOS;
sendCommandValidateCountryCodeChangeEvent(mMockContext);
verify(mMockSatelliteOnDeviceAccessController,
- times(1)).isSatCommunicationAllowedAtLocation(
+ times(1)).getRegionalConfigIdForLocation(
any(SatelliteOnDeviceAccessController.LocationToken.class));
// Case that isCommunicationAllowedCacheValid is true
clearInvocations(mMockSatelliteOnDeviceAccessController);
mSatelliteAccessControllerUT.elapsedRealtimeNanos = TEST_LOCATION_FRESH_DURATION_NANOS + 1;
sendCommandValidateCountryCodeChangeEvent(mMockContext);
- verify(mMockSatelliteOnDeviceAccessController, never()).isSatCommunicationAllowedAtLocation(
+ verify(mMockSatelliteOnDeviceAccessController, never()).getRegionalConfigIdForLocation(
any(SatelliteOnDeviceAccessController.LocationToken.class));
// Case that mLatestCacheEnforcedValidateTimeNanos is over
@@ -1011,11 +1015,11 @@
when(mMockLocation0.getLongitude()).thenReturn(2.0);
when(mMockLocation1.getLatitude()).thenReturn(3.0);
when(mMockLocation1.getLongitude()).thenReturn(3.0);
- when(mMockSatelliteOnDeviceAccessController.isSatCommunicationAllowedAtLocation(
- any(SatelliteOnDeviceAccessController.LocationToken.class))).thenReturn(false);
+ when(mMockSatelliteOnDeviceAccessController.getRegionalConfigIdForLocation(
+ any(SatelliteOnDeviceAccessController.LocationToken.class))).thenReturn(null);
sendCommandValidateCountryCodeChangeEvent(mMockContext);
verify(mMockSatelliteOnDeviceAccessController,
- times(1)).isSatCommunicationAllowedAtLocation(
+ times(1)).getRegionalConfigIdForLocation(
any(SatelliteOnDeviceAccessController.LocationToken.class));
}
@@ -1135,8 +1139,9 @@
.thenReturn(TEST_SATELLITE_ALLOW);
setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
setUpResponseForRequestIsSatelliteProvisioned(true, SATELLITE_RESULT_SUCCESS);
- when(mMockSatelliteOnDeviceAccessController.isSatCommunicationAllowedAtLocation(
- any(SatelliteOnDeviceAccessController.LocationToken.class))).thenReturn(true);
+ when(mMockSatelliteOnDeviceAccessController.getRegionalConfigIdForLocation(
+ any(SatelliteOnDeviceAccessController.LocationToken.class)))
+ .thenReturn(DEFAULT_REGIONAL_SATELLITE_CONFIG_ID);
replaceInstance(SatelliteAccessController.class, "mCachedAccessRestrictionMap",
mSatelliteAccessControllerUT, mMockCachedAccessRestrictionMap);
doReturn(false).when(mMockCachedAccessRestrictionMap).containsKey(any());
diff --git a/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/PopulatedSuffixTableBlock.java b/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/PopulatedSuffixTableBlock.java
index 9aa56b2..2feccbf 100644
--- a/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/PopulatedSuffixTableBlock.java
+++ b/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/PopulatedSuffixTableBlock.java
@@ -20,7 +20,6 @@
import static com.android.storage.s2.S2Support.cellIdToString;
import static com.android.storage.util.Conditions.checkStateInRange;
-import com.android.storage.s2.S2LevelRange;
import com.android.storage.table.packed.read.IntValueTypedPackedTable;
import com.android.storage.table.reader.IntValueTable;
@@ -141,7 +140,7 @@
private final IntValueTable.TableEntry mSuffixTableEntry;
- private S2LevelRange mSuffixTableRange;
+ private SuffixTableRange mSuffixTableRange;
Entry(IntValueTable.TableEntry suffixTableEntry) {
mSuffixTableEntry = Objects.requireNonNull(suffixTableEntry);
@@ -154,7 +153,7 @@
/** Returns the data for this entry. */
@Override
- public S2LevelRange getSuffixTableRange() {
+ public SuffixTableRange getSuffixTableRange() {
// Creating SuffixTableRange is relatively expensive so it is created lazily and
// memoized.
if (mSuffixTableRange == null) {
@@ -190,7 +189,7 @@
endCellIdSuffix = 0;
}
long endCellId = mFileFormat.createCellId(endCellPrefixValue, endCellIdSuffix);
- mSuffixTableRange = new S2LevelRange(startCellId, endCellId);
+ mSuffixTableRange = new SuffixTableRange(startCellId, endCellId);
}
return mSuffixTableRange;
}
diff --git a/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/SatS2RangeFileReader.java b/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/SatS2RangeFileReader.java
index ecfa0a9..2c6c4af 100644
--- a/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/SatS2RangeFileReader.java
+++ b/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/SatS2RangeFileReader.java
@@ -19,7 +19,6 @@
import com.android.storage.block.read.Block;
import com.android.storage.block.read.BlockFileReader;
import com.android.storage.block.read.BlockInfo;
-import com.android.storage.s2.S2LevelRange;
import com.android.storage.s2.S2Support;
import com.android.storage.util.Conditions;
import com.android.storage.util.Visitor;
@@ -144,11 +143,11 @@
}
/**
- * Finds an {@link S2LevelRange} associated with a range covering {@code cellId}.
+ * Finds an {@link SuffixTableRange} associated with a range covering {@code cellId}.
* Returns {@code null} if no range exists. Throws {@link IllegalArgumentException} if
* {@code cellId} is not the correct S2 level for the file. See {@link #getS2Level()}.
*/
- public S2LevelRange findEntryByCellId(long cellId) throws IOException {
+ public SuffixTableRange findEntryByCellId(long cellId) throws IOException {
checkNotClosed();
int dataS2Level = mFileFormat.getS2Level();
int searchS2Level = S2Support.getS2Level(cellId);
diff --git a/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/SuffixTableBlock.java b/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/SuffixTableBlock.java
index 90ddd89..ffd28d5 100644
--- a/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/SuffixTableBlock.java
+++ b/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/SuffixTableBlock.java
@@ -20,7 +20,6 @@
import static com.android.storage.s2.S2Support.getS2Level;
import com.android.storage.block.read.BlockData;
-import com.android.storage.s2.S2LevelRange;
import com.android.storage.table.packed.read.IntValueTypedPackedTable;
import com.android.storage.util.BitwiseUtils;
import com.android.storage.util.Visitor;
@@ -180,6 +179,6 @@
public abstract int getIndex();
/** Returns the data for this entry. */
- public abstract S2LevelRange getSuffixTableRange();
+ public abstract SuffixTableRange getSuffixTableRange();
}
}
diff --git a/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/SuffixTableRange.java b/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/SuffixTableRange.java
new file mode 100644
index 0000000..88f1b2e
--- /dev/null
+++ b/utils/satellite/s2storage/src/readonly/java/com/android/telephony/sats2range/read/SuffixTableRange.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.telephony.sats2range.read;
+
+import static com.android.storage.s2.S2Support.cellIdToString;
+
+import com.android.storage.s2.S2LevelRange;
+
+import java.util.Objects;
+
+public final class SuffixTableRange extends S2LevelRange {
+ private static final int DEAFAULT_ENTRY_VALUE = -1;
+ private final int mEntryValue;
+
+ // For backward compatibility
+ public SuffixTableRange(long startCellId, long endCellId) {
+ this(startCellId, endCellId, DEAFAULT_ENTRY_VALUE);
+ }
+
+ public SuffixTableRange(long startCellId, long endCellId, int entryValue) {
+ super(startCellId, endCellId);
+ mEntryValue = entryValue;
+ }
+
+ /** Returns the entry value associated with this range. */
+ public int getEntryValue() {
+ return mEntryValue;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ if (super.equals(o)) {
+ int entryValue = ((SuffixTableRange) o).mEntryValue;
+ return mEntryValue == entryValue;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mStartCellId, mEndCellId, mEntryValue);
+ }
+
+ @Override
+ public String toString() {
+ return "SuffixTableRange{"
+ + "mS2Level=" + mS2Level
+ + ", mStartCellId=" + cellIdToString(mStartCellId)
+ + ", mEndCellId=" + cellIdToString(mEndCellId)
+ + ", mEntryValue=" + mEntryValue
+ + '}';
+ }
+}
diff --git a/utils/satellite/s2storage/src/test/java/com/android/telephony/sats2range/SatS2RangeFileReaderTest.java b/utils/satellite/s2storage/src/test/java/com/android/telephony/sats2range/SatS2RangeFileReaderTest.java
index bbfaef7..2797b77 100644
--- a/utils/satellite/s2storage/src/test/java/com/android/telephony/sats2range/SatS2RangeFileReaderTest.java
+++ b/utils/satellite/s2storage/src/test/java/com/android/telephony/sats2range/SatS2RangeFileReaderTest.java
@@ -18,9 +18,9 @@
import static org.junit.Assert.assertEquals;
-import com.android.storage.s2.S2LevelRange;
import com.android.telephony.sats2range.read.SatS2RangeFileFormat;
import com.android.telephony.sats2range.read.SatS2RangeFileReader;
+import com.android.telephony.sats2range.read.SuffixTableRange;
import com.android.telephony.sats2range.utils.TestUtils;
import com.android.telephony.sats2range.write.SatS2RangeFileWriter;
@@ -38,24 +38,24 @@
SatS2RangeFileFormat fileFormat;
boolean isAllowedList = true;
- S2LevelRange expectedRange1, expectedRange2, expectedRange3;
+ SuffixTableRange expectedRange1, expectedRange2, expectedRange3;
try (SatS2RangeFileWriter satS2RangeFileWriter = SatS2RangeFileWriter.open(
file, TestUtils.createS2RangeFileFormat(isAllowedList))) {
fileFormat = satS2RangeFileWriter.getFileFormat();
// Two ranges that share a prefix.
- expectedRange1 = new S2LevelRange(
+ expectedRange1 = new SuffixTableRange(
TestUtils.createCellId(fileFormat, 1, 1000, 1000),
TestUtils.createCellId(fileFormat, 1, 1000, 2000));
- expectedRange2 = new S2LevelRange(
+ expectedRange2 = new SuffixTableRange(
TestUtils.createCellId(fileFormat, 1, 1000, 2000),
TestUtils.createCellId(fileFormat, 1, 1000, 3000));
// This range has a different prefix, so will be in a different suffix table.
- expectedRange3 = new S2LevelRange(
+ expectedRange3 = new SuffixTableRange(
TestUtils.createCellId(fileFormat, 1, 1001, 1000),
TestUtils.createCellId(fileFormat, 1, 1001, 2000));
- List<S2LevelRange> ranges = new ArrayList<>();
+ List<SuffixTableRange> ranges = new ArrayList<>();
ranges.add(expectedRange1);
ranges.add(expectedRange2);
ranges.add(expectedRange3);
@@ -65,15 +65,15 @@
try (SatS2RangeFileReader satS2RangeFileReader = SatS2RangeFileReader.open(file)) {
assertEquals(isAllowedList, satS2RangeFileReader.isAllowedList());
- S2LevelRange range1 = satS2RangeFileReader.findEntryByCellId(
+ SuffixTableRange range1 = satS2RangeFileReader.findEntryByCellId(
TestUtils.createCellId(fileFormat, 1, 1000, 1500));
assertEquals(expectedRange1, range1);
- S2LevelRange range2 = satS2RangeFileReader.findEntryByCellId(
+ SuffixTableRange range2 = satS2RangeFileReader.findEntryByCellId(
TestUtils.createCellId(fileFormat, 1, 1000, 2500));
assertEquals(expectedRange2, range2);
- S2LevelRange range3 = satS2RangeFileReader.findEntryByCellId(
+ SuffixTableRange range3 = satS2RangeFileReader.findEntryByCellId(
TestUtils.createCellId(fileFormat, 1, 1001, 1500));
assertEquals(expectedRange3, range3);
}
diff --git a/utils/satellite/s2storage/src/test/java/com/android/telephony/sats2range/SuffixTableBlockTest.java b/utils/satellite/s2storage/src/test/java/com/android/telephony/sats2range/SuffixTableBlockTest.java
index 04b915b..7b9ce4a 100644
--- a/utils/satellite/s2storage/src/test/java/com/android/telephony/sats2range/SuffixTableBlockTest.java
+++ b/utils/satellite/s2storage/src/test/java/com/android/telephony/sats2range/SuffixTableBlockTest.java
@@ -24,9 +24,9 @@
import static org.mockito.ArgumentMatchers.argThat;
import com.android.storage.block.write.BlockWriter;
-import com.android.storage.s2.S2LevelRange;
import com.android.telephony.sats2range.read.SatS2RangeFileFormat;
import com.android.telephony.sats2range.read.SuffixTableBlock;
+import com.android.telephony.sats2range.read.SuffixTableRange;
import com.android.telephony.sats2range.read.SuffixTableSharedData;
import com.android.telephony.sats2range.utils.TestUtils;
import com.android.telephony.sats2range.write.SuffixTableWriter;
@@ -78,12 +78,14 @@
long invalidEndCellId = fileFormat.createCellId(tablePrefixValue + 1, maxSuffixValue);
long validEndCellId = fileFormat.createCellId(tablePrefixValue, maxSuffixValue);
{
- S2LevelRange badStartCellId = new S2LevelRange(invalidStartCellId, validEndCellId);
+ SuffixTableRange badStartCellId = new SuffixTableRange(invalidStartCellId,
+ validEndCellId);
assertThrows(IllegalArgumentException.class,
() -> suffixTableWriter.addRange(badStartCellId));
}
{
- S2LevelRange badEndCellId = new S2LevelRange(validStartCellId, invalidEndCellId);
+ SuffixTableRange badEndCellId = new SuffixTableRange(validStartCellId,
+ invalidEndCellId);
assertThrows(IllegalArgumentException.class,
() -> suffixTableWriter.addRange(badEndCellId));
}
@@ -101,13 +103,13 @@
SuffixTableWriter suffixTableWriter =
SuffixTableWriter.createPopulated(fileFormat, suffixTableSharedData);
- S2LevelRange suffixTableRange1 = new S2LevelRange(
+ SuffixTableRange suffixTableRange1 = new SuffixTableRange(
fileFormat.createCellId(tablePrefixValue, 1000),
fileFormat.createCellId(tablePrefixValue, 1001));
suffixTableWriter.addRange(suffixTableRange1);
// It's fine to add a range that starts adjacent to the last one.
- S2LevelRange suffixTableRange2 = new S2LevelRange(
+ SuffixTableRange suffixTableRange2 = new SuffixTableRange(
fileFormat.createCellId(tablePrefixValue, 1001),
fileFormat.createCellId(tablePrefixValue, 1002));
suffixTableWriter.addRange(suffixTableRange2);
@@ -117,7 +119,7 @@
() -> suffixTableWriter.addRange(suffixTableRange2));
// Try similar checks at the top end of the table.
- S2LevelRange suffixTableRange3 = new S2LevelRange(
+ SuffixTableRange suffixTableRange3 = new SuffixTableRange(
fileFormat.createCellId(tablePrefixValue, maxSuffixValue - 1),
fileFormat.createCellId(tablePrefixValue, maxSuffixValue));
suffixTableWriter.addRange(suffixTableRange3);
@@ -131,7 +133,7 @@
() -> suffixTableWriter.addRange(suffixTableRange3));
// Now "complete" the table: there can be no entry after this one.
- S2LevelRange suffixTableRange4 = new S2LevelRange(
+ SuffixTableRange suffixTableRange4 = new SuffixTableRange(
fileFormat.createCellId(tablePrefixValue, maxSuffixValue),
fileFormat.createCellId(tablePrefixValue + 1, 0));
suffixTableWriter.addRange(suffixTableRange4);
@@ -180,23 +182,23 @@
long entry1StartCellId = fileFormat.createCellId(tablePrefix, 1000);
long entry1EndCellId = fileFormat.createCellId(tablePrefix, 2000);
- S2LevelRange entry1 = new S2LevelRange(entry1StartCellId, entry1EndCellId);
+ SuffixTableRange entry1 = new SuffixTableRange(entry1StartCellId, entry1EndCellId);
suffixTableWriter.addRange(entry1);
long entry2StartCellId = fileFormat.createCellId(tablePrefix, 2000);
long entry2EndCellId = fileFormat.createCellId(tablePrefix, 3000);
- S2LevelRange entry2 = new S2LevelRange(entry2StartCellId, entry2EndCellId);
+ SuffixTableRange entry2 = new SuffixTableRange(entry2StartCellId, entry2EndCellId);
suffixTableWriter.addRange(entry2);
// There is a deliberate gap here between entry2 and entry3.
long entry3StartCellId = fileFormat.createCellId(tablePrefix, 4000);
long entry3EndCellId = fileFormat.createCellId(tablePrefix, 5000);
- S2LevelRange entry3 = new S2LevelRange(entry3StartCellId, entry3EndCellId);
+ SuffixTableRange entry3 = new SuffixTableRange(entry3StartCellId, entry3EndCellId);
suffixTableWriter.addRange(entry3);
long entry4StartCellId = fileFormat.createCellId(tablePrefix, maxSuffix - 999);
long entry4EndCellId = fileFormat.createCellId(tablePrefix + 1, 0);
- S2LevelRange entry4 = new S2LevelRange(entry4StartCellId, entry4EndCellId);
+ SuffixTableRange entry4 = new SuffixTableRange(entry4StartCellId, entry4EndCellId);
suffixTableWriter.addRange(entry4);
BlockWriter.ReadBack blockReadback = suffixTableWriter.close();
@@ -251,7 +253,7 @@
SuffixTableWriter.createPopulated(fileFormat, suffixTableSharedData);
long entry1StartCellId = fileFormat.createCellId(tablePrefix, 1000);
long entry1EndCellId = fileFormat.createCellId(tablePrefix, 2000);
- S2LevelRange entry1 = new S2LevelRange(entry1StartCellId, entry1EndCellId);
+ SuffixTableRange entry1 = new SuffixTableRange(entry1StartCellId, entry1EndCellId);
suffixTableWriter.addRange(entry1);
BlockWriter.ReadBack blockReadback = suffixTableWriter.close();
@@ -276,12 +278,12 @@
SuffixTableWriter suffixTableWriter =
SuffixTableWriter.createPopulated(fileFormat, sharedData);
- S2LevelRange entry1 = new S2LevelRange(
+ SuffixTableRange entry1 = new SuffixTableRange(
fileFormat.createCellId(tablePrefix, 1001),
fileFormat.createCellId(tablePrefix, 1101));
suffixTableWriter.addRange(entry1);
- S2LevelRange entry2 = new S2LevelRange(
+ SuffixTableRange entry2 = new SuffixTableRange(
fileFormat.createCellId(tablePrefix, 2001),
fileFormat.createCellId(tablePrefix, 2101));
suffixTableWriter.addRange(entry2);
@@ -302,7 +304,7 @@
inOrder.verify(mockVisitor).end();
}
- private S2LevelRange findEntryByCellId(SatS2RangeFileFormat fileFormat,
+ private SuffixTableRange findEntryByCellId(SatS2RangeFileFormat fileFormat,
SuffixTableBlock suffixTableBlock, int prefix, int suffix) {
long cellId = fileFormat.createCellId(prefix, suffix);
SuffixTableBlock.Entry entry = suffixTableBlock.findEntryByCellId(cellId);
diff --git a/utils/satellite/s2storage/src/test/java/com/android/telephony/sats2range/SuffixTableExtraInfoTest.java b/utils/satellite/s2storage/src/test/java/com/android/telephony/sats2range/SuffixTableExtraInfoTest.java
index f992ae7..f978bd5 100644
--- a/utils/satellite/s2storage/src/test/java/com/android/telephony/sats2range/SuffixTableExtraInfoTest.java
+++ b/utils/satellite/s2storage/src/test/java/com/android/telephony/sats2range/SuffixTableExtraInfoTest.java
@@ -20,9 +20,9 @@
import com.android.storage.block.read.BlockInfo;
import com.android.storage.block.write.BlockWriter;
-import com.android.storage.s2.S2LevelRange;
import com.android.telephony.sats2range.read.SatS2RangeFileFormat;
import com.android.telephony.sats2range.read.SuffixTableExtraInfo;
+import com.android.telephony.sats2range.read.SuffixTableRange;
import com.android.telephony.sats2range.read.SuffixTableSharedData;
import com.android.telephony.sats2range.utils.TestUtils;
import com.android.telephony.sats2range.write.SuffixTableWriter;
@@ -54,13 +54,13 @@
SuffixTableWriter.createPopulated(fileFormat, suffixTableSharedData);
int tablePrefix = suffixTableSharedData.getTablePrefix();
- S2LevelRange range1 = new S2LevelRange(
+ SuffixTableRange range1 = new SuffixTableRange(
fileFormat.createCellId(tablePrefix, 1000),
fileFormat.createCellId(tablePrefix, 1001));
- S2LevelRange range2 = new S2LevelRange(
+ SuffixTableRange range2 = new SuffixTableRange(
fileFormat.createCellId(tablePrefix, 1002),
fileFormat.createCellId(tablePrefix, 1003));
- S2LevelRange range3 = new S2LevelRange(
+ SuffixTableRange range3 = new SuffixTableRange(
fileFormat.createCellId(tablePrefix, 1004),
fileFormat.createCellId(tablePrefix, 1005));
diff --git a/utils/satellite/s2storage/src/write/java/com/android/telephony/sats2range/write/SatS2RangeFileWriter.java b/utils/satellite/s2storage/src/write/java/com/android/telephony/sats2range/write/SatS2RangeFileWriter.java
index 9b3c20e..3018aec 100644
--- a/utils/satellite/s2storage/src/write/java/com/android/telephony/sats2range/write/SatS2RangeFileWriter.java
+++ b/utils/satellite/s2storage/src/write/java/com/android/telephony/sats2range/write/SatS2RangeFileWriter.java
@@ -19,9 +19,9 @@
import com.android.storage.block.write.BlockFileWriter;
import com.android.storage.block.write.BlockWriter;
import com.android.storage.block.write.EmptyBlockWriter;
-import com.android.storage.s2.S2LevelRange;
import com.android.storage.s2.S2Support;
import com.android.telephony.sats2range.read.SatS2RangeFileFormat;
+import com.android.telephony.sats2range.read.SuffixTableRange;
import com.android.telephony.sats2range.read.SuffixTableSharedData;
import java.io.File;
@@ -64,8 +64,8 @@
* needed to fit them into suffix blocks. The ranges must be of the expected S2 level
* and ordered by cell ID.
*/
- public void createSortedSuffixBlocks(Iterator<S2LevelRange> ranges) throws IOException {
- PushBackIterator<S2LevelRange> pushBackIterator = new PushBackIterator<>(ranges);
+ public void createSortedSuffixBlocks(Iterator<SuffixTableRange> ranges) throws IOException {
+ PushBackIterator<SuffixTableRange> pushBackIterator = new PushBackIterator<>(ranges);
// For each prefix value, collect all the ranges that match.
for (int currentPrefix = 0;
@@ -74,7 +74,7 @@
// Step 1:
// populate samePrefixRanges, which holds ranges that have a prefix of currentPrefix.
- List<S2LevelRange> samePrefixRanges =
+ List<SuffixTableRange> samePrefixRanges =
collectSamePrefixRanges(pushBackIterator, currentPrefix);
// Step 2: Write samePrefixRanges to a suffix table.
@@ -88,11 +88,11 @@
}
}
- private List<S2LevelRange> collectSamePrefixRanges(
- PushBackIterator<S2LevelRange> pushBackIterator, int currentPrefix) {
- List<S2LevelRange> samePrefixRanges = new ArrayList<>();
+ private List<SuffixTableRange> collectSamePrefixRanges(
+ PushBackIterator<SuffixTableRange> pushBackIterator, int currentPrefix) {
+ List<SuffixTableRange> samePrefixRanges = new ArrayList<>();
while (pushBackIterator.hasNext()) {
- S2LevelRange currentRange = pushBackIterator.next();
+ SuffixTableRange currentRange = pushBackIterator.next();
long startCellId = currentRange.getStartCellId();
if (mFileFormat.getS2Level() != S2Support.getS2Level(startCellId)) {
@@ -123,17 +123,18 @@
// Create a range for the current prefix.
{
long newEndCellId = mFileFormat.createCellId(startCellPrefix + 1, 0);
- S2LevelRange satS2Range = new S2LevelRange(startCellId, newEndCellId);
+ SuffixTableRange satS2Range = new SuffixTableRange(startCellId, newEndCellId);
samePrefixRanges.add(satS2Range);
}
- Deque<S2LevelRange> otherRanges = new ArrayDeque<>();
+ Deque<SuffixTableRange> otherRanges = new ArrayDeque<>();
// Intermediate prefixes.
startCellPrefix = startCellPrefix + 1;
while (startCellPrefix != endCellPrefixValue) {
long newStartCellId = mFileFormat.createCellId(startCellPrefix, 0);
long newEndCellId = mFileFormat.createCellId(startCellPrefix + 1, 0);
- S2LevelRange satS2Range = new S2LevelRange(newStartCellId, newEndCellId);
+ SuffixTableRange satS2Range = new SuffixTableRange(newStartCellId,
+ newEndCellId);
otherRanges.add(satS2Range);
startCellPrefix++;
}
@@ -142,7 +143,8 @@
{
long newStartCellId = mFileFormat.createCellId(endCellPrefixValue, 0);
if (newStartCellId != endCellId) {
- S2LevelRange satS2Range = new S2LevelRange(newStartCellId, endCellId);
+ SuffixTableRange satS2Range = new SuffixTableRange(newStartCellId,
+ endCellId);
otherRanges.add(satS2Range);
}
}
@@ -160,7 +162,7 @@
}
private BlockWriter writeSamePrefixRanges(
- int currentPrefix, List<S2LevelRange> samePrefixRanges) throws IOException {
+ int currentPrefix, List<SuffixTableRange> samePrefixRanges) throws IOException {
BlockWriter blockWriter;
if (samePrefixRanges.size() == 0) {
// Add an empty block.
@@ -170,8 +172,8 @@
SuffixTableSharedData sharedData = new SuffixTableSharedData(currentPrefix);
SuffixTableWriter suffixTableWriter =
SuffixTableWriter.createPopulated(mFileFormat, sharedData);
- S2LevelRange lastRange = null;
- for (S2LevelRange currentRange : samePrefixRanges) {
+ SuffixTableRange lastRange = null;
+ for (SuffixTableRange currentRange : samePrefixRanges) {
// Validate ranges don't overlap.
if (lastRange != null) {
if (lastRange.overlaps(currentRange)) {
@@ -188,12 +190,13 @@
int rangeLength = mFileFormat.calculateRangeLength(startCellId, endCellId);
while (rangeLength > maxRangeLength) {
long newEndCellId = S2Support.offsetCellId(startCellId, maxRangeLength);
- S2LevelRange suffixTableRange = new S2LevelRange(startCellId, newEndCellId);
+ SuffixTableRange suffixTableRange = new SuffixTableRange(startCellId,
+ newEndCellId);
suffixTableWriter.addRange(suffixTableRange);
startCellId = newEndCellId;
rangeLength = mFileFormat.calculateRangeLength(startCellId, endCellId);
}
- S2LevelRange suffixTableRange = new S2LevelRange(startCellId, endCellId);
+ SuffixTableRange suffixTableRange = new SuffixTableRange(startCellId, endCellId);
suffixTableWriter.addRange(suffixTableRange);
}
blockWriter = suffixTableWriter;
diff --git a/utils/satellite/s2storage/src/write/java/com/android/telephony/sats2range/write/SuffixTableWriter.java b/utils/satellite/s2storage/src/write/java/com/android/telephony/sats2range/write/SuffixTableWriter.java
index dc265d5..31b35eb 100644
--- a/utils/satellite/s2storage/src/write/java/com/android/telephony/sats2range/write/SuffixTableWriter.java
+++ b/utils/satellite/s2storage/src/write/java/com/android/telephony/sats2range/write/SuffixTableWriter.java
@@ -22,11 +22,11 @@
import com.android.storage.block.write.BlockWriter;
import com.android.storage.block.write.EmptyBlockWriter;
import com.android.storage.io.write.TypedOutputStream;
-import com.android.storage.s2.S2LevelRange;
import com.android.storage.s2.S2Support;
import com.android.storage.table.packed.write.PackedTableWriter;
import com.android.telephony.sats2range.read.SatS2RangeFileFormat;
import com.android.telephony.sats2range.read.SuffixTableExtraInfo;
+import com.android.telephony.sats2range.read.SuffixTableRange;
import com.android.telephony.sats2range.read.SuffixTableSharedData;
import java.io.ByteArrayOutputStream;
@@ -42,7 +42,7 @@
* To write empty tables use {@link #createEmptyBlockWriter()}.
* To write populated tables use {@link
* #createPopulated(SatS2RangeFileFormat, SuffixTableSharedData)} and add entries with
- * {@link #addRange(S2LevelRange)}
+ * {@link #addRange(SuffixTableRange)}
*/
public final class SuffixTableWriter implements BlockWriter {
@@ -54,7 +54,7 @@
private final File mFile;
- private S2LevelRange mLastRangeAdded;
+ private SuffixTableRange mLastRangeAdded;
private SuffixTableWriter(SatS2RangeFileFormat fileFormat, SuffixTableSharedData sharedData)
throws IOException {
@@ -90,7 +90,7 @@
* called at least once. See {@link SuffixTableWriter#createEmptyBlockWriter()} for empty
* tables.
*/
- public void addRange(S2LevelRange suffixTableRange) throws IOException {
+ public void addRange(SuffixTableRange suffixTableRange) throws IOException {
checkIsOpen();
long rangeStartCellId = suffixTableRange.getStartCellId();
diff --git a/utils/satellite/tools/src/main/java/com/android/telephony/tools/sats2/CreateTestSatS2File.java b/utils/satellite/tools/src/main/java/com/android/telephony/tools/sats2/CreateTestSatS2File.java
index f9a9347..41ce416 100644
--- a/utils/satellite/tools/src/main/java/com/android/telephony/tools/sats2/CreateTestSatS2File.java
+++ b/utils/satellite/tools/src/main/java/com/android/telephony/tools/sats2/CreateTestSatS2File.java
@@ -16,8 +16,8 @@
package com.android.telephony.tools.sats2;
-import com.android.storage.s2.S2LevelRange;
import com.android.telephony.sats2range.read.SatS2RangeFileFormat;
+import com.android.telephony.sats2range.read.SuffixTableRange;
import com.android.telephony.sats2range.write.SatS2RangeFileWriter;
import java.io.File;
@@ -42,18 +42,18 @@
try (SatS2RangeFileWriter satS2RangeFileWriter =
SatS2RangeFileWriter.open(file, fileFormat)) {
// Two ranges that share a prefix.
- S2LevelRange range1 = new S2LevelRange(
+ SuffixTableRange range1 = new SuffixTableRange(
fileFormat.createCellId(0b100_11111111, 1000),
fileFormat.createCellId(0b100_11111111, 2000));
- S2LevelRange range2 = new S2LevelRange(
+ SuffixTableRange range2 = new SuffixTableRange(
fileFormat.createCellId(0b100_11111111, 2000),
fileFormat.createCellId(0b100_11111111, 3000));
// This range has a different face, so a different prefix, and will be in a different
// suffix table.
- S2LevelRange range3 = new S2LevelRange(
+ SuffixTableRange range3 = new SuffixTableRange(
fileFormat.createCellId(0b101_11111111, 1000),
fileFormat.createCellId(0b101_11111111, 2000));
- List<S2LevelRange> allRanges = listOf(range1, range2, range3);
+ List<SuffixTableRange> allRanges = listOf(range1, range2, range3);
satS2RangeFileWriter.createSortedSuffixBlocks(allRanges.iterator());
}
}
diff --git a/utils/satellite/tools/src/main/java/com/android/telephony/tools/sats2/SatS2FileCreator.java b/utils/satellite/tools/src/main/java/com/android/telephony/tools/sats2/SatS2FileCreator.java
index dd7d8c0..1ed9680 100644
--- a/utils/satellite/tools/src/main/java/com/android/telephony/tools/sats2/SatS2FileCreator.java
+++ b/utils/satellite/tools/src/main/java/com/android/telephony/tools/sats2/SatS2FileCreator.java
@@ -16,9 +16,9 @@
package com.android.telephony.tools.sats2;
-import com.android.storage.s2.S2LevelRange;
import com.android.telephony.sats2range.read.SatS2RangeFileFormat;
import com.android.telephony.sats2range.read.SatS2RangeFileReader;
+import com.android.telephony.sats2range.read.SuffixTableRange;
import com.android.telephony.sats2range.write.SatS2RangeFileWriter;
import com.google.common.base.Stopwatch;
@@ -73,15 +73,15 @@
FileFormats.getFileFormatForLevel(s2Level, isAllowedList);
try (SatS2RangeFileWriter satS2RangeFileWriter =
SatS2RangeFileWriter.open(new File(outputFile), fileFormat)) {
- Iterator<S2LevelRange> s2LevelRangeIterator = satS2Ranges
+ Iterator<SuffixTableRange> suffixTableRangeIterator = satS2Ranges
.stream()
- .map(x -> new S2LevelRange(x.rangeStart.id(), x.rangeEnd.id()))
+ .map(x -> new SuffixTableRange(x.rangeStart.id(), x.rangeEnd.id()))
.iterator();
/*
* Group the sorted ranges into contiguous suffix blocks. Big ranges might get split as
* needed to fit them into suffix blocks.
*/
- satS2RangeFileWriter.createSortedSuffixBlocks(s2LevelRangeIterator);
+ satS2RangeFileWriter.createSortedSuffixBlocks(suffixTableRangeIterator);
}
// Validate the output block file