From f066382d4cd997b2d4b5d6d030aba3ba5c8058fd Mon Sep 17 00:00:00 2001 From: Fankesyooni Date: Mon, 28 Feb 2022 20:31:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=B3=BB=E7=BB=9F=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E9=80=82=E9=85=8D=20ColorOS=2011?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fankes/coloros/notify/hook/HookEntry.kt | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/fankes/coloros/notify/hook/HookEntry.kt b/app/src/main/java/com/fankes/coloros/notify/hook/HookEntry.kt index 2ed4590..1079d3f 100644 --- a/app/src/main/java/com/fankes/coloros/notify/hook/HookEntry.kt +++ b/app/src/main/java/com/fankes/coloros/notify/hook/HookEntry.kt @@ -84,16 +84,18 @@ class HookEntry : YukiHookXposedInitProxy { /** 原生存在的类 */ private const val IconManagerClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.icon.IconManager" - /** ColorOS 存在的类 */ + /** ColorOS 存在的类 - 旧版本不存在 */ private const val OplusContrastColorUtilClass = "com.oplusos.util.OplusContrastColorUtil" - /** ColorOS 存在的类 */ - private const val OplusPowerNotificationWarningsClass = - "com.oplusos.systemui.notification.power.OplusPowerNotificationWarnings" - /** ColorOS 存在的类 */ private const val SystemPromptControllerClass = "com.oplusos.systemui.statusbar.policy.SystemPromptController" + /** 根据多个版本存在不同的包名相同的类 */ + private val OplusPowerNotificationWarningsClass = VariousClass( + "com.oplusos.systemui.notification.power.OplusPowerNotificationWarnings", + "com.coloros.systemui.notification.power.ColorosPowerNotificationWarnings" + ) + /** 根据多个版本存在不同的包名相同的类 */ private val ExpandableNotificationRowClass = VariousClass( "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.ExpandableNotificationRow", @@ -293,16 +295,17 @@ class HookEntry : YukiHookXposedInitProxy { } } } - /** 修复并替换 ColorOS 原生灰度图标色彩判断 */ - NotificationUtilsClass.hook { - injectMember { - method { - name = "isGrayscaleOplus" - param(ImageViewClass, OplusContrastColorUtilClass.clazz) + /** 修复并替换新版本 ColorOS 原生灰度图标色彩判断 */ + if (OplusContrastColorUtilClass.hasClass) + NotificationUtilsClass.hook { + injectMember { + method { + name = "isGrayscaleOplus" + param(ImageViewClass, OplusContrastColorUtilClass.clazz) + } + replaceAny { (firstArgs as? ImageView?)?.let { isGrayscaleIcon(it.context, it.drawable) } } } - replaceAny { (firstArgs as? ImageView?)?.let { isGrayscaleIcon(it.context, it.drawable) } } } - } /** 替换状态栏图标 */ IconManagerClass.hook { injectMember {