本文整理汇总了Java中com.tencent.tinker.lib.util.TinkerLog.i方法的典型用法代码示例。如果您正苦于以下问题:Java TinkerLog.i方法的具体用法?Java TinkerLog.i怎么用?Java TinkerLog.i使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.tencent.tinker.lib.util.TinkerLog
的用法示例。
在下文中一共展示了TinkerLog.i方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installNavitveLibraryABI
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的package包/类
/**
* you can reflect your current abi to classloader library path
* as you don't need to use load*Library method above
* @param context
* @param currentABI
*/
public static void installNavitveLibraryABI(Context context, String currentABI) {
Tinker tinker = Tinker.with(context);
if (!tinker.isTinkerLoaded()) {
TinkerLog.i(TAG, "tinker is not loaded, just return");
return;
}
TinkerLoadResult loadResult = tinker.getTinkerLoadResultIfPresent();
if (loadResult.libs == null) {
TinkerLog.i(TAG, "tinker libs is null, just return");
return;
}
File soDir = new File(loadResult.libraryDirectory, "lib/" + currentABI);
if (!soDir.exists()) {
TinkerLog.e(TAG, "current libraryABI folder is not exist, path: %s", soDir.getPath());
return;
}
ClassLoader classLoader = context.getClassLoader();
if (classLoader == null) {
TinkerLog.e(TAG, "classloader is null");
return;
}
TinkerLog.i(TAG, "before hack classloader:" + classLoader.toString());
try {
installNativeLibraryPath(classLoader, soDir);
} catch (Throwable throwable) {
TinkerLog.e(TAG, "installNativeLibraryPath fail:" + throwable);
}
TinkerLog.i(TAG, "after hack classloader:" + classLoader.toString());
}
示例2: tryRecoverResourceFiles
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的package包/类
protected static boolean tryRecoverResourceFiles(Tinker manager, ShareSecurityCheck checker,
Context context, String
patchVersionDirectory, File
patchFile, boolean isUpgradePatch) {
if (manager.isEnabledForResource()) {
String resourceMeta = (String) checker.getMetaContentMap().get(ShareConstants
.RES_META_FILE);
if (resourceMeta == null || resourceMeta.length() == 0) {
TinkerLog.w(TAG, "patch recover, resource is not contained", new Object[0]);
return true;
}
long begin = SystemClock.elapsedRealtime();
long cost = SystemClock.elapsedRealtime() - begin;
TinkerLog.i(TAG, "recover resource result:%b, cost:%d, isNewPatch:%b", Boolean
.valueOf(patchResourceExtractViaResourceDiff(context, patchVersionDirectory,
resourceMeta, patchFile, isUpgradePatch)), Long.valueOf(cost),
Boolean.valueOf(isUpgradePatch));
return patchResourceExtractViaResourceDiff(context, patchVersionDirectory,
resourceMeta, patchFile, isUpgradePatch);
}
TinkerLog.w(TAG, "patch recover, resource is not enabled", new Object[0]);
return true;
}
示例3: onPatchDexOptFail
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的package包/类
/**
* dex opt failed
*
* @param patchFile the input patch file to recover
* @param dexFiles the dex files
* @param t
*/
@Override
public void onPatchDexOptFail(File patchFile, List<File> dexFiles, Throwable t) {
TinkerLog.i(TAG, "patchReporter onPatchDexOptFail: dex opt fail path: %s, dex size: %d",
patchFile.getAbsolutePath(), dexFiles.size());
TinkerLog.printErrStackTrace(TAG, t, "onPatchDexOptFail:");
// some phone such as VIVO/OPPO like to change dex2oat to interpreted may go here
// check oat file if it is elf format
if (t.getMessage().contains(ShareConstants.CHECK_DEX_OAT_EXIST_FAIL)
|| t.getMessage().contains(ShareConstants.CHECK_DEX_OAT_FORMAT_FAIL)) {
shouldRetry = true;
deleteOptFiles(dexFiles);
} else {
Tinker.with(context).cleanPatchByVersion(patchFile);
}
}
示例4: onPatchServiceStart
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的package包/类
/**
* use for report or some work at the beginning of TinkerPatchService
* {@code TinkerPatchService.onHandleIntent} begin
*
* @param intent
*/
@Override
public void onPatchServiceStart(Intent intent) {
TinkerLog.i(TAG, "patchReporter onPatchServiceStart: patch service start");
shouldRetry = false;
UpgradePatchRetry.getInstance(context).onPatchServiceStart(intent);
}
示例5: extract
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的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;
}
示例6: onPatchResult
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的package包/类
public void onPatchResult(final PatchResult result) {
if (result == null) {
TinkerLog.e(TAG, "SampleResultService received null result!!!!", new Object[0]);
return;
}
TinkerLog.i(TAG, "SampleResultService receive result: %s", result.toString());
TinkerServiceInternals.killTinkerPatchServiceProcess(getApplicationContext());
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
if (result.isSuccess) {
MobclickAgent.onEvent(MyApplication.getContext(), Event.tinker_combine_success);
Helper.showLog(OneTinkerResultService.TAG, "patch success, please restart " +
"process");
return;
}
MobclickAgent.onEvent(MyApplication.getContext(), Event.tinker_combine_failed);
Helper.showLog(OneTinkerResultService.TAG, "patch fail, please check reason");
}
});
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)) {
TinkerLog.i(TAG, "I have already install the newly patch version!", new Object[0]);
} else if (Utils.isBackground()) {
TinkerLog.i(TAG, "it is in background, just restart process", new Object[0]);
restartProcess();
} else {
TinkerLog.i(TAG, "tinker wait screen to restart process", new Object[0]);
ScreenState screenState = new ScreenState(getApplicationContext(), new
IOnScreenOff() {
public void onScreenOff() {
OneTinkerResultService.this.restartProcess();
}
});
}
}
if (!result.isSuccess && !result.isUpgradePatch) {
Tinker.with(getApplicationContext()).cleanPatch();
}
}
示例7: onLoadPatchListenerReceiveFail
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的package包/类
public void onLoadPatchListenerReceiveFail(File patchFile, int errorCode, boolean isUpgrade) {
TinkerLog.i(TAG, "patch load Reporter: patch receive fail:%s, code:%d, isUpgrade:%b",
patchFile.getAbsolutePath(), Integer.valueOf(errorCode), Boolean.valueOf
(isUpgrade));
}
示例8: patchCheck
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的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) {
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);
if (returnCode == ShareConstants.ERROR_PATCH_OK) {
returnCode = Utils.checkForPatchRecover(NEW_PATCH_RESTRICTION_SPACE_SIZE_MIN, maxMemory);
}
if (returnCode == ShareConstants.ERROR_PATCH_OK) {
String patchMd5 = SharePatchFileUtil.getMD5(patchFile);
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;
} else {
//for upgrade patch, version must be not the same
//for repair patch, we won't has the tinker load flag
Tinker tinker = Tinker.with(context);
if (tinker.isTinkerLoaded()) {
TinkerLoadResult tinkerLoadResult = tinker.getTinkerLoadResultIfPresent();
if (tinkerLoadResult != null) {
String currentVersion = tinkerLoadResult.currentVersion;
if (patchMd5.equals(currentVersion)) {
returnCode = Utils.ERROR_PATCH_ALREADY_APPLY;
}
}
}
}
//check whether retry so many times
if (returnCode == ShareConstants.ERROR_PATCH_OK) {
returnCode = UpgradePatchRetry.getInstance(context).onPatchListenerCheck(patchMd5)
? ShareConstants.ERROR_PATCH_OK : Utils.ERROR_PATCH_RETRY_COUNT_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) {
returnCode = Utils.ERROR_PATCH_CONDITION_NOT_SATISFIED;
}
}
}
SampleTinkerReport.onTryApply(returnCode == ShareConstants.ERROR_PATCH_OK);
return returnCode;
}
示例9: onPatchResult
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的package包/类
@Override
public void onPatchResult(final PatchResult result) {
if (result == null) {
TinkerLog.e(TAG, "SampleResultService received null result!!!!");
return;
}
TinkerLog.i(TAG, "SampleResultService receive result: %s", result.toString());
//first, we want to kill the recover process
TinkerServiceInternals.killTinkerPatchServiceProcess(getApplicationContext());
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
if (result.isSuccess) {
Toast.makeText(getApplicationContext(), "patch success, please restart process", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "patch fail, please check reason", Toast.LENGTH_LONG).show();
}
}
});
// is success and newPatch, it is nice to delete the raw file, and restart at once
// for old patch, you can't delete the patch file
if (result.isSuccess) {
deleteRawPatchFile(new File(result.rawPatchFilePath));
//not like TinkerResultService, I want to restart just when I am at background!
//if you have not install tinker this moment, you can use TinkerApplicationHelper api
if (checkIfNeedKill(result)) {
if (Utils.isBackground()) {
TinkerLog.i(TAG, "it is in background, just restart process");
restartProcess();
} else {
//we can wait process at background, such as onAppBackground
//or we can restart when the screen off
TinkerLog.i(TAG, "tinker wait screen to restart process");
new ScreenState(getApplicationContext(), new ScreenState.IOnScreenOff() {
@Override
public void onScreenOff() {
restartProcess();
}
});
}
} else {
TinkerLog.i(TAG, "I have already install the newly patch version!");
}
}
}
示例10: SamplePatchListener
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的package包/类
public SamplePatchListener(Context context) {
super(context);
this.maxMemory = ((ActivityManager) context.getSystemService(ModelName.ACTIVITY))
.getMemoryClass();
TinkerLog.i(TAG, "application maxMemory:" + this.maxMemory, new Object[0]);
}
示例11: patchCheck
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的package包/类
public int patchCheck(String path, boolean isUpgrade) {
File patchFile = new File(path);
TinkerLog.i(TAG, "receive a patch file: %s, isUpgrade:%b, file size:%d", path, Boolean
.valueOf(isUpgrade), Long.valueOf(SharePatchFileUtil.getFileOrDirectorySize
(patchFile)));
int returnCode = super.patchCheck(path, isUpgrade);
if (returnCode == 0) {
if (isUpgrade) {
returnCode = Utils.checkForPatchRecover(NEW_PATCH_RESTRICTION_SPACE_SIZE_MIN,
this.maxMemory);
} else {
returnCode = Utils.checkForPatchRecover(OLD_PATCH_RESTRICTION_SPACE_SIZE_MIN,
this.maxMemory);
}
}
if (returnCode == 0) {
String patchMd5 = SharePatchFileUtil.getMD5(patchFile);
if (this.context.getSharedPreferences(ShareConstants.TINKER_SHARE_PREFERENCE_CONFIG,
4).getInt(patchMd5, 0) >= 3) {
returnCode = -9;
} else {
Tinker tinker = Tinker.with(this.context);
if (tinker.isTinkerLoaded()) {
TinkerLoadResult tinkerLoadResult = tinker.getTinkerLoadResultIfPresent();
if (tinkerLoadResult != null && patchMd5.equals(tinkerLoadResult
.currentVersion)) {
returnCode = -8;
}
}
}
}
if (returnCode == 0) {
Properties properties = ShareTinkerInternals.fastGetPatchPackageMeta(patchFile);
if (properties == null) {
returnCode = -10;
} else {
String platform = properties.getProperty("platform");
TinkerLog.i(TAG, "get platform:" + platform, new Object[0]);
if (platform == null || !platform.equals(BuildInfo.PLATFORM)) {
returnCode = -10;
}
}
}
SampleTinkerReport.onTryApply(isUpgrade, returnCode == 0);
return returnCode;
}
示例12: onApplied
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的package包/类
public static void onApplied(boolean isUpgrade, long cost, boolean success) {
if (reporter != null) {
if (success) {
reporter.onReport(5);
}
if (isUpgrade) {
if (success) {
reporter.onReport(101);
} else {
reporter.onReport(103);
}
} else if (success) {
reporter.onReport(100);
} else {
reporter.onReport(102);
}
TinkerLog.i(TAG, "hp_report report apply cost = %d", Long.valueOf(cost));
if (cost < 0) {
TinkerLog.e(TAG, "hp_report report apply cost failed, invalid cost", new Object[0]);
} else if (cost <= 5000) {
if (success) {
reporter.onReport(200);
} else {
reporter.onReport(205);
}
} else if (cost <= 10000) {
if (success) {
reporter.onReport(201);
} else {
reporter.onReport(206);
}
} else if (cost <= 30000) {
if (success) {
reporter.onReport(202);
} else {
reporter.onReport(207);
}
} else if (cost <= 60000) {
if (success) {
reporter.onReport(203);
} else {
reporter.onReport(208);
}
} else if (success) {
reporter.onReport(204);
} else {
reporter.onReport(209);
}
}
}
示例13: patchCheck
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的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) {
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);
if (returnCode == ShareConstants.ERROR_PATCH_OK) {
returnCode = Utils.checkForPatchRecover(NEW_PATCH_RESTRICTION_SPACE_SIZE_MIN, maxMemory);
}
if (returnCode == ShareConstants.ERROR_PATCH_OK) {
String patchMd5 = SharePatchFileUtil.getMD5(patchFile);
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;
} else {
//for upgrade patch, version must be not the same
//for repair patch, we won't has the tinker load flag
Tinker tinker = Tinker.with(context);
if (tinker.isTinkerLoaded()) {
TinkerLoadResult tinkerLoadResult = tinker.getTinkerLoadResultIfPresent();
if (tinkerLoadResult != null && !tinkerLoadResult.useInterpretMode) {
String currentVersion = tinkerLoadResult.currentVersion;
if (patchMd5.equals(currentVersion)) {
returnCode = Utils.ERROR_PATCH_ALREADY_APPLY;
}
}
}
}
//check whether retry so many times
if (returnCode == ShareConstants.ERROR_PATCH_OK) {
returnCode = UpgradePatchRetry.getInstance(context).onPatchListenerCheck(patchMd5)
? ShareConstants.ERROR_PATCH_OK : Utils.ERROR_PATCH_RETRY_COUNT_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;
}
示例14: loadLibraryFromTinker
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的package包/类
public static boolean loadLibraryFromTinker(ApplicationLike applicationLike, String
relativePath, String libname) throws UnsatisfiedLinkError {
if (!libname.startsWith(ShareConstants.SO_PATH)) {
libname = ShareConstants.SO_PATH + libname;
}
if (!libname.endsWith(".so")) {
libname = libname + ".so";
}
String relativeLibPath = relativePath + "/" + libname;
if (isTinkerEnableForNativeLib(applicationLike) && isTinkerLoadSuccess(applicationLike)) {
HashMap<String, String> loadLibraries = getLoadLibraryAndMd5(applicationLike);
if (loadLibraries != null) {
String currentVersion = getCurrentVersion(applicationLike);
if (ShareTinkerInternals.isNullOrNil(currentVersion)) {
return false;
}
File patchDirectory = SharePatchFileUtil.getPatchDirectory(applicationLike
.getApplication());
if (patchDirectory == null) {
return false;
}
String libPrePath = new File(patchDirectory.getAbsolutePath() + "/" +
SharePatchFileUtil.getPatchVersionDirectory(currentVersion))
.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()) {
continue;
} else if (!applicationLike.getTinkerLoadVerifyFlag() ||
SharePatchFileUtil.verifyFileMd5(library, (String) loadLibraries
.get(name))) {
System.load(patchLibraryPath);
TinkerLog.i(TAG, "loadLibraryFromTinker success:" + patchLibraryPath,
new Object[0]);
return true;
} else {
TinkerLog.i(TAG, "loadLibraryFromTinker md5mismatch fail:" +
patchLibraryPath, new Object[0]);
}
}
}
}
}
return false;
}
示例15: onPatchInfoCorrupted
import com.tencent.tinker.lib.util.TinkerLog; //导入方法依赖的package包/类
public void onPatchInfoCorrupted(File patchFile, String oldVersion, String newVersion,
boolean isUpgradePatch) {
TinkerLog.i(TAG, "patchReporter: patch info is corrupted. old:%s, new:%s, isUpgradeP:%b",
oldVersion, newVersion, Boolean.valueOf(isUpgradePatch));
Tinker.with(this.context).cleanPatch();
}