Commit 50e2f33d authored by topjohnwu's avatar topjohnwu

More debug indication in UI

Close #5874
parent 5e6eb8dd
...@@ -52,13 +52,17 @@ object Info { ...@@ -52,13 +52,17 @@ object Info {
} }
} }
private fun loadState() = Env( private fun loadState(): Env {
fastCmd("magisk -v").split(":".toRegex())[0], val v = fastCmd("magisk -v").split(":".toRegex())
return Env(
v[0], v.size >= 3 && v[2] == "D",
runCatching { fastCmd("magisk -V").toInt() }.getOrDefault(-1) runCatching { fastCmd("magisk -V").toInt() }.getOrDefault(-1)
) )
}
class Env( class Env(
val versionString: String = "", val versionString: String = "",
val isDebug: Boolean = false,
code: Int = -1 code: Int = -1
) { ) {
val versionCode = when { val versionCode = when {
......
...@@ -57,7 +57,7 @@ class HomeViewModel( ...@@ -57,7 +57,7 @@ class HomeViewModel(
val magiskInstalledVersion val magiskInstalledVersion
get() = Info.env.run { get() = Info.env.run {
if (isActive) if (isActive)
"$versionString ($versionCode)".asText() ("$versionString ($versionCode)" + if (isDebug) " (D)" else "").asText()
else else
R.string.not_available.asText() R.string.not_available.asText()
} }
...@@ -93,8 +93,10 @@ class HomeViewModel( ...@@ -93,8 +93,10 @@ class HomeViewModel(
else -> MagiskState.UP_TO_DATE else -> MagiskState.UP_TO_DATE
} }
val isDebug = Config.updateChannel == Config.Value.DEBUG_CHANNEL
managerRemoteVersion = managerRemoteVersion =
"${magisk.version} (${magisk.versionCode}) (${stub.versionCode})".asText() ("${magisk.version} (${magisk.versionCode}) (${stub.versionCode})" +
if (isDebug) " (D)" else "").asText()
} ?: run { } ?: run {
state = State.LOADING_FAILED state = State.LOADING_FAILED
managerRemoteVersion = R.string.not_available.asText() managerRemoteVersion = R.string.not_available.asText()
......
...@@ -174,7 +174,11 @@ static void handle_request_async(int client, int code, const sock_cred &cred) { ...@@ -174,7 +174,11 @@ static void handle_request_async(int client, int code, const sock_cred &cred) {
static void handle_request_sync(int client, int code) { static void handle_request_sync(int client, int code) {
switch (code) { switch (code) {
case MainRequest::CHECK_VERSION: case MainRequest::CHECK_VERSION:
write_string(client, MAGISK_VERSION ":MAGISK"); #if MAGISK_DEBUG
write_string(client, MAGISK_VERSION ":MAGISK:D");
#else
write_string(client, MAGISK_VERSION ":MAGISK:R");
#endif
break; break;
case MainRequest::CHECK_VERSION_CODE: case MainRequest::CHECK_VERSION_CODE:
write_int(client, MAGISK_VER_CODE); write_int(client, MAGISK_VER_CODE);
......
...@@ -52,7 +52,11 @@ int magisk_main(int argc, char *argv[]) { ...@@ -52,7 +52,11 @@ int magisk_main(int argc, char *argv[]) {
if (argc < 2) if (argc < 2)
usage(); usage();
if (argv[1] == "-c"sv) { if (argv[1] == "-c"sv) {
printf(MAGISK_VERSION ":MAGISK (" str(MAGISK_VER_CODE) ")\n"); #if MAGISK_DEBUG
printf(MAGISK_VERSION ":MAGISK:D (" str(MAGISK_VER_CODE) ")\n");
#else
printf(MAGISK_VERSION ":MAGISK:R (" str(MAGISK_VER_CODE) ")\n");
#endif
return 0; return 0;
} else if (argv[1] == "-v"sv) { } else if (argv[1] == "-v"sv) {
int fd = connect_daemon(MainRequest::CHECK_VERSION); int fd = connect_daemon(MainRequest::CHECK_VERSION);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment