本文整理汇总了Java中com.tencent.tinker.loader.shareutil.SharePatchFileUtil.safeDeleteFile方法的典型用法代码示例。如果您正苦于以下问题:Java SharePatchFileUtil.safeDeleteFile方法的具体用法?Java SharePatchFileUtil.safeDeleteFile怎么用?Java SharePatchFileUtil.safeDeleteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.tencent.tinker.loader.shareutil.SharePatchFileUtil
的用法示例。
在下文中一共展示了SharePatchFileUtil.safeDeleteFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例3: 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);
}
}
}
示例4: 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;
}
示例5: 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();
}
}
示例6: 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;
}
示例7: 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;
}
示例8: 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());
}
}
示例9: 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);
}
}
示例10: 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);
}
}
示例11: patchDexExtractViaDexDiff
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
private static boolean patchDexExtractViaDexDiff(Context context, String
patchVersionDirectory, String meta, File patchFile, boolean isUpgradePatch) {
String dir = patchVersionDirectory + "/" + ShareConstants.DEX_PATH + "/";
if (extractDexDiffInternals(context, dir, meta, patchFile, ShareTinkerInternals.isVmArt()
? 4 : 3, isUpgradePatch)) {
Tinker manager = Tinker.with(context);
File[] files = new File(dir).listFiles();
if (files != null) {
String optimizeDexDirectory = patchVersionDirectory + "/" + ShareConstants
.DEX_OPTIMIZE_PATH + "/";
File file = new File(optimizeDexDirectory);
if (!file.exists()) {
file.mkdirs();
}
int length = files.length;
int i = 0;
while (i < length) {
File file2 = files[i];
try {
String outputPathName = SharePatchFileUtil.optimizedPathFor(file2, file);
long start = System.currentTimeMillis();
DexFile.loadDex(file2.getAbsolutePath(), outputPathName, 0);
TinkerLog.i(TAG, "success dex optimize file, path: %s, use time: %d",
file2.getPath(), Long.valueOf(System.currentTimeMillis() - start));
i++;
} catch (Throwable e) {
TinkerLog.e(TAG, "dex optimize or load failed, path:" + file2.getPath(),
new Object[0]);
SharePatchFileUtil.safeDeleteFile(file2);
manager.getPatchReporter().onPatchDexOptFail(patchFile, file2,
optimizeDexDirectory, file2.getName(), e, isUpgradePatch);
return false;
}
}
}
return true;
}
TinkerLog.w(TAG, "patch recover, extractDiffInternals fail", new Object[0]);
return false;
}
示例12: onPatchServiceResult
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
public void onPatchServiceResult(boolean isUpgradePatch) {
if (!this.isRetryEnable) {
TinkerLog.w(TAG, "onPatchServiceResult retry disabled, just return", new Object[0]);
} else if (isUpgradePatch) {
if (this.retryInfoFile.exists()) {
SharePatchFileUtil.safeDeleteFile(this.retryInfoFile);
}
if (this.tempPatchFile.exists()) {
SharePatchFileUtil.safeDeleteFile(this.tempPatchFile);
}
} else {
TinkerLog.w(TAG, "onPatchServiceResult is not upgrade patch, just return", new
Object[0]);
}
}
示例13: onPatchServiceStart
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
public void onPatchServiceStart(Intent intent) {
if (!isRetryEnable) {
TinkerLog.w(TAG, "onPatchServiceStart retry disabled, just return");
return;
}
if (intent == null) {
TinkerLog.e(TAG, "onPatchServiceStart intent is null, just return");
return;
}
String path = TinkerPatchService.getPatchPathExtra(intent);
if (path == null) {
TinkerLog.w(TAG, "onPatchServiceStart patch path is null, just return");
return;
}
RetryInfo retryInfo;
File patchFile = new File(path);
String patchMd5 = SharePatchFileUtil.getMD5(patchFile);
if (patchMd5 == null) {
TinkerLog.w(TAG, "onPatchServiceStart patch md5 is null, just return");
return;
}
if (retryInfoFile.exists()) {
retryInfo = RetryInfo.readRetryProperty(retryInfoFile);
if (retryInfo.md5 == null || retryInfo.times == null || !patchMd5.equals(retryInfo.md5)) {
copyToTempFile(patchFile);
retryInfo.md5 = patchMd5;
retryInfo.times = "1";
} else {
int nowTimes = Integer.parseInt(retryInfo.times);
if (nowTimes >= RETRY_MAX_COUNT) {
SharePatchFileUtil.safeDeleteFile(tempPatchFile);
TinkerLog.w(TAG, "onPatchServiceStart retry more than max count, delete retry info file!");
return;
} else {
retryInfo.times = String.valueOf(nowTimes + 1);
}
}
} else {
copyToTempFile(patchFile);
retryInfo = new RetryInfo(patchMd5, "1");
}
RetryInfo.writeRetryProperty(retryInfoFile, retryInfo);
}
示例14: onLoadException
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
/**
* load patch occur unknown exception that we have wrap try catch for you!
* you may need to report this exception and contact me
* welcome to report a new issues for us!
* you can disable patch as {@link DefaultLoadReporter#onLoadException(Throwable, int)}
*
* @param e
* @param errorCode exception code
* {@code ShareConstants.ERROR_LOAD_EXCEPTION_UNKNOWN} unknown exception
* {@code ShareConstants.ERROR_LOAD_EXCEPTION_DEX} exception when load dex
* {@code ShareConstants.ERROR_LOAD_EXCEPTION_RESOURCE} exception when load resource
* {@code ShareConstants.ERROR_LOAD_EXCEPTION_UNCAUGHT} exception unCaught
*/
@Override
public void onLoadException(Throwable e, int errorCode) {
//for unCaught or dex exception, disable tinker all the time with sp
switch (errorCode) {
case ShareConstants.ERROR_LOAD_EXCEPTION_DEX:
if (e.getMessage().contains(ShareConstants.CHECK_DEX_INSTALL_FAIL)) {
TinkerLog.e(TAG, "patch loadReporter onLoadException: tinker dex check fail:" + e.getMessage());
} else {
TinkerLog.i(TAG, "patch loadReporter onLoadException: patch load dex exception: %s", e);
}
ShareTinkerInternals.setTinkerDisableWithSharedPreferences(context);
TinkerLog.i(TAG, "dex exception disable tinker forever with sp");
break;
case ShareConstants.ERROR_LOAD_EXCEPTION_RESOURCE:
if (e.getMessage().contains(ShareConstants.CHECK_RES_INSTALL_FAIL)) {
TinkerLog.e(TAG, "patch loadReporter onLoadException: tinker res check fail:" + e.getMessage());
} else {
TinkerLog.i(TAG, "patch loadReporter onLoadException: patch load resource exception: %s", e);
}
ShareTinkerInternals.setTinkerDisableWithSharedPreferences(context);
TinkerLog.i(TAG, "res exception disable tinker forever with sp");
break;
case ShareConstants.ERROR_LOAD_EXCEPTION_UNCAUGHT:
TinkerLog.i(TAG, "patch loadReporter onLoadException: patch load unCatch exception: %s", e);
ShareTinkerInternals.setTinkerDisableWithSharedPreferences(context);
TinkerLog.i(TAG, "unCaught exception disable tinker forever with sp");
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;
case ShareConstants.ERROR_LOAD_EXCEPTION_UNKNOWN:
TinkerLog.i(TAG, "patch loadReporter onLoadException: patch load unknown exception: %s", e);
//exception can be caught, it is no need to disable Tinker with sharedPreference
break;
}
TinkerLog.e(TAG, "tinker load exception, welcome to submit issue to us: https://github.com/Tencent/tinker/issues");
TinkerLog.printErrStackTrace(TAG, e, "tinker load exception");
Tinker.with(context).setTinkerDisable();
checkAndCleanPatch();
}
示例15: deleteOptFiles
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
private void deleteOptFiles(List<File> dexFiles) {
for (File file : dexFiles) {
SharePatchFileUtil.safeDeleteFile(file);
}
}