fix: airplane mode bug
This commit is contained in:
parent
16e65aec9f
commit
515e91d191
|
@ -245,36 +245,48 @@ class WireGuardConnectivityWatcherService : ForegroundService() {
|
||||||
|
|
||||||
private suspend fun manageVpn() {
|
private suspend fun manageVpn() {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (isEthernetConnected && setting.isTunnelOnEthernetEnabled && vpnService.getState() == Tunnel.State.DOWN) {
|
when {
|
||||||
|
((isEthernetConnected &&
|
||||||
|
setting.isTunnelOnEthernetEnabled &&
|
||||||
|
vpnService.getState() == Tunnel.State.DOWN)) ->
|
||||||
ServiceManager.startVpnService(this, tunnelConfig)
|
ServiceManager.startVpnService(this, tunnelConfig)
|
||||||
}
|
|
||||||
if (!isEthernetConnected && setting.isTunnelOnMobileDataEnabled &&
|
(!isEthernetConnected &&
|
||||||
|
setting.isTunnelOnMobileDataEnabled &&
|
||||||
!isWifiConnected &&
|
!isWifiConnected &&
|
||||||
isMobileDataConnected
|
isMobileDataConnected &&
|
||||||
&& vpnService.getState() == Tunnel.State.DOWN
|
vpnService.getState() == Tunnel.State.DOWN) ->
|
||||||
) {
|
|
||||||
ServiceManager.startVpnService(this, tunnelConfig)
|
ServiceManager.startVpnService(this, tunnelConfig)
|
||||||
} else if (!isEthernetConnected && !setting.isTunnelOnMobileDataEnabled &&
|
|
||||||
|
(!isEthernetConnected &&
|
||||||
|
!setting.isTunnelOnMobileDataEnabled &&
|
||||||
!isWifiConnected &&
|
!isWifiConnected &&
|
||||||
vpnService.getState() == Tunnel.State.UP
|
vpnService.getState() == Tunnel.State.UP) ->
|
||||||
) {
|
|
||||||
ServiceManager.stopVpnService(this)
|
ServiceManager.stopVpnService(this)
|
||||||
} else if (!isEthernetConnected && isWifiConnected &&
|
|
||||||
|
(!isEthernetConnected && isWifiConnected &&
|
||||||
!setting.trustedNetworkSSIDs.contains(currentNetworkSSID) &&
|
!setting.trustedNetworkSSIDs.contains(currentNetworkSSID) &&
|
||||||
setting.isTunnelOnWifiEnabled &&
|
setting.isTunnelOnWifiEnabled &&
|
||||||
(vpnService.getState() != Tunnel.State.UP)
|
(vpnService.getState() != Tunnel.State.UP)) ->
|
||||||
) {
|
|
||||||
ServiceManager.startVpnService(this, tunnelConfig)
|
ServiceManager.startVpnService(this, tunnelConfig)
|
||||||
} else if (!isEthernetConnected && (isWifiConnected &&
|
|
||||||
|
(!isEthernetConnected && (isWifiConnected &&
|
||||||
setting.trustedNetworkSSIDs.contains(currentNetworkSSID)) &&
|
setting.trustedNetworkSSIDs.contains(currentNetworkSSID)) &&
|
||||||
(vpnService.getState() == Tunnel.State.UP)
|
(vpnService.getState() == Tunnel.State.UP)) ->
|
||||||
) {
|
|
||||||
ServiceManager.stopVpnService(this)
|
ServiceManager.stopVpnService(this)
|
||||||
} else if (!isEthernetConnected && (isWifiConnected &&
|
|
||||||
|
(!isEthernetConnected && (isWifiConnected &&
|
||||||
!setting.isTunnelOnWifiEnabled &&
|
!setting.isTunnelOnWifiEnabled &&
|
||||||
(vpnService.getState() == Tunnel.State.UP)
|
(vpnService.getState() == Tunnel.State.UP))) ->
|
||||||
)) {
|
|
||||||
ServiceManager.stopVpnService(this)
|
ServiceManager.stopVpnService(this)
|
||||||
|
|
||||||
|
(!isEthernetConnected && !isWifiConnected &&
|
||||||
|
!isMobileDataConnected &&
|
||||||
|
(vpnService.getState() == Tunnel.State.UP)) ->
|
||||||
|
ServiceManager.stopVpnService(this)
|
||||||
|
else -> {
|
||||||
|
Timber.d("Unknown case")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
delay(Constants.VPN_CONNECTIVITY_CHECK_INTERVAL)
|
delay(Constants.VPN_CONNECTIVITY_CHECK_INTERVAL)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue