mirror of https://github.com/M66B/NetGuard.git
Try to workaround handover fail
https://code.google.com/p/android/issues/detail?id=62410
This commit is contained in:
parent
e92b51643b
commit
902a0de9a0
|
@ -370,22 +370,43 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
||||||
List<Rule> listRule = Rule.getRules(true, SinkholeService.this);
|
List<Rule> listRule = Rule.getRules(true, SinkholeService.this);
|
||||||
List<Rule> listAllowed = getAllowedRules(listRule);
|
List<Rule> listAllowed = getAllowedRules(listRule);
|
||||||
|
|
||||||
// Attempt seamless handover
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||||
ParcelFileDescriptor prev = vpn;
|
if (vpn != null) {
|
||||||
vpn = startVPN(listAllowed);
|
stopNative(vpn, false);
|
||||||
if (prev != null && vpn == null) {
|
stopVPN(vpn);
|
||||||
Log.w(TAG, "Handover failed");
|
vpn = null;
|
||||||
stopVPN(prev);
|
try {
|
||||||
prev = null;
|
Thread.sleep(3000);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
vpn = startVPN(listAllowed);
|
vpn = startVPN(listAllowed);
|
||||||
if (vpn == null)
|
|
||||||
throw new IllegalStateException("Handover failed");
|
} else {
|
||||||
|
// Attempt seamless handover
|
||||||
|
ParcelFileDescriptor prev = vpn;
|
||||||
|
vpn = startVPN(listAllowed);
|
||||||
|
|
||||||
|
if (prev != null && vpn == null) {
|
||||||
|
Log.w(TAG, "Handover failed");
|
||||||
|
stopNative(prev, false);
|
||||||
|
stopVPN(prev);
|
||||||
|
prev = null;
|
||||||
|
try {
|
||||||
|
Thread.sleep(3000);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
|
vpn = startVPN(listAllowed);
|
||||||
|
if (vpn == null)
|
||||||
|
throw new IllegalStateException("Handover failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prev != null) {
|
||||||
|
stopNative(prev, false);
|
||||||
|
stopVPN(prev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev != null) {
|
|
||||||
stopNative(prev, false);
|
|
||||||
stopVPN(prev);
|
|
||||||
}
|
|
||||||
if (vpn == null)
|
if (vpn == null)
|
||||||
throw new IllegalStateException("VPN start failed");
|
throw new IllegalStateException("VPN start failed");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue