Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:优化网易云歌词强开代码 #278

Merged
merged 3 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/main/assets/app_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,6 @@
]
}
],
"appRulesVersion": 14,
"version": 11
"appRulesVersion": 15,
"version": 12
}
11 changes: 1 addition & 10 deletions app/src/main/kotlin/cn/lyric/getter/hook/app/Kugou.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import cn.lyric.getter.hook.BaseHook
import cn.lyric.getter.tool.HookTools
import cn.lyric.getter.tool.HookTools.eventTools
import cn.lyric.getter.tool.HookTools.fuckTinker
import cn.lyric.getter.tool.HookTools.getProcessName
import cn.lyric.getter.tool.Tools.getVersionCode
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
import com.github.kyuubiran.ezxhelper.EzXHelper.classLoader
Expand Down Expand Up @@ -60,16 +61,6 @@ object Kugou : BaseHook() {
}
}

private fun getProcessName(context: Context): String? {
val pid = Process.myPid()
val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
for (process in manager.runningAppProcesses) {
if (process.pid == pid) {
return process.processName
}
}
return null
}

private fun hookCarLyric() {
loadClass("com.kugou.framework.player.c").methodFinder()
Expand Down
13 changes: 8 additions & 5 deletions app/src/main/kotlin/cn/lyric/getter/hook/app/Netease.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ import android.os.Build
import cn.lyric.getter.hook.BaseHook
import cn.lyric.getter.tool.ConfigTools.xConfig
import cn.lyric.getter.tool.HookTools
import cn.lyric.getter.tool.HookTools.MockFlyme
import cn.lyric.getter.tool.HookTools.dexKitBridge
import cn.lyric.getter.tool.HookTools.eventTools
import cn.lyric.getter.tool.HookTools.fuckTinker
import cn.lyric.getter.tool.HookTools.mediaMetadataCompatLyric
import cn.lyric.getter.tool.MeiZuNotification
import cn.lyric.getter.tool.Tools.getVersionCode
import cn.xiaowine.xkt.LogTool.log
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
import com.github.kyuubiran.ezxhelper.ClassUtils.setStaticObject
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
import com.github.kyuubiran.ezxhelper.params
import java.lang.reflect.Method

private fun Method.replaceName() {
Expand Down Expand Up @@ -47,7 +45,7 @@ object Netease : BaseHook() {
}
Class::class.java.methodFinder().first { name == "getField" }.replaceName()
Class::class.java.methodFinder().first { name == "getDeclaredField" }.replaceName()
fuckTinker()
//fuckTinker()
HookTools.getApplication {
val verCode = it.packageManager?.getPackageInfo(it.packageName, 0)?.getVersionCode() ?: 0
if (verCode >= 8000041 || it.packageName == "com.hihonor.cloudmusic") {
Expand All @@ -63,7 +61,12 @@ object Netease : BaseHook() {
}
}
if (verCode >= 9002033 ){
loadClass("vh0.a").methodFinder().filterByParamCount(0).filterByName("a").first().createHook {
val fuckwyy = dexKitBridge.findClass {
matcher {
usingStrings("com/netease/cloudmusic/module/lyric/flyme/StatusBarLyricSettingManager.class:setSwitchStatus:(Z)V")
}
}.single()
loadClass(fuckwyy.name).methodFinder().filterByParamCount(0).filterByName("a").first().createHook {
after { hookParam ->
val a = hookParam.result as SharedPreferences
a.edit().putBoolean("status_bar_lyric_setting_key",xConfig.fuckwyy).commit()
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/kotlin/cn/lyric/getter/tool/HookTools.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package cn.lyric.getter.tool

import android.app.ActivityManager
import android.app.AndroidAppHelper
import android.app.Application
import android.app.Notification
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Process
import cn.xiaowine.xkt.LogTool.log
import cn.xiaowine.xkt.Tool.isNot
import cn.xiaowine.xkt.Tool.isNotNull
Expand Down Expand Up @@ -94,6 +96,20 @@ object HookTools {
}
}

/** 获取应用进程名
* @param context 为应用context
* @return 为进程名*/
fun getProcessName(context: Context): String? {
val pid = Process.myPid()
val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
for (process in manager.runningAppProcesses) {
if (process.pid == pid) {
return process.processName
}
}
return null
}

fun lockNotStopLyric(classLoader: ClassLoader, fileFilter: ArrayList<String>? = null) {
dexKitBridge(classLoader) { dexKitBridge ->
dexKitBridge.apply {
Expand Down
Loading