Skip to content

Commit 47633ed

Browse files
CopilotDerGoogler
andcommitted
Remove API bypass SDK dependencies and refactor code
Co-authored-by: DerGoogler <54764558+DerGoogler@users.noreply.github.com>
1 parent 5257d11 commit 47633ed

7 files changed

Lines changed: 0 additions & 48 deletions

File tree

app/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ dependencies {
193193

194194
implementation(libs.kotlin.stdlib)
195195

196-
implementation(libs.hiddenApiBypass)
197196
// implementation(libs.timber)
198197
implementation(libs.arbor.jvm)
199198
implementation(libs.arbor.android)
@@ -205,7 +204,6 @@ dependencies {
205204
implementation(libs.libsu.service)
206205
implementation(libs.libsu.io)
207206

208-
implementation(libs.rikka.refine.runtime)
209207
implementation(libs.rikka.shizuku.api)
210208
implementation(libs.rikka.shizuku.provider)
211209

app/src/main/kotlin/com/dergoogler/mmrl/App.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ class App : Application() {
1919
super.onCreate()
2020
app = this
2121

22-
PlatformManager.setHiddenApiExemptions()
23-
2422
NotificationUtils.init(this)
2523
NetworkUtils.setCacheDir(cacheDir)
2624
}

gradle/libs.versions.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ androidxRoom = "2.7.2"
2424
browser = "1.8.0"
2525
coilCompose = "2.7.0"
2626
composeMarkdown = "0.5.4"
27-
hiddenApiRefine = "4.4.0"
2827
hilt = "2.51.1"
2928
kotlin = "2.0.0"
3029
kotlinReflect = "1.9.24"
@@ -115,9 +114,6 @@ multiplatform-markdown-renderer-m3 = { module = "com.mikepenz:multiplatform-mark
115114
process-phoenix = { module = "com.jakewharton:process-phoenix", version.ref = "processPhoenix" }
116115
protobuf-kotlin-lite = { group = "com.google.protobuf", name = "protobuf-kotlin-lite", version.ref = "protobuf" }
117116
protobuf-protoc = { group = "com.google.protobuf", name = "protoc", version.ref = "protobuf" }
118-
rikka-refine-annotation = { module = "dev.rikka.tools.refine:annotation", version.ref = "hiddenApiRefine" }
119-
rikka-refine-compiler = { module = "dev.rikka.tools.refine:annotation-processor", version.ref = "hiddenApiRefine" }
120-
rikka-refine-runtime = { module = "dev.rikka.tools.refine:runtime", version.ref = "hiddenApiRefine" }
121117
rikka-shizuku-api = { module = "dev.rikka.shizuku:api", version.ref = "shizuku" }
122118
rikka-shizuku-provider = { module = "dev.rikka.shizuku:provider", version.ref = "shizuku" }
123119
semver = { module = "io.github.z4kn4fein:semver", version.ref = "semver" }
@@ -133,7 +129,6 @@ square-moshi-kotlin = { group = "com.squareup.moshi", name = "moshi-kotlin-codeg
133129
dev-rikka-rikkax-parcelablelist = { module = "dev.rikka.rikkax.parcelablelist:parcelablelist", version.ref = "parcelablelist" }
134130

135131
markwon-core = "io.noties.markwon:core:4.6.2"
136-
hiddenApiBypass = "org.lsposed.hiddenapibypass:hiddenapibypass:4.3"
137132
timber = "com.jakewharton.timber:timber:5.0.1"
138133

139134
# Dependencies of the included build-logic
@@ -161,7 +156,6 @@ hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
161156
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
162157
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
163158
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
164-
rikka-refine = { id = "dev.rikka.tools.refine", version.ref = "hiddenApiRefine" }
165159
protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" }
166160
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
167161

hidden-api/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,5 @@ android {
2424
}
2525

2626
dependencies {
27-
annotationProcessor(libs.rikka.refine.compiler)
28-
compileOnly(libs.rikka.refine.annotation)
2927
compileOnly(libs.androidx.annotation)
3028
}

hidden-api/src/main/java/android/os/PowerManagerHidden.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
import androidx.annotation.RequiresApi;
44

5-
import dev.rikka.tools.refine.RefineAs;
6-
7-
@RefineAs(PowerManager.class)
85
public class PowerManagerHidden {
96
@RequiresApi(30)
107
public static boolean isRebootingUserspaceSupportedImpl() {

platform/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ dependencies {
7777
implementation(projects.ext)
7878
implementation(projects.compat)
7979
implementation(libs.androidx.core.ktx)
80-
implementation(libs.hiddenApiBypass)
8180
implementation(libs.androidx.compose.ui)
8281
implementation(libs.androidx.compose.runtime)
8382
implementation(libs.apache.commons.compress)

platform/src/main/kotlin/com/dergoogler/mmrl/platform/PlatformManager.kt

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import kotlinx.coroutines.flow.asStateFlow
4040
import kotlinx.coroutines.suspendCancellableCoroutine
4141
import kotlinx.coroutines.withContext
4242
import kotlinx.coroutines.withTimeout
43-
import org.lsposed.hiddenapibypass.HiddenApiBypass
4443
import java.io.FileDescriptor
4544
import kotlin.coroutines.resumeWithException
4645

@@ -523,37 +522,6 @@ object PlatformManager {
523522
}
524523
}
525524

526-
/**
527-
* Sets Hidden API exemptions using [HiddenApiBypass.addHiddenApiExemptions].
528-
*
529-
* This function attempts to bypass Android's restrictions on accessing non-SDK interfaces (hidden APIs)
530-
* by adding the specified signature prefixes to an exemption list. This is primarily useful on
531-
* Android P (API level 28) and above, where these restrictions are enforced more strictly.
532-
*
533-
* On SDK versions below P, this function does nothing and returns `true` as exemptions are not needed.
534-
*
535-
* @param signaturePrefixes A vararg array of strings, where each string is a prefix of a hidden API
536-
* signature to be exempted. For example, "Landroid/app/ActivityThread;"
537-
* would exempt all members of the `ActivityThread` class. If no prefixes
538-
* are provided (i.e., an empty array or `arrayOf("")`), it might attempt
539-
* to exempt all hidden APIs, depending on the `HiddenApiBypass` library's
540-
* behavior.
541-
* @return `true` if the exemptions were successfully added (or not needed for the current SDK version),
542-
* `false` otherwise (e.g., if `HiddenApiBypass.addHiddenApiExemptions` returns `false`).
543-
* @see HiddenApiBypass.addHiddenApiExemptions
544-
*/
545-
fun setHiddenApiExemptions(vararg signaturePrefixes: String = arrayOf("")): Boolean =
546-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
547-
Log.d(
548-
TAG,
549-
"Setting Hidden API exemptions with prefixes: ${signaturePrefixes.joinToString()}",
550-
)
551-
HiddenApiBypass.addHiddenApiExemptions(*signaturePrefixes)
552-
} else {
553-
Log.d(TAG, "Hidden API exemptions not needed on SDK < P.")
554-
true
555-
}
556-
557525
fun <T : IBinder> T.proxyBy(service: IServiceManager): IBinder =
558526
object : IBinder {
559527
private val originalBinder: IBinder = this@proxyBy

0 commit comments

Comments
 (0)