Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,5 @@ node_modules/

# Ignore IDEA files
.idea/
/src/main/kotlin/crimera/patches/twitter/test*
/src/main/kotlin/crimera/patches/twitter/test*
bin/
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ object SettingsPatch : BytecodePatch(
) {
private const val INTEGRATIONS_PACKAGE = "Lapp/revanced/integrations/twitter"
const val UTILS_DESCRIPTOR = "$INTEGRATIONS_PACKAGE/Utils"
private const val ACTIVITY_HOOK_CLASS = "Lapp/revanced/integrations/twitter/settings/ActivityHook;"
private const val DEEPLINK_HOOK_CLASS = "Lapp/revanced/integrations/twitter/settings/DeepLink;"
private const val ACTIVITY_SETTINGS_CLASS = "$INTEGRATIONS_PACKAGE/settings"
private const val ACTIVITY_HOOK_CLASS = "$ACTIVITY_SETTINGS_CLASS/ActivityHook;"
private const val DEEPLINK_HOOK_CLASS = "$ACTIVITY_SETTINGS_CLASS/DeepLink;"
private const val ADD_PREF_DESCRIPTOR =
"$UTILS_DESCRIPTOR;->addPref([Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;"

const val PREF_DESCRIPTOR = "$INTEGRATIONS_PACKAGE/Pref"
const val PATCHES_DESCRIPTOR = "$INTEGRATIONS_PACKAGE/patches"
const val CUSTOMISE_DESCRIPTOR = "$PATCHES_DESCRIPTOR/customise/Customise"
const val SSTS_DESCRIPTOR = "invoke-static {}, $INTEGRATIONS_PACKAGE/settings/SettingsStatus;"
const val NATIVE_DESCRIPTOR = "$PATCHES_DESCRIPTOR/nativeFeatures"

const val SSTS_DESCRIPTOR = "invoke-static {}, $ACTIVITY_SETTINGS_CLASS/SettingsStatus;"
const val FSTS_DESCRIPTOR = "invoke-static {}, $INTEGRATIONS_PACKAGE/patches/FeatureSwitchPatch;"

private const val START_ACTIVITY_DESCRIPTOR =
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ import com.android.tools.smali.dexlib2.iface.MethodParameter
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
import com.android.tools.smali.dexlib2.iface.instruction.formats.*
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.iface.reference.Reference
import crimera.patches.twitter.misc.settings.SettingsPatch
import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint
import crimera.patches.twitter.misc.shareMenu.fingerprints.ActionEnumsFingerprint
import crimera.patches.twitter.misc.shareMenu.fingerprints.ShareMenuButtonFuncCallFingerprint
import crimera.patches.twitter.misc.shareMenu.hooks.ShareMenuButtonAddHook
import crimera.patches.twitter.misc.shareMenu.hooks.ShareMenuButtonInitHook
import crimera.patches.twitter.models.ExtMediaEntityPatch
import crimera.patches.twitter.models.TweetEntityPatch
import crimera.patches.twitter.models.extractDescriptors

class InitMethod(
private val validator: () -> Unit,
Expand Down Expand Up @@ -138,7 +140,7 @@ val MutableList<BuilderInstruction>.indexOfLastFilledNewArrayRange
@Patch(
name = "Custom downloader",
description = "Requires X 11.0.0-release.0 or higher.",
dependencies = [SettingsPatch::class, NativeDownloaderHooksPatch::class, ResourceMappingPatch::class],
dependencies = [SettingsPatch::class, TweetEntityPatch::class, ExtMediaEntityPatch::class, ResourceMappingPatch::class],
compatiblePackages = [CompatiblePackage("com.twitter.android")],
use = true,
)
Expand All @@ -152,7 +154,7 @@ object NativeDownloaderPatch : BytecodePatch(
ActionEnumsFingerprint,
),
) {
var offset: Boolean = false
// var offset: Boolean = false

override fun execute(context: BytecodeContext) {
// TODO: make this whole button addition in a new function or a class?
Expand Down Expand Up @@ -226,16 +228,11 @@ object NativeDownloaderPatch : BytecodePatch(
check-cast v$timelineRefReg, ${timelineRef.reference.extractDescriptors()[0]}
iget-object v1, v$timelineRefReg, ${timelineRef.reference}

invoke-static {v$activityRefReg, v1}, ${SettingsPatch.PATCHES_DESCRIPTOR}/NativeDownloader;->downloader(Landroid/content/Context;Ljava/lang/Object;)V
invoke-static {v$activityRefReg, v1}, ${SettingsPatch.NATIVE_DESCRIPTOR}/NativeDownloader;->downloader(Landroid/content/Context;Ljava/lang/Object;)V
""".trimIndent(),
viewDebugDialogReference,
)

SettingsStatusLoadFingerprint.enableSettings("nativeDownloader")
}
}

fun Reference.extractDescriptors(): List<String> {
val regex = Regex("L[^;]+;")
return regex.findAll(this.toString()).map { it.value }.toList()
}
Loading
Loading