Skip to content

Commit

Permalink
Merge pull request #68 from NihilityT/upstream
Browse files Browse the repository at this point in the history
support Android 14
  • Loading branch information
fei-ke authored Oct 19, 2023
2 parents 117499e + cfad13c commit 1e752c8
Showing 1 changed file with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import de.robv.android.xposed.XposedHelpers.findMethodExact
import one.yufz.hmspush.common.ANDROID_PACKAGE_NAME
import one.yufz.hmspush.common.HMS_PACKAGE_NAME
import one.yufz.xposed.HookCallback
import one.yufz.xposed.HookContext
import one.yufz.xposed.hook
import one.yufz.xposed.hookMethod

Expand Down Expand Up @@ -96,28 +97,32 @@ object NmsPermissionHooker {
findMethodExact(classINotificationManager, "getNotificationChannelsForPackage", String::class.java, Int::class.java, Boolean::class.java)
.hook(hookPermission(0))

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val deleteNotificationChannelHook: HookContext.() -> Unit = {
doBefore {
val packageName = args[0] as String
if (packageName != HMS_PACKAGE_NAME && Binder.getCallingUid() == Process.SYSTEM_UID) {
args[1] = getPackageUid(packageName)
}
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
findClass("com.android.server.notification.PreferencesHelper", classINotificationManager.classLoader)
//public boolean deleteNotificationChannel(String pkg, int uid, String channelId, int callingUid, boolean fromSystemOrSystemUi)
.hookMethod("deleteNotificationChannel", String::class.java, Int::class.java, String::class.java, Int::class.java, Boolean::class.java,
callback = deleteNotificationChannelHook
)
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
findClass("com.android.server.notification.PreferencesHelper", classINotificationManager.classLoader)
//public boolean deleteNotificationChannel(String pkg, int uid, String channelId)
.hookMethod("deleteNotificationChannel", String::class.java, Int::class.java, String::class.java) {
doBefore {
val packageName = args[0] as String
if (packageName != HMS_PACKAGE_NAME && Binder.getCallingUid() == Process.SYSTEM_UID) {
args[1] = getPackageUid(packageName)
}
}
}
.hookMethod("deleteNotificationChannel", String::class.java, Int::class.java, String::class.java,
callback = deleteNotificationChannelHook
)
} else {
findClass("com.android.server.notification.RankingHelper", classINotificationManager.classLoader)
//public void deleteNotificationChannel(String pkg, int uid, String channelId)
.hookMethod("deleteNotificationChannel", String::class.java, Int::class.java, String::class.java) {
doBefore {
val packageName = args[0] as String
if (packageName != HMS_PACKAGE_NAME && Binder.getCallingUid() == Process.SYSTEM_UID) {
args[1] = getPackageUid(packageName)
}
}
}
.hookMethod("deleteNotificationChannel", String::class.java, Int::class.java, String::class.java,
callback = deleteNotificationChannelHook
)
}
}
}

0 comments on commit 1e752c8

Please sign in to comment.