596372f9d66552aadbfecb68d432a861462516b5
[strongswan.git] / src / frontends / android / src / org / strongswan / android / CharonVpnService.java
1 package org.strongswan.android;
2
3 import android.content.Intent;
4 import android.net.VpnService;
5
6 public class CharonVpnService extends VpnService {
7
8 @Override
9 public int onStartCommand(Intent intent, int flags, int startId) {
10 // called whenever the service is started with startService
11 // create our own thread because we are running in the calling processes main thread
12 return super.onStartCommand(intent, flags, startId);
13 }
14
15 @Override
16 public void onCreate() {
17 // onCreate is only called once
18 initializeCharon();
19 super.onCreate();
20 }
21
22 @Override
23 public void onDestroy() {
24 // called once the service is to be destroyed
25 deinitializeCharon();
26 super.onDestroy();
27 }
28
29 /**
30 * Initialization of charon, provided by libandroidbridge.so
31 */
32 public native void initializeCharon();
33
34 /**
35 * Deinitialize charon, provided by libandroidbridge.so
36 */
37 public native void deinitializeCharon();
38
39 /*
40 * The libraries are extracted to /data/data/org.strongswan.android/...
41 * during installation.
42 */
43 static {
44 System.loadLibrary("crypto");
45 System.loadLibrary("strongswan");
46 System.loadLibrary("hydra");
47 System.loadLibrary("charon");
48 System.loadLibrary("androidbridge");
49 }
50 }