Esempio n. 1
0
def get_app_permission():
    entry.delete(0, END)  #清空entry里面的内容
    listbox_filename.delete(1.0, END)

    package_name = utils.get_current_package_name()
    permission_list = []
    result_list = utils.shell(
        "dumpsys package %s | %s android.permission" %
        (package_name, utils.find_util)).stdout.readlines()

    for permission in result_list:
        permission_list.append(permission.strip())

    permission_json_file = file("permission.json")

    file_content = json.load(permission_json_file)["PermissList"]

    if utils.system is "Windows":
        listbox_filename.insert(END, "package:" + package_name)
        for permission in permission_list:
            for permission_dict in file_content:
                if permission == permission_dict["Key"]:
                    listbox_filename.insert(END, permission_dict["Key"])
                    listbox_filename.insert(END, "\n")
                    listbox_filename.insert(END, permission_dict["Memo"])
                    listbox_filename.insert(END, "\n")
Esempio n. 2
0
def get_current_activity():
    entry.delete(0, END)  #清空entry里面的内容
    listbox_filename.delete(1.0, END)

    listbox_filename.insert(
        END, "Activity:" + utils.get_focused_package_and_activity())
    listbox_filename.insert(END, "\n\n")

    package_name = utils.get_current_package_name()

    # print package_name

    # print os.popen("aapt dump badging %s" %(get_match_apk(package_name))).readlines()

    # print get_match_apk(package_name)
    for line in os.popen("aapt dump badging %s" %
                         (get_match_apk(package_name))).readlines():
        print line
        listbox_filename.insert(END, line)
Esempio n. 3
0
'''
Created on 2015年1月26日

@author: xuxu
'''

import os

from scriptUtils import utils

#打开手机上的应用(包括系统应用),运行脚本,会将该应用对应的apk复制到本地的App文件夹下

PATH = lambda p: os.path.abspath(p)

def get_match_apk(package_name, path):
    list = []
    for packages in utils.shell("pm list packages -f %s" %package_name).stdout.readlines():
        if packages.split(":")[0] == "package":
            list.append(packages.split(":")[-1].split("=")[0])

    utils.adb("pull %s %s" %(list[0], path)).wait()

if __name__ == "__main__":
    path = PATH("%s/App" %os.getcwd())
    if not os.path.isdir(path):
        os.makedirs(path)

    get_match_apk(utils.get_current_package_name(), path)
    print "Completed"
    

def get_aapt():
    if "ANDROID_HOME" in os.environ:
        rootDir = os.path.join(os.environ["ANDROID_HOME"], "build-tools")
        for path, subdir, files in os.walk(rootDir):
            if "aapt.exe" in files:
                return os.path.join(path, "aapt.exe")
            elif "aapt" in files:
                return os.path.join(path, "aapt")
    else:
        raise SriptException("ANDROID_HOME not exist")


def get_match_apk(package_name):
    list = []
    for packages in utils.shell("pm list packages -f %s" % package_name).stdout.readlines():
        list.append(packages.split(":")[-1].split("=")[0])
    apk_name = list[0].split("/")[-1]

    utils.adb("pull %s %s" % (list[0], tempFile)).wait()

    return PATH("%s/%s" % (tempFile, apk_name))


if __name__ == "__main__":
    package_name = utils.get_current_package_name()
    os.popen("%s dump badging %s > PackageInfo.txt" % (get_aapt(), get_match_apk(package_name)))
    # os.popen("del %s\\*.apk" %tempFile)
    print "Completed"
Esempio n. 5
0
#需要安装pychartdir模块,http://blog.csdn.net/gb112211/article/details/43272049

from pychartdir import *

from scriptUtils import utils

PATH = lambda p: os.path.abspath(p)

#打开待测应用,运行脚本,默认times为20次(可自己手动修改次数),获取该应用cpu、memory占用率的曲线图,图表保存至chart目录下

#top次数
times = 20

#设备当前运行应用的包名
pkg_name = utils.get_current_package_name()


#获取cpu、mem占用
def top():
    cpu = []
    mem = []

    top_info = utils.shell(
        "top -n %s | %s %s$" %
        (str(times), utils.find_util, pkg_name)).stdout.readlines()

    for info in top_info:
        #temp_list = del_space(info)
        temp_list = info.split()
        cpu.append(temp_list[2])
#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
Created on 2015年1月26日

@author: xuxu
'''

import os
import sys

from scriptUtils import utils

#获取设备上当前应用的包名,结果存放于当前目录下的PackageName.txt中

PATH = lambda p: os.path.abspath(p)

if __name__ == "__main__":
    f = open(PATH("%s/PackageName.txt" %os.getcwd()), "w")
    f.write("Package: \n%s" %utils.get_current_package_name())
    f.close()
    print "Completed"
    sys.exit(0)
Esempio n. 7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2015年1月26日

@author: xuxu
'''

import os
import sys

from scriptUtils import utils

#获取设备上当前应用的包名,结果存放于当前目录下的PackageName.txt中

PATH = lambda p: os.path.abspath(p)

if __name__ == "__main__":
    f = open(PATH("%s/PackageName.txt" % os.getcwd()), "w")
    f.write("Package: \n%s" % utils.get_current_package_name())
    f.close()
    print "Completed"
    sys.exit(0)
Esempio n. 8
0
import tempfile
import re

from scriptUtils import utils

#获取设备上当前应用的包信息,结果存放于当前目录下的PackageInfo.txt中

tempFile = tempfile.gettempdir()

def get_aapt():
    if "ANDROID_HOME" in os.environ:
        rootDir = os.path.join(os.environ["ANDROID_HOME"], "build-tools")
        for path, subdir, files in os.walk(rootDir):
            if "aapt.exe" in files:
                return os.path.join(path, "aapt.exe")
    else:
        return "ANDROID_HOME not exist"

def get_match_apk(package_name):
    list = []
    for packages in utils.shell("pm list packages -f %s" %package_name).stdout.readlines():
        list.append(packages.split(":")[-1].split("=")[0])
    apk_name = list[0].split("/")[-1]
    utils.adb("pull %s %s" %(list[0], tempFile)).wait()

    return "%s\\%s" %(tempFile, apk_name)

if __name__ == "__main__":
    os.popen("%s dump badging %s > PackageInfo.txt" %(get_aapt(), utils.get_current_package_name()))
    os.popen("del %s\\*.apk" %tempFile)
    print "Completed"
#获取设备上当前应用的包信息,结果存放于当前目录下的PackageInfo.txt中

tempFile = tempfile.gettempdir()


def get_aapt():
    if "ANDROID_HOME" in os.environ:
        rootDir = os.path.join(os.environ["ANDROID_HOME"], "build-tools")
        for path, subdir, files in os.walk(rootDir):
            if "aapt.exe" in files:
                return os.path.join(path, "aapt.exe")
    else:
        return "ANDROID_HOME not exist"


def get_match_apk(package_name):
    list = []
    for packages in utils.shell("pm list packages -f %s" %
                                package_name).stdout.readlines():
        list.append(packages.split(":")[-1].split("=")[0])
    apk_name = list[0].split("/")[-1]
    utils.adb("pull %s %s" % (list[0], tempFile)).wait()

    return "%s\\%s" % (tempFile, apk_name)


if __name__ == "__main__":
    os.popen("%s dump badging %s > PackageInfo.txt" %
             (get_aapt(), utils.get_current_package_name()))
    os.popen("del %s\\*.apk" % tempFile)
    print "Completed"