{"id":378973,"date":"2024-06-16T09:00:06","date_gmt":"2024-06-16T09:00:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=378973"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-16T09:00:06","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=378973","title":{"rendered":"<span>\u0414\u0440\u043e\u0438\u0434\u044b \u0438 \u043f\u0438\u0442\u043e\u043d\u044b: \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 ADB \u043d\u0430 Python<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041e\u0434\u043d\u0430\u0436\u0434\u044b, \u0432 \u043e\u0434\u043d\u0443 \u0438\u0437 \u0431\u0435\u0441\u0441\u043e\u043d\u043d\u044b\u0445 \u043d\u043e\u0447\u0435\u0439, \u044f \u0434\u0443\u043c\u0430\u043b, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0443\u0442\u0438\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430 \u0430\u043d\u0434\u0440\u043e\u0438\u0434-\u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u0435. \u041d\u0443 \u0432\u044b \u0436\u0435 \u0437\u043d\u0430\u0435\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 &#8212; \u0438\u0445 \u0445\u043b\u0435\u0431\u043e\u043c \u043d\u0435 \u043a\u043e\u0440\u043c\u0438, \u0434\u0430\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e-\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0411\u0443\u0434\u044c \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043e\u0442\u0447\u0435\u0442\u043e\u0432 \u0438\u043b\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>\u0418 \u0432\u043e\u0442, \u0442\u043e\u0433\u0434\u0430 \u044f \u0443\u0437\u043d\u0430\u043b \u043e\u0431 \u043e\u0434\u043d\u043e\u0439 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u0435 &#8212; Android Debug Bridge, ADB. \u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Android &#8212; \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b \u0442\u0435\u043b\u0435\u0444\u043e\u043d, \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0439\u0441\u044f \u0447\u0435\u043c \u0445\u043e\u0447\u0435\u0448\u044c. \u041d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0442\u0430\u043a \u043b\u0435\u043d\u044c \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u0438\u0445 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437&#8230; \u0412\u043e\u0442 \u0437\u0434\u0435\u0441\u044c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 Python. \u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 ADB \u0447\u0435\u0440\u0435\u0437 python.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b &#8212; \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f Android, \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0438\u043b\u0438 \u044e\u0437\u0435\u0440 &#8212; \u0442\u043e \u0432\u044b \u043f\u043e\u043f\u0430\u043b\u0438 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u0442\u044c, \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e Python.<\/p>\n<p>Python &#8212; \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u043e\u0438\u0445 \u043b\u044e\u0431\u0438\u043c\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u0442\u0441\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0438\u0447 &#8212; \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 Python 3.10 \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f match-case.<\/p>\n<pre><code class=\"python\">http_status = 404  match http_status: case 400: print(\"Bad Request\") case 404: print(\"Not Found\") case 200: print(\"Success\") case _: print('Other') <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441\u0442\u043e\u0438\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e Python &#8212; &#171;\u043a\u043e\u043b\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u044f\u0437\u044b\u043a&#187;, \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438, \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438, \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438.<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u044f\u0437\u044b\u043a \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u0434\u0435\u0431\u0430\u0433\u0433\u0438\u043d\u0433\u0430 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0439:<\/p>\n<pre><code class=\"python\">number: int = 10 fnum: float = 10.10 text: str = \"Hello\" is_normal: bool = True  # \u0418 \u0434\u0440\u0443\u0433\u0438\u0435, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0441\u043f\u0438\u0441\u043a\u0438, \u043a\u043e\u0440\u0442\u0435\u0436\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 <\/code><\/pre>\n<p>\u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 Python. \u041e\u043d \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u044f\u0445 \u043b\u0438\u0441\u043f\u0430. \u0422\u0430\u043a, \u0432 \u043f\u0438\u0442\u043e\u043d\u0435 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>filter<\/code>, <code>map<\/code> \u0438 <code>reduce<\/code>.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0438\u0437 \u043b\u0438\u0441\u043f\u0430 \u0431\u044b\u043b\u0438 \u0432\u0437\u044f\u0442\u044b \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u043e\u0432. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u043c\u043e\u0434\u0443\u043b\u044f (<code>itertools<\/code> \u0438 <code>functools<\/code>), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 Haskell.<\/p>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e &#171;\u0434\u0437\u0435\u043d\u0443&#187; \u043f\u0438\u0442\u043e\u043d\u0430, \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 \u044f\u0434\u0440\u043e \u044f\u0437\u044b\u043a\u0430 \u0432\u0441\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043e\u043d \u0431\u044b\u043b \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u043c. \u041f\u0438\u0442\u043e\u043d \u0441\u0442\u0430\u043b \u0442\u0430\u043a\u0438\u043c \u0438\u0437-\u0437\u0430 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u044f\u0437\u044b\u043a\u0430 ABC &#8212; \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0413\u0432\u0438\u0434\u043e \u0412\u0430\u043d \u0420\u043e\u0441\u0441\u0443\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u043b \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u044f\u0434\u0440\u043e.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c &#8212; \u0432 Python \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 C-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a (.so \u0432 \u043b\u0438\u043d\u0443\u043a\u0441\u0435, .dll \u0432 Windows) \u0432 \u043a\u043e\u0434 \u043d\u0430 \u043f\u0438\u0442\u043e\u043d\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u043e\u0434\u0443\u043b\u044f ctypes.<\/p>\n<p>Python \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u0438 \u041e\u0421. \u0414\u0430\u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u043a\u0430\u0436\u0443, <a href=\"https:\/\/wiki.osdev.org\/Porting_Python\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u041e\u0421<\/a>!<\/p>\n<p>\u0412\u044b\u0431\u0440\u0430\u043b \u044f \u0435\u0433\u043e \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u0430 \u043d\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u043e\u0439, \u043a\u0430\u043a bash), \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c, \u0438 \u0438\u043c\u0435\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u0410 \u0442\u0430\u043a\u0436\u0435 \u043e\u043d \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0446\u0435\u043b\u0435\u0439.<\/p>\n<h2>ADB, \u043e\u0442\u043b\u0430\u0434\u043a\u0430 \u043f\u043e USB<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 &#171;\u043c\u043e\u0441\u0442 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 android&#187; &#8212; \u0442\u043e \u0435\u0441\u0442\u044c ADB.<\/p>\n<p>ADB \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0435\u0439 Google \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438, \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 Android. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e. \u041e\u043d \u043f\u0440\u0438\u0437\u0432\u0430\u043d \u0440\u0435\u0448\u0430\u0442\u044c \u0446\u0435\u043b\u044b\u0439 \u0440\u044f\u0434 \u0437\u0430\u0434\u0430\u0447, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438.<\/p>\n<p>\u0421\u0440\u0435\u0434\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ul>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435, \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 shell-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0438 \u043a\u043e\u043c\u0430\u043d\u0434<\/p>\n<\/li>\n<li>\n<p>\u042d\u043c\u0443\u043b\u044f\u0446\u0438\u044f \u043d\u0430\u0436\u0430\u0442\u0438\u0439, \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430, \u0441\u0432\u0430\u0439\u043f\u043e\u0432 \u0438 \u0442\u0434<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u043d\u0438\u043c\u043a\u0438 \u0438 \u0432\u0438\u0434\u0435\u043e \u0441 \u044d\u043a\u0440\u0430\u043d\u0430<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430:<\/p>\n<pre><code class=\"bash\">sudo apt install android-tools-adb # Ubuntu\/debian sudo pacman -S android-tools # Arch <\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f ADB, \u043d\u0430\u0434\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043f\u043e USB.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/s7\/im\/kn\/s7imkn3hwqnvanqpmmkpfg8xdde.png\" alt=\"USB Debug\" data-src=\"https:\/\/habrastorage.org\/webt\/s7\/im\/kn\/s7imkn3hwqnvanqpmmkpfg8xdde.png\"\/><\/p>\n<div><figcaption>USB Debug<\/figcaption><\/div>\n<\/figure>\n<blockquote>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <code>scrcpy<\/code> &#8212; \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0434\u043b\u044f \u0448\u0430\u0440\u0438\u043d\u0433\u0430 \u044d\u043a\u0440\u0430\u043d\u0430 \u0441 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u043d\u0430 \u041f\u041a \u0447\u0435\u0440\u0435\u0437 ADB<\/p>\n<\/blockquote>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448\u0435\u043c \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u043f\u043e USB. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0443 \u0442\u0435\u043b\u0435\u0444\u043e\u043d \u0447\u0435\u0440\u0435\u0437 USB-\u043f\u0440\u043e\u0432\u043e\u0434 \u0438 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>adb usb<\/code> \u0438 <code>adb devices<\/code>. \u0412\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0434\u0435\u0432\u0430\u0439\u0441\u044b, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0443 \u0432\u0430\u0441 \u0442\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u0438\u043d \u0434\u0435\u0432\u0430\u0439\u0441. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u043c\u043e\u0436\u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<h2>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b ADB<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u0434\u0435\u0431\u0430\u0433\u0430.<\/p>\n<ul>\n<li>\n<p><code>adb reboot<\/code> &#8212; \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<\/li>\n<li>\n<p><code>adb reboot recovery<\/code> &#8212; \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f (recovery)<\/p>\n<\/li>\n<li>\n<p><code>adb reboot bootloader<\/code> &#8212; \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c fastboot.<\/p>\n<\/li>\n<li>\n<p><code>adb install &lt;APK><\/code> &#8212; \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 APK \u0444\u0430\u0439\u043b\u0430. \u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438. \u041a\u0441\u0442\u0430\u0442\u0438, \u044d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u043a\u043d\u043e \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u043a\u043e\u043d \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p><code>adb install -t &lt;APK><\/code> &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><code>adb install -r &lt;APK><\/code> &#8212; \u043f\u0435\u0440\u0435\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p><code>adb shell pm list packages<\/code> &#8212; \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p><code>adb uninstall com.example.example<\/code> &#8212; \u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0435\u0433\u043e Bundle ID.<\/p>\n<\/li>\n<li>\n<p><code>adb shell<\/code> &#8212; \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0448\u0435\u043b\u043b, \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0443<\/p>\n<\/li>\n<li>\n<p><code>adb shell screencap \/sdcard\/screenshot.png<\/code> &#8212; \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0441\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430<\/p>\n<\/li>\n<li>\n<p><code>adb shell screenrecord --size 1280x720 --bit-rate 6000000 --time-limit 20 --verbose \/sdcard\/video.mp<\/code> &#8212; \u0441\u043a\u0440\u0438\u043d\u043a\u0430\u0441\u0442. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440, \u0431\u0438\u0442\u0440\u0435\u0439\u0442, \u043b\u0438\u043c\u0438\u0442 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445).<\/p>\n<\/li>\n<li>\n<p><code>adb shell dumpsys package com.app.example<\/code> &#8212; \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438<\/p>\n<\/li>\n<li>\n<p><code>adb logcat<\/code> &#8212; \u0432\u044b\u0432\u043e\u0434 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043b\u043e\u0433\u043e\u0432<\/p>\n<\/li>\n<li>\n<p><code>adb bugreport<\/code> &#8212; \u0434\u043e\u043a\u043b\u0430\u0434 \u043e \u0433\u0440\u0435\u0448\u043a\u0430\u0445. \u0421\u0431\u043e\u0440 \u043e\u0442\u0447\u0435\u0442\u0430 \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p><code>adb shell dumpsys<\/code> &#8212; \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0441\u043b\u0443\u0436\u0431\u0430\u0445<\/p>\n<\/li>\n<li>\n<p><code>adb push &lt;local> &lt;remote><\/code> &#8212; \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e<\/p>\n<\/li>\n<li>\n<p><code>adb pull &lt;remote> &lt;local><\/code> &#8212; \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p><code>adb shell am start -a android.intent.action.VIEW 'https:\/\/nometa.xyz'<\/code> &#8212; \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0430\u0439\u0442\u0430<\/p>\n<\/li>\n<li>\n<p><code>adb shell input tap X Y<\/code> &#8212; \u0442\u0430\u043f \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435<\/p>\n<\/li>\n<li>\n<p><code>adb shell input swipe X1 Y1 X2 Y2 &lt;\u0414\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u043c\u0441><\/code> &#8212; \u0441\u0432\u0430\u0439\u043f.<\/p>\n<\/li>\n<li>\n<p><code>adb shell dumpsys<\/code> &#8212; \u0434\u0430\u043c\u043f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<\/li>\n<li>\n<p><code>adb shell dumpsys battery<\/code> &#8212; \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0431\u0430\u0442\u0430\u0440\u0435\u0435.<\/p>\n<\/li>\n<li>\n<p><code>adb shell input text \"Hello, Habr!\"<\/code> &#8212; \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044f \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430<\/p>\n<\/li>\n<\/ul>\n<h2>\u0427\u0442\u043e \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c?<\/h2>\n<p>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>adb input tap\/swipe<\/code>? ADB \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c &#171;\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u043c&#187; adb-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c, \u0437\u0430\u043f\u0440\u043e\u0441 \u0443\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0448\u0435\u043b\u043b \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442, \u0441\u043a\u0440\u0438\u043f\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 Java-\u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0430 \u0443\u0436\u0435 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0436\u0435 \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u0438\u043b\u0438 \u0441\u0432\u0430\u0439\u043f. \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0442\u0430\u043f\u0430 \u0438 \u0441\u0432\u0430\u0439\u043f\u0430 \u0435\u0441\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 &#8212; <code>adb shell input touchscreen tap X Y<\/code> \u0438 <code>adb shell input touchscreen X1 Y1 X2 Y2<\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u0430\u0439\u043f \u0432\u043d\u0438\u0437, \u0432\u0432\u0435\u0440\u0445 \u0438 \u0442\u0434 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>adb shell touchscreen motionevent DOWN\/MOVE\/UP X Y<\/code>.<\/p>\n<p>\u042d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u0430\u044f \u0438 \u043d\u0443\u0436\u043d\u0430\u044f, \u0432\u0435\u0434\u044c \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0437\u0430 \u0432\u0430\u0441.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 <code>adb shell input<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>adb shell input keyboard keyevent 3<\/code> \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u0434\u043e\u043c\u043e\u0439.<\/p>\n<p>\u041a\u0435\u0439\u043a\u043e\u0434\u044b \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e <a href=\"https:\/\/developer.android.com\/reference\/android\/view\/keyevent#keycode_home\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<h2>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 ADB \u0447\u0435\u0440\u0435\u0437 python?<\/h2>\n<p>\u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 &#8212; \u0447\u0435\u0440\u0435\u0437 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 subprocess, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 &#8212; \u0447\u0435\u0440\u0435\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 ppadb.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<pre><code class=\"bash\">python3 -m venv venv source venv\/bin\/activate <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0444\u0430\u0439\u043b \u0438 \u043d\u0430\u0447\u043d\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">import subprocess # \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043c\u0430\u043d\u0434   def get_devices(self) -> list: \"\"\" \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432.  :return: \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \"\"\" # \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 adb devices command = subprocess.run(['adb', 'devices'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)  # \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0435 0, \u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u043c \u043e\u0431 \u044d\u0442\u043e\u043c if command.returncode != 0: print(f'Error receiving devices: {command.stderr}') return None  # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u043e\u0442 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u0438 \u0441\u043f\u043b\u0438\u0442\u0438\u043c \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c result = command.stdout.strip().split('\\n') # \u041e\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0431\u0435\u0440\u0435\u043c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c 1 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 devices = result[1:]  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u0443\u0434\u0430\u043b\u044f\u044f \u043b\u0438\u0448\u043d\u0435\u0435 devices = [device.replace('\\tdevice', '') for device in devices]  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 return devices   print(f'\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430: {\" \".join(devices)}') <\/code><\/pre>\n<p>\u0418 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code>\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430: da7045007d79 <\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u0432\u0441\u0435 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0449\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b &#8212; \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430<\/p>\n<pre><code class=\"python\">def reboot(reboot_type: str='plain') -> bool: \"\"\" \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430  :param reboot_type: \u0422\u0438\u043f \u0440\u0435\u0431\u0443\u0442\u0430, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e plain. \u0422\u0430\u043a\u0436\u0435: recovery, fastboot :return: True \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, False \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \"\"\" if reboot_type == 'plain': command = ['adb', 'reboot'] elif reboot_type == 'recovery': command = ['adb', 'reboot', 'recovery'] elif reboot_type == 'fastboot': command = ['adb', 'reboot', 'fastboot']  result = subprocess.run(command,  stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)  if result.returncode != 0: return False  return True <\/code><\/pre>\n<p>\u042f \u0434\u0443\u043c\u0430\u044e \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043d\u0430 Python. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0443\u0437\u043d\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u0448\u043b\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 &#8212; \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u0434 \u043a\u043e\u0440\u043e\u0447\u0435, \u0438 \u043a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043e\u0442\u043d\u0435\u0441\u0435\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"python\">import subprocess from typing import Union   def execute(command: Union[list, str]) -> subprocess.CompletedProcess: \"\"\" \u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0447\u0435\u0440\u0435\u0437 subprocess.  :param command: \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\" if isinstance(command, str): command = command.split(' ')  result = subprocess.run(command,  stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)  if result.returncode != 0: print(f'Failed execute command: {result.stderr}')  return result <\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 &#8212; \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 Keyevent, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u0439 \u043e\u0442 Enum.<\/p>\n<p>\u041e\u043d \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0433\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043a\u043b\u0430\u0432\u0438\u0448 \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>adb shell input keyevent<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043b\u0430\u0432\u0438\u0448<\/p>\n<pre><code class=\"python\">from enum import Enum   class Keyevent(Enum): \"\"\" \u0427\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043b\u0430\u0432\u0438\u0448 (adb shell keyevent)  \u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u0432:  DIGIT - \u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 CONTROL - \u043a\u043b\u0430\u0432\u0438\u0448\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u044b WORD - \u043a\u043b\u0430\u0432\u0438\u0448\u0438 \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430 \"\"\" DIGIT_0 = 7 DIGIT_1 = 8 DIGIT_2 = 9 DIGIT_3 = 10 DIGIT_4 = 11 DIGIT_5 = 12 DIGIT_6 = 13 DIGIT_7 = 14 DIGIT_8 = 15 DIGIT_9 = 16  CONTROL_BACK = 4 CONTROL_CALL = 5 CONTROL_CAMERA = 27 CONTROL_CHANNEL_DOWN = 167 CONTROL_CHANNEL_UP = 166 CONTROL_DPAD_CENTER = 23 CONTROL_DPAD_DOWN = 20 CONTROL_DPAD_LEFT = 21 CONTROL_DPAD_RIGHT = 22 CONTROL_DPAD_UP = 19 CONTROL_ENDCALL = 6 CONTROL_ENTER = 66 CONTROL_ESCAPE = 111 CONTROL_HEADSETHOOK = 79 CONTROL_HOME = 3 CONTROL_MENU = 82 CONTROL_MUTE = 91 CONTROL_NOTIFICATION = 83 CONTROL_POWER = 26 CONTROL_SEARCH = 84 CONTROL_SETTINGS = 176 CONTROL_VOLUME_DOWN = 25 CONTROL_VOLUME_UP = 24 CONTROL_VOLUME_MUTE = 164 CONTROL_ZOOM_IN = 168 CONTROL_ZOOM_OUT = 169 CONTROL_BRIGHTNESS_DOWN = 220 CONTROL_BRIGHTNESS_UP = 221 CONTROL_MEDIA_PREVIOUS = 89 CONTROL_MEDIA_NEXT = 87 CONTROL_MEDIA_PLAY_PAUSE = 85 CONTROL_MEDIA_STOP = 86 CONTROL_MEDIA_REWIND = 90 CONTROL_MEDIA_FAST_FORWARD = 88  WORD_A = 29 WORD_B = 30 WORD_C = 31 WORD_D = 32 WORD_E = 33 WORD_F = 34 WORD_G = 35 WORD_H = 36 WORD_I = 37 WORD_J = 38 WORD_K = 39 WORD_L = 40 WORD_M = 41 WORD_N = 42 WORD_O = 43 WORD_P = 44 WORD_Q = 45 WORD_R = 46 WORD_S = 47 WORD_T = 48 WORD_U = 49 WORD_V = 50 WORD_W = 51 WORD_X = 52 WORD_Y = 53 WORD_Z = 54 <\/code><\/pre>\n<p>\u0417\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 &#8212; Device.<\/p>\n<pre><code class=\"python\">class Device: \"\"\" \u041a\u043b\u0430\u0441\u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 ADB  \u041a\u0430\u0436\u0434\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440. \"\"\" def __init__(self, serial: str) -> None: \"\"\" \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430  :param serial: \u0421\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \"\"\" self.serial: str = serial self.shell_template: str = 'adb shell'# \u0428\u0430\u0431\u043b\u043e\u043d \u0432\u044b\u0437\u043e\u0432\u0430 \u0448\u0435\u043b\u043b-\u043a\u043e\u043c\u0430\u043d\u0434\u044b <\/code><\/pre>\n<p>\u0418 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439, \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 ADB:<\/p>\n<pre><code class=\"python\">class ADB: \"\"\" \u041a\u043b\u0430\u0441\u0441, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u0431\u043e\u0439 \u043e\u0441\u043d\u043e\u0432\u0443 \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 ADB \"\"\" def __init__(self): \"\"\" \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \"\"\" self.devices: list = [] execute(['adb', 'start-server'])  def get_devices(self) -> list: \"\"\" \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432.  :return: \u0421\u043f\u0438\u0441\u043e\u043a \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 Device \"\"\" result = execute(['adb', 'devices'])  result = result.stdout.strip().split('\\n') devices = result[1:]  devices = [Device(device.replace('\\tdevice', '')) for device in devices]  if not devices: print('No devices attached')  return devices <\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Device \u043c\u0435\u0442\u043e\u0434 shell, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 \u0432\u044b\u0437\u043e\u0432 shell-\u043a\u043e\u043c\u0430\u043d\u0434:<\/p>\n<pre><code class=\"python\">def shell(self, command: str) -> subprocess: \"\"\" \u0412\u044b\u0437\u043e\u0432 shell-\u043a\u043e\u043c\u0430\u043d\u0434\u044b.  \u0428\u0430\u0431\u043b\u043e\u043d: adb shell &lt;command>  :param command: \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\" command = f'{self.shell_template} {command}' command_list = command.split(' ')  result = execute(command_list) print(f'Command {command} has been processed')  return result <\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u044f \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u043b\u0438\u0448\u043d\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f &#8212; \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u043d\u043e \u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435, \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043b\u0430\u0432\u0438\u0448:<\/p>\n<pre><code class=\"python\">def input_key(self, keyevent: Keyevent) -> subprocess: \"\"\" \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043b\u0430\u0432\u0438\u0448  :param keyevent: \u041d\u043e\u043c\u0435\u0440 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\" result = self.shell(f'input keyevent {keyevent.value}') print(f'Event of pressing {keyevent.value} ({keyevent}) key has been processed')  return result <\/code><\/pre>\n<p>\u0412 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u043c\u044b \u0432\u0438\u0434\u0435\u043c, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f Keyevent. \u042d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0442\u043e\u0442 Enum-\u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0432\u043d\u0430\u0447\u0430\u043b\u0435. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u0434\u043e\u043c\u043e\u0439, \u0447\u0438\u0441\u043b\u043e 3 (\u043d\u043e\u043c\u0435\u0440), \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 &#8212; \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c <code>Keyevent.CONTROL_HOME<\/code>. \u0421\u0442\u0430\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0439, \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430.<\/p>\n<p>\u0418 \u043a\u0430\u043a \u0440\u0430\u0437 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u043c\u044b \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c \u0434\u0440\u0443\u0433\u043e\u0439, \u0434\u043b\u044f \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430. \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0441\u043b\u043e\u0436\u043d\u043e\u0435.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c &#8212; \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u0438 \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430, \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>adb shell input text<\/code>.<\/p>\n<pre><code class=\"python\">def input_text(self, text: str) -> subprocess: \"\"\" \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0438\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430.  :param text: \u0422\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\" result = self.shell(f'input text \"{text}\"') print(f'Text input event processed: {text}')  return result <\/code><\/pre>\n<p>\u0423\u0447\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c.<\/p>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 input&#8217;\u0430 &#8212; tap \u0438 swipe:<\/p>\n<pre><code class=\"python\">def input_tap(self, x: int, y: int) -> subprocess.CompletedProcess: \"\"\" \u0418\u043c\u0438\u0442\u0430\u0446\u0438\u044f \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b adb shell input tap x y  :param x: \u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 X :param y: \u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 Y  :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\" result = self.shell(f'input tap {x} {y}') print(f'Action processed: tap {x} {y}')  return result  def input_swipe(self, x1: int, y1: int,  x2: int, y2: int, duration: int) -> subprocess.CompletedProcess: \"\"\" \u0418\u043c\u0438\u0442\u0430\u0446\u0438\u044f \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b adb shell input swipe x1 y1 x2 y2 duration.  :param x1: \u041f\u0435\u0440\u0432\u0430\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 X :param y1: \u041f\u0435\u0440\u0432\u0430\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 Y :param x2: \u0412\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 X :param y2: \u0412\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 Y :param duration: \u0414\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u043c\u0441  :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\" result = self.shell(f'input swipe {x1} {y1} {x2} {y2} {duration}') print(f'Action processed: swipe {x1} {y1} {x2} {y2} ({duration}ms)')  return result <\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441, \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 &#8212; \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0431\u0430\u0442\u0430\u0440\u0435\u0438.<\/p>\n<pre><code class=\"python\">def _get_battery_status(self, status_code: int) -> str: \"\"\" \u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0431\u0430\u0442\u0430\u0440\u0435\u0438 \u0438\u0437 \u0441\u0442\u0430\u0442\u0443\u0441-\u043a\u043e\u0434\u0430  :param status_code: \u041a\u043e\u0434 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0431\u0430\u0442\u0430\u0440\u0435\u0438 :return: \u0427\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \"\"\" match status_code: case 1: status = 'Charing' case 2: status = 'Discharging' case 3: status = \"Not charging\" case 4: status = \"Full\"  return status  def _get_battery_health(self, status_code: int) -> str: \"\"\" \u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u044f \u0431\u0430\u0442\u0430\u0440\u0435\u0438 \u0438\u0437 \u0441\u0442\u0430\u0442\u0443\u0441-\u043a\u043e\u0434\u0430.  :param status_code: \u041a\u043e\u0434 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u044f \u0431\u0430\u0442\u0430\u0440\u0435\u0438 :return: \u0427\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u044f \"\"\" match status_code: case 1: status = 'Good' case 2: status = \"Overheat\" case 3: status = 'Dead' case 4: status = \"Over voltage\" case 5: status = 'Unspecified failure' case 6: status = \"Cold\"  return status  def get_battery_info(self) -> dict: \"\"\" \u041c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0431\u0430\u0442\u0430\u0440\u0435\u0435 \u0432 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435.  :return: \u0421\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0437\u0430\u0440\u044f\u0434\u0430, \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0430, \u0441\u0442\u0430\u0442\u0443\u0441 \u0431\u0430\u0442\u0430\u0440\u0435\u0438 \"\"\" result = self.shell('dumpsys battery')  for line in result.stdout.splitlines(): if \"level\" in line: level = int(line.split(':')[1].strip()) elif 'scale' in line: scale = int(line.split(':')[1].strip()) elif 'status' in line: status = self._get_battery_status(int(line.split(':')[1].strip())) elif 'health' in line: health = self._get_battery_health(int(line.split(':')[1].strip())) elif 'temperature' in line: temp = float(line.split(':')[1].strip()) \/ 10 elif 'technology' in line: technology = line.split(':')[1].strip()  return { 'level': level, 'scale': scale, 'status': status, 'health': health, 'temp': temp, 'technology': technology } <\/code><\/pre>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0444\u0430\u043a\u0442, \u0432 \u043a\u043e\u0434\u0435 \u0433\u0434\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441 \u0431\u0430\u0442\u0430\u0440\u0435\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0435 \u0447\u0435\u0440\u0435\u0437 USB, \u0442\u043e \u0432\u0430\u0448 \u0442\u0435\u043b\u0435\u0444\u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0447\u0442\u043e \u043e\u043d \u0437\u0430\u0440\u044f\u0436\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043e\u0434, \u0442\u043e \u0442\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0430\u0442\u0443\u0441 \u0447\u0442\u043e \u043e\u043d \u0440\u0430\u0437\u0440\u044f\u0436\u0430\u0435\u0442\u0441\u044f (\u0442\u043e \u0435\u0441\u0442\u044c 2). \u0422\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0447\u0442\u043e \u0440\u0435\u0436\u0438\u043c \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u044d\u043d\u0435\u0440\u0433\u0438\u0438, \u0447\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c USB \u043f\u043e\u0440\u0442.<\/p>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b &#8212; \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0431\u0430\u0442\u0430\u0440\u0435\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>adb shell getprop<\/code>:<\/p>\n<pre><code class=\"python\">def _split_getprop(self, line: str) -> str: \"\"\" \u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f get_system_info, \u043f\u0430\u0440\u0441\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u0432\u044b\u0432\u043e\u0434\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b adb shell getprop.  :param line: \u0421\u0442\u0440\u043e\u043a\u0430 \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 :return: \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \"\"\" return line.split(\"[\")[2].split(\"]\")[0]  def get_system_info(self) -> dict: \"\"\" \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 adb shell getprop.  :return: \u0421\u043b\u043e\u0432\u0430\u0440\u044c \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \"\"\" result = self.shell(\"getprop\") other_info = dict()  for line in result.stdout.splitlines(): try: param_name = line.split(':')[0].replace('[', '').replace(']', '') other_info[param_name] = self._split_getprop(line) except IndexError: continue  return other_info <\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>adb shell pm list packages<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u0442 Bundle ID \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"python\">def get_packages(self) -> list: \"\"\" \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 bundle id.  :return: \u0421\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \"\"\" installed_packages = list()  result = self.shell('pm list packages')  for line in result.stdout.splitlines(): try: installed_packages.append(line.split(':')[-1]) except IndexError: continue  return installed_packages  def get_package_by_bundle(self, bundle_name: str) -> list: \"\"\" \u041c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 \u043f\u043e \u0435\u0433\u043e bundle id.  :param bundle_name: Bundle ID \u0438\u0441\u043a\u043e\u043c\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 :return: \u0421\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 \"\"\" result = self.shell('pm list packages') matches = list()  for line in result.stdout.splitlines(): if bundle_name in line.split(':')[-1].split('.')[-1]: matches.append(line.split(':')[-1])  return matches <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u0443\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\">import os  # ... def install_apk(self, apk_path: str, test=False) -> subprocess.CompletedProcess: \"\"\" \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 adb install &lt;APK>.  :param apk_path: \u041f\u0443\u0442\u044c \u0434\u043e APK-\u0444\u0430\u0439\u043b\u0430 :param test: \u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0436\u0438\u043c  :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\" apk_path = os.path.join(apk_path)  if not os.path.isfile(apk_path): print(f'APK {apk_path} for installing is not exists') return None  match test: case True: result = execute(f'adb install {apk_path} -t') case False: result = execute(f'adb install {apk_path} -t')  return result  def remove_apk(self, bundle_name: str) -> subprocess.CompletedProcess: \"\"\" \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u0430 \u043f\u043e \u0435\u0433\u043e Bundle ID.  :param bundle_name: Bundle ID \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f  :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\"  result = execute(f'adb uninstall {bundle_name}')  return result <\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u0434\u0432\u0443\u043c\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0434\u043b\u044f \u0434\u0435\u0431\u0430\u0433\u0430 &#8212; logcat \u0438 bugreport:<\/p>\n<pre><code class=\"python\">def logcat(self, loglevel: str) -> str: \"\"\" \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043b\u043e\u0433\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 adb logcat.  :param loglevel: \u0423\u0440\u043e\u0432\u0435\u0442 \u043b\u043e\u0433\u043e\u0432 (Verbose, Debug, Info, Warn, Error, Fatal, Silent) :return: \u041b\u043e\u0433\u0438 \"\"\" if loglevel not in ['V', 'D', 'I', 'W', 'E', \"F\", \"S\"]: return f'Invalid log level {loglevel}'  result = execute(f\"adb logcat '*:{loglevel}\")  return result.stdout  def bugreport(self) -> str: \"\"\" \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0443 adb bugreport.  :return: \u041e\u0442\u0447\u0435\u0442 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \"\"\" result = execute('adb bugreport')  return result.stdout <\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0447\u0435\u0440\u0435\u0437 <code>adb shell start -a android.intent.action.&lt;\u0414\u0415\u0419\u0421\u0422\u0412\u0418\u0415><\/code>:<\/p>\n<pre><code class=\"python\">def input_action(self, action: str, metadata: dict) -> subprocess.CompletedProcess: \"\"\" \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.  :param action: \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435 (send, call, sms, email, app, shutdown). :param metadata: \u0421\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043c\u0435\u0442\u0430-\u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f send, call, sms, emaiil, app. :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\" pattern = 'am start -a android.intent.action.'  print(action, metadata)  if action == 'view': # \u041e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 pattern = f\"{pattern}VIEW '{metadata['URL']}'\" elif action == 'call': # \u0417\u0432\u043e\u043d\u043e\u043a pattern = f'{pattern}DIAL \"{metadata[\"tel\"]}\"' elif action == 'sms': # \u0421\u041c\u0421 pattern = f'{pattern}SENDTO \"{metadata[\"tel\"]}\"' elif action == 'email': # \u041f\u0438\u0441\u044c\u043c\u043e \u043d\u0430 \u0435\u043c\u0430\u0439\u043b pattern = f'{pattern}SEND --es subject \"{metadata[\"subject\"]}\"' \\ f' --es text {metadata[\"text\"]}\" --es email \"{metadata[\"email\"]}\"' elif action == 'app': # \u041e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 pattern = f'{pattern}MAIN {metadata[\"app\"]}\/.MainActivity' elif action == 'shutdown': # \u0412\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 pattern = f'{pattern}REQUEST_SHUTDOWN' else: print(f'Unsupported action: {action}')  result = self.shell(pattern)  return result <\/code><\/pre>\n<p>\u041c\u044b \u043d\u0430 \u0444\u0438\u043d\u0438\u0448\u043d\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439! \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043d\u0435\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043a\u0440\u0438\u043d\u043a\u0430\u0441\u0442\u0430 \u0438 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0430, \u0430 \u043f\u043e\u0441\u043b\u0435 &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0443 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u043e\u043c \u0438 \u0441\u043a\u0440\u0438\u043d\u043a\u0430\u0441\u0442\u043e\u043c:<\/p>\n<pre><code class=\"python\">def screenshot(self, filepath: str) -> subprocess.CompletedProcess: \"\"\" \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0430.  :param filepath: \u043f\u0443\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\" result = self.shell(f'screencap {filepath}')  return result  def screencast(self, filepath: str, size: str=None, bitrate: int=6000000, time_limit: int=20) -> subprocess.CompletedProcess: \"\"\" \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043d\u043a\u0430\u0441\u0442\u0430.  :param filepath: \u041f\u0443\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f :param size: \u0420\u0430\u0437\u043c\u0435\u0440 \u0432\u0438\u0434\u0435\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 1280x720) :param bitrate: \u0411\u0438\u0442\u0440\u0435\u0439\u0442 :param time_limit: \u0412\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0438\u0441\u0438 (\u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445)  :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\" command = f'screenrecord --bit-rate {bitrate} --time-limit {time_limit}'  if size is not None: command += f' --size {size}'  result = self.shell(f'{command} --verbose {filepath}')  return result <\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0442\u043e \u0444\u0438\u043d\u0430\u043b &#8212; \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<pre><code class=\"python\">def push_file(self, local_path: str,  remote_path: str) -> subprocess.CompletedProcess: \"\"\" \u041c\u0435\u0442\u043e\u0434, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d.  :param local_path: \u041f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d :param remote_path: \u041f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430 \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f  :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\" local_path = os.path.join(local_path)  if not os.path.isfile(local_path): print(f'Local file {local_path} is not exists') return None  result = execute(f'adb push {local_path} {remote_path}')  print(result.stdout.strip()) return result  def pull_file(self, remote_path: str,  local_path: str) -> subprocess.CompletedProcess: \"\"\" \u041c\u0435\u0442\u043e\u0434, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0443 \u0444\u0430\u0439\u043b\u0430 \u0441 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430.  :param remote_path: \u041f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435 \u0434\u043b\u044f \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 :param local_path: \u041f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438  :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\" result = execute(f'adb pull {remote_path} {local_path}')  print(result.stdout.strip()) return result <\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u0432\u043e\u0442 \u043c\u044b \u0438 \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0443 \u0444\u0430\u0439\u043b\u043e\u0432, \u0438\u043b\u0438 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u0443\u044e \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435 (\u043f\u0440\u0430\u0432\u0434\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430).<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>\u041d\u043e \u0430 \u043c\u044b \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u0442\u043e\u0440\u043e\u0439, \u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/Swind\/pure-python-adb\" rel=\"noopener noreferrer nofollow\">ppadb<\/a>.<\/p>\n<h2>Pure Python ADB<\/h2>\n<p>\u0410\u0431\u0431\u0440\u0435\u0432\u0438\u0430\u0442\u0443\u0440\u0430 <code>ppadb<\/code> \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a Pure Python ADB.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/hd\/xr\/-f\/hdxr-fnary2wp50xksljlzs7ba4.png\" data-src=\"https:\/\/habrastorage.org\/webt\/hd\/xr\/-f\/hdxr-fnary2wp50xksljlzs7ba4.png\"\/><\/figure>\n<p>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: <a href=\"https:\/\/github.com\/Swind\/pure-python-adb\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"bash\">pip3 install pure-python-adb <\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432:<\/p>\n<pre><code class=\"python\">from ppadb.client import Client as ADBClient  client = ADBClient() devices = client.devices()  for device in devices: print(f'\u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e: {device.serial}') <\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0430 \u0432\u0441\u0435 \u0434\u0435\u0432\u0430\u0439\u0441\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043b\u0438 \u043f\u0430\u043a\u0435\u0442, \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"python\">from ppadb.client import Client as AdbClient  apk_path = \"example.apk\"  client = AdbClient(host=\"127.0.0.1\", port=5037) devices = client.devices()  for device in devices:     device.install(apk_path)  for device in devices:     print(device.is_installed(\"example.package\"))  for device in devices:     device.uninstall(\"example.package\") <\/code><\/pre>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0432\u044b\u0437\u043e\u0432 \u0448\u0435\u043b\u043b-\u043a\u043e\u043c\u0430\u043d\u0434?<\/p>\n<pre><code class=\"python\">from ppadb.client import Client as AdbClient  client = AdbClient(host=\"127.0.0.1\", port=5037) devices = client.devices()  for device in devices:     device.shell('echo Hello, Habr!') <\/code><\/pre>\n<p>\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u044b:<\/p>\n<pre><code class=\"python\">from ppadb.client import Client as AdbClient  client = AdbClient(host=\"127.0.0.1\", port=5037) device = client.device(\"emulator-5554\") result = device.screencap()  with open(\"screen.png\", \"wb\") as fp:     fp.write(result) <\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<pre><code class=\"python\">from ppadb.client import Client as AdbClient client = AdbClient(host=\"127.0.0.1\", port=5037) device = client.device(\"emulator-5554\")  device.push(\"example.apk\", \"\/sdcard\/example.apk\") <\/code><\/pre>\n<p>\u0412\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<pre><code class=\"python\">from ppadb.client import Client as AdbClient client = AdbClient(host=\"127.0.0.1\", port=5037) device = client.device(\"emulator-5554\")  device.shell(\"screencap -p \/sdcard\/screen.png\") device.pull(\"\/sdcard\/screen.png\", \"screen.png\") <\/code><\/pre>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0432 ppadb \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"python\">import asyncio import aiofiles from ppadb.client_async import ClientAsync as AdbClient  async def _save_screenshot(device):     result = await device.screencap()     file_name = f\"{device.serial}.png\"     async with aiofiles.open(f\"{file_name}\", mode='wb') as f:         await f.write(result)      return file_name  async def main():     client = AdbClient(host=\"127.0.0.1\", port=5037)     devices = await client.devices()     for device in devices:         print(device.serial)      result = await asyncio.gather(*[_save_screenshot(device) for device in devices])     print(result)  asyncio.run(main()) <\/code><\/pre>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0440\u0443\u0442\u0438\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430 \u0430\u043d\u0434\u0440\u043e\u0438\u0434 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435 \u0447\u0435\u0440\u0435\u0437 adb, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c python \u043a\u0430\u043a \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u0430. \u041e\u0434\u0438\u043d \u0440\u0430\u0437 \u043d\u0430\u043f\u0438\u0441\u0430\u0432, \u043c\u043e\u0436\u043d\u043e \u0435\u0433\u043e \u0432\u0441\u044f\u0447\u0435\u0441\u043a\u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u0442\u044c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u0435\u043d.<\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0432\u0441\u0435\u0445 \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435!<\/p>\n<h3>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/h3>\n<p>\u041d\u0438\u0436\u0435 \u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/dev.to\/plotegor\/adb-fastboot-3mgf\" rel=\"noopener noreferrer nofollow\">dev.to\/adb fastboot commands<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Swind\/pure-python-adb\" rel=\"noopener noreferrer nofollow\">github\/ppadb repository<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/822099\/\"> https:\/\/habr.com\/ru\/articles\/822099\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041e\u0434\u043d\u0430\u0436\u0434\u044b, \u0432 \u043e\u0434\u043d\u0443 \u0438\u0437 \u0431\u0435\u0441\u0441\u043e\u043d\u043d\u044b\u0445 \u043d\u043e\u0447\u0435\u0439, \u044f \u0434\u0443\u043c\u0430\u043b, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0443\u0442\u0438\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430 \u0430\u043d\u0434\u0440\u043e\u0438\u0434-\u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u0435. \u041d\u0443 \u0432\u044b \u0436\u0435 \u0437\u043d\u0430\u0435\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 &#8212; \u0438\u0445 \u0445\u043b\u0435\u0431\u043e\u043c \u043d\u0435 \u043a\u043e\u0440\u043c\u0438, \u0434\u0430\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e-\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0411\u0443\u0434\u044c \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043e\u0442\u0447\u0435\u0442\u043e\u0432 \u0438\u043b\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>\u0418 \u0432\u043e\u0442, \u0442\u043e\u0433\u0434\u0430 \u044f \u0443\u0437\u043d\u0430\u043b \u043e\u0431 \u043e\u0434\u043d\u043e\u0439 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u0435 &#8212; Android Debug Bridge, ADB. \u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Android &#8212; \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b \u0442\u0435\u043b\u0435\u0444\u043e\u043d, \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0439\u0441\u044f \u0447\u0435\u043c \u0445\u043e\u0447\u0435\u0448\u044c. \u041d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0442\u0430\u043a \u043b\u0435\u043d\u044c \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u0438\u0445 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437&#8230; \u0412\u043e\u0442 \u0437\u0434\u0435\u0441\u044c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 Python. \u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 ADB \u0447\u0435\u0440\u0435\u0437 python.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b &#8212; \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f Android, \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0438\u043b\u0438 \u044e\u0437\u0435\u0440 &#8212; \u0442\u043e \u0432\u044b \u043f\u043e\u043f\u0430\u043b\u0438 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u0442\u044c, \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e Python.<\/p>\n<p>Python &#8212; \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u043e\u0438\u0445 \u043b\u044e\u0431\u0438\u043c\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u0442\u0441\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0438\u0447 &#8212; \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 Python 3.10 \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f match-case.<\/p>\n<pre><code class=\"python\">http_status = 404  match http_status: case 400: print(\"Bad Request\") case 404: print(\"Not Found\") case 200: print(\"Success\") case _: print('Other') <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441\u0442\u043e\u0438\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e Python &#8212; &#171;\u043a\u043e\u043b\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u044f\u0437\u044b\u043a&#187;, \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438, \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438, \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438.<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u044f\u0437\u044b\u043a \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u0434\u0435\u0431\u0430\u0433\u0433\u0438\u043d\u0433\u0430 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0439:<\/p>\n<pre><code class=\"python\">number: int = 10 fnum: float = 10.10 text: str = \"Hello\" is_normal: bool = True  # \u0418 \u0434\u0440\u0443\u0433\u0438\u0435, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0441\u043f\u0438\u0441\u043a\u0438, \u043a\u043e\u0440\u0442\u0435\u0436\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 <\/code><\/pre>\n<p>\u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 Python. \u041e\u043d \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u044f\u0445 \u043b\u0438\u0441\u043f\u0430. \u0422\u0430\u043a, \u0432 \u043f\u0438\u0442\u043e\u043d\u0435 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>filter<\/code>, <code>map<\/code> \u0438 <code>reduce<\/code>.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0438\u0437 \u043b\u0438\u0441\u043f\u0430 \u0431\u044b\u043b\u0438 \u0432\u0437\u044f\u0442\u044b \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u043e\u0432. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u043c\u043e\u0434\u0443\u043b\u044f (<code>itertools<\/code> \u0438 <code>functools<\/code>), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 Haskell.<\/p>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e &#171;\u0434\u0437\u0435\u043d\u0443&#187; \u043f\u0438\u0442\u043e\u043d\u0430, \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 \u044f\u0434\u0440\u043e \u044f\u0437\u044b\u043a\u0430 \u0432\u0441\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043e\u043d \u0431\u044b\u043b \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u043c. \u041f\u0438\u0442\u043e\u043d \u0441\u0442\u0430\u043b \u0442\u0430\u043a\u0438\u043c \u0438\u0437-\u0437\u0430 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u044f\u0437\u044b\u043a\u0430 ABC &#8212; \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0413\u0432\u0438\u0434\u043e \u0412\u0430\u043d \u0420\u043e\u0441\u0441\u0443\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u043b \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u044f\u0434\u0440\u043e.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c &#8212; \u0432 Python \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 C-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a (.so \u0432 \u043b\u0438\u043d\u0443\u043a\u0441\u0435, .dll \u0432 Windows) \u0432 \u043a\u043e\u0434 \u043d\u0430 \u043f\u0438\u0442\u043e\u043d\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u043e\u0434\u0443\u043b\u044f ctypes.<\/p>\n<p>Python \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u0438 \u041e\u0421. \u0414\u0430\u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u043a\u0430\u0436\u0443, <a href=\"https:\/\/wiki.osdev.org\/Porting_Python\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u041e\u0421<\/a>!<\/p>\n<p>\u0412\u044b\u0431\u0440\u0430\u043b \u044f \u0435\u0433\u043e \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u0430 \u043d\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u043e\u0439, \u043a\u0430\u043a bash), \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c, \u0438 \u0438\u043c\u0435\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u0410 \u0442\u0430\u043a\u0436\u0435 \u043e\u043d \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0446\u0435\u043b\u0435\u0439.<\/p>\n<h2>ADB, \u043e\u0442\u043b\u0430\u0434\u043a\u0430 \u043f\u043e USB<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 &#171;\u043c\u043e\u0441\u0442 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 android&#187; &#8212; \u0442\u043e \u0435\u0441\u0442\u044c ADB.<\/p>\n<p>ADB \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0435\u0439 Google \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438, \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 Android. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e. \u041e\u043d \u043f\u0440\u0438\u0437\u0432\u0430\u043d \u0440\u0435\u0448\u0430\u0442\u044c \u0446\u0435\u043b\u044b\u0439 \u0440\u044f\u0434 \u0437\u0430\u0434\u0430\u0447, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438.<\/p>\n<p>\u0421\u0440\u0435\u0434\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ul>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435, \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 shell-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0438 \u043a\u043e\u043c\u0430\u043d\u0434<\/p>\n<\/li>\n<li>\n<p>\u042d\u043c\u0443\u043b\u044f\u0446\u0438\u044f \u043d\u0430\u0436\u0430\u0442\u0438\u0439, \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430, \u0441\u0432\u0430\u0439\u043f\u043e\u0432 \u0438 \u0442\u0434<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u043d\u0438\u043c\u043a\u0438 \u0438 \u0432\u0438\u0434\u0435\u043e \u0441 \u044d\u043a\u0440\u0430\u043d\u0430<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430:<\/p>\n<pre><code class=\"bash\">sudo apt install android-tools-adb # Ubuntu\/debian sudo pacman -S android-tools # Arch <\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f ADB, \u043d\u0430\u0434\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043f\u043e USB.<\/p>\n<figure class=\"\">\n<div><figcaption>USB Debug<\/figcaption><\/div>\n<\/figure>\n<blockquote>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <code>scrcpy<\/code> &#8212; \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0434\u043b\u044f \u0448\u0430\u0440\u0438\u043d\u0433\u0430 \u044d\u043a\u0440\u0430\u043d\u0430 \u0441 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u043d\u0430 \u041f\u041a \u0447\u0435\u0440\u0435\u0437 ADB<\/p>\n<\/blockquote>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448\u0435\u043c \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u043f\u043e USB. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0443 \u0442\u0435\u043b\u0435\u0444\u043e\u043d \u0447\u0435\u0440\u0435\u0437 USB-\u043f\u0440\u043e\u0432\u043e\u0434 \u0438 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>adb usb<\/code> \u0438 <code>adb devices<\/code>. \u0412\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0434\u0435\u0432\u0430\u0439\u0441\u044b, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0443 \u0432\u0430\u0441 \u0442\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u0438\u043d \u0434\u0435\u0432\u0430\u0439\u0441. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u043c\u043e\u0436\u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<h2>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b ADB<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u0434\u0435\u0431\u0430\u0433\u0430.<\/p>\n<ul>\n<li>\n<p><code>adb reboot<\/code> &#8212; \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<\/li>\n<li>\n<p><code>adb reboot recovery<\/code> &#8212; \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f (recovery)<\/p>\n<\/li>\n<li>\n<p><code>adb reboot bootloader<\/code> &#8212; \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c fastboot.<\/p>\n<\/li>\n<li>\n<p><code>adb install &lt;APK><\/code> &#8212; \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 APK \u0444\u0430\u0439\u043b\u0430. \u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438. \u041a\u0441\u0442\u0430\u0442\u0438, \u044d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u043a\u043d\u043e \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u043a\u043e\u043d \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p><code>adb install -t &lt;APK><\/code> &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><code>adb install -r &lt;APK><\/code> &#8212; \u043f\u0435\u0440\u0435\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p><code>adb shell pm list packages<\/code> &#8212; \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p><code>adb uninstall com.example.example<\/code> &#8212; \u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0435\u0433\u043e Bundle ID.<\/p>\n<\/li>\n<li>\n<p><code>adb shell<\/code> &#8212; \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0448\u0435\u043b\u043b, \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0443<\/p>\n<\/li>\n<li>\n<p><code>adb shell screencap \/sdcard\/screenshot.png<\/code> &#8212; \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0441\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430<\/p>\n<\/li>\n<li>\n<p><code>adb shell screenrecord --size 1280x720 --bit-rate 6000000 --time-limit 20 --verbose \/sdcard\/video.mp<\/code> &#8212; \u0441\u043a\u0440\u0438\u043d\u043a\u0430\u0441\u0442. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440, \u0431\u0438\u0442\u0440\u0435\u0439\u0442, \u043b\u0438\u043c\u0438\u0442 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445).<\/p>\n<\/li>\n<li>\n<p><code>adb shell dumpsys package com.app.example<\/code> &#8212; \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438<\/p>\n<\/li>\n<li>\n<p><code>adb logcat<\/code> &#8212; \u0432\u044b\u0432\u043e\u0434 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043b\u043e\u0433\u043e\u0432<\/p>\n<\/li>\n<li>\n<p><code>adb bugreport<\/code> &#8212; \u0434\u043e\u043a\u043b\u0430\u0434 \u043e \u0433\u0440\u0435\u0448\u043a\u0430\u0445. \u0421\u0431\u043e\u0440 \u043e\u0442\u0447\u0435\u0442\u0430 \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p><code>adb shell dumpsys<\/code> &#8212; \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0441\u043b\u0443\u0436\u0431\u0430\u0445<\/p>\n<\/li>\n<li>\n<p><code>adb push &lt;local> &lt;remote><\/code> &#8212; \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e<\/p>\n<\/li>\n<li>\n<p><code>adb pull &lt;remote> &lt;local><\/code> &#8212; \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p><code>adb shell am start -a android.intent.action.VIEW 'https:\/\/nometa.xyz'<\/code> &#8212; \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0430\u0439\u0442\u0430<\/p>\n<\/li>\n<li>\n<p><code>adb shell input tap X Y<\/code> &#8212; \u0442\u0430\u043f \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435<\/p>\n<\/li>\n<li>\n<p><code>adb shell input swipe X1 Y1 X2 Y2 &lt;\u0414\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u043c\u0441><\/code> &#8212; \u0441\u0432\u0430\u0439\u043f.<\/p>\n<\/li>\n<li>\n<p><code>adb shell dumpsys<\/code> &#8212; \u0434\u0430\u043c\u043f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<\/li>\n<li>\n<p><code>adb shell dumpsys battery<\/code> &#8212; \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0431\u0430\u0442\u0430\u0440\u0435\u0435.<\/p>\n<\/li>\n<li>\n<p><code>adb shell input text \"Hello, Habr!\"<\/code> &#8212; \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044f \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430<\/p>\n<\/li>\n<\/ul>\n<h2>\u0427\u0442\u043e \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c?<\/h2>\n<p>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>adb input tap\/swipe<\/code>? ADB \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c &#171;\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u043c&#187; adb-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c, \u0437\u0430\u043f\u0440\u043e\u0441 \u0443\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0448\u0435\u043b\u043b \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442, \u0441\u043a\u0440\u0438\u043f\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 Java-\u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0430 \u0443\u0436\u0435 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0436\u0435 \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u0438\u043b\u0438 \u0441\u0432\u0430\u0439\u043f. \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0442\u0430\u043f\u0430 \u0438 \u0441\u0432\u0430\u0439\u043f\u0430 \u0435\u0441\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 &#8212; <code>adb shell input touchscreen tap X Y<\/code> \u0438 <code>adb shell input touchscreen X1 Y1 X2 Y2<\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u0430\u0439\u043f \u0432\u043d\u0438\u0437, \u0432\u0432\u0435\u0440\u0445 \u0438 \u0442\u0434 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>adb shell touchscreen motionevent DOWN\/MOVE\/UP X Y<\/code>.<\/p>\n<p>\u042d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u0430\u044f \u0438 \u043d\u0443\u0436\u043d\u0430\u044f, \u0432\u0435\u0434\u044c \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0437\u0430 \u0432\u0430\u0441.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 <code>adb shell input<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>adb shell input keyboard keyevent 3<\/code> \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u0434\u043e\u043c\u043e\u0439.<\/p>\n<p>\u041a\u0435\u0439\u043a\u043e\u0434\u044b \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e <a href=\"https:\/\/developer.android.com\/reference\/android\/view\/keyevent#keycode_home\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<h2>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 ADB \u0447\u0435\u0440\u0435\u0437 python?<\/h2>\n<p>\u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 &#8212; \u0447\u0435\u0440\u0435\u0437 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 subprocess, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 &#8212; \u0447\u0435\u0440\u0435\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 ppadb.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<pre><code class=\"bash\">python3 -m venv venv source venv\/bin\/activate <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0444\u0430\u0439\u043b \u0438 \u043d\u0430\u0447\u043d\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">import subprocess # \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043c\u0430\u043d\u0434   def get_devices(self) -> list: \"\"\" \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432.  :return: \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \"\"\" # \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 adb devices command = subprocess.run(['adb', 'devices'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)  # \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0435 0, \u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u043c \u043e\u0431 \u044d\u0442\u043e\u043c if command.returncode != 0: print(f'Error receiving devices: {command.stderr}') return None  # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u043e\u0442 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u0438 \u0441\u043f\u043b\u0438\u0442\u0438\u043c \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c result = command.stdout.strip().split('\\n') # \u041e\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0431\u0435\u0440\u0435\u043c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c 1 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 devices = result[1:]  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u0443\u0434\u0430\u043b\u044f\u044f \u043b\u0438\u0448\u043d\u0435\u0435 devices = [device.replace('\\tdevice', '') for device in devices]  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 return devices   print(f'\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430: {\" \".join(devices)}') <\/code><\/pre>\n<p>\u0418 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code>\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430: da7045007d79 <\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u0432\u0441\u0435 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0449\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b &#8212; \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430<\/p>\n<pre><code class=\"python\">def reboot(reboot_type: str='plain') -> bool: \"\"\" \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430  :param reboot_type: \u0422\u0438\u043f \u0440\u0435\u0431\u0443\u0442\u0430, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e plain. \u0422\u0430\u043a\u0436\u0435: recovery, fastboot :return: True \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, False \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \"\"\" if reboot_type == 'plain': command = ['adb', 'reboot'] elif reboot_type == 'recovery': command = ['adb', 'reboot', 'recovery'] elif reboot_type == 'fastboot': command = ['adb', 'reboot', 'fastboot']  result = subprocess.run(command,  stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)  if result.returncode != 0: return False  return True <\/code><\/pre>\n<p>\u042f \u0434\u0443\u043c\u0430\u044e \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043d\u0430 Python. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0443\u0437\u043d\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u0448\u043b\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 &#8212; \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u0434 \u043a\u043e\u0440\u043e\u0447\u0435, \u0438 \u043a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043e\u0442\u043d\u0435\u0441\u0435\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"python\">import subprocess from typing import Union   def execute(command: Union[list, str]) -> subprocess.CompletedProcess: \"\"\" \u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0447\u0435\u0440\u0435\u0437 subprocess.  :param command: \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 :return: \u041e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 subprocess \"\"\" if isinstance(command, str): command = command.split(' ')  result = subprocess.run(command,  stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)  if result.returncode != 0: print(f'Failed execute command: {result.stderr}')  return result <\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 &#8212; \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 Keyevent, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u0439 \u043e\u0442 Enum.<\/p>\n<p>\u041e\u043d \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0433\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043a\u043b\u0430\u0432\u0438\u0448 \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>adb shell input keyevent<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043b\u0430\u0432\u0438\u0448<\/p>\n<pre><code class=\"python\">from enum import Enum   class Keyevent(Enum): \"\"\" \u0427\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043b\u0430\u0432\u0438\u0448 (adb shell keyevent)  \u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u0432:  DIGIT - \u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 CONTROL - \u043a\u043b\u0430\u0432\u0438\u0448\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u044b<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-378973","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/378973","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=378973"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/378973\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=378973"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=378973"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=378973"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}