That fuck shit the fascists are using
1package org.tm.archive.logsubmit;
2
3import android.app.usage.UsageStatsManager;
4import android.content.Context;
5
6import androidx.annotation.NonNull;
7import androidx.annotation.RequiresApi;
8
9import org.tm.archive.util.BucketInfo;
10
11import java.util.concurrent.TimeUnit;
12
13@RequiresApi(28)
14public class LogSectionPower implements LogSection {
15
16 @Override
17 public @NonNull String getTitle() {
18 return "POWER";
19 }
20
21 @Override
22 public @NonNull CharSequence getContent(@NonNull Context context) {
23 final UsageStatsManager usageStatsManager = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE);
24
25 if (usageStatsManager == null) {
26 return "UsageStatsManager not available";
27 }
28
29 BucketInfo info = BucketInfo.getInfo(usageStatsManager, TimeUnit.DAYS.toMillis(3));
30
31 return new StringBuilder().append("Current bucket: ").append(BucketInfo.bucketToString(info.getCurrentBucket())).append('\n')
32 .append("Highest bucket: ").append(BucketInfo.bucketToString(info.getBestBucket())).append('\n')
33 .append("Lowest bucket : ").append(BucketInfo.bucketToString(info.getWorstBucket())).append("\n\n")
34 .append(info.getHistory());
35 }
36}