mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
slightly better patch method
This commit is contained in:
@ -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))
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user