feat(YouTube): remove Spoof test client patch

This commit is contained in:
inotia00
2024-05-23 01:16:01 +09:00
parent 65bb867bd2
commit 8e53382194
5 changed files with 0 additions and 157 deletions

View File

@ -1,119 +0,0 @@
package app.revanced.patches.youtube.misc.test
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.spoofappversion.fingerprints.ClientInfoFingerprint
import app.revanced.patches.shared.spoofappversion.fingerprints.ClientInfoParentFingerprint
import app.revanced.patches.youtube.misc.test.fingerprints.ClientNamelEnumConstructorFingerprint
import app.revanced.patches.youtube.misc.test.fingerprints.SetClientNameFingerprint
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getTargetIndexWithFieldReferenceName
import app.revanced.util.getWalkerMethod
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@Suppress("unused")
object SpoofTestClientPatch : BaseBytecodePatch(
name = "Spoof test client",
description = "Adds an option to spoof the client as a test client.",
dependencies = setOf(SettingsPatch::class),
compatiblePackages = COMPATIBLE_PACKAGE,
fingerprints = setOf(
ClientInfoParentFingerprint,
ClientNamelEnumConstructorFingerprint,
SetClientNameFingerprint,
)
) {
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"$MISC_PATH/SpoofTestClientPatch;"
override fun execute(context: BytecodeContext) {
var clientNameEnumClass: String
var testClientEnumReference: String
// region get test client enum and reference
ClientNamelEnumConstructorFingerprint.resultOrThrow().mutableMethod.apply {
clientNameEnumClass = definingClass
val testClientStringIndex = getStringInstructionIndex("ANDROID_TESTSUITE")
val testClientEnumIndex = getTargetIndex(testClientStringIndex, Opcode.SPUT_OBJECT)
testClientEnumReference = getInstruction<ReferenceInstruction>(testClientEnumIndex).reference.toString()
}
// endregion
// region override client name
SetClientNameFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val walkerIndex = it.scanResult.patternScanResult!!.startIndex + 2
val walkerReference = getInstruction<ReferenceInstruction>(walkerIndex).reference as MethodReference
if (walkerReference.parameterTypes[2].toString() != clientNameEnumClass)
throw PatchException("parameterType does not match")
val walkerMethod = getWalkerMethod(context, walkerIndex)
walkerMethod.apply {
addInstructionsWithLabels(
0, """
invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->spoofTestClient()Z
move-result v0
if-eqz v0, :ignore
sget-object p2, $testClientEnumReference
""", ExternalLabel("ignore", getInstruction(0))
)
}
}
}
// endregion
// region override client version
ClientInfoParentFingerprint.resultOrThrow().let { parentResult ->
ClientInfoFingerprint.resolve(context, parentResult.classDef)
ClientInfoFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val versionIndex = getTargetIndexWithFieldReferenceName("RELEASE") + 1
val insertIndex = getTargetIndexReversed(versionIndex, Opcode.IPUT_OBJECT)
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
addInstructions(
insertIndex, """
invoke-static {v$insertRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->spoofTestClient(Ljava/lang/String;)Ljava/lang/String;
move-result-object v$insertRegister
"""
)
}
}
}
// endregion
/**
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE_CATEGORY: MISC_EXPERIMENTAL_FLAGS",
"SETTINGS: SPOOF_TEST_CLIENT"
)
)
SettingsPatch.updatePatchStatus(this)
}
}

View File

@ -1,11 +0,0 @@
package app.revanced.patches.youtube.misc.test.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
internal object ClientNamelEnumConstructorFingerprint : MethodFingerprint(
returnType = "V",
strings = listOf(
"UNKNOWN_INTERFACE",
"ANDROID_TESTSUITE"
)
)

View File

@ -1,18 +0,0 @@
package app.revanced.patches.youtube.misc.test.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
internal object SetClientNameFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
opcodes = listOf(
Opcode.CONST_HIGH16,
Opcode.CONST_HIGH16,
Opcode.INVOKE_STATIC,
),
strings = listOf("_partition")
)