[debugview 添加杀死APP]
This commit is contained in:
yangyakun
2023-08-21 17:51:55 +08:00
parent 9ddb562bb7
commit 5c056cf0af
2 changed files with 25 additions and 0 deletions

View File

@@ -89,6 +89,7 @@ import kotlin.collections.component3
import kotlin.collections.component4
import kotlin.collections.set
import kotlin.math.abs
import kotlin.system.exitProcess
/**
@@ -745,6 +746,9 @@ internal class DebugSettingView @JvmOverloads constructor(
CallerAutoPilotControlManager.sendIpcReboot()
ToastUtils.showLong("重启命令已发送")
}
btnAppReboot.onClick {
killApp()
}
//只在司机端设置工控机节点重启功能
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
btnIpcReboot.visibility = View.GONE
@@ -2035,6 +2039,17 @@ internal class DebugSettingView @JvmOverloads constructor(
}
}
private fun killApp() {
Intent(Intent.ACTION_MAIN).apply {
addCategory(Intent.CATEGORY_HOME)
flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(this)
Process.killProcess(Process.myPid())
exitProcess(0)
}
}
/**
* 初始化上报
*/

View File

@@ -333,6 +333,16 @@
android:padding="@dimen/dp_20"
android:textSize="@dimen/dp_24" />
<Button
android:id="@+id/btnAppReboot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:background="@drawable/radio_button_normal_background_right"
android:text="杀死APP"
android:padding="@dimen/dp_20"
android:textSize="@dimen/dp_24" />
<ToggleButton
android:id="@+id/tbDeviceBind"
android:layout_width="match_parent"