本文整理汇总了Java中com.tencent.tinker.loader.shareutil.SharePatchFileUtil.verifyDexFileMd5方法的典型用法代码示例。如果您正苦于以下问题:Java SharePatchFileUtil.verifyDexFileMd5方法的具体用法?Java SharePatchFileUtil.verifyDexFileMd5怎么用?Java SharePatchFileUtil.verifyDexFileMd5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.tencent.tinker.loader.shareutil.SharePatchFileUtil
的用法示例。
在下文中一共展示了SharePatchFileUtil.verifyDexFileMd5方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extract
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
public static boolean extract(ZipFile zipFile, ZipEntry entryFile, File extractTo, String targetMd5, boolean isDex) throws IOException {
int numAttempts = 0;
boolean isExtractionSuccessful = false;
while (numAttempts < MAX_EXTRACT_ATTEMPTS && !isExtractionSuccessful) {
numAttempts++;
BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entryFile));
FileOutputStream fos = new FileOutputStream(extractTo);
BufferedOutputStream out = new BufferedOutputStream(fos);
TinkerLog.i(TAG, "try Extracting " + extractTo.getPath());
try {
byte[] buffer = new byte[ShareConstants.BUFFER_SIZE];
int length = bis.read(buffer);
while (length != -1) {
out.write(buffer, 0, length);
length = bis.read(buffer);
}
} finally {
SharePatchFileUtil.closeQuietly(out);
SharePatchFileUtil.closeQuietly(bis);
}
if (isDex) {
isExtractionSuccessful = SharePatchFileUtil.verifyDexFileMd5(extractTo, targetMd5);
} else {
isExtractionSuccessful = SharePatchFileUtil.verifyFileMd5(extractTo, targetMd5);
}
TinkerLog.i(TAG, "isExtractionSuccessful: %b", isExtractionSuccessful);
if (!isExtractionSuccessful) {
extractTo.delete();
if (extractTo.exists()) {
TinkerLog.e(TAG, "Failed to delete corrupted dex " + extractTo.getPath());
}
}
}
return isExtractionSuccessful;
}
示例2: extract
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
public static boolean extract(ZipFile zipFile, ZipEntry entryFile, File extractTo, String
targetMd5, boolean isDex) throws IOException {
int numAttempts = 0;
boolean isExtractionSuccessful = false;
while (numAttempts < 2 && !isExtractionSuccessful) {
numAttempts++;
BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entryFile));
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(extractTo));
TinkerLog.i(TAG, "try Extracting " + extractTo.getPath(), new Object[0]);
try {
byte[] buffer = new byte[16384];
for (int length = bis.read(buffer); length != -1; length = bis.read(buffer)) {
out.write(buffer, 0, length);
}
if (isDex) {
isExtractionSuccessful = SharePatchFileUtil.verifyDexFileMd5(extractTo,
targetMd5);
} else {
isExtractionSuccessful = SharePatchFileUtil.verifyFileMd5(extractTo, targetMd5);
}
TinkerLog.i(TAG, "isExtractionSuccessful: %b", Boolean.valueOf
(isExtractionSuccessful));
if (!isExtractionSuccessful) {
extractTo.delete();
if (extractTo.exists()) {
TinkerLog.e(TAG, "Failed to delete corrupted dex " + extractTo.getPath(),
new Object[0]);
}
}
} finally {
SharePatchFileUtil.closeQuietly(out);
SharePatchFileUtil.closeQuietly(bis);
}
}
return isExtractionSuccessful;
}
示例3: loadTinkerJars
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
@TargetApi(14)
public static boolean loadTinkerJars(Application application, boolean tinkerLoadVerifyFlag,
String directory, Intent intentResult) {
if (dexList.isEmpty()) {
Log.w(TAG, "there is no dex to load");
return true;
}
PathClassLoader classLoader = (PathClassLoader) TinkerDexLoader.class.getClassLoader();
if (classLoader != null) {
Log.i(TAG, "classloader: " + classLoader.toString());
String dexPath = directory + "/" + "dex" + "/";
File optimizeDir = new File(directory + "/" + "odex");
ArrayList<File> legalFiles = new ArrayList();
boolean isArtPlatForm = ShareTinkerInternals.isVmArt();
Iterator it = dexList.iterator();
while (it.hasNext()) {
ShareDexDiffPatchInfo info = (ShareDexDiffPatchInfo) it.next();
if (!isJustArtSupportDex(info)) {
File file = new File(dexPath + info.realName);
if (tinkerLoadVerifyFlag) {
long start = System.currentTimeMillis();
if (SharePatchFileUtil.verifyDexFileMd5(file, isArtPlatForm ? info
.destMd5InArt : info.destMd5InDvm)) {
Log.i(TAG, "verify dex file:" + file.getPath() + " md5, use time: " +
(System.currentTimeMillis() - start));
} else {
ShareIntentUtil.setIntentReturnCode(intentResult, -14);
intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_MISMATCH_DEX_PATH,
file.getAbsolutePath());
return false;
}
}
legalFiles.add(file);
}
}
try {
SystemClassLoaderAdder.installDexes(application, classLoader, optimizeDir,
legalFiles);
Log.i(TAG, "after loaded classloader: " + application.getClassLoader().toString());
return true;
} catch (Throwable e) {
Log.e(TAG, "install dexes failed");
intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_EXCEPTION, e);
ShareIntentUtil.setIntentReturnCode(intentResult, -15);
return false;
}
}
Log.e(TAG, "classloader is null");
ShareIntentUtil.setIntentReturnCode(intentResult, -13);
return false;
}
示例4: extractDexToJar
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
private static boolean extractDexToJar(ZipFile zipFile, ZipEntry entryFile, File extractTo,
String targetMd5) throws IOException {
Throwable th;
int numAttempts = 0;
boolean isExtractionSuccessful = false;
while (numAttempts < 2 && !isExtractionSuccessful) {
numAttempts++;
FileOutputStream fos = new FileOutputStream(extractTo);
InputStream in = zipFile.getInputStream(entryFile);
ZipOutputStream zos = null;
BufferedInputStream bis = null;
TinkerLog.i(TAG, "try Extracting " + extractTo.getPath(), new Object[0]);
try {
ZipOutputStream zos2 = new ZipOutputStream(new BufferedOutputStream(fos));
try {
BufferedInputStream bis2 = new BufferedInputStream(in);
try {
byte[] buffer = new byte[16384];
zos2.putNextEntry(new ZipEntry("classes.dex"));
for (int length = bis2.read(buffer); length != -1; length = bis2.read
(buffer)) {
zos2.write(buffer, 0, length);
}
zos2.closeEntry();
SharePatchFileUtil.closeQuietly(bis2);
SharePatchFileUtil.closeQuietly(zos2);
isExtractionSuccessful = SharePatchFileUtil.verifyDexFileMd5(extractTo,
targetMd5);
TinkerLog.i(TAG, "isExtractionSuccessful: %b", Boolean.valueOf
(isExtractionSuccessful));
if (!isExtractionSuccessful) {
extractTo.delete();
if (extractTo.exists()) {
TinkerLog.e(TAG, "Failed to delete corrupted dex " + extractTo
.getPath(), new Object[0]);
}
}
} catch (Throwable th2) {
th = th2;
bis = bis2;
zos = zos2;
}
} catch (Throwable th3) {
th = th3;
zos = zos2;
}
} catch (Throwable th4) {
th = th4;
}
}
return isExtractionSuccessful;
SharePatchFileUtil.closeQuietly(bis);
SharePatchFileUtil.closeQuietly(zos);
throw th;
}
示例5: extractDexToJar
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
/**
* repack dex to jar
*
* @param zipFile
* @param entryFile
* @param extractTo
* @param targetMd5
* @return boolean
* @throws IOException
*/
private static boolean extractDexToJar(ZipFile zipFile, ZipEntry entryFile, File extractTo, String targetMd5) throws IOException {
int numAttempts = 0;
boolean isExtractionSuccessful = false;
while (numAttempts < MAX_EXTRACT_ATTEMPTS && !isExtractionSuccessful) {
numAttempts++;
FileOutputStream fos = new FileOutputStream(extractTo);
InputStream in = zipFile.getInputStream(entryFile);
ZipOutputStream zos = null;
BufferedInputStream bis = null;
TinkerLog.i(TAG, "try Extracting " + extractTo.getPath());
try {
zos = new ZipOutputStream(new
BufferedOutputStream(fos));
bis = new BufferedInputStream(in);
byte[] buffer = new byte[ShareConstants.BUFFER_SIZE];
ZipEntry entry = new ZipEntry(ShareConstants.DEX_IN_JAR);
zos.putNextEntry(entry);
int length = bis.read(buffer);
while (length != -1) {
zos.write(buffer, 0, length);
length = bis.read(buffer);
}
zos.closeEntry();
} finally {
SharePatchFileUtil.closeQuietly(bis);
SharePatchFileUtil.closeQuietly(zos);
}
isExtractionSuccessful = SharePatchFileUtil.verifyDexFileMd5(extractTo, targetMd5);
TinkerLog.i(TAG, "isExtractionSuccessful: %b", isExtractionSuccessful);
if (!isExtractionSuccessful) {
extractTo.delete();
if (extractTo.exists()) {
TinkerLog.e(TAG, "Failed to delete corrupted dex " + extractTo.getPath());
}
}
}
return isExtractionSuccessful;
}