You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am managing to read preferences from my module inside of my hooked app, but I can't for the life of me get the OnSharedPreferenceChangeListener to work.
fun init(classLoader: ClassLoader?) {
XposedHelpers.findAndHookMethod(
CentralSurfacesImpl,
classLoader,
"start",
object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam) {
log("mwilky: in CentralSurfacesImpl")
val prefs = XposedInit.prefForSystemUI
if (prefs != null) {
//Get prefs
val switchOneEnabled = prefs.getBoolean("switch_one", false)
log("mwilky: switchOneEnabled = $switchOneEnabled")
// Add a listener to the shared preferences to track changes
val listener =
SharedPreferences.OnSharedPreferenceChangeListener { _, _ ->
prefs.reload()
log("mwilky: prefs Reloaded")
}
prefs.registerOnSharedPreferenceChangeListener(listener)
}
}
}
)
}
log("mwilky: switchOneEnabled = $switchOneEnabled") logs the correct value each time i reboot, so i know the values is being passed and read correctly in the hooked app.
log("mwilky: prefs Reloaded") is never being executed no matter how many times i change the preference
XposedInit class is as the documentation for the new XSharedPreference writes:
class XposedInit : IXposedHookLoadPackage {
companion object {
private fun getPref(path: String) : XSharedPreferences? {
val pref = XSharedPreferences("com.mwilky.androidenhanced", path)
return if(pref.file.canRead()) pref else null
}
const val SYSTEMUI_PREFS = "sysui_prefs"
// lazy loads when needed
val prefForSystemUI by lazy { getPref(SYSTEMUI_PREFS) }
}
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
//Packages to hook
val SystemUI = "com.android.systemui"
when(lpparam?.packageName) {
SystemUI -> {
SystemUIStatusbar.init(lpparam.classLoader)
}
}
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all,
I am managing to read preferences from my module inside of my hooked app, but I can't for the life of me get the OnSharedPreferenceChangeListener to work.
log("mwilky: switchOneEnabled = $switchOneEnabled")
logs the correct value each time i reboot, so i know the values is being passed and read correctly in the hooked app.log("mwilky: prefs Reloaded")
is never being executed no matter how many times i change the preferenceXposedInit class is as the documentation for the new XSharedPreference writes:
Beta Was this translation helpful? Give feedback.
All reactions