feat(issue-14): connect Android operator terminal to hub #15

Merged
rznz merged 1 commit from feat/14-android-hub-client into main 2026-10-27 09:43:10 +03:00
Collaborator

Issue

Closes #14

Summary

The Java operator terminal now displays actual linux-hub state instead of predefined data. A saved server origin drives OkHttp GET and WebSocket connections; nested JSONObject decoding and connection-scoped state revisions reject stale updates. The screen shows phase, power/signal/alarm and connection status while preserving the physical panel's separate role.

One worker orders HTTP bootstrap, WS snapshots and reconnects. Attempts and lifecycle generations reject old callbacks; stopping/destroying the Activity cancels owned resources. Connection failures and malformed responses disconnect safely, with retries capped at ten seconds. Android 17 local-network permission is handled for the existing target SDK 37.

Acceptance Criteria

  • Java/module structure retained, server origin stored in SharedPreferences, HTTP and WS use OkHttp.
  • Explicit nested JSON parsing, snapshot/state_changed handling and long state_revision filtering, including a fresh baseline after hub restart.
  • Actual operator phase/systems/connectivity; no puzzle instructions, hints, timer or complete panel mirror.
  • Safe errors, background network/JSON work, bounded reconnect and lifecycle cancellation without duplicate sockets or destroyed-screen delivery.
  • JSON/revision tests, debug APK, browser-panel/loss/reopen checks and setup/prompt documentation.

Verification

  • gradlew.bat testDebugUnitTest assembleDebug assembleDebugAndroidTest: passed; 16 JVM tests (7 parser/URLs, 5 revision/backoff, 4 real MockWebServer transport/lifecycle tests), both APKs built.
  • gradlew.bat testDebugUnitTest assembleDebug lintDebug, then assembleDebug lintDebug after address-label cleanup: passed. No lint errors; two pre-existing scaffold warnings remain (window overdraw and missing launcher icon).
  • Android 17/API 37.0 AOSP ATD emulator: OperatorLiveIntegrationTest passed, 1 test in 152.315 s. Actual browser toggles changed Activity phase/power; owned hub stop/restart showed disconnection and recovery at revision 0. Activity recreate, background/resume and close/reopen with saved address passed.
  • After Activity/test clients closed, only Node-RED's connection remained on the isolated hub port; no Android connection leak observed.
  • No physical phone was available; phone Wi-Fi and USB instructions are documented without claiming verification.
  • git diff --check passed. SDK/JDK/cache/APKs, credentials and local runtime files are outside tracked changes.

Documentation and architecture

  • Root README, Android setup guide, ARCHITECTURE.md and prompt index updated; task-memory indexes and generated documentation rebuilt.
  • Existing hub endpoints, scenario rules and physical-panel behavior preserved.

Depends on #10 / PR #12 for state_revision and broadcasts; real integration used its corrected runtime at e569268. The browser simulator is #11 / PR #13 at a880198. Merge those dependencies first; then rebase this main-based branch and regenerate the shared indexes to preserve all tasks' projections.

AI assistance

  • Prompt log: docs/prompts/14-android-hub-client.md
  • Task outcome: .agents/work/tasks/14-android-hub-client/outcome.md

Review

  • Branch feat/14-android-hub-client matches the issue.
  • Work is complete without a feature flag.
  • Reviewer: echo1 (non-author).
  • Squash subject: feat(issue-14): connect Android operator terminal to hub.

The user explicitly authorized review and merge in the preceding conversation and resumed that instruction on 2026-10-27.

2026-10-27 integration verification

Rebased onto merged PRs #12 and #13. README/architecture combined and shared indexes/generated documentation rebuilt from all frozen outcomes. Android app source and test files are byte-for-byte unchanged by rebase. Hub/device pytest: 16 passed; panel tests: 10 passed; global secret/conflict checks passed.

The ordinary Android Gradle build on this macOS host cannot run because Android SDK is absent. As an additional check, compiled the unchanged client/model sources and all JVM tests using a temporary Java Gradle project with the exact declared dependencies: 16 tests passed, including real MockWebServer HTTP/WebSocket and lifecycle-generation cases. Temporary project: /private/tmp/sl-jvm-20261027; command: android/gradlew -p /private/tmp/sl-jvm-20261027 test. This does not rebuild the APK or repeat Activity instrumentation; previous successful APK/lint/emulator evidence above still applies.

