diff options
author | Hall Liu <hallliu@google.com> | 2020-09-25 10:46:54 -0700 |
---|---|---|
committer | Hall Liu <hallliu@google.com> | 2020-10-21 16:23:34 -0700 |
commit | 83bb093cc5fb86ed63a94bfb98f94cbb301663a7 (patch) | |
tree | 91d527f2f0ea6cff91e173fc6aa00f41e51837d4 /telephony/java | |
parent | 9caec7855727db80524ca759dcd24fe75acc64f9 (diff) |
Add new methods for setting mobile data policy
Add isMobileDataPolicyEnabled and setMobileDataPolicyEnabledStatus in
TelephonyManager. These are intended to replace the mms-always-allowed
and data-during-voice-call setters/getters.
Old methods will be removed in a follow up commit.
Fixes: 169367013
Test: atest TelephonyManagerTest
Change-Id: I6033a84f0a0163e460343ebf603d66078455fe38
Merged-In: I6033a84f0a0163e460343ebf603d66078455fe38
Diffstat (limited to 'telephony/java')
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 99 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/ITelephony.aidl | 4 |
2 files changed, 99 insertions, 4 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index fc20f8a4a2fc..1d812f28182e 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -12938,10 +12938,101 @@ public class TelephonyManager { } /** - * Set allowing mobile data during voice call. This is used for allowing data on the non-default - * data SIM. When a voice call is placed on the non-default data SIM on DSDS devices, users will - * not be able to use mobile data. By calling this API, data will be temporarily enabled on the - * non-default data SIM during the life cycle of the voice call. + * Controls whether mobile data on the non-default SIM is allowed during a voice call. + * + * This is used for allowing data on the non-default data SIM when a voice call is placed on + * the non-default data SIM on DSDS devices. If this policy is disabled, users will not be able + * to use mobile data via the non-default data SIM during the call, which may mean no mobile + * data at all since some modem implementations disallow mobile data via the default data SIM + * during voice calls. + * If this policy is enabled, data will be temporarily enabled on the non-default data SIM + * during any voice calls. + * + * This policy can be enabled and disabled via {@link #setMobileDataPolicyEnabledStatus}. + * @hide + */ + @SystemApi + @TestApi + public static final int MOBILE_DATA_POLICY_DATA_ON_NON_DEFAULT_DURING_VOICE_CALL = 1; + + /** + * Controls whether MMS messages bypass the user-specified "mobile data" toggle. + * + * When enabled, requests for connections to the MMS APN will be accepted by telephony even if + * the user has turned "mobile data" off on this specific sim card. {@link #isDataEnabledForApn} + * will also return true for {@link ApnSetting#TYPE_MMS}. + * When disabled, the MMS APN will be governed by the same rules as all other APNs. + * + * This policy can be enabled and disabled via {@link #setMobileDataPolicyEnabledStatus}. + * @hide + */ + @SystemApi + @TestApi + public static final int MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED = 2; + + /** + * @hide + */ + @IntDef(prefix = { "MOBILE_DATA_POLICY_" }, value = { + MOBILE_DATA_POLICY_DATA_ON_NON_DEFAULT_DURING_VOICE_CALL, + MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface MobileDataPolicy { } + + /** + * Enables or disables a piece of mobile data policy. + * + * Enables or disables the mobile data policy specified in {@code policy}. See the detailed + * description of each policy constant for what they do. + * + * @param policy The data policy to enable. + * @param enabled Whether to enable or disable the policy. + * @hide + */ + @SystemApi + @TestApi + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) + public void setMobileDataPolicyEnabledStatus(@MobileDataPolicy int policy, boolean enabled) { + try { + ITelephony service = getITelephony(); + if (service != null) { + service.setMobileDataPolicyEnabledStatus(getSubId(), policy, enabled); + } + } catch (RemoteException ex) { + // This could happen if binder process crashes. + if (!isSystemProcess()) { + ex.rethrowAsRuntimeException(); + } + } + } + + /** + * Fetches the status of a piece of mobile data policy. + * + * @param policy The data policy that you want the status for. + * @return {@code true} if enabled, {@code false} otherwise. + * @hide + */ + @SystemApi + @TestApi + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + public boolean isMobileDataPolicyEnabled(@MobileDataPolicy int policy) { + try { + ITelephony service = getITelephony(); + if (service != null) { + return service.isMobileDataPolicyEnabled(getSubId(), policy); + } + } catch (RemoteException ex) { + // This could happen if binder process crashes. + if (!isSystemProcess()) { + ex.rethrowAsRuntimeException(); + } + } + return false; + } + + /** * * @param allow {@code true} if allowing using data during voice call, {@code false} if * disallowed. diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 934103ebe2b6..7d873b6eecb7 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -2233,6 +2233,10 @@ interface ITelephony { */ String getMmsUAProfUrl(int subId); + void setMobileDataPolicyEnabledStatus(int subscriptionId, int policy, boolean enabled); + + boolean isMobileDataPolicyEnabled(int subscriptionId, int policy); + /** * Set allowing mobile data during voice call. */ |