diff --git a/.github/workflows/manual_release.yml b/.github/workflows/manual_release.yml index a8e59b1..4407bbd 100644 --- a/.github/workflows/manual_release.yml +++ b/.github/workflows/manual_release.yml @@ -2,11 +2,16 @@ name: Manual Release on: workflow_dispatch: inputs: + draft: + description: "Publish as draft" + type: boolean + default: true publish: description: "Publish to Xposed Module Repository" type: boolean default: false + jobs: build_inject_tool: runs-on: ubuntu-latest @@ -168,7 +173,8 @@ jobs: - name: Release to current repository uses: softprops/action-gh-release@v2 with: - name: BanUninstall + name: ${{ format('BanUninstall_{0}', env.TAG_NAME) }} + draft: ${{ inputs.draft }} tag_name: ${{ env.TAG_NAME }} body_path: ${{ github.workspace }}/CHANGELOG.md token: ${{ secrets.CUSTOM_GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index b28f4cd..bdb58ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,3 @@ -- 修复清除独立密码逻辑 -- 不拦截某些静态共享库的卸载操作 -- 支持使用Root激活 - * Root激活和Xposed二选一即可,请勿同时使用 - * 带后缀的为支持Root激活的构建,不带后缀的则只支持Xposed - * 如果不知道下载什么版本直接下载universal版本即可 -- 升级版本号 \ No newline at end of file +- 修复首次安装Root激活失败的问题 +- 如果你已经安装了LSPosed或者其他Xposed框架,请不要使用Root激活,这可能会导致系统软重启 +- 如果你非要在装了Xposed框架的系统上用Root激活,也请在系统启动后过几分钟,再尝试用Root激活 \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8349fac..68bdc86 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -36,8 +36,8 @@ android { applicationId = "cn.tinyhai.ban_uninstall" minSdk = 21 targetSdk = 34 - versionCode = 5 - versionName = "1.3.0" + versionCode = 6 + versionName = "1.3.1" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 21ba214..f0e7573 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -60,6 +60,16 @@ + + + + \ No newline at end of file diff --git a/app/src/main/java/cn/tinyhai/ban_uninstall/ui/screen/MainScreen.kt b/app/src/main/java/cn/tinyhai/ban_uninstall/ui/screen/MainScreen.kt index d3771f2..fa99350 100644 --- a/app/src/main/java/cn/tinyhai/ban_uninstall/ui/screen/MainScreen.kt +++ b/app/src/main/java/cn/tinyhai/ban_uninstall/ui/screen/MainScreen.kt @@ -1,5 +1,6 @@ package cn.tinyhai.ban_uninstall.ui.screen +import android.content.Intent import android.widget.Toast import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.layout.Column @@ -8,6 +9,7 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.BugReport import androidx.compose.material.icons.outlined.Cancel import androidx.compose.material.icons.outlined.CheckCircle import androidx.compose.material.icons.outlined.Sms @@ -19,12 +21,15 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.* import androidx.compose.ui.window.PopupPositionProvider +import androidx.core.content.FileProvider import androidx.lifecycle.viewmodel.compose.viewModel +import cn.tinyhai.ban_uninstall.BuildConfig import cn.tinyhai.ban_uninstall.R import cn.tinyhai.ban_uninstall.transact.entities.ActiveMode import cn.tinyhai.ban_uninstall.ui.component.rememberConfirmDialog import cn.tinyhai.ban_uninstall.ui.component.rememberSetPwdDialog import cn.tinyhai.ban_uninstall.ui.component.rememberVerifyPwdDialog +import cn.tinyhai.ban_uninstall.utils.getLogcatFile import cn.tinyhai.ban_uninstall.vm.MainState import cn.tinyhai.ban_uninstall.vm.MainViewModel import com.alorma.compose.settings.ui.SettingsGroup @@ -49,6 +54,8 @@ fun MainScreen(navigator: DestinationsNavigator) { title = { Text(text = stringResource(id = R.string.app_title_main)) }, actions = { if (state.isActive) { + val context = LocalContext.current + val scope = rememberCoroutineScope() TooltipBox( positionProvider = rememberTooltipPositionProvider(), tooltip = { @@ -68,6 +75,49 @@ fun MainScreen(navigator: DestinationsNavigator) { ) } } + if (BuildConfig.ROOT_FEATURE) { + TooltipBox( + positionProvider = rememberTooltipPositionProvider(), + tooltip = { + Surface( + color = MaterialTheme.colorScheme.secondaryContainer, + shape = RoundedCornerShape(4.dp), + ) { + Text(text = stringResource(R.string.icon_description_bug_report)) + } + }, + state = rememberTooltipState() + ) { + IconButton( + onClick = { + scope.launch { + val logcatFile = getLogcatFile() + val uri = FileProvider.getUriForFile( + context, + "${BuildConfig.APPLICATION_ID}.fileprovider", + logcatFile + ) + val shareIntent = Intent(Intent.ACTION_SEND) + shareIntent.putExtra(Intent.EXTRA_STREAM, uri) + shareIntent.setDataAndType(uri, "text/*") + shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + + context.startActivity( + Intent.createChooser( + shareIntent, + context.getString(R.string.icon_description_bug_report) + ) + ) + } + } + ) { + Icon( + Icons.Outlined.BugReport, + contentDescription = stringResource(R.string.icon_description_bug_report) + ) + } + } + } } } ) diff --git a/app/src/main/java/cn/tinyhai/ban_uninstall/utils/Bugreport.kt b/app/src/main/java/cn/tinyhai/ban_uninstall/utils/Bugreport.kt new file mode 100644 index 0000000..bf61a0c --- /dev/null +++ b/app/src/main/java/cn/tinyhai/ban_uninstall/utils/Bugreport.kt @@ -0,0 +1,39 @@ +package cn.tinyhai.ban_uninstall.utils + +import android.annotation.SuppressLint +import cn.tinyhai.ban_uninstall.App +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import java.io.File +import java.text.SimpleDateFormat +import java.util.GregorianCalendar + +@SuppressLint("SimpleDateFormat") +suspend fun getLogcatFile() = withContext(Dispatchers.IO) { + val cacheDir = App.app.cacheDir + val bugreportDir = File(cacheDir, "bugreport").also { it.mkdirs() } + val time = GregorianCalendar.getInstance().time + val formatter = SimpleDateFormat("yyyy-MM-dd_HH_mm") + val logcatFile = File(bugreportDir, "logcat.txt") + fastResultWithRootShell("logcat", "-d", ">", logcatFile.absolutePath) + val bugreportFile = File(cacheDir, "BanUninstall_bugreport_${formatter.format(time)}.tar.gz") + fastResultWithRootShell( + "tar", + "-czf", + bugreportFile.absolutePath, + "-C", + bugreportDir.absolutePath, + "." + ) + fastResultWithRootShell( + "rm", + "-rf", + bugreportDir.absolutePath + ) + fastResultWithRootShell( + "chmod", + "0644", + bugreportFile.absolutePath + ) + bugreportFile +} \ No newline at end of file diff --git a/app/src/main/java/cn/tinyhai/ban_uninstall/utils/Cli.kt b/app/src/main/java/cn/tinyhai/ban_uninstall/utils/Cli.kt index 8ec590e..6021ad3 100644 --- a/app/src/main/java/cn/tinyhai/ban_uninstall/utils/Cli.kt +++ b/app/src/main/java/cn/tinyhai/ban_uninstall/utils/Cli.kt @@ -73,7 +73,11 @@ private suspend fun copyPrefsToTmp(filename: String) = withContext(Dispatchers.I Environment.getDataDirectory().absolutePath + File.separator + "data" + File.separator + BuildConfig.APPLICATION_ID val prefDir = appDataDir + File.separator + "shared_prefs" val prefFile = prefDir + File.separator + prefName - fastResultWithRootShell("cp", prefFile, LSPATCH_PATH) + if (File(prefFile).exists()) { + fastResultWithRootShell("cp", prefFile, LSPATCH_PATH) + } else { + true + } } private suspend fun setFilesPermission() = withContext(Dispatchers.IO) { diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index c227d08..c2c7724 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -54,4 +54,5 @@ Auto activate with root after system boot completed Activate With Root Do you want to activate it with root right now? + Bug Report \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bc7c318..d1fa3a6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -53,4 +53,5 @@ 在系统启动后自动通过Root激活 使用Root激活 是否立即使用Root权限激活? + 抓取日志 \ No newline at end of file diff --git a/app/src/main/res/xml/filepaths.xml b/app/src/main/res/xml/filepaths.xml new file mode 100644 index 0000000..3c390ff --- /dev/null +++ b/app/src/main/res/xml/filepaths.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file