11package com .lody .virtual .client .hook .proxies .view ;
22
33import android .annotation .SuppressLint ;
4+ import android .content .ComponentName ;
45import android .util .Log ;
56
7+ import com .lody .virtual .client .core .VirtualCore ;
68import com .lody .virtual .client .hook .base .BinderInvocationProxy ;
79import com .lody .virtual .client .hook .base .MethodProxy ;
810import com .lody .virtual .client .hook .utils .MethodParameterUtils ;
11+ import com .lody .virtual .helper .utils .ArrayUtils ;
912
1013import java .lang .reflect .Field ;
1114import java .lang .reflect .Method ;
@@ -52,10 +55,28 @@ public String getMethodName() {
5255 }
5356 @ Override
5457 public boolean beforeCall (Object who , Method method , Object ... args ) {
55- MethodParameterUtils .replaceLastAppPkg (args );
58+ if (args == null ) {
59+ return super .beforeCall (who , method , args );
60+ }
61+ int length = args .length ;
62+ if (length == 0 ) {
63+ return super .beforeCall (who , method , args );
64+ }
65+
66+ int lastIndex = length - 1 ;
67+ Object lastParam = args [lastIndex ];
68+ if (lastParam instanceof String ) {
69+ MethodParameterUtils .replaceLastAppPkg (args );
70+ } else if (lastParam instanceof ComponentName ){
71+ ComponentName lastComponent = (ComponentName ) lastParam ;
72+ ComponentName newComponent = new ComponentName (VirtualCore .get ().getHostPkg (),
73+ lastComponent .getClassName ());
74+ args [lastIndex ] = newComponent ;
75+ }
5676 return super .beforeCall (who , method , args );
5777 }
5878 });
79+
5980 addMethodProxy (new MethodProxy () {
6081 @ Override
6182 public String getMethodName () {
@@ -64,6 +85,12 @@ public String getMethodName() {
6485 @ Override
6586 public boolean beforeCall (Object who , Method method , Object ... args ) {
6687 MethodParameterUtils .replaceLastAppPkg (args );
88+ int index = ArrayUtils .indexOfLast (args , ComponentName .class );
89+ if (index > 0 ) {
90+ ComponentName origComponent = (ComponentName ) args [index ];
91+ ComponentName newComponent = new ComponentName (getHostPkg (), origComponent .getClassName ());
92+ args [index ] = newComponent ;
93+ }
6794 return super .beforeCall (who , method , args );
6895 }
6996 });
0 commit comments