chore: Lint code

This commit is contained in:
inotia00
2025-02-10 16:34:48 +09:00
parent 9e1f6726a7
commit 1fb36685ad
6 changed files with 39 additions and 41 deletions

View File

@ -4,7 +4,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.shared.extension.Constants.SPOOF_PATH
import app.revanced.util.fingerprint.matchOrThrow
import app.revanced.util.fingerprint.methodOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -18,20 +17,18 @@ val blockRequestPatch = bytecodePatch(
execute {
// region Block /initplayback requests to fall back to /get_watch requests.
buildInitPlaybackRequestFingerprint.matchOrThrow().let {
it.method.apply {
val moveUriStringIndex = it.patternMatch!!.startIndex
val targetRegister =
getInstruction<OneRegisterInstruction>(moveUriStringIndex).registerA
buildInitPlaybackRequestFingerprint.methodOrThrow().apply {
val uriIndex = indexOfUriToStringInstruction(this)
val uriRegister =
getInstruction<FiveRegisterInstruction>(uriIndex).registerC
addInstructions(
moveUriStringIndex + 1,
"""
invoke-static { v$targetRegister }, $EXTENSION_CLASS_DESCRIPTOR->blockInitPlaybackRequest(Ljava/lang/String;)Ljava/lang/String;
move-result-object v$targetRegister
""",
)
}
addInstructions(
uriIndex,
"""
invoke-static { v$uriRegister }, $EXTENSION_CLASS_DESCRIPTOR->blockInitPlaybackRequest(Landroid/net/Uri;)Landroid/net/Uri;
move-result-object v$uriRegister
""",
)
}
// endregion
@ -39,7 +36,7 @@ val blockRequestPatch = bytecodePatch(
// region Block /get_watch requests to fall back to /player requests.
buildPlayerRequestURIFingerprint.methodOrThrow().apply {
val invokeToStringIndex = indexOfToStringInstruction(this)
val invokeToStringIndex = indexOfUriToStringInstruction(this)
val uriRegister =
getInstruction<FiveRegisterInstruction>(invokeToStringIndex).registerC

View File

@ -18,6 +18,9 @@ internal val buildInitPlaybackRequestFingerprint = legacyFingerprint(
"Content-Type",
"Range",
),
customFingerprint = { method, _ ->
indexOfUriToStringInstruction(method) >= 0
},
)
internal val buildPlayerRequestURIFingerprint = legacyFingerprint(
@ -28,11 +31,11 @@ internal val buildPlayerRequestURIFingerprint = legacyFingerprint(
"asig",
),
customFingerprint = { method, _ ->
indexOfToStringInstruction(method) >= 0
indexOfUriToStringInstruction(method) >= 0
},
)
internal fun indexOfToStringInstruction(method: Method) =
internal fun indexOfUriToStringInstruction(method: Method) =
method.indexOfFirstInstruction {
opcode == Opcode.INVOKE_VIRTUAL &&
getReference<MethodReference>().toString() == "Landroid/net/Uri;->toString()Ljava/lang/String;"