import android.content.Intent;
import android.net.VpnService;
-public class CharonVpnService extends VpnService {
+public class CharonVpnService extends VpnService
+{
@Override
- public int onStartCommand(Intent intent, int flags, int startId) {
+ public int onStartCommand(Intent intent, int flags, int startId)
+ {
// called whenever the service is started with startService
- // create our own thread because we are running in the calling processes main thread
+ // create our own thread because we are running in the calling processes
+ // main thread
return super.onStartCommand(intent, flags, startId);
}
@Override
- public void onCreate() {
+ public void onCreate()
+ {
// onCreate is only called once
initializeCharon();
super.onCreate();
}
@Override
- public void onDestroy() {
+ public void onDestroy()
+ {
// called once the service is to be destroyed
deinitializeCharon();
super.onDestroy();
* The libraries are extracted to /data/data/org.strongswan.android/...
* during installation.
*/
- static {
+ static
+ {
System.loadLibrary("crypto");
System.loadLibrary("strongswan");
System.loadLibrary("hydra");
import android.net.VpnService;
import android.os.Bundle;
-public class strongSwanActivity extends Activity {
+public class strongSwanActivity extends Activity
+{
@Override
- public void onCreate(Bundle savedInstanceState) {
+ public void onCreate(Bundle savedInstanceState)
+ {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
startVpnService();
}
- private void startVpnService() {
+ private void startVpnService()
+ {
Intent intent = VpnService.prepare(this);
- if (intent != null) {
+ if (intent != null)
+ {
startActivityForResult(intent, 0);
- } else {
+ }
+ else
+ {
onActivityResult(0, RESULT_OK, null);
}
}
@Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (resultCode == RESULT_OK) {
+ protected void onActivityResult(int requestCode, int resultCode, Intent data)
+ {
+ if (resultCode == RESULT_OK)
+ {
Intent intent = new Intent(this, CharonVpnService.class);
startService(intent);
}
}
-}
\ No newline at end of file
+}