mirror of https://github.com/M66B/FairEmail.git
Debug info public suffix list size
This commit is contained in:
parent
3717dfe5a5
commit
490fd589bb
|
@ -37,6 +37,7 @@ import android.os.Bundle;
|
|||
import android.os.Debug;
|
||||
import android.provider.Settings;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.Pair;
|
||||
|
@ -143,6 +144,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
private TextView tvMemoryClass;
|
||||
private TextView tvMemoryUsage;
|
||||
private TextView tvStorageUsage;
|
||||
private TextView tvSuffixes;
|
||||
private TextView tvFingerprint;
|
||||
private Button btnGC;
|
||||
private Button btnCharsets;
|
||||
|
@ -262,6 +264,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
tvMemoryClass = view.findViewById(R.id.tvMemoryClass);
|
||||
tvMemoryUsage = view.findViewById(R.id.tvMemoryUsage);
|
||||
tvStorageUsage = view.findViewById(R.id.tvStorageUsage);
|
||||
tvSuffixes = view.findViewById(R.id.tvSuffixes);
|
||||
tvFingerprint = view.findViewById(R.id.tvFingerprint);
|
||||
btnGC = view.findViewById(R.id.btnGC);
|
||||
btnCharsets = view.findViewById(R.id.btnCharsets);
|
||||
|
@ -959,8 +962,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
|
||||
setLastCleanup(prefs.getLong("last_cleanup", -1));
|
||||
|
||||
setPermissionInfo();
|
||||
|
||||
swExactAlarms.setEnabled(AlarmManagerCompatEx.canScheduleExactAlarms(getContext()));
|
||||
swTestIab.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
||||
|
||||
|
@ -969,6 +970,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
setSuffixes();
|
||||
setPermissionInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
@ -1227,79 +1235,121 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
time < 0 ? "-" : DTF.format(time)));
|
||||
}
|
||||
|
||||
private void setSuffixes() {
|
||||
new SimpleTask<Integer>() {
|
||||
@Override
|
||||
protected void onPreExecute(Bundle args) {
|
||||
tvSuffixes.setText(getString(R.string.title_advanced_suffixes, -1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer onExecute(Context context, Bundle args) {
|
||||
return UriHelper.getSuffixCount(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, Integer count) {
|
||||
tvSuffixes.setText(getString(R.string.title_advanced_suffixes, count));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.w(ex);
|
||||
tvSuffixes.setText(ex.toString());
|
||||
}
|
||||
}.execute(this, new Bundle(), "suffixes");
|
||||
}
|
||||
|
||||
private void setPermissionInfo() {
|
||||
try {
|
||||
int start = 0;
|
||||
int dp24 = Helper.dp2pixels(getContext(), 24);
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilderEx();
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
PackageInfo pi = pm.getPackageInfo(BuildConfig.APPLICATION_ID, PackageManager.GET_PERMISSIONS);
|
||||
for (int i = 0; i < pi.requestedPermissions.length; i++) {
|
||||
boolean granted = ((pi.requestedPermissionsFlags[i] & PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0);
|
||||
new SimpleTask<Spanned>() {
|
||||
@Override
|
||||
protected void onPreExecute(Bundle args) {
|
||||
tvPermissions.setText(null);
|
||||
}
|
||||
|
||||
PermissionInfo info;
|
||||
try {
|
||||
info = pm.getPermissionInfo(pi.requestedPermissions[i], PackageManager.GET_META_DATA);
|
||||
} catch (Throwable ex) {
|
||||
info = new PermissionInfo();
|
||||
info.name = pi.requestedPermissions[i];
|
||||
if (!(ex instanceof PackageManager.NameNotFoundException))
|
||||
info.group = ex.toString();
|
||||
}
|
||||
@Override
|
||||
protected Spanned onExecute(Context context, Bundle args) throws Throwable {
|
||||
int start = 0;
|
||||
int dp24 = Helper.dp2pixels(getContext(), 24);
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilderEx();
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
PackageInfo pi = pm.getPackageInfo(BuildConfig.APPLICATION_ID, PackageManager.GET_PERMISSIONS);
|
||||
for (int i = 0; i < pi.requestedPermissions.length; i++) {
|
||||
boolean granted = ((pi.requestedPermissionsFlags[i] & PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0);
|
||||
|
||||
ssb.append(info.name).append('\n');
|
||||
if (granted)
|
||||
ssb.setSpan(new StyleSpan(Typeface.BOLD), start, ssb.length(), 0);
|
||||
start = ssb.length();
|
||||
PermissionInfo info;
|
||||
try {
|
||||
info = pm.getPermissionInfo(pi.requestedPermissions[i], PackageManager.GET_META_DATA);
|
||||
} catch (Throwable ex) {
|
||||
info = new PermissionInfo();
|
||||
info.name = pi.requestedPermissions[i];
|
||||
if (!(ex instanceof PackageManager.NameNotFoundException))
|
||||
info.group = ex.toString();
|
||||
}
|
||||
|
||||
if (info.group != null) {
|
||||
ssb.append(info.group).append('\n');
|
||||
ssb.setSpan(new IndentSpan(dp24), start, ssb.length(), 0);
|
||||
ssb.append(info.name).append('\n');
|
||||
if (granted)
|
||||
ssb.setSpan(new StyleSpan(Typeface.BOLD), start, ssb.length(), 0);
|
||||
start = ssb.length();
|
||||
}
|
||||
|
||||
CharSequence description = info.loadDescription(pm);
|
||||
if (description != null) {
|
||||
ssb.append(description).append('\n');
|
||||
ssb.setSpan(new IndentSpan(dp24), start, ssb.length(), 0);
|
||||
ssb.setSpan(new RelativeSizeSpan(HtmlHelper.FONT_SMALL), start, ssb.length(), 0);
|
||||
start = ssb.length();
|
||||
}
|
||||
if (info.group != null) {
|
||||
ssb.append(info.group).append('\n');
|
||||
ssb.setSpan(new IndentSpan(dp24), start, ssb.length(), 0);
|
||||
start = ssb.length();
|
||||
}
|
||||
|
||||
if (info.protectionLevel != 0) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
|
||||
switch (info.getProtection()) {
|
||||
case PermissionInfo.PROTECTION_DANGEROUS:
|
||||
ssb.append("dangerous ");
|
||||
break;
|
||||
case PermissionInfo.PROTECTION_NORMAL:
|
||||
ssb.append("normal ");
|
||||
break;
|
||||
case PermissionInfo.PROTECTION_SIGNATURE:
|
||||
ssb.append("signature ");
|
||||
break;
|
||||
case PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM:
|
||||
ssb.append("signatureOrSystem ");
|
||||
break;
|
||||
}
|
||||
CharSequence description = info.loadDescription(pm);
|
||||
if (description != null) {
|
||||
ssb.append(description).append('\n');
|
||||
ssb.setSpan(new IndentSpan(dp24), start, ssb.length(), 0);
|
||||
ssb.setSpan(new RelativeSizeSpan(HtmlHelper.FONT_SMALL), start, ssb.length(), 0);
|
||||
start = ssb.length();
|
||||
}
|
||||
|
||||
ssb.append(Integer.toHexString(info.protectionLevel));
|
||||
if (info.protectionLevel != 0) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
|
||||
switch (info.getProtection()) {
|
||||
case PermissionInfo.PROTECTION_DANGEROUS:
|
||||
ssb.append("dangerous ");
|
||||
break;
|
||||
case PermissionInfo.PROTECTION_NORMAL:
|
||||
ssb.append("normal ");
|
||||
break;
|
||||
case PermissionInfo.PROTECTION_SIGNATURE:
|
||||
ssb.append("signature ");
|
||||
break;
|
||||
case PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM:
|
||||
ssb.append("signatureOrSystem ");
|
||||
break;
|
||||
}
|
||||
|
||||
if (info.flags != 0)
|
||||
ssb.append(' ').append(Integer.toHexString(info.flags));
|
||||
ssb.append(Integer.toHexString(info.protectionLevel));
|
||||
|
||||
if (info.flags != 0)
|
||||
ssb.append(' ').append(Integer.toHexString(info.flags));
|
||||
|
||||
ssb.append('\n');
|
||||
ssb.setSpan(new IndentSpan(dp24), start, ssb.length(), 0);
|
||||
start = ssb.length();
|
||||
}
|
||||
|
||||
ssb.append('\n');
|
||||
ssb.setSpan(new IndentSpan(dp24), start, ssb.length(), 0);
|
||||
start = ssb.length();
|
||||
}
|
||||
|
||||
ssb.append('\n');
|
||||
return ssb;
|
||||
}
|
||||
tvPermissions.setText(ssb);
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
tvPermissions.setText(ex.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, Spanned permissions) {
|
||||
tvPermissions.setText(permissions);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.w(ex);
|
||||
tvPermissions.setText(ex.toString());
|
||||
}
|
||||
}.execute(this, new Bundle(), "permissions");
|
||||
}
|
||||
|
||||
private static class StorageData {
|
||||
|
|
|
@ -162,7 +162,14 @@ public class UriHelper {
|
|||
}
|
||||
}
|
||||
|
||||
static void ensureSuffixList(Context context) {
|
||||
static int getSuffixCount(Context context) {
|
||||
ensureSuffixList(context);
|
||||
synchronized (suffixList) {
|
||||
return suffixList.size();
|
||||
}
|
||||
}
|
||||
|
||||
private static void ensureSuffixList(Context context) {
|
||||
synchronized (suffixList) {
|
||||
if (suffixList.size() > 0)
|
||||
return;
|
||||
|
|
|
@ -855,6 +855,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvMemoryUsage" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvSuffixes"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_advanced_suffixes"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvStorageUsage" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvFingerprint"
|
||||
android:layout_width="0dp"
|
||||
|
@ -865,7 +876,7 @@
|
|||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvStorageUsage" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvSuffixes" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnGC"
|
||||
|
|
|
@ -660,6 +660,7 @@
|
|||
<string name="title_advanced_memory_class" translatable="false">Memory class: %1$s/%2$s Total: %3$s</string>
|
||||
<string name="title_advanced_memory_usage" translatable="false">Memory usage: %1$s/%2$s Native: %3$s</string>
|
||||
<string name="title_advanced_storage_usage" translatable="false">Storage space: %1$s/%2$s App: %3$s</string>
|
||||
<string name="title_advanced_suffixes" translatable="false">Public suffix list: %1$d</string>
|
||||
<string name="title_advanced_gc" translatable="false">GC</string>
|
||||
<string name="title_advanced_charsets" translatable="false">Charsets</string>
|
||||
<string name="title_advanced_ciphers" translatable="false">Ciphers</string>
|
||||
|
|
Loading…
Reference in New Issue