33import android .content .ComponentName ;
44import android .content .Intent ;
55import android .content .pm .ActivityInfo ;
6- import android .content .pm .ApplicationInfo ;
76import android .content .pm .ServiceInfo ;
87import android .os .Handler ;
98import android .os .IBinder ;
1918import com .lody .virtual .remote .InstalledAppInfo ;
2019import com .lody .virtual .remote .StubActivityRecord ;
2120
21+ import java .util .List ;
22+
23+ import me .weishu .exposed .ExposedBridge ;
2224import mirror .android .app .ActivityManagerNative ;
2325import mirror .android .app .ActivityThread ;
2426import mirror .android .app .IActivityManager ;
@@ -107,6 +109,8 @@ private boolean handleLaunchActivity(Message msg) {
107109 ComponentName caller = saveInstance .caller ;
108110 IBinder token = ActivityThread .ActivityClientRecord .token .get (r );
109111 ActivityInfo info = saveInstance .info ;
112+ ClassLoader appClassLoader = VClientImpl .get ().getClassLoader (info .applicationInfo );
113+
110114 if (VClientImpl .get ().getToken () == null ) {
111115 InstalledAppInfo installedAppInfo = VirtualCore .get ().getInstalledAppInfo (info .packageName , 0 );
112116 if (installedAppInfo == null ){
@@ -117,6 +121,12 @@ private boolean handleLaunchActivity(Message msg) {
117121 return false ;
118122 }
119123 if (!VClientImpl .get ().isBound ()) {
124+ ExposedBridge .initOnce (VirtualCore .get ().getContext (), info .applicationInfo , appClassLoader );
125+ List <InstalledAppInfo > installedApps = VirtualCore .get ().getInstalledApps (0 );
126+ for (InstalledAppInfo installedApp : installedApps ) {
127+ ExposedBridge .loadModule (installedApp .apkPath , installedApp .getOdexFile ().getParent (),
128+ installedApp .libPath , info .applicationInfo , appClassLoader );
129+ }
120130 VClientImpl .get ().bindApplication (info .packageName , info .processName );
121131 getH ().sendMessageAtFrontOfQueue (Message .obtain (msg ));
122132 return false ;
@@ -127,8 +137,8 @@ private boolean handleLaunchActivity(Message msg) {
127137 false
128138 );
129139 VActivityManager .get ().onActivityCreate (ComponentUtils .toComponentName (info ), caller , token , info , intent , ComponentUtils .getTaskAffinity (info ), taskId , info .launchMode , info .flags );
130- ClassLoader appClassLoader = VClientImpl . get (). getClassLoader ( info . applicationInfo );
131- intent .setExtrasClassLoader (appClassLoader );
140+
141+ intent .setExtrasClassLoader (ExposedBridge . getAppClassLoaderWithXposed ( appClassLoader ) );
132142 ActivityThread .ActivityClientRecord .intent .set (r , intent );
133143 ActivityThread .ActivityClientRecord .activityInfo .set (r , info );
134144 return true ;
0 commit comments