Commit 5e87483f authored by topjohnwu's avatar topjohnwu

Move addAssetPath to shared

parent f7aa4515
......@@ -27,12 +27,8 @@ import com.topjohnwu.magisk.utils.currentLocale
import com.topjohnwu.magisk.utils.defaultLocale
import java.util.*
private val addAssetPath by lazy {
AssetManager::class.java.getMethod("addAssetPath", String::class.java)
}
fun AssetManager.addAssetPath(path: String) {
addAssetPath.invoke(this, path)
DynAPK.addAssetPath(this, path)
}
fun Context.wrap(global: Boolean = true): Context
......
package com.topjohnwu.magisk;
import android.content.Context;
import android.content.res.AssetManager;
import java.io.File;
import java.lang.reflect.Method;
import java.util.Map;
import static android.os.Build.VERSION.SDK_INT;
......@@ -24,6 +26,7 @@ public class DynAPK {
public static final int MAGISKHIDE = 4;
private static File dynDir;
private static Method addAssetPath;
private static File getDynDir(Context c) {
if (dynDir == null) {
......@@ -62,6 +65,14 @@ public class DynAPK {
return arr;
}
public static void addAssetPath(AssetManager asset, String path) {
try {
if (addAssetPath == null)
addAssetPath = AssetManager.class.getMethod("addAssetPath", String.class);
addAssetPath.invoke(asset, path);
} catch (Exception ignored) {}
}
public static class Data {
public int version;
public Map<String, String> componentMap;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment