diff options
| author | 2023-04-26 16:47:27 +0000 | |
|---|---|---|
| committer | 2023-04-26 16:47:27 +0000 | |
| commit | 5b3b93240b918c63164452ab53a51cb806c9b9dd (patch) | |
| tree | 1828ccd079ef8b2cf6cc6e03aeb42c75d73be289 | |
| parent | a341f280d02a9433878f4865ca6d566e71c8a96a (diff) | |
| parent | 4e5e8d7e83a84d8904c0445423be16faa34fa50a (diff) | |
Merge "Handle negative CPU availability percent in CpuMonitorService." into udc-dev
| -rw-r--r-- | services/core/java/com/android/server/cpu/CpuMonitorService.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/cpu/CpuMonitorService.java b/services/core/java/com/android/server/cpu/CpuMonitorService.java index df8cfad4ab03..7ea2c1b02040 100644 --- a/services/core/java/com/android/server/cpu/CpuMonitorService.java +++ b/services/core/java/com/android/server/cpu/CpuMonitorService.java @@ -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 |