From a722139f9cdf3f3368589cf5667b29e26bd29459 Mon Sep 17 00:00:00 2001 From: Brad Ebinger Date: Thu, 28 Sep 2017 18:00:46 -0700 Subject: Decouple Content Name Locale from Content Language Locale There was an assumption that content language Locale was a 1:1 mapping with content locale name, which is not the case. This change separates the two and provides a new API for retreiving the set of Locales for content name. Test: Manual Bug: 67112896 Merged-In: If87094f15e3a1dfe36d37745ed3d2cf79cc441f1 Change-Id: I44cb527ceb77fe321500f9d5fc00f6880ee52cb7 --- .../java/android/telephony/mbms/ServiceInfo.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/telephony/java/android/telephony/mbms/ServiceInfo.java b/telephony/java/android/telephony/mbms/ServiceInfo.java index 3b9cc0e762eb..9404c19a87e4 100644 --- a/telephony/java/android/telephony/mbms/ServiceInfo.java +++ b/telephony/java/android/telephony/mbms/ServiceInfo.java @@ -23,6 +23,7 @@ import android.os.Parcelable; import android.text.TextUtils; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -63,12 +64,6 @@ public class ServiceInfo { throw new RuntimeException("bad locales length " + newLocales.size()); } - for (Locale l : newLocales) { - if (!newNames.containsKey(l)) { - throw new IllegalArgumentException("A name must be provided for each locale"); - } - } - names = new HashMap(newNames.size()); names.putAll(newNames); className = newClassName; @@ -128,7 +123,7 @@ public class ServiceInfo { * Get the user-displayable name for this cell-broadcast service corresponding to the * provided {@link Locale}. * @param locale The {@link Locale} in which you want the name of the service. This must be a - * value from the list returned by {@link #getLocales()} -- an + * value from the set returned by {@link #getNamedContentLocales()} -- an * {@link java.util.NoSuchElementException} may be thrown otherwise. * @return The {@link CharSequence} providing the name of the service in the given * {@link Locale} @@ -140,6 +135,17 @@ public class ServiceInfo { return names.get(locale); } + /** + * Return an unmodifiable set of the current {@link Locale}s that have a user-displayable name + * associated with them. The user-displayable name associated with any {@link Locale} in this + * set can be retrieved with {@link #getNameForLocale(Locale)}. + * @return An unmodifiable set of {@link Locale} objects corresponding to a user-displayable + * content name in that locale. + */ + public @NonNull Set getNamedContentLocales() { + return Collections.unmodifiableSet(names.keySet()); + } + /** * The class name for this service - used to categorize and filter */ -- cgit v1.2.3-59-g8ed1b