Pair Android phone and Wear OS emulators via adb, then build TwoFac watch app
Session from pi-coding-sessions on Hugging Face by championswimmer · MIT · condensed by Coders Talk
Pair a running Android phone emulator with a Wear OS watch emulator purely from CLI using adb, then build and install a Kotlin Multiplatform app's watch companion and wire up phone-triggered sync.
- +0Prompt · +0Pair the running Android phone and watch emulators purely from adb CLI; ask me if I need to tap anything on the screens.
- +0mAgent did · +0mResearched pairing docs, set up adb port forwarding on 5601, launched the Wear emulator pairing activity via am start, then drove the UI blind with uiautomator dumps, screenshots and input taps to click through consent/pairing screens.
- +3mIntervention · +3mDeveloper noticed the watch had entered a factory reset and flagged it mid-flow.Why: the watch seemed to be resetting right now, wanted to flag that before things got worse
- +7mIntervention · +7mDeveloper pointed the agent to use emulator/avd CLI tools to just wipe and restart the watch instead of continuing to poke at broken UI state.Why: it was stuck fumbling with taps and dumps, so I reminded it there's a simpler emulator-level reset it could use
- +8mAgent did · +8mWiped and relaunched the Pixel_Watch AVD via emulator CLI, waited for boot, cleared companion device associations on both sides, cleared the wearable app data on the phone, retried the EMULATOR_PAIR intent flow, and confirmed pairing succeeded via companion device state and screenshots.
- +10mPrompt · +10mBuild and install the watch app of TwoFac into the Pixel watch emulator.
- +11mAgent did · +11mExplored the Kotlin Multiplatform TwoFac repo structure and skills docs, ran ./gradlew :watchApp:installDebug targeting the watch emulator, then launched and screenshotted the app to confirm it installed and ran.
- +13mPrompt · +13mInstead of 'sync requested, open phone app', make Sync now open the phone app and start the sync workflow directly.
- +13mAgent did · +13mTraced the watch-sync data layer contract, added a new WearableListenerService on the phone to receive the sync-request message, wired it to open the phone MainActivity and trigger CompanionSyncCoordinator.syncNow, updated manifests and strings, then rebuilt and reinstalled both apps, debugging via logcat and dumpsys when the listener initially didn't register.
- +20mPrompt · +20mConnect the two emulator devices via Bluetooth using adb.
- +21mFail · +21mAfter research and attempts (adb forwarding tricks, checking bluetooth_manager dumps), confirmed Android emulators have no virtual Bluetooth hardware, so adb tunneling cannot fake or establish real Bluetooth pairing between them.
- +25mOutcome · +25mSession ended mid-restart: both emulators were killed and relaunched, watch/phone rebooted and re-forwarded tcp:5601, but the watch adb connection was still coming online (offline/timeout) when the transcript cuts off, so re-pairing after restart was not confirmed complete.
Next time I'd start by telling the agent up front that Android emulators have no real Bluetooth stack, so it doesn't waste a round trip researching 'fake bluetooth pairing via adb tunneling' before concluding it's impossible. The correction that actually unblocked things was reminding it to use the emulator/avd CLI to wipe and restart the watch instead of endlessly poking at uiautomator dumps and taps on a broken factory-reset screen. The watch-app build and phone-sync wiring went smoothly once the pairing was solid, but the final restart-and-repair step wasn't confirmed working before the session ended.