Added standby bucket names

This commit is contained in:
M66B 2021-08-18 20:43:25 +02:00
parent 03e2013ab1
commit 5657b35069
2 changed files with 21 additions and 1 deletions

View File

@ -26,6 +26,7 @@ import android.Manifest;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.KeyguardManager;
import android.app.usage.UsageStatsManager;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.ContentResolver;
@ -546,6 +547,23 @@ public class Helper {
}
}
static String getStandbyBucketName(int bucket) {
switch (bucket) {
case UsageStatsManager.STANDBY_BUCKET_ACTIVE:
return "active";
case UsageStatsManager.STANDBY_BUCKET_WORKING_SET:
return "workingset";
case UsageStatsManager.STANDBY_BUCKET_FREQUENT:
return "frequent";
case UsageStatsManager.STANDBY_BUCKET_RARE:
return "rare";
case UsageStatsManager.STANDBY_BUCKET_RESTRICTED:
return "restricted";
default:
return Integer.toString(bucket);
}
}
// View
static Intent getChooser(Context context, Intent intent) {

View File

@ -1766,7 +1766,9 @@ public class Log {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
UsageStatsManager usm = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE);
int bucket = usm.getAppStandbyBucket();
sb.append(String.format("Standby bucket: %d\r\n", bucket));
boolean inactive = usm.isAppInactive(BuildConfig.APPLICATION_ID);
sb.append(String.format("Standby bucket: %d-%s;p inactive: %b\r\n",
bucket, Helper.getStandbyBucketName(bucket), inactive));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)