| Index: apk/hijack/org/chromium/deconstructed/ResourceInstaller.java
|
| diff --git a/apk/hijack/org/chromium/deconstructed/ResourceInstaller.java b/apk/hijack/org/chromium/deconstructed/ResourceInstaller.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f2928d55a2c7cb9df471074c11d90e3802c5f6c3
|
| --- /dev/null
|
| +++ b/apk/hijack/org/chromium/deconstructed/ResourceInstaller.java
|
| @@ -0,0 +1,31 @@
|
| +package org.chromium.deconstructed;
|
| +
|
| +import android.content.res.AssetManager;
|
| +import android.content.res.Resources;
|
| +import android.util.ArrayMap;
|
| +
|
| +import java.io.File;
|
| +import java.lang.ref.WeakReference;
|
| +import java.lang.reflect.InvocationTargetException;
|
| +
|
| +public class ResourceInstaller {
|
| + private static final String TAG = "org.chromium.deconstructed.ResourceInstaller";
|
| +
|
| + public static void install(File resources)
|
| + throws NoSuchFieldException, NoSuchMethodException, InvocationTargetException,
|
| + InstantiationException, ClassNotFoundException, IllegalAccessException {
|
| + AssetManager assetManager = AssetManager.class.getConstructor().newInstance();
|
| + if ((int) Reflect.invokeMethod(assetManager, "addAssetPath", resources.getPath()) == 0) {
|
| + throw new IllegalStateException("Couldn't add assets.");
|
| + }
|
| + Object resourcesManager =
|
| + Reflect.invokeStaticMethod("android.app.ResourcesManager", "getInstance");
|
| + for (WeakReference<Resources> ref :
|
| + ((ArrayMap<?, WeakReference<Resources>>) Reflect.getField(
|
| + resourcesManager, "mActiveResources")).values()) {
|
| + Resources res = ref.get();
|
| + Reflect.setField(res, "mAssets", assetManager);
|
| + res.updateConfiguration(res.getConfiguration(), res.getDisplayMetrics());
|
| + }
|
| + }
|
| +}
|
|
|