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

View File

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