Files
piik/tests/android-release-package.test.ts
T
AAA 815f1a07c4 fix(media): stabilize sharing recovery and remote input (#513)
## Problem and outcome

Connection recovery and packet repair could leave stale pictures, missing sound or unreliable remote input. This maintenance release repairs media/route ownership, H.264 negotiation, voice forwarding and Windows input recovery, and makes shared mobile controls and popovers easier to use.

## Release notes
**Piik, now in your pocket.**

Piik App supports Android screen sharing, with touch controls for a friend's computer.

**手机,也能开播。**

Piik App 支持 Android 屏幕分享,也能用手机控制朋友的电脑。

### English

Piik v2.5.1 improves sharing recovery, voice playback and remote control, with clearer mobile controls. It keeps the existing 2.x compatibility baseline.

- Improve H.264 selection and picture recovery after reconnecting, changing sources or recovering lost packets; keep a working share when a replacement source fails.
- Keep audio and room voice continuous, and prevent duplicate sound when switching playback windows.
- Improve Windows input recovery and release remote-control permissions when their connection ends.
- Keep mobile controls together and popovers usable after layout changes or in short viewports.
- Open the appropriate Android update download, including the Gitee ZIP containing the APK. Self-hosted SFU servers refresh public addresses for new connections without a restart.
- Add macOS source-thumbnail support.

Update the App and self-hosted site together to receive all fixes. Browser settings and existing room data are retained.

### 中文

Piik v2.5.1 改善分享恢复、语音播放与远程控制的稳定性,让手机操作更顺手,沿用现有 2.x 兼容基线。

- 改善 H.264 编码选择,以及重连、切换分享源和丢包后的画面恢复;新分享源切换失败时保留正常分享。
- 保持声音与房间语音连续,避免切换播放窗口时出现双重声音。
- 改善 Windows 输入恢复,并在连接结束时释放远程控制授权。
- 手机控件保持成组,浮层在布局变化或可见高度较小时仍可操作。
- Android 更新打开对应下载入口,Gitee 提供内含 APK 的 ZIP;自部署 SFU 为新连接刷新公网地址,无需重启服务。
- 补齐 macOS 选源缩略图支持。

请一起更新 App 与自部署站点,以获得全部修复。浏览器设置与已有房间数据保留。
## Validation

- Full frontend typecheck, test and production-build acceptance; current Windows App/Server packaging, extracted-file checks and exact served JavaScript verified locally.
- Existing Go, vulnerability, native media and controlled-network results retained at their tested revisions. The final production delta from the fully checked candidate is the shared short-viewport popover correction.
- The diagnostic report supplied for #502 informed the Windows input fixes. #500 sharing is confirmed working; its missing source previews are implemented. Original-device follow-up remains separate from this release's verified local fixes.

## Compatibility and scope

Preserves the published 2.x Browser/server, Native control, capture and SQLite contracts. No 3.0 or iOS implementation or external contributor patch is included. Related: #500, #502, #510, #512.
2026-10-31 16:34:12 -04:00

57 lines
3.6 KiB
TypeScript

import { createHash } from "node:crypto";
import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
import { packageAndroidRelease } from "../scripts/package-android-release.mjs";
import { extractZip } from "../scripts/archive-tool.mjs";
import { readReleaseArtifacts } from "../scripts/release-artifacts.mjs";
import { APP_PACKAGE_TARGETS, ANDROID_APP_PACKAGE_TARGET } from "../scripts/app-package-targets.mjs";
import { SERVER_PACKAGE_TARGETS } from "../scripts/server-package-targets.mjs";
const hash = (bytes: string | Buffer) => createHash("sha256").update(bytes).digest("hex");
describe("Android signed package distributions", () => {
it("wraps only the unchanged APK, validates both distributions and retains old descriptors", () => {
const root = mkdtempSync(join(tmpdir(), "piik-android-distribution-"));
const output = join(root, "output"), extracted = join(root, "extracted");
const version = "v2.5.1", revision = "a".repeat(40);
try {
const apk = join(root, "signed.apk");
writeFileSync(apk, "signed APK fixture bytes");
const descriptor = packageAndroidRelease(apk, output, version, revision);
mkdirSync(extracted);
extractZip(join(output, descriptor.mirrorArtifact), extracted);
expect(readdirSync(extracted)).toEqual([descriptor.artifact]);
expect(hash(readFileSync(join(extracted, descriptor.artifact)))).toBe(hash(readFileSync(apk)));
expect(descriptor.artifactSha256).toBe(hash(readFileSync(apk)));
for (const target of [...SERVER_PACKAGE_TARGETS, ...APP_PACKAGE_TARGETS]) {
const server = SERVER_PACKAGE_TARGETS.some(value => value.id === target.id);
const artifact = `${target.id}.zip`;
writeFileSync(join(output, artifact), target.id);
writeFileSync(join(output, `${artifact}.sha256`), `${hash(target.id)} ${artifact}\n`);
writeFileSync(join(output, `${target.id}.manifest.tsv`), "manifest");
writeFileSync(join(output, `${target.id}.release.json`), JSON.stringify({ schema: 2, version, revision,
target: target.id, artifact, artifactSha256: hash(target.id),
...(server ? { manifest: `${target.id}.manifest.tsv`, manifestSha256: hash("manifest") } : {}) }));
}
const current = readReleaseArtifacts(output, version, revision);
expect(current.targets).toHaveLength(9);
expect(current.files).toHaveLength(10);
expect(current.mirrorFiles).toHaveLength(9);
expect(current.mirrorFiles.some(file => file.name.endsWith(".apk"))).toBe(false);
const sidecar = join(output, `${descriptor.mirrorArtifact}.sha256`);
writeFileSync(sidecar, "wrong");
expect(() => readReleaseArtifacts(output, version, revision)).toThrow(/mirror artifact checksum/);
writeFileSync(sidecar, `${descriptor.mirrorArtifactSha256} ${descriptor.mirrorArtifact}\n`);
writeFileSync(join(output, descriptor.mirrorArtifact), "corrupt ZIP");
expect(() => readReleaseArtifacts(output, version, revision)).toThrow(/mirror artifact checksum/);
const { mirrorArtifact, mirrorArtifactSha256, ...legacy } = descriptor;
writeFileSync(join(output, ANDROID_APP_PACKAGE_TARGET.artifact.replace(/\.apk$/, ".release.json")), JSON.stringify(legacy));
const old = readReleaseArtifacts(output, version, revision);
expect(old.files).toHaveLength(9);
expect(old.mirrorFiles).toEqual(old.files);
} finally { rmSync(root, { recursive: true, force: true }); }
}, 30_000);
});