Skip to content

Commit

Permalink
华为音乐支持 (#205)
Browse files Browse the repository at this point in the history
* 华为音乐支持

* Update app_rules.json

---------

Co-authored-by: xiao_wine <[email protected]>
  • Loading branch information
ghhccghk and xiaowine authored Oct 6, 2024
1 parent 0ecb07f commit 6ef4a57
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.refine)
kotlin("plugin.parcelize")
}

val localProperties = Properties()
Expand Down Expand Up @@ -97,4 +98,5 @@ dependencies {
implementation(libs.modernandroidpreferences)
implementation(libs.swiperefreshlayout)


}
19 changes: 17 additions & 2 deletions app/src/main/assets/app_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,23 @@
"remarks": ""
}
]
},
{
"packageName": "com.huawei.music",
"name": "华为音乐",
"rules": [
{
"startVersionCode": 121136301,
"endVersionCode": 2147483647,
"excludeVersions": [],
"apiVersion": 0,
"useApi": false,
"getLyricType": 1,
"remarks": ""
}
]
}
],
"appRulesVersion": 11,
"version": 8
"appRulesVersion": 12,
"version": 9
}
2 changes: 2 additions & 0 deletions app/src/main/kotlin/cn/lyric/getter/hook/MainHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import cn.lyric.getter.hook.app.Apple
import cn.lyric.getter.hook.app.Aqzscn
import cn.lyric.getter.hook.app.Bodian
import cn.lyric.getter.hook.app.Flamingo
import cn.lyric.getter.hook.app.Huawei
import cn.lyric.getter.hook.app.Kde
import cn.lyric.getter.hook.app.Kugou
import cn.lyric.getter.hook.app.Kuwo
Expand Down Expand Up @@ -61,6 +62,7 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
"com.mimicry.mymusic" -> initHooks(Mimicry)
"yos.music.player" -> initHooks(Flamingo)
"org.kde.kdeconnect_tp" -> initHooks(Kde)
"com.huawei.music" -> initHooks(Huawei)
else -> initHooks(Api)
}
}
Expand Down
42 changes: 42 additions & 0 deletions app/src/main/kotlin/cn/lyric/getter/hook/app/Huawei.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package cn.lyric.getter.hook.app

import cn.lyric.getter.hook.BaseHook
import cn.lyric.getter.tool.HookTools
import cn.lyric.getter.tool.HookTools.eventTools
import cn.xiaowine.xkt.LogTool.log
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
import java.util.Arrays

object Huawei : BaseHook() {
override fun init() {
super.init()
//// 让程序以为连接了蓝牙
loadClass("com.android.mediacenter.localmusic.VehicleLyricControl").methodFinder()
.first { name == "isEnableRefreshShowLyric" }
.createHook {
after { param ->
val resultIntent = param.result as Boolean
//resultIntent.log()
}
before {
val field = it.thisObject.javaClass.getDeclaredField("mIsBluetoothA2dpConnect")
field.isAccessible = true // 确保可以访问私有字段
field.setBoolean(it.thisObject, true) // 设置值为 true
}
}


loadClass("com.android.mediacenter.localmusic.MediaSessionController").methodFinder()
.first { name == "updateLyric" }
.createHook {
before {
val lyric = it.args
val lyricWithoutBrackets = Arrays.toString(lyric).substring(1, Arrays.toString(lyric).length - 1)
//lyricWithoutBrackets.log()
eventTools.sendLyric(lyricWithoutBrackets)
}
}
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
<item>com.mimicry.mymusic</item>
<item>yos.music.player</item>
<item>org.kde.kdeconnect_tp</item>
<item>com.huawei.music</item>
</array>
</resources>

0 comments on commit 6ef4a57

Please sign in to comment.