Skip to content

Android app: remote access (web mode, camex tunnel, optional password) - #98

Merged
compot-dev merged 10 commits into
mainfrom
microsnander-camex
Nov 17, 2026
Merged

compot-dev merged 10 commits into
mainfrom
microsnander-camex

Conversation

@compot-dev

Copy link
Copy Markdown
Collaborator

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)

  • The page of microsnander -W served by the app in a foreground service, on every interface, with the screen off and after a reboot.
  • The programmer is opened for each operation of the page (permission once, with Always), so it can be replugged; the app's own operations and the page's share one slot and show on both sides.
  • src/web.c: device hooks, a shared local slot, web_stop, any Host for tunnels; tests/websim.c covers 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.
  • VPN consent once: Allow VPN…, or adb shell appops set org.openipc.microsnander ACTIVATE_VPN allow and adb shell appops write-settings.
  • The page's port (8085 by default) goes to camex as the web port, so the server's nginx opens the page by the client's name (camex server 3.19.0 or later).

Password (1.47.0)

  • Optional everywhere: an empty password means none. Console: -K, else MICROSNANDER_WEB_PASSWORD. Compared by SHA-256 of both sides in constant time; 401 with charset="UTF-8".

Tests

  • tests/run.sh (all, including websim) in compot/cross.
  • Android: assembleDebug lintDebug assembleRelease in compot/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.
  • On a TV box with a CH341A and a live chip: remote Detect, Registers, Read and ranged download; local and remote operations exclude each other.

README (en, ru, zh-CN) and CHANGELOG updated.

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]
…ER_WEB_PASSWORD; the app on port 8085 gives it to camex as the web port [skip ci]
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Add unattended Android web access and a built-in camex tunnel

✨ Enhancement 🧪 Tests 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Serve the programmer’s web page from Android, including after reboot and while the screen is off.
• Share one operation slot between local and browser controls, with an optional web password.
• Integrate camex for tunneled access and add simulation, emulator, and usage coverage.
Merge Risk 🟡 Medium

Evidence: Partial. bundles/camex submodule and the camex-tunnel library were not inspected. Docs, strings, layouts, the CI workflow and the e2e test script were not individually evidenced as non-behavioral; the CI submodule checkout and the Gradle project wiring are build-only. The report lists 19 more gaps.

Blast radius 🟡 Medium 💥 2 capabilities

  • 2 affected capabilities within one bounded functional scope: remote_access.
  • The auth, host and listen settings gate the one page that drives the programmer, on both Linux and Android.
  • The app's operations now pass through the same slot as the page, so a fault in the slot affects both.
  • This is a regression path for the main feature.
  • The page's worker opens the device through the service and shares the slot.
Sources

