本文整理汇总了Java中com.tencent.tinker.lib.tinker.TinkerInstaller类的典型用法代码示例。如果您正苦于以下问题:Java TinkerInstaller类的具体用法?Java TinkerInstaller怎么用?Java TinkerInstaller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TinkerInstaller类属于com.tencent.tinker.lib.tinker包,在下文中一共展示了TinkerInstaller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installTinker
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的package包/类
/**
* you can specify all class you want.
* sometimes, you can only install tinker in some process you want!
*
* @param appLike
*/
public static void installTinker(ApplicationLike appLike) {
if (isInstalled) {
TinkerLog.w(TAG, "install tinker, but has installed, ignore");
return;
}
//or you can just use DefaultLoadReporter
LoadReporter loadReporter = new SampleLoadReporter(appLike.getApplication());
//or you can just use DefaultPatchReporter
PatchReporter patchReporter = new SamplePatchReporter(appLike.getApplication());
//or you can just use DefaultPatchListener
PatchListener patchListener = new SamplePatchListener(appLike.getApplication());
//you can set your own upgrade patch if you need
AbstractPatch upgradePatchProcessor = new UpgradePatch();
TinkerInstaller.install(appLike,
loadReporter, patchReporter, patchListener,
SampleResultService.class, upgradePatchProcessor);
isInstalled = true;
}
示例2: onBaseContextAttached
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的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());
}
示例3: onBaseContextAttached
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的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());
}
示例4: retryPatch
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的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;
}
示例5: onBaseContextAttached
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的package包/类
@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();
TinkerManager.setUpgradeRetryEnable(true);
TinkerInstaller.setLogIml(new MyLogImp());
TinkerManager.installTinker(this);
}
示例6: onLoadFileNotFound
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的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();
}
}
示例7: onLoadPatchListenerReceiveFail
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的package包/类
public void onLoadPatchListenerReceiveFail(final File patchFile, int errorCode, boolean
isUpgrade) {
super.onLoadPatchListenerReceiveFail(patchFile, errorCode, isUpgrade);
switch (errorCode) {
case -6:
MobclickAgent.onEvent(MyApplication.getContext(), Event.tinker_error_no_space);
break;
case -3:
if (isUpgrade) {
this.handler.postDelayed(new Runnable() {
public void run() {
TinkerInstaller.onReceiveUpgradePatch(SampleLoadReporter.this
.context, patchFile.getAbsolutePath());
}
}, 60000);
break;
}
break;
case -2:
MobclickAgent.onEvent(MyApplication.getContext(), Event.tinker_error_patch_noexits);
break;
}
SampleTinkerReport.onTryApplyFail(errorCode);
}
示例8: onPatchRetryLoad
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的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();
}
}
示例9: installTinker
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的package包/类
/**
* 自定义安装Tinker(使用你自定义的reporter类:SampleLoadReporter、SamplePatchReporter、SamplePatchListener、SampleResultService)
* you can specify all class you want.
* sometimes, you can only install tinker in some process you want!
*/
public static void installTinker(ApplicationLike appLike) {
if (isInstalled) {
TinkerLog.w(TAG, "install tinker, but has installed, ignore");
return;
}
//or you can just use DefaultLoadReporter
LoadReporter loadReporter = new SampleLoadReporter(appLike.getApplication());
//or you can just use DefaultPatchReporter
PatchReporter patchReporter = new SamplePatchReporter(appLike.getApplication());
//or you can just use DefaultPatchListener
PatchListener patchListener = new SamplePatchListener(appLike.getApplication());
//you can set your own upgrade patch if you need
AbstractPatch upgradePatchProcessor = new UpgradePatch();
TinkerInstaller.install(appLike,
loadReporter, patchReporter, patchListener,
SampleResultService.class, upgradePatchProcessor);
isInstalled = true;
}
示例10: installTinker
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的package包/类
/**
* you can specify all class you want.
* sometimes, you can only install com.dx168.patchsdk.sample in some process you want!
*
* @param appLike
*/
public static void installTinker(ApplicationLike appLike) {
if (isInstalled) {
TinkerLog.w(TAG, "install com.dx168.patchsdk.sample, but has installed, ignore");
return;
}
//or you can just use DefaultLoadReporter
LoadReporter loadReporter = new SampleLoadReporter(appLike.getApplication());
//or you can just use DefaultPatchReporter
PatchReporter patchReporter = new SamplePatchReporter(appLike.getApplication());
//or you can just use DefaultPatchListener
PatchListener patchListener = new SamplePatchListener(appLike.getApplication());
//you can set your own upgrade patch if you need
// AbstractPatch upgradePatchProcessor = new SampleUpgradePatch();
AbstractPatch upgradePatchProcessor = new UpgradePatch();
TinkerInstaller.install(appLike, loadReporter, patchReporter, patchListener, SampleResultService.class,
upgradePatchProcessor);
isInstalled = true;
}
示例11: onBaseContextAttached
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的package包/类
/**
* install multiDex before install com.dx168.patchsdk.sample
* so we don't need to put the com.dx168.patchsdk.sample 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 com.dx168.patchsdk.sample is installed!
MultiDex.install(base);
SampleTinkerManager.setTinkerApplicationLike(this);
SampleTinkerManager.initFastCrashProtect();
//should set before com.dx168.patchsdk.sample is installed
SampleTinkerManager.setUpgradeRetryEnable(true);
//optional set logIml, or you can use default debug log
TinkerInstaller.setLogIml(new SampleTinkerLog());
//installTinker after load multiDex
//or you can put com.tencent.com.dx168.patchsdk.sample.** to main dex
SampleTinkerManager.installTinker(this);
}
示例12: installTinker
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的package包/类
/**
* you can specify all class you want.
* sometimes, you can only install tinker in some process you want!
*
* @param appLike ApplicationLike
*/
public static void installTinker(ApplicationLike appLike) {
if (isInstalled) {
TinkerLog.w(TAG, "install tinker, but has installed, ignore");
return;
}
//or you can just use DefaultLoadReporter
LoadReporter loadReporter = new TinkerServerLoadReporter(appLike.getApplication());
//or you can just use DefaultPatchReporter
PatchReporter patchReporter = new DefaultPatchReporter(appLike.getApplication());
//or you can just use DefaultPatchListener
PatchListener patchListener = new TinkerServerPatchListener(appLike.getApplication());
//you can set your own upgrade patch if you need
AbstractPatch upgradePatchProcessor = new UpgradePatch();
TinkerInstaller.install(appLike,
loadReporter, patchReporter, patchListener,
TinkerServerResultService.class, upgradePatchProcessor
);
isInstalled = true;
}
示例13: handlePatchFile
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的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;
}
示例14: tryPatchFile
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的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());
}
}
示例15: onLoadFileNotFound
import com.tencent.tinker.lib.tinker.TinkerInstaller; //导入依赖的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);
}