summaryrefslogtreecommitdiff
path: root/core/java/android/content/Context.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/content/Context.java')
-rw-r--r--core/java/android/content/Context.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index c02dcfd3d681..9c60f431b06e 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -46,6 +46,7 @@ import android.app.time.TimeManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.ApplicationInfoFlags;
import android.content.res.AssetManager;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
@@ -6268,6 +6269,23 @@ public abstract class Context {
}
/**
+ * Similar to {@link #createPackageContextAsUser(String, int, UserHandle)}, but also allows
+ * specifying the flags used to retrieve the {@link ApplicationInfo} of the package.
+ *
+ * @hide
+ */
+ @NonNull
+ public Context createPackageContextAsUser(
+ @NonNull String packageName, @CreatePackageOptions int flags, @NonNull UserHandle user,
+ @ApplicationInfoFlags int packageFlags)
+ throws PackageManager.NameNotFoundException {
+ if (Build.IS_ENG) {
+ throw new IllegalStateException("createPackageContextAsUser not overridden!");
+ }
+ return this;
+ }
+
+ /**
* Similar to {@link #createPackageContext(String, int)}, but for the own package with a
* different {@link UserHandle}. For example, {@link #getContentResolver()}
* will open any {@link Uri} as the given user.
@@ -6286,10 +6304,18 @@ public abstract class Context {
/**
* Creates a context given an {@link android.content.pm.ApplicationInfo}.
*
+ * @deprecated use {@link #createPackageContextAsUser(String, int, UserHandle, int)}
+ * If an application caches an ApplicationInfo and uses it to call this method,
+ * the app will not get the most recent version of Runtime Resource Overlays for
+ * that application. To make things worse, the LoadedApk stored in
+ * {@code ActivityThread#mResourcePackages} is updated using the old ApplicationInfo
+ * causing further uses of the cached LoadedApk to return outdated information.
+ *
* @hide
*/
@SuppressWarnings("HiddenAbstractMethod")
@UnsupportedAppUsage
+ @Deprecated
public abstract Context createApplicationContext(ApplicationInfo application,
@CreatePackageOptions int flags) throws PackageManager.NameNotFoundException;