Add TtsSpan for formatted time.

Talk back will read "Used for 3m" as "Used for 3 meters", but
it will read "Used for 3h 3m" correctly.

This cl add specific Ttsspan if the time only contains "minute"

Bug: 36379530
Test: Run SettingsRoboTests

Change-Id: I033575938cce24221980dddd9d66be4e18804541
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index d04ae8d..f6f980a 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -81,6 +81,8 @@
 import android.telephony.TelephonyManager;
 import android.text.Spannable;
 import android.text.SpannableString;
+import android.text.SpannableStringBuilder;
+import android.text.Spanned;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
 import android.text.style.TtsSpan;
@@ -770,8 +772,9 @@
      * @param withSeconds include seconds?
      * @return the formatted elapsed time
      */
-    public static String formatElapsedTime(Context context, double millis, boolean withSeconds) {
-        StringBuilder sb = new StringBuilder();
+    public static CharSequence formatElapsedTime(Context context, double millis,
+            boolean withSeconds) {
+        SpannableStringBuilder sb = new SpannableStringBuilder();
         int seconds = (int) Math.floor(millis / 1000);
         if (!withSeconds) {
             // Round up.
@@ -812,9 +815,15 @@
                         hours, minutes));
             } else {
                 sb.append(context.getString(R.string.battery_history_minutes_no_seconds, minutes));
+
+                // Add ttsSpan if it only have minute value, because it will be read as "meters"
+                TtsSpan ttsSpan = new TtsSpan.MeasureBuilder().setNumber(minutes)
+                        .setUnit("minute").build();
+                sb.setSpan(ttsSpan, 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
             }
         }
-        return sb.toString();
+
+        return sb;
     }
 
     /**
@@ -1256,4 +1265,5 @@
         return (volume != null) && (volume.getType() == VolumeInfo.TYPE_PRIVATE)
                 && volume.isMountedReadable();
     }
+
 }