aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/CMakeLists.txt25
-rw-r--r--app/build.gradle18
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseActivity.java71
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt62
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StartActivity.java82
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt82
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Command.java67
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Command.kt36
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Executor.java44
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Executor.kt43
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/PermissionFixer.java34
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/PermissionFixer.kt20
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tinc.java60
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tinc.kt49
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tincd.java28
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tincd.kt25
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppInfo.java42
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppInfo.kt32
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppPaths.java75
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppPaths.kt43
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/TincVpnService.java51
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt49
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/VpnInterfaceConfigurator.java81
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/VpnInterfaceConfigurator.kt52
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/VpnServiceBuilderExtensions.kt45
-rw-r--r--app/src/main/java/org/pacien/tincapp/util/Function.java28
26 files changed, 561 insertions, 683 deletions
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index d115cb6..8114db4 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -2,20 +2,19 @@ cmake_minimum_required(VERSION 3.4.1)
2include(ExternalProject) 2include(ExternalProject)
3 3
4set(xCONFIG 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}" 5 "CC=${CMAKE_C_COMPILER} \
6 ${CMAKE_C_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN}${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN} \
7 ${CMAKE_C_COMPILE_OPTIONS_TARGET}${CMAKE_C_COMPILER_TARGET} \
8 ${CMAKE_C_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}"
6 "LD=${CMAKE_LINKER}" 9 "LD=${CMAKE_LINKER}"
7 "AR=${CMAKE_AR}" 10 "AR=${CMAKE_AR}"
8 "RANLIB=${CMAKE_RANLIB}" 11 "RANLIB=${CMAKE_RANLIB}"
9 "CFLAGS=${CMAKE_C_FLAGS} ${CMAKE_C_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}" 12 "CFLAGS=${CMAKE_C_FLAGS}"
10 "LDFLAGS=${CMAKE_STATIC_LINKER_FLAGS} ${CMAKE_C_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}" 13 "LDFLAGS=${CMAKE_SHARED_LINKER_FLAGS}"
11 "--host=${CMAKE_C_COMPILER_TARGET}" 14 "--host=${CMAKE_C_COMPILER_TARGET}"
12) 15)
13 16
14if(${ANDROID_ABI} STREQUAL "mips64") 17ExternalProject_Add( lzo
15 list(APPEND xCONFIG --disable-asm)
16endif()
17
18ExternalProject_Add(lzo
19 URL http://files.pacien.net/tmp/lzo-2.10.tar.gz 18 URL http://files.pacien.net/tmp/lzo-2.10.tar.gz
20 URL_HASH SHA1=4924676a9bae5db58ef129dc1cebce3baa3c4b5d 19 URL_HASH SHA1=4924676a9bae5db58ef129dc1cebce3baa3c4b5d
21 CONFIGURE_COMMAND <SOURCE_DIR>/configure ${xCONFIG} --disable-shared 20 CONFIGURE_COMMAND <SOURCE_DIR>/configure ${xCONFIG} --disable-shared
@@ -24,7 +23,7 @@ ExternalProject_Add(lzo
24 rm -r <BINARY_DIR> 23 rm -r <BINARY_DIR>
25) 24)
26 25
27ExternalProject_Add(libressl 26ExternalProject_Add( libressl
28 URL http://files.pacien.net/tmp/libressl-2.5.4.tar.gz 27 URL http://files.pacien.net/tmp/libressl-2.5.4.tar.gz
29 URL_HASH SHA256=107a5b522fbb8318d4c3be668075e5e607296f0a9255d71674caa94571336efa 28 URL_HASH SHA256=107a5b522fbb8318d4c3be668075e5e607296f0a9255d71674caa94571336efa
30 CONFIGURE_COMMAND <SOURCE_DIR>/configure ${xCONFIG} --disable-shared 29 CONFIGURE_COMMAND <SOURCE_DIR>/configure ${xCONFIG} --disable-shared
@@ -34,7 +33,7 @@ ExternalProject_Add(libressl
34 rm -r <BINARY_DIR> 33 rm -r <BINARY_DIR>
35) 34)
36 35
37ExternalProject_Add(tinc 36ExternalProject_Add( tinc
38 DEPENDS lzo libressl 37 DEPENDS lzo libressl
39 URL http://files.pacien.net/tmp/tinc-1.1pre15-SNAPSHOT.tar.gz 38 URL http://files.pacien.net/tmp/tinc-1.1pre15-SNAPSHOT.tar.gz
40 CONFIGURE_COMMAND autoreconf -fsi <SOURCE_DIR> && 39 CONFIGURE_COMMAND autoreconf -fsi <SOURCE_DIR> &&
@@ -45,8 +44,10 @@ ExternalProject_Add(tinc
45 --disable-readline 44 --disable-readline
46 BUILD_COMMAND make -j4 -C src 45 BUILD_COMMAND make -j4 -C src
47 INSTALL_COMMAND make -C src install DESTDIR=${CMAKE_CURRENT_BINARY_DIR} && 46 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 && 47 ${CMAKE_COMMAND} -E copy
49 ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/usr/local/sbin/tincd ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libtincd.so && 48 ${CMAKE_CURRENT_BINARY_DIR}/usr/local/sbin/tinc ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libtinc.so &&
49 ${CMAKE_COMMAND} -E copy
50 ${CMAKE_CURRENT_BINARY_DIR}/usr/local/sbin/tincd ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libtincd.so &&
50 rm -r <BINARY_DIR> 51 rm -r <BINARY_DIR>
51) 52)
52 53
diff --git a/app/build.gradle b/app/build.gradle
index 33514ea..a707cbb 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,5 +1,6 @@
1apply plugin: 'com.android.application' 1apply plugin: 'com.android.application'
2apply plugin: 'me.tatarka.retrolambda' 2apply plugin: 'kotlin-android'
3apply plugin: 'kotlin-android-extensions'
3 4
4android { 5android {
5 compileSdkVersion 25 6 compileSdkVersion 25
@@ -7,10 +8,12 @@ android {
7 defaultConfig { 8 defaultConfig {
8 applicationId "org.pacien.tincapp" 9 applicationId "org.pacien.tincapp"
9 minSdkVersion 21 10 minSdkVersion 21
10 targetSdkVersion 25 11 targetSdkVersion 21
11 versionCode 1 12 versionCode 1
12 versionName "0.1-preview" 13 versionName "0.1-preview"
13 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 ndk {
15 abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a'
16 }
14 } 17 }
15 buildTypes { 18 buildTypes {
16 release { 19 release {
@@ -18,10 +21,6 @@ android {
18 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 } 22 }
20 } 23 }
21 compileOptions {
22 sourceCompatibility JavaVersion.VERSION_1_8
23 targetCompatibility JavaVersion.VERSION_1_8
24 }
25 externalNativeBuild { 24 externalNativeBuild {
26 cmake { 25 cmake {
27 path "CMakeLists.txt" 26 path "CMakeLists.txt"
@@ -45,5 +44,8 @@ dependencies {
45 exclude group: 'commons-logging', module: 'commons-logging' 44 exclude group: 'commons-logging', module: 'commons-logging'
46 } 45 }
47 46
48 compile 'com.annimon:stream:1.1.5' 47 compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
48}
49repositories {
50 mavenCentral()
49} 51}
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.java b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.java
deleted file mode 100644
index 0e6cb95..0000000
--- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.java
+++ /dev/null
@@ -1,71 +0,0 @@
1package org.pacien.tincapp.activities;
2
3import android.content.ClipData;
4import android.content.ClipboardManager;
5import android.content.Context;
6import android.content.Intent;
7import android.net.Uri;
8import android.os.Bundle;
9import android.support.annotation.StringRes;
10import android.support.design.widget.Snackbar;
11import android.support.v7.app.AlertDialog;
12import android.support.v7.app.AppCompatActivity;
13import android.support.v7.widget.Toolbar;
14import android.view.Menu;
15import android.view.MenuItem;
16import android.view.ViewGroup;
17
18import org.pacien.tincapp.BuildConfig;
19import org.pacien.tincapp.R;
20import org.pacien.tincapp.context.AppInfo;
21
22/**
23 * @author pacien
24 */
25public abstract class BaseActivity extends AppCompatActivity {
26
27 @Override
28 protected void onCreate(Bundle savedInstanceState) {
29 super.onCreate(savedInstanceState);
30 setContentView(R.layout.base);
31 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
32 setSupportActionBar(toolbar);
33 }
34
35 @Override
36 public boolean onCreateOptionsMenu(Menu m) {
37 getMenuInflater().inflate(R.menu.menu_base, m);
38 return true;
39 }
40
41 public void aboutDialog(MenuItem i) {
42 new AlertDialog.Builder(this)
43 .setTitle(BuildConfig.APPLICATION_ID)
44 .setMessage(getResources().getString(R.string.app_short_desc) + "\n\n" +
45 getResources().getString(R.string.app_copyright) + " " +
46 getResources().getString(R.string.app_license) + "\n\n" +
47 AppInfo.all(getResources()))
48 .setNeutralButton(R.string.action_open_project_website, (dialog, which) -> openWebsite(R.string.app_website_url))
49 .setPositiveButton(R.string.action_close, (dialog, which) -> { /* nop */ })
50 .show();
51 }
52
53 protected ViewGroup getContentView() {
54 return (ViewGroup) findViewById(R.id.main_content); <