use of com.android.internal.os.BatterySipper in project android_packages_apps_Settings by crdroidandroid.
the class BatteryEntryTest method createSipperForApp.
private BatterySipper createSipperForApp() {
BatterySipper sipper = new BatterySipper(DrainType.APP, new FakeUid(APP_UID), 0);
sipper.packageWithHighestDrain = HIGH_DRAIN_PACKAGE;
return sipper;
}
use of com.android.internal.os.BatterySipper in project android_packages_apps_Settings by crdroidandroid.
the class WakeLockAnomalyDetector method detectAnomalies.
@Override
public List<Anomaly> detectAnomalies(BatteryStatsHelper batteryStatsHelper, String targetPackageName) {
final List<BatterySipper> batterySippers = batteryStatsHelper.getUsageList();
final List<Anomaly> anomalies = new ArrayList<>();
final long rawRealtime = SystemClock.elapsedRealtime();
final int targetUid = mBatteryUtils.getPackageUid(targetPackageName);
// Check the app one by one
for (int i = 0, size = batterySippers.size(); i < size; i++) {
final BatterySipper sipper = batterySippers.get(i);
final BatteryStats.Uid uid = sipper.uidObj;
if (uid == null || mBatteryUtils.shouldHideSipper(sipper) || (targetUid != BatteryUtils.UID_NULL && targetUid != uid.getUid())) {
continue;
}
final long currentDurationMs = getCurrentDurationMs(uid, rawRealtime);
final long backgroundDurationMs = getBackgroundTotalDurationMs(uid, rawRealtime);
if (backgroundDurationMs > mWakeLockThresholdMs && currentDurationMs != 0) {
final String packageName = mBatteryUtils.getPackageName(uid.getUid());
final CharSequence displayName = Utils.getApplicationLabel(mContext, packageName);
Anomaly anomaly = new Anomaly.Builder().setUid(uid.getUid()).setType(Anomaly.AnomalyType.WAKE_LOCK).setDisplayName(displayName).setPackageName(packageName).setWakeLockTimeMs(backgroundDurationMs).build();
if (mAnomalyUtils.getAnomalyAction(anomaly).isActionActive(anomaly)) {
anomalies.add(anomaly);
}
}
}
return anomalies;
}
use of com.android.internal.os.BatterySipper in project android_packages_apps_Settings by SudaMod.
the class BatteryEntryTest method createSipperForSystem.
private BatterySipper createSipperForSystem() {
BatterySipper sipper = new BatterySipper(DrainType.APP, new FakeUid(SYSTEM_UID), 0);
sipper.packageWithHighestDrain = HIGH_DRAIN_PACKAGE;
sipper.mPackages = SYSTEM_PACKAGES;
return sipper;
}
use of com.android.internal.os.BatterySipper in project android_packages_apps_Settings by SudaMod.
the class BatteryEntryTest method createSipperForApp.
private BatterySipper createSipperForApp() {
BatterySipper sipper = new BatterySipper(DrainType.APP, new FakeUid(APP_UID), 0);
sipper.packageWithHighestDrain = HIGH_DRAIN_PACKAGE;
return sipper;
}
use of com.android.internal.os.BatterySipper in project android_packages_apps_Settings by SudaMod.
the class PowerUsageAdvancedTest method testFindBatterySipperWithMaxBatteryUsage_findCorrectOne.
@Test
public void testFindBatterySipperWithMaxBatteryUsage_findCorrectOne() {
mPowerUsageData.usageList.add(mNormalBatterySipper);
mPowerUsageData.usageList.add(mMaxBatterySipper);
BatterySipper sipper = mPowerUsageAdvanced.findBatterySipperWithMaxBatteryUsage(mPowerUsageData.usageList);
assertThat(sipper).isEqualTo(mMaxBatterySipper);
}
Aggregations