From e5a4826a90f117b423830445f87b0a5603727ca8 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 29 Sep 2021 12:11:14 +0200 Subject: [PATCH] Debug cursor window size --- .../eu/faircode/email/FragmentOptionsMisc.java | 14 ++++++++++++++ app/src/main/res/layout/fragment_options_misc.xml | 13 ++++++++++++- app/src/main/res/values/strings.xml | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index b9c6384a7b..c9c55a9c98 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -70,6 +70,7 @@ import androidx.preference.PreferenceManager; import java.io.File; import java.io.IOException; +import java.lang.reflect.Field; import java.nio.charset.Charset; import java.text.NumberFormat; import java.util.ArrayList; @@ -146,6 +147,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private TextView tvStorageUsage; private TextView tvSuffixes; private TextView tvFingerprint; + private TextView tvCursorWindow; private Button btnGC; private Button btnCharsets; private Button btnCiphers; @@ -266,6 +268,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc tvStorageUsage = view.findViewById(R.id.tvStorageUsage); tvSuffixes = view.findViewById(R.id.tvSuffixes); tvFingerprint = view.findViewById(R.id.tvFingerprint); + tvCursorWindow = view.findViewById(R.id.tvCursorWindow); btnGC = view.findViewById(R.id.btnGC); btnCharsets = view.findViewById(R.id.btnCharsets); btnCiphers = view.findViewById(R.id.btnCiphers); @@ -1172,6 +1175,17 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc tvFingerprint.setText(Helper.getFingerprint(getContext())); + int cursorWindowSize = -1; + try { + Field fCursorWindowSize = io.requery.android.database.CursorWindow.class.getDeclaredField("sDefaultCursorWindowSize"); + fCursorWindowSize.setAccessible(true); + cursorWindowSize = fCursorWindowSize.getInt(null); + } catch (Throwable ex) { + Log.w(ex); + } + tvCursorWindow.setText(getString(R.string.title_advanced_cursor_window, + Helper.humanReadableByteCount(cursorWindowSize, false))); + cardDebug.setVisibility(swDebug.isChecked() || BuildConfig.DEBUG ? View.VISIBLE : View.GONE); } diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index a5fa92a1c3..6191a9a77a 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -855,6 +855,17 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvMemoryUsage" /> + + + app:layout_constraintTop_toBottomOf="@id/tvCursorWindow" /> Memory class: %1$s/%2$s Total: %3$s Memory usage: %1$s/%2$s Native: %3$s Storage space: %1$s/%2$s App: %3$s + Cursor window size: %1$s Public suffix list: %1$d GC Charsets