summaryrefslogtreecommitdiffstats
path: root/services/core/java/com/android/server/clipboard
diff options
context:
space:
mode:
authorNicolas Prevot <nprevot@google.com>2014-04-16 19:52:08 +0100
committerNicolas Prevot <nprevot@google.com>2014-05-13 14:59:52 +0100
commitd85fc72fb810858f7502e7e7f1bad53e1bf03edd (patch)
tree01c4624393d93312774716cf3233bcdcacf8243f /services/core/java/com/android/server/clipboard
parent2ac997917924161ed2eed5f4387246beb58c456e (diff)
downloadframeworks_base-d85fc72fb810858f7502e7e7f1bad53e1bf03edd.zip
frameworks_base-d85fc72fb810858f7502e7e7f1bad53e1bf03edd.tar.gz
frameworks_base-d85fc72fb810858f7502e7e7f1bad53e1bf03edd.tar.bz2
Resolving resources across users.
When an intent is sent to another profile: For content uris contained in this intent: The userId of the source user is added to the userInfo part. The ActivityManagerService has been modified to resolve resources in the user specified by the uri. The user id to which the uri belongs to is stored in the UriPermission. Change-Id: I43dc76895aba692bf148d276253aeaf9c75fce34
Diffstat (limited to 'services/core/java/com/android/server/clipboard')
-rw-r--r--services/core/java/com/android/server/clipboard/ClipboardService.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/clipboard/ClipboardService.java b/services/core/java/com/android/server/clipboard/ClipboardService.java
index f47d66d..15e3e89 100644
--- a/services/core/java/com/android/server/clipboard/ClipboardService.java
+++ b/services/core/java/com/android/server/clipboard/ClipboardService.java
@@ -23,6 +23,7 @@ import android.app.IActivityManager;
import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ClipDescription;
+import android.content.ContentProvider;
import android.content.IClipboard;
import android.content.IOnPrimaryClipChangedListener;
import android.content.Context;
@@ -255,7 +256,8 @@ public class ClipboardService extends IClipboard.Stub {
long ident = Binder.clearCallingIdentity();
try {
// This will throw SecurityException for us.
- mAm.checkGrantUriPermission(uid, null, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
+ mAm.checkGrantUriPermission(uid, null, ContentProvider.getUriWithoutUserId(uri),
+ Intent.FLAG_GRANT_READ_URI_PERMISSION, resolveUserId(uri, uid));
} catch (RemoteException e) {
} finally {
Binder.restoreCallingIdentity(ident);
@@ -282,8 +284,10 @@ public class ClipboardService extends IClipboard.Stub {
private final void grantUriLocked(Uri uri, String pkg) {
long ident = Binder.clearCallingIdentity();
try {
- mAm.grantUriPermissionFromOwner(mPermissionOwner, Process.myUid(), pkg, uri,
- Intent.FLAG_GRANT_READ_URI_PERMISSION);
+ mAm.grantUriPermissionFromOwner(mPermissionOwner, Process.myUid(), pkg,
+ ContentProvider.getUriWithoutUserId(uri),
+ Intent.FLAG_GRANT_READ_URI_PERMISSION,
+ resolveUserId(uri, Process.myUid()));
} catch (RemoteException e) {
} finally {
Binder.restoreCallingIdentity(ident);
@@ -331,9 +335,10 @@ public class ClipboardService extends IClipboard.Stub {
private final void revokeUriLocked(Uri uri) {
long ident = Binder.clearCallingIdentity();
try {
- mAm.revokeUriPermissionFromOwner(mPermissionOwner, uri,
- Intent.FLAG_GRANT_READ_URI_PERMISSION
- | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
+ mAm.revokeUriPermissionFromOwner(mPermissionOwner,
+ ContentProvider.getUriWithoutUserId(uri),
+ Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION,
+ resolveUserId(uri, Process.myUid()));
} catch (RemoteException e) {
} finally {
Binder.restoreCallingIdentity(ident);
@@ -361,4 +366,8 @@ public class ClipboardService extends IClipboard.Stub {
revokeItemLocked(clipboard.primaryClip.getItemAt(i));
}
}
+
+ private final int resolveUserId(Uri uri, int uid) {
+ return ContentProvider.getUserIdFromUri(uri, UserHandle.getUserId(uid));
+ }
}