From 82f303e1c66e094bb9465bd2aae81c3b5da5dc67 Mon Sep 17 00:00:00 2001 From: vvb2060 Date: Wed, 8 Sep 2021 12:05:49 +0800 Subject: [PATCH] Allow save app log when not activated may be useful for patch boot. --- .../com/topjohnwu/magisk/data/repository/LogRepository.kt | 7 ++++++- app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt | 1 - .../main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/data/repository/LogRepository.kt b/app/src/main/java/com/topjohnwu/magisk/data/repository/LogRepository.kt index 765e625cd..7973fe4a7 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/repository/LogRepository.kt +++ b/app/src/main/java/com/topjohnwu/magisk/data/repository/LogRepository.kt @@ -1,6 +1,7 @@ package com.topjohnwu.magisk.data.repository import com.topjohnwu.magisk.core.Const +import com.topjohnwu.magisk.core.Info import com.topjohnwu.magisk.core.model.su.SuLog import com.topjohnwu.magisk.data.database.SuLogDao import com.topjohnwu.magisk.ktx.await @@ -27,7 +28,11 @@ class LogRepository( } } } - Shell.su("cat ${Const.MAGISK_LOG}").to(list).await() + if (Info.env.isActive) { + Shell.su("cat ${Const.MAGISK_LOG} || logcat -d -s Magisk").to(list).await() + } else { + Shell.sh("logcat -d").to(list).await() + } return list.buf.toString() } diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt index 4562bb740..582d1ea08 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt @@ -99,7 +99,6 @@ open class MainActivity : BaseUIActivity( super.onResume() binding.mainNavigation.menu.apply { findItem(R.id.superuserFragment)?.isEnabled = Utils.showSuperUser() - findItem(R.id.logFragment)?.isEnabled = Info.env.isActive } } diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt index a96c31163..bee42cad3 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt @@ -66,7 +66,7 @@ class LogViewModel( ProcessBuilder("getprop").start() .inputStream.reader().use { it.copyTo(file) } - file.write("---System MountInfo---\n\n") + file.write("\n\n---System MountInfo---\n\n") FileInputStream("/proc/self/mountinfo").reader().use { it.copyTo(file) } file.write("\n---Magisk Logs---\n")