Skip to content

Commit dc379a4

Browse files
muhomorrthestinger
authored andcommitted
add workaround for updateWifiBatteryStats() system_server crash
1 parent 2512151 commit dc379a4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

services/core/java/com/android/server/power/stats/BatteryStatsImpl.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12660,11 +12660,13 @@ private void updateWifiBatteryStats(WifiActivityEnergyInfo info,
1266012660

1266112661
// Distribute the remaining Tx power appropriately between all apps that transmitted
1266212662
// packets.
12663-
for (int i = 0; i < txPackets.size(); i++) {
12664-
final int uid = txPackets.keyAt(i);
12665-
final long myTxTimeMs = (txPackets.valueAt(i) * leftOverTxTimeMs)
12666-
/ totalTxPackets;
12667-
txTimesMs.incrementValue(uid, myTxTimeMs);
12663+
if (totalTxPackets > 0) { // see https://github.com/GrapheneOS/os-issue-tracker/issues/4627
12664+
for (int i = 0; i < txPackets.size(); i++) {
12665+
final int uid = txPackets.keyAt(i);
12666+
final long myTxTimeMs = (txPackets.valueAt(i) * leftOverTxTimeMs)
12667+
/ totalTxPackets;
12668+
txTimesMs.incrementValue(uid, myTxTimeMs);
12669+
}
1266812670
}
1266912671

1267012672
// Distribute the remaining Rx power appropriately between all apps that received

0 commit comments

Comments
 (0)