android: add launcher shortcuts to connect and disconnect the VPN#810
android: add launcher shortcuts to connect and disconnect the VPN#810brettjenkins wants to merge 2 commits into
Conversation
Add an AutomationActivity trampoline and two static launcher shortcuts (Connect, Disconnect) wired to the existing CONNECT_VPN / DISCONNECT_VPN intents. The actions can also be invoked from Samsung Modes and Routines or Tasker. The activity exists because starting an activity reliably wakes an app that the OS has force-stopped or deep-slept (e.g. Samsung battery management) and lets connect start the foreground VPN service, whereas the broadcast/Worker path is unreliable from that state. Exit-node automation is unchanged and remains available via the existing IPNReceiver USE_EXIT_NODE broadcast once the VPN is connected. Updates tailscale/tailscale#10831 Updates tailscale/tailscale#14148 Updates tailscale/tailscale#13623 Updates tailscale/tailscale#18847 Updates tailscale/tailscale#9531 Updates tailscale/tailscale#9497 Updates tailscale/tailscale#16415 Updates tailscale/tailscale#17855 Updates tailscale/tailscale#17738 Signed-off-by: Brett Jenkins <brett@brettjenkins.co.uk>
A localAPI request issued from a cold-started process (e.g. UseExitNodeWorker, kicked off by IPNReceiver) reads Request's lateinit `app` before the backend has been initialized, crashing the process with UninitializedPropertyAccessException. Resolve the app lazily via App.get() in execute(), matching the lazy init that Client already uses. Signed-off-by: Brett Jenkins <brett@brettjenkins.co.uk>
d0259c1 to
469e51a
Compare
…ainium (#7) - README.md: add a banner so the GitHub landing page makes clear this is an auto-updated fork, pointing at README-FORK.md. - README-FORK.md: add an explicit 'Included patches' table (app-shortcuts -> upstream PR tailscale#810) and step-by-step Obtainium install instructions.
|
Thanks @brettjenkins , hope they approve and merge it soon. This is much needed. Thanks again. |
|
I definitely want to +1 the urgency on this. I haven't looked too heavily at the code, but the workarounds to use the intent method causes some very irritating side-effects on all the devices I manage using this. As long as there isn't a security hole opened by this, it would be a much needed relief for administrators like myself. |
|
+1 — would love to see this merged. Just looked into automating Tailscale connect/disconnect via Samsung Routines/Automate on a Galaxy S25 and ran into exactly the problem this PR describes. Native shortcut support like this would remove the need for third-party automation apps entirely — hope the second review comes through soon. |
Summary
Adds two static launcher shortcuts — Connect and Disconnect — backed by a transparent, no-UI
AutomationActivitytrampoline on the existingCONNECT_VPN/DISCONNECT_VPNintents. The actions can also be invoked from Samsung Modes & Routines and Tasker (Send Intent → Activity).Why an activity rather than the existing broadcast
I wrote the original
IPNReceiverbroadcast support, and it worked reliably when it landed. Over successive Android releases the background-execution and power-saving restrictions have tightened (Doze, app standby, and OEM battery managers like Samsung's deep sleep), and the broadcast path has become unreliable at waking an app that's been stopped or slept — it often can't start the foreground VPN service from that state.Starting an activity avoids this: it wakes the app and lets connect start the foreground VPN service. The existing broadcast actions are unchanged.
On-device validation
On a Galaxy S25 (SM-S948B, Android 16), with Tailscale put into deep sleep (hibernated + background-execution denied + restricted standby bucket + force-stopped) and triggered by real Tasker intents:
IPNReceiver: failed to connectAutomationActivity: connected — both screen-on and screen-offNotes for reviewers
IPNReceiver. This adds an activity entry point for the reliable foreground-wake path, not new capability.IPNReceiverUSE_EXIT_NODEbroadcast once connected.Related issues
Implements the launcher-shortcut / automation requests in tailscale/tailscale#9531, tailscale/tailscale#9497, tailscale/tailscale#16415, tailscale/tailscale#17855, and tailscale/tailscale#17738, and improves the broadcast-intent reliability reported in tailscale/tailscale#10831, tailscale/tailscale#14148, tailscale/tailscale#13623, and tailscale/tailscale#18847.
Also fixes a cold-start crash
Found while testing the shortcuts against a force-stopped app. A localAPI call from a cold process (e.g.
UseExitNodeWorker, started byIPNReceiver) readsRequest'slateinit appbefore the backend is initialized, so it crashes withUninitializedPropertyAccessException.execute()now resolves the app lazily viaApp.get(), the same wayClientalready does.