mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-06 10:45:49 +08:00
Merge code
This commit is contained in:
@@ -329,12 +329,19 @@ fun findPropString(key: String, default: String = "") = safeOf(default) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行命令 - su
|
* 是否有 Root 权限
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
val isRootAccess get() = safeOfFalse { Shell.rootAccess() }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行命令
|
||||||
* @param cmd 命令
|
* @param cmd 命令
|
||||||
|
* @param isSu 是否使用 Root 权限执行 - 默认:是
|
||||||
* @return [String] 执行结果
|
* @return [String] 执行结果
|
||||||
*/
|
*/
|
||||||
fun execShellSu(cmd: String) = safeOfNothing {
|
fun execShell(cmd: String, isSu: Boolean = true) = safeOfNothing {
|
||||||
Shell.su(cmd).exec().out.let {
|
(if (isSu) Shell.su(cmd) else Shell.sh(cmd)).exec().out.let {
|
||||||
if (it.isNotEmpty()) it[0].trim() else ""
|
if (it.isNotEmpty()) it[0].trim() else ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -86,9 +86,9 @@ object SystemUITool {
|
|||||||
msg = "你确定要立即重启系统界面吗?\n\n" +
|
msg = "你确定要立即重启系统界面吗?\n\n" +
|
||||||
"重启过程会黑屏并等待进入锁屏重新解锁。"
|
"重启过程会黑屏并等待进入锁屏重新解锁。"
|
||||||
confirmButton {
|
confirmButton {
|
||||||
execShellSu(cmd = "pgrep systemui").also { pid ->
|
execShell(cmd = "pgrep systemui").also { pid ->
|
||||||
if (pid.isNotBlank())
|
if (pid.isNotBlank())
|
||||||
execShellSu(cmd = "kill -9 $pid")
|
execShell(cmd = "kill -9 $pid")
|
||||||
else toast(msg = "ROOT 权限获取失败")
|
else toast(msg = "ROOT 权限获取失败")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user