mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-04 09:45:34 +08:00
Modify move new app support functions to a new way to implement and shielded some apps that shouldn't appear in SystemUIHooker
This commit is contained in:
@@ -25,8 +25,10 @@
|
|||||||
package com.fankes.coloros.notify.hook.entity
|
package com.fankes.coloros.notify.hook.entity
|
||||||
|
|
||||||
import android.app.WallpaperManager
|
import android.app.WallpaperManager
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
@@ -93,9 +95,6 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
/** 原生存在的类 */
|
/** 原生存在的类 */
|
||||||
private const val IconManagerClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.icon.IconManager"
|
private const val IconManagerClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.icon.IconManager"
|
||||||
|
|
||||||
/** 原生存在的类 */
|
|
||||||
private const val PluginManagerImplClass = "$SYSTEMUI_PACKAGE_NAME.shared.plugins.PluginManagerImpl"
|
|
||||||
|
|
||||||
/** 原生存在的类 */
|
/** 原生存在的类 */
|
||||||
private const val NotificationBackgroundViewClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.NotificationBackgroundView"
|
private const val NotificationBackgroundViewClass = "$SYSTEMUI_PACKAGE_NAME.statusbar.notification.row.NotificationBackgroundView"
|
||||||
|
|
||||||
@@ -158,12 +157,6 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
"com.coloros.systemui.notification.power.ColorosPowerNotificationWarnings"
|
"com.coloros.systemui.notification.power.ColorosPowerNotificationWarnings"
|
||||||
)
|
)
|
||||||
|
|
||||||
/** 根据多个版本存在不同的包名相同的类 */
|
|
||||||
private val AbstractReceiverClass = VariousClass(
|
|
||||||
"com.oplusos.systemui.common.receiver.AbstractReceiver",
|
|
||||||
"com.coloros.systemui.common.receiver.AbstractReceiver"
|
|
||||||
)
|
|
||||||
|
|
||||||
/** 根据多个版本存在不同的包名相同的类 */
|
/** 根据多个版本存在不同的包名相同的类 */
|
||||||
private val StatusBarNotificationPresenterClass = VariousClass(
|
private val StatusBarNotificationPresenterClass = VariousClass(
|
||||||
"$SYSTEMUI_PACKAGE_NAME.statusbar.phone.StatusBarNotificationPresenter",
|
"$SYSTEMUI_PACKAGE_NAME.statusbar.phone.StatusBarNotificationPresenter",
|
||||||
@@ -542,8 +535,43 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
|
|
||||||
/** 注册生命周期 */
|
/** 注册生命周期 */
|
||||||
private fun registerLifecycle() {
|
private fun registerLifecycle() {
|
||||||
/** 解锁后重新刷新状态栏图标防止系统重新设置它 */
|
onAppLifecycle {
|
||||||
onAppLifecycle { registerReceiver(Intent.ACTION_USER_PRESENT) { _, _ -> if (isUsingCachingMethod) refreshStatusBarIcons() } }
|
/** 解锁后重新刷新状态栏图标防止系统重新设置它 */
|
||||||
|
registerReceiver(Intent.ACTION_USER_PRESENT) { _, _ -> if (isUsingCachingMethod) refreshStatusBarIcons() }
|
||||||
|
/** 注册定时监听 */
|
||||||
|
registerReceiver(Intent.ACTION_TIME_TICK) { context, _ ->
|
||||||
|
if (isEnableHookColorNotifyIcon() && prefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_AUTO))
|
||||||
|
IconAdaptationTool.prepareAutoUpdateIconRule(context, prefs.get(DataConst.NOTIFY_ICON_FIX_AUTO_TIME))
|
||||||
|
}
|
||||||
|
onCreate {
|
||||||
|
/** 注册发送适配新的 APP 图标通知监听 */
|
||||||
|
registerReceiver(object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context, intent: Intent?) {
|
||||||
|
if (isEnableHookColorNotifyIcon()) intent?.also {
|
||||||
|
if (it.action.equals(Intent.ACTION_PACKAGE_REPLACED).not() &&
|
||||||
|
it.getBooleanExtra(Intent.EXTRA_REPLACING, false)
|
||||||
|
) return@also
|
||||||
|
it.data?.schemeSpecificPart?.also { packageName ->
|
||||||
|
when (it.action) {
|
||||||
|
Intent.ACTION_PACKAGE_ADDED -> {
|
||||||
|
if (iconDatas.takeIf { e -> e.isNotEmpty() }
|
||||||
|
?.filter { e -> e.packageName == packageName }
|
||||||
|
.isNullOrEmpty()
|
||||||
|
) IconAdaptationTool.pushNewAppSupportNotify(context, packageName)
|
||||||
|
}
|
||||||
|
Intent.ACTION_PACKAGE_REMOVED -> IconAdaptationTool.removeNewAppSupportNotify(context, packageName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, IntentFilter().apply {
|
||||||
|
addDataScheme("package")
|
||||||
|
addAction(Intent.ACTION_PACKAGE_ADDED)
|
||||||
|
addAction(Intent.ACTION_PACKAGE_REPLACED)
|
||||||
|
addAction(Intent.ACTION_PACKAGE_REMOVED)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
/** 刷新图标缓存 */
|
/** 刷新图标缓存 */
|
||||||
SystemUITool.Host.onRefreshSystemUI(param = this) { recachingPrefs(it) }
|
SystemUITool.Host.onRefreshSystemUI(param = this) { recachingPrefs(it) }
|
||||||
}
|
}
|
||||||
@@ -835,54 +863,5 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 发送适配新的 APP 图标通知 */
|
|
||||||
PluginManagerImplClass.hook {
|
|
||||||
injectMember {
|
|
||||||
method {
|
|
||||||
name = "onReceive"
|
|
||||||
param(ContextClass, IntentClass)
|
|
||||||
}
|
|
||||||
afterHook {
|
|
||||||
if (isEnableHookColorNotifyIcon()) args().last().cast<Intent>()?.also {
|
|
||||||
if (it.action.equals(Intent.ACTION_PACKAGE_REPLACED).not() &&
|
|
||||||
it.getBooleanExtra(Intent.EXTRA_REPLACING, false)
|
|
||||||
) return@also
|
|
||||||
when (it.action) {
|
|
||||||
Intent.ACTION_PACKAGE_ADDED ->
|
|
||||||
it.data?.schemeSpecificPart?.also { newPkgName ->
|
|
||||||
if (iconDatas.takeIf { e -> e.isNotEmpty() }
|
|
||||||
?.filter { e -> e.packageName == newPkgName }
|
|
||||||
.isNullOrEmpty()
|
|
||||||
) IconAdaptationTool.pushNewAppSupportNotify(args().first().cast()!!, newPkgName)
|
|
||||||
}
|
|
||||||
Intent.ACTION_PACKAGE_REMOVED ->
|
|
||||||
IconAdaptationTool.removeNewAppSupportNotify(
|
|
||||||
context = args().first().cast()!!,
|
|
||||||
packageName = it.data?.schemeSpecificPart ?: ""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** 自动检查通知图标优化更新的注入监听 */
|
|
||||||
AbstractReceiverClass.hook {
|
|
||||||
injectMember {
|
|
||||||
method {
|
|
||||||
name = "onReceive"
|
|
||||||
param(ContextClass, IntentClass)
|
|
||||||
}
|
|
||||||
afterHook {
|
|
||||||
args().first().cast<Context>()?.also {
|
|
||||||
/** 注册定时监听 */
|
|
||||||
if (isEnableHookColorNotifyIcon() && prefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_AUTO))
|
|
||||||
IconAdaptationTool.prepareAutoUpdateIconRule(
|
|
||||||
context = it,
|
|
||||||
timeSet = prefs.get(DataConst.NOTIFY_ICON_FIX_AUTO_TIME)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -119,7 +119,8 @@ object IconAdaptationTool {
|
|||||||
* @param packageName 安装的 APP 包名
|
* @param packageName 安装的 APP 包名
|
||||||
*/
|
*/
|
||||||
fun pushNewAppSupportNotify(context: Context, packageName: String) {
|
fun pushNewAppSupportNotify(context: Context, packageName: String) {
|
||||||
if (context.isDebugApp(packageName)) return
|
if (packageName.startsWith("com.google.android.trichromelibrary")) return
|
||||||
|
if (context.isSystemApp(packageName) || context.isDebugApp(packageName)) return
|
||||||
context.getSystemService(NotificationManager::class.java)?.apply {
|
context.getSystemService(NotificationManager::class.java)?.apply {
|
||||||
createNotificationChannel(
|
createNotificationChannel(
|
||||||
NotificationChannel(
|
NotificationChannel(
|
||||||
|
Reference in New Issue
Block a user