feat(android): add isolated lvbu persona build and pinned asset selection

This commit is contained in:
zenord
2026-10-14 16:41:36 +08:00
parent 3371997252
commit 5a7be557d0
23 changed files with 1507 additions and 31 deletions
+41 -15
View File
@@ -4,6 +4,14 @@ plugins {
id 'org.jetbrains.kotlin.plugin.compose'
}
def characterProfileId = providers.gradleProperty('characterProfile').orNull ?: 'main'
def characterCatalogFile = rootProject.file('manifests/character-build-profiles.json')
def characterCatalog = new groovy.json.JsonSlurper().parse(characterCatalogFile)
def characterProfile = characterCatalog.profiles[characterProfileId]
if (!characterProfile || !(characterProfileId in ['main', 'lvbu-test'])) throw new GradleException('Unknown trusted character profile')
if (characterProfileId != 'main') layout.buildDirectory.set(file('build/characters/' + characterProfileId))
if (characterProfileId == 'lvbu-test' && gradle.startParameter.taskNames.any { it.toLowerCase().contains('release') }) throw new GradleException('Lvbu profile is debug-only')
// Populated once by scripts/prepare-expression.sh from stable Maven versions, then pinned.
def expressionVersions = new Properties()
def expressionVersionFile = rootProject.file('gradle/expression-versions.properties')
@@ -32,6 +40,7 @@ def avatarPlaybackDiagnostic = providers.gradleProperty('avatarPlaybackDiagnosti
def avatarRuntimeFix = providers.gradleProperty('avatarRuntimeFix').orNull == 'true'
def avatarFullActionCandidate = providers.gradleProperty('avatarFullActionCandidate').orNull == 'true'
def actionVersionCode = (providers.gradleProperty('actionVersionCode').orNull ?: '16').toInteger()
if (characterProfileId == 'lvbu-test' && (!avatarUserAssetCandidate || !avatarUserNetworkActions || actionVersionCode < 34)) throw new GradleException('Lvbu test requires existing exact black media/network flags and fresh code >=34')
if (avatarActionCandidate && (!avatarMouthCandidate || actionVersionCode < 16)) {
throw new GradleException('Action stage requires the existing mouth runtime and a fresh code >=16')
}
@@ -43,6 +52,7 @@ if (avatarUiCandidate && !avatarNatural) {
}
def naturalManifestSha = providers.gradleProperty('naturalManifestSha').orNull ?: ''
def emotionManifestSha = providers.gradleProperty('emotionManifestSha').orNull ?: ''
def characterMedia = characterCatalog.mediaBundles[avatarUserAssetCandidate ? 'black-correct03' : 'white-full04']
if (emotionManifestSha && !(emotionManifestSha ==~ /[0-9a-f]{64}/)) throw new GradleException('Emotion graph requires exact external manifest SHA')
if (emotionManifestSha && (!avatarActionCandidate || !avatarMouthCandidate || !avatarNatural || actionVersionCode < 17)) throw new GradleException('Emotion candidate requires own-mouth runtime and a fresh code >=17')
if (avatarFullActionCandidate && (!emotionManifestSha || !avatarActionCandidate || actionVersionCode < 18)) throw new GradleException('Full candidate requires pinned emotion/action graph and fresh code >=18')
@@ -86,31 +96,42 @@ def generateNetworkSecurityConfig = tasks.register('generateNetworkSecurityConfi
}
}
// AndroidSourceDirectorySet excludes do not reliably filter mergeAssets. A Sync
// staging directory applies actual file exclusions without touching archived imports.
// Explicit common assets, runtime references, bootstrap and code29 fallback retention.
// Unlisted source directories cannot enter mergeAssets.
def packagedAssets = layout.buildDirectory.dir('generated/packagedAssets')
def stagePackagedAssets = tasks.register('stagePackagedAssets', Sync) {
from('src/main/assets')
exclude 'avatar/a01-v1/**', 'avatar/a01-standing-v2/**'
if (!avatarMouthCandidate) exclude 'avatar/a01-neutral-graph-v1/runtime-04/**'
if (!avatarStartupFix || avatarUserAssetCandidate) exclude 'avatar/startup-white-01/**'
if (!avatarUserAssetCandidate) exclude 'avatar/startup-black-tulle-correct03/**', 'avatar/a01-black-tulle-roomy720-correct03/**'
if (avatarUserAssetCandidate) exclude 'avatar/a01-expression-action-v1/**'
if (!emotionManifestSha) exclude 'avatar/a01-expression-action-v1/**'
into(packagedAssets)
def stagePackagedAssets = tasks.register('stagePackagedAssets', Exec) {
workingDir rootProject.projectDir
inputs.files(characterCatalogFile, rootProject.file('manifests/retained-avatar-files.json'), rootProject.file('scripts/select-character-assets.py'))
inputs.dir(file('src/main/assets'))
inputs.dir(file('src/main/res/drawable-nodpi'))
inputs.property('selection', [characterProfileId, emotionManifestSha, avatarUserAssetCandidate, avatarMouthCandidate, avatarStartupFix].toString())
outputs.dir(packagedAssets)
outputs.file(layout.buildDirectory.file('generated/character-selection.json'))
commandLine 'python3', rootProject.file('scripts/select-character-assets.py'), '--profile', characterProfileId,
'--assets', file('src/main/assets'), '--emotion-sha', emotionManifestSha,
'--user-assets', avatarUserAssetCandidate.toString(), '--mouth', avatarMouthCandidate.toString(),
'--startup', avatarStartupFix.toString(), '--output', packagedAssets.get().asFile,
'--report', layout.buildDirectory.file('generated/character-selection.json').get().asFile
}
android {
namespace 'com.gorios.lanvoice'
compileSdk 34
defaultConfig {
applicationId 'com.gorios.lanvoice'
applicationId characterProfile.applicationId
manifestPlaceholders = [characterAllowBackup: characterProfile.allowBackup.toString()]
resValue 'string', 'character_app_name', characterProfile.appName
buildConfigField 'String', 'CHARACTER_PROFILE', groovy.json.JsonOutput.toJson(characterProfileId)
buildConfigField 'String', 'DIALOGUE_PERSONA', groovy.json.JsonOutput.toJson(characterProfile.persona)
buildConfigField 'String', 'CHARACTER_NOTE', groovy.json.JsonOutput.toJson(characterProfile.settingsNote)
buildConfigField 'boolean', 'PERMISSION_CONNECTION_RETENTION', characterProfile.permissionConnectionRetention.toString()
minSdk 26
targetSdk 34
testInstrumentationRunner 'com.gorios.lanvoice.AvatarCleanUiInstrumentation'
versionCode avatarActionCandidate ? actionVersionCode : (avatarMouthCandidate ? 15 : (avatarUiCandidate ? 14 : (avatarNatural ? 13 : 12)))
versionName = avatarUserNetworkActions ? '0.7.14' : avatarUserAssetCandidate ? '0.7.12' : cameraProbeDiagnostic ? '0.7.11' : cameraPreviewStream ? '0.7.9' : cameraDirectYuv ? '0.7.8' : cameraCompatibilityFix ? '0.7.7' : faceDiagnosticsFix ? '0.7.6' : presenceCandidate ? '0.7.5' : avatarStartupFix ? '0.7.4' : avatarPlaybackClockFix ? '0.7.3' : avatarPlaybackDiagnostic ? '0.7.2' : avatarRuntimeFix ? '0.7.1' : (avatarActionCandidate ? '0.7.0' : ((avatarUiCandidate || avatarMouthCandidate) ? '0.6.2' : '0.6.1'))
ndk { abiFilters 'arm64-v8a' }
versionName += characterProfile.versionSuffix
}
compileOptions { sourceCompatibility JavaVersion.VERSION_17; targetCompatibility JavaVersion.VERSION_17 }
kotlinOptions { jvmTarget = '17' }
@@ -126,9 +147,9 @@ android {
else if (avatarEngineering) versionNameSuffix '-dev'
buildConfigField 'boolean', 'AVATAR_NETWORK_ACTIONS_ALLOWED', (!avatarUserAssetCandidate || avatarUserNetworkActions) ? 'true' : 'false'
buildConfigField 'boolean', 'AVATAR_USER_ASSET_CANDIDATE', avatarUserAssetCandidate ? 'true' : 'false'
buildConfigField 'String', 'EMOTION_ASSET_ROOT', '"' + (avatarUserAssetCandidate ? 'avatar/a01-black-tulle-roomy720-correct03/' : 'avatar/a01-expression-action-v1/') + '"'
buildConfigField 'String', 'STARTUP_ASSET_ROOT', '"' + (avatarUserAssetCandidate ? 'avatar/startup-black-tulle-correct03/' : 'avatar/startup-white-01/') + '"'
buildConfigField 'String', 'STARTUP_MANIFEST_SHA', '"' + (avatarUserAssetCandidate ? '29669529887db78e0d64d2e7afd89cb8866aefc84e2523195d4bb936ec2ae382' : '461f5cfc10036de5f10ca3ce765fb8d9998697d3fd035aa9b1862d2ccfc3eaa2') + '"'
buildConfigField 'String', 'EMOTION_ASSET_ROOT', groovy.json.JsonOutput.toJson(characterMedia.assetRoot)
buildConfigField 'String', 'STARTUP_ASSET_ROOT', groovy.json.JsonOutput.toJson(characterMedia.bootstrapRoot)
buildConfigField 'String', 'STARTUP_MANIFEST_SHA', groovy.json.JsonOutput.toJson(characterMedia.bootstrapSha256)
buildConfigField 'boolean', 'CAMERA_PROBE_DIAGNOSTIC', cameraProbeDiagnostic ? 'true' : 'false'
buildConfigField 'boolean', 'AVATAR_STARTUP_FIX', avatarStartupFix ? 'true' : 'false'
buildConfigField 'boolean', 'AVATAR_ENGINEERING', (avatarEngineering || avatarNatural) ? 'true' : 'false'
@@ -159,6 +180,11 @@ android {
sourceSets.main.assets.setSrcDirs([packagedAssets])
}
tasks.named('preBuild').configure { dependsOn(generateNetworkSecurityConfig, stagePackagedAssets) }
androidComponents {
beforeVariants(selector().withBuildType('release')) { variant ->
if (characterProfileId == 'lvbu-test') variant.enable = false
}
}
dependencies {
implementation platform('androidx.compose:compose-bom:2024.09.03')
implementation 'androidx.compose.ui:ui'