| 537 | } |
| 538 | |
| 539 | private static boolean hasCustomTabs(Context context, Uri uri, String pkg) { |
| 540 | PackageManager pm = context.getPackageManager(); |
| 541 | Intent view = new Intent(Intent.ACTION_VIEW, uri); |
| 542 | |
| 543 | try { |
| 544 | int flags = (Build.VERSION.SDK_INT < Build.VERSION_CODES.M ? 0 : PackageManager.MATCH_ALL); |
| 545 | List<ResolveInfo> ris = pm.queryIntentActivities(view, flags); // action whitelisted |
| 546 | for (ResolveInfo info : ris) { |
| 547 | Intent intent = new Intent(); |
| 548 | intent.setAction(ACTION_CUSTOM_TABS_CONNECTION); |
| 549 | intent.setPackage(info.activityInfo.packageName); |
| 550 | if (pkg != null && !pkg.equals(info.activityInfo.packageName)) |
| 551 | continue; |
| 552 | if (pm.resolveService(intent, 0) != null) |
| 553 | return true; |
| 554 | } |
| 555 | } catch (Throwable ex) { |
| 556 | /* |
| 557 | java.lang.SecurityException: You need INTERACT_ACROSS_USERS, MANAGE_USERS, or QUERY_USERS permission to: check isProfile |
| 558 | at android.os.Parcel.createExceptionOrNull(Unknown Source:7) |
| 559 | at android.os.Parcel.createException(Unknown Source:0) |
| 560 | at android.os.Parcel.readException(Unknown Source:11) |
| 561 | at android.os.Parcel.readException(Unknown Source:10) |
| 562 | at android.content.pm.IPackageManager$Stub$Proxy.queryIntentActivities(Unknown Source:38) |
| 563 | at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(Unknown Source:22) |
| 564 | at android.app.ApplicationPackageManager.queryIntentActivities(Unknown Source:4) |
| 565 | at android.app.ApplicationPackageManager.queryIntentActivities(Unknown Source:5) |
| 566 | at eu.faircode.email.Helper.hasCustomTabs(SourceFile:23) |
| 567 | */ |
| 568 | Log.e(ex); |
| 569 | return false; |
| 570 | } |
| 571 | |
| 572 | return false; |
| 573 | } |
| 574 | |
| 575 | static boolean hasWebView(Context context) { |
| 576 | if (hasWebView == null) |