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

Commit 9d8f51cb authored by yuanhuihui's avatar yuanhuihui
Browse files

fix wrong algorithm in WifiPowerPerPacket()



step1: PowerProfile.POWER_WIFI_ACTIVE represents energy consumption(mAh) per hour
devied by 3600, then WIFI_POWER ==> energy consumption(mAh) per second

step2: WIFI_BPS represents 1000000 bit per second
then (double)WIFI_BPS) / 8  ==> 1000000/8 Byte per second

step3: as upload and download, so divided  by 2;
then   (((double)WIFI_BPS) / 8 / 2048))  ==> 1000000/8/2048 KB per second
==> packet  per second (where 1 packet = 2 KB)

so WIFI_POWER / (((double)WIFI_BPS) / 8 / 2048) represents  mAh per Packet where 1 packet = 2 K.

when  divided by (60*60) again , that make WifiPowerEstimator narrow 3600 times.

Change-Id: Ic055a5145b6dfb1129c8969826329a3024c9e2b6
Signed-off-by: default avataryuanhuihui <yuanhuihui@xiaomi.com>
parent f7c508ae
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -38,13 +38,13 @@ public class WifiPowerEstimator extends PowerCalculator {
    }

    /**
     * Return estimated power (in mAs) of sending a byte with the Wi-Fi radio.
     * Return estimated power per Wi-Fi packet in mAh/packet where 1 packet = 2 KB.
     */
    private static double getWifiPowerPerPacket(PowerProfile profile) {
        final long WIFI_BPS = 1000000; // TODO: Extract average bit rates from system
        final double WIFI_POWER = profile.getAveragePower(PowerProfile.POWER_WIFI_ACTIVE)
                / 3600;
        return (WIFI_POWER / (((double)WIFI_BPS) / 8 / 2048)) / (60*60);
        return WIFI_POWER / (((double)WIFI_BPS) / 8 / 2048);
    }

    @Override