注销功能
This commit is contained in:
parent
9d5f4dc3a9
commit
c531965106
|
|
@ -44,8 +44,12 @@ public class CallBackResolution {
|
|||
}
|
||||
|
||||
public static void resetPttLoginStatus() {
|
||||
loginState = false;
|
||||
pttLoginStatus = "00";
|
||||
pttLoginId = "";
|
||||
indexGroupId ="";
|
||||
indexGroupName = "";
|
||||
keepAliveExecutor.shutdownNow();
|
||||
}
|
||||
|
||||
public static String getCurrentGroupId() {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public class SendAtUtil {
|
|||
*/
|
||||
public static void toCancelLogin() {
|
||||
send("050000\r\n");
|
||||
send("05000000\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -37,6 +38,7 @@ public class SendAtUtil {
|
|||
*/
|
||||
public static void toLogout() {
|
||||
send("040000\r\n");
|
||||
send("04000000\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ class AndroidInterface(private val activity: MainActivity) {
|
|||
"showJsonDialog" -> { showJsonDialog(args.optString(0, "")); "" }
|
||||
"getTempCallStatus" -> getTempCallStatus()
|
||||
"maximizeTempCall" -> { maximizeTempCall(); "" }
|
||||
"logout" -> { logout(); "" }
|
||||
else -> {
|
||||
Timber.tag("Bridge").w("Unknown method: $method")
|
||||
""
|
||||
|
|
@ -502,4 +503,8 @@ class AndroidInterface(private val activity: MainActivity) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun logout() {
|
||||
activity.logout()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.os.Bundle
|
|||
import android.view.KeyEvent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.widget.FrameLayout
|
||||
import com.example.kingway.ptt.CallBackResolution
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.geckoview.GeckoRuntime
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
|
|
@ -419,45 +420,78 @@ class MainActivity : AppCompatActivity() {
|
|||
.show()
|
||||
}
|
||||
|
||||
private fun pttLogoutAndDestroy() {
|
||||
fun logout() {
|
||||
runOnUiThread {
|
||||
Timber.tag("MainActivity").i("用户注销,清理程序")
|
||||
|
||||
// 1. PTT Logout and cancel login
|
||||
try {
|
||||
com.example.kingway.ptt.SendAtUtil.toCancelLogin()
|
||||
} catch (e: Exception) {
|
||||
Timber.tag("LoginActivity").e(e, "PTT cancel failed")
|
||||
Timber.tag("MainActivity").e(e, "PTT cancel failed")
|
||||
}
|
||||
try {
|
||||
com.example.kingway.ptt.SendAtUtil.toLogout()
|
||||
Timber.tag("LoginActivity").i("PTT logout sent")
|
||||
Timber.tag("MainActivity").i("PTT logout sent")
|
||||
} catch (e: Exception) {
|
||||
Timber.tag("LoginActivity").e(e, "PTT logout failed")
|
||||
Timber.tag("MainActivity").e(e, "PTT logout failed")
|
||||
}
|
||||
|
||||
// 2. Stop GPIO listening
|
||||
try {
|
||||
com.stand.standapp.utils.GpioManager.stopListening()
|
||||
Timber.tag("MainActivity").i("GPIO stop listening")
|
||||
} catch (e: Exception) {
|
||||
Timber.tag("MainActivity").e(e, "GPIO stop failed")
|
||||
}
|
||||
|
||||
// 3. Destroy/release AudioTrack in PTT Native
|
||||
try {
|
||||
com.stand.standapp.utils.GpioManager.stopListening()
|
||||
com.stand.standapp.MyApplication.pNative?.destory()
|
||||
com.stand.standapp.MyApplication.pNative = null
|
||||
Timber.tag("MainActivity").i("PTT native AudioTrack destroyed")
|
||||
} catch (e: Exception) {
|
||||
Timber.tag("LoginActivity").e(e, "GPIO stop failed")
|
||||
Timber.tag("MainActivity").e(e, "PTT native destroy failed")
|
||||
}
|
||||
|
||||
// 4. Stop and destroy AudioRecord
|
||||
try {
|
||||
com.example.kingway.ptt.AudioRecordManager.getInstance().destroyAudio()
|
||||
Timber.tag("MainActivity").i("AudioRecordManager destroyed")
|
||||
} catch (e: Exception) {
|
||||
Timber.tag("MainActivity").e(e, "AudioRecordManager destroy failed")
|
||||
}
|
||||
|
||||
// 5. Close printer connection
|
||||
try {
|
||||
com.stand.standapp.printer.PrinterManager.getFactory()?.ClosePort()
|
||||
Timber.tag("MainActivity").i("Printer port closed")
|
||||
} catch (e: Exception) {
|
||||
Timber.tag("MainActivity").e(e, "Printer close failed")
|
||||
}
|
||||
|
||||
// 6. Clear Access Token
|
||||
try {
|
||||
AppConfig.setAccessToken(this, "")
|
||||
Timber.tag("MainActivity").i("Cleared access token")
|
||||
} catch (e: Exception) {
|
||||
Timber.tag("MainActivity").e(e, "Failed to clear access token")
|
||||
}
|
||||
|
||||
// 7. Redirect back to LoginActivity and clear task stack
|
||||
try {
|
||||
val intent = Intent(this, LoginActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
startActivity(intent)
|
||||
finish()
|
||||
} catch (e: Exception) {
|
||||
Timber.tag("MainActivity").e(e, "Failed to redirect to LoginActivity")
|
||||
}
|
||||
try {
|
||||
// com.example.kingway.ptt.MyApplication.destroy()
|
||||
Timber.tag("LoginActivity").i("PTT native destroyed")
|
||||
CallBackResolution.resetPttLoginStatus();
|
||||
}catch (e: Exception) {
|
||||
Timber.tag("LoginActivity").e(e, "PTT destroy failed")
|
||||
Timber.tag("MainActivity").e(e, "Failed to clear public value")
|
||||
}
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue