wireguard-android
wireguard-android copied to clipboard
Fix solution for launching the service on pre-8.0 devices.
Fix for the following error that occurs when launching the service from background (onBoot f.e.):
E/WireGuard/TunnelManager: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=com.tun.android.debug/com.wireguard.android.backend.GoBackend$VpnService }: app is in background
When are you encountering this? We already ship a trampoline activity that is launched by the QS tile to bring the app to the foreground before the GoBackend
code path is hit.
Oh , I embedded the library implementation 'com.wireguard.android:tunnel:1.0.20210211'
version, applied the fix & it worked tho.
btw this may occur when calling from BootShutdownReceiver -> tunnelManager.restoreState(true)
,followed by this https://github.com/WireGuard/wireguard-android/blob/master/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.kt
Oh , I embedded the library
implementation 'com.wireguard.android:tunnel:$wireguardTunnelVersion'
version, applied the fix & it worked tho.
Ah, I see. The problem with launching a foreground service is that it requires a persistent notification as well as an additional permission. My personal recommendation would be to replicate the trampoline workaround that we use in the WireGuard app for user-initiated triggers and relying on the Android platform's always-on VPN option for starting up right after boot.
btw this may occur when calling from
BootShutdownReceiver -> tunnelManager.restoreState(true)
,followed by thishttps://github.com/WireGuard/wireguard-android/blob/master/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.kt
Yeah I guessed as much. I will look into fixing this separately. In the meantime can you please force push your commit with your real name as author and a Signed-off-by
line? That'll make my life easier in case I end up merging your patch.
Oh , I embedded the library
implementation 'com.wireguard.android:tunnel:$wireguardTunnelVersion'
version, applied the fix & it worked tho.Ah, I see. The problem with launching a foreground service is that it requires a persistent notification as well as an additional permission. My personal recommendation would be to replicate the trampoline workaround that we use in the WireGuard app for user-initiated triggers and relying on the Android platform's always-on VPN option for starting up right after boot.
Well at this point the best option (tested) would be to create a trampoline foreground service to trigger from BootShutdownReceiver
on ACTION_BOOT_COMPLETED
:)
Anyway Thanks
implementation 'com.wireguard.android:tunnel:1.0.20220516' not on mavent 有没有谁知道,解决方案是什么
Failed to resolve: com.wireguard.android:tunnel:1.0.20220516
btw this may occur when calling from
BootShutdownReceiver -> tunnelManager.restoreState(true)
,followed by thishttps://github.com/WireGuard/wireguard-android/blob/master/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.kt
Yeah I guessed as much. I will look into fixing this separately. In the meantime can you please force push your commit with your real name as author and a
Signed-off-by
line? That'll make my life easier in case I end up merging your patch.
Failed to resolve: com.wireguard.android:tunnel:1.0.20220516