manager: Add send log
This commit is contained in:
@@ -32,6 +32,16 @@
|
|||||||
android:name="android.app.lib_name"
|
android:name="android.app.lib_name"
|
||||||
android:value="" />
|
android:value="" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="${applicationId}.fileprovider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/filepaths" />
|
||||||
|
</provider>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -1,25 +1,27 @@
|
|||||||
package me.weishu.kernelsu.ui.screen
|
package me.weishu.kernelsu.ui.screen
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.ArrowBack
|
import androidx.compose.material.icons.filled.ArrowBack
|
||||||
import androidx.compose.material.icons.filled.Info
|
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.core.content.FileProvider
|
||||||
import com.alorma.compose.settings.storage.base.SettingValueState
|
|
||||||
import com.alorma.compose.settings.ui.*
|
import com.alorma.compose.settings.ui.*
|
||||||
import com.ramcosta.composedestinations.annotation.Destination
|
import com.ramcosta.composedestinations.annotation.Destination
|
||||||
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
|
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
|
||||||
|
import me.weishu.kernelsu.ui.util.getBugreportFile
|
||||||
|
import me.weishu.kernelsu.BuildConfig
|
||||||
import me.weishu.kernelsu.R
|
import me.weishu.kernelsu.R
|
||||||
import me.weishu.kernelsu.ui.util.LinkifyText
|
import me.weishu.kernelsu.ui.util.LinkifyText
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author weishu
|
* @author weishu
|
||||||
* @date 2023/1/1.
|
* @date 2023/1/1.
|
||||||
@@ -76,6 +78,26 @@ fun SettingScreen(navigator: DestinationsNavigator) {
|
|||||||
Toast.makeText(context, "coming soon", Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, "coming soon", Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
SettingsMenuLink(title = {
|
||||||
|
Text(stringResource(id = R.string.send_log))
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
val bugreport = getBugreportFile(context)
|
||||||
|
val uri: Uri = FileProvider.getUriForFile(context, "${BuildConfig.APPLICATION_ID}.fileprovider", bugreport)
|
||||||
|
|
||||||
|
val shareIntent = Intent(Intent.ACTION_SEND)
|
||||||
|
shareIntent.putExtra(Intent.EXTRA_STREAM, uri)
|
||||||
|
shareIntent.setDataAndType(uri, "application/zip")
|
||||||
|
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
|
|
||||||
|
context.startActivity(
|
||||||
|
Intent.createChooser(
|
||||||
|
shareIntent,
|
||||||
|
context.getString(R.string.send_log)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
SettingsMenuLink(title = {
|
SettingsMenuLink(title = {
|
||||||
Text(stringResource(id = R.string.about))
|
Text(stringResource(id = R.string.about))
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package me.weishu.kernelsu.ui.util
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
|
import android.system.Os
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileWriter
|
||||||
|
import java.io.PrintWriter
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
|
fun getBugreportFile(context: Context): File {
|
||||||
|
|
||||||
|
val bugreportDir = File(context.cacheDir, "bugreport")
|
||||||
|
bugreportDir.mkdirs()
|
||||||
|
|
||||||
|
val dmesgFile = File(bugreportDir, "dmesg.txt")
|
||||||
|
val logcatFile = File(bugreportDir, "logcat.txt")
|
||||||
|
val tombstonesFile = File(bugreportDir, "tombstones.tar.gz")
|
||||||
|
val dropboxFile = File(bugreportDir, "dropbox.tar.gz")
|
||||||
|
|
||||||
|
val shell = createRootShell()
|
||||||
|
|
||||||
|
shell.newJob().add("dmesg > ${dmesgFile.absolutePath}").exec()
|
||||||
|
shell.newJob().add("logcat -d > ${logcatFile.absolutePath}").exec()
|
||||||
|
shell.newJob().add("tar -czf ${tombstonesFile.absolutePath} /data/tombstones").exec()
|
||||||
|
shell.newJob().add("tar -czf ${dropboxFile.absolutePath} /data/system/dropbox").exec()
|
||||||
|
|
||||||
|
// build.prop
|
||||||
|
val buildInfo = File(bugreportDir, "basic.txt")
|
||||||
|
PrintWriter(FileWriter(buildInfo)).use { pw ->
|
||||||
|
pw.println("Kernel: ${System.getProperty("os.version")}")
|
||||||
|
pw.println("BRAND: " + Build.BRAND)
|
||||||
|
pw.println("MODEL: " + Build.MODEL)
|
||||||
|
pw.println("PRODUCT: " + Build.PRODUCT)
|
||||||
|
pw.println("MANUFACTURER: " + Build.MANUFACTURER)
|
||||||
|
pw.println("SDK: " + Build.VERSION.SDK_INT)
|
||||||
|
pw.println("PREVIEW_SDK: " + Build.VERSION.PREVIEW_SDK_INT)
|
||||||
|
pw.println("FINGERPRINT: " + Build.FINGERPRINT)
|
||||||
|
pw.println("DEVICE: " + Build.DEVICE)
|
||||||
|
val packageInfo =
|
||||||
|
context.packageManager.getPackageInfo(context.packageName, 0)
|
||||||
|
pw.println("PACKAGE: " + packageInfo.packageName)
|
||||||
|
pw.println("VERSION: " + packageInfo.versionName)
|
||||||
|
|
||||||
|
val uname = Os.uname()
|
||||||
|
pw.println("KernelRelease: ${uname.release}")
|
||||||
|
pw.println("KernelVersion: ${uname.version}")
|
||||||
|
pw.println("Mahcine: ${uname.machine}")
|
||||||
|
pw.println("Nodename: ${uname.nodename}")
|
||||||
|
pw.println("Sysname: ${uname.sysname}")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// modules
|
||||||
|
val modulesFile = File(bugreportDir, "modules.json")
|
||||||
|
modulesFile.writeText(listModules())
|
||||||
|
|
||||||
|
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH_mm")
|
||||||
|
val current = LocalDateTime.now().format(formatter)
|
||||||
|
|
||||||
|
val targetFile = File(context.cacheDir, "KernelSU_bugreport_${current}.tar.gz")
|
||||||
|
|
||||||
|
shell.newJob().add("tar czf ${targetFile.absolutePath} -C ${bugreportDir.absolutePath} .").exec()
|
||||||
|
shell.newJob().add("rm -rf ${bugreportDir.absolutePath}").exec()
|
||||||
|
shell.newJob().add("chmod 0644 ${targetFile.absolutePath}").exec()
|
||||||
|
|
||||||
|
return targetFile;
|
||||||
|
}
|
||||||
@@ -49,4 +49,5 @@
|
|||||||
<string name="refresh">刷新</string>
|
<string name="refresh">刷新</string>
|
||||||
<string name="show_system_apps">显示系统应用</string>
|
<string name="show_system_apps">显示系统应用</string>
|
||||||
<string name="hide_system_apps">隐藏系统应用</string>
|
<string name="hide_system_apps">隐藏系统应用</string>
|
||||||
|
<string name="send_log">发送日志</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -53,5 +53,6 @@
|
|||||||
<string name="refresh">Refresh</string>
|
<string name="refresh">Refresh</string>
|
||||||
<string name="show_system_apps">Show system apps</string>
|
<string name="show_system_apps">Show system apps</string>
|
||||||
<string name="hide_system_apps">Hide system apps</string>
|
<string name="hide_system_apps">Hide system apps</string>
|
||||||
|
<string name="send_log">Send Log</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
6
manager/app/src/main/res/xml/filepaths.xml
Normal file
6
manager/app/src/main/res/xml/filepaths.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<paths>
|
||||||
|
<cache-path name="cache" path="."/>
|
||||||
|
<root-path name="root" path="." />
|
||||||
|
</paths>
|
||||||
Reference in New Issue
Block a user