fix(adb): pass int intent extras to am without leading zeros (#6843)
Fixes #6807 Co-authored-by: Abelo9996 <Abelo9996@users.noreply.github.com> Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
2 files changed
+45
-1
No files matched your search
@@ -2043,6 +2043,46 @@ ${shellStub({ "am:start": "Starting: Intent { act=android.intent.action.VIEW dat
|
||||
]);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ value: "10", operand: "10" },
|
||||
{ value: "010", operand: "10" },
|
||||
{ value: "-010", operand: "-10" },
|
||||
{ value: "08", operand: "8" },
|
||||
{ value: "000", operand: "0" },
|
||||
])(
|
||||
"passes int extra $value to am as decimal $operand",
|
||||
async ({ value, operand }) => {
|
||||
const { binary, root } = await writeAdbStub(
|
||||
(root) => `printf '%s\\n' "$@" >> ${join(root, "argv.log")}
|
||||
${shellStub({ "am:start": "Starting: Intent { act=android.intent.action.VIEW }\n" })(root)}`,
|
||||
);
|
||||
await evidenceResult(providerOver(binary), {
|
||||
operation: "start_adb_activity",
|
||||
input: {
|
||||
serial: "emulator-5554",
|
||||
action: "android.intent.action.VIEW",
|
||||
extras: [
|
||||
{ key: "count", type: "int", value },
|
||||
// `--el` is read with Long.valueOf, which is always decimal.
|
||||
{ key: "total", type: "long", value },
|
||||
],
|
||||
},
|
||||
});
|
||||
const logged = (await readFile(join(root, "argv.log"), "utf8"))
|
||||
.trim()
|
||||
.split("\n");
|
||||
// am reads `--ei` with Integer.decode, where a leading zero means octal.
|
||||
expect(logged.slice(-6)).toEqual([
|
||||
"--ei",
|
||||
"count",
|
||||
operand,
|
||||
"--el",
|
||||
"total",
|
||||
value,
|
||||
]);
|
||||
},
|
||||
);
|
||||
|
||||
it("collects a device bugreport archive with its digest", async () => {
|
||||
const { binary, root } = await writeAdbStub(
|
||||
() => `if [ "$1" = "version" ]; then ${VERSION_BLOCK}; exit 0; fi
|
||||
|
||||
@@ -2823,7 +2823,11 @@ export class AdbProvider {
|
||||
...input.extras.flatMap((extra) => [
|
||||
extraFlags[extra.type],
|
||||
extra.key,
|
||||
extra.value,
|
||||
// am reads `--ei` with Integer.decode, where a leading zero selects
|
||||
// octal; drop redundant zeros so the decimal value is what arrives.
|
||||
extra.type === "int"
|
||||
? extra.value.replace(/^(-?)0+(?=\d)/u, "$1")
|
||||
: extra.value,
|
||||
]),
|
||||
];
|
||||
return this.runAmStart(
|
||||
|
||||
Reference in new issue
Block a user