This commit is contained in:
844143714@qq,com 2026-07-19 03:20:33 +08:00
parent 24c8289a0d
commit f840740a1a
1 changed files with 28 additions and 28 deletions

View File

@ -214,7 +214,7 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
geckoView = findViewById<GeckoView>(R.id.geckoView) geckoView = findViewById<GeckoView>(R.id.geckoView)
?: return ?: return
findViewById<android.widget.Button>(R.id.btn_retry)?.setOnClickListener { findViewById<android.widget.Button>(R.id.btn_retry)?.setOnClickListener {
hideErrorPage() hideErrorPage()
@ -388,7 +388,7 @@ class MainActivity : AppCompatActivity() {
val result = handleBridgeCall(payload, prompt.defaultValue ?: "") val result = handleBridgeCall(payload, prompt.defaultValue ?: "")
return GeckoResult.fromValue(prompt.confirm(result)) return GeckoResult.fromValue(prompt.confirm(result))
} }
// 默认处理(显示对话框) // 默认处理(显示对话框)
val res = GeckoResult<GeckoSession.PromptDelegate.PromptResponse>() val res = GeckoResult<GeckoSession.PromptDelegate.PromptResponse>()
runOnUiThread { runOnUiThread {
@ -499,19 +499,19 @@ class MainActivity : AppCompatActivity() {
fun logout() { fun logout() {
runOnUiThread { runOnUiThread {
Timber.tag("MainActivity").i("用户注销,清理程序") Timber.tag("MainActivity").i("用户注销,清理程序")
// 1. PTT Logout and cancel login // 1. PTT Logout and cancel login
try { // try {
com.example.kingway.ptt.SendAtUtil.toCancelLogin() // com.example.kingway.ptt.SendAtUtil.toCancelLogin()
} catch (e: Exception) { // } catch (e: Exception) {
Timber.tag("MainActivity").e(e, "PTT cancel failed") // Timber.tag("MainActivity").e(e, "PTT cancel failed")
} // }
try { // try {
com.example.kingway.ptt.SendAtUtil.toLogout() // com.example.kingway.ptt.SendAtUtil.toLogout()
Timber.tag("MainActivity").i("PTT logout sent") // Timber.tag("MainActivity").i("PTT logout sent")
} catch (e: Exception) { // } catch (e: Exception) {
Timber.tag("MainActivity").e(e, "PTT logout failed") // Timber.tag("MainActivity").e(e, "PTT logout failed")
} // }
// 2. Stop GPIO listening // 2. Stop GPIO listening
try { try {
@ -520,6 +520,20 @@ class MainActivity : AppCompatActivity() {
} catch (e: Exception) { } catch (e: Exception) {
Timber.tag("MainActivity").e(e, "GPIO stop failed") Timber.tag("MainActivity").e(e, "GPIO stop failed")
} }
try {
resetAutoJumpStates()
CallBackResolution.resetPttLoginStatus();
}catch (e: Exception) {
Timber.tag("MainActivity").e(e, "Failed to clear public value")
}
// 4. Stop and destroy AudioRecord
try {
com.example.kingway.ptt.AudioRecordManager.destroy()
Timber.tag("MainActivity").i("AudioRecordManager destroyed")
} catch (e: Exception) {
Timber.tag("MainActivity").e(e, "AudioRecordManager destroy failed")
}
// 3. Destroy/release AudioTrack in PTT Native // 3. Destroy/release AudioTrack in PTT Native
try { try {
@ -530,14 +544,6 @@ class MainActivity : AppCompatActivity() {
Timber.tag("MainActivity").e(e, "PTT native destroy failed") Timber.tag("MainActivity").e(e, "PTT native destroy failed")
} }
// 4. Stop and destroy AudioRecord
try {
com.example.kingway.ptt.AudioRecordManager.destroy()
Timber.tag("MainActivity").i("AudioRecordManager destroyed")
} catch (e: Exception) {
Timber.tag("MainActivity").e(e, "AudioRecordManager destroy failed")
}
// 5. Close printer connection and reset // 5. Close printer connection and reset
try { try {
com.stand.standapp.printer.PrinterManager.destroy() com.stand.standapp.printer.PrinterManager.destroy()
@ -563,12 +569,6 @@ class MainActivity : AppCompatActivity() {
} catch (e: Exception) { } catch (e: Exception) {
Timber.tag("MainActivity").e(e, "Failed to redirect to LoginActivity") Timber.tag("MainActivity").e(e, "Failed to redirect to LoginActivity")
} }
try {
resetAutoJumpStates()
CallBackResolution.resetPttLoginStatus();
}catch (e: Exception) {
Timber.tag("MainActivity").e(e, "Failed to clear public value")
}
} }
} }