diff options
| author | Pratyush More <pratyushmore@google.com> | 2022-03-17 15:08:27 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2022-03-17 15:08:27 +0000 |
| commit | ef269fabdea83aa4c5bb1af413e6c302603c0270 (patch) | |
| tree | 8418715665cf2f099a417f1ebce4124f60cda299 /core/java/android | |
| parent | 286fd132d616b1402b10cf4515cc681de514db1b (diff) | |
| parent | c6f766d74df955493132148bfa686d9ca37c52c6 (diff) | |
Merge "Add getSystemLocale public API in response to developer feedback." into tm-dev
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/ILocaleManager.aidl | 5 | ||||
| -rw-r--r-- | core/java/android/app/LocaleManager.java | 28 |
2 files changed, 21 insertions, 12 deletions
diff --git a/core/java/android/app/ILocaleManager.aidl b/core/java/android/app/ILocaleManager.aidl index 348cb2d30739..3002c8bb9c3e 100644 --- a/core/java/android/app/ILocaleManager.aidl +++ b/core/java/android/app/ILocaleManager.aidl @@ -40,4 +40,9 @@ import android.os.LocaleList; */ LocaleList getApplicationLocales(String packageName, int userId); + /** + * Returns the current system locales. + */ + LocaleList getSystemLocales(); + }
\ No newline at end of file diff --git a/core/java/android/app/LocaleManager.java b/core/java/android/app/LocaleManager.java index 522dc845f57c..efe9e35d4c64 100644 --- a/core/java/android/app/LocaleManager.java +++ b/core/java/android/app/LocaleManager.java @@ -18,7 +18,6 @@ package android.app; import android.Manifest; import android.annotation.NonNull; -import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.annotation.SystemService; @@ -127,31 +126,36 @@ public class LocaleManager { } /** - * Sets the current system locales to the provided value. + * Returns the current system locales, ignoring app-specific overrides. * - * @hide + * <p><b>Note:</b> Apps should generally access the user's locale preferences as indicated in + * their in-process {@link LocaleList}s. However, in case an app-specific locale is set, this + * method helps cater to rare use-cases which might require specifically knowing the system + * locale. + * + * <p><b>Note:</b> This API is not user-aware. It returns the system locales for the foreground + * user. */ - @TestApi - public void setSystemLocales(@NonNull LocaleList locales) { + @NonNull + public LocaleList getSystemLocales() { try { - Configuration conf = ActivityManager.getService().getConfiguration(); - conf.setLocales(locales); - ActivityManager.getService().updatePersistentConfiguration(conf); + return mService.getSystemLocales(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** - * Returns the current system locales for the device. + * Sets the current system locales to the provided value. * * @hide */ @TestApi - @Nullable - public LocaleList getSystemLocales() { + public void setSystemLocales(@NonNull LocaleList locales) { try { - return ActivityManager.getService().getConfiguration().getLocales(); + Configuration conf = ActivityManager.getService().getConfiguration(); + conf.setLocales(locales); + ActivityManager.getService().updatePersistentConfiguration(conf); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } |
