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

Commit 21037e95 authored by Siddharth Ray's avatar Siddharth Ray Committed by Android (Google) Code Review
Browse files

Merge "GPS power calculation"

parents 0dea6c9e 0ed2e95f
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -6211,9 +6211,21 @@ public class BatteryStatsImpl extends BatteryStats {
    }
    @Override public long getGpsBatteryDrainMaMs() {
        //TODO: Add GPS power computation (b/67213967)
        final double opVolt = mPowerProfile.getAveragePower(
            PowerProfile.POWER_GPS_OPERATING_VOLTAGE) / 1000.0;
        if (opVolt == 0) {
            return 0;
        }
        double energyUsedMaMs = 0.0;
        final int which = STATS_SINCE_CHARGED;
        final long rawRealtime = SystemClock.elapsedRealtime() * 1000;
        for(int i=0; i < GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS; i++) {
            energyUsedMaMs
                += mPowerProfile.getAveragePower(PowerProfile.POWER_GPS_SIGNAL_QUALITY_BASED, i)
                * (getGpsSignalQualityTime(i, rawRealtime, which) / 1000);
        }
        return (long) energyUsedMaMs;
    }
    @Override public long getPhoneOnTime(long elapsedRealtimeUs, int which) {
        return mPhoneOnTimer.getTotalTimeLocked(elapsedRealtimeUs, which);
+7 −1
Original line number Diff line number Diff line
@@ -109,6 +109,12 @@ public class PowerProfile {
     */
    public static final String POWER_GPS_ON = "gps.on";

    /**
     * GPS power parameters based on signal quality
     */
    public static final String POWER_GPS_SIGNAL_QUALITY_BASED = "gps.signalqualitybased";
    public static final String POWER_GPS_OPERATING_VOLTAGE = "gps.voltage";

    /**
     * Power consumption when Bluetooth driver is on.
     * @deprecated
+7 −0
Original line number Diff line number Diff line
@@ -127,4 +127,11 @@
  </array>
  <item name="modem.controller.voltage">0</item>

  <!-- GPS related values. Default is 0.-->
  <array name="gps.signalqualitybased"> <!-- Strength 0 to 1 -->
    <value>0</value>
    <value>0</value>
  </array>
  <item name="gps.voltage">0</item>

</device>