本文整理汇总了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);
}
示例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;
}
示例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;
}
}