Merge changes from topic "128616035"
* changes:
Adding @hide API to return whether an APN is metered or not.
Providing a way for user to allow MMS data even if mobile data is off.
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 080740f..46c2847 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -141,6 +141,7 @@
import com.android.internal.telephony.SmsApplication.SmsApplicationData;
import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.TelephonyPermissions;
+import com.android.internal.telephony.dataconnection.ApnSettingUtils;
import com.android.internal.telephony.emergency.EmergencyNumberTracker;
import com.android.internal.telephony.euicc.EuiccConnector;
import com.android.internal.telephony.ims.ImsResolver;
@@ -6933,4 +6934,56 @@
if (hv.equals(HalVersion.UNKNOWN)) return -1;
return hv.major * 100 + hv.minor;
}
+
+ /**
+ * Return whether data is enabled for certain APN type. This will tell if framework will accept
+ * corresponding network requests on a subId.
+ *
+ * Data is enabled if:
+ * 1) user data is turned on, or
+ * 2) APN is un-metered for this subscription, or
+ * 3) APN type is whitelisted. E.g. MMS is whitelisted if
+ * {@link SubscriptionManager#setAlwaysAllowMmsData} is turned on.
+ *
+ * @return whether data is allowed for a apn type.
+ *
+ * @hide
+ */
+ @Override
+ public boolean isDataEnabledForApn(int apnType, int subId, String callingPackage) {
+ if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
+ mApp, subId, callingPackage, "isDataEnabledForApn")) {
+ throw new SecurityException("Needs READ_PHONE_STATE for isDataEnabledForApn");
+ }
+
+ // Now that all security checks passes, perform the operation as ourselves.
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ Phone phone = getPhone(subId);
+ if (phone == null) return false;
+
+ boolean isMetered = ApnSettingUtils.isMeteredApnType(ApnSetting.getApnTypeString(
+ apnType), phone);
+ return !isMetered || phone.getDataEnabledSettings().isDataEnabled(apnType);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
+ public boolean isApnMetered(int apnType, int subId) {
+ enforceReadPrivilegedPermission("isApnMetered");
+
+ // Now that all security checks passes, perform the operation as ourselves.
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ Phone phone = getPhone(subId);
+ if (phone == null) return true; // By default return true.
+
+ return ApnSettingUtils.isMeteredApnType(ApnSetting.getApnTypeString(
+ apnType), phone);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
}