[feat] add a thermal status row to the debug overlay panel#248
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis PR introduces an optional thermal-status row to the debug overlay's compact metrics panel. It adds thermal data collection via Android thermal APIs (API 30+), opt-in configuration through ChangesThermal Status Display Feature
Sequence DiagramsequenceDiagram
participant Config as User Configuration
participant OVM as OverlayViewManager
participant TDS as ThermalDataSource
participant PM as PowerManager
participant Panel as DebugOverlayPanel
participant UI as ThermalRow Composable
Config->>OVM: OverlayMode.FullMetrics(showThermal=true)
OVM->>TDS: subscribe to thermalState flow
par Push Updates
PM->>TDS: OnThermalStatusChanged event
and Periodic Polling
TDS->>PM: getThermalHeadroom every 10s
end
TDS->>TDS: deriveThermalStatus(raw status, headroom)
TDS->>OVM: emit ThermalState(status)
OVM->>Panel: pass thermalState parameter
Panel->>UI: render if status != UNSUPPORTED
UI->>UI: apply toStatusColor + compactLabelResId
UI-->>Config: display colored thermal indicator
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Claude encountered an error after 2m 55s —— View job Claude PR Review
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Line 192: The README currently lists thermal statuses as
PowerManager.THERMAL_STATUS_* using UI abbreviations
(NONE/LIGHT/MOD/SEV/CRIT/EMER/SHUT); update this to avoid confusion with actual
Android API constants by either expanding the abbreviations to the official
constant names (e.g., THERMAL_STATUS_MODERATE, THERMAL_STATUS_SEVERE,
THERMAL_STATUS_CRITICAL, THERMAL_STATUS_EMERGENCY, THERMAL_STATUS_SHUTDOWN) or
explicitly note that MOD/SEV/CRIT/EMER/SHUT are UI labels and provide a
parenthetical mapping to the corresponding PowerManager.THERMAL_STATUS_*
constants so readers can unambiguously map UI labels to API constants.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6b149842-8cc4-40f6-8ba3-c2af3b626c66
📒 Files selected for processing (14)
CHANGELOG.mdREADME.mddebugoverlay-core/src/debug/kotlin/com/ms/square/debugoverlay/internal/ui/DebugOverlayPanelPreviews.ktdebugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/OverlayMode.ktdebugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/OverlayViewManager.ktdebugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/model/DebugOverlayPanelMetrics.ktdebugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/model/ThermalState.ktdebugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/source/DebugOverlayPanelDataSource.ktdebugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/source/ThermalDataSource.ktdebugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/ui/DebugOverlayPanel.ktdebugoverlay-core/src/main/res/values/strings.xmldebugoverlay-core/src/test/kotlin/com/ms/square/debugoverlay/internal/data/source/ThermalDataSourceTest.ktsample/src/debugOverlay/kotlin/com/ms/square/debugoverlay/sample/DebugOverlaySetup.ktsample/src/main/kotlin/com/ms/square/debugoverlay/sample/ui/overlaytests/OverlayTestsScreen.kt
Qodana for JVMIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at qodana-support@jetbrains.com
|
|
Claude finished @Manabu-GT's task in 4m 3s —— View job Claude PR Review
Overall this is a well-scoped, well-tested feature with thoughtful API-level fallbacks (push + poll, headroom heuristic, UNSUPPORTED graceful degradation) and good doc references to Google's ADPF guidance. The bulk of the implementation is solid. Below are the items I'd flag. 🟠 Medium —
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/model/ThermalState.kt`:
- Around line 14-16: Update the KDoc for the ThermalState sealed values to match
runtime behavior: change the description that currently states "API 30+ device
with an incomplete thermal HAL maps to UNSUPPORTED" so it instead documents that
path maps to NONE. Locate the ThermalState enum/sealed class and adjust the KDoc
for the UNSUPPORTED and NONE entries (references: ThermalState, UNSUPPORTED,
NONE) so UNPSUPPORTED remains for devices lacking API and NONE documents the
API30+ incomplete HAL case.
In
`@debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/source/ThermalDataSource.kt`:
- Around line 80-82: The KDoc on ThermalDataSource incorrectly states that the
flow "stays open" for unsupported devices, but the implementation uses
flowOf(...) (at the creation in ThermalDataSource) which emits a single
ThermalStatus.UNSUPPORTED and completes; update the KDoc on the class or the
providing function to state that on Android < 11 the data source emits a single
ThermalStatus.UNSUPPORTED and completes (or alternatively change the
implementation to return a never-ending flow if you really need it to stay
open); reference ThermalDataSource and the flowOf(...) usage when making the
doc-change so the behavior and docs match.
In
`@debugoverlay-core/src/test/kotlin/com/ms/square/debugoverlay/internal/data/source/ThermalDataSourceTest.kt`:
- Around line 20-21: The KDoc for the ThermalDataSourceTest currently states
that an incomplete thermal HAL should be treated as `UNSUPPORTED`, but the test
suite asserts `NONE`; update the KDoc in ThermalDataSourceTest (the
class/comment block above the test cases) to state that an incomplete HAL is
treated as `NONE` to match the asserted behavior in the tests (adjust the
wording in the comment near the tests that mention incomplete HAL / ADPF
guidance so it reflects `NONE` instead of `UNSUPPORTED`).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 191e2f84-6719-4421-9d41-4edf7a67daf5
📒 Files selected for processing (8)
README.mddebugoverlay-core/src/debug/kotlin/com/ms/square/debugoverlay/internal/ui/DebugOverlayPanelPreviews.ktdebugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/OverlayViewManager.ktdebugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/model/ThermalState.ktdebugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/source/DebugOverlayPanelDataSource.ktdebugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/source/ThermalDataSource.ktdebugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/ui/DebugOverlayPanel.ktdebugoverlay-core/src/test/kotlin/com/ms/square/debugoverlay/internal/data/source/ThermalDataSourceTest.kt
✅ Files skipped from review due to trivial changes (1)
- README.md

Summary by CodeRabbit
New Features
OverlayMode.FullMetrics(showThermal = true). Displays device thermal throttling states: None, Light, Moderate, Severe, Critical, Emergency, and Shutdown.Documentation
Tests