android.os.StrictMode.ThreadPolicy Java Examples

The following examples show how to use android.os.StrictMode.ThreadPolicy. 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: PackageManagerDelegate.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Retrieves the list of activities that can respond to the given intent. And returns the
 * activites' meta data in ResolveInfo.
 *
 * @param intent The intent to query.
 * @return The list of activities that can respond to the intent.
 */
public List<ResolveInfo> getActivitiesThatCanRespondToIntentWithMetaData(Intent intent) {
    ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        return ContextUtils.getApplicationContext().getPackageManager().queryIntentActivities(
                intent, PackageManager.GET_META_DATA);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
Example #2
Source File: SliceProvider.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private Slice onBindSliceStrict(Uri sliceUri, List<SliceSpec> supportedSpecs) {
    ThreadPolicy oldPolicy = StrictMode.getThreadPolicy();
    try {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                .detectAll()
                .penaltyDeath()
                .build());
        return onBindSlice(sliceUri, new ArraySet<>(supportedSpecs));
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
Example #3
Source File: PackageManagerDelegate.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves the single activity that matches the given intent, or null if none found.
 * @param intent The intent to query.
 * @return The matching activity.
 */
public ResolveInfo resolveActivity(Intent intent) {
    ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        return ContextUtils.getApplicationContext().getPackageManager().resolveActivity(
                intent, 0);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
Example #4
Source File: PackageManagerDelegate.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves the list of activities that can respond to the given intent.
 * @param intent The intent to query.
 * @return The list of activities that can respond to the intent.
 */
public List<ResolveInfo> getActivitiesThatCanRespondToIntent(Intent intent) {
    ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        return ContextUtils.getApplicationContext().getPackageManager().queryIntentActivities(
                intent, 0);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
Example #5
Source File: PackageManagerDelegate.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves the list of services that can respond to the given intent.
 * @param intent The intent to query.
 * @return The list of services that can respond to the intent.
 */
public List<ResolveInfo> getServicesThatCanRespondToIntent(Intent intent) {
    ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        return ContextUtils.getApplicationContext().getPackageManager().queryIntentServices(
                intent, 0);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
Example #6
Source File: NotesApplication.java    From agera with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();
  setThreadPolicy(new ThreadPolicy.Builder().detectAll().penaltyLog().build());
  setVmPolicy(new VmPolicy.Builder().detectAll().penaltyLog().build());
}