Fix missing zone strings in some cases
ICU's TimeZoneNames requires a "canonical" zone ID, otherwise it will return no data. Usually the ID being used is the same as the canonical ID so there's no problem. This change is based on an equivalent fix in the newer SettingsUI code. It is for completeness, to ensure incorrect code is not copied in future. Bug: 155167041 Test: None Change-Id: I2becbebb0213c4aa60031178a760ee12bfb7d295
This commit is contained in:
@@ -242,7 +242,16 @@ public class ZoneGetter {
|
||||
final TimeZoneNames.NameType nameType =
|
||||
tz.inDaylightTime(now) ? TimeZoneNames.NameType.LONG_DAYLIGHT
|
||||
: TimeZoneNames.NameType.LONG_STANDARD;
|
||||
return names.getDisplayName(tz.getID(), nameType, now.getTime());
|
||||
return names.getDisplayName(getCanonicalZoneId(tz), nameType, now.getTime());
|
||||
}
|
||||
|
||||
private static String getCanonicalZoneId(TimeZone timeZone) {
|
||||
final String id = timeZone.getID();
|
||||
final String canonicalId = android.icu.util.TimeZone.getCanonicalID(id);
|
||||
if (canonicalId != null) {
|
||||
return canonicalId;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
private static void appendWithTtsSpan(SpannableStringBuilder builder, CharSequence content,
|
||||
|
||||
Reference in New Issue
Block a user