diff options
author | Elliot Sisteron <elliotsisteron@google.com> | 2023-05-18 11:59:01 +0000 |
---|---|---|
committer | Elliot Sisteron <elliotsisteron@google.com> | 2023-05-18 12:02:40 +0000 |
commit | 8af54622983518325b8b0093ad79aecb19b0b2fe (patch) | |
tree | 9db6396c5f7a007ed7d858b1a4d36f52022ee1fe /SafetyCenter | |
parent | 496ff14a441cfe1b2a8f96fa6a36fb86135cad21 (diff) | |
download | Permission-8af54622983518325b8b0093ad79aecb19b0b2fe.tar.gz |
Fix crash when posting notification on HSUM.
Bug: 283100177
Test: atest SafetyCenterNotificationTest (on hsum)
Relnote: Fix crash in headless system user mode
Change-Id: Iec7e6bb36d00b23bbf8909058870b7f61eb7b2ec
Diffstat (limited to 'SafetyCenter')
-rw-r--r-- | SafetyCenter/ResourcesLib/java/com/android/safetycenter/resources/SafetyCenterResourcesContext.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/SafetyCenter/ResourcesLib/java/com/android/safetycenter/resources/SafetyCenterResourcesContext.java b/SafetyCenter/ResourcesLib/java/com/android/safetycenter/resources/SafetyCenterResourcesContext.java index 5417e7b89..9a77296e2 100644 --- a/SafetyCenter/ResourcesLib/java/com/android/safetycenter/resources/SafetyCenterResourcesContext.java +++ b/SafetyCenter/ResourcesLib/java/com/android/safetycenter/resources/SafetyCenterResourcesContext.java @@ -123,6 +123,21 @@ public class SafetyCenterResourcesContext extends ContextWrapper { contextBase, /* shouldFallbackIfNamedResourceNotFound */ false); } + /** + * Initializes the {@link Context}'s {@link AssetManager}, {@link Resources} and {@link + * Resources.Theme}. + * + * <p>This call is optional as this can also be lazily instantiated. This is useful to ensure + * that resources are loaded prior to interacting with the {@link SafetyCenterResourcesContext}, + * as this code needs to run for the same user as the provided base {@link Context}; which may + * not be the case with a binder call. + */ + public void init() { + mAssetsFromApk = getAssets(); + mResourcesFromApk = getResources(); + mThemeFromApk = getTheme(); + } + /** Get the package name of the Safety Center resources APK. */ @VisibleForTesting @Nullable |