Files
utun2/tools/chatgui-android/app/build.gradle.kts
T
evgeny 99b5244ad5 Make Android microphone capture stoppable and cleanup resilient
Use nonblocking AudioRecord reads with data and timestamp deadlines. Serialize idempotent close, finish interrupted joins before release, isolate callback failures, and abort stereo fallback when partial-record cleanup fails.

Close failed shared readers to new subscriptions, roll back worker startup, isolate observers, preserve interrupt state, and release the last consumer exactly once. Add an independent capture-tests JVM module to the standard Android unit-test task.

Validation: 38 capture scenarios (25 AudioRecord plus 13 PCM/PTT), 455 JVM tests, assembleDebug, core build, and full check.sh (225 tests plus proxy/burst/load) passed.
2026-10-28 00:53:01 +01:00

113 lines
4.3 KiB
Kotlin

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
// Фон берём из desktop-чатгуи; drawable-nodpi сохраняет исходный размер плитки.
val prepareChatBackground by tasks.registering(Copy::class) {
from("../../chatgui/resources/bg.png")
into(layout.buildDirectory.dir("generated/chatBackground/res/drawable-nodpi"))
rename { "chat_background.png" }
}
tasks.named("preBuild") { dependsOn(prepareChatBackground) }
// Общий комплект лицензий ядра и встроенных библиотек включается в каждый APK.
val prepareLicenses by tasks.registering(Sync::class) {
from("../../..") { include("LICENSE", "LICENSING", "THIRD_PARTY_NOTICES") }
into(layout.buildDirectory.dir("generated/licenses/assets/licenses"))
doLast { logger.lifecycle("uTun license documents prepared for APK assets/licenses") }
}
tasks.named("preBuild") { dependsOn(prepareLicenses) }
android {
namespace = "com.utun.chat"
compileSdk = 36
ndkVersion = "29.0.14206865"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
defaultConfig {
applicationId = "com.utun.chat"
minSdk = 26
targetSdk = 36
versionCode = 1
versionName = "0.1.0"
externalNativeBuild {
cmake {
arguments("-DANDROID_STL=c++_static")
}
}
ndk {
abiFilters += listOf("arm64-v8a", "x86_64")
}
}
buildFeatures {
compose = true
buildConfig = true
}
// Общие TGS-анимации с desktop-чатгуи, без копирования ресурсов.
sourceSets["main"].assets.srcDir("../../chatgui/resources/animations")
sourceSets["main"].assets.srcDir(layout.buildDirectory.dir("generated/licenses/assets"))
sourceSets["main"].res.srcDir(layout.buildDirectory.dir("generated/chatBackground/res"))
composeOptions {
kotlinCompilerExtensionVersion = "1.5.5"
}
externalNativeBuild {
cmake {
path = file("src/main/cpp/CMakeLists.txt")
}
}
buildTypes {
release {
isMinifyEnabled = false
}
}
}
// Зависимость только между задачами: Android fixtures из JVM-модуля не входят в classpath приложения/APK.
tasks.withType<org.gradle.api.tasks.testing.Test>().configureEach {
dependsOn(":router-tests:test", ":capture-tests:test")
val messageLinkCases = rootProject.file("../chatgui/tests/message_links_cases.tsv")
inputs.file(messageLinkCases)
systemProperty("utun.messageLinkCases", messageLinkCases.absolutePath)
}
dependencies {
testImplementation("junit:junit:4.13.2")
testImplementation("org.json:json:20240303") // Реальный JSON для проверки границы JNI, без Android mock stubs.
implementation(platform("androidx.compose:compose-bom:2024.02.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.material:material-icons-extended")
implementation("androidx.compose.foundation:foundation")
implementation("com.airbnb.android:lottie-compose:6.3.0")
implementation("androidx.activity:activity-compose:1.8.2")
implementation("androidx.appcompat:appcompat:1.7.1")
implementation("androidx.core:core-ktx:1.15.0")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.7.0")
implementation("androidx.datastore:datastore-preferences:1.0.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
implementation("com.google.code.gson:gson:2.10.1")
implementation("com.google.mlkit:barcode-scanning:17.3.0")
implementation("com.google.zxing:core:3.5.3")
implementation("androidx.camera:camera-camera2:1.4.0")
implementation("androidx.camera:camera-lifecycle:1.4.0")
implementation("androidx.camera:camera-view:1.4.0")
implementation("androidx.camera:camera-video:1.4.0")
}