simplify DeleOnPoseNotification.kt

This commit is contained in:
QQ littleice
2022-03-10 18:26:33 +08:00
parent bf06b7b69e
commit df51e0cb89

View File

@@ -1,25 +1,16 @@
package com.lt2333.simplicitytools.hook.app.android
import com.lt2333.simplicitytools.util.XSPUtils
import com.lt2333.simplicitytools.util.hasEnable
import com.lt2333.simplicitytools.util.hookBeforeMethod
import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XposedHelpers
import de.robv.android.xposed.callbacks.XC_LoadPackage
class DeleteOnPostNotification : IXposedHookLoadPackage {
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
val classIfExists = XposedHelpers.findClassIfExists(
"com.android.server.wm.AlertWindowNotification",
lpparam.classLoader
)
XposedHelpers.findAndHookMethod(classIfExists,
"onPostNotification",
object : XC_MethodHook() {
override fun beforeHookedMethod(param: MethodHookParam) {
if (XSPUtils.getBoolean("delete_on_post_notification", false)) {
param.result = null
hasEnable("delete_on_post_notification") {
"com.android.server.wm.AlertWindowNotification".hookBeforeMethod(lpparam.classLoader, "onPostNotification") {
it.result = null
}
}
})
}
}