def refresh_devices_list(self): self.clear_all_textctrl() out, err = ShellTool.run("adb devices") devices = out.split('\n') self.devices_list = [] for device in devices: if len(device) > 0 and '\tdevice' in device: self.devices_list.append(device.replace('\tdevice', '')) self.combobox_devices.SetItems(self.devices_list) if len(self.devices_list) > 0: self.combobox_devices.SetValue(self.devices_list[0]) SelectItem.set_selected_device_name(self.devices_list[0]) device_name = DeviceTool.getprop_ro_product_name() device_os_version = DeviceTool.getprop_ro_build_version_release() self.statictext_device_name.SetLabel('Name: {}'.format( device_name[0]).strip()) self.statictext_device_os_version.SetLabel('OS Version: {}'.format( device_os_version[0]).strip()) pub.sendMessage('re_select_device') else: SelectItem.set_selected_device_name('') device_name = ' ' device_os_version = ' ' self.statictext_device_name.SetLabel( 'Name: {}'.format(device_name)) self.statictext_device_os_version.SetLabel( 'OS Version: {}'.format(device_os_version)) SelectItem.clear_all() pub.sendMessage('no_device')
def on_get_device_info(self, event): self.clear_all_textctrl() shell = 'adb -s {} shell getprop'.format(SelectItem.get_selected_device_name()) self.textctrl_shell.SetValue(shell) out, err = ShellTool.run(shell) self.textctrl_output.SetValue(out) self.textctrl_output.AppendText('\n') self.textctrl_output.AppendText(err)
def get_top_activity(device_panel): device_build_version = DeviceTool.getprop_ro_build_version_release() shell = '' if device_build_version[0].startswith("7"): shell = 'adb -s {} shell dumpsys activity | grep "mFocusedActivity"' \ .format(SelectItem.get_selected_device_name()) elif device_build_version[0].startswith("8"): shell = 'adb -s {} shell dumpsys activity activities | grep "mResumedActivity"' \ .format(SelectItem.get_selected_device_name()) elif device_build_version[0].startswith("9"): shell = 'adb -s {} shell dumpsys activity activities | grep "mResumedActivity"' \ .format(SelectItem.get_selected_device_name()) elif device_build_version[0].startswith("10"): shell = 'adb -s {} shell dumpsys activity activities | grep "mResumedActivity"' \ .format(SelectItem.get_selected_device_name()) device_panel.textctrl_shell.SetValue(shell) out, err = ShellTool.run(shell) device_panel.textctrl_output.SetValue(out) device_panel.textctrl_output.AppendText('\n') device_panel.textctrl_output.AppendText(err)
def on_command_exec(self, event): shell = self.textctrl_shell.GetValue() out, err = ShellTool.run(shell) self.textctrl_output.SetValue(out) self.textctrl_output.AppendText('\n') self.textctrl_output.AppendText(err)
def get_all_packages_with_filepath(): return ShellTool.run("adb -s {} shell pm list packages -f".format(SelectItem.get_selected_device_name()))
def getprop_ro_build_version_release(): return ShellTool.run( "adb -s {} shell getprop ro.build.version.release".format(SelectItem.get_selected_device_name()))
def getprop_ro_product_name(): return ShellTool.run("adb -s {} shell getprop ro.product.name".format(SelectItem.get_selected_device_name()))