Skip to content
Closed
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
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ val latestTag = repo?.latestTag?.removePrefix("v") ?: "1.0"

android {
namespace = "com.parallelc.micts"
compileSdk = 36
compileSdk = 37

defaultConfig {
minSdk = 28
targetSdk = 36
targetSdk = 37
versionCode = commitCount
versionName = latestTag

Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/com/parallelc/micts/hooker/CSMSHooker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ class CSMSHooker {
@SuppressLint("PrivateApi")
fun hook(param: SystemServerStartingParam) {
val rString = param.classLoader.loadClass("com.android.internal.R\$string")
contextualSearchPackageName = rString.getField("config_defaultContextualSearchPackageName").getInt(null)

// Android 17+: Handle reflection to static final fields with try-catch
contextualSearchPackageName = runCatching {
rString.getField("config_defaultContextualSearchPackageName").getInt(null)
}.onFailure { e ->
module!!.log(Log.WARN, "MiCTS", "Failed to get config_defaultContextualSearchPackageName on Android 17+", e)
}.getOrElse { -1 }

val systemServer = param.classLoader.loadClass("com.android.server.SystemServer")
module!!.hook(systemServer.getDeclaredMethod("deviceHasConfigString", Context::class.java, Int::class.java))
.intercept(DeviceHasConfigStringHooker())
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/com/parallelc/micts/hooker/VIMSHooker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@ class VIMSHooker {
fun hook(param: SystemServerStartingParam) {
val vimsStub = param.classLoader.loadClass("com.android.server.voiceinteraction.VoiceInteractionManagerService\$VoiceInteractionManagerServiceStub")
val rString = param.classLoader.loadClass("com.android.internal.R\$string")
contextualSearchKey = rString.getField("config_defaultContextualSearchKey").getInt(null)
contextualSearchPackageName = rString.getField("config_defaultContextualSearchPackageName").getInt(null)
// Android 17+: Handle reflection to static final fields with try-catch
contextualSearchKey = runCatching {
rString.getField("config_defaultContextualSearchKey").getInt(null)
}.onFailure { e ->
module!!.log(Log.WARN, "MiCTS", "Failed to get config_defaultContextualSearchKey on Android 17+", e)
}.getOrElse { -1 }

contextualSearchPackageName = runCatching {
rString.getField("config_defaultContextualSearchPackageName").getInt(null)
}.onFailure { e ->
module!!.log(Log.WARN, "MiCTS", "Failed to get config_defaultContextualSearchPackageName on Android 17+", e)
}.getOrElse { -1 }
module!!.hook(vimsStub.getDeclaredMethod("showSessionFromSession", IBinder::class.java, Bundle::class.java, Int::class.java, String::class.java)).intercept(ShowSessionHooker())
}

Expand Down
Loading