docs(project): 更新项目说明文档并添加相机遥测功能
- 重写 AGENTS.md 为 drone-controller-v5 项目说明与打包指南 - 添加系统概述、项目结构、开发环境和关键配置说明 - 补充 Android Studio 和命令行打包 APK 详细步骤 - 增加签名说明、安装指导和打包前检查清单 - 添加常用构建命令、代码规范和验证建议 - 新增 CameraCloudTelemetry 类用于读取相机遥测数据 - 添加 CameraStreamCapabilities 类获取相机流能力 - 实现 CloudCameraValues 映射 SDK 枚举到云端协议 - 添加云端绑定响应验证功能和单元测试 - 集成紧急停止和航线暂停恢复云控命令 - 重构航线任务管理为独立的 CloudWaylineService
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
// deployment.properties is the only source for app deployment addresses.
|
||||
def configFile = rootProject.file(project.findProperty('deploymentConfig') ?: 'deployment.properties')
|
||||
if (!configFile.isFile()) throw new GradleException("Deployment config not found: ${configFile}")
|
||||
def deployment = new Properties()
|
||||
configFile.withReader('UTF-8') { deployment.load(it) }
|
||||
def required = { String key ->
|
||||
def value = deployment.getProperty(key, '').trim()
|
||||
if (!value) throw new GradleException("${configFile.name}: ${key} must not be empty")
|
||||
value
|
||||
}
|
||||
def validateHost = { String host ->
|
||||
// Host names and IPv4 only; reject URL syntax and XML metacharacters.
|
||||
if (!(host ==~ /[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?/)) {
|
||||
throw new GradleException("Invalid deployment host '${host}': use an IP or domain without scheme, port or path")
|
||||
}
|
||||
host.toLowerCase(java.util.Locale.ROOT)
|
||||
}
|
||||
def baseUrl = required('CLOUD_BASE_URL')
|
||||
def baseUri
|
||||
try { baseUri = new URI(baseUrl) } catch (Exception e) {
|
||||
throw new GradleException('CLOUD_BASE_URL must be a valid http/https URL', e)
|
||||
}
|
||||
if (!(baseUri.scheme in ['http', 'https']) || !baseUri.host || baseUri.userInfo ||
|
||||
baseUri.query || baseUri.fragment || baseUri.port == 0 || baseUri.port > 65535) {
|
||||
throw new GradleException('CLOUD_BASE_URL must be an http/https URL without credentials, query or fragment')
|
||||
}
|
||||
def platformHost = validateHost(baseUri.host)
|
||||
def fallbackHost = deployment.getProperty('CLOUD_FALLBACK_HOST', '').trim()
|
||||
if (fallbackHost) fallbackHost = validateHost(fallbackHost)
|
||||
def httpHosts = ([platformHost, fallbackHost] + deployment.getProperty('HTTP_EXTRA_HOSTS', '').split(',').toList())
|
||||
.collect { it.trim() }.findAll { it }.collect { validateHost(it) }.unique()
|
||||
def rtmpPortText = required('RTMP_PORT')
|
||||
if (!rtmpPortText.isInteger() || !(rtmpPortText.toInteger() in 1..65535)) {
|
||||
throw new GradleException('RTMP_PORT must be between 1 and 65535')
|
||||
}
|
||||
def rtmpApp = required('RTMP_DEFAULT_APP')
|
||||
if (!(rtmpApp ==~ /[A-Za-z0-9_-]+/)) throw new GradleException('RTMP_DEFAULT_APP must be a single app name')
|
||||
|
||||
android.defaultConfig {
|
||||
buildConfigField 'String', 'CLOUD_BASE_URL', groovy.json.JsonOutput.toJson(baseUrl)
|
||||
buildConfigField 'String', 'CLOUD_PLATFORM_HOST', groovy.json.JsonOutput.toJson(platformHost)
|
||||
buildConfigField 'String', 'CLOUD_FALLBACK_HOST', groovy.json.JsonOutput.toJson(fallbackHost)
|
||||
buildConfigField 'int', 'CLOUD_RTMP_PORT', rtmpPortText.toInteger().toString()
|
||||
buildConfigField 'String', 'CLOUD_RTMP_DEFAULT_APP', groovy.json.JsonOutput.toJson(rtmpApp)
|
||||
}
|
||||
|
||||
def generatedRes = layout.buildDirectory.dir('generated/res/deployment')
|
||||
android.sourceSets.main.res.srcDir(generatedRes)
|
||||
def generateNetworkConfig = tasks.register('generateDeploymentNetworkConfig') {
|
||||
inputs.file(configFile)
|
||||
inputs.property('httpHosts', httpHosts)
|
||||
outputs.dir(generatedRes)
|
||||
doLast {
|
||||
def output = new File(generatedRes.get().asFile, 'xml/network_security_config.xml')
|
||||
output.parentFile.mkdirs()
|
||||
output.setText('''<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generated from deployment.properties. Do not edit this build output. -->
|
||||
<network-security-config>
|
||||
<base-config cleartextTrafficPermitted="false" />
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
''' + httpHosts.collect { ' <domain includeSubdomains="true">' + it + '</domain>' }.join('\n') + '''
|
||||
</domain-config>
|
||||
</network-security-config>
|
||||
''', 'UTF-8')
|
||||
}
|
||||
}
|
||||
tasks.named('preBuild').configure { dependsOn(generateNetworkConfig) }
|
||||
Reference in New Issue
Block a user