mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-12-07 01:51:27 +01:00
fix(TikTok - Downloads): Fix download path setting (#6191)
This commit is contained in:
@@ -3,14 +3,20 @@ package app.revanced.patches.tiktok.interaction.downloads
|
|||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
|
||||||
import app.revanced.patcher.patch.bytecodePatch
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
import app.revanced.patches.tiktok.misc.extension.sharedExtensionPatch
|
import app.revanced.patches.tiktok.misc.extension.sharedExtensionPatch
|
||||||
import app.revanced.patches.tiktok.misc.settings.settingsPatch
|
import app.revanced.patches.tiktok.misc.settings.settingsPatch
|
||||||
import app.revanced.patches.tiktok.misc.settings.settingsStatusLoadFingerprint
|
import app.revanced.patches.tiktok.misc.settings.settingsStatusLoadFingerprint
|
||||||
|
import app.revanced.util.findInstructionIndicesReversedOrThrow
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
import app.revanced.util.returnEarly
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||||
|
|
||||||
|
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/tiktok/download/DownloadsPatch;"
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
val downloadsPatch = bytecodePatch(
|
val downloadsPatch = bytecodePatch(
|
||||||
@@ -28,60 +34,45 @@ val downloadsPatch = bytecodePatch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
execute {
|
execute {
|
||||||
aclCommonShareFingerprint.method.replaceInstructions(
|
aclCommonShareFingerprint.method.returnEarly(0)
|
||||||
0,
|
aclCommonShare2Fingerprint.method.returnEarly(2)
|
||||||
"""
|
|
||||||
const/4 v0, 0x0
|
|
||||||
return v0
|
|
||||||
""",
|
|
||||||
)
|
|
||||||
|
|
||||||
aclCommonShare2Fingerprint.method.replaceInstructions(
|
|
||||||
0,
|
|
||||||
"""
|
|
||||||
const/4 v0, 0x2
|
|
||||||
return v0
|
|
||||||
""",
|
|
||||||
)
|
|
||||||
|
|
||||||
// Download videos without watermark.
|
// Download videos without watermark.
|
||||||
aclCommonShare3Fingerprint.method.addInstructionsWithLabels(
|
aclCommonShare3Fingerprint.method.addInstructionsWithLabels(
|
||||||
0,
|
0,
|
||||||
"""
|
"""
|
||||||
invoke-static {}, Lapp/revanced/extension/tiktok/download/DownloadsPatch;->shouldRemoveWatermark()Z
|
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->shouldRemoveWatermark()Z
|
||||||
move-result v0
|
move-result v0
|
||||||
if-eqz v0, :noremovewatermark
|
if-eqz v0, :noremovewatermark
|
||||||
const/4 v0, 0x1
|
const/4 v0, 0x1
|
||||||
return v0
|
return v0
|
||||||
:noremovewatermark
|
:noremovewatermark
|
||||||
nop
|
nop
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|
||||||
// Change the download path patch.
|
// Change the download path patch.
|
||||||
downloadUriFingerprint.method.apply {
|
downloadUriFingerprint.method.apply {
|
||||||
val firstIndex = indexOfFirstInstructionOrThrow {
|
findInstructionIndicesReversedOrThrow {
|
||||||
getReference<MethodReference>()?.name == "<init>"
|
getReference<FieldReference>().let {
|
||||||
}
|
it?.definingClass == "Landroid/os/Environment;" && it.name.startsWith("DIRECTORY_")
|
||||||
val secondIndex = indexOfFirstInstructionOrThrow {
|
}
|
||||||
getReference<MethodReference>()?.returnType?.contains("Uri") == true
|
}.forEach { fieldIndex ->
|
||||||
}
|
val pathRegister = getInstruction<OneRegisterInstruction>(fieldIndex).registerA
|
||||||
|
val builderRegister = getInstruction<FiveRegisterInstruction>(fieldIndex + 1).registerC
|
||||||
|
|
||||||
addInstructions(
|
// Remove 'field load → append → "/Camera/" → append' block.
|
||||||
secondIndex,
|
removeInstructions(fieldIndex, 4)
|
||||||
"""
|
|
||||||
invoke-static {}, Lapp/revanced/extension/tiktok/download/DownloadsPatch;->getDownloadPath()Ljava/lang/String;
|
|
||||||
move-result-object v0
|
|
||||||
""",
|
|
||||||
)
|
|
||||||
|
|
||||||
addInstructions(
|
addInstructions(
|
||||||
firstIndex,
|
fieldIndex,
|
||||||
"""
|
"""
|
||||||
invoke-static {}, Lapp/revanced/extension/tiktok/download/DownloadsPatch;->getDownloadPath()Ljava/lang/String;
|
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->getDownloadPath()Ljava/lang/String;
|
||||||
move-result-object v0
|
move-result-object v$pathRegister
|
||||||
""",
|
invoke-virtual { v$builderRegister, v$pathRegister }, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
||||||
)
|
""",
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsStatusLoadFingerprint.method.addInstruction(
|
settingsStatusLoadFingerprint.method.addInstruction(
|
||||||
|
|||||||
Reference in New Issue
Block a user