Java code style fixed (analogous to C code).
This commit is contained in:
@@ -3,24 +3,29 @@ package org.strongswan.android;
|
||||
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();
|
||||
@@ -40,7 +45,8 @@ public class CharonVpnService extends VpnService {
|
||||
* The libraries are extracted to /data/data/org.strongswan.android/...
|
||||
* during installation.
|
||||
*/
|
||||
static {
|
||||
static
|
||||
{
|
||||
System.loadLibrary("crypto");
|
||||
System.loadLibrary("strongswan");
|
||||
System.loadLibrary("hydra");
|
||||
|
||||
@@ -5,28 +5,36 @@ import android.content.Intent;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user