Explicitly take flags in createContextAsUser()
Bug: 142472686
Test: atest android.content.cts.ContextTest#testCreateContextAsUser
Change-Id: Id2e3d5ffe5887a4916e0872a7e85d62cbb439744
diff --git a/api/system-current.txt b/api/system-current.txt
index 4986aeb..91f2588 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -1358,7 +1358,7 @@
public abstract class Context {
method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public boolean bindServiceAsUser(@RequiresPermission android.content.Intent, android.content.ServiceConnection, int, android.os.UserHandle);
- method @NonNull public android.content.Context createContextAsUser(@NonNull android.os.UserHandle);
+ method @NonNull public android.content.Context createContextAsUser(@NonNull android.os.UserHandle, int);
method public abstract android.content.Context createCredentialProtectedStorageContext();
method @NonNull public android.content.Context createPackageContextAsUser(@NonNull String, int, @NonNull android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException;
method @Nullable public abstract java.io.File getPreloadsFileCache();
diff --git a/api/test-current.txt b/api/test-current.txt
index 47854059..85cf224 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -659,7 +659,7 @@
}
public abstract class Context {
- method @NonNull public android.content.Context createContextAsUser(@NonNull android.os.UserHandle);
+ method @NonNull public android.content.Context createContextAsUser(@NonNull android.os.UserHandle, int);
method @NonNull public android.content.Context createPackageContextAsUser(@NonNull String, int, @NonNull android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract android.view.Display getDisplay();
method public abstract int getDisplayId();
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 39fab63..d5bc9b0 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -2212,9 +2212,9 @@
}
@Override
- public Context createContextAsUser(UserHandle user) {
+ public Context createContextAsUser(UserHandle user, @CreatePackageOptions int flags) {
try {
- return createPackageContextAsUser(getPackageName(), mFlags, user);
+ return createPackageContextAsUser(getPackageName(), flags, user);
} catch (NameNotFoundException e) {
throw new IllegalStateException("Own package not found: package=" + getPackageName());
}
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 2dde3ae..dfd691b 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -5237,7 +5237,7 @@
@SystemApi
@TestApi
@NonNull
- public Context createContextAsUser(@NonNull UserHandle user) {
+ public Context createContextAsUser(@NonNull UserHandle user, @CreatePackageOptions int flags) {
if (Build.IS_ENG) {
throw new IllegalStateException("createContextAsUser not overridden!");
}
diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java
index f7cd51e..7993ea1 100644
--- a/core/java/android/content/ContextWrapper.java
+++ b/core/java/android/content/ContextWrapper.java
@@ -885,8 +885,8 @@
/** @hide */
@Override
- public Context createContextAsUser(UserHandle user) {
- return mBase.createContextAsUser(user);
+ public Context createContextAsUser(UserHandle user, @CreatePackageOptions int flags) {
+ return mBase.createContextAsUser(user, flags);
}
/** @hide */
diff --git a/test-mock/src/android/test/mock/MockContext.java b/test-mock/src/android/test/mock/MockContext.java
index fcd4701..5053cee 100644
--- a/test-mock/src/android/test/mock/MockContext.java
+++ b/test-mock/src/android/test/mock/MockContext.java
@@ -758,7 +758,7 @@
/** {@hide} */
@Override
- public Context createContextAsUser(UserHandle user) {
+ public Context createContextAsUser(UserHandle user, @CreatePackageOptions int flags) {
throw new UnsupportedOperationException();
}