Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix: block installer-locked Play APKs

tianma-ifd1eb66584d3e
diff --git a/docs/store-delivery.md b/docs/store-delivery.md
index d25c905e..ecd4806c 100644
--- a/docs/store-delivery.md
+++ b/docs/store-delivery.md
@@ -91,7 +91,10 @@ Play-signed universal APK, verifies the pinned app-signing certificate, and
replaces the GitHub Release Android asset. This makes installations from
Google Play and GitHub mutually updateable. The uploaded AAB is intentionally
limited to `arm64-v8a`, so the Play-generated universal APK does not bundle
-unused 32-bit ARM or x86 native libraries.
+unused 32-bit ARM or x86 native libraries. Automatic Protection must be
+disabled for the release. The downloader fails closed when Play reports
+installer-locked artifacts, preventing a protected APK from being published
+for GitHub sideloading.
Internal, Alpha, Beta, and Production profiles use a completed release on the
selected track. The default command targets Production; use
diff --git a/docs/store-delivery.zh-CN.md b/docs/store-delivery.zh-CN.md
index 6287ddb1..7d0b503e 100644
--- a/docs/store-delivery.zh-CN.md
+++ b/docs/store-delivery.zh-CN.md
@@ -85,7 +85,8 @@ Google Play 处理完 AAB 后,工作流会下载由 Play 应用签名密钥签
核对固定的应用签名证书,并替换 GitHub Release 中的 Android 资产。这样从 Play
和 GitHub 安装的版本可以互相覆盖升级。上传的 AAB 会明确限制为
`arm64-v8a`,因此 Play 生成的通用 APK 不会再打包无用的 32 位 ARM 或 x86
-原生库。
+原生库。该 Release 必须关闭 Automatic Protection;当 Play 返回带安装来源限制
+的产物时,下载器会直接失败,防止此类 APK 再次发布到 GitHub 供侧载。
Internal、Alpha、Beta 和 Production 配置都会在所选轨道创建 Completed
Release。默认命令直接使用 Production;只有明确要求测试交付时才使用
diff --git a/scripts/download-play-universal-apk.mjs b/scripts/download-play-universal-apk.mjs
index 8bcdf083..4fbc1c35 100644
--- a/scripts/download-play-universal-apk.mjs
+++ b/scripts/download-play-universal-apk.mjs
@@ -59,8 +59,17 @@ export const selectPlayUniversalApk = (response, expectedSignerSha256) => {
if (candidates.length !== 1) {
throw new Error(`Expected one Play universal APK for signer ${expectedSigner}, found ${candidates.length}.`);
}
+ const selected = candidates[0];
+ if (
+ Object.hasOwn(selected, "unprotectedGeneratedSplitApks") ||
+ Object.hasOwn(selected, "unprotectedGeneratedStandaloneApks")
+ ) {
+ throw new Error(
+ "Google Play Automatic Protection is enabled for this release; refusing to distribute its installer-locked universal APK.",
+ );
+ }
return {
- downloadId: candidates[0].generatedUniversalApk.downloadId,
+ downloadId: selected.generatedUniversalApk.downloadId,
signerSha256: expectedSigner,
};
};
diff --git a/scripts/download-play-universal-apk.test.mjs b/scripts/download-play-universal-apk.test.mjs
index cc489118..63895874 100644
--- a/scripts/download-play-universal-apk.test.mjs
+++ b/scripts/download-play-universal-apk.test.mjs
@@ -35,6 +35,17 @@ describe("Google Play universal APK selection", () => {
);
});
+ test("refuses an installer-locked universal APK when automatic protection is enabled", () => {
+ const signer = "ab".repeat(32);
+ expect(() => selectPlayUniversalApk({
+ generatedApks: [{
+ certificateSha256Hash: signer,
+ generatedUniversalApk: { downloadId: "protected-universal" },
+ unprotectedGeneratedSplitApks: [],
+ }],
+ }, signer)).toThrow("Automatic Protection is enabled");
+ });
+
test("reports protected and unprotected generated APK variants", () => {
const signer = "ab".repeat(32);
expect(summarizePlayGeneratedApks({