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. 退出按钮 // 4. 退出按钮
btnExit.setOnClickListener { btnExit.setOnClickListener {
// fullCleanup() fullCleanup()
// finishAffinity() finishAffinity()
// android.os.Process.killProcess(android.os.Process.myPid()) 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()
} }
// 5. 彩蛋:点击底部版权 10 次进入开发者模式 // 5. 彩蛋:点击底部版权 10 次进入开发者模式

View File

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

View File

@ -8,36 +8,6 @@ import timber.log.Timber
class MyApplication : Application() { 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 { companion object {
private lateinit var mApp: MyApplication private lateinit var mApp: MyApplication