Search in sources :

Example 21 with Tinker

use of com.tencent.tinker.lib.tinker.Tinker in project tinker by Tencent.

the class SampleLoadReporter method onLoadFileNotFound.

/**
     * 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);
    // 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);
}
Also used : Tinker(com.tencent.tinker.lib.tinker.Tinker) File(java.io.File)

Aggregations

Tinker (com.tencent.tinker.lib.tinker.Tinker)21 File (java.io.File)16 TinkerRuntimeException (com.tencent.tinker.loader.TinkerRuntimeException)8 TinkerLoadResult (com.tencent.tinker.lib.tinker.TinkerLoadResult)5 ZipFile (java.util.zip.ZipFile)5 ApplicationInfo (android.content.pm.ApplicationInfo)3 ZipEntry (java.util.zip.ZipEntry)3 SharedPreferences (android.content.SharedPreferences)2 TinkerZipEntry (com.tencent.tinker.commons.ziputil.TinkerZipEntry)2 TinkerZipFile (com.tencent.tinker.commons.ziputil.TinkerZipFile)2 SharePatchInfo (com.tencent.tinker.loader.shareutil.SharePatchInfo)2 ShareResPatchInfo (com.tencent.tinker.loader.shareutil.ShareResPatchInfo)2 DexFile (dalvik.system.DexFile)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 TargetApi (android.annotation.TargetApi)1 AlertDialog (android.app.AlertDialog)1 Context (android.content.Context)1 ViewGroup (android.view.ViewGroup)1