Use locale language instead of harcoded langauge

Used the locale language instead of the hardcoded language since
ISO 639 is not a stable standard. Some language codes changed before.

This is part of the cell broadcast language filtering feature
added per U.S. FCC requirement.

Test: Manual
Bug: 110754638, 71497689, 110896497
Merged-In: I3cf42eb037cdbb40597c1053fedb36b478277fc9
Change-Id: I3cf42eb037cdbb40597c1053fedb36b478277fc9
(cherry picked from commit 28e9684705)
(cherry picked from commit 232b237b0f)
This commit is contained in:
Jack Yu
2018-09-17 10:46:40 -07:00
parent c8482b39f1
commit 7dafd0d7e9

View File

@@ -33,6 +33,7 @@ import com.android.internal.telephony.GsmAlphabet;
import com.android.internal.telephony.SmsConstants;
import java.io.UnsupportedEncodingException;
import java.util.Locale;
/**
* Parses a GSM or UMTS format SMS-CB message into an {@link SmsCbMessage} object. The class is
@@ -44,16 +45,34 @@ public class GsmSmsCbMessage {
* Languages in the 0000xxxx DCS group as defined in 3GPP TS 23.038, section 5.
*/
private static final String[] LANGUAGE_CODES_GROUP_0 = {
"de", "en", "it", "fr", "es", "nl", "sv", "da", "pt", "fi", "no", "el", "tr", "hu",
"pl", null
Locale.GERMAN.getLanguage(), // German
Locale.ENGLISH.getLanguage(), // English
Locale.ITALIAN.getLanguage(), // Italian
Locale.FRENCH.getLanguage(), // French
new Locale("es").getLanguage(), // Spanish
new Locale("nl").getLanguage(), // Dutch
new Locale("sv").getLanguage(), // Swedish
new Locale("da").getLanguage(), // Danish
new Locale("pt").getLanguage(), // Portuguese
new Locale("fi").getLanguage(), // Finnish
new Locale("nb").getLanguage(), // Norwegian
new Locale("el").getLanguage(), // Greek
new Locale("tr").getLanguage(), // Turkish
new Locale("hu").getLanguage(), // Hungarian
new Locale("pl").getLanguage(), // Polish
null
};
/**
* Languages in the 0010xxxx DCS group as defined in 3GPP TS 23.038, section 5.
*/
private static final String[] LANGUAGE_CODES_GROUP_2 = {
"cs", "he", "ar", "ru", "is", null, null, null, null, null, null, null, null, null,
null, null
new Locale("cs").getLanguage(), // Czech
new Locale("he").getLanguage(), // Hebrew
new Locale("ar").getLanguage(), // Arabic
new Locale("ru").getLanguage(), // Russian
new Locale("is").getLanguage(), // Icelandic
null, null, null, null, null, null, null, null, null, null, null
};
private static final char CARRIAGE_RETURN = 0x0d;