(apkFilePath: string)
| 10 | * @param apkFilePath path of the an apk file to be signed. |
| 11 | */ |
| 12 | export async function signAPK(apkFilePath: string): Promise<void> { |
| 13 | if (!apkFilePath || !fs.existsSync(apkFilePath)) { |
| 14 | vscode.window.showErrorMessage( |
| 15 | `APKLab: APK file not found: ${apkFilePath}`, |
| 16 | ); |
| 17 | return; |
| 18 | } |
| 19 | |
| 20 | const extensionConfig = |
| 21 | vscode.workspace.getConfiguration(extensionConfigName); |
| 22 | const apkSignerPath = extensionConfig.get("apkSignerPath"); |
| 23 | |
| 24 | if (!apkSignerPath || !fs.existsSync(String(apkSignerPath))) { |
| 25 | vscode.window.showErrorMessage( |
| 26 | "APKLab: uber-apk-signer not found. Please check your configuration.", |
| 27 | ); |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | const keystorePath = extensionConfig.get("keystorePath"); |
| 32 | const keystorePassword = extensionConfig.get("keystorePassword"); |
| 33 | const keyAlias = extensionConfig.get("keyAlias"); |
| 34 | const keyPassword = extensionConfig.get("keyPassword"); |
| 35 | const report = `Signing ${apkFilePath}`; |
| 36 | const args = [ |
| 37 | "-jar", |
| 38 | String(apkSignerPath), |
| 39 | "-a", |
| 40 | apkFilePath, |
| 41 | "--allowResign", |
| 42 | "--overwrite", |
| 43 | ]; |
| 44 | if ( |
| 45 | keystorePath && |
| 46 | fs.existsSync(String(keystorePath)) && |
| 47 | keystorePassword && |
| 48 | keyAlias && |
| 49 | keyPassword |
| 50 | ) { |
| 51 | args.push( |
| 52 | "--ks", |
| 53 | String(keystorePath), |
| 54 | "--ksPass", |
| 55 | String(keystorePassword), |
| 56 | "--ksAlias", |
| 57 | String(keyAlias), |
| 58 | "--ksKeyPass", |
| 59 | String(keyPassword), |
| 60 | ); |
| 61 | } |
| 62 | await executeProcess({ |
| 63 | name: "Signing", |
| 64 | report: report, |
| 65 | command: getJavaPath(), |
| 66 | args: args, |
| 67 | shouldExist: apkFilePath, |
| 68 | }); |
| 69 | } |
nothing calls this directly
no test coverage detected