Skip to content

Commit f07a4ec

Browse files
authored
refactor(android): drop the snapshot helper manifest installArgs (#2618)
The release manifest's installArgs only ever spelled `install -r` plus the `-t` that #2603 retired with the testOnly flag. Its consumer parsed the array, validated it against a four-flag allowlist, lowered it to semantic options, and lowered those back to flags at the provider — a round trip that carried nothing once the flag was gone. The snapshot helper now installs with a fixed `replace: true`, the same path the IME helper already used. The manifest type, parser, packaging script, and README contract drop the field; older manifests that still carry it parse unchanged and the field is ignored. The adb provider install capability narrows to `replace` — `-t`, `-d`, `-g` had no producer left. Refs #2364.
1 parent 23fd3c9 commit f07a4ec

14 files changed

Lines changed: 40 additions & 189 deletions

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
- Changed (android): the snapshot helper release manifest no longer carries `installArgs`, and the
6+
helper installs with a fixed `adb install -r` like the IME helper. The array only ever spelled
7+
`install -r` plus the `-t` that #2603 retired with the `testOnly` flag, so the manifest → flag →
8+
option → flag round trip and its allowlist carried nothing. Older manifests that still contain
9+
the field parse unchanged; the field is ignored. The adb provider `install` capability now takes
10+
only `replace` (#2364).
511
- Fixed: BrowserStack sessions honour `--provider-project`, `--provider-build`, and
612
`--provider-session-name`. The capability builder emitted the legacy JSON Wire keys `device`,
713
`os_version`, and `app` at the top level next to the W3C `bstack:options` block; the hub treats a

‎android/snapshot-helper/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,6 @@ The final instrumentation result for the default `snapshot` mode includes:
137137
Failures return `ok=false`, `errorType`, and `message` in the final result.
138138

139139
The release manifest is a stable provider contract for the current helper protocol. Providers should
140-
resolve the APK from `apkUrl`, verify `sha256`, install using `installArgs`, and run
141-
`instrumentationRunner`. `installArgs` must start with `install`; extra arguments are limited to the
142-
allowlisted adb install flags `-r`, `-t`, `-d`, and `-g`, and the consumer appends the APK path.
140+
resolve the APK from `apkUrl`, verify `sha256`, install it with `adb install -r <apk>`, and run
141+
`instrumentationRunner`. Manifests up to 0.21.3 also carried an `installArgs` array; it only ever
142+
spelled `install -r` (plus `-t` while the helper was `testOnly`), so consumers can ignore it.

‎packages/platform-android/src/__tests__/adb-executor.test.ts‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,7 @@ test('createLocalAndroidAdbProvider exposes local pull and install capabilities'
209209
});
210210

211211
await provider.pull?.('/sdcard/video.mp4', '/tmp/video.mp4', { allowFailure: true });
212-
await provider.install?.('/tmp/app.apk', {
213-
allowDowngrade: true,
214-
allowTestPackages: true,
215-
grantPermissions: true,
216-
replace: true,
217-
timeoutMs: 2000,
218-
});
212+
await provider.install?.('/tmp/app.apk', { replace: true, timeoutMs: 2000 });
219213

220214
assert.deepEqual(mockRunCmd.mock.calls, [
221215
[
@@ -225,7 +219,7 @@ test('createLocalAndroidAdbProvider exposes local pull and install capabilities'
225219
],
226220
[
227221
'adb',
228-
['-s', 'emulator-5554', 'install', '-r', '-t', '-d', '-g', '/tmp/app.apk'],
222+
['-s', 'emulator-5554', 'install', '-r', '/tmp/app.apk'],
229223
{ timeoutMs: 2000, ...localAdbExecOptions },
230224
],
231225
]);

‎packages/platform-android/src/__tests__/snapshot-helper.test.ts‎

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const manifest: AndroidSnapshotHelperManifest = {
3535
targetSdk: 36,
3636
outputFormat: 'uiautomator-xml',
3737
statusProtocol: 'android-snapshot-helper-v1',
38-
installArgs: ['install', '-r'],
3938
};
4039

4140
beforeEach(() => {
@@ -592,17 +591,11 @@ test('ensureAndroidSnapshotHelper uninstalls and retries when signatures differ'
592591
assert.deepEqual(calls[3], ['install', '-r', apkPath]);
593592
});
594593

595-
test('ensureAndroidSnapshotHelper uses provider install capability and semantic install options', async () => {
594+
test('ensureAndroidSnapshotHelper uses provider install capability with a replace install', async () => {
596595
const tmpDir = await mkdtempForTest('snapshot-helper-provider-install-');
597596
const apkPath = path.join(tmpDir, 'helper.apk');
598597
await fs.writeFile(apkPath, 'helper-apk');
599-
const installCalls: Array<{
600-
apkPath: string;
601-
replace?: boolean;
602-
allowTestPackages?: boolean;
603-
allowDowngrade?: boolean;
604-
grantPermissions?: boolean;
605-
}> = [];
598+
const installCalls: Array<{ apkPath: string; replace?: boolean }> = [];
606599
const adb: AndroidAdbExecutor = async (args) => {
607600
if (args.includes('--show-versioncode')) {
608601
return { exitCode: 1, stdout: '', stderr: 'not found' };
@@ -612,13 +605,7 @@ test('ensureAndroidSnapshotHelper uses provider install capability and semantic
612605
const adbProvider: AndroidAdbProvider = {
613606
exec: adb,
614607
install: async (path, options) => {
615-
installCalls.push({
616-
apkPath: path,
617-
replace: options?.replace,
618-
allowTestPackages: options?.allowTestPackages,
619-
allowDowngrade: options?.allowDowngrade,
620-
grantPermissions: options?.grantPermissions,
621-
});
608+
installCalls.push({ apkPath: path, replace: options?.replace });
622609
return { exitCode: 0, stdout: '', stderr: '' };
623610
},
624611
};
@@ -628,24 +615,12 @@ test('ensureAndroidSnapshotHelper uses provider install capability and semantic
628615
adbProvider,
629616
artifact: {
630617
apkPath,
631-
manifest: {
632-
...manifest,
633-
installArgs: ['install', '-r', '-t', '-d', '-g'],
634-
sha256: sha256Text('helper-apk'),
635-
},
618+
manifest: { ...manifest, sha256: sha256Text('helper-apk') },
636619
},
637620
});
638621

639622
assert.equal(result.installed, true);
640-
assert.deepEqual(installCalls, [
641-
{
642-
apkPath,
643-
replace: true,
644-
allowTestPackages: true,
645-
allowDowngrade: true,
646-
grantPermissions: true,
647-
},
648-
]);
623+
assert.deepEqual(installCalls, [{ apkPath, replace: true }]);
649624
});
650625

651626
test('ensureAndroidSnapshotHelper retry install also uses provider install capability', async () => {
@@ -935,15 +910,11 @@ test('parseAndroidSnapshotHelperManifest validates manifest shape', () => {
935910
assert.throws(() => parseAndroidSnapshotHelperManifest({ ...manifest, outputFormat: 'json' }), {
936911
message: 'Android snapshot helper manifest outputFormat must be "uiautomator-xml".',
937912
});
938-
assert.throws(() => parseAndroidSnapshotHelperManifest({ ...manifest, installArgs: ['shell'] }), {
939-
message: 'Android snapshot helper manifest installArgs must start with "install".',
940-
});
941-
assert.throws(
942-
() => parseAndroidSnapshotHelperManifest({ ...manifest, installArgs: ['install', '--user'] }),
943-
{
944-
message:
945-
'Android snapshot helper manifest installArgs contains unsupported install flag "--user".',
946-
},
913+
// Release manifests up to 0.21.3 carried installArgs; it is ignored, never validated or kept.
914+
assert.equal(
915+
'installArgs' in
916+
parseAndroidSnapshotHelperManifest({ ...manifest, installArgs: ['install', '-r', '-t'] }),
917+
false,
947918
);
948919
assert.throws(() => parseAndroidSnapshotHelperManifest({ ...manifest, sha256: 'not-a-sha' }), {
949920
message: 'Android snapshot helper manifest sha256 must be a 64-character hex string.',

‎packages/platform-android/src/__tests__/test-utils/android-snapshot-helper.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export const ANDROID_SNAPSHOT_HELPER_FIXTURE_ARTIFACT: AndroidSnapshotHelperArti
2323
targetSdk: 36,
2424
outputFormat: 'uiautomator-xml',
2525
statusProtocol: 'android-snapshot-helper-v1',
26-
installArgs: ['install', '-r'],
2726
},
2827
};
2928

‎packages/platform-android/src/__tests__/touch-helper.fixtures.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export const ANDROID_TOUCH_HELPER_MANIFEST = {
1616
versionCode: 17000,
1717
instrumentationRunner: 'com.callstack.agentdevice.snapshothelper/.SnapshotInstrumentation',
1818
statusProtocol: 'android-snapshot-helper-v1' as const,
19-
installArgs: ['install', '-r'],
2019
};
2120

2221
export function androidTouchHelperResultRecord(values: Record<string, string>): string {

‎packages/platform-android/src/adb-transfer.test.ts‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test('semantic provider methods win over the exec fallback and escape the overri
3737
expect(escaped).toBe(2);
3838
});
3939

40-
test('the exec fallback lowers semantic install options into adb flags', async () => {
40+
test('the exec fallback lowers the semantic replace option into adb flags', async () => {
4141
bindAndroidAdbHostStub();
4242
const calls: string[][] = [];
4343
const provider: AndroidAdbProvider = {
@@ -47,17 +47,11 @@ test('the exec fallback lowers semantic install options into adb flags', async (
4747
},
4848
};
4949

50-
await installAndroidAdbPackage('/tmp/a.apk', {
51-
provider,
52-
replace: true,
53-
allowTestPackages: true,
54-
allowDowngrade: true,
55-
grantPermissions: true,
56-
});
50+
await installAndroidAdbPackage('/tmp/a.apk', { provider, replace: true });
5751
await pullAndroidAdbFile('/device/a.apk', '/tmp/a.apk', { provider });
5852

5953
expect(calls).toEqual([
60-
['install', '-r', '-t', '-d', '-g', '/tmp/a.apk'],
54+
['install', '-r', '/tmp/a.apk'],
6155
['pull', '/device/a.apk', '/tmp/a.apk'],
6256
]);
6357
});

‎packages/platform-android/src/adb-transport.ts‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ export type AndroidPortReverseProvider = {
102102
export type AndroidAdbTransferOptions = AndroidAdbExecutorOptions;
103103
export type AndroidAdbInstallOptions = AndroidAdbTransferOptions & {
104104
replace?: boolean;
105-
allowTestPackages?: boolean;
106-
allowDowngrade?: boolean;
107-
grantPermissions?: boolean;
108105
};
109106

110107
export type AndroidAdbPuller = (
@@ -114,8 +111,8 @@ export type AndroidAdbPuller = (
114111
) => Promise<AndroidAdbExecutorResult>;
115112

116113
/**
117-
* Installs an APK path. Implementations are responsible for honoring semantic
118-
* install options such as replace/test/downgrade/grant-permissions.
114+
* Installs an APK path. Implementations are responsible for honoring the
115+
* semantic `replace` option (`adb install -r`).
119116
*/
120117
export type AndroidAdbInstaller = (
121118
apkPath: string,
@@ -196,12 +193,6 @@ export function normalizeAndroidAdbInstallOptions(options?: AndroidAdbInstallOpt
196193
installArgs: string[];
197194
execOptions: AndroidAdbTransferOptions;
198195
} {
199-
const { replace, allowTestPackages, allowDowngrade, grantPermissions, ...execOptions } =
200-
options ?? {};
201-
const installArgs: string[] = [];
202-
if (replace) installArgs.push('-r');
203-
if (allowTestPackages) installArgs.push('-t');
204-
if (allowDowngrade) installArgs.push('-d');
205-
if (grantPermissions) installArgs.push('-g');
206-
return { installArgs, execOptions };
196+
const { replace, ...execOptions } = options ?? {};
197+
return { installArgs: replace ? ['-r'] : [], execOptions };
207198
}

‎packages/platform-android/src/helper-artifacts.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export type AndroidSnapshotHelperManifest = {
3535
targetSdk?: number;
3636
outputFormat: 'uiautomator-xml';
3737
statusProtocol: 'android-snapshot-helper-v1';
38-
installArgs: string[];
3938
};
4039

4140
export type AndroidSnapshotHelperArtifact = {

‎packages/platform-android/src/mechanics.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,7 @@ export {
255255
classifyAndroidHelperContent,
256256
type AndroidHelperContentRecoveryDecision,
257257
} from './snapshot-content-recovery.ts';
258-
export {
259-
parseAndroidSnapshotHelperManifest,
260-
readAndroidSnapshotHelperInstallOptions,
261-
type AndroidSnapshotHelperInstallOptions,
262-
} from './snapshot-helper-artifact.ts';
258+
export { parseAndroidSnapshotHelperManifest } from './snapshot-helper-artifact.ts';
263259
export {
264260
buildAndroidSnapshotHelperArgs,
265261
buildAndroidSnapshotHelperCaptureOptions,

0 commit comments

Comments
 (0)