summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xapp/ovpnlibs/assets/minivpn.mipsbin5164 -> 5164 bytes
-rw-r--r--app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java2
-rw-r--r--app/src/main/AndroidManifest.xml13
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java32
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EIP.java9
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java32
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java24
-rw-r--r--app/src/main/java/se/leap/openvpn/OpenVpnService.java37
-rw-r--r--app/src/main/java/se/leap/openvpn/ProfileManager.java3
9 files changed, 117 insertions, 35 deletions
diff --git a/app/ovpnlibs/assets/minivpn.mips b/app/ovpnlibs/assets/minivpn.mips
index 59a031ba..6c8a3f5e 100755
--- a/app/ovpnlibs/assets/minivpn.mips
+++ b/app/ovpnlibs/assets/minivpn.mips
Binary files differ
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
index fb63b47a..cf013f3a 100644
--- a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -81,7 +81,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
final public static String TAG = "se.leap.bitmaskclient.ConfigurationWizard";
final public static String TYPE_OF_CERTIFICATE = "type_of_certificate";
final public static String ANON_CERTIFICATE = "anon_certificate";
- final public static String AUTHED_CERTIFICATE = "authed_certificate";
+ final public static String AUTHED_CERTIFICATE = "authed_certificate";
final protected static String PROVIDER_SET = "PROVIDER SET";
final protected static String SERVICES_RETRIEVED = "SERVICES RETRIEVED";
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b2366b82..0d23b069 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -22,7 +22,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
-
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- <uses-permission android:name="com.android.vending.BILLING" /> -->
<uses-sdk
@@ -43,7 +43,16 @@
</intent-filter>
</service>
<service android:name="se.leap.bitmaskclient.ProviderAPI" android:enabled="true"/>
-
+
+ <receiver
+ android:name="se.leap.bitmaskclient.OnBootReceiver"
+ android:enabled="true"
+ android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
+ </intent-filter>
+ </receiver>
+
<activity
android:name="se.leap.openvpn.LaunchVPN"
android:label="@string/vpn_launch_title" >
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index 292434c7..3c17ebb8 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -57,7 +57,11 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
final public static String SHARED_PREFERENCES = "LEAPPreferences";
final public static String ACTION_QUIT = "quit";
- public static final String REQUEST_CODE = "request_code";
+ public static final String REQUEST_CODE = "request_code";
+ public static final String PARAMETERS = "dashboard parameters";
+ public static final String START_ON_BOOT = "dashboard start on boot";
+ final public static String ON_BOOT = "dashboard on boot";
+
private ProgressBar mProgressBar;
private TextView eipStatus;
@@ -90,14 +94,18 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
if (preferences.getString(Provider.KEY, "").isEmpty())
startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP);
else
- buildDashboard();
+ buildDashboard(getIntent().getBooleanExtra(ON_BOOT, false));
}
@Override
protected void onDestroy() {
super.onDestroy();
}
-
+
+ protected void onPause() {
+ super.onPause();
+ }
+
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
if ( requestCode == CONFIGURE_LEAP || requestCode == SWITCH_PROVIDER) {
@@ -108,7 +116,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
Intent updateEIP = new Intent(getApplicationContext(), EIP.class);
updateEIP.setAction(EIP.ACTION_UPDATE_EIP_SERVICE);
startService(updateEIP);
- buildDashboard();
+ buildDashboard(false);
invalidateOptionsMenu();
if(data != null && data.hasExtra(LogInDialog.VERB)) {
View view = ((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
@@ -152,7 +160,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
* Inflates permanent UI elements of the View and contains logic for what
* service dependent UI elements to include.
*/
- private void buildDashboard() {
+ private void buildDashboard(boolean hide_and_turn_on_eip) {
provider = Provider.getInstance();
provider.init( this );
@@ -167,7 +175,17 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
FragmentManager fragMan = getFragmentManager();
if ( provider.hasEIP()){
EipServiceFragment eipFragment = new EipServiceFragment();
+ if (hide_and_turn_on_eip) {
+ getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().remove(Dashboard.START_ON_BOOT).commit();
+ Bundle arguments = new Bundle();
+ arguments.putBoolean(EipServiceFragment.START_ON_BOOT, true);
+ eipFragment.setArguments(arguments);
+ }
fragMan.beginTransaction().replace(R.id.servicesCollection, eipFragment, EipServiceFragment.TAG).commit();
+
+ if (hide_and_turn_on_eip) {
+ onBackPressed();
+ }
}
}
@@ -464,9 +482,9 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
// TODO validate "action"...how do we get the list of intent-filters for a class via Android API?
Intent eip_intent = new Intent(this, EIP.class);
eip_intent.setAction(EIP.ACTION_STOP_EIP);
- // eip_intent.putExtra(EIP.RECEIVER_TAG, eip_receiver);
+ // eip_intent.putExtra(EIP.RECEIVER_TAG, eip_receiver);fi
startService(eip_intent);
-
+
}
private void eipStart(){
diff --git a/app/src/main/java/se/leap/bitmaskclient/EIP.java b/app/src/main/java/se/leap/bitmaskclient/EIP.java
index e773e3b9..68688b90 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EIP.java
@@ -108,11 +108,12 @@ public final class EIP extends IntentService {
@Override
public void onDestroy() {
- unbindService(mVpnServiceConn);
- mBound = false;
-
- super.onDestroy();
+ unbindService(mVpnServiceConn);
+ mBound = false;
+
+ super.onDestroy();
}
+
@Override
protected void onHandleIntent(Intent intent) {
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
index b4cb541a..4341c9dc 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
@@ -27,6 +27,7 @@ import android.widget.TextView;
public class EipServiceFragment extends Fragment implements StateListener, OnCheckedChangeListener {
protected static final String IS_EIP_PENDING = "is_eip_pending";
+ public static final String START_ON_BOOT = "start on boot";
private View eipFragment;
private static Switch eipSwitch;
@@ -73,6 +74,8 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe
});
eipSwitch.setOnCheckedChangeListener(this);
+ if(getArguments() != null && getArguments().containsKey(START_ON_BOOT) && getArguments().getBoolean(START_ON_BOOT))
+ startEipFromScratch();
return eipFragment;
}
@@ -108,24 +111,32 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe
OpenVPN.removeStateListener(this);
}
-
+
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(IS_EIP_PENDING, mEipStartPending);
}
-
+
+ protected void saveEipStatus() {
+ boolean eip_is_on = false;
+ Log.d("bitmask", "saveEipStatus");
+ if(eipSwitch.isChecked()) {
+ eip_is_on = true;
+ }
+
+ if(getActivity() != null)
+ getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit().putBoolean(Dashboard.START_ON_BOOT, eip_is_on).commit();
+ }
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ Log.d("bitmask", "onCheckChanged");
if (buttonView.equals(eipSwitch) && !eipAutoSwitched){
boolean allowed_anon = getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).getBoolean(EIP.ALLOWED_ANON, false);
String certificate = getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).getString(EIP.CERTIFICATE, "");
if(allowed_anon || !certificate.isEmpty()) {
if (isChecked){
- mEipStartPending = true;
- eipFragment.findViewById(R.id.eipProgress).setVisibility(View.VISIBLE);
- ((TextView) eipFragment.findViewById(R.id.eipStatus)).setText(R.string.eip_status_start_pending);
- eipCommand(EIP.ACTION_START_EIP);
+ startEipFromScratch();
} else {
if (mEipStartPending){
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getActivity());
@@ -165,9 +176,18 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe
eipStatus.setText(R.string.state_noprocess);
}
eipAutoSwitched = true;
+ saveEipStatus();
}
+ public void startEipFromScratch() {
+ mEipStartPending = true;
+ eipFragment.findViewById(R.id.eipProgress).setVisibility(View.VISIBLE);
+ ((TextView) eipFragment.findViewById(R.id.eipStatus)).setText(R.string.eip_status_start_pending);
+ eipSwitch.setChecked(true);
+ saveEipStatus();
+ eipCommand(EIP.ACTION_START_EIP);
+ }
/**
* Send a command to EIP
diff --git a/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java b/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
new file mode 100644
index 00000000..eb196d46
--- /dev/null
+++ b/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
@@ -0,0 +1,24 @@
+package se.leap.bitmaskclient;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+
+public class OnBootReceiver extends BroadcastReceiver {
+
+ // Debug: am broadcast -a android.intent.action.BOOT_COMPLETED
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
+ if (!context.getSharedPreferences(Dashboard.SHARED_PREFERENCES, Context.MODE_PRIVATE).getString(Provider.KEY, "").isEmpty() && context.getSharedPreferences(Dashboard.SHARED_PREFERENCES, Context.MODE_PRIVATE).getBoolean(Dashboard.START_ON_BOOT, false)) {
+ Intent dashboard_intent = new Intent(context, Dashboard.class);
+ dashboard_intent.setAction(EIP.ACTION_START_EIP);
+ dashboard_intent.putExtra(Dashboard.ON_BOOT, true);
+ dashboard_intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(dashboard_intent);
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/se/leap/openvpn/OpenVpnService.java b/app/src/main/java/se/leap/openvpn/OpenVpnService.java
index b5c9c798..deec8518 100644
--- a/app/src/main/java/se/leap/openvpn/OpenVpnService.java
+++ b/app/src/main/java/se/leap/openvpn/OpenVpnService.java
@@ -1,13 +1,8 @@
package se.leap.openvpn;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Vector;
-import se.leap.bitmaskclient.Dashboard;
-import se.leap.bitmaskclient.R;
import android.annotation.TargetApi;
+import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
@@ -20,11 +15,17 @@ import android.net.LocalSocket;
import android.net.LocalSocketAddress;
import android.net.VpnService;
import android.os.Binder;
-import android.os.Handler.Callback;
import android.os.Build;
+import android.os.Handler.Callback;
import android.os.IBinder;
import android.os.Message;
import android.os.ParcelFileDescriptor;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Vector;
+import se.leap.bitmaskclient.Dashboard;
+import se.leap.bitmaskclient.R;
import se.leap.openvpn.OpenVPN.StateListener;
public class OpenVpnService extends VpnService implements StateListener, Callback {
@@ -163,7 +164,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
PendingIntent getLogPendingIntent() {
// Let the configure Button show the Dashboard
- Intent intent = new Intent(Dashboard.getAppContext(),Dashboard.class);
+ Intent intent = new Intent(getApplicationContext(),Dashboard.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent startLW = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@@ -278,10 +279,11 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
@Override
public void onDestroy() {
- if (mProcessThread != null) {
+ if (mProcessThread != null) {
mSocketManager.managmentCommand("signal SIGINT\n");
mProcessThread.interrupt();
+
}
if (mNetworkStateReceiver!= null) {
this.unregisterReceiver(mNetworkStateReceiver);
@@ -468,11 +470,16 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
public void updateState(String state,String logmessage, int resid) {
// If the process is not running, ignore any state,
// Notification should be invisible in this state
- if(mProcessThread==null)
- return;
- if("CONNECTED".equals(state)) {
- mNotificationManager.cancel(OPENVPN_STATUS);
- } else if(!"BYTECOUNT".equals(state)) {
+ android.util.Log.d("OpenVpnService", "updateState(" + state + ","+logmessage);
+
+ if(mProcessThread==null) {
+ if(mNotificationManager != null)
+ mNotificationManager.cancel(OPENVPN_STATUS);
+ return;
+ }
+ if("CONNECTED".equalsIgnoreCase(state)) {
+ mNotificationManager.cancel(OPENVPN_STATUS);
+ } else if(!"BYTECOUNT".equals(state)) {
// Other notifications are shown,
// This also mean we are no longer connected, ignore bytecount messages until next
@@ -481,6 +488,8 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
boolean persist = false;
if (("NOPROCESS".equals(state) ) || ("EXITING").equals(state)){
showNotification(state, getString(R.string.eip_state_not_connected), ticker, false, 0, persist);
+ if(getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE) != null)
+ getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit().putBoolean(Dashboard.START_ON_BOOT, false).commit();
}
else if (state.equals("GET_CONFIG") || state.equals("ASSIGN_IP")){ //don't show them in the notification message
}
diff --git a/app/src/main/java/se/leap/openvpn/ProfileManager.java b/app/src/main/java/se/leap/openvpn/ProfileManager.java
index b9eb3ab6..07a4087a 100644
--- a/app/src/main/java/se/leap/openvpn/ProfileManager.java
+++ b/app/src/main/java/se/leap/openvpn/ProfileManager.java
@@ -71,7 +71,8 @@ public class ProfileManager {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
Editor prefsedit = prefs.edit();
- prefsedit.putString(ONBOOTPROFILE, connectedrofile.getUUIDString());
+ //prefsedit.putString(ONBOOTPROFILE, connectedrofile.getUUIDString());
+ prefsedit.putString(ONBOOTPROFILE, VpnProfile.EXTRA_PROFILEUUID);
prefsedit.apply();
mLastConnectedVpn=connectedrofile;