Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a267976 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Statsd: change power units from double to int64"

parents fd671a5a 3dbc13a9
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -3474,10 +3474,10 @@ message BuildInformation {
 * Pulls on-device BatteryStats power use calculations for the overall device.
 */
message DeviceCalculatedPowerUse {
    // Power used by the device in mAh, as computed by BatteryStats, since BatteryStats last reset
    // (i.e. roughly since device was last significantly charged).
    // Currently, this is BatteryStatsHelper.getComputedPower() (not getTotalPower()).
    optional float computed_power_milli_amp_hours = 1;
    // Power used by the device in nAs (i.e. nanocoulombs (nC)), as computed by BatteryStats, since
    // BatteryStats last reset (i.e. roughly since device was last significantly charged).
    // Currently, this is from BatteryStatsHelper.getComputedPower() (not getTotalPower()).
    optional int64 computed_power_nano_amp_secs = 1;
}

/**
@@ -3489,9 +3489,9 @@ message DeviceCalculatedPowerBlameUid {
    // Uid being blamed. Note: isolated uids have already been mapped to host uid.
    optional int32 uid = 1 [(is_uid) = true];

    // Power used by this uid in mAh, as computed by BatteryStats, since BatteryStats last reset
    // (i.e. roughly since device was last significantly charged).
    optional float power_milli_amp_hours = 2;
    // Power used by this uid in nAs (i.e. nanocoulombs (nC)), as computed by BatteryStats, since
    // BatteryStats last reset (i.e. roughly since device was last significantly charged).
    optional int64 power_nano_amp_secs = 2;
}

/**
@@ -3525,9 +3525,9 @@ message DeviceCalculatedPowerBlameOther {
    }
    optional DrainType drain_type = 1;

    // Power used by this item in mAh, as computed by BatteryStats, since BatteryStats last reset
    // (i.e. roughly since device was last significantly charged).
    optional float power_milli_amp_hours = 2;
    // Power used by this item in nAs (i.e. nanocoulombs (nC)), as computed by BatteryStats, since
    // BatteryStats last reset (i.e. roughly since device was last significantly charged).
    optional int64 power_nano_amp_secs = 2;
}

/**
+8 −3
Original line number Diff line number Diff line
@@ -1563,11 +1563,16 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
        return mBatteryStatsHelper;
    }

    private long milliAmpHrsToNanoAmpSecs(double mAh) {
        final long MILLI_AMP_HR_TO_NANO_AMP_SECS = 1_000_000L * 3600L;
        return (long) (mAh * MILLI_AMP_HR_TO_NANO_AMP_SECS + 0.5);
    }

    private void pullDeviceCalculatedPowerUse(int tagId,
            long elapsedNanos, final long wallClockNanos, List<StatsLogEventWrapper> pulledData) {
        BatteryStatsHelper bsHelper = getBatteryStatsHelper();
        StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
        e.writeFloat((float) bsHelper.getComputedPower());
        e.writeLong(milliAmpHrsToNanoAmpSecs(bsHelper.getComputedPower()));
        pulledData.add(e);
    }

@@ -1583,7 +1588,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
            }
            StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
            e.writeInt(bs.uidObj.getUid());
            e.writeFloat((float) bs.totalPowerMah);
            e.writeLong(milliAmpHrsToNanoAmpSecs(bs.totalPowerMah));
            pulledData.add(e);
        }
    }
@@ -1603,7 +1608,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
            }
            StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
            e.writeInt(bs.drainType.ordinal());
            e.writeFloat((float) bs.totalPowerMah);
            e.writeLong(milliAmpHrsToNanoAmpSecs(bs.totalPowerMah));
            pulledData.add(e);
        }
    }