Return UNSUPPORTED_ON_DEVICE in network/phonenumber when no telephony

If the device does not have any telephony support (either via the
build-time config_show_sim_info=false boolean flag, or when not
declaring the PackageManager.FEATURE_TELEPHONY_DATA feature flag),
returning UNSUPPORTED_ON_DEVICE makes more sense than
CONDITIONALLY_UNAVAILABLE, as there is no runtime change that would
make it available.

This change also aligns the behavior with the deviceinfo/phonenumber
entry.

Bug: 395714454
Flag: EXEMPT bugfix
Test: atest MobileNetworkPhoneNumberPreferenceControllerTest

Change-Id: I5f2392969fad1884a89de3870ad37be5601fbe37
This commit is contained in:
Aleksander Morgado
2025-02-10 16:03:59 +00:00
parent 90feafb10a
commit a66d27c488
2 changed files with 5 additions and 5 deletions

View File

@@ -44,10 +44,10 @@ constructor(
}
override fun getAvailabilityStatus(subId: Int): Int = when {
!SubscriptionUtil.isSimHardwareVisible(mContext)
|| Utils.isWifiOnly(mContext) -> UNSUPPORTED_ON_DEVICE
!Flags.isDualSimOnboardingEnabled()
|| !SubscriptionManager.isValidSubscriptionId(subId)
|| !SubscriptionUtil.isSimHardwareVisible(mContext)
|| Utils.isWifiOnly(mContext) -> CONDITIONALLY_UNAVAILABLE
|| !SubscriptionManager.isValidSubscriptionId(subId) -> CONDITIONALLY_UNAVAILABLE
!mContext.userManager.isAdminUser -> DISABLED_FOR_USER
else -> AVAILABLE
}

View File

@@ -123,7 +123,7 @@ class MobileNetworkPhoneNumberPreferenceControllerTest {
whenever(SubscriptionUtil.isSimHardwareVisible(context)).thenReturn(false)
val availabilityStatus = controller.availabilityStatus
assertThat(availabilityStatus).isEqualTo(BasePreferenceController.CONDITIONALLY_UNAVAILABLE)
assertThat(availabilityStatus).isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE)
}
@Test
@@ -141,7 +141,7 @@ class MobileNetworkPhoneNumberPreferenceControllerTest {
whenever(Utils.isWifiOnly(context)).thenReturn(true)
val availabilityStatus = controller.availabilityStatus
assertThat(availabilityStatus).isEqualTo(BasePreferenceController.CONDITIONALLY_UNAVAILABLE)
assertThat(availabilityStatus).isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE)
}
private companion object {