mirror of
https://github.com/yggdrasil-network/crispa-android.git
synced 2025-01-22 07:56:30 +00:00
1. Added vpn state fix
This commit is contained in:
parent
e73b6c8814
commit
394a0a9177
@ -148,16 +148,20 @@ class MainActivity : AppCompatActivity() {
|
|||||||
connectivityManager?.let {
|
connectivityManager?.let {
|
||||||
it.registerDefaultNetworkCallback(object : ConnectivityManager.NetworkCallback() {
|
it.registerDefaultNetworkCallback(object : ConnectivityManager.NetworkCallback() {
|
||||||
override fun onAvailable(network: Network) {
|
override fun onAvailable(network: Network) {
|
||||||
showToast("network on")
|
if(isStarted) {
|
||||||
stopVpn()
|
showToast("network on")
|
||||||
Thread.sleep(1000)
|
stopVpn()
|
||||||
startVpn()
|
Thread.sleep(1000)
|
||||||
|
startVpn()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
override fun onLost(network: Network?) {
|
override fun onLost(network: Network?) {
|
||||||
showToast("network off")
|
if(isStarted) {
|
||||||
stopVpn()
|
showToast("network off")
|
||||||
Thread.sleep(1000)
|
stopVpn()
|
||||||
startVpn()
|
Thread.sleep(1000)
|
||||||
|
startVpn()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -168,11 +172,19 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Log.i(TAG, "Network state has been changed")
|
Log.i(TAG, "Network state has been changed")
|
||||||
if ("android.net.conn.CONNECTIVITY_CHANGE" == intent.action) {
|
if ("android.net.conn.CONNECTIVITY_CHANGE" == intent.action) {
|
||||||
if (status == NetworkUtils.NETWORK_STATUS_NOT_CONNECTED) {
|
if (status == NetworkUtils.NETWORK_STATUS_NOT_CONNECTED) {
|
||||||
showToast("network on")
|
if(isStarted) {
|
||||||
stopVpn()
|
showToast("network on")
|
||||||
|
stopVpn()
|
||||||
|
Thread.sleep(1000)
|
||||||
|
startVpn()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
showToast("network of")
|
if(isStarted) {
|
||||||
startVpn()
|
showToast("network off")
|
||||||
|
stopVpn()
|
||||||
|
Thread.sleep(1000)
|
||||||
|
startVpn()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user