fixes for onboot logic and handling

This commit is contained in:
Nathan Freitas 2015-04-02 23:11:04 -04:00
parent 8c5b38eeea
commit 150488dd9c
3 changed files with 43 additions and 31 deletions

View File

@ -18,6 +18,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:name="org.torproject.android.OrbotApp" android:icon="@drawable/ic_launcher" <application android:name="org.torproject.android.OrbotApp" android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:description="@string/app_description" android:description="@string/app_description"
@ -89,7 +90,8 @@
<activity android:name="org.torproject.android.ui.wizard.PromoAppsActivity" android:exported="false"/> <activity android:name="org.torproject.android.ui.wizard.PromoAppsActivity" android:exported="false"/>
org.torproject.android.ui.wizard.ChooseLocaleWizardActivityui.ChooseLocaleWizardActivity" android:exported="false"/> <activity android:name="org.torproject.android.ui.wizard.ChooseLocaleWizardActivity" android:exported="false"/>
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/> <activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/>
<activity android:name=".settings.AppManager" android:label="@string/app_name"/> <activity android:name=".settings.AppManager" android:label="@string/app_name"/>
@ -105,11 +107,21 @@
</intent-filter> </intent-filter>
</service> </service>
<receiver android:name="org.torproject.android.service.OnBootReceiver"> <receiver android:name="org.torproject.android.service.OnBootReceiver"
android:enabled="true" android:exported="true"
>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.QUICKBOOT_POWERON" /> <action android:name="android.intent.action.QUICKBOOT_POWERON" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MEDIA_MOUNTED"/> <action android:name="android.intent.action.MEDIA_MOUNTED"/>
<category android:name="android.intent.category.HOME" />
</intent-filter> </intent-filter>
</receiver> </receiver>

View File

@ -20,12 +20,13 @@ public class OnBootReceiver extends BroadcastReceiver {
if (startOnBoot) if (startOnBoot)
{ {
if (useVPN)
startVpnService(context);
startService(TorServiceConstants.CMD_INIT,context); startService(TorServiceConstants.CMD_INIT,context);
startService(TorServiceConstants.CMD_START,context); startService(TorServiceConstants.CMD_START,context);
if (useVPN)
startVpnService(context);
} }
} }

View File

@ -28,8 +28,11 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.net.VpnService; import android.net.VpnService;
import android.os.Build; import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder;
import android.os.Message; import android.os.Message;
import android.os.Parcel;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
@ -37,6 +40,7 @@ import com.runjva.sourceforge.jsocks.protocol.ProxyServer;
import com.runjva.sourceforge.jsocks.server.ServerAuthenticatorNone; import com.runjva.sourceforge.jsocks.server.ServerAuthenticatorNone;
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public class OrbotVpnService extends VpnService implements Handler.Callback { public class OrbotVpnService extends VpnService implements Handler.Callback {
private static final String TAG = "OrbotVpnService"; private static final String TAG = "OrbotVpnService";
@ -221,10 +225,6 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
@Override @Override
public void onRevoke() { public void onRevoke() {
new Thread ()
{
public void run()
{
try try
{ {
Log.d(TAG,"closing interface, destroying VPN interface"); Log.d(TAG,"closing interface, destroying VPN interface");
@ -246,8 +246,7 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
{ {
Log.d(TAG,"error stopping tun2socks",e); Log.d(TAG,"error stopping tun2socks",e);
} }
}
}.start();
super.onRevoke(); super.onRevoke();
} }