feat: add Android 17 (API 37) support (failed) - #182
Conversation
… Android 17+ compatibility Android 17 blocks reflection to static final fields. VIMSHooker and CSMSHooker access config strings via reflection, which will throw IllegalAccessException on Android 17+. Wrap with runCatching and fallback to -1 if field access fails. Fixes: Android 17 (API 37) compatibility issue
PR Summary by QodoAdd Android 17 support and harden resource reflection
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1. Fallback disables CSMS override
|
| rString.getField("config_defaultContextualSearchPackageName").getInt(null) | ||
| }.onFailure { e -> | ||
| module!!.log(Log.WARN, "MiCTS", "Failed to get config_defaultContextualSearchPackageName on Android 17+", e) | ||
| }.getOrElse { -1 } |
There was a problem hiding this comment.
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
| }.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 } |
There was a problem hiding this comment.
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
Support for Android 17 (API 37) with reflection hardening
Tested on Android 17 (API 37)