In High usage, hide apps without screen time.

If the screen time is less than 1 minute, don't show it in high
usage dialog.

Also sort the list first before cut the list size.

Change-Id: I2f8876dcc16b3d6156cb0aa9e19c7fdd4ceac34e
Fixes: 77303928
Test: RunSettingsRoboTests
This commit is contained in:
Lei Yu
2018-03-30 14:43:34 -07:00
parent f3789adffd
commit 7b9682ce87
2 changed files with 41 additions and 16 deletions

View File

@@ -19,6 +19,7 @@ package com.android.settings.fuelgauge.batterytip.detectors;
import android.content.Context;
import android.os.BatteryStats;
import android.support.annotation.VisibleForTesting;
import android.text.format.DateUtils;
import com.android.internal.os.BatterySipper;
import com.android.internal.os.BatteryStatsHelper;
@@ -72,18 +73,20 @@ public class HighUsageDetector implements BatteryTipDetector {
final long foregroundTimeMs = mBatteryUtils.getProcessTimeMs(
BatteryUtils.StatusType.FOREGROUND, batterySipper.uidObj,
BatteryStats.STATS_SINCE_CHARGED);
mHighUsageAppList.add(new AppInfo.Builder()
.setUid(batterySipper.getUid())
.setPackageName(
mBatteryUtils.getPackageName(batterySipper.getUid()))
.setScreenOnTimeMs(foregroundTimeMs)
.build());
if (foregroundTimeMs >= DateUtils.MINUTE_IN_MILLIS) {
mHighUsageAppList.add(new AppInfo.Builder()
.setUid(batterySipper.getUid())
.setPackageName(
mBatteryUtils.getPackageName(batterySipper.getUid()))
.setScreenOnTimeMs(foregroundTimeMs)
.build());
}
}
}
Collections.sort(mHighUsageAppList, Collections.reverseOrder());
mHighUsageAppList = mHighUsageAppList.subList(0,
Math.min(mPolicy.highUsageAppCount, mHighUsageAppList.size()));
Collections.sort(mHighUsageAppList, Collections.reverseOrder());
}
}