src/web.c[353-355]

	if (st.busy || st.uploading) {
		pthread_mutex_unlock(&st.lock);
		return -1;

src/web.c[266-266]

	int opened = !web_device_open || !web_device_open();
Behavioral complexity 🔴 High 🧩 Concurrent ordering, State transitions

  • Before: the app ran operations one at a time under a Java synchronised lock, and the web server ran only on Linux.
  • After: three actors (app buttons, page worker threads, the service stop/restart and tunnel retry) share one mutex-guarded busy slot.
  • The page worker also opens and closes a USB connection through JNI.
  • New correctness condition: begin and end must pair on every path, and the device handle must be acquired and released once per operation, across stop, restart and retry interleavings.
Potential damage 🔴 High 🩹 Integrity

  • An unauthenticated client can erase or overwrite a target flash chip.
  • The feature is opt-in and the screen warns when no password is set.
  • Code revert is simple.
  • A chip that has been erased or overwritten needs its content restored from a dump, if one exists.
Assessed commit d836c9a > Snapshot assessment: the current PR revision could not be verified.
Diagram

sequenceDiagram
    actor Operator
    participant Camex as Camex tunnel
    participant Web as Native web server
    participant Bridge as JNI bridge
    participant Service as Remote service
    participant USB as USB programmer
    participant UI as Local app
    Service->>Web: Start web mode
    Operator->>Camex: Open page
    Camex->>Web: Forward request
    Web->>Bridge: Request programmer
    Bridge->>Service: Open device
    Service->>USB: Open for operation
    UI->>Bridge: Start local operation
    Bridge->>Web: Claim shared slot
    Web-->>Operator: State and result
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Require an external VPN app
  • ➕ Avoids embedding and maintaining camex’s Android tunnel integration.
  • ➖ Requires separate installation and configuration on each device.
  • ➖ Makes unattended recovery and unified tunnel status harder to provide.

Recommendation: Reuse the existing native web mode and embed camex for the stated unattended-device goal. An external VPN would reduce integration scope, but would shift setup and recovery responsibilities outside the app; the shared operation slot is also necessary when both interfaces can control the same programmer.

Files changed (31) +2132 / -37

Enhancement (17) +1595 / -26
AndroidManifest.xmlDeclare remote service, boot handling, and link entry points +51/-1

Declare remote service, boot handling, and link entry points

• Adds network, foreground-service, notification, wake-lock, and boot permissions. Registers the remote service, boot receiver, USB attach activity, and camex link intent filters.

android/app/src/main/AndroidManifest.xml

microsnander-jni.cBridge web serving and shared operations to Android +193/-0

Bridge web serving and shared operations to Android

• Exposes web lifecycle and state methods to Java and obtains USB devices through RemoteService for browser operations. Places local native operations in the same slot and publishes their progress and results.

android/app/src/main/cpp/microsnander-jni.c

BootReceiver.javaRestore enabled remote access after boot +14/-0

Restore enabled remote access after boot

• Starts the foreground service after boot when remote access is enabled.

android/app/src/main/java/org/openipc/microsnander/BootReceiver.java

MainActivity.javaAdd remote controls and cross-device status to the app +196/-2

Add remote controls and cross-device status to the app

• Adds web and tunnel settings, VPN consent handling, link imports, and remote-operation status on the local screen. Publishes locally kept dumps to the web page.

android/app/src/main/java/org/openipc/microsnander/MainActivity.java

Native.javaDeclare native remote-access methods +16/-0

Declare native remote-access methods

• Adds Java declarations for web serving and stopping, shared state, tunnel status, and dump publication.

android/app/src/main/java/org/openipc/microsnander/Native.java

RemoteService.javaHost web mode and camex in a foreground service +390/-0

Host web mode and camex in a foreground service

• Manages the web server, wake lock, notification, retries, and tunnel lifecycle. Opens and closes an Android USB connection for each browser operation.

android/app/src/main/java/org/openipc/microsnander/RemoteService.java

Settings.javaPersist web and tunnel settings +88/-0

Persist web and tunnel settings

• Stores remote-access enablement, port, optional password, and camex fields. Supplies the web port to camex automatically and defaults it to 8085.

android/app/src/main/java/org/openipc/microsnander/Settings.java

TunnelDialog.javaConfigure camex from fields or a connection link +162/-0

Configure camex from fields or a connection link

• Builds a settings dialog from camex’s field definitions and supports pasted or opened connection links. Validates settings before saving them.

android/app/src/main/java/org/openipc/microsnander/TunnelDialog.java

UsbAttachActivity.javaHandle programmer attachment without opening the main screen +24/-0

Handle programmer attachment without opening the main screen

• Starts remote access when enabled after a programmer is attached; otherwise opens the main activity.

android/app/src/main/java/org/openipc/microsnander/UsbAttachActivity.java

ic_notify.xmlAdd a remote-service notification icon +15/-0

Add a remote-service notification icon

• Provides the monochrome vector icon used by the foreground notification.

android/app/src/main/res/drawable/ic_notify.xml

activity_main.xmlAdd a remote-access status panel +88/-0

Add a remote-access status panel

• Adds listening and tunnel status text plus settings and VPN-consent controls to the main screen.

android/app/src/main/res/layout/activity_main.xml

remote_settings.xmlAdd web-access settings layout +53/-0

Add web-access settings layout

• Provides controls for enabling remote access and setting its port and optional password.

android/app/src/main/res/layout/remote_settings.xml

strings.xmlAdd remote-access interface text +37/-0

Add remote-access interface text

• Defines labels, status messages, validation text, and consent guidance for web access and the camex tunnel.

android/app/src/main/res/values/strings.xml

main.cAccept an environment password for CLI web mode +5/-2

Accept an environment password for CLI web mode

• Updates the version to 1.47.1 and uses MICROSNANDER_WEB_PASSWORD when -K is absent. Updates command-line help accordingly.

src/main.c

web.cExtend web mode for Android and optional authentication +226/-20

Extend web mode for Android and optional authentication

• Adds stop and USB-device hooks, shared local-operation state, tunnel status, and a JSON state API. Allows empty passwords, compares password hashes, accepts named Hosts when configured, and uses lseek for dump ranges.

src/web.c

web.hExpose the Android web-mode integration API +36/-1

Expose the Android web-mode integration API

• Declares operation identifiers and the stop, device-hook, shared-state, dump, tunnel, and Host-control interfaces.

src/web.h

web_page.htmlShow tunnel status on the web page +1/-0

Show tunnel status on the web page

• Displays the app’s camex tunnel status alongside operation and dump information.

src/web_page.html

Tests (2) +326 / -2
remote-e2e.shExercise Android access through a camex tunnel +231/-0

Exercise Android access through a camex tunnel

• Adds a Docker-and-emulator test covering VPN consent, server web-port registration, authenticated and open access, an operation, and recovery after reboot.

tests/android/remote-e2e.sh

websim.cTest web hooks, shared state, stopping, and passwords +95/-2

Test web hooks, shared state, stopping, and passwords

• Adds simulator coverage for device acquisition, local-operation exclusion and progress, dump visibility, named Hosts, server stop/restart, and SHA-256 password behavior.

tests/websim.c

Documentation (4) +165 / -6
CHANGELOG.mdRecord Android remote-access releases +58/-0

Record Android remote-access releases

• Documents the web service, camex integration, optional password, default port, and related tests across versions 1.44.0–1.47.1.

CHANGELOG.md

README.mdDocument remote access in English +41/-2

Document remote access in English

• Explains browser access, USB association, shared operations, camex setup, VPN consent, and password behavior. Adds the CLI environment-variable password option.

README.md

README.ru.mdDocument remote access in Russian +40/-2

Document remote access in Russian

• Adds translated Android remote-access and camex instructions, including consent and password behavior.

README.ru.md

README.zh-CN.mdDocument remote access in Simplified Chinese +26/-2

Document remote access in Simplified Chinese

• Adds translated Android remote-access and camex instructions, including consent and password behavior.

README.zh-CN.md

Other (8) +46 / -3
build.ymlCheck out camex in Android CI jobs +4/-0

Check out camex in Android CI jobs

• Enables submodule checkout in the Android build jobs so the embedded tunnel library is available.

.github/workflows/build.yml

.gitmodulesRegister the camex submodule +3/-0

Register the camex submodule

• Adds the upstream camex repository as the source of the bundled tunnel library.

.gitmodules

build.gradle.ktsLink camex and pass the app version to native code +5/-0

Link camex and pass the app version to native code

• Adds the camex tunnel project dependency and supplies the application version to CMake for display in web mode.

android/app/build.gradle.kts

proguard-rules.proPreserve service methods called through JNI +5/-0

Preserve service methods called through JNI

• Keeps RemoteService’s static USB open and close methods available to native worker threads.

android/app/proguard-rules.pro

CMakeLists.txtBuild native web mode into the Android app +18/-3

Build native web mode into the Android app

• Compiles web.c into the JNI library, generates its page header from HTML, and passes the app version to native code.

android/app/src/main/cpp/CMakeLists.txt

build.gradle.ktsConfigure the camex Android library plugin and ABIs +6/-0

Configure the camex Android library plugin and ABIs

• Declares the Android library plugin and forwards the app’s selected ABI list to the tunnel build.

android/build.gradle.kts

settings.gradle.ktsInclude the bundled camex tunnel module +4/-0

Include the bundled camex tunnel module

• Maps the Gradle camex-tunnel project to the submodule’s Android library directory.

android/settings.gradle.kts

camexPin the camex tunnel dependency +1/-0

Pin the camex tunnel dependency

• Adds the camex submodule at the commit used for the built-in Android tunnel.

bundles/camex

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Android native builds fail to compile 🐞 Bug ≡ Correctness
Description
target_compile_definitions strips the CMake argument quotes around WEB_PAGE_H and MS_VERSION,
leaving both macros without the literal quotes their C consumers require. On an Android build, the
resulting header path is invalid at #include WEB_PAGE_H, and the version value is invalid as a C
string initializer.
Code

android/app/src/main/cpp/CMakeLists.txt[26]

+target_compile_definitions(microsnander PRIVATE WEB_PAGE_H="${CMAKE_CURRENT_BINARY_DIR}/gen/web_page.h")
Evidence
The changed CMake definitions supply a path and a dotted version without preserved C quotes. Their
consumers use one macro as a preprocessor header name and the other as a const char * initializer.

android/app/src/main/cpp/CMakeLists.txt[23-29]
src/web.c[411-415]
android/app/src/main/cpp/microsnander-jni.c[27-29]
android/app/build.gradle.kts[7-14]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
CMake removes argument-grouping quotes, so the two new compiler macros do not expand to a quoted header path and a C string.
## Fix Focus Areas
- android/app/src/main/cpp/CMakeLists.txt[26-29]
## Recommended Fix
Escape the literal double quotes in both `target_compile_definitions` values so `WEB_PAGE_H` expands to a quoted absolute path and `MS_VERSION` expands to a C string literal.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Changing settings can disrupt a live read ✓ Resolved
Description
stopServing() clears server and proceeds after join(3000) even if the old webServe thread is
still waiting for a page operation to finish. When remote settings change during a long read,
startServing() can launch another native server that overwrites shared password and dump-directory
settings while the old operation still uses them.

3. Rebinding to localhost.<domain> passes the no-password guard ✓ Resolved
Description
Without a password webServe turns off web_any_host and relies on host_ok, which accepts any
Host equal to gethostname() or starting with it followed by '.', and on Android the kernel host
name is normally localhost. A site can serve its page as localhost.attacker.example, rebind that
name to the device's address, pass host_ok and make same-origin requests (with the page-only
header) to read dumps and erase or write the chip. That is exactly what the 1.47.2 change says it
prevents.

