INNER CODE UNIT · Java
unsealByDexFile
tiann/FreeReflection · library/src/main/java/me/weishu/reflection/Reflection.java:45
private static boolean unsealByDexFile(Context context) {
byte[] bytes = Base64.decode(DEX, Base64.NO_WRAP);
File codeCacheDir = getCodeCacheDir(context);
if (codeCacheDir == null) {
return false;
}
File code = new File(codeCacheDir, System.currentTimeMillis() + ".dex");
try {
try (FileOutputStream fos = new FileOutputStream(code)) {
fos.write(bytes);
}
// Support target Android U.
// https://developer.android.com/about/versions/14/behavior-changes-14#safer-dynamic-code-loading
try {
//noinspection ResultOfMethodCallIgnored
code.setReadOnly();