Skip to content

Commit 234feb7

Browse files
inotia00Francesco146
authored andcommitted
fix(Shorts components): Hide sound button doesn't work (A/B tests)
1 parent 96a0ca7 commit 234feb7

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsComponentPatch.kt

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import app.revanced.patcher.util.smali.ExternalLabel
1313
import app.revanced.patches.shared.litho.LithoFilterPatch
1414
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsButtonFingerprint
1515
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsPaidPromotionFingerprint
16-
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsPivotFingerprint
1716
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsPivotLegacyFingerprint
1817
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsSubscriptionsTabletFingerprint
1918
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsSubscriptionsTabletParentFingerprint
@@ -27,25 +26,26 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
2726
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelDynRemix
2827
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelDynShare
2928
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelForcedMuteButton
30-
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelPivotButton
3129
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelPlayerFooter
30+
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelPlayerRightPivotV2Size
3231
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelRightDislikeIcon
3332
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelRightLikeIcon
3433
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.RightComment
3534
import app.revanced.patches.youtube.utils.settings.SettingsPatch
3635
import app.revanced.patches.youtube.video.information.VideoInformationPatch
36+
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
3737
import app.revanced.util.getTargetIndexOrThrow
3838
import app.revanced.util.getTargetIndexReversedOrThrow
3939
import app.revanced.util.getTargetIndexWithReferenceOrThrow
4040
import app.revanced.util.getWideLiteralInstructionIndex
41+
import app.revanced.util.literalInstructionHook
4142
import app.revanced.util.patch.BaseBytecodePatch
4243
import app.revanced.util.resultOrThrow
4344
import com.android.tools.smali.dexlib2.Opcode
4445
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
4546
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
4647
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
4748
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
48-
import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction
4949
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
5050

5151
@Suppress("unused")
@@ -65,7 +65,6 @@ object ShortsComponentPatch : BaseBytecodePatch(
6565
fingerprints = setOf(
6666
ShortsButtonFingerprint,
6767
ShortsPaidPromotionFingerprint,
68-
ShortsPivotFingerprint,
6968
ShortsPivotLegacyFingerprint,
7069
ShortsSubscriptionsTabletParentFingerprint,
7170
TextComponentSpecFingerprint
@@ -134,8 +133,11 @@ object ShortsComponentPatch : BaseBytecodePatch(
134133

135134
// region patch for hide sound button
136135

137-
ShortsPivotLegacyFingerprint.result?.let {
138-
it.mutableMethod.apply {
136+
val shortsPivotLegacyFingerprintResult = ShortsPivotLegacyFingerprint.result
137+
138+
if (shortsPivotLegacyFingerprintResult != null) {
139+
// Legacy method.
140+
shortsPivotLegacyFingerprintResult.mutableMethod.apply {
139141
val targetIndex = getWideLiteralInstructionIndex(ReelForcedMuteButton)
140142
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
141143

@@ -150,23 +152,19 @@ object ShortsComponentPatch : BaseBytecodePatch(
150152
""", ExternalLabel("hide", getInstruction(jumpIndex))
151153
)
152154
}
153-
} ?: ShortsPivotFingerprint.resultOrThrow().let {
154-
it.mutableMethod.apply {
155-
val constCalls = implementation!!.instructions.withIndex()
156-
.filter { instruction ->
157-
(instruction.value as? WideLiteralInstruction)?.wideLiteral == ReelPivotButton
158-
}
159-
val targetIndex = constCalls.elementAt(constCalls.size - 1).index
160-
val insertIndex =
161-
getTargetIndexReversedOrThrow(targetIndex, Opcode.INVOKE_STATIC) + 1
162-
if (insertIndex == 0)
163-
throw PatchException("insert index not found")
155+
} else if (ReelPlayerRightPivotV2Size != -1L) {
156+
// Invoke Sound button dimen into integrations.
157+
val smaliInstruction = """
158+
invoke-static {v$REGISTER_TEMPLATE_REPLACEMENT}, $SHORTS_CLASS_DESCRIPTOR->getShortsSoundButtonDimenId(I)I
159+
move-result v$REGISTER_TEMPLATE_REPLACEMENT
160+
"""
164161

165-
hideButtons(
166-
insertIndex,
167-
"hideShortsSoundButton(Ljava/lang/Object;)Ljava/lang/Object;"
168-
)
169-
}
162+
context.literalInstructionHook(
163+
ReelPlayerRightPivotV2Size,
164+
smaliInstruction
165+
)
166+
} else {
167+
throw PatchException("ReelPlayerRightPivotV2Size is not found")
170168
}
171169

172170
// endregion

src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ object SharedResourceIdPatch : ResourcePatch() {
7979
var ReelDynRemix = -1L
8080
var ReelDynShare = -1L
8181
var ReelForcedMuteButton = -1L
82-
var ReelPivotButton = -1L
8382
var ReelPlayerFooter = -1L
83+
var ReelPlayerRightPivotV2Size = -1L
8484
var ReelRightDislikeIcon = -1L
8585
var ReelRightLikeIcon = -1L
8686
var ReelTimeBarPlayedColor = -1L
@@ -176,8 +176,8 @@ object SharedResourceIdPatch : ResourcePatch() {
176176
ReelDynRemix = getId(ID, "reel_dyn_remix")
177177
ReelDynShare = getId(ID, "reel_dyn_share")
178178
ReelForcedMuteButton = getId(ID, "reel_player_forced_mute_button")
179-
ReelPivotButton = getId(ID, "reel_pivot_button")
180179
ReelPlayerFooter = getId(LAYOUT, "reel_player_dyn_footer_vert_stories3")
180+
ReelPlayerRightPivotV2Size = getId(DIMEN, "reel_player_right_pivot_v2_size")
181181
ReelRightDislikeIcon = getId(DRAWABLE, "reel_right_dislike_icon")
182182
ReelRightLikeIcon = getId(DRAWABLE, "reel_right_like_icon")
183183
ReelTimeBarPlayedColor = getId(COLOR, "reel_time_bar_played_color")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3+
<item type="dimen" name="revanced_zero_padding">0.0dip</item>
34
<item type="dimen" name="revanced_edit_text_dialog_min_width_major">80.0%</item>
45
<item type="dimen" name="revanced_edit_text_dialog_min_width_minor">90.0%</item>
56
</resources>

0 commit comments

Comments
 (0)