def _fetchWeixinToolsProcessPid(device=None): osName = OS.getPlatform() cmd = _ADB_GET_TOP_ACTIVITY_CMD[osName] stdout, stdError = runCommand(AdbHelper.specifyDeviceOnCmd( cmd, device)) print "fetchWeixinToolsProcessActivity:\n", stdout mmActivity = stdout.split('com.tencent.mm/') pid = 0 for activity in mmActivity: if '.plugin.appbrand.ui.AppBrandInToolsUI' in activity: # 小米 strlist = activity.split('pid=') pid = strlist[1].split("\r\n")[0] break elif '.plugin.appbrand.ui.AppBrandUI' in activity: # VIVO strlist = activity.split('pid=') pid = strlist[1].split("\r\n")[0] break webviewCmd = _ADB_GET_WEBVIEW_TOOLS_CMD[osName] % (pid) print "pid:", pid if pid == 0: # 维持原有逻辑 strlist = stdout.split('pid=') pid = strlist[1].split("\r\n")[0] # 验证是否启动了小程序webview try: webStdout, webStdError = runCommand( AdbHelper.specifyDeviceOnCmd(webviewCmd, device)) except: errorMsg = ErrorMsgManager().errorCodeToString( ERROR_CODE_NOT_ENTER_XCX) raise RuntimeError(errorMsg) return pid
def _fetchWeixinToolsProcessPid(device=None): osName = OS.getPlatform() cmd = _ADB_GET_TOP_ACTIVITY_CMD[osName] stdout, stdError = runCommand(AdbHelper.specifyDeviceOnCmd(cmd, device)) strlist = stdout.split('pid=') pid = strlist[1].split("\r\n")[0] webviewCmd = _ADB_GET_WEBVIEW_TOOLS_CMD[osName] % (pid) # 验证是否启动了小程序webview try: webStdout, webStdError = runCommand(AdbHelper.specifyDeviceOnCmd(webviewCmd, device)) except: errorMsg = ErrorMsgManager().errorCodeToString(ERROR_CODE_NOT_ENTER_XCX) raise RuntimeError(errorMsg) return pid
def _getProcessInfo(cmd, device): nums = 0 retry = True stdout = '' while (retry and nums < 8): try: stdout, stdError = runCommand(AdbHelper.specifyDeviceOnCmd(cmd, device)) retry = False except: nums = nums + 1 time.sleep(1) Log().getLogger().debug('open port mapping ---> retry ' + str(nums)) return stdout
def _forwardLocalPort(localPort, pid, device=None): cmd = "adb forward tcp:%s localabstract:webview_devtools_remote_%s" % ( localPort, pid) runCommand(AdbHelper.specifyDeviceOnCmd(cmd, device))