def _connect_with_wifi(self): interface = adb.shell('ifconfig wlan0', self._udid)[1] key = 'inet addr:' s = interface.index(key) e = interface.index(' ', s + len(key)) ip = interface[s + len(key):e].strip() found = False devices = _cmd_list_devices() for device in devices: if ip in device: found = True self._udid = device.split(' ')[0] break if not found: self._udid = adb.connect(ip) # check if connect success found = False devices = _cmd_list_devices() for device in devices: if ip not in device: found = True break if ip not in self._udid: found = False if not found: raise Exception('Failed to connect device though wifi.')
def adb_command(self, cmd): """ Executes an adb shell command, and return the standard output in string. Example:: d = Device() d.adb_command('dumpsys meminfo') :param cmd: the command to run :return the standard output of the command """ return adb.shell(cmd, self._udid)[1]
def cmd_stop_response_info(udid): return adb.shell('atrace gfx input --async_stop', udid)[1]
def cmd_start_response_info(udid): adb.shell('atrace gfx input --async_start', udid)
def _cmd_get_prop(name, udid): return adb.shell('getprop %s' % name, udid)[1]
def _cmd_wm_density(self): return int(adb.shell('wm density', self._udid)[1].split(':')[1])
def _cmd_wm_size(self): wxh = adb.shell('wm size', self._udid)[1].split(':')[1].split('x') width = int(wxh[0]) height = int(wxh[1]) return width, height
def cmd_dump_gfx_info(package_name, udid): return adb.shell('dumpsys gfxinfo %s' % package_name, udid)[1]
def cmd_reset_gfx_info(package_name, udid): adb.shell('dumpsys gfxinfo %s reset' % package_name, udid)