Don't fetch signature when lv=0

This commit is contained in:
LoveSy 2021-06-21 00:47:55 +08:00
parent e8ccca40a9
commit 19089a3097
2 changed files with 15 additions and 14 deletions

View File

@ -149,17 +149,19 @@ public class LSPatch {
System.out.println("Parsing original apk...");
ZFile zFile = ZFile.openReadWrite(tmpApk);
// save the apk original signature info, to support crach signature.
String originalSignature = ApkSignatureHelper.getApkSignInfo(srcApkFile.getAbsolutePath());
if (originalSignature == null || originalSignature.isEmpty()) {
throw new PatchError("get original signature failed");
}
if (verbose)
System.out.println("Original signature\n" + originalSignature);
try (var is = new ByteArrayInputStream(originalSignature.getBytes(StandardCharsets.UTF_8))) {
zFile.add(SIGNATURE_INFO_ASSET_PATH, is);
} catch (Throwable e) {
throw new PatchError("Error when saving signature: " + e);
if (sigbypassLevel > 0) {
// save the apk original signature info, to support crack signature.
String originalSignature = ApkSignatureHelper.getApkSignInfo(srcApkFile.getAbsolutePath());
if (originalSignature == null || originalSignature.isEmpty()) {
throw new PatchError("get original signature failed");
}
if (verbose)
System.out.println("Original signature\n" + originalSignature);
try (var is = new ByteArrayInputStream(originalSignature.getBytes(StandardCharsets.UTF_8))) {
zFile.add(SIGNATURE_INFO_ASSET_PATH, is);
} catch (Throwable e) {
throw new PatchError("Error when saving signature: " + e);
}
}
// get the dex count in the apk zip file

View File

@ -72,9 +72,8 @@ public class ApkSignatureHelper {
}
}
jarFile.close();
return new String(toChars(certs[0].getEncoded()));
} catch (Exception e) {
e.printStackTrace();
return certs != null ? new String(toChars(certs[0].getEncoded())) : null;
} catch (Throwable ignored) {
}
return null;
}