This commit is contained in:
parent
f840740a1a
commit
65943334b1
|
|
@ -43,7 +43,7 @@ class DeveloperActivity : AppCompatActivity() {
|
||||||
|
|
||||||
val etUser = EditText(this).apply {
|
val etUser = EditText(this).apply {
|
||||||
hint = "账号"
|
hint = "账号"
|
||||||
setText("test007")
|
setText("test010")
|
||||||
}
|
}
|
||||||
layout.addView(etUser)
|
layout.addView(etUser)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@ class MainActivity : AppCompatActivity() {
|
||||||
companion object {
|
companion object {
|
||||||
private var instance: MainActivity? = null
|
private var instance: MainActivity? = null
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
private var geckoRuntime: GeckoRuntime? = null
|
||||||
|
|
||||||
// 防止对话框堆叠
|
// 防止对话框堆叠
|
||||||
@Volatile
|
@Volatile
|
||||||
private var isConflictDialogShowing = false
|
private var isConflictDialogShowing = false
|
||||||
|
|
@ -186,7 +189,6 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private var geckoSession: GeckoSession? = null
|
private var geckoSession: GeckoSession? = null
|
||||||
private var geckoRuntime: GeckoRuntime? = null
|
|
||||||
private var pttInterface: AndroidInterface? = null
|
private var pttInterface: AndroidInterface? = null
|
||||||
private var canGoBack = false
|
private var canGoBack = false
|
||||||
private lateinit var geckoView: GeckoView
|
private lateinit var geckoView: GeckoView
|
||||||
|
|
@ -275,6 +277,12 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createGeckoRuntime(): GeckoRuntime {
|
private fun createGeckoRuntime(): GeckoRuntime {
|
||||||
|
synchronized(MainActivity::class.java) {
|
||||||
|
val existing = geckoRuntime
|
||||||
|
if (existing != null) {
|
||||||
|
return existing
|
||||||
|
}
|
||||||
|
|
||||||
// 1. 将配置写入应用的本地沙盒文件 (YAML 格式)
|
// 1. 将配置写入应用的本地沙盒文件 (YAML 格式)
|
||||||
val configFile = java.io.File(filesDir, "geckoview-config.yaml")
|
val configFile = java.io.File(filesDir, "geckoview-config.yaml")
|
||||||
try {
|
try {
|
||||||
|
|
@ -297,7 +305,8 @@ class MainActivity : AppCompatActivity() {
|
||||||
settingsBuilder.configFilePath(configFile.absolutePath)
|
settingsBuilder.configFilePath(configFile.absolutePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
val runtime = GeckoRuntime.create(this, settingsBuilder.build())
|
val runtime = GeckoRuntime.create(this.applicationContext, settingsBuilder.build())
|
||||||
|
geckoRuntime = runtime
|
||||||
|
|
||||||
// 3. 强制清缓存,确保 JS/CSS 等资源获取最新版本
|
// 3. 强制清缓存,确保 JS/CSS 等资源获取最新版本
|
||||||
try {
|
try {
|
||||||
|
|
@ -308,6 +317,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
return runtime
|
return runtime
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun createSession(): GeckoSession {
|
private fun createSession(): GeckoSession {
|
||||||
val session = GeckoSession()
|
val session = GeckoSession()
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,9 @@ object GpioManager {
|
||||||
handleGpioChange(currentValue)
|
handleGpioChange(currentValue)
|
||||||
lastGpioValue = currentValue
|
lastGpioValue = currentValue
|
||||||
}
|
}
|
||||||
|
} catch (e: InterruptedException) {
|
||||||
|
Timber.tag("GPIO").i("GPIO thread interrupted, exiting gracefully")
|
||||||
|
break
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.tag("GPIO").e(e, "Error in GPIO loop")
|
Timber.tag("GPIO").e(e, "Error in GPIO loop")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue