Skip to content

Commit 399cfaf

Browse files
committed
Make SystemUIHooker singleton
1 parent 6ae1d3e commit 399cfaf

2 files changed

Lines changed: 105 additions & 106 deletions

File tree

app/src/main/java/com/fankes/coloros/notify/hook/HookEntry.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class HookEntry : IYukiHookXposedInit {
4747
/** Hook 被手动关闭停止 Hook */
4848
prefs.get(DataConst.ENABLE_MODULE).not() -> loggerW(msg = "Aborted Hook -> Hook Closed")
4949
/** 开始 Hook */
50-
else -> loadApp(SYSTEMUI_PACKAGE_NAME, SystemUIHooker())
50+
else -> loadApp(SYSTEMUI_PACKAGE_NAME, SystemUIHooker)
5151
}
5252
}
5353
}

app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt

Lines changed: 104 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*
2121
* This file is Created by fankes on 2022/3/25.
2222
*/
23+
@file:Suppress("StaticFieldLeak")
24+
2325
package com.fankes.coloros.notify.hook.entity
2426

2527
import android.app.WallpaperManager
@@ -71,111 +73,108 @@ import com.highcapable.yukihookapi.hook.type.java.LongType
7173
/**
7274
* 系统界面核心 Hook 类
7375
*/
74-
class SystemUIHooker : YukiBaseHooker() {
75-
76-
companion object {
77-
78-
/** 原生存在的类 */
79-
private const val ContrastColorUtilClass = "com.android.internal.util.ContrastColorUtil"
80-
81-
/** 原生存在的类 */
82-
private const val NotificationUtilsClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.NotificationUtils"
83-
84-
/** 原生存在的类 */
85-
private const val NotificationEntryClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.collection.NotificationEntry"
86-
87-
/** 原生存在的类 */
88-
private const val StatusBarIconClass = "com.android.internal.statusbar.StatusBarIcon"
89-
90-
/** 原生存在的类 */
91-
private const val StatusBarIconViewClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.StatusBarIconView"
92-
93-
/** 原生存在的类 */
94-
private const val IconBuilderClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.icon.IconBuilder"
95-
96-
/** 原生存在的类 */
97-
private const val IconManagerClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.icon.IconManager"
98-
99-
/** ColorOS 存在的类 - 旧版本不存在 */
100-
private const val OplusContrastColorUtilClass = "com.oplusos.util.OplusContrastColorUtil"
101-
102-
/** 原生存在的类 */
103-
private const val PluginManagerImplClass = "$SYSTEMUI_PACKAGE_NAME.shared.plugins.PluginManagerImpl"
104-
105-
/** 原生存在的类 */
106-
private const val NotificationBackgroundViewClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.NotificationBackgroundView"
107-
108-
/** ColorOS 存在的类 - 旧版本不存在 */
109-
private const val OplusNotificationBackgroundViewClass =
110-
"com.oplusos.systemui.statusbar.notification.row.OplusNotificationBackgroundView"
111-
112-
/** 根据多个版本存在不同的包名相同的类 */
113-
private val OplusNotificationIconAreaControllerClass = VariousClass(
114-
"com.oplusos.systemui.statusbar.phone.OplusNotificationIconAreaController",
115-
"com.oplusos.systemui.statusbar.policy.OplusNotificationIconAreaController",
116-
"com.coloros.systemui.statusbar.policy.ColorNotificationIconAreaController"
117-
)
118-
119-
/** 根据多个版本存在不同的包名相同的类 */
120-
private val SystemPromptControllerClass = VariousClass(
121-
"com.oplusos.systemui.statusbar.policy.SystemPromptController",
122-
"com.coloros.systemui.statusbar.policy.ColorSystemPromptController"
123-
)
124-
125-
/** 根据多个版本存在不同的包名相同的类 */
126-
private val RoundRectDrawableUtilClass = VariousClass(
127-
"com.oplusos.systemui.notification.util.RoundRectDrawableUtil",
128-
"com.coloros.systemui.notification.util.RoundRectDrawableUtil"
129-
)
130-
131-
/** 根据多个版本存在不同的包名相同的类 */
132-
private val RoundRectDrawableUtil_CompanionClass = VariousClass(
133-
"com.oplusos.systemui.notification.util.RoundRectDrawableUtil\$Companion",
134-
"com.oplusos.systemui.notification.util.RoundRectDrawableUtil\$Companion"
135-
)
136-
137-
/** 根据多个版本存在不同的包名相同的类 */
138-
private val DndAlertHelperClass = VariousClass(
139-
"com.oplusos.systemui.notification.helper.DndAlertHelper",
140-
"com.coloros.systemui.notification.helper.DndAlertHelper"
141-
)
142-
143-
/** 根据多个版本存在不同的包名相同的类 */
144-
private val OplusPowerNotificationWarningsClass = VariousClass(
145-
"com.oplusos.systemui.notification.power.OplusPowerNotificationWarnings",
146-
"com.coloros.systemui.notification.power.ColorosPowerNotificationWarnings"
147-
)
148-
149-
/** 根据多个版本存在不同的包名相同的类 */
150-
private val AbstractReceiverClass = VariousClass(
151-
"com.oplusos.systemui.common.receiver.AbstractReceiver",
152-
"com.coloros.systemui.common.receiver.AbstractReceiver"
153-
)
154-
155-
/** 根据多个版本存在不同的包名相同的类 */
156-
private val StatusBarNotificationPresenterClass = VariousClass(
157-
"$SYSTEMUI_PACKAGE_NAME.statusbar.phone.StatusBarNotificationPresenter",
158-
"$SYSTEMUI_PACKAGE_NAME.statusbar.phone.StatusBar"
159-
)
160-
161-
/** 根据多个版本存在不同的包名相同的类 */
162-
private val ExpandableNotificationRowClass = VariousClass(
163-
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.ExpandableNotificationRow",
164-
"$SYSTEMUI_PACKAGE_NAME.statusbar.ExpandableNotificationRow"
165-
)
166-
167-
/** 根据多个版本存在不同的包名相同的类 */
168-
private val NotificationViewWrapperClass = VariousClass(
169-
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.wrapper.NotificationViewWrapper",
170-
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.NotificationViewWrapper"
171-
)
172-
173-
/** 根据多个版本存在不同的包名相同的类 */
174-
private val NotificationHeaderViewWrapperClass = VariousClass(
175-
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.wrapper.NotificationHeaderViewWrapper",
176-
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.NotificationHeaderViewWrapper"
177-
)
178-
}
76+
object SystemUIHooker : YukiBaseHooker() {
77+
78+
/** 原生存在的类 */
79+
private const val ContrastColorUtilClass = "com.android.internal.util.ContrastColorUtil"
80+
81+
/** 原生存在的类 */
82+
private const val NotificationUtilsClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.NotificationUtils"
83+
84+
/** 原生存在的类 */
85+
private const val NotificationEntryClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.collection.NotificationEntry"
86+
87+
/** 原生存在的类 */
88+
private const val StatusBarIconClass = "com.android.internal.statusbar.StatusBarIcon"
89+
90+
/** 原生存在的类 */
91+
private const val StatusBarIconViewClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.StatusBarIconView"
92+
93+
/** 原生存在的类 */
94+
private const val IconBuilderClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.icon.IconBuilder"
95+
96+
/** 原生存在的类 */
97+
private const val IconManagerClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.icon.IconManager"
98+
99+
/** ColorOS 存在的类 - 旧版本不存在 */
100+
private const val OplusContrastColorUtilClass = "com.oplusos.util.OplusContrastColorUtil"
101+
102+
/** 原生存在的类 */
103+
private const val PluginManagerImplClass = "$SYSTEMUI_PACKAGE_NAME.shared.plugins.PluginManagerImpl"
104+
105+
/** 原生存在的类 */
106+
private const val NotificationBackgroundViewClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.NotificationBackgroundView"
107+
108+
/** ColorOS 存在的类 - 旧版本不存在 */
109+
private const val OplusNotificationBackgroundViewClass =
110+
"com.oplusos.systemui.statusbar.notification.row.OplusNotificationBackgroundView"
111+
112+
/** 根据多个版本存在不同的包名相同的类 */
113+
private val OplusNotificationIconAreaControllerClass = VariousClass(
114+
"com.oplusos.systemui.statusbar.phone.OplusNotificationIconAreaController",
115+
"com.oplusos.systemui.statusbar.policy.OplusNotificationIconAreaController",
116+
"com.coloros.systemui.statusbar.policy.ColorNotificationIconAreaController"
117+
)
118+
119+
/** 根据多个版本存在不同的包名相同的类 */
120+
private val SystemPromptControllerClass = VariousClass(
121+
"com.oplusos.systemui.statusbar.policy.SystemPromptController",
122+
"com.coloros.systemui.statusbar.policy.ColorSystemPromptController"
123+
)
124+
125+
/** 根据多个版本存在不同的包名相同的类 */
126+
private val RoundRectDrawableUtilClass = VariousClass(
127+
"com.oplusos.systemui.notification.util.RoundRectDrawableUtil",
128+
"com.coloros.systemui.notification.util.RoundRectDrawableUtil"
129+
)
130+
131+
/** 根据多个版本存在不同的包名相同的类 */
132+
private val RoundRectDrawableUtil_CompanionClass = VariousClass(
133+
"com.oplusos.systemui.notification.util.RoundRectDrawableUtil\$Companion",
134+
"com.oplusos.systemui.notification.util.RoundRectDrawableUtil\$Companion"
135+
)
136+
137+
/** 根据多个版本存在不同的包名相同的类 */
138+
private val DndAlertHelperClass = VariousClass(
139+
"com.oplusos.systemui.notification.helper.DndAlertHelper",
140+
"com.coloros.systemui.notification.helper.DndAlertHelper"
141+
)
142+
143+
/** 根据多个版本存在不同的包名相同的类 */
144+
private val OplusPowerNotificationWarningsClass = VariousClass(
145+
"com.oplusos.systemui.notification.power.OplusPowerNotificationWarnings",
146+
"com.coloros.systemui.notification.power.ColorosPowerNotificationWarnings"
147+
)
148+
149+
/** 根据多个版本存在不同的包名相同的类 */
150+
private val AbstractReceiverClass = VariousClass(
151+
"com.oplusos.systemui.common.receiver.AbstractReceiver",
152+
"com.coloros.systemui.common.receiver.AbstractReceiver"
153+
)
154+
155+
/** 根据多个版本存在不同的包名相同的类 */
156+
private val StatusBarNotificationPresenterClass = VariousClass(
157+
"$SYSTEMUI_PACKAGE_NAME.statusbar.phone.StatusBarNotificationPresenter",
158+
"$SYSTEMUI_PACKAGE_NAME.statusbar.phone.StatusBar"
159+
)
160+
161+
/** 根据多个版本存在不同的包名相同的类 */
162+
private val ExpandableNotificationRowClass = VariousClass(
163+
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.ExpandableNotificationRow",
164+
"$SYSTEMUI_PACKAGE_NAME.statusbar.ExpandableNotificationRow"
165+
)
166+
167+
/** 根据多个版本存在不同的包名相同的类 */
168+
private val NotificationViewWrapperClass = VariousClass(
169+
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.wrapper.NotificationViewWrapper",
170+
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.NotificationViewWrapper"
171+
)
172+
173+
/** 根据多个版本存在不同的包名相同的类 */
174+
private val NotificationHeaderViewWrapperClass = VariousClass(
175+
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.wrapper.NotificationHeaderViewWrapper",
176+
"$SYSTEMUI_PACKAGE_NAME.statusbar.notification.NotificationHeaderViewWrapper"
177+
)
179178

180179
/** 缓存的彩色 APP 图标 */
181180
private var appIcons = ArrayMap<String, Drawable>()

0 commit comments

Comments
 (0)