mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-01 08:15:32 +08:00
fix: block coloros 15 fixSmallIcon method (#78)
* fix: block coloros 15 fixSmallIcon method * fix: hook error * feat: complete ColorOS 15 support * docs: update README --------- Co-authored-by: fankesyooni <qzmmcn@163.com>
This commit is contained in:
@@ -35,6 +35,13 @@ This project will not be adapted i18n, please stay tuned for my new projects in
|
||||
|
||||
- 建议在不低于 ColorOS 11 的版本上使用
|
||||
|
||||
## 注意事项
|
||||
|
||||
由于 ColorOS 15 版本的系统性通知图标行为变更,系统强制在通知图标初始化阶段就将图标强制替换为 APP 彩色图标进行破坏,所以目前加入了 “系统框架”
|
||||
作用域,如果在模块安装后没有自动勾选此作用域,请手动进行勾选并重新启动系统以修复此破坏行为,ColorOS 15 以下版本的系统无需勾选。
|
||||
|
||||
感谢 [Nep-Timeline](https://github.com/Nep-Timeline) 提供的解决方案。
|
||||
|
||||
## 历史背景
|
||||
|
||||
继 MIUI 之后的第二大系统 ColorOS 虽然支持原生通知图标,但是第三方推送五颜六色的图标系统并没有做适配,甚至系统自己的图标都是彩色的,极其不友好。
|
||||
|
@@ -24,6 +24,7 @@ package com.fankes.coloros.notify.hook
|
||||
|
||||
import com.fankes.coloros.notify.const.PackageName
|
||||
import com.fankes.coloros.notify.data.ConfigData
|
||||
import com.fankes.coloros.notify.hook.entity.FrameworkHooker
|
||||
import com.fankes.coloros.notify.hook.entity.SystemUIHooker
|
||||
import com.fankes.coloros.notify.utils.factory.isNotColorOS
|
||||
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
|
||||
@@ -45,13 +46,13 @@ object HookEntry : IYukiHookXposedInit {
|
||||
}
|
||||
|
||||
override fun onHook() = encase {
|
||||
if (isNotColorOS) return@encase YLog.warn("Aborted Hook -> This System is not ColorOS")
|
||||
loadSystem(FrameworkHooker)
|
||||
loadApp(PackageName.SYSTEMUI) {
|
||||
ConfigData.init(instance = this)
|
||||
when {
|
||||
isNotColorOS -> YLog.warn("Aborted Hook -> This System is not ColorOS")
|
||||
ConfigData.isEnableModule.not() -> YLog.warn("Aborted Hook -> Hook Closed")
|
||||
else -> loadHooker(SystemUIHooker)
|
||||
}
|
||||
if (ConfigData.isEnableModule)
|
||||
loadHooker(SystemUIHooker)
|
||||
else YLog.warn("Aborted Hook -> Hook Closed")
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* ColorOSNotifyIcon - Optimize notification icons for ColorOS and adapt to native notification icon specifications.
|
||||
* Copyright (C) 20174 Fankes Studio(qzmmcn@163.com)
|
||||
* https://github.com/fankes/ColorOSNotifyIcon
|
||||
*
|
||||
* This software is non-free but opensource software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Affero General Public License
|
||||
* as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
* <p>
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* and eula along with this software. If not, see
|
||||
* <https://www.gnu.org/licenses/>
|
||||
*
|
||||
* This file is created by Nep-Timeline on 2025/5/27.
|
||||
*/
|
||||
package com.fankes.coloros.notify.hook.entity
|
||||
|
||||
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
|
||||
import com.highcapable.yukihookapi.hook.factory.method
|
||||
import com.highcapable.yukihookapi.hook.type.android.NotificationClass
|
||||
import com.highcapable.yukihookapi.hook.type.java.BooleanType
|
||||
import com.highcapable.yukihookapi.hook.type.java.StringClass
|
||||
|
||||
/**
|
||||
* 系统框架核心 Hook 类
|
||||
*/
|
||||
object FrameworkHooker : YukiBaseHooker() {
|
||||
|
||||
/** ColorOS 存在的类 - 旧版本不存在 */
|
||||
private val OplusNotificationFixHelperClass by lazyClassOrNull("com.android.server.notification.OplusNotificationFixHelper")
|
||||
|
||||
override fun onHook() {
|
||||
/** 拦截 ColorOS 覆盖应用通知图标 */
|
||||
OplusNotificationFixHelperClass?.method {
|
||||
name = "fixSmallIcon"
|
||||
param(NotificationClass, StringClass, StringClass, BooleanType)
|
||||
}?.ignored()?.hook()?.intercept()
|
||||
}
|
||||
}
|
@@ -32,7 +32,6 @@ import android.content.IntentFilter
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.graphics.Outline
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.Icon
|
||||
import android.os.SystemClock
|
||||
@@ -43,6 +42,7 @@ import android.view.ViewGroup
|
||||
import android.view.ViewOutlineProvider
|
||||
import android.widget.ImageView
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
import androidx.core.view.children
|
||||
import com.fankes.coloros.notify.R
|
||||
import com.fankes.coloros.notify.bean.IconDataBean
|
||||
@@ -81,6 +81,7 @@ import com.highcapable.yukihookapi.hook.type.android.ContextClass
|
||||
import com.highcapable.yukihookapi.hook.type.android.DrawableClass
|
||||
import com.highcapable.yukihookapi.hook.type.android.IconClass
|
||||
import com.highcapable.yukihookapi.hook.type.android.ImageViewClass
|
||||
import com.highcapable.yukihookapi.hook.type.android.NotificationClass
|
||||
import com.highcapable.yukihookapi.hook.type.android.StatusBarNotificationClass
|
||||
import com.highcapable.yukihookapi.hook.type.defined.VagueType
|
||||
import com.highcapable.yukihookapi.hook.type.java.BooleanType
|
||||
@@ -88,8 +89,6 @@ import com.highcapable.yukihookapi.hook.type.java.FloatType
|
||||
import com.highcapable.yukihookapi.hook.type.java.IntType
|
||||
import com.highcapable.yukihookapi.hook.type.java.LongType
|
||||
import top.defaults.drawabletoolbox.DrawableBuilder
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
import com.highcapable.yukihookapi.hook.type.android.NotificationClass
|
||||
|
||||
/**
|
||||
* 系统界面核心 Hook 类
|
||||
@@ -301,15 +300,15 @@ object SystemUIHooker : YukiBaseHooker() {
|
||||
private fun loggerDebug(tag: String, context: Context, nf: StatusBarNotification?, isCustom: Boolean, isGrayscale: Boolean) {
|
||||
if (ConfigData.isEnableModuleLog) YLog.debug(
|
||||
msg = "(Processing $tag) ↓\n" +
|
||||
"[Title]: ${nf?.notification?.extras?.getString(Notification.EXTRA_TITLE)}\n" +
|
||||
"[Content]: ${nf?.notification?.extras?.getString(Notification.EXTRA_TEXT)}\n" +
|
||||
"[App Name]: ${context.appNameOf(packageName = nf?.packageName ?: "")}\n" +
|
||||
"[Package Name]: ${nf?.packageName}\n" +
|
||||
"[Sender Package Name]: ${nf?.opPkg}\n" +
|
||||
"[Custom Icon]: $isCustom\n" +
|
||||
"[Grayscale Icon]: $isGrayscale\n" +
|
||||
"[From System Push]: ${nf?.isOplusPush}\n" +
|
||||
"[String]: ${nf?.notification}"
|
||||
"[Title]: ${nf?.notification?.extras?.getString(Notification.EXTRA_TITLE)}\n" +
|
||||
"[Content]: ${nf?.notification?.extras?.getString(Notification.EXTRA_TEXT)}\n" +
|
||||
"[App Name]: ${context.appNameOf(packageName = nf?.packageName ?: "")}\n" +
|
||||
"[Package Name]: ${nf?.packageName}\n" +
|
||||
"[Sender Package Name]: ${nf?.opPkg}\n" +
|
||||
"[Custom Icon]: $isCustom\n" +
|
||||
"[Grayscale Icon]: $isGrayscale\n" +
|
||||
"[From System Push]: ${nf?.isOplusPush}\n" +
|
||||
"[String]: ${nf?.notification}"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -938,4 +937,4 @@ object SystemUIHooker : YukiBaseHooker() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1213,7 +1213,7 @@
|
||||
android:layout_marginBottom="10dp"
|
||||
android:alpha="0.8"
|
||||
android:lineSpacingExtra="10dp"
|
||||
android:text="Q.哪些是已知问题?\nA.以下是问题描述列表:\n(1) 由于机型有限,仅对 ColorOS 12、12.1、13 测试正常运行,根据酷友的需要云调试修复 ColorOS 11 的问题,其它版本情况未知,请自行进行测试。\n(2) OxygenOS 只支持 12、12.1、13 版本,其它类 ColorOS 魔改的 UI 理论没有问题,请自行测试。\n(3) 动态刷新系统界面为实验性功能,若动态地改变了系统深色模式,调节了分辨率和字体大小,状态栏、通知栏中的通知图标会还原或直接不起作用,或在刷新时发生图标黑白块问题,发生类似这种情况请手动重启一次系统界面即可解决。\n(4) 部分机型的 ColorOS 12、12.1 版本概率性出现通知栏的通知图标黑白块问题,属于系统强制重新设置图标问题,无法修复,建议可以更新到 ColorOS 13 的机型更新系统解决,不再负责修复这个问题。"
|
||||
android:text="Q.哪些是已知问题?\nA.以下是问题描述列表:\n(1) 由于机型有限,仅对 ColorOS 12、12.1、13 测试正常运行,根据酷友的需要云调试修复 ColorOS 11 的问题,其它版本情况未知,请自行进行测试。\n(2) OxygenOS 只支持 12、12.1、13 版本,其它类 ColorOS 魔改的 UI 理论没有问题,请自行测试。\n(3) 动态刷新系统界面为实验性功能,若动态地改变了系统深色模式,调节了分辨率和字体大小,状态栏、通知栏中的通知图标会还原或直接不起作用,或在刷新时发生图标黑白块问题,发生类似这种情况请手动重启一次系统界面即可解决。\n(4) 部分机型的 ColorOS 12、12.1 版本概率性出现通知栏的通知图标黑白块问题,属于系统强制重新设置图标问题,无法修复,建议可以更新到 ColorOS 13 的机型更新系统解决,不再负责修复这个问题。\n(5) 由于 ColorOS 15 版本的系统性通知图标行为变更,系统强制在通知图标初始化阶段就将图标强制替换为 APP 彩色图标进行破坏,所以目前加入了 “系统框架” 作用域,如果在模块安装后没有自动勾选此作用域,请手动进行勾选并重新启动系统以修复此破坏行为,ColorOS 15 以下版本的系统无需勾选。"
|
||||
android:textColor="@color/colorTextDark"
|
||||
android:textSize="12sp" />
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="module_scope">
|
||||
<item>android</item>
|
||||
<item>com.android.systemui</item>
|
||||
</string-array>
|
||||
</resources>
|
Reference in New Issue
Block a user