mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-24 02:42:11 +02:00
chore: lint code
This commit is contained in:
parent
80727591ae
commit
5e8d280294
@ -198,7 +198,11 @@ object CustomBrandingIconPatch : BaseResourcePatch(
|
|||||||
if (oldSplashIconNotExists) {
|
if (oldSplashIconNotExists) {
|
||||||
splashIconResourceGroups.let { resourceGroups ->
|
splashIconResourceGroups.let { resourceGroups ->
|
||||||
resourceGroups.forEach {
|
resourceGroups.forEach {
|
||||||
context.copyResources("$youtubeMusicIconResourcePath/splash", it, createDirectoryIfNotExist = true)
|
context.copyResources(
|
||||||
|
"$youtubeMusicIconResourcePath/splash",
|
||||||
|
it,
|
||||||
|
createDirectoryIfNotExist = true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,11 @@ abstract class BaseAdsPatch(
|
|||||||
VideoAdsFingerprint
|
VideoAdsFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
private companion object {
|
||||||
|
const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||||
|
"$PATCHES_PATH/FullscreenAdsPatch;"
|
||||||
|
}
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
MusicAdsFingerprint.resultOrThrow().let {
|
MusicAdsFingerprint.resultOrThrow().let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
@ -119,9 +124,4 @@ abstract class BaseAdsPatch(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
|
||||||
const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
|
||||||
"$PATCHES_PATH/FullscreenAdsPatch;"
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -180,7 +180,8 @@ object ToolBarComponentsPatch : BaseBytecodePatch(
|
|||||||
"invoke-static {v$viewRegister}, $GENERAL_CLASS_DESCRIPTOR->setWideSearchBarLayout(Landroid/view/View;)V"
|
"invoke-static {v$viewRegister}, $GENERAL_CLASS_DESCRIPTOR->setWideSearchBarLayout(Landroid/view/View;)V"
|
||||||
)
|
)
|
||||||
|
|
||||||
val targetIndex = ActionBarRingoBackgroundFingerprint.indexOfStaticInstruction(this) + 1
|
val targetIndex =
|
||||||
|
ActionBarRingoBackgroundFingerprint.indexOfStaticInstruction(this) + 1
|
||||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||||
|
|
||||||
injectSearchBarHook(
|
injectSearchBarHook(
|
||||||
|
@ -2,8 +2,8 @@ package app.revanced.patches.youtube.general.toolbar.fingerprints
|
|||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
import app.revanced.patches.youtube.general.toolbar.fingerprints.ActionBarRingoTextFingerprint.indexOfStaticInstruction
|
|
||||||
import app.revanced.patches.youtube.general.toolbar.fingerprints.ActionBarRingoTextFingerprint.indexOfStartDelayInstruction
|
import app.revanced.patches.youtube.general.toolbar.fingerprints.ActionBarRingoTextFingerprint.indexOfStartDelayInstruction
|
||||||
|
import app.revanced.patches.youtube.general.toolbar.fingerprints.ActionBarRingoTextFingerprint.indexOfStaticInstruction
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.indexOfFirstInstruction
|
import app.revanced.util.indexOfFirstInstruction
|
||||||
import app.revanced.util.indexOfFirstInstructionReversed
|
import app.revanced.util.indexOfFirstInstructionReversed
|
||||||
|
@ -54,7 +54,8 @@ object BackgroundPlaybackPatch : BaseBytecodePatch(
|
|||||||
"invoke-static { v$register }, $MISC_PATH/BackgroundPlaybackPatch;->allowBackgroundPlayback(Z)Z"
|
"invoke-static { v$register }, $MISC_PATH/BackgroundPlaybackPatch;->allowBackgroundPlayback(Z)Z"
|
||||||
)
|
)
|
||||||
|
|
||||||
addInstructions(index + 1,
|
addInstructions(
|
||||||
|
index + 1,
|
||||||
"""
|
"""
|
||||||
move-result v$register
|
move-result v$register
|
||||||
return v$register
|
return v$register
|
||||||
|
@ -10,7 +10,8 @@ internal object PlayerResponseModelUtils {
|
|||||||
const val PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR =
|
const val PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR =
|
||||||
"Lcom/google/android/libraries/youtube/innertube/model/player/PlayerResponseModel;"
|
"Lcom/google/android/libraries/youtube/innertube/model/player/PlayerResponseModel;"
|
||||||
|
|
||||||
fun indexOfPlayerResponseModelInstruction(methodDef: Method) = methodDef.indexOfFirstInstruction {
|
fun indexOfPlayerResponseModelInstruction(methodDef: Method) =
|
||||||
|
methodDef.indexOfFirstInstruction {
|
||||||
opcode == Opcode.INVOKE_INTERFACE &&
|
opcode == Opcode.INVOKE_INTERFACE &&
|
||||||
getReference<MethodReference>()?.definingClass == PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR
|
getReference<MethodReference>()?.definingClass == PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
|||||||
import app.revanced.util.addFieldAndInstructions
|
import app.revanced.util.addFieldAndInstructions
|
||||||
import app.revanced.util.getStringInstructionIndex
|
import app.revanced.util.getStringInstructionIndex
|
||||||
import app.revanced.util.getTargetIndexOrThrow
|
import app.revanced.util.getTargetIndexOrThrow
|
||||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
|
||||||
import app.revanced.util.resultOrThrow
|
import app.revanced.util.resultOrThrow
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
|
@ -274,10 +274,13 @@ object VideoInformationPatch : BytecodePatch(
|
|||||||
/**
|
/**
|
||||||
* Set current video information
|
* Set current video information
|
||||||
*/
|
*/
|
||||||
channelIdMethodCall = ChannelIdFingerprint.getPlayerResponseInstruction("Ljava/lang/String;")
|
channelIdMethodCall =
|
||||||
channelNameMethodCall = ChannelNameFingerprint.getPlayerResponseInstruction("Ljava/lang/String;")
|
ChannelIdFingerprint.getPlayerResponseInstruction("Ljava/lang/String;")
|
||||||
|
channelNameMethodCall =
|
||||||
|
ChannelNameFingerprint.getPlayerResponseInstruction("Ljava/lang/String;")
|
||||||
videoIdMethodCall = VideoIdFingerprint.getPlayerResponseInstruction("Ljava/lang/String;")
|
videoIdMethodCall = VideoIdFingerprint.getPlayerResponseInstruction("Ljava/lang/String;")
|
||||||
videoTitleMethodCall = VideoTitleFingerprint.getPlayerResponseInstruction("Ljava/lang/String;")
|
videoTitleMethodCall =
|
||||||
|
VideoTitleFingerprint.getPlayerResponseInstruction("Ljava/lang/String;")
|
||||||
videoLengthMethodCall = VideoLengthFingerprint.getPlayerResponseInstruction("J")
|
videoLengthMethodCall = VideoLengthFingerprint.getPlayerResponseInstruction("J")
|
||||||
videoIsLiveMethodCall = ChannelIdFingerprint.getPlayerResponseInstruction("Z")
|
videoIsLiveMethodCall = ChannelIdFingerprint.getPlayerResponseInstruction("Z")
|
||||||
|
|
||||||
|
@ -20,7 +20,8 @@ internal object PlaybackInitializationFingerprint : MethodFingerprint(
|
|||||||
indexOfPlayerResponseModelInstruction(methodDef) >= 0
|
indexOfPlayerResponseModelInstruction(methodDef) >= 0
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
fun indexOfPlayerResponseModelInstruction(methodDef: Method) = methodDef.indexOfFirstInstruction {
|
fun indexOfPlayerResponseModelInstruction(methodDef: Method) =
|
||||||
|
methodDef.indexOfFirstInstruction {
|
||||||
opcode == Opcode.INVOKE_DIRECT &&
|
opcode == Opcode.INVOKE_DIRECT &&
|
||||||
getReference<MethodReference>()?.returnType == PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR
|
getReference<MethodReference>()?.returnType == PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,10 @@ fun Method.indexOfFirstInstructionReversed(startIndex: Int? = null, targetOpcode
|
|||||||
* @return -1 if the instruction is not found.
|
* @return -1 if the instruction is not found.
|
||||||
* @see indexOfFirstInstructionReversedOrThrow
|
* @see indexOfFirstInstructionReversedOrThrow
|
||||||
*/
|
*/
|
||||||
fun Method.indexOfFirstInstructionReversed(startIndex: Int? = null, predicate: Instruction.() -> Boolean): Int {
|
fun Method.indexOfFirstInstructionReversed(
|
||||||
|
startIndex: Int? = null,
|
||||||
|
predicate: Instruction.() -> Boolean
|
||||||
|
): Int {
|
||||||
var instructions = this.implementation!!.instructions
|
var instructions = this.implementation!!.instructions
|
||||||
if (startIndex != null) {
|
if (startIndex != null) {
|
||||||
instructions = instructions.take(startIndex + 1)
|
instructions = instructions.take(startIndex + 1)
|
||||||
@ -308,7 +311,10 @@ fun Method.indexOfFirstInstructionReversed(startIndex: Int? = null, predicate: I
|
|||||||
* @return -1 if the instruction is not found.
|
* @return -1 if the instruction is not found.
|
||||||
* @see indexOfFirstInstructionReversed
|
* @see indexOfFirstInstructionReversed
|
||||||
*/
|
*/
|
||||||
fun Method.indexOfFirstInstructionReversedOrThrow(startIndex: Int? = null, targetOpcode: Opcode): Int =
|
fun Method.indexOfFirstInstructionReversedOrThrow(
|
||||||
|
startIndex: Int? = null,
|
||||||
|
targetOpcode: Opcode
|
||||||
|
): Int =
|
||||||
indexOfFirstInstructionReversedOrThrow(startIndex) {
|
indexOfFirstInstructionReversedOrThrow(startIndex) {
|
||||||
opcode == targetOpcode
|
opcode == targetOpcode
|
||||||
}
|
}
|
||||||
@ -321,7 +327,10 @@ fun Method.indexOfFirstInstructionReversedOrThrow(startIndex: Int? = null, targe
|
|||||||
* @return -1 if the instruction is not found.
|
* @return -1 if the instruction is not found.
|
||||||
* @see indexOfFirstInstructionReversed
|
* @see indexOfFirstInstructionReversed
|
||||||
*/
|
*/
|
||||||
fun Method.indexOfFirstInstructionReversedOrThrow(startIndex: Int? = null, predicate: Instruction.() -> Boolean): Int {
|
fun Method.indexOfFirstInstructionReversedOrThrow(
|
||||||
|
startIndex: Int? = null,
|
||||||
|
predicate: Instruction.() -> Boolean
|
||||||
|
): Int {
|
||||||
val index = indexOfFirstInstructionReversed(startIndex, predicate)
|
val index = indexOfFirstInstructionReversed(startIndex, predicate)
|
||||||
|
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
@ -424,7 +433,8 @@ inline fun <reified T : Reference> Instruction.getReference() =
|
|||||||
* @param predicate The predicate to match.
|
* @param predicate The predicate to match.
|
||||||
* @return The index of the first [Instruction] that matches the predicate.
|
* @return The index of the first [Instruction] that matches the predicate.
|
||||||
*/
|
*/
|
||||||
fun Method.indexOfFirstInstruction(predicate: Instruction.() -> Boolean) = indexOfFirstInstruction(0, predicate)
|
fun Method.indexOfFirstInstruction(predicate: Instruction.() -> Boolean) =
|
||||||
|
indexOfFirstInstruction(0, predicate)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the index of the first [Instruction] that matches the predicate, starting from [startIndex].
|
* Get the index of the first [Instruction] that matches the predicate, starting from [startIndex].
|
||||||
|
Loading…
x
Reference in New Issue
Block a user