diff options
-rw-r--r-- | core/api/system-current.txt | 7 | ||||
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 111 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/ITelephony.aidl | 8 |
3 files changed, 106 insertions, 20 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 3207ca50e6c0..e3e2655aeaa8 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -10114,6 +10114,8 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String getCdmaMin(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String getCdmaMin(int); method public String getCdmaPrlVersion(); + method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getCdmaRoamingMode(); + method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getCdmaSubscriptionMode(); method public int getCurrentPhoneType(); method public int getCurrentPhoneType(int); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getDataActivationState(); @@ -10185,6 +10187,8 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCallWaitingEnabled(boolean, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>); method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCarrierDataEnabled(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setCarrierRestrictionRules(@NonNull android.telephony.CarrierRestrictionRules); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCdmaRoamingMode(int); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCdmaSubscriptionMode(int); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataActivationState(int); method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataEnabled(int, boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataRoamingEnabled(boolean); @@ -10230,6 +10234,9 @@ package android.telephony { field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1 field public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0; // 0x0 field public static final int CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED = -1; // 0xffffffff + field public static final int CDMA_SUBSCRIPTION_NV = 1; // 0x1 + field public static final int CDMA_SUBSCRIPTION_RUIM_SIM = 0; // 0x0 + field public static final int CDMA_SUBSCRIPTION_UNKNOWN = -1; // 0xffffffff field public static final int ENABLE_NR_DUAL_CONNECTIVITY_INVALID_STATE = 4; // 0x4 field public static final int ENABLE_NR_DUAL_CONNECTIVITY_NOT_SUPPORTED = 1; // 0x1 field public static final int ENABLE_NR_DUAL_CONNECTIVITY_RADIO_ERROR = 3; // 0x3 diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index f0274ca68cc1..92dc2fffe6e2 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -9334,11 +9334,22 @@ public class TelephonyManager { * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()} * - * @return one of {@link #CDMA_ROAMING_MODE_RADIO_DEFAULT}, {@link #CDMA_ROAMING_MODE_HOME}, - * {@link #CDMA_ROAMING_MODE_AFFILIATED}, {@link #CDMA_ROAMING_MODE_ANY}. + * @return the CDMA roaming mode. + * @throws SecurityException if the caller does not have the permission. + * @throws IllegalStateException if the Telephony process is not currently available. + * + * @see #CDMA_ROAMING_MODE_RADIO_DEFAULT + * @see #CDMA_ROAMING_MODE_HOME + * @see #CDMA_ROAMING_MODE_AFFILIATED + * @see #CDMA_ROAMING_MODE_ANY + * + * <p>Requires permission: + * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public @CdmaRoamingMode int getCdmaRoamingMode() { int mode = CDMA_ROAMING_MODE_RADIO_DEFAULT; @@ -9346,9 +9357,12 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) { mode = telephony.getCdmaRoamingMode(getSubId()); + } else { + throw new IllegalStateException("telephony service is null."); } } catch (RemoteException ex) { Log.e(TAG, "Error calling ITelephony#getCdmaRoamingMode", ex); + ex.rethrowFromSystemServer(); } return mode; } @@ -9359,25 +9373,36 @@ public class TelephonyManager { * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()} * - * @param mode should be one of {@link #CDMA_ROAMING_MODE_RADIO_DEFAULT}, - * {@link #CDMA_ROAMING_MODE_HOME}, {@link #CDMA_ROAMING_MODE_AFFILIATED}, - * {@link #CDMA_ROAMING_MODE_ANY}. + * @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. * - * @return {@code true} if successed. + * @see #CDMA_ROAMING_MODE_RADIO_DEFAULT + * @see #CDMA_ROAMING_MODE_HOME + * @see #CDMA_ROAMING_MODE_AFFILIATED + * @see #CDMA_ROAMING_MODE_ANY + * + * <p>Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public boolean setCdmaRoamingMode(@CdmaRoamingMode int mode) { + public void setCdmaRoamingMode(@CdmaRoamingMode int mode) { try { ITelephony telephony = getITelephony(); if (telephony != null) { - return telephony.setCdmaRoamingMode(getSubId(), mode); + boolean result = telephony.setCdmaRoamingMode(getSubId(), mode); + if (!result) throw new IllegalStateException("radio is unavailable."); + } else { + throw new IllegalStateException("telephony service is null."); } } catch (RemoteException ex) { Log.e(TAG, "Error calling ITelephony#setCdmaRoamingMode", ex); + ex.rethrowFromSystemServer(); } - return false; } /** @hide */ @@ -9389,48 +9414,94 @@ public class TelephonyManager { @Retention(RetentionPolicy.SOURCE) public @interface CdmaSubscription{} - /** Used for CDMA subscription mode, it'll be UNKNOWN if there is no Subscription source. + /** + * Used for CDMA subscription mode, it'll be UNKNOWN if there is no Subscription source. * @hide */ + @SystemApi public static final int CDMA_SUBSCRIPTION_UNKNOWN = -1; - /** Used for CDMA subscription mode: RUIM/SIM (default) + /** + * Used for CDMA subscription mode: RUIM/SIM (default) * @hide */ + @SystemApi public static final int CDMA_SUBSCRIPTION_RUIM_SIM = 0; - /** Used for CDMA subscription mode: NV -> non-volatile memory + /** + * Used for CDMA subscription mode: NV -> non-volatile memory * @hide */ + @SystemApi public static final int CDMA_SUBSCRIPTION_NV = 1; - /** @hide */ - public static final int PREFERRED_CDMA_SUBSCRIPTION = CDMA_SUBSCRIPTION_RUIM_SIM; + /** + * Gets the subscription mode for CDMA phone. + * + * @return the CDMA subscription mode. + * @throws SecurityException if the caller does not have the permission. + * @throws IllegalStateException if the Telephony process or radio is not currently available. + * + * @see #CDMA_SUBSCRIPTION_UNKNOWN + * @see #CDMA_SUBSCRIPTION_RUIM_SIM + * @see #CDMA_SUBSCRIPTION_NV + * + * <p>Requires Permission: + * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). + * + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + public @CdmaSubscription int getCdmaSubscriptionMode() { + int mode = CDMA_SUBSCRIPTION_RUIM_SIM; + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + mode = telephony.getCdmaSubscriptionMode(getSubId()); + } else { + throw new IllegalStateException("telephony service is null."); + } + } catch (RemoteException ex) { + Log.e(TAG, "Error calling ITelephony#getCdmaSubscriptionMode", ex); + ex.rethrowFromSystemServer(); + } + return mode; + } /** * Sets the subscription mode for CDMA phone to the given mode {@code mode}. * - * @param mode CDMA subscription mode - * - * @return {@code true} if successed. + * @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. * * @see #CDMA_SUBSCRIPTION_UNKNOWN * @see #CDMA_SUBSCRIPTION_RUIM_SIM * @see #CDMA_SUBSCRIPTION_NV * + * <p>Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). + * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public boolean setCdmaSubscriptionMode(@CdmaSubscription int mode) { + public void setCdmaSubscriptionMode(@CdmaSubscription int mode) { try { ITelephony telephony = getITelephony(); if (telephony != null) { - return telephony.setCdmaSubscriptionMode(getSubId(), mode); + boolean result = telephony.setCdmaSubscriptionMode(getSubId(), mode); + if (!result) throw new IllegalStateException("radio is unavailable."); + } else { + throw new IllegalStateException("telephony service is null."); } } catch (RemoteException ex) { Log.e(TAG, "Error calling ITelephony#setCdmaSubscriptionMode", ex); + ex.rethrowFromSystemServer(); } - return false; } /** diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index d16cb16a290c..4895fffa5849 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1799,6 +1799,14 @@ interface ITelephony { boolean setCdmaRoamingMode(int subId, int mode); /** + * Gets the subscription mode for the CDMA phone with the subscription id {@code subId}. + * + * @param the subscription id. + * @return the subscription mode for CDMA phone. + */ + int getCdmaSubscriptionMode(int subId); + + /** * Sets the subscription mode for CDMA phone with the subscription {@code subId} to the given * subscription mode {@code mode}. * |