use of android.content.ContentProviderClient in project VirtualXposed by android-hacker.
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;
}
use of android.content.ContentProviderClient in project VirtualXposed by android-hacker.
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;
}
use of android.content.ContentProviderClient in project AnExplorer by 1hakr.
the class DocumentsContract method compressDocument.
public static boolean compressDocument(ContentResolver resolver, Uri fromDocumentUri, ArrayList<String> fromDocumentIds) {
final ContentProviderClient client = resolver.acquireUnstableContentProviderClient(fromDocumentUri.getAuthority());
try {
final Bundle in = new Bundle();
in.putString(Document.COLUMN_DOCUMENT_ID, getDocumentId(fromDocumentUri));
in.putParcelable(DocumentsContract.EXTRA_URI, fromDocumentUri);
in.putStringArrayList(DocumentsContract.EXTRA_DOCUMENTS_COMPRESS, fromDocumentIds);
resolver.call(fromDocumentUri, METHOD_COMPRESS_DOCUMENT, null, in);
return true;
} catch (Exception e) {
Log.w(TAG, "Failed to compress document", e);
return false;
} finally {
ContentProviderClientCompat.releaseQuietly(client);
}
}
use of android.content.ContentProviderClient in project AnExplorer by 1hakr.
the class DocumentInfo method updateFromUri.
public void updateFromUri(ContentResolver resolver, Uri uri) throws FileNotFoundException {
ContentProviderClient client = null;
Cursor cursor = null;
try {
client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver, uri.getAuthority());
cursor = client.query(uri, null, null, null, null);
if (!cursor.moveToFirst()) {
throw new FileNotFoundException("Missing details for " + uri);
}
updateFromCursor(cursor, uri.getAuthority());
} catch (Throwable t) {
throw asFileNotFoundException(t);
} finally {
IoUtils.closeQuietly(cursor);
ContentProviderClientCompat.releaseQuietly(client);
}
}
use of android.content.ContentProviderClient in project AnExplorer by 1hakr.
the class DocumentsApplication method acquireUnstableProviderOrThrow.
public static ContentProviderClient acquireUnstableProviderOrThrow(ContentResolver resolver, String authority) throws RemoteException {
final ContentProviderClient client = ContentProviderClientCompat.acquireUnstableContentProviderClient(resolver, authority);
if (client == null) {
throw new RemoteException("Failed to acquire provider for " + authority);
}
ContentProviderClientCompat.setDetectNotResponding(client, PROVIDER_ANR_TIMEOUT);
return client;
}
Aggregations