Search in sources :

Example 86 with ContentProviderClient

use of android.content.ContentProviderClient in project DroidPlugin by DroidPluginTeam.

the class ContentProviderCompat method crazyAcquireContentProvider.

public static ContentProviderClient crazyAcquireContentProvider(Context context, Uri uri) {
    ContentProviderClient client = acquireContentProviderClient(context, uri);
    if (client == null) {
        int retry = 0;
        while (retry < 5 && client == null) {
            SystemClock.sleep(100);
            retry++;
            client = acquireContentProviderClient(context, uri);
        }
    }
    return client;
}
Also used : ContentProviderClient(android.content.ContentProviderClient)

Example 87 with ContentProviderClient

use of android.content.ContentProviderClient in project UnityModManager by xausky.

the class VClientImpl method acquireProviderClient.

@Override
public IBinder acquireProviderClient(ProviderInfo info) {
    if (mTempLock != null) {
        mTempLock.block();
    }
    if (!isBound()) {
        VClientImpl.get().bindApplication(info.packageName, info.processName);
    }
    IInterface provider = null;
    String[] authorities = info.authority.split(";");
    String authority = authorities.length == 0 ? info.authority : authorities[0];
    ContentResolver resolver = VirtualCore.get().getContext().getContentResolver();
    ContentProviderClient client = null;
    try {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            client = resolver.acquireUnstableContentProviderClient(authority);
        } else {
            client = resolver.acquireContentProviderClient(authority);
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
    if (client != null) {
        provider = mirror.android.content.ContentProviderClient.mContentProvider.get(client);
        client.release();
    }
    return provider != null ? provider.asBinder() : null;
}
Also used : IInterface(android.os.IInterface) ContentProviderClient(android.content.ContentProviderClient) ContentResolver(android.content.ContentResolver)

Example 88 with ContentProviderClient

use of android.content.ContentProviderClient in project UnityModManager by xausky.

the class ContentProviderCompat method crazyAcquireContentProvider.

public static ContentProviderClient crazyAcquireContentProvider(Context context, Uri uri) {
    ContentProviderClient client = acquireContentProviderClient(context, uri);
    if (client == null) {
        int retry = 0;
        while (retry < 5 && client == null) {
            SystemClock.sleep(100);
            retry++;
            client = acquireContentProviderClient(context, uri);
        }
    }
    return client;
}
Also used : ContentProviderClient(android.content.ContentProviderClient)

Example 89 with ContentProviderClient

use of android.content.ContentProviderClient in project VirtualApp by asLody.

the class ContentProviderCompat method crazyAcquireContentProvider.

public static ContentProviderClient crazyAcquireContentProvider(Context context, Uri uri) {
    ContentProviderClient client = acquireContentProviderClient(context, uri);
    if (client == null) {
        int retry = 0;
        while (retry < 5 && client == null) {
            SystemClock.sleep(100);
            retry++;
            client = acquireContentProviderClient(context, uri);
        }
    }
    return client;
}
Also used : ContentProviderClient(android.content.ContentProviderClient)

Example 90 with ContentProviderClient

use of android.content.ContentProviderClient in project VirtualApp by asLody.

the class ContentProviderCompat method call.

public static Bundle call(Context context, Uri uri, String method, String arg, Bundle extras) {
    if (VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return context.getContentResolver().call(uri, method, arg, extras);
    }
    ContentProviderClient client = crazyAcquireContentProvider(context, uri);
    Bundle res = null;
    try {
        res = client.call(method, arg, extras);
    } catch (RemoteException e) {
        e.printStackTrace();
    } finally {
        releaseQuietly(client);
    }
    return res;
}
Also used : Bundle(android.os.Bundle) RemoteException(android.os.RemoteException) ContentProviderClient(android.content.ContentProviderClient)

Aggregations

ContentProviderClient (android.content.ContentProviderClient)94 RemoteException (android.os.RemoteException)30 Cursor (android.database.Cursor)28 Uri (android.net.Uri)24 Bundle (android.os.Bundle)19 ContentResolver (android.content.ContentResolver)18 FileNotFoundException (java.io.FileNotFoundException)15 ArrayList (java.util.ArrayList)13 IOException (java.io.IOException)10 Test (org.junit.Test)9 OperationCanceledException (android.os.OperationCanceledException)8 CancellationSignal (android.os.CancellationSignal)7 IContentProvider (android.content.IContentProvider)6 ActivityManager (android.app.ActivityManager)5 AlertDialog (android.app.AlertDialog)5 ClipData (android.content.ClipData)5 ComponentName (android.content.ComponentName)5 Intent (android.content.Intent)5 ServiceConnection (android.content.ServiceConnection)5 UriPermission (android.content.UriPermission)5