refactor: remove all parameter names

also fixed some warnings.
This commit is contained in:
Lucaskyy 2022-04-14 18:45:34 +02:00
parent f55d917db4
commit 8034fee8ea
No known key found for this signature in database
GPG Key ID: 1530BFF96D1EEB89
8 changed files with 177 additions and 168 deletions

View File

@ -1,8 +1,8 @@
package app.revanced.patches.ad
import app.revanced.patcher.PatcherData
import app.revanced.patcher.extensions.or
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.or
import app.revanced.patcher.patch.*
import app.revanced.patcher.signature.MethodMetadata
import app.revanced.patcher.signature.MethodSignature
@ -15,32 +15,32 @@ import org.jf.dexlib2.Opcode
private val compatiblePackages = listOf("com.google.android.youtube")
class VideoAdsPatch : Patch(
metadata = PatchMetadata(
shortName = "video-ads",
name = "YouTube Video Ads Patch",
description = "Patch to remove ads in the YouTube video player.",
compatiblePackages = compatiblePackages,
version = "0.0.1"
PatchMetadata(
"video-ads",
"YouTube Video Ads Patch",
"Patch to remove ads in the YouTube video player.",
compatiblePackages,
"0.0.1"
),
signatures = listOf(
listOf(
MethodSignature(
methodSignatureMetadata = MethodSignatureMetadata(
name = "show-video-ads-constructor",
methodMetadata = MethodMetadata(
definingClass = "zai",
name = "<init>",
MethodSignatureMetadata(
"show-video-ads-constructor",
MethodMetadata(
"zai",
"<init>",
),
patternScanMethod = PatternScanMethod.Fuzzy(2),// FIXME: Test this threshold and find the best value.
compatiblePackages = compatiblePackages,
description = """Signature for the constructor of some class.
PatternScanMethod.Fuzzy(2),// FIXME: Test this threshold and find the best value.
compatiblePackages,
"""Signature for the constructor of some class.
This signature is being used to find another method in the parent class
and was discovered in the YouTube version v17.03.38""".trimIndent(),
version = "0.0.1"
"0.0.1"
),
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
methodParameters = listOf("L", "L", "L"),
opcodes = listOf(
"V",
AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
listOf("L", "L", "L"),
listOf(
Opcode.INVOKE_DIRECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
@ -62,30 +62,30 @@ class VideoAdsPatch : Patch(
)
) {
override fun execute(patcherData: PatcherData): PatchResult {
var result = signatures.first().result!!
val result = signatures.first().result!!
val responsibleMethodSignature = MethodSignature(
methodSignatureMetadata = MethodSignatureMetadata(
name = "show-video-ads-method",
methodMetadata = MethodMetadata(
definingClass = "zai",
name = null // unknown
MethodSignatureMetadata(
"show-video-ads-method",
MethodMetadata(
"zai",
null // unknown
),
patternScanMethod = PatternScanMethod.Direct(),
compatiblePackages = compatiblePackages,
description = "Signature to find the method, which is responsible for showing the video ads",
version = "0.0.1"
PatternScanMethod.Direct(),
compatiblePackages,
"Signature to find the method, which is responsible for showing the video ads",
"0.0.1"
),
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
methodParameters = listOf("Z"),
opcodes = null
"V",
AccessFlags.PUBLIC or AccessFlags.FINAL,
listOf("Z"),
null
)
result = result.findParentMethod(
result.findParentMethod(
responsibleMethodSignature
) ?: return PatchResultError(
"Could not find parent method with signature ${responsibleMethodSignature.methodSignatureMetadata.name}"
"Could not find parent method with signature ${responsibleMethodSignature.metadata.name}"
)
// Override the parameter by calling shouldShowAds and setting the parameter to the result

View File

@ -1,8 +1,8 @@
package app.revanced.patches.interaction
import app.revanced.patcher.PatcherData
import app.revanced.patcher.extensions.or
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.or
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.PatchMetadata
import app.revanced.patcher.patch.PatchResult
@ -21,27 +21,27 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction11n
private val compatiblePackages = listOf("com.google.android.youtube")
class EnableSeekbarTappingPatch : Patch(
metadata = PatchMetadata(
PatchMetadata(
"seekbar-tapping",
"Enable seekbar tapping patch",
"Enable tapping on the seekbar of the YouTube player.",
compatiblePackages,
"1.0.0"
),
signatures = listOf(
listOf(
MethodSignature(
methodSignatureMetadata = MethodSignatureMetadata(
name = "enable-seekbar-tapping-parent-signature",
methodMetadata = MethodMetadata(null, null), // unknown
patternScanMethod = PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages = compatiblePackages,
description = "Signature for a parent method, which is needed to find the actual method required to be patched.",
version = "0.0.1"
MethodSignatureMetadata(
"enable-seekbar-tapping-parent-signature",
MethodMetadata(null, null), // unknown
PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages,
"Signature for a parent method, which is needed to find the actual method required to be patched.",
"0.0.1"
),
returnType = "L",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
methodParameters = listOf(),
opcodes = listOf(
"L",
AccessFlags.PUBLIC or AccessFlags.FINAL,
listOf(),
listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL,
@ -75,18 +75,18 @@ class EnableSeekbarTappingPatch : Patch(
)
),
MethodSignature(
methodSignatureMetadata = MethodSignatureMetadata(
name = "enable-seekbar-tapping-signature",
methodMetadata = MethodMetadata(null, null), // unknown
patternScanMethod = PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages = compatiblePackages,
description = "Signature for the method required to be patched.",
version = "0.0.1"
MethodSignatureMetadata(
"enable-seekbar-tapping-signature",
MethodMetadata(null, null), // unknown
PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages,
"Signature for the method required to be patched.",
"0.0.1"
),
returnType = "Z",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
methodParameters = listOf("L"),
opcodes = listOf(
"Z",
AccessFlags.PUBLIC or AccessFlags.FINAL,
listOf("L"),
listOf(
Opcode.CMPG_DOUBLE,
Opcode.IF_GTZ,
Opcode.GOTO,
@ -124,7 +124,7 @@ class EnableSeekbarTappingPatch : Patch(
)
) {
override fun execute(patcherData: PatcherData): PatchResult {
var result = signatures.first().result!!
val result = signatures.first().result!!
val tapSeekMethods = mutableMapOf<String, Method>()
@ -149,7 +149,7 @@ class EnableSeekbarTappingPatch : Patch(
}
// replace map because we dont need the upper one anymore
result = signatures.last().result!!
signatures.last().result!!
val implementation = result.method.implementation!!

View File

@ -17,27 +17,27 @@ import org.jf.dexlib2.Opcode
private val compatiblePackages = listOf("com.google.android.youtube")
class CreateButtonRemoverPatch : Patch(
metadata = PatchMetadata(
PatchMetadata(
"create-button",
"Create button patch",
"Disable the create button.",
compatiblePackages,
"1.0.0"
),
signatures = listOf(
listOf(
MethodSignature(
methodSignatureMetadata = MethodSignatureMetadata(
name = "create-button-method",
methodMetadata = MethodMetadata(null, null), // unknown
patternScanMethod = PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages = compatiblePackages,
description = "Signature for the method required to be patched.",
version = "0.0.1"
MethodSignatureMetadata(
"create-button-method",
MethodMetadata(null, null), // unknown
PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages,
"Signature for the method required to be patched.",
"0.0.1"
),
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
methodParameters = listOf("Z"),
opcodes = listOf(
"V",
AccessFlags.PUBLIC or AccessFlags.FINAL,
listOf("Z"),
listOf(
Opcode.IGET,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,

View File

@ -17,26 +17,26 @@ import org.jf.dexlib2.Opcode
private val compatiblePackages = listOf("com.google.android.youtube")
class HideReelsPatch : Patch(
metadata = PatchMetadata(
PatchMetadata(
"hide-reels",
"Hide reels patch",
"Hide reels on the page.",
compatiblePackages,
"1.0.0"
),
signatures = listOf(
listOf(
MethodSignature(
methodSignatureMetadata = MethodSignatureMetadata(
name = "hide-reels-signature",
methodMetadata = MethodMetadata(null, null), // unknown
patternScanMethod = PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages = compatiblePackages,
description = "Signature for the method required to be patched.",
version = "0.0.1"
MethodSignatureMetadata(
"hide-reels-signature",
MethodMetadata(null, null), // unknown
PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages,
"Signature for the method required to be patched.",
"0.0.1"
),
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
methodParameters = listOf(
"V",
AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
listOf(
"L",
"L",
"L",
@ -55,7 +55,7 @@ class HideReelsPatch : Patch(
"[B",
"[B"
),
opcodes = listOf(
listOf(
Opcode.MOVE_OBJECT,
Opcode.MOVE_OBJECT,
Opcode.INVOKE_DIRECT,

View File

@ -2,7 +2,10 @@ package app.revanced.patches.layout
import app.revanced.patcher.PatcherData
import app.revanced.patcher.extensions.or
import app.revanced.patcher.patch.*
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.PatchMetadata
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.signature.MethodMetadata
import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata
@ -13,27 +16,27 @@ import org.jf.dexlib2.Opcode
private val compatiblePackages = listOf("com.google.android.youtube")
class HideSuggestionsPatch : Patch(
metadata = PatchMetadata(
PatchMetadata(
"hide-suggestions",
"Hide suggestions patch",
"Hide suggested videos.",
compatiblePackages,
"1.0.0"
),
signatures = listOf(
listOf(
MethodSignature(
methodSignatureMetadata = MethodSignatureMetadata(
name = "hide-suggestions-parent-method",
methodMetadata = MethodMetadata(null, null), // unknown
patternScanMethod = PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages = compatiblePackages,
description = "Signature for a parent method, which is needed to find the actual method required to be patched.",
version = "0.0.1"
MethodSignatureMetadata(
"hide-suggestions-parent-method",
MethodMetadata(null, null), // unknown
PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages,
"Signature for a parent method, which is needed to find the actual method required to be patched.",
"0.0.1"
),
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
methodParameters = listOf("L", "Z"),
opcodes = listOf(
"V",
AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
listOf("L", "Z"),
listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
@ -67,16 +70,16 @@ class HideSuggestionsPatch : Patch(
/*
val result = signatures.first().result!!.findParentMethod(
MethodSignature(
methodSignatureMetadata = MethodSignatureMetadata(
name = "hide-suggestions-method",
methodMetadata = MethodMetadata(null, null), // unknown
patternScanMethod = PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages = compatiblePackages,
description = "Signature for the method, which is required to be patched.",
version = "0.0.1"
MethodSignatureMetadata(
"hide-suggestions-method",
MethodMetadata(null, null), // unknown
PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages,
"Signature for the method, which is required to be patched.",
"0.0.1"
),
returnType = "V",
accessFlags = AccessFlags.FINAL or AccessFlags.PUBLIC,
"V",
AccessFlags.FINAL or AccessFlags.PUBLIC,
listOf("Z"),
listOf(
Opcode.IPUT_BOOLEAN,

View File

@ -1,9 +1,12 @@
package app.revanced.patches.layout
import app.revanced.patcher.PatcherData
import app.revanced.patcher.extensions.or
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.patch.*
import app.revanced.patcher.extensions.or
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.PatchMetadata
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.signature.MethodMetadata
import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata
@ -15,27 +18,27 @@ import org.jf.dexlib2.Opcode
private val compatiblePackages = listOf("com.google.android.youtube")
class MinimizedPlaybackPatch : Patch(
metadata = PatchMetadata(
PatchMetadata(
"minimized-playback",
"Minimized Playback Patch",
"Enable minimized and background playback.",
compatiblePackages,
"1.0.0"
),
signatures = listOf(
listOf(
MethodSignature(
methodSignatureMetadata = MethodSignatureMetadata(
name = "minimized-playback-manager",
methodMetadata = MethodMetadata(null, null), // unknown
patternScanMethod = PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages = compatiblePackages,
description = "Signature for the method required to be patched.",
version = "0.0.1"
MethodSignatureMetadata(
"minimized-playback-manager",
MethodMetadata(null, null), // unknown
PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages,
"Signature for the method required to be patched.",
"0.0.1"
),
returnType = "Z",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
methodParameters = listOf("L"),
opcodes = listOf(
"Z",
AccessFlags.PUBLIC or AccessFlags.STATIC,
listOf("L"),
listOf(
Opcode.CONST_4,
Opcode.IF_EQZ,
Opcode.IGET,

View File

@ -1,8 +1,8 @@
package app.revanced.patches.layout
import app.revanced.patcher.PatcherData
import app.revanced.patcher.extensions.or
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.or
import app.revanced.patcher.patch.*
import app.revanced.patcher.signature.MethodMetadata
import app.revanced.patcher.signature.MethodSignature
@ -16,27 +16,27 @@ import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
private val compatiblePackages = listOf("com.google.android.youtube")
class OldQualityLayoutPatch : Patch(
metadata = PatchMetadata(
PatchMetadata(
"old-quality-layout",
"Old Quality Layout Patch",
"Enable the original quality flyout menu",
compatiblePackages,
"1.0.0"
),
signatures = listOf(
listOf(
MethodSignature(
methodSignatureMetadata = MethodSignatureMetadata(
name = "old-quality-parent-method-signature",
methodMetadata = MethodMetadata(null, null), // unknown
patternScanMethod = PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages = compatiblePackages,
description = "Signature to find a parent method required by the Old Quality Layout patch.",
version = "0.0.1"
MethodSignatureMetadata(
"old-quality-parent-method-signature",
MethodMetadata(null, null), // unknown
PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages,
"Signature to find a parent method required by the Old Quality Layout patch.",
"0.0.1"
),
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
methodParameters = listOf("L", "L", "L", "L", "L", "L", "L"),
opcodes = listOf(
"V",
AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
listOf("L", "L", "L", "L", "L", "L", "L"),
listOf(
Opcode.IPUT_OBJECT,
Opcode.CONST,
Opcode.CONST,
@ -72,20 +72,20 @@ class OldQualityLayoutPatch : Patch(
)
) {
override fun execute(patcherData: PatcherData): PatchResult {
var result = signatures.first().result!!
val result = signatures.first().result!!
result = result.findParentMethod(
result.findParentMethod(
MethodSignature(
methodSignatureMetadata = MethodSignatureMetadata(
name = "old-quality-method-signature",
methodMetadata = MethodMetadata(null, null), // unknown
patternScanMethod = PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages = compatiblePackages,
description = "Signature to find the method required by the Old Quality Layout patch",
version = "0.0.1"
MethodSignatureMetadata(
"old-quality-method-signature",
MethodMetadata(null, null), // unknown
PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages,
"Signature to find the method required by the Old Quality Layout patch",
"0.0.1"
),
returnType = "L",
accessFlags = AccessFlags.FINAL or AccessFlags.PUBLIC,
"L",
AccessFlags.FINAL or AccessFlags.PUBLIC,
emptyList(),
listOf(
Opcode.IGET,

View File

@ -1,9 +1,12 @@
package app.revanced.patches.misc
import app.revanced.patcher.PatcherData
import app.revanced.patcher.extensions.or
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.patch.*
import app.revanced.patcher.extensions.or
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.PatchMetadata
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.proxy.mutableTypes.MutableMethod.Companion.toMutable
import app.revanced.patcher.signature.MethodMetadata
import app.revanced.patcher.signature.MethodSignature
@ -18,27 +21,27 @@ import org.jf.dexlib2.immutable.ImmutableMethodImplementation
private val compatiblePackages = listOf("com.google.android.youtube")
class IntegrationsPatch : Patch(
metadata = PatchMetadata(
PatchMetadata(
"integrations",
"Inject integrations Patch",
"Applies mandatory patches to implement the ReVanced integrations into the application.",
compatiblePackages,
"1.0.0"
),
signatures = listOf(
listOf(
MethodSignature(
methodSignatureMetadata = MethodSignatureMetadata(
name = "integrations-patch",
methodMetadata = MethodMetadata(null, null), // unknown
patternScanMethod = PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages = compatiblePackages,
description = "Inject the integrations into the application with the method of this signature",
version = "0.0.1"
MethodSignatureMetadata(
"integrations-patch",
MethodMetadata(null, null), // unknown
PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages,
"Inject the integrations into the application with the method of this signature",
"0.0.1"
),
returnType = "V",
accessFlags = AccessFlags.PUBLIC.value,
methodParameters = listOf(),
opcodes = listOf(
"V",
AccessFlags.PUBLIC.value,
listOf(),
listOf(
Opcode.SGET_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,