Skip to content

Commit 406925b

Browse files
committed
[Android 10]: Add getSerialForPackage hook
Signed-off-by: tiann <[email protected]>
1 parent 317727b commit 406925b

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

VirtualApp/lib/src/main/java/com/lody/virtual/client/core/InvocationStubManager.java

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.lody.virtual.client.hook.proxies.mount.MountServiceStub;
3939
import com.lody.virtual.client.hook.proxies.network.NetworkManagementStub;
4040
import com.lody.virtual.client.hook.proxies.notification.NotificationManagerStub;
41+
import com.lody.virtual.client.hook.proxies.os.DeviceIdentifiersPolicyServiceStub;
4142
import com.lody.virtual.client.hook.proxies.persistent_data_block.PersistentDataBlockServiceStub;
4243
import com.lody.virtual.client.hook.proxies.phonesubinfo.PhoneSubInfoStub;
4344
import com.lody.virtual.client.hook.proxies.pm.LauncherAppsStub;
@@ -196,6 +197,9 @@ private void injectInternal() throws Throwable {
196197
}
197198
if (BuildCompat.isQ()) {
198199
addInjector(new ActivityTaskManagerStub());
200+
201+
// http://aospxref.com/android-10.0.0_r47/xref/frameworks/base/core/java/android/os/IDeviceIdentifiersPolicyService.aidl#24
202+
addInjector(new DeviceIdentifiersPolicyServiceStub());
199203
}
200204
}
201205
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.lody.virtual.client.hook.proxies.os;
2+
3+
import android.content.pm.ApplicationInfo;
4+
5+
import com.lody.virtual.client.VClientImpl;
6+
import com.lody.virtual.client.hook.base.BinderInvocationProxy;
7+
import com.lody.virtual.client.hook.base.ReplaceCallingPkgMethodProxy;
8+
import com.lody.virtual.helper.compat.BuildCompat;
9+
10+
import java.lang.reflect.Method;
11+
12+
import mirror.android.os.IDeviceIdentifiersPolicyService;
13+
14+
/**
15+
* @author weishu
16+
* @date 2021/8/19.
17+
*/
18+
public class DeviceIdentifiersPolicyServiceStub extends BinderInvocationProxy {
19+
public DeviceIdentifiersPolicyServiceStub() {
20+
super(IDeviceIdentifiersPolicyService.Stub.TYPE, "device_identifiers");
21+
}
22+
23+
@Override
24+
protected void onBindMethods() {
25+
26+
addMethodProxy(new ReplaceCallingPkgMethodProxy("getSerialForPackage") {
27+
@Override
28+
public Object call(Object who, Method method, Object... args) throws Throwable {
29+
ApplicationInfo info = VClientImpl.get().getCurrentApplicationInfo();
30+
if (info != null && info.targetSdkVersion >= 29 && BuildCompat.isQ()) {
31+
return "unknown";
32+
}
33+
return super.call(who, method, args);
34+
}
35+
});
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package mirror.android.os;
2+
3+
import android.annotation.TargetApi;
4+
import android.os.IBinder;
5+
import android.os.IInterface;
6+
7+
import mirror.MethodParams;
8+
import mirror.RefClass;
9+
import mirror.RefStaticMethod;
10+
11+
/**
12+
* @author weishu
13+
* @date 2021/8/19.
14+
*/
15+
@TargetApi(29)
16+
public class IDeviceIdentifiersPolicyService {
17+
public static Class<?> TYPE = RefClass.load(IDeviceIdentifiersPolicyService.class, "android.os.IDeviceIdentifiersPolicyService");
18+
19+
public static class Stub {
20+
public static Class<?> TYPE = RefClass.load(IDeviceIdentifiersPolicyService.Stub.class, "android.os.IDeviceIdentifiersPolicyService$Stub");
21+
@MethodParams({IBinder.class})
22+
public static RefStaticMethod<IInterface> asInterface;
23+
}
24+
}

0 commit comments

Comments
 (0)