Repository navigation
Android app: remote access (web mode, camex tunnel, optional password) - #98
Conversation
With "Allow remote access" and a password in Settings, the app serves the page of the web mode (src/web.c) on every network of the device, port 8080 by default: an operator elsewhere drives the programmer from a browser and nobody has to be at the device. - RemoteService: a foreground service (specialUse) runs web_serve in a thread, with the screen off and from boot (BootReceiver); the settings change it on the fly. Each operation of the page asks it for the USB device (openDevice/closeDevice, called from the native thread). - UsbAttachActivity takes the plug-in of a programmer: chosen once with Always, it is the app's on every plug-in and after a reboot. - The app's own operations take the same slot as the page's: each side shows what the other runs (REMOTE: READ 42% on the device, local:true on the page) and refuses a second one; the page links the last dump of either side. - web.c: web_stop, device hooks, web_local_begin/progress/end, web_state_json, web_show_dump, any Host for the app (a password always); Linux behaviour unchanged. A dump Range is sought with lseek: 32-bit Android before 7.0 has no fseeko with a 64-bit offset. - CMake builds web.c with the page (web_page.h made as src/Makefile does), the version from build.gradle.kts. - tests/websim.c: the hooks, the shared slot, any Host, stop and serve again. Checked: tests/run.sh (699 ok), make and make LIBUSB=1 without warnings, static musl x86_64/arm/mipsel/mips, assembleDebug lintDebug assembleRelease; Android 14 and 5.0 emulators (service, password, page, port change, start after reboot; the R8 release build on 5.0); a TV box with a CH341A and a BY25Q64AS: Detect, Registers and Read from the page, the dump and its Range match, local and remote operations exclude each other and show on both sides. [skip ci]
With remote access on, Tunnel... makes the device join a camex server:
the tunnel library of camex (bundles/camex, a submodule, android/tunnel
as :camex-tunnel) runs in the app, and the operator, another client of
that server, opens the page by the device's address in the tunnel.
- RemoteService starts the tunnel with the page and stops it with it;
a start with the same values (a plug-in of the programmer) does not
cut it; it reconnects by itself; one notification for both.
- VPN consent both ways: Allow VPN... (the system dialog, once), or on a
device with nobody at it adb shell appops set ... ACTIVATE_VPN allow
and appops write-settings (a reboot soon after loses it otherwise).
Without it the screen, the notification and the page ("tunnel" in
/api/state) say so, and the app tries again every minute.
- TunnelDialog: the fields of the library, filled from a camex link
pasted there or opened with the app (camex://connect, the
openipc.github.io/camex/connect page).
- The ABIs of the app (-PmicrosnanderAbis) build the library's native
code too (camexTunnelAbis).
- CI: the Android jobs check out the submodule.
- tests/android/remote-e2e.sh: a camex server and an operator in
Docker, the app on an emulator: no consent, the consent, 401 and the
state through the tunnel, an operation, back after a reboot.
The submodule is at the head of camex PR #171 (3.18.0) for now; it
moves to the camex release once that is out.
Checked: remote-e2e.sh 8 of 8 on Android 14 (appops) and 5.0 (the
dialog); tests/run.sh 699 ok; make and make LIBUSB=1 without warnings;
static musl x86_64/arm/mipsel/mips; assembleDebug lintDebug
assembleRelease. [skip ci]
…b port) [skip ci]
…ER_WEB_PASSWORD; the app on port 8085 gives it to camex as the web port [skip ci]
PR Summary by QodoAdd unattended Android web access and a built-in camex tunnel
AI Description
Merge Risk
|
Code Review by Qodo
1. Android native builds fail to compile
|
…ip after the slot, busy answers, strings kept after a stop
|
Qodo review: all four fixed in 9069b14 (1.47.2).
Checked: |
|
/review |
…site>, the page header by full path, buttons back after unseen remote ends
|
Qodo review of 9069b14: all five fixed in 8dcf667.
Checked: |
|
/review |
…TF-8 password, local after remote, tunnel check message
|
Qodo review of 8dcf667: fixed in a7341a4. 1 / 7. Changing settings / stopping can disrupt a running operation — Checked: |
|
/review |
…ed as the service stopped (Qodo, #98)
|
Qodo review of a7341a4:
Checked: Android |
|
/review |
Remote access in the Android app: an operator anywhere drives the programmer from a browser, nobody needs to be at the device.
Web mode in the app (1.44.0)
microsnander -Wserved by the app in a foreground service, on every interface, with the screen off and after a reboot.src/web.c: device hooks, a shared local slot,web_stop, any Host for tunnels;tests/websim.ccovers them.camex tunnel built in (1.45.0 – 1.47.1)
bundles/camex(submodule, camex 4.0.0): the device joins a camex server, the operator opens the page by the device's tunnel address; the tunnel reconnects by itself and comes back after a reboot.adb shell appops set org.openipc.microsnander ACTIVATE_VPN allowandadb shell appops write-settings.Password (1.47.0)
-K, elseMICROSNANDER_WEB_PASSWORD. Compared by SHA-256 of both sides in constant time;401withcharset="UTF-8".Tests
tests/run.sh(all, including websim) incompot/cross.assembleDebug lintDebug assembleReleaseincompot/android.tests/android/remote-e2e.sh: camex server and operator in Docker, the app on an emulator, API 34 and API 21: 10/10 — consent, tunnel, web port on the server, 401 without the password, the page and an operation through the tunnel, no psk in logcat, after a reboot, the page without a password.README (en, ru, zh-CN) and CHANGELOG updated.