Integrate exact user-authorized correct03 720 debug assets with isolated admission
This commit is contained in:
@@ -232,8 +232,8 @@ class MainActivity : ComponentActivity() {
|
||||
onConnectionLog = { connectionLogs = (connectionLogs + it).takeLast(10) },
|
||||
onPreparePlayback = audioOutput::prepare,
|
||||
onVoiceStopped = audioOutput::release,
|
||||
reviewedActionPack = avatarPack?.emotionAction?.actionPack?.takeIf { !BuildConfig.AVATAR_STARTUP_FIX || mediaReady },
|
||||
pendingActionPackSha = { if(BuildConfig.AVATAR_STARTUP_FIX) BuildConfig.EMOTION_MANIFEST_SHA else null },
|
||||
reviewedActionPack = avatarPack?.emotionAction?.actionPack?.takeIf { !BuildConfig.AVATAR_USER_ASSET_CANDIDATE && (!BuildConfig.AVATAR_STARTUP_FIX || mediaReady) },
|
||||
pendingActionPackSha = { if(BuildConfig.AVATAR_STARTUP_FIX && !BuildConfig.AVATAR_USER_ASSET_CANDIDATE) BuildConfig.EMOTION_MANIFEST_SHA else null },
|
||||
actionPlayer = avatarMedia,
|
||||
onPrepareExpression = avatarMedia::prepare,
|
||||
)
|
||||
@@ -251,7 +251,7 @@ class MainActivity : ComponentActivity() {
|
||||
presenceEnabled=preferences().getBoolean("presenceEnabled",false)
|
||||
session.setPresence(presenceEnabled,false)
|
||||
if(inForeground) session.foreground(connectAutomatically=false)
|
||||
if(mediaReady) avatarPack?.emotionAction?.actionPack?.let(session::installReviewedActions)
|
||||
if(mediaReady && !BuildConfig.AVATAR_USER_ASSET_CANDIDATE) avatarPack?.emotionAction?.actionPack?.let(session::installReviewedActions)
|
||||
scheduleEntry()
|
||||
}
|
||||
private fun startShell() {
|
||||
@@ -282,7 +282,7 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
private fun startupVisible() {
|
||||
mediaReady=true;startupStage="ready"
|
||||
if(!offlineAvatarPreview && ::session.isInitialized)
|
||||
if(!offlineAvatarPreview && ::session.isInitialized && !BuildConfig.AVATAR_USER_ASSET_CANDIDATE)
|
||||
avatarPack?.emotionAction?.actionPack?.let(session::installReviewedActions)
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ data class AvatarPack(val idle: String = "", val talk: String = "", val fallback
|
||||
if(BuildConfig.DEBUG && BuildConfig.EMOTION_MANIFEST_SHA.isNotEmpty()) {
|
||||
var stage="index_read_or_hash"
|
||||
val admitted=try {
|
||||
val root="avatar/a01-expression-action-v1/"
|
||||
val root=BuildConfig.EMOTION_ASSET_ROOT
|
||||
val parsedAt=SystemClock.elapsedRealtime()
|
||||
val raw=read(context,root+"manifest.json",2_000_000)
|
||||
check(sha(raw)==BuildConfig.EMOTION_MANIFEST_SHA)
|
||||
@@ -44,7 +44,8 @@ data class AvatarPack(val idle: String = "", val talk: String = "", val fallback
|
||||
val bytes=read(context,root+path,2_000_000)
|
||||
check(sha(bytes)==hash)
|
||||
stage="runtime_schema"
|
||||
val runtime=checkNotNull(ContinuousAvatarManifest.read(jsonMap(JSONObject(String(bytes,Charsets.UTF_8))),hash,hash,true,runtimeRoot))
|
||||
val runtime=checkNotNull(ContinuousAvatarManifest.read(jsonMap(JSONObject(String(bytes,Charsets.UTF_8))),hash,hash,true,runtimeRoot,
|
||||
userAuthorizedDebug=BuildConfig.AVATAR_USER_ASSET_CANDIDATE))
|
||||
stage="runtime_body_patch_hash_or_shape"
|
||||
if(!immutableReceipt) verifyRuntime(context,runtime,verified)
|
||||
stage="index_schema_or_binding";runtime
|
||||
@@ -69,7 +70,7 @@ data class AvatarPack(val idle: String = "", val talk: String = "", val fallback
|
||||
}
|
||||
}
|
||||
StartupTrace.mark(StartupTrace.Phase.MEDIA_VERIFY,mediaAt)
|
||||
static.copy(continuous=index.packages.getValue(index.fallbackId),emotionAction=index,motionStatus="externally_pinned_emotion_graph",emotionAdmission="accepted")
|
||||
static.copy(continuous=index.packages.getValue(index.fallbackId),emotionAction=index,motionStatus=if(BuildConfig.AVATAR_USER_ASSET_CANDIDATE) "user_authorized_debug_assets_review_pending" else "externally_pinned_emotion_graph",emotionAdmission="accepted")
|
||||
} catch(_: Exception) {
|
||||
static=static.copy(emotionAdmission=stage)
|
||||
DiagnosticLog.record("avatar_loader","result=rejected reason=$stage pin=${BuildConfig.EMOTION_MANIFEST_SHA.take(12)}")
|
||||
|
||||
@@ -168,6 +168,7 @@ fun CallScreen(state: VoiceUiState,entry: EntryPhase,permissionMessage: String?,
|
||||
Text("当前画面:${visualEmotion?.label ?: if(pack?.emotionAction!=null) "过渡或未呈现" else "中立"} · ${video.actual}",fontSize=12.sp)
|
||||
Text("视觉选择:${mediaBinding?.selection?.let { "${it.visualEmotion.wire}/${it.visualIntensity}" } ?: "未选择"} · ${mediaBinding?.visualStatus ?: "旧中立素材"}",fontSize=12.sp)
|
||||
if(pack?.emotionAction!=null) Text("整合候选 · 动态自然度、音乐听审及真机未测;表达可能等待 2–4 秒出口和约 1 秒过渡",fontSize=12.sp)
|
||||
if(BuildConfig.AVATAR_USER_ASSET_CANDIDATE) Text("用户授权素材调试候选 · 联网舞蹈未开放 · 音乐听审与真机自然度待验",fontSize=12.sp)
|
||||
Text("版本 ${com.gorios.lanvoice.BuildConfig.VERSION_NAME} · code ${com.gorios.lanvoice.BuildConfig.VERSION_CODE} · pin ${com.gorios.lanvoice.BuildConfig.EMOTION_MANIFEST_SHA.take(12)}",fontSize=12.sp)
|
||||
if(BuildConfig.VERSION_NAME=="0.7.2") Text("播放诊断版:未确认手机根因;可离线检查两段原舞蹈并发送状态报告",fontSize=12.sp)
|
||||
Text("素材准入:${pack?.emotionAdmission ?: "unavailable"} · ${mediaBinding?.diagnosticState ?: "legacy_neutral"}",fontSize=11.sp)
|
||||
|
||||
@@ -44,7 +44,7 @@ object BodyTimeline {
|
||||
object ContinuousAvatarManifest {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun read(root: Map<String,Any?>,sha: String,expectedSha: String,debug: Boolean,pathRoot: String,
|
||||
onReject: ((String)->Unit)? = null): ContinuousAvatarPack? {
|
||||
onReject: ((String)->Unit)? = null, userAuthorizedDebug: Boolean=false): ContinuousAvatarPack? {
|
||||
if(!debug || !expectedSha.matches(Regex("[0-9a-f]{64}")) || sha!=expectedSha) {
|
||||
onReject?.invoke("externalPin");return null
|
||||
}
|
||||
@@ -60,7 +60,10 @@ object ContinuousAvatarManifest {
|
||||
require(integer(root["schemaVersion"])==(if(dynamic) 2L else 1L) && root["identityId"]=="a01" &&
|
||||
(apertureMode || root["packId"]=="a01-neutral-graph-v1-runtime-03"))
|
||||
field="publishApproval/runtimeReady"
|
||||
require(root["publishApproval"]==false && root["runtimeReady"]==true)
|
||||
// A candidate is accepted only by an explicit caller bound to the verified
|
||||
// user-authorized parent index. Self metadata cannot open this path.
|
||||
require(root["publishApproval"]==false && (root["runtimeReady"]==true ||
|
||||
userAuthorizedDebug && dynamic && root["runtimeReady"]==false))
|
||||
field="body"
|
||||
val b=obj(root["body"])
|
||||
val count=smallInt(b["frameCount"]);require(count in 2..BodyTimeline.MAX_TALK_FRAMES)
|
||||
@@ -87,7 +90,11 @@ object ContinuousAvatarManifest {
|
||||
val rows=root["patches"] as List<Map<String,Any?>>; require(rows.size==count)
|
||||
val patches=rows.mapIndexed { index,p ->
|
||||
field="patches[$index]"
|
||||
val patch=RegisteredMouthPatch(smallInt(p["frameIndex"]),integer(p["ptsUs"]),p["path"] as String,hash(p["sha256"]),
|
||||
// Schema2 five-level tracks may omit redundant top-level L4 aliases.
|
||||
// Explicit aliases remain strict, and every level is validated below.
|
||||
val alias=if(dynamic && !p.containsKey("path") && !p.containsKey("sha256"))
|
||||
obj((p["levels"] as List<*>).last()) else p
|
||||
val patch=RegisteredMouthPatch(smallInt(p["frameIndex"]),integer(p["ptsUs"]),alias["path"] as String,hash(alias["sha256"]),
|
||||
finite(p["x"]),finite(p["y"]),smallInt(p["width"]),smallInt(p["height"]))
|
||||
require(patch.frameIndex==index && if(dynamic) patch.ptsUs==pts[index] else kotlin.math.abs(patch.ptsUs-pts[index])<=2)
|
||||
require(patch.path.matches(Regex("patches/[a-zA-Z0-9_.-]+\\.png")))
|
||||
|
||||
@@ -14,8 +14,8 @@ import java.util.concurrent.Executors
|
||||
|
||||
/** Immutable APK cache; no Activity, Surface, GL texture or camera retained. */
|
||||
object StartupAvatarRepository {
|
||||
const val BASIC_SHA="461f5cfc10036de5f10ca3ce765fb8d9998697d3fd035aa9b1862d2ccfc3eaa2"
|
||||
private const val ROOT="avatar/startup-white-01/"
|
||||
private val BASIC_SHA get()=BuildConfig.STARTUP_MANIFEST_SHA
|
||||
private val ROOT get()=BuildConfig.STARTUP_ASSET_ROOT
|
||||
private val worker=Executors.newSingleThreadExecutor { Thread(it,"avatar-validation").apply { isDaemon=true } }
|
||||
private val main=Handler(Looper.getMainLooper())
|
||||
private val full=StartupLoadCache<AvatarPack>(worker)
|
||||
@@ -30,7 +30,7 @@ object StartupAvatarRepository {
|
||||
val app=context.applicationContext
|
||||
val info=app.packageManager.getPackageInfo(app.packageName,0)
|
||||
val key=StartupAssetKey(info.versionCode.toLong(),info.lastUpdateTime,BuildConfig.EMOTION_MANIFEST_SHA,
|
||||
"avatar/a01-expression-action-v1/",2)
|
||||
BuildConfig.EMOTION_ASSET_ROOT,3)
|
||||
var cancelled=false
|
||||
var basicFailed=false
|
||||
// Both requests use one serial IO worker: the tiny baseline is prioritized.
|
||||
@@ -41,7 +41,7 @@ object StartupAvatarRepository {
|
||||
val json=JSONObject(String(raw,Charsets.UTF_8))
|
||||
check(json.getString("sourceIndexSha256")==BuildConfig.EMOTION_MANIFEST_SHA)
|
||||
val b=json.getJSONObject("body")
|
||||
val path=b.getString("path");check(path=="avatar/a01-expression-action-v1/runtime/neutral/body/idle.mp4")
|
||||
val path=b.getString("path");check(path==BuildConfig.EMOTION_ASSET_ROOT+"runtime/neutral/body/idle.mp4")
|
||||
val bytes=readBounded(app.assets.open(path),64_000_000);check(bytes.size<=64_000_000 && sha(bytes)==b.getString("sha256"))
|
||||
val poster=readBounded(app.assets.open(ROOT+"poster.png"),100_000);check(poster.size<=100_000 && sha(poster)==json.getString("posterSha256"))
|
||||
val pts=b.getJSONArray("ptsUs");val timeline=List(pts.length()) { pts.getLong(it) }
|
||||
|
||||
@@ -15,7 +15,7 @@ class StartupAvatarView(context: Context,private val binding: AvatarMediaBinding
|
||||
private val report: (VideoPresentation)->Unit,private val fullVisible: ()->Unit,private val failed: ()->Unit={}): FrameLayout(context) {
|
||||
private val poster=ImageView(context).apply {
|
||||
scaleType=ImageView.ScaleType.FIT_CENTER
|
||||
setImageResource(R.drawable.startup_poster)
|
||||
setImageResource(if(com.gorios.lanvoice.BuildConfig.AVATAR_USER_ASSET_CANDIDATE) R.drawable.startup_black_tulle_poster else R.drawable.startup_poster)
|
||||
}
|
||||
private val surface=TextureView(context).apply { isOpaque=false;alpha=0f }
|
||||
private var basic: ContinuousAvatarPack?=null
|
||||
|
||||
@@ -12,7 +12,9 @@ import java.util.concurrent.Executor
|
||||
data class StartupAssetKey(val versionCode: Long,val installedAt: Long,val pin: String,
|
||||
val root: String,val validator: Int) {
|
||||
init { require(versionCode>0 && installedAt>0 && pin.matches(Regex("[0-9a-f]{64}")) &&
|
||||
root=="avatar/a01-expression-action-v1/" && validator>0) }
|
||||
(root=="avatar/a01-expression-action-v1/" ||
|
||||
root=="avatar/a01-black-tulle-roomy720-correct03/" &&
|
||||
pin=="208f703ed92bf795bfeb78a1cef89b67bed2e45da80038a56157fd1ecd4cfa93" && validator>=3) && validator>0) }
|
||||
val fingerprint: String get() = digest("$versionCode/$installedAt/$pin/$root/$validator")
|
||||
}
|
||||
private fun digest(value: String): String = MessageDigest.getInstance("SHA-256").digest(value.toByteArray())
|
||||
|
||||
Reference in New Issue
Block a user