Skip to content

Commit cf30892

Browse files
author
tiann
committed
[VXP]: fix crash of AutoFillManager service.
1 parent f151744 commit cf30892

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

VirtualApp/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ android {
2828
applicationId "io.va.exposed"
2929
minSdkVersion 21
3030
targetSdkVersion 23
31-
versionCode 125
32-
versionName "0.12.5"
31+
versionCode 126
32+
versionName "0.12.6"
3333
multiDexEnabled false
3434
android {
3535
defaultConfig {

VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/view/AutoFillManagerStub.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.lody.virtual.client.hook.proxies.view;
22

33
import android.annotation.SuppressLint;
4+
import android.content.ComponentName;
45
import android.util.Log;
56

7+
import com.lody.virtual.client.core.VirtualCore;
68
import com.lody.virtual.client.hook.base.BinderInvocationProxy;
79
import com.lody.virtual.client.hook.base.MethodProxy;
810
import com.lody.virtual.client.hook.utils.MethodParameterUtils;
11+
import com.lody.virtual.helper.utils.ArrayUtils;
912

1013
import java.lang.reflect.Field;
1114
import 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

Comments
 (0)