创建 Adb 控制器 / Create Adb controller Args: adb_path: adb 路径 / adb path address: 连接地址 / connection address screencap_methods: 所有可使用的截图方式 / all available screenshot methods input_methods: 所有可使用的输入方式 / all available input methods config
(
self,
adb_path: Union[str, Path],
address: str,
screencap_methods: int = MaaAdbScreencapMethodEnum.Default,
input_methods: int = MaaAdbInputMethodEnum.Default,
config: Optional[dict[str, Any]] = None,
agent_path: Union[str, Path] = AGENT_BINARY_PATH,
)
| 802 | ) |
| 803 | |
| 804 | def __init__( |
| 805 | self, |
| 806 | adb_path: Union[str, Path], |
| 807 | address: str, |
| 808 | screencap_methods: int = MaaAdbScreencapMethodEnum.Default, |
| 809 | input_methods: int = MaaAdbInputMethodEnum.Default, |
| 810 | config: Optional[dict[str, Any]] = None, |
| 811 | agent_path: Union[str, Path] = AGENT_BINARY_PATH, |
| 812 | ): |
| 813 | """创建 Adb 控制器 / Create Adb controller |
| 814 | |
| 815 | Args: |
| 816 | adb_path: adb 路径 / adb path |
| 817 | address: 连接地址 / connection address |
| 818 | screencap_methods: 所有可使用的截图方式 / all available screenshot methods |
| 819 | input_methods: 所有可使用的输入方式 / all available input methods |
| 820 | config: 额外配置 / extra config |
| 821 | agent_path: MaaAgentBinary 路径 / MaaAgentBinary path |
| 822 | |
| 823 | Raises: |
| 824 | RuntimeError: 如果创建失败 |
| 825 | """ |
| 826 | if config is None: |
| 827 | config = {} |
| 828 | super().__init__() |
| 829 | self._set_adb_api_properties() |
| 830 | |
| 831 | self._handle = Library.framework().MaaAdbControllerCreate( |
| 832 | str(adb_path).encode(), |
| 833 | address.encode(), |
| 834 | MaaAdbScreencapMethod(screencap_methods), |
| 835 | MaaAdbInputMethod(input_methods), |
| 836 | json.dumps(config, ensure_ascii=False).encode(), |
| 837 | str(agent_path).encode(), |
| 838 | ) |
| 839 | |
| 840 | if not self._handle: |
| 841 | raise RuntimeError("Failed to create ADB controller.") |
| 842 | |
| 843 | def _set_adb_api_properties(self): |
| 844 | Library.framework().MaaAdbControllerCreate.restype = MaaControllerHandle |
nothing calls this directly
no test coverage detected