summaryrefslogtreecommitdiff
path: root/SafetyCenter
diff options
context:
space:
mode:
authorElliot Sisteron <elliotsisteron@google.com>2023-05-18 11:59:01 +0000
committerElliot Sisteron <elliotsisteron@google.com>2023-05-18 12:02:32 +0000
commit7d1fdb7389e121fabefaf23510a99cf585c27f0c (patch)
tree83477b41967c886f1d77aa5b1d07f5002c00e033 /SafetyCenter
parentaf18f36a2f0d7cb1bc5d70c32691c0f2f3aed20f (diff)
downloadPermission-7d1fdb7389e121fabefaf23510a99cf585c27f0c.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.java15
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