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


Java SharePatchFileUtil.isLegalFile方法代码示例

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


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

示例1: deleteRawPatchFile

import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
/**
 * don't delete tinker version file
 * @param rawFile
 */
public void deleteRawPatchFile(File rawFile) {
    if (!SharePatchFileUtil.isLegalFile(rawFile)) {
        return;
    }
    TinkerLog.w(TAG, "deleteRawPatchFile rawFile path: %s", rawFile.getPath());
    String fileName = rawFile.getName();
    if (!fileName.startsWith(ShareConstants.PATCH_BASE_NAME)
        || !fileName.endsWith(ShareConstants.PATCH_SUFFIX)) {
        SharePatchFileUtil.safeDeleteFile(rawFile);
        return;
    }
    File parentFile = rawFile.getParentFile();
    if (!parentFile.getName().startsWith(ShareConstants.PATCH_BASE_NAME)) {
        SharePatchFileUtil.safeDeleteFile(rawFile);
    } else {
        File grandFile = parentFile.getParentFile();
        if (!grandFile.getName().equals(ShareConstants.PATCH_DIRECTORY_NAME)) {
            SharePatchFileUtil.safeDeleteFile(rawFile);
        }
    }

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:DefaultTinkerResultService.java

示例2: run

import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
public boolean run() {
    try {
        if (!SharePatchFileUtil.isLegalFile(dexFile)) {
            if (callback != null) {
                callback.onFailed(dexFile, optimizedDir,
                    new IOException("dex file " + dexFile.getAbsolutePath() + " is not exist!"));
                return false;
            }
        }
        if (callback != null) {
            callback.onStart(dexFile, optimizedDir);
        }
        String optimizedPath = SharePatchFileUtil.optimizedPathFor(this.dexFile, this.optimizedDir);
        if (useInterpretMode) {
            interpretDex2Oat(dexFile.getAbsolutePath(), optimizedPath);
        } else {
            DexFile.loadDex(dexFile.getAbsolutePath(), optimizedPath, 0);
        }
        if (callback != null) {
            callback.onSuccess(dexFile, optimizedDir, new File(optimizedPath));
        }
    } catch (final Throwable e) {
        Log.e(TAG, "Failed to optimize dex: " + dexFile.getAbsolutePath(), e);
        if (callback != null) {
            callback.onFailed(dexFile, optimizedDir, e);
            return false;
        }
    }
    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:TinkerDexOptimizer.java

示例3: checkAllDexOptFile

import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
/**
 * for ViVo or some other rom, they would make dex2oat asynchronous
 * so we need to check whether oat file is actually generated.
 *
 * @param files
 * @param count
 * @return
 */
private static boolean checkAllDexOptFile(ArrayList<File> files, int count) {
    for (File file : files) {
        if (!SharePatchFileUtil.isLegalFile(file)) {
            TinkerLog.e(TAG, "parallel dex optimizer file %s is not exist, just wait %d times", file.getName(), count);
            return false;
        }
    }
    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:DexDiffPatchInternal.java

示例4: waitDexOptFile

import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
public static boolean waitDexOptFile() {
        if (optFiles.isEmpty()) {
            return true;
        }

        int size = optFiles.size() * 6;
        if (size > MAX_WAIT_COUNT) {
            size = MAX_WAIT_COUNT;
        }
        TinkerLog.i(TAG, "dex count: %d, final wait time: %d", optFiles.size(), size);

        for (int i = 0; i < size; i++) {
            if (!checkAllDexOptFile(optFiles, i + 1)) {
                try {
                    Thread.sleep(WAIT_ASYN_OAT_TIME);
                } catch (InterruptedException e) {
                    TinkerLog.e(TAG, "thread sleep InterruptedException e:" + e);
                }
            }
        }

        // check again, if still can be found, just return
        for (File file : optFiles) {
            TinkerLog.i(TAG, "check dex optimizer file %s, size %d", file.getName(), file.length());

            if (!SharePatchFileUtil.isLegalFile(file)) {
                TinkerLog.e(TAG, "final parallel dex optimizer file %s is not exist, return false", file.getName());
                // don't report fail
//                manager.getPatchReporter()
//                    .onPatchDexOptFail(patchFile, file, file.getParentFile().getPath(),
//                        file.getName(), new TinkerRuntimeException("dexOpt file:" + file.getName() + " is not exist"));
                return false;

            }
        }
        return true;
    }
 
开发者ID:baidao,项目名称:tinker-manager,代码行数:38,代码来源:SampleDexDiffPatchInternal.java

示例5: checkAllDexOptFile

import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
/**
 * for ViVo or some other rom, they would make dex2oat asynchronous
 * so we need to check whether oat file is actually generated.
 * @param files
 * @param count
 * @return
 */
private static boolean checkAllDexOptFile(ArrayList<File> files, int count) {
    for (File file : files) {
        if (!SharePatchFileUtil.isLegalFile(file)) {
            TinkerLog.e(TAG, "parallel dex optimizer file %s is not exist, just wait %d times", file.getName(), count);
            return false;
        }
    }
    return true;
}
 
开发者ID:baidao,项目名称:tinker-manager,代码行数:17,代码来源:SampleDexDiffPatchInternal.java

示例6: checkComplete

import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
/**
 * resource file exist?
 * fast check, only check whether exist
 *
 * @param directory
 * @return boolean
 */
public static boolean checkComplete(Context context, String directory, ShareSecurityCheck securityCheck, Intent intentResult) {
    String meta = securityCheck.getMetaContentMap().get(RESOURCE_META_FILE);
    //not found resource
    if (meta == null) {
        return true;
    }
    //only parse first line for faster
    ShareResPatchInfo.parseResPatchInfoFirstLine(meta, resPatchInfo);

    if (resPatchInfo.resArscMd5 == null) {
        return true;
    }
    if (!ShareResPatchInfo.checkResPatchInfo(resPatchInfo)) {
        intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_PACKAGE_PATCH_CHECK, ShareConstants.ERROR_PACKAGE_CHECK_RESOURCE_META_CORRUPTED);
        ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_PACKAGE_CHECK_FAIL);
        return false;
    }
    String resourcePath = directory + "/" + RESOURCE_PATH + "/";

    File resourceDir = new File(resourcePath);

    if (!resourceDir.exists() || !resourceDir.isDirectory()) {
        ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_VERSION_RESOURCE_DIRECTORY_NOT_EXIST);
        return false;
    }

    File resourceFile = new File(resourcePath + RESOURCE_FILE);
    if (!SharePatchFileUtil.isLegalFile(resourceFile)) {
        ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_VERSION_RESOURCE_FILE_NOT_EXIST);
        return false;
    }
    try {
        TinkerResourcePatcher.isResourceCanPatch(context);
    } catch (Throwable e) {
        Log.e(TAG, "resource hook check failed.", e);
        intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_EXCEPTION, e);
        ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_VERSION_RESOURCE_LOAD_EXCEPTION);
        return false;
    }
    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:49,代码来源:TinkerResourceLoader.java

