Java Code Examples for com.tencent.tinker.loader.shareutil.ShareConstants#ERROR_PATCH_OK
The following examples show how to use
com.tencent.tinker.loader.shareutil.ShareConstants#ERROR_PATCH_OK .
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: TinkerServerManager.java From tinkerpatch-sdk with MIT License | 6 votes |
/** * 上报补丁合成情况 * @param patchMd5 */ public static void reportTinkerPatchListenerFail(int returnCode, String patchMd5) { if (sTinkerServerClient == null) { TinkerLog.e(TAG, "reportTinkerPatchListenerFail, sTinkerServerClient == null"); return; } if (returnCode == ShareConstants.ERROR_PATCH_OK) { return; } if (patchMd5 == null) { TinkerLog.e(TAG, "reportTinkerPatchListenerFail, patchMd5 == null"); return; } if (!patchMd5.equals(sTinkerServerClient.getCurrentPatchMd5())) { TinkerLog.e(TAG, "reportTinkerPatchListenerFail, md5 not equal, patchMd5:%s, currentPatchMd5:%s", patchMd5, sTinkerServerClient.getCurrentPatchMd5() ); return; } sTinkerServerClient.reportPatchFail( sTinkerServerClient.getCurrentPatchVersion(), DefaultPatchRequestCallback.ERROR_LISTENER_CHECK_FAIL ); }
Example 2
Source File: SamplePatchListener.java From HotFixDemo with MIT License | 5 votes |
/** * 若检查成功,我们会调用TinkerPatchService.runPatchService唤起:patch进程,去尝试完成补丁合成操作。反之,会回调检验失败的接口。 * 若检查失败,会在LoadReporter的onLoadPatchListenerReceiveFail中回调。 * <p> * 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, String patchMd5) { 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, patchMd5); if (returnCode == ShareConstants.ERROR_PATCH_OK) { returnCode = TinkerUtils.checkForPatchRecover(NEW_PATCH_RESTRICTION_SPACE_SIZE_MIN, maxMemory); } if (returnCode == ShareConstants.ERROR_PATCH_OK) { 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 = TinkerUtils.ERROR_PATCH_CRASH_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 = TinkerUtils.ERROR_PATCH_CONDITION_NOT_SATISFIED; } else { String platform = properties.getProperty(TinkerUtils.PLATFORM); TinkerLog.i(TAG, "get platform:" + platform); // check patch platform require if (platform == null || !platform.equals("all")) { returnCode = TinkerUtils.ERROR_PATCH_CONDITION_NOT_SATISFIED; } } } SampleTinkerReport.onTryApply(returnCode == ShareConstants.ERROR_PATCH_OK); return returnCode; }
Example 3
Source File: TinkerUtils.java From HotFixDemo with MIT License | 5 votes |
/** * 判断当前是否非GP渠道,且空间足够 */ public static int checkForPatchRecover(long roomSize, int maxMemory) { if (TinkerUtils.isGooglePlay()) { return TinkerUtils.ERROR_PATCH_GOOGLEPLAY_CHANNEL; } if (maxMemory < MIN_MEMORY_HEAP_SIZE) { return TinkerUtils.ERROR_PATCH_MEMORY_LIMIT; } //or you can mention user to clean their rom space! if (!checkRomSpaceEnough(roomSize)) { return TinkerUtils.ERROR_PATCH_ROM_SPACE; } return ShareConstants.ERROR_PATCH_OK; }
Example 4
Source File: SamplePatchListener.java From tinker-manager with Apache License 2.0 | 5 votes |
/** * 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, String patchMd5) { 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, patchMd5); if (returnCode == ShareConstants.ERROR_PATCH_OK) { returnCode = SampleUtils.checkForPatchRecover(NEW_PATCH_RESTRICTION_SPACE_SIZE_MIN, maxMemory); } if (returnCode == ShareConstants.ERROR_PATCH_OK) { 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 = SampleUtils.ERROR_PATCH_CRASH_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 = SampleUtils.ERROR_PATCH_CONDITION_NOT_SATISFIED; } else { String platform = properties.getProperty(SampleUtils.PLATFORM); TinkerLog.i(TAG, "get platform:" + platform); // check patch platform require if (platform == null) { returnCode = SampleUtils.ERROR_PATCH_CONDITION_NOT_SATISFIED; } } } SampleTinkerReport.onTryApply(returnCode == ShareConstants.ERROR_PATCH_OK); return returnCode; }
Example 5
Source File: SamplePatchListener.java From tinker-manager with Apache License 2.0 | 5 votes |
@Override public int onPatchReceived(String path) { path = PatchUtils.release(path); int returnCode = patchCheck(path, SharePatchFileUtil.getMD5(new File(path))); if (returnCode == ShareConstants.ERROR_PATCH_OK) { SamplePatchService.runPatchService(context, path); } else { Tinker.with(context).getLoadReporter().onLoadPatchListenerReceiveFail(new File(path), returnCode); } return returnCode; }
Example 6
Source File: SampleUtils.java From tinker-manager with Apache License 2.0 | 5 votes |
public static int checkForPatchRecover(long roomSize, int maxMemory) { if (SampleUtils.isGooglePlay()) { return SampleUtils.ERROR_PATCH_GOOGLEPLAY_CHANNEL; } if (maxMemory < MIN_MEMORY_HEAP_SIZE) { return SampleUtils.ERROR_PATCH_MEMORY_LIMIT; } //or you can mention user to clean their rom space! if (!checkRomSpaceEnough(roomSize)) { return SampleUtils.ERROR_PATCH_ROM_SPACE; } return ShareConstants.ERROR_PATCH_OK; }