Adapter

interface Adapter(source)

AutoTweaker 的适配器,允许访问 CoreAPI 来将 AutoTweaker 的能力接入任何地方。

需要打上 @AutoService(Adapter::class) 来让 AutoTweaker 发现。

插件(包括适配器)的 jar 将被 AutoTweaker 使用同一个 URLClassLoader 加载,无论实现什么接口。 这意味着插件内部即使实现了不同接口也可以互相访问,插件之间也可以互相访问。

甚至被 AutoTweaker 加载的插件实现还可以通过 ServiceLoader.load(T::class.java, this::class.java.classLoader) 加载其他插件的类。

Properties

Link copied to clipboard
abstract val isRunning: Boolean

确保反映了适配器的实际运行状态,与 start / stop 控制的生命周期匹配。

Functions

Link copied to clipboard
abstract suspend fun init(core: CoreAPI): AdapterInfo

初始化适配器,请不要在此时启动适配器,只做初始化工作。

Link copied to clipboard
abstract suspend fun start()

启动适配器,请确保方法返回后 isRunning 为 true,请确保在启动后可以通过 stop 停止。

Link copied to clipboard
abstract suspend fun stop()

停止适配器,AutoTweaker 退出前必然调用此方法,请确保停止事件循环以及协程,请确保在停止后仍然能够再次通过 start 启动。