Debug: cache size

This commit is contained in:
M66B
2022-04-30 22:05:28 +02:00
parent ccf888cd77
commit 3d2291c551
4 changed files with 25 additions and 5 deletions

View File

@@ -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();