@author cinit
| 10 | * @author cinit |
| 11 | */ |
| 12 | public interface DynamicHook extends Initializable { |
| 13 | |
| 14 | /** |
| 15 | * Check if the hook is initialized and ready to be used. |
| 16 | * If initialization is not successful, the hook should not be used, and this method should return false. |
| 17 | * |
| 18 | * @return true if the hook is initialized and usable. |
| 19 | */ |
| 20 | boolean isInitialized(); |
| 21 | |
| 22 | /** |
| 23 | * Initialize the hook. |
| 24 | * Note that you MUST NOT take too much time to initialize the hook. |
| 25 | * Because the initialization may be called in main thread. |
| 26 | * Avoid time-consuming operations in this method. |
| 27 | * |
| 28 | * @return true if initialization is successful. |
| 29 | */ |
| 30 | @Override |
| 31 | boolean initialize(); |
| 32 | |
| 33 | /** |
| 34 | * Get the errors if anything goes wrong. |
| 35 | * Note that this method has NOTHING to do with the initialization. |
| 36 | * |
| 37 | * @return the errors, null if no errors. |
| 38 | */ |
| 39 | @Nullable |
| 40 | List<Throwable> getErrors(); |
| 41 | |
| 42 | /** |
| 43 | * Whether the hook is enabled by user. |
| 44 | * |
| 45 | * @return true if the hook is enabled by user. |
| 46 | */ |
| 47 | boolean isEnabledByUser(); |
| 48 | |
| 49 | /** |
| 50 | * Set the hook enabled by user. |
| 51 | * |
| 52 | * @param enabled true if the hook is enabled by user. |
| 53 | */ |
| 54 | void setEnabledByUser(boolean enabled); |
| 55 | |
| 56 | /** |
| 57 | * Check if the hook is compatible with the current application. |
| 58 | * If the hook is not compatible, the hook should not be used, and initialize() shall NOT be called. |
| 59 | * This method is called before initialize() on main thread. |
| 60 | * Avoid time-consuming operations in this method. |
| 61 | * |
| 62 | * @return true if the hook is compatible |
| 63 | */ |
| 64 | boolean isAvailable(); |
| 65 | |
| 66 | /** |
| 67 | * Some hooks may need to do some time-consuming operations before initialization. |
| 68 | * Such as dex-deobfuscation, or some other operations. |
| 69 | * |
no outgoing calls
no test coverage detected