summaryrefslogtreecommitdiff
path: root/core/java/android/content/Context.java
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2019-11-20 14:11:19 -0800
committerandroid-build-merger <android-build-merger@google.com>2019-11-20 14:11:19 -0800
commit2dfdf1a4cfcd98ec74be8541b89f026c88771fb5 (patch)
tree6ecf14291731be2d799434c8a07ed0f312308351 /core/java/android/content/Context.java
parent104112d399c22132adda5c18fc3c971eb8655ee5 (diff)
parent056b8f00b70f4c231760c68f3def16c00e32b98f (diff)
Merge "Add Context.createContextAsUser()" am: 63d5e4a0b9
am: 056b8f00b7 Change-Id: I703b0234c75f91ad548a0c431277d684212e0586
Diffstat (limited to 'core/java/android/content/Context.java')
-rw-r--r--core/java/android/content/Context.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index aca8f5d8a4e2..bd678bb00de5 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -5264,8 +5264,9 @@ public abstract class Context {
*/
@SystemApi
@TestApi
+ @NonNull
public Context createPackageContextAsUser(
- String packageName, @CreatePackageOptions int flags, UserHandle user)
+ @NonNull String packageName, @CreatePackageOptions int flags, @NonNull UserHandle user)
throws PackageManager.NameNotFoundException {
if (Build.IS_ENG) {
throw new IllegalStateException("createPackageContextAsUser not overridden!");
@@ -5274,6 +5275,23 @@ public abstract class Context {
}
/**
+ * 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.
+ *
+ * @hide
+ */
+ @SystemApi
+ @TestApi
+ @NonNull
+ public Context createContextAsUser(@NonNull UserHandle user) {
+ if (Build.IS_ENG) {
+ throw new IllegalStateException("createContextAsUser not overridden!");
+ }
+ return this;
+ }
+
+ /**
* Creates a context given an {@link android.content.pm.ApplicationInfo}.
*
* @hide