2024-08-17 12:35:07 -04:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2024-08-05 16:03:46 -04:00
|
|
|
From: Makoto Onuki <omakoto@google.com>
|
|
|
|
Date: Fri, 11 Oct 2019 20:19:58 -0700
|
|
|
|
Subject: [PATCH] Explicitly take flags in createContextAsUser()
|
|
|
|
|
|
|
|
Bug: 142472686
|
|
|
|
Test: atest android.content.cts.ContextTest#testCreateContextAsUser
|
|
|
|
Change-Id: Id2e3d5ffe5887a4916e0872a7e85d62cbb439744
|
|
|
|
---
|
|
|
|
api/system-current.txt | 2 +-
|
|
|
|
api/test-current.txt | 2 +-
|
|
|
|
core/java/android/app/ContextImpl.java | 4 ++--
|
|
|
|
core/java/android/content/Context.java | 2 +-
|
|
|
|
core/java/android/content/ContextWrapper.java | 4 ++--
|
|
|
|
test-mock/src/android/test/mock/MockContext.java | 2 +-
|
|
|
|
6 files changed, 8 insertions(+), 8 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/api/system-current.txt b/api/system-current.txt
|
2024-08-17 12:35:07 -04:00
|
|
|
index 02e348309fff..c08667a02b4b 100644
|
2024-08-05 16:03:46 -04:00
|
|
|
--- a/api/system-current.txt
|
|
|
|
+++ b/api/system-current.txt
|
|
|
|
@@ -1346,7 +1346,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();
|
|
|
|
diff --git a/api/test-current.txt b/api/test-current.txt
|
2024-08-17 12:35:07 -04:00
|
|
|
index 5f53b2a40a49..29c580da327f 100644
|
2024-08-05 16:03:46 -04:00
|
|
|
--- a/api/test-current.txt
|
|
|
|
+++ b/api/test-current.txt
|
|
|
|
@@ -638,7 +638,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();
|
|
|
|
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
|
2024-08-17 12:35:07 -04:00
|
|
|
index 1f3c3a46792a..9c46b23d8df8 100644
|
2024-08-05 16:03:46 -04:00
|
|
|
--- a/core/java/android/app/ContextImpl.java
|
|
|
|
+++ b/core/java/android/app/ContextImpl.java
|
2024-08-17 12:35:07 -04:00
|
|
|
@@ -2201,9 +2201,9 @@ class ContextImpl extends Context {
|
2024-08-05 16:03:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
2024-08-17 12:35:07 -04:00
|
|
|
index 713287d26f80..c161f8183584 100644
|
2024-08-05 16:03:46 -04:00
|
|
|
--- a/core/java/android/content/Context.java
|
|
|
|
+++ b/core/java/android/content/Context.java
|
2024-08-17 12:35:07 -04:00
|
|
|
@@ -5216,7 +5216,7 @@ public abstract class Context {
|
2024-08-05 16:03:46 -04:00
|
|
|
@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
|
2024-08-17 12:35:07 -04:00
|
|
|
index f7cd51e7ffbc..7993ea192424 100644
|
2024-08-05 16:03:46 -04:00
|
|
|
--- a/core/java/android/content/ContextWrapper.java
|
|
|
|
+++ b/core/java/android/content/ContextWrapper.java
|
2024-08-17 12:35:07 -04:00
|
|
|
@@ -885,8 +885,8 @@ public class ContextWrapper extends Context {
|
2024-08-05 16:03:46 -04:00
|
|
|
|
|
|
|
/** @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
|
2024-08-17 12:35:07 -04:00
|
|
|
index fcd4701c7630..5053ceedc703 100644
|
2024-08-05 16:03:46 -04:00
|
|
|
--- a/test-mock/src/android/test/mock/MockContext.java
|
|
|
|
+++ b/test-mock/src/android/test/mock/MockContext.java
|
2024-08-17 12:35:07 -04:00
|
|
|
@@ -758,7 +758,7 @@ public class MockContext extends Context {
|
2024-08-05 16:03:46 -04:00
|
|
|
|
|
|
|
/** {@hide} */
|
|
|
|
@Override
|
|
|
|
- public Context createContextAsUser(UserHandle user) {
|
|
|
|
+ public Context createContextAsUser(UserHandle user, @CreatePackageOptions int flags) {
|
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|