From d773727bdfcbf6016c9568fbb1b045a8afb5756e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CAnkita?= Date: Thu, 23 Sep 2021 11:36:59 +0000 Subject: [PATCH] Add new broadcast intent action APPLICATION_LOCALE_CHANGED and extra LOCALE_LIST. Also modify javadoc for ACTION_LOCALE_CHANGED to include application locale changed broadcast info. Test: builds Bug: 200926920 Change-Id: I4e1fa1fc1b60bb906fc9407cb64c53527271aa95 --- core/api/current.txt | 2 ++ core/java/android/content/Intent.java | 43 ++++++++++++++++++++++++++- core/res/AndroidManifest.xml | 1 + 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/core/api/current.txt b/core/api/current.txt index a1f6352776460..9370be907b17b 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -11078,6 +11078,7 @@ package android.content { field public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE"; field public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS"; field public static final String ACTION_ANSWER = "android.intent.action.ANSWER"; + field public static final String ACTION_APPLICATION_LOCALE_CHANGED = "android.intent.action.APPLICATION_LOCALE_CHANGED"; field public static final String ACTION_APPLICATION_PREFERENCES = "android.intent.action.APPLICATION_PREFERENCES"; field public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED = "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED"; field public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR"; @@ -11298,6 +11299,7 @@ package android.content { field public static final String EXTRA_INSTALLER_PACKAGE_NAME = "android.intent.extra.INSTALLER_PACKAGE_NAME"; field public static final String EXTRA_INTENT = "android.intent.extra.INTENT"; field public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT"; + field public static final String EXTRA_LOCALE_LIST = "android.intent.extra.LOCALE_LIST"; field public static final String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY"; field public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID"; field public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES"; diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 335e703ddacd9..896bf9ce2de42 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -2098,6 +2098,14 @@ public class Intent implements Parcelable, Cloneable { */ public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME"; + /** + * Intent extra: A {@link android.os.LocaleList} + *

+ * Type: LocaleList + *

+ */ + public static final String EXTRA_LOCALE_LIST = "android.intent.extra.LOCALE_LIST"; + /** * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}. @@ -3070,13 +3078,46 @@ public class Intent implements Parcelable, Cloneable { public static final String ACTION_SPLIT_CONFIGURATION_CHANGED = "android.intent.action.SPLIT_CONFIGURATION_CHANGED"; /** - * Broadcast Action: The current device's locale has changed. + * Broadcast Action: The receiver's effective locale has changed. + * + * This happens when the device locale, or the + * {(TODO: will only compile after ag/15518063) @link LocaleManager#setApplicationLocales} + * receiving app's locale changed. + * + * Can be received by manifest-declared receivers. + * + *

If only the app locale changed, includes the following extras: + *

* *

This is a protected intent that can only be sent * by the system. */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED"; + /** + * Broadcast Action: Locale of a particular app has changed. + * + *

This broadcast is explicitly sent to the + * {@link android.content.pm.InstallSourceInfo#getInstallingPackageName} installer + * of the app whose locale has changed. + *

The broadcast could also be received by manifest-declared receivers with + * {@code android.permission.READ_APP_SPECIFIC_LOCALES} + * + *

This is a protected intent that can only be sent + * by the system. + * + *

Includes the following extras: + *

+ */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_APPLICATION_LOCALE_CHANGED = + "android.intent.action.APPLICATION_LOCALE_CHANGED"; /** * Broadcast Action: This is a sticky broadcast containing the * charging state, level, and other information about the battery. diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index c1de2f42c0154..c8d70a8fcb69d 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -64,6 +64,7 @@ +