com.tencent.tinker.lib.tinker.TinkerInstaller Java Examples
The following examples show how to use
com.tencent.tinker.lib.tinker.TinkerInstaller.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TinkerManager.java From HotFixDemo with MIT License | 6 votes |
/** * 自定义安装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; }
Example #2
Source File: SampleTinkerManager.java From tinker-manager with Apache License 2.0 | 6 votes |
/** * 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; }
Example #3
Source File: SampleApplicationLike.java From tinker-manager with Apache License 2.0 | 6 votes |
/** * 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); }
Example #4
Source File: TinkerManager.java From tinkerpatch-sdk with MIT License | 6 votes |
/** * 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; }
Example #5
Source File: TinkerServerPatchRequestCallback.java From tinkerpatch-sdk with MIT License | 6 votes |
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; }
Example #6
Source File: DefaultPatchRequestCallback.java From tinkerpatch-sdk with MIT License | 6 votes |
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()); } }
Example #7
Source File: TinkerManager.java From HotFixDemo with MIT License | 5 votes |
/** * 默认安装Tinker(使用默认的reporter类:DefaultLoadReporter、DefaultPatchReporter、DefaultPatchListener、DefaultTinkerResultService) * 如果你不需要对监听app打补丁的情况(如:当打补丁失败时上传失败信息),则使用该方法 */ public static void sampleInstallTinker(ApplicationLike appLike) { if (isInstalled) { TinkerLog.w(TAG, "install tinker, but has installed, ignore"); return; } TinkerInstaller.install(appLike); isInstalled = true; }
Example #8
Source File: TinkerApplicationLike.java From HotFixDemo with MIT License | 5 votes |
private void initTinker(Context base) { // tinker需要你开启MultiDex MultiDex.install(base); TinkerManager.setTinkerApplicationLike(this); // 设置全局异常捕获 TinkerManager.initFastCrashProtect(); //开启升级重试功能(在安装Tinker之前设置) TinkerManager.setUpgradeRetryEnable(true); //设置Tinker日志输出类 TinkerInstaller.setLogIml(new MyLogImp()); //安装Tinker(在加载完multiDex之后,否则你需要将com.tencent.tinker.**手动放到main dex中) TinkerManager.installTinker(this); mTinker = Tinker.with(getApplication()); }
Example #9
Source File: SampleLoadReporter.java From tinker-manager with Apache License 2.0 | 5 votes |
/** * 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); }
Example #10
Source File: SampleTinkerManager.java From tinker-manager with Apache License 2.0 | 5 votes |
/** * all use default class, simply Tinker install method */ public static void sampleInstallTinker(ApplicationLike appLike) { if (isInstalled) { TinkerLog.w(TAG, "install com.dx168.patchsdk.sample, but has installed, ignore"); return; } TinkerInstaller.install(appLike); isInstalled = true; }
Example #11
Source File: MainActivity.java From HotFixDemo with MIT License | 4 votes |
public void install_patch(View view) { TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), Environment.getExternalStorageDirectory().getAbsolutePath() + "/patch_signed_7zip.apk"); // TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), getCacheDir().getAbsolutePath() + "/patch_signed_7zip.apk"); }