From 9ad3f40880fa998063e6d3bcb994e918b44272bc Mon Sep 17 00:00:00 2001 From: Chia-chi Yeh Date: Wed, 23 Nov 2011 17:09:17 -0800 Subject: [PATCH] Android VPN sample for ICS SDK Change-Id: I84e568625c5c9cc9b48f338e2d6226a8e9f67017 --- build/sdk.atree | 1 + samples/ToyVpn/Android.mk | 16 + samples/ToyVpn/AndroidManifest.xml | 41 +++ samples/ToyVpn/_index.html | 7 + samples/ToyVpn/res/layout/form.xml | 37 ++ samples/ToyVpn/res/values/strings.xml | 29 ++ samples/ToyVpn/res/values/styles.xml | 25 ++ samples/ToyVpn/server/linux/Makefile | 18 + samples/ToyVpn/server/linux/ToyVpnServer.cpp | 288 +++++++++++++++ samples/ToyVpn/server/linux/_index.html | 1 + .../example/android/toyvpn/ToyVpnClient.java | 66 ++++ .../example/android/toyvpn/ToyVpnService.java | 337 ++++++++++++++++++ 12 files changed, 866 insertions(+) create mode 100644 samples/ToyVpn/Android.mk create mode 100644 samples/ToyVpn/AndroidManifest.xml create mode 100755 samples/ToyVpn/_index.html create mode 100644 samples/ToyVpn/res/layout/form.xml create mode 100644 samples/ToyVpn/res/values/strings.xml create mode 100644 samples/ToyVpn/res/values/styles.xml create mode 100644 samples/ToyVpn/server/linux/Makefile create mode 100644 samples/ToyVpn/server/linux/ToyVpnServer.cpp create mode 100755 samples/ToyVpn/server/linux/_index.html create mode 100644 samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnClient.java create mode 100644 samples/ToyVpn/src/com/example/android/toyvpn/ToyVpnService.java diff --git a/build/sdk.atree b/build/sdk.atree index 44430f627..148899b52 100644 --- a/build/sdk.atree +++ b/build/sdk.atree @@ -184,6 +184,7 @@ development/samples/SpinnerTest samples/${PLATFORM_NAME}/SpinnerT development/samples/TicTacToeLib samples/${PLATFORM_NAME}/TicTacToeLib development/samples/TicTacToeMain samples/${PLATFORM_NAME}/TicTacToeMain development/samples/TtsEngine samples/${PLATFORM_NAME}/TtsEngine +development/samples/ToyVpn samples/${PLATFORM_NAME}/ToyVpn development/samples/USB/MissileLauncher samples/${PLATFORM_NAME}/USB/MissileLauncher development/samples/USB/AdbTest samples/${PLATFORM_NAME}/USB/AdbTest development/samples/VoiceRecognitionService samples/${PLATFORM_NAME}/VoiceRecognitionService diff --git a/samples/ToyVpn/Android.mk b/samples/ToyVpn/Android.mk new file mode 100644 index 000000000..8fe714cae --- /dev/null +++ b/samples/ToyVpn/Android.mk @@ -0,0 +1,16 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := samples + +# Only compile source java files in this apk. +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := ToyVpn + +LOCAL_SDK_VERSION := current + +include $(BUILD_PACKAGE) + +# Use the following include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/samples/ToyVpn/AndroidManifest.xml b/samples/ToyVpn/AndroidManifest.xml new file mode 100644 index 000000000..8366dd6bc --- /dev/null +++ b/samples/ToyVpn/AndroidManifest.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ToyVpn/_index.html b/samples/ToyVpn/_index.html new file mode 100755 index 000000000..d896899c2 --- /dev/null +++ b/samples/ToyVpn/_index.html @@ -0,0 +1,7 @@ +

ToyVPN is a sample application that shows how to build a VPN client using the VpnService class introduced in API level 14.

+ +

This application consists of an Android client and a sample implementation of a server. It performs IP over UDP and is capable of doing seamless handover between different networks as long as it receives the same VPN parameters.

+ +

The sample code of the server-side implementation is Linux-specific and is available in the server directory. To run the server or port it to another platform, please see comments in the code for the details.

+ + diff --git a/samples/ToyVpn/res/layout/form.xml b/samples/ToyVpn/res/layout/form.xml new file mode 100644 index 000000000..7a325db54 --- /dev/null +++ b/samples/ToyVpn/res/layout/form.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + +