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

Commit e761adc7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Updated StatsPerUidLogger device wide component power consumed reporting" into main

parents 61cb4abb 3ed19f26
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -1251,12 +1251,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub
        }

        private static float clampPowerMah(double powerMah, String consumer) {
            float resultPowerMah = 0;
            if (powerMah <= Float.MAX_VALUE && powerMah >= Float.MIN_VALUE) {
                resultPowerMah = (float) powerMah;
            } else {
                // Handle overflow appropriately
                Slog.wtfStack(TAG, consumer + " reported powerMah float overflow: " + powerMah);
            float resultPowerMah = Double.valueOf(powerMah).floatValue();
            if (Float.isInfinite(resultPowerMah)) {
                resultPowerMah = 0;
                Slog.d(TAG, consumer + " reported powerMah float overflow : " + powerMah);
            }
            return resultPowerMah;
        }
@@ -1361,11 +1359,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub

            final String powerComponentName = batteryConsumer.getPowerComponentName(componentId);
            final double consumedPowerMah = batteryConsumer.getConsumedPower(key);
            float powerMah =
            final float powerMah =
                    clampPowerMah(
                            consumedPowerMah, "uidConsumer-" + uid + "-" + powerComponentName);
                            consumedPowerMah, "uid-" + uid + "-" + powerComponentName);
            final long powerComponentDurationMillis = batteryConsumer.getUsageDurationMillis(key);

            if (powerMah == 0 && powerComponentDurationMillis == 0) {
                return true;
            }