View action required (3)
4. Stopping the page can crash the app ✓ Resolved
Description
web_serve returns after stopping its listening socket without waiting for active request and
operation threads, and the JNI caller immediately frees the password and dump-directory strings
those threads use. Stopping or restarting remote access during a read, upload, or active request can
therefore leave those threads dereferencing freed memory.

5. Concurrent runs can lose chip checks ✓ Resolved
Description
The new local-operation slot is acquired inside each operation's JNI method, but MainActivity
calls Native.expect() beforehand as a separate call that changes the process-global expected chip.
A remote worker can set its own expectation between those calls and have it overwritten or consumed
by the local call, so a confirmed operation can run without checking the chip the operator selected.

6. Any website can erase the chip via DNS rebinding ✓ Resolved
Description
Android’s webServe unconditionally calls web_allow_any_host(1), causing the server to skip
host_ok, its DNS-rebinding check, even when no password is set. Since 1.47.0 defaults to an empty
password and the service binds every interface, a page opened on the same network can rebind its
hostname to a reachable device and make same-origin requests, including the custom header, to read
state and dumps or erase and write the chip.


Remediation recommended

7. Remote results disappear between polls ✓ Resolved

Resolving commit: 6b9aadf

Resolution reason
The watcher now keeps running after the service ends while a page operation was shown, and the
completion branch comments that unseen endings are handled by the newest outcome. Sequence tracking
was removed, and a quick operation that never shows busy is still not displayed because
remoteRunning is still required.
Description
watch() processes a completed page operation only if an earlier poll set remoteRunning while it
was busy. A quick operation, or one completed while the activity is paused, never meets that
condition, so its result is not shown on the device screen.

