Merge "getSimLocale should return locale rather than string tag"

This commit is contained in:
Chen Xu
2019-02-25 22:26:05 +00:00
committed by Gerrit Code Review
2 changed files with 8 additions and 6 deletions

View File

@@ -6359,7 +6359,7 @@ package android.telephony {
method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public int getRadioPowerState(); method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public int getRadioPowerState();
method public int getSimApplicationState(); method public int getSimApplicationState();
method public int getSimCardState(); method public int getSimCardState();
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getSimLocale(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.Locale getSimLocale();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getSupportedRadioAccessFamily(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getSupportedRadioAccessFamily();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public java.util.List<android.telephony.TelephonyHistogram> getTelephonyHistograms(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public java.util.List<android.telephony.TelephonyHistogram> getTelephonyHistograms();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.UiccSlotInfo[] getUiccSlotsInfo(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.UiccSlotInfo[] getUiccSlotsInfo();

View File

@@ -8640,24 +8640,26 @@ public class TelephonyManager {
/** /**
* Returns a well-formed IETF BCP 47 language tag representing the locale from the SIM, e.g, * Returns a locale based on the country and language from the SIM. Returns {@code null} if
* en-US. Returns {@code null} if no locale could be derived from subscriptions. * no locale could be derived from subscriptions.
* *
* <p>Requires Permission: * <p>Requires Permission:
* {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE}
* *
* @see Locale#toLanguageTag() * @see Locale#toLanguageTag()
* @see Locale#forLanguageTag(String)
* *
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
@Nullable public String getSimLocale() { @Nullable public Locale getSimLocale() {
try { try {
final ITelephony telephony = getITelephony(); final ITelephony telephony = getITelephony();
if (telephony != null) { if (telephony != null) {
return telephony.getSimLocaleForSubscriber(getSubId()); String languageTag = telephony.getSimLocaleForSubscriber(getSubId());
if (!TextUtils.isEmpty(languageTag)) {
return Locale.forLanguageTag(languageTag);
}
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
} }