1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| loadClass("android.os.ServiceManagerProxy") .findMethod { name == "addService" } .hookAfter { val name = it.args[0] as String if ("wifi" in name) { Log.d(TAG, "addService: find $name ${it.args[1]}") } if (name == "wifi") { val class_WifiServiceImpl = it.args[1].javaClass Log.d(TAG, "addService: get $class_WifiServiceImpl") handle_WifiServiceImpl(class_WifiServiceImpl) } }
data class WifiState( var enabled: Boolean = false, )
val wifiState = WifiState()
fun handle_WifiServiceImpl(clazz: Class<*>) { clazz .findMethod { name == "setWifiEnabledInternal" } .hookReplace { wifiState.enabled = it.args[1] as Boolean Unit } clazz .findMethod { name == "getWifiEnabledState" } .hookReplace { return@hookReplace if (wifiState.enabled) 3 else 1 } }
|