fix: Do not sign if mounting

This commit is contained in:
oSumAtrIX 2023-09-17 05:36:41 +02:00
parent 1319ab7629
commit 578e16b099
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
3 changed files with 11 additions and 28 deletions

View File

@ -208,16 +208,17 @@ internal object PatchCommand : Runnable {
// region Save
ApkUtils.alignAndSign(
apk,
val aligned = resourceCachePath.resolve(apk.name)
ApkUtils.align(apk, aligned, patcherResult)
if (!mount) ApkUtils.sign(
aligned,
outputFilePath,
SigningOptions(
commonName,
password,
keystoreFilePath ?: outputFilePath.parentFile
keystoreFilePath ?: outputFilePath.absoluteFile.parentFile
.resolve("${outputFilePath.nameWithoutExtension}.keystore"),
),
patcherResult
)
)
// endregion

View File

@ -1,6 +1,7 @@
public final class app/revanced/lib/ApkUtils {
public static final field INSTANCE Lapp/revanced/lib/ApkUtils;
public final fun alignAndSign (Ljava/io/File;Ljava/io/File;Lapp/revanced/lib/signing/SigningOptions;Lapp/revanced/patcher/PatcherResult;)V
public final fun align (Ljava/io/File;Ljava/io/File;Lapp/revanced/patcher/PatcherResult;)V
public final fun sign (Ljava/io/File;Ljava/io/File;Lapp/revanced/lib/signing/SigningOptions;)V
}
public final class app/revanced/lib/Options {

View File

@ -9,29 +9,10 @@ import app.revanced.patcher.PatcherResult
import java.io.File
import java.util.logging.Logger
@Suppress("MemberVisibilityCanBePrivate", "unused")
object ApkUtils {
private val logger = Logger.getLogger(ApkUtils::class.java.name)
/**
* Aligns and signs the apk at [apkFile] and writes it to [outputFile].
*
* @param apkFile The apk to align and sign.
* @param outputFile The apk to write the aligned and signed apk to.
* @param signingOptions The options to use for signing.
* @param patchedEntriesSource The result of the patcher to add the patched dex files and resources.
*/
fun alignAndSign(
apkFile: File,
outputFile: File,
signingOptions: SigningOptions,
patchedEntriesSource: PatcherResult
) {
if (outputFile.exists()) outputFile.delete()
align(apkFile, outputFile, patchedEntriesSource)
sign(outputFile, outputFile, signingOptions)
}
/**
* Creates a new apk from [apkFile] and [patchedEntriesSource] and writes it to [outputFile].
*
@ -39,7 +20,7 @@ object ApkUtils {
* @param outputFile The apk to write the new entries to.
* @param patchedEntriesSource The result of the patcher to add the patched dex files and resources.
*/
private fun align(apkFile: File, outputFile: File, patchedEntriesSource: PatcherResult) {
fun align(apkFile: File, outputFile: File, patchedEntriesSource: PatcherResult) {
logger.info("Aligning ${apkFile.name}")
ZipFile(outputFile).use { file ->
@ -72,7 +53,7 @@ object ApkUtils {
* @param output The apk to write the signed apk to.
* @param signingOptions The options to use for signing.
*/
private fun sign(
fun sign(
apk: File,
output: File,
signingOptions: SigningOptions,