def getCpuNums():
    num_info = util.shell('cat /proc/cpuinfo|grep processor').stdout.readlines()
    # print("cpu nums is %d" %(len(num_info)))
    return len(num_info)
def get_uid():
    cmd = 'cat  /proc/'+ get_pid() + '/status'
    uid_info = util.shell(cmd).stdout.readlines()
    uid = uid_info[6].split()[1]
    print('uid为:%s' %(uid))
    return str(uid)
def get_flow_send():
    cmd = '"cat proc/net/xt_qtaguid/stats|grep '+'%s"'%get_uid()
    print(cmd)
    flow = util.shell(cmd).stdout.readlines()
    print(flow)
def getSDKVersion():
    SDKVersion = str(util.shell('getprop ro.build.version.sdk').stdout.read())[2:-7]
    return SDKVersion
def getSDKVersion():
    SDKVersion = util.shell('getprop ro.build.version.sdk').stdout.read().decode().strip()
    return int(SDKVersion)
def getDevicesName():
    devicesName = str(util.shell('getprop ro.product.model').stdout.read())
    return devicesName
def getDevicesName():
    devicesName = util.shell('getprop ro.product.model').stdout.read().decode().strip()
    return devicesName
def getSDKVersion():
    SDKVersion = str(util.shell('getprop ro.build.version.sdk').stdout.read())[0:-6]
    print(SDKVersion)
    return SDKVersion
        if(len(top_info)!=0):
            for x in top_info:
                temp_list = x.split()
                    cpu = round(float(temp_list[2].decode().split('%')[0]),2)
                    mem = round(float(temp_list[6].decode()[0:-1])/1024,1)
                    print(cpu)
                    print(mem)                
                else:
                    cpu = 0.0
                    mem = 0.0
                return (cpu,mem)
        else:
            return 0.0
    else:
        cpunums=getCpuNums()
        top_info = util.shell('top -n 1 | grep %d' % (int(pid))).stdout.readlines()
        if(len(top_info)!=0):
            for x in top_info:
                temp_list = x.split()
                    cpu = round(float(temp_list[8])/cpunums,2)
                    print(cpu)
                else:
                    cpu = 0.0
        else:
            return 0.0
        mem_info = util.shell('dumpsys meminfo %d |grep TOTAL:' %(int(pid))).stdout.readlines()
        for x in mem_info:
            temp_list = x.split()
            mem=round(float(temp_list[1])/1024,1)
            print(mem)
Beispiel #10
0
def get_pid():
    pid_info = util.shell('adb shell ps| grep %s' %(package_name)).stdout.readlines()
    print(pid_info)
    pid = pid_info[0].split()[1]
    print('pid为: %s' %(pid))
    return pid