Repository navigation
Brighten the screen while a QR code is displayed - #387
Open
zachisfine wants to merge 1 commit into
Open
zachisfine wants to merge 1 commit into
zachisfine wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A pending attestation callback can re-enable full brightness after onPause() resets it, so the override needs a resumed-state check in addition to the QR-stage check.
1 open issue
What changed in this PR
This PR improves QR-code scanning in both exchange directions by temporarily increasing the activity window’s brightness without changing the system setting.
Changes:
- Adds a window-scoped brightness override for Auditor and Auditee QR-code stages.
- Updates brightness when QR codes appear, after a successful scan, and during activity resume and pause.
| File | Description |
|---|---|
app/src/main/java/app/attestation/auditor/AttestationActivity.java |
Adds brightness helpers and connects them to QR-display transitions and activity lifecycle callbacks. |
Review effort: Balanced
The QR code is hard to scan at a low screen brightness, especially on older devices. Brighten the window while the code is on screen and restore the user's own brightness afterwards. The brightness follows the stage rather than a separate flag: it is applied in onResume so it covers entering the activity and returning from the scanner, and both QR-producing paths apply it directly because they run after onResume. onPause restores it unconditionally so the camera activity or another app never inherits the override. Only a resumed window may be brightened. The attestation is generated on a background executor and shown from a posted UI callback, which can land after onPause: onPause restores the user's brightness, and the callback would then re-apply the override to a window that is no longer resumed. So updateQrCodeBrightness() also requires an active onResume, tracked by a resumed flag cleared before onPause's unconditional reset. Fixes GrapheneOS#290
zachisfine
force-pushed
the
increase-qr-code-brightness
branch
from
November 6, 2026 23:17
cea47fa to
b27aaa2
Compare
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.

Problem
The QR code is hard to scan, especially on older devices such as the Pixel 6 and 7 (#290). The reporter's workaround is to raise the screen brightness manually before showing the code and lower it again afterwards.
This matters for both directions of the exchange, since either device can be showing the code:
Stage.Auditor— the Auditor shows its challenge QR for the Auditee to scan (runAuditor()).Stage.AuditeeResults— the Auditee shows its attestation QR for the Auditor to scan (auditeeShowAttestation()).Fix
Brighten the screen for as long as a QR code is being displayed, then restore the user's own brightness.
setQrCodeBrightness(true)setsWindowManager.LayoutParams.screenBrightnesstoBRIGHTNESS_OVERRIDE_FULLfor the current window only. This overrides the system brightness while the window is visible without persisting anything or changing the global setting, and it needs no permission.setQrCodeBrightness(false)sets it back toBRIGHTNESS_OVERRIDE_NONE(-1), which returns control to the system setting.The state is derived from
stagerather than tracked separately, so it cannot get out of sync:onResume()callsupdateQrCodeBrightness(), which covers entering the activity and returning to it from the scanner.stageis restored fromsavedInstanceState, so a configuration change or process death re-applies the right brightness.onResume()has already fired:runAuditor()synchronously from the click handler, andauditeeShowAttestation()from the async attestation-generation callback.Stage.Resultafter a successful scan calls it too, so the screen dims as soon as the code is gone.onPause()restores the brightness unconditionally, so the camera activity, another app, or the lock screen never inherits the override.Testing
Compiles and
./gradlew buildpasses. There is no automated test for this: the repo has no instrumentation tests, and window brightness is not observable from a unit test.