Skip to content

Commit 067f21e

Browse files
committed
FIX getDeviceIdWithFeature
Signed-off-by: tiann <[email protected]>
1 parent 015764e commit 067f21e

File tree

1 file changed

+32
-1
lines changed
  • VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/telephony

1 file changed

+32
-1
lines changed

VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/telephony/TelephonyStub.java

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
package com.lody.virtual.client.hook.proxies.telephony;
22

3+
import android.Manifest;
34
import android.content.Context;
5+
import android.content.pm.ApplicationInfo;
6+
import android.content.pm.PackageManager;
7+
import android.os.Build;
48

5-
import com.lody.virtual.client.hook.base.Inject;
9+
import com.lody.virtual.client.VClientImpl;
10+
import com.lody.virtual.client.core.VirtualCore;
611
import com.lody.virtual.client.hook.base.BinderInvocationProxy;
12+
import com.lody.virtual.client.hook.base.Inject;
713
import com.lody.virtual.client.hook.base.ReplaceCallingPkgMethodProxy;
814
import com.lody.virtual.client.hook.base.ReplaceLastPkgMethodProxy;
915

16+
import java.lang.reflect.Method;
17+
1018
import mirror.com.android.internal.telephony.ITelephony;
1119

1220
/**
@@ -51,5 +59,28 @@ protected void onBindMethods() {
5159
addMethodProxy(new ReplaceCallingPkgMethodProxy("getMergedSubscriberIds"));
5260
addMethodProxy(new ReplaceLastPkgMethodProxy("getRadioAccessFamily"));
5361
addMethodProxy(new ReplaceCallingPkgMethodProxy("isVideoCallingEnabled"));
62+
63+
addMethodProxy(new ReplaceCallingPkgMethodProxy("getDeviceIdWithFeature") {
64+
@Override
65+
public Object call(Object who, Method method, Object... args) throws Throwable{
66+
try {
67+
return super.call(who, method, args);
68+
} catch (SecurityException e) {
69+
ApplicationInfo ai = VClientImpl.get().getCurrentApplicationInfo();
70+
if (ai.targetSdkVersion >= 29) {
71+
throw e;
72+
}
73+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
74+
Context context = VirtualCore.get().getContext();
75+
if (context.checkSelfPermission(Manifest.permission.READ_PHONE_STATE)
76+
!= PackageManager.PERMISSION_GRANTED) {
77+
// 不排除不检查权限直接使用 try-catch 判断的情况
78+
throw e;
79+
}
80+
}
81+
return null;
82+
}
83+
}
84+
});
5485
}
5586
}

0 commit comments

Comments
 (0)