Files
VibeCoding/WebRTCControlled/app/build.gradle
tongtongstudio 6eb2c7321a feat(controlled): 实现设备激活与安全认证流程
- 添加API客户端、加密存储和provision/token激活逻辑
- WebSocket改用Bearer令牌认证,移除REGISTER请求
- 设备ID改为服务端下发,支持令牌刷新和强制下线处理
- 新增deviceSecret加密存储和accessToken自动刷新
- 更新设备ID获取方式为出厂SN,添加安全存储依赖
2026-08-01 15:13:12 +08:00

166 lines
5.4 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
plugins {
id 'com.android.application'
id 'com.google.protobuf'
}
def releaseTime() {
return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}
def appName() {
return "WebRTCControlled"
}
android {
namespace 'com.ttstd.controlled'
compileSdk 34
defaultConfig {
applicationId "com.ttstd.controlled"
minSdk 24
targetSdk 34
versionCode 1
versionName "1.0"
// 服务端地址(信令 wss 与 HTTP api 同源)。部署时通过 flavor / CI 注入真实值。
buildConfigField "String", "API_BASE", "\"https://www.ttstd.com\""
// 出厂预置共享密钥(用于 provision 签名)。正式发布必须替换并通过安全方式注入。
buildConfigField "String", "DEVICE_PROVISION_SECRET", "\"dev-device-provision-secret-change-me\""
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
dataBinding true
buildConfig true
aidl true
}
sourceSets {
zhanRuiDebug.manifest.srcFile 'src/system/AndroidManifest.xml'
zhanRuiRelease.manifest.srcFile 'src/system/AndroidManifest.xml'
CrosshatchDebug.manifest.srcFile 'src/system/AndroidManifest.xml'
CrosshatchRelease.manifest.srcFile 'src/system/AndroidManifest.xml'
}
signingConfigs {
keypub {
storeFile file(rootProject.ext.signingConfigs.keypub.storeFile)
storePassword rootProject.ext.signingConfigs.keypub.storePassword
keyAlias rootProject.ext.signingConfigs.keypub.keyAlias
keyPassword rootProject.ext.signingConfigs.keypub.keyPassword
}
crosshatch {
storeFile file(rootProject.ext.signingConfigs.crosshatch.storeFile)
storePassword rootProject.ext.signingConfigs.crosshatch.storePassword
keyAlias rootProject.ext.signingConfigs.crosshatch.keyAlias
keyPassword rootProject.ext.signingConfigs.crosshatch.keyPassword
}
zhanxun {
storeFile file(rootProject.ext.signingConfigs.zhanxun.storeFile)
storePassword rootProject.ext.signingConfigs.zhanxun.storePassword
keyAlias rootProject.ext.signingConfigs.zhanxun.keyAlias
keyPassword rootProject.ext.signingConfigs.zhanxun.keyPassword
}
}
buildTypes {
zhanRuiDebug.initWith(debug)
zhanRuiDebug {
debuggable true
signingConfig signingConfigs.zhanxun
}
zhanRuiRelease.initWith(release)
zhanRuiRelease {
signingConfig signingConfigs.zhanxun
}
CrosshatchDebug.initWith(debug)
CrosshatchDebug {
debuggable true
signingConfig signingConfigs.crosshatch
}
CrosshatchRelease.initWith(release)
CrosshatchRelease {
signingConfig signingConfigs.crosshatch
}
debug {
versionNameSuffix "_debug"
debuggable true
minifyEnabled false
//Zipalign优化
zipAlignEnabled true
signingConfig signingConfigs.keypub
}
release {
minifyEnabled false
//Zipalign优化
zipAlignEnabled true
//前一部分代表系统默认的android程序的混淆文件该文件已经包含了基本的混淆声明后一个文件是自己的定义混淆文件
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
//签名
signingConfig signingConfigs.keypub
}
}
// Add application variant configuration here instead
applicationVariants.all { variant ->
variant.outputs.each { output ->
def buildType = variant.buildType.name
def fileName = ""
if (buildType.contains("debug")) {
fileName = "${appName()}_V${defaultConfig.versionName}_${releaseTime()}.apk"
} else {
fileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}.apk"
}
output.outputFileName = fileName
}
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.25.1'
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {}
}
}
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// WebRTC
implementation 'io.github.webrtc-sdk:android:144.7559.09'
// implementation 'org.webrtc:google-webrtc:1.0.32006'
// OkHttp for WebSocket
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
// Gson for JSON信令消息仍使用 JSON
implementation 'com.google.code.gson:gson:2.10.1'
// ProtobufDataChannel 控制指令二进制)
implementation 'com.google.protobuf:protobuf-java:3.25.1'
// 安全存储:加密 SharedPreferences保存激活得到的 deviceSecret / deviceUid / accessToken
implementation 'androidx.security:security-crypto:1.1.0-alpha06'
}