feat(YouTube): remove support versions 18.25.40, 18.27.36

This commit is contained in:
inotia00 2024-03-23 19:46:50 +09:00
parent c3f865e8cd
commit d89587dfd3
6 changed files with 34 additions and 131 deletions

View File

@ -4,11 +4,9 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.misc.splashanimation.fingerprints.WatchWhileActivityWithInFlagsFingerprint
import app.revanced.patches.youtube.misc.splashanimation.fingerprints.WatchWhileActivityWithOutFlagsFingerprint
import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH
import app.revanced.patches.youtube.utils.mainactivity.MainActivityResolvePatch
@ -16,6 +14,7 @@ import app.revanced.patches.youtube.utils.mainactivity.MainActivityResolvePatch.
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.DarkSplashAnimation
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -61,25 +60,12 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
)
@Suppress("unused")
object NewSplashAnimationPatch : BytecodePatch(emptySet()) {
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"$MISC_PATH/SplashAnimationPatch;"
override fun execute(context: BytecodeContext) {
WatchWhileActivityWithInFlagsFingerprint.resolve(context, mainActivityClassDef)
WatchWhileActivityWithOutFlagsFingerprint.resolve(context, mainActivityClassDef)
WatchWhileActivityWithInFlagsFingerprint.result
?: WatchWhileActivityWithOutFlagsFingerprint.result
?: throw PatchException("Failed to resolve fingerprints")
/**
* ~YouTube v18.27.36
*/
WatchWhileActivityWithInFlagsFingerprint.result?.let {
it.mutableMethod.apply {
val targetIndex = getWideLiteralInstructionIndex(45407550) + 3
inject(targetIndex)
}
}
/**
* YouTube v18.28.xx~
*/
@ -97,7 +83,7 @@ object NewSplashAnimationPatch : BytecodePatch(emptySet()) {
arrayOf(
index,
index - 8
).forEach { insertIndex -> inject(insertIndex) }
).forEach { insertIndex -> injectCall(insertIndex) }
break
}
@ -106,12 +92,12 @@ object NewSplashAnimationPatch : BytecodePatch(emptySet()) {
if (getInstruction(index).opcode != Opcode.IF_NE)
continue
inject(index)
injectCall(index)
break
}
}
}
} ?: throw WatchWhileActivityWithOutFlagsFingerprint.exception
/**
* Add settings
@ -126,7 +112,7 @@ object NewSplashAnimationPatch : BytecodePatch(emptySet()) {
}
private fun MutableMethod.inject(
private fun MutableMethod.injectCall(
index: Int
) {
if (getInstruction(index).opcode == Opcode.IF_NE)
@ -140,7 +126,7 @@ object NewSplashAnimationPatch : BytecodePatch(emptySet()) {
addInstructions(
index, """
invoke-static {v$register}, $MISC_PATH/SplashAnimationPatch;->enableNewSplashAnimationBoolean(Z)Z
invoke-static {v$register}, $INTEGRATIONS_CLASS_DESCRIPTOR->enableNewSplashAnimationBoolean(Z)Z
move-result v$register
"""
)
@ -151,7 +137,7 @@ object NewSplashAnimationPatch : BytecodePatch(emptySet()) {
addInstructions(
index, """
invoke-static {v$register}, $MISC_PATH/SplashAnimationPatch;->enableNewSplashAnimationInt(I)I
invoke-static {v$register}, $INTEGRATIONS_CLASS_DESCRIPTOR->enableNewSplashAnimationInt(I)I
move-result v$register
"""
)

View File

@ -1,13 +0,0 @@
package app.revanced.patches.youtube.misc.splashanimation.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.util.containsWideLiteralInstructionIndex
object WatchWhileActivityWithInFlagsFingerprint : MethodFingerprint(
returnType = "V",
parameters = listOf("Landroid/os/Bundle;"),
customFingerprint = { methodDef, _ ->
methodDef.name == "onCreate"
&& methodDef.containsWideLiteralInstructionIndex(45407550)
}
)

View File

@ -21,13 +21,10 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import com.android.tools.smali.dexlib2.Opcode
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.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@Patch(
name = "Hide filmstrip overlay",
@ -94,48 +91,28 @@ object HideFilmstripOverlayPatch : BytecodePatch(
FineScrubbingOverlayFingerprint.result?.let {
it.mutableMethod.apply {
if (SettingsPatch.upward1828) {
var insertIndex = it.scanResult.patternScanResult!!.startIndex + 2
val jumpIndex = getTargetIndexUpTo(insertIndex, Opcode.GOTO, Opcode.GOTO_16)
val initialIndex = jumpIndex - 1
var insertIndex = it.scanResult.patternScanResult!!.startIndex + 2
val jumpIndex = getTargetIndexUpTo(insertIndex, Opcode.GOTO, Opcode.GOTO_16)
val initialIndex = jumpIndex - 1
if (getInstruction(insertIndex).opcode == Opcode.INVOKE_VIRTUAL)
insertIndex++
if (getInstruction(insertIndex).opcode == Opcode.INVOKE_VIRTUAL)
insertIndex++
val replaceInstruction = getInstruction<TwoRegisterInstruction>(insertIndex)
val replaceReference =
getInstruction<ReferenceInstruction>(insertIndex).reference
val replaceInstruction = getInstruction<TwoRegisterInstruction>(insertIndex)
val replaceReference =
getInstruction<ReferenceInstruction>(insertIndex).reference
addComponentUpward1828(insertIndex, initialIndex)
addLiteralValues(insertIndex, initialIndex)
addInstructionsWithLabels(
insertIndex + 1, fixComponent + """
invoke-static {}, $PLAYER->hideFilmstripOverlay()Z
move-result v${replaceInstruction.registerA}
if-nez v${replaceInstruction.registerA}, :hidden
iget-object v${replaceInstruction.registerA}, v${replaceInstruction.registerB}, $replaceReference
""", ExternalLabel("hidden", getInstruction(jumpIndex))
)
removeInstruction(insertIndex)
} else {
val setOnClickListenerIndex = getIndex("setOnClickListener")
val jumpIndex = setOnClickListenerIndex + 3
val initialIndex = setOnClickListenerIndex - 1
val insertIndex = getIndex("bringChildToFront") + 1
val insertRegister =
getInstruction<TwoRegisterInstruction>(insertIndex).registerA
addComponentBelow1828(insertIndex, initialIndex)
addInstructionsWithLabels(
insertIndex, fixComponent + """
invoke-static {}, $PLAYER->hideFilmstripOverlay()Z
move-result v$insertRegister
if-nez v$insertRegister, :hidden
""", ExternalLabel("hidden", getInstruction(jumpIndex))
)
}
addInstructionsWithLabels(
insertIndex + 1, literalComponent + """
invoke-static {}, $PLAYER->hideFilmstripOverlay()Z
move-result v${replaceInstruction.registerA}
if-nez v${replaceInstruction.registerA}, :hidden
iget-object v${replaceInstruction.registerA}, v${replaceInstruction.registerB}, $replaceReference
""", ExternalLabel("hidden", getInstruction(jumpIndex))
)
removeInstruction(insertIndex)
}
} ?: throw FineScrubbingOverlayFingerprint.exception
@ -154,34 +131,9 @@ object HideFilmstripOverlayPatch : BytecodePatch(
}
private var fixComponent: String = ""
private var literalComponent: String = ""
private fun MutableMethod.addComponentBelow1828(
startIndex: Int,
endIndex: Int
) {
val fixRegister =
getInstruction<FiveRegisterInstruction>(endIndex).registerE
for (index in endIndex downTo startIndex) {
val opcode = getInstruction(index).opcode
if (opcode != Opcode.CONST_16)
continue
val register = getInstruction<OneRegisterInstruction>(index).registerA
if (register != fixRegister)
continue
val fixValue = getInstruction<WideLiteralInstruction>(index).wideLiteral.toInt()
fixComponent = "const/16 v$fixRegister, $fixValue"
break
}
}
private fun MutableMethod.addComponentUpward1828(
private fun MutableMethod.addLiteralValues(
startIndex: Int,
endIndex: Int
) {
@ -213,7 +165,7 @@ object HideFilmstripOverlayPatch : BytecodePatch(
else -> ""
}
fixComponent += line
literalComponent += line
}
}
@ -242,12 +194,4 @@ object HideFilmstripOverlayPatch : BytecodePatch(
""", ExternalLabel("shown", getInstruction(0))
)
}
private fun MutableMethod.getIndex(methodName: String): Int {
return implementation!!.instructions.indexOfFirst { instruction ->
if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return@indexOfFirst false
return@indexOfFirst ((instruction as Instruction35c).reference as MethodReference).name == methodName
}
}
}

View File

@ -110,18 +110,8 @@ object SeekMessagePatch : BytecodePatch(
if-nez v$insertRegister, :default
""", ExternalLabel("default", getInstruction(jumpIndex + 1))
)
/**
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: PLAYER_SETTINGS",
"SETTINGS: HIDE_SEEK_UNDO_MESSAGE"
)
)
}
}
} ?: throw SeekEduUndoOverlayFingerprint.exception
/**
* Add settings

View File

@ -91,7 +91,6 @@ object SettingsPatch : AbstractSettingsResourcePatch(
val playServicesVersion = node.textContent.toInt()
upward1828 = 232900000 <= playServicesVersion
upward1831 = 233200000 <= playServicesVersion
upward1834 = 233502000 <= playServicesVersion
upward1839 = 234002000 <= playServicesVersion
@ -161,7 +160,6 @@ object SettingsPatch : AbstractSettingsResourcePatch(
private val threadPoolExecutor = Executors.newFixedThreadPool(THREAD_COUNT)
internal lateinit var contexts: ResourceContext
internal var upward1828: Boolean = false
internal var upward1831: Boolean = false
internal var upward1834: Boolean = false
internal var upward1839: Boolean = false

View File

@ -611,10 +611,8 @@
<SwitchPreference android:title="@string/revanced_hide_previous_next_button_title" android:key="revanced_hide_previous_next_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_previous_next_button_summary_on" android:summaryOff="@string/revanced_hide_previous_next_button_summary_off" />SETTINGS: HIDE_PREVIOUS_NEXT_BUTTON -->
<!-- SETTINGS: HIDE_SEEK_MESSAGE
<SwitchPreference android:title="@string/revanced_hide_seek_message_title" android:key="revanced_hide_seek_message" android:defaultValue="false" android:summaryOn="@string/revanced_hide_seek_message_summary_on" android:summaryOff="@string/revanced_hide_seek_message_summary_off" />SETTINGS: HIDE_SEEK_MESSAGE -->
<!-- SETTINGS: HIDE_SEEK_UNDO_MESSAGE
<SwitchPreference android:title="@string/revanced_hide_seek_undo_message_title" android:key="revanced_hide_seek_undo_message" android:defaultValue="false" android:summaryOn="@string/revanced_hide_seek_undo_message_summary_on" android:summaryOff="@string/revanced_hide_seek_undo_message_summary_off" />SETTINGS: HIDE_SEEK_UNDO_MESSAGE -->
<SwitchPreference android:title="@string/revanced_hide_seek_message_title" android:key="revanced_hide_seek_message" android:defaultValue="false" android:summaryOn="@string/revanced_hide_seek_message_summary_on" android:summaryOff="@string/revanced_hide_seek_message_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_seek_undo_message_title" android:key="revanced_hide_seek_undo_message" android:defaultValue="false" android:summaryOn="@string/revanced_hide_seek_undo_message_summary_on" android:summaryOff="@string/revanced_hide_seek_undo_message_summary_off" />SETTINGS: HIDE_SEEK_MESSAGE -->
<!-- SETTINGS: HIDE_SUGGESTED_ACTION
<SwitchPreference android:title="@string/revanced_hide_suggested_actions_title" android:key="revanced_hide_suggested_actions" android:defaultValue="true" android:summaryOn="@string/revanced_hide_suggested_actions_summary_on" android:summaryOff="@string/revanced_hide_suggested_actions_summary_off" />SETTINGS: HIDE_SUGGESTED_ACTION -->