summaryrefslogtreecommitdiff
path: root/SafetyCenter
diff options
context:
space:
mode:
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