当前位置: 首页>>代码示例>>Java>>正文


Java Tinker.getTinkerLoadResultIfPresent方法代码示例

本文整理汇总了Java中com.tencent.tinker.lib.tinker.Tinker.getTinkerLoadResultIfPresent方法的典型用法代码示例。如果您正苦于以下问题:Java Tinker.getTinkerLoadResultIfPresent方法的具体用法?Java Tinker.getTinkerLoadResultIfPresent怎么用?Java Tinker.getTinkerLoadResultIfPresent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.tencent.tinker.lib.tinker.Tinker的用法示例。


在下文中一共展示了Tinker.getTinkerLoadResultIfPresent方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: onLoadFileNotFound

import com.tencent.tinker.lib.tinker.Tinker; //导入方法依赖的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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:SampleLoadReporter.java

示例6: checkIfNeedKill

import com.tencent.tinker.lib.tinker.Tinker; //导入方法依赖的package包/类
public boolean checkIfNeedKill(PatchResult result) {
    Tinker tinker = Tinker.with(getApplicationContext());
    if (tinker.isTinkerLoaded()) {
        TinkerLoadResult tinkerLoadResult = tinker.getTinkerLoadResultIfPresent();
        if (tinkerLoadResult != null) {
            String currentVersion = tinkerLoadResult.currentVersion;
            if (result.patchVersion != null && result.patchVersion.equals(currentVersion)) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:DefaultTinkerResultService.java

示例7: loadLibraryFromTinker

import com.tencent.tinker.lib.tinker.Tinker; //导入方法依赖的package包/类
/**
 * sample usage for native library
 *
 * @param context
 * @param relativePath such as lib/armeabi
 * @param libName      for the lib libTest.so, you can pass Test or libTest, or libTest.so
 * @return boolean
 * @throws UnsatisfiedLinkError
 */
public static boolean loadLibraryFromTinker(Context context, String relativePath, String libName) throws UnsatisfiedLinkError {
    final Tinker tinker = Tinker.with(context);

    libName = libName.startsWith("lib") ? libName : "lib" + libName;
    libName = libName.endsWith(".so") ? libName : libName + ".so";
    String relativeLibPath = relativePath + "/" + libName;

    //TODO we should add cpu abi, and the real path later
    if (tinker.isEnabledForNativeLib() && tinker.isTinkerLoaded()) {
        TinkerLoadResult loadResult = tinker.getTinkerLoadResultIfPresent();
        if (loadResult.libs != null) {
            for (String name : loadResult.libs.keySet()) {
                if (name.equals(relativeLibPath)) {
                    String patchLibraryPath = loadResult.libraryDirectory + "/" + name;
                    File library = new File(patchLibraryPath);
                    if (library.exists()) {
                        //whether we check md5 when load
                        boolean verifyMd5 = tinker.isTinkerLoadVerify();
                        if (verifyMd5 && !SharePatchFileUtil.verifyFileMd5(library, loadResult.libs.get(name))) {
                            tinker.getLoadReporter().onLoadFileMd5Mismatch(library, ShareConstants.TYPE_LIBRARY);
                        } else {
                            System.load(patchLibraryPath);
                            TinkerLog.i(TAG, "loadLibraryFromTinker success:" + patchLibraryPath);
                            return true;
                        }
                    }
                }
            }
        }
    }

    return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:43,代码来源:TinkerLoadLibrary.java

示例8: onLoadFileNotFound

import com.tencent.tinker.lib.tinker.Tinker; //导入方法依赖的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);
}
 
开发者ID:baidao,项目名称:tinker-manager,代码行数:34,代码来源:SampleLoadReporter.java

示例9: beforePatchRequest

import com.tencent.tinker.lib.tinker.Tinker; //导入方法依赖的package包/类
@Override
public boolean beforePatchRequest() {
    boolean result = super.beforePatchRequest();
    if (result) {
        TinkerServerClient client = TinkerServerClient.get();
        Tinker tinker = client.getTinker();
        Context context = client.getContext();

        if (!tinker.isMainProcess()) {
            TinkerLog.e(TAG, "beforePatchRequest, only request on the main process");
            return false;
        }
        if (TinkerServerManager.isGooglePlayChannel()) {
            TinkerLog.e(TAG, "beforePatchRequest, google play channel, return false");
            return false;
        }
        // main process must be the newly version
        // check whether it is pending work
        String currentPatchMd5 = client.getCurrentPatchMd5();
        TinkerLoadResult tinkerLoadResult = tinker.getTinkerLoadResultIfPresent();

        if (tinkerLoadResult.currentVersion == null || !currentPatchMd5.equals(tinkerLoadResult.currentVersion)) {
            Integer version = client.getCurrentPatchVersion();
            if (version > 0) {
                File patchFile = ServerUtils.getServerFile(
                    context, client.getAppVersion(), String.valueOf(version)
                );
                if (patchFile.exists() && patchFile.isFile() && handlePatchFile(context, version, patchFile)) {
                    return false;
                }
            }
        }
    }
    return result;
}
 
开发者ID:TinkerPatch,项目名称:tinkerpatch-sdk,代码行数:36,代码来源:TinkerServerPatchRequestCallback.java

示例10: patchCheck

import com.tencent.tinker.lib.tinker.Tinker; //导入方法依赖的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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:66,代码来源:SamplePatchListener.java

示例11: patchCheck

import com.tencent.tinker.lib.tinker.Tinker; //导入方法依赖的package包/类
protected int patchCheck(String path, String patchMd5) {
    Tinker manager = Tinker.with(context);
    //check SharePreferences also
    if (!manager.isTinkerEnabled() || !ShareTinkerInternals.isTinkerEnableWithSharedPreferences(context)) {
        return ShareConstants.ERROR_PATCH_DISABLE;
    }
    File file = new File(path);

    if (!SharePatchFileUtil.isLegalFile(file)) {
        return ShareConstants.ERROR_PATCH_NOTEXIST;
    }

    //patch service can not send request
    if (manager.isPatchProcess()) {
        return ShareConstants.ERROR_PATCH_INSERVICE;
    }

    //if the patch service is running, pending
    if (TinkerServiceInternals.isTinkerPatchServiceRunning(context)) {
        return ShareConstants.ERROR_PATCH_RUNNING;
    }
    if (ShareTinkerInternals.isVmJit()) {
        return ShareConstants.ERROR_PATCH_JIT;
    }

    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)) {
                return ShareConstants.ERROR_PATCH_ALREADY_APPLY;
            }
        }
    }

    if (!UpgradePatchRetry.getInstance(context).onPatchListenerCheck(patchMd5)) {
        return ShareConstants.ERROR_PATCH_RETRY_COUNT_LIMIT;
    }

    return ShareConstants.ERROR_PATCH_OK;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:44,代码来源:DefaultPatchListener.java

