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 }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Fallback disables csms override 🐞 Bug ≡ Correctness

When the resource-field lookup fails, CSMSHooker.hook stores -1 but still installs
DeviceHasConfigStringHooker, whose override only runs when the framework's resource ID equals that
sentinel. Real configuration-resource checks therefore proceed unchanged, so the CSMS availability
override is disabled on the reflection-failure path this change is intended to support.
Agent Prompt
## Issue description
The new `-1` fallback allows setup to continue but prevents `DeviceHasConfigStringHooker` from recognizing the contextual-search package resource, disabling the CSMS override whenever reflection fails.

## Issue Context
Use an Android-17-compatible lookup (for example, a framework resource-name lookup or another verified reflection path) that produces the actual resource ID. Do not install the dependent behavior with a sentinel that can never match a real resource request.

## Fix Focus Areas
- app/src/main/java/com/parallelc/micts/hooker/CSMSHooker.kt[25-33]
- app/src/main/java/com/parallelc/micts/hooker/CSMSHooker.kt[58-65]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


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 }
Comment on lines +33 to +39

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Fallback disables vims substitutions 🐞 Bug ≡ Correctness

Each failed VIMS resource-field lookup is replaced with -1, yet GetStringHooker only substitutes
the contextual-search key or package when the requested resource ID equals those stored values.
Consequently, a failed lookup silently removes the corresponding key/package substitution and breaks
that contextual-search trigger path instead of providing Android 17 compatibility.
Agent Prompt
## Issue description
The `-1` fallbacks cannot match real `Resources.getString` IDs, so any failed lookup disables the corresponding VIMS contextual-search substitution while hook setup appears successful.

## Issue Context
Resolve both internal string IDs through an Android-17-compatible mechanism and only enable the dependent hook after obtaining valid IDs. Preserve independent handling if one ID can be resolved and the other cannot, but do not represent an operational substitution with `-1`.

## Fix Focus Areas
- app/src/main/java/com/parallelc/micts/hooker/VIMSHooker.kt[29-40]
- app/src/main/java/com/parallelc/micts/hooker/VIMSHooker.kt[67-78]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

module!!.hook(vimsStub.getDeclaredMethod("showSessionFromSession", IBinder::class.java, Bundle::class.java, Int::class.java, String::class.java)).intercept(ShowSessionHooker())
}

Expand Down
Loading