Skip to content

Commit

Permalink
Support activate with root (#8)
Browse files Browse the repository at this point in the history
* support active using root

* add auto start for root mode

* fix clear pin

* Bump to v1.3.0
  • Loading branch information
TinyHai authored May 14, 2024
1 parent bb8b57c commit 840c2fa
Show file tree
Hide file tree
Showing 40 changed files with 1,213 additions and 494 deletions.
122 changes: 118 additions & 4 deletions .github/workflows/manual_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,127 @@ on:
default: false

jobs:
build:
build_inject_tool:
runs-on: ubuntu-latest
steps:
- name: Checking out InjectTool
uses: actions/checkout@v4
with:
repository: TinyHai/InjectTool
fetch-depth: 0

- name: Setup rustup
run: |
rustup update stable
- uses: Swatinem/rust-cache@v2
with:
cache-targets: false

- name: Install cross
run: |
cargo install cross --git https://github.com/cross-rs/cross --rev 66845c1
- name: Build InejctTool
run: |
./build.sh
- name: Upload InjectTool
uses: actions/upload-artifact@v4
with:
name: InjectTool
path: out/

build_lspatch:
runs-on: ubuntu-latest
steps:
- name: Checking out LSPatch
uses: actions/checkout@v4
with:
repository: TinyHai/LSPatch
ref: 'dev'
submodules: 'recursive'
fetch-depth: 0

- name: Checkout libxposed/api
uses: actions/checkout@v4
with:
ref: 'a42f85d06eac3373d266a534ab3b31a584b30774'
repository: libxposed/api
path: libxposed/api

- name: Checkout libxposed/service
uses: actions/checkout@v4
with:
ref: '4351a735755c86c031a977a62e52005b23048c4d'
repository: libxposed/service
path: libxposed/service

- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

- name: Set up ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
max-size: 2G
key: ${{ runner.os }}
restore-keys: ${{ runner.os }}
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}

- name: Build dependencies
working-directory: libxposed
run: |
cd api
echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
./gradlew :api:publishApiPublicationToMavenLocal
cd ..
cd service
echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
./gradlew :interface:publishInterfacePublicationToMavenLocal
- name: Build with Gradle
run: |
echo 'org.gradle.parallel=true' >> gradle.properties
echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
echo 'android.native.buildOutput=verbose' >> gradle.properties
./gradlew buildAll
- name: Upload Release Assets
uses: actions/upload-artifact@v4
with:
name: LSPatchReleaseAssets
path: out/assets/release/
- name: Upload Debug Assets
uses: actions/upload-artifact@v4
with:
name: LSPatchDebugAssets
path: out/assets/debug/


build_apk:
needs: [build_inject_tool, build_lspatch]
runs-on: ubuntu-latest
steps:
- name: Checking out branch
uses: actions/checkout@v4

- name: Download LSPatchReleaseAssets
uses: actions/download-artifact@v4
with:
name: LSPatchReleaseAssets
path: app/src/main/assets
- name: Download InjectTool
uses: actions/download-artifact@v4
with:
name: InjectTool
path: app/src/main/jniLibs

- name: Setup Java
uses: actions/setup-java@v4
with:
Expand All @@ -37,7 +151,7 @@ jobs:
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
./gradlew clean assembleRelease
./gradlew clean buildRelease
- name: Generate tag name
run: |
Expand All @@ -49,7 +163,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: BanUninstall
path: app/build/outputs/apk/release/*.apk
path: app/build/outputs/apk/**/*.apk

- name: Release to current repository
uses: softprops/action-gh-release@v2
Expand All @@ -59,7 +173,7 @@ jobs:
body_path: ${{ github.workspace }}/CHANGELOG.md
token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
files: |
app/build/outputs/apk/release/*.apk
app/build/outputs/apk/**/*.apk
- name: Release to xposed module repository
uses: softprops/action-gh-release@v2
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
- 修复v1.2.0引入的bug(未加入禁止列表的应用也被拦截)
- 修复清除独立密码逻辑
- 不拦截某些静态共享库的卸载操作
- 支持使用Root激活
* Root激活和Xposed二选一即可,请勿同时使用
* 带后缀的为支持Root激活的构建,不带后缀的则只支持Xposed
* 如果不知道下载什么版本直接下载universal版本即可
- 升级版本号
6 changes: 5 additions & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/build
/build

**/assets/lspatch

**/jniLibs/**/*.so
141 changes: 107 additions & 34 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ fun String.execute(): String {
return String(byteOut.toByteArray()).trim()
}

val allArch: Array<String> by rootProject.ext

