From d1430abd066575fc5d72266e922e46d3e28672ac Mon Sep 17 00:00:00 2001 From: Sarah Chin Date: Fri, 16 Apr 2021 12:08:30 -0700 Subject: [PATCH] Set CDMA roaming/subscription mode throws ISE if not CDMA Since the phone can switch to/from CDMA, returning when not CDMA could cause issues later on. This essentially reverts ag/13862397 and updates the documentation to call out more clearly when ISE is thrown. Test: make Fix: 175665470 Change-Id: Ie6ab0fd4b317d66a74a7c667a0ed6a54ee56c150 --- .../android/telephony/TelephonyManager.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index f0771bedc8388..fd74061eac1e0 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -10094,14 +10094,15 @@ public class TelephonyManager { /** * Sets the roaming mode for CDMA phone to the given mode {@code mode}. If the phone is not - * CDMA capable, this method does nothing. + * CDMA capable, this method throws an IllegalStateException. * *

If this object has been created with {@link #createForSubscriptionId}, applies to the * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()} * * @param mode CDMA roaming mode. * @throws SecurityException if the caller does not have the permission. - * @throws IllegalStateException if the Telephony process or radio is not currently available. + * @throws IllegalStateException if the Telephony process or radio is not currently available, + * the device is not CDMA capable, or the request fails. * * @see #CDMA_ROAMING_MODE_RADIO_DEFAULT * @see #CDMA_ROAMING_MODE_HOME @@ -10117,7 +10118,9 @@ public class TelephonyManager { @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCdmaRoamingMode(@CdmaRoamingMode int mode) { - if (getPhoneType() != PHONE_TYPE_CDMA) return; + if (getPhoneType() != PHONE_TYPE_CDMA) { + throw new IllegalStateException("Phone does not support CDMA."); + } try { ITelephony telephony = getITelephony(); if (telephony != null) { @@ -10199,11 +10202,12 @@ public class TelephonyManager { /** * Sets the subscription mode for CDMA phone to the given mode {@code mode}. If the phone is not - * CDMA capable, this method does nothing. + * CDMA capable, this method throws an IllegalStateException. * * @param mode CDMA subscription mode. * @throws SecurityException if the caller does not have the permission. - * @throws IllegalStateException if the Telephony process is not currently available. + * @throws IllegalStateException if the Telephony process or radio is not currently available, + * the device is not CDMA capable, or the request fails. * * @see #CDMA_SUBSCRIPTION_UNKNOWN * @see #CDMA_SUBSCRIPTION_RUIM_SIM @@ -10218,7 +10222,9 @@ public class TelephonyManager { @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCdmaSubscriptionMode(@CdmaSubscription int mode) { - if (getPhoneType() != PHONE_TYPE_CDMA) return; + if (getPhoneType() != PHONE_TYPE_CDMA) { + throw new IllegalStateException("Phone does not support CDMA."); + } try { ITelephony telephony = getITelephony(); if (telephony != null) {