Repository navigation
fix: drop nfc from scanner pill while polling is off - #2037
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The PR appears safe to merge; no blocking issues remain. SummaryThe scanner hides NFC from its status pill when the adapter is off or a camera is expected to stop polling.
Reviews (2) · Last reviewed commit: "fix: do not cache nfc property read when..." · Reviewed by Greptile |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Drops NFC from the scanner pill while a camera stop (ro.camera.notify_nfc) or the adapter being off means the phone is not polling, and makes rememberNfcState follow ACTION_ADAPTER_STATE_CHANGED instead of only resume. Reviewed ca7133c, full tier, statically: per this repo's track rules the branch was not built here, so this rests on the code and CI.
What I checked, and 5 candidates I ruled out
Read in full: NfcPolling.kt, NfcEffects.kt (all of rememberNfcState, rememberNfcStoppedByCamera, rememberCameraNfcStopTracker, NfcReaderEffect), NearbyScanSources.kt, both NfcDevOverride.kt copies, the DevToolsProvider.kt change
Call sites traced: rememberNfcState (scanner sources and rememberCanEmitNfc through offerPaymentNearby), isNfcActive into scannerStatusText
CI: build-and-test, build, lint, detekt, compose-ui green at this head; e2e shards still running
Ruled out
- Exported receiver can be spoofed:
ACTION_ADAPTER_STATE_CHANGEDis a protected broadcast, andonReceiveonly re-readscontext.nfcState(), so even a forged intent changes nothing. - Camera already open when the tracker registers is missed:
registerAvailabilityCallbackreports the current state of every camera on registration, so the scanner's own open camera lands in the set. - Release build referencing
NfcDevOverride.set: only the debugDevToolsProvidercalls it, and the release copy exposes the two flows the main source set reads. - Tracker state surviving a disable:
onDisposeclears it wheneverenabledflips, and the key no longer carries the NFC state, so an NFC off/on keeps the stop as the body intends. getpropon the main thread: it runs inproduceStateunderDispatchers.IO, with the cached value used for the first frame.
Merge confidence: 4/5, the tracker is unit tested but the effect key that keeps the stop across an NFC toggle has no test (the body says so), and the branch was not built here.
Reviewer model: claude-opus-5-5
Reasoning effort: Unknown (the session does not report it)
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR diff against its merge base, at ca7133c86.
No new actionable code findings.
No new actionable code findings were identified in this pass across the ro.camera.notify_nfc property reader and CameraNfcStopTracker, the Compose NFC state/camera-availability effects (NfcEffects.kt) and their scanner/Receive callers (NearbyScanSources.kt, QrScanningScreen.kt, SendRecipientScreen.kt, UsdtSendContent.kt, NearbyEffects.kt), the debug-only DevToolsProvider/NfcDevOverride seam and its release no-op counterpart, or the unit tests and changelog fragment.
Existing external review concern: Greptile's unresolved review thread on NfcPolling.kt:54 remains open at ca7133c86. Verified against pinned source: readSystemProperty waits for getprop exit and merges stderr into stdout, but does not verify process.exitValue() == 0; if getprop terminates with a non-zero exit status, the read is treated as successful, parsed as false, and cached for the process lifetime instead of taking the documented retry path.
Validation and limitations: Local Gradle execution could not run in this environment because the Android SDK (ANDROID_HOME) is not installed. At ca7133c86, CI passed build-and-test, compose-ui / ui-tests, lint, and detekt, while the e2e-tests-local shards (run 45818511444) were still in progress. Unit tests cover cameraStopsNfcPolling, CameraNfcStopTracker, and NearbyScanSources/scannerStatusText, while the Compose effect wiring in NfcEffects.kt (ACTION_ADAPTER_STATE_CHANGED receiver and keying rememberCameraNfcStopTracker solely on cameraStopsPolling) is not covered by automated unit tests and relies on device/emulator verification.
iOS comparison: Compared against synonymdev/bitkit-ios Bitkit/Components/Scanner.swift at edce3cdee. iOS starts CoreNFC reads explicitly via the system reader sheet rather than passively polling alongside the camera and has no user NFC adapter toggle or ro.camera.notify_nfc camera-stop behavior, so this change is Android-specific while keeping the shared four-state scanner status pill vocabulary.
Recommended before device testing
- Address or resolve Greptile's open thread on
NfcPolling.kt:54(checkprocess.exitValue() == 0so non-zerogetpropexits retry rather than cachingfalse). - Wait for the in-progress
e2e-tests-localCI run (run 45818511444) to complete. - Emulator setup note:
DevToolsProvider'soverrideNfcoverwrites both fields on each call (nullclears), so ending the camera stop on an emulator without NFC hardware requires passing{"adapterState":"ON","cameraStopsPolling":false}rather than{"cameraStopsPolling":false}alone.
Suggested additional test cases
- Android (Pixel 11 /
ro.camera.notify_nfc=1, camera permission granted, NFC and Bluetooth on): open Send -> USDT to display the embeddedUsdtScanner(UsdtSendContent.kt, which passesreadsNearby = true) and verify its status pill omits NFC (Scanning QR & Bluetooth) while keeping Bluetooth.
Device testing: not performed in this review. The author reports emulator and physical Pixel 11 / Xiaomi verification at ca7133c86 in the PR description.
Reviewer model: gemini-4-neon
Reasoning effort: high
There was a problem hiding this comment.
Verdict:
Findings: None new. The existing failed-property-read retry thread remains open.
QA for ca7133c:
Build the dev app and release Kotlin sources ✅ Both build targets completed.
Ran assembleDevDebug and compileDevReleaseKotlin at the reviewed head.
NFC polling tracker and scanner status tests ✅ The focused tests passed.
Ran testDevDebugUnitTest filtered to NfcPollingTest, CameraNfcStopTrackerTest and NearbyScanSourcesTest; checked the generated XML reports for execution, failures and skips.
Check: shared scanner and Receive state wiring ✅ Verified in source, including the embedded USDT scanner.
Traced the main and Send scanners, UsdtSendContent, adapter-driven reader/emitter effects and the camera tracker lifetime. git diff --check passed.
USDT scanner reflects the camera polling stop ⏭️ The emulator setup could not reach the scanner.
Tried fresh Android 15/API 35 and Android 9/API 28 emulators. The first did not finish startup. The fallback produced System UI/Google service failures before Bitkit launched; after installation succeeded, Bitkit remained on its splash screen and showed a startup ANR. Android CLI could not retrieve the app UI; the fallback dump confirmed the startup ANR dialog. The case was not driven, and these observations do not establish a PR defect.
Physical NFC, adapter-toggle, Bluetooth and Receive cases 1–6, including 6a/6b, were not repeated; relied on the same-head phone and emulator report. No scanner or Receive flow was independently driven in this session. The additional USDT case came from the QA review.
Coverage: the full ten-file PR diff, 747926f…ca7133c, and its scanner/Receive callers. Receiver and Compose effect wiring was checked in source; device behavior relies on the linked reports.
Twin: none. Compared NfcReader.swift in synonymdev/bitkit-ios#1302; it uses explicit CoreNFC read sessions.
Gemini's run records expose its model ID but no reasoning-effort setting.
Reviewed by gpt-6.1-sol-high
Pull request was converted to draft
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Verdict:
Findings: No completed review. The draft rule in AGENTS.md at the base requires AI reviewers to skip drafts and wait until ready for review.
QA for e9bad3c:
Build the dev app at the reviewed head ⏭️ Not started while the PR is a draft.
No build was run.
Reject failed property reads and preserve successful reads ⏭️ Not started while the PR is a draft.
The two new command exit-status tests were not run.
USDT scanner reflects the camera polling stop ⏭️ Not started while the PR is a draft.
The additional case from the QA review remains unrun; no device case was driven.
The prior review at ca7133c and phone report for manual cases 1–6 were read. They are historical evidence, not verification of this head.
Coverage: preliminary inspection of the two-file delta ca7133c…e9bad3c and its property-read caller only; the review stopped after confirming draft status. The existing failed-read thread was not resolved.
Twin: none; this delta changes Android's getprop handling only.
Reviewed by gpt-6.1-sol-high
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: changes since ca7133c86, including affected code paths and prior findings, at e9bad3caa. Baseline: prior QA review (unchanged Compose NFC/camera effects, scanner status pill wiring, and debug override seam inherited).
No new actionable code findings.
No new actionable code findings in the follow-up.
Prior concern verified fixed: Greptile's review thread on NfcPolling.kt:54 is marked resolved and verified fixed in source at e9bad3caa. readCommandOutput (app/src/main/java/to/bitkit/nfc/NfcPolling.kt) now enforces process.exitValue() == 0 after the timeout check, so non-zero getprop exits throw IllegalStateException into deviceCameraStopsNfcPolling()'s runCatching, log a warning, return false without updating cachedCameraStopsNfcPolling, and retry on the next scanner visit. Normal exit-0 reads (including unset properties) continue to cache as before, and NfcPollingTest.kt adds unit tests covering both non-zero and zero exit codes.
Validation and limitations: Local :app:detekt passed at e9bad3caa; local Gradle unit test execution could not run because the Android SDK is not installed in this environment. At e9bad3caa, CI passed build-and-test (including testDevDebugUnitTest), compose-ui / ui-tests, lint, and detekt, while two e2e-tests-local shards (send and onchain_boost_receive_widgets) were still in progress. NfcPollingTest.kt exercises readCommandOutput directly via sh; deviceCameraStopsNfcPolling()'s retry-after-failure caching path itself is verified by source inspection.
iOS comparison: This follow-up changes Android getprop process exit handling only, which has no iOS equivalent (checked synonymdev/bitkit-ios master at 3623e527d, where NFC uses explicit CoreNFC reader sessions).
Recommended before device testing
- Wait for the in-progress
e2e-tests-localCI shards (send and onchain_boost_receive_widgets) to complete.
Suggested additional test cases
- Android (Pixel 11 /
ro.camera.notify_nfc=1, camera permission granted, NFC and Bluetooth on): open Send -> USDT to display the embeddedUsdtScanner(UsdtSendContent.kt, which passesreadsNearby = true) and verify its status pill omits NFC (Scanning QR & Bluetooth) while keeping Bluetooth. (Remains unrun after emulator startup issues in prior bot QA run at ca7133c.)
Device testing: not performed in this review. The author's emulator and physical Pixel 11 / Xiaomi manual test results in the PR description were recorded at ca7133c86; the intervening delta at e9bad3caa only rejects non-zero getprop exit codes and does not change normal exit-0 scanner or Receive behavior, though no device run has been recorded on e9bad3caa.
Reviewer model: gemini-4-neon
Reasoning effort: high
piotr-iohk
left a comment
There was a problem hiding this comment.
Device QA on e9bad3ca.
- PASS · Android emulator control. Opened the embedded Send USDT scanner from the USDT wallet on Android 13. The camera was active and Bluetooth access was enabled. With the PR’s debug adapter set to ON, the pill changed from Scanning QR, NFC & Bluetooth to Scanning QR & Bluetooth when the simulated camera polling stop was enabled. Clearing the stop restored NFC to the pill.
- BLOCKED · Pixel 11 hardware check. The available emulator has no NFC hardware. No physical Pixel 11 was connected to exercise the real camera-triggered polling stop.
The scanner indicator behavior passed under the debug override. The physical check remains open.
piotr-iohk
left a comment
There was a problem hiding this comment.
PASS · Physical camera-stop follow-up at e9bad3ca. Tested on a Samsung Galaxy S22 (SM-S901B, Android 16), where ro.camera.notify_nfc=1.
- Opened the embedded Send USDT scanner with NFC and Bluetooth enabled. The active camera was visible in Android’s service dump, and the scanner showed Scanning QR & Bluetooth.
- The app logged the native camera-stop property as true. Samsung’s NFC service independently logged
active polling is forced to disable now. The main scanner showed the same pill when opened. - The hardware run used the regtest APK with the exact PR source and the native Samsung camera/NFC behavior. It used no debug override or NFC tag exchange.
This covers the camera-stop case that was open after the emulator check. All required checks passed.
Fixes #2000
The payment scanners' status pill no longer lists NFC while the phone is not polling for NFC: when NFC is switched off while the scanner is open, and on phones that stop NFC polling while a camera is open (Pixel 11 on Android 17).
Description
CameraServiceProxy. When the read-only propertyro.camera.notify_nfcis above 0, it callsNfcAdapter.setReaderModePollingEnabled(false)when the set of active cameras goes from empty to non-empty, and turns polling back on when it empties. It keys on camera sessions going active or idle, so a capture-session restart sends the stop again. That call sendsDISABLE_POLLING_FLAGS = 0x1000, theflags 4096/tech_mask = 00seen in the issue. The scanner reads that property withgetprop(a successful read is cached; a failed or timed-out read counts as unset and is retried the next time the scanner opens; a value already read is used without waiting for a new read) and watches camera availability (CameraManager.AvailabilityCallback).CameraNfcStopTrackertreats polling as stopped while any present camera is unavailable, whatever NFC toggles happened meanwhile. This errs toward hiding NFC: an NFC toggle can drop the system's stop without apps seeing it, and a session restart can bring it back without any availability callback. The camera watcher runs whenever the property is set, independent of NFC, so NFC turned on with a camera already open stays hidden. When the scanner opens, the pill lists NFC until its camera opens. That is accurate: CameraServiceProxy only stops polling once a camera session is active (CAMERA_STATE_ACTIVE), and the availability callback fires when the camera opens, slightly earlier. Camera IDs missing fromcameraIdList(a removed camera) are ignored, and the set is reconciled against that list on resume; ifcameraIdListcannot be read, the camera counts as present and the reconcile is skipped. While the tracker says polling is off,NearbyScanSources.isNfcStoppedByCamerais true and NFC is dropped from the pill.rememberNfcStateused to refresh only on resume, and pulling down quick settings does not pause the activity. It now also listens forNfcAdapter.ACTION_ADAPTER_STATE_CHANGED. Because NFC state now follows the adapter, the reader effect is also disabled and enabled again with it. The receiver is exported because the NFC service, not the system server, sends that protected broadcast.rememberNfcStateis shared, so Receive's NFC emitter (rememberCanEmitNfc) now also stops and starts with the adapter instead of waiting for a resume.NfcDevOverridelives in thedebugsource set, with a no-op copy inrelease. It is set over adb through a newDevToolsProvidermethodoverrideNfc, so an emulator, which has no NFC, can show the pill states. It runs outside the LDK queue so it does not wait behind node work.What is and is not detectable
NfcAdapteron API 34, 35, 36 and 37.0 (android.jardiff andapi-versions.xml). Reader mode gets no callback or exception when polling stops.enableReaderModeagain does not bring polling back. InNfcService.setReaderMode(packages/modules/Nfc, main), an app's request is dropped while a polling-disable request is registered: it logssetReaderMode: active polling is forced to disable nowand returns. So this PR reports the stop instead of fighting it.ro.camera.notify_nfchas the SELinux contextcamera_config_prop. system/sepolicy grantsget_prop(coredomain, camera_config_prop), anduntrusted_appis incoredomain.AvailabilityCallback) is broader than CameraServiceProxy's "camera active": it re-enables polling when a camera goes idle. An idle camera held open by another app therefore hides NFC from the pill although polling runs. The scanner's own camera is active while it shows a preview.NfcService.disableInternalclears the polling-disable list, so in that window a tap may still read until the camera session restarts and the stop is sent again; apps cannot see which state applies.getpropis read with a 2 s timeout; on a timeout or failure the property counts as unset for that scanner visit and is read again on the next one.Out of Scope
ui/screens/scanner: a way to read NFC on affected phones without leaving the scanner (camera-unbinding control or NFC-only state). The issue's decision was to only make the pill truthful.mReaderModeParams = null). Reader mode then stays off until the scanner resumes. This is unchanged here.Design
N/A — no design available. The pill reuses the existing status strings.
Preview
Emulator, debug build at 424f74a. Left to right: open (reading) → camera stop → stop ended → adapter off → adapter on → camera stop again.
nfc-pill.mp4
QA Notes
Setup
just build(devDebug) from this branch,adb install -rover an existingto.bitkit.devwallet.adb shell getprop ro.camera.notify_nfcprints1. Xiaomi 22031116BG (Android 13) or another phone where it prints nothing.adb root && adb shell setprop ro.camera.notify_nfc 1 && adb unroot, then grant camera permission and open the scanner. Fake the adapter state withadb shell content call --uri content://to.bitkit.dev.devtools --method overrideNfc --arg "'{\"adapterState\":\"ON\"}'"."OFF"fakes the adapter off,"cameraStopsPolling":falseends the camera stop, and'{}'clears the overrides.Journeys
N/A — not drivable; see Manual Tests.
Manual Tests
Read camera stops NFC polling 'true'andDetected NFC polling stopped by an open camera— needs NFC hardware.Automated Checks
NfcPollingTest.kt—ro.camera.notify_nfcparsed as CameraServiceProxy does ("1"stops polling; empty,0andtruedo not);CameraNfcStopTrackerstops while any present camera is unavailable, handles a camera reported unavailable twice and an available event for an unseen camera, ignores or drops cameras missing from the camera list, keeps the stop across an NFC off/on toggle with a camera open, and counts a camera as present when the camera list cannot be readNearbyScanSourcesTest.kt— NFC drops from the status during a camera stop or with the adapter off, Bluetooth stays, NFC returns when the stop endsEvidence
Gate_Root_API35(API 35, google_apis, rooted,-read-only), devDebug at 424f74a, withro.camera.notify_nfc=1set bysetprop:Read camera stops NFC polling 'true'from its own process.Detected NFC polling stopped by an open camera.overrideNfc.android layout:SCANNING QR, NFC & BLUETOOTHSCANNING QR & BLUETOOTHSCANNING QR, NFC & BLUETOOTHSCANNING QR & BLUETOOTHplus the Enable NFC buttonSCANNING QR, NFC & BLUETOOTHSCANNING QR & BLUETOOTHrun-as to.bitkit.dev):getprop ro.camera.notify_nfcis empty, so the camera-stop path stays off there.testDevDebugUnitTest: 6652 tests, 0 failures.detektandlintDevDebug: pass.assembleDevDebugandcompileDevReleaseKotlin: pass.assembleDevDebuganddetektpass.getproptimeout):testDevDebugUnitTest: 6658 tests, 0 failures.compileDevReleaseKotlin,detektandlintDevDebug: pass.onNfcOffand the camera-list checks reverted, 3 of the 6CameraNfcStopTrackertests fail.getpropcaches only a successful read):testDevDebugUnitTest: 6658 tests, 0 failures.compileDevReleaseKotlin,detektandlintDevDebug: pass.CameraNfcStopTrackertests fail.testDevDebugUnitTest: 6661 tests, 0 failures (9 inCameraNfcStopTracker).compileDevReleaseKotlin,detektandlintDevDebug: pass.CameraNfcStopTracker, clearing the camera set on NFC off and treating an unreadable camera list as empty makes the two new tests for those cases fail. This checks the tracker, not the fix itself: the fix is the effect key inNfcEffects.kt(rememberCameraNfcStopTracker(enabled = cameraStopsPolling), which no longer includes the NFC state). Putting the NFC state back into that key would clear the tracker on NFC off, and no unit test would catch it. Manual test 4 covers it on the Pixel.Gate_Root_API35, API 35 google_apis, read-only,ro.camera.notify_nfc=1set bysetprop, NFC adapter faked withoverrideNfc, Bluetooth on):SCANNING QR & BLUETOOTH. The log showsRead camera stops NFC polling 'true'andDetected NFC polling stopped by an open camera.SCANNING QR & BLUETOOTHplus Enable NFC. NFC back on with the camera open: stillSCANNING QR & BLUETOOTH, no Enable NFC.SCANNING QR, NFC & BLUETOOTHfor about 0.9 s over the black area before the preview appears, thenSCANNING QR & BLUETOOTH. The polling stop only starts once the camera session is active, so this is expected.cameraStopsPolling:false):SCANNING QR, NFC & BLUETOOTH.& BLUETOOTHstays in every pill. With Bluetooth off, the pill readsSCANNING QRand NFC stays hidden with the camera open.3-reopen.mp4
adb install -ron both phones; Pixel 11 Android 17 withro.camera.notify_nfc=1, Xiaomi 22031116BG Android 13 with it empty; tag holds a 12 000 satlightning:invoice; no payment confirmed, balances unchanged):SCANNING QR & BLUETOOTHin every sample, NFC never listed; tag held 5 s on Send: no read.Detected NFC polling stopped by an open cameraonce per openDetectedlineESCANEANDO QR, NFC E BLUETOOTHwith the camera open; tag read from both scanners (Confirm 12 000)ESCANEANDO QR E BLUETOOTH+ Enable NFC (2.9 s); on: NFC back (3.0 s); tag read afterwardsNo NFC or camera warnings or errors, no crashes. Outside the scanner, the Xiaomi showed the system app chooser twice for an NFC tap on its home screen; that is system dispatch, not this change.
c1-px.mp4
Gaps
c1-px.mp4in the run folder was not examined frame by frame).Models used
claude-opus-5-5(reasoning: Not exposed)claude-opus-5-5(reasoning: Not exposed)claude-opus-5-5(reasoning: Unknown)Metadata note: the session reports the model ID; it does not expose a reasoning-effort setting. The review model was reported by the coordinating session; its effort was not.
🤖 Generated with Claude Code