Repository navigation
chore: gate API-level mistakes with lint in CI - #196
Conversation
Lint had never run on this project — no config, no baseline, not in CI — and two startup crashes reached users because of it: a Spatializer call gated at API 31 for a class introduced at 32 (#195), and this change fixes the two remaining unguarded calls in the same file. AudioDeviceInfo.getAddress() is API 28 and had no guard at all; it threw NoSuchMethodError on API 24-27 whenever diagnostics were collected. AudioTrack.isDirectPlaybackSupported() is API 29 and was reached on anything below TIRAMISU; runCatching swallowed the error, so pre-Q devices silently reported no passthrough and transcoded audio they could have played directly. The gate itself: NewApi and InlinedApi are fatal, apps set checkDependencies so android-shared is actually analysed — it is where both crashes lived and where app-level lint was blind — and per-module baselines hold the existing findings so only new violations fail. The baselines are almost entirely desugared java.* calls and deliberate media3 @UnstableApi usage. Verified by reintroducing the unguarded getAddress call: the build fails with 'Call requires API level 28 (current min is 24)'. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe pull request adds Android lint enforcement to three modules and CI. It also adds API-level guards for audio device addresses, direct playback probing, and E-AC3 JOC capability checks. ChangesAndroid quality and compatibility
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
…t in CI Two gaps left by the lint gate itself. `EncodingSupport` carries a `minSdk` field precisely so an encoding constant is only queried on platforms that have it. `dts_hd`, `truehd` and `ac4` all use it. `eac3_joc` needs API 28 exactly as `ac4` does, and was the one entry left on the default of 1, so API 24-27 queried the platform for an encoding that does not exist there. It could not crash — the constant is inlined, and the platform answers false for a value it does not know — so the result was right by accident in a table where every neighbour is right by design. Lint cannot see this: `InlinedApi` fires on the constant reference, not on the runtime guard, which is why the correctly-guarded `truehd` and `ac4` entries are baselined too. All three baseline entries stay. This is about the code being right, not about silencing lint. The second gap is structural. `checkReleaseBuilds` makes `lintVitalRelease` part of `assembleRelease`, which runs only from release.yml on a v* tag. The release variant was therefore gated by a check no pull request ran, and its first execution would have been mid-release. Adding both vital tasks to the lint job moves that discovery to the PR, and covers the release-only source sets `lintDebug` never analyses. Verified: `:androidApp:lintVitalRelease` and `:androidTvApp:lintVitalRelease` both pass, `:android-shared:lintDebug` reports no new issues, and `:android-shared:testDebugUnitTest` is 1101 tests, 0 failures. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
@coderabbitai review |
✅ Action performedReview finished.
|
Follow-up to #195. Two startup crashes reached users this week because nothing
in this project checked API levels — lint had never been configured, had no
baseline, and did not run in CI.
Three API-guard bugs, all in
AudioCapabilityManagerAudioDeviceInfo.getAddress()NoSuchMethodErroron API 24–27 whenever diagnostics were collectedAudioTrack.isDirectPlaybackSupported()runCatchingswallowed the resulting error on API 24–28, so "no passthrough" was an accident rather than a decisionAudioFormat.ENCODING_E_AC3_JOCminSdkThe first is the same shape as #195 and is a real behaviour fix.
The second is not a behaviour change, and the table above previously implied
it was. Pre-Q devices reported no passthrough before this change and still do —
the platform offers no way to ask before API 29, so
falseis the only honestanswer. What changes is that the answer is now an explicit branch instead of a
swallowed
NoSuchMethodError, which means lint can see it and a reader can tellit was intended. Worth having, but nobody's audio improves.
The third was found by this PR's own lint run.
EncodingSupportcarries aminSdkfield so a constant is only queried where it exists —dts_hd,truehdandac4all use it.eac3_jocneeds API 28 exactly asac4doesand was the one entry left on the default of
1. It cannot crash (theconstant inlines, and the platform returns false for a value it does not
know), so the result was right by accident in a table where every neighbour
is right by design.
Note that this does not remove a baseline entry:
InlinedApifires on theconstant reference, not the runtime guard, which is why correctly-guarded
truehdandac4are baselined too. All three entries stay. The fix is aboutthe code being right, not about silencing lint.
The gate
NewApiandInlinedApiare fatal onandroid-shared,androidAppandandroidTvApp.checkDependencies = trueon both apps. This is the structural part:android-sharedis where both crashes lived, and app-level lint does notanalyse library sources without it — so the module holding the risk was the
one nothing examined.
lint-baseline.xmlholds today's findings so only newviolations fail. They are overwhelmingly desugared
java.*calls (corelibrary desugaring is enabled; lint does not model it) and deliberate media3
@UnstableApiusage.Lintjob inandroid-build.yml, mirroring the unit-test job, uploadingreports on failure.
lintVitalReleasefor both apps as well.checkReleaseBuildsmakes that part of
assembleRelease, which runs only fromrelease.ymlon av*tag — so the release variant was gated by a check no pull requestexercised, and its first run would have been mid-release. It also covers the
release-only source sets
lintDebugnever analyses.Verification
The two fixes were made before generating the baselines, so neither is
baselined — grep confirms no
Spatializer,getAddressorisDirectPlaybackSupportedentries in any of the three files. Baselining firstwould have permanently accepted both.
Reintroducing the unguarded
getAddress()call fails the build withCall requires API level 28 (current min is 24); with the fix in place lintreports
no new issues (242 errors … filtered by baseline).Note for future contributors
If the lint job fails, fix the call. Regenerating a baseline to make it pass is
how this protection gets quietly dismantled.
Summary by CodeRabbit
Bug Fixes
Quality Improvements