diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-03-21 18:09:39 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-04-15 12:34:40 -0700 |
commit | 328ebf222167ee1d25a54fd34c8293e183303752 (patch) | |
tree | 6e00783e36b0553657c662d43ddac0cdf0243539 /core/java | |
parent | 60113556355f25d02d9d0e0556a02483cad8ff48 (diff) | |
download | frameworks_base-328ebf222167ee1d25a54fd34c8293e183303752.zip frameworks_base-328ebf222167ee1d25a54fd34c8293e183303752.tar.gz frameworks_base-328ebf222167ee1d25a54fd34c8293e183303752.tar.bz2 |
Support persistable Uri permission grants.
When granting a Uri permission with new PERSIST_GRANT_URI_PERMISSION
flag, persist that grant across device reboots until explicitly
revoked. Adds new persistedModeFlags dimension to UriPermission,
and moves all flag mutation into UriPermission for clarity. Adds
flag documentation. Only inflate HashSet as needed.
Write persisted grants into XML file, saving based on source and
target package name and user handle. Sanity check grants when
parsing.
Wipe all grants from/to a package when uninstalled, and wipe any
transient grants when a package or user is force stopped.
Persistable grants are always considered "needed."
Change-Id: I3f001571b498fd607456a1257a6383f904d19497
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/content/Context.java | 2 | ||||
-rw-r--r-- | core/java/android/content/Intent.java | 12 | ||||
-rw-r--r-- | core/java/com/android/internal/util/IndentingPrintWriter.java | 4 |
3 files changed, 16 insertions, 2 deletions
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 03e241a..cb5c315 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -2443,7 +2443,7 @@ public abstract class Context { * Remove all permissions to access a particular content provider Uri * that were previously added with {@link #grantUriPermission}. The given * Uri will match all previously granted Uris that are the same or a - * sub-path of the given Uri. That is, revoking "content://foo/one" will + * sub-path of the given Uri. That is, revoking "content://foo/target" will * revoke both "content://foo/target" and "content://foo/target/sub", but not * "content://foo". * diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index e36f815..36c69ef 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -3228,6 +3228,15 @@ public class Intent implements Parcelable, Cloneable { public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020; /** + * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or + * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the grant will be remembered + * until explicitly revoked with + * {@link Context#revokeUriPermission(Uri, int)}. These grants persist + * across device reboots. + */ + public static final int FLAG_PERSIST_GRANT_URI_PERMISSION = 0x00000040; + + /** * If set, the new activity is not kept in the history stack. As soon as * the user navigates away from it, the activity is finished. This may also * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory @@ -7016,7 +7025,8 @@ public class Intent implements Parcelable, Cloneable { // and flags to ourselves to grant. setClipData(target.getClipData()); addFlags(target.getFlags() - & (FLAG_GRANT_READ_URI_PERMISSION | FLAG_GRANT_WRITE_URI_PERMISSION)); + & (FLAG_GRANT_READ_URI_PERMISSION | FLAG_GRANT_WRITE_URI_PERMISSION + | FLAG_PERSIST_GRANT_URI_PERMISSION)); return true; } else { return false; diff --git a/core/java/com/android/internal/util/IndentingPrintWriter.java b/core/java/com/android/internal/util/IndentingPrintWriter.java index d01a817..6fddd09 100644 --- a/core/java/com/android/internal/util/IndentingPrintWriter.java +++ b/core/java/com/android/internal/util/IndentingPrintWriter.java @@ -68,6 +68,10 @@ public class IndentingPrintWriter extends PrintWriter { print(key + "=" + String.valueOf(value) + " "); } + public void printHexPair(String key, int value) { + print(key + "=0x" + Integer.toHexString(value) + " "); + } + @Override public void write(char[] buf, int offset, int count) { final int indentLength = mIndentBuilder.length(); |