diff options
-rw-r--r-- | src/java/com/android/internal/telephony/satellite/SatelliteController.java | 29 | ||||
-rw-r--r-- | tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java | 60 |
2 files changed, 86 insertions, 3 deletions
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteController.java b/src/java/com/android/internal/telephony/satellite/SatelliteController.java index d311b8a663..a39ba91bda 100644 --- a/src/java/com/android/internal/telephony/satellite/SatelliteController.java +++ b/src/java/com/android/internal/telephony/satellite/SatelliteController.java @@ -7927,14 +7927,37 @@ public class SatelliteController extends Handler { } if(carrierTagIds == null) { - plogd("isSatelliteAvailableAtCurrentLocation: tagids for carrier satellite enabled " + - "are not available"); - return false; + String satelliteAccessConfigFile = + getSatelliteAccessConfigurationFileFromOverlayConfig(); + if (TextUtils.isEmpty(satelliteAccessConfigFile)) { + plogd("isSatelliteAvailableAtCurrentLocation: device does not support" + + " custom satellite access configuration per location"); + return true; + } else { + plogd("isSatelliteAvailableAtCurrentLocation: tagids for carrier " + + info.getCarrierName() + ", subId=" + info.getSubscriptionId() + + " are not available"); + return false; + } } return isCarrierSatelliteAvailableAtCurrentLocation(carrierTagIds); } + @Nullable + private String getSatelliteAccessConfigurationFileFromOverlayConfig() { + String satelliteAccessConfigFile = null; + try { + satelliteAccessConfigFile = mContext.getResources().getString( + com.android.internal.R.string.satellite_access_config_file); + } catch (Resources.NotFoundException ex) { + loge("getSatelliteAccessConfigurationFileFromOverlayConfig: got ex=" + ex); + } + + logd("satelliteAccessConfigFile =" + satelliteAccessConfigFile); + return satelliteAccessConfigFile; + } + /** * Compares tagIds and determine if * carrier satellite is available at current location while selecting highest priority profile. 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 2120f4682b..60cd83bcd9 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java @@ -6056,6 +6056,11 @@ public class SatelliteControllerTest extends TelephonyTest { return mLocationServiceEnabled; } + @Override + protected boolean isSatelliteAvailableAtCurrentLocation(@Nullable SubscriptionInfo info) { + return super.isSatelliteAvailableAtCurrentLocation(info); + } + void setSatelliteProvisioned(@Nullable Boolean isProvisioned) { synchronized (mDeviceProvisionLock) { mIsDeviceProvisioned = isProvisioned; @@ -6966,6 +6971,61 @@ public class SatelliteControllerTest extends TelephonyTest { assertTrue(mSatelliteControllerUT.isCarrierRoamingNtnEligible(mPhone)); } + @Test + public void testIsSatelliteAvailableAtCurrentLocation() throws Exception { + SubscriptionInfo ntnOnlySubscriptionInfo = new SubscriptionInfo.Builder() + .setOnlyNonTerrestrialNetwork(true) + .build(); + SubscriptionInfo esosSubscriptionInfo = new SubscriptionInfo.Builder() + .setSatelliteESOSSupported(true) + .build(); + Field currentLocationTagIdsField = SatelliteController.class.getDeclaredField( + "mCurrentLocationTagIds"); + currentLocationTagIdsField.setAccessible(true); + + // Null subscription info + assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation(null)); + + // Satellite is not allowed + mSatelliteControllerUT.setIsSatelliteAllowedState(false); + assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation( + ntnOnlySubscriptionInfo)); + assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation( + esosSubscriptionInfo)); + + // Satellite is allowed + mSatelliteControllerUT.setIsSatelliteAllowedState(true); + assertTrue(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation( + ntnOnlySubscriptionInfo)); + + // Both config_verizon_satellite_enabled_tagids and satellite_access_config_file + // are not configured + assertTrue(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation( + esosSubscriptionInfo)); + + // config_verizon_satellite_enabled_tagids is not configured whereas + // satellite_access_config_file is configured + mContextFixture.putResource( + com.android.internal.R.string.satellite_access_config_file, + "test_satellite_access_config_file"); + assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation( + esosSubscriptionInfo)); + + // Both config_verizon_satellite_enabled_tagids and satellite_access_config_file + // are configured, but mCurrentLocationTagIds is empty + mContextFixture.putIntArrayResource( + R.array.config_verizon_satellite_enabled_tagids, + new int[]{1001}); + assertFalse(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation( + esosSubscriptionInfo)); + + // Both config_verizon_satellite_enabled_tagids and satellite_access_config_file + // are configured, and mCurrentLocationTagIds contains the carrier tag id + currentLocationTagIdsField.set(mSatelliteControllerUT, Arrays.asList(1001)); + assertTrue(mSatelliteControllerUT.isSatelliteAvailableAtCurrentLocation( + esosSubscriptionInfo)); + } + public void testNotifyNtnEligibilityLocationServiceStatusChanged() { // Enable CarrierRoamingNtn mContextFixture.putBooleanResource( |