mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 13:17:46 +02:00
chore: Lint code
This commit is contained in:
@ -30,7 +30,9 @@ internal class JsonPatchesFileGenerator : PatchesFileGenerator {
|
||||
},
|
||||
)
|
||||
}.let {
|
||||
patchesJson.writeText(GsonBuilder().serializeNulls().setPrettyPrinting().create().toJson(it))
|
||||
patchesJson.writeText(
|
||||
GsonBuilder().serializeNulls().setPrettyPrinting().create().toJson(it)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,8 @@ val albumMusicVideoPatch = bytecodePatch(
|
||||
|
||||
audioVideoSwitchToggleConstructorFingerprint.methodOrThrow().apply {
|
||||
val onClickListenerIndex = indexOfAudioVideoSwitchSetOnClickListenerInstruction(this)
|
||||
val viewRegister = getInstruction<FiveRegisterInstruction>(onClickListenerIndex).registerC
|
||||
val viewRegister =
|
||||
getInstruction<FiveRegisterInstruction>(onClickListenerIndex).registerC
|
||||
|
||||
addInstruction(
|
||||
onClickListenerIndex + 1,
|
||||
@ -83,11 +84,13 @@ val albumMusicVideoPatch = bytecodePatch(
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->setAudioVideoSwitchToggleOnLongClickListener(Landroid/view/View;)V"
|
||||
)
|
||||
|
||||
val onClickListenerSyntheticIndex = indexOfFirstInstructionReversedOrThrow(onClickListenerIndex) {
|
||||
opcode == Opcode.INVOKE_DIRECT &&
|
||||
getReference<MethodReference>()?.name == "<init>"
|
||||
}
|
||||
val onClickListenerSyntheticClass = (getInstruction<ReferenceInstruction>(onClickListenerSyntheticIndex).reference as MethodReference).definingClass
|
||||
val onClickListenerSyntheticIndex =
|
||||
indexOfFirstInstructionReversedOrThrow(onClickListenerIndex) {
|
||||
opcode == Opcode.INVOKE_DIRECT &&
|
||||
getReference<MethodReference>()?.name == "<init>"
|
||||
}
|
||||
val onClickListenerSyntheticClass =
|
||||
(getInstruction<ReferenceInstruction>(onClickListenerSyntheticIndex).reference as MethodReference).definingClass
|
||||
|
||||
findMethodOrThrow(onClickListenerSyntheticClass) {
|
||||
name == "onClick"
|
||||
|
@ -5,11 +5,8 @@ import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import app.revanced.util.or
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
import com.android.tools.smali.dexlib2.iface.reference.StringReference
|
||||
import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||
|
||||
const val GET_GMS_CORE_VENDOR_GROUP_ID_METHOD_NAME = "getGmsCoreVendorGroupId"
|
||||
|
||||
|
@ -1,19 +1,8 @@
|
||||
package app.revanced.patches.shared.materialyou
|
||||
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.ResourcePatchContext
|
||||
import app.revanced.util.copyXmlNode
|
||||
import app.revanced.util.inputStreamFromBundledResource
|
||||
import org.w3c.dom.Element
|
||||
import org.w3c.dom.Node
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.StandardCopyOption
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import javax.xml.transform.OutputKeys
|
||||
import javax.xml.transform.TransformerFactory
|
||||
import javax.xml.transform.dom.DOMSource
|
||||
import javax.xml.transform.stream.StreamResult
|
||||
|
||||
private fun ResourcePatchContext.patchXmlFile(
|
||||
fromDir: String,
|
||||
|
@ -116,15 +116,20 @@ fun baseSpoofStreamingDataPatch(
|
||||
// region Replace the streaming data.
|
||||
|
||||
val approxDurationMsReference = formatStreamModelConstructorFingerprint.matchOrThrow().let {
|
||||
with (it.method) {
|
||||
with(it.method) {
|
||||
getInstruction<ReferenceInstruction>(it.patternMatch!!.startIndex).reference
|
||||
}
|
||||
}
|
||||
|
||||
val streamingDataFormatsReference = with(videoStreamingDataConstructorFingerprint.methodOrThrow(videoStreamingDataToStringFingerprint)) {
|
||||
val streamingDataFormatsReference = with(
|
||||
videoStreamingDataConstructorFingerprint.methodOrThrow(
|
||||
videoStreamingDataToStringFingerprint
|
||||
)
|
||||
) {
|
||||
val getFormatsFieldIndex = indexOfGetFormatsFieldInstruction(this)
|
||||
val longMaxValueIndex = indexOfLongMaxValueInstruction(this, getFormatsFieldIndex)
|
||||
val longMaxValueRegister = getInstruction<OneRegisterInstruction>(longMaxValueIndex).registerA
|
||||
val longMaxValueRegister =
|
||||
getInstruction<OneRegisterInstruction>(longMaxValueIndex).registerA
|
||||
val videoIdIndex =
|
||||
indexOfFirstInstructionOrThrow(longMaxValueIndex) {
|
||||
val reference = getReference<FieldReference>()
|
||||
|
@ -209,6 +209,10 @@ internal val poTokenToStringFingerprint = legacyFingerprint(
|
||||
classDef.fields.find { it.type == "[B" } != null &&
|
||||
// In YouTube, this field's type is 'Lcom/google/android/gms/potokens/PoToken;'.
|
||||
// In YouTube Music, this class name is obfuscated.
|
||||
classDef.fields.find { it.accessFlags == AccessFlags.PRIVATE.value && it.type.startsWith("L") } != null
|
||||
classDef.fields.find {
|
||||
it.accessFlags == AccessFlags.PRIVATE.value && it.type.startsWith(
|
||||
"L"
|
||||
)
|
||||
} != null
|
||||
},
|
||||
)
|
||||
|
@ -342,10 +342,11 @@ val toolBarComponentsPatch = bytecodePatch(
|
||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||
getReference<MethodReference>()?.toString() == voiceInputControllerActivityMethodCall
|
||||
}
|
||||
val setOnClickListenerIndex = indexOfFirstInstructionOrThrow(voiceInputControllerActivityIndex) {
|
||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||
getReference<MethodReference>()?.name == "setOnClickListener"
|
||||
}
|
||||
val setOnClickListenerIndex =
|
||||
indexOfFirstInstructionOrThrow(voiceInputControllerActivityIndex) {
|
||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||
getReference<MethodReference>()?.name == "setOnClickListener"
|
||||
}
|
||||
val viewRegister =
|
||||
getInstruction<FiveRegisterInstruction>(setOnClickListenerIndex).registerC
|
||||
|
||||
|
@ -249,7 +249,7 @@ val overlayButtonsPatch = resourcePatch(
|
||||
)
|
||||
|
||||
val isButton = if (is_19_17_or_greater)
|
||||
// Note: Do not modify fullscreen button and multiview button
|
||||
// Note: Do not modify fullscreen button and multiview button
|
||||
id.endsWith("_button") && id != "@id/multiview_button"
|
||||
else
|
||||
id.endsWith("_button") || id == "@id/youtube_controls_fullscreen_button_stub"
|
||||
|
@ -271,7 +271,9 @@ val seekbarComponentsPatch = bytecodePatch(
|
||||
).forEach { method ->
|
||||
method.apply {
|
||||
val literalIndex =
|
||||
indexOfFirstLiteralInstructionOrThrow(launchScreenLayoutTypeLotteFeatureFlag)
|
||||
indexOfFirstLiteralInstructionOrThrow(
|
||||
launchScreenLayoutTypeLotteFeatureFlag
|
||||
)
|
||||
val resultIndex =
|
||||
indexOfFirstInstructionOrThrow(literalIndex, Opcode.MOVE_RESULT)
|
||||
val register = getInstruction<OneRegisterInstruction>(resultIndex).registerA
|
||||
|
@ -17,8 +17,9 @@ internal val mainActivityBaseContextHook = extensionHook(
|
||||
attachBaseContextIndex + 1
|
||||
},
|
||||
contextRegisterResolver = { method ->
|
||||
val overrideInstruction = method.implementation!!.instructions.elementAt(attachBaseContextIndex)
|
||||
as FiveRegisterInstruction
|
||||
val overrideInstruction =
|
||||
method.implementation!!.instructions.elementAt(attachBaseContextIndex)
|
||||
as FiveRegisterInstruction
|
||||
"v${overrideInstruction.registerD}"
|
||||
},
|
||||
) {
|
||||
|
@ -31,18 +31,21 @@ val fullscreenButtonHookPatch = bytecodePatch(
|
||||
dependsOn(sharedExtensionPatch)
|
||||
|
||||
execute {
|
||||
val (referenceClass, fullscreenActionClass) = with (nextGenWatchLayoutFullscreenModeFingerprint.methodOrThrow()) {
|
||||
val (referenceClass, fullscreenActionClass) = with(
|
||||
nextGenWatchLayoutFullscreenModeFingerprint.methodOrThrow()
|
||||
) {
|
||||
val targetIndex = indexOfFirstInstructionReversedOrThrow {
|
||||
opcode == Opcode.INVOKE_DIRECT &&
|
||||
getReference<MethodReference>()?.parameterTypes?.size == 2
|
||||
}
|
||||
val targetReference = getInstruction<ReferenceInstruction>(targetIndex).reference as MethodReference
|
||||
val targetReference =
|
||||
getInstruction<ReferenceInstruction>(targetIndex).reference as MethodReference
|
||||
|
||||
Pair(targetReference.definingClass, targetReference.parameterTypes[1].toString())
|
||||
}
|
||||
|
||||
val (enterFullscreenReference, exitFullscreenReference, opcodeName) =
|
||||
with (findMethodOrThrow(referenceClass) { parameters == listOf("I") }) {
|
||||
with(findMethodOrThrow(referenceClass) { parameters == listOf("I") }) {
|
||||
val enterFullscreenIndex = indexOfFirstInstructionOrThrow {
|
||||
val reference = getReference<MethodReference>()
|
||||
reference?.returnType == "V" &&
|
||||
@ -62,7 +65,8 @@ val fullscreenButtonHookPatch = bytecodePatch(
|
||||
getInstruction<ReferenceInstruction>(exitFullscreenIndex).reference
|
||||
val opcode = getInstruction(enterFullscreenIndex).opcode
|
||||
|
||||
val enterFullscreenClass = (enterFullscreenReference as MethodReference).definingClass
|
||||
val enterFullscreenClass =
|
||||
(enterFullscreenReference as MethodReference).definingClass
|
||||
|
||||
enterFullscreenMethod = if (opcode == Opcode.INVOKE_INTERFACE) {
|
||||
classes.find { classDef -> classDef.interfaces.contains(enterFullscreenClass) }
|
||||
|
Reference in New Issue
Block a user