This commit is contained in:
844143714@qq,com 2026-04-30 01:11:18 +08:00
parent e943361349
commit 828ad240eb
3 changed files with 52 additions and 103 deletions

View File

@ -65,30 +65,9 @@ class LoginActivity : AppCompatActivity() {
// 4. 退出按钮
btnExit.setOnClickListener {
// fullCleanup()
// finishAffinity()
// android.os.Process.killProcess(android.os.Process.myPid())
try {
// com.example.kingway.ptt.MyApplication.init(this@LoginActivity)
// Thread.sleep(500)
// com.example.kingway.ptt.SendAtUtil.toCancelLogin()
// com.example.kingway.ptt.SendAtUtil.toLogout()
} catch (e: Exception) {
Timber.tag("PTT").e(e, "PTT init error")
}
Thread {
try {
Thread.sleep(500)
runOnUiThread {
Toast.makeText(this@LoginActivity, "PTT初始化中", Toast.LENGTH_SHORT).show()
}
Thread.sleep(3000)
com.example.kingway.ptt.SendAtUtil.toLogin("gzz22222", "1111", "61.243.1.123", 1, 1)
// com.example.kingway.ptt.SendAtUtil.toLogin("gzzdweb01", "123456", "61.243.1.123", 1, 1)
} catch (e: Exception) {
Timber.tag("PTT").e(e, "PTT login error")
}
}.start()
fullCleanup()
finishAffinity()
android.os.Process.killProcess(android.os.Process.myPid())
}
// 5. 彩蛋:点击底部版权 10 次进入开发者模式

View File

@ -61,15 +61,15 @@ class MainActivity : AppCompatActivity() {
.setMessage("您的 PTT 账号已在其他设备登录,当前设备已被迫下线。\n请点击确认退出并重新登录。")
.setCancelable(false)
.setPositiveButton("确认") { _, _ ->
// try {
// com.example.kingway.ptt.SendAtUtil.toLogout()
try {
com.example.kingway.ptt.SendAtUtil.toLogout()
// com.example.kingway.ptt.MyApplication.destroy()
// com.stand.standapp.utils.GpioManager.stopListening()
// } catch (_: Exception) {}
// val pm = ctx.packageManager
// val intent = pm.getLaunchIntentForPackage(ctx.packageName)
// intent?.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
// ctx.startActivity(intent)
com.stand.standapp.utils.GpioManager.stopListening()
} catch (_: Exception) {}
val pm = ctx.packageManager
val intent = pm.getLaunchIntentForPackage(ctx.packageName)
intent?.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(intent)
android.os.Process.killProcess(android.os.Process.myPid())
}
.show()
@ -263,7 +263,7 @@ class MainActivity : AppCompatActivity() {
.setTitle("提示")
.setMessage("确定要退出应用吗?")
.setPositiveButton("确定") { _, _ ->
// pttLogoutAndDestroy()
pttLogoutAndDestroy()
finishAffinity()
android.os.Process.killProcess(android.os.Process.myPid())
}
@ -271,47 +271,47 @@ class MainActivity : AppCompatActivity() {
.show()
}
// private fun pttLogoutAndDestroy() {
// try {
// com.example.kingway.ptt.SendAtUtil.toCancelLogin()
// } catch (e: Exception) {
// Timber.tag("LoginActivity").e(e, "PTT cancel failed")
// }
// try {
// com.example.kingway.ptt.SendAtUtil.toLogout()
// Timber.tag("LoginActivity").i("PTT logout sent")
// } catch (e: Exception) {
// Timber.tag("LoginActivity").e(e, "PTT logout failed")
// }
// try {
// com.stand.standapp.utils.GpioManager.stopListening()
// } catch (e: Exception) {
// Timber.tag("MainActivity").e(e, "GPIO stop failed")
// }
// try {
// com.stand.standapp.utils.GpioManager.stopListening()
// } catch (e: Exception) {
// Timber.tag("LoginActivity").e(e, "GPIO stop failed")
// }
// try {
private fun pttLogoutAndDestroy() {
try {
com.example.kingway.ptt.SendAtUtil.toCancelLogin()
} catch (e: Exception) {
Timber.tag("LoginActivity").e(e, "PTT cancel failed")
}
try {
com.example.kingway.ptt.SendAtUtil.toLogout()
Timber.tag("LoginActivity").i("PTT logout sent")
} catch (e: Exception) {
Timber.tag("LoginActivity").e(e, "PTT logout failed")
}
try {
com.stand.standapp.utils.GpioManager.stopListening()
} catch (e: Exception) {
Timber.tag("MainActivity").e(e, "GPIO stop failed")
}
try {
com.stand.standapp.utils.GpioManager.stopListening()
} catch (e: Exception) {
Timber.tag("LoginActivity").e(e, "GPIO stop failed")
}
try {
// com.example.kingway.ptt.MyApplication.destroy()
// Timber.tag("LoginActivity").i("PTT native destroyed")
// } catch (e: Exception) {
// Timber.tag("LoginActivity").e(e, "PTT destroy failed")
// }
// try {
//// PrinterManager.shutdown()
// Timber.tag("LoginActivity").i("Printer shut down")
// } catch (e: Exception) {
// Timber.tag("LoginActivity").e(e, "Printer shutdown failed")
// }
// try {
// com.stand.standapp.utils.LogManager.shutdown()
// Timber.tag("LoginActivity").i("LogManager shut down")
// } catch (e: Exception) {
// Timber.tag("LoginActivity").e(e, "LogManager shutdown failed")
// }
// }
Timber.tag("LoginActivity").i("PTT native destroyed")
} catch (e: Exception) {
Timber.tag("LoginActivity").e(e, "PTT destroy failed")
}
try {
// PrinterManager.shutdown()
Timber.tag("LoginActivity").i("Printer shut down")
} catch (e: Exception) {
Timber.tag("LoginActivity").e(e, "Printer shutdown failed")
}
try {
com.stand.standapp.utils.LogManager.shutdown()
Timber.tag("LoginActivity").i("LogManager shut down")
} catch (e: Exception) {
Timber.tag("LoginActivity").e(e, "LogManager shutdown failed")
}
}
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
if (keyCode == KeyEvent.KEYCODE_BACK) {

View File

@ -8,36 +8,6 @@ import timber.log.Timber
class MyApplication : Application() {
// companion object {
// private var instance: MyApplication? = null
// fun getAppInstance(): MyApplication = instance ?: error("MyApplication not yet initialized")
// }
// override fun onCreate() {
// super.onCreate()
// instance = this
// // 第一步:初始化日志
// LogManager.init(this)
//
// // 初始化 xCrash 以捕获 Native (SO) 崩溃
// xcrash.XCrash.init(this, xcrash.XCrash.InitParameters().apply {
// setAppVersion(packageManager.getPackageInfo(packageName, 0).versionName)
// setLogDir(getExternalFilesDir("tombstones")?.absolutePath)
// setNativeDumpAllThreads(true)
//
// setJavaCallback { logPath, emergency ->
// LogManager.onCrashDetected(logPath, "Java-xCrash", null)
// }
//
// setNativeCallback { logPath, emergency ->
// LogManager.onCrashDetected(logPath, "Native-xCrash", null)
// android.util.Log.e("MyApplication", "NATIVE CRASH DETECTED at: $logPath")
// }
// })
//
// Timber.tag("MyApplication").i("=== Application Starting ===")
// }
// 单例实例
companion object {
private lateinit var mApp: MyApplication