Skip to content

Commit f95fcb0

Browse files
committed
DroidPlugin: 解决IAudioServiceHookHandle callingpackage的问题。
1 parent de51f5b commit f95fcb0

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

project/Libraries/DroidPlugin/src/com/morgoo/droidplugin/hook/handle/IAudioServiceHookHandle.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import android.os.Build.VERSION;
2727
import android.os.Build.VERSION_CODES;
2828
import android.text.TextUtils;
29+
2930
import com.morgoo.droidplugin.hook.BaseHookHandle;
3031
import 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

Comments
 (0)