mirror of https://github.com/M66B/FairEmail.git
Debug info: added browser info
This commit is contained in:
parent
68506954f2
commit
320b986a64
|
@ -19,6 +19,8 @@ package eu.faircode.email;
|
||||||
Copyright 2018-2023 by Marcel Bokhorst (M66B)
|
Copyright 2018-2023 by Marcel Bokhorst (M66B)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import static androidx.browser.customtabs.CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ApplicationExitInfo;
|
import android.app.ApplicationExitInfo;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
@ -38,6 +40,7 @@ import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PermissionGroupInfo;
|
import android.content.pm.PermissionGroupInfo;
|
||||||
import android.content.pm.PermissionInfo;
|
import android.content.pm.PermissionInfo;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.verify.domain.DomainVerificationManager;
|
import android.content.pm.verify.domain.DomainVerificationManager;
|
||||||
import android.content.pm.verify.domain.DomainVerificationUserState;
|
import android.content.pm.verify.domain.DomainVerificationUserState;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
@ -155,6 +158,7 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
@ -2981,6 +2985,7 @@ public class Log {
|
||||||
attachment.id = db.attachment().insertAttachment(attachment);
|
attachment.id = db.attachment().insertAttachment(attachment);
|
||||||
|
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
|
PackageManager pm = context.getPackageManager();
|
||||||
|
|
||||||
long size = 0;
|
long size = 0;
|
||||||
File file = attachment.getFile(context);
|
File file = attachment.getFile(context);
|
||||||
|
@ -3001,8 +3006,7 @@ public class Log {
|
||||||
size += write(os, "\r\n");
|
size += write(os, "\r\n");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PackageInfo pi = context.getPackageManager()
|
PackageInfo pi = pm.getPackageInfo(BuildConfig.APPLICATION_ID, PackageManager.GET_PERMISSIONS);
|
||||||
.getPackageInfo(BuildConfig.APPLICATION_ID, PackageManager.GET_PERMISSIONS);
|
|
||||||
for (int i = 0; i < pi.requestedPermissions.length; i++)
|
for (int i = 0; i < pi.requestedPermissions.length; i++)
|
||||||
if (pi.requestedPermissions[i] != null &&
|
if (pi.requestedPermissions[i] != null &&
|
||||||
pi.requestedPermissions[i].startsWith("android.permission.")) {
|
pi.requestedPermissions[i].startsWith("android.permission.")) {
|
||||||
|
@ -3048,6 +3052,33 @@ public class Log {
|
||||||
|
|
||||||
size += write(os, "\r\n");
|
size += write(os, "\r\n");
|
||||||
|
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW)
|
||||||
|
.addCategory(Intent.CATEGORY_BROWSABLE)
|
||||||
|
.setData(Uri.parse("http://example.com/"));
|
||||||
|
ResolveInfo main = pm.resolveActivity(intent, 0);
|
||||||
|
|
||||||
|
int flags = (Build.VERSION.SDK_INT < Build.VERSION_CODES.M ? 0 : PackageManager.MATCH_ALL);
|
||||||
|
intent.setData(Uri.parse("http://example.com"));
|
||||||
|
List<ResolveInfo> browsers = pm.queryIntentActivities(intent, flags);
|
||||||
|
|
||||||
|
for (ResolveInfo ri : browsers) {
|
||||||
|
Intent serviceIntent = new Intent();
|
||||||
|
serviceIntent.setAction(ACTION_CUSTOM_TABS_CONNECTION);
|
||||||
|
serviceIntent.setPackage(ri.activityInfo.packageName);
|
||||||
|
CharSequence label = pm.getApplicationLabel(ri.activityInfo.applicationInfo);
|
||||||
|
boolean tabs = (pm.resolveService(serviceIntent, 0) != null);
|
||||||
|
boolean def = (main != null &&
|
||||||
|
Objects.equals(ri.activityInfo.packageName, main.activityInfo.packageName));
|
||||||
|
size += write(os, String.format("Browser: %s (%s) tabs=%b default=%b\r\n",
|
||||||
|
ri.activityInfo.packageName, label, tabs, def));
|
||||||
|
}
|
||||||
|
|
||||||
|
size += write(os, "\r\n");
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
size += write(os, String.format("%s\r\n", ex));
|
||||||
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
try {
|
try {
|
||||||
DomainVerificationManager dvm = Helper.getSystemService(context, DomainVerificationManager.class);
|
DomainVerificationManager dvm = Helper.getSystemService(context, DomainVerificationManager.class);
|
||||||
|
@ -3210,7 +3241,6 @@ public class Log {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PackageManager pm = context.getPackageManager();
|
|
||||||
List<PermissionGroupInfo> groups = pm.getAllPermissionGroups(0);
|
List<PermissionGroupInfo> groups = pm.getAllPermissionGroups(0);
|
||||||
groups.add(0, null); // Ungrouped
|
groups.add(0, null); // Ungrouped
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue