Exemplo n.º 1
0
def access_to_electricity(tag, uid_info):
    info = Modules.BatteryInfo()
    info.end_time.append(FunCom.current_time())
    battery_info = FunCom.p_open(Res.adb_dump_battery(tag)).readlines()
    for ii in range(len(battery_info) - 1):
        if 'level:' in battery_info[ii]:
            battery_info_arr = battery_info[ii].split('  level: ')
            info.battery_percentage.append(battery_info_arr[1].strip())

    battery_detailed_info = FunCom.p_open(
        Res.adb_dump_battery_status(tag)).readlines()
    for i in range(len(battery_detailed_info) - 1):
        if 'Capacity:' in battery_detailed_info[i]:
            bat_info = battery_detailed_info[i].split(',')

            battery_capacity = bat_info[0].split('    Capacity: ')
            battery_computed_drain = bat_info[1].split(' Computed drain: ')
            info.battery_actual_drain = bat_info[2].split(' actual drain: ')
            info.capacity.append(int(battery_capacity[1].strip()))
            info.computed.append(float(battery_computed_drain[1].strip()))

        if 'Uid ' + str(uid_info) in battery_detailed_info[i]:
            num = battery_detailed_info[i].split(':')
            num = num[1].split('(')
            info.uid_item_info.append(float(num[0].strip()))
    return info
Exemplo n.º 2
0
def information_collection(apk_tag, dev, path):
    Fun.log('trigger gc')
    absolute_tmp_dump_path = os.path.realpath(path)
    Fun.p_open(
        Res.adb_grab_heap_dump_file_with_pkg(dev, absolute_tmp_dump_path,
                                             Res.pkg_name))
    Fun.sleep(10)

    lines = Fun.p_open(Res.asb_shell_dump_mem_info(dev)).readlines()
    name = apk_tag + Res.dump + Fun.current_time()
    dump_mem_info_store_to_file(name, lines, path)
    Grab.grab_dump_and_convert(dev, name, absolute_tmp_dump_path, Res.pkg_name)
Exemplo n.º 3
0
def exception_handle(device_id, logcat_to_file=False):
    # if logcat_to_file:
    FunCom.log_cat_to_file(device_id)
    device_info = FunCom.parse_device_info(device_id)
    dir_to_store_logfile = FunCom.get_abspath(
        FunCom.path_join(
            Res.log_path, device_info + Res.underline + Res.logcat_tag +
            FunCom.current_time()))
    FunCom.make_dir_if_not_exist(dir_to_store_logfile)
    FunCom.log('Exception handle id:' + device_id + " dir to store log::" +
               dir_to_store_logfile)
    FunCom.p_open(Res.asb_shell_pull_log_file(device_id, dir_to_store_logfile))
Exemplo n.º 4
0
def grab_dump_and_convert(dev, target_name, dest_path, pkg):
    Fun.p_open(
        Res.adb_grab_heap_dump_file_with_pkg(dev, absolute_tmp_dump_path, pkg))
    Fun.sleep(4)
    dump_file_path = os.path.join(dest_path, target_name)
    dump_file = dump_file_path + Res.hprof_suffix if not dump_file_path.endswith(
        Res.hprof_suffix) else dump_file_path
    if os.path.exists(dump_file):
        dump_file = dump_file.replace(Res.hprof_suffix,
                                      Fun.current_time() + Res.hprof_suffix)
    Fun.p_open(
        Res.adb_pull_heap_file_to_dest(dev, absolute_tmp_dump_path, dump_file))
    convert_file_into_directory(dump_file)