feat(android): Share to Shade — a video from the gallery is sealed on the phone and uploaded

ShadeUpload turns a shared content:// URI into meta and an upload job;
KeystoreSecretFile keeps the owner seed under a Keystore key. The demo app
takes SEND/SEND_MULTIPLE of video, images, audio and documents, uploads in a
foreground service with progress, and its done notification plays the file
or shares the link; the player gets a Share button. The live cross-check
also uploads a content:// share under Robolectric.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-10-19 00:28:36 +02:00
parent b53dcd7813
commit 0a706cdb47
16 changed files with 733 additions and 11 deletions

View File

@@ -11,7 +11,8 @@
* `SHADE_MEDIA_LIVE_SPEC` set. That test opens the TS file from its link,
* seals and uploads a 40 MiB film in pieces and a photo in one PUT, puts the
* film again (the relay already has it), runs an upload job that is "killed"
* after its first piece and resumed, and deletes the photo. This script
* after its first piece and resumed, and deletes the photo. Then the
* Robolectric `ShadeUploadTest` shares a video by its content:// URI. This script
* then opens the Kotlin film from its link with the TS reader and checks every
* byte, and that both faults were hit and recovered from.
*
@@ -91,6 +92,14 @@ try {
{ cwd: androidDir, env: { ...process.env, SHADE_MEDIA_LIVE_SPEC: specPath }, stdout: 'inherit', stderr: 'inherit' },
);
check((await gradle.exited) === 0, 'Kotlin MediaLiveTest failed');
// And on Android (Robolectric): a shared video, sealed from its content:// URI.
const robo = Bun.spawn(
['./gradlew', ':shade-android-media:testDebugUnitTest', '--tests', 'no.zyon.shade.media.android.ShadeUploadTest', '--console=plain'],
{ cwd: androidDir, env: { ...process.env, SHADE_MEDIA_LIVE_SPEC: specPath }, stdout: 'inherit', stderr: 'inherit' },
);
check((await robo.exited) === 0, 'Android ShadeUploadTest failed');
const shared = fromCapabilityUrl(await readFile(join(dir, 'android-out.txt'), 'utf8')) as MediaGrant;
check((await openGrant(shared)).meta.name === 'VID_0042.mp4', 'the shared video lost its name');
const out = JSON.parse(await readFile(kotlinOut, 'utf8')) as {
film: { link: string; sha256: string; size: number };
@@ -106,10 +115,10 @@ try {
check((await fetch(out.photo.url, { method: 'HEAD' })).status === 404, 'the deleted photo is still served');
check(faults.lostAnswer === 1 && faults.refused === 1, `faults not hit: ${JSON.stringify(faults)}`);
const left = await new MediaClient(url, kotlinOwner).list();
check(left.items.length === 2, `Kotlin owner should have 2 files left (film, re-shared video), has ${left.items.length}`);
check(left.items.length === 3, `Kotlin owner should have 3 files left (film, re-shared video, Android share), has ${left.items.length}`);
console.log(
`LIVE OK — Kotlin read the TS file; Kotlin film ${(out.film.size / MiB).toFixed(1)} MiB in ${faults.pieces} piece requests ` +
`(${faults.starts} starts/resyncs, 1 lost answer, 1 refusal) read back by TS byte for byte; upload job killed and resumed; photo deleted`,
`(${faults.starts} starts/resyncs, 1 lost answer, 1 refusal) read back by TS byte for byte; upload job killed and resumed; a content:// share uploaded from Robolectric; photo deleted`,
);
} finally {
server.stop(true);