Fix Android 11 notification action not clickable#793
Conversation
… for all Workers, thus fixing intent handling on Android 11 and older Fixes tailscale/tailscale#19772 Signed-off-by: Pawloland <59684145+Pawloland@users.noreply.github.com>
|
I tested the intents with bellow adb commands. It works as expected on Android 11 now. I also added guards inside, so workers are triggered only when the actual state changes. Otherwise the temporary notification which is always sent by the system on older Androids, when expedited worker request is run, would replace the normal status notification, the one with the connect/disconnect button. Since the state would not change, the rerender of the default notification would not be triggered, but the temporary one would be, and it would be shown until the VPN is connected again, triggering the change in prefs and rerender of the default notification. This fixed the issue which made it apparent to me - non clickable connect/disconnect button in the notification, but it fundamentally fixes intent handling on older APIs, so 3rd party apps integrations on those. |
…smissible on Android 11 and older when triggering USE_EXIT_NODE intent Signed-off-by: Pawloland <59684145+Pawloland@users.noreply.github.com>
|
@kari-ts Should be ready to merge. The second commit also fixed the bellow warnings: |
|
@kari-ts I hate to be that guy, but is there any hope of merging it? |
|
@barnstar, can it be merged? |
There was a problem hiding this comment.
Pull request overview
This PR addresses Android 11 and older behavior for expedited WorkRequests triggered by notification actions by adding getForegroundInfo() implementations to the Workers involved, so WorkManager can run them as foreground work without throwing and breaking intent handling.
Changes:
- Add
getForegroundInfo()toStartVPNWorker,StopVPNWorker, andUseExitNodeWorkerwith minimal “status” notifications. - Add new string resources for “Starting…”, “Stopping…”, and “Changing exit node…” notification titles (and update the About footer year).
- Add receiver-side short-circuiting to avoid enqueuing work that would overwrite the status notification when the requested state appears unchanged.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| android/src/main/res/values/strings.xml | Adds notification-title strings used for Worker foreground notifications; minor formatting/year update. |
| android/src/main/java/com/tailscale/ipn/UseExitNodeWorker.kt | Refactors exit-node preference update flow and adds getForegroundInfo() for expedited work compatibility. |
| android/src/main/java/com/tailscale/ipn/StopVPNWorker.java | Adds getForegroundInfo() so expedited stop work can run on Android 11 and older. |
| android/src/main/java/com/tailscale/ipn/StartVPNWorker.java | Adds getForegroundInfo() so expedited start work can run on Android 11 and older. |
| android/src/main/java/com/tailscale/ipn/IPNReceiver.java | Adds “skip enqueuing” checks for disconnect/exit-node actions to reduce notification churn. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!app.isAbleToStartVPN()) { | ||
| return Result.failure( | ||
| Data.Builder().putString( | ||
| ERROR_KEY, app.getString(R.string.vpn_is_not_ready_to_start) | ||
| ).build() | ||
| ) | ||
| } | ||
|
|
||
| val netmap = Notifier.netmap.value ?: return Result.failure( | ||
| Data.Builder().putString( | ||
| ERROR_KEY, app.getString(R.string.tailscale_is_not_setup) | ||
| ).build() | ||
| ) |
Fix expedited WorkRequests by implementing getForegroundInfo() method for all Workers, thus fixing intent handling on Android 11 and older.
Fixes tailscale/tailscale#19772