Skip to content

Commit

Permalink
feat: force system media controls (yujincheng08#1292)
Browse files Browse the repository at this point in the history
  • Loading branch information
tehcneko authored Oct 14, 2023
1 parent 9a49cd8 commit ae5b4f5
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/src/main/java/me/iacn/biliroaming/SettingDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ class SettingDialog(context: Context) : AlertDialog.Builder(context) {

private fun checkCompatibleVersion() {
val versionCode = getVersionCode(packageName)
var supportMusicNotificationHook = versionCode >= 7500300 &&
// from bilibili
Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Build.MANUFACTURER.lowercase().equals("huawei")
var supportCustomizeTab = true
val supportFullSplash = try {
instance.splashInfoClass?.getMethod("getMode") != null
Expand Down Expand Up @@ -275,6 +278,15 @@ class SettingDialog(context: Context) : AlertDialog.Builder(context) {
if (!supportFullSplash) {
disablePreference("full_splash")
}
if (!supportMusicNotificationHook) {
if (versionCode >= 7500300) {
disablePreference(
"music_notification",
context.getString(R.string.os_not_support))
} else {
disablePreference("music_notification")
}
}
if (!supportMain) {
disablePreference("main_func", "Android O以下系统不支持64位Xpatch版,请使用32位版")
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/me/iacn/biliroaming/XposedInit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class XposedInit : IXposedHookLoadPackage, IXposedHookZygoteInit {
startHook(SplashHook(lpparam.classLoader))
startHook(EnvHook(lpparam.classLoader))
startHook(DownloadThreadHook(lpparam.classLoader))
startHook(MusicNotificationHook(lpparam.classLoader))
startHook(DrawerHook(lpparam.classLoader))
startHook(CoverHook(lpparam.classLoader))
startHook(SubtitleHook(lpparam.classLoader))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package me.iacn.biliroaming.hook

import me.iacn.biliroaming.utils.Log
import me.iacn.biliroaming.utils.findClassOrNull
import me.iacn.biliroaming.utils.hookBeforeMethod
import me.iacn.biliroaming.utils.sPrefs

class MusicNotificationHook(classLoader: ClassLoader) : BaseHook(classLoader) {
override fun startHook() {
if (!sPrefs.getBoolean("music_notification", false)) return

Log.d("startHook: MusicNotification")

"com.bilibili.lib.blconfig.ConfigManager\$Companion".findClassOrNull(mClassLoader)?.run {
hookBeforeMethod(
"isHitFF",
String::class.java
) { param ->
(param.args[0] as String).run {
if (this == "ff_background_use_system_media_controls") {
param.result = true
}
}
}
}
}

}
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
<string name="fix_download_summary">提高版权番剧的下载速度,但是会导致音视频分离</string>
<string name="customize_home_tab_title">净化首页标签</string>
<string name="customize_home_tab_summary">请勿全部选择,会使用之前的的标签</string>
<string name="music_notification_title">原生音乐通知样式</string>
<string name="music_notification_summary">强制音乐通知栏为原生样式</string>
<string name="custom_server_title">设置解析服务器</string>
<string name="custom_server_summary">使用设置的服务器解析区域限制番剧的播放地址;如不知如何设置,请查看帮助文档</string>
<string name="drawer_title">移动我的页面到侧边栏</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/xml/prefs_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
android:key="full_splash"
android:summary="@string/full_splash_summary"
android:title="@string/full_splash_title" />
<SwitchPreference
android:key="music_notification"
android:summary="@string/music_notification_summary"
android:title="@string/music_notification_title" />
<SwitchPreference
android:key="drawer"
android:summary="@string/drawer_summary"
Expand Down

0 comments on commit ae5b4f5

Please sign in to comment.