Skip to content

Commit

Permalink
[try fix for HyperOS] 系统界面-图标-通知图标 相关设置
Browse files Browse the repository at this point in the history
  • Loading branch information
lingqiqi5211 committed Oct 30, 2023
1 parent f04fe0a commit 79529e1
Showing 1 changed file with 48 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,61 @@ 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

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)
Expand All @@ -25,15 +69,15 @@ 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)
}
} 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)
Expand Down

0 comments on commit 79529e1

Please sign in to comment.