Migrate <plurals> to ICU plurals

Bug: 199230421
Test: Manual
Change-Id: I6a3c5b5a9937188166013e976684f3fd2579b3f8
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6fda189..1684e89 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1446,19 +1446,19 @@
     <!-- ECM: Displays the time when ECM will end, Example: "No Data Connection until 10:45 AM" -->
     <string name="phone_in_ecm_notification_complete_time">No data connection until <xliff:g id="completeTime">%s</xliff:g></string>
     <!-- ECM: Dialog box message for exiting from the notifications screen -->
-    <plurals name="alert_dialog_exit_ecm">
+    <string name="alert_dialog_exit_ecm"> {count, plural,
         <!-- number of minutes is one -->
-        <item quantity="one">The phone will be in Emergency Callback mode for <xliff:g id="count">%s</xliff:g> minute. While in this mode no apps using a data connection can be used. Do you want to exit now?</item>
+        =1    {The phone will be in Emergency Callback mode for one minute. While in this mode no apps using a data connection can be used. Do you want to exit now?}
         <!-- number of minutes is not equal to one -->
-        <item quantity="other">The phone will be in Emergency Callback mode for <xliff:g id="count">%s</xliff:g> minutes. While in this mode no applications using a data connection can be used. Do you want to exit now?</item>
-    </plurals>
+        other {The phone will be in Emergency Callback mode for %s minutes. While in this mode no applications using a data connection can be used. Do you want to exit now?}
+    }</string>
     <!-- ECM: Dialog box message for exiting from any other app -->
-    <plurals name="alert_dialog_not_avaialble_in_ecm">
+    <string name="alert_dialog_not_avaialble_in_ecm"> {count, plural,
         <!-- number of minutes is one -->
-        <item quantity="one">The selected action isn\'t available while in the Emergency Callback mode. The phone will be in this mode for <xliff:g id="count">%s</xliff:g> minute. Do you want to exit now?</item>
+        =1    {The selected action isn\'t available while in the Emergency Callback mode. The phone will be in this mode for one minute. Do you want to exit now?}
         <!-- number of minutes is not equal to one -->
-        <item quantity="other">The selected action isn\'t available while in the Emergency Callback mode. The phone will be in this mode for <xliff:g id="count">%s</xliff:g> minutes. Do you want to exit now?</item>
-    </plurals>
+        other {The selected action isn\'t available while in the Emergency Callback mode. The phone will be in this mode for %s minutes. Do you want to exit now?}
+    }</string>
     <!-- ECM: Dialog box message while in emergency call -->
     <string name="alert_dialog_in_ecm_call">The selected action isn\'t available while in an emergency call.</string>
     <!-- ECM: Progress text -->
@@ -1474,12 +1474,12 @@
     <!-- ECM: Displays the time when ECM will end without data restriction hint, Example: "Until 10:45 AM" -->
     <string name="phone_in_ecm_notification_complete_time_without_data_restriction_hint">Until <xliff:g id="completeTime">%s</xliff:g></string>
     <!-- ECM: Dialog box message without data restriction hint for exiting from the notifications screen -->
-    <plurals name="alert_dialog_exit_ecm_without_data_restriction_hint">
+    <string name="alert_dialog_exit_ecm_without_data_restriction_hint"> {count, plural,
         <!-- number of minutes is one -->
-        <item quantity="one">The phone will be in emergency callback mode for <xliff:g id="count">%s</xliff:g> minute.\nDo you want to exit now?</item>
+        =1    {The phone will be in emergency callback mode for one minute.\nDo you want to exit now?}
         <!-- number of minutes is not equal to one -->
-        <item quantity="other">The phone will be in emergency callback mode for <xliff:g id="count">%s</xliff:g> minutes.\nDo you want to exit now?</item>
-    </plurals>
+        other {The phone will be in emergency callback mode for %s minutes.\nDo you want to exit now?}
+    }</string>
 
     <!-- For incoming calls, this is a string we can get from a CDMA network instead of
          the actual phone number, to indicate there's no number present.  DO NOT TRANSLATE. -->
diff --git a/src/com/android/phone/EmergencyCallbackModeExitDialog.java b/src/com/android/phone/EmergencyCallbackModeExitDialog.java
index adba850..fc0e513 100644
--- a/src/com/android/phone/EmergencyCallbackModeExitDialog.java
+++ b/src/com/android/phone/EmergencyCallbackModeExitDialog.java
@@ -30,6 +30,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
+import android.icu.text.MessageFormat;
 import android.os.AsyncResult;
 import android.os.Bundle;
 import android.os.CountDownTimer;
@@ -43,6 +44,9 @@
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.TelephonyIntents;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * Displays dialog that enables users to exit Emergency Callback Mode
  *
@@ -297,20 +301,22 @@
         int minutes = (int)(millisUntilFinished / 60000);
         String time = String.format("%d:%02d", minutes,
                 (millisUntilFinished % 60000) / 1000);
+        Map<String, Object> msgArgs = new HashMap<>();
+        msgArgs.put("count", minutes);
 
         switch (mDialogType) {
         case EXIT_ECM_BLOCK_OTHERS:
-            return String.format(getResources().getQuantityText(
-                    R.plurals.alert_dialog_not_avaialble_in_ecm, minutes).toString(), time);
+            return MessageFormat.format(getResources().getString(
+                    R.string.alert_dialog_not_avaialble_in_ecm, time), msgArgs);
         case EXIT_ECM_DIALOG:
                 boolean shouldRestrictData = mPhone.getImsPhone() != null
                         && mPhone.getImsPhone().isInImsEcm();
-                return String.format(getResources().getQuantityText(
+                return MessageFormat.format(getResources().getString(
                         // During IMS ECM, data restriction hint should be removed.
                         shouldRestrictData
-                        ? R.plurals.alert_dialog_exit_ecm_without_data_restriction_hint
-                        : R.plurals.alert_dialog_exit_ecm,
-                        minutes).toString(), time);
+                        ? R.string.alert_dialog_exit_ecm_without_data_restriction_hint
+                        : R.string.alert_dialog_exit_ecm,
+                        time), msgArgs);
         }
         return null;
     }