This commit is contained in:
parent
ba37d3365e
commit
619d1c4153
|
|
@ -0,0 +1 @@
|
||||||
|
E:\SDK\platform-tools\adb.exe exec-out "run-as com.stand.standapp cat /data/data/com.stand.standapp/cfg.dat" > cfg.dat
|
||||||
|
|
@ -150,19 +150,29 @@ class MainActivity : AppCompatActivity() {
|
||||||
// 创建 GeckoRuntime
|
// 创建 GeckoRuntime
|
||||||
geckoRuntime = createGeckoRuntime()
|
geckoRuntime = createGeckoRuntime()
|
||||||
|
|
||||||
// 安装桥接扩展
|
|
||||||
geckoRuntime?.webExtensionController?.installBuiltIn(
|
|
||||||
"resource://android/assets/extensions/bridge/"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 创建 AndroidInterface
|
// 创建 AndroidInterface
|
||||||
pttInterface = AndroidInterface(this)
|
pttInterface = AndroidInterface(this)
|
||||||
|
|
||||||
// 创建 GeckoSession 并配置
|
// 创建 GeckoSession 并配置(但不加载页面)
|
||||||
createSessionAndLoad()
|
val session = createSession()
|
||||||
|
geckoSession = session
|
||||||
|
geckoView.setSession(session)
|
||||||
|
|
||||||
startTimeoutTimer()
|
startTimeoutTimer()
|
||||||
|
|
||||||
|
// 安装桥接扩展,等安装完成后再加载页面
|
||||||
|
geckoRuntime?.webExtensionController?.installBuiltIn(
|
||||||
|
"resource://android/assets/extensions/bridge/"
|
||||||
|
)?.accept { extension ->
|
||||||
|
Timber.tag("MainActivity").d("WebExtension installed: ${extension?.metaData?.name}")
|
||||||
|
runOnUiThread {
|
||||||
|
val serverUrl = AppConfig.getServerUrl(this)
|
||||||
|
val finalUrl = "$serverUrl/example/print_demo.html?t=${System.currentTimeMillis()}"
|
||||||
|
Timber.tag("MainActivity").d("Loading URL: $finalUrl")
|
||||||
|
session.loadUri(finalUrl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 启动时检查更新
|
// 启动时检查更新
|
||||||
UpdateManager(this).checkUpdate()
|
UpdateManager(this).checkUpdate()
|
||||||
|
|
||||||
|
|
@ -178,7 +188,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
return runtime
|
return runtime
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createSessionAndLoad() {
|
private fun createSession(): GeckoSession {
|
||||||
val session = GeckoSession()
|
val session = GeckoSession()
|
||||||
val sessionSettings = session.settings
|
val sessionSettings = session.settings
|
||||||
|
|
||||||
|
|
@ -186,7 +196,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
sessionSettings.allowJavascript = true
|
sessionSettings.allowJavascript = true
|
||||||
sessionSettings.userAgentMode = GeckoSessionSettings.USER_AGENT_MODE_MOBILE
|
sessionSettings.userAgentMode = GeckoSessionSettings.USER_AGENT_MODE_MOBILE
|
||||||
|
|
||||||
val runtime = geckoRuntime ?: return
|
val runtime = geckoRuntime ?: return session
|
||||||
|
|
||||||
// 设置各种代理
|
// 设置各种代理
|
||||||
setupDelegates(session)
|
setupDelegates(session)
|
||||||
|
|
@ -194,16 +204,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
// 打开会话
|
// 打开会话
|
||||||
session.open(runtime)
|
session.open(runtime)
|
||||||
|
|
||||||
geckoSession = session
|
return session
|
||||||
|
|
||||||
// 将 session 绑定到 GeckoView
|
|
||||||
geckoView.setSession(session)
|
|
||||||
|
|
||||||
// 加载页面
|
|
||||||
val serverUrl = AppConfig.getServerUrl(this)
|
|
||||||
val finalUrl = "$serverUrl/example/print_demo.html?t=${System.currentTimeMillis()}"
|
|
||||||
Timber.tag("MainActivity").d("Loading URL: $finalUrl")
|
|
||||||
session.loadUri(finalUrl)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDelegates(session: GeckoSession) {
|
private fun setupDelegates(session: GeckoSession) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue