diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-12-08 12:06:55 -0800 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2015-12-10 00:48:24 +0000 |
commit | ba88e68fe47b66f1fc5d10c15f04f20fe662399e (patch) | |
tree | 34b07bf2d99d9758841cfd91650f346d8b01a291 /core/java/com | |
parent | 180dd72a9b36ca6f74e5ad255347d815a0c8729a (diff) | |
download | frameworks_base-ba88e68fe47b66f1fc5d10c15f04f20fe662399e.zip frameworks_base-ba88e68fe47b66f1fc5d10c15f04f20fe662399e.tar.gz frameworks_base-ba88e68fe47b66f1fc5d10c15f04f20fe662399e.tar.bz2 |
Prevent DivideByZero error in BatteryStatsImpl
It was assumed that when a UID had either rx or tx bytes/packets that it would
have the other as well.
Bug:25706750
Change-Id: Iefac59a6bd02876aed9a0bac218d187b81807a95
Diffstat (limited to 'core/java/com')
-rw-r--r-- | core/java/com/android/internal/os/BatteryStatsImpl.java | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 64b7768..a47724c 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -7699,26 +7699,35 @@ public final class BatteryStatsImpl extends BatteryStats { } final Uid u = getUidStatsLocked(mapUid(entry.uid)); - u.noteNetworkActivityLocked(NETWORK_WIFI_RX_DATA, entry.rxBytes, - entry.rxPackets); - u.noteNetworkActivityLocked(NETWORK_WIFI_TX_DATA, entry.txBytes, - entry.txPackets); - 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 - // be evenly distributed amongst the apps. - totalRxPackets += entry.rxPackets; - totalTxPackets += entry.txPackets; - - mNetworkByteActivityCounters[NETWORK_WIFI_RX_DATA].addCountLocked( - entry.rxBytes); - mNetworkByteActivityCounters[NETWORK_WIFI_TX_DATA].addCountLocked( - entry.txBytes); - mNetworkPacketActivityCounters[NETWORK_WIFI_RX_DATA].addCountLocked( - entry.rxPackets); - mNetworkPacketActivityCounters[NETWORK_WIFI_TX_DATA].addCountLocked( - entry.txPackets); + if (entry.rxBytes != 0) { + u.noteNetworkActivityLocked(NETWORK_WIFI_RX_DATA, entry.rxBytes, + entry.rxPackets); + mNetworkByteActivityCounters[NETWORK_WIFI_RX_DATA].addCountLocked( + entry.rxBytes); + mNetworkPacketActivityCounters[NETWORK_WIFI_RX_DATA].addCountLocked( + entry.rxPackets); + + rxPackets.put(u.getUid(), entry.rxPackets); + + // Sum the total number of packets so that the Rx Power can + // be evenly distributed amongst the apps. + totalRxPackets += entry.rxPackets; + } + + 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_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; + } } } |