示例7: checkComplete

import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的package包/类
/**
 * all the library files in meta file exist?
 * fast check, only check whether exist
 *
 * @param directory
 * @return boolean
 */
public static boolean checkComplete(String directory, ShareSecurityCheck securityCheck, Intent intentResult) {
    String meta = securityCheck.getMetaContentMap().get(SO_MEAT_FILE);
    //not found lib
    if (meta == null) {
        return true;
    }
    ArrayList<ShareBsDiffPatchInfo> libraryList = new ArrayList<>();
    ShareBsDiffPatchInfo.parseDiffPatchInfo(meta, libraryList);

    if (libraryList.isEmpty()) {
        return true;
    }

    //tinker//patch-641e634c/lib
    String libraryPath = directory + "/" + SO_PATH + "/";

    HashMap<String, String> libs = new HashMap<>();

    for (ShareBsDiffPatchInfo info : libraryList) {
        if (!ShareBsDiffPatchInfo.checkDiffPatchInfo(info)) {
            intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_PACKAGE_PATCH_CHECK, ShareConstants.ERROR_PACKAGE_CHECK_LIB_META_CORRUPTED);
            ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_PACKAGE_CHECK_FAIL);
            return false;
        }
        String middle = info.path + "/" + info.name;

        //unlike dex, keep the original structure
        libs.put(middle, info.md5);
    }

    File libraryDir = new File(libraryPath);

    if (!libraryDir.exists() || !libraryDir.isDirectory()) {
        ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_VERSION_LIB_DIRECTORY_NOT_EXIST);
        return false;
    }

    //fast check whether there is any dex files missing
    for (String relative : libs.keySet()) {
        File libFile = new File(libraryPath + relative);
        if (!SharePatchFileUtil.isLegalFile(libFile)) {
            ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_VERSION_LIB_FILE_NOT_EXIST);
            intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_MISSING_LIB_PATH, libFile.getAbsolutePath());
            return false;
        }
    }

    //if is ok, add to result intent
    intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_LIBS_PATH, libs);
    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:59,代码来源:TinkerSoLoader.java

示例8: patchCheck

import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; //导入方法依赖的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


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