diff --git a/README.md b/README.md index cb0b5ea..25a9e84 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # NESLite NESLite 是一个面向 Android 的轻量 NES/FC 模拟器前端。它使用固定版本的 -FCEUmm libretro 内核。当前仓库已完成 M7 的隔离实现和本地验证,包括统一返回、横屏安全区、 -前后台资源交接、刷新率采样、异常循环保护和限额诊断;由于目标手机未连接,M2~M7 的实机 -验收仍待补齐。 +FCEUmm libretro 内核。当前仓库已准备 0.9.4 RC 的冻结样本、输入延迟指标、升级架构、原生对齐审计 +和候选交付脚本;由于目标手机、发布签名和可观察玩法的合法 ROM 样本尚未提供,M2~M8 的实机 +验收及 G8 仍待补齐。 ## 快速构建 @@ -16,6 +16,7 @@ pwsh -NoProfile -File .\tools\check.ps1 -Scope Build 该命令默认只生成 arm64-v8a 调试 APK,不会运行耐久或实机验收。 日常操作见 [使用说明](docs/usage.md),存档兼容与安全边界见 [存档格式](docs/save-format.md)。 +候选版证据、静态审计和阻断项见 [M8 候选报告](docs/reports/m8-release-candidate.md)。 连接并授权目标手机后,可用 `tools/check-m1-device.ps1` 安装和启动当前调试 APK;实测步骤见 [X5 Lite 键位表](docs/controller-x5lite.md)。 diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c5656f3..839016c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -21,8 +21,8 @@ android { applicationId = "org.neslite.app" minSdk = 28 targetSdk = 36 - versionCode = 7004 - versionName = "0.7.4" + versionCode = 9004 + versionName = "0.9.4" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" ndk { @@ -34,6 +34,12 @@ android { cppFlags += listOf("-std=c++20", "-Wall", "-Wextra", "-Werror") } } + + javaCompileOptions { + annotationProcessorOptions { + arguments["room.schemaLocation"] = "$projectDir/schemas" + } + } } buildTypes { @@ -43,6 +49,9 @@ android { } release { isMinifyEnabled = false + ndk { + debugSymbolLevel = "FULL" + } proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", @@ -62,6 +71,8 @@ android { useLegacyPackaging = false } } + + sourceSets.getByName("androidTest").assets.srcDir("$projectDir/schemas") } kotlin { @@ -80,4 +91,5 @@ dependencies { testImplementation(libs.json) androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(libs.androidx.room.testing) } diff --git a/app/schemas/org.neslite.app.library.GameDatabase/1.json b/app/schemas/org.neslite.app.library.GameDatabase/1.json new file mode 100644 index 0000000..1ab7066 --- /dev/null +++ b/app/schemas/org.neslite.app.library.GameDatabase/1.json @@ -0,0 +1,27 @@ +{ + "formatVersion": 1, + "database": { + "version": 1, + "identityHash": "10ed8505009ecafab98dd61d2297a006", + "entities": [ + { + "tableName": "games", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sha256` TEXT NOT NULL, `displayName` TEXT NOT NULL, `sizeBytes` INTEGER NOT NULL, `format` TEXT NOT NULL, `fileName` TEXT NOT NULL, `status` TEXT NOT NULL, `addedAtEpochMs` INTEGER NOT NULL, PRIMARY KEY(`sha256`))", + "fields": [ + { "fieldPath": "sha256", "columnName": "sha256", "affinity": "TEXT", "notNull": true }, + { "fieldPath": "displayName", "columnName": "displayName", "affinity": "TEXT", "notNull": true }, + { "fieldPath": "sizeBytes", "columnName": "sizeBytes", "affinity": "INTEGER", "notNull": true }, + { "fieldPath": "format", "columnName": "format", "affinity": "TEXT", "notNull": true }, + { "fieldPath": "fileName", "columnName": "fileName", "affinity": "TEXT", "notNull": true }, + { "fieldPath": "status", "columnName": "status", "affinity": "TEXT", "notNull": true }, + { "fieldPath": "addedAtEpochMs", "columnName": "addedAtEpochMs", "affinity": "INTEGER", "notNull": true } + ], + "primaryKey": { "autoGenerate": false, "columnNames": ["sha256"] } + } + ], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '10ed8505009ecafab98dd61d2297a006')" + ] + } +} diff --git a/app/schemas/org.neslite.app.library.GameDatabase/2.json b/app/schemas/org.neslite.app.library.GameDatabase/2.json new file mode 100644 index 0000000..475d9ac --- /dev/null +++ b/app/schemas/org.neslite.app.library.GameDatabase/2.json @@ -0,0 +1,88 @@ +{ + "formatVersion": 1, + "database": { + "version": 2, + "identityHash": "a1419cc44d08e6e0d04843f45852eaed", + "entities": [ + { + "tableName": "games", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sha256` TEXT NOT NULL, `displayName` TEXT NOT NULL, `sizeBytes` INTEGER NOT NULL, `format` TEXT NOT NULL, `fileName` TEXT NOT NULL, `status` TEXT NOT NULL, `addedAtEpochMs` INTEGER NOT NULL, `favorite` INTEGER NOT NULL DEFAULT 0, `hidden` INTEGER NOT NULL DEFAULT 0, `lastPlayedAtEpochMs` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`sha256`))", + "fields": [ + { + "fieldPath": "sha256", + "columnName": "sha256", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "displayName", + "columnName": "displayName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "sizeBytes", + "columnName": "sizeBytes", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "format", + "columnName": "format", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "fileName", + "columnName": "fileName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "status", + "columnName": "status", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "addedAtEpochMs", + "columnName": "addedAtEpochMs", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "favorite", + "columnName": "favorite", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "hidden", + "columnName": "hidden", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "lastPlayedAtEpochMs", + "columnName": "lastPlayedAtEpochMs", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "sha256" + ] + } + } + ], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'a1419cc44d08e6e0d04843f45852eaed')" + ] + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/org/neslite/app/library/GameDatabaseMigrationTest.kt b/app/src/androidTest/java/org/neslite/app/library/GameDatabaseMigrationTest.kt new file mode 100644 index 0000000..fdd7f1e --- /dev/null +++ b/app/src/androidTest/java/org/neslite/app/library/GameDatabaseMigrationTest.kt @@ -0,0 +1,46 @@ +package org.neslite.app.library + +import androidx.room.testing.MigrationTestHelper +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry +import org.junit.Assert.assertEquals +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class GameDatabaseMigrationTest { + @get:Rule + val helper = MigrationTestHelper( + InstrumentationRegistry.getInstrumentation(), + GameDatabase::class.java, + ) + + @Test + fun migration1To2PreservesLibraryAndAddsDailyUseState() { + helper.createDatabase(TEST_DATABASE, 1).apply { + execSQL( + "INSERT INTO games " + + "(sha256, displayName, sizeBytes, format, fileName, status, addedAtEpochMs) " + + "VALUES ('hash-a', '中文长文件名.nes', 40976, 'iNES', 'hash-a.nes', 'READY', 1234)", + ) + close() + } + + helper.runMigrationsAndValidate(TEST_DATABASE, 2, true, GameDatabase.MIGRATION_1_2).use { database -> + database.query( + "SELECT displayName, favorite, hidden, lastPlayedAtEpochMs FROM games WHERE sha256='hash-a'", + ).use { cursor -> + check(cursor.moveToFirst()) + assertEquals("中文长文件名.nes", cursor.getString(0)) + assertEquals(0, cursor.getInt(1)) + assertEquals(0, cursor.getInt(2)) + assertEquals(0L, cursor.getLong(3)) + } + } + } + + companion object { + private const val TEST_DATABASE = "m8-migration-test" + } +} diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 1024659..0192b81 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -10,6 +10,7 @@ set(NESLITE_COMMON_SOURCES session_rules.cpp audio_ring_buffer.cpp linear_resampler.cpp + input_latency_metrics.cpp timing_metrics.cpp video_buffer.cpp sha256.cpp diff --git a/app/src/main/cpp/core_session.cpp b/app/src/main/cpp/core_session.cpp index ea4d874..fe90b42 100644 --- a/app/src/main/cpp/core_session.cpp +++ b/app/src/main/cpp/core_session.cpp @@ -24,6 +24,7 @@ #include "libretro.h" #include "audio_engine.h" #include "linear_resampler.h" +#include "input_latency_metrics.h" #include "safe_commit.h" #include "save_package.h" #include "save_policy.h" @@ -101,6 +102,8 @@ struct Host { std::atomic joypad{0}; std::atomic turbo{0}; std::atomic effective_joypad{0}; + std::atomic input_event_generation{0}; + std::atomic input_event_received_ns{0}; std::atomic issued_session{0}; std::atomic state{SessionState::Idle}; std::atomic session_id{0}; @@ -122,6 +125,8 @@ struct Host { AudioEngine audio{audio_buffer}; LinearStereoResampler resampler; TimingMetrics timing; + InputLatencyMetrics input_latency; + std::uint64_t sampled_input_generation = 0; std::atomic fast_forward{false}; std::atomic audio_target_frames{800}; double turbo_simulated_seconds = 0.0; @@ -503,6 +508,9 @@ struct Host { joypad.store(0, std::memory_order_relaxed); turbo.store(0, std::memory_order_relaxed); effective_joypad.store(0, std::memory_order_relaxed); + input_event_received_ns.store(0, std::memory_order_relaxed); + sampled_input_generation = input_event_generation.load(std::memory_order_acquire); + input_latency.reset(); turbo_simulated_seconds = 0.0; previous_turbo_mask = 0; save_schedule.reset(); @@ -888,7 +896,15 @@ struct Host { host.audio_buffer.push(converted.data(), converted.size() / 2U); return frames; } - static void input_poll_callback() {} + static void input_poll_callback() { + Host& host = instance(); + const std::uint64_t generation = host.input_event_generation.load(std::memory_order_acquire); + if (generation != host.sampled_input_generation) { + host.input_latency.record(host.input_event_received_ns.load(std::memory_order_acquire), + monotonic_now_ns()); + host.sampled_input_generation = generation; + } + } static std::int16_t input_state_callback(unsigned port, unsigned device, unsigned, unsigned id) { if (port != 0 || device != RETRO_DEVICE_JOYPAD) return 0; const std::uint16_t mask = instance().effective_joypad.load(std::memory_order_relaxed); @@ -938,7 +954,11 @@ bool save_package_command(std::uint64_t session_id, const std::string& command, } void set_joypad_mask(std::uint16_t mask) { - Host::instance().joypad.store(mask, std::memory_order_relaxed); + Host& host = Host::instance(); + if (host.joypad.exchange(mask, std::memory_order_acq_rel) != mask) { + host.input_event_received_ns.store(monotonic_now_ns(), std::memory_order_release); + host.input_event_generation.fetch_add(1, std::memory_order_release); + } } void set_turbo_mask(std::uint16_t mask) { @@ -950,6 +970,7 @@ std::string session_status_json() { std::lock_guard lock(host.mutex); const AudioDiagnostics audio = host.audio.diagnostics(); const TimingSnapshot timing = host.timing.snapshot(monotonic_now_ns()); + const InputLatencySnapshot input_latency = host.input_latency.snapshot(); std::ostringstream json; json << "{\"sessionId\":" << host.session_id.load(std::memory_order_acquire) << ",\"state\":\"" << session_state_name(host.state.load(std::memory_order_acquire)) @@ -963,7 +984,13 @@ std::string session_status_json() { << ",\"recoverySignature\":\"" << json_escape(host.recovery_signature) << "\"" << ",\"input\":{\"baseMask\":" << host.joypad.load(std::memory_order_relaxed) << ",\"turboMask\":" << host.turbo.load(std::memory_order_relaxed) - << ",\"effectiveMask\":" << host.effective_joypad.load(std::memory_order_relaxed) << "}" + << ",\"effectiveMask\":" << host.effective_joypad.load(std::memory_order_relaxed) + << ",\"latencyClock\":\"native_steady_clock_jni_to_first_core_sample\"" + << ",\"latencyCapacity\":2048" + << ",\"latencySamples\":" << input_latency.samples + << ",\"latencyAverageMs\":" << input_latency.average_ms + << ",\"latencyP95Ms\":" << input_latency.p95_ms + << ",\"latencyMaximumMs\":" << input_latency.maximum_ms << "}" << ",\"audio\":{\"open\":" << (audio.open ? "true" : "false") << ",\"active\":" << (audio.active ? "true" : "false") << ",\"muted\":" << (audio.muted ? "true" : "false") diff --git a/app/src/main/cpp/input_latency_metrics.cpp b/app/src/main/cpp/input_latency_metrics.cpp new file mode 100644 index 0000000..09bfc75 --- /dev/null +++ b/app/src/main/cpp/input_latency_metrics.cpp @@ -0,0 +1,47 @@ +#include "input_latency_metrics.h" + +#include +#include +#include +#include +#include + +namespace neslite { +namespace { +constexpr double kNanosPerMillisecond = 1'000'000.0; +} + +InputLatencyMetrics::InputLatencyMetrics(std::size_t capacity) : capacity_(capacity) { + if (capacity_ == 0) throw std::invalid_argument("input latency capacity must be positive"); +} + +void InputLatencyMetrics::reset() { + std::lock_guard lock(mutex_); + samples_ns_.clear(); +} + +void InputLatencyMetrics::record(std::int64_t received_ns, std::int64_t sampled_ns) { + if (received_ns <= 0 || sampled_ns < received_ns) return; + std::lock_guard lock(mutex_); + if (samples_ns_.size() == capacity_) samples_ns_.pop_front(); + samples_ns_.push_back(sampled_ns - received_ns); +} + +InputLatencySnapshot InputLatencyMetrics::snapshot() const { + std::lock_guard lock(mutex_); + if (samples_ns_.empty()) return {}; + std::vector sorted(samples_ns_.begin(), samples_ns_.end()); + std::sort(sorted.begin(), sorted.end()); + const std::size_t p95_index = static_cast( + std::ceil(static_cast(sorted.size()) * 0.95)) - 1U; + const std::int64_t total = std::accumulate(sorted.begin(), sorted.end(), std::int64_t{0}); + return InputLatencySnapshot{ + .samples = sorted.size(), + .average_ms = static_cast(total) / static_cast(sorted.size()) / + kNanosPerMillisecond, + .p95_ms = static_cast(sorted[p95_index]) / kNanosPerMillisecond, + .maximum_ms = static_cast(sorted.back()) / kNanosPerMillisecond, + }; +} + +} // namespace neslite diff --git a/app/src/main/cpp/input_latency_metrics.h b/app/src/main/cpp/input_latency_metrics.h new file mode 100644 index 0000000..c620768 --- /dev/null +++ b/app/src/main/cpp/input_latency_metrics.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include +#include +#include + +namespace neslite { + +struct InputLatencySnapshot { + std::size_t samples = 0; + double average_ms = 0.0; + double p95_ms = 0.0; + double maximum_ms = 0.0; +}; + +class InputLatencyMetrics { + public: + explicit InputLatencyMetrics(std::size_t capacity = 2048); + void reset(); + void record(std::int64_t received_ns, std::int64_t sampled_ns); + InputLatencySnapshot snapshot() const; + + private: + const std::size_t capacity_; + mutable std::mutex mutex_; + std::deque samples_ns_; +}; + +} // namespace neslite diff --git a/app/src/main/cpp/tests/native_smoke_test.cpp b/app/src/main/cpp/tests/native_smoke_test.cpp index 0918769..b7409b9 100644 --- a/app/src/main/cpp/tests/native_smoke_test.cpp +++ b/app/src/main/cpp/tests/native_smoke_test.cpp @@ -1,5 +1,6 @@ #include "audio_ring_buffer.h" #include "linear_resampler.h" +#include "input_latency_metrics.h" #include "native_smoke.h" #include "session_rules.h" #include "timing_metrics.h" @@ -108,6 +109,18 @@ int main() { } if (ntsc_pulses != 15 || pal_pulses != 15 || neslite::turbo_gate(-1.0)) return 40; + neslite::InputLatencyMetrics input_latency(4); + input_latency.record(1'000'000, 2'000'000); + input_latency.record(1'000'000, 3'000'000); + input_latency.record(1'000'000, 4'000'000); + input_latency.record(1'000'000, 5'000'000); + input_latency.record(1'000'000, 10'000'000); + const auto latency = input_latency.snapshot(); + if (latency.samples != 4 || std::abs(latency.average_ms - 4.5) > 0.0001 || + std::abs(latency.p95_ms - 9.0) > 0.0001 || std::abs(latency.maximum_ms - 9.0) > 0.0001) return 63; + input_latency.reset(); + if (input_latency.snapshot().samples != 0) return 64; + const std::vector abc = {'a', 'b', 'c'}; if (neslite::sha256_hex(abc) != "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad") return 41; diff --git a/app/src/main/java/org/neslite/app/MainActivity.kt b/app/src/main/java/org/neslite/app/MainActivity.kt index 4d22dfd..fa774d9 100644 --- a/app/src/main/java/org/neslite/app/MainActivity.kt +++ b/app/src/main/java/org/neslite/app/MainActivity.kt @@ -1645,9 +1645,11 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener { } val audio = status.optJSONObject("audio") ?: JSONObject() val timing = status.optJSONObject("timing") ?: JSONObject() + val input = status.optJSONObject("input") ?: JSONObject() audioStatus.text = "音频:${audio.optString("mode")},核心/设备 ${audio.optInt("coreRate")}/${audio.optInt("deviceRate")} Hz\n" + "回调 ${audio.optLong("callbacks")},帧/回调 ${audio.optInt("maxCallbackFrames")},缓冲 ${audio.optInt("bufferLevel")}/${audio.optInt("bufferTarget")}/${audio.optInt("bufferCapacity")},欠载 ${audio.optLong("underrunFrames")},重建 ${audio.optLong("rebuilds")}\n" + - "速度 ${String.format(Locale.ROOT, "%.3f", timing.optDouble("speedRatio"))}×,模拟帧 ${timing.optLong("frames")},帧工作 ${String.format(Locale.ROOT, "%.2f", timing.optDouble("averageFrameWorkMs"))}/${String.format(Locale.ROOT, "%.2f", timing.optDouble("maximumFrameWorkMs"))} ms" + "速度 ${String.format(Locale.ROOT, "%.3f", timing.optDouble("speedRatio"))}×,模拟帧 ${timing.optLong("frames")},帧工作 ${String.format(Locale.ROOT, "%.2f", timing.optDouble("averageFrameWorkMs"))}/${String.format(Locale.ROOT, "%.2f", timing.optDouble("maximumFrameWorkMs"))} ms\n" + + "输入延迟 ${input.optLong("latencySamples")}/1000,P95 ${String.format(Locale.ROOT, "%.2f", input.optDouble("latencyP95Ms"))} ms(JNI→核心首次采样)" }.onFailure { emulatorStatus.text = raw } } mainHandler.postDelayed(::pollSessionStatus, 250) diff --git a/app/src/main/java/org/neslite/app/library/GameDatabase.java b/app/src/main/java/org/neslite/app/library/GameDatabase.java index 5e80e90..3600f4b 100644 --- a/app/src/main/java/org/neslite/app/library/GameDatabase.java +++ b/app/src/main/java/org/neslite/app/library/GameDatabase.java @@ -8,7 +8,7 @@ import androidx.room.RoomDatabase; import androidx.room.migration.Migration; import androidx.sqlite.db.SupportSQLiteDatabase; -@Database(entities = {GameEntity.class}, version = 2, exportSchema = false) +@Database(entities = {GameEntity.class}, version = 2, exportSchema = true) public abstract class GameDatabase extends RoomDatabase { private static volatile GameDatabase instance; @@ -30,7 +30,7 @@ public abstract class GameDatabase extends RoomDatabase { return current; } - private static final Migration MIGRATION_1_2 = new Migration(1, 2) { + public static final Migration MIGRATION_1_2 = new Migration(1, 2) { @Override public void migrate(@NonNull SupportSQLiteDatabase database) { database.execSQL("ALTER TABLE games ADD COLUMN favorite INTEGER NOT NULL DEFAULT 0"); database.execSQL("ALTER TABLE games ADD COLUMN hidden INTEGER NOT NULL DEFAULT 0"); diff --git a/app/src/test/java/org/neslite/app/BuildIdentityTest.kt b/app/src/test/java/org/neslite/app/BuildIdentityTest.kt index aa2294d..28615ec 100644 --- a/app/src/test/java/org/neslite/app/BuildIdentityTest.kt +++ b/app/src/test/java/org/neslite/app/BuildIdentityTest.kt @@ -7,7 +7,7 @@ class BuildIdentityTest { @Test fun debugBuildUsesTheDocumentedIdentity() { assertEquals("org.neslite.app.debug", BuildConfig.APPLICATION_ID) - assertEquals("0.7.4-debug", BuildConfig.VERSION_NAME) - assertEquals(7004, BuildConfig.VERSION_CODE) + assertEquals("0.9.4-debug", BuildConfig.VERSION_NAME) + assertEquals(9004, BuildConfig.VERSION_CODE) } } diff --git a/docs/architecture.md b/docs/architecture.md index 59e7bb7..c288ff9 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -1,4 +1,4 @@ -# NESLite 架构(M7 基线) +# NESLite 架构(0.9.4 RC 基线) ## 边界与线程 @@ -117,3 +117,14 @@ AndroidX 返回分发先把当前页面和会话状态归一成单一决策: 重复进入,用户仍可从列表明确手动重试。系统事件以最多 3 个、每个 256 KiB 的 JSONL 文件轮换。 诊断导出列出应用/设备、输入、可用显示模式及两秒运行样本、帧与音频、存档边界和原生错误,只记录 ROM 哈希,不包含 ROM 字节或文件路径。 + +## M8 候选可观测性与升级边界 + +基础输入掩码在 JNI 收到实际变化时记录原生 `steady_clock` 时间,单内核线程在下一次有效帧采样前 +计算延迟。固定窗口保留最近 2048 个样本并只导出数量、平均、P95 和最大值,既不在音频回调中工作, +也不保存按键序列。该指标的时间域明确为 JNI 入口到首次核心采样,不宣称是物理按键到屏幕总延迟。 + +Room v1 和 v2 架构随源码保存,v1→v2 迁移继续显式添加收藏、隐藏和最近游玩字段且默认值为零;Android +迁移测试在设备上验证旧中文名称及行数据保留。release 构建保存 FULL 原生符号但不启用混淆。RC 打包 +只接受干净提交,产出未签名 release APK、逐库 16 KB 静态审计、应用/固定第三方源码归档、许可证、 +候选清单和校验和;签名、双页大小环境、API 28 与覆盖升级仍是独立实机门槛。 diff --git a/docs/build.md b/docs/build.md index e42dcc0..fa1ae46 100644 --- a/docs/build.md +++ b/docs/build.md @@ -1,6 +1,6 @@ # NESLite 可复现构建说明 -本说明对应 M0~M6 基线。命令使用系统默认 PowerShell 7.6.6(`pwsh`)从仓库根目录执行;不需要手工复制 `.so`、 +本说明对应 0.9.4 RC 基线。命令使用系统默认 PowerShell 7.6.6(`pwsh`)从仓库根目录执行;不需要手工复制 `.so`、 FCEUmm 或 Oboe 文件。 ## 前置条件 @@ -40,6 +40,31 @@ pwsh -NoProfile -File .\tools\check.ps1 -Scope Build `Stage` 是本地阶段入口,不是 G1~G9 的替代。实机、ROM、存档、插拔和耐久验收必须在 相应里程碑按 [acceptance.md](acceptance.md) 执行和记录。 +## 构建候选交付材料 + +先提交所有候选源码并保持工作区干净,然后执行: + +```powershell +pwsh -NoProfile -ExecutionPolicy Bypass -File .\tools\package-rc.ps1 +``` + +脚本重跑 Stage 和 release lint,生成 `org.neslite.app` 的未签名 release APK、完整原生符号、应用及 +三个固定第三方依赖的源码包、许可证/说明、静态原生审计、候选清单和 SHA-256。输出位于 +`.build/rc-0.9.4/`。静态审计逐个检查 APK 内 `.so` 的 ELF LOAD 段和 APK 16 KB 对齐,并拒绝非 +arm64-v8a 库。 + +默认 APK 刻意保持未签名;发布私钥和口令不得传入仓库或写入脚本。获得受保护的发布密钥后,在隔离 +环境签名并重新执行对齐/签名/设备检查。未签名包不能用于安装、覆盖升级或 G8 运行验收。 + +冻结的 12 个 CC0 最小 ROM 冒烟样本可用下列命令在忽略目录重建: + +```powershell +pwsh -NoProfile -ExecutionPolicy Bypass -File .\tools\generate-rc-roms.ps1 +``` + +它们不包含游戏素材,也不能替代音画、滚屏、电池进度和长稳所需的合法代表游戏样本。设备长稳采集 +入口为 `tools/collect-h-long.ps1`;默认 120 分钟、60 秒一次,只负责采集,不自动批准内存趋势。 + ## M1 诊断版安装 连接并授权一台目标手机后执行: diff --git a/docs/identity.md b/docs/identity.md index 7a1e0ca..05fb884 100644 --- a/docs/identity.md +++ b/docs/identity.md @@ -6,7 +6,7 @@ | --- | --- | | 显示名称 | `NESLite` | | 正式 application ID/namespace | `org.neslite.app` | -| 当前开发版本 | `0.7.4`,`versionCode = 7004` | +| 当前候选版本 | `0.9.4`,`versionCode = 9004` | | 调试 application ID | `org.neslite.app.debug` | | 发布 ABI | `arm64-v8a` | | min/target SDK | 28/36 | diff --git a/docs/known-issues.md b/docs/known-issues.md new file mode 100644 index 0000000..cc19e46 --- /dev/null +++ b/docs/known-issues.md @@ -0,0 +1,15 @@ +# 已知问题与候选版限制 + +本清单对应 0.9.4 RC 源码。优先级含义:阻断表示 G8 不可通过;高表示发布前必须处理;中/低需有 +明确接受或修复结论。 + +| 编号 | 优先级 | 状态 | 问题与处理条件 | +| --- | --- | --- | --- | +| RC-B01 | 阻断 | 开放 | 未连接目标 MagicOS 10 手机,G1~G7 的实机门槛及 G8 关键路径均无有效证据。 | +| RC-B02 | 阻断 | 开放 | 尚无满足动作/滚屏、声音和可观察电池进度要求的合法游戏样本;冻结的 12 个 CC0 最小样本只能用于加载冒烟。 | +| RC-B03 | 阻断 | 开放 | H-LONG、H-INPUT、4 KB/16 KB 运行、API 28 冒烟及 H-UPGRADE 尚未在设备执行。 | +| RC-B04 | 阻断 | 开放 | 尚未提供受保护的发布签名密钥及同 ID/同签名旧版数据集;当前 RC 静态审计包为未签名 APK。 | +| RC-M01 | 中 | 开放 | Release lint 有 55 个非阻断警告,主要是动态界面文本国际化、依赖版本提示和 Android 16 固定横屏兼容提醒;无 lint 错误。 | + +不得通过删除失败 ROM、缩短规定轮数/时长、用 x86_64 替代 arm64,或用桌面原生测试替代 Android +实机运行来关闭阻断项。每项关闭时应在 M8 报告登记设备、包哈希、ROM 哈希、命令、原始日志和结论。 diff --git a/docs/reports/m8-rc-rom-set.md b/docs/reports/m8-rc-rom-set.md new file mode 100644 index 0000000..9c53a71 --- /dev/null +++ b/docs/reports/m8-rc-rom-set.md @@ -0,0 +1,25 @@ +# M8 冻结兼容样本集 + +冻结规则:下列 12 个样本由 `tools/generate-rc-roms.ps1` 确定性生成,均为本项目原创的最小循环程序, +以 CC0-1.0 提供,不包含第三方游戏代码、图形或音频。验收期间不得删除失败样本;生成器、规格或哈希 +发生变化即建立新一版样本集并说明原因。本表只冻结 ROM 身份,不把尚未执行的结果写成通过。 + +| 代号 | SHA-256 | 区域 | Mapper | 头 | 电池标志 | +| --- | --- | --- | ---: | --- | --- | +| RC01 | `FF989B8059D97193F76957D525CE980CCA63400871B866D31800656CA4882308` | NTSC | 0 | iNES | 否 | +| RC02 | `404550B9A6D016489C745BDA4DC40C44167E6D1E8D5B7AF0F1B4805D616D21CD` | PAL | 0 | NES 2.0 | 否 | +| RC03 | `34B58A0BDE66ED4061069BEF7589A13D1CD18CB8B0E7421B4EF77459A5F71DA5` | NTSC | 1 | iNES | 是 | +| RC04 | `27BFABD42A20AE2C7E4C37AC2942E1425CFAEA7A25223B3CD80AA2A2A4EC4254` | PAL | 1 | NES 2.0 | 是 | +| RC05 | `2FCA7D87F1B4C8FAFCFAD50AA7696F6CA0A27249C638383BF835386F366F2763` | NTSC | 2 | iNES | 否 | +| RC06 | `918E9DAD6567EBEECA076BF5685C93BCD96444D0DCCD702165F8F0E0BA4412C7` | PAL | 2 | NES 2.0 | 否 | +| RC07 | `6DD922B8777A2AAFFA9A5178467D5D764CE2B4F929F1FFE4423D5189EB50B266` | NTSC | 3 | iNES | 否 | +| RC08 | `36D5C72495E3ED7568929C348695D365F1EB14C76AD92CDFAC48C6325BE87D64` | PAL | 3 | NES 2.0 | 否 | +| RC09 | `00FC0A41DD14F095475F3D0EDA8B7B9B851C73D7C8F21D3EA4BECDBF610D27BF` | NTSC | 4 | iNES | 是 | +| RC10 | `3B27032AABC0D027F00DAE1688D0A7E0B43B4110D62EC8226BD4BDCE00FFD2BA` | PAL | 4 | NES 2.0 | 是 | +| RC11 | `19B69240BF8E1D96D2EB049EC89FE4F9BE2365216547ABDB7948FBB61819CB6C` | NTSC | 0 | NES 2.0 | 是 | +| RC12 | `60F486E91CC3A21A866B82A044200E871297EEEA50CC78FB9ADC2D0581A91062` | NTSC | 4 | NES 2.0 | 否 | + +这些样本覆盖计划指定的 Mapper 0/1/2/3/4、NTSC/PAL、iNES/NES 2.0 和电池标志,可用于导入、 +头解析、核心加载、暂停与退出的确定性冒烟。它们没有交互画面、滚屏、有效音频或可观察的电池进度, +因此不能替代 H-AV、H-LONG、H-INPUT、H-SAVE 或产品关键路径所需的合法代表游戏样本。相关缺口在 +`m8-release-candidate.md` 中保留为阻断项。 diff --git a/docs/reports/m8-release-candidate.md b/docs/reports/m8-release-candidate.md new file mode 100644 index 0000000..b2fde40 --- /dev/null +++ b/docs/reports/m8-release-candidate.md @@ -0,0 +1,72 @@ +# M8 0.9.4 发布候选记录 + +日期:2026-09-12 + +候选范围冻结为 M7 已实现功能加 M8 验收/交付能力,不再新增产品功能。源码冻结点为包含本报告的 +M8 提交;`tools/package-rc.ps1` 只接受干净工作区,并把实际提交写入 `candidate-manifest.json`。 + +## 冻结身份与配置 + +| 项目 | 冻结值 | +| --- | --- | +| applicationId | `org.neslite.app` | +| RC 版本 | `0.9.4`,versionCode 9004,arm64-v8a,min/target SDK 28/36 | +| FCEUmm | `236ccdfc911e84c60fea6b9d0699c2d440a8de14`,静态链接 | +| libretro header | `0c9622896333ee62dc4326bbe8784a210ddeb03c` | +| Oboe | 1.10.0 / `a81bb9f87d4105b84b682685d3bfbb5beca371d1`,静态链接 | +| 构建 | AGP 8.13.2、Gradle 8.13、Kotlin 2.3.0、JDK 17.0.17+10、NDK 28.2.13676358、CMake 3.22.1 | +| 显示/音频/存档 | M7 配置、48 kHz 请求与设备实际格式、M5 v1 存档封装;本阶段未改变核心提交和存档格式 | +| 兼容样本 | `m8-rc-rom-set.md` 中 12 个固定 CC0 样本;失败样本不得移除 | + +## F01~F14 证据索引与重跑决定 + +| 需求 | 当前可引用证据 | RC 决定 | +| --- | --- | --- | +| F01 导入 | M2 报告及 JVM 解析/边界测试 | 用 12 个冻结样本执行 RC 导入;真机待跑 | +| F02 游戏库 | M2/M6 报告及 Room/JVM 测试 | 中文长名、收藏、隐藏、重关联关键路径待跑 | +| F03 游戏控制 | M2/M7 状态机及原生测试 | 加载、运行、暂停、继续、重置、退出待跑 | +| F04 显示 | M2/M6 视口与设置实现 | 实际画面、过滤、整数缩放和重建待跑 | +| F05 音频/时序 | M3/M7 实现与原生统计 | H-AV 从未取得,必须跑 NTSC/PAL | +| F06 手柄映射 | M1/M4 诊断和 JVM 映射测试 | X5 Lite 实测签名及全路径缺失,必须跑 | +| F07 输入细节 | M4 输入来源/连发测试 | H-HOT 从未取得,必须跑;存档菜单手柄路径待跑 | +| F08 快进 | M3/M4/M6 实现与时钟测试 | 真机倍率、静音及失焦取消待跑 | +| F09 游戏/状态存档 | M5 原生安全提交与格式测试 | H-SAVE 100 次及实机分支从未取得,必须跑 | +| F10 存档包/恢复 | M5 格式、校验和故障测试 | SAF、实际空间/中断及恢复路径待跑 | +| F11 生命周期 | M7 策略与竞态测试 | H-LIFE 从未取得,必须跑 | +| F12 虚拟按键 | M6 多来源 JVM 测试 | 纯触屏完整主链待跑 | +| F13 诊断 | M1/M7 有界导出与轮换测试 | 真机导出可读性及会话关联待跑 | +| F14 原生与交付 | M0 工具链锁、M8 静态审计与交付脚本 | 静态 16 KB 审计可本机完成;双页大小、API 28、签名升级待跑 | + +现有报告没有任何满足 H-AV、H-HOT、H-SAVE、H-LIFE、H-LONG、H-INPUT、H-NATIVE 运行部分或 +H-UPGRADE 完整口径的实机结果,因此本候选不复用这些项目为“通过”。M8 新增输入指标在 JNI 接收 +变化掩码时以 C++ `steady_clock` 起点计时,在核心线程首次采样前结束;容量 2048,导出样本数、平均、 +P95 和最大值。只有正常 Running 状态下累计至少 1000 次后,才能按一个实际模拟帧的阈值判定。 + +## 自动检查与静态原生审计 + +- `tools/check.ps1 -Scope Stage` 通过:arm64-v8a debug APK 构建成功,Windows 原生测试 1/1,JVM + 37/37、0 失败。原生测试新增固定容量输入延迟窗口、平均、P95、最大值和重置验证。 +- release APK、FULL 原生符号和 Android 迁移测试 APK 均构建成功;迁移测试只完成编译,因无设备没有 + 执行。release lint 为 0 错误、55 个非阻断警告,详情见 `docs/known-issues.md`。 +- 静态审计清点出 `lib/arm64-v8a/libneslite_jni.so` 与 DataStore 的 + `lib/arm64-v8a/libdatastore_shared_counter.so`,没有遗漏或非 arm64 ABI。Android Build Tools 36.1.0 + 的 `zipalign -P 16` 通过;NDK r28c 的 LLVM 19.0.1 检查两库全部 ELF LOAD 段,最小对齐均为 + 16,384 字节。FCEUmm 和 Oboe 静态链接在 `libneslite_jni.so` 中。 +- 最终干净提交的 APK、符号、应用源码、三个第三方源码和材料哈希由 `tools/package-rc.ps1` 写入 + `.build/rc-0.9.4/candidate-manifest.json` 与 `SHA256SUMS.txt`,避免在受提交元数据影响的报告中固定 + 预检产物哈希。 + +## 设备验收入口 + +- 12 个固定样本由 `tools/generate-rc-roms.ps1` 重建并逐哈希核对;它们只承担解析、加载、暂停和退出 + 冒烟。产品关键路径、H-AV 与 H-LONG 仍需具有动作/滚屏、声音和可观察电池进度的合法游戏样本。 +- H-LONG 使用 `tools/collect-h-long.ps1`,两个不同代表样本各运行 120 分钟,每 60 秒保留一次原始 + meminfo、CSV 和警告日志;脚本只把无崩溃/ANR的足时运行标为“待审内存趋势”,不能自动宣判通过。 +- Room v1/v2 架构已随源码保存,Android 迁移测试验证中文名称和新增收藏/隐藏/最近字段;仍须在 + 同 ID/同签名覆盖安装中核对 ROM、DataStore、控制器档案和全部存档文件。 + +## 当前结论 + +M8 的自动采集、静态审计和交付基础设施已准备。由于没有连接 Android 设备、可观察玩法的合法样本、 +发布密钥和旧版同签名数据集,M8-01b、M8-02a/b、M8-03b、M8-04a 及 G8 不能执行;M8-04b 的完整 +候选交付也受签名和前置验收阻断。按照 `todo.md` 的阶段依赖与证据规则,M8 全部条目保持未勾选。 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f5d69db..a089fec 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -17,6 +17,7 @@ androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" } androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" } androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" } +androidx-room-testing = { module = "androidx.room:room-testing", version.ref = "room" } androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastore" } junit = { module = "junit:junit", version.ref = "junit" } json = { module = "org.json:json", version.ref = "json" } diff --git a/tests/rc-rom-manifest.json b/tests/rc-rom-manifest.json new file mode 100644 index 0000000..ccd99ee --- /dev/null +++ b/tests/rc-rom-manifest.json @@ -0,0 +1,18 @@ +{ + "formatVersion": 1, + "generator": "tools/generate-rc-roms.ps1", + "samples": [ + { "id": "RC01", "sha256": "FF989B8059D97193F76957D525CE980CCA63400871B866D31800656CA4882308", "region": "NTSC", "mapper": 0, "header": "iNES", "battery": false }, + { "id": "RC02", "sha256": "404550B9A6D016489C745BDA4DC40C44167E6D1E8D5B7AF0F1B4805D616D21CD", "region": "PAL", "mapper": 0, "header": "NES2", "battery": false }, + { "id": "RC03", "sha256": "34B58A0BDE66ED4061069BEF7589A13D1CD18CB8B0E7421B4EF77459A5F71DA5", "region": "NTSC", "mapper": 1, "header": "iNES", "battery": true }, + { "id": "RC04", "sha256": "27BFABD42A20AE2C7E4C37AC2942E1425CFAEA7A25223B3CD80AA2A2A4EC4254", "region": "PAL", "mapper": 1, "header": "NES2", "battery": true }, + { "id": "RC05", "sha256": "2FCA7D87F1B4C8FAFCFAD50AA7696F6CA0A27249C638383BF835386F366F2763", "region": "NTSC", "mapper": 2, "header": "iNES", "battery": false }, + { "id": "RC06", "sha256": "918E9DAD6567EBEECA076BF5685C93BCD96444D0DCCD702165F8F0E0BA4412C7", "region": "PAL", "mapper": 2, "header": "NES2", "battery": false }, + { "id": "RC07", "sha256": "6DD922B8777A2AAFFA9A5178467D5D764CE2B4F929F1FFE4423D5189EB50B266", "region": "NTSC", "mapper": 3, "header": "iNES", "battery": false }, + { "id": "RC08", "sha256": "36D5C72495E3ED7568929C348695D365F1EB14C76AD92CDFAC48C6325BE87D64", "region": "PAL", "mapper": 3, "header": "NES2", "battery": false }, + { "id": "RC09", "sha256": "00FC0A41DD14F095475F3D0EDA8B7B9B851C73D7C8F21D3EA4BECDBF610D27BF", "region": "NTSC", "mapper": 4, "header": "iNES", "battery": true }, + { "id": "RC10", "sha256": "3B27032AABC0D027F00DAE1688D0A7E0B43B4110D62EC8226BD4BDCE00FFD2BA", "region": "PAL", "mapper": 4, "header": "NES2", "battery": true }, + { "id": "RC11", "sha256": "19B69240BF8E1D96D2EB049EC89FE4F9BE2365216547ABDB7948FBB61819CB6C", "region": "NTSC", "mapper": 0, "header": "NES2", "battery": true }, + { "id": "RC12", "sha256": "60F486E91CC3A21A866B82A044200E871297EEEA50CC78FB9ADC2D0581A91062", "region": "NTSC", "mapper": 4, "header": "NES2", "battery": false } + ] +} diff --git a/tools/check-rc-native.ps1 b/tools/check-rc-native.ps1 new file mode 100644 index 0000000..fa65c1e --- /dev/null +++ b/tools/check-rc-native.ps1 @@ -0,0 +1,88 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory = $true)] + [string]$ApkPath, + [string]$OutputPath = '' +) + +$ErrorActionPreference = 'Stop' +$root = Split-Path -Parent $PSScriptRoot +$sdkRoot = if ($env:ANDROID_HOME) { $env:ANDROID_HOME } else { 'C:\Users\shenw_o246oq4\AppData\Local\Android\Sdk' } +$ndkVersion = '28.2.13676358' +$buildToolsVersion = '36.1.0' +$zipalign = Join-Path $sdkRoot "build-tools\$buildToolsVersion\zipalign.exe" +$readelf = Join-Path $sdkRoot "ndk\$ndkVersion\toolchains\llvm\prebuilt\windows-x86_64\bin\llvm-readelf.exe" +$resolvedApk = (Resolve-Path $ApkPath).Path +if (-not (Test-Path $zipalign)) { throw "zipalign not found: $zipalign" } +if (-not (Test-Path $readelf)) { throw "llvm-readelf not found: $readelf" } + +$auditRoot = Join-Path $root '.build\rc-native-audit' +if (Test-Path $auditRoot) { Remove-Item -LiteralPath $auditRoot -Recurse -Force } +$null = New-Item -ItemType Directory -Path $auditRoot +Add-Type -AssemblyName System.IO.Compression.FileSystem +[System.IO.Compression.ZipFile]::ExtractToDirectory($resolvedApk, $auditRoot) + +$nativeFiles = Get-ChildItem (Join-Path $auditRoot 'lib') -Filter '*.so' -File -Recurse -ErrorAction SilentlyContinue +if (-not $nativeFiles) { throw 'No native libraries were found in the candidate APK.' } +$unexpectedAbi = $nativeFiles | Where-Object { $_.FullName -notmatch '[\\/]lib[\\/]arm64-v8a[\\/]' } +if ($unexpectedAbi) { throw "Unexpected non-arm64 native libraries: $($unexpectedAbi.FullName -join ', ')" } + +$zipalignOutput = & $zipalign -c -P 16 -v 4 $resolvedApk 2>&1 +if ($LASTEXITCODE -ne 0) { throw "APK 16 KB zip alignment failed:`n$($zipalignOutput -join [Environment]::NewLine)" } + +$libraries = foreach ($library in $nativeFiles) { + $segments = & $readelf -lW $library.FullName 2>&1 + if ($LASTEXITCODE -ne 0) { throw "ELF inspection failed for $($library.Name)." } + $loadLines = @($segments | Where-Object { $_ -match '^\s*LOAD\s+' }) + if (-not $loadLines) { throw "No LOAD segments found in $($library.Name)." } + $alignments = foreach ($line in $loadLines) { + if ($line -notmatch '(0x[0-9a-fA-F]+)\s*$') { throw "Cannot parse LOAD alignment: $line" } + [Convert]::ToInt64($Matches[1].Substring(2), 16) + } + if (($alignments | Measure-Object -Minimum).Minimum -lt 16384) { + throw "$($library.Name) contains a LOAD segment aligned below 16 KB." + } + $dynamic = & $readelf -dW $library.FullName 2>&1 + if ($LASTEXITCODE -ne 0) { throw "Dynamic dependency inspection failed for $($library.Name)." } + $needed = @($dynamic | ForEach-Object { + if ($_ -match '\(NEEDED\).*\[(.+?)\]') { $Matches[1] } + }) + [ordered]@{ + apkPath = $library.FullName.Substring($auditRoot.Length + 1).Replace('\', '/') + bytes = $library.Length + sha256 = (Get-FileHash $library.FullName -Algorithm SHA256).Hash + minimumLoadAlignmentBytes = ($alignments | Measure-Object -Minimum).Minimum + needed = $needed + } +} + +$readelfVersion = ((& $readelf --version 2>&1 | Select-Object -First 2) -join ' ').Trim() +$result = [ordered]@{ + formatVersion = 1 + apk = [ordered]@{ + path = $resolvedApk + bytes = (Get-Item $resolvedApk).Length + sha256 = (Get-FileHash $resolvedApk -Algorithm SHA256).Hash + zipAlignmentBytes = 16384 + zipAlignmentPassed = $true + } + packaging = [ordered]@{ + abi = 'arm64-v8a' + fceumm = 'statically linked into libneslite_jni.so' + oboe = 'statically linked into libneslite_jni.so' + runtimeLibraries = @($libraries | ForEach-Object { $_.apkPath }) + } + libraries = @($libraries) + tools = [ordered]@{ + androidBuildTools = $buildToolsVersion + ndk = $ndkVersion + llvmReadelf = $readelfVersion + } +} + +if (-not $OutputPath) { $OutputPath = Join-Path $root '.build\rc-native-audit.json' } +$outputDirectory = Split-Path -Parent $OutputPath +if ($outputDirectory) { $null = New-Item -ItemType Directory -Path $outputDirectory -Force } +$result | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath $OutputPath -Encoding utf8NoBOM +Write-Output "RC native static audit passed: $OutputPath" +$result | ConvertTo-Json -Depth 8 diff --git a/tools/collect-h-long.ps1 b/tools/collect-h-long.ps1 new file mode 100644 index 0000000..44ac22c --- /dev/null +++ b/tools/collect-h-long.ps1 @@ -0,0 +1,118 @@ +[CmdletBinding()] +param( + [string]$Serial = '', + [string]$Package = 'org.neslite.app', + [ValidateRange(1, 1440)] + [int]$Minutes = 120, + [ValidateRange(10, 300)] + [int]$IntervalSeconds = 60, + [string]$OutputDirectory = '' +) + +$ErrorActionPreference = 'Stop' +$root = Split-Path -Parent $PSScriptRoot +$sdkRoot = if ($env:ANDROID_HOME) { $env:ANDROID_HOME } else { 'C:\Users\shenw_o246oq4\AppData\Local\Android\Sdk' } +$adb = Join-Path $sdkRoot 'platform-tools\adb.exe' +if (-not (Test-Path $adb)) { throw "adb not found: $adb" } +$adbArguments = @() +if ($Serial) { $adbArguments += @('-s', $Serial) } + +function Invoke-Adb([string[]]$Arguments) { + $output = & $adb @adbArguments @Arguments 2>&1 + if ($LASTEXITCODE -ne 0) { throw "adb failed: $($output -join [Environment]::NewLine)" } + return @($output) +} + +$state = (Invoke-Adb @('get-state') | Select-Object -First 1).Trim() +if ($state -ne 'device') { throw "Target device is not ready: $state" } +$pidValue = (Invoke-Adb @('shell', 'pidof', $Package) | Select-Object -First 1).Trim() +if (-not $pidValue) { throw "Package is not running: $Package" } + +if (-not $OutputDirectory) { + $stamp = Get-Date -Format 'yyyyMMdd-HHmmss' + $OutputDirectory = Join-Path $root ".build\device-evidence\h-long-$stamp" +} +$null = New-Item -ItemType Directory -Path $OutputDirectory -Force +$rawDirectory = Join-Path $OutputDirectory 'meminfo' +$null = New-Item -ItemType Directory -Path $rawDirectory -Force + +$device = [ordered]@{ + serial = (Invoke-Adb @('get-serialno') | Select-Object -First 1).Trim() + product = (Invoke-Adb @('shell', 'getprop', 'ro.product.model') | Select-Object -First 1).Trim() + release = (Invoke-Adb @('shell', 'getprop', 'ro.build.version.release') | Select-Object -First 1).Trim() + api = (Invoke-Adb @('shell', 'getprop', 'ro.build.version.sdk') | Select-Object -First 1).Trim() + abi = (Invoke-Adb @('shell', 'getprop', 'ro.product.cpu.abi') | Select-Object -First 1).Trim() + pageSizeBytes = [long]((Invoke-Adb @('shell', 'getconf', 'PAGESIZE') | Select-Object -First 1).Trim()) +} +$started = Get-Date +$deadline = $started.AddMinutes($Minutes) +$samples = [System.Collections.Generic.List[object]]::new() +$index = 0 +while ((Get-Date) -lt $deadline) { + $pidValue = (Invoke-Adb @('shell', 'pidof', $Package) | Select-Object -First 1).Trim() + if (-not $pidValue) { throw "Package exited during H-LONG at sample $index." } + $raw = Invoke-Adb @('shell', 'dumpsys', 'meminfo', '--local', $Package) + $rawPath = Join-Path $rawDirectory ("sample-{0:D4}.txt" -f $index) + $raw | Set-Content -LiteralPath $rawPath -Encoding utf8NoBOM + $text = $raw -join "`n" + $totalPss = if ($text -match 'TOTAL PSS:\s*([0-9,]+)') { [long]($Matches[1] -replace ',', '') } else { 0L } + $javaHeap = if ($text -match 'Java Heap:\s*([0-9,]+)') { [long]($Matches[1] -replace ',', '') } else { 0L } + $nativeHeap = if ($text -match 'Native Heap:\s*([0-9,]+)') { [long]($Matches[1] -replace ',', '') } else { 0L } + $samples.Add([pscustomobject]@{ + index = $index + epochMs = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() + elapsedMinutes = [Math]::Round(((Get-Date) - $started).TotalMinutes, 3) + pid = $pidValue + totalPssKiB = $totalPss + javaHeapKiB = $javaHeap + nativeHeapKiB = $nativeHeap + }) + $samples | Export-Csv -LiteralPath (Join-Path $OutputDirectory 'memory.csv') -NoTypeInformation -Encoding utf8NoBOM + ++$index + if ((Get-Date).AddSeconds($IntervalSeconds) -lt $deadline) { Start-Sleep -Seconds $IntervalSeconds } +} + +$logcat = Invoke-Adb @('logcat', '-d', '--pid', $pidValue, '-v', 'epoch', '*:W') +$logcat | Set-Content -LiteralPath (Join-Path $OutputDirectory 'logcat-warnings.txt') -Encoding utf8NoBOM +$logText = $logcat -join "`n" +$trendSamples = @($samples | Where-Object elapsedMinutes -ge 10) +$trendSlopeKiBPerMinute = 0.0 +if ($trendSamples.Count -ge 2) { + $meanX = ($trendSamples.elapsedMinutes | Measure-Object -Average).Average + $meanY = ($trendSamples.totalPssKiB | Measure-Object -Average).Average + $numerator = 0.0 + $denominator = 0.0 + foreach ($sample in $trendSamples) { + $deltaX = $sample.elapsedMinutes - $meanX + $numerator += $deltaX * ($sample.totalPssKiB - $meanY) + $denominator += $deltaX * $deltaX + } + if ($denominator -gt 0) { $trendSlopeKiBPerMinute = $numerator / $denominator } +} +$summary = [ordered]@{ + formatVersion = 1 + package = $Package + device = $device + requestedMinutes = $Minutes + intervalSeconds = $IntervalSeconds + startedAt = $started.ToString('o') + finishedAt = (Get-Date).ToString('o') + sampleCount = $samples.Count + firstTotalPssKiB = if ($samples.Count) { $samples[0].totalPssKiB } else { 0 } + lastTotalPssKiB = if ($samples.Count) { $samples[$samples.Count - 1].totalPssKiB } else { 0 } + peakTotalPssKiB = if ($samples.Count) { ($samples.totalPssKiB | Measure-Object -Maximum).Maximum } else { 0 } + postWarmupTrendStartMinute = 10 + postWarmupTotalPssSlopeKiBPerMinute = [Math]::Round($trendSlopeKiBPerMinute, 3) + fatalExceptionCount = ([regex]::Matches($logText, 'FATAL EXCEPTION')).Count + anrCount = ([regex]::Matches($logText, 'ANR in ' + [regex]::Escape($Package))).Count + verdict = if ($Minutes -ge 120 -and $samples.Count -ge 120 -and + @($samples | Where-Object totalPssKiB -eq 0).Count -eq 0 -and + $logText -notmatch 'FATAL EXCEPTION|ANR in ') { + 'REVIEW_MEMORY_TREND' + } else { + 'INCOMPLETE_OR_FAILED' + } +} +$summary | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath (Join-Path $OutputDirectory 'summary.json') -Encoding utf8NoBOM +Write-Output "H-LONG capture complete: $OutputDirectory" +Write-Output 'Review memory.csv for a sustained post-warmup trend before marking the run passed.' diff --git a/tools/generate-rc-roms.ps1 b/tools/generate-rc-roms.ps1 new file mode 100644 index 0000000..fb2fb37 --- /dev/null +++ b/tools/generate-rc-roms.ps1 @@ -0,0 +1,103 @@ +[CmdletBinding()] +param( + [string]$OutputDirectory = '' +) + +$ErrorActionPreference = 'Stop' +$root = Split-Path -Parent $PSScriptRoot +if (-not $OutputDirectory) { $OutputDirectory = Join-Path $root '.build\rc-roms' } +$resolvedOutput = [IO.Path]::GetFullPath($OutputDirectory) +$resolvedBuildRoot = [IO.Path]::GetFullPath((Join-Path $root '.build')) +if (-not $resolvedOutput.StartsWith($resolvedBuildRoot, [StringComparison]::OrdinalIgnoreCase)) { + throw 'Generated ROM output must remain inside the repository .build directory.' +} +if (Test-Path $resolvedOutput) { Remove-Item -LiteralPath $resolvedOutput -Recurse -Force } +$null = New-Item -ItemType Directory -Path $resolvedOutput + +$specifications = @( + @{ id = 'RC01'; mapper = 0; region = 'NTSC'; header = 'iNES'; battery = $false; prgBanks = 1 }, + @{ id = 'RC02'; mapper = 0; region = 'PAL'; header = 'NES2'; battery = $false; prgBanks = 2 }, + @{ id = 'RC03'; mapper = 1; region = 'NTSC'; header = 'iNES'; battery = $true; prgBanks = 2 }, + @{ id = 'RC04'; mapper = 1; region = 'PAL'; header = 'NES2'; battery = $true; prgBanks = 2 }, + @{ id = 'RC05'; mapper = 2; region = 'NTSC'; header = 'iNES'; battery = $false; prgBanks = 2 }, + @{ id = 'RC06'; mapper = 2; region = 'PAL'; header = 'NES2'; battery = $false; prgBanks = 2 }, + @{ id = 'RC07'; mapper = 3; region = 'NTSC'; header = 'iNES'; battery = $false; prgBanks = 2 }, + @{ id = 'RC08'; mapper = 3; region = 'PAL'; header = 'NES2'; battery = $false; prgBanks = 2 }, + @{ id = 'RC09'; mapper = 4; region = 'NTSC'; header = 'iNES'; battery = $true; prgBanks = 2 }, + @{ id = 'RC10'; mapper = 4; region = 'PAL'; header = 'NES2'; battery = $true; prgBanks = 2 }, + @{ id = 'RC11'; mapper = 0; region = 'NTSC'; header = 'NES2'; battery = $true; prgBanks = 1 }, + @{ id = 'RC12'; mapper = 4; region = 'NTSC'; header = 'NES2'; battery = $false; prgBanks = 2 } +) + +$manifestEntries = foreach ($specification in $specifications) { + $header = [byte[]]::new(16) + $header[0] = 0x4e; $header[1] = 0x45; $header[2] = 0x53; $header[3] = 0x1a + $header[4] = [byte]$specification.prgBanks + $header[5] = 1 + $header[6] = [byte]((($specification.mapper -band 0x0f) -shl 4) -bor $(if ($specification.battery) { 0x02 } else { 0 })) + $header[7] = [byte]($specification.mapper -band 0xf0) + if ($specification.header -eq 'NES2') { $header[7] = [byte]($header[7] -bor 0x08) } + if ($specification.region -eq 'PAL') { + if ($specification.header -eq 'NES2') { $header[12] = 1 } else { $header[9] = 1 } + } + + $prg = [byte[]]::new([int]$specification.prgBanks * 16384) + [Array]::Fill($prg, [byte]0xea) + $programOffset = $prg.Length - 16384 + $program = [byte[]](0x78, 0xd8, 0xa2, 0xff, 0x9a, 0xe8, 0x8e, 0x00, 0x20, 0x8e, 0x01, 0x20, 0x4c, 0x0c, 0xc0) + [Array]::Copy($program, 0, $prg, $programOffset, $program.Length) + $marker = [Text.Encoding]::ASCII.GetBytes("NESLITE-$($specification.id)-M$($specification.mapper)-$($specification.region)-$($specification.header)") + [Array]::Copy($marker, 0, $prg, $programOffset + 64, $marker.Length) + $vectorOffset = $prg.Length - 6 + for ($index = 0; $index -lt 3; ++$index) { + $prg[$vectorOffset + ($index * 2)] = 0x00 + $prg[$vectorOffset + ($index * 2) + 1] = 0xc0 + } + $chr = [byte[]]::new(8192) + $rom = [byte[]]::new($header.Length + $prg.Length + $chr.Length) + [Array]::Copy($header, 0, $rom, 0, $header.Length) + [Array]::Copy($prg, 0, $rom, $header.Length, $prg.Length) + [Array]::Copy($chr, 0, $rom, $header.Length + $prg.Length, $chr.Length) + $fileName = "$($specification.id)-m$($specification.mapper)-$($specification.region.ToLowerInvariant())-$($specification.header.ToLowerInvariant()).nes" + $path = Join-Path $resolvedOutput $fileName + [IO.File]::WriteAllBytes($path, $rom) + [ordered]@{ + id = $specification.id + fileName = $fileName + sha256 = (Get-FileHash $path -Algorithm SHA256).Hash + bytes = $rom.Length + region = $specification.region + mapper = $specification.mapper + header = $specification.header + battery = [bool]$specification.battery + license = 'CC0-1.0 generated test fixture' + purpose = 'Deterministic loader/header/mapper-declaration smoke fixture; not gameplay evidence.' + } +} + +$manifest = [ordered]@{ + formatVersion = 1 + generator = 'tools/generate-rc-roms.ps1' + rights = 'Generated by NESLite for this test set and dedicated under CC0-1.0; contains no third-party game data.' + limitations = 'Minimal looping programs validate import/load declarations only; they do not replace action, scrolling, audio, or battery-progress gameplay samples.' + samples = @($manifestEntries) +} +$frozenPath = Join-Path $root 'tests\rc-rom-manifest.json' +$frozen = Get-Content $frozenPath -Raw | ConvertFrom-Json +if ($frozen.samples.Count -ne $manifestEntries.Count) { throw 'Frozen RC ROM sample count changed.' } +foreach ($expected in $frozen.samples) { + $matches = @($manifestEntries | Where-Object id -eq $expected.id) + $actual = if ($matches.Count -eq 1) { $matches[0] } else { $null } + if (-not $actual -or $actual.sha256 -ne $expected.sha256 -or $actual.region -ne $expected.region -or + $actual.mapper -ne $expected.mapper -or $actual.header -ne $expected.header -or + $actual.battery -ne $expected.battery) { + throw "Generated RC ROM no longer matches frozen manifest: $($expected.id)" + } +} +$manifest | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath (Join-Path $resolvedOutput 'manifest.json') -Encoding utf8NoBOM +@' +To the extent possible under law, the author has waived all copyright and related or neighboring rights to these generated test fixtures under CC0 1.0 Universal. +These fixtures contain only a minimal original loop and deterministic metadata; they contain no third-party game code, graphics, audio, or other ROM content. +'@ | Set-Content -LiteralPath (Join-Path $resolvedOutput 'LICENSE.txt') -Encoding utf8NoBOM +Write-Output "Generated 12 deterministic RC ROM fixtures: $resolvedOutput" +$manifest | ConvertTo-Json -Depth 6 diff --git a/tools/package-rc.ps1 b/tools/package-rc.ps1 new file mode 100644 index 0000000..dd90c2f --- /dev/null +++ b/tools/package-rc.ps1 @@ -0,0 +1,152 @@ +[CmdletBinding()] +param( + [string]$OutputDirectory = '' +) + +$ErrorActionPreference = 'Stop' +$root = Split-Path -Parent $PSScriptRoot +$sdkRoot = if ($env:ANDROID_HOME) { $env:ANDROID_HOME } else { 'C:\Users\shenw_o246oq4\AppData\Local\Android\Sdk' } +$bundledJdk = Join-Path $root '.toolchains\jdk-17.0.17+10' +$env:JAVA_HOME = if ($env:JAVA_HOME -and (Test-Path (Join-Path $env:JAVA_HOME 'bin\java.exe'))) { + $env:JAVA_HOME +} else { + $bundledJdk +} +$env:ANDROID_HOME = $sdkRoot +$env:ANDROID_SDK_ROOT = $sdkRoot +$versionName = '0.9.4' +$versionCode = 9004 +$gitStatus = @(& git -C $root status --porcelain) +if ($LASTEXITCODE -ne 0) { throw 'Cannot inspect the Git worktree.' } +if ($gitStatus.Count -ne 0) { throw 'RC packaging requires a clean committed worktree.' } +$sourceCommit = (& git -C $root rev-parse HEAD).Trim() +if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve the source commit.' } + +if (-not $OutputDirectory) { $OutputDirectory = Join-Path $root ".build\rc-$versionName" } +$resolvedOutput = [IO.Path]::GetFullPath($OutputDirectory) +$resolvedBuildRoot = [IO.Path]::GetFullPath((Join-Path $root '.build')) +if (-not $resolvedOutput.StartsWith($resolvedBuildRoot, [StringComparison]::OrdinalIgnoreCase)) { + throw 'RC output must remain inside the repository .build directory.' +} +if (Test-Path $resolvedOutput) { Remove-Item -LiteralPath $resolvedOutput -Recurse -Force } +$null = New-Item -ItemType Directory -Path $resolvedOutput + +& pwsh -NoProfile -ExecutionPolicy Bypass -File (Join-Path $root 'tools\check.ps1') -Scope Stage +if ($LASTEXITCODE -ne 0) { throw 'Stage checks failed.' } +& (Join-Path $root 'gradlew.bat') ':app:assembleRelease' ':app:lintRelease' ':app:assembleDebugAndroidTest' +if ($LASTEXITCODE -ne 0) { throw 'Release build or lint failed.' } + +$builtApk = Join-Path $root 'app\build\outputs\apk\release\app-release-unsigned.apk' +$builtSymbols = Join-Path $root 'app\build\outputs\native-debug-symbols\release\native-debug-symbols.zip' +if (-not (Test-Path $builtApk)) { throw "Unsigned release APK not found: $builtApk" } +if (-not (Test-Path $builtSymbols)) { throw "Native symbols not found: $builtSymbols" } +$candidateApk = Join-Path $resolvedOutput "NESLite-$versionName-rc-arm64-v8a-unsigned.apk" +$candidateSymbols = Join-Path $resolvedOutput "NESLite-$versionName-native-debug-symbols.zip" +Copy-Item -LiteralPath $builtApk -Destination $candidateApk +Copy-Item -LiteralPath $builtSymbols -Destination $candidateSymbols +$testTools = Join-Path $resolvedOutput 'test-tools' +$null = New-Item -ItemType Directory -Path $testTools +Copy-Item -LiteralPath (Join-Path $root 'app\build\outputs\apk\debug\app-debug.apk') -Destination $testTools +Copy-Item -LiteralPath (Join-Path $root 'app\build\outputs\apk\androidTest\debug\app-debug-androidTest.apk') -Destination $testTools + +$nativeAudit = Join-Path $resolvedOutput 'native-audit.json' +& pwsh -NoProfile -ExecutionPolicy Bypass -File (Join-Path $root 'tools\check-rc-native.ps1') -ApkPath $candidateApk -OutputPath $nativeAudit +if ($LASTEXITCODE -ne 0) { throw 'Native static audit failed.' } + +$aapt = Join-Path $sdkRoot 'build-tools\36.1.0\aapt.exe' +$badging = @(& $aapt dump badging $candidateApk 2>&1) +if ($LASTEXITCODE -ne 0) { throw 'Could not inspect candidate APK identity.' } +$packageLine = $badging | Select-Object -First 1 +if ($packageLine -notmatch "name='org\.neslite\.app'.*versionCode='$versionCode'.*versionName='$versionName'") { + throw "Unexpected release identity: $packageLine" +} + +$appSourceArchive = Join-Path $resolvedOutput "NESLite-$versionName-source.zip" +& git -C $root archive --format=zip "--prefix=NESLite-$versionName/" "--output=$appSourceArchive" HEAD +if ($LASTEXITCODE -ne 0) { throw 'Application source archive failed.' } +$thirdPartyManifest = Get-Content (Join-Path $root 'third_party\manifest.json') -Raw | ConvertFrom-Json +$thirdPartyArchives = @() +foreach ($source in $thirdPartyManifest.sources) { + $sourceDirectory = Join-Path $root "third_party\sources\$($source.directory)" + if (-not (Test-Path $sourceDirectory)) { throw "Third-party source is missing: $($source.directory)" } + $actualCommit = (& git -C $sourceDirectory rev-parse HEAD).Trim() + if ($LASTEXITCODE -ne 0 -or $actualCommit -ne $source.commit) { + throw "Third-party source is not at its locked commit: $($source.directory)" + } + $archive = Join-Path $resolvedOutput "$($source.directory)-$($source.commit.Substring(0, 12))-source.zip" + & git -C $sourceDirectory archive --format=zip "--prefix=$($source.directory)/" "--output=$archive" $source.commit + if ($LASTEXITCODE -ne 0) { throw "Source archive failed: $($source.directory)" } + $thirdPartyArchives += Split-Path -Leaf $archive +} + +$materials = Join-Path $resolvedOutput 'release-materials' +$null = New-Item -ItemType Directory -Path $materials +Copy-Item -LiteralPath (Join-Path $root 'LICENSE') -Destination $materials +Copy-Item -LiteralPath (Join-Path $root 'THIRD_PARTY_NOTICES.md') -Destination $materials +Copy-Item -LiteralPath (Join-Path $root 'third_party\manifest.json') -Destination $materials +Copy-Item -LiteralPath (Join-Path $root 'third_party\sources\oboe\LICENSE') -Destination (Join-Path $materials 'APACHE-2.0.txt') +Copy-Item -LiteralPath (Join-Path $root 'third_party\sources\libretro-fceumm\Copying') -Destination (Join-Path $materials 'GPL-2.0.txt') +Copy-Item -LiteralPath (Join-Path $root 'docs\build.md') -Destination $materials +Copy-Item -LiteralPath (Join-Path $root 'docs\usage.md') -Destination $materials +Copy-Item -LiteralPath (Join-Path $root 'docs\architecture.md') -Destination $materials +Copy-Item -LiteralPath (Join-Path $root 'docs\save-format.md') -Destination $materials +Copy-Item -LiteralPath (Join-Path $root 'docs\known-issues.md') -Destination $materials +Copy-Item -LiteralPath (Join-Path $root 'docs\reports\m8-release-candidate.md') -Destination $materials + +& pwsh -NoProfile -ExecutionPolicy Bypass -File (Join-Path $root 'tools\generate-rc-roms.ps1') +if ($LASTEXITCODE -ne 0) { throw 'Frozen RC ROM generation or hash verification failed.' } +$fixtureMetadata = Join-Path $resolvedOutput 'rom-fixture-metadata' +$null = New-Item -ItemType Directory -Path $fixtureMetadata +Copy-Item -LiteralPath (Join-Path $root '.build\rc-roms\manifest.json') -Destination $fixtureMetadata +Copy-Item -LiteralPath (Join-Path $root '.build\rc-roms\LICENSE.txt') -Destination $fixtureMetadata + +$manifest = [ordered]@{ + formatVersion = 1 + generatedAt = (Get-Date).ToUniversalTime().ToString('o') + sourceCommit = $sourceCommit + versionName = $versionName + versionCode = $versionCode + applicationId = 'org.neslite.app' + abi = @('arm64-v8a') + signing = [ordered]@{ + signed = $false + status = 'BLOCKED_PENDING_RELEASE_KEY' + note = 'This static-audit candidate must be signed with the protected release key before installation or upgrade testing.' + } + native = [ordered]@{ + fceummCommit = '236ccdfc911e84c60fea6b9d0699c2d440a8de14' + libretroHeaderCommit = '0c9622896333ee62dc4326bbe8784a210ddeb03c' + oboeCommit = 'a81bb9f87d4105b84b682685d3bfbb5beca371d1' + symbols = Split-Path -Leaf $candidateSymbols + mapping = 'not generated; minification is disabled' + } + artifacts = [ordered]@{ + apk = Split-Path -Leaf $candidateApk + applicationSource = Split-Path -Leaf $appSourceArchive + thirdPartySources = $thirdPartyArchives + nativeAudit = Split-Path -Leaf $nativeAudit + materials = 'release-materials/' + romFixtureMetadata = 'rom-fixture-metadata/' + androidMigrationTest = 'test-tools/app-debug-androidTest.apk' + } + runtimeEvidence = [ordered]@{ + romCompatibility = 'BLOCKED_NO_EXECUTED_RC_COMPATIBILITY_OR_GAMEPLAY_SAMPLES' + hLong = 'BLOCKED_NO_DEVICE' + hInput = 'BLOCKED_NO_DEVICE' + fourKiB = 'BLOCKED_NO_DEVICE' + sixteenKiB = 'BLOCKED_NO_DEVICE' + api28 = 'BLOCKED_NO_DEVICE' + upgrade = 'BLOCKED_NO_SIGNED_OLD_DATASET_OR_DEVICE' + } +} +$manifestPath = Join-Path $resolvedOutput 'candidate-manifest.json' +$manifest | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath $manifestPath -Encoding utf8NoBOM + +$checksumFiles = Get-ChildItem $resolvedOutput -File -Recurse | Where-Object Name -ne 'SHA256SUMS.txt' | Sort-Object FullName +$checksumLines = foreach ($file in $checksumFiles) { + $relative = [IO.Path]::GetRelativePath($resolvedOutput, $file.FullName).Replace('\', '/') + "{0} {1}" -f (Get-FileHash $file.FullName -Algorithm SHA256).Hash, $relative +} +$checksumLines | Set-Content -LiteralPath (Join-Path $resolvedOutput 'SHA256SUMS.txt') -Encoding ascii +Write-Output "RC materials created: $resolvedOutput" +Write-Output 'The APK is intentionally unsigned; device and upgrade gates remain blocked until release signing is available.'