예제 #1
0
def main():
    aapt_instance = AAPT("/home/holmes/prosoft/android-sdk-linux/build-tools/17.0.0/aapt")    
    apk_file = "/home/holmes/xy/release/RomasterSu_1.0.4_0922_1200_1001_kingsoft.apk"    
    apk_info = aapt_instance.dump_badging(apk_file)
    # print(apk_info)
    apk_info_list = apk_info.split("\n")
    # for i in xrange(len(apk_info_list)):
    #     print(i)
    #     print(apk_info_list[i])
    package_info = aapt_utils.parse_map(apk_info_list[0])
    print(package_info)

    _adb = adb.ADB("/home/holmes/prosoft/android-sdk-linux/platform-tools/adb")
    result = _adb.install(reinstall=True, pkgapp=apk_file)
    # result = _adb.shell_command("id")
    # print(_adb.lastFailed())
    print(result if result != None else _adb.get_error())
예제 #2
0
def main():
    args = sys.argv 
    apk_file = None;
    if len(args) <= 1:
        print("Need a apk file")
        exit(-1)

    apk_file = args[1]
    if not os.path.isabs(apk_file):
        apk_file = os.path.abspath(apk_file)

    # print(__ADB_PATH)
    _adb = adb.ADB(__ADB_PATH)
    print("Try to install app %s" % apk_file)
    # print(_adb.check_path())
    # print(_adb.get_adb_path())
    result = install_apk(_adb, apk_file)
    if result == None:
        print("error for adb install")
        exit(-2)
    install_result = result.split("\n")[1]
    install_result_code = parse_install_result(install_result.strip())
    if install_result_code == 0:
        exit(0)

    aapt_instance = AAPT(__AAPT_PATH)
    apk_info = aapt_instance.dump_badging(apk_file)
    apk_info_list = apk_info.split("\n")
    package_info = aapt_utils.parse_map(apk_info_list[0])
    # print(package_info)
    package_name = package_info["name"]
    version_name = package_info["versionName"]
    print("Uninstall app %s with version %s" % (package_name, version_name))
    print(_adb.uninstall(package=package_name, keepdata=True))
    print("Reinstall app")
    print(install_apk(_adb, apk_file))