Merge "Fixes Telephony ProgressDialog to use system theme" into cw-e-dev
diff --git a/res/values/config.xml b/res/values/config.xml
index fa730d4..fbbbcd6 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -212,4 +212,7 @@
 
     <!-- Flag indicating whether to allow pstn phone accounts [DO NOT TRANSLATE] -->
     <bool name="config_pstn_phone_accounts_enabled">true</bool>
+
+    <!-- Flag indicating whether the the emergency phone account should be emergency calls only -->
+    <bool name="config_emergency_account_emergency_calls_only">false</bool>
 </resources>
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 8cee71a..d43a4a0 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -174,9 +174,8 @@
             }
             mIsMergeCallSupported = isCarrierMergeCallSupported();
 
-            if (isEmergency && mContext.getPackageManager().hasSystemFeature(
-                    PackageManager.FEATURE_WATCH)) {
-                // For Wear, we mark the emergency phone account as emergency calls only.
+            if (isEmergency && mContext.getResources().getBoolean(
+                    R.bool.config_emergency_account_emergency_calls_only)) {
                 capabilities |= PhoneAccount.CAPABILITY_EMERGENCY_CALLS_ONLY;
             }
 
@@ -427,8 +426,14 @@
     private void cleanupPhoneAccounts() {
         ComponentName telephonyComponentName =
                 new ComponentName(mContext, TelephonyConnectionService.class);
-        List<PhoneAccountHandle> accountHandles =
-                mTelecomManager.getCallCapablePhoneAccounts(true /* includeDisabled */);
+        // This config indicates whether the emergency account was flagged as emergency calls only
+        // in which case we need to consider all phone accounts, not just the call capable ones.
+        final boolean emergencyCallsOnlyEmergencyAccount = mContext.getResources().getBoolean(
+                R.bool.config_emergency_account_emergency_calls_only);
+        List<PhoneAccountHandle> accountHandles = emergencyCallsOnlyEmergencyAccount
+                ? mTelecomManager.getAllPhoneAccountHandles()
+                : mTelecomManager.getCallCapablePhoneAccounts(true /* includeDisabled */);
+
         for (PhoneAccountHandle handle : accountHandles) {
             if (telephonyComponentName.equals(handle.getComponentName()) &&
                     !hasAccountEntryForPhoneAccount(handle)) {