| 11 | import de.robv.android.xposed.XposedBridge; |
| 12 | |
| 13 | public class HookUtils { |
| 14 | |
| 15 | private HookUtils() { |
| 16 | throw new AssertionError("no instance for you!"); |
| 17 | } |
| 18 | |
| 19 | public interface BeforeHookedMethod { |
| 20 | void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable; |
| 21 | } |
| 22 | |
| 23 | public interface AfterHookedMethod { |
| 24 | void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable; |
| 25 | } |
| 26 | |
| 27 | public interface BeforeAndAfterHookedMethod { |
| 28 | void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable; |
| 29 | |
| 30 | void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable; |
| 31 | } |
| 32 | |
| 33 | public static void hookAfterIfEnabled(final @NonNull CommonDynamicHook this0, final @NonNull Method method, |
| 34 | int priority, final @NonNull AfterHookedMethod afterHookedMethod) { |
| 35 | Objects.requireNonNull(this0, "this0 == null"); |
| 36 | Objects.requireNonNull(method, "method == null"); |
| 37 | XposedBridge.hookMethod(method, new XC_MethodHook(priority) { |
| 38 | @Override |
| 39 | protected void afterHookedMethod(MethodHookParam param) throws Throwable { |
| 40 | try { |
| 41 | if (this0.isEnabled()) { |
| 42 | afterHookedMethod.afterHookedMethod(param); |
| 43 | } |
| 44 | } catch (Throwable e) { |
| 45 | this0.logError(e); |
| 46 | throw e; |
| 47 | } |
| 48 | } |
| 49 | }); |
| 50 | } |
| 51 | |
| 52 | public static XC_MethodHook beforeIfEnabled(final @NonNull CommonDynamicHook this0, int priority, |
| 53 | final @NonNull BeforeHookedMethod beforeHookedMethod) { |
| 54 | Objects.requireNonNull(this0, "this0 == null"); |
| 55 | return new XC_MethodHook(priority) { |
| 56 | @Override |
| 57 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable { |
| 58 | try { |
| 59 | if (this0.isEnabled()) { |
| 60 | beforeHookedMethod.beforeHookedMethod(param); |
| 61 | } |
| 62 | } catch (Throwable e) { |
| 63 | this0.logError(e); |
| 64 | throw e; |
| 65 | } |
| 66 | } |
| 67 | }; |
| 68 | } |
| 69 | |
| 70 | public static XC_MethodHook afterIfEnabled(final @NonNull CommonDynamicHook this0, int priority, |
nothing calls this directly
no outgoing calls
no test coverage detected