Merge "Device config for RTT and PhoneAccount capability" am: bdbc6b8b3d am: feb660957b
am: a94cbf294c

Change-Id: Icee758da41debc3a3639de9b47a8889a5b91d6a9
diff --git a/res/values/config.xml b/res/values/config.xml
index 615d43f..b3fc30a 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -232,6 +232,9 @@
          disconnecting the ongoing Telephony call when the call goes active. -->
     <bool name="config_support_handover_from">false</bool>
 
+    <!-- Flag indicating whether the device supports RTT (real-time text) -->
+    <bool name="config_support_rtt">false</bool>
+
     <!-- Flag indicating whether a system app can use video calling fallback if carrier video
          calling is not available. -->
     <bool name="config_support_video_calling_fallback">false</bool>
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index fd89159..cdceda3 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -226,6 +226,12 @@
                         isHandoverFromSupported);
             }
 
+            boolean isDeviceRttSupported = mContext.getResources().getBoolean(
+                    R.bool.config_support_rtt);
+            if (isDeviceRttSupported && isCarrierRttSupported()) {
+                capabilities |= PhoneAccount.CAPABILITY_RTT;
+            }
+
             extras.putBoolean(PhoneAccount.EXTRA_SUPPORTS_VIDEO_CALLING_FALLBACK,
                     mContext.getResources()
                             .getBoolean(R.bool.config_support_video_calling_fallback));
@@ -390,6 +396,12 @@
                     b.getBoolean(CarrierConfigManager.KEY_SUPPORT_VIDEO_CONFERENCE_CALL_BOOL);
         }
 
+        private boolean isCarrierRttSupported() {
+            PersistableBundle b =
+                    PhoneGlobals.getInstance().getCarrierConfigForSubId(mPhone.getSubId());
+            return b != null && b.getBoolean(CarrierConfigManager.KEY_RTT_SUPPORTED_BOOL);
+        }
+
         /**
          * Determines from carrier config whether merging of wifi calls is allowed when VoWIFI is
          * turned off.