From ed53a97323d0c5603a540741647d781a011eb070 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 30 May 2021 17:52:15 +0200 Subject: [PATCH] Improved logging --- .../java/eu/faircode/email/FragmentOAuth.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOAuth.java b/app/src/main/java/eu/faircode/email/FragmentOAuth.java index 9e3a40f5d5..b6dd434d6e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOAuth.java +++ b/app/src/main/java/eu/faircode/email/FragmentOAuth.java @@ -24,9 +24,11 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.text.TextUtils; import android.util.Base64; @@ -242,8 +244,19 @@ public class FragmentOAuth extends FragmentBase { hideError(); final Context context = getContext(); + PackageManager pm = context.getPackageManager(); EmailProvider provider = EmailProvider.getProvider(context, id); + int flags = PackageManager.GET_RESOLVED_FILTER; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) + flags |= PackageManager.MATCH_ALL; + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com")); + List ris = pm.queryIntentActivities(intent, flags); + EntityLog.log(context, "Browsers=" + (ris == null ? null : ris.size())); + if (ris != null) + for (ResolveInfo ri : ris) + EntityLog.log(context, "Browser=" + ri.activityInfo.packageName); + AppAuthConfiguration appAuthConfig = new AppAuthConfiguration.Builder() .setBrowserMatcher(new BrowserMatcher() { @Override @@ -322,7 +335,7 @@ public class FragmentOAuth extends FragmentBase { Log.e(ex); throw new ActivityNotFoundException("Browser not found"); } - PackageManager pm = context.getPackageManager(); + if (authIntent.resolveActivity(pm) == null) // action whitelisted throw new ActivityNotFoundException(authIntent.toString()); else