8. Remote work can start after shutdown ✓ Resolved

Resolving commit: 6b9aadf

Resolution reason
The fix registers accepted sockets in conn_fd[] under st.lock (the slot is filled right after the
connections++ check), and web_stop() now shuts down every registered conn_fd[] under st.lock.
web_serve() also waits after the accept loop until connections reach zero and no non-local operation
is busy before clearing web_stopping, so a connection that slipped past the stop check is cut by the
scan or waited for before web_serve returns. This is a different mechanism from the suggested fix
(which would re-check web_stopping under the lock and close the socket), but it addresses the same
race: a late-registered connection is no longer left uncut and unwaited.
Description
web_serve() checks web_stopping before locking and registering an accepted socket, while
web_stop() shuts down only sockets already registered. If stopping occurs between that check and
registration, the connection can still reach handle() and start a chip operation after remote
access was turned off; an idle connection instead delays shutdown until its receive timeout.

9. Device buttons stay locked after stopping remote access mid-operation ✓ Resolved
Description
The watchRemote runnable calls watch() only while RemoteService.instance != null, and
watch() is the only place that clears remoteRunning and re-enables the buttons after a page
operation. If the user turns remote access off while an operator's write is running, stopServing
waits for that operation, then stopped() → stopSelf() → onDestroy sets instance = null,
often within one 700 ms poll. From then on watch() is never called again, so the screen keeps
showing "REMOTE: WRITE …" with every button disabled until the activity is recreated.

