Skip to content

Commit a2005cc

Browse files
committed
YouTube: Support multiple videoQualityMenuViewInflate methods
Support YouTube 20.43.32
1 parent 1dff248 commit a2005cc

File tree

2 files changed

+47
-33
lines changed

2 files changed

+47
-33
lines changed

app/src/main/java/io/github/chsbuffer/revancedxposed/youtube/video/quality/AdvancedVideoQualityMenuPatch.kt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@ fun YoutubeHook.AdvancedVideoQualityMenu() {
2929
// region Patch for the old type of the video quality menu.
3030
// Used for regular videos when spoofing to old app version,
3131
// and for the Shorts quality flyout on newer app versions.
32-
::videoQualityMenuViewInflateFingerprint.hookMethod(scopedHook(DexMethod("Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;").toMember()) {
33-
val bottom_sheet_list_fragment =
34-
Utils.getResourceIdentifier("bottom_sheet_list_fragment", "layout")
35-
val bottom_sheet_list_view = Utils.getResourceIdentifier("bottom_sheet_list_view", "id")
36-
after {
37-
if (it.args[0] != bottom_sheet_list_fragment) return@after
38-
val view = it.result as View
39-
val listView: ListView = view.findViewById(bottom_sheet_list_view)
40-
AdvancedVideoQualityMenuPatch.addVideoQualityListMenuListener(listView)
41-
}
42-
})
32+
::videoQualityMenuViewInflateFingerprint.dexMethodList.forEach {
33+
it.hookMethod(scopedHook(DexMethod("Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;").toMember()) {
34+
val bottom_sheet_list_fragment =
35+
Utils.getResourceIdentifier("bottom_sheet_list_fragment", "layout")
36+
val bottom_sheet_list_view = Utils.getResourceIdentifier("bottom_sheet_list_view", "id")
37+
after {
38+
if (it.args[0] != bottom_sheet_list_fragment) return@after
39+
val view = it.result as View
40+
val listView: ListView = view.findViewById(bottom_sheet_list_view)
41+
AdvancedVideoQualityMenuPatch.addVideoQualityListMenuListener(listView)
42+
}
43+
})
44+
}
4345

4446
// Force YT to add the 'advanced' quality menu for Shorts.
4547
::videoQualityMenuOptionsFingerprint.hookMethod {

app/src/main/java/io/github/chsbuffer/revancedxposed/youtube/video/quality/Fingerprints.kt

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ package io.github.chsbuffer.revancedxposed.youtube.video.quality
22

33
import io.github.chsbuffer.revancedxposed.AccessFlags
44
import io.github.chsbuffer.revancedxposed.Opcode
5+
import io.github.chsbuffer.revancedxposed.accessFlags
6+
import io.github.chsbuffer.revancedxposed.findMethodListDirect
57
import io.github.chsbuffer.revancedxposed.fingerprint
8+
import io.github.chsbuffer.revancedxposed.literal
9+
import io.github.chsbuffer.revancedxposed.opcodes
10+
import io.github.chsbuffer.revancedxposed.parameters
611
import io.github.chsbuffer.revancedxposed.resourceMappings
12+
import io.github.chsbuffer.revancedxposed.returns
713

814
val videoQualityItemOnClickParentFingerprint = fingerprint {
915
returns("V")
@@ -41,25 +47,31 @@ val videoQualityBottomSheetListFragmentTitle get() = resourceMappings[
4147
"video_quality_bottom_sheet_list_fragment_title",
4248
]
4349

44-
val videoQualityMenuViewInflateFingerprint = fingerprint {
45-
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
46-
returns("L")
47-
parameters("L", "L", "L")
48-
opcodes(
49-
Opcode.INVOKE_SUPER,
50-
Opcode.CONST,
51-
Opcode.CONST_4,
52-
Opcode.INVOKE_VIRTUAL,
53-
Opcode.MOVE_RESULT_OBJECT,
54-
Opcode.CONST,
55-
Opcode.INVOKE_VIRTUAL,
56-
Opcode.MOVE_RESULT_OBJECT,
57-
Opcode.CONST_16,
58-
Opcode.INVOKE_VIRTUAL,
59-
Opcode.CONST,
60-
Opcode.INVOKE_VIRTUAL,
61-
Opcode.MOVE_RESULT_OBJECT,
62-
Opcode.CHECK_CAST,
63-
)
64-
literal { videoQualityBottomSheetListFragmentTitle }
65-
}
50+
val videoQualityMenuViewInflateFingerprint = findMethodListDirect {
51+
// two matches in versions 20.43.32
52+
// one match in versions <=v20.42.xx
53+
findMethod {
54+
matcher {
55+
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
56+
returns("L")
57+
parameters("L", "L", "L")
58+
opcodes(
59+
Opcode.INVOKE_SUPER,
60+
Opcode.CONST,
61+
Opcode.CONST_4,
62+
Opcode.INVOKE_VIRTUAL,
63+
Opcode.MOVE_RESULT_OBJECT,
64+
Opcode.CONST,
65+
Opcode.INVOKE_VIRTUAL,
66+
Opcode.MOVE_RESULT_OBJECT,
67+
Opcode.CONST_16,
68+
Opcode.INVOKE_VIRTUAL,
69+
Opcode.CONST,
70+
Opcode.INVOKE_VIRTUAL,
71+
Opcode.MOVE_RESULT_OBJECT,
72+
Opcode.CHECK_CAST,
73+
)
74+
literal { videoQualityBottomSheetListFragmentTitle }
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)