adbkit
adbkit copied to clipboard
Failed to get png file from screencap command
I use adbkit on Android 7.1.1 (Nexus 5X), and call client.screencap() api, when I pipe the stream to fs.createWriteStream("/tmp/a.png"). I got an invalid png format file. But when I remove "LineTransform" Module in screencap command, it works fine..
So, I don't know if the linetransform should be deprecated ?
The following screencap command works fine on My Device..
class ScreencapCommand extends Command
execute: ->
this._send 'shell:screencap -p 2>/dev/null'
@parser.readAscii 4
.then (reply) =>
switch reply
when Protocol.OKAY
@parser.raw()
when Protocol.FAIL
@parser.readError()
else
@parser.unexpected reply, 'OKAY or FAIL'
module.exports = ScreencapCommand
Hmm, interesting. Will have to look into this at some point. If if turns out that they really did remove the encoding, then for backwards compatibility we could probably do something like this._send 'shell:echo && screencap -p 2>/dev/null'
and then check the first two bytes and have low overhead automatic detection that way.
+1 I'll try this way or wait for your updates :P
Hi, I checked this issue on Mi 4 LTE (Marshmallow 6.0.1), It execute screencap command must be transformed by Linetransform. And execute 'shell:echo && screencap -p 2>/dev/null' to check 0x0a is an easy way to fix this issue. But I don't have more android devices, if I should request a pull request ?
Feel free to create a PR, we can tweak it later!