Java Code Examples for android.content.ContentResolver#call()

The following examples show how to use android.content.ContentResolver#call() . 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: DocumentsContract.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 2
Source File: DocumentsContract.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
public static boolean uncompressDocument(ContentResolver resolver, Uri fromDocumentUri) {
    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);

        resolver.call(fromDocumentUri, METHOD_UNCOMPRESS_DOCUMENT, null, in);
        return true;
    } catch (Exception e) {
        Log.w(TAG, "Failed to uncompress document", e);
        return false;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
Example 3
Source File: DocumentsContract.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 4
Source File: PackageReceiver.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    final ContentResolver resolver = context.getContentResolver();

    final String action = intent.getAction();
    if (Intent.ACTION_PACKAGE_FULLY_REMOVED.equals(action)) {
        resolver.call(RecentsProvider.buildRecent(), RecentsProvider.METHOD_PURGE, null, null);

    } else if (Intent.ACTION_PACKAGE_DATA_CLEARED.equals(action)) {
        final Uri data = intent.getData();
        if (data != null) {
            final String packageName = data.getSchemeSpecificPart();
            resolver.call(RecentsProvider.buildRecent(), RecentsProvider.METHOD_PURGE_PACKAGE,
                    packageName, null);
        }
    }
}
 
Example 5
Source File: DocumentsContract.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
public static boolean uncompressDocument(ContentResolver resolver, Uri fromDocumentUri) {
    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);

        resolver.call(fromDocumentUri, METHOD_UNCOMPRESS_DOCUMENT, null, in);
        return true;
    } catch (Exception e) {
        Log.w(TAG, "Failed to uncompress document", e);
        return false;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
Example 6
Source File: DocumentsContract.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 7
Source File: PackageReceiver.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    final ContentResolver resolver = context.getContentResolver();

    final String action = intent.getAction();
    if (Intent.ACTION_PACKAGE_FULLY_REMOVED.equals(action)) {
        resolver.call(RecentsProvider.buildRecent(), RecentsProvider.METHOD_PURGE, null, null);

    } else if (Intent.ACTION_PACKAGE_DATA_CLEARED.equals(action)) {
        final Uri data = intent.getData();
        if (data != null) {
            final String packageName = data.getSchemeSpecificPart();
            resolver.call(RecentsProvider.buildRecent(), RecentsProvider.METHOD_PURGE_PACKAGE,
                    packageName, null);
        }
    }
}
 
Example 8
Source File: DocumentsContract.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
public static boolean uncompressDocument(ContentResolver resolver, Uri fromDocumentUri) {
    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);

        resolver.call(fromDocumentUri, METHOD_UNCOMPRESS_DOCUMENT, null, in);
        return true;
    } catch (Exception e) {
        Log.w(TAG, "Failed to uncompress document", e);
        return false;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
 
Example 9
Source File: PackageReceiver.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    final ContentResolver resolver = context.getContentResolver();

    final String action = intent.getAction();
    if (Intent.ACTION_PACKAGE_FULLY_REMOVED.equals(action)) {
        resolver.call(RecentsProvider.buildRecent(), RecentsProvider.METHOD_PURGE, null, null);

    } else if (Intent.ACTION_PACKAGE_DATA_CLEARED.equals(action)) {
        final Uri data = intent.getData();
        if (data != null) {
            final String packageName = data.getSchemeSpecificPart();
            resolver.call(RecentsProvider.buildRecent(), RecentsProvider.METHOD_PURGE_PACKAGE,
                    packageName, null);
        }
    }
}
 
Example 10
Source File: FontRequests.java    From FontProvider with MIT License 5 votes vote down vote up
@Nullable
public BundledFontFamily request(@NonNull ContentResolver resolver) {
    Bundle data = new Bundle();
    data.setClassLoader(this.getClass().getClassLoader());
    data.putParcelable("data", this);

    Bundle result = resolver.call(
            Uri.parse("content://moe.shizuku.fontprovider"), "request", "bundled", data);
    if (result != null) {
        result.setClassLoader(this.getClass().getClassLoader());
        return result.getParcelable("data");
    }
    return null;
}
 
Example 11
Source File: MainActivity.java    From AideHelper with MIT License 5 votes vote down vote up
/**
 * 判断模块是否开启
 */
private boolean isExpModuleActive(Context context) {

  boolean isExp = false;
  if (context == null) {
    throw new IllegalArgumentException("context must not be null!!");
  }

  try {
    ContentResolver contentResolver = context.getContentResolver();
    Uri uri = Uri.parse("content://me.weishu.exposed.CP/");
    Bundle result = null;
    try {
      result = contentResolver.call(uri, "active", null, null);
    } catch (RuntimeException e) {
      // TaiChi is killed, try invoke
      try {
        Intent intent = new Intent("me.weishu.exp.ACTION_ACTIVE");
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
      } catch (Throwable e1) {
        return false;
      }
    }
    if (result == null) {
      result = contentResolver.call(uri, "active", null, null);
    }

    if (result == null) {
      return false;
    }
    isExp = result.getBoolean("active", false);
  } catch (Throwable ignored) {
  }
  return isExp;
}
 
