Skip to content

Commit 9cdb154

Browse files
committed
Fix ADB root detection command quoting & add another possibility
Quoting was definitely wrong here - it turns out that ADB is actually extra-quoting our arguments under the hood, so we were effectively doing it twice, and this definitely didn't work as intended. The new logic definitely does send the correct command however, so should work for the devices affected by that issue. This also adds a similar case for the 'su root' devices, just in case some are also affected, and reorders the commands a little (I think this order is preferably, but really it shouldn't make much difference given the new unambiguous testing approach).
1 parent 595eefc commit 9cdb154

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/interceptors/android/adb-commands.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,15 @@ export async function pushFile(
153153
const runAsRootCommands = [
154154
// Maybe we're already root?
155155
(...cmd: string[]) => [...cmd],
156-
// 'su' as available on official emulators:
157-
(...cmd: string[]) => ['su', 'root', ...cmd],
158-
// Su on many physical rooted devices requires quotes:
159-
(...cmd: string[]) => ['su', '-c', `'${cmd.join(' ').replace("'", "\\'")}'`],
156+
// Su on many physical rooted devices requires quotes. Adbkit automatically quotes
157+
// each argument in the array, so we just have to make it a single arg:
158+
(...cmd: string[]) => ['su', '-c', cmd.join(' ')],
160159
// But sometimes it doesn't like them, so try that too:
161-
(...cmd: string[]) => ['su', '-c', ...cmd]
160+
(...cmd: string[]) => ['su', '-c', ...cmd],
161+
// 'su' as available on official emulators, no quoting of commands required:
162+
(...cmd: string[]) => ['su', 'root', ...cmd],
163+
// 'su' with a single-arg command here too, just in case:
164+
(...cmd: string[]) => ['su', 'root', cmd.join(' ')]
162165
];
163166

164167
type RootCmd = (...cmd: string[]) => string[];

0 commit comments

Comments
 (0)