test(scanner): verifiedbootstate coverage for DeviceAuditor (#86)#219
Merged
Conversation
Backfill the unit test required by #86 covering all four Android Verified Boot states (green/yellow/orange/red). Reflection into android.os.SystemProperties is unreachable on the JVM test runtime, so the boot-state decision logic is extracted into a pure, internal interpretVerifiedBootState() (matching the existing internal test-seam convention used by AppScanner / DeviceAdminGrantEmitter) and verified directly. Behavior note: an unrecognised non-blank verifiedbootstate value now falls through to the Build.BOOTLOADER heuristic instead of hard-returning false. This is a deliberate improvement — a device reporting an unexpected state no longer suppresses the secondary unlock check; the heuristic still defaults to locked when it finds no unlock marker. Closes #86 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backfills the unit test required by the #86 acceptance criteria, covering all four Android Verified Boot states (
green/yellow/orange/red).The authoritative
ro.boot.verifiedbootstatepath already landed inDeviceAuditor(reflection intoSystemProperties,orange⇒ unlocked). Reflection intoandroid.os.SystemPropertiesis unreachable on the JVM test runtime, so the boot-state decision logic is extracted into a pure,internalinterpretVerifiedBootState()— matching the existing internal test-seam convention used byAppScanner/DeviceAdminGrantEmitter(the repo usesinternalseams, not@VisibleForTesting) — and verified directly.Behavior note (flagged by both reviewers)
An unrecognised non-blank
verifiedbootstatevalue now returnsnull→ falls through to theBuild.BOOTLOADERheuristic, where the old code hard-returnedfalse. This is a deliberate improvement: a device reporting an unexpected/future state no longer suppresses the secondary unlock check. The heuristic still defaults tolockedwhen it finds no unlock marker, so the locked-case outcome is unchanged.Test plan
./gradlew :app:testDebugUnitTest --tests "com.androdr.scanner.DeviceAuditorBootStateTest"— 8 cases pass (4 states + case-insensitivity + null/blank/unrecognised fall-through)./gradlew detekt— cleanCloses #86
🤖 Generated with Claude Code