Example 12
Source File: BaseActivity.java    From mhzs with MIT License 5 votes vote down vote up
protected boolean isExpModuleActive() {
    boolean isActive = false;
    try {
        ContentResolver contentResolver = getContentResolver();
        Uri uri = Uri.parse("content://me.weishu.exposed.CP/");
        Bundle result = contentResolver.call(uri, "active", null, null);
        if (result == null) {
            return false;
        }
        isActive = result.getBoolean("active", false);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return isActive;
}
 
Example 13
Source File: CompatForContentProvider.java    From Android-Plugin-Framework with MIT License 5 votes vote down vote up
public static Bundle call(Uri uri, String method, String arg, Bundle extras) {

        ContentResolver resolver = FairyGlobal.getHostApplication().getContentResolver();

        if (Build.VERSION.SDK_INT >= 11) {
            try {
                return resolver.call(uri, method, arg, extras);
            } catch (Exception e) {
                LogUtil.e("call uri fail", uri, method, arg, extras);
            }
            return null;
        } else {
            ContentProviderClient client = resolver.acquireContentProviderClient(uri);
            if (client == null) {
                throw new IllegalArgumentException("Unknown URI " + uri);
            }
            try {
                HackContentProviderClient hackContentProviderClient = new HackContentProviderClient(client);
                Object mContentProvider = hackContentProviderClient.getContentProvider();
                if (mContentProvider != null) {
                    //public Bundle call(String method, String request, Bundle args)
                    Object result = new HackIContentProvider(mContentProvider).call(method, arg, extras);
                    return  (Bundle) result;
                }

            } finally {
                client.release();
            }
            return null;
        }
    }
 
Example 14
Source File: ContentProviderClientCompat.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
   public static Bundle call(ContentResolver resolver, ContentProviderClient client, Uri uri, String method, String arg, Bundle extras) throws Exception{
	if(Utils.hasJellyBeanMR1()){
    	return client.call(method, arg, extras);
	}
	else{
        return resolver.call(uri, method, arg, extras);
	}
}
 
Example 15
Source File: MainActivity.java    From BiliRoaming with GNU General Public License v3.0 5 votes vote down vote up
private static boolean isTaiChiModuleActive(Context context) {
    ContentResolver contentResolver = context.getContentResolver();
    Uri uri = Uri.parse("content://me.weishu.exposed.CP/");

    try {
        Bundle result = contentResolver.call(uri, "active", null, null);
        return result.getBoolean("active", false);
    } catch (Exception e) {
        return false;
    }
}
 
Example 16
Source File: MainActivity.java    From XQuickEnergy with Apache License 2.0 5 votes vote down vote up
private static boolean isExpModuleActive(Context context)
{
 boolean isExp = false;
 if(context == null)
  throw new IllegalArgumentException("context must not be null!!");

 try
 {
  ContentResolver contentResolver = context.getContentResolver();
  Uri uri = Uri.parse("content://me.weishu.exposed.CP/");
  Bundle result = null;
  try
  {
   result = contentResolver.call(uri, "active", null, null);
  }catch(RuntimeException e)
  {
   // TaiChi is killed, try invoke
   try
   {
    Intent intent = new Intent("me.weishu.exp.ACTION_ACTIVE");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
   }catch(Throwable e1)
   {
    return false;
   }
  }
  if(result == null)
   result = contentResolver.call(uri, "active", null, null);

  if(result == null)
   return false;
  isExp = result.getBoolean("active", false);
 }catch(Throwable ignored)
 {
 }
 return isExp;
}
 
Example 17
Source File: DisableSecurityCheck.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
private Bundle remoteChange(String action, Bundle bundle, ContentResolver contentResolver) {
    Uri uri;
    if (getMyUerId()==999) {
        Uri parse = Uri.parse("content://com.miui.securitycenter.remoteprovider");
        Uri.Builder buildUpon = parse.buildUpon();
        String authority = "0@" +
                parse.getEncodedAuthority();
        buildUpon.encodedAuthority(authority);
        uri = buildUpon.build();
    } else {
        uri = Uri.parse("content://com.miui.securitycenter.remoteprovider");
    }
    return contentResolver.call(uri, "callPreference", action, bundle);
}
 
Example 18
Source File: LauncherSettings.java    From LaunchEnr with GNU General Public License v3.0 4 votes vote down vote up
public static Bundle call(ContentResolver cr, String method) {
    return cr.call(CONTENT_URI, method, null, null);
}
 
Example 19
Source File: CompatUtils.java    From DroidService with GNU Lesser General Public License v3.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static Bundle callAPI11(ContentResolver resolver, Uri uri, String method, String arg, Bundle extras) {
    return resolver.call(uri, method, arg, extras);
}
 
Example 20
Source File: ProviderCall.java    From container with GNU General Public License v3.0 4 votes vote down vote up
public static Bundle call(String authority, Context context, String methodName, String arg, Bundle bundle) {
	Uri uri = Uri.parse("content://" + authority);
	ContentResolver contentResolver = context.getContentResolver();
	return contentResolver.call(uri, methodName, arg, bundle);
}