diff options
author | Parménides GV <parmegv@sdf.org> | 2014-12-15 16:22:58 +0100 |
---|---|---|
committer | Parménides GV <parmegv@sdf.org> | 2014-12-15 16:22:58 +0100 |
commit | 18fef7c99aa36b3e5622b3865f36d78d0879e92d (patch) | |
tree | 7a04fc87318d5008bbc1f1ac145ebb505bb5238c /app/src | |
parent | 56fe0400b8983ce57112ed5a0f993985a87741c0 (diff) | |
parent | 33c5958a18599267820f73b151d8161d83f93d88 (diff) |
Merge branch 'research/Test-on-Android-5-#6543' into develop
Diffstat (limited to 'app/src')
50 files changed, 979 insertions, 456 deletions
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java index 9ac5ff66..f47510bc 100644 --- a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java +++ b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java @@ -62,11 +62,11 @@ public class ProviderAPI extends IntentService { ; final public static int - SRP_AUTHENTICATION_SUCCESSFUL = 3, - SRP_AUTHENTICATION_FAILED = 4, - SRP_REGISTRATION_SUCCESSFUL = 5, - SRP_REGISTRATION_FAILED = 6, - LOGOUT_SUCCESSFUL = 7, + SUCCESSFUL_LOGIN = 3, + FAILED_LOGIN = 4, + SUCCESSFUL_SIGNUP = 5, + FAILED_SIGNUP = 6, + SUCCESSFUL_LOGOUT = 7, LOGOUT_FAILED = 8, CORRECTLY_DOWNLOADED_CERTIFICATE = 9, INCORRECTLY_DOWNLOADED_CERTIFICATE = 10, @@ -142,20 +142,20 @@ public class ProviderAPI extends IntentService { } else if (action.equalsIgnoreCase(SRP_REGISTER)) { Bundle session_id_bundle = tryToRegister(parameters); if(session_id_bundle.getBoolean(RESULT_KEY)) { - receiver.send(SRP_REGISTRATION_SUCCESSFUL, session_id_bundle); + receiver.send(SUCCESSFUL_SIGNUP, session_id_bundle); } else { - receiver.send(SRP_REGISTRATION_FAILED, session_id_bundle); + receiver.send(FAILED_SIGNUP, session_id_bundle); } } else if (action.equalsIgnoreCase(SRP_AUTH)) { Bundle session_id_bundle = tryToAuthenticate(parameters); if(session_id_bundle.getBoolean(RESULT_KEY)) { - receiver.send(SRP_AUTHENTICATION_SUCCESSFUL, session_id_bundle); + receiver.send(SUCCESSFUL_LOGIN, session_id_bundle); } else { - receiver.send(SRP_AUTHENTICATION_FAILED, session_id_bundle); + receiver.send(FAILED_LOGIN, session_id_bundle); } } else if (action.equalsIgnoreCase(LOG_OUT)) { if(logOut()) { - receiver.send(LOGOUT_SUCCESSFUL, Bundle.EMPTY); + receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY); } else { receiver.send(LOGOUT_FAILED, Bundle.EMPTY); } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7d1063ef..6b548dbb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,13 +27,14 @@ <uses-sdk android:minSdkVersion="14" - android:targetSdkVersion="18" /> + android:targetSdkVersion="21"/> <application android:allowBackup="true" android:icon="@drawable/icon" android:logo="@drawable/icon" - android:label="@string/app" > + android:label="@string/app" + android:theme="@style/appstyle"> <service android:name="se.leap.bitmaskclient.eip.VoidVpnService" @@ -66,7 +67,6 @@ android:theme="@android:style/Theme.NoDisplay" /> <activity - android:theme="@android:style/Theme.DeviceDefault.Light.Dialog" android:name="de.blinkt.openvpn.activities.DisconnectVPN" /> <activity diff --git a/app/src/main/java/de/blinkt/openvpn/VpnProfile.java b/app/src/main/java/de/blinkt/openvpn/VpnProfile.java index 65214c4f..fb2ba90d 100644 --- a/app/src/main/java/de/blinkt/openvpn/VpnProfile.java +++ b/app/src/main/java/de/blinkt/openvpn/VpnProfile.java @@ -45,7 +45,6 @@ import java.util.Collection; import java.util.Locale; import java.util.UUID; import java.util.Vector; -import java.util.concurrent.Future; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -54,6 +53,7 @@ import javax.crypto.NoSuchPaddingException; import de.blinkt.openvpn.core.NativeUtils; import de.blinkt.openvpn.core.OpenVPNService; +import de.blinkt.openvpn.core.VPNLaunchHelper; import de.blinkt.openvpn.core.VpnStatus; import de.blinkt.openvpn.core.X509Utils; @@ -68,11 +68,8 @@ public class VpnProfile implements Serializable { public static final String EXTRA_PROFILEUUID = "de.blinkt.openvpn.profileUUID"; public static final String INLINE_TAG = "[[INLINE]]"; public static final String DISPLAYNAME_TAG = "[[NAME]]"; - private static final String MININONPIEVPN = "nopievpn"; - private static final String MINIPIEVPN = "pievpn"; private static final long serialVersionUID = 7085688938959334563L; - private static final String OVPNCONFIGFILE = "android.conf"; public static final int MAXLOGLEVEL = 4; public static final int CURRENT_PROFILE_VERSION = 2; public static final int DEFAULT_MSSFIX_SIZE = 1450; @@ -164,20 +161,6 @@ public class VpnProfile implements Serializable { mProfileVersion = CURRENT_PROFILE_VERSION; } - public static String getMiniVPNExecutableName() - { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) - return VpnProfile.MINIPIEVPN; - else - return VpnProfile.MININONPIEVPN; - } - - public static String[] replacePieWithNoPie(String[] mArgv) - { - mArgv[0] = mArgv[0].replace(MINIPIEVPN, MININONPIEVPN); - return mArgv; - } - public static String openVpnEscape(String unescaped) { if (unescaped == null) return null; @@ -576,19 +559,6 @@ public class VpnProfile implements Serializable { return parts[0] + " " + netmask; } - private String[] buildOpenvpnArgv(File cacheDir) { - Vector<String> args = new Vector<String>(); - - // Add fixed paramenters - //args.add("/data/data/de.blinkt.openvpn/lib/openvpn"); - args.add(cacheDir.getAbsolutePath() + "/" + getMiniVPNExecutableName()); - - args.add("--config"); - args.add(cacheDir.getAbsolutePath() + "/" + OVPNCONFIGFILE); - - - return args.toArray(new String[args.size()]); - } @@ -603,7 +573,7 @@ public class VpnProfile implements Serializable { try { - FileWriter cfg = new FileWriter(context.getCacheDir().getAbsolutePath() + "/" + OVPNCONFIGFILE); + FileWriter cfg = new FileWriter(VPNLaunchHelper.getConfigFilePath(context)); cfg.write(getConfigFile(context, false)); cfg.flush(); cfg.close(); @@ -618,7 +588,7 @@ public class VpnProfile implements Serializable { String prefix = context.getPackageName(); Intent intent = new Intent(context, OpenVPNService.class); - intent.putExtra(prefix + ".ARGV", buildOpenvpnArgv(context.getCacheDir())); + intent.putExtra(prefix + ".ARGV", VPNLaunchHelper.buildOpenvpnArgv(context)); intent.putExtra(prefix + ".profileUUID", mUuid.toString()); ApplicationInfo info = context.getApplicationInfo(); @@ -648,7 +618,7 @@ public class VpnProfile implements Serializable { public static boolean isEmbedded(String data) { if (data==null) return false; - if(data.startsWith(INLINE_TAG) || data.startsWith(DISPLAYNAME_TAG)) + if (data.startsWith(INLINE_TAG) || data.startsWith(DISPLAYNAME_TAG)) return true; else return false; diff --git a/app/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java b/app/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java index e6b73a48..4940d5d6 100644 --- a/app/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java +++ b/app/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java @@ -17,7 +17,7 @@ import de.blinkt.openvpn.core.ProfileManager; /** * Created by arne on 13.10.13. */ -public class DisconnectVPN extends Activity implements DialogInterface.OnClickListener{ +public class DisconnectVPN extends Activity implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener { protected OpenVPNService mService; private ServiceConnection mConnection = new ServiceConnection() { @@ -71,6 +71,7 @@ public class DisconnectVPN extends Activity implements DialogInterface.OnClickLi builder.setMessage(R.string.cancel_connection_query); builder.setNegativeButton(android.R.string.no, this); builder.setPositiveButton(android.R.string.yes,this); + builder.setOnCancelListener(this); builder.show(); } @@ -84,4 +85,9 @@ public class DisconnectVPN extends Activity implements DialogInterface.OnClickLi } finish(); } + + @Override + public void onCancel(DialogInterface dialog) { + finish(); + } } diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java index ada065ba..d9830955 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -719,6 +719,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac public void updateState(String state, String logmessage, int resid, ConnectionStatus level) { // If the process is not running, ignore any state, // Notification should be invisible in this state + doSendBroadcast(state, level); if (mProcessThread == null && !mNotificationAlwaysVisible) return; diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java index e3c60854..e36a5b8a 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java +++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java @@ -5,6 +5,7 @@ package de.blinkt.openvpn.core; +import android.annotation.SuppressLint; import android.util.Log; import java.io.BufferedReader; @@ -30,6 +31,7 @@ import de.blinkt.openvpn.core.VpnStatus.LogItem; public class OpenVPNThread implements Runnable { private static final String DUMP_PATH_STRING = "Dump path: "; + @SuppressLint("SdCardPath") private static final String BROKEN_PIE_SUPPORT = "/data/data/de.blinkt.openvpn/cache/pievpn[1]: syntax error:"; private static final String TAG = "OpenVPN"; public static final int M_FATAL = (1 << 4); @@ -78,7 +80,8 @@ public class OpenVPNThread implements Runnable { if( exitvalue != 0) { VpnStatus.logError("Process exited with exit value " + exitvalue); if (mBrokenPie) { - String[] noPieArgv = VpnProfile.replacePieWithNoPie(mArgv); + /* This will probably fail since the NoPIE binary is probably not written */ + String[] noPieArgv = VPNLaunchHelper.replacePieWithNoPie(mArgv); // We are already noPIE, nothing to gain if (!noPieArgv.equals(mArgv)) { @@ -190,7 +193,7 @@ public class OpenVPNThread implements Runnable { private String genLibraryPath(String[] argv, ProcessBuilder pb) { // Hack until I find a good way to get the real library path - String applibpath = argv[0].replace("/cache/" + VpnProfile.getMiniVPNExecutableName() , "/lib"); + String applibpath = argv[0].replaceFirst("/cache/.*$" , "/lib"); String lbpath = pb.environment().get("LD_LIBRARY_PATH"); if(lbpath==null) diff --git a/app/src/main/java/de/blinkt/openvpn/core/VPNLaunchHelper.java b/app/src/main/java/de/blinkt/openvpn/core/VPNLaunchHelper.java index 40f9742b..208aa359 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/VPNLaunchHelper.java +++ b/app/src/main/java/de/blinkt/openvpn/core/VPNLaunchHelper.java @@ -5,70 +5,122 @@ package de.blinkt.openvpn.core; +import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; +import android.content.pm.ApplicationInfo; import android.os.Build; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.util.Vector; import se.leap.bitmaskclient.R; import de.blinkt.openvpn.VpnProfile; public class VPNLaunchHelper { - static private boolean writeMiniVPN(Context context) { - File mvpnout = new File(context.getCacheDir(),VpnProfile.getMiniVPNExecutableName()); - if (mvpnout.exists() && mvpnout.canExecute()) - return true; - - IOException e2 = null; - - try { - InputStream mvpn; - - try { - mvpn = context.getAssets().open(VpnProfile.getMiniVPNExecutableName() + "." + Build.CPU_ABI); - } - catch (IOException errabi) { - VpnStatus.logInfo("Failed getting assets for archicture " + Build.CPU_ABI); - e2=errabi; - mvpn = context.getAssets().open(VpnProfile.getMiniVPNExecutableName() + "." + Build.CPU_ABI2); - - } - - - FileOutputStream fout = new FileOutputStream(mvpnout); - - byte buf[]= new byte[4096]; - - int lenread = mvpn.read(buf); - while(lenread> 0) { - fout.write(buf, 0, lenread); - lenread = mvpn.read(buf); - } - fout.close(); - - if(!mvpnout.setExecutable(true)) { - VpnStatus.logError("Failed to make OpenVPN executable"); - return false; - } - - - return true; - } catch (IOException e) { - if(e2!=null) - VpnStatus.logException(e2); - VpnStatus.logException(e); - - return false; - } + private static final String MININONPIEVPN = "nopievpn"; + private static final String MINIPIEVPN = "pievpn"; + private static final String OVPNCONFIGFILE = "android.conf"; + + + + static private String writeMiniVPN(Context context) { + String[] abis; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + abis = getSupportedAbisLollipop(); + else + abis = new String[]{Build.CPU_ABI, Build.CPU_ABI2}; + + for (String abi: abis) { + + File mvpnout = new File(context.getCacheDir(), getMiniVPNExecutableName() + "." + abi); + if ((mvpnout.exists() && mvpnout.canExecute()) || writeMiniVPNBinary(context, abi, mvpnout)) { + return mvpnout.getPath(); + } + } + + return null; } + + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + private static String[] getSupportedAbisLollipop() { + return Build.SUPPORTED_ABIS; + } + + private static String getMiniVPNExecutableName() + { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) + return MINIPIEVPN; + else + return MININONPIEVPN; + } + + + public static String[] replacePieWithNoPie(String[] mArgv) + { + mArgv[0] = mArgv[0].replace(MINIPIEVPN, MININONPIEVPN); + return mArgv; + } + + + public static String[] buildOpenvpnArgv(Context c) { + Vector<String> args = new Vector<String>(); + + // Add fixed paramenters + //args.add("/data/data/de.blinkt.openvpn/lib/openvpn"); + args.add(writeMiniVPN(c)); + + args.add("--config"); + args.add(c.getCacheDir().getAbsolutePath() + "/" + OVPNCONFIGFILE); + + + return args.toArray(new String[args.size()]); + } + + private static boolean writeMiniVPNBinary(Context context, String abi, File mvpnout) { + try { + InputStream mvpn; + + try { + mvpn = context.getAssets().open(getMiniVPNExecutableName() + "." + abi); + } + catch (IOException errabi) { + VpnStatus.logInfo("Failed getting assets for archicture " + abi); + return false; + } + + + FileOutputStream fout = new FileOutputStream(mvpnout); + + byte buf[]= new byte[4096]; + + int lenread = mvpn.read(buf); + while(lenread> 0) { + fout.write(buf, 0, lenread); + lenread = mvpn.read(buf); + } + fout.close(); + + if(!mvpnout.setExecutable(true)) { + VpnStatus.logError("Failed to make OpenVPN executable"); + return false; + } + + + return true; + } catch (IOException e) { + VpnStatus.logException(e); + return false; + } + + } public static void startOpenVpn(VpnProfile startprofile, Context context) { - if(!writeMiniVPN(context)) { + if(writeMiniVPN(context)==null) { VpnStatus.logError("Error writing minivpn binary"); return; } @@ -80,4 +132,9 @@ public class VPNLaunchHelper { context.startService(startVPN); } + + public static String getConfigFilePath(Context context) { + return context.getCacheDir().getAbsolutePath() + "/" + OVPNCONFIGFILE; + } + } diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index 3ecf5e52..862086eb 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -16,6 +16,7 @@ */ package se.leap.bitmaskclient; +import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; import android.app.DialogFragment; @@ -34,6 +35,7 @@ import android.view.MenuItem; import android.widget.ProgressBar; import android.widget.TextView; +import org.jetbrains.annotations.NotNull; import org.json.JSONException; import org.json.JSONObject; @@ -48,7 +50,7 @@ import se.leap.bitmaskclient.eip.EIP; import se.leap.bitmaskclient.eip.EipStatus; /** - * The main user facing Activity of LEAP Android, consisting of status, controls, + * The main user facing Activity of Bitmask Android, consisting of status, controls, * and access to preferences. * * @author Sean Leonard <meanderingcode@aetherislands.net> @@ -81,7 +83,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn public ProviderAPIResultReceiver providerAPI_result_receiver; @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NotNull Bundle outState) { if(provider != null) outState.putParcelable(Provider.KEY, provider); super.onSaveInstanceState(outState); @@ -99,24 +101,36 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn fragment_manager = new FragmentManagerEnhanced(getFragmentManager()); handleVersion(); - if(savedInstanceState != null) - provider = savedInstanceState.getParcelable(Provider.KEY); - if(provider == null && preferences.getBoolean(Constants.PROVIDER_CONFIGURED, false)) - try { - provider = new Provider(new URL(preferences.getString(Provider.MAIN_URL, ""))); - provider.define(new JSONObject(preferences.getString(Provider.KEY, ""))); - } catch (MalformedURLException e) { - e.printStackTrace(); - } catch (JSONException e) { - e.printStackTrace(); - } - + provider = getSavedProvider(savedInstanceState); if (provider == null || provider.getName().isEmpty()) startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP); else buildDashboard(getIntent().getBooleanExtra(ON_BOOT, false)); } + private Provider getSavedProvider(Bundle savedInstanceState) { + Provider provider = null; + if(savedInstanceState != null) + provider = savedInstanceState.getParcelable(Provider.KEY); + else if(preferences.getBoolean(Constants.PROVIDER_CONFIGURED, false)) + provider = getSavedProviderFromSharedPreferences(); + + return provider; + } + + private Provider getSavedProviderFromSharedPreferences() { + Provider provider = null; + try { + provider = new Provider(new URL(preferences.getString(Provider.MAIN_URL, ""))); + provider.define(new JSONObject(preferences.getString(Provider.KEY, ""))); + } catch (MalformedURLException | JSONException e) { + e.printStackTrace(); + } + + return provider; + } + + private void handleVersion() { try { int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; @@ -140,13 +154,12 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn } } + @SuppressLint("CommitPrefEdits") @Override protected void onActivityResult(int requestCode, int resultCode, Intent data){ Log.d(TAG, "onActivityResult: requestCode = " + requestCode); if ( requestCode == CONFIGURE_LEAP || requestCode == SWITCH_PROVIDER) { - // It should be equivalent: if ( (requestCode == CONFIGURE_LEAP) || (data!= null && data.hasExtra(STOP_FIRST))) { if ( resultCode == RESULT_OK ) { - preferences.edit().putInt(Constants.PARSED_SERIAL, 0).apply(); preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply(); updateEipService(); @@ -205,7 +218,6 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn ButterKnife.inject(this); provider_name.setText(provider.getDomain()); - if ( provider.hasEIP()){ fragment_manager.removePreviousFragment(EipServiceFragment.TAG); @@ -412,16 +424,16 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn @Override public void onReceiveResult(int resultCode, Bundle resultData) { Log.d(TAG, "onReceiveResult"); - if(resultCode == ProviderAPI.SRP_REGISTRATION_SUCCESSFUL) { + if(resultCode == ProviderAPI.SUCCESSFUL_SIGNUP) { String username = resultData.getString(SessionDialog.USERNAME); String password = resultData.getString(SessionDialog.PASSWORD); logIn(username, password); - } else if(resultCode == ProviderAPI.SRP_REGISTRATION_FAILED) { + } else if(resultCode == ProviderAPI.FAILED_SIGNUP) { changeStatusMessage(resultCode); hideProgressBar(); signUpDialog(resultData); - } else if(resultCode == ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL) { + } else if(resultCode == ProviderAPI.SUCCESSFUL_LOGIN) { changeStatusMessage(resultCode); hideProgressBar(); @@ -431,12 +443,12 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply(); downloadAuthedUserCertificate(); - } else if(resultCode == ProviderAPI.SRP_AUTHENTICATION_FAILED) { + } else if(resultCode == ProviderAPI.FAILED_LOGIN) { changeStatusMessage(resultCode); hideProgressBar(); logInDialog(resultData); - } else if(resultCode == ProviderAPI.LOGOUT_SUCCESSFUL) { + } else if(resultCode == ProviderAPI.SUCCESSFUL_LOGOUT) { changeStatusMessage(resultCode); hideProgressBar(); @@ -477,7 +489,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn } } }; - updateEIP.putExtra(Constants.RECEIVER_TAG, receiver); + //updateEIP.putExtra(Constants.RECEIVER_TAG, receiver); startService(updateEIP); } @@ -491,11 +503,11 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn if (resultCode == Activity.RESULT_OK){ switch(previous_result_code){ - case ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL: eip_fragment.status_message.setText(R.string.succesful_authentication_message); break; - case ProviderAPI.SRP_AUTHENTICATION_FAILED: eip_fragment.status_message.setText(R.string.authentication_failed_message); break; + case ProviderAPI.SUCCESSFUL_LOGIN: eip_fragment.status_message.setText(R.string.succesful_authentication_message); break; + case ProviderAPI.FAILED_LOGIN: eip_fragment.status_message.setText(R.string.authentication_failed_message); break; case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: eip_fragment.status_message.setText(R.string.authed_secured_status); break; case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: eip_fragment.status_message.setText(R.string.incorrectly_downloaded_certificate_message); break; - case ProviderAPI.LOGOUT_SUCCESSFUL: eip_fragment.status_message.setText(R.string.logged_out_message); break; + case ProviderAPI.SUCCESSFUL_LOGOUT: eip_fragment.status_message.setText(R.string.logged_out_message); break; case ProviderAPI.LOGOUT_FAILED: eip_fragment.status_message.setText(R.string.log_out_failed_message); break; } @@ -504,12 +516,12 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn switch(previous_result_code){ - case ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL: eip_fragment.status_message.setText(R.string.succesful_authentication_message); break; - case ProviderAPI.SRP_AUTHENTICATION_FAILED: eip_fragment.status_message.setText(R.string.authentication_failed_message); break; - case ProviderAPI.SRP_REGISTRATION_FAILED: eip_fragment.status_message.setText(R.string.registration_failed_message); break; + case ProviderAPI.SUCCESSFUL_LOGIN: eip_fragment.status_message.setText(R.string.succesful_authentication_message); break; + case ProviderAPI.FAILED_LOGIN: eip_fragment.status_message.setText(R.string.authentication_failed_message); break; + case ProviderAPI.FAILED_SIGNUP: eip_fragment.status_message.setText(R.string.registration_failed_message); break; case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: break; case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: eip_fragment.status_message.setText(R.string.incorrectly_downloaded_certificate_message); break; - case ProviderAPI.LOGOUT_SUCCESSFUL: eip_fragment.status_message.setText(R.string.logged_out_message); break; + case ProviderAPI.SUCCESSFUL_LOGOUT: eip_fragment.status_message.setText(R.string.logged_out_message); break; case ProviderAPI.LOGOUT_FAILED: eip_fragment.status_message.setText(R.string.log_out_failed_message); break; } } diff --git a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java index 904aa31d..1b40c94c 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java @@ -47,6 +47,7 @@ public class EipServiceFragment extends Fragment implements Observer { private static Activity parent_activity; private static EIPReceiver mEIPReceiver; private static EipStatus eip_status; + private boolean is_starting_to_connect; @Override public void onAttach(Activity activity) { @@ -139,7 +140,7 @@ public class EipServiceFragment extends Fragment implements Observer { private boolean canStartEIP() { boolean certificateExists = !Dashboard.preferences.getString(Constants.CERTIFICATE, "").isEmpty(); boolean isAllowedAnon = Dashboard.preferences.getBoolean(Constants.ALLOWED_ANON, false); - return (isAllowedAnon || certificateExists) && !eip_status.isConnected(); + return (isAllowedAnon || certificateExists) && !eip_status.isConnected() && !eip_status.isConnecting(); } private boolean canLogInToStartEIP() { @@ -178,6 +179,7 @@ public class EipServiceFragment extends Fragment implements Observer { } public void startEipFromScratch() { + is_starting_to_connect = true; progress_bar.setVisibility(View.VISIBLE); eip_switch.setVisibility(View.VISIBLE); String status = parent_activity.getString(R.string.eip_status_start_pending); @@ -230,18 +232,19 @@ public class EipServiceFragment extends Fragment implements Observer { Log.d(TAG, "handleNewState: " + eip_status.toString()); if(eip_status.wantsToDisconnect()) setDisconnectedUI(); + else if(eip_status.isConnecting() || is_starting_to_connect) + setInProgressUI(eip_status); else if (eip_status.isConnected()) setConnectedUI(); else if (eip_status.isDisconnected() && !eip_status.isConnecting()) setDisconnectedUI(); - else - setInProgressUI(eip_status); } private void setConnectedUI() { hideProgressBar(); Log.d(TAG, "setConnectedUi? " + eip_status.isConnected()); adjustSwitch(); + is_starting_to_connect = false; status_message.setText(parent_activity.getString(R.string.eip_state_connected)); } @@ -252,14 +255,14 @@ public class EipServiceFragment extends Fragment implements Observer { } private void adjustSwitch() { - if(eip_status.isConnected() || eip_status.isConnecting()) { - Log.d(TAG, "adjustSwitch, isConnected || isConnecting, is checked? " + eip_switch.isChecked()); + if(eip_status.isConnected() || eip_status.isConnecting() || is_starting_to_connect) { + Log.d(TAG, "adjustSwitch, isConnected || isConnecting, is checked"); if(!eip_switch.isChecked()) { eip_switch.setChecked(true); } } else { Log.d(TAG, "adjustSwitch, !isConnected && !isConnecting? " + eip_status.toString()); - + if(eip_switch.isChecked()) { eip_switch.setChecked(false); } @@ -272,22 +275,17 @@ public class EipServiceFragment extends Fragment implements Observer { String prefix = parent_activity.getString(localizedResId); status_message.setText(prefix + " " + logmessage); + is_starting_to_connect = false; adjustSwitch(); } - protected void setStatusMessage(String status) { - if(status_message == null) - status_message = (TextView) parent_activity.findViewById(R.id.status_message); - status_message.setText(status); - } - private void hideProgressBar() { if(progress_bar != null) progress_bar.setVisibility(View.GONE); } protected class EIPReceiver extends ResultReceiver { - + protected EIPReceiver(Handler handler){ super(handler); } @@ -295,17 +293,14 @@ public class EipServiceFragment extends Fragment implements Observer { @Override protected void onReceiveResult(int resultCode, Bundle resultData) { super.onReceiveResult(resultCode, resultData); - + String request = resultData.getString(Constants.REQUEST_TAG); if (request.equals(Constants.ACTION_START_EIP)) { switch (resultCode){ case Activity.RESULT_OK: - Log.d(TAG, "Action start eip = Result OK"); - progress_bar.setVisibility(View.VISIBLE); break; case Activity.RESULT_CANCELED: - progress_bar.setVisibility(View.GONE); break; } } else if (request.equals(Constants.ACTION_STOP_EIP)) { @@ -336,13 +331,13 @@ public class EipServiceFragment extends Fragment implements Observer { status_message.setText(getString(R.string.updating_certificate_message)); if(LeapSRPSession.getToken().isEmpty() && !Dashboard.preferences.getBoolean(Constants.ALLOWED_ANON, false)) { dashboard.logInDialog(Bundle.EMPTY); - } else { + } else { Intent provider_API_command = new Intent(parent_activity, ProviderAPI.class); if(dashboard.providerAPI_result_receiver == null) { dashboard.providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler()); dashboard.providerAPI_result_receiver.setReceiver(dashboard); } - + provider_API_command.setAction(ProviderAPI.DOWNLOAD_CERTIFICATE); provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, dashboard.providerAPI_result_receiver); parent_activity.startService(provider_API_command); @@ -352,7 +347,7 @@ public class EipServiceFragment extends Fragment implements Observer { } } } - + public static EIPReceiver getReceiver() { return mEIPReceiver; diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java b/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java index 01a83d5f..12c2e015 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java @@ -39,7 +39,6 @@ public interface Constants { public final static String CERTIFICATE = "cert"; public final static String PRIVATE_KEY = TAG + ".PRIVATE_KEY"; public final static String KEY = TAG + ".KEY"; - public final static String PARSED_SERIAL = TAG + ".PARSED_SERIAL"; public final static String RECEIVER_TAG = TAG + ".RECEIVER_TAG"; public final static String REQUEST_TAG = TAG + ".REQUEST_TAG"; public final static String START_BLOCKING_VPN_PROFILE = TAG + ".START_BLOCKING_VPN_PROFILE"; diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java index 4363dd13..0713e521 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -22,6 +22,7 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import android.os.Handler; import android.os.ResultReceiver; import android.util.Log; @@ -38,7 +39,6 @@ import de.blinkt.openvpn.VpnProfile; import de.blinkt.openvpn.core.ProfileManager; import se.leap.bitmaskclient.Dashboard; import se.leap.bitmaskclient.EipServiceFragment; -import se.leap.bitmaskclient.Provider; import static se.leap.bitmaskclient.eip.Constants.ACTION_CHECK_CERT_VALIDITY; import static se.leap.bitmaskclient.eip.Constants.ACTION_IS_EIP_RUNNING; @@ -65,20 +65,19 @@ public final class EIP extends IntentService { public final static String TAG = EIP.class.getSimpleName(); public final static String SERVICE_API_PATH = "config/eip-service.json"; - public static final int DISCONNECT = 15; private static Context context; private static ResultReceiver mReceiver; private static SharedPreferences preferences; - private static JSONObject eip_definition = null; + private static JSONObject eip_definition; private static List<Gateway> gateways = new ArrayList<Gateway>(); private static ProfileManager profile_manager; - private static Gateway activeGateway = null; + private static Gateway gateway; public EIP(){ - super("LEAPEIP"); + super(TAG); } @Override @@ -117,13 +116,15 @@ public final class EIP extends IntentService { private void startEIP() { if(gateways.isEmpty()) updateEIPService(); - GatewaySelector gateway_selector = new GatewaySelector(gateways); - activeGateway = gateway_selector.select(); - if(activeGateway != null && activeGateway.getProfile() != null) { + earlyRoutes(); + + GatewaySelector gateway_selector = new GatewaySelector(gateways); + gateway = gateway_selector.select(); + if(gateway != null && gateway.getProfile() != null) { mReceiver = EipServiceFragment.getReceiver(); launchActiveGateway(); } - earlyRoutes(); + tellToReceiver(ACTION_START_EIP, Activity.RESULT_OK); } /** @@ -140,16 +141,11 @@ public final class EIP extends IntentService { Intent intent = new Intent(this,LaunchVPN.class); intent.setAction(Intent.ACTION_MAIN); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.putExtra(LaunchVPN.EXTRA_NAME, activeGateway.getProfile().getName() ); + intent.putExtra(LaunchVPN.EXTRA_NAME, gateway.getProfile().getName()); intent.putExtra(LaunchVPN.EXTRA_HIDELOG, true); - intent.putExtra(RECEIVER_TAG, mReceiver); startActivity(intent); } - - /** - * Disconnects the EIP connection gracefully through the bound service or forcefully - * if there is no bound service. Sends a message to the requesting ResultReceiver. - */ + private void stopEIP() { EipStatus eip_status = EipStatus.getInstance(); Log.d(TAG, "stopEip(): eip is connected? " + eip_status.isConnected()); diff --git a/app/src/main/res/drawable-hdpi/ic_close_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_close_white_24dp.png Binary files differnew file mode 100644 index 00000000..0fd15563 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/ic_close_white_24dp.png diff --git a/app/src/main/res/drawable-hdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_delete_white_24dp.png Binary files differnew file mode 100644 index 00000000..a9eac0ca --- /dev/null +++ b/app/src/main/res/drawable-hdpi/ic_delete_white_24dp.png diff --git a/app/src/main/res/drawable-hdpi/ic_edit_grey600_24dp.png b/app/src/main/res/drawable-hdpi/ic_edit_grey600_24dp.png Binary files differnew file mode 100644 index 00000000..b5f88c80 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/ic_edit_grey600_24dp.png diff --git a/app/src/main/res/drawable-hdpi/ic_edit_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_edit_white_24dp.png Binary files differnew file mode 100644 index 00000000..730416c9 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/ic_edit_white_24dp.png diff --git a/app/src/main/res/drawable-hdpi/ic_filter_list_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_filter_list_white_24dp.png Binary files differnew file mode 100644 index 00000000..30122adf --- /dev/null +++ b/app/src/main/res/drawable-hdpi/ic_filter_list_white_24dp.png diff --git a/app/src/main/res/drawable-hdpi/ic_share_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_share_white_24dp.png Binary files differnew file mode 100644 index 00000000..93b3c219 --- /dev/null +++ b/app/src/main/res/drawable-hdpi/ic_share_white_24dp.png diff --git a/app/src/main/res/drawable-mdpi/ic_close_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_close_white_24dp.png Binary files differnew file mode 100644 index 00000000..e80681ae --- /dev/null +++ b/app/src/main/res/drawable-mdpi/ic_close_white_24dp.png diff --git a/app/src/main/res/drawable-mdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_delete_white_24dp.png Binary files differnew file mode 100644 index 00000000..e4ea52ef --- /dev/null +++ b/app/src/main/res/drawable-mdpi/ic_delete_white_24dp.png diff --git a/app/src/main/res/drawable-mdpi/ic_edit_grey600_24dp.png b/app/src/main/res/drawable-mdpi/ic_edit_grey600_24dp.png Binary files differnew file mode 100644 index 00000000..bae3480c --- /dev/null +++ b/app/src/main/res/drawable-mdpi/ic_edit_grey600_24dp.png diff --git a/app/src/main/res/drawable-mdpi/ic_edit_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_edit_white_24dp.png Binary files differnew file mode 100644 index 00000000..85cff0b9 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/ic_edit_white_24dp.png diff --git a/app/src/main/res/drawable-mdpi/ic_filter_list_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_filter_list_white_24dp.png Binary files differnew file mode 100644 index 00000000..49cec669 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/ic_filter_list_white_24dp.png diff --git a/app/src/main/res/drawable-mdpi/ic_share_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_share_white_24dp.png Binary files differnew file mode 100644 index 00000000..4d019722 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/ic_share_white_24dp.png diff --git a/app/src/main/res/drawable-xhdpi/ic_close_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_close_white_24dp.png Binary files differnew file mode 100644 index 00000000..76e07f09 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/ic_close_white_24dp.png diff --git a/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png Binary files differnew file mode 100644 index 00000000..cdb230c2 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png diff --git a/app/src/main/res/drawable-xhdpi/ic_edit_grey600_24dp.png b/app/src/main/res/drawable-xhdpi/ic_edit_grey600_24dp.png Binary files differnew file mode 100644 index 00000000..4c95bd57 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/ic_edit_grey600_24dp.png diff --git a/app/src/main/res/drawable-xhdpi/ic_edit_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_edit_white_24dp.png Binary files differnew file mode 100644 index 00000000..7f0ea51b --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/ic_edit_white_24dp.png diff --git a/app/src/main/res/drawable-xhdpi/ic_filter_list_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_filter_list_white_24dp.png Binary files differnew file mode 100644 index 00000000..d4ca77bf --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/ic_filter_list_white_24dp.png diff --git a/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png Binary files differnew file mode 100644 index 00000000..dd536bca --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png diff --git a/app/src/main/res/drawable-xxhdpi/ic_close_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_close_white_24dp.png Binary files differnew file mode 100644 index 00000000..0eb9d8b0 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/ic_close_white_24dp.png diff --git a/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png Binary files differnew file mode 100644 index 00000000..0e95e9b1 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png diff --git a/app/src/main/res/drawable-xxhdpi/ic_edit_grey600_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_edit_grey600_24dp.png Binary files differnew file mode 100644 index 00000000..6ed4351c --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/ic_edit_grey600_24dp.png diff --git a/app/src/main/res/drawable-xxhdpi/ic_edit_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_edit_white_24dp.png Binary files differnew file mode 100644 index 00000000..34ec7092 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/ic_edit_white_24dp.png diff --git a/app/src/main/res/drawable-xxhdpi/ic_filter_list_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_filter_list_white_24dp.png Binary files differnew file mode 100644 index 00000000..802b3cd5 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/ic_filter_list_white_24dp.png diff --git a/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png Binary files differnew file mode 100644 index 00000000..9963c6a0 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png diff --git a/app/src/main/res/drawable-xxxhdpi/ic_close_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_close_white_24dp.png Binary files differnew file mode 100644 index 00000000..7b2a480a --- /dev/null +++ b/app/src/main/res/drawable-xxxhdpi/ic_close_white_24dp.png diff --git a/app/src/main/res/drawable-xxxhdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_delete_white_24dp.png Binary files differnew file mode 100644 index 00000000..ccf8c716 --- /dev/null +++ b/app/src/main/res/drawable-xxxhdpi/ic_delete_white_24dp.png diff --git a/app/src/main/res/drawable-xxxhdpi/ic_edit_grey600_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_edit_grey600_24dp.png Binary files differnew file mode 100644 index 00000000..0c0fd76f --- /dev/null +++ b/app/src/main/res/drawable-xxxhdpi/ic_edit_grey600_24dp.png diff --git a/app/src/main/res/drawable-xxxhdpi/ic_edit_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_edit_white_24dp.png Binary files differnew file mode 100644 index 00000000..9380370f --- /dev/null +++ b/app/src/main/res/drawable-xxxhdpi/ic_edit_white_24dp.png diff --git a/app/src/main/res/drawable-xxxhdpi/ic_filter_list_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_filter_list_white_24dp.png Binary files differnew file mode 100644 index 00000000..511008ce --- /dev/null +++ b/app/src/main/res/drawable-xxxhdpi/ic_filter_list_white_24dp.png diff --git a/app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png Binary files differnew file mode 100644 index 00000000..bb521c14 --- /dev/null +++ b/app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png diff --git a/app/src/main/res/menu/logmenu.xml b/app/src/main/res/menu/logmenu.xml index a1d2a7b5..52ba4b7d 100644 --- a/app/src/main/res/menu/logmenu.xml +++ b/app/src/main/res/menu/logmenu.xml @@ -10,33 +10,33 @@ <item android:id="@+id/toggle_time" android:alphabeticShortcut="t" - android:icon="@android:drawable/ic_menu_view" + android:icon="@drawable/ic_menu_view" android:showAsAction="withText|ifRoom" android:title="@string/logview_options" /> <item android:id="@+id/clearlog" - android:icon="@android:drawable/ic_menu_delete" + android:icon="@drawable/ic_menu_delete" android:showAsAction="ifRoom|withText" android:title="@string/clear_log" android:titleCondensed="@string/clear"/> <item android:id="@+id/send" - android:icon="@android:drawable/ic_menu_share" + android:icon="@drawable/ic_menu_share" android:showAsAction="ifRoom|withText" android:title="@string/send_logfile" android:titleCondensed="@string/send"/> <item android:id="@+id/cancel" - android:icon="@android:drawable/ic_menu_close_clear_cancel" + android:icon="@drawable/ic_menu_close_clear_cancel" android:showAsAction="ifRoom|withText" android:title="@string/cancel_connection_long" android:titleCondensed="@string/cancel_connection"/> <item android:id="@+id/edit_vpn" android:alphabeticShortcut="e" - android:icon="@android:drawable/ic_menu_edit" + android:icon="@drawable/ic_menu_edit" android:showAsAction="withText|ifRoom" android:title="@string/edit_vpn" android:visible="false"/> diff --git a/app/src/main/res/values-v21/refs.xml b/app/src/main/res/values-v21/refs.xml new file mode 100644 index 00000000..0d5d271a --- /dev/null +++ b/app/src/main/res/values-v21/refs.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (c) 2012-2014 Arne Schwabe + ~ Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt + --> + +<resources> + <drawable name="ic_menu_close_clear_cancel">@drawable/ic_close_white_24dp</drawable> + <drawable name="ic_menu_share">@drawable/ic_share_white_24dp </drawable> + <drawable name="ic_menu_view">@drawable/ic_filter_list_white_24dp</drawable> + <drawable name="ic_menu_delete">@drawable/ic_delete_white_24dp</drawable> + <drawable name="ic_menu_edit">@drawable/ic_edit_white_24dp</drawable> +</resources> diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml new file mode 100644 index 00000000..892b6cb0 --- /dev/null +++ b/app/src/main/res/values-v21/styles.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (c) 2012-2014 Arne Schwabe + ~ Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt + --> + +<resources> + + <!-- http://www.google.de/design/spec/style/color.html#color-color-palette --> + <style name="appstyle" parent="android:Theme.Material.Light.DarkActionBar"> + <item name="android:colorPrimary">@color/primary</item> + <item name="android:colorPrimaryDark">@color/primary_dark</item> + <item name="android:colorAccent">@color/accent</item> + </style> +</resources> diff --git a/app/src/main/res/values/colours.xml b/app/src/main/res/values/colours.xml new file mode 100644 index 00000000..89fb41dd --- /dev/null +++ b/app/src/main/res/values/colours.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (c) 2012-2014 Arne Schwabe + ~ Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt + --> + +<resources> + <!-- Indigo --> + <!-- OpenVPN colours #203155, #C66D0D --> + <color name="primary">#3F51B5</color> + <color name="primary_dark">#303F9F</color> + <color name="accent">#FFA726</color> +</resources>
\ No newline at end of file diff --git a/app/src/main/res/values/refs.xml b/app/src/main/res/values/refs.xml new file mode 100644 index 00000000..5e7f5e14 --- /dev/null +++ b/app/src/main/res/values/refs.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (c) 2012-2014 Arne Schwabe + ~ Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt + --> + +<resources> + <drawable name="ic_menu_close_clear_cancel">@android:drawable/ic_menu_close_clear_cancel</drawable> + <drawable name="ic_menu_share">@android:drawable/ic_menu_share </drawable> + <drawable name="ic_menu_save">@android:drawable/ic_menu_save</drawable> + <drawable name="ic_menu_view">@android:drawable/ic_menu_view</drawable> + <drawable name="ic_menu_delete">@android:drawable/ic_menu_delete</drawable> + <drawable name="ic_menu_edit">@android:drawable/ic_menu_edit</drawable> + +</resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 7b26a4a7..a60e29b8 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -5,6 +5,10 @@ --> <resources> + <style name="appstyle" parent="android:Theme.DeviceDefault.Light"> + + </style> + <style name="item"> <item name="android:layout_width">match_parent</item> @@ -23,7 +27,7 @@ <item name="android:paddingTop">10sp</item> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">wrap_content</item> - <item name="android:textAppearance">?android:attr/textAppearanceMedium</item> + <item name="android:textAppearance">?android:attr/textAppearanceLarge</item> <!-- <item name="android:singleLine">true</item> --> </style> diff --git a/app/src/main/res/values/untranslatable.xml b/app/src/main/res/values/untranslatable.xml index 619a550f..82147ab5 100644 --- a/app/src/main/res/values/untranslatable.xml +++ b/app/src/main/res/values/untranslatable.xml @@ -2470,4 +2470,704 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + </resources>
\ No newline at end of file diff --git a/app/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java b/app/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java deleted file mode 100644 index e595106c..00000000 --- a/app/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java +++ /dev/null @@ -1,275 +0,0 @@ -package de.blinkt.openvpn.core; - -import net.openvpn.ovpn3.ClientAPI_Config; -import net.openvpn.ovpn3.ClientAPI_EvalConfig; -import net.openvpn.ovpn3.ClientAPI_Event; -import net.openvpn.ovpn3.ClientAPI_ExternalPKICertRequest; -import net.openvpn.ovpn3.ClientAPI_ExternalPKISignRequest; -import net.openvpn.ovpn3.ClientAPI_LogInfo; -import net.openvpn.ovpn3.ClientAPI_OpenVPNClient; -import net.openvpn.ovpn3.ClientAPI_ProvideCreds; -import net.openvpn.ovpn3.ClientAPI_Status; -import net.openvpn.ovpn3.ClientAPI_TransportStats; - -import java.lang.Override; - -import de.blinkt.openvpn.VpnProfile; - -import android.content.Context; - -public class OpenVPNThreadv3 extends ClientAPI_OpenVPNClient implements Runnable, OpenVPNManagement { - - static { - /*System.loadLibrary("crypto"); - System.loadLibrary("ssl");*/ - System.loadLibrary("polarssl-dynamic"); - System.loadLibrary("ovpn3"); - } - - private VpnProfile mVp; - private OpenVPNService mService; - - class StatusPoller implements Runnable - { - private long mSleeptime; - - boolean mStopped=false; - - public StatusPoller(long sleeptime) { - mSleeptime=sleeptime; - } - - public void run() { - while(!mStopped) { - try { - Thread.sleep(mSleeptime); - } catch (InterruptedException e) { - } - ClientAPI_TransportStats t = transport_stats(); - long in = t.getBytesIn(); - long out = t.getBytesOut(); - VpnStatus.updateByteCount(in, out); - } - } - - public void stop() { - mStopped=true; - } - } - - @Override - public void run() { - String configstr = mVp.getConfigFile((Context)mService,true); - if(!setConfig(configstr)) - return; - setUserPW(); - VpnStatus.logInfo(copyright()); - - StatusPoller statuspoller = new StatusPoller(5000); - new Thread(statuspoller,"Status Poller").start(); - - ClientAPI_Status status = connect(); - if(status.getError()) { - VpnStatus.logError(String.format("connect() error: %s: %s",status.getStatus(),status.getMessage())); - } else { - VpnStatus.logInfo("OpenVPN3 thread finished"); - } - statuspoller.stop(); - } - - @Override - public boolean tun_builder_set_remote_address(String address, boolean ipv6) { - mService.setMtu(1500); - return true; - } - - @Override - public boolean tun_builder_set_mtu(int mtu) { - mService.setMtu(mtu); - return true; - } - @Override - public boolean tun_builder_add_dns_server(String address, boolean ipv6) { - mService.addDNS(address); - return true; - } - - @Override - public boolean tun_builder_add_route(String address, int prefix_length, - boolean ipv6) { - if (address.equals("remote_host")) - return false; - - if(ipv6) - mService.addRoutev6(address + "/" + prefix_length,"tun"); - else - mService.addRoute(new CIDRIP(address, prefix_length)); - return true; - } - - @Override - public boolean tun_builder_add_search_domain(String domain) { - mService.setDomain(domain); - return true; - } - - @Override - public int tun_builder_establish() { - return mService.openTun().detachFd(); - } - - @Override - public boolean tun_builder_set_session_name(String name) { - VpnStatus.logInfo("We should call this session" + name); - return true; - } - - - - @Override - public boolean tun_builder_add_address(String address, int prefix_length, - boolean ipv6) { - if(!ipv6) - mService.setLocalIP(new CIDRIP(address, prefix_length)); - else - mService.setLocalIPv6(address+ "/" + prefix_length); - return true; - } - - @Override - public boolean tun_builder_new() { - - return true; - } - - @Override - public boolean tun_builder_reroute_gw(String server_address, - boolean server_address_ipv6, boolean ipv4, boolean ipv6, long flags) { - // ignore - return true; - } - - @Override - public boolean tun_builder_exclude_route(String address, int prefix_length, - boolean ipv6) { - //ignore - return true; - } - - - private boolean setConfig(String vpnconfig) { - - ClientAPI_Config config = new ClientAPI_Config(); - if(mVp.getPasswordPrivateKey()!=null) - config.setPrivateKeyPassword(mVp.getPasswordPrivateKey()); - - config.setContent(vpnconfig); - config.setTunPersist(mVp.mPersistTun); - config.setGuiVersion(mVp.getVersionEnvString(mService)); - config.setExternalPkiAlias("extpki"); - - ClientAPI_EvalConfig ec = eval_config(config); - if(ec.getExternalPki()) { - VpnStatus.logError("OpenVPN seem to think as external PKI"); - } - if (ec.getError()) { - VpnStatus.logError("OpenVPN config file parse error: " + ec.getMessage()); - return false; - } else { - config.setContent(vpnconfig); - return true; - } - } - - @Override - public void external_pki_cert_request(ClientAPI_ExternalPKICertRequest certreq) { - VpnStatus.logError("EXT PKI CERT"); - String[] ks = mVp.getKeyStoreCertificates((Context) mService); - if(ks==null) { - certreq.setError(true); - certreq.setErrorText("Error in pki cert request"); - return; - } - - String supcerts = ks[0]; - /* FIXME: How to differentiate between chain and ca certs in OpenVPN 3? */ - if (ks[1]!=null) - supcerts += "\n" + ks[1]; - certreq.setSupportingChain(supcerts); - certreq.setCert(ks[2]); - certreq.setError(false); - } - - @Override - public void external_pki_sign_request(ClientAPI_ExternalPKISignRequest signreq) { - signreq.setSig(mVp.getSignedData(signreq.getData())); - } - - void setUserPW() { - if(mVp.isUserPWAuth()) { - ClientAPI_ProvideCreds creds = new ClientAPI_ProvideCreds(); - creds.setCachePassword(true); - creds.setPassword(mVp.getPasswordAuth()); - creds.setUsername(mVp.mUsername); - provide_creds(creds); - } - } - - @Override - public boolean socket_protect(int socket) { - boolean b= mService.protect(socket); - return b; - - } - - public OpenVPNThreadv3(OpenVPNService openVpnService, VpnProfile vp) { - init_process(); - mVp =vp; - mService =openVpnService; - } - - @Override - public void pause(pauseReason pauseReason) - { - pause(); - } - - @Override - public void log(ClientAPI_LogInfo arg0) { - String logmsg =arg0.getText(); - while (logmsg.endsWith("\n")) - logmsg = logmsg.substring(0, logmsg.length()-1); - - VpnStatus.logInfo(logmsg); - } - - @Override - public void event(ClientAPI_Event event) { - VpnStatus.updateStateString(event.getName(), event.getInfo()); - if(event.getError()) - VpnStatus.logError(String.format("EVENT(Error): %s: %s",event.getName(),event.getInfo())); - } - - - // When a connection is close to timeout, the core will call this - // method. If it returns false, the core will disconnect with a - // CONNECTION_TIMEOUT event. If true, the core will enter a PAUSE - // state. - - @Override - public boolean pause_on_connection_timeout() { - VpnStatus.logInfo("pause on connection timeout?! "); - return true; - } - - public boolean stopVPN() { - stop(); - return true; - } - - @Override - public void reconnect() { - reconnect(1); - } - -} diff --git a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java index f5f27247..f1cb84d6 100644 --- a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java +++ b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java @@ -63,12 +63,11 @@ public class ProviderAPI extends IntentService { ; final public static int - CUSTOM_PROVIDER_ADDED = 0, - SRP_AUTHENTICATION_SUCCESSFUL = 3, - SRP_AUTHENTICATION_FAILED = 4, - SRP_REGISTRATION_SUCCESSFUL = 5, - SRP_REGISTRATION_FAILED = 6, - LOGOUT_SUCCESSFUL = 7, + SUCCESSFUL_LOGIN = 3, + FAILED_LOGIN = 4, + SUCCESSFUL_SIGNUP = 5, + FAILED_SIGNUP = 6, + SUCCESSFUL_LOGOUT = 7, LOGOUT_FAILED = 8, CORRECTLY_DOWNLOADED_CERTIFICATE = 9, INCORRECTLY_DOWNLOADED_CERTIFICATE = 10, @@ -140,20 +139,20 @@ public class ProviderAPI extends IntentService { } else if (action.equalsIgnoreCase(SRP_REGISTER)) { Bundle result = tryToRegister(parameters); if(result.getBoolean(RESULT_KEY)) { - receiver.send(SRP_REGISTRATION_SUCCESSFUL, result); + receiver.send(SUCCESSFUL_SIGNUP, result); } else { - receiver.send(SRP_REGISTRATION_FAILED, result); + receiver.send(FAILED_SIGNUP, result); } } else if (action.equalsIgnoreCase(SRP_AUTH)) { Bundle result = tryToAuthenticate(parameters); if(result.getBoolean(RESULT_KEY)) { - receiver.send(SRP_AUTHENTICATION_SUCCESSFUL, result); + receiver.send(SUCCESSFUL_LOGIN, result); } else { - receiver.send(SRP_AUTHENTICATION_FAILED, result); + receiver.send(FAILED_LOGIN, result); } } else if (action.equalsIgnoreCase(LOG_OUT)) { if(logOut()) { - receiver.send(LOGOUT_SUCCESSFUL, Bundle.EMPTY); + receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY); } else { receiver.send(LOGOUT_FAILED, Bundle.EMPTY); } |