Java Code Examples for de.blinkt.openvpn.core.VpnStatus#updateStateString()
The following examples show how to use
de.blinkt.openvpn.core.VpnStatus#updateStateString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VPNActivity.java From SimpleOpenVpn-Android with Apache License 2.0 | 6 votes |
/** * 开始连接 */ public void connectVpn() { Intent intent = VpnService.prepare(this); if (intent != null) { VpnStatus.updateStateString("USER_VPN_PERMISSION", "", R.string.state_user_vpn_permission, LEVEL_WAITING_FOR_USER_INPUT); // Start the query try { startActivityForResult(intent, START_VPN_PROFILE); } catch (ActivityNotFoundException ane) { // Shame on you Sony! At least one user reported that // an official Sony Xperia Arc S image triggers this exception VpnStatus.logError(R.string.no_vpn_support_image); } } else { onActivityResult(START_VPN_PROFILE, Activity.RESULT_OK, null); } }
Example 2
Source File: ServerActivity.java From EasyVPN-Free with GNU General Public License v3.0 | 6 votes |
private void startVpn() { stopwatch = new Stopwatch(); connectedServer = currentServer; hideCurrentConnection = true; adbBlockCheck.setEnabled(false); Intent intent = VpnService.prepare(this); if (intent != null) { VpnStatus.updateStateString("USER_VPN_PERMISSION", "", R.string.state_user_vpn_permission, VpnStatus.ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT); // Start the query try { startActivityForResult(intent, START_VPN_PROFILE); } catch (ActivityNotFoundException ane) { // Shame on you Sony! At least one user reported that // an official Sony Xperia Arc S image triggers this exception VpnStatus.logError(R.string.no_vpn_support_image); } } else { onActivityResult(START_VPN_PROFILE, Activity.RESULT_OK, null); } }
Example 3
Source File: LaunchVPN.java From bitmask_android with GNU General Public License v3.0 | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode==START_VPN_PROFILE) { SharedPreferences prefs = Preferences.getDefaultSharedPreferences(this); boolean showLogWindow = prefs.getBoolean("showlogwindow", true); if(!mhideLog && showLogWindow) showLogWindow(); VPNLaunchHelper.startOpenVpn(mSelectedProfile, getBaseContext()); finish(); } else if (resultCode == Activity.RESULT_CANCELED) { // User does not want us to start, so we just vanish VpnStatus.updateStateString("USER_VPN_PERMISSION_CANCELLED", "", R.string.state_user_vpn_permission_cancelled, ConnectionStatus.LEVEL_NOTCONNECTED); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) VpnStatus.logError(R.string.nought_alwayson_warning); finish(); } }
Example 4
Source File: VoidVpnService.java From bitmask_android with GNU General Public License v3.0 | 6 votes |
private void establishBlockingVpn() { try { VpnStatus.logInfo(getProviderFormattedString(getResources(), R.string.void_vpn_establish)); VpnStatus.updateStateString(STATE_ESTABLISH, "", R.string.void_vpn_establish, ConnectionStatus.LEVEL_BLOCKING); Builder builder = prepareBlockingVpnProfile(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.addDisallowedApplication(getPackageName()); } fd = builder.establish(); } catch (Exception e) { // Catch any exception e.printStackTrace(); VpnStatus.logError(R.string.void_vpn_error_establish); } }
Example 5
Source File: LaunchVPN.java From android with GNU General Public License v3.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == START_VPN_PROFILE) { if (resultCode == Activity.RESULT_OK) { int needpw = mSelectedProfile.needUserPWInput(false); if (needpw != 0) { VpnStatus.updateStateString("USER_VPN_PASSWORD", "", R.string.state_user_vpn_password, ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT); askForPW(needpw); } else { new Thread(startOpenVpnRunnable).start(); } } else if (resultCode == Activity.RESULT_CANCELED) { // User does not want us to start, so we just vanish VpnStatus.updateStateString("USER_VPN_PERMISSION_CANCELLED", "", R.string.state_user_vpn_permission_cancelled, ConnectionStatus.LEVEL_NOTCONNECTED); finish(); } } else if(requestCode == LOGIN_ACTIVITY) { if (resultCode == RESULT_OK) { mSelectedProfile.mUsername = PrefUtils.get(this, Preferences.USERNAME, ""); mSelectedProfile.mPassword = PrefUtils.get(this, Preferences.PASSWORD, ""); onActivityResult(START_VPN_PROFILE, Activity.RESULT_OK, null); } else { VpnStatus.updateStateString("USER_VPN_PASSWORD_CANCELLED", "", R.string.state_user_vpn_password_cancelled, ConnectionStatus.LEVEL_NOTCONNECTED); finish(); } } }
Example 6
Source File: LaunchVPN.java From android with GNU General Public License v3.0 | 5 votes |
void launchVPN() { int vpnok = mSelectedProfile.checkProfile(this); if (vpnok != R.string.no_error_found) { showConfigErrorDialog(vpnok); return; } Intent intent = VpnService.prepare(this); // Check if we want to fix /dev/tun SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean usecm9fix = prefs.getBoolean("useCM9Fix", false); boolean loadTunModule = prefs.getBoolean("loadTunModule", false); if (loadTunModule) execeuteSUcmd("insmod /system/lib/modules/tun.ko"); if (usecm9fix && !mCmfixed) { execeuteSUcmd("chown system /dev/tun"); } if (intent != null) { VpnStatus.updateStateString("USER_VPN_PERMISSION", "", R.string.state_user_vpn_permission, ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT); // Start the query startActivityForResult(new Intent(this, GrantPermissionsActivity.class), START_VPN_PROFILE); } else { onActivityResult(START_VPN_PROFILE, Activity.RESULT_OK, null); } }
Example 7
Source File: VoidVpnService.java From bitmask_android with GNU General Public License v3.0 | 5 votes |
private void stop() { notificationManager.stopNotifications(NOTIFICATION_CHANNEL_NEWSTATUS_ID); notificationManager.deleteNotificationChannel(NOTIFICATION_CHANNEL_NEWSTATUS_ID); if (thread != null) { thread.interrupt(); } closeFd(); VpnStatus.updateStateString("NOPROCESS", "BLOCKING VPN STOPPED", R.string.state_noprocess, ConnectionStatus.LEVEL_NOTCONNECTED); }
Example 8
Source File: EipStatusTest.java From bitmask_android with GNU General Public License v3.0 | 5 votes |
@Test public void testUpdateState_LEVEL_VPNPAUSED_hasPersistentTun() throws Exception { mockStatic(PreferenceHelper.class); VpnProfile mockVpnProfile = new VpnProfile("mockProfile", OPENVPN); mockVpnProfile.mPersistTun = true; doNothing().when(PreferenceHelper.class); VpnStatus.setLastConnectedVpnProfile(null, mockVpnProfile); VpnStatus.updateStateString("SCREENOFF", "", R.string.state_screenoff, LEVEL_VPNPAUSED); assertTrue("LEVEL_VPN_PAUSED eipLevel", eipStatus.getEipLevel() == CONNECTING); assertTrue("LEVEL_VPN_PAUSED level", eipStatus.getLevel() == LEVEL_VPNPAUSED); }
Example 9
Source File: EipStatusTest.java From bitmask_android with GNU General Public License v3.0 | 5 votes |
@Test public void testUpdateState_LEVEL_VPNPAUSED_hasNotPersistentTun() throws Exception { mockStatic(PreferenceHelper.class); VpnProfile mockVpnProfile = new VpnProfile("mockProfile", OPENVPN); mockVpnProfile.mPersistTun = false; doNothing().when(PreferenceHelper.class); VpnStatus.setLastConnectedVpnProfile(null, mockVpnProfile); VpnStatus.updateStateString("SCREENOFF", "", R.string.state_screenoff, LEVEL_VPNPAUSED); assertTrue("LEVEL_VPN_PAUSED eipLevel", eipStatus.getEipLevel() == DISCONNECTED); assertTrue("LEVEL_VPN_PAUSED level", eipStatus.getLevel() == LEVEL_VPNPAUSED); }
Example 10
Source File: LaunchVPN.java From bitmask_android with GNU General Public License v3.0 | 4 votes |
void launchVPN() { int vpnok = mSelectedProfile.checkProfile(this); if (vpnok != R.string.no_error_found) { showConfigErrorDialog(vpnok); return; } Intent intent = null; try { intent = VpnService.prepare(this.getApplicationContext()); } catch (NullPointerException npe) { tellToReceiverOrBroadcast(this.getApplicationContext(), EIP_ACTION_PREPARE_VPN, RESULT_CANCELED); finish(); return; } // Check if we want to fix /dev/tun SharedPreferences prefs = Preferences.getDefaultSharedPreferences(this); boolean usecm9fix = prefs.getBoolean("useCM9Fix", false); boolean loadTunModule = prefs.getBoolean("loadTunModule", false); if (loadTunModule) execeuteSUcmd("insmod /system/lib/modules/tun.ko"); if (usecm9fix && !mCmfixed) { execeuteSUcmd("chown system /dev/tun"); } if (intent != null) { VpnStatus.updateStateString("USER_VPN_PERMISSION", "", R.string.state_user_vpn_permission, ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT); // Start the query try { startActivityForResult(intent, START_VPN_PROFILE); } catch (ActivityNotFoundException ane) { // Shame on you Sony! At least one user reported that // an official Sony Xperia Arc S image triggers this exception VpnStatus.logError(R.string.no_vpn_support_image); showLogWindow(); } } else { onActivityResult(START_VPN_PROFILE, Activity.RESULT_OK, null); } }
Example 11
Source File: EIP.java From bitmask_android with GNU General Public License v3.0 | 4 votes |
/** * Stop VPN * First checks if the OpenVpnConnection is open then * terminates EIP if currently connected or connecting */ private void stopEIP() { VpnStatus.updateStateString("STOPPING", "STOPPING VPN", R.string.state_exiting, ConnectionStatus.LEVEL_STOPPING); int resultCode = stop() ? RESULT_OK : RESULT_CANCELED; tellToReceiverOrBroadcast(this, EIP_ACTION_STOP, resultCode); }