hid相关 Hid correlation
| 4 | |
| 5 | |
| 6 | class AndroidHidCorrelation: |
| 7 | """ |
| 8 | hid相关 |
| 9 | Hid correlation |
| 10 | """ |
| 11 | |
| 12 | def __init_accessory(self) -> bool: |
| 13 | """ |
| 14 | 初始化 android Accessory,获取手机 hid 相关的数据 |
| 15 | Initialize android Accessory to get the data related to mobile phone hid |
| 16 | |
| 17 | return: True或者False |
| 18 | return: True or False. |
| 19 | """ |
| 20 | return "true" in self.SendData("initAccessory") |
| 21 | |
| 22 | def init_hid(self, win_driver) -> bool: |
| 23 | """ |
| 24 | 初始化Hid,不能重复调用,重复调用会导致get_hid_data取不到数据 |
| 25 | Initialize Hid, and you can't call it repeatedly. Repeated calls will cause get_hid_data to get no data |
| 26 | |
| 27 | hid实际上是由windowsBot 通过数据线直接发送命令给安卓系统并执行,并不是由aibote.apk执行的命令。 |
| 28 | 我们应当将所有设备准备就绪再调用此函数初始化。 |
| 29 | Windows initHid 和 android initAccessory函数 初始化目的是两者的数据交换,并告知windowsBot发送命令给哪台安卓设备 |
| 30 | win_driver: windowsDriver 实例,是调用 build_win_driver 的返回值 |
| 31 | return: True或者False |
| 32 | |
| 33 | In fact, hid is a command directly sent by windowsBot to Android system through data line and executed, not by aibote.apk |
| 34 | We should get all the devices ready before calling this function to initialize |
| 35 | The initialization purpose of Windows initHid and android initAccessory functions is to exchange data between them and tell windowsBot which Android device to send commands to |
| 36 | Win_driver: windowsDriver instance, which is the return value of calling build_win_driver |
| 37 | return: True or False |
| 38 | """ |
| 39 | |
| 40 | self.android_id = self.get_android_id() |
| 41 | self.win_driver = win_driver |
| 42 | if not self.win_driver: |
| 43 | return False |
| 44 | if not self.__init_accessory(): |
| 45 | return False |
| 46 | self.android_ids = self.win_driver.get_hid_data() |
| 47 | |
| 48 | for android_id in self.android_ids: |
| 49 | if android_id == self.android_id: |
| 50 | return True |
| 51 | return False |
| 52 | |
| 53 | def get_rotation_angle(self) -> int: |
| 54 | """ |
| 55 | 获取手机旋转角度 |
| 56 | Get the rotation angle of the mobile phone |
| 57 | |
| 58 | return: 手机旋转的角度 |
| 59 | return: the angle at which the phone rotates. |
| 60 | """ |
| 61 | response = self.SendData("getRotationAngle") |
| 62 | return int(response) |
| 63 |
nothing calls this directly
no outgoing calls
no test coverage detected