11package de.binarynoise.freeNotifications
22
33import android.app.NotificationChannel
4- import android.app.NotificationChannelGroup
54import android.os.Build
65import de.binarynoise.logger.Logger.log
76import de.binarynoise.reflection.findDeclaredField
@@ -49,7 +48,7 @@ class Hook : IXposedHookLoadPackage {
4948 * only if the letter following the prefix is uppercase.
5049 */
5150 fun String.removeCamelCasePrefix (prefix : String ): String {
52- if (! this .isCharUpperCase(prefix.length + 1 )) return this .removePrefix(prefix)
51+ if (this .isCharUpperCase(prefix.length)) return this .removePrefix(prefix)
5352 return this
5453 }
5554
@@ -77,7 +76,6 @@ class Hook : IXposedHookLoadPackage {
7776 return hookVariable(clazz, name, name, value)
7877 }
7978
80- // AOSP
8179 hookVariable(
8280 NotificationChannel ::class .java,
8381 " mBlockableSystem" ,
@@ -86,7 +84,6 @@ class Hook : IXposedHookLoadPackage {
8684 )
8785
8886 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
89- // AOSP
9087 hookVariable(
9188 NotificationChannel ::class .java,
9289 " mImportanceLockedDefaultApp" ,
@@ -96,21 +93,28 @@ class Hook : IXposedHookLoadPackage {
9693 }
9794
9895 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q && Build .VERSION .SDK_INT <= Build .VERSION_CODES .S_V2 ) {
99- // AOSP
10096 hookVariable(
10197 NotificationChannel ::class .java,
10298 " mImportanceLockedByOEM" ,
10399 false ,
104100 )
105101 }
106102
107- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .P ) {
108- // AOSP
109- hookVariable(
110- NotificationChannelGroup ::class .java,
111- " mBlocked" ,
112- false ,
113- )
103+ if (lpparam.packageName == " android" && Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
104+ tryAndLog(" PreferencesHelperClass lockChannelsForOEM" ) {
105+ val PreferencesHelperClass = Class .forName(" com.android.server.notification.PreferencesHelper" , false , lpparam.classLoader)
106+ XposedHelpers .findAndHookMethod(
107+ PreferencesHelperClass ,
108+ " lockChannelsForOEM" ,
109+ Array <String >::class .java,
110+ DO_NOTHING ,
111+ )
112+ }
113+ tryAndLog(" NotificationManagerService NON_BLOCKABLE_DEFAULT_ROLES" ) {
114+ val NotificationManagerService =
115+ Class .forName(" com.android.server.notification.NotificationManagerService" , false , lpparam.classLoader)
116+ XposedHelpers .setStaticObjectField(NotificationManagerService , " NON_BLOCKABLE_DEFAULT_ROLES" , emptyArray<String >())
117+ }
114118 }
115119 }
116120}
0 commit comments