Skip to content

test(scanner): verifiedbootstate coverage for DeviceAuditor (#86)#219

Merged
yasirhamza merged 1 commit into
mainfrom
fix/86-verifiedbootstate-test
Jun 13, 2026
Merged

test(scanner): verifiedbootstate coverage for DeviceAuditor (#86)#219
yasirhamza merged 1 commit into
mainfrom
fix/86-verifiedbootstate-test

Conversation

@yasirhamza

Copy link
Copy Markdown
Owner

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.verifiedbootstate path already landed in DeviceAuditor (reflection into SystemProperties, orange ⇒ unlocked). 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 (the repo uses internal seams, not @VisibleForTesting) — and verified directly.

Behavior note (flagged by both reviewers)

An unrecognised non-blank verifiedbootstate value now returns null → falls through to the Build.BOOTLOADER heuristic, where the old code hard-returned false. This is a deliberate improvement: a device reporting an unexpected/future state no longer suppresses the secondary unlock check. The heuristic still defaults to locked when 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 — clean
  • Reviewed by two independent agents (correctness + style) — both APPROVE

Closes #86

🤖 Generated with Claude Code

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>
@yasirhamza yasirhamza merged commit 5f29de3 into main Jun 13, 2026
2 of 9 checks passed
@yasirhamza yasirhamza deleted the fix/86-verifiedbootstate-test branch June 13, 2026 15:55
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.

DeviceAuditor: replace bootloader string heuristic with ro.boot.verifiedbootstate

1 participant