Skip to content

Commit a6f4d58

Browse files
author
Amith Yamasani
committed
Allow singleton providers to accept connections from other users
This is required for singleton providers like sms log. Change-Id: Icb18a764c27dc1b43f8b8bcc24c21c91274995fd
1 parent 9985aaf commit a6f4d58

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

core/java/android/content/ContentProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public abstract class ContentProvider implements ComponentCallbacks2 {
107107
private PathPermission[] mPathPermissions;
108108
private boolean mExported;
109109
private boolean mNoPerms;
110+
private boolean mSingleUser;
110111

111112
private final ThreadLocal<String> mCallingPackage = new ThreadLocal<String>();
112113

@@ -460,6 +461,7 @@ private int enforceWritePermission(String callingPkg, Uri uri) throws SecurityEx
460461

461462
boolean checkUser(int pid, int uid, Context context) {
462463
return UserHandle.getUserId(uid) == context.getUserId()
464+
|| mSingleUser
463465
|| context.checkPermission(INTERACT_ACROSS_USERS, pid, uid)
464466
== PERMISSION_GRANTED;
465467
}
@@ -1674,6 +1676,7 @@ private void attachInfo(Context context, ProviderInfo info, boolean testing) {
16741676
setWritePermission(info.writePermission);
16751677
setPathPermissions(info.pathPermissions);
16761678
mExported = info.exported;
1679+
mSingleUser = (info.flags & ProviderInfo.FLAG_SINGLE_USER) != 0;
16771680
setAuthorities(info.authority);
16781681
}
16791682
ContentProvider.this.onCreate();

0 commit comments

Comments
 (0)