Skip to content

Commit

Permalink
Merge pull request #1101 from cauchy733/master
Browse files Browse the repository at this point in the history
check jpg header and footer to enhanced compatibility
  • Loading branch information
yimelia committed Jul 4, 2023
2 parents 3bfd5b1 + 7d84b92 commit 255048f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions airtest/core/android/cap_methods/minicap.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from airtest.utils.threadsafe import threadsafe_generator
from airtest.core.android.cap_methods.base_cap import BaseCap
from airtest import aircv

from airtest.core.error import ScreenError

LOGGING = get_logger(__name__)

Expand Down Expand Up @@ -176,7 +176,10 @@ def get_frame(self, projection=None):
)
jpg_data = raw_data.split(b"for JPG encoder" + self.adb.line_breaker)[-1]
jpg_data = jpg_data.replace(self.adb.line_breaker, b"\n")
return jpg_data
if jpg_data.startswith(b"\xff\xd8") and jpg_data.endswith(b"\xff\xd9"):
return jpg_data
else:
raise ScreenError("invalid jpg format")

def _get_params(self, projection=None):
"""
Expand Down

0 comments on commit 255048f

Please sign in to comment.