diff options
Diffstat (limited to 'core/java/android/content/ContentResolver.java')
-rw-r--r-- | core/java/android/content/ContentResolver.java | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java index 243c91a..45fed2d 100644 --- a/core/java/android/content/ContentResolver.java +++ b/core/java/android/content/ContentResolver.java @@ -16,8 +16,6 @@ package android.content; -import dalvik.system.CloseGuard; - import android.accounts.Account; import android.app.ActivityManagerNative; import android.app.ActivityThread; @@ -44,7 +42,8 @@ import android.os.UserHandle; import android.text.TextUtils; import android.util.EventLog; import android.util.Log; -import android.util.Pair; + +import dalvik.system.CloseGuard; import java.io.File; import java.io.FileInputStream; @@ -1389,6 +1388,58 @@ public abstract class ContentResolver { } /** + * Return list of all Uri permissions that have been granted <em>to</em> the + * calling package, and which exactly match the requested flags. For + * example, to return all Uris that the calling application has + * <em>non-persistent</em> read access to: + * + * <pre class="prettyprint"> + * getIncomingUriPermissionGrants(Intent.FLAG_GRANT_READ_URI_PERMISSION, + * Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_PERSIST_GRANT_URI_PERMISSION); + * </pre> + * + * @param modeFlags any combination of + * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION}, + * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}, or + * {@link Intent#FLAG_PERSIST_GRANT_URI_PERMISSION}. + * @param modeMask mask indicating which flags must match. + */ + public Uri[] getIncomingUriPermissionGrants(int modeFlags, int modeMask) { + try { + return ActivityManagerNative.getDefault() + .getGrantedUriPermissions(null, getPackageName(), modeFlags, modeMask); + } catch (RemoteException e) { + return new Uri[0]; + } + } + + /** + * Return list of all Uri permissions that have been granted <em>from</em> the + * calling package, and which exactly match the requested flags. For + * example, to return all Uris that the calling application has granted + * <em>non-persistent</em> read access to: + * + * <pre class="prettyprint"> + * getOutgoingUriPermissionGrants(Intent.FLAG_GRANT_READ_URI_PERMISSION, + * Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_PERSIST_GRANT_URI_PERMISSION); + * </pre> + * + * @param modeFlags any combination of + * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION}, + * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}, or + * {@link Intent#FLAG_PERSIST_GRANT_URI_PERMISSION}. + * @param modeMask mask indicating which flags must match. + */ + public Uri[] getOutgoingUriPermissionGrants(int modeFlags, int modeMask) { + try { + return ActivityManagerNative.getDefault() + .getGrantedUriPermissions(getPackageName(), null, modeFlags, modeMask); + } catch (RemoteException e) { + return new Uri[0]; + } + } + + /** * Start an asynchronous sync operation. If you want to monitor the progress * of the sync you may register a SyncObserver. Only values of the following * types may be used in the extras bundle: |