From 150488dd9c04594cc646e38e728a16659683e6aa Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Thu, 2 Apr 2015 23:11:04 -0400 Subject: [PATCH] fixes for onboot logic and handling --- AndroidManifest.xml | 16 +++++- .../android/service/OnBootReceiver.java | 7 +-- .../android/vpn/OrbotVpnService.java | 51 +++++++++---------- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 2dd7d1c3..18e13c35 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -17,6 +17,7 @@ + - org.torproject.android.ui.wizard.ChooseLocaleWizardActivityui.ChooseLocaleWizardActivity" android:exported="false"/> + + @@ -105,11 +107,21 @@ - + + + + + + + + diff --git a/src/org/torproject/android/service/OnBootReceiver.java b/src/org/torproject/android/service/OnBootReceiver.java index 340bfabc..9ed66aec 100644 --- a/src/org/torproject/android/service/OnBootReceiver.java +++ b/src/org/torproject/android/service/OnBootReceiver.java @@ -20,12 +20,13 @@ public class OnBootReceiver extends BroadcastReceiver { if (startOnBoot) { - if (useVPN) - startVpnService(context); startService(TorServiceConstants.CMD_INIT,context); startService(TorServiceConstants.CMD_START,context); - + + if (useVPN) + startVpnService(context); + } } diff --git a/src/org/torproject/android/vpn/OrbotVpnService.java b/src/org/torproject/android/vpn/OrbotVpnService.java index 93a4d0ad..ec841cb9 100644 --- a/src/org/torproject/android/vpn/OrbotVpnService.java +++ b/src/org/torproject/android/vpn/OrbotVpnService.java @@ -28,8 +28,11 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.net.VpnService; import android.os.Build; import android.os.Handler; +import android.os.IBinder; import android.os.Message; +import android.os.Parcel; import android.os.ParcelFileDescriptor; +import android.os.RemoteException; import android.util.Log; import android.widget.Toast; @@ -37,6 +40,7 @@ import com.runjva.sourceforge.jsocks.protocol.ProxyServer; import com.runjva.sourceforge.jsocks.server.ServerAuthenticatorNone; @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) + public class OrbotVpnService extends VpnService implements Handler.Callback { private static final String TAG = "OrbotVpnService"; @@ -217,37 +221,32 @@ public class OrbotVpnService extends VpnService implements Handler.Callback { } - + @Override public void onRevoke() { - - new Thread () + + try { - public void run() + Log.d(TAG,"closing interface, destroying VPN interface"); + + //Tun2Socks.Stop(); + + if (mInterface != null) { - try - { - Log.d(TAG,"closing interface, destroying VPN interface"); - - //Tun2Socks.Stop(); - - if (mInterface != null) - { - mInterface.close(); - mInterface = null; - } - - } - catch (Exception e) - { - Log.d(TAG,"error stopping tun2socks",e); - } - catch (Error e) - { - Log.d(TAG,"error stopping tun2socks",e); - } + mInterface.close(); + mInterface = null; } - }.start(); + + } + catch (Exception e) + { + Log.d(TAG,"error stopping tun2socks",e); + } + catch (Error e) + { + Log.d(TAG,"error stopping tun2socks",e); + } + super.onRevoke(); }