View review recommended (6)
10. Local results can appear as remote work ✓ Resolved
Description
watch() ignores a local state only when remoteRunning is false, so an earlier observed page
operation leaves the watcher treating subsequent local work as remote. If that page operation ends
and a local operation starts before the next poll, the screen can label the local operation remote
and then replace its normal result with a remote-completion message.

11. Stopping remote access can abandon a running chip write ✓ Resolved
Description
stopServing calls Native.webStop() but waits only t.join(3000) for the server thread, then
releases the wake lock, and onStartCommand goes on to stopSelf(). web_serve itself waits for
the page's operation (st.busy && !st.local), so an erase or write longer than 3 s keeps running
with no wake lock and no foreground service. The CPU may then sleep or Android may kill the process
mid-write, and a Restart leaves the page unreachable, because the new web_serve still sees
web_stopping set until the old operation ends.

12. Android builds can ship an outdated page ✓ Resolved
Description
CMake generates gen/web_page.h, but web.c includes the header with quotes, so an existing
src/web_page.h takes precedence over the generated copy. After tests/run.sh or make creates
that ignored source-tree file, editing the page and rebuilding Android can compile the stale copy
despite CMake regenerating its header.

13. Repeated bind retries drain app memory 🐞 Bug ☼ Reliability
Description
webServe duplicates the password and dump directory on every call but never frees either
allocation, including when web_serve cannot bind its port. If another process occupies the
configured port, serve retries every five seconds and accumulates those allocations for as long as
the foreground service runs.
Code

android/app/src/main/cpp/microsnander-jni.c[R374-377]

+	/* web.c keeps the password (empty: none) and the directory while it
+	   serves, and a connection or an operation may outlive a stop: they are
+	   never freed (one copy per start of the server) */
+	char *pw = strdup(password), *d = strdup(dir), *l = strdup(listen);
Evidence
The JNI wrapper allocates pw, d, and l, but frees only l. The native server returns failure
when binding fails, and the service immediately retries that call after a five-second sleep.

android/app/src/main/cpp/microsnander-jni.c[369-395]
src/web.c[1027-1035]
android/app/src/main/java/org/openipc/microsnander/RemoteService.java[176-199]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Every failed attempt to bind the web port retains newly duplicated configuration strings, while the service retries indefinitely.
## Fix Focus Areas
- android/app/src/main/cpp/microsnander-jni.c[369-395]
- android/app/src/main/java/org/openipc/microsnander/RemoteService.java[176-199]
## Recommended Fix
Free copies when a server start fails before accepting requests. For successful starts, give request and operation threads a safe lifetime for the strings and release them only after those users finish; do not restore the use-after-free behavior on stop.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


