本文整理汇总了Java中com.tencent.tinker.loader.shareutil.SharePatchFileUtil类的典型用法代码示例。如果您正苦于以下问题:Java SharePatchFileUtil类的具体用法?Java SharePatchFileUtil怎么用?Java SharePatchFileUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SharePatchFileUtil类属于com.tencent.tinker.loader.shareutil包,在下文中一共展示了SharePatchFileUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onLoadException
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
@Override
public void onLoadException(Throwable e, int errorCode) {
super.onLoadException(e, errorCode);
switch (errorCode) {
case ShareConstants.ERROR_LOAD_EXCEPTION_UNCAUGHT:
String uncaughtString = SharePatchFileUtil.checkTinkerLastUncaughtCrash(context);
if (!ShareTinkerInternals.isNullOrNil(uncaughtString)) {
File laseCrashFile = SharePatchFileUtil.getPatchLastCrashFile(context);
SharePatchFileUtil.safeDeleteFile(laseCrashFile);
// found really crash reason
TinkerLog.e(TAG, "tinker uncaught real exception:" + uncaughtString);
}
break;
}
SampleTinkerReport.onLoadException(e, errorCode);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:SampleLoadReporter.java
示例2: onPatchListenerCheck
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
public boolean onPatchListenerCheck(String md5) {
if (!isRetryEnable) {
TinkerLog.w(TAG, "onPatchListenerCheck retry disabled, just return");
return true;
}
if (!retryInfoFile.exists()) {
TinkerLog.w(TAG, "onPatchListenerCheck retry file is not exist, just return");
return true;
}
if (md5 == null) {
TinkerLog.w(TAG, "onPatchListenerCheck md5 is null, just return");
return true;
}
RetryInfo retryInfo = RetryInfo.readRetryProperty(retryInfoFile);
if (md5.equals(retryInfo.md5)) {
int nowTimes = Integer.parseInt(retryInfo.times);
if (nowTimes >= RETRY_MAX_COUNT) {
TinkerLog.w(TAG, "onPatchListenerCheck, retry count %d must exceed than max retry count", nowTimes);
SharePatchFileUtil.safeDeleteFile(tempPatchFile);
return false;
}
}
return true;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:UpgradePatchRetry.java
示例3: Builder
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
/**
* Start building a new {@link Tinker} instance.
*/
public Builder(Context context) {
if (context == null) {
throw new TinkerRuntimeException("Context must not be null.");
}
this.context = context;
this.mainProcess = TinkerServiceInternals.isInMainProcess(context);
this.patchProcess = TinkerServiceInternals.isInTinkerPatchServiceProcess(context);
this.patchDirectory = SharePatchFileUtil.getPatchDirectory(context);
if (this.patchDirectory == null) {
TinkerLog.e(TAG, "patchDirectory is null!");
return;
}
this.patchInfoFile = SharePatchFileUtil.getPatchInfoFile(patchDirectory.getAbsolutePath());
this.patchInfoLockFile = SharePatchFileUtil.getPatchInfoLockFile(patchDirectory.getAbsolutePath());
TinkerLog.w(TAG, "tinker patch directory: %s", patchDirectory);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:Tinker.java
示例4: retryPatch
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
public boolean retryPatch() {
final Tinker tinker = Tinker.with(context);
if (!tinker.isMainProcess()) {
return false;
}
File patchVersionFile = tinker.getTinkerLoadResultIfPresent().patchVersionFile;
if (patchVersionFile != null) {
if (UpgradePatchRetry.getInstance(context).onPatchListenerCheck(SharePatchFileUtil.getMD5(patchVersionFile))) {
TinkerLog.i(TAG, "try to repair oat file on patch process");
TinkerInstaller.onReceiveUpgradePatch(context, patchVersionFile.getAbsolutePath());
return true;
}
// else {
// TinkerLog.i(TAG, "repair retry exceed must max time, just clean");
// checkAndCleanPatch();
// }
}
return false;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:DefaultLoadReporter.java
示例5: deleteRawPatchFile
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
/**
* don't delete tinker version file
* @param rawFile
*/
public void deleteRawPatchFile(File rawFile) {
if (!SharePatchFileUtil.isLegalFile(rawFile)) {
return;
}
TinkerLog.w(TAG, "deleteRawPatchFile rawFile path: %s", rawFile.getPath());
String fileName = rawFile.getName();
if (!fileName.startsWith(ShareConstants.PATCH_BASE_NAME)
|| !fileName.endsWith(ShareConstants.PATCH_SUFFIX)) {
SharePatchFileUtil.safeDeleteFile(rawFile);
return;
}
File parentFile = rawFile.getParentFile();
if (!parentFile.getName().startsWith(ShareConstants.PATCH_BASE_NAME)) {
SharePatchFileUtil.safeDeleteFile(rawFile);
} else {
File grandFile = parentFile.getParentFile();
if (!grandFile.getName().equals(ShareConstants.PATCH_DIRECTORY_NAME)) {
SharePatchFileUtil.safeDeleteFile(rawFile);
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:DefaultTinkerResultService.java
示例6: onPatchListenerCheck
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
public boolean onPatchListenerCheck(String md5) {
if (!isRetryEnable) {
TinkerLog.w(TAG, "onPatchListenerCheck retry disabled, just return");
return true;
}
if (!retryInfoFile.exists()) {
TinkerLog.w(TAG, "onPatchListenerCheck retry file is not exist, just return");
return true;
}
if (md5 == null) {
TinkerLog.w(TAG, "onPatchListenerCheck md5 is null, just return");
return true;
}
RetryInfo retryInfo = RetryInfo.readRetryProperty(retryInfoFile);
if (md5.equals(retryInfo.md5)) {
int nowTimes = Integer.parseInt(retryInfo.times);
if (nowTimes >= maxRetryCount) {
TinkerLog.w(TAG, "onPatchListenerCheck, retry count %d must exceed than max retry count", nowTimes);
SharePatchFileUtil.safeDeleteFile(tempPatchFile);
return false;
}
}
return true;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:UpgradePatchRetry.java
示例7: Builder
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
public Builder(Context context) {
if (context == null) {
throw new TinkerRuntimeException("Context must not be null.");
}
this.context = context;
this.mainProcess = ShareTinkerInternals.isInMainProcess(context);
this.patchProcess = TinkerServiceInternals.isInTinkerPatchServiceProcess(context);
this.patchDirectory = SharePatchFileUtil.getPatchDirectory(context);
if (this.patchDirectory == null) {
TinkerLog.e(Tinker.TAG, "patchDirectory is null!", new Object[0]);
return;
}
this.patchInfoFile = SharePatchFileUtil.getPatchInfoFile(this.patchDirectory
.getAbsolutePath());
TinkerLog.w(Tinker.TAG, "tinker patch directory: %s", this.patchDirectory);
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:Tinker.java
示例8: onLoadPatchVersionChanged
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
public void onLoadPatchVersionChanged(String oldVersion, String newVersion, File
patchDirectoryFile, String currentPatchName) {
int i = 0;
TinkerLog.i(TAG, "patch version change from " + oldVersion + " to " + newVersion, new
Object[0]);
if (oldVersion != null && newVersion != null && !oldVersion.equals(newVersion) && Tinker
.with(this.context).isMainProcess()) {
TinkerLog.i(TAG, "try kill all other process", new Object[0]);
ShareTinkerInternals.killAllOtherProcess(this.context);
File[] files = patchDirectoryFile.listFiles();
if (files != null) {
int length = files.length;
while (i < length) {
File file = files[i];
String name = file.getName();
if (file.isDirectory() && !name.equals(currentPatchName)) {
SharePatchFileUtil.deleteDir(file);
}
i++;
}
}
}
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:DefaultLoadReporter.java
示例9: onPatchResult
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
public void onPatchResult(PatchResult result) {
if (result == null) {
TinkerLog.e(TAG, "DefaultTinkerResultService received null result!!!!", new Object[0]);
return;
}
TinkerLog.i(TAG, "DefaultTinkerResultService received a result:%s ", result.toString());
TinkerServiceInternals.killTinkerPatchServiceProcess(getApplicationContext());
if (result.isSuccess && result.isUpgradePatch) {
File rawFile = new File(result.rawPatchFilePath);
if (rawFile.exists()) {
TinkerLog.i(TAG, "save delete raw patch file", new Object[0]);
SharePatchFileUtil.safeDeleteFile(rawFile);
}
if (checkIfNeedKill(result)) {
Process.killProcess(Process.myPid());
} else {
TinkerLog.i(TAG, "I have already install the newly patch version!", new Object[0]);
}
}
if (!result.isSuccess && !result.isUpgradePatch) {
Tinker.with(getApplicationContext()).cleanPatch();
}
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:DefaultTinkerResultService.java
示例10: extractDexToJar
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
private static void extractDexToJar(File dex) throws IOException {
FileOutputStream fos = new FileOutputStream(dex + ".jar");
InputStream in = new FileInputStream(dex);
ZipOutputStream zos = null;
BufferedInputStream bis = null;
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);
}
}
开发者ID:baidao,项目名称:tinker-manager,代码行数:27,代码来源:SampleUpgradePatch.java
示例11: handlePatchFile
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
private boolean handlePatchFile(Context context, Integer version, File patchFile) {
SharedPreferences sp = context.getSharedPreferences(
TinkerServerClient.SHARE_SERVER_PREFERENCE_CONFIG, Context.MODE_PRIVATE
);
int current = sp.getInt(TINKER_RETRY_PATCH, 0);
if (current >= TINKER_MAX_RETRY_COUNT) {
SharePatchFileUtil.safeDeleteFile(patchFile);
sp.edit().putInt(TINKER_RETRY_PATCH, 0).commit();
TinkerLog.w(TAG,
"beforePatchRequest, retry patch install more than %d times, version: %d, patch:%s",
current, version, patchFile.getPath()
);
} else {
TinkerLog.w(TAG, "beforePatchRequest, have pending patch to install, version: %d, patch:%s",
version, patchFile.getPath()
);
sp.edit().putInt(TINKER_RETRY_PATCH, ++current).commit();
TinkerInstaller.onReceiveUpgradePatch(context, patchFile.getAbsolutePath());
return true;
}
return false;
}
开发者ID:TinkerPatch,项目名称:tinkerpatch-sdk,代码行数:24,代码来源:TinkerServerPatchRequestCallback.java
示例12: readVersionProperty
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
private void readVersionProperty() {
if (versionFile == null || !versionFile.exists() || versionFile.length() == 0) {
return;
}
Properties properties = new Properties();
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(versionFile);
properties.load(inputStream);
uuid = properties.getProperty(UUID_VALUE);
appVersion = properties.getProperty(APP_VERSION);
grayValue = ServerUtils.stringToInteger(properties.getProperty(GRAY_VALUE));
patchVersion = ServerUtils.stringToInteger(properties.getProperty(CURRENT_VERSION));
patchMd5 = properties.getProperty(CURRENT_MD5);
} catch (IOException e) {
TinkerLog.e(TAG, "readVersionProperty exception:" + e);
} finally {
SharePatchFileUtil.closeQuietly(inputStream);
}
}
开发者ID:TinkerPatch,项目名称:tinkerpatch-sdk,代码行数:23,代码来源:VersionUtils.java
示例13: onPatchUpgrade
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
@Override
public boolean onPatchUpgrade(File file, Integer newVersion, Integer currentVersion) {
TinkerLog.i(TAG, "onPatchUpgrade, file:%s, newVersion:%d, currentVersion:%d",
file.getPath(), newVersion, currentVersion);
TinkerServerClient client = TinkerServerClient.get();
Context context = client.getContext();
client.reportPatchDownloadSuccess(newVersion);
ShareSecurityCheck securityCheck = new ShareSecurityCheck(context);
if (!securityCheck.verifyPatchMetaSignature(file)) {
TinkerLog.e(TAG, "onPatchUpgrade, signature check fail. file: %s, version:%d", file.getPath(), newVersion);
//treat it as download fail
if (increaseDownloadError(context)) {
//update tinker version also, don't request again
client.updateTinkerVersion(newVersion, SharePatchFileUtil.getMD5(file));
client.reportPatchFail(newVersion, ERROR_DOWNLOAD_CHECK_FAIL);
}
SharePatchFileUtil.safeDeleteFile(file);
return false;
}
tryPatchFile(file, newVersion);
return true;
}
开发者ID:TinkerPatch,项目名称:tinkerpatch-sdk,代码行数:24,代码来源:DefaultPatchRequestCallback.java
示例14: tryPatchFile
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
private void tryPatchFile(File patchFile, Integer newVersion) {
TinkerServerClient client = TinkerServerClient.get();
Context context = client.getContext();
//In order to calculate the user number, just report success here
String patchMd5 = SharePatchFileUtil.getMD5(patchFile);
//update version
client.updateTinkerVersion(newVersion, patchMd5);
//delete old patch sever file
File serverDir = ServerUtils.getServerDirectory(context);
if (serverDir != null) {
File[] files = serverDir.listFiles();
if (files != null) {
String currentName = patchFile.getName();
for (File file : files) {
String fileName = file.getName();
if (fileName.equals(currentName) || fileName.equals(ServerUtils.TINKER_VERSION_FILE)) {
continue;
}
SharePatchFileUtil.safeDeleteFile(file);
}
}
client.reportPatchApplySuccess(newVersion);
//try install
TinkerInstaller.onReceiveUpgradePatch(context, patchFile.getAbsolutePath());
}
}
开发者ID:TinkerPatch,项目名称:tinkerpatch-sdk,代码行数:27,代码来源:DefaultPatchRequestCallback.java
示例15: onLoadFileNotFound
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
/**
* try to recover patch oat file
* @param file
* @param fileType
* @param isDirectory
*/
@Override
public void onLoadFileNotFound(File file, int fileType, boolean isDirectory) {
TinkerLog.i(TAG, "patch loadReporter onLoadFileNotFound: patch file not found: %s, fileType:%d, isDirectory:%b",
file.getAbsolutePath(), fileType, isDirectory);
// only try to recover opt file
// check dex opt file at last, some phone such as VIVO/OPPO like to change dex2oat to interpreted
if (fileType == ShareConstants.TYPE_DEX_OPT) {
Tinker tinker = Tinker.with(context);
//we can recover at any process except recover process
if (tinker.isMainProcess()) {
File patchVersionFile = tinker.getTinkerLoadResultIfPresent().patchVersionFile;
if (patchVersionFile != null) {
if (UpgradePatchRetry.getInstance(context).onPatchListenerCheck(SharePatchFileUtil.getMD5(patchVersionFile))) {
TinkerLog.i(TAG, "try to repair oat file on patch process");
TinkerInstaller.onReceiveUpgradePatch(context, patchVersionFile.getAbsolutePath());
} else {
TinkerLog.i(TAG, "repair retry exceed must max time, just clean");
checkAndCleanPatch();
}
}
}
} else {
checkAndCleanPatch();
}
SampleTinkerReport.onLoadFileNotFound(fileType);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:SampleLoadReporter.java
示例16: onPatchServiceResult
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
/**
* if we receive any result, we can delete the temp retry info file
*/
public void onPatchServiceResult() {
if (!isRetryEnable) {
TinkerLog.w(TAG, "onPatchServiceResult retry disabled, just return");
return;
}
//delete temp patch file
if (tempPatchFile.exists()) {
SharePatchFileUtil.safeDeleteFile(tempPatchFile);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:UpgradePatchRetry.java
示例17: copyToTempFile
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
private void copyToTempFile(File patchFile) {
if (patchFile.getAbsolutePath().equals(tempPatchFile.getAbsolutePath())) {
return;
}
TinkerLog.w(TAG, "try copy file: %s to %s", patchFile.getAbsolutePath(), tempPatchFile.getAbsolutePath());
try {
SharePatchFileUtil.copyFileUsingStream(patchFile, tempPatchFile);
} catch (IOException e) {
TinkerLog.e(TAG, "fail to copy file: %s to %s", patchFile.getAbsolutePath(), tempPatchFile.getAbsolutePath());
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:UpgradePatchRetry.java
示例18: patchCheck
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
/**
* because we use the defaultCheckPatchReceived method
* the error code define by myself should after {@code ShareConstants.ERROR_RECOVER_INSERVICE
*
* @param path
* @param newPatch
* @return
*/
@Override
public int patchCheck(String path, String patchMd5) {
File patchFile = new File(path);
TinkerLog.i(TAG, "receive a patch file: %s, file size:%d", path, SharePatchFileUtil.getFileOrDirectorySize(patchFile));
int returnCode = super.patchCheck(path, patchMd5);
if (returnCode == ShareConstants.ERROR_PATCH_OK) {
returnCode = Utils.checkForPatchRecover(NEW_PATCH_RESTRICTION_SPACE_SIZE_MIN, maxMemory);
}
if (returnCode == ShareConstants.ERROR_PATCH_OK) {
SharedPreferences sp = context.getSharedPreferences(ShareConstants.TINKER_SHARE_PREFERENCE_CONFIG, Context.MODE_MULTI_PROCESS);
//optional, only disable this patch file with md5
int fastCrashCount = sp.getInt(patchMd5, 0);
if (fastCrashCount >= SampleUncaughtExceptionHandler.MAX_CRASH_COUNT) {
returnCode = Utils.ERROR_PATCH_CRASH_LIMIT;
}
}
// Warning, it is just a sample case, you don't need to copy all of these
// Interception some of the request
if (returnCode == ShareConstants.ERROR_PATCH_OK) {
Properties properties = ShareTinkerInternals.fastGetPatchPackageMeta(patchFile);
if (properties == null) {
returnCode = Utils.ERROR_PATCH_CONDITION_NOT_SATISFIED;
} else {
String platform = properties.getProperty(Utils.PLATFORM);
TinkerLog.i(TAG, "get platform:" + platform);
// check patch platform require
if (platform == null || !platform.equals(BuildInfo.PLATFORM)) {
returnCode = Utils.ERROR_PATCH_CONDITION_NOT_SATISFIED;
}
}
}
SampleTinkerReport.onTryApply(returnCode == ShareConstants.ERROR_PATCH_OK);
return returnCode;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:46,代码来源:SamplePatchListener.java
示例19: run
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
public boolean run() {
try {
if (!SharePatchFileUtil.isLegalFile(dexFile)) {
if (callback != null) {
callback.onFailed(dexFile, optimizedDir,
new IOException("dex file " + dexFile.getAbsolutePath() + " is not exist!"));
return false;
}
}
if (callback != null) {
callback.onStart(dexFile, optimizedDir);
}
String optimizedPath = SharePatchFileUtil.optimizedPathFor(this.dexFile, this.optimizedDir);
if (useInterpretMode) {
interpretDex2Oat(dexFile.getAbsolutePath(), optimizedPath);
} else {
DexFile.loadDex(dexFile.getAbsolutePath(), optimizedPath, 0);
}
if (callback != null) {
callback.onSuccess(dexFile, optimizedDir, new File(optimizedPath));
}
} catch (final Throwable e) {
Log.e(TAG, "Failed to optimize dex: " + dexFile.getAbsolutePath(), e);
if (callback != null) {
callback.onFailed(dexFile, optimizedDir, e);
return false;
}
}
return true;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:TinkerDexOptimizer.java
示例20: deleteOutOfDateOATFile
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入依赖的package包/类
private static void deleteOutOfDateOATFile(String directory) {
String optimizeDexDirectory = directory + "/" + DEFAULT_DEX_OPTIMIZE_PATH + "/";
SharePatchFileUtil.deleteDir(optimizeDexDirectory);
// delete android o
if (ShareTinkerInternals.isAfterAndroidO()) {
String androidODexDirectory = directory + "/" + ShareConstants.ANDROID_O_DEX_OPTIMIZE_PATH + "/";
SharePatchFileUtil.deleteDir(androidODexDirectory);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:TinkerDexLoader.java
注:本文中的com.tencent.tinker.loader.shareutil.SharePatchFileUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论