Skip to content

Commit

Permalink
add workaround for updateWifiBatteryStats() system_server crash
Browse files Browse the repository at this point in the history
  • Loading branch information
muhomorr authored and thestinger committed Jan 7, 2025
1 parent 2512151 commit dc379a4
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12660,11 +12660,13 @@ private void updateWifiBatteryStats(WifiActivityEnergyInfo info,

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

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

0 comments on commit dc379a4

Please sign in to comment.