Skip to content

Commit cc94dde

Browse files
fix method hook for recordCanBeBlocked in FreeNotifications
1 parent 99f4ce9 commit cc94dde

File tree

1 file changed

+11
-20
lines changed
  • FreeNotifications/src/main/java/de/binarynoise/freeNotifications

1 file changed

+11
-20
lines changed

FreeNotifications/src/main/java/de/binarynoise/freeNotifications/SettingsHook.kt

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ package de.binarynoise.freeNotifications
22

33
import android.app.NotificationChannel
44
import android.app.NotificationChannelGroup
5-
import android.app.role.RoleManager
65
import android.content.Context
76
import android.content.pm.ApplicationInfo
8-
import android.content.pm.PackageInfo
9-
import android.content.pm.PackageManager
107
import android.os.Build
118
import de.robv.android.xposed.IXposedHookLoadPackage
129
import de.robv.android.xposed.XC_MethodHook
@@ -123,23 +120,6 @@ class SettingsHook : IXposedHookLoadPackage {
123120
)
124121
}
125122
}
126-
tryAndLog("recordCanBeBlocked") {
127-
XposedHelpers.findAndHookMethod(
128-
NotificationBackendClass,
129-
"recordCanBeBlocked",
130-
Context::class.java,
131-
PackageManager::class.java,
132-
RoleManager::class.java,
133-
PackageInfo::class.java,
134-
AppRowClass,
135-
object : XC_MethodHook() {
136-
override fun afterHookedMethod(param: MethodHookParam) {
137-
val row = param.args[4]
138-
XposedHelpers.setBooleanField(row, "systemApp", false)
139-
}
140-
},
141-
)
142-
}
143123
tryAndLog("markAppRowWithBlockables") {
144124
XposedHelpers.findAndHookMethod(
145125
NotificationBackendClass,
@@ -156,6 +136,17 @@ class SettingsHook : IXposedHookLoadPackage {
156136
)
157137
}
158138
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
139+
tryAndLog("recordCanBeBlocked") {
140+
XposedBridge.hookMethod(
141+
NotificationBackendClass.declaredMethods.single { it.name == "recordCanBeBlocked" },
142+
object : XC_MethodHook() {
143+
override fun afterHookedMethod(param: MethodHookParam) {
144+
val row = param.args.last()
145+
XposedHelpers.setBooleanField(row, "systemApp", false)
146+
}
147+
},
148+
)
149+
}
159150
tryAndLog("isSystemApp") {
160151
XposedHelpers.findAndHookMethod(
161152
NotificationBackendClass,

0 commit comments

Comments
 (0)