feat: replace arti-mobile-ex with custom-built Arti native library
The Guardian Project's arti-mobile-ex AAR has three problems: 1. No 16KB page-aligned binaries (required for Google Play) 2. ArtiProxy's stop()+start() causes state file lock conflicts (lock is tied to TorClient object lifetime, released only on GC) 3. ~140MB AAR size Replace with a custom JNI bridge built from Arti source, following BitChat's proven approach: Build tooling (tools/arti-build/): - build-arti.sh: Clones official Arti, compiles with cargo-ndk for ARM64 + x86_64, NDK 25+ for 16KB page alignment - Cargo.toml: Minimal deps with size-optimized release profile - src/lib.rs: Custom SOCKS5 proxy with proper lifecycle: - initialize() creates TorClient once (holds state lock forever) - startSocksProxy() binds port and accepts connections - stopSocksProxy() aborts listener only (TorClient stays alive) This cleanly separates "stop routing traffic" from "destroy client" Kotlin side: - ArtiNative.kt: JNI declarations + ArtiLogCallback interface - TorService.kt: Uses ArtiNative directly, start() initializes + starts proxy, stop() only stops proxy (no lock issues) - TorManager.kt: Restored stop() calls for OFF/EXTERNAL modes since our native stop is now safe Removed: arti-mobile-ex dependency from build.gradle and version catalog Native libraries must be built separately: cd tools/arti-build && ./build-arti.sh https://claude.ai/code/session_01BApgDd5udqBzMqysSRMpZu
This commit is contained in:
@@ -25,7 +25,6 @@ fragmentKtx = "1.8.9"
|
||||
gms = "4.4.4"
|
||||
jacksonModuleKotlin = "2.21.2"
|
||||
javaKeyring = "1.0.4"
|
||||
artiMobileEx = "1.2.3"
|
||||
junit = "4.13.2"
|
||||
kchesslib = "1.0.5"
|
||||
kotlin = "2.3.20"
|
||||
@@ -140,7 +139,6 @@ google-mlkit-language-id = { group = "com.google.mlkit", name = "language-id", v
|
||||
google-mlkit-translate = { group = "com.google.mlkit", name = "translate", version.ref = "translate" }
|
||||
jackson-module-kotlin = { group = "com.fasterxml.jackson.module", name = "jackson-module-kotlin", version.ref = "jacksonModuleKotlin" }
|
||||
java-keyring = { group = "com.github.javakeyring", name = "java-keyring", version.ref = "javaKeyring" }
|
||||
arti-mobile-ex = { module = "info.guardianproject:arti-mobile-ex", version.ref = "artiMobileEx" }
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
kchesslib = { module = "io.github.cvb941:kchesslib", version.ref = "kchesslib" }
|
||||
kotlinx-collections-immutable = { group = "org.jetbrains.kotlinx", name = "kotlinx-collections-immutable", version.ref = "kotlinxCollectionsImmutable" }
|
||||
|
||||
Reference in New Issue
Block a user