refactor: reformat code and optimize imports

This commit is contained in:
inotia00
2023-06-20 18:27:17 +09:00
parent 0f820822cf
commit bf643c23c5
252 changed files with 1292 additions and 725 deletions

View File

@ -13,8 +13,8 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint
import app.revanced.patches.youtube.utils.fingerprints.LayoutConstructorFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.AutoNavPreviewStub
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
@ -45,12 +45,15 @@ class HideAutoplayPreviewPatch : BytecodePatch(
it.mutableMethod.apply {
val insertInstruction = implementation!!.instructions
val dummyRegister = getInstruction<OneRegisterInstruction>(getStringIndex("1.0x")).registerA
val dummyRegister =
getInstruction<OneRegisterInstruction>(getStringIndex("1.0x")).registerA
val insertIndex = getWideLiteralIndex(AutoNavPreviewStub)
val branchIndex = insertInstruction.subList(insertIndex + 1, insertInstruction.size - 1).indexOfFirst { instruction ->
((instruction as? ReferenceInstruction)?.reference as? FieldReference)?.type == "Lcom/google/android/apps/youtube/app/player/autonav/AutonavToggleController;"
} + 1
val branchIndex =
insertInstruction.subList(insertIndex + 1, insertInstruction.size - 1)
.indexOfFirst { instruction ->
((instruction as? ReferenceInstruction)?.reference as? FieldReference)?.type == "Lcom/google/android/apps/youtube/app/player/autonav/AutonavToggleController;"
} + 1
val jumpInstruction = getInstruction<Instruction>(insertIndex + branchIndex)

View File

@ -12,5 +12,9 @@ object YouTubeControlsOverlayFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT,
Opcode.IF_EQZ
),
customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists(YoutubeControlsOverlay) }
customFingerprint = { it, _ ->
it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists(
YoutubeControlsOverlay
)
}
)

View File

@ -14,7 +14,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.fullscreen.compactcontrolsoverlay.fingerprints.YouTubeControlsOverlayFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
@ -38,10 +38,11 @@ class CompactControlsOverlayPatch : BytecodePatch(
override fun execute(context: BytecodeContext): PatchResult {
YouTubeControlsOverlayFingerprint.result?.let {
with (context
.toMethodWalker(it.method)
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true)
.getMethod() as MutableMethod
with(
context
.toMethodWalker(it.method)
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true)
.getMethod() as MutableMethod
) {
val insertIndex = implementation!!.instructions.size - 1
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA

View File

@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.fullscreen.endscreenoverlay.fingerprints.EndScreenResultsFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch

View File

@ -6,5 +6,9 @@ import app.revanced.util.bytecode.isWideLiteralExists
object FullscreenEngagementPanelFingerprint : MethodFingerprint(
returnType = "L",
customFingerprint = { it, _ -> it.definingClass.endsWith("FullscreenEngagementPanelOverlay;") && it.isWideLiteralExists(FullScreenEngagementPanel) }
customFingerprint = { it, _ ->
it.definingClass.endsWith("FullscreenEngagementPanelOverlay;") && it.isWideLiteralExists(
FullScreenEngagementPanel
)
}
)

View File

@ -16,8 +16,8 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint
import app.revanced.patches.youtube.utils.fingerprints.LayoutConstructorFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.fullscreen.fullscreenpanels.fingerprints.FullscreenEngagementPanelFingerprint
import app.revanced.patches.youtube.fullscreen.fullscreenpanels.fingerprints.FullscreenViewAdderFingerprint
import app.revanced.patches.youtube.utils.quickactionscontainer.patch.HideQuickActionsContainerPatch
@ -83,7 +83,8 @@ class HideFullscreenPanelsPatch : BytecodePatch(
LayoutConstructorFingerprint.result?.let {
it.mutableMethod.apply {
val dummyRegister = getInstruction<OneRegisterInstruction>(getStringIndex("1.0x")).registerA
val dummyRegister =
getInstruction<OneRegisterInstruction>(getStringIndex("1.0x")).registerA
val invokeIndex = implementation!!.instructions.indexOfFirst { instruction ->
instruction.opcode == Opcode.INVOKE_VIRTUAL &&

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object OrientationPrimaryFingerprint : MethodFingerprint (
object OrientationPrimaryFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = listOf("L"),
@ -13,5 +13,5 @@ object OrientationPrimaryFingerprint : MethodFingerprint (
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT
),
customFingerprint = { it, _ -> it.name == "<init>"}
customFingerprint = { it, _ -> it.name == "<init>" }
)

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object OrientationSecondaryFingerprint : MethodFingerprint (
object OrientationSecondaryFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),

View File

@ -14,8 +14,10 @@ import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.*
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.OrientationParentFingerprint
import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.OrientationPrimaryFingerprint
import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.OrientationSecondaryFingerprint
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.FULLSCREEN
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@ -35,7 +37,8 @@ class LandScapeModePatch : BytecodePatch(
OrientationPrimaryFingerprint,
OrientationSecondaryFingerprint
).forEach {
it.also { it.resolve(context, classDef) }.result?.injectOverride() ?: return it.toErrorResult()
it.also { it.resolve(context, classDef) }.result?.injectOverride()
?: return it.toErrorResult()
}
} ?: return OrientationParentFingerprint.toErrorResult()
@ -64,7 +67,7 @@ class LandScapeModePatch : BytecodePatch(
val register = getInstruction<OneRegisterInstruction>(index).registerA
addInstructions(
index +1, """
index + 1, """
invoke-static {v$register}, $INTEGRATIONS_CLASS_DESCRIPTOR
move-result v$register
"""

View File

@ -9,8 +9,8 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.ads.general.resource.patch.GeneralAdsPatch
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.quickactionscontainer.patch.HideQuickActionsContainerPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch