[Satellite] Restrict requestIsSupported only in Manual type

- SatelliteManager#requestIsSupported only can be used in Manual
   conneciton type. Hence add a type check with this API for the
   condition check

Flag: EXEMPT bug fix
Fix: b/395811260
Test: atest pass
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:d033f603b819c5b1264d116648c9f6f00b061320)
Merged-In: Ia9fed86a63dd8fa87cc20a83888b3cabbf28ddd8
Change-Id: Ia9fed86a63dd8fa87cc20a83888b3cabbf28ddd8
This commit is contained in:
tom hsu
2025-03-31 03:38:11 +00:00
committed by Android Build Coastguard Worker
parent e9e45b4a01
commit c8b730509d
2 changed files with 15 additions and 4 deletions

View File

@@ -99,12 +99,19 @@ public class SatelliteSettingsPreferenceCategoryController extends
if (!com.android.internal.telephony.flags.Flags.carrierEnabledSatelliteFlag()) { if (!com.android.internal.telephony.flags.Flags.carrierEnabledSatelliteFlag()) {
return UNSUPPORTED_ON_DEVICE; return UNSUPPORTED_ON_DEVICE;
} }
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
if (!mIsSatelliteSupported.get()) { boolean isSatelliteConnectedTypeIsAuto =
CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC == carrierConfig.getInt(
KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT,
CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC);
// SatelliteManager#requestIsSupported is only supported for manual connection type, so
// if type is auto, this check shall be skipped.
if (!isSatelliteConnectedTypeIsAuto && !mIsSatelliteSupported.get()) {
return UNSUPPORTED_ON_DEVICE; return UNSUPPORTED_ON_DEVICE;
} }
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
boolean isSatelliteSosSupported = false; boolean isSatelliteSosSupported = false;
if (Flags.satelliteOemSettingsUxMigration()) { if (Flags.satelliteOemSettingsUxMigration()) {
isSatelliteSosSupported = carrierConfig.getBoolean(KEY_SATELLITE_ESOS_SUPPORTED_BOOL); isSatelliteSosSupported = carrierConfig.getBoolean(KEY_SATELLITE_ESOS_SUPPORTED_BOOL);
@@ -118,8 +125,7 @@ public class SatelliteSettingsPreferenceCategoryController extends
return AVAILABLE_UNSEARCHABLE; return AVAILABLE_UNSEARCHABLE;
} }
if (CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC == carrierConfig.getInt( if (isSatelliteConnectedTypeIsAuto) {
KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT, CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC)) {
return AVAILABLE_UNSEARCHABLE; return AVAILABLE_UNSEARCHABLE;
} else { } else {
return mCarrierRoamingNtnModeCallback.isSatelliteSmsAvailable() return mCarrierRoamingNtnModeCallback.isSatelliteSmsAvailable()

View File

@@ -77,6 +77,8 @@ public class SatelliteSettingsPreferenceCategoryControllerTest {
CarrierConfigCache.setTestInstance(mContext, mCarrierConfigCache); CarrierConfigCache.setTestInstance(mContext, mCarrierConfigCache);
mController = new SatelliteSettingsPreferenceCategoryController(mContext, KEY); mController = new SatelliteSettingsPreferenceCategoryController(mContext, KEY);
when(mCarrierConfigCache.getConfigForSubId(TEST_SUB_ID)).thenReturn(mPersistableBundle); when(mCarrierConfigCache.getConfigForSubId(TEST_SUB_ID)).thenReturn(mPersistableBundle);
mPersistableBundle.putInt(KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT,
CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC);
when(mContext.getSystemService(SatelliteManager.class)).thenReturn(satelliteManager); when(mContext.getSystemService(SatelliteManager.class)).thenReturn(satelliteManager);
mController.mIsSatelliteSupported.set(true); mController.mIsSatelliteSupported.set(true);
} }
@@ -95,7 +97,10 @@ public class SatelliteSettingsPreferenceCategoryControllerTest {
@Test @Test
@EnableFlags(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG) @EnableFlags(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
public void getAvailabilityStatus_deviceUnsupported_returnUnsupported() { public void getAvailabilityStatus_deviceUnsupported_returnUnsupported() {
mPersistableBundle.putInt(KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT,
CARRIER_ROAMING_NTN_CONNECT_MANUAL);
mController.mIsSatelliteSupported.set(false); mController.mIsSatelliteSupported.set(false);
mController.init(TEST_SUB_ID);
int result = mController.getAvailabilityStatus(TEST_SUB_ID); int result = mController.getAvailabilityStatus(TEST_SUB_ID);