Search in sources :

Example 16 with TinkerRuntimeException

use of com.tencent.tinker.loader.TinkerRuntimeException in project tinker by Tencent.

the class TinkerApplicationHelper method getLoadLibraryAndMd5.

/**
     * you can use this api to get load libs before tinker is installed
     * same as {@code Tinker.getTinkerLoadResultIfPresent.libs}
     *
     * @return
     */
public static HashMap<String, String> getLoadLibraryAndMd5(ApplicationLike applicationLike) {
    if (applicationLike == null || applicationLike.getApplication() == null) {
        throw new TinkerRuntimeException("tinkerApplication is null");
    }
    Intent tinkerResultIntent = applicationLike.getTinkerResultIntent();
    if (tinkerResultIntent == null) {
        return null;
    }
    int loadCode = ShareIntentUtil.getIntentReturnCode(tinkerResultIntent);
    if (loadCode == ShareConstants.ERROR_LOAD_OK) {
        return ShareIntentUtil.getIntentPatchLibsPaths(tinkerResultIntent);
    }
    return null;
}
Also used : TinkerRuntimeException(com.tencent.tinker.loader.TinkerRuntimeException) Intent(android.content.Intent)

Example 17 with TinkerRuntimeException

use of com.tencent.tinker.loader.TinkerRuntimeException in project tinker by Tencent.

the class TinkerApplicationHelper method getPackageConfigs.

/**
     * you can use this api to get tinker package configs before tinker is installed
     * same as {@code Tinker.getTinkerLoadResultIfPresent.packageConfig}
     *
     * @return
     */
public static HashMap<String, String> getPackageConfigs(ApplicationLike applicationLike) {
    if (applicationLike == null || applicationLike.getApplication() == null) {
        throw new TinkerRuntimeException("tinkerApplication is null");
    }
    Intent tinkerResultIntent = applicationLike.getTinkerResultIntent();
    if (tinkerResultIntent == null) {
        return null;
    }
    int loadCode = ShareIntentUtil.getIntentReturnCode(tinkerResultIntent);
    if (loadCode == ShareConstants.ERROR_LOAD_OK) {
        return ShareIntentUtil.getIntentPackageConfig(tinkerResultIntent);
    }
    return null;
}
Also used : TinkerRuntimeException(com.tencent.tinker.loader.TinkerRuntimeException) Intent(android.content.Intent)

Example 18 with TinkerRuntimeException

use of com.tencent.tinker.loader.TinkerRuntimeException in project tinker by Tencent.

the class TinkerApplicationHelper method getLoadDexesAndMd5.

/**
     * you can use this api to get load dexes before tinker is installed
     * same as {@code Tinker.getTinkerLoadResultIfPresent.dexes}
     *
     * @return
     */
public static HashMap<String, String> getLoadDexesAndMd5(ApplicationLike applicationLike) {
    if (applicationLike == null || applicationLike.getApplication() == null) {
        throw new TinkerRuntimeException("tinkerApplication is null");
    }
    Intent tinkerResultIntent = applicationLike.getTinkerResultIntent();
    if (tinkerResultIntent == null) {
        return null;
    }
    int loadCode = ShareIntentUtil.getIntentReturnCode(tinkerResultIntent);
    if (loadCode == ShareConstants.ERROR_LOAD_OK) {
        return ShareIntentUtil.getIntentPatchDexPaths(tinkerResultIntent);
    }
    return null;
}
Also used : TinkerRuntimeException(com.tencent.tinker.loader.TinkerRuntimeException) Intent(android.content.Intent)

Example 19 with TinkerRuntimeException

use of com.tencent.tinker.loader.TinkerRuntimeException in project tinker by Tencent.

the class TinkerApplication method createDelegate.

private ApplicationLike createDelegate() {
    try {
        // Use reflection to create the delegate so it doesn't need to go into the primary dex.
        // And we can also patch it
        Class<?> delegateClass = Class.forName(delegateClassName, false, getClassLoader());
        Constructor<?> constructor = delegateClass.getConstructor(Application.class, int.class, boolean.class, long.class, long.class, Intent.class);
        return (ApplicationLike) constructor.newInstance(this, tinkerFlags, tinkerLoadVerifyFlag, applicationStartElapsedTime, applicationStartMillisTime, tinkerResultIntent);
    } catch (Throwable e) {
        throw new TinkerRuntimeException("createDelegate failed", e);
    }
}
Also used : TinkerRuntimeException(com.tencent.tinker.loader.TinkerRuntimeException)

Example 20 with TinkerRuntimeException

use of com.tencent.tinker.loader.TinkerRuntimeException in project tinker by Tencent.

the class SharePatchInfo method rewritePatchInfoFileWithLock.

public static boolean rewritePatchInfoFileWithLock(File pathInfoFile, SharePatchInfo info, File lockFile) {
    if (pathInfoFile == null || info == null || lockFile == null) {
        return false;
    }
    File lockParentFile = lockFile.getParentFile();
    if (!lockParentFile.exists()) {
        lockParentFile.mkdirs();
    }
    boolean rewriteSuccess;
    ShareFileLockHelper fileLock = null;
    try {
        fileLock = ShareFileLockHelper.getFileLock(lockFile);
        rewriteSuccess = rewritePatchInfoFile(pathInfoFile, info);
    } catch (Exception e) {
        throw new TinkerRuntimeException("rewritePatchInfoFileWithLock fail", e);
    } finally {
        try {
            if (fileLock != null) {
                fileLock.close();
            }
        } catch (IOException e) {
            Log.i(TAG, "releaseInfoLock error", e);
        }
    }
    return rewriteSuccess;
}
Also used : TinkerRuntimeException(com.tencent.tinker.loader.TinkerRuntimeException) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException) TinkerRuntimeException(com.tencent.tinker.loader.TinkerRuntimeException)

Aggregations

TinkerRuntimeException (com.tencent.tinker.loader.TinkerRuntimeException)21 File (java.io.File)9 Tinker (com.tencent.tinker.lib.tinker.Tinker)8 Intent (android.content.Intent)6 ZipFile (java.util.zip.ZipFile)5 IOException (java.io.IOException)4 ZipEntry (java.util.zip.ZipEntry)4 ApplicationInfo (android.content.pm.ApplicationInfo)3 InputStream (java.io.InputStream)3 TinkerZipEntry (com.tencent.tinker.commons.ziputil.TinkerZipEntry)2 TinkerZipFile (com.tencent.tinker.commons.ziputil.TinkerZipFile)2 ShareResPatchInfo (com.tencent.tinker.loader.shareutil.ShareResPatchInfo)2 DexFile (dalvik.system.DexFile)2 BufferedOutputStream (java.io.BufferedOutputStream)2 FileOutputStream (java.io.FileOutputStream)2 X509Certificate (java.security.cert.X509Certificate)2 ArrayList (java.util.ArrayList)2 SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 PackageInfo (android.content.pm.PackageInfo)1