Closed PythonTryHard closed 1 year ago
Has you tested on windows?
Yes. The commits are signed by my Windows-only key, and I remember benchmarking for speed improvement. I can't remember the result though.
My friend has also independently confirmed the PR to be working on Windows 10 21H2 (build number 19044.2130). Neither of us have access to Windows 11.
thanks, merged
will be published with version 1.0.10
This PR aims to improve
adbutils.AdbDevice.screenshot()
by removing usage of temporary screenshots.Currently, the behaviour of
screenshot()
is to write the screenshot to a temp file then pull the screenshot out to load in and return. This behaviour is marked as "not thread-safe", to which I assume is related to the use of temp file.screencap -p
when not given theFILENAME
argument will output the PNG screenshot tostdout
which can then be read and loaded intoPIL.Image
. This behaviour is utilised to eliminate the need of a temp file on both the connected Android machine and the local machine.As the screenshot is supposed to be raw bytes, using built-in methods such as
read_until_close()
with automatic decode to UTF-8 will mess with the bytes, thereforestream=True
is enabled in the.shell()
call, and manually reading the output in a similar fashion toread_until_close()
. While this PR could have included a backward-compatible change inread_until_close()
to allow opting out of decoding, therefore reducing duplicated code, by:I decided against it as it is out-of-scope for this PR, and might cause breakage somewhere else.