Enable shortcut view for only specific countries.

- It's impossible to test emergency numbers of all countries in the
  world at once. Shortcut view should be enabled for countries which
  has been, or is going to be tested.
- There are some countries where the combination of categories has a
  meaning. That is, a emergency number labeled with POLICE+FIRE may
  actually equal to "poison control" in a specific country. Since
  DATABASE source should contain normalized categories, and also should
  be well tested before shipping, the concern is eased.

Bug: 123564553
Bug: 123556446
Test: Manually
Change-Id: I9eb8225e23a9049d2e2ab39009b7dc1817351214
diff --git a/res/values/config.xml b/res/values/config.xml
index b1f8ae8..6b6bf04 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -254,6 +254,7 @@
     <!-- Intent action to launch target emergency app. -->
     <string name="config_emergency_app_intent" translatable="false"></string>
 
-    <!-- Flag indicating whether shortcut view of promoted emergency numbers should be enabled. -->
-    <bool name="config_emergency_shortcut_view_enabled">false</bool>
+    <!-- The country list that shortcut view can be enabled. -->
+    <string-array name="config_countries_to_enable_shortcut_view" translatable="false">
+    </string-array>
 </resources>
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index 80b4632..d7443d5 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -810,10 +810,6 @@
     }
 
     private boolean canEnableShortcutView(PersistableBundle carrierConfig) {
-        if (!getResources().getBoolean(R.bool.config_emergency_shortcut_view_enabled)) {
-            // Disables shortcut view by project.
-            return false;
-        }
         if (!carrierConfig.getBoolean(
                 CarrierConfigManager.KEY_SUPPORT_EMERGENCY_DIALER_SHORTCUT_BOOL)) {
             Log.d(LOG_TAG, "Disables shortcut view by carrier requirement");
diff --git a/src/com/android/phone/ShortcutViewUtils.java b/src/com/android/phone/ShortcutViewUtils.java
index 28ee24f..595ea86 100644
--- a/src/com/android/phone/ShortcutViewUtils.java
+++ b/src/com/android/phone/ShortcutViewUtils.java
@@ -96,12 +96,12 @@
             return mPromotedEmergencyNumbers;
         }
 
-        public boolean isSufficientForEmergencyCall() {
+        public boolean isSufficientForEmergencyCall(@NonNull Context context) {
             // Checking mCountryIso because the emergency number list is not reliable to be
             // suggested to users if the device didn't camp to any network. In this case, users
             // can still try to dial emergency numbers with dial pad.
             return mCanPlaceEmergencyCall && mPromotedEmergencyNumbers != null
-                    && !TextUtils.isEmpty(mCountryIso);
+                    && isSupportedCountry(context, mCountryIso);
         }
 
         public boolean hasPromotedEmergencyNumber(String number) {
@@ -166,7 +166,7 @@
         if (defaultHandle != null) {
             PhoneInfo phone = loadPhoneInfo(defaultHandle, telephonyManager, telecomManager,
                     promotedLists);
-            if (phone.isSufficientForEmergencyCall()) {
+            if (phone.isSufficientForEmergencyCall(context)) {
                 return phone;
             }
             Log.w(LOG_TAG, "Default PhoneAccount is insufficient for emergency call: "
@@ -181,7 +181,7 @@
             for (PhoneAccountHandle handle : allHandles) {
                 PhoneInfo phone = loadPhoneInfo(handle, telephonyManager, telecomManager,
                         promotedLists);
-                if (phone.isSufficientForEmergencyCall()) {
+                if (phone.isSufficientForEmergencyCall(context)) {
                     return phone;
                 } else {
                     if (Log.isLoggable(LOG_TAG, Log.DEBUG)) {
@@ -196,6 +196,21 @@
         return null;
     }
 
+    private static boolean isSupportedCountry(@NonNull Context context, String countryIso) {
+        if (TextUtils.isEmpty(countryIso)) {
+            return false;
+        }
+
+        String[] countrysToEnableShortcutView = context.getResources().getStringArray(
+                R.array.config_countries_to_enable_shortcut_view);
+        for (String supportedCountry : countrysToEnableShortcutView) {
+            if (countryIso.equalsIgnoreCase(supportedCountry)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     private static PhoneInfo loadPhoneInfo(@NonNull PhoneAccountHandle handle,
             @NonNull TelephonyManager telephonyManager, @NonNull TelecomManager telecomManager,
             Map<Integer, List<EmergencyNumber>> promotedLists) {