Skip to content

Commit 0d24479

Browse files
fei-keNihilityT
authored andcommitted
Fix Samsung OneUI 7 hook error
1 parent 2bc35c7 commit 0d24479

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

xposed/src/main/java/one/yufz/hmspush/hook/system/NmsPermissionHooker.kt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ import de.robv.android.xposed.XposedHelpers.findClass
1212
import de.robv.android.xposed.XposedHelpers.findMethodExact
1313
import one.yufz.hmspush.common.ANDROID_PACKAGE_NAME
1414
import one.yufz.hmspush.common.HMS_PACKAGE_NAME
15+
import one.yufz.hmspush.hook.XLog
1516
import one.yufz.xposed.HookCallback
1617
import one.yufz.xposed.HookContext
1718
import one.yufz.xposed.hook
1819
import one.yufz.xposed.hookMethod
1920

2021
object NmsPermissionHooker {
22+
private const val TAG = "NmsPermissionHooker"
23+
2124
private fun fromHms() = try {
2225
Binder.getCallingUid() == getPackageUid(HMS_PACKAGE_NAME)
2326
} catch (e: Throwable) {
@@ -108,11 +111,17 @@ object NmsPermissionHooker {
108111
}
109112
}
110113
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
111-
findClass("com.android.server.notification.PreferencesHelper", classINotificationManager.classLoader)
112-
//public boolean deleteNotificationChannel(String pkg, int uid, String channelId, int callingUid, boolean fromSystemOrSystemUi)
113-
.hookMethod("deleteNotificationChannel", String::class.java, Int::class.java, String::class.java, Int::class.java, Boolean::class.java,
114-
callback = deleteNotificationChannelHook
115-
)
114+
try {
115+
findClass("com.android.server.notification.PreferencesHelper", classINotificationManager.classLoader)
116+
//public boolean deleteNotificationChannel(String pkg, int uid, String channelId, int callingUid, boolean fromSystemOrSystemUi)
117+
.hookMethod(
118+
"deleteNotificationChannel", String::class.java, Int::class.java, String::class.java, Int::class.java, Boolean::class.java,
119+
callback = deleteNotificationChannelHook
120+
)
121+
} catch (e: NoSuchMethodError) {
122+
//Samsung One UI 7 delete this method
123+
XLog.d(TAG, "hook deleteNotificationChannel error, NoSuchMethodError")
124+
}
116125
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
117126
findClass("com.android.server.notification.PreferencesHelper", classINotificationManager.classLoader)
118127
//public boolean deleteNotificationChannel(String pkg, int uid, String channelId)

0 commit comments

Comments
 (0)