Expose accessibility config on PhoneInterfaceManager.

+ Add methods to PhoneInterfaceManager, so that elsewhere in the
system applications can tell whether TTY mode or HAC are supported
by querying the TelephonyManager.
+ Updated some usages/exposure of configs in Telephony.
+ Some styling/capitalization fixes.

Bug: 19372734
Change-Id: I5e56d45156c5a89cf519e2d2dada5fc23ffdb639
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index 6d3b252..8b3f482 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -1163,7 +1163,7 @@
             mButtonAutoRetry = null;
         }
 
-        if (!getResources().getBoolean(R.bool.world_phone)) {
+        if (!PhoneGlobals.getInstance().phoneMgr.isWorldPhone()) {
             Preference cdmaOptions = prefSet.findPreference(BUTTON_CDMA_OPTIONS);
             prefSet.removePreference(cdmaOptions);
 
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 94a4661..d3e8829 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -144,7 +144,7 @@
     CallNotifier notifier;
     CallerInfoCache callerInfoCache;
     NotificationMgr notificationMgr;
-    PhoneInterfaceManager phoneMgr;
+    public PhoneInterfaceManager phoneMgr;
 
     private BluetoothManager bluetoothManager;
     private CallGatewayManager callGatewayManager;
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 2162c36..2f75089 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -36,6 +36,7 @@
 import android.preference.PreferenceManager;
 import android.provider.Settings;
 import android.telecom.PhoneAccount;
+import android.telecom.TelecomManager;
 import android.telephony.CellInfo;
 import android.telephony.IccOpenLogicalChannelResponse;
 import android.telephony.NeighboringCellInfo;
@@ -2245,6 +2246,19 @@
         return mPhone.getContext().getResources().getBoolean(R.bool.world_phone);
     }
 
+    @Override
+    public boolean isTtyModeSupported() {
+        TelecomManager telecomManager = TelecomManager.from(mPhone.getContext());
+        TelephonyManager telephonyManager =
+                (TelephonyManager) mPhone.getContext().getSystemService(Context.TELEPHONY_SERVICE);
+        return !telephonyManager.isMultiSimEnabled() && telecomManager.isTtySupported();
+    }
+
+    @Override
+    public boolean isHearingAidCompatibilitySupported() {
+        return mPhone.getContext().getResources().getBoolean(R.bool.hac_enabled);
+    }
+
     /**
      * Returns the unique device ID of phone, for example, the IMEI for
      * GSM and the MEID for CDMA phones. Return null if device ID is not available.
diff --git a/src/com/android/phone/settings/AccessibilitySettingsFragment.java b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
index 4d78026..fdb0cd5 100644
--- a/src/com/android/phone/settings/AccessibilitySettingsFragment.java
+++ b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
@@ -43,7 +43,7 @@
 
     private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
         /**
-         * Enable/disable the TTY setting when in/out of a call (and if carrier doesn't
+         * Disable the TTY setting when in/out of a call (and if carrier doesn't
          * support VoLTE with TTY).
          * @see android.telephony.PhoneStateListener#onCallStateChanged(int,
          * java.lang.String)
@@ -61,8 +61,8 @@
     private Context mContext;
     private AudioManager mAudioManager;
 
-    private TtyModeListPreference mButtonTTY;
-    private CheckBoxPreference mButtonHAC;
+    private TtyModeListPreference mButtonTty;
+    private CheckBoxPreference mButtonHac;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -73,36 +73,33 @@
 
         addPreferencesFromResource(R.xml.accessibility_settings);
 
-        mButtonTTY = (TtyModeListPreference) findPreference(
+        mButtonTty = (TtyModeListPreference) findPreference(
                 getResources().getString(R.string.tty_mode_key));
-        mButtonHAC = (CheckBoxPreference) findPreference(BUTTON_HAC_KEY);
+        mButtonHac = (CheckBoxPreference) findPreference(BUTTON_HAC_KEY);
 
-        TelecomManager telecomManager = TelecomManager.from(mContext);
-        TelephonyManager telephonyManager =
-                (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
-
-        if (!telephonyManager.isMultiSimEnabled() && telecomManager.isTtySupported()) {
-            mButtonTTY.init();
+        if (PhoneGlobals.getInstance().phoneMgr.isTtyModeSupported()) {
+            mButtonTty.init();
         } else {
-            getPreferenceScreen().removePreference(mButtonTTY);
-            mButtonTTY = null;
+            getPreferenceScreen().removePreference(mButtonTty);
+            mButtonTty = null;
         }
 
-        if (getResources().getBoolean(R.bool.hac_enabled)) {
+        if (PhoneGlobals.getInstance().phoneMgr.isHearingAidCompatibilitySupported()) {
             int hac = Settings.System.getInt(mContext.getContentResolver(),
                     Settings.System.HEARING_AID, SettingsConstants.HAC_DISABLED);
-            mButtonHAC.setChecked(hac == SettingsConstants.HAC_ENABLED);
+            mButtonHac.setChecked(hac == SettingsConstants.HAC_ENABLED);
         } else {
-            getPreferenceScreen().removePreference(mButtonHAC);
-            mButtonHAC = null;
+            getPreferenceScreen().removePreference(mButtonHac);
+            mButtonHac = null;
         }
     }
 
     @Override
     public void onResume() {
         super.onResume();
+
         if (ImsManager.isVolteEnabledByPlatform(mContext) &&
-                mContext.getResources().getBoolean(
+                !mContext.getResources().getBoolean(
                         com.android.internal.R.bool.config_carrier_volte_tty_supported)) {
             TelephonyManager tm =
                     (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
@@ -125,10 +122,10 @@
 
     @Override
     public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
-        if (preference == mButtonTTY) {
+        if (preference == mButtonTty) {
             return true;
-        } else if (preference == mButtonHAC) {
-            int hac = mButtonHAC.isChecked()
+        } else if (preference == mButtonHac) {
+            int hac = mButtonHac.isChecked()
                     ? SettingsConstants.HAC_ENABLED : SettingsConstants.HAC_DISABLED;
             // Update HAC value in Settings database.
             Settings.System.putInt(mContext.getContentResolver(), Settings.System.HEARING_AID, hac);