14. Device buttons stay locked after remote operations ✓ Resolved
Description
watch() re-enables the buttons (via showResult) only when the finished state's seq equals
remoteSeq, the last operation it saw running. If more page operations finish while the activity is
paused (polling stops in onPause) or within one 700 ms poll, seq moves on and the early return
leaves remoteRunning true. The buttons then stay disabled under the stale "REMOTE: …" text until
another remote operation is caught running.

15. Busy app operations leak file handles and leave a stale chip expectation ✓ Resolved
Description
read and write open a file and acquire a JNI UTF string, while selftest acquires a JNI UTF
string, before checking web_local_begin; their busy_result returns skip cleanup, and write
also skips ms_expect(NULL, 0). When a remote operation holds the slot, each rejected local attempt
retains those resources, read truncates its persistent dump file, and a rejected write leaves
the chip expectation in force for the next operation, including one started from the page.


Informational

16. Address-list comment sits on the wrong method 🐞 Bug ⚙ Maintainability
Description
In RemoteService, the Javadoc for addresses(int) ("http://ADDRESS:PORT of each IPv4 address…")
sits directly on top of the Javadoc for listening(int), so addresses has no doc and listening
has two. Javadoc and IDE tooltips pick up only the comment next to the method, so a reader sees the
wrong description for one method and none for the other.
Code

android/app/src/main/java/org/openipc/microsnander/RemoteService.java[R276-283]

+    /** http://ADDRESS:PORT of each IPv4 address of the device (Ethernet, Wi-Fi, a tunnel) */
+    /** "Listening: http://…", and that the page is open when it has no password */
+    private String listening(int port) {
+        return getString(Settings.password(this).isEmpty() ? R.string.remote_on_open : R.string.remote_on,
+                addresses(port));
+    }
+
+    static String addresses(int port) {
Evidence
Lines 276-277 are two Javadoc blocks one after the other in front of listening. The first one
describes addresses, which starts at line 283 and has no comment of its own.

android/app/src/main/java/org/openipc/microsnander/RemoteService.java[276-297]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The Javadoc for `addresses(int)` sits on top of `listening(int)`'s Javadoc, so the wrong method carries it.
## Fix Focus Areas
- android/app/src/main/java/org/openipc/microsnander/RemoteService.java[276-283]
## Recommended Fix
Delete line 276 (`/** http://ADDRESS:PORT of each IPv4 address ... */`) and put it directly above `static String addresses(int port)`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


17. Tunnel settings Save fails silently on some errors ✓ Resolved
Description
When CamexTunnel.check rejects a field that has no EditText (for example the transport choice),
the Save handler calls linkErrors.setText(bad[1]) but never makes linkErrors visible. The view
starts as View.GONE, so Save does nothing and shows no reason unless a link error was already on
screen.

18. Passwords with emoji never match in the app ✓ Resolved
Description
webServe reads the password with GetStringUTFChars, which returns Java's modified UTF-8, where
supplementary characters become 6-byte surrogate pairs. Browsers send standard UTF-8 after the
charset="UTF-8" 401, so a password containing emoji or other non-BMP characters never matches its
SHA-256.

Grey Divider

Tip of the day
💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

…ip after the slot, busy answers, strings kept after a stop
@compot-dev

Copy link
Copy Markdown
Collaborator Author

Qodo review: all four fixed in 9069b14 (1.47.2).

  1. Stopping the page can crash the app — webServe no longer frees the password and the dump directory: a connection or an operation that outlives a stop keeps valid strings (one copy per start of the server).
  2. Concurrent runs can lose chip checks — Native.expect now only records the confirmed chip; it is passed to ms_expect after the operation holds the slot shared with the page (erase, write, self-test, unprotect, register write), and dropped on a busy answer or by a non-confirmed operation.
  3. DNS rebinding — any Host name is taken only with a password. Without one the page takes addresses, localhost, the device's name, and names under the camex server (web_allow_host_domain, set from the tunnel's server), which is how its nginx reaches the page. web.h comment updated.
  4. Busy app operations leak — the slot is taken before GetStringUTFChars and fopen in read, write and self-test, so a busy read no longer truncates the last dump and nothing is left open; the pending expectation is dropped.

