Add new methods to enable data policies
Add setMobileDataPolicyEnabledStatus and isMobileDataPolicyEnabled.
Old methods to be removed in followup commit.
Bug: 169367013
Test: atest TelephonyManagerTest
Change-Id: I64eb81a80fdf4aaf2183254ea316b5cbc8e6575c
Merged-In: I64eb81a80fdf4aaf2183254ea316b5cbc8e6575c
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index a28130d..ea47bba 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -8399,6 +8399,53 @@
}
@Override
+ public boolean isMobileDataPolicyEnabled(int subscriptionId, int policy) {
+ enforceReadPrivilegedPermission("isMobileDataPolicyEnabled");
+
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ Phone phone = getPhone(subscriptionId);
+ if (phone == null) return false;
+
+ switch (policy) {
+ case TelephonyManager.MOBILE_DATA_POLICY_DATA_ON_NON_DEFAULT_DURING_VOICE_CALL:
+ return phone.getDataEnabledSettings().isDataAllowedInVoiceCall();
+ case TelephonyManager.MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED:
+ return phone.getDataEnabledSettings().isMmsAlwaysAllowed();
+ default:
+ throw new IllegalArgumentException(policy + " is not a valid policy");
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
+ public void setMobileDataPolicyEnabledStatus(int subscriptionId, int policy,
+ boolean enabled) {
+ enforceModifyPermission();
+
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ Phone phone = getPhone(subscriptionId);
+ if (phone == null) return;
+
+ switch (policy) {
+ case TelephonyManager.MOBILE_DATA_POLICY_DATA_ON_NON_DEFAULT_DURING_VOICE_CALL:
+ phone.getDataEnabledSettings().setAllowDataDuringVoiceCall(enabled);
+ break;
+ case TelephonyManager.MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED:
+ phone.getDataEnabledSettings().setAlwaysAllowMmsData(enabled);
+ break;
+ default:
+ throw new IllegalArgumentException(policy + " is not a valid policy");
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
public boolean setDataAllowedDuringVoiceCall(int subId, boolean allow) {
enforceModifyPermission();