Skip to content

Commit 204e447

Browse files
committed
fix(android): read proven termination in the recovery warning too
Review follow-up. Classify the recovered chunk's recorder with the owning observation predicate, so a recorder proven gone through pid reuse also discloses that the MP4 may be truncated instead of only a pid directory that went absent. Attribute each `ownership-lost` producer — reassigned executable, foreign remote path, exited task with no command line — in the transport test, and state them in the contract comment the classification rests on.
1 parent 62b4580 commit 204e447

3 files changed

Lines changed: 39 additions & 14 deletions

File tree

‎packages/platform-android/src/recording/recovery.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,29 @@ test('reattaches an ended pid with an artifact as finishable recovery and report
7272
});
7373
});
7474

75+
test('discloses truncation when recovery proved the recorder gone before record stop', async () => {
76+
let manifest = '';
77+
const observations = ['ownership-lost', 'missing'] as const;
78+
let observation = 0;
79+
const runtime = await start({
80+
writeManifest: async ({ contents }: { contents: string }) => {
81+
manifest = contents;
82+
},
83+
readManifest: async () =>
84+
manifest ? { status: 'read' as const, contents: manifest } : { status: 'missing' as const },
85+
inspect: async () => observations[Math.min(observation++, observations.length - 1)],
86+
stop: async () => 'uncertain' as const,
87+
});
88+
const started = await runtime.screenRecordingStart(recordingInput());
89+
const reattached = await runtime.screenRecordingReattach({ envelope: started.envelope });
90+
expect(reattached.status).toBe('active');
91+
if (reattached.status === 'active')
92+
await expect(reattached.handle.finish()).resolves.toMatchObject({
93+
status: 'completed',
94+
result: { warning: expect.stringContaining('likely after reaching the 180s platform limit') },
95+
});
96+
});
97+
7598
test('returns fenced native completion after a crash between native finalization and daemon terminalization', async () => {
7699
let manifest = '';
77100
const removals: string[] = [];

‎packages/platform-android/src/recording/recovery.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async function reattachEvidence(params: {
176176
evidence,
177177
manifestPath: descriptor.manifestPath,
178178
recording: current,
179-
reachedLimit: running === 'missing',
179+
reachedLimit: provesAndroidScreenRecordTermination(running),
180180
});
181181
nativeCleanupConfirmed = true;
182182
return outcome;

‎src/platform-runtime-screen-recording-android-host.test.ts‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,19 @@ test('retains an interrupted empty-stderr manifest probe as unavailable', async
196196
}
197197
});
198198

199-
test('proves termination for a reassigned pid and an exited task, and never for an unreadable one', async () => {
199+
test('proves termination from each ownership-lost producer without signalling', async () => {
200200
const commands: string[] = [];
201-
let identity: { stat: string; cmdline: string } = {
202-
stat: procStat(4004, '5432'),
201+
const recorded = { pid: '4004', remotePath: '/sdcard/capture.mp4', startTime: '3766' };
202+
const reassignedPid = {
203+
stat: procStat(4004, '3766'),
203204
cmdline: ['/system/bin/servicemanager', ''].join('\0'),
204205
};
206+
const otherArtifact = {
207+
stat: procStat(4004, '3766'),
208+
cmdline: ['/system/bin/screenrecord', '--bit-rate', '8000000', '/other.mp4', ''].join('\0'),
209+
};
210+
const exitedTask = { stat: procStat(4004, '3766'), cmdline: '' };
211+
let identity = reassignedPid;
205212
await withAndroidAdbProvider(
206213
{
207214
exec: async (args) => {
@@ -215,16 +222,11 @@ test('proves termination for a reassigned pid and an exited task, and never for
215222
{ serial: android.id },
216223
async () => {
217224
const transport = await createAndroidScreenRecordingTransport(android);
218-
const recorded = { pid: '4004', remotePath: '/sdcard/capture.mp4', startTime: '3766' };
219-
await expect(transport.inspect(recorded)).resolves.toBe('ownership-lost');
220-
identity = {
221-
stat: procStat(4004, '3766'),
222-
cmdline: ['/system/bin/screenrecord', '--bit-rate', '8000000', '/other.mp4', ''].join('\0'),
223-
};
224-
await expect(transport.inspect(recorded)).resolves.toBe('ownership-lost');
225-
identity = { stat: procStat(4004, '3766'), cmdline: '' };
226-
await expect(transport.inspect(recorded)).resolves.toBe('ownership-lost');
227-
identity = { stat: procStat(4004, '3766'), cmdline: '' };
225+
for (const replacement of [reassignedPid, otherArtifact, exitedTask]) {
226+
identity = replacement;
227+
await expect(transport.inspect(recorded)).resolves.toBe('ownership-lost');
228+
}
229+
identity = exitedTask;
228230
await expect(transport.stop(recorded)).resolves.toBe('ownership-lost');
229231
expect(commands.some((command) => command.startsWith('kill '))).toBe(false);
230232
},

0 commit comments

Comments
 (0)