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 . These examples are extracted from open source projects. 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
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
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 3
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 4
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 5
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 6
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 7
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
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 9
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
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 Project: android_9.0.0_r45   File: UriPermission.java    License: Apache License 2.0 6 votes vote down vote up
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 12
Source Project: android_9.0.0_r45   File: ContextImpl.java    License: Apache License 2.0 6 votes vote down vote up
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
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 14
Source Project: FireFiles   File: DocumentsProvider.java    License: Apache License 2.0 6 votes vote down vote up
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 15
Source Project: FireFiles   File: DocumentsProvider.java    License: Apache License 2.0 6 votes vote down vote up
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 16
Source Project: FireFiles   File: DocumentsProvider.java    License: Apache License 2.0 6 votes vote down vote up
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 17
@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();
        }
    }
}