### Install MYT SDK from Source Source: https://github.com/kuqitt/myt_sdk/blob/main/README.md Install the MYT SDK by cloning the repository and installing it in editable mode. This is useful for development. ```bash git clone https://github.com/moyunteng/myt-sdk.git cd myt-sdk pip install -e . ``` -------------------------------- ### Install MYT SDK from PyPI Source: https://github.com/kuqitt/myt_sdk/blob/main/README.md Use this command to install the MYT SDK package from the Python Package Index. This is the recommended installation method. ```bash pip install myt-sdk ``` -------------------------------- ### Install APK from URL Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Installs an APK directly from a URL. The 'retry' parameter can be set to attempt installation multiple times if it fails. ```python result = client.install_apk_from_url( "192.168.1.100", "container_name", "https://example.com/app.apk", retry=2 ) print(f"URL安装结果: {result}") ``` -------------------------------- ### Install APK from Local File Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Installs an APK file from a local path on the device. Ensure the provided path to the APK is correct. ```python result = client.install_apk("192.168.1.100", "container_name", "/path/to/app.apk") print(f"安装结果: {result}") ``` -------------------------------- ### Batch Get Image List Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Retrieves lists of images for different types in batches. This example demonstrates iterating through image types and fetching their respective lists, with error handling for failed requests. ```python with create_client() as client: # 批量获取不同类型的镜像 image_types = ['p1', 'q1', 'a1', 'c1'] for img_type in image_types: try: images = client.get_image_list_v2(img_type) print(f"镜像类型 {img_type}: {len(images['msg'])} 个镜像") except MYTSDKError as e: print(f"获取镜像类型 {img_type} 失败: {e}") ``` -------------------------------- ### Application Management Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Methods for installing, uninstalling, and running applications. ```APIDOC ## POST /install_apk ### Description Installs an APK file from a local path onto the device. ### Method POST ### Endpoint /install_apk ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **apk_path** (str) - Required - The local path to the APK file. ### Response #### Success Response (200) - **result** (bool) - Indicates if the installation was successful. ## POST /install_apk_from_url ### Description Installs an APK from a given URL onto the device. ### Method POST ### Endpoint /install_apk_from_url ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **apk_url** (str) - Required - The URL of the APK file. - **retry** (int) - Optional - Number of retries for the download and installation. ### Response #### Success Response (200) - **result** (bool) - Indicates if the installation was successful. ## POST /uninstall_apk ### Description Uninstalls an application from the device. ### Method POST ### Endpoint /uninstall_apk ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **package_name** (str) - Required - The package name of the application to uninstall. ### Response #### Success Response (200) - **result** (bool) - Indicates if the uninstallation was successful. ## POST /run_app ### Description Runs an application on the device. ### Method POST ### Endpoint /run_app ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **package_name** (str) - Required - The package name of the application to run. ### Response #### Success Response (200) - **result** (bool) - Indicates if the application was successfully launched. ``` -------------------------------- ### Initialize MYT SDK (Command Line) Source: https://github.com/kuqitt/myt_sdk/blob/main/README.md Initialize the MYT SDK from the command line. Options include forcing a re-download, skipping the start process, specifying a cache directory, and enabling verbose logging. ```bash # 基本初始化 myt-sdk init # 强制重新下载 myt-sdk init --force # 只下载不启动 myt-sdk init --no-start # 使用自定义缓存目录 myt-sdk init --cache-dir /path/to/cache # 启用详细日志 myt-sdk init --verbose ``` -------------------------------- ### Initialize and Manage MYT SDK with Python Source: https://github.com/kuqitt/myt_sdk/blob/main/README.md Use the MYTSDKManager class to check the SDK's installation and running status, and to initialize the SDK programmatically. ```python from py_myt import MYTSDKManager # 创建SDK管理器 sdk_manager = MYTSDKManager() # 检查SDK状态 status = sdk_manager.get_status() print(f"SDK已安装: {status['installed']}") print(f"SDK正在运行: {status['running']}") # 初始化SDK result = sdk_manager.init() print(f"初始化结果: {result}") ``` -------------------------------- ### Run Application Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Launches an installed application on the device. Specify the package name of the application to run. ```python result = client.run_app("192.168.1.100", "container_name", "com.example.app") print(f"运行应用结果: {result}") ``` -------------------------------- ### Batch Operations Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Example of batch operations, such as retrieving different types of images. ```APIDOC ## GET /get_image_list_v2 ### Description Retrieves a list of images of a specified type. ### Method GET ### Endpoint /get_image_list_v2 ### Parameters #### Query Parameters - **image_type** (str) - Required - The type of images to retrieve (e.g., 'p1', 'q1', 'a1', 'c1'). ### Response #### Success Response (200) - **msg** (list) - A list of image objects. ``` -------------------------------- ### Get Clipboard Content Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Retrieves the content of the device's clipboard. Ensure the IP address and container name are correct. ```python result = client.get_clipboard_content("192.168.1.100", "container_name") print(f"剪切板内容: {result}") ``` -------------------------------- ### Perform Linting with Flake8 Source: https://github.com/kuqitt/myt_sdk/blob/main/README.md Run Flake8 on the py_myt directory to check for style guide violations and potential errors. This is part of maintaining code quality. ```bash flake8 py_myt/ ``` -------------------------------- ### Clipboard Operations Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Methods for getting and setting clipboard content on a remote device. ```APIDOC ## GET /get_clipboard_content ### Description Retrieves the content of the clipboard from a specified device. ### Method GET ### Endpoint /get_clipboard_content ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. ### Response #### Success Response (200) - **result** (str) - The content of the clipboard. ## POST /set_clipboard_content ### Description Sets the clipboard content on a specified device. ### Method POST ### Endpoint /set_clipboard_content ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **content** (str) - Required - The content to set to the clipboard. ### Response #### Success Response (200) - **result** (bool) - Indicates if the operation was successful. ``` -------------------------------- ### Check MYT SDK Status (Command Line) Source: https://github.com/kuqitt/myt_sdk/blob/main/README.md Check the current status of the MYT SDK from the command line. ```bash myt-sdk status ``` -------------------------------- ### Interact with MYT SDK API Client Source: https://github.com/kuqitt/myt_sdk/blob/main/README.md Create an API client to manage containers, configure streams, and set up proxy connections. Handles potential MYTSDKError exceptions. ```python from py_myt import create_client from py_myt.exceptions import MYTSDKError # 创建API客户端 client = create_client(base_url="http://192.168.1.100:5000") try: # 容器管理 containers = client.get_containers(ip="192.168.1.100") print(f"容器列表: {containers}") # 创建Android容器 result = client.create_android_container( ip="192.168.1.100", index=1, name="my_container", image_addr="android_image" ) print(f"容器创建结果: {result}") # 设置摄像头推流 client.set_camera_stream( ip="192.168.1.100", name="my_container", v_type=1, # RTMP流 resolution=1, # 1920x1080@30 addr="rtmp://live.example.com/stream" ) # 配置S5代理 client.set_s5_connection( ip="192.168.1.100", name="my_container", s5ip="127.0.0.1", s5port="1080", s5user="username", s5pwd="password" ) except MYTSDKError as e: print(f"API调用失败: {e}") ``` -------------------------------- ### System Control Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Methods for controlling system audio playback and executing ADB commands. ```APIDOC ## POST /set_audio_playback ### Description Controls audio playback on the device. ### Method POST ### Endpoint /set_audio_playback ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **action** (str) - Required - The action to perform (e.g., "play"). - **file_path** (str) - Required - The path to the audio file. ### Response #### Success Response (200) - **result** (bool) - Indicates if the audio playback action was successful. ## POST /execute_adb_command ### Description Executes an ADB command on the device. ### Method POST ### Endpoint /execute_adb_command ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **command** (str) - Required - The ADB command to execute. ### Response #### Success Response (200) - **result** (str) - The output of the ADB command. ## POST /execute_adb_command2 ### Description Executes a second type of ADB command on the device. ### Method POST ### Endpoint /execute_adb_command2 ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **command** (str) - Required - The ADB command to execute. ### Response #### Success Response (200) - **result** (str) - The output of the ADB command. ``` -------------------------------- ### Execute ADB Command 2 Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Executes a second type of ADB command, potentially for different functionalities or command structures. Ensure the command syntax is correct. ```python result = client.execute_adb_command2( "192.168.1.100", "container_name", "getprop ro.build.version.release" ) print(f"ADB命令2结果: {result}") ``` -------------------------------- ### Format Code with Black Source: https://github.com/kuqitt/myt_sdk/blob/main/README.md Apply code formatting to the py_myt directory using the Black formatter. This ensures consistent code style across the project. ```bash black py_myt/ ``` -------------------------------- ### Set All App Permissions Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Grants all available permissions to a specified application. Use with caution as it may impact device security. ```python result = client.set_app_all_permissions("192.168.1.100", "container_name", "com.example.app") print(f"所有权限设置结果: {result}") ``` -------------------------------- ### Set Basic Custom Device Information Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Sets basic custom device information, including model, manufacturer, and build details. This is crucial for digital twin functionality. Use with caution as incorrect data may prevent booting. ```python device_data = ''' { "device_model": "SM-G991B", "manufacturer": "Samsung", "brand": "samsung", "hardware": "exynos2100", "fingerprint": "samsung/o1sxxx/o1s:12/SP1A.210812.016/G991BXXU5DVKB:user/release-keys", "build_id": "SP1A.210812.016", "version_release": "12", "version_sdk": "31" } ''' result = client.set_custom_device_info( ip="192.168.1.100", name="test_container", device_data=device_data ) ``` -------------------------------- ### Execute ADB Command Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Executes a raw ADB command on the device. This is useful for performing operations not directly covered by the client's methods. ```python result = client.execute_adb_command( "192.168.1.100", "container_name", "pm list packages" ) print(f"ADB命令结果: {result}") ``` -------------------------------- ### System Status Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Methods for checking system status and capturing screenshots. ```APIDOC ## GET /get_android_boot_status ### Description Checks the boot status of an Android device. ### Method GET ### Endpoint /get_android_boot_status ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **isblock** (int) - Optional - Whether to block until status is retrieved (1 for true, 0 for false). - **timeout** (int) - Optional - Timeout in seconds for the operation. - **init_devinfo** (int) - Optional - Whether to initialize device info (1 for true, 0 for false). ### Response #### Success Response (200) - **result** (str) - The boot status of the device. ## POST /take_screenshot ### Description Takes a screenshot of the device screen. ### Method POST ### Endpoint /take_screenshot ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **level** (int) - Optional - The quality level of the screenshot (e.g., 3). ### Response #### Success Response (200) - **result** (str) - The screenshot image data or path. ``` -------------------------------- ### Run All Tests Source: https://github.com/kuqitt/myt_sdk/blob/main/README.md Execute all tests in the project using pytest. This is a standard command for verifying code integrity. ```bash pytest ``` -------------------------------- ### Upload Google Certificate Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Uploads a Google certificate file to the device. Provide the correct path to the certificate file. ```python result = client.upload_google_cert( "192.168.1.100", "container_name", "/path/to/cert.p12" ) print(f"证书上传结果: {result}") ``` -------------------------------- ### Set Clipboard Content Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Sets the content of the device's clipboard. This operation requires the target IP address and container name. ```python result = client.set_clipboard_content("192.168.1.100", "container_name", "Hello World") print(f"设置剪切板结果: {result}") ``` -------------------------------- ### Network Configuration Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Methods for network configuration, including certificate upload and URL filtering. ```APIDOC ## POST /upload_google_cert ### Description Uploads a Google certificate to the device. ### Method POST ### Endpoint /upload_google_cert ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **cert_path** (str) - Required - The local path to the certificate file. ### Response #### Success Response (200) - **result** (bool) - Indicates if the certificate upload was successful. ## POST /set_s5_filter_url ### Description Sets URL filtering for S5 proxy. ### Method POST ### Endpoint /set_s5_filter_url ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **urls** (str) - Required - A JSON string representing a list of URLs to filter. ### Response #### Success Response (200) - **result** (bool) - Indicates if the S5 filter was set successfully. ## GET /query_s5_connection ### Description Queries the S5 connection information. ### Method GET ### Endpoint /query_s5_connection ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. ### Response #### Success Response (200) - **result** (dict) - Information about the S5 connection. ``` -------------------------------- ### Set Full Custom Device Information Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Sets comprehensive custom device information, including all available parameters like Android ID, ICCID, IMEI, and MAC addresses. This allows for detailed device emulation. Ensure all provided data is accurate. ```python result = client.set_custom_device_info( ip="192.168.1.100", name="test_container", device_data=device_data, android_id="1234567890abcdef", # Android ID iccid="89860000000000000000", # SIM卡ICCID imei="123456789012345", # IMEI号 imsi="123456789012345", # IMSI号 series_num="R58N123ABCD", # 序列号 btaddr="AA:BB:CC:DD:EE:FF", # 蓝牙地址 btname="Samsung Galaxy S21", # 蓝牙名称 wifi_mac="11:22:33:44:55:66", # WiFi MAC地址 wifi_name="Galaxy-S21", # WiFi名称 oaid="12345678-1234-1234-1234-123456789012", # OAID aaid="12345678-1234-1234-1234-123456789012", # AAID vaid="12345678-1234-1234-1234-123456789012" # VAID ) ``` -------------------------------- ### Permission Management Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Methods for managing application permissions. ```APIDOC ## POST /set_app_root_permission ### Description Grants root permissions to an application. ### Method POST ### Endpoint /set_app_root_permission ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **package_name** (str) - Required - The package name of the application. ### Response #### Success Response (200) - **result** (bool) - Indicates if the root permission was set successfully. ## POST /set_app_all_permissions ### Description Grants all permissions to an application. ### Method POST ### Endpoint /set_app_all_permissions ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **package_name** (str) - Required - The package name of the application. ### Response #### Success Response (200) - **result** (bool) - Indicates if all permissions were set successfully. ## POST /set_app_resolution_filter ### Description Configures resolution-aware filtering for an application. ### Method POST ### Endpoint /set_app_resolution_filter ### Parameters #### Query Parameters - **ip** (str) - Required - The IP address of the device. - **container_name** (str) - Required - The name of the container instance. - **package_name** (str) - Required - The package name of the application. - **enable** (int) - Required - Enable (1) or disable (0) the resolution filter. ### Response #### Success Response (200) - **result** (bool) - Indicates if the setting was applied successfully. ``` -------------------------------- ### Run Tests with Coverage Source: https://github.com/kuqitt/myt_sdk/blob/main/README.md Execute tests using pytest and generate a code coverage report. This helps in identifying areas of the code that are not adequately tested. ```bash pytest --cov=py_myt ``` -------------------------------- ### Take Screenshot Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Captures a screenshot of the device. The 'level' parameter can be used to control the screenshot quality or type. ```python result = client.take_screenshot("192.168.1.100", "container_name", level=3) print(f"截图结果: {result}") ``` -------------------------------- ### Custom Device Information (Digital Twin) Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Methods for setting custom device information, including basic and comprehensive parameters. ```APIDOC ## POST /set_custom_device_info ### Description Sets custom device information for a container instance. Use with caution as incorrect data may prevent the system from booting. ### Method POST ### Endpoint /set_custom_device_info ### Parameters #### Request Body - **ip** (str) - Required - The IP address of the 3588 host. - **name** (str) - Required - The name of the container instance. - **device_data** (str) - Required - Exported device information data from a real device. - **android_id** (str) - Optional - Android ID. - **iccid** (str) - Optional - SIM card ICCID. - **imei** (str) - Optional - IMEI number. - **imsi** (str) - Optional - IMSI number. - **series_num** (str) - Optional - Serial number. - **btaddr** (str) - Optional - Bluetooth address. - **btname** (str) - Optional - Bluetooth name. - **wifi_mac** (str) - Optional - WiFi MAC address. - **wifi_name** (str) - Optional - WiFi name. - **oaid** (str) - Optional - OAID. - **aaid** (str) - Optional - AAID. - **vaid** (str) - Optional - VAID. ### Request Example ```json { "ip": "192.168.1.100", "name": "test_container", "device_data": "{\"device_model\": \"SM-G991B\", \"manufacturer\": \"Samsung\", \"brand\": \"samsung\", \"hardware\": \"exynos2100\", \"fingerprint\": \"samsung/o1sxxx/o1s:12/SP1A.210812.016/G991BXXU5DVKB:user/release-keys\", \"build_id\": \"SP1A.210812.016\", \"version_release\": \"12\", \"version_sdk\": \"31\"}", "android_id": "1234567890abcdef", "iccid": "89860000000000000000", "imei": "123456789012345", "imsi": "123456789012345", "series_num": "R58N123ABCD", "btaddr": "AA:BB:CC:DD:EE:FF", "btname": "Samsung Galaxy S21", "wifi_mac": "11:22:33:44:55:66", "wifi_name": "Galaxy-S21", "oaid": "12345678-1234-1234-1234-123456789012", "aaid": "12345678-1234-1234-1234-123456789012", "vaid": "12345678-1234-1234-1234-123456789012" } ``` ### Response #### Success Response (200) - **result** (bool) - Indicates if the custom device information was set successfully. ``` -------------------------------- ### Control Audio Playback Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Controls audio playback on the device, allowing actions like 'play' with a specified audio file path. ```python result = client.set_audio_playback( "192.168.1.100", "container_name", "play", "/sdcard/Music/test.mp3" ) print(f"音频播放结果: {result}") ``` -------------------------------- ### Check Android Boot Status Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Checks the boot status of an Android device. Parameters like isblock, timeout, and init_devinfo can be adjusted for specific needs. ```python result = client.get_android_boot_status( "192.168.1.100", "container_name", isblock=1, timeout=60, init_devinfo=1 ) print(f"启动状态: {result}") ``` -------------------------------- ### Query S5 Connection Information Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Retrieves connection information related to S5 proxy settings on the device. ```python result = client.query_s5_connection("192.168.1.100", "container_name") print(f"S5连接信息: {result}") ``` -------------------------------- ### Set App Root Permission Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Grants root permissions to a specific application. This operation requires the device to be rooted. ```python result = client.set_app_root_permission("192.168.1.100", "container_name", "com.example.app") print(f"Root权限设置结果: {result}") ``` -------------------------------- ### Run Specific Tests Source: https://github.com/kuqitt/myt_sdk/blob/main/README.md Run specific test files using pytest. This allows for targeted testing of different modules or functionalities. ```bash pytest tests/test_api_client.py pytest tests/test_new_api_methods.py ``` -------------------------------- ### Uninstall APK Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Uninstalls an application from the device using its package name. Provide the correct package name for the app to be removed. ```python result = client.uninstall_apk("192.168.1.100", "container_name", "com.example.app") print(f"卸载结果: {result}") ``` -------------------------------- ### Set S5 Filter URL Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Configures S5 domain filtering by providing a list of URLs to filter. Ensure the URL list is correctly formatted as a string representation of a list. ```python result = client.set_s5_filter_url( "192.168.1.100", "container_name", "['www.baidu.com','qq.com']" ) print(f"S5过滤设置结果: {result}") ``` -------------------------------- ### Set Resolution Filter for App Source: https://github.com/kuqitt/myt_sdk/blob/main/docs/api_client.md Enables or disables resolution-aware filtering for an application. The 'enable' parameter controls the filter status. ```python result = client.set_app_resolution_filter( "192.168.1.100", "container_name", "com.example.app", enable=1 ) print(f"分辨率过滤设置结果: {result}") ``` -------------------------------- ### Perform Type Checking with Mypy Source: https://github.com/kuqitt/myt_sdk/blob/main/README.md Check the Python code in the py_myt directory for type errors using Mypy. This helps in catching type-related bugs early in the development process. ```bash mypy py_myt/ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.