|
1 | 1 | package org.lsposed.hiddenapibypass; |
2 | 2 |
|
3 | | -import static org.lsposed.hiddenapibypass.HiddenApiBypass.checkArgsForInvokeMethod; |
4 | | - |
5 | 3 | import android.os.Build; |
6 | 4 | import android.util.Log; |
7 | 5 | import android.util.Property; |
@@ -34,6 +32,23 @@ public final class LSPass { |
34 | 32 | fields = Property.of(Class.class, Field[].class, "DeclaredFields"); |
35 | 33 | } |
36 | 34 |
|
| 35 | + private static boolean checkArgsForInvokeMethod(Class<?>[] params, Object[] args) { |
| 36 | + if (params.length != args.length) return false; |
| 37 | + for (int i = 0; i < params.length; ++i) { |
| 38 | + if (params[i].isPrimitive()) { |
| 39 | + if (params[i] == int.class && !(args[i] instanceof Integer)) return false; |
| 40 | + else if (params[i] == byte.class && !(args[i] instanceof Byte)) return false; |
| 41 | + else if (params[i] == char.class && !(args[i] instanceof Character)) return false; |
| 42 | + else if (params[i] == boolean.class && !(args[i] instanceof Boolean)) return false; |
| 43 | + else if (params[i] == double.class && !(args[i] instanceof Double)) return false; |
| 44 | + else if (params[i] == float.class && !(args[i] instanceof Float)) return false; |
| 45 | + else if (params[i] == long.class && !(args[i] instanceof Long)) return false; |
| 46 | + else if (params[i] == short.class && !(args[i] instanceof Short)) return false; |
| 47 | + } else if (args[i] != null && !params[i].isInstance(args[i])) return false; |
| 48 | + } |
| 49 | + return true; |
| 50 | + } |
| 51 | + |
37 | 52 | /** |
38 | 53 | * get declared methods of given class without hidden api restriction |
39 | 54 | * |
@@ -168,7 +183,7 @@ public static boolean setHiddenApiExemptions(@NonNull String... signaturePrefixe |
168 | 183 | Object runtime = invoke(VMRuntime.class, null, "getRuntime"); |
169 | 184 | invoke(VMRuntime.class, runtime, "setHiddenApiExemptions", (Object) signaturePrefixes); |
170 | 185 | return true; |
171 | | - } catch (Throwable e) { |
| 186 | + } catch (ReflectiveOperationException e) { |
172 | 187 | Log.w(TAG, "setHiddenApiExemptions", e); |
173 | 188 | return false; |
174 | 189 | } |
|
0 commit comments