Skip to content

chore: gate API-level mistakes with lint in CI - #196

Merged
RXWatcher merged 2 commits into
Silo-Server:mainfrom
RXWatcher:chore/lint-gate
Aug 7, 2026
Merged

RXWatcher merged 2 commits into
Silo-Server:mainfrom
RXWatcher:chore/lint-gate

Conversation

@RXWatcher

@RXWatcher RXWatcher commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

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 AudioCapabilityManager

Call Level Effect
AudioDeviceInfo.getAddress() API 28, no guard at all NoSuchMethodError on API 24–27 whenever diagnostics were collected
AudioTrack.isDirectPlaybackSupported() API 29, only gated for TIRAMISU runCatching swallowed the resulting error on API 24–28, so "no passthrough" was an accident rather than a decision
AudioFormat.ENCODING_E_AC3_JOC API 28, no minSdk Queried on API 24–27 for an encoding that does not exist there

The 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 false is the only honest
answer. 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 tell
it was intended. Worth having, but nobody's audio improves.

The third was found by this PR's own lint run. EncodingSupport carries a
minSdk field so a constant is only queried where it exists — 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. It cannot crash (the
constant 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: InlinedApi fires on the
constant reference, not the runtime guard, which is why correctly-guarded
truehd and ac4 are baselined too. All three entries stay. The fix is about
the code being right, not about silencing lint.

The gate

  • NewApi and InlinedApi are fatal on android-shared, androidApp and
    androidTvApp.
  • checkDependencies = true on both apps. This is the structural part:
    android-shared is where both crashes lived, and app-level lint does not
    analyse library sources without it — so the module holding the risk was the
    one nothing examined.
  • Per-module lint-baseline.xml holds today's findings so only new
    violations fail. They are overwhelmingly desugared java.* calls (core
    library desugaring is enabled; lint does not model it) and deliberate media3
    @UnstableApi usage.
  • A Lint job in android-build.yml, mirroring the unit-test job, uploading
    reports on failure.
  • The job runs lintVitalRelease for both apps as well. checkReleaseBuilds
    makes that part of assembleRelease, which runs only from release.yml on a
    v* tag — so the release variant was gated by a check no pull request
    exercised, and its first run would have been mid-release. It also covers the
    release-only source sets lintDebug never analyses.

Verification

The two fixes were made before generating the baselines, so neither is
baselined — grep confirms no Spatializer, getAddress or
isDirectPlaybackSupported entries in any of the three files. Baselining first
would have permanently accepted both.

Reintroducing the unguarded getAddress() call fails the build with
Call requires API level 28 (current min is 24); with the fix in place lint
reports 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

    • Improved compatibility with older Android versions by preventing unsupported audio APIs from being called.
    • Refined audio capability detection for device routes and newer audio formats.
  • Quality Improvements

    • Added Android lint checks across mobile and TV builds.
    • Release builds now enforce critical API compatibility checks and fail when lint errors are detected.
    • Lint reports are available for troubleshooting when checks fail.

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]>
@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 25adcae2-0f9f-45fb-a659-32f0510b5577

📥 Commits

Reviewing files that changed from the base of the PR and between 25b1d6b and 52cbf02.

📒 Files selected for processing (8)
  • .github/workflows/android-build.yml
  • android-shared/build.gradle.kts
  • android-shared/lint-baseline.xml
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/AudioCapabilityManager.kt
  • androidApp/build.gradle.kts
  • androidApp/lint-baseline.xml
  • androidTvApp/build.gradle.kts
  • androidTvApp/lint-baseline.xml

📝 Walkthrough

Walkthrough

The 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.

Changes

Android quality and compatibility

Layer / File(s) Summary
Audio API version guards
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/AudioCapabilityManager.kt
Audio capability checks now guard AudioDeviceInfo.address, AudioTrack.isDirectPlaybackSupported, and E-AC3 JOC support by Android API level.
Lint configuration and CI validation
android-shared/build.gradle.kts, androidApp/build.gradle.kts, androidTvApp/build.gradle.kts, .github/workflows/android-build.yml
The Android modules use lint baselines, fail on errors, and treat NewApi and InlinedApi as fatal. CI runs debug lint and release lintVital checks and uploads reports on failure.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: quick104, zzebrahz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: using Android lint in CI to block API-level mistakes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…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]>
@RXWatcher

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@RXWatcher
RXWatcher merged commit c9de96b into Silo-Server:main Aug 7, 2026
3 checks passed
This was referenced Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant