Java code style fixed (analogous to C code).

This commit is contained in:
Tobias Brunner
2012-08-08 15:12:24 +02:00
parent 06ed785e5a
commit a405760395
2 changed files with 28 additions and 14 deletions
@@ -3,24 +3,29 @@ package org.strongswan.android;
import android.content.Intent; import android.content.Intent;
import android.net.VpnService; import android.net.VpnService;
public class CharonVpnService extends VpnService { public class CharonVpnService extends VpnService
{
@Override @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 // 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); return super.onStartCommand(intent, flags, startId);
} }
@Override @Override
public void onCreate() { public void onCreate()
{
// onCreate is only called once // onCreate is only called once
initializeCharon(); initializeCharon();
super.onCreate(); super.onCreate();
} }
@Override @Override
public void onDestroy() { public void onDestroy()
{
// called once the service is to be destroyed // called once the service is to be destroyed
deinitializeCharon(); deinitializeCharon();
super.onDestroy(); super.onDestroy();
@@ -40,7 +45,8 @@ public class CharonVpnService extends VpnService {
* The libraries are extracted to /data/data/org.strongswan.android/... * The libraries are extracted to /data/data/org.strongswan.android/...
* during installation. * during installation.
*/ */
static { static
{
System.loadLibrary("crypto"); System.loadLibrary("crypto");
System.loadLibrary("strongswan"); System.loadLibrary("strongswan");
System.loadLibrary("hydra"); System.loadLibrary("hydra");
@@ -5,28 +5,36 @@ import android.content.Intent;
import android.net.VpnService; import android.net.VpnService;
import android.os.Bundle; import android.os.Bundle;
public class strongSwanActivity extends Activity { public class strongSwanActivity extends Activity
{
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.main); setContentView(R.layout.main);
startVpnService(); startVpnService();
} }
private void startVpnService() { private void startVpnService()
{
Intent intent = VpnService.prepare(this); Intent intent = VpnService.prepare(this);
if (intent != null) { if (intent != null)
{
startActivityForResult(intent, 0); startActivityForResult(intent, 0);
} else { }
else
{
onActivityResult(0, RESULT_OK, null); onActivityResult(0, RESULT_OK, null);
} }
} }
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data)
if (resultCode == RESULT_OK) { {
if (resultCode == RESULT_OK)
{
Intent intent = new Intent(this, CharonVpnService.class); Intent intent = new Intent(this, CharonVpnService.class);
startService(intent); startService(intent);
} }
} }
} }