Make RTT while roaming configurable

Read a carrier config key to determine whether RTT should be disabled
while roaming.

Bug: 168676696
Test: manual
Change-Id: I318e83b3f8b04ca45ce8696ce7aac6d08a4df9c3
Merged-In: I318e83b3f8b04ca45ce8696ce7aac6d08a4df9c3
diff --git a/src/com/android/phone/settings/AccessibilitySettingsFragment.java b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
index 37212cf..ad3f133 100644
--- a/src/com/android/phone/settings/AccessibilitySettingsFragment.java
+++ b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
@@ -122,8 +122,12 @@
                     (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
             boolean isRoaming = tm.isNetworkRoaming(
                     SubscriptionManager.getDefaultVoiceSubscriptionId());
+            boolean alwaysAllowWhileRoaming = isCarrierAllowRttWhenRoaming(
+                    SubscriptionManager.getDefaultVoiceSubscriptionId());
 
-            boolean shouldDisableBecauseRoamingOffWfc = isRoaming && !isOnWfc();
+            boolean shouldDisableBecauseRoamingOffWfc =
+                    (isRoaming && !isOnWfc()) && !alwaysAllowWhileRoaming;
+
             if (shouldDisableBecauseRoamingOffWfc) {
                 mButtonRtt.setSummary(TextUtils.concat(getText(R.string.rtt_mode_summary), "\n",
                         getText(R.string.no_rtt_when_roaming)));
@@ -277,4 +281,13 @@
         return configManager.getConfig().getBoolean(
                 CarrierConfigManager.KEY_TTY_SUPPORTED_BOOL);
     }
+
+    /**
+     * Determines from carrier config whether to always allow RTT while roaming.
+     */
+    private boolean isCarrierAllowRttWhenRoaming(int subId) {
+        PersistableBundle b =
+                PhoneGlobals.getInstance().getCarrierConfigForSubId(subId);
+        return b.getBoolean(CarrierConfigManager.KEY_RTT_SUPPORTED_WHILE_ROAMING_BOOL);
+    }
 }
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 4edd36d..7d6e65a 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -729,6 +729,15 @@
         }
 
         /**
+         * Determines from carrier config whether to always allow RTT while roaming.
+         */
+        private boolean isCarrierAllowRttWhenRoaming() {
+            PersistableBundle b =
+                    PhoneGlobals.getInstance().getCarrierConfigForSubId(mPhone.getSubId());
+            return b.getBoolean(CarrierConfigManager.KEY_RTT_SUPPORTED_WHILE_ROAMING_BOOL);
+        }
+
+        /**
          * Where a device supports instant lettering and call subjects, retrieves the necessary
          * PhoneAccount extras for those features.
          *
@@ -869,11 +878,15 @@
             boolean isRoaming = mTelephonyManager.isNetworkRoaming(mPhone.getSubId());
             boolean isOnWfc = mPhone.getImsRegistrationTech()
                     == ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN;
+            boolean alwaysAllowWhileRoaming = isCarrierAllowRttWhenRoaming();
 
-            boolean shouldDisableBecauseRoamingOffWfc = isRoaming && !isOnWfc;
+            boolean shouldDisableBecauseRoamingOffWfc =
+                    (isRoaming && !isOnWfc) && !alwaysAllowWhileRoaming;
+
             Log.i(this, "isRttCurrentlySupported -- regular acct,"
                     + " hasVoiceAvailability: " + hasVoiceAvailability + "\n"
                     + " isRttSupported: " + isRttSupported + "\n"
+                    + " alwaysAllowWhileRoaming: " + alwaysAllowWhileRoaming + "\n"
                     + " isRoaming: " + isRoaming + "\n"
                     + " isOnWfc: " + isOnWfc + "\n");