|
1 | 1 | package com.lody.virtual.client.hook.proxies.telephony;
|
2 | 2 |
|
| 3 | +import android.Manifest; |
3 | 4 | import android.content.Context;
|
| 5 | +import android.content.pm.ApplicationInfo; |
| 6 | +import android.content.pm.PackageManager; |
| 7 | +import android.os.Build; |
4 | 8 |
|
5 |
| -import com.lody.virtual.client.hook.base.Inject; |
| 9 | +import com.lody.virtual.client.VClientImpl; |
| 10 | +import com.lody.virtual.client.core.VirtualCore; |
6 | 11 | import com.lody.virtual.client.hook.base.BinderInvocationProxy;
|
| 12 | +import com.lody.virtual.client.hook.base.Inject; |
7 | 13 | import com.lody.virtual.client.hook.base.ReplaceCallingPkgMethodProxy;
|
8 | 14 | import com.lody.virtual.client.hook.base.ReplaceLastPkgMethodProxy;
|
9 | 15 |
|
| 16 | +import java.lang.reflect.Method; |
| 17 | + |
10 | 18 | import mirror.com.android.internal.telephony.ITelephony;
|
11 | 19 |
|
12 | 20 | /**
|
@@ -51,5 +59,28 @@ protected void onBindMethods() {
|
51 | 59 | addMethodProxy(new ReplaceCallingPkgMethodProxy("getMergedSubscriberIds"));
|
52 | 60 | addMethodProxy(new ReplaceLastPkgMethodProxy("getRadioAccessFamily"));
|
53 | 61 | 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 | + }); |
54 | 85 | }
|
55 | 86 | }
|
0 commit comments