Checked: tests/run.sh (websim: a name under the camex server 200; another name, a suffix-only match, the server's name inside another, no tunnel: 403), Android assembleDebug lintDebug assembleRelease, tests/android/remote-e2e.sh on API 34 and 21: 10/10.

@compot-dev

Copy link
Copy Markdown
Collaborator Author

/review

…site>, the page header by full path, buttons back after unseen remote ends
@compot-dev

Copy link
Copy Markdown
Collaborator Author

Qodo review of 9069b14: all five fixed in 8dcf667.

  1. Rebinding to localhost.<domain> — host_ok never takes the machine's own name when it is localhost (or localhost.*), so localhost.evil.example is refused; websim covers it.
  2. Stopping the page can crash the app — web_stop now also cuts the open connections, and web_serve returns only after they and the page's operation have ended (threads joined). webServe frees the password and directory again after that; websim checks that a stop waits for a running operation.
  3. Repeated bind retries drain memory — gone with 2: the copies are freed on every return, the bind failure included.
  4. Android builds can ship an outdated page — web.c includes WEB_PAGE_H by its full path when CMake defines it; checked by building Android with a stale src/web_page.h present: the library carries the generated page, not the stale one.
  5. Device buttons stay locked — watch() ends the remote display on any finished state while one was seen running, whatever its seq; the unused seq tracking is gone.

Checked: tests/run.sh, Android assembleDebug lintDebug assembleRelease, tests/android/remote-e2e.sh on API 34 and 21: 10/10.

@compot-dev

Copy link
Copy Markdown
Collaborator Author

/review

…TF-8 password, local after remote, tunnel check message
@compot-dev

Copy link
Copy Markdown
Collaborator Author

Qodo review of 8dcf667: fixed in a7341a4.

1 / 7. Changing settings / stopping can disrupt a running operation — stopServing no longer joins with a timeout: a stopper thread calls webStop and joins the server thread fully, with the wake lock held and the status "Stopping: an operation of the page ends first…". A restart (or a start while stopping) serves again only once the old webServe has returned, so two servers never share the settings; ACTION_STOP ends the foreground service and stopSelf only after it.
6. Local results as remote work — a local state clears the remote marker and is left to the app's own call.
9. Repeated bind retries — already fixed in 8dcf667: webServe frees its copies on every return, as web_serve returns only when nothing uses them (the finding quotes the code of 9069b14).
12. Tunnel Save fails silently — the message is made visible.
13. Emoji passwords — webServe takes the password as UTF-8 bytes (byte[]), copied NUL-terminated in C; remote-e2e.sh now checks a password with an emoji through the tunnel.

Checked: tests/run.sh, Android assembleDebug lintDebug assembleRelease, tests/android/remote-e2e.sh on API 34 and 21: 11/11. Also on a TV box through a camex 4.0.0 server: the page by its nginx name (web port sent by the app), an 8 MB dump downloaded with the same md5.

@compot-dev

Copy link
Copy Markdown
Collaborator Author

/review

@compot-dev

Copy link
Copy Markdown
Collaborator Author

Qodo review of a7341a4:

  1. Android native builds fail to compile — not reproduced. CMake keeps the quotes of these definitions: compile_commands.json has -DMS_VERSION=\"1.47.2\" and -DWEB_PAGE_H=\"…/gen/web_page.h\"; CI's "Android app (APK)" passed on a7341a4, the library carries the generated page, and /api/state of the app on a TV box answers "version":"1.47.2".
  2. Device buttons stay locked after stopping remote access mid-operation — fixed in the next commit: watchRemote also polls while remoteRunning, so the final state (static native data) unlocks the screen after the service has gone.
  3. Repeated bind retries — fixed since 8dcf667 (webServe frees pw and d on every return); the finding still quotes the code of 9069b14.

Checked: Android assembleDebug lintDebug assembleRelease; tests/run.sh unchanged since a7341a4.

@compot-dev

Copy link
Copy Markdown
Collaborator Author

/review

@compot-dev
compot-dev merged commit 4f26e86 into main Nov 17, 2026
9 checks passed
@compot-dev
compot-dev deleted the microsnander-camex branch November 17, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant