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

Commit f8fc8299 authored by Adam Bookatz's avatar Adam Bookatz Committed by Automerger Merge Worker
Browse files

Merge "Fix error in MeasuredEnergySnapshot voltage" into sc-dev am: ed21f7f9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13932813

Change-Id: I6d419718957f3193cfc37c0effb306b53b2aecc9
parents 54a676c5 ed21f7f9
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -241,7 +241,7 @@ public class MeasuredEnergySnapshot {
    /**
     * For a consumer of type {@link EnergyConsumerType#OTHER}, updates
     * {@link #mAttributionSnapshots} with freshly measured energies (per uid) and returns the
     * charge consumed (in microcouloumbs) between the previously stored values and the passed-in
     * charge consumed (in microcoulombs) between the previously stored values and the passed-in
     * values.
     *
     * @param consumerInfo a consumer of type {@link EnergyConsumerType#OTHER}.
@@ -341,11 +341,11 @@ public class MeasuredEnergySnapshot {
        return numOrdinals;
    }

    /** Calculate charge consumption (in microcouloumbs) from a given energy and voltage */
    /** Calculate charge consumption (in microcoulombs) from a given energy and voltage */
    private long calculateChargeConsumedUC(long deltaEnergyUJ, int avgVoltageMV) {
        // To overflow, a 3.7V 10000mAh battery would need to completely drain 69244 times
        // since the last snapshot. Round up to the nearest whole long.
        return (deltaEnergyUJ * MILLIVOLTS_PER_VOLT + (avgVoltageMV + 1) / 2) / avgVoltageMV;
        // since the last snapshot. Round off to the nearest whole long.
        return (deltaEnergyUJ * MILLIVOLTS_PER_VOLT + (avgVoltageMV / 2)) / avgVoltageMV;
    }

}