diff options
Diffstat (limited to 'main/src/main/java/de/blinkt/openvpn/LaunchVPN.java')
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/LaunchVPN.java | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/LaunchVPN.java b/main/src/main/java/de/blinkt/openvpn/LaunchVPN.java index 86eef35a..90ea053a 100644 --- a/main/src/main/java/de/blinkt/openvpn/LaunchVPN.java +++ b/main/src/main/java/de/blinkt/openvpn/LaunchVPN.java @@ -73,6 +73,7 @@ public class LaunchVPN extends Activity { public static final String EXTRA_KEY = "de.blinkt.openvpn.shortcutProfileUUID"; public static final String EXTRA_NAME = "de.blinkt.openvpn.shortcutProfileName"; public static final String EXTRA_HIDELOG = "de.blinkt.openvpn.showNoLogWindow"; + public static final String EXTRA_START_REASON = "de.blinkt.openvpn.start_reason"; public static final String CLEARLOG = "clearlogconnect"; @@ -85,6 +86,7 @@ public class LaunchVPN extends Activity { private boolean mCmfixed = false; private String mTransientAuthPW; private String mTransientCertOrPCKS12PW; + private String mSelectedProfileReason; @Override public void onCreate(Bundle icicle) { @@ -99,7 +101,6 @@ public class LaunchVPN extends Activity { IServiceStatus service = IServiceStatus.Stub.asInterface(binder); try { if (mTransientAuthPW != null) - service.setCachedPassword(mSelectedProfile.getUUIDString(), PasswordCache.AUTHPASSWORD, mTransientAuthPW); if (mTransientCertOrPCKS12PW != null) service.setCachedPassword(mSelectedProfile.getUUIDString(), PasswordCache.PCKS12ORCERTPASSWORD, mTransientCertOrPCKS12PW); @@ -126,38 +127,41 @@ public class LaunchVPN extends Activity { final String action = intent.getAction(); // If the intent is a request to create a shortcut, we'll do that and exit + if (!Intent.ACTION_MAIN.equals(action)) { + return; + } + // Check if we need to clear the log + if (Preferences.getDefaultSharedPreferences(this).getBoolean(CLEARLOG, true)) + VpnStatus.clearLog(); - if (Intent.ACTION_MAIN.equals(action)) { - // Check if we need to clear the log - if (Preferences.getDefaultSharedPreferences(this).getBoolean(CLEARLOG, true)) - VpnStatus.clearLog(); - - // we got called to be the starting point, most likely a shortcut - String shortcutUUID = intent.getStringExtra(EXTRA_KEY); - String shortcutName = intent.getStringExtra(EXTRA_NAME); - mhideLog = intent.getBooleanExtra(EXTRA_HIDELOG, false); + // we got called to be the starting point, most likely a shortcut + String shortcutUUID = intent.getStringExtra(EXTRA_KEY); + String shortcutName = intent.getStringExtra(EXTRA_NAME); + String startReason = intent.getStringExtra(EXTRA_START_REASON); + mhideLog = intent.getBooleanExtra(EXTRA_HIDELOG, false); - VpnProfile profileToConnect = ProfileManager.get(this, shortcutUUID); - if (shortcutName != null && profileToConnect == null) { - profileToConnect = ProfileManager.getInstance(this).getProfileByName(shortcutName); - if (!(new ExternalAppDatabase(this).checkRemoteActionPermission(this, getCallingPackage()))) { - finish(); - return; - } + VpnProfile profileToConnect = ProfileManager.get(this, shortcutUUID); + if (shortcutName != null && profileToConnect == null) { + profileToConnect = ProfileManager.getInstance(this).getProfileByName(shortcutName); + if (!(new ExternalAppDatabase(this).checkRemoteActionPermission(this, getCallingPackage()))) { + finish(); + return; } + } - if (profileToConnect == null) { - VpnStatus.logError(R.string.shortcut_profile_notfound); - // show Log window to display error - showLogWindow(); - finish(); - } else { - mSelectedProfile = profileToConnect; - launchVPN(); - } + if (profileToConnect == null) { + VpnStatus.logError(R.string.shortcut_profile_notfound); + // show Log window to display error + showLogWindow(); + finish(); + } else { + mSelectedProfile = profileToConnect; + mSelectedProfileReason = startReason; + launchVPN(); } + } private void askForPW(final int type) { @@ -251,7 +255,7 @@ public class LaunchVPN extends Activity { if (!mhideLog && showLogWindow) showLogWindow(); ProfileManager.updateLRU(this, mSelectedProfile); - VPNLaunchHelper.startOpenVpn(mSelectedProfile, getBaseContext()); + VPNLaunchHelper.startOpenVpn(mSelectedProfile, getBaseContext(), mSelectedProfileReason); finish(); } } else if (resultCode == Activity.RESULT_CANCELED) { |