
com.mcxiaoke.packer.cli.Bridge Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cli Show documentation
Show all versions of cli Show documentation
Next Generation Android Multi Packer Gradle Plugin
package com.mcxiaoke.packer.cli;
import com.android.apksig.ApkVerifier;
import com.android.apksig.ApkVerifier.Builder;
import com.android.apksig.ApkVerifier.Result;
import com.android.apksig.apk.ApkFormatException;
import com.mcxiaoke.packer.common.Parser;
import java.io.File;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
/**
* User: mcxiaoke
* Date: 2017/5/26
* Time: 16:21
*/
public class Bridge {
public static void writeChannel(File file, String channel) throws IOException {
Parser.create(file).writeChannel(channel);
}
public static String readChannel(File file) throws IOException {
return Parser.create(file).readChannel();
}
public static boolean verifyChannel(File file, String channel) throws IOException {
return verifyApk(file) && (channel.equals(readChannel(file)));
}
public static boolean verifyApk(File file) throws IOException {
ApkVerifier verifier = new Builder(file).build();
try {
Result result = verifier.verify();
return result.isVerified()
&& result.isVerifiedUsingV1Scheme()
&& result.isVerifiedUsingV2Scheme();
} catch (ApkFormatException e) {
throw new IOException(e);
} catch (NoSuchAlgorithmException e) {
throw new IOException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy