Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe22c257 authored by Aleksander Morgado's avatar Aleksander Morgado
Browse files

Check voice support using TelephonyManager.isDeviceVoiceCapable()

The isVoiceCapable() method in TelephonyManager, which relied
exclusively on checking the config_voice_capable config setting is now
deprecated. The config_voice_capable config setting is itself
deprecated since VENDOR_API_2024_Q2.

On newer vendor API levels, the isDeviceVoiceCapable() method uses the
new FEATURE_TELEPHONY_CALLING PackageManager flag to report whether a
device is voice capable or not.

NO_IFTTT=Underlying unit tests don't require an update.

Bug: 395714454
Test: mm && atest SettingsRoboTests
Flag: EXEMPT bugfix
Change-Id: I9ba202ded585e64f39391dc557863e26f2f25864
parent a6bd2b9c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ public final class Utils extends com.android.settingslib.Utils {
        if (isTelephonyDisabled(context)) return false;
        final TelephonyManager telephony =
                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return telephony != null && telephony.isVoiceCapable();
        return telephony != null && telephony.isDeviceVoiceCapable();
    }

    /**
+3 −3
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ public class HearingDeviceCallRoutingPreferenceControllerTest {
    public void getAvailabilityStatus_telephonyEnabled_voiceCapable_available() {
        when(mResources.getBoolean(com.android.settings.R.bool.config_show_sim_info))
                .thenReturn(true);
        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
        when(mTelephonyManager.isDeviceVoiceCapable()).thenReturn(true);

        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
    }
@@ -81,7 +81,7 @@ public class HearingDeviceCallRoutingPreferenceControllerTest {
    public void getAvailabilityStatus_telephonyEnabled_notVoiceCapable_unsupported() {
        when(mResources.getBoolean(com.android.settings.R.bool.config_show_sim_info))
                .thenReturn(true);
        when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
        when(mTelephonyManager.isDeviceVoiceCapable()).thenReturn(false);

        assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
    }
@@ -90,7 +90,7 @@ public class HearingDeviceCallRoutingPreferenceControllerTest {
    public void getAvailabilityStatus_telephonyDisabled_voiceCapable_unsupported() {
        when(mResources.getBoolean(com.android.settings.R.bool.config_show_sim_info))
                .thenReturn(false);
        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
        when(mTelephonyManager.isDeviceVoiceCapable()).thenReturn(true);

        assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
    }
+4 −4
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ public class PowerButtonEndsCallPreferenceControllerTest {
        ShadowKeyCharacterMap.setDevicehasKey(true);
        when(mResources.getBoolean(com.android.settings.R.bool.config_show_sim_info))
                .thenReturn(true);
        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
        when(mTelephonyManager.isDeviceVoiceCapable()).thenReturn(true);

        assertThat(mController.getAvailabilityStatus())
                .isEqualTo(BasePreferenceController.AVAILABLE);
@@ -93,7 +93,7 @@ public class PowerButtonEndsCallPreferenceControllerTest {
        ShadowKeyCharacterMap.setDevicehasKey(true);
        when(mResources.getBoolean(com.android.settings.R.bool.config_show_sim_info))
                .thenReturn(true);
        when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
        when(mTelephonyManager.isDeviceVoiceCapable()).thenReturn(false);

        assertThat(mController.getAvailabilityStatus())
                .isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
@@ -104,7 +104,7 @@ public class PowerButtonEndsCallPreferenceControllerTest {
        ShadowKeyCharacterMap.setDevicehasKey(true);
        when(mResources.getBoolean(com.android.settings.R.bool.config_show_sim_info))
                .thenReturn(false);
        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
        when(mTelephonyManager.isDeviceVoiceCapable()).thenReturn(true);

        assertThat(mController.getAvailabilityStatus())
                .isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
@@ -115,7 +115,7 @@ public class PowerButtonEndsCallPreferenceControllerTest {
        ShadowKeyCharacterMap.setDevicehasKey(false);
        when(mResources.getBoolean(com.android.settings.R.bool.config_show_sim_info))
                .thenReturn(true);
        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
        when(mTelephonyManager.isDeviceVoiceCapable()).thenReturn(true);

        assertThat(mController.getAvailabilityStatus())
                .isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+4 −4
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ public class VibrationRampingRingerTogglePreferenceControllerTest {
    public void getAvailabilityStatus_notVoiceCapable_returnUnsupportedOnDevice() {
        when(mResources.getBoolean(com.android.settings.R.bool.config_show_sim_info))
                .thenReturn(true);
        when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
        when(mTelephonyManager.isDeviceVoiceCapable()).thenReturn(false);
        when(mDeviceConfigProvider.isRampingRingerEnabledOnTelephonyConfig()).thenReturn(false);

        assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
@@ -102,7 +102,7 @@ public class VibrationRampingRingerTogglePreferenceControllerTest {
    public void getAvailabilityStatus_telephonyDisabled_returnUnsupportedOnDevice() {
        when(mResources.getBoolean(com.android.settings.R.bool.config_show_sim_info))
                .thenReturn(false);
        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
        when(mTelephonyManager.isDeviceVoiceCapable()).thenReturn(true);
        when(mDeviceConfigProvider.isRampingRingerEnabledOnTelephonyConfig()).thenReturn(false);

        assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
@@ -112,7 +112,7 @@ public class VibrationRampingRingerTogglePreferenceControllerTest {
    public void getAvailabilityStatus_rampingRingerEnabled_returnUnsupportedOnDevice() {
        when(mResources.getBoolean(com.android.settings.R.bool.config_show_sim_info))
                .thenReturn(true);
        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
        when(mTelephonyManager.isDeviceVoiceCapable()).thenReturn(true);
        when(mDeviceConfigProvider.isRampingRingerEnabledOnTelephonyConfig()).thenReturn(true);

        assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
@@ -122,7 +122,7 @@ public class VibrationRampingRingerTogglePreferenceControllerTest {
    public void getAvailabilityStatus_voiceCapableAndRampingRingerDisabled_returnAvailable() {
        when(mResources.getBoolean(com.android.settings.R.bool.config_show_sim_info))
                .thenReturn(true);
        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
        when(mTelephonyManager.isDeviceVoiceCapable()).thenReturn(true);
        when(mDeviceConfigProvider.isRampingRingerEnabledOnTelephonyConfig()).thenReturn(false);

        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+2 −2
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ public class DialPadTonePreferenceControllerTest {
        MockitoAnnotations.initMocks(this);
        when(mContext.getResources()).thenReturn(mResources);
        when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
        when(mTelephonyManager.isDeviceVoiceCapable()).thenReturn(true);
        when(mResources.getBoolean(com.android.settings.R.bool.config_show_sim_info))
                .thenReturn(true);
        when(mSetting.getActivity()).thenReturn(mActivity);
@@ -90,7 +90,7 @@ public class DialPadTonePreferenceControllerTest {

    @Test
    public void isAvailable_notVoiceCapable_shouldReturnFalse() {
        when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
        when(mTelephonyManager.isDeviceVoiceCapable()).thenReturn(false);

        assertThat(mController.isAvailable()).isFalse();
    }
Loading