Merge "Set emergency video calling capability when registering phone accounts." into nyc-dev
am: 419b93b

* commit '419b93b0543aa571c28d39bbc28de2b8ed7a76b4':
  Set emergency video calling capability when registering phone accounts.

Change-Id: Ib0f44c396c3202de278c8e4d13526038f930baec
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index fc4bb4d..c6a121b 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -178,6 +178,10 @@
                 capabilities |= PhoneAccount.CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE;
             }
 
+            if (mIsVideoCapable && isCarrierEmergencyVideoCallsAllowed()) {
+                capabilities |= PhoneAccount.CAPABILITY_EMERGENCY_VIDEO_CALLING;
+            }
+
             mIsVideoPauseSupported = isCarrierVideoPauseSupported();
             Bundle instantLetteringExtras = null;
             if (isCarrierInstantLetteringSupported()) {
@@ -278,6 +282,17 @@
         }
 
         /**
+         * Determines from carrier config whether emergency video calls are supported.
+         *
+         * @return {@code true} if emergency video calls are allowed, {@code false} otherwise.
+         */
+        private boolean isCarrierEmergencyVideoCallsAllowed() {
+            PersistableBundle b =
+                    PhoneGlobals.getInstance().getCarrierConfigForSubId(mPhone.getSubId());
+            return b.getBoolean(CarrierConfigManager.KEY_ALLOW_EMERGENCY_VIDEO_CALLS_BOOL);
+        }
+
+        /**
          * @return The {@linke PhoneAccount} extras associated with the current subscription.
          */
         private Bundle getPhoneAccountExtras() {