From e3013addb43d9e4720bbcefa15aa7de50c3b175b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=84=95=E6=99=A8HChen?= <123531821+HChenX@users.noreply.github.com> Date: Sat, 8 Feb 2025 21:28:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=AF=E8=83=BD=E7=9A=84=E5=B4=A9?= =?UTF-8?q?=E6=BA=83=E9=97=AE=E9=A2=98=20(#548)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lyric/hook/module/SystemUILyric.kt | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/app/src/main/kotlin/statusbar/lyric/hook/module/SystemUILyric.kt b/app/src/main/kotlin/statusbar/lyric/hook/module/SystemUILyric.kt index cb2e60a6..96fbbc06 100644 --- a/app/src/main/kotlin/statusbar/lyric/hook/module/SystemUILyric.kt +++ b/app/src/main/kotlin/statusbar/lyric/hook/module/SystemUILyric.kt @@ -283,7 +283,7 @@ class SystemUILyric : BaseHook() { if (hookParam.args[0] == View.VISIBLE) { val view = hookParam.thisObject as View if ( - (this@SystemUILyric::clockView.isInitialized && clockView == view && config.hideTime) || + (isReady && clockView == view && config.hideTime) || (this@SystemUILyric::mNotificationIconArea.isInitialized && mNotificationIconArea == view && config.hideNotificationIcon) || (this@SystemUILyric::mCarrierLabel.isInitialized && mCarrierLabel == view && config.hideCarrier) || (this@SystemUILyric::mMiuiNetworkSpeedView.isInitialized && mMiuiNetworkSpeedView == view && config.mMiuiHideNetworkSpeed) || @@ -349,13 +349,15 @@ class SystemUILyric : BaseHook() { loadClassOrNull("com.android.systemui.statusbar.phone.KeyguardStatusBarView").isNotNull { it.methodFinder().filterByName("onFinishInflate").first().createHook { after { hookParam -> - val clazz = hookParam.thisObject::class.java - if (clazz.simpleName == "KeyguardStatusBarView") { - hookParam.thisObject.objectHelper { - mCarrierLabel = this.getObjectOrNullAs("mCarrierLabel")!! + kotlin.runCatching { + val clazz = hookParam.thisObject::class.java + if (clazz.simpleName == "KeyguardStatusBarView") { + hookParam.thisObject.objectHelper { + mCarrierLabel = this.getObjectOrNullAs("mCarrierLabel")!! + } + } else { + mCarrierLabel = clazz.superclass.getField("mCarrierLabel").get(hookParam.thisObject) as View } - } else { - mCarrierLabel = clazz.superclass.getField("mCarrierLabel").get(hookParam.thisObject) as View } } } @@ -826,6 +828,7 @@ class SystemUILyric : BaseHook() { } private fun changeLyric(lyric: String, delay: Int) { + if (!isReady) return if (lyric.isEmpty()) return if (isHiding || isScreenLock) return @@ -887,6 +890,7 @@ class SystemUILyric : BaseHook() { } private fun hideLyric(anim: Boolean = true) { + if (!isReady) return if (isStop) return if (!isHiding && isPlaying && anim) { isPlaying = false @@ -1035,11 +1039,9 @@ class SystemUILyric : BaseHook() { if (clazz!!.existMethod("onWallpaperChanged")) { clazz.methodFinder().filterByName("onWallpaperChanged").first().createHook { after { - if (this@SystemUILyric::clockView.isInitialized) { - "onWallpaperChanged".log() - canLoad = true - hideLyric() - } + "onWallpaperChanged".log() + canLoad = true + hideLyric() } } break @@ -1056,8 +1058,8 @@ class SystemUILyric : BaseHook() { val newConfig = hookParam.args[0] as Configuration // themeMode = newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE || newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { - if (isReady) - changeLyricStateIfInFullScreenMode() + if (!isReady) return@after + changeLyricStateIfInFullScreenMode() } } }