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


Java SharePatchFileUtil.getPatchVersionDirectory方法代码示例

本文整理汇总了Java中com.tencent.tinker.loader.shareutil.SharePatchFileUtil.getPatchVersionDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java SharePatchFileUtil.getPatchVersionDirectory方法的具体用法?Java SharePatchFileUtil.getPatchVersionDirectory怎么用?Java SharePatchFileUtil.getPatchVersionDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.tencent.tinker.loader.shareutil.SharePatchFileUtil的用法示例。


在下文中一共展示了SharePatchFileUtil.getPatchVersionDirectory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cleanPatchByVersion

import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
/**
 * try delete the temp version files
 *
 * @param patchFile
 */
public void cleanPatchByVersion(File patchFile) {
    if (patchDirectory == null || patchFile == null || !patchFile.exists()) {
        return;
    }
    String versionName = SharePatchFileUtil.getPatchVersionDirectory(SharePatchFileUtil.getMD5(patchFile));
    cleanPatchByVersion(versionName);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:Tinker.java

示例2: loadLibraryFromTinker

import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
/**
 * you can use these api to load tinker library without tinker is installed!
 * same as {@code TinkerInstaller#loadLibraryFromTinker}
 *
 * @param applicationLike
 * @param relativePath
 * @param libname
 * @return
 * @throws UnsatisfiedLinkError
 */
public static boolean loadLibraryFromTinker(ApplicationLike applicationLike, String relativePath, String libname) throws UnsatisfiedLinkError {
    libname = libname.startsWith("lib") ? libname : "lib" + libname;
    libname = libname.endsWith(".so") ? libname : libname + ".so";
    String relativeLibPath = relativePath + "/" + libname;

    //TODO we should add cpu abi, and the real path later
    if (TinkerApplicationHelper.isTinkerEnableForNativeLib(applicationLike)
        && TinkerApplicationHelper.isTinkerLoadSuccess(applicationLike)) {
        HashMap<String, String> loadLibraries = TinkerApplicationHelper.getLoadLibraryAndMd5(applicationLike);
        if (loadLibraries != null) {
            String currentVersion = TinkerApplicationHelper.getCurrentVersion(applicationLike);
            if (ShareTinkerInternals.isNullOrNil(currentVersion)) {
                return false;
            }
            File patchDirectory = SharePatchFileUtil.getPatchDirectory(applicationLike.getApplication());
            if (patchDirectory == null) {
                return false;
            }
            File patchVersionDirectory = new File(patchDirectory.getAbsolutePath() + "/" + SharePatchFileUtil.getPatchVersionDirectory(currentVersion));
            String libPrePath = patchVersionDirectory.getAbsolutePath() + "/" + ShareConstants.SO_PATH;

            for (String name : loadLibraries.keySet()) {
                if (name.equals(relativeLibPath)) {
                    String patchLibraryPath = libPrePath + "/" + name;
                    File library = new File(patchLibraryPath);
                    if (library.exists()) {
                        //whether we check md5 when load
                        boolean verifyMd5 = applicationLike.getTinkerLoadVerifyFlag();
                        if (verifyMd5 && !SharePatchFileUtil.verifyFileMd5(library, loadLibraries.get(name))) {
                            //do not report, because tinker is not install
                            TinkerLog.i(TAG, "loadLibraryFromTinker md5mismatch fail:" + patchLibraryPath);
                        } else {
                            System.load(patchLibraryPath);
                            TinkerLog.i(TAG, "loadLibraryFromTinker success:" + patchLibraryPath);
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:54,代码来源:TinkerApplicationHelper.java

示例3: tryPatch

import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
public boolean tryPatch(Context context, String tempPatchPath, PatchResult patchResult) {
    Tinker manager = Tinker.with(context);
    File patchFile = new File(tempPatchPath);
    if (!manager.isTinkerEnabled() || !ShareTinkerInternals
            .isTinkerEnableWithSharedPreferences(context)) {
        TinkerLog.e(TAG, "RepairPatch tryPatch:patch is disabled, just return", new Object[0]);
        return false;
    } else if (patchFile.isFile() && patchFile.exists()) {
        ShareSecurityCheck signatureCheck = new ShareSecurityCheck(context);
        int returnCode = ShareTinkerInternals.checkSignatureAndTinkerID(context, patchFile,
                signatureCheck);
        if (returnCode != 0) {
            TinkerLog.e(TAG, "RepairPatch tryPatch:onPatchPackageCheckFail", new Object[0]);
            manager.getPatchReporter().onPatchPackageCheckFail(patchFile, false, returnCode);
            return false;
        }
        patchResult.patchTinkerID = signatureCheck.getNewTinkerID();
        patchResult.baseTinkerID = signatureCheck.getTinkerID();
        SharePatchInfo oldInfo = manager.getTinkerLoadResultIfPresent().patchInfo;
        String patchMd5 = SharePatchFileUtil.getMD5(patchFile);
        patchResult.patchVersion = patchMd5;
        if (oldInfo == null) {
            TinkerLog.e(TAG, "OldPatchProcessor tryPatch:onPatchVersionCheckFail, oldInfo is " +
                    "null", new Object[0]);
            manager.getPatchReporter().onPatchVersionCheckFail(patchFile, oldInfo, patchMd5,
                    false);
            return false;
        } else if (oldInfo.oldVersion == null || oldInfo.newVersion == null) {
            TinkerLog.e(TAG, "RepairPatch tryPatch:onPatchInfoCorrupted", new Object[0]);
            manager.getPatchReporter().onPatchInfoCorrupted(patchFile, oldInfo.oldVersion,
                    oldInfo.newVersion, false);
            return false;
        } else if (oldInfo.oldVersion.equals(patchMd5) && oldInfo.newVersion.equals(patchMd5)) {
            String patchDirectory = manager.getPatchDirectory().getAbsolutePath();
            String patchVersionDirectory = patchDirectory + "/" + SharePatchFileUtil
                    .getPatchVersionDirectory(patchMd5);
            if (!DexDiffPatchInternal.tryRecoverDexFiles(manager, signatureCheck, context,
                    patchVersionDirectory, patchFile, false)) {
                TinkerLog.e(TAG, "RepairPatch tryPatch:try patch dex failed", new Object[0]);
                return false;
            } else if (!BsDiffPatchInternal.tryRecoverLibraryFiles(manager, signatureCheck,
                    context, patchVersionDirectory, patchFile, false)) {
                TinkerLog.e(TAG, "RepairPatch tryPatch:try patch library failed", new
                        Object[0]);
                return false;
            } else if (ResDiffPatchInternal.tryRecoverResourceFiles(manager, signatureCheck,
                    context, patchVersionDirectory, patchFile, false)) {
                return true;
            } else {
                TinkerLog.e(TAG, "RepairPatch tryPatch:try patch resource failed", new
                        Object[0]);
                return false;
            }
        } else {
            TinkerLog.e(TAG, "RepairPatch tryPatch:onPatchVersionCheckFail", new Object[0]);
            manager.getPatchReporter().onPatchVersionCheckFail(patchFile, oldInfo, patchMd5,
                    false);
            return false;
        }
    } else {
        TinkerLog.e(TAG, "RepairPatch tryPatch:patch file is not found, just return", new
                Object[0]);
        return false;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:66,代码来源:RepairPatch.java


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