Merge "Embms Download setup"
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index a7d0205..f51422c 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -19,7 +19,6 @@
 import static com.android.internal.telephony.PhoneConstants.SUBSCRIPTION_KEY;
 
 import android.Manifest.permission;
-import android.annotation.Nullable;
 import android.app.ActivityManager;
 import android.app.AppOpsManager;
 import android.app.PendingIntent;
@@ -29,6 +28,7 @@
 import android.content.SharedPreferences;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
+import android.net.NetworkStats;
 import android.net.Uri;
 import android.os.AsyncResult;
 import android.os.Binder;
@@ -59,8 +59,8 @@
 import android.telephony.NetworkScanRequest;
 import android.telephony.RadioAccessFamily;
 import android.telephony.ServiceState;
-import android.telephony.SmsManager;
 import android.telephony.SignalStrength;
+import android.telephony.SmsManager;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyHistogram;
@@ -3649,27 +3649,25 @@
     }
 
     /**
-     * Get aggregated video call data usage from all subscriptions since boot.
-     * @return total data usage in bytes
+     * Get aggregated video call data usage since boot.
+     *
+     * @param perUidStats True if requesting data usage per uid, otherwise overall usage.
+     * @return Snapshot of video call data usage
      * {@hide}
      */
     @Override
-    public long getVtDataUsage() {
+    public NetworkStats getVtDataUsage(int subId, boolean perUidStats) {
         mApp.enforceCallingOrSelfPermission(android.Manifest.permission.READ_NETWORK_USAGE_HISTORY,
                 null);
 
-        // NetworkStatsService keeps tracking the active network interface and identity. It will
-        // record the delta with the corresponding network identity. What we need to do here is
-        // returning total video call data usage from all subscriptions since boot.
-
-        // TODO: Add sub id support in the future. We'll need it when we support DSDA and
-        // simultaneous VT calls.
-        final Phone[] phones = PhoneFactory.getPhones();
-        long total = 0;
-        for (Phone phone : phones) {
-            total += phone.getVtDataUsage();
+        // NetworkStatsService keeps tracking the active network interface and identity. It
+        // records the delta with the corresponding network identity. We just return the total video
+        // call data usage snapshot since boot.
+        Phone phone = getPhone(subId);
+        if (phone != null) {
+            return phone.getVtDataUsage(perUidStats);
         }
-        return total;
+        return null;
     }
 
     /**
diff --git a/src/com/android/services/telephony/DisconnectCauseUtil.java b/src/com/android/services/telephony/DisconnectCauseUtil.java
index fcc37f4..727907f 100644
--- a/src/com/android/services/telephony/DisconnectCauseUtil.java
+++ b/src/com/android/services/telephony/DisconnectCauseUtil.java
@@ -20,9 +20,9 @@
 import android.media.ToneGenerator;
 import android.telecom.DisconnectCause;
 
+import com.android.phone.ImsUtil;
 import com.android.phone.PhoneGlobals;
 import com.android.phone.common.R;
-import com.android.phone.ImsUtil;
 
 public class DisconnectCauseUtil {
 
@@ -130,6 +130,7 @@
             case android.telephony.DisconnectCause.DIALED_CALL_FORWARDING_WHILE_ROAMING:
             case android.telephony.DisconnectCause.IMEI_NOT_ACCEPTED:
             case android.telephony.DisconnectCause.WIFI_LOST:
+            case android.telephony.DisconnectCause.IMS_ACCESS_BLOCKED:
                 return DisconnectCause.ERROR;
 
             case android.telephony.DisconnectCause.DIALED_MMI:
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 9ac40fd..a403d1f 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -152,7 +152,8 @@
                     break;
                 case MSG_SUPP_SERVICE_NOTIFY:
                     Log.v(TelephonyConnection.this, "MSG_SUPP_SERVICE_NOTIFY on phoneId : "
-                            +getPhone().getPhoneId());
+                            + getPhone() != null ? Integer.toString(getPhone().getPhoneId())
+                            : "null");
                     SuppServiceNotification mSsNotification = null;
                     if (msg.obj != null && ((AsyncResult) msg.obj).result != null) {
                         mSsNotification =
@@ -1741,7 +1742,7 @@
         boolean isVoWifiEnabled = false;
         if (isIms) {
             ImsPhone imsPhone = (ImsPhone) phone;
-            isVoWifiEnabled = imsPhone.isWifiCallingEnabled();
+            isVoWifiEnabled = ImsUtil.isWfcEnabled(phone.getContext());
         }
         PhoneAccountHandle phoneAccountHandle = isIms ? PhoneUtils
                 .makePstnPhoneAccountHandle(phone.getDefaultPhone())