Explicitly take flags in createContextAsUser()

Bug: 142472686
Test: atest android.content.cts.ContextTest#testCreateContextAsUser
Change-Id: Id2e3d5ffe5887a4916e0872a7e85d62cbb439744
This commit is contained in:
Makoto Onuki
2019-10-11 20:19:58 -07:00
parent 701edd6c0c
commit e5449f0b34
6 changed files with 8 additions and 8 deletions

View File

@@ -1358,7 +1358,7 @@ package android.content {
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();

View File

@@ -659,7 +659,7 @@ package android.content {
}
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();

View File

@@ -2212,9 +2212,9 @@ class ContextImpl extends Context {
}
@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());
}

View File

@@ -5237,7 +5237,7 @@ public abstract class Context {
@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!");
}

View File

@@ -885,8 +885,8 @@ public class ContextWrapper extends Context {
/** @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 */

View File

@@ -758,7 +758,7 @@ public class MockContext extends Context {
/** {@hide} */
@Override
public Context createContextAsUser(UserHandle user) {
public Context createContextAsUser(UserHandle user, @CreatePackageOptions int flags) {
throw new UnsupportedOperationException();
}