Add DebugNfcTagEmulator in DevPlaygound - #7282
Open
TimoPtr wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a debug-only NFC tag emulator inside the Dev Playground, allowing developers to emulate a writable NFC Forum Type 4 tag via Host Card Emulation (HCE) and inspect/modify its NDEF payload for debugging tag handling.
Changes:
- Introduces a debug
HostApduService+ in-memory NDEF file state to emulate a writable Type 4 tag. - Adds a Dev Playground UI screen to control the emulated tag ID and view raw/decoded NDEF content.
- Refactors NFC tag writing helpers by extracting
NFCUtil.createTagUrl/createTagMessageand adds Robolectric coverage for the emulator APDU behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| app/src/testDebug/kotlin/io/homeassistant/companion/android/developer/nfc/DebugNfcTagEmulatorServiceTest.kt | Adds Robolectric tests validating APDU select/read/write flows and summary updates. |
| app/src/main/kotlin/io/homeassistant/companion/android/nfc/NFCUtil.kt | Extracts URL/message builders for HA NFC tags and reuses them for tag writing. |
| app/src/main/kotlin/io/homeassistant/companion/android/nfc/NfcSetupActivity.kt | Switches tag URL construction to NFCUtil.createTagUrl. |
| app/src/debug/res/xml/debug_nfc_tag_apduservice.xml | Declares the HCE AID filter for an NDEF Type 4 Tag application. |
| app/src/debug/res/values/strings.xml | Adds a debug label string for the emulator. |
| app/src/debug/kotlin/io/homeassistant/companion/android/developer/nfc/DebugNfcTagEmulatorActivity.kt | New Dev Playground screen for controlling and inspecting the emulated tag. |
| app/src/debug/kotlin/io/homeassistant/companion/android/developer/nfc/DebugNfcTagEmulator.kt | Implements emulator state + HostApduService APDU handling and logging. |
| app/src/debug/kotlin/io/homeassistant/companion/android/developer/DevPlaygroundActivity.kt | Adds entry point button to launch the emulator screen. |
| app/src/debug/AndroidManifest.xml | Registers the emulator activity and HCE service (disabled by default). |
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
I wanted to debug some NFC tag issue but I don't have any writable NFC tag so I've asked Claude to do an emulator of tag. This is Claude work using the
android.nfc.cardemulation.HostApduServicewithin the DevPlaygound. I tested it on Android 9 and 17 and both managed to make proper tag read by our app.Checklist
Select exactly one option that describes AI usage in this contribution:
Screenshots
Any other notes
I didn't review in details the service I assumed that since it works the tag used is valid.