Skip to content

fix: camex 4.4.1, the tunnel no longer takes the VPN from another app by itself (2.27.4) - #297

Merged
compot-dev merged 2 commits into
v2from
fix/camex-4.4.0-296
Nov 21, 2026
Merged

compot-dev merged 2 commits into
v2from
fix/camex-4.4.0-296

Conversation

@compot-dev

Copy link
Copy Markdown
Collaborator

Closes #296.

camex 4.4.0/4.4.1 (OpenIPC/camex#197, #200): VpnService.prepare() of an app with the consent takes the device's one VPN at once, so Decoder's own starts of the tunnel took it from vectis, microsnander or the camex app.

  • bundles/camex → 7a8834e (4.4.1; 4.4.0's getOwnerUid() on Android 10 failed lint with NewApi and is fixed there).
  • NetworkPanel: the app's start and the restart for a new web page port use startWhenFree(); Save with Join on keeps start(). At the app's start consentIntent() is called only when otherVpnActive() is false (the first set-up on Android 5.0 still shows the dialog).
  • WAITING: "Waiting for the VPN: another app holds it; Save takes it" in Settings, waiting in /stats.json (docs/debug.md) and on the web page's board.
  • tests/e2e.sh: the tunnel's address on any tun*: the library keeps the old TUN until the new one is up, so a restarted tunnel is on tun1 (the restart check failed, and the after-update "no tunnel" check looked only at tun0).
  • README (en/ru/zh-CN), CHANGELOG 2.27.4.

Checked locally in compot/android:2026.10: testDebugUnitTest lintDebug assembleDebug (13 lint warnings, as in the baseline), .github/check-version.sh, TRANSPORT=TCP tests/e2e.sh API 21 and 34: 20/20 each.

… by itself (2.27.4)

The app's start and the restart for a new web page port use startWhenFree():
while another app's VPN is up the tunnel waits (WAITING in Settings, in
/stats.json and on the web page) and connects when that VPN ends. The consent
is asked at the app's start only when no other app's VPN is up, since with the
consent given consentIntent() takes the VPN. Save with Join on keeps start().

e2e: the tunnel's interface is any tun*, not tun0: camex 4.4.0 keeps the old
TUN until the new one is up, so a restarted tunnel is on tun1.

Closes #296
@qodo-free-for-open-source-projects

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

Copy link
Copy Markdown

PR Summary by Qodo

Wait for other apps’ VPNs before automatically starting the camex tunnel

🐞 Bug fix 🧪 Tests 📝 Documentation ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Prevent automatic tunnel starts and web-port restarts from taking another app’s VPN; Save still
 connects immediately.
• Show the waiting state in Settings, /stats.json, and the web board.
• Upgrade to camex 4.4.1 and make end-to-end checks recognize any tun* interface.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The camera traffic and Decoder debug-page traffic are two surfaces of the same bounded camex tunnel integration: NetworkPanel supplies the tunnel lifecycle and page port, the camex library owns the VPN transport, and downstream camera/debug consumers use the resulting tunnel.
  • They are not independent functional scopes merely because they cross Java, native-library, and server boundaries.
  • The debug page's changed waiting status is a presentation of this same tunnel lifecycle, supported by ev-status-consumer.
Behavioral complexity 🔴 High 🧩 Interacting branches, Concurrent ordering

  • Before: automatic startup and automatic page-port restart directly called the tunnel start path, while explicit Save also started it; there was no application-level WAITING branch in these callers.
  • After: automatic paths call startWhenFree, skip when already WAITING, distinguish explicit Save from startup, retry after a port change, and conditionally invoke consent handling; the UI and stats consumers add a WAITING representation.
  • New correctness condition: an automatic start/restart must atomically observe Android's single-VPN ownership and either preserve the other app's VPN while establishing a recoverable WAITING state or acquire Decoder's VPN only after release, while explicit Save retains takeover semantics.
  • A second condition is that a page-port-triggered restart must not lose the tunnel or race with another VPN owner.
  • These are newly interacting lifecycle and ordering states, not complexity inherited merely from using an existing tunnel helper.
Sources

bundles/camex[1-1]

Subproject commit 7a8834e3a37823798c066e5168af0209868cbcad
Potential damage 🟡 Medium 🩹 Recoverable

  • Within the affected capability, the concrete failure is temporary loss or interruption of camera and/or debug-page access through the tunnel, or temporary disruption of another app's VPN if ownership arbitration is wrong.
  • Reverting the APK restores the prior lifecycle code but does not necessarily restore a VPN already displaced or a tunnel already left in a stale waiting/failed state; the affected app may need to release/restart its VPN or the user may need to press Save/restart Decoder.
  • No changed code shown here writes persistent camera data or makes an irreversible external financial or data-integrity change.
  • This supports recoverable degradation rather than a serious or irreversible consequence.
  • Usually recoverable by the other VPN ending, a subsequent eligible start/retry, pressing Save with Join enabled, or restarting the affected app/VPN.
  • Automatic recovery is only a supported hypothesis until the camex worker/scheduler and its retry/cleanup implementation are inspected; code rollback alone may not repair an already displaced VPN or stale runtime state.
Assessed commit 6e378f5
Diagram

graph TD
  Auto["Automatic triggers"] --> Check{"Other VPN active?"} -->|Yes| Wait["Wait until free"] -->|Released| Tunnel["Camex tunnel"] --> Status["Status views"]
  Check -->|No| Consent["VPN consent"] --> Tunnel
  Save["User saves Join"] --> Consent
  Wait --> Status
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Defer every automatic start without checking VPN ownership
  • ➕ Simpler app-side startup path.
  • ➖ Would skip the first-time VPN consent prompt needed during Android 5.0 setup.
2. Manage VPN availability entirely in Decoder
  • ➕ Keeps waiting policy under application control.
  • ➖ Duplicates camex’s waiting behavior and adds Android-version-specific VPN lifecycle handling.

Recommendation: Keep the PR’s ownership check and camex-managed waiting: it preserves first-time consent when the VPN is free, avoids automatic takeover when it is not, and leaves explicit Save behavior intact.

Files changed (10) +50 / -18

Bug fix (2) +25 / -6
DebugServer.javaDisplay VPN waiting on the web board +2/-1

Display VPN waiting on the web board

• Adds a readable message for the camex 'waiting' state to the debug page’s status board.

android/app/src/main/java/com/openipc/decoder/DebugServer.java

NetworkPanel.javaMake automatic tunnel starts wait for VPN availability +23/-5

Make automatic tunnel starts wait for VPN availability

• Checks for another app’s VPN before requesting consent on app startup, and uses 'startWhenFree()' for automatic starts and web-port restarts. Explicit Save retains 'start()', while Settings gains a waiting-state explanation.

android/app/src/main/java/com/openipc/decoder/NetworkPanel.java

Tests (1) +9 / -5
e2e.shFind tunnel addresses across all tun interfaces +9/-5

Find tunnel addresses across all tun interfaces

• Introduces a helper that finds an address on any 'tun*' interface and uses it for startup, restart, port-change, and post-update checks. This accommodates camex keeping the old TUN while bringing up its replacement.

tests/e2e.sh

Documentation (5) +13 / -4
CHANGELOG.mdDocument the 2.27.4 VPN ownership fix +9/-0

Document the 2.27.4 VPN ownership fix

• Adds release notes explaining when the tunnel waits for another app’s VPN and when Save takes it immediately.

CHANGELOG.md

README.mdExplain waiting behavior in the English network guide +1/-1

Explain waiting behavior in the English network guide

• Updates the camex version to 4.4.1 and describes the waiting state and the distinction between automatic startup and Save.

README.md

README.ru.mdExplain waiting behavior in the Russian network guide +1/-1

Explain waiting behavior in the Russian network guide

• Updates the camex version and documents VPN waiting and explicit Save behavior in Russian.

README.ru.md

README.zh-CN.mdExplain waiting behavior in the Chinese network guide +1/-1

Explain waiting behavior in the Chinese network guide

• Updates the camex version and documents VPN waiting and explicit Save behavior in Simplified Chinese.

README.zh-CN.md

debug.mdDocument the waiting stats state +1/-1

Document the waiting stats state

• Adds 'waiting' to the documented camex states returned by '/stats.json'.

docs/debug.md

Other (2) +3 / -3
build.gradleBump Android release version to 2.27.4 +2/-2

Bump Android release version to 2.27.4

• Increments the Android version code from 66 to 67 and version name from 2.27.3 to 2.27.4.

android/app/build.gradle

camexAdvance the camex submodule to 4.4.1 +1/-1

Advance the camex submodule to 4.4.1

• Moves the camex submodule from '0c3e7cb' to '7a8834e', supplying the VPN availability and waiting behavior used by Decoder.

bundles/camex

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

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Auto-start can still seize another VPN ✓ Resolved
Description
autoStart() calls otherVpnActive() and then calls connect(a, false) when the check returns
false, but connect() calls consentIntent(), which can immediately take the VPN when consent was
previously granted. If another app activates its VPN between the check and that call, Decoder's
automatic startup takes it despite using startWhenFree() for the later tunnel start.

Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

…in one call (Qodo on #297)

autoStart() checked otherVpnActive() and then called consentIntent(), which takes
the VPN when the consent is there: another app's VPN coming up in between was
taken. It calls startWhenFree() now; only NEEDS_CONSENT (no consent, so nothing
can be taken) shows the system dialog, once per start of the app.
@compot-dev

Copy link
Copy Markdown
Collaborator Author

Qodo finding 1 (auto-start can still seize another VPN): fixed in 6e378f5. autoStart() no longer checks otherVpnActive() and then calls consentIntent(); it calls startWhenFree(), which checks and starts in one call in the library. Only when that ends in NEEDS_CONSENT (no consent, so prepare() takes nothing) is the system dialog shown, once per start of the app. Re-checked: testDebugUnitTest lintDebug assembleDebug, TRANSPORT=TCP tests/e2e.sh API 21 and 34: 20/20 each.

@compot-dev
compot-dev merged commit 76197ed into v2 Nov 21, 2026
7 checks passed
@compot-dev
compot-dev deleted the fix/camex-4.4.0-296 branch November 21, 2026 00:31
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.

camex 4.4.0: the tunnel does not take the VPN from another app by itself

1 participant