mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-15 16:39:37 +00:00
Added standby bucket names
This commit is contained in:
parent
03e2013ab1
commit
5657b35069
2 changed files with 21 additions and 1 deletions
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue