refactor: start migrating some signatures to Kotlin

This commit is contained in:
Lucaskyy 2022-04-13 21:47:09 +02:00
parent bc56555d9e
commit 36a2780ab1
No known key found for this signature in database
GPG Key ID: 1530BFF96D1EEB89
13 changed files with 160 additions and 36 deletions

View File

@ -1,28 +0,0 @@
package app.revanced.patches
import app.revanced.patcher.patch.Patch
import app.revanced.patches.ad.VideoAds
import app.revanced.patches.interaction.EnableSeekbarTapping
import app.revanced.patches.layout.*
import app.revanced.patches.misc.Integrations
/**
* Index contains all the patches and should be imported when using this library.
*/
@Suppress("Unused")
object Index {
/**
* Array of patches.
* New patches should be added to the array.
*/
val patches: Array<() -> Patch> = arrayOf(
::Integrations,
::VideoAds,
::MinimizedPlayback,
::CreateButtonRemover,
::HideReels,
::HideSuggestions,
::OldQualityLayout,
::EnableSeekbarTapping
)
}

View File

@ -9,7 +9,7 @@ import app.revanced.patcher.smali.asInstructions
import app.revanced.patches.SHARED_METADATA
import org.jf.dexlib2.AccessFlags
class VideoAds : Patch(
class VideoAdsPatch : Patch(
PatchMetadata(
"video-ads",
"TODO",

View File

@ -12,7 +12,7 @@ import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
import org.jf.dexlib2.iface.Method
import org.jf.dexlib2.iface.instruction.formats.Instruction11n
class EnableSeekbarTapping : Patch(
class EnableSeekbarTappingPatch : Patch(
PatchMetadata(
"enable-seekbar-tapping",
"TODO",

View File

@ -7,7 +7,7 @@ import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.smali.asInstruction
class CreateButtonRemover : Patch(
class CreateButtonRemoverPatch : Patch(
PatchMetadata(
"create-button-remover",
"TODO",

View File

@ -7,7 +7,7 @@ import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.smali.asInstruction
class HideReels : Patch(
class HideReelsPatch : Patch(
PatchMetadata(
"hide-reels",
"TODO",

View File

@ -17,7 +17,7 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction35c
import org.jf.dexlib2.immutable.ImmutableMethod
import org.jf.dexlib2.immutable.ImmutableMethodImplementation
class HideSuggestions : Patch(
class HideSuggestionsPatch : Patch(
PatchMetadata(
"hide-suggestions",
"TODO",

View File

@ -8,7 +8,7 @@ import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.smali.asInstructions
class MinimizedPlayback : Patch(
class MinimizedPlaybackPatch : Patch(
PatchMetadata(
"minimized-playback",
"TODO",

View File

@ -11,7 +11,7 @@ import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
class OldQualityLayout : Patch(
class OldQualityLayoutPatch : Patch(
PatchMetadata(
"old-quality-layout",
"TODO",

View File

@ -13,7 +13,7 @@ import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.immutable.ImmutableMethod
import org.jf.dexlib2.immutable.ImmutableMethodImplementation
class Integrations : Patch(
class IntegrationsPatch : Patch(
PatchMetadata(
"integrations",
"TODO",

View File

@ -0,0 +1,40 @@
package app.revanced.shared
import app.revanced.patcher.patch.Patch
import app.revanced.patches.ad.VideoAdsPatch
import app.revanced.patches.interaction.EnableSeekbarTappingPatch
import app.revanced.patches.layout.*
import app.revanced.patches.misc.IntegrationsPatch
import app.revanced.signatures.SignatureSupplier
import app.revanced.signatures.ad.VideoAdsSignature
import app.revanced.signatures.misc.IntegrationsSignature
/**
* Index contains all the patches and signatures.
*/
@Suppress("Unused")
object Index {
/**
* Array of patches.
* New patches should be added to the array.
*/
val patches: Array<() -> Patch> = arrayOf(
::IntegrationsPatch,
::VideoAdsPatch,
::MinimizedPlaybackPatch,
::CreateButtonRemoverPatch,
::HideReelsPatch,
::HideSuggestionsPatch,
::OldQualityLayoutPatch,
::EnableSeekbarTappingPatch
)
/**
* Array of signatures.
* New signatures should be added to the array.
*/
val signatures: Array<() -> SignatureSupplier> = arrayOf(
::IntegrationsSignature,
::VideoAdsSignature,
)
}

View File

@ -0,0 +1,7 @@
package app.revanced.signatures
import app.revanced.patcher.signature.MethodSignature
interface SignatureSupplier {
fun get(): MethodSignature
}

View File

@ -0,0 +1,45 @@
package app.revanced.signatures.ad
import app.revanced.patcher.extensions.AccessFlagExtensions.Companion.or
import app.revanced.patcher.signature.*
import app.revanced.signatures.SignatureSupplier
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
class VideoAdsSignature : SignatureSupplier {
override fun get() = MethodSignature(
"show-video-ads-constructor",
SignatureMetadata(
method = MethodMetadata(
definingClass = "zai",
methodName = "<init>",
comment = "YouTube v17.03.38"
),
patcher = PatcherMetadata(
// FIXME: Test this threshold and find the best value.
resolverMethod = ResolverMethod.Fuzzy(2)
)
),
"V",
AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
listOf("L", "L", "L"),
listOf(
Opcode.INVOKE_DIRECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.CONST_4,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.CONST_4,
Opcode.IPUT_BOOLEAN,
Opcode.RETURN_VOID
)
)
}

View File

@ -0,0 +1,60 @@
package app.revanced.signatures.misc
import app.revanced.patcher.signature.*
import app.revanced.signatures.SignatureSupplier
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
class IntegrationsSignature : SignatureSupplier {
override fun get() = MethodSignature(
"integrations-patch",
SignatureMetadata(
method = MethodMetadata(
definingClass = "???", // TODO: Fill this in.
methodName = "???", // TODO: Fill this in.
comment = "YouTube v17.03.38"
),
patcher = PatcherMetadata(
// FIXME: Test this threshold and find the best value.
resolverMethod = ResolverMethod.Fuzzy(2)
)
),
"V",
AccessFlags.PUBLIC.value,
listOf(),
listOf(
Opcode.SGET_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.IGET_OBJECT,
Opcode.CONST_STRING,
Opcode.IF_NEZ,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.MOVE_OBJECT,
Opcode.CHECK_CAST,
Opcode.MOVE_OBJECT,
Opcode.CHECK_CAST,
Opcode.CONST_4,
Opcode.CONST_STRING,
Opcode.INVOKE_INTERFACE_RANGE,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.SPUT_OBJECT,
Opcode.SGET_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IGET_OBJECT,
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
Opcode.INVOKE_VIRTUAL,
Opcode.INVOKE_SUPER,
Opcode.INVOKE_VIRTUAL
)
)
}