Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: apk/hijack/org/chromium/deconstructed/ResourceInstaller.java

Issue 949803002: Deconstructed APK prototyping Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 package org.chromium.deconstructed;
2
3 import android.content.res.AssetManager;
4 import android.content.res.Resources;
5 import android.util.ArrayMap;
6
7 import java.io.File;
8 import java.lang.ref.WeakReference;
9 import java.lang.reflect.InvocationTargetException;
10
11 public class ResourceInstaller {
12 private static final String TAG = "org.chromium.deconstructed.ResourceInstal ler";
13
14 public static void install(File resources)
15 throws NoSuchFieldException, NoSuchMethodException, InvocationTarget Exception,
16 InstantiationException, ClassNotFoundException, IllegalAccess Exception {
17 AssetManager assetManager = AssetManager.class.getConstructor().newInsta nce();
18 if ((int) Reflect.invokeMethod(assetManager, "addAssetPath", resources.g etPath()) == 0) {
19 throw new IllegalStateException("Couldn't add assets.");
20 }
21 Object resourcesManager =
22 Reflect.invokeStaticMethod("android.app.ResourcesManager", "getI nstance");
23 for (WeakReference<Resources> ref :
24 ((ArrayMap<?, WeakReference<Resources>>) Reflect.getField(
25 resourcesManager, "mActiveResources")).values()) {
26 Resources res = ref.get();
27 Reflect.setField(res, "mAssets", assetManager);
28 res.updateConfiguration(res.getConfiguration(), res.getDisplayMetric s());
29 }
30 }
31 }
OLDNEW
« no previous file with comments | « apk/hijack/org/chromium/deconstructed/Reflect.java ('k') | apk/java/org/chromium/simple/MainActivity.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698