Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9 #10

Merged
merged 5 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/manual_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
10 changes: 3 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
- 修复清除独立密码逻辑
- 不拦截某些静态共享库的卸载操作
- 支持使用Root激活
* Root激活和Xposed二选一即可,请勿同时使用
* 带后缀的为支持Root激活的构建,不带后缀的则只支持Xposed
* 如果不知道下载什么版本直接下载universal版本即可
- 升级版本号
- 修复首次安装Root激活失败的问题
- 如果你已经安装了LSPosed或者其他Xposed框架,请不要使用Root激活,这可能会导致系统软重启
- 如果你非要在装了Xposed框架的系统上用Root激活,也请在系统启动后过几分钟,再尝试用Root激活
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@
</intent-filter>
</receiver>

<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>

</manifest>
50 changes: 50 additions & 0 deletions app/src/main/java/cn/tinyhai/ban_uninstall/ui/screen/MainScreen.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 = {
Expand All @@ -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)
)
}
}
}
}
}
)
Expand Down
39 changes: 39 additions & 0 deletions app/src/main/java/cn/tinyhai/ban_uninstall/utils/Bugreport.kt
Original file line number Diff line number Diff line change
@@ -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
}
6 changes: 5 additions & 1 deletion app/src/main/java/cn/tinyhai/ban_uninstall/utils/Cli.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@
<string name="switch_subtitle_auto_start">Auto activate with root after system boot completed</string>
<string name="title_active_with_root">Activate With Root</string>
<string name="text_content_activate_with_root">Do you want to activate it with root right now?</string>
<string name="icon_description_bug_report">Bug Report</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@
<string name="switch_subtitle_auto_start">在系统启动后自动通过Root激活</string>
<string name="title_active_with_root">使用Root激活</string>
<string name="text_content_activate_with_root">是否立即使用Root权限激活?</string>
<string name="icon_description_bug_report">抓取日志</string>
</resources>
5 changes: 5 additions & 0 deletions app/src/main/res/xml/filepaths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>

<paths>
<cache-path name="cache" path="."/>
</paths>