## Issue Closes #14 ## Summary The Java operator terminal now displays actual linux-hub state instead of predefined data. A saved server origin drives OkHttp GET and WebSocket connections; nested JSONObject decoding and connection-scoped state revisions reject stale updates. The screen shows phase, power/signal/alarm and connection status while preserving the physical panel's separate role. One worker orders HTTP bootstrap, WS snapshots and reconnects. Attempts and lifecycle generations reject old callbacks; stopping/destroying the Activity cancels owned resources. Connection failures and malformed responses disconnect safely, with retries capped at ten seconds. Android 17 local-network permission is handled for the existing target SDK 37. ## Acceptance Criteria - [x] Java/module structure retained, server origin stored in SharedPreferences, HTTP and WS use OkHttp. - [x] Explicit nested JSON parsing, snapshot/state_changed handling and long state_revision filtering, including a fresh baseline after hub restart. - [x] Actual operator phase/systems/connectivity; no puzzle instructions, hints, timer or complete panel mirror. - [x] Safe errors, background network/JSON work, bounded reconnect and lifecycle cancellation without duplicate sockets or destroyed-screen delivery. - [x] JSON/revision tests, debug APK, browser-panel/loss/reopen checks and setup/prompt documentation. ## Verification - `gradlew.bat testDebugUnitTest assembleDebug assembleDebugAndroidTest`: passed; 16 JVM tests (7 parser/URLs, 5 revision/backoff, 4 real MockWebServer transport/lifecycle tests), both APKs built. - `gradlew.bat testDebugUnitTest assembleDebug lintDebug`, then `assembleDebug lintDebug` after address-label cleanup: passed. No lint errors; two pre-existing scaffold warnings remain (window overdraw and missing launcher icon). - Android 17/API 37.0 AOSP ATD emulator: `OperatorLiveIntegrationTest` passed, 1 test in 152.315 s. Actual browser toggles changed Activity phase/power; owned hub stop/restart showed disconnection and recovery at revision 0. Activity recreate, background/resume and close/reopen with saved address passed. - After Activity/test clients closed, only Node-RED's connection remained on the isolated hub port; no Android connection leak observed. - No physical phone was available; phone Wi-Fi and USB instructions are documented without claiming verification. - `git diff --check` passed. SDK/JDK/cache/APKs, credentials and local runtime files are outside tracked changes. ## Documentation and architecture - [x] Root README, Android setup guide, ARCHITECTURE.md and prompt index updated; task-memory indexes and generated documentation rebuilt. - [x] Existing hub endpoints, scenario rules and physical-panel behavior preserved. Depends on #10 / PR #12 for state_revision and broadcasts; real integration used its corrected runtime at e569268. The browser simulator is #11 / PR #13 at a880198. Merge those dependencies first; then rebase this main-based branch and regenerate the shared indexes to preserve all tasks' projections. ## AI assistance - Prompt log: `docs/prompts/14-android-hub-client.md` - Task outcome: `.agents/work/tasks/14-android-hub-client/outcome.md` ## Review - [x] Branch `feat/14-android-hub-client` matches the issue. - [x] Work is complete without a feature flag. - Reviewer: echo1 (non-author). - Squash subject: `feat(issue-14): connect Android operator terminal to hub`. The user explicitly authorized review and merge in the preceding conversation and resumed that instruction on 2026-10-27. ## 2026-10-27 integration verification Rebased onto merged PRs #12 and #13. README/architecture combined and shared indexes/generated documentation rebuilt from all frozen outcomes. Android app source and test files are byte-for-byte unchanged by rebase. Hub/device pytest: 16 passed; panel tests: 10 passed; global secret/conflict checks passed. The ordinary Android Gradle build on this macOS host cannot run because Android SDK is absent. As an additional check, compiled the unchanged client/model sources and all JVM tests using a temporary Java Gradle project with the exact declared dependencies: 16 tests passed, including real MockWebServer HTTP/WebSocket and lifecycle-generation cases. Temporary project: /private/tmp/sl-jvm-20261027; command: android/gradlew -p /private/tmp/sl-jvm-20261027 test. This does not rebuild the APK or repeat Activity instrumentation; previous successful APK/lint/emulator evidence above still applies.
dudll requested review from echo1 2026-10-26 20:11:30 +03:00
rznz force-pushed feat/14-android-hub-client from ef52d7145f to 3644ab5590 2026-10-27 09:42:35 +03:00 Compare
rznz approved these changes 2026-10-27 09:43:08 +03:00
rznz left a comment

No blocking findings. Reviewed issue criteria, nested parser, per-connection revision baseline, retry/lifecycle ownership and existing tests/emulator evidence. Rebase preserves Android app and tests exactly. Current verification: 16 JVM tests passed via separate Java Gradle harness with exact declared dependencies; Python 16/16 and Node 10/10 passed; secret/conflict checks passed. Ordinary Android build cannot run here without SDK; APK/lint and Activity instrumentation rely on the prior recorded successful run. Physical phone remains unverified. Reviewer account rznz differs from PR author dudll; user explicitly requested review and merge.

No blocking findings. Reviewed issue criteria, nested parser, per-connection revision baseline, retry/lifecycle ownership and existing tests/emulator evidence. Rebase preserves Android app and tests exactly. Current verification: 16 JVM tests passed via separate Java Gradle harness with exact declared dependencies; Python 16/16 and Node 10/10 passed; secret/conflict checks passed. Ordinary Android build cannot run here without SDK; APK/lint and Activity instrumentation rely on the prior recorded successful run. Physical phone remains unverified. Reviewer account rznz differs from PR author dudll; user explicitly requested review and merge.
rznz merged commit 87d98dd4e1 into main 2026-10-27 09:43:10 +03:00
rznz deleted branch feat/14-android-hub-client 2026-10-27 09:43:11 +03:00
Sign in to join this conversation.
No description provided.