From 846318a3250fa95f47a9decfbffb05a31dbd0006 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 4 Apr 2014 12:12:41 -0700 Subject: Allow prefix-based Uri permission grants. Define new FLAG_GRANT_PREFIX_URI_PERMISSION which indicates that a Uri permission grant should also apply to any other Uris that have matching scheme, authority, and path segments. For example, a prefix grant for /foo/ would allow /foo/bar/ but not /foo2/. Allow persistable and prefix grants to be issued directly through grantUriPermission(). Relaxing persistable is fine, since it still requires the receiver to actively take the permission. Since exact- and prefix-match grants for the same Uri can coexist, we track them separately using a new UriGrant key. (Consider the case where an app separately extends READ|PREFIX and WRITE for the same Uri: we can't let that become READ|WRITE|PREFIX.) Fix revoke to always take away persisted permissions. Move prefix matching logic to Uri and add tests. Add new flags to "am" tool, and various internal uses around Intent and Context. Switch some lagging users to ArraySet. Bug: 10607375 Change-Id: Ia8ce2b88421ff9f2fe5a979a27a026fc445d46f1 --- cmds/am/src/com/android/commands/am/Am.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cmds') diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 92cb52c..7df55a5 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -240,6 +240,7 @@ public class Am extends BaseCommand { " (to embed a comma into a string escape it using \"\\,\")\n" + " [-n ] [-f ]\n" + " [--grant-read-uri-permission] [--grant-write-uri-permission]\n" + + " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]\n" + " [--debug-log-resolution] [--exclude-stopped-packages]\n" + " [--include-stopped-packages]\n" + " [--activity-brought-to-front] [--activity-clear-top]\n" + @@ -455,6 +456,10 @@ public class Am extends BaseCommand { intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else if (opt.equals("--grant-write-uri-permission")) { intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + } else if (opt.equals("--grant-persistable-uri-permission")) { + intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); + } else if (opt.equals("--grant-prefix-uri-permission")) { + intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); } else if (opt.equals("--exclude-stopped-packages")) { intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); } else if (opt.equals("--include-stopped-packages")) { -- cgit v1.1