当前位置: 首页>>代码示例>>Java>>正文


Java SharePatchFileUtil.verifyDexFileMd5方法代码示例

本文整理汇总了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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:BasePatchInternal.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:37,代码来源:BasePatchInternal.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:52,代码来源:TinkerDexLoader.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:56,代码来源:DexDiffPatchInternal.java

示例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;
}
 
开发者ID:baidao,项目名称:tinker-manager,代码行数:55,代码来源:SampleDexDiffPatchInternal.java


注:本文中的com.tencent.tinker.loader.shareutil.SharePatchFileUtil.verifyDexFileMd5方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。