diff options
author | Sooraj Sasindran <sasindran@google.com> | 2020-07-15 01:27:47 -0700 |
---|---|---|
committer | Sooraj Sasindran <sasindran@google.com> | 2020-10-31 16:22:53 +0000 |
commit | 64db0761f7438820945c84d966d0679e2d8de9fe (patch) | |
tree | d9484744c572f1afbd6a8b016276e52653d5e4fb /telephony/java | |
parent | dfaf434b2080323b1b131b17bc0a0622c2349186 (diff) |
Rename setDataEnabledWithReason
1. Rename setDataEnabledWithReason to
setDataEnabledForReasn
2. Allow isDataConnectionAllowed to be accessed by
same apps as isDataEnabledForReason
3. Make these apis public
Bug: 156332911
Test: cts and build
Change-Id: I8672ab8861fdec1854427ee9ce5ad8eec8774608
Merged-In: I8672ab8861fdec1854427ee9ce5ad8eec8774608
Diffstat (limited to 'telephony/java')
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 75 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/ITelephony.aidl | 4 |
2 files changed, 37 insertions, 42 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 5ecd4a2a9d47..0e327b42fe3a 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -9160,7 +9160,7 @@ public class TelephonyManager { * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param enable Whether to enable mobile data. - * @deprecated use setDataEnabledWithReason with reason DATA_ENABLED_REASON_USER instead. + * @deprecated use setDataEnabledForReason with reason DATA_ENABLED_REASON_USER instead. * */ @Deprecated @@ -9172,16 +9172,16 @@ public class TelephonyManager { /** * @hide - * @deprecated use {@link #setDataEnabledWithReason(int, boolean)} instead. + * @deprecated use {@link #setDataEnabledForReason(int, boolean)} instead. */ @SystemApi @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataEnabled(int subId, boolean enable) { try { - setDataEnabledWithReason(subId, DATA_ENABLED_REASON_USER, enable); + setDataEnabledForReason(subId, DATA_ENABLED_REASON_USER, enable); } catch (RuntimeException e) { - Log.e(TAG, "Error calling setDataEnabledWithReason e:" + e); + Log.e(TAG, "Error calling setDataEnabledForReason e:" + e); } } @@ -9390,9 +9390,9 @@ public class TelephonyManager { @SystemApi public boolean getDataEnabled(int subId) { try { - return isDataEnabledWithReason(DATA_ENABLED_REASON_USER); + return isDataEnabledForReason(DATA_ENABLED_REASON_USER); } catch (RuntimeException e) { - Log.e(TAG, "Error calling isDataEnabledWithReason e:" + e); + Log.e(TAG, "Error calling isDataEnabledForReason e:" + e); } return false; } @@ -10952,7 +10952,7 @@ public class TelephonyManager { * * @param enabled control enable or disable carrier data. * @see #resetAllCarrierActions() - * @deprecated use {@link #setDataEnabledWithReason(int, boolean) with + * @deprecated use {@link #setDataEnabledForReason(int, boolean) with * reason {@link #DATA_ENABLED_REASON_CARRIER}} instead. * @hide */ @@ -10961,9 +10961,9 @@ public class TelephonyManager { @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCarrierDataEnabled(boolean enabled) { try { - setDataEnabledWithReason(DATA_ENABLED_REASON_CARRIER, enabled); + setDataEnabledForReason(DATA_ENABLED_REASON_CARRIER, enabled); } catch (RuntimeException e) { - Log.e(TAG, "Error calling setDataEnabledWithReason e:" + e); + Log.e(TAG, "Error calling setDataEnabledForReason e:" + e); } } @@ -11049,7 +11049,7 @@ public class TelephonyManager { /** * Policy control of data connection. Usually used when data limit is passed. * @param enabled True if enabling the data, otherwise disabling. - * @deprecated use {@link #setDataEnabledWithReason(int, boolean) with + * @deprecated use {@link #setDataEnabledForReason(int, boolean) with * reason {@link #DATA_ENABLED_REASON_POLICY}} instead. * @hide */ @@ -11057,9 +11057,9 @@ public class TelephonyManager { @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) public void setPolicyDataEnabled(boolean enabled) { try { - setDataEnabledWithReason(DATA_ENABLED_REASON_POLICY, enabled); + setDataEnabledForReason(DATA_ENABLED_REASON_POLICY, enabled); } catch (RuntimeException e) { - Log.e(TAG, "Error calling setDataEnabledWithReason e:" + e); + Log.e(TAG, "Error calling setDataEnabledForReason e:" + e); } } @@ -11075,36 +11075,28 @@ public class TelephonyManager { /** * To indicate that user enabled or disabled data. - * @hide */ - @SystemApi public static final int DATA_ENABLED_REASON_USER = 0; /** * To indicate that data control due to policy. Usually used when data limit is passed. * Policy data on/off won't affect user settings but will bypass the * settings and turns off data internally if set to {@code false}. - * @hide */ - @SystemApi public static final int DATA_ENABLED_REASON_POLICY = 1; /** * To indicate enable or disable carrier data by the system based on carrier signalling or * carrier privileged apps. Carrier data on/off won't affect user settings but will bypass the * settings and turns off data internally if set to {@code false}. - * @hide */ - @SystemApi public static final int DATA_ENABLED_REASON_CARRIER = 2; /** * To indicate enable or disable data by thermal service. * Thermal data on/off won't affect user settings but will bypass the * settings and turns off data internally if set to {@code false}. - * @hide */ - @SystemApi public static final int DATA_ENABLED_REASON_THERMAL = 3; /** @@ -11133,25 +11125,23 @@ public class TelephonyManager { * has {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} irrespective of * the reason. * @throws IllegalStateException if the Telephony process is not currently available. - * @hide */ @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) - @SystemApi - public void setDataEnabledWithReason(@DataEnabledReason int reason, boolean enabled) { - setDataEnabledWithReason(getSubId(), reason, enabled); + public void setDataEnabledForReason(@DataEnabledReason int reason, boolean enabled) { + setDataEnabledForReason(getSubId(), reason, enabled); } - private void setDataEnabledWithReason(int subId, @DataEnabledReason int reason, + private void setDataEnabledForReason(int subId, @DataEnabledReason int reason, boolean enabled) { try { ITelephony service = getITelephony(); if (service != null) { - service.setDataEnabledWithReason(subId, reason, enabled); + service.setDataEnabledForReason(subId, reason, enabled); } else { throw new IllegalStateException("telephony service is null."); } } catch (RemoteException ex) { - Log.e(TAG, "Telephony#setDataEnabledWithReason RemoteException", ex); + Log.e(TAG, "Telephony#setDataEnabledForReason RemoteException", ex); ex.rethrowFromSystemServer(); } } @@ -11159,9 +11149,11 @@ public class TelephonyManager { /** * Return whether data is enabled for certain reason . * - * If {@link #isDataEnabledWithReason} returns false, it means in data enablement for a + * If {@link #isDataEnabledForReason} returns false, it means in data enablement for a * specific reason is turned off. If any of the reason is off, then it will result in - * bypassing user preference and result in data to be turned off. + * bypassing user preference and result in data to be turned off. Call + * {@link #isDataConnectionAllowed} in order to know whether + * data connection is allowed on the device. * * <p>If this object has been created with {@link #createForSubscriptionId}, applies * to the given subId. Otherwise, applies to @@ -11170,27 +11162,26 @@ public class TelephonyManager { * @param reason the reason the data enable change is taking place * @return whether data is enabled for a reason. * <p>Requires Permission: - * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} or + * {@link android.Manifest.permission#ACCESS_NETWORK_STATE} * @throws IllegalStateException if the Telephony process is not currently available. - * @hide */ @RequiresPermission(anyOf = {android.Manifest.permission.ACCESS_NETWORK_STATE, android.Manifest.permission.READ_PHONE_STATE}) - @SystemApi - public boolean isDataEnabledWithReason(@DataEnabledReason int reason) { - return isDataEnabledWithReason(getSubId(), reason); + public boolean isDataEnabledForReason(@DataEnabledReason int reason) { + return isDataEnabledForReason(getSubId(), reason); } - private boolean isDataEnabledWithReason(int subId, @DataEnabledReason int reason) { + private boolean isDataEnabledForReason(int subId, @DataEnabledReason int reason) { try { ITelephony service = getITelephony(); if (service != null) { - return service.isDataEnabledWithReason(subId, reason); + return service.isDataEnabledForReason(subId, reason); } else { throw new IllegalStateException("telephony service is null."); } } catch (RemoteException ex) { - Log.e(TAG, "Telephony#isDataEnabledWithReason RemoteException", ex); + Log.e(TAG, "Telephony#isDataEnabledForReason RemoteException", ex); ex.rethrowFromSystemServer(); } return false; @@ -11331,10 +11322,14 @@ public class TelephonyManager { * <LI>And possibly others.</LI> * </UL> * @return {@code true} if the overall data connection is allowed; {@code false} if not. - * @hide + * <p>Requires Permission: + * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} or + * {@link android.Manifest.permission#ACCESS_NETWORK_STATE} or + * android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE */ - @SystemApi - @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + @RequiresPermission(anyOf = {android.Manifest.permission.ACCESS_NETWORK_STATE, + android.Manifest.permission.READ_PHONE_STATE, + android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE}) public boolean isDataConnectionAllowed() { boolean retVal = false; try { diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index db3c1b637893..79456360c377 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1008,7 +1008,7 @@ interface ITelephony { * @param reason the reason the data enable change is taking place * @param enable true to turn on, else false */ - void setDataEnabledWithReason(int subId, int reason, boolean enable); + void setDataEnabledForReason(int subId, int reason, boolean enable); /** * Return whether data is enabled for certain reason @@ -1016,7 +1016,7 @@ interface ITelephony { * @param reason the reason the data enable change is taking place * @return true on enabled */ - boolean isDataEnabledWithReason(int subId, int reason); + boolean isDataEnabledForReason(int subId, int reason); /** * Checks if manual network selection is allowed. |