diff --git a/solox/__init__.py b/solox/__init__.py index 18f874c..10bb4d6 100644 --- a/solox/__init__.py +++ b/solox/__init__.py @@ -2,4 +2,4 @@ from __future__ import absolute_import -__version__ = '2.7.8' +__version__ = '2.7.9' diff --git a/solox/public/apm_pk.py b/solox/public/apm_pk.py index 41f0af1..975f28c 100644 --- a/solox/public/apm_pk.py +++ b/solox/public/apm_pk.py @@ -28,10 +28,10 @@ def getprocessCpuStat(self, pkgName, deviceId): return processCpu - def getTotalCpuStat(self): + def getTotalCpuStat(self, deviceId): """get the total cpu usage at a certain time""" cmd = 'cat /proc/stat |{} ^cpu'.format(d.filterType()) - result = adb.shell(cmd=cmd, deviceId=self.deviceId) + result = adb.shell(cmd=cmd, deviceId=deviceId) totalCpu = 0 lines = result.split('\n') for line in lines: diff --git a/solox/public/common.py b/solox/public/common.py index 7f6f9e8..d1de41e 100644 --- a/solox/public/common.py +++ b/solox/public/common.py @@ -80,11 +80,15 @@ def getIdbyDevice(self, deviceinfo, platform): else: deviceId = deviceinfo return deviceId + + def getSdkVersion(self, deviceId): + version = adb.shell(cmd='getprop ro.build.version.sdk', deviceId=deviceId) + return version def getPid(self, deviceId, pkgName): """Get the pid corresponding to the Android package name""" try: - sdkversion = adb.shell(cmd='getprop ro.build.version.sdk', deviceId=deviceId) + sdkversion = self.getSdkVersion(deviceId) if sdkversion and int(sdkversion) < 26: result = os.popen(f"{self.adb} -s {deviceId} shell ps | {self.filterType()} {pkgName}").readlines() processList = ['{}:{}'.format(process.split()[1],process.split()[8]) for process in result] @@ -131,11 +135,16 @@ def checkPkgname(self, pkgname): flag = False return flag - def getPkgname(self, devicesId): + def getPkgname(self, deviceId): """Get all package names of Android devices""" - pkginfo = os.popen(f"{self.adb} -s {devicesId} shell pm list package") + pkginfo = os.popen(f"{self.adb} -s {deviceId} shell pm list packages --user 0") pkglist = [p.lstrip('package').lstrip(":").strip() for p in pkginfo] - return pkglist + if pkglist.__len__() > 0: + return pkglist + else: + pkginfo = os.popen(f"{self.adb} -s {deviceId} shell pm list packages") + pkglist = [p.lstrip('package').lstrip(":").strip() for p in pkginfo] + return pkglist def getDeviceInfoByiOS(self): """Get a list of all successfully connected iOS devices""" diff --git a/solox/templates/base.html b/solox/templates/base.html index 9e61f64..0e98ac5 100644 --- a/solox/templates/base.html +++ b/solox/templates/base.html @@ -130,7 +130,7 @@