Question

I know that VpnService is-a Service and that stopSelf() works to stop the service itself (at least it seems to since onDestroy() is called).

The issue is that the notification at the top (which appears once VpnService.Builder.establish() is called ) does not clear itself when I call stopSelf() in my service instance.

Also, I've noticed that the VPN settings (connection, routes, nameservers) stay in tact while that notification remains, thus there is a disconnect between Android and the VpnService.

Can anyone help me programmatically cancel the VPN ?

Était-ce utile?

La solution

After a bunch of testing, it appears that if the FD in the ParcelFileDescriptor returned by VpnService.Builder.establish() is closed, then the notification is cleared.

Therefore, on the native side, if you close all references to the FD, the notification will clear. Be sure to ACTUALLY call close() on the FD.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top