ECBM SystemProperty cleanup

- Add getEmergencyCallbackMode() method to get the boolean
value for ECBM callback mode from the phone, in the
PhoneInterfaceManager.java

- Replace the 'get' of PROPERTY_INECM_MODE system property
in the packages/services/Telephony

Change-Id: Ide35e28b3339f58523bfe92be3c2fdfce111d45e
Test: Manual
Bug: 30361624
diff --git a/src/com/android/phone/CdmaSystemSelectListPreference.java b/src/com/android/phone/CdmaSystemSelectListPreference.java
index 9bc55bd..ca2bc02 100644
--- a/src/com/android/phone/CdmaSystemSelectListPreference.java
+++ b/src/com/android/phone/CdmaSystemSelectListPreference.java
@@ -54,8 +54,7 @@
 
     @Override
     protected void showDialog(Bundle state) {
-        if (Boolean.parseBoolean(
-                    SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {
+        if (mPhone.isInEcm()) {
             // In ECM mode do not show selection options
         } else {
             super.showDialog(state);
diff --git a/src/com/android/phone/EmergencyCallbackModeExitDialog.java b/src/com/android/phone/EmergencyCallbackModeExitDialog.java
index b423e14..f5509b9 100644
--- a/src/com/android/phone/EmergencyCallbackModeExitDialog.java
+++ b/src/com/android/phone/EmergencyCallbackModeExitDialog.java
@@ -80,8 +80,7 @@
 
         mPhone = PhoneGlobals.getInstance().getPhoneInEcm();
         // Check if phone is in Emergency Callback Mode. If not, exit.
-        final boolean isInEcm = Boolean.parseBoolean(
-                SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE));
+        final boolean isInEcm = mPhone.isInEcm();
         Log.i(TAG, "ECMModeExitDialog launched - isInEcm: " + isInEcm + " phone:" + mPhone);
         if (mPhone == null || !isInEcm) {
             finish();
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 8d58107..c817a9b 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -201,8 +201,7 @@
                 return true;
             } else if (mCdmaOptions != null &&
                     mCdmaOptions.preferenceTreeClick(preference) == true) {
-                if (Boolean.parseBoolean(
-                        SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {
+                if (mPhone.isInEcm()) {
 
                     mClickedPreference = preference;
 
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 52c2a79..3f61b34 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -3807,4 +3807,18 @@
             phone.setSimPowerState(powerUp);
         }
     }
+
+    /**
+     * Check if phone is in emergency callback mode
+     * @return true if phone is in emergency callback mode
+     * @param subId sub id
+     */
+    public boolean getEmergencyCallbackMode(int subId) {
+        final Phone phone = getPhone(subId);
+        if (phone != null) {
+            return phone.isInEcm();
+        } else {
+            return false;
+        }
+    }
 }
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 6fdff14..d92d349 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -2175,16 +2175,7 @@
      */
     /* package */ static boolean isPhoneInEcm(Phone phone) {
         if ((phone != null) && TelephonyCapabilities.supportsEcm(phone)) {
-            // For phones that support ECM, return true iff PROPERTY_INECM_MODE == "true".
-            // TODO: There ought to be a better API for this than just
-            // exposing a system property all the way up to the app layer,
-            // probably a method like "inEcm()" provided by the telephony
-            // layer.
-            String ecmMode =
-                    SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE);
-            if (ecmMode != null) {
-                return ecmMode.equals("true");
-            }
+            return phone.isInEcm();
         }
         return false;
     }