Skip to content
PidebugMobile3 files · +112 −30

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

25msession
2interventions
GOAL

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.

  1. Prompt · +0
    Pair the running Android phone and watch emulators purely from adb CLI; ask me if I need to tap anything on the screens.
  2. Agent did · +0m
    Researched 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.
  3. Intervention · +3m
    Developer 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
  4. Intervention · +7m
    Developer 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
  5. Agent did · +8m
    Wiped 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.
  6. Prompt · +10m
    Build and install the watch app of TwoFac into the Pixel watch emulator.
  7. Agent did · +11m
    Explored 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.
  8. Prompt · +13m
    Instead of 'sync requested, open phone app', make Sync now open the phone app and start the sync workflow directly.
  9. Agent did · +13m
    Traced 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.
  10. Prompt · +20m
    Connect the two emulator devices via Bluetooth using adb.
  11. Fail · +21m
    After 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.
  12. Outcome · +25m
    Session 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.
VERDICT

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.

I tried this · 0

Discussion · 0

How Builds work