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

Commit 794a18f5 authored by Adam Lesinski's avatar Adam Lesinski Committed by android-build-merger
Browse files

Prevent DivideByZero error in BatteryStatsImpl am: ba88e68f am: 4e4ff058

am: 0b754d12

* commit '0b754d12':
  Prevent DivideByZero error in BatteryStatsImpl
parents 65fd3fec 0b754d12
Loading
Loading
Loading
Loading
+29 −20
Original line number Diff line number Diff line
@@ -7732,26 +7732,35 @@ public final class BatteryStatsImpl extends BatteryStats {
                }

                final Uid u = getUidStatsLocked(mapUid(entry.uid));
                if (entry.rxBytes != 0) {
                    u.noteNetworkActivityLocked(NETWORK_WIFI_RX_DATA, entry.rxBytes,
                            entry.rxPackets);
                u.noteNetworkActivityLocked(NETWORK_WIFI_TX_DATA, entry.txBytes,
                        entry.txPackets);
                    mNetworkByteActivityCounters[NETWORK_WIFI_RX_DATA].addCountLocked(
                            entry.rxBytes);
                    mNetworkPacketActivityCounters[NETWORK_WIFI_RX_DATA].addCountLocked(
                            entry.rxPackets);

                    rxPackets.put(u.getUid(), entry.rxPackets);
                txPackets.put(u.getUid(), entry.txPackets);

                // Sum the total number of packets so that the Rx Power and Tx Power can
                    // Sum the total number of packets so that the Rx Power can
                    // be evenly distributed amongst the apps.
                    totalRxPackets += entry.rxPackets;
                totalTxPackets += entry.txPackets;
                }

                mNetworkByteActivityCounters[NETWORK_WIFI_RX_DATA].addCountLocked(
                        entry.rxBytes);
                if (entry.txBytes != 0) {
                    u.noteNetworkActivityLocked(NETWORK_WIFI_TX_DATA, entry.txBytes,
                            entry.txPackets);
                    mNetworkByteActivityCounters[NETWORK_WIFI_TX_DATA].addCountLocked(
                            entry.txBytes);
                mNetworkPacketActivityCounters[NETWORK_WIFI_RX_DATA].addCountLocked(
                        entry.rxPackets);
                    mNetworkPacketActivityCounters[NETWORK_WIFI_TX_DATA].addCountLocked(
                            entry.txPackets);

                    txPackets.put(u.getUid(), entry.txPackets);

                    // Sum the total number of packets so that the Tx Power can
                    // be evenly distributed amongst the apps.
                    totalTxPackets += entry.txPackets;
                }
            }
        }