Change isRttSupported to use a subscription ID

Hook up isRttSupported to a TestApi and also change its signature to
take a sub id for multisim compatibility.

Bug: 113069001
Test: manual (on internal)
Change-Id: Iec6df11668448e4538f1672c7b1e00fad957444e
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 4e47bda..70cba7f 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -4370,7 +4370,14 @@
         }
     }
 
-    public boolean isRttSupported() {
+    /**
+     * Determines whether the device currently supports RTT (Real-time text). Based both on carrier
+     * support for the feature and device firmware support.
+     *
+     * @return {@code true} if the device and carrier both support RTT, {@code false} otherwise.
+     */
+    @Override
+    public boolean isRttSupported(int subscriptionId) {
         final long identity = Binder.clearCallingIdentity();
         try {
             boolean isCarrierSupported = mApp.getCarrierConfigForSubId(
@@ -4384,10 +4391,14 @@
         }
     }
 
-    public boolean isRttEnabled() {
+    /**
+     * Determines whether the user has turned on RTT. Only returns true if the device and carrier
+     * both also support RTT.
+     */
+    public boolean isRttEnabled(int subscriptionId) {
         final long identity = Binder.clearCallingIdentity();
         try {
-            return isRttSupported() && Settings.Secure.getInt(
+            return isRttSupported(subscriptionId) && Settings.Secure.getInt(
                     mPhone.getContext().getContentResolver(),
                     Settings.Secure.RTT_CALLING_MODE, 0) != 0;
         } finally {
diff --git a/src/com/android/phone/settings/AccessibilitySettingsFragment.java b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
index 0eb3845..5c614d9 100644
--- a/src/com/android/phone/settings/AccessibilitySettingsFragment.java
+++ b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
@@ -109,7 +109,8 @@
             mButtonHac = null;
         }
 
-        if (PhoneGlobals.getInstance().phoneMgr.isRttSupported()) {
+        if (PhoneGlobals.getInstance().phoneMgr
+                .isRttSupported(SubscriptionManager.getDefaultVoiceSubscriptionId())) {
             // TODO: this is going to be a on/off switch for now. Ask UX about how to integrate
             // this settings with TTY
             boolean rttOn = Settings.Secure.getInt(
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 6b7a002..a0e5530 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -260,7 +260,7 @@
                 extras.putBoolean(PhoneAccount.EXTRA_PLAY_CALL_RECORDING_TONE, true);
             }
 
-            if (PhoneGlobals.getInstance().phoneMgr.isRttEnabled()) {
+            if (PhoneGlobals.getInstance().phoneMgr.isRttEnabled(subId)) {
                 capabilities |= PhoneAccount.CAPABILITY_RTT;
             }
 
@@ -525,7 +525,8 @@
         }
 
         public void updateRttCapability() {
-            boolean isRttEnabled = PhoneGlobals.getInstance().phoneMgr.isRttEnabled();
+            boolean isRttEnabled = PhoneGlobals.getInstance().phoneMgr
+                    .isRttEnabled(mPhone.getSubId());
             boolean oldRttEnabled = mAccount.hasCapabilities(PhoneAccount.CAPABILITY_RTT);
             if (isRttEnabled != oldRttEnabled) {
                 mAccount = registerPstnPhoneAccount(mIsEmergency, mIsDummy);