()
| 36 | * Show a APK file chooser window and decompile that APK. |
| 37 | */ |
| 38 | export async function openApkFile(): Promise<void> { |
| 39 | // browse for an APK file |
| 40 | const result = await window.showOpenDialog({ |
| 41 | canSelectFolders: false, |
| 42 | filters: { |
| 43 | APK: [APK_FILE_EXTENSION.substring(1)], // Remove the dot |
| 44 | }, |
| 45 | openLabel: "Select an APK file", |
| 46 | }); |
| 47 | if (result && result.length === 1) { |
| 48 | const quickPickItems = await showArgsQuickPick( |
| 49 | quickPickUtil.getQuickPickItems("decodeQuickPickItems"), |
| 50 | "Additional features & Apktool/Jadx arguments", |
| 51 | ); |
| 52 | |
| 53 | if (quickPickItems) { |
| 54 | const args = quickPickItems.map<string>((item) => item.label); |
| 55 | const argDescriptions = quickPickItems.map<string | undefined>( |
| 56 | (item) => item.description, |
| 57 | ); |
| 58 | const decompileJavaIndex = |
| 59 | argDescriptions.indexOf("[Use Jadx]"); |
| 60 | const quarkAnalysisIndex = |
| 61 | argDescriptions.indexOf("[Use Quark-Engine]"); |
| 62 | const jadxOptionsIndex = argDescriptions.indexOf("jadx"); |
| 63 | const jadxOptionsNumber = argDescriptions.filter( |
| 64 | (item) => item === "jadx", |
| 65 | ).length; |
| 66 | let decompileJava = false; |
| 67 | let quarkAnalysis = false; |
| 68 | let jadxArgs: string[] = []; |
| 69 | |
| 70 | // Extract jadx options if present |
| 71 | if (jadxOptionsIndex !== -1) { |
| 72 | jadxArgs = args.splice(jadxOptionsIndex, jadxOptionsNumber); |
| 73 | } |
| 74 | |
| 75 | // Check if Java decompilation was requested |
| 76 | if (decompileJavaIndex !== -1) { |
| 77 | decompileJava = true; |
| 78 | args.splice(decompileJavaIndex, 1); |
| 79 | } |
| 80 | |
| 81 | // Check if Quark analysis was requested |
| 82 | if (quarkAnalysisIndex !== -1) { |
| 83 | quarkAnalysis = true; |
| 84 | args.splice(quarkAnalysisIndex, 1); |
| 85 | if (!Quark.checkQuarkInstalled()) { |
| 86 | window.showErrorMessage( |
| 87 | "APKLab: Quark command not found. " + |
| 88 | "Please make sure you have installed python3 and Quark-Engine. " + |
| 89 | "Check here to install Quark-Engine: " + |
| 90 | "https://github.com/quark-engine/quark-engine", |
| 91 | ); |
| 92 | return; |
| 93 | } |
| 94 | } |
| 95 |
nothing calls this directly
no test coverage detected