Merge "IMS: Disable TTY settings during call" am: 7e00f5a7ed am: 612b9697dd
am: 1c076c6157

Change-Id: Ia4d5f60bc34311b977fe8af3d9b64ee0574e6e9b
diff --git a/src/com/android/phone/settings/AccessibilitySettingsFragment.java b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
index 57b6d8e..0eb3845 100644
--- a/src/com/android/phone/settings/AccessibilitySettingsFragment.java
+++ b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
@@ -57,10 +57,17 @@
             if (DBG) Log.d(LOG_TAG, "PhoneStateListener.onCallStateChanged: state=" + state);
             Preference pref = getPreferenceScreen().findPreference(BUTTON_TTY_KEY);
             if (pref != null) {
-                final boolean isVolteTtySupported = ImsManager.isVolteEnabledByPlatform(mContext)
-                        && getVolteTtySupported();
-                pref.setEnabled((isVolteTtySupported && !isVideoCallOrConferenceInProgress()) ||
-                        (state == TelephonyManager.CALL_STATE_IDLE));
+                // Use TelephonyManager#getCallState instead of 'state' parameter because
+                // needs to check the current state of all phone calls to
+                // support multi sim configuration.
+                TelephonyManager telephonyManager =
+                        (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+                final boolean isVolteTtySupported = getVolteTtySupported();
+                final boolean isVolteCurrentlyEnabled =
+                        ImsManager.isVolteEnabledByPlatform(mContext);
+                pref.setEnabled((isVolteTtySupported && isVolteCurrentlyEnabled &&
+                        !isVideoCallOrConferenceInProgress()) ||
+                        (telephonyManager.getCallState() == TelephonyManager.CALL_STATE_IDLE));
             }
         }
     };