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