Merge "Make connection events work for conferences" into qt-dev
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 2a5ccc3..3d7a489 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -17,6 +17,7 @@
 package com.android.phone;
 
 import static android.content.pm.PackageManager.PERMISSION_GRANTED;
+import static android.telephony.data.ApnSetting.TYPE_MMS;
 
 import static com.android.internal.telephony.PhoneConstants.SUBSCRIPTION_KEY;
 
@@ -141,6 +142,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;
@@ -4470,16 +4472,6 @@
             }
         }
 
-        // STOPSHIP Revisit PLMN check (b/130253962).
-        //List<String> allowedMccMncs =
-        //        NetworkScanRequestTracker.getAllowedMccMncsForLocationRestrictedScan(mApp);
-        //for (String mccmnc : request.getPlmns()) {
-        //    if (!allowedMccMncs.contains(mccmnc)) {
-        //        return new SecurityException("Requested mccmnc " + mccmnc + " is not known to the"
-        //                + " device and cannot be scanned for without location access.");
-        //    }
-        //}
-
         return null;
     }
 
@@ -6964,4 +6956,31 @@
         if (hv.equals(HalVersion.UNKNOWN)) return -1;
         return hv.major * 100 + hv.minor;
     }
+
+    /**
+     *  Mms is allowed if
+     *  1) user data is turned on, or
+     *  2) Mms is un-metered, or
+     *  3) alwaysAllowMms setting is turned on.
+     */
+    @Override
+    public boolean isMmsDataEnabled(int subId, String callingPackage) {
+        if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
+                mApp, subId, callingPackage, "isMmsDataEnabled")) {
+            throw new SecurityException("Needs READ_PHONE_STATE for isMmsDataEnabled");
+        }
+
+        // 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(
+                    TYPE_MMS), phone);
+            return !isMetered || phone.getDataEnabledSettings().isDataEnabled(TYPE_MMS);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
+    }
 }