Search in sources :

Example 26 with BatterySipper

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;
}
Also used : BatterySipper(com.android.internal.os.BatterySipper)

Example 27 with BatterySipper

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;
}
Also used : BatterySipper(com.android.internal.os.BatterySipper) ArrayList(java.util.ArrayList) Anomaly(com.android.settings.fuelgauge.anomaly.Anomaly) BatteryStats(android.os.BatteryStats)

Example 28 with BatterySipper

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;
}
Also used : BatterySipper(com.android.internal.os.BatterySipper)

Example 29 with BatterySipper

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;
}
Also used : BatterySipper(com.android.internal.os.BatterySipper)

Example 30 with BatterySipper

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);
}
Also used : BatterySipper(com.android.internal.os.BatterySipper) Test(org.junit.Test)

Aggregations

BatterySipper (com.android.internal.os.BatterySipper)148 ArrayList (java.util.ArrayList)60 BatteryStats (android.os.BatteryStats)48 VisibleForTesting (android.support.annotation.VisibleForTesting)30 Test (org.junit.Test)29 Anomaly (com.android.settings.fuelgauge.anomaly.Anomaly)18 HashMap (java.util.HashMap)16 UserHandle (android.os.UserHandle)15 ArrayMap (android.util.ArrayMap)10 BatteryStatsHelper (com.android.internal.os.BatteryStatsHelper)10 Map (java.util.Map)10 Drawable (android.graphics.drawable.Drawable)8 SparseArray (android.util.SparseArray)8 DrainType (com.android.internal.os.BatterySipper.DrainType)8 PowerProfile (com.android.internal.os.PowerProfile)8 Bundle (android.os.Bundle)7 SparseLongArray (android.util.SparseLongArray)7 Context (android.content.Context)6 TypedArray (android.content.res.TypedArray)6 PowerUsageData (com.android.settings.fuelgauge.PowerUsageAdvanced.PowerUsageData)6