Java Code Examples for android.content.Intent#FLAG_GRANT_PERSISTABLE_URI_PERMISSION
The following examples show how to use
android.content.Intent#FLAG_GRANT_PERSISTABLE_URI_PERMISSION .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private String uriModeFlagToString(int uriModeFlags) { StringBuilder builder = new StringBuilder(); if ((uriModeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { builder.append("read and "); } if ((uriModeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { builder.append("write and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) { builder.append("persistable and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PREFIX_URI_PERMISSION) != 0) { builder.append("prefix and "); } if (builder.length() > 5) { builder.setLength(builder.length() - 5); return builder.toString(); } else { throw new IllegalArgumentException("Unknown permission mode flags: " + uriModeFlags); } }
Example 2
Source File: UploadWidgetActivity.java From cloudinary_android with MIT License | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == MEDIA_CHOOSER_REQUEST_CODE) { if (resultCode == RESULT_OK && data != null) { ArrayList<Uri> uris = extractImageUris(data); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); for (Uri uri : uris) { if (DocumentsContract.isDocumentUri(this, uri)) { getContentResolver().takePersistableUriPermission(uri, takeFlags); } } } showImages(uris); } else { setResult(RESULT_CANCELED); finish(); } } }
Example 3
Source File: DocumentsProvider.java From FireFiles with Apache License 2.0 | 6 votes |
private static int getCallingOrSelfUriPermissionModeFlags(Context context, Uri uri) { // TODO: move this to a direct AMS call int modeFlags = 0; if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION) == PackageManager.PERMISSION_GRANTED) { modeFlags |= Intent.FLAG_GRANT_READ_URI_PERMISSION; } if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION) == PackageManager.PERMISSION_GRANTED) { modeFlags |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION; } if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION) == PackageManager.PERMISSION_GRANTED) { modeFlags |= Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION; } return modeFlags; }
Example 4
Source File: DocumentsProvider.java From FireFiles with Apache License 2.0 | 6 votes |
private static int getCallingOrSelfUriPermissionModeFlags(Context context, Uri uri) { // TODO: move this to a direct AMS call int modeFlags = 0; if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION) == PackageManager.PERMISSION_GRANTED) { modeFlags |= Intent.FLAG_GRANT_READ_URI_PERMISSION; } if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION) == PackageManager.PERMISSION_GRANTED) { modeFlags |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION; } if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION) == PackageManager.PERMISSION_GRANTED) { modeFlags |= Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION; } return modeFlags; }
Example 5
Source File: DocumentsProvider.java From FireFiles with Apache License 2.0 | 6 votes |
private static int getCallingOrSelfUriPermissionModeFlags(Context context, Uri uri) { // TODO: move this to a direct AMS call int modeFlags = 0; if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION) == PackageManager.PERMISSION_GRANTED) { modeFlags |= Intent.FLAG_GRANT_READ_URI_PERMISSION; } if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION) == PackageManager.PERMISSION_GRANTED) { modeFlags |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION; } if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION) == PackageManager.PERMISSION_GRANTED) { modeFlags |= Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION; } return modeFlags; }
Example 6
Source File: DocumentsProvider.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private static int getCallingOrSelfUriPermissionModeFlags(Context context, Uri uri) { // TODO: move this to a direct AMS call int modeFlags = 0; if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION) == PackageManager.PERMISSION_GRANTED) { modeFlags |= Intent.FLAG_GRANT_READ_URI_PERMISSION; } if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION) == PackageManager.PERMISSION_GRANTED) { modeFlags |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION; } if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) == PackageManager.PERMISSION_GRANTED) { modeFlags |= Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION; } return modeFlags; }
Example 7
Source File: ContextImpl.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private String uriModeFlagToString(int uriModeFlags) { StringBuilder builder = new StringBuilder(); if ((uriModeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { builder.append("read and "); } if ((uriModeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { builder.append("write and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) { builder.append("persistable and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PREFIX_URI_PERMISSION) != 0) { builder.append("prefix and "); } if (builder.length() > 5) { builder.setLength(builder.length() - 5); return builder.toString(); } else { throw new IllegalArgumentException("Unknown permission mode flags: " + uriModeFlags); } }
Example 8
Source File: UriPermission.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
void grantModes(int modeFlags, UriPermissionOwner owner) { final boolean persistable = (modeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0; modeFlags &= (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); if (persistable) { persistableModeFlags |= modeFlags; } if (owner == null) { globalModeFlags |= modeFlags; } else { if ((modeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { addReadOwner(owner); } if ((modeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { addWriteOwner(owner); } } updateModeFlags(); }
Example 9
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private String uriModeFlagToString(int uriModeFlags) { StringBuilder builder = new StringBuilder(); if ((uriModeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { builder.append("read and "); } if ((uriModeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { builder.append("write and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) { builder.append("persistable and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PREFIX_URI_PERMISSION) != 0) { builder.append("prefix and "); } if (builder.length() > 5) { builder.setLength(builder.length() - 5); return builder.toString(); } else { throw new IllegalArgumentException("Unknown permission mode flags: " + uriModeFlags); } }
Example 10
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private String uriModeFlagToString(int uriModeFlags) { StringBuilder builder = new StringBuilder(); if ((uriModeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { builder.append("read and "); } if ((uriModeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { builder.append("write and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) { builder.append("persistable and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PREFIX_URI_PERMISSION) != 0) { builder.append("prefix and "); } if (builder.length() > 5) { builder.setLength(builder.length() - 5); return builder.toString(); } else { throw new IllegalArgumentException("Unknown permission mode flags: " + uriModeFlags); } }
Example 11
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private String uriModeFlagToString(int uriModeFlags) { StringBuilder builder = new StringBuilder(); if ((uriModeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { builder.append("read and "); } if ((uriModeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { builder.append("write and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) { builder.append("persistable and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PREFIX_URI_PERMISSION) != 0) { builder.append("prefix and "); } if (builder.length() > 5) { builder.setLength(builder.length() - 5); return builder.toString(); } else { throw new IllegalArgumentException("Unknown permission mode flags: " + uriModeFlags); } }
Example 12
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private String uriModeFlagToString(int uriModeFlags) { StringBuilder builder = new StringBuilder(); if ((uriModeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { builder.append("read and "); } if ((uriModeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { builder.append("write and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) { builder.append("persistable and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PREFIX_URI_PERMISSION) != 0) { builder.append("prefix and "); } if (builder.length() > 5) { builder.setLength(builder.length() - 5); return builder.toString(); } else { throw new IllegalArgumentException("Unknown permission mode flags: " + uriModeFlags); } }
Example 13
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private String uriModeFlagToString(int uriModeFlags) { StringBuilder builder = new StringBuilder(); if ((uriModeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { builder.append("read and "); } if ((uriModeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { builder.append("write and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) { builder.append("persistable and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PREFIX_URI_PERMISSION) != 0) { builder.append("prefix and "); } if (builder.length() > 5) { builder.setLength(builder.length() - 5); return builder.toString(); } else { throw new IllegalArgumentException("Unknown permission mode flags: " + uriModeFlags); } }
Example 14
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private String uriModeFlagToString(int uriModeFlags) { StringBuilder builder = new StringBuilder(); if ((uriModeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { builder.append("read and "); } if ((uriModeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { builder.append("write and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) { builder.append("persistable and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PREFIX_URI_PERMISSION) != 0) { builder.append("prefix and "); } if (builder.length() > 5) { builder.setLength(builder.length() - 5); return builder.toString(); } else { throw new IllegalArgumentException("Unknown permission mode flags: " + uriModeFlags); } }
Example 15
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private String uriModeFlagToString(int uriModeFlags) { StringBuilder builder = new StringBuilder(); if ((uriModeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { builder.append("read and "); } if ((uriModeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { builder.append("write and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) { builder.append("persistable and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PREFIX_URI_PERMISSION) != 0) { builder.append("prefix and "); } if (builder.length() > 5) { builder.setLength(builder.length() - 5); return builder.toString(); } else { throw new IllegalArgumentException("Unknown permission mode flags: " + uriModeFlags); } }
Example 16
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private String uriModeFlagToString(int uriModeFlags) { StringBuilder builder = new StringBuilder(); if ((uriModeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { builder.append("read and "); } if ((uriModeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { builder.append("write and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) { builder.append("persistable and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PREFIX_URI_PERMISSION) != 0) { builder.append("prefix and "); } if (builder.length() > 5) { builder.setLength(builder.length() - 5); return builder.toString(); } else { throw new IllegalArgumentException("Unknown permission mode flags: " + uriModeFlags); } }
Example 17
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private String uriModeFlagToString(int uriModeFlags) { StringBuilder builder = new StringBuilder(); if ((uriModeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { builder.append("read and "); } if ((uriModeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { builder.append("write and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) { builder.append("persistable and "); } if ((uriModeFlags & Intent.FLAG_GRANT_PREFIX_URI_PERMISSION) != 0) { builder.append("prefix and "); } if (builder.length() > 5) { builder.setLength(builder.length() - 5); return builder.toString(); } else { throw new IllegalArgumentException("Unknown permission mode flags: " + uriModeFlags); } }