Skip to content

Commit

Permalink
feat: update patches to latest version
Browse files Browse the repository at this point in the history
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
oSumAtrIX committed May 22, 2022
1 parent c4c86b6 commit bad25de
Show file tree
Hide file tree
Showing 33 changed files with 64 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class CodecsUnlockPatch : BytecodePatch(

val implementation = result.method.implementation!!

val instructionIndex = result.scanData.startIndex
val instructionIndex = result.scanResult.startIndex

result = signatures.last().result!!
val codecMethod = data.toMethodWalker(result.immutableMethod).walk(result.scanData.startIndex).getMethod()
val codecMethod = data.toMethodWalker(result.immutableMethod).walk(result.scanResult.startIndex).getMethod()

implementation.replaceInstruction(
instructionIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RemoveTasteBuilderPatch : BytecodePatch(
val result = signatures.first().result!!
val implementation = result.method.implementation!!

val insertIndex = result.scanData.endIndex - 8
val insertIndex = result.scanResult.endIndex - 8

val register = (implementation.instructions[insertIndex] as Instruction22c).registerA

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RemoveUpgradeButtonPatch : BytecodePatch(
val implementation = result.method.implementation!!

val pivotBarElementFieldRef =
(implementation.instructions[result.scanData.endIndex - 1] as Instruction22c).reference
(implementation.instructions[result.scanResult.endIndex - 1] as Instruction22c).reference

val register = (implementation.instructions.first() as Instruction35c).registerC
// first compile all the needed instructions
Expand All @@ -48,14 +48,14 @@ class RemoveUpgradeButtonPatch : BytecodePatch(

// replace the instruction to retain the label at given index
implementation.replaceInstruction(
result.scanData.endIndex - 1, instructionList[0] // invoke-interface
result.scanResult.endIndex - 1, instructionList[0] // invoke-interface
)
// do not forget to remove this instruction since we added it already
instructionList.removeFirst()

val exitInstruction = instructionList.last() // iput-object
implementation.addInstruction(
result.scanData.endIndex, exitInstruction
result.scanResult.endIndex, exitInstruction
)
// do not forget to remove this instruction since we added it already
instructionList.removeLast()
Expand All @@ -64,12 +64,12 @@ class RemoveUpgradeButtonPatch : BytecodePatch(
instructionList.add(
2, // if-le
BuilderInstruction22t(
Opcode.IF_LE, 1, 2, implementation.newLabelForIndex(result.scanData.endIndex)
Opcode.IF_LE, 1, 2, implementation.newLabelForIndex(result.scanResult.endIndex)
)
)

implementation.addInstructions(
result.scanData.endIndex, instructionList
result.scanResult.endIndex, instructionList
)
return PatchResultSuccess()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package

@Compatibility(
[Package(
"com.google.android.youtube", arrayOf("17.03.38", "17.14.35", "17.17.34")
"com.google.android.youtube", arrayOf("17.03.38", "17.14.35", "17.17.34", "17.19.36")
)]
)
@Target(AnnotationTarget.CLASS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ for (i in 0 until signatures.count()) {
val signature = signatures.elementAt(i)
val result = signature.result!!
val implementation = result.method.implementation!!
val index = result.scanData.startIndex
val index = result.scanResult.startIndex
val instructions = implementation.instructions
val register = (instructions[index + (if (i < 2) -1 else 1)] as Instruction11x).registerA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import app.revanced.patcher.extensions.or
import app.revanced.patcher.signature.implementation.method.MethodSignature
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod
import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility
import app.revanced.patches.youtube.ad.home.annotation.PromotionsCompatibility
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode

@Name("promoted-discovery-app-parent-signature")
@MatchingMethod(
"Ljre;", "lP"
"Ljqb;", "lG"
)
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@SeekbarTappingCompatibility
@PromotionsCompatibility
@Version("0.0.1")
object PromotedDiscoveryActionParentSignature : MethodSignature(
"V",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import app.revanced.patcher.extensions.or
import app.revanced.patcher.signature.implementation.method.MethodSignature
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod
import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility
import app.revanced.patches.youtube.ad.home.annotation.PromotionsCompatibility
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode

@Name("promoted-discovery-action-parent-signature")
@MatchingMethod(
"Ljqv;",
"lP"
"Ljqj;",
"lG"
)
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@SeekbarTappingCompatibility
@PromotionsCompatibility
@Version("0.0.1")

object PromotedDiscoveryAppParentSignature : MethodSignature(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package

@Compatibility(
[Package(
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34")
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36")
)]
)
@Target(AnnotationTarget.CLASS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import app.revanced.patcher.extensions.or
import app.revanced.patcher.signature.implementation.method.MethodSignature
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod
import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility
import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode

@Name("show-video-ads-constructor-signature")
@MatchingMethod(
"Laadb",
"Laair",
"<init>",
)
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@SeekbarTappingCompatibility
@VideoAdsCompatibility
@Version("0.0.1")
object ShowVideoAdsConstructorSignature : MethodSignature(
"V", AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, listOf("L", "L", "L"), listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package

@Compatibility(
[Package(
"com.google.android.youtube", arrayOf("17.17.34")
"com.google.android.youtube", arrayOf("17.17.34", "17.19.36")
)]
)
@Target(AnnotationTarget.CLASS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,25 @@ class EnableSeekbarTappingPatch : BytecodePatch(
val oMethod = tapSeekMethods["O"]!!

// get the required register
val instruction = implementation.instructions[result.scanData.endIndex]
val instruction = implementation.instructions[result.scanResult.endIndex]
if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return PatchResultError("Could not find the correct register")
val register = (instruction as Instruction35c).registerC

// the instructions are written in reverse order.
implementation.addInstructions(
result.scanData.endIndex + 1, """
result.scanResult.endIndex + 1, """
invoke-virtual { v$register, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V
invoke-virtual { v$register, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V
""".trimIndent().toInstructions()
)

// if tap-seeking is disabled, do not invoke the two methods above by jumping to the else label
val elseLabel = implementation.newLabelForIndex(result.scanData.endIndex + 1)
val elseLabel = implementation.newLabelForIndex(result.scanResult.endIndex + 1)
implementation.addInstruction(
result.scanData.endIndex + 1, BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel)
result.scanResult.endIndex + 1, BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel)
)
implementation.addInstructions(
result.scanData.endIndex + 1, """
result.scanResult.endIndex + 1, """
invoke-static { }, Lfi/razerman/youtube/preferences/BooleanPreferences;->isTapSeekingEnabled()Z
move-result v0
""".trimIndent().toInstructions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode

@Name("enable-seekbar-tapping-parent")
@MatchingMethod("Lzhj;", "J")
@MatchingMethod("Lzmx;", "I")
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@SeekbarTappingCompatibility
@Version("0.0.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode

@Name("enable-seekbar-tapping-signature")
@MatchingMethod("Lfao;", "onTouchEvent")
@MatchingMethod("Lfbl;", "onTouchEvent")
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@SeekbarTappingCompatibility
@Version("0.0.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package

@Compatibility(
[Package(
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34")
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36")
)]
)
@Target(AnnotationTarget.CLASS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.io.File

@Patch
@Name("amoled")
@Description("Enables black theme (amoled mode)")
@Description("Enables pure black theme.")
@AmoledCompatibility
@Version("0.0.1")
class AmoledPatch : ResourcePatch() {
Expand All @@ -23,18 +23,13 @@ class AmoledPatch : ResourcePatch() {
val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element

for (i in 0 until resourcesNode.childNodes.length) {
val node = resourcesNode.childNodes.item(i) as Element
val node = resourcesNode.childNodes.item(i)
if (node !is Element) continue

node.nodeValue = when (node.getAttribute("name")) {
"yt_black1",
"yt_black1_opacity95",
"yt_black2",
"yt_black3",
"yt_black4",
"yt_status_bar_background_dark"
-> "@android:color/black"
"yt_selected_nav_label_dark"
-> "#ffdf0000"
val element = resourcesNode.childNodes.item(i) as Element
element.textContent = when (element.getAttribute("name")) {
"yt_black1", "yt_black1_opacity95", "yt_black2", "yt_black3", "yt_black4", "yt_status_bar_background_dark" -> "@android:color/black"
"yt_selected_nav_label_dark" -> "#ffdf0000"
else -> continue
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package

@Compatibility(
[Package(
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34")
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36")
)]
)
@Target(AnnotationTarget.CLASS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import app.revanced.patcher.patch.implementation.misc.PatchResult
import app.revanced.patcher.patch.implementation.misc.PatchResultError
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
import app.revanced.patcher.util.smali.toInstruction
import app.revanced.patches.youtube.layout.createbutton.annotations.CreateButtonCompatibility
import app.revanced.patches.youtube.layout.createbutton.signatures.CreateButtonSignature
import app.revanced.patches.youtube.layout.minimizedplayback.annotations.MinimizedPlaybackCompatibility
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.formats.Instruction35c

@Patch
@Name("disable-create-button")
@Description("Disable the create button.")
@MinimizedPlaybackCompatibility
@CreateButtonCompatibility
@Version("0.0.1")
class CreateButtonRemoverPatch : BytecodePatch(
listOf(
Expand All @@ -30,14 +30,14 @@ class CreateButtonRemoverPatch : BytecodePatch(

// Get the required register which holds the view object we need to pass to the method hideCreateButton
val implementation = result.method.implementation!!
val instruction = implementation.instructions[result.scanData.endIndex + 1]
val instruction = implementation.instructions[result.scanResult.endIndex + 1]
if (instruction.opcode != Opcode.INVOKE_STATIC)
return PatchResultError("Could not find the correct register")
val register = (instruction as Instruction35c).registerC

// Hide the button view via proxy by passing it to the hideCreateButton method
implementation.addInstruction(
result.scanData.endIndex + 1,
result.scanResult.endIndex + 1,
"invoke-static { v$register }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V".toInstruction()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.jf.dexlib2.Opcode

@Name("create-button-signature")
@MatchingMethod(
"Lkne", "z"
"Lknw", "z"
)
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@CreateButtonCompatibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package

@Compatibility(
[Package(
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34")
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36")
)]
)
@Target(AnnotationTarget.CLASS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.jf.dexlib2.Opcode

@Name("minimized-playback-manager-signature")
@MatchingMethod(
"Lype", "j"
"Lyuf", "n"
)
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@MinimizedPlaybackCompatibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package

@Compatibility(
[Package(
"com.google.android.youtube", arrayOf("17.17.34")
"com.google.android.youtube", arrayOf("17.17.34", "17.19.36")
)]
)
@Target(AnnotationTarget.CLASS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class OldQualityLayoutPatch : BytecodePatch(

// if useOldStyleQualitySettings == true, jump over all instructions
val jmpInstruction = BuilderInstruction21t(
Opcode.IF_NEZ, 0, implementation.instructions[result.scanData.endIndex].location.labels.first()
Opcode.IF_NEZ, 0, implementation.instructions[result.scanResult.endIndex].location.labels.first()
)
implementation.addInstruction(5, jmpInstruction)
implementation.addInstructions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.implementation.BytecodeData
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.implementation.BytecodePatch
import app.revanced.patcher.patch.implementation.misc.PatchResult
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
import app.revanced.patcher.util.smali.toInstruction
import app.revanced.patches.youtube.layout.reels.annotations.HideReelsCompatibility
import app.revanced.patches.youtube.layout.reels.signatures.HideReelsSignature

@Patch
//@Patch TODO: converted to litho
@Name("hide-reels")
@Description("Hide reels on the page.")
@HideReelsCompatibility
Expand All @@ -29,7 +28,7 @@ class HideReelsPatch : BytecodePatch(
// HideReel will hide the reel view before it is being used,
// so we pass the view to the HideReel method
implementation.addInstruction(
result.scanData.endIndex,
result.scanResult.endIndex,
"invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->HideReel(Landroid/view/View;)V".toInstruction()
)

Expand Down
Loading

0 comments on commit bad25de

Please sign in to comment.