Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Commit 438a421

Browse files
authored
Use adb exec-out instead of shell
This removes the need for the perl hack and makes it work with API level 25 which were producing corrupted images due to said hack.
1 parent 57ee55c commit 438a421

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/android.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,11 @@ export async function saveScreenshot(adb: string, perl: string, device: string,
8181
const maxBuffer = 1024 * 1000 * 50 // 50 MB
8282

8383
// create the processes needed in the chain
84-
const adbProcess = execa(adb, ['-s', device, 'shell', 'screencap', '-p'], { maxBuffer })
85-
const perlProcess = execa(perl, ['-pe', 's/\\x0D\\x0A/\\x0A/g'], { maxBuffer })
86-
87-
// hook up the chain: adb -> perl -> image.png
88-
adbProcess.stdout.pipe(perlProcess.stdin)
89-
perlProcess.stdout.pipe(createWriteStream(filename))
84+
const adbProcess = execa(adb, ['-s', device, 'exec-out', 'screencap', '-p'], { maxBuffer })
85+
adbProcess.stdout.pipe(createWriteStream(filename))
9086

9187
// determine when we've ended
92-
perlProcess.on('exit', exitCode => {
88+
adbProcess.on('exit', exitCode => {
9389
if (exitCode === 0) {
9490
resolve()
9591
} else {

0 commit comments

Comments
 (0)