本文整理汇总了Java中com.tencent.tinker.lib.tinker.Tinker类的典型用法代码示例。如果您正苦于以下问题:Java Tinker类的具体用法?Java Tinker怎么用?Java Tinker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tinker类属于com.tencent.tinker.lib.tinker包,在下文中一共展示了Tinker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onBaseContextAttached
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
/**
* install multiDex before install tinker
* so we don't need to put the tinker lib classes in the main dex
*
* @param base
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
public void onBaseContextAttached(Context base) {
super.onBaseContextAttached(base);
sContext = getApplication();
//you must install multiDex whatever tinker is installed!
MultiDex.install(base);
TinkerManager.setTinkerApplicationLike(this);
TinkerManager.initFastCrashProtect();
//should set before tinker is installed
TinkerManager.setUpgradeRetryEnable(true);
//optional set logIml, or you can use default debug log
TinkerInstaller.setLogIml(new MyLogImp());
//installTinker after load multiDex
//or you can put com.tencent.tinker.** to main dex
TinkerManager.installTinker(this);
Tinker tinker = Tinker.with(getApplication());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:AndroidApplication.java
示例2: onBaseContextAttached
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
/**
* install multiDex before install tinker
* so we don't need to put the tinker lib classes in the main dex
*
* @param base
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
public void onBaseContextAttached(Context base) {
super.onBaseContextAttached(base);
//you must install multiDex whatever tinker is installed!
MultiDex.install(base);
SampleApplicationContext.application = getApplication();
SampleApplicationContext.context = getApplication();
TinkerManager.setTinkerApplicationLike(this);
TinkerManager.initFastCrashProtect();
//should set before tinker is installed
TinkerManager.setUpgradeRetryEnable(true);
//optional set logIml, or you can use default debug log
TinkerInstaller.setLogIml(new MyLogImp());
//installTinker after load multiDex
//or you can put com.tencent.tinker.** to main dex
TinkerManager.installTinker(this);
Tinker tinker = Tinker.with(getApplication());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:SampleApplicationLike.java
示例3: tryRecoverDexFiles
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
protected static boolean tryRecoverDexFiles(Tinker manager, ShareSecurityCheck checker, Context context,
String patchVersionDirectory, File patchFile) {
if (!manager.isEnabledForDex()) {
TinkerLog.w(TAG, "patch recover, dex is not enabled");
return true;
}
String dexMeta = checker.getMetaContentMap().get(DEX_META_FILE);
if (dexMeta == null) {
TinkerLog.w(TAG, "patch recover, dex is not contained");
return true;
}
long begin = SystemClock.elapsedRealtime();
boolean result = patchDexExtractViaDexDiff(context, patchVersionDirectory, dexMeta, patchFile);
long cost = SystemClock.elapsedRealtime() - begin;
TinkerLog.i(TAG, "recover dex result:%b, cost:%d", result, cost);
return result;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:DexDiffPatchInternal.java
示例4: tryRecoverResourceFiles
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
protected static boolean tryRecoverResourceFiles(Tinker manager, ShareSecurityCheck checker, Context context,
String patchVersionDirectory, File patchFile) {
if (!manager.isEnabledForResource()) {
TinkerLog.w(TAG, "patch recover, resource is not enabled");
return true;
}
String resourceMeta = checker.getMetaContentMap().get(RES_META_FILE);
if (resourceMeta == null || resourceMeta.length() == 0) {
TinkerLog.w(TAG, "patch recover, resource is not contained");
return true;
}
long begin = SystemClock.elapsedRealtime();
boolean result = patchResourceExtractViaResourceDiff(context, patchVersionDirectory, resourceMeta, patchFile);
long cost = SystemClock.elapsedRealtime() - begin;
TinkerLog.i(TAG, "recover resource result:%b, cost:%d", result, cost);
return result;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:ResDiffPatchInternal.java
示例5: tryRecoverLibraryFiles
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
protected static boolean tryRecoverLibraryFiles(Tinker manager, ShareSecurityCheck checker, Context context,
String patchVersionDirectory, File patchFile) {
if (!manager.isEnabledForNativeLib()) {
TinkerLog.w(TAG, "patch recover, library is not enabled");
return true;
}
String libMeta = checker.getMetaContentMap().get(SO_META_FILE);
if (libMeta == null) {
TinkerLog.w(TAG, "patch recover, library is not contained");
return true;
}
long begin = SystemClock.elapsedRealtime();
boolean result = patchLibraryExtractViaBsDiff(context, patchVersionDirectory, libMeta, patchFile);
long cost = SystemClock.elapsedRealtime() - begin;
TinkerLog.i(TAG, "recover lib result:%b, cost:%d", result, cost);
return result;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:BsDiffPatchInternal.java
示例6: checkAndCleanPatch
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
/**
* other process may have installed old patch version,
* if we try to clean patch, we should kill other process first
*/
public void checkAndCleanPatch() {
Tinker tinker = Tinker.with(context);
//only main process can load a new patch
if (tinker.isMainProcess()) {
TinkerLoadResult tinkerLoadResult = tinker.getTinkerLoadResultIfPresent();
//if versionChange and the old patch version is not ""
if (tinkerLoadResult.versionChanged) {
SharePatchInfo sharePatchInfo = tinkerLoadResult.patchInfo;
if (sharePatchInfo != null && !ShareTinkerInternals.isNullOrNil(sharePatchInfo.oldVersion)) {
TinkerLog.w(TAG, "checkAndCleanPatch, oldVersion %s is not null, try kill all other process",
sharePatchInfo.oldVersion);
ShareTinkerInternals.killAllOtherProcess(context);
}
}
}
tinker.cleanPatch();
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:DefaultLoadReporter.java
示例7: retryPatch
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的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
示例8: onPatchDexOptFail
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的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);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:DefaultPatchReporter.java
示例9: onPatchException
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
/**
* recover 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!
*
* @param patchFile the input file to patch
* @param e
*/
@Override
public void onPatchException(File patchFile, Throwable e) {
TinkerLog.i(TAG, "patchReporter onPatchException: patch exception path: %s, throwable: %s",
patchFile.getAbsolutePath(), e.getMessage());
TinkerLog.e(TAG, "tinker patch exception, welcome to submit issue to us: https://github.com/Tencent/tinker/issues");
// if (e.getMessage().contains(ShareConstants.CHECK_VM_PROPERTY_FAIL)) {
// ShareTinkerInternals.setTinkerDisableWithSharedPreferences(context);
// TinkerLog.i(TAG, "check vm property exception disable tinker forever with sp");
// }
TinkerLog.printErrStackTrace(TAG, e, "tinker patch exception");
//don't accept request any more!
Tinker.with(context).setTinkerDisable();
////delete temp files, I think we don't have to clean all patch
Tinker.with(context).cleanPatchByVersion(patchFile);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:DefaultPatchReporter.java
示例10: installNavitveLibraryABI
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的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());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:TinkerLoadLibrary.java
示例11: tryRecoverDexFiles
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
protected static boolean tryRecoverDexFiles(Tinker manager, ShareSecurityCheck checker,
Context context, String patchVersionDirectory,
File patchFile, boolean isUpgradePatch) {
if (manager.isEnabledForDex()) {
String dexMeta = (String) checker.getMetaContentMap().get(ShareConstants.DEX_META_FILE);
if (dexMeta == null) {
TinkerLog.w(TAG, "patch recover, dex is not contained", new Object[0]);
return true;
}
long begin = SystemClock.elapsedRealtime();
long cost = SystemClock.elapsedRealtime() - begin;
TinkerLog.i(TAG, "recover dex result:%b, cost:%d, isUpgradePatch:%b", Boolean.valueOf
(patchDexExtractViaDexDiff(context, patchVersionDirectory, dexMeta,
patchFile, isUpgradePatch)), Long.valueOf(cost), Boolean.valueOf
(isUpgradePatch));
return patchDexExtractViaDexDiff(context, patchVersionDirectory, dexMeta, patchFile,
isUpgradePatch);
}
TinkerLog.w(TAG, "patch recover, dex is not enabled", new Object[0]);
return true;
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:DexDiffPatchInternal.java
示例12: tryRecoverResourceFiles
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的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;
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:ResDiffPatchInternal.java
示例13: tryRecoverLibraryFiles
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
protected static boolean tryRecoverLibraryFiles(Tinker manager, ShareSecurityCheck checker,
Context context, String
patchVersionDirectory, File
patchFile, boolean isUpgradePatch) {
if (manager.isEnabledForNativeLib()) {
String libMeta = (String) checker.getMetaContentMap().get(ShareConstants.SO_META_FILE);
if (libMeta == null) {
TinkerLog.w(TAG, "patch recover, library is not contained", new Object[0]);
return true;
}
long begin = SystemClock.elapsedRealtime();
long cost = SystemClock.elapsedRealtime() - begin;
TinkerLog.i(TAG, "recover lib result:%b, cost:%d, isUpgradePatch:%b", Boolean.valueOf
(patchLibraryExtractViaBsDiff(context, patchVersionDirectory, libMeta,
patchFile, isUpgradePatch)), Long.valueOf(cost), Boolean.valueOf
(isUpgradePatch));
return patchLibraryExtractViaBsDiff(context, patchVersionDirectory, libMeta,
patchFile, isUpgradePatch);
}
TinkerLog.w(TAG, "patch recover, library is not enabled", new Object[0]);
return true;
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:BsDiffPatchInternal.java
示例14: onLoadPatchVersionChanged
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的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
示例15: onLoadFileNotFound
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
public void onLoadFileNotFound(File file, int fileType, boolean isDirectory) {
TinkerLog.i(TAG, "patch file not found: %s, fileType:%d, isDirectory:%b", file
.getAbsolutePath(), Integer.valueOf(fileType), Boolean.valueOf(isDirectory));
if (fileType == 3 || fileType == 5 || fileType == 6 || fileType == 7) {
Tinker tinker = Tinker.with(this.context);
if (!tinker.isPatchProcess()) {
File patchVersionFile = tinker.getTinkerLoadResultIfPresent().patchVersionFile;
if (patchVersionFile != null) {
TinkerInstaller.onReceiveRepairPatch(this.context, patchVersionFile
.getAbsolutePath());
}
}
} else if (fileType == 1 || fileType == 2) {
Tinker.with(this.context).cleanPatch();
}
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:DefaultLoadReporter.java
示例16: patchCheck
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
protected int patchCheck(String path, boolean isUpgrade) {
Tinker manager = Tinker.with(this.context);
if (!manager.isTinkerEnabled() || !ShareTinkerInternals
.isTinkerEnableWithSharedPreferences(this.context)) {
return -1;
}
File file = new File(path);
if (!file.isFile() || !file.exists() || file.length() == 0) {
return -2;
}
if (manager.isPatchProcess()) {
return -4;
}
if (TinkerServiceInternals.isTinkerPatchServiceRunning(this.context)) {
return -3;
}
return 0;
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:DefaultPatchListener.java
示例17: onPatchResult
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的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
示例18: onPatchRetryLoad
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
public void onPatchRetryLoad() {
if (!this.isRetryEnable) {
TinkerLog.w(TAG, "onPatchRetryLoad retry disabled, just return", new Object[0]);
} else if (!Tinker.with(this.context).isMainProcess()) {
TinkerLog.w(TAG, "onPatchRetryLoad retry is not main process, just return", new
Object[0]);
} else if (!this.retryInfoFile.exists()) {
TinkerLog.w(TAG, "onPatchRetryLoad retry info not exist, just return", new Object[0]);
} else if (TinkerServiceInternals.isTinkerPatchServiceRunning(this.context)) {
TinkerLog.w(TAG, "onPatchRetryLoad tinker service is running, just return", new
Object[0]);
} else {
String path = this.tempPatchFile.getAbsolutePath();
if (path == null || !new File(path).exists()) {
TinkerLog.w(TAG, "onPatchRetryLoad patch file: %s is not exist, just return", path);
return;
}
TinkerLog.w(TAG, "onPatchRetryLoad patch file: %s is exist, retry to patch", path);
TinkerInstaller.onReceiveUpgradePatch(this.context, path);
SampleTinkerReport.onReportRetryPatch();
}
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:UpgradePatchRetry.java
示例19: tryRecoverDexFiles
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
public static boolean tryRecoverDexFiles(Tinker manager, ShareSecurityCheck checker, Context context,
String patchVersionDirectory, File patchFile) {
if (!manager.isEnabledForDex()) {
TinkerLog.w(TAG, "patch recover, dex is not enabled");
return true;
}
String dexMeta = checker.getMetaContentMap().get(DEX_META_FILE);
if (dexMeta == null) {
TinkerLog.w(TAG, "patch recover, dex is not contained");
return true;
}
long begin = SystemClock.elapsedRealtime();
boolean result = patchDexExtractViaDexDiff(context, patchVersionDirectory, dexMeta, patchFile);
long cost = SystemClock.elapsedRealtime() - begin;
TinkerLog.i(TAG, "recover dex result:%b, cost:%d", result, cost);
return result;
}
开发者ID:baidao,项目名称:tinker-manager,代码行数:20,代码来源:SampleDexDiffPatchInternal.java
示例20: tryRecoverLibraryFiles
import com.tencent.tinker.lib.tinker.Tinker; //导入依赖的package包/类
public static boolean tryRecoverLibraryFiles(Tinker manager, ShareSecurityCheck checker, Context context,
String patchVersionDirectory, File patchFile) {
if (!manager.isEnabledForNativeLib()) {
TinkerLog.w(TAG, "patch recover, library is not enabled");
return true;
}
String libMeta = checker.getMetaContentMap().get(SO_META_FILE);
if (libMeta == null) {
TinkerLog.w(TAG, "patch recover, library is not contained");
return true;
}
long begin = SystemClock.elapsedRealtime();
boolean result = patchLibraryExtractViaBsDiff(context, patchVersionDirectory, libMeta, patchFile);
long cost = SystemClock.elapsedRealtime() - begin;
TinkerLog.i(TAG, "recover lib result:%b, cost:%d", result, cost);
return result;
}
开发者ID:baidao,项目名称:tinker-manager,代码行数:20,代码来源:SampleBsDiffPatchInternal.java
注:本文中的com.tencent.tinker.lib.tinker.Tinker类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论