Search in sources :

Example 6 with HealthStatsWriter

use of android.os.health.HealthStatsWriter in project android_frameworks_base by ResurrectionRemix.

the class BatteryStatsService method getHealthStatsForUidLocked.

/**
     * Gets a HealthStatsParceler for the given uid. You should probably call
     * updateExternalStatsSync first.
     */
HealthStatsParceler getHealthStatsForUidLocked(int requestUid) {
    final HealthStatsBatteryStatsWriter writer = new HealthStatsBatteryStatsWriter();
    final HealthStatsWriter uidWriter = new HealthStatsWriter(UidHealthStats.CONSTANTS);
    final BatteryStats.Uid uid = mStats.getUidStats().get(requestUid);
    if (uid != null) {
        writer.writeUid(uidWriter, mStats, uid);
    }
    return new HealthStatsParceler(uidWriter);
}
Also used : HealthStatsWriter(android.os.health.HealthStatsWriter) HealthStatsParceler(android.os.health.HealthStatsParceler) IBatteryStats(com.android.internal.app.IBatteryStats) BatteryStats(android.os.BatteryStats)

Example 7 with HealthStatsWriter

use of android.os.health.HealthStatsWriter in project android_frameworks_base by ResurrectionRemix.

the class HealthStatsBatteryStatsWriter method writePkg.

/**
     * Writes the contents of a BatteryStats.Uid.Pkg into a HealthStatsWriter.
     */
public void writePkg(HealthStatsWriter pkgWriter, BatteryStats.Uid.Pkg pkg) {
    // STATS_SERVICES
    for (final Map.Entry<String, ? extends BatteryStats.Uid.Pkg.Serv> entry : pkg.getServiceStats().entrySet()) {
        final HealthStatsWriter writer = new HealthStatsWriter(ServiceHealthStats.CONSTANTS);
        writeServ(writer, entry.getValue());
        pkgWriter.addStats(PackageHealthStats.STATS_SERVICES, entry.getKey(), writer);
    }
    // MEASUREMENTS_WAKEUP_ALARMS_COUNT
    for (final Map.Entry<String, ? extends BatteryStats.Counter> entry : pkg.getWakeupAlarmStats().entrySet()) {
        final BatteryStats.Counter counter = entry.getValue();
        if (counter != null) {
            pkgWriter.addMeasurements(PackageHealthStats.MEASUREMENTS_WAKEUP_ALARMS_COUNT, entry.getKey(), counter.getCountLocked(STATS_SINCE_UNPLUGGED));
        }
    }
}
Also used : HealthStatsWriter(android.os.health.HealthStatsWriter) Map(java.util.Map) BatteryStats(android.os.BatteryStats)

Example 8 with HealthStatsWriter

use of android.os.health.HealthStatsWriter in project android_frameworks_base by crdroidandroid.

the class HealthStatsBatteryStatsWriter method writePkg.

/**
     * Writes the contents of a BatteryStats.Uid.Pkg into a HealthStatsWriter.
     */
public void writePkg(HealthStatsWriter pkgWriter, BatteryStats.Uid.Pkg pkg) {
    // STATS_SERVICES
    for (final Map.Entry<String, ? extends BatteryStats.Uid.Pkg.Serv> entry : pkg.getServiceStats().entrySet()) {
        final HealthStatsWriter writer = new HealthStatsWriter(ServiceHealthStats.CONSTANTS);
        writeServ(writer, entry.getValue());
        pkgWriter.addStats(PackageHealthStats.STATS_SERVICES, entry.getKey(), writer);
    }
    // MEASUREMENTS_WAKEUP_ALARMS_COUNT
    for (final Map.Entry<String, ? extends BatteryStats.Counter> entry : pkg.getWakeupAlarmStats().entrySet()) {
        final BatteryStats.Counter counter = entry.getValue();
        if (counter != null) {
            pkgWriter.addMeasurements(PackageHealthStats.MEASUREMENTS_WAKEUP_ALARMS_COUNT, entry.getKey(), counter.getCountLocked(STATS_SINCE_UNPLUGGED));
        }
    }
}
Also used : HealthStatsWriter(android.os.health.HealthStatsWriter) Map(java.util.Map) BatteryStats(android.os.BatteryStats)

Example 9 with HealthStatsWriter

use of android.os.health.HealthStatsWriter in project platform_frameworks_base by android.

the class BatteryStatsService method getHealthStatsForUidLocked.

/**
     * Gets a HealthStatsParceler for the given uid. You should probably call
     * updateExternalStatsSync first.
     */
HealthStatsParceler getHealthStatsForUidLocked(int requestUid) {
    final HealthStatsBatteryStatsWriter writer = new HealthStatsBatteryStatsWriter();
    final HealthStatsWriter uidWriter = new HealthStatsWriter(UidHealthStats.CONSTANTS);
    final BatteryStats.Uid uid = mStats.getUidStats().get(requestUid);
    if (uid != null) {
        writer.writeUid(uidWriter, mStats, uid);
    }
    return new HealthStatsParceler(uidWriter);
}
Also used : HealthStatsWriter(android.os.health.HealthStatsWriter) HealthStatsParceler(android.os.health.HealthStatsParceler) IBatteryStats(com.android.internal.app.IBatteryStats) BatteryStats(android.os.BatteryStats)

Example 10 with HealthStatsWriter

use of android.os.health.HealthStatsWriter in project platform_frameworks_base by android.

the class HealthStatsBatteryStatsWriter method writePkg.

/**
     * Writes the contents of a BatteryStats.Uid.Pkg into a HealthStatsWriter.
     */
public void writePkg(HealthStatsWriter pkgWriter, BatteryStats.Uid.Pkg pkg) {
    // STATS_SERVICES
    for (final Map.Entry<String, ? extends BatteryStats.Uid.Pkg.Serv> entry : pkg.getServiceStats().entrySet()) {
        final HealthStatsWriter writer = new HealthStatsWriter(ServiceHealthStats.CONSTANTS);
        writeServ(writer, entry.getValue());
        pkgWriter.addStats(PackageHealthStats.STATS_SERVICES, entry.getKey(), writer);
    }
    // MEASUREMENTS_WAKEUP_ALARMS_COUNT
    for (final Map.Entry<String, ? extends BatteryStats.Counter> entry : pkg.getWakeupAlarmStats().entrySet()) {
        final BatteryStats.Counter counter = entry.getValue();
        if (counter != null) {
            pkgWriter.addMeasurements(PackageHealthStats.MEASUREMENTS_WAKEUP_ALARMS_COUNT, entry.getKey(), counter.getCountLocked(STATS_SINCE_UNPLUGGED));
        }
    }
}
Also used : HealthStatsWriter(android.os.health.HealthStatsWriter) Map(java.util.Map) BatteryStats(android.os.BatteryStats)

Aggregations

BatteryStats (android.os.BatteryStats)15 HealthStatsWriter (android.os.health.HealthStatsWriter)15 Map (java.util.Map)10 HealthStatsParceler (android.os.health.HealthStatsParceler)5 IBatteryStats (com.android.internal.app.IBatteryStats)5