slightly better patch method

This commit is contained in:
inotia00
2023-01-08 01:10:42 +09:00
parent a1a74e7c51
commit 500055e046
12 changed files with 82 additions and 31 deletions

View File

@ -7,11 +7,11 @@ import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.extensions.findMutableMethodOf
import app.revanced.shared.extensions.toResult
import app.revanced.shared.patches.mapping.ResourceMappingPatch
import app.revanced.shared.util.integrations.Constants.FULLSCREEN_LAYOUT
import org.jf.dexlib2.Opcode
@ -28,6 +28,7 @@ class HideEndscreenOverlayBytecodePatch : BytecodePatch() {
).map { name ->
ResourceMappingPatch.resourceMappings.single { it.name == name }.id
}
private var patchSuccessArray = Array(resourceIds.size) {false}
override fun execute(context: BytecodeContext): PatchResult {
context.classes.forEach { classDef ->
@ -53,6 +54,8 @@ class HideEndscreenOverlayBytecodePatch : BytecodePatch() {
return-void
""", listOf(ExternalLabel("on", mutableMethod.instruction(insertIndex)))
)
patchSuccessArray[0] = true;
}
}
}
@ -62,6 +65,6 @@ class HideEndscreenOverlayBytecodePatch : BytecodePatch() {
}
}
}
return PatchResultSuccess()
return toResult(patchSuccessArray.indexOf(false))
}
}

View File

@ -3,17 +3,17 @@ package app.revanced.patches.youtube.layout.fullscreen.fullscreenbuttoncontainer
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.extensions.findMutableMethodOf
import app.revanced.shared.extensions.injectHideCall
import app.revanced.shared.extensions.toResult
import app.revanced.shared.patches.mapping.ResourceMappingPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
import org.jf.dexlib2.Opcode
@Name("hide-fullscreen-buttoncontainer-bytecode-patch")
@DependsOn([ResourceMappingPatch::class])
@ -25,6 +25,7 @@ class FullscreenButtonContainerBytecodePatch : BytecodePatch() {
).map { name ->
ResourceMappingPatch.resourceMappings.single { it.name == name }.id
}
private var patchSuccessArray = Array(resourceIds.size) {false}
override fun execute(context: BytecodeContext): PatchResult {
context.classes.forEach { classDef ->
@ -43,6 +44,8 @@ class FullscreenButtonContainerBytecodePatch : BytecodePatch() {
val viewRegister = (invokeInstruction as Instruction21c).registerA
mutableMethod.implementation!!.injectHideCall(insertIndex, viewRegister, "layout/FullscreenLayoutPatch", "hideFullscreenButtonContainer")
patchSuccessArray[0] = true;
}
}
}
@ -52,6 +55,6 @@ class FullscreenButtonContainerBytecodePatch : BytecodePatch() {
}
}
}
return PatchResultSuccess()
return toResult(patchSuccessArray.indexOf(false))
}
}