@@ -54,6 +54,7 @@ public synchronized static Object currentActivityThread() {
54
54
}
55
55
56
56
public static Object getResCompatibilityInfo () {
57
+ //貌似没啥用
57
58
Object mBoundApplication = RefInvoker .getFieldObject (currentActivityThread (), android_app_ActivityThread , "mBoundApplication" );
58
59
Object compatInfo = RefInvoker .getFieldObject (mBoundApplication , android_app_ActivityThread_AppBindData , "compatInfo" );
59
60
return compatInfo ;
@@ -166,7 +167,7 @@ public static void wrapInstrumentation() {
166
167
// 42 parent = baseParent;
167
168
// 43 }
168
169
//
169
- public static void installPackageInfo (Context hostContext , String pluginId ) throws ClassNotFoundException {
170
+ public static void installPackageInfo (Context hostContext , String pluginId , PluginDescriptor pluginDescriptor ) throws ClassNotFoundException {
170
171
enableLog ();
171
172
Object applicationLoaders = RefInvoker .invokeStaticMethod ("android.app.ApplicationLoaders" , "getDefault" , (Class []) null , (Object []) null );
172
173
Map mLoaders = (Map )RefInvoker .getFieldObject (applicationLoaders , "android.app.ApplicationLoaders" , "mLoaders" );
@@ -181,6 +182,15 @@ public static void installPackageInfo(Context hostContext, String pluginId) thro
181
182
Object pluginLoadedApk = RefInvoker .invokeMethod (currentActivityThread (), android_app_ActivityThread , "getPackageInfoNoCheck" ,
182
183
new Class []{ApplicationInfo .class , Class .forName ("android.content.res.CompatibilityInfo" )},
183
184
new Object []{info , compatibilityInfo });
185
+ if (pluginLoadedApk != null ) {
186
+ Class loadedAPKClass = pluginLoadedApk .getClass ();
187
+ RefInvoker .setFieldObject (pluginLoadedApk , loadedAPKClass , "mApplication" , pluginDescriptor .getPluginApplication ());
188
+ RefInvoker .setFieldObject (pluginLoadedApk , loadedAPKClass , "mResources" , pluginDescriptor .getPluginContext ().getResources ());
189
+ //TODO
190
+ //RefInvoker.setFieldObject(pluginLoadedApk, loadedAPKClass, "mLibDir", );
191
+ //RefInvoker.setFieldObject(pluginLoadedApk, loadedAPKClass, "mDataDirFile", );
192
+ //RefInvoker.setFieldObject(pluginLoadedApk, loadedAPKClass, "mDataDir", );
193
+ }
184
194
//再还原
185
195
Thread .currentThread ().setContextClassLoader (classLoader );
186
196
} catch (PackageManager .NameNotFoundException e ) {
0 commit comments