aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2017-05-05 01:02:16 +0200
committerPacien TRAN-GIRARD2017-05-05 01:02:16 +0200
commit2495d8032eb6839a55080b79ac818383c2f75b79 (patch)
tree6dfbab541368d10ddf1903e3ad93c44ea81080be /app
parent6fcd36fb73b2351a58f812532ce846414ed77117 (diff)
downloadtincapp-2495d8032eb6839a55080b79ac818383c2f75b79.tar.gz
Import unversioned prototypev0.1-preview
Diffstat (limited to 'app')
-rw-r--r--app/CMakeLists.txt54
-rw-r--r--app/build.gradle49
-rw-r--r--app/proguard-rules.pro1
-rw-r--r--app/src/androidTest/java/org/pacien/tincapp/.gitkeep0
-rw-r--r--app/src/main/AndroidManifest.xml35
-rw-r--r--app/src/main/c/exec.c34
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseActivity.java71
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StartActivity.java82
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Command.java67
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Executor.java44
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/PermissionFixer.java34
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tinc.java60
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tincd.java28
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppInfo.java42
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppPaths.java75
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/TincVpnService.java51
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/VpnInterfaceConfigurator.java81
-rw-r--r--app/src/main/java/org/pacien/tincapp/util/Function.java28
-rw-r--r--app/src/main/res/drawable/ic_help_primary_24dp.xml9
-rw-r--r--app/src/main/res/icon.pngbin0 -> 13933 bytes
-rw-r--r--app/src/main/res/icon.svg1
-rw-r--r--app/src/main/res/layout/base.xml47
-rw-r--r--app/src/main/res/layout/dialog_frame.xml11
-rw-r--r--app/src/main/res/layout/page_start.xml43
-rw-r--r--app/src/main/res/menu/menu_base.xml14
-rw-r--r--app/src/main/res/mipmap-hdpi/ic_launcher.pngbin0 -> 1103 bytes
-rw-r--r--app/src/main/res/mipmap-mdpi/ic_launcher.pngbin0 -> 777 bytes
-rw-r--r--app/src/main/res/mipmap-xhdpi/ic_launcher.pngbin0 -> 1400 bytes
-rw-r--r--app/src/main/res/mipmap-xxhdpi/ic_launcher.pngbin0 -> 2312 bytes
-rw-r--r--app/src/main/res/mipmap-xxxhdpi/ic_launcher.pngbin0 -> 3425 bytes
-rw-r--r--app/src/main/res/values-v21/styles.xml8
-rw-r--r--app/src/main/res/values-w820dp/dimens.xml3
-rw-r--r--app/src/main/res/values/colors.xml7
-rw-r--r--app/src/main/res/values/dimens.xml9
-rw-r--r--app/src/main/res/values/strings.xml33
-rw-r--r--app/src/main/res/values/styles.xml16
36 files changed, 1037 insertions, 0 deletions
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
new file mode 100644
index 0000000..d115cb6
--- /dev/null
+++ b/app/CMakeLists.txt
@@ -0,0 +1,54 @@
1cmake_minimum_required(VERSION 3.4.1)
2include(ExternalProject)
3
4set(xCONFIG
5 "CC=${CMAKE_C_COMPILER} ${CMAKE_C_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN}${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN} ${CMAKE_C_COMPILE_OPTIONS_TARGET}${CMAKE_C_COMPILER_TARGET}"
6 "LD=${CMAKE_LINKER}"
7 "AR=${CMAKE_AR}"
8 "RANLIB=${CMAKE_RANLIB}"
9 "CFLAGS=${CMAKE_C_FLAGS} ${CMAKE_C_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}"
10 "LDFLAGS=${CMAKE_STATIC_LINKER_FLAGS} ${CMAKE_C_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}"
11 "--host=${CMAKE_C_COMPILER_TARGET}"
12)
13
14if(${ANDROID_ABI} STREQUAL "mips64")
15 list(APPEND xCONFIG --disable-asm)
16endif()
17
18ExternalProject_Add(lzo
19 URL http://files.pacien.net/tmp/lzo-2.10.tar.gz
20 URL_HASH SHA1=4924676a9bae5db58ef129dc1cebce3baa3c4b5d
21 CONFIGURE_COMMAND <SOURCE_DIR>/configure ${xCONFIG} --disable-shared
22 BUILD_COMMAND make -j4
23 INSTALL_COMMAND make install DESTDIR=${CMAKE_CURRENT_BINARY_DIR} &&
24 rm -r <BINARY_DIR>
25)
26
27ExternalProject_Add(libressl
28 URL http://files.pacien.net/tmp/libressl-2.5.4.tar.gz
29 URL_HASH SHA256=107a5b522fbb8318d4c3be668075e5e607296f0a9255d71674caa94571336efa
30 CONFIGURE_COMMAND <SOURCE_DIR>/configure ${xCONFIG} --disable-shared
31 BUILD_COMMAND make -j4 -C crypto
32 INSTALL_COMMAND make -C crypto install DESTDIR=${CMAKE_CURRENT_BINARY_DIR} &&
33 make -C include install DESTDIR=${CMAKE_CURRENT_BINARY_DIR} &&
34 rm -r <BINARY_DIR>
35)
36
37ExternalProject_Add(tinc
38 DEPENDS lzo libressl
39 URL http://files.pacien.net/tmp/tinc-1.1pre15-SNAPSHOT.tar.gz
40 CONFIGURE_COMMAND autoreconf -fsi <SOURCE_DIR> &&
41 <SOURCE_DIR>/configure ${xCONFIG}
42 --with-openssl=${CMAKE_CURRENT_BINARY_DIR}/usr/local
43 --with-lzo=${CMAKE_CURRENT_BINARY_DIR}/usr/local
44 --disable-curses
45 --disable-readline
46 BUILD_COMMAND make -j4 -C src
47 INSTALL_COMMAND make -C src install DESTDIR=${CMAKE_CURRENT_BINARY_DIR} &&
48 ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/usr/local/sbin/tinc ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libtinc.so &&
49 ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/usr/local/sbin/tincd ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libtincd.so &&
50 rm -r <BINARY_DIR>
51)
52
53add_library(exec SHARED src/main/c/exec.c)
54add_dependencies(exec tinc)
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..33514ea
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,49 @@
1apply plugin: 'com.android.application'
2apply plugin: 'me.tatarka.retrolambda'
3
4android {
5 compileSdkVersion 25
6 buildToolsVersion '25.0.0'
7 defaultConfig {
8 applicationId "org.pacien.tincapp"
9 minSdkVersion 21
10 targetSdkVersion 25
11 versionCode 1
12 versionName "0.1-preview"
13 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 }
15 buildTypes {
16 release {
17 minifyEnabled true
18 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 }
20 }
21 compileOptions {
22 sourceCompatibility JavaVersion.VERSION_1_8
23 targetCompatibility JavaVersion.VERSION_1_8
24 }
25 externalNativeBuild {
26 cmake {
27 path "CMakeLists.txt"
28 }
29 }
30}
31
32dependencies {
33 compile fileTree(dir: 'libs', include: ['*.jar'])
34
35 compile 'com.android.support:appcompat-v7:25.3.1'
36 compile 'com.android.support:design:25.3.1'
37 compile 'com.android.support:support-v4:25.3.1'
38 compile 'com.android.support:recyclerview-v7:25.3.1'
39 compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4'
40
41 compile('org.apache.commons:commons-configuration2:2.1.1') {
42 exclude group: 'commons-logging', module: 'commons-logging'
43 }
44 compile('commons-beanutils:commons-beanutils:1.9.3') {
45 exclude group: 'commons-logging', module: 'commons-logging'
46 }
47
48 compile 'com.annimon:stream:1.1.5'
49}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..f795eae
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1 @@
-dontwarn org.apache.commons.**
diff --git a/app/src/androidTest/java/org/pacien/tincapp/.gitkeep b/app/src/androidTest/java/org/pacien/tincapp/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/src/androidTest/java/org/pacien/tincapp/.gitkeep
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..2822d37
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,35 @@
1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="org.pacien.tincapp">
4
5 <uses-permission android:name="android.permission.INTERNET"/>
6 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
7
8 <application
9 android:allowBackup="false"
10 android:icon="@mipmap/ic_launcher"
11 android:label="@string/app_label"
12 android:supportsRtl="true"
13 android:theme="@style/AppTheme">
14
15 <activity
16 android:name=".activities.StartActivity"
17 android:label="@string/app_label"
18 android:theme="@style/AppTheme.NoActionBar">
19 <intent-filter>
20 <action android:name="android.intent.action.MAIN"/>
21 <category android:name="android.intent.category.LAUNCHER"/>
22 </intent-filter>
23 </activity>
24
25 <service
26 android:name="org.pacien.tincapp.service.TincVpnService"
27 android:permission="android.permission.BIND_VPN_SERVICE">
28 <intent-filter>
29 <action android:name="android.net.VpnService"/>
30 </intent-filter>
31 </service>
32
33 </application>
34
35</manifest>
diff --git a/app/src/main/c/exec.c b/app/src/main/c/exec.c
new file mode 100644
index 0000000..fdaec0f
--- /dev/null
+++ b/app/src/main/c/exec.c
@@ -0,0 +1,34 @@
1#include <jni.h>
2#include <unistd.h>
3#include <stdlib.h>
4
5static inline const char **to_string_array(JNIEnv *env, jobjectArray ja) {
6 const int len = (*env)->GetArrayLength(env, ja);
7 const char **ca = calloc((size_t) len + 1, sizeof(char *));
8
9 for (int i = 0; i < len; ++i) {
10 jstring jstr = (jstring) (*env)->GetObjectArrayElement(env, ja, i);
11 ca[i] = (*env)->GetStringUTFChars(env, jstr, NULL);
12 }
13
14 ca[len] = NULL;
15 return ca;
16}
17
18static inline void exec(const char **argcv) {
19 execv(argcv[0], (char *const *) argcv);
20 exit(1);
21}
22
23JNIEXPORT jint JNICALL
24Java_org_pacien_tincapp_commands_Executor_forkExec(JNIEnv *env, jclass class, jobjectArray argcv) {
25 pid_t pid = fork();
26 switch (pid) {
27 case 0: