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

Commit 5b3b9324 authored by Lakshman Annadorai's avatar Lakshman Annadorai Committed by Android (Google) Code Review
Browse files

Merge "Handle negative CPU availability percent in CpuMonitorService." into udc-dev

parents a341f280 4e5e8d7e
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -653,8 +653,17 @@ public final class CpuMonitorService extends SystemService {
            }

            public int getAverageAvailableCpuFreqPercent() {
                return (int) ((totalNormalizedAvailableCpuFreqKHz * 100.0)
                int percent = (int) ((totalNormalizedAvailableCpuFreqKHz * 100.0)
                        / totalOnlineMaxCpuFreqKHz);
                if (percent < 0) {
                    // TODO(b/279478586): This case should never happen. But this case happens
                    // rarely on certain hardware, which indicates a deeper issue. Once this
                    // issue is reproduced, use this log to debug the issue and fix it.
                    Slogf.wtf(TAG, "Computed negative CPU availability percent(%d) for %s ",
                            percent, toString());
                    return 0;
                }
                return percent;
            }

            @Override