Workaround handover problems

This commit is contained in:
M66B 2015-11-23 08:34:47 +01:00
parent 22f3d0766a
commit e613966d35
2 changed files with 16 additions and 4 deletions

View File

@ -66,6 +66,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/renderscript" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes-proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/debug" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
@ -75,6 +76,8 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-rules" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/release" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />

View File

@ -86,6 +86,9 @@ public class SinkholeService extends VpnService {
public void handleMessage(Message msg) {
try {
handleIntent((Intent) msg.obj);
} catch (Throwable ex) {
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
Util.sendCrashReport(ex, SinkholeService.this);
} finally {
try {
PowerManager.WakeLock wl = getLock(SinkholeService.this);
@ -116,6 +119,15 @@ public class SinkholeService extends VpnService {
// Seamless handover
ParcelFileDescriptor prev = vpn;
vpn = startVPN();
if (prev != null && vpn == null) {
Log.w(TAG, "Handover failed");
stopDebug();
stopVPN(prev);
prev = null;
vpn = startVPN();
if (vpn == null)
throw new IllegalStateException("Handover failed");
}
stopDebug();
startDebug(vpn);
if (prev != null)
@ -197,10 +209,7 @@ public class SinkholeService extends VpnService {
// Start VPN service
try {
ParcelFileDescriptor result = builder.establish();
if (result == null)
throw new IllegalStateException("VpnService.Builder.establish returned unexpectedly NULL");
return result;
return builder.establish();
} catch (Throwable ex) {
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));