示例12: patchCheck

import com.tencent.tinker.lib.tinker.Tinker; //导入方法依赖的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;
    }
 
开发者ID:xingstarx,项目名称:TinkerDemo,代码行数:66,代码来源:SamplePatchListener.java

示例13: tryPatch

import com.tencent.tinker.lib.tinker.Tinker; //导入方法依赖的package包/类
public boolean tryPatch(Context context, String tempPatchPath, PatchResult patchResult) {
    Tinker manager = Tinker.with(context);
    File patchFile = new File(tempPatchPath);
    if (!manager.isTinkerEnabled() || !ShareTinkerInternals
            .isTinkerEnableWithSharedPreferences(context)) {
        TinkerLog.e(TAG, "RepairPatch tryPatch:patch is disabled, just return", new Object[0]);
        return false;
    } else if (patchFile.isFile() && patchFile.exists()) {
        ShareSecurityCheck signatureCheck = new ShareSecurityCheck(context);
        int returnCode = ShareTinkerInternals.checkSignatureAndTinkerID(context, patchFile,
                signatureCheck);
        if (returnCode != 0) {
            TinkerLog.e(TAG, "RepairPatch tryPatch:onPatchPackageCheckFail", new Object[0]);
            manager.getPatchReporter().onPatchPackageCheckFail(patchFile, false, returnCode);
            return false;
        }
        patchResult.patchTinkerID = signatureCheck.getNewTinkerID();
        patchResult.baseTinkerID = signatureCheck.getTinkerID();
        SharePatchInfo oldInfo = manager.getTinkerLoadResultIfPresent().patchInfo;
        String patchMd5 = SharePatchFileUtil.getMD5(patchFile);
        patchResult.patchVersion = patchMd5;
        if (oldInfo == null) {
            TinkerLog.e(TAG, "OldPatchProcessor tryPatch:onPatchVersionCheckFail, oldInfo is " +
                    "null", new Object[0]);
            manager.getPatchReporter().onPatchVersionCheckFail(patchFile, oldInfo, patchMd5,
                    false);
            return false;
        } else if (oldInfo.oldVersion == null || oldInfo.newVersion == null) {
            TinkerLog.e(TAG, "RepairPatch tryPatch:onPatchInfoCorrupted", new Object[0]);
            manager.getPatchReporter().onPatchInfoCorrupted(patchFile, oldInfo.oldVersion,
                    oldInfo.newVersion, false);
            return false;
        } else if (oldInfo.oldVersion.equals(patchMd5) && oldInfo.newVersion.equals(patchMd5)) {
            String patchDirectory = manager.getPatchDirectory().getAbsolutePath();
            String patchVersionDirectory = patchDirectory + "/" + SharePatchFileUtil
                    .getPatchVersionDirectory(patchMd5);
            if (!DexDiffPatchInternal.tryRecoverDexFiles(manager, signatureCheck, context,
                    patchVersionDirectory, patchFile, false)) {
                TinkerLog.e(TAG, "RepairPatch tryPatch:try patch dex failed", new Object[0]);
                return false;
            } else if (!BsDiffPatchInternal.tryRecoverLibraryFiles(manager, signatureCheck,
                    context, patchVersionDirectory, patchFile, false)) {
                TinkerLog.e(TAG, "RepairPatch tryPatch:try patch library failed", new
                        Object[0]);
                return false;
            } else if (ResDiffPatchInternal.tryRecoverResourceFiles(manager, signatureCheck,
                    context, patchVersionDirectory, patchFile, false)) {
                return true;
            } else {
                TinkerLog.e(TAG, "RepairPatch tryPatch:try patch resource failed", new
                        Object[0]);
                return false;
            }
        } else {
            TinkerLog.e(TAG, "RepairPatch tryPatch:onPatchVersionCheckFail", new Object[0]);
            manager.getPatchReporter().onPatchVersionCheckFail(patchFile, oldInfo, patchMd5,
                    false);
            return false;
        }
    } else {
        TinkerLog.e(TAG, "RepairPatch tryPatch:patch file is not found, just return", new
                Object[0]);
        return false;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:66,代码来源:RepairPatch.java

示例14: patchCheck

import com.tencent.tinker.lib.tinker.Tinker; //导入方法依赖的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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:47,代码来源:SamplePatchListener.java


注:本文中的com.tencent.tinker.lib.tinker.Tinker.getTinkerLoadResultIfPresent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。