diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/src/main/AndroidManifest.xml | 9 | ||||
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/api/RemoteAction.java | 47 |
2 files changed, 36 insertions, 20 deletions
diff --git a/main/src/main/AndroidManifest.xml b/main/src/main/AndroidManifest.xml index 7ff33676..6cfbfffa 100644 --- a/main/src/main/AndroidManifest.xml +++ b/main/src/main/AndroidManifest.xml @@ -126,6 +126,15 @@ android:name=".api.DisconnectVPN" android:exported="true" android:targetActivity=".api.RemoteAction" /> + <activity-alias + android:name=".api.PauseVPN" + android:exported="true" + android:targetActivity=".api.RemoteAction" /> + <activity-alias + android:name=".api.ResumeVPN" + android:exported="true" + android:targetActivity=".api.RemoteAction" /> + </application> </manifest>
\ No newline at end of file diff --git a/main/src/main/java/de/blinkt/openvpn/api/RemoteAction.java b/main/src/main/java/de/blinkt/openvpn/api/RemoteAction.java index ebd2fe44..0554b88c 100644 --- a/main/src/main/java/de/blinkt/openvpn/api/RemoteAction.java +++ b/main/src/main/java/de/blinkt/openvpn/api/RemoteAction.java @@ -24,10 +24,9 @@ import de.blinkt.openvpn.core.ProfileManager; public class RemoteAction extends Activity { public static final String EXTRA_NAME = "de.blinkt.openvpn.api.profileName"; - private ExternalAppDatabase mExtAppDb; private boolean mDoDisconnect; private IOpenVPNServiceInternal mService; - private ServiceConnection mConnection = new ServiceConnection() { + private final ServiceConnection mConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName className, IBinder service) { @@ -50,8 +49,6 @@ public class RemoteAction extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - mExtAppDb = new ExternalAppDatabase(this); } @Override @@ -74,24 +71,34 @@ public class RemoteAction extends Activity { Intent intent = getIntent(); setIntent(null); ComponentName component = intent.getComponent(); - if (component.getShortClassName().equals(".api.DisconnectVPN")) { - mService.stopVPN(false); - } else if (component.getShortClassName().equals(".api.ConnectVPN")) { - String vpnName = intent.getStringExtra(EXTRA_NAME); - VpnProfile profile = ProfileManager.getInstance(this).getProfileByName(vpnName); - if (profile == null) { - Toast.makeText(this, String.format("Vpn profile %s from API call not found", vpnName), Toast.LENGTH_LONG).show(); - } else { - Intent startVPN = new Intent(this, LaunchVPN.class); - startVPN.putExtra(LaunchVPN.EXTRA_KEY, profile.getUUID().toString()); - startVPN.setAction(Intent.ACTION_MAIN); - startActivity(startVPN); - } - } - finish(); - + if (component == null) + return; + switch (component.getShortClassName()) { + case ".api.DisconnectVPN": + mService.stopVPN(false); + break; + case ".api.PauseVPN": + mService.userPause(true); + break; + case ".api.ResumeVPN": + mService.userPause(false); + break; + case ".api.ConnectVPN": + String vpnName = intent.getStringExtra(EXTRA_NAME); + VpnProfile profile = ProfileManager.getInstance(this).getProfileByName(vpnName); + if (profile == null) { + Toast.makeText(this, String.format("Vpn profile %s from API call not found", vpnName), Toast.LENGTH_LONG).show(); + } else { + Intent startVPN = new Intent(this, LaunchVPN.class); + startVPN.putExtra(LaunchVPN.EXTRA_KEY, profile.getUUID().toString()); + startVPN.setAction(Intent.ACTION_MAIN); + startActivity(startVPN); + } + break; + } + finish(); } @Override |