mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-03 15:46:34 +02:00
Debug: cache quota
This commit is contained in:
@@ -180,6 +180,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
private TextView tvMemoryClass;
|
||||
private TextView tvMemoryUsage;
|
||||
private TextView tvStorageUsage;
|
||||
private TextView tvCacheUsage;
|
||||
private TextView tvContactInfo;
|
||||
private TextView tvSuffixes;
|
||||
private TextView tvAndroidId;
|
||||
@@ -350,6 +351,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);
|
||||
tvCacheUsage = view.findViewById(R.id.tvCacheUsage);
|
||||
tvContactInfo = view.findViewById(R.id.tvContactInfo);
|
||||
tvSuffixes = view.findViewById(R.id.tvSuffixes);
|
||||
tvAndroidId = view.findViewById(R.id.tvAndroidId);
|
||||
@@ -1819,8 +1821,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
data.nheap = Debug.getNativeHeapAllocatedSize();
|
||||
data.available = Helper.getAvailableStorageSpace();
|
||||
data.total = Helper.getTotalStorageSpace();
|
||||
data.used = Helper.getSize(context.getFilesDir());
|
||||
data.cache = Helper.getCacheQuota(context);
|
||||
data.used = Helper.getSizeUsed(context.getFilesDir());
|
||||
data.cache_used = Helper.getSizeUsed(context.getCacheDir());
|
||||
data.cache_quota = Helper.getCacheQuota(context);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1834,8 +1837,10 @@ 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),
|
||||
data.cache > 0 ? Helper.humanReadableByteCount(data.cache) : "-"));
|
||||
Helper.humanReadableByteCount(data.used)));
|
||||
tvCacheUsage.setText(getString(R.string.title_advanced_cache_usage,
|
||||
Helper.humanReadableByteCount(data.cache_used),
|
||||
Helper.humanReadableByteCount(data.cache_quota)));
|
||||
|
||||
getView().postDelayed(new Runnable() {
|
||||
@Override
|
||||
@@ -1991,6 +1996,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
private long available;
|
||||
private long total;
|
||||
private long used;
|
||||
private long cache;
|
||||
private long cache_used;
|
||||
private long cache_quota;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2029,16 +2029,16 @@ public class Helper {
|
||||
} catch (IOException ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long getSize(File dir) {
|
||||
static long getSizeUsed(File dir) {
|
||||
long size = 0;
|
||||
File[] listed = dir.listFiles();
|
||||
if (listed != null)
|
||||
for (File file : listed)
|
||||
if (file.isDirectory())
|
||||
size += getSize(file);
|
||||
size += getSizeUsed(file);
|
||||
else
|
||||
size += file.length();
|
||||
return size;
|
||||
|
||||
@@ -1885,13 +1885,17 @@ public class Log {
|
||||
|
||||
long storage_available = Helper.getAvailableStorageSpace();
|
||||
long storage_total = Helper.getTotalStorageSpace();
|
||||
long storage_used = Helper.getSize(context.getFilesDir());
|
||||
long cache = Helper.getCacheQuota(context);
|
||||
sb.append(String.format("Storage space: %s/%s App: %s cache: %s\r\n",
|
||||
long storage_used = Helper.getSizeUsed(context.getFilesDir());
|
||||
sb.append(String.format("Storage space: %s/%s App: %s\r\n",
|
||||
Helper.humanReadableByteCount(storage_total - storage_available),
|
||||
Helper.humanReadableByteCount(storage_total),
|
||||
Helper.humanReadableByteCount(storage_used),
|
||||
cache > 0 ? Helper.humanReadableByteCount(cache) : "-"));
|
||||
Helper.humanReadableByteCount(storage_used)));
|
||||
|
||||
long cache_used = Helper.getSizeUsed(context.getCacheDir());
|
||||
long cache_quota = Helper.getCacheQuota(context);
|
||||
sb.append(String.format("Cache space: %s/%s\r\n",
|
||||
Helper.humanReadableByteCount(cache_used),
|
||||
Helper.humanReadableByteCount(cache_quota)));
|
||||
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
long hused = (rt.totalMemory() - rt.freeMemory()) / 1024L / 1024L;
|
||||
|
||||
Reference in New Issue
Block a user