Repository navigation
Add QR-code pairing - #22
Merged
Merged
Conversation
Pure, Android-framework-free parser for the dashboard's QR/link pairing format, plus the client policy on top of it: a valid https link needs confirmation before anything happens, an http link is rejected to keep this app's HTTPS-only design, and a bad version or otherwise malformed link gets a clear error. Never pairs by itself.
Both are FOSS (Apache-2.0) with no Play Services in their dependency trees: androidx.camera:* 1.6.2 for the camera preview/frame analysis, com.google.zxing:core 3.5.4 (zero runtime deps) for decoding. Also adds androidx.lifecycle:lifecycle-runtime-compose, needed for the non-deprecated LocalLifecycleOwner this build's warnings-as-errors settings require.
Adds an in-app scanner (CameraX + ZXing, fully offline) next to the existing manual server+code entry, and registers this app as the handler for daycompass://pair links so the system camera or other apps can hand off to it too. Both paths land on a mandatory confirmation screen showing the server's host before pairing - never automatically. Camera permission is asked for only when the person taps "Scan QR code", and a denial falls back to manual entry. Adds the CAMERA permission and a new daycompass://pair intent-filter to the manifest; MainActivity now runs singleTask and scrubs the link out of the activity's Intent right after reading it, since the link is a secret until redeemed.
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
daycompass://pairlinks (matching the server's new QR-pairing format, backendDaycompass/Daycompass#65, not yet merged to backendmain), so the system camera or another app can hand off here too.httpserver is refused with the existing "Daycompass only connects over HTTPS" message, rather than the warn-and-allow behavior the backend spec permits for other platforms' LAN installs. Confirmed with the maintainer before implementing.DeviceApiClient.pair.Permissions/manifest surface added (flagging per repo convention): new
android.permission.CAMERA(+ optionalandroid.hardware.camera.anyfeature, so camera-less devices still install and can pair manually) and a newdaycompass://pairintent-filter onMainActivity, which now runssingleTask.New dependencies:
androidx.camera:*1.6.2 andcom.google.zxing:core3.5.4 (zero runtime deps), both Apache-2.0 with no Play Services anywhere in their dependency trees; alsoandroidx.lifecycle:lifecycle-runtime-composefor the non-deprecatedLocalLifecycleOwner.gradle/verification-metadata.xmlregenerated and reviewed.Closes #21
Test plan
./gradlew ktlintCheck detekt lint testDebugUnitTest assembleDebugall pass (101 unit tests, 0 failures; 16 new inPairingLinkTestcovering link parsing, percent-decoding incl. IPv6+port, and the "confirmation is mandatory" invariant)gitleaks detect— no leaksadb shell am start -a android.intent.action.VIEW -d "daycompass://pair?v=1&server=https%3A%2F%2Fexample.org&code=<code>" org.daycompass.androidlands on the confirm screen showingexample.org, pairs only after confirming