Search in sources :

Example 21 with UriPermission

use of android.content.UriPermission in project android_frameworks_base by ResurrectionRemix.

the class ActivityManagerProxy method getPersistedUriPermissions.

@Override
public ParceledListSlice<UriPermission> getPersistedUriPermissions(String packageName, boolean incoming) throws RemoteException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    data.writeInterfaceToken(IActivityManager.descriptor);
    data.writeString(packageName);
    data.writeInt(incoming ? 1 : 0);
    mRemote.transact(GET_PERSISTED_URI_PERMISSIONS_TRANSACTION, data, reply, 0);
    reply.readException();
    @SuppressWarnings("unchecked") final ParceledListSlice<UriPermission> perms = ParceledListSlice.CREATOR.createFromParcel(reply);
    data.recycle();
    reply.recycle();
    return perms;
}
Also used : Parcel(android.os.Parcel) UriPermission(android.content.UriPermission)

Example 22 with UriPermission

use of android.content.UriPermission in project android_frameworks_base by crdroidandroid.

the class OpenExternalDirectoryActivity method getIntentForExistingPermission.

private static Intent getIntentForExistingPermission(OpenExternalDirectoryActivity activity, boolean isRoot, File root, File file) {
    final String packageName = activity.getCallingPackage();
    final ContentProviderClient storageClient = activity.getExternalStorageClient();
    final Uri grantedUri = getGrantedUriPermission(activity, storageClient, file);
    final Uri rootUri = root.equals(file) ? grantedUri : getGrantedUriPermission(activity, storageClient, root);
    if (DEBUG)
        Log.d(TAG, "checking if " + packageName + " already has permission for " + grantedUri + " or its root (" + rootUri + ")");
    final ActivityManager am = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE);
    for (UriPermission uriPermission : am.getGrantedUriPermissions(packageName).getList()) {
        final Uri uri = uriPermission.getUri();
        if (uri == null) {
            Log.w(TAG, "null URI for " + uriPermission);
            continue;
        }
        if (uri.equals(grantedUri) || uri.equals(rootUri)) {
            if (DEBUG)
                Log.d(TAG, packageName + " already has permission: " + uriPermission);
            return createGrantedUriPermissionsIntent(grantedUri);
        }
    }
    if (DEBUG)
        Log.d(TAG, packageName + " does not have permission for " + grantedUri);
    return null;
}
Also used : UriPermission(android.content.UriPermission) ActivityManager(android.app.ActivityManager) Uri(android.net.Uri) ContentProviderClient(android.content.ContentProviderClient)

Example 23 with UriPermission

use of android.content.UriPermission in project android_frameworks_base by crdroidandroid.

the class ActivityManagerProxy method getPersistedUriPermissions.

@Override
public ParceledListSlice<UriPermission> getPersistedUriPermissions(String packageName, boolean incoming) throws RemoteException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    data.writeInterfaceToken(IActivityManager.descriptor);
    data.writeString(packageName);
    data.writeInt(incoming ? 1 : 0);
    mRemote.transact(GET_PERSISTED_URI_PERMISSIONS_TRANSACTION, data, reply, 0);
    reply.readException();
    @SuppressWarnings("unchecked") final ParceledListSlice<UriPermission> perms = ParceledListSlice.CREATOR.createFromParcel(reply);
    data.recycle();
    reply.recycle();
    return perms;
}
Also used : Parcel(android.os.Parcel) UriPermission(android.content.UriPermission)

Aggregations

UriPermission (android.content.UriPermission)23 Uri (android.net.Uri)11 Parcel (android.os.Parcel)10 ActivityManager (android.app.ActivityManager)6 IOException (java.io.IOException)6 ContentProviderClient (android.content.ContentProviderClient)5 SQLiteDiskIOException (android.database.sqlite.SQLiteDiskIOException)5 Point (android.graphics.Point)5 StorageManager (android.os.storage.StorageManager)5 File (java.io.File)2 ContentResolver (android.content.ContentResolver)1 PackageManager (android.content.pm.PackageManager)1 ProviderInfo (android.content.pm.ProviderInfo)1 Cursor (android.database.Cursor)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 DocumentFile (android.support.v4.provider.DocumentFile)1 Preference (android.support.v7.preference.Preference)1 MutableInt (android.util.MutableInt)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1