2626import android .os .Build .VERSION ;
2727import android .os .Build .VERSION_CODES ;
2828import android .text .TextUtils ;
29+
2930import com .morgoo .droidplugin .hook .BaseHookHandle ;
3031import com .morgoo .droidplugin .hook .HookedMethodHandler ;
3132
@@ -51,6 +52,7 @@ protected void init() {
5152 sHookedMethodHandlers .put ("setMasterVolume" , new setMasterVolume (mHostContext ));
5253 sHookedMethodHandlers .put ("requestAudioFocus" , new requestAudioFocus (mHostContext ));
5354 sHookedMethodHandlers .put ("registerRemoteControlClient" , new registerRemoteControlClient (mHostContext ));
55+
5456 }
5557
5658 private static class MyBaseHandler extends HookedMethodHandler {
@@ -63,11 +65,12 @@ public MyBaseHandler(Context context) {
6365 protected boolean beforeInvoke (Object receiver , Method method , Object [] args ) throws Throwable {
6466 if (VERSION .SDK_INT >= VERSION_CODES .KITKAT ) {
6567 if (args != null && args .length > 0 ) {
66- int index = args .length - 1 ;
67- if (args [index ] instanceof String ) {
68- String callingPkg = (String ) args [index ];
69- if (!TextUtils .equals (callingPkg , mHostContext .getPackageName ())) {
70- args [index ] = mHostContext .getPackageName ();
68+ for (int index = 0 ; index < args .length ; index ++) {
69+ if (args [index ] instanceof String ) {
70+ String callingPkg = (String ) args [index ];
71+ if (!TextUtils .equals (callingPkg , mHostContext .getPackageName ())) {
72+ args [index ] = mHostContext .getPackageName ();
73+ }
7174 }
7275 }
7376 }
0 commit comments