mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-06 10:45:49 +08:00
更换通知刷新方案,彻底解决系统界面卡死问题
This commit is contained in:
@@ -36,7 +36,6 @@ import android.graphics.drawable.Icon
|
|||||||
import android.graphics.drawable.VectorDrawable
|
import android.graphics.drawable.VectorDrawable
|
||||||
import android.service.notification.StatusBarNotification
|
import android.service.notification.StatusBarNotification
|
||||||
import android.util.ArrayMap
|
import android.util.ArrayMap
|
||||||
import android.util.ArraySet
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.ViewOutlineProvider
|
import android.view.ViewOutlineProvider
|
||||||
@@ -56,6 +55,7 @@ import com.fankes.coloros.notify.utils.factory.*
|
|||||||
import com.fankes.coloros.notify.utils.tool.IconAdaptationTool
|
import com.fankes.coloros.notify.utils.tool.IconAdaptationTool
|
||||||
import com.highcapable.yukihookapi.hook.bean.VariousClass
|
import com.highcapable.yukihookapi.hook.bean.VariousClass
|
||||||
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
|
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.current
|
||||||
import com.highcapable.yukihookapi.hook.factory.field
|
import com.highcapable.yukihookapi.hook.factory.field
|
||||||
import com.highcapable.yukihookapi.hook.factory.method
|
import com.highcapable.yukihookapi.hook.factory.method
|
||||||
import com.highcapable.yukihookapi.hook.log.loggerD
|
import com.highcapable.yukihookapi.hook.log.loggerD
|
||||||
@@ -144,6 +144,12 @@ class SystemUIHooker : YukiBaseHooker() {
|
|||||||
"com.coloros.systemui.common.receiver.AbstractReceiver"
|
"com.coloros.systemui.common.receiver.AbstractReceiver"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/** 根据多个版本存在不同的包名相同的类 */
|
||||||
|
private val StatusBarNotificationPresenterClass = VariousClass(
|
||||||
|
"$SYSTEMUI_PACKAGE_NAME.statusbar.phone.StatusBarNotificationPresenter",
|
||||||
|
"$SYSTEMUI_PACKAGE_NAME.statusbar.phone.StatusBar"
|
||||||
|
)
|
||||||
|
|
||||||
/** 根据多个版本存在不同的包名相同的类 */
|
/** 根据多个版本存在不同的包名相同的类 */
|
||||||
private val ExpandableNotificationRowClass = VariousClass(
|
private val ExpandableNotificationRowClass = VariousClass(
|
||||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.ExpandableNotificationRow",
|
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.ExpandableNotificationRow",
|
||||||
@@ -175,8 +181,8 @@ class SystemUIHooker : YukiBaseHooker() {
|
|||||||
/** 状态栏通知图标数组 */
|
/** 状态栏通知图标数组 */
|
||||||
private var notificationIconInstances = ArrayList<View>()
|
private var notificationIconInstances = ArrayList<View>()
|
||||||
|
|
||||||
/** 缓存的通知小图标包装纸实例 */
|
/** 通知栏通知控制器 */
|
||||||
private var notificationViewWrappers = ArraySet<Any>()
|
private var notificationPresenter: Any? = null
|
||||||
|
|
||||||
/** 仅监听一次主题壁纸颜色变化 */
|
/** 仅监听一次主题壁纸颜色变化 */
|
||||||
private var isWallpaperColorListenerSetUp = false
|
private var isWallpaperColorListenerSetUp = false
|
||||||
@@ -334,8 +340,11 @@ class SystemUIHooker : YukiBaseHooker() {
|
|||||||
|
|
||||||
/** 刷新通知小图标 */
|
/** 刷新通知小图标 */
|
||||||
private fun refreshNotificationIcons() = runInSafe {
|
private fun refreshNotificationIcons() = runInSafe {
|
||||||
NotificationHeaderViewWrapperClass.clazz.method { name = "resolveHeaderViews" }.also { result ->
|
notificationPresenter?.current {
|
||||||
notificationViewWrappers.takeIf { it.isNotEmpty() }?.forEach { result.get(it).call() }
|
method {
|
||||||
|
name = "updateNotificationsOnDensityOrFontScaleChanged"
|
||||||
|
emptyParam()
|
||||||
|
}.call()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -629,6 +638,13 @@ class SystemUIHooker : YukiBaseHooker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/** 注入通知控制器实例 */
|
||||||
|
StatusBarNotificationPresenterClass.hook {
|
||||||
|
injectMember {
|
||||||
|
allConstructors()
|
||||||
|
afterHook { notificationPresenter = instance }
|
||||||
|
}
|
||||||
|
}
|
||||||
/** 注入状态栏通知图标容器实例 */
|
/** 注入状态栏通知图标容器实例 */
|
||||||
OplusNotificationIconAreaControllerClass.hook {
|
OplusNotificationIconAreaControllerClass.hook {
|
||||||
injectMember {
|
injectMember {
|
||||||
@@ -684,11 +700,6 @@ class SystemUIHooker : YukiBaseHooker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 记录实例 */
|
|
||||||
injectMember {
|
|
||||||
constructor { param(ContextClass, ViewClass, ExpandableNotificationRowClass) }
|
|
||||||
afterHook { notificationViewWrappers.add(instance) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/** 发送适配新的 APP 图标通知 */
|
/** 发送适配新的 APP 图标通知 */
|
||||||
PluginManagerImplClass.hook {
|
PluginManagerImplClass.hook {
|
||||||
|
@@ -7,7 +7,7 @@ plugins {
|
|||||||
ext {
|
ext {
|
||||||
appVersionName = "1.53"
|
appVersionName = "1.53"
|
||||||
appVersionCode = 10
|
appVersionCode = 10
|
||||||
enableR8 = true
|
enableR8 = false
|
||||||
}
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
|
Reference in New Issue
Block a user