Debug: cache size

pull/207/head
M66B 3 years ago
parent ccf888cd77
commit 3d2291c551

@ -40,6 +40,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
import android.os.Environment;
import android.os.storage.StorageManager;
import android.provider.Settings;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
@ -1811,7 +1812,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
new SimpleTask<StorageData>() {
@Override
protected StorageData onExecute(Context context, Bundle args) throws Throwable {
protected StorageData onExecute(Context context, Bundle args) {
StorageData data = new StorageData();
Runtime rt = Runtime.getRuntime();
data.hused = rt.totalMemory() - rt.freeMemory();
@ -1820,6 +1821,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
data.available = Helper.getAvailableStorageSpace();
data.total = Helper.getTotalStorageSpace();
data.used = Helper.getSize(context.getFilesDir());
data.cache = Helper.getCacheSize(context);
return data;
}
@ -1833,7 +1835,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvStorageUsage.setText(getString(R.string.title_advanced_storage_usage,
Helper.humanReadableByteCount(data.total - data.available),
Helper.humanReadableByteCount(data.total),
Helper.humanReadableByteCount(data.used)));
Helper.humanReadableByteCount(data.used),
data.cache > 0 ? Helper.humanReadableByteCount(data.cache) : "-"));
getView().postDelayed(new Runnable() {
@Override
@ -1989,5 +1992,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private long available;
private long total;
private long used;
private long cache;
}
}

@ -54,6 +54,7 @@ import android.os.LocaleList;
import android.os.Parcel;
import android.os.PowerManager;
import android.os.StatFs;
import android.os.storage.StorageManager;
import android.provider.Settings;
import android.security.KeyChain;
import android.security.KeyChainAliasCallback;
@ -2018,6 +2019,18 @@ public class Helper {
return stats.getTotalBytes();
}
static long getCacheSize(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
try {
StorageManager sm = Helper.getSystemService(context, StorageManager.class);
File cache = context.getCacheDir();
return sm.getCacheQuotaBytes(sm.getUuidForPath(cache));
} catch (IOException ex) {
Log.w(ex);
}
return -1;
}
static long getSize(File dir) {
long size = 0;
File[] listed = dir.listFiles();

@ -1886,10 +1886,12 @@ public class Log {
long storage_available = Helper.getAvailableStorageSpace();
long storage_total = Helper.getTotalStorageSpace();
long storage_used = Helper.getSize(context.getFilesDir());
sb.append(String.format("Storage space: %s/%s App: %s\r\n",
long cache = Helper.getCacheSize(context);
sb.append(String.format("Storage space: %s/%s App: %s cache: %s\r\n",
Helper.humanReadableByteCount(storage_total - storage_available),
Helper.humanReadableByteCount(storage_total),
Helper.humanReadableByteCount(storage_used)));
Helper.humanReadableByteCount(storage_used),
cache > 0 ? Helper.humanReadableByteCount(cache) : "-"));
Runtime rt = Runtime.getRuntime();
long hused = (rt.totalMemory() - rt.freeMemory()) / 1024L / 1024L;

@ -754,7 +754,8 @@
<string name="title_advanced_processors" translatable="false">Processors: %1$d</string>
<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_storage_usage" translatable="false">Storage space: %1$s/%2$s App: %3$s Cache: %4$s</string>
<string name="title_advanced_cache_size" translatable="false">Cache size: %1$s</string>
<string name="title_advanced_cursor_window" translatable="false">Cursor window size: %1$s</string>
<string name="title_advanced_contact_info" translatable="false">Contact lookup: %1$d cached: %2$d</string>
<string name="title_advanced_suffixes" translatable="false">Public suffix list: %1$d</string>

Loading…
Cancel
Save