summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipFragment.java64
1 files changed, 41 insertions, 23 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
index 08622453..7c61ddae 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
@@ -45,11 +45,12 @@ import java.util.Observer;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
+import de.blinkt.openvpn.VpnProfile;
import de.blinkt.openvpn.core.IOpenVPNServiceInternal;
import de.blinkt.openvpn.core.OpenVPNService;
+import de.blinkt.openvpn.core.ProfileManager;
import se.leap.bitmaskclient.eip.EipCommand;
import se.leap.bitmaskclient.eip.EipStatus;
-import se.leap.bitmaskclient.eip.VoidVpnService;
import se.leap.bitmaskclient.views.VpnStateImage;
import static android.view.View.GONE;
@@ -68,7 +69,6 @@ public class EipFragment extends Fragment implements Observer {
public final static String TAG = EipFragment.class.getSimpleName();
- public static final String START_EIP_ON_BOOT = "start on boot";
public static final String ASK_TO_CANCEL_VPN = "ask_to_cancel_vpn";
@@ -101,23 +101,7 @@ public class EipFragment extends Fragment implements Observer {
AlertDialog alertDialog;
private IOpenVPNServiceInternal mService;
- private ServiceConnection openVpnConnection = new ServiceConnection() {
-
-
-
- @Override
- public void onServiceConnected(ComponentName className,
- IBinder service) {
-
- mService = IOpenVPNServiceInternal.Stub.asInterface(service);
- }
-
- @Override
- public void onServiceDisconnected(ComponentName arg0) {
- mService = null;
- }
-
- };
+ private ServiceConnection openVpnConnection;
@Override
public void onAttach(Context context) {
@@ -142,6 +126,7 @@ public class EipFragment extends Fragment implements Observer {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ openVpnConnection = new EipFragmentServiceConnection();
eipStatus = EipStatus.getInstance();
Activity activity = getActivity();
if (activity != null) {
@@ -172,8 +157,8 @@ public class EipFragment extends Fragment implements Observer {
super.onResume();
//FIXME: avoid race conditions while checking certificate an logging in at about the same time
//eipCommand(Constants.EIP_ACTION_CHECK_CERT_VALIDITY);
- handleNewState();
bindOpenVpnService();
+ handleNewState();
}
@Override
@@ -231,7 +216,7 @@ public class EipFragment extends Fragment implements Observer {
}
void handleIcon() {
- if (eipStatus.isConnected() || eipStatus.isConnecting())
+ if (isOpenVpnRunningWithoutNetwork() || eipStatus.isConnected() || eipStatus.isConnecting())
handleSwitchOff();
else
handleSwitchOn();
@@ -387,13 +372,23 @@ public class EipFragment extends Fragment implements Observer {
routedText.setVisibility(GONE);
vpnRoute.setVisibility(GONE);
colorBackgroundALittle();
- } else if (eipStatus.isConnected() || isOpenVpnRunningWithoutNetwork()) {
+ } else if (eipStatus.isConnected() ) {
mainButton.setText(activity.getString(R.string.vpn_button_turn_off));
vpnStateImage.setStateIcon(R.drawable.vpn_connected);
vpnStateImage.stopProgress(true);
+ routedText.setText(R.string.vpn_securely_routed);
+ routedText.setVisibility(VISIBLE);
+ vpnRoute.setVisibility(VISIBLE);
+ setVpnRouteText();
+ colorBackground();
+ } else if(isOpenVpnRunningWithoutNetwork()){
+ mainButton.setText(activity.getString(R.string.vpn_button_turn_off));
+ vpnStateImage.setStateIcon(R.drawable.vpn_disconnected);
+ vpnStateImage.stopProgress(true);
+ routedText.setText(R.string.vpn_securely_routed_no_internet);
routedText.setVisibility(VISIBLE);
vpnRoute.setVisibility(VISIBLE);
- vpnRoute.setText(ConfigHelper.getProviderName(preferences));
+ setVpnRouteText();
colorBackground();
} else {
mainButton.setText(activity.getString(R.string.vpn_button_turn_on));
@@ -466,4 +461,27 @@ public class EipFragment extends Fragment implements Observer {
activity.startActivityForResult(intent, REQUEST_CODE_LOG_IN);
}
}
+
+ private void setVpnRouteText() {
+ String vpnRouteString = provider.getName();
+ VpnProfile vpnProfile = ProfileManager.getLastConnectedVpn();
+ if (vpnProfile != null && vpnProfile.mName != null) {
+ vpnRouteString += " (" + vpnProfile.mName + ")";
+ }
+ vpnRoute.setText(vpnRouteString);
+ }
+
+ private class EipFragmentServiceConnection implements ServiceConnection {
+ @Override
+ public void onServiceConnected(ComponentName className,
+ IBinder service) {
+ mService = IOpenVPNServiceInternal.Stub.asInterface(service);
+ handleNewState();
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName arg0) {
+ mService = null;
+ }
+ }
}