Fix solution for launching the service on pre-8.0 devices.#29
Fix solution for launching the service on pre-8.0 devices.#29w3rkzeug wants to merge 1 commit intoWireGuard:masterfrom
Conversation
|
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 |
|
Oh , I embedded the library |
|
btw this may occur when calling from |
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. |
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 |
Well at this point the best option (tested) would be to create a trampoline foreground service to trigger from |
|
|
Failed to resolve: com.wireguard.android:tunnel:1.0.20220516 |
Failed to resolve: com.wireguard.android:tunnel:1.0.20220516 |
| Log.d(TAG, "Requesting to start VpnService"); | ||
| context.startService(new Intent(context, VpnService.class)); | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| context.startForegroundService(new Intent(context, VpnService.class)); |
There was a problem hiding this comment.
If you are starting the service as a foreground service, you should accompany it with a notification.
Also, according to the guidelines, it is okay to start the VPN service as a background service, but you must promote it to foreground by showing the notification using the Service#setForeground method.
https://developer.android.com/guide/topics/connectivity/vpn#starting_a_service
Thoughts?
581ab92 to
ec126a9
Compare
b2568c4 to
b1324e2
Compare
ab02c51 to
44a2603
Compare
5020d17 to
d016aef
Compare
c046706 to
40eaa54
Compare
In my opinion, it would be better to start a VPN Service as a foreground one, but I've seen(WireGuard#29) that you don't want additional permissions that come with it.
In my opinion, it would be better to start a VPN Service as a foreground one, but I've seen(WireGuard#29) that you don't want additional permissions that come with it. Signed-off-by: Alexander Perfilyev <alexander.perfilyev@gmail.com>
827495b to
4ba8794
Compare
c1d59a2 to
6aab7cc
Compare
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