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

[pull] master from yujincheng08:master #195

Merged
merged 50 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
81827e2
feat: fake_non_multiwindow (#1353)
duzhaokun123 Dec 27, 2023
8dfab0c
fix: settings crash if module updated (#1354)
duzhaokun123 Dec 27, 2023
62ff4b9
build(deps): bump the maven-dependencies group with 1 update (#1359)
dependabot[bot] Jan 4, 2024
f6cf56e
Full match to partial match for title filter
yujincheng08 Jan 8, 2024
f738fef
No more `client_info` since it's deprecated
yujincheng08 Jan 8, 2024
3490999
Fix default speed
yujincheng08 Jan 10, 2024
94ab2fe
Fix Rick Astley view
yujincheng08 Jan 10, 2024
db61722
Fix small window playing
yujincheng08 Jan 10, 2024
808cef4
build(deps): bump the maven-dependencies group with 3 updates (#1365)
dependabot[bot] Jan 11, 2024
67ed7d0
Fix PlayArc hook when no arc conf
yujincheng08 Jan 11, 2024
edfd65b
Also fix arc config for async call
yujincheng08 Jan 11, 2024
669b2d7
Fix play ver support
yujincheng08 Jan 11, 2024
bcd5fc7
Clean up codes
yujincheng08 Jan 11, 2024
e3508fc
Fix typo
yujincheng08 Jan 11, 2024
1573deb
Show cache button for thai bangumi
yujincheng08 Jan 11, 2024
c24f135
Use old app api to get season
yujincheng08 Jan 13, 2024
7cf8440
Fix missing season id
yujincheng08 Jan 13, 2024
6d14523
Add missing section
yujincheng08 Jan 13, 2024
a75eeb3
Fix hidden bangumi
yujincheng08 Jan 13, 2024
8d5ee10
Show replies for hidden bangumi
yujincheng08 Jan 13, 2024
a0a6187
Clean up codes
yujincheng08 Jan 13, 2024
7a2ace2
Fix class not found
yujincheng08 Jan 17, 2024
ff79035
Fix search from other area
yujincheng08 Jan 17, 2024
1d13a8d
Fix Thai subtitles
yujincheng08 Jan 28, 2024
bfa9ad3
build(deps): bump the maven-dependencies group with 1 update (#1380)
dependabot[bot] Jan 28, 2024
409db67
update bv2av magic number (#1388)
5ec1cff Feb 1, 2024
d0755f2
Change shared id (#1389)
aviraxp Feb 1, 2024
61e166c
Update bv2av algorithm (#1390)
5ec1cff Feb 1, 2024
34bd5fd
Changing the path for saving the image (#1379)
oxy2ray Feb 4, 2024
6b2f41f
feat: export access_key (#1387)
Mufanc Feb 4, 2024
80677cb
build(deps): bump the maven-dependencies group with 2 updates (#1404)
dependabot[bot] Feb 16, 2024
fb2d8db
build(deps): bump the maven-dependencies group with 3 updates (#1407)
dependabot[bot] Feb 17, 2024
898cbd7
build(deps): bump the maven-dependencies group with 3 updates (#1420)
dependabot[bot] Mar 8, 2024
4620fb8
Upgrade Gradle
yujincheng08 Mar 8, 2024
93ff173
Upgrade resopt
yujincheng08 Mar 8, 2024
96baa8e
build(deps): bump the maven-dependencies group with 3 updates (#1423)
dependabot[bot] Mar 15, 2024
b6eb963
build(deps): bump the maven-dependencies group with 1 update (#1431)
dependabot[bot] Mar 19, 2024
b55430e
feat: splash screen following dark mode (#1436)
5ec1cff Mar 27, 2024
569357d
build(deps): bump the maven-dependencies group with 3 updates (#1438)
dependabot[bot] Apr 8, 2024
965e3db
build(deps): bump com.android.application from 8.3.1 to 8.3.2 in the …
dependabot[bot] Apr 11, 2024
bad5473
Upgrade gradle
yujincheng08 Apr 28, 2024
b3f81b7
Use c++ modules
yujincheng08 Apr 28, 2024
e3c23ff
build(deps): bump com.android.application from 8.3.2 to 8.4.0 in the …
dependabot[bot] Apr 30, 2024
6f00f5c
build(deps): bump the maven-dependencies group across 1 directory wit…
dependabot[bot] May 11, 2024
a25d80a
Cache result of resolveB23URL (#1466)
5ec1cff May 15, 2024
dcc9561
build(deps): bump com.android.application from 8.4.0 to 8.4.1 in the …
dependabot[bot] May 21, 2024
15ad63f
Upgrade to kotlin 2.0
dependabot[bot] May 22, 2024
2c3045b
build(deps): bump the maven-dependencies group with 3 updates (#1472)
dependabot[bot] May 25, 2024
a28c22e
Enable 16k page size support
yujincheng08 Jun 2, 2024
637bd43
[skip ci] PR builds only on Linux
yujincheng08 Jun 2, 2024
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
8 changes: 7 additions & 1 deletion .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ]
os: [ ubuntu-latest ]

steps:
- name: Check out
Expand All @@ -28,13 +28,19 @@ jobs:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- uses: seanmiddleditch/gha-setup-ninja@master
with:
version: 1.12.0
- name: Set up ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ runner.os }}-${{ github.sha }}
restore-keys: ${{ runner.os }}
- name: Build with Gradle
run: |
sudo rm -rf $ANDROID_HOME/cmake
echo 'org.gradle.caching=true' >> gradle.properties
echo 'org.gradle.parallel=true' >> gradle.properties
echo 'org.gradle.vfs.watch=true' >> gradle.properties
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
distribution: 'temurin'
java-version: 17
cache: 'gradle'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- uses: seanmiddleditch/gha-setup-ninja@master
with:
version: 1.12.0
- name: Retrieve version
run: |
echo VERSION=$(echo ${{ github.event.head_commit.id }} | head -c 10) >> $GITHUB_ENV
Expand All @@ -33,6 +38,7 @@ jobs:
restore-keys: ${{ runner.os }}
- name: Build with Gradle
run: |
sudo rm -rf $ANDROID_HOME/cmake
echo 'org.gradle.caching=true' >> gradle.properties
echo 'org.gradle.parallel=true' >> gradle.properties
echo 'org.gradle.vfs.watch=true' >> gradle.properties
Expand Down
11 changes: 7 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ cmaker {
default {
targets("biliroaming")
abiFilters("armeabi-v7a", "arm64-v8a", "x86")
arguments += "-DANDROID_STL=none"
cppFlags += "-Wno-c++2b-extensions"
arguments += arrayOf(
"-DANDROID_STL=none",
"-DCMAKE_CXX_STANDARD=23",
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON",
)
}

buildTypes {
Expand All @@ -47,7 +50,7 @@ android {
namespace = "me.iacn.biliroaming"
compileSdk = 34
buildToolsVersion = "34.0.0"
ndkVersion = "26.0.10792818"
ndkVersion = "27.0.11718014-beta1"

buildFeatures {
prefab = true
Expand Down Expand Up @@ -115,7 +118,7 @@ android {
externalNativeBuild {
cmake {
path("src/main/jni/CMakeLists.txt")
version = "3.22.1+"
version = "3.28.0+"
}
}
}
Expand Down
71 changes: 21 additions & 50 deletions app/src/main/java/me/iacn/biliroaming/BiliBiliPackage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class BiliBiliPackage constructor(private val mClassLoader: ClassLoader, mContex
}
val searchAllResponseClass by Weak { "com.bapis.bilibili.polymer.app.search.v1.SearchAllResponse" from mClassLoader }
val searchVideoCardClass by Weak { "com.bapis.bilibili.polymer.app.search.v1.SearchVideoCard" from mClassLoader }
val playSpeedManager by Weak { mHookInfo.playSpeedManager from mClassLoader }

val ids: Map<String, Int> by lazy {
mHookInfo.mapIds.idsMap
Expand Down Expand Up @@ -231,12 +232,6 @@ class BiliBiliPackage constructor(private val mClassLoader: ClassLoader, mContex

fun getPlaybackSpeed() = mHookInfo.playerCoreService.getPlaybackSpeed.orNull

fun setPlaybackSpeed() = mHookInfo.playerCoreService.setPlaybackSpeed.orNull

fun theseusPlayerSetSpeed() = mHookInfo.playerCoreService.theseusPlayerSetSpeed.orNull

fun playerOnPrepare() = mHookInfo.playerCoreService.playerOnPrepare.orNull

fun urlField() = mHookInfo.okHttp.request.url.orNull

fun gsonToJson() = mHookInfo.gsonHelper.toJson.orNull
Expand Down Expand Up @@ -1136,7 +1131,7 @@ class BiliBiliPackage constructor(private val mClassLoader: ClassLoader, mContex
dexHelper.decodeMethodIndex(it)
}
} ?: doSeekToMethod
} ?: return@playerCoreService
}
val playerCoreServiceClass = seekToMethod.declaringClass
seekTo = method { name = seekToMethod.name }
class_ = class_ { name = playerCoreServiceClass.name }
Expand Down Expand Up @@ -1173,58 +1168,34 @@ class BiliBiliPackage constructor(private val mClassLoader: ClassLoader, mContex
dexHelper.decodeMethodIndex(it)
}?.name ?: return@method
}
dexHelper.findMethodUsingString(
"player_key_video_speed",
true,
-1,
1,
"VF",
dexHelper.encodeClassIndex(playerCoreServiceClass),
null,
null,
null,
true
).asSequence().firstOrNull()?.also { mIndex ->
dexHelper.decodeMethodIndex(mIndex)?.let {
setPlaybackSpeed = method {
name = it.name
}
}
}?.let {
dexHelper.findMethodInvoked(
it,
-1,
}
val playSpeedManagerClass = ("com.bilibili.player.tangram.basic.PlaySpeedManagerImpl" from classloader) ?: run {
val pcsFacadeClass = dexHelper.findMethodUsingString(
"Cannot switch to quality ",
false,
-1,
"VF",
-1,
null,
null,
null,
true
).asSequence().firstNotNullOfOrNull {
dexHelper.decodeMethodIndex(it)
}?.let {
theseusPlayerSetSpeed = method {
name = it.name
}
}
}
playerOnPrepare = method {
name = dexHelper.findMethodUsingString(
"[ijk][callback]player onPrepared",
true,
-1,
-1,
"VLL",
dexHelper.encodeClassIndex(playerCoreServiceClass),
null,
null,
null,
true
).asSequence().firstNotNullOfOrNull {
dexHelper.decodeMethodIndex(it)
}?.name ?: return@method
).asSequence().firstNotNullOfOrNull {
dexHelper.decodeMethodIndex(it)
}?.declaringClass ?: return@run null

val playSpeedManagerInterface = pcsFacadeClass.declaredFields.firstNotNullOfOrNull { f ->
if (f.type.isInterface && f.type.declaredMethods.size == 1) f.type else null
}
classesList.filter {
it.startsWith("com.bilibili.player.tangram")
}.firstNotNullOfOrNull { c ->
c.findClass(classloader).takeIf { it.interfaces.contains(playSpeedManagerInterface) }
}
}
playSpeedManager = class_ {
name = playSpeedManagerClass?.name ?: return@class_
}
generalResponse = class_ {
name = "com.bilibili.okretro.GeneralResponse"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/me/iacn/biliroaming/Constant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ object Constant {
const val CUSTOM_COLOR_KEY = "biliroaming_custom_color"
const val CURRENT_COLOR_KEY = "theme_entries_current_key"
const val DEFAULT_CUSTOM_COLOR = -0xe6b7d
const val infoUrl = "https://api.bilibili.com/client_info"
const val zoneUrl = "https://api.bilibili.com/x/web-interface/zone"
}
27 changes: 26 additions & 1 deletion app/src/main/java/me/iacn/biliroaming/SettingDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import android.app.Activity
import android.app.Activity.RESULT_CANCELED
import android.app.AlertDialog
import android.content.ActivityNotFoundException
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.content.res.Resources
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.Typeface
Expand All @@ -32,6 +35,7 @@ import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.*
import android.widget.SeekBar.OnSeekBarChangeListener
import android.widget.Toast
import androidx.documentfile.provider.DocumentFile
import kotlinx.coroutines.*
import me.iacn.biliroaming.BiliBiliPackage.Companion.instance
Expand Down Expand Up @@ -104,6 +108,7 @@ class SettingDialog(context: Context) : AlertDialog.Builder(context) {
findPreference("customize_dynamic")?.onPreferenceClickListener = this
findPreference("filter_search")?.onPreferenceClickListener = this
findPreference("filter_comment")?.onPreferenceClickListener = this
findPreference("copy_access_key")?.onPreferenceClickListener = this
checkCompatibleVersion()
searchItems = retrieve(preferenceScreen)
checkUpdate()
Expand Down Expand Up @@ -846,6 +851,16 @@ class SettingDialog(context: Context) : AlertDialog.Builder(context) {
}.show()
return true
}

private fun onCopyAccessKeyClick(): Boolean {
val manager = context.getSystemService(ClipboardManager::class.java)

manager.setPrimaryClip(ClipData.newPlainText("access_key", instance.accessKey))
Toast.makeText(context, R.string.copy_access_key_toast, Toast.LENGTH_SHORT).show()

return true
}

@Deprecated("Deprecated in Java")
override fun onPreferenceClick(preference: Preference) = when (preference.key) {
"version" -> onVersionClick()
Expand All @@ -866,6 +881,7 @@ class SettingDialog(context: Context) : AlertDialog.Builder(context) {
"default_speed" -> onDefaultSpeedClick()
"filter_search" -> onFilterSearchClick()
"filter_comment" -> onFilterCommentClick()
"copy_access_key" -> onCopyAccessKeyClick()
else -> false
}
}
Expand Down Expand Up @@ -1060,7 +1076,16 @@ class SettingDialog(context: Context) : AlertDialog.Builder(context) {
}

fun show(context: Context) {
SettingDialog(context).show()
try {
SettingDialog(context).show()
} catch (e: Resources.NotFoundException) {
AlertDialog.Builder(context)
.setTitle("需要重启")
.setMessage("哔哩漫游更新了")
.setPositiveButton("重启") { _, _ ->
restartApplication(context as Activity)
}.show()
}
}

const val SPLASH_SELECTION = 0
Expand Down
16 changes: 5 additions & 11 deletions app/src/main/java/me/iacn/biliroaming/XposedInit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import kotlinx.coroutines.MainScope
import kotlinx.coroutines.future.future
import me.iacn.biliroaming.hook.*
import me.iacn.biliroaming.utils.*
import org.json.JSONObject
import java.util.concurrent.CompletableFuture


Expand Down Expand Up @@ -69,16 +68,10 @@ class XposedInit : IXposedHookLoadPackage, IXposedHookZygoteInit {
)

country = MainScope().future(Dispatchers.IO) {
fun JSONObject.optStringFix(name: String, fallback: String = "") =
if (isNull(name)) fallback else optString(name, fallback)
when (fetchJson(Constant.infoUrl)?.optJSONObject("data")
?.optStringFix("country").orEmpty().ifEmpty {
fetchJson(Constant.zoneUrl)?.optJSONObject("data")
?.optStringFix("country")
}) {
"中国" -> "cn"
"香港", "澳门" -> "hk"
"台湾" -> "tw"
when (fetchJson(Constant.zoneUrl)?.optJSONObject("data")?.optInt("country_code", 0)?.or(0)) {
86 -> "cn"
852, 853 -> "hk"
886 -> "tw"
else -> "global"
}.also { Log.d("当前地区: $it") }
}
Expand Down Expand Up @@ -127,6 +120,7 @@ class XposedInit : IXposedHookLoadPackage, IXposedHookZygoteInit {
startHook(PublishToFollowingHook(lpparam.classLoader))
startHook(UposReplaceHook(lpparam.classLoader))
startHook(SpeedHook(lpparam.classLoader))
startHook(MultiWindowHook(lpparam.classLoader))
}

lpparam.processName.endsWith(":web") -> {
Expand Down
22 changes: 16 additions & 6 deletions app/src/main/java/me/iacn/biliroaming/hook/AllowMiniPlayHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package me.iacn.biliroaming.hook

import me.iacn.biliroaming.utils.from
import me.iacn.biliroaming.utils.getStaticObjectField
import me.iacn.biliroaming.utils.hookBeforeAllConstructors
import me.iacn.biliroaming.utils.hookBeforeConstructor
import me.iacn.biliroaming.utils.sPrefs

Expand All @@ -10,18 +11,27 @@ class AllowMiniPlayHook(classLoader: ClassLoader) : BaseHook(classLoader) {
if (!sPrefs.getBoolean("main_func", false)) return

if (sPrefs.getBoolean("allow_mini_play", false)) {
"com.bilibili.lib.media.resource.PlayConfig\$PlayMenuConfig".from(mClassLoader)
?.hookBeforeConstructor(
Boolean::class.javaPrimitiveType,
val miniPlayerType =
"com.bilibili.lib.media.resource.PlayConfig\$PlayConfigType"
.from(mClassLoader)?.getStaticObjectField("MINIPLAYER")
"com.bilibili.lib.media.resource.PlayConfig\$PlayMenuConfig".from(mClassLoader)?.run {
hookBeforeConstructor(
Boolean::class.javaPrimitiveType,
"com.bilibili.lib.media.resource.PlayConfig\$PlayConfigType"
) { param ->
val type = param.args[1]
if (type == miniPlayerType)
param.args[0] = true
}
hookBeforeConstructor(Boolean::class.javaPrimitiveType,
"com.bilibili.lib.media.resource.PlayConfig\$PlayConfigType",
List::class.java
) { param ->
val type = param.args[1]
val miniPlayerType =
"com.bilibili.lib.media.resource.PlayConfig\$PlayConfigType"
.from(mClassLoader)?.getStaticObjectField("MINIPLAYER")
if (type == miniPlayerType)
param.args[0] = true
}
}
}
}
}
Loading