def android_all_package_list(): msg = filter( None, WindowsOsUtil.get_shell_output(['adb', 'shell'], 'pm list packages -3 -f').split('\r\n')) package_list = [] for ms in msg: ms = android_aapt_get_app_info( ms[ms.index('/'):ms.rindex('=')]).replace('\r\n', '').split('\'') if ms.count('package: name=') == 1: pkg = ms[ms.index('package: name=') + 1] else: pkg = '' if ms.count('application-label-zh-CN:') == 1: name = ms[ms.index('application-label-zh-CN:') + 1] elif ms.count('application-label:') == 1: name = ms[ms.index('application-label:') + 1] elif ms.count('application: label=') == 1: name = ms[ms.index('application: label=') + 1] else: name = 'no label name' if ms.count('launchable-activity: name=') == 1: launch = ms[ms.index('launchable-activity: name=') + 1] else: launch = android_search_app_activity(pkg) package_list.append(','.join((pkg, name, launch))) write_string_to_file( GlobalParam.get_android_apk_list().replace( 'android_apk_list', android_product_info() + '_android_apk_list'), package_list, 'utf8') return package_list
def android_search_package_by_name(app_name): read_list = list( read_file( GlobalParam.get_android_apk_list().replace( 'android_apk_list', android_product_info() + '_android_apk_list'), 'utf8').strip('][').replace('\'', '').split(', ')) for rl in read_list: if rl.__contains__(app_name): return rl.split(',')[0], rl.split(',')[2]