android {
namespace = "cn.tinyhai.ban_uninstall"
compileSdk = 34
Expand All @@ -34,13 +36,16 @@ android {
applicationId = "cn.tinyhai.ban_uninstall"
minSdk = 21
targetSdk = 34
versionCode = 4
versionName = "1.2.1"
versionCode = 5
versionName = "1.3.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
debug {
versionNameSuffix = "-${"git rev-parse --verify --short HEAD".execute()}_debug"
}
release {
isMinifyEnabled = true
proguardFiles(
Expand All @@ -50,6 +55,37 @@ android {
signingConfig = signingConfigs.getByName("release")
versionNameSuffix = "-${"git rev-parse --verify --short HEAD".execute()}"
}

allArch.forEach { arch ->
register(arch) {
initWith(getByName("release"))
versionNameSuffix = "${versionNameSuffix}_$arch"
ndk {
abiFilters.clear()
abiFilters += if (arch == "universal") arrayOf(
"arm64-v8a",
"armeabi-v7a",
"x86",
"x86_64"
) else arrayOf(arch)
}
}
}

all {
matchingFallbacks += "release"
val fieldValue = when (this.name) {
"debug", in allArch -> "true"
else -> "false"
}
buildConfigField("boolean", "ROOT_FEATURE", fieldValue)
}
}

packaging {
jniLibs {
useLegacyPackaging = true
}
}

buildFeatures {
Expand All @@ -75,45 +111,81 @@ afterEvaluate {
val flavor = flavorName
val versionCode = versionCode
val versionName = this.versionName
val renameTaskName =
"rename${flavor.uppercaseFirstChar()}${buildType.uppercaseFirstChar()}Output"
tasks.register(renameTaskName) {
val apkName = buildString {
append("app")
if (flavor.isNotBlank()) {
append("-$flavor")
}
append("-$buildType")
append(".apk")

val apkName = buildString {
append("app")
if (flavor.isNotBlank()) {
append("-$flavor")
}
append("-$buildType")
append(".apk")
}
val newApkName = "${rootProject.name}_$versionName.apk"
val apkPath = buildString {
append(layout.buildDirectory.asFile.get().path)
append("/outputs/apk/")
if (flavor.isNotBlank()) {
append("$flavor/")
}
val newApkName = "${rootProject.name}_$versionName.apk"
val apkPath = buildString {
append(layout.buildDirectory.asFile.get().path)
append("/outputs/apk/")
if (flavor.isNotBlank()) {
append("$flavor/")
append(buildType)
}
val apkFile = File(apkPath, apkName)

val renameTask =
tasks.register("rename${flavor.uppercaseFirstChar()}${buildType.uppercaseFirstChar()}Output") {
doLast {
apkFile.renameTo(File(apkPath, newApkName))
}
append(buildType)
}
val apkFile = File(apkPath, apkName)
doLast {
apkFile.renameTo(File(apkPath, newApkName))
val versionCodeFile = File(apkPath, "versionCode")
.apply { if (!exists()) createNewFile() }
versionCodeFile.bufferedWriter().use {
it.append(versionCode.toString())
it.flush()

val assembleTask =
tasks.findByName("assemble${flavor.uppercaseFirstChar()}${buildType.uppercaseFirstChar()}")
assembleTask?.finalizedBy(renameTask)

when (buildType) {
"release" -> {
assembleTask?.doLast {
val versionCodeFile = File(apkPath, "versionCode")
.apply { if (!exists()) createNewFile() }
versionCodeFile.bufferedWriter().use {
it.append(versionCode.toString())
it.flush()
}
val versionNameFile = File(apkPath, "versionName")
.apply { if (!exists()) createNewFile() }
versionNameFile.bufferedWriter().use {
it.append(versionName)
it.flush()
}
}
val versionNameFile = File(apkPath, "versionName")
.apply { if (!exists()) createNewFile() }
versionNameFile.bufferedWriter().use {
it.append(versionName)
it.flush()

tasks.findByName("strip${buildType.uppercaseFirstChar()}DebugSymbols")?.doLast {
file(this.outputs.files.asPath).let { if (it.exists()) it.deleteRecursively() }
}

tasks.findByName("merge${flavor.uppercaseFirstChar()}${buildType.uppercaseFirstChar()}Assets")
?.doLast {
val lspatchDir = file(this.outputs.files.asPath).resolve("lspatch")
if (lspatchDir.exists()) {
lspatchDir.deleteRecursively()
}
}
}

in allArch -> {
tasks.findByName("merge${flavor.uppercaseFirstChar()}${buildType.uppercaseFirstChar()}Assets")
?.doLast {
val soDir = file(this.outputs.files.asPath).resolve("lspatch").resolve("so")
soDir.listFiles()?.filter { it.isDirectory }?.forEach {
if (it.name != buildType) {
it.deleteRecursively()
}
}
}
}

"universal", "debug" -> {}
}
tasks.findByName("assemble${flavor.uppercaseFirstChar()}${buildType.uppercaseFirstChar()}")
?.finalizedBy(renameTaskName)
}
}

Expand All @@ -134,6 +206,7 @@ dependencies {
implementation(libs.coil.compose)
implementation(libs.compose.destinations.core)
implementation(libs.compose.destinations.bottomsheet)
implementation(libs.libsu.core)
implementation("com.github.TinyHai:ComposeDragDrop:dev-SNAPSHOT")
implementation(project(":hook"))
ksp(project(":processor"))
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

<uses-sdk tools:overrideLibrary="cn.tinyhai.compose.dragdrop" />

<uses-permission
android:name="android.permission.RECEIVE_BOOT_COMPLETED"
android:required="false" />

<application
android:name=".App"
android:allowBackup="true"
Expand Down Expand Up @@ -46,6 +50,16 @@
android:noHistory="true"
android:taskAffinity=".Auth"
android:theme="@style/Theme.AppCompat.DayNight.Dialog" />

<receiver
android:name=".receiver.BootCompletedReceiver"
android:enabled="false"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

</application>

</manifest>
Loading

0 comments on commit 840c2fa

Please sign in to comment.