6.7.0 - Alpha16 - 修复打包应用 devPluginService 实例初始化时机异常
This commit is contained in:
@@ -25,7 +25,6 @@ import org.autojs.autojs.event.GlobalKeyObserver
|
||||
import org.autojs.autojs.external.receiver.DynamicBroadcastReceivers
|
||||
import org.autojs.autojs.ipc.InAppEventBus
|
||||
import org.autojs.autojs.leakcanary.LeakCanarySetup
|
||||
import org.autojs.autojs.pluginclient.DevPluginService
|
||||
import org.autojs.autojs.theme.ThemeColorManager
|
||||
import org.autojs.autojs.timing.TimedTaskManager
|
||||
import org.autojs.autojs.timing.TimedTaskScheduler
|
||||
@@ -40,16 +39,13 @@ import java.lang.reflect.Method
|
||||
|
||||
/**
|
||||
* Created by Stardust on Jan 27, 2017.
|
||||
* Modified by SuperMonster003 as of Aug 23, 2022.
|
||||
* Modified by SuperMonster003 as of Jan 17, 2026.
|
||||
*/
|
||||
class App : MultiDexApplication() {
|
||||
|
||||
lateinit var dynamicBroadcastReceivers: DynamicBroadcastReceivers
|
||||
private set
|
||||
|
||||
lateinit var devPluginService: DevPluginService
|
||||
private set
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
@@ -62,8 +58,6 @@ class App : MultiDexApplication() {
|
||||
setUpDefaultNightMode()
|
||||
}
|
||||
else /* Main process. */ -> {
|
||||
devPluginService = DevPluginService(this)
|
||||
|
||||
setUpDebugEnvironment()
|
||||
setUpLeakCanary()
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.autojs.autojs.execution.ScriptExecutionGlobalListener
|
||||
import org.autojs.autojs.external.fileprovider.AppFileProvider
|
||||
import org.autojs.autojs.ipc.LayoutInspectEvent
|
||||
import org.autojs.autojs.ipc.LayoutInspectEventBus
|
||||
import org.autojs.autojs.pluginclient.DevPluginService
|
||||
import org.autojs.autojs.runtime.ScriptRuntime
|
||||
import org.autojs.autojs.runtime.api.AppUtils
|
||||
import org.autojs.autojs.runtime.api.AppUtils.Companion.ActivityShortForm
|
||||
@@ -33,12 +34,16 @@ import org.autojs.autojs.inrt.autojs.AutoJs as AutoJsInrt
|
||||
|
||||
/**
|
||||
* Created by Stardust on Apr 2, 2017.
|
||||
* Modified by SuperMonster003 as of Dec 1, 2021.
|
||||
* Transformed by SuperMonster003 on Oct 10, 2022.
|
||||
* Modified by LZX284 (https://github.com/LZX284) as of Sep 30, 2023.
|
||||
* Modified by SuperMonster003 as of Jan 17, 2026.
|
||||
*/
|
||||
open class AutoJs(appContext: Application) : AbstractAutoJs(appContext) {
|
||||
|
||||
internal val devPluginService by lazy {
|
||||
DevPluginService(application)
|
||||
}
|
||||
|
||||
// @Thank to Zen2H
|
||||
// Use bounded queue to prevent log flooding from blocking the whole channel.
|
||||
// zh-CN: 使用有界队列避免日志洪泛导致整个通道被阻塞.
|
||||
@@ -122,7 +127,6 @@ open class AutoJs(appContext: Application) : AbstractAutoJs(appContext) {
|
||||
override fun createAppUtils(context: Context) = AppUtils(context, AppFileProvider.AUTHORITY)
|
||||
|
||||
override fun createGlobalConsole(): GlobalConsole {
|
||||
val devPluginService by lazy { App.app.devPluginService }
|
||||
return object : GlobalConsole(uiHandler) {
|
||||
override fun println(level: Int, charSequence: CharSequence): String {
|
||||
return super.println(level, charSequence).also {
|
||||
|
||||
@@ -4,16 +4,16 @@ import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.functions.Consumer
|
||||
import org.autojs.autojs.App
|
||||
import org.autojs.autojs.AutoJs
|
||||
import org.autojs.autojs.ui.main.drawer.SocketItemHelper
|
||||
|
||||
/**
|
||||
* Created by SuperMonster003 on Jun 24, 2022.
|
||||
* Modified by SuperMonster003 as of Jan 14, 2026.
|
||||
* Modified by SuperMonster003 as of Jan 17, 2026.
|
||||
*/
|
||||
abstract class AbstractJsonSocketTool(final override val context: Context) : SocketItemHelper {
|
||||
|
||||
protected val devPlugin by lazy { App.app.devPluginService }
|
||||
protected val devPlugin by lazy { AutoJs.instance.devPluginService }
|
||||
|
||||
@JvmField
|
||||
protected var stateDisposable: Disposable? = null
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.content.edit
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.google.gson.Gson
|
||||
import org.autojs.autojs.AbstractAutoJs.Companion.isInrt
|
||||
import org.autojs.autojs.App.Companion.app
|
||||
import org.autojs.autojs.annotation.KeyRes
|
||||
import org.autojs.autojs.annotation.ScriptInterfaceCompatible
|
||||
@@ -26,6 +27,7 @@ import java.util.*
|
||||
|
||||
/**
|
||||
* Created by Stardust on Jan 31, 2017.
|
||||
* Modified by SuperMonster003 as of Jan 17, 2026.
|
||||
*/
|
||||
object Pref {
|
||||
|
||||
@@ -231,7 +233,7 @@ object Pref {
|
||||
private fun updateTimestamp(@KeyRes keyRes: Int) = putLong(keyRes, System.currentTimeMillis())
|
||||
|
||||
@JvmStatic
|
||||
fun getServerAddress(): String = getString(R.string.key_server_address, NetworkUtils.getGatewayAddress())
|
||||
fun getServerAddress(): String = getString(R.string.key_server_address, if (!isInrt) NetworkUtils.getGatewayAddress() else NetworkUtils.DEFAULT_IP_ADDRESS)
|
||||
|
||||
@JvmStatic
|
||||
fun setServerAddress(address: String?) = putString(R.string.key_server_address, address)
|
||||
|
||||
@@ -13,7 +13,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import org.autojs.autojs.App
|
||||
import org.autojs.autojs.AutoJs
|
||||
import org.autojs.autojs.app.tool.FloatingButtonTool
|
||||
import org.autojs.autojs.app.tool.JsonSocketClientTool
|
||||
import org.autojs.autojs.app.tool.JsonSocketServerTool
|
||||
@@ -223,7 +223,7 @@ open class DrawerFragment : Fragment() {
|
||||
}
|
||||
|
||||
JsonSocketClientTool(mActivity).apply {
|
||||
val devPluginService = App.app.devPluginService
|
||||
val devPluginService = AutoJs.instance.devPluginService
|
||||
|
||||
val drawerItem = DrawerMenuDisposableItem(
|
||||
helper = this,
|
||||
@@ -269,7 +269,7 @@ open class DrawerFragment : Fragment() {
|
||||
}
|
||||
|
||||
JsonSocketServerTool(mActivity).apply {
|
||||
val devPluginService = App.app.devPluginService
|
||||
val devPluginService = AutoJs.instance.devPluginService
|
||||
|
||||
val drawerItem = DrawerMenuDisposableItem(
|
||||
helper = this,
|
||||
|
||||
Reference in New Issue
Block a user