diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/NotificationIconColumns.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/NotificationIconColumns.kt index 465bd0a355..b73c48d29d 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/NotificationIconColumns.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/NotificationIconColumns.kt @@ -6,10 +6,15 @@ import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinde import com.sevtinge.hyperceiler.module.base.BaseHook import com.sevtinge.hyperceiler.utils.callMethod import com.sevtinge.hyperceiler.utils.devicesdk.isAndroidR -import com.sevtinge.hyperceiler.utils.devicesdk.isMoreAndroidVersion +import com.sevtinge.hyperceiler.utils.devicesdk.isAndroidT +import com.sevtinge.hyperceiler.utils.devicesdk.isAndroidU +import com.sevtinge.hyperceiler.utils.devicesdk.isMoreHyperOSVersion +import com.sevtinge.hyperceiler.utils.getBooleanField +import com.sevtinge.hyperceiler.utils.getObjectField +import com.sevtinge.hyperceiler.utils.hookAfterAllConstructors +import com.sevtinge.hyperceiler.utils.log.XposedLogUtils import com.sevtinge.hyperceiler.utils.setObjectField - object NotificationIconColumns : BaseHook() { override fun init() { if (isAndroidR()) return @@ -17,6 +22,45 @@ object NotificationIconColumns : BaseHook() { val maxIconsNum = mPrefsMap.getInt("system_ui_status_bar_notification_icon_maximum", 3) val maxDotsNum = mPrefsMap.getInt("system_ui_status_bar_notification_dots_maximum", 3) + if (isAndroidU() && isMoreHyperOSVersion(1f)) { + mAndroidU(maxIconsNum, maxDotsNum) + } else { + mAndroidS(maxIconsNum, maxDotsNum) + } + } + + private fun mAndroidU(maxIconsNum: Int, maxDotsNum: Int) { + val notificationIconObserver = findClass("com.android.systemui.statusbar.policy.NotificationIconObserver") + var getBoolean = false + + notificationIconObserver.hookAfterAllConstructors { + getBoolean = it.thisObject.getBooleanField("mShowNotificationIcons") + XposedLogUtils.logI(getBoolean.toString()) + } + + loadClass("com.android.systemui.statusbar.phone.NotificationIconAreaController").methodFinder() + .filterByName("init") + .first().createHook { + after { + val getIcons = it.thisObject.getObjectField("mNotificationIcons") + if (getBoolean) { + getIcons.setObjectField("mMaxDot", maxDotsNum) + getIcons.setObjectField("mMaxStaticIcon", maxIconsNum) + getIcons.setObjectField("mMaxIconsOnLockscreen", maxIconsNum) + } else { + getIcons.setObjectField("mMaxDot", 0) + getIcons.setObjectField("mMaxStaticIcon", 0) + getIcons.setObjectField("mMaxIconsOnLockscreen", 0) + } + getIcons?.callMethod("resetViewStates") + getIcons?.callMethod("calculateIconXTranslations") + getIcons?.callMethod("applyIconStates") + XposedLogUtils.logI("NotificationIconAreaController hook success") + } + } + } + + private fun mAndroidS(maxIconsNum: Int, maxDotsNum: Int) { loadClass("com.android.systemui.statusbar.phone.NotificationIconContainer").methodFinder() .filterByName("miuiShowNotificationIcons") .filterByParamCount(1) @@ -25,7 +69,7 @@ object NotificationIconColumns : BaseHook() { if (it.args[0] as Boolean) { it.thisObject.setObjectField("MAX_DOTS", maxDotsNum) it.thisObject.setObjectField("MAX_STATIC_ICONS", maxIconsNum) - if (isMoreAndroidVersion(33)) { + if (isAndroidT()) { it.thisObject.setObjectField("MAX_ICONS_ON_LOCKSCREEN", maxIconsNum) } else { it.thisObject.setObjectField("MAX_VISIBLE_ICONS_ON_LOCK", maxIconsNum) @@ -33,7 +77,7 @@ object NotificationIconColumns : BaseHook() { } else { it.thisObject.setObjectField("MAX_DOTS", 0) it.thisObject.setObjectField("MAX_STATIC_ICONS", 0) - if (isMoreAndroidVersion(33)) { + if (isAndroidT()) { it.thisObject.setObjectField("MAX_ICONS_ON_LOCKSCREEN", 0) } else { it.thisObject.setObjectField("MAX_VISIBLE_ICONS_ON_LOCK", 0)