#!/usr/bin/python # -*- coding: utf-8 -*- import subprocess from pathlib import Path import time APK_TOOLS_FOLDER = Path('C:/Users/main/AppData/Local/Android/Sdk/platform-tools') DESTINATION = Path('C:/Mc/Aws/APKs/FromPy') DESTINATION.mkdir(exist_ok=True, parents=True) # it.beghelli.dome # .\adb.exe shell pm list packages -3 # .\adb.exe shell pm list packages -3 > x5_find_l3_2025_02_09.txt # .\adb.exe shell dumpsys activity recents # .\adb.exe shell pm path it.beghelli.dome # .\adb.exe pull /data/app/~~ImzbTI0j21ORlO9dusKcAg==/it.beghelli.dome-dtycHO3eKSqdeUqiMRedDw==/base.apk dome.apk # .\adb.exe install .\dome.apk def run_command(command): # Run the command and capture the output try: result = subprocess.run(command, shell=True, check=True, text=True, capture_output=True) # Print the standard output and error # print("Standard Output:\n", result.stdout) # print("Standard Error:\n", result.stderr) return result.stdout # Return stdout if you want to use it elsewhere except subprocess.CalledProcessError as e: print(f"Command failed with error: {e.stderr}") return None def do_adb(params): tool = APK_TOOLS_FOLDER / 'adb.exe' cmd = f'{tool} {params}' return run_command(cmd) def find_apks_files(package_name): r = do_adb(f' shell pm path {package_name}') return r.split('\n') if __name__ == '__main__': # r = do_adb('devices') # print(r) # # r = do_adb(' shell pm list packages -3') # for line in r.split('\n'): # if 'translate' in line.lower(): # print(f'-{line}') # str_now = time.strftime('%Y_%m_%d_%H%M%S') pkg_name = 'com.google.android.apps.translate' dest_folder = DESTINATION / f'{pkg_name.replace(".", "_")}_{str_now}' dest_folder.mkdir(parents=True, exist_ok=True) for f in find_apks_files(pkg_name): if len(f) > 8: source = f[8:] src = Path(source) print(src.name) print(source, dest_folder) do_adb(f'pull {source} {dest_folder}')