Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Commit c128514

Browse files
committed
move service consts to new base module for topl-service
1 parent d9f81cd commit c128514

File tree

10 files changed

+231
-150
lines changed

10 files changed

+231
-150
lines changed

build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ apply plugin: 'org.jetbrains.dokka'
22

33
buildscript {
44
apply from: "$rootDir/gradle/dependencies.gradle"
5+
ext {
6+
kotlin_version = '1.4.10'
7+
}
58

69
repositories {
710
google()

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include ':topl-service-base'
12
rootProject.name = 'TorOnionProxyLibrary-Android'
23
include ':sampleapp'
34
include ':topl-core'

topl-service-base/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

topl-service-base/build.gradle

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
5+
android {
6+
compileSdkVersion versions.compileSdk
7+
buildToolsVersion versions.buildTools
8+
9+
defaultConfig {
10+
minSdkVersion versions.minSdk
11+
targetSdkVersion versions.compileSdk
12+
versionCode VERSION_CODE.toInteger()
13+
versionName VERSION_NAME
14+
15+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
16+
testInstrumentationRunnerArguments disableAnalytics: 'true'
17+
consumerProguardFiles 'proguard-rules.pro'
18+
}
19+
20+
buildTypes {
21+
release {
22+
minifyEnabled false
23+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24+
}
25+
}
26+
27+
compileOptions {
28+
sourceCompatibility JavaVersion.VERSION_1_8
29+
targetCompatibility JavaVersion.VERSION_1_8
30+
}
31+
32+
kotlinOptions {
33+
jvmTarget = JavaVersion.VERSION_1_8
34+
freeCompilerArgs += [
35+
'-Xopt-in=kotlin.time.ExperimentalTime',
36+
'-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi',
37+
]
38+
}
39+
}
40+
41+
dependencies {
42+
implementation fileTree(dir: "libs", include: ["*.jar"])
43+
implementation project(path: ':topl-core-base')
44+
implementation deps.kotlin.stdlib
45+
implementation deps.androidx.core
46+
}

topl-service-base/consumer-rules.pro

Whitespace-only changes.

topl-service-base/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.matthewnelson.topl_service_base" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
package io.matthewnelson.topl_service_base
2+
3+
import androidx.annotation.StringDef
4+
import io.matthewnelson.topl_core_base.BaseConsts
5+
6+
abstract class BaseServiceConsts: BaseConsts() {
7+
8+
9+
///////////////////////////////
10+
/// BackgroundManagerPolicy ///
11+
///////////////////////////////
12+
@Target(
13+
AnnotationTarget.CLASS,
14+
AnnotationTarget.PROPERTY,
15+
AnnotationTarget.VALUE_PARAMETER,
16+
AnnotationTarget.TYPE
17+
)
18+
@StringDef(
19+
BackgroundPolicy.RESPECT_RESOURCES,
20+
BackgroundPolicy.RUN_IN_FOREGROUND
21+
)
22+
@Retention(AnnotationRetention.SOURCE)
23+
annotation class BackgroundPolicy {
24+
companion object {
25+
private const val BACKGROUND_POLICY = "BackgroundPolicy_"
26+
const val RESPECT_RESOURCES = "${BACKGROUND_POLICY}RESPECT_RESOURCES"
27+
const val RUN_IN_FOREGROUND = "${BACKGROUND_POLICY}RUN_IN_FOREGROUND"
28+
}
29+
}
30+
31+
32+
///////////////////////
33+
/// TorServicePrefs ///
34+
///////////////////////
35+
@StringDef(
36+
PrefKeyBoolean.DISABLE_NETWORK,
37+
PrefKeyBoolean.HAS_BRIDGES,
38+
PrefKeyBoolean.HAS_COOKIE_AUTHENTICATION,
39+
PrefKeyBoolean.HAS_DEBUG_LOGS,
40+
PrefKeyBoolean.HAS_DORMANT_CANCELED_BY_STARTUP,
41+
PrefKeyBoolean.HAS_OPEN_PROXY_ON_ALL_INTERFACES,
42+
PrefKeyBoolean.HAS_REACHABLE_ADDRESS,
43+
PrefKeyBoolean.HAS_REDUCED_CONNECTION_PADDING,
44+
PrefKeyBoolean.HAS_SAFE_SOCKS,
45+
PrefKeyBoolean.HAS_STRICT_NODES,
46+
PrefKeyBoolean.HAS_TEST_SOCKS,
47+
PrefKeyBoolean.IS_AUTO_MAP_HOSTS_ON_RESOLVE,
48+
PrefKeyBoolean.IS_RELAY,
49+
PrefKeyBoolean.RUN_AS_DAEMON,
50+
PrefKeyBoolean.USE_SOCKS5
51+
)
52+
@Retention(AnnotationRetention.SOURCE)
53+
annotation class PrefKeyBoolean {
54+
companion object {
55+
// Keys for returning Booleans
56+
const val DISABLE_NETWORK = "DISABLE_NETWORK"
57+
const val HAS_BRIDGES = "HAS_BRIDGES"
58+
const val HAS_COOKIE_AUTHENTICATION = "HAS_COOKIE_AUTHENTICATION"
59+
const val HAS_DEBUG_LOGS = "HAS_DEBUG_LOGS"
60+
const val HAS_DORMANT_CANCELED_BY_STARTUP = "HAS_DORMANT_CANCELED_BY_STARTUP"
61+
const val HAS_OPEN_PROXY_ON_ALL_INTERFACES = "HAS_OPEN_PROXY_ON_ALL_INTERFACES"
62+
const val HAS_REACHABLE_ADDRESS = "HAS_REACHABLE_ADDRESS"
63+
const val HAS_REDUCED_CONNECTION_PADDING = "HAS_REDUCED_CONNECTION_PADDING"
64+
const val HAS_SAFE_SOCKS = "HAS_SAFE_SOCKS"
65+
const val HAS_STRICT_NODES = "HAS_STRICT_NODES"
66+
const val HAS_TEST_SOCKS = "HAS_TEST_SOCKS"
67+
const val IS_AUTO_MAP_HOSTS_ON_RESOLVE = "IS_AUTO_MAP_HOSTS_ON_RESOLVE"
68+
const val IS_RELAY = "IS_RELAY"
69+
const val RUN_AS_DAEMON = "RUN_AS_DAEMON"
70+
const val USE_SOCKS5 = "USE_SOCKS5"
71+
}
72+
}
73+
74+
@StringDef(
75+
PrefKeyInt.DORMANT_CLIENT_TIMEOUT,
76+
PrefKeyInt.PROXY_PORT,
77+
PrefKeyInt.PROXY_SOCKS5_SERVER_PORT
78+
)
79+
@Retention(AnnotationRetention.SOURCE)
80+
annotation class PrefKeyInt {
81+
companion object {
82+
// Keys for returning Ints
83+
const val DORMANT_CLIENT_TIMEOUT = "DORMANT_CLIENT_TIMEOUT"
84+
const val PROXY_PORT = "PROXY_PORT"
85+
const val PROXY_SOCKS5_SERVER_PORT = "PROXY_SOCKS5_SERVER_PORT"
86+
}
87+
}
88+
89+
@StringDef(
90+
PrefKeyList.DNS_PORT_ISOLATION_FLAGS,
91+
PrefKeyList.HTTP_TUNNEL_PORT_ISOLATION_FLAGS,
92+
PrefKeyList.SOCKS_PORT_ISOLATION_FLAGS,
93+
PrefKeyList.TRANS_PORT_ISOLATION_FLAGS,
94+
PrefKeyList.USER_DEFINED_BRIDGES
95+
)
96+
@Retention(AnnotationRetention.SOURCE)
97+
annotation class PrefKeyList {
98+
companion object {
99+
// Keys for returning Lists
100+
const val DNS_PORT_ISOLATION_FLAGS = "DNS_PORT_ISOLATION_FLAGS"
101+
const val HTTP_TUNNEL_PORT_ISOLATION_FLAGS = "HTTP_PORT_ISOLATION_FLAGS"
102+
const val SOCKS_PORT_ISOLATION_FLAGS = "SOCKS_PORT_ISOLATION_FLAGS"
103+
const val TRANS_PORT_ISOLATION_FLAGS = "TRANS_PORT_ISOLATION_FLAGS"
104+
const val USER_DEFINED_BRIDGES = "USER_DEFINED_BRIDGES"
105+
}
106+
}
107+
108+
@StringDef(
109+
PrefKeyString.DNS_PORT,
110+
PrefKeyString.CUSTOM_TORRC,
111+
PrefKeyString.ENTRY_NODES,
112+
PrefKeyString.EXCLUDED_NODES,
113+
PrefKeyString.EXIT_NODES,
114+
PrefKeyString.HTTP_TUNNEL_PORT,
115+
PrefKeyString.PROXY_HOST,
116+
PrefKeyString.PROXY_PASSWORD,
117+
PrefKeyString.PROXY_SOCKS5_HOST,
118+
PrefKeyString.PROXY_TYPE,
119+
PrefKeyString.PROXY_USER,
120+
PrefKeyString.REACHABLE_ADDRESS_PORTS,
121+
PrefKeyString.RELAY_NICKNAME,
122+
PrefKeyString.RELAY_PORT,
123+
PrefKeyString.SOCKS_PORT,
124+
PrefKeyString.VIRTUAL_ADDRESS_NETWORK,
125+
PrefKeyString.HAS_CONNECTION_PADDING,
126+
PrefKeyString.TRANS_PORT
127+
)
128+
@Retention(AnnotationRetention.SOURCE)
129+
annotation class PrefKeyString {
130+
companion object {
131+
// Keys for returning Strings
132+
const val DNS_PORT = "DNS_PORT"
133+
const val CUSTOM_TORRC = "CUSTOM_TORRC"
134+
const val ENTRY_NODES = "ENTRY_NODES"
135+
const val EXCLUDED_NODES = "EXCLUDED_NODES"
136+
const val EXIT_NODES = "EXIT_NODES"
137+
const val HTTP_TUNNEL_PORT = "HTTP_TUNNEL_PORT"
138+
const val PROXY_HOST = "PROXY_HOST"
139+
const val PROXY_PASSWORD = "PROXY_PASSWORD"
140+
const val PROXY_SOCKS5_HOST = "PROXY_SOCKS5_HOST"
141+
const val PROXY_TYPE = "PROXY_TYPE"
142+
const val PROXY_USER = "PROXY_USER"
143+
const val REACHABLE_ADDRESS_PORTS = "REACHABLE_ADDRESS_PORTS"
144+
const val RELAY_NICKNAME = "RELAY_NICKNAME"
145+
const val RELAY_PORT = "RELAY_PORT"
146+
const val SOCKS_PORT = "SOCKS_PORT"
147+
const val VIRTUAL_ADDRESS_NETWORK = "VIRTUAL_ADDRESS_NETWORK"
148+
const val HAS_CONNECTION_PADDING = "HAS_CONNECTION_PADDING"
149+
const val TRANS_PORT = "TRANS_PORT"
150+
}
151+
}
152+
}

topl-service/build.gradle

+3-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ dokka {
7474

7575
dependencies {
7676
implementation fileTree(dir: "libs", include: ["*.jar"])
77-
implementation project(':topl-core')
78-
implementation project(':topl-core-base')
77+
implementation project(path: ':topl-core')
78+
api project(path: ':topl-core-base')
79+
api project(path: ':topl-service-base')
7980
implementation deps.androidx.core
8081
implementation deps.androidx.lifecycle.runtime
8182
implementation deps.androidx.lifecycle.processLifecycleOwner

0 commit comments

Comments
 (0)