feat: Restore previous release

This reverts commit 3938f2f1b3.
This commit is contained in:
oSumAtrIX
2023-08-27 21:41:04 +02:00
parent 392021124c
commit 2adfc37a66
496 changed files with 2425 additions and 2551 deletions
@@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.autorepeat.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35", "18.29.38", "18.32.39"))])
@Target(AnnotationTarget.CLASS)
internal annotation class AutoRepeatCompatibility
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.autorepeat.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
object AutoRepeatFingerprint : MethodFingerprint(
"V",
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.autorepeat.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
object AutoRepeatParentFingerprint : MethodFingerprint(
"V",
@@ -7,9 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
@@ -30,7 +28,7 @@ class AutoRepeatPatch : BytecodePatch(
AutoRepeatParentFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
SwitchPreference(
"revanced_auto_repeat",
@@ -42,7 +40,7 @@ class AutoRepeatPatch : BytecodePatch(
//Get Result from the ParentFingerprint which is the playMethod we need to get.
val parentResult = AutoRepeatParentFingerprint.result
?: return PatchResultError("ParentFingerprint did not resolve.")
?: throw PatchException("ParentFingerprint did not resolve.")
//this one needs to be called when app/revanced/integrations/patches/AutoRepeatPatch;->shouldAutoRepeat() returns true
val playMethod = parentResult.mutableMethod
@@ -52,7 +50,7 @@ class AutoRepeatPatch : BytecodePatch(
//This is the method we search for
val result = AutoRepeatFingerprint.result
?: return PatchResultError("FingerPrint did not resolve.")
?: throw PatchException("FingerPrint did not resolve.")
val method = result.mutableMethod
//Instructions to add to the smali code
@@ -67,7 +65,7 @@ class AutoRepeatPatch : BytecodePatch(
//Get the implementation so we can do a check for null and get instructions size.
val implementation = method.implementation
?: return PatchResultError("No Method Implementation found!")
?: throw PatchException("No Method Implementation found!")
//Since addInstructions needs an index which starts counting at 0 and size starts counting at 1,
//we have to remove 1 to get the latest instruction
@@ -80,6 +78,5 @@ class AutoRepeatPatch : BytecodePatch(
method.addInstructionsWithLabels(index, instructions)
//Everything worked as expected, return Success
return PatchResultSuccess()
}
}
@@ -3,7 +3,7 @@ package app.revanced.patches.youtube.misc.bottomsheet.hook.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.misc.bottomsheet.hook.patch.BottomSheetHookResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
object CreateBottomSheetFingerprint : LiteralValueFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
@@ -1,22 +1,20 @@
package app.revanced.patches.youtube.misc.bottomsheet.hook.patch
import app.revanced.extensions.toErrorResult
import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.misc.bottomsheet.hook.fingerprints.CreateBottomSheetFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@DependsOn([IntegrationsPatch::class, BottomSheetHookResourcePatch::class])
class BottomSheetHookPatch : BytecodePatch(
listOf(CreateBottomSheetFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
CreateBottomSheetFingerprint.result?.let {
it.mutableMethod.apply {
val returnLinearLayoutIndex = implementation!!.instructions.lastIndex
@@ -31,9 +29,7 @@ class BottomSheetHookPatch : BytecodePatch(
)
}
}
} ?: return CreateBottomSheetFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw CreateBottomSheetFingerprint.exception
}
internal companion object {
@@ -1,20 +1,16 @@
package app.revanced.patches.youtube.misc.bottomsheet.hook.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@DependsOn([ResourceMappingPatch::class])
class BottomSheetHookResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
bottomSheetMargins = ResourceMappingPatch.resourceMappings.find { it.name == "bottom_sheet_margins" }?.id
?: return PatchResultError("Could not find resource")
return PatchResultSuccess()
?: throw PatchException("Could not find resource")
}
internal companion object {
@@ -3,8 +3,6 @@ package app.revanced.patches.youtube.misc.debugging.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
@@ -20,7 +18,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@Description("Adds debugging options.")
@DebuggingCompatibility
class DebuggingPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
app.revanced.patches.shared.settings.preference.impl.PreferenceScreen(
"revanced_debug_preference_screen",
@@ -32,6 +30,15 @@ class DebuggingPatch : ResourcePatch {
StringResource("revanced_debug_summary_on", "Debug logs are enabled"),
StringResource("revanced_debug_summary_off", "Debug logs are disabled")
),
SwitchPreference(
"revanced_debug_protobuffer",
StringResource(
"revanced_debug_protobuffer_title",
"Log protocol buffer"
),
StringResource("revanced_debug_protobuffer_summary_on", "Debug logs include proto buffer"),
StringResource("revanced_debug_protobuffer_summary_off", "Debug logs do not include proto buffer")
),
SwitchPreference(
"revanced_debug_stacktrace",
StringResource(
@@ -58,7 +65,5 @@ class DebuggingPatch : ResourcePatch {
StringResource("revanced_debug_preference_screen_summary", "Enable or disable debugging options")
)
)
return PatchResultSuccess()
}
}
@@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.fix.backtoexitgesture.annotation
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35", "18.29.38", "18.32.39"))])
@Target(AnnotationTarget.CLASS)
internal annotation class FixBackToExitGestureCompatibility
@@ -2,8 +2,8 @@ package app.revanced.patches.youtube.misc.fix.backtoexitgesture.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object OnBackPressedFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
@@ -2,8 +2,8 @@ package app.revanced.patches.youtube.misc.fix.backtoexitgesture.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object RecyclerViewScrollingFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
@@ -2,8 +2,8 @@ package app.revanced.patches.youtube.misc.fix.backtoexitgesture.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object RecyclerViewTopScrollingFingerprint : MethodFingerprint(
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), listOf(
@@ -2,8 +2,8 @@ package app.revanced.patches.youtube.misc.fix.backtoexitgesture.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object RecyclerViewTopScrollingParentFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
@@ -1,15 +1,12 @@
package app.revanced.patches.youtube.misc.fix.backtoexitgesture.patch
import app.revanced.extensions.toErrorResult
import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.youtube.misc.fix.backtoexitgesture.annotation.FixBackToExitGestureCompatibility
import app.revanced.patches.youtube.misc.fix.backtoexitgesture.fingerprints.OnBackPressedFingerprint
import app.revanced.patches.youtube.misc.fix.backtoexitgesture.fingerprints.RecyclerViewScrollingFingerprint
@@ -25,12 +22,12 @@ class FixBackToExitGesturePatch : BytecodePatch(
OnBackPressedFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
RecyclerViewTopScrollingFingerprint.apply {
resolve(
context,
RecyclerViewTopScrollingParentFingerprint.result?.classDef
?: return RecyclerViewTopScrollingParentFingerprint.toErrorResult()
?: throw RecyclerViewTopScrollingParentFingerprint.exception
)
}
@@ -44,15 +41,7 @@ class FixBackToExitGesturePatch : BytecodePatch(
OnBackPressedFingerprint to IntegrationsMethod(
"p0", "onBackPressed", "Lcom/google/android/apps/youtube/app/watchwhile/WatchWhileActivity;"
)
).forEach { (fingerprint, target) ->
try {
fingerprint.injectCall(target)
} catch (error: PatchResultError) {
return error
}
}
return PatchResultSuccess()
).forEach { (fingerprint, target) -> fingerprint.injectCall(target) }
}
private companion object {
@@ -79,6 +68,6 @@ class FixBackToExitGesturePatch : BytecodePatch(
mutableMethod.addInstruction(
scanResult.patternScanResult!!.endIndex, targetMethod.toString()
)
} ?: throw this.toErrorResult()
} ?: throw this.exception
}
}
@@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.fix.playback.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35", "18.29.38", "18.32.39"))])
@Target(AnnotationTarget.CLASS)
internal annotation class ClientSpoofCompatibility
@@ -1,7 +1,7 @@
package app.revanced.patches.youtube.misc.fix.playback.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.Opcode
object ProtobufParameterBuilderFingerprint : MethodFingerprint(
opcodes = listOf(
@@ -3,8 +3,8 @@ package app.revanced.patches.youtube.misc.fix.playback.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.misc.fix.playback.patch.SpoofSignatureVerificationResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object ScrubbedPreviewLayoutFingerprint : LiteralValueFingerprint(
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
@@ -2,8 +2,8 @@ package app.revanced.patches.youtube.misc.fix.playback.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
/**
* Resolves using the class found in [StoryboardThumbnailParentFingerprint].
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.fix.playback.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
/**
* Here lies code that creates the seekbar thumbnails.
@@ -1,7 +1,7 @@
package app.revanced.patches.youtube.misc.fix.playback.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.Opcode
object UserAgentHeaderBuilderFingerprint : MethodFingerprint(
parameters = listOf("L", "L", "L"),
@@ -1,19 +1,17 @@
package app.revanced.patches.youtube.misc.fix.playback.patch
import app.revanced.extensions.toErrorResult
import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.misc.fix.playback.annotations.ClientSpoofCompatibility
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.UserAgentHeaderBuilderFingerprint
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Patch
@Name("Client spoof")
@@ -23,7 +21,7 @@ import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
class ClientSpoofPatch : BytecodePatch(
listOf(UserAgentHeaderBuilderFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
UserAgentHeaderBuilderFingerprint.result?.let { result ->
val insertIndex = result.scanResult.patternScanResult!!.endIndex
result.mutableMethod.apply {
@@ -32,9 +30,7 @@ class ClientSpoofPatch : BytecodePatch(
addInstruction(insertIndex, "const-string v$packageNameRegister, \"$ORIGINAL_PACKAGE_NAME\"")
}
} ?: return UserAgentHeaderBuilderFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw UserAgentHeaderBuilderFingerprint.exception
}
private companion object {
@@ -1,17 +1,14 @@
package app.revanced.patches.youtube.misc.fix.playback.patch
import app.revanced.extensions.toErrorResult
import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.ProtobufParameterBuilderFingerprint
@@ -20,7 +17,7 @@ import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardThu
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardThumbnailParentFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@Name("Spoof signature verification")
@Description("Spoofs the client to prevent playback issues.")
@@ -36,7 +33,7 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
ScrubbedPreviewLayoutFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// hook parameter
ProtobufParameterBuilderFingerprint.result?.let {
@@ -55,14 +52,14 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
"""
)
}
} ?: return ProtobufParameterBuilderFingerprint.toErrorResult()
} ?: throw ProtobufParameterBuilderFingerprint.exception
// When signature spoofing is enabled, the seekbar when tapped does not show
// the video time, chapter names, or the video thumbnail.
// Changing the value returned of this method forces all of these to show up,
// except the thumbnails are blank, which is handled with the patch below.
StoryboardThumbnailParentFingerprint.result ?: return StoryboardThumbnailParentFingerprint.toErrorResult()
StoryboardThumbnailParentFingerprint.result ?: throw StoryboardThumbnailParentFingerprint.exception
StoryboardThumbnailFingerprint.resolve(context, StoryboardThumbnailParentFingerprint.result!!.classDef)
StoryboardThumbnailFingerprint.result?.apply {
val endIndex = scanResult.patternScanResult!!.endIndex
@@ -84,7 +81,7 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
return v0
"""
)
} ?: return StoryboardThumbnailFingerprint.toErrorResult()
} ?: throw StoryboardThumbnailFingerprint.exception
// Seekbar thumbnail now show up but are always a blank image.
@@ -102,9 +99,7 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
"""
)
}
} ?: return ScrubbedPreviewLayoutFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw ScrubbedPreviewLayoutFingerprint.exception
}
private companion object {
@@ -1,20 +1,17 @@
package app.revanced.patches.youtube.misc.fix.playback.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.*
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
class SpoofSignatureVerificationResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
SwitchPreference(
"revanced_spoof_signature_verification",
@@ -23,19 +20,17 @@ class SpoofSignatureVerificationResourcePatch : ResourcePatch {
"App signature spoofed\\n\\n"
+ "Side effects include:\\n"
+ "• Ambient mode may not work\\n"
+ "• Seekbar thumbnails are hidden\\n"
+ "• Downloading videos may not work"),
StringResource("revanced_spoof_signature_verification_summary_off", "App signature not spoofed"),
+ "• Downloading videos may not work\\n"
+ "• Seekbar thumbnails are always hidden"),
StringResource("revanced_spoof_signature_verification_summary_off", "App signature not spoofed\\n\\nVideo playback may not work"),
StringResource("revanced_spoof_signature_verification_user_dialog_message",
"Turning off this setting may cause playback issues.")
"Turning off this setting will cause video playback issues.")
)
)
scrubbedPreviewThumbnailResourceId = ResourceMappingPatch.resourceMappings.single {
it.type == "id" && it.name == "thumbnail"
}.id
return PatchResultSuccess()
}
companion object {
@@ -1,8 +0,0 @@
package app.revanced.patches.youtube.misc.integrations.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Target(AnnotationTarget.CLASS)
internal annotation class IntegrationsCompatibility
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
/**
* For embedded playback.
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
/**
* For embedded playback inside Google Play store (and probably other situations as well).
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
/**
* For embedded playback inside the Google app (such as the in app 'discover' tab).
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
/**
* For embedded playback. Likely covers Google Play store and other Google products.
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
/**
* For embedded playback inside 3rd party android app (such as 3rd party Reddit apps).
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
/**
* Old API activity to embed YouTube into 3rd party Android apps.
@@ -3,17 +3,9 @@ package app.revanced.patches.youtube.misc.integrations.patch
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.patch.annotations.RequiresIntegrations
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch
import app.revanced.patches.youtube.misc.integrations.annotations.IntegrationsCompatibility
import app.revanced.patches.youtube.misc.integrations.fingerprints.EmbeddedPlayerControlsOverlayFingerprint
import app.revanced.patches.youtube.misc.integrations.fingerprints.EmbeddedPlayerFingerprint
import app.revanced.patches.youtube.misc.integrations.fingerprints.ApplicationInitFingerprint
import app.revanced.patches.youtube.misc.integrations.fingerprints.RemoteEmbedFragmentFingerprint
import app.revanced.patches.youtube.misc.integrations.fingerprints.RemoteEmbeddedPlayerFingerprint
import app.revanced.patches.youtube.misc.integrations.fingerprints.APIPlayerServiceFingerprint
import app.revanced.patches.youtube.misc.integrations.fingerprints.StandalonePlayerActivityFingerprint
import app.revanced.patches.youtube.misc.integrations.fingerprints.*
@Name("Integrations")
@IntegrationsCompatibility
@RequiresIntegrations
class IntegrationsPatch : AbstractIntegrationsPatch(
"Lapp/revanced/integrations/utils/ReVancedUtils;",
@@ -1,8 +1,8 @@
package app.revanced.patches.youtube.misc.links.open.annotations
package app.revanced.patches.youtube.misc.links.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35", "18.29.38", "18.32.39"))])
@Target(AnnotationTarget.CLASS)
internal annotation class OpenLinksExternallyCompatibility
@@ -1,17 +0,0 @@
package app.revanced.patches.youtube.misc.links.open.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object BindSessionServiceFingerprint : MethodFingerprint(
returnType = "L",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
opcodes = listOf(
Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.CONST_STRING
),
strings = listOf("android.support.customtabs.action.CustomTabsService")
)
@@ -1,18 +0,0 @@
package app.revanced.patches.youtube.misc.links.open.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object GetCustomTabPackageNameFingerprint : MethodFingerprint(
returnType = "L",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
opcodes = listOf(
Opcode.CHECK_CAST,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.CONST_STRING
),
strings = listOf("android.support.customtabs.action.CustomTabsService")
)
@@ -1,18 +0,0 @@
package app.revanced.patches.youtube.misc.links.open.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object InitializeCustomTabSupportFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
opcodes = listOf(
Opcode.CHECK_CAST,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.CONST_STRING
),
strings = listOf("android.support.customtabs.action.CustomTabsService")
)
@@ -1,63 +0,0 @@
package app.revanced.patches.youtube.misc.links.open.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.youtube.misc.links.open.annotations.OpenLinksExternallyCompatibility
import app.revanced.patches.youtube.misc.links.open.fingerprints.BindSessionServiceFingerprint
import app.revanced.patches.youtube.misc.links.open.fingerprints.GetCustomTabPackageNameFingerprint
import app.revanced.patches.youtube.misc.links.open.fingerprints.InitializeCustomTabSupportFingerprint
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
@Patch
@Name("Open links externally")
@Description("Open links outside of the app directly in your browser.")
@OpenLinksExternallyCompatibility
class OpenLinksExternallyPatch : BytecodePatch(
listOf(
GetCustomTabPackageNameFingerprint,
BindSessionServiceFingerprint,
InitializeCustomTabSupportFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
SwitchPreference(
"revanced_external_browser",
StringResource("revanced_external_browser_title", "Open links in browser"),
StringResource("revanced_external_browser_summary_on", "Opening links externally"),
StringResource("revanced_external_browser_summary_off", "Opening links in app")
)
)
arrayOf(
GetCustomTabPackageNameFingerprint,
BindSessionServiceFingerprint,
InitializeCustomTabSupportFingerprint
).forEach {
val result = it.result ?: return it.toErrorResult()
val insertIndex = result.scanResult.patternScanResult!!.endIndex + 1
with(result.mutableMethod) {
val register = (implementation!!.instructions[insertIndex - 1] as Instruction21c).registerA
addInstructions(
insertIndex,
"""
invoke-static {v$register}, Lapp/revanced/integrations/patches/OpenLinksExternallyPatch;->enableExternalBrowser(Ljava/lang/String;)Ljava/lang/String;
move-result-object v$register
"""
)
}
}
return PatchResultSuccess()
}
}
@@ -0,0 +1,63 @@
package app.revanced.patches.youtube.misc.links.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.youtube.misc.links.annotations.OpenLinksExternallyCompatibility
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.util.patch.AbstractTransformInstructionsPatch
import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
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.reference.StringReference
@Patch
@Name("Open links externally")
@Description("Open links outside of the app directly in your browser.")
@OpenLinksExternallyCompatibility
class OpenLinksExternallyPatch : AbstractTransformInstructionsPatch<Pair<Int, Int>>(
) {
override fun filterMap(
classDef: ClassDef, method: Method, instruction: Instruction, instructionIndex: Int
): Pair<Int, Int>? {
if (instruction !is ReferenceInstruction) return null
val reference = instruction.reference as? StringReference ?: return null
if (reference.string != "android.support.customtabs.action.CustomTabsService") return null
return instructionIndex to (instruction as OneRegisterInstruction).registerA
}
override fun transform(mutableMethod: MutableMethod, entry: Pair<Int, Int>) {
val (intentStringIndex, register) = entry
// Hook the intent string.
mutableMethod.addInstructions(
intentStringIndex + 1,
"""
invoke-static {v$register}, Lapp/revanced/integrations/patches/OpenLinksExternallyPatch;->getIntent(Ljava/lang/String;)Ljava/lang/String;
move-result-object v$register
"""
)
}
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
SwitchPreference(
"revanced_external_browser",
StringResource("revanced_external_browser_title", "Open links in browser"),
StringResource("revanced_external_browser_summary_on", "Opening links externally"),
StringResource("revanced_external_browser_summary_off", "Opening links in app")
)
)
super.execute(context)
}
}
@@ -1,7 +1,7 @@
package app.revanced.patches.youtube.misc.litho.filter.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.Opcode
object ComponentContextParserFingerprint : MethodFingerprint(
opcodes = listOf(
@@ -1,7 +1,7 @@
package app.revanced.patches.youtube.misc.litho.filter.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.Opcode
object EmptyComponentBuilderFingerprint : MethodFingerprint(
opcodes = listOf(
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.litho.filter.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
object LithoFilterFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC or AccessFlags.CONSTRUCTOR,
@@ -2,8 +2,8 @@ package app.revanced.patches.youtube.misc.litho.filter.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object ProtobufBufferReferenceFingerprint : MethodFingerprint(
returnType = "V",
@@ -1,7 +1,7 @@
package app.revanced.patches.youtube.misc.litho.filter.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.Opcode
object ReadComponentIdentifierFingerprint : MethodFingerprint(
opcodes = listOf(
@@ -1,6 +1,6 @@
package app.revanced.patches.youtube.misc.litho.filter.patch
import app.revanced.extensions.toErrorResult
import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
@@ -9,23 +9,17 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.litho.filter.fingerprints.*
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
import org.jf.dexlib2.iface.instruction.Instruction
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.immutable.ImmutableField
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import java.io.Closeable
@DependsOn([IntegrationsPatch::class])
@@ -41,59 +35,47 @@ class LithoFilterPatch : BytecodePatch(
* Additionally, the method contains a reference to the components identifier.
* The identifier is used to filter components by their identifier.
*
* In addition to that, a static field is added to the class of this method. (See protobufBufferField).
* This field holds a reference to the protobuf buffer object.
* The field is being set in another method that holds a reference to the protobuf buffer object.
* The object contains a large byte array that represents the component tree.
* The protobuf buffer is passed along from a different injection point before the filtering occurs.
* The buffer is a large byte array that represents the component tree.
* This byte array is searched for strings that indicate the current component.
*
* The following pseudo code shows how the patch works:
*
* class SomeOtherClass {
* // Called before ComponentContextParser.parseBytesToComponentContext method.
* public void someOtherMethod(ByteBuffer byteBuffer) {
* IntegrationsClass.setProtoBuffer(byteBuffer); // Inserted by this patch.
* ...
* }
* }
*
* class ComponentContextParser {
* public static ByteBuffer buffer; // Inserted by this patch.
*
* public ComponentContext parseBytesToComponentContext(...) {
* ...
* if (filter(identifier, pathBuilder, buffer)); // Inserted by this patch.
* if (IntegrationsClass.filter(identifier, pathBuilder)); // Inserted by this patch.
* return emptyComponent;
* ...
* }
* }
*
* class SomeOtherClass {
* // Called before ComponentContextParser.parseBytesToComponentContext method.
* public void someOtherMethod(ByteBuffer byteBuffer) {
* ComponentContextParser.buffer = byteBuffer; // Inserted by this patch.
* ...
* }
* }
*/
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
ComponentContextParserFingerprint.result?.also {
arrayOf(
EmptyComponentBuilderFingerprint,
ReadComponentIdentifierFingerprint
).forEach { fingerprint ->
if (fingerprint.resolve(context, it.mutableMethod, it.mutableClass)) return@forEach
return fingerprint.toErrorResult()
throw fingerprint.exception
}
}?.let { bytesToComponentContextMethod ->
// region Add a static field that holds a reference to the protobuf buffer object.
val protobufBufferField = ImmutableField(
bytesToComponentContextMethod.mutableClass.type,
"buffer",
"Ljava/nio/ByteBuffer;",
AccessFlags.PUBLIC or AccessFlags.STATIC,
null,
null,
null
).toMutable()
bytesToComponentContextMethod.mutableClass.staticFields.add(protobufBufferField)
// Set the field with the reference to the protobuf buffer object.
// region Pass the buffer into Integrations.
ProtobufBufferReferenceFingerprint.result
?.mutableMethod?.addInstruction(0, "sput-object p2, $protobufBufferField")
?: return ProtobufBufferReferenceFingerprint.toErrorResult()
?.mutableMethod?.addInstruction(0,
" invoke-static { p2 }, $INTEGRATIONS_CLASS_DESCRIPTOR->setProtoBuffer(Ljava/nio/ByteBuffer;)V")
?: throw ProtobufBufferReferenceFingerprint.exception
// endregion
@@ -135,17 +117,13 @@ class LithoFilterPatch : BytecodePatch(
// region Patch the method.
// Insert the instructions that are responsible
// to return an EmptyComponent instead of the original component if the filter method returns false.
// to return an EmptyComponent instead of the original component if the filter method returns true.
addInstructionsWithLabels(
insertHookIndex,
"""
# Register "free1" holds the protobuf buffer object
sget-object v$free1, $protobufBufferField
# Invoke the filter method.
invoke-static { v$stringBuilderRegister, v$identifierRegister, v$free1 }, $FILTER_METHOD_DESCRIPTOR
invoke-static { v$identifierRegister, v$stringBuilderRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->filter(Ljava/lang/String;Ljava/lang/StringBuilder;)Z
move-result v$free1
if-eqz v$free1, :unfiltered
@@ -163,7 +141,7 @@ class LithoFilterPatch : BytecodePatch(
}
// endregion
} ?: return ComponentContextParserFingerprint.toErrorResult()
} ?: throw ComponentContextParserFingerprint.exception
LithoFilterFingerprint.result?.mutableMethod?.apply {
removeInstructions(2, 4) // Remove dummy filter.
@@ -179,9 +157,7 @@ class LithoFilterPatch : BytecodePatch(
"""
)
}
} ?: return LithoFilterFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw LithoFilterFingerprint.exception
}
override fun close() = LithoFilterFingerprint.result!!
@@ -197,9 +173,7 @@ class LithoFilterPatch : BytecodePatch(
private val Instruction.descriptor
get() = (this as ReferenceInstruction).reference.toString()
private const val FILTER_METHOD_DESCRIPTOR =
"Lapp/revanced/integrations/patches/components/LithoFilterPatch;" +
"->filter(Ljava/lang/StringBuilder;Ljava/lang/String;Ljava/nio/ByteBuffer;)Z"
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/components/LithoFilterPatch;"
internal lateinit var addFilter: (String) -> Unit
private set
@@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.microg.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35", "18.29.38", "18.32.39"))])
@Target(AnnotationTarget.CLASS)
internal annotation class MicroGPatchCompatibility
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.microg.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
object GooglePlayUtilityFingerprint : MethodFingerprint(
returnType = "I",
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.microg.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
object ServiceCheckFingerprint : MethodFingerprint(
returnType = "V",
@@ -4,8 +4,6 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint
@@ -40,7 +38,7 @@ class MicroGBytecodePatch : BytecodePatch(
WatchWhileActivityFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// apply common microG patch
MicroGBytecodeHelper.patchBytecode(
context, arrayOf(
@@ -65,7 +63,5 @@ class MicroGBytecodePatch : BytecodePatch(
// inject the notice for MicroG
MicroGBytecodeHelper.injectNotice(WatchWhileActivityFingerprint)
return PatchResultSuccess()
}
}
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.misc.microg.patch.resource
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.settings.preference.impl.Preference
@@ -20,7 +18,7 @@ import app.revanced.util.microg.MicroGResourceHelper
@DependsOn([SettingsResourcePatch::class])
class MicroGResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.addPreference(
Preference(
StringResource("microg_settings", "MicroG Settings"),
@@ -47,7 +45,5 @@ class MicroGResourcePatch : ResourcePatch {
// add strings
MicroGResourceHelper.addStrings(context)
return PatchResultSuccess()
}
}
@@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.minimizedplayback.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35", "18.29.38", "18.32.39"))])
@Target(AnnotationTarget.CLASS)
internal annotation class MinimizedPlaybackCompatibility
@@ -2,24 +2,33 @@ package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction
object KidsMinimizedPlaybackPolicyControllerFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("I", "L", "L"),
parameters = listOf("I", "L", "L"),
opcodes = listOf(
Opcode.IF_EQZ,
Opcode.CONST_4,
Opcode.IF_NE,
Opcode.SGET_OBJECT,
Opcode.IF_NE,
Opcode.CONST_4,
Opcode.IPUT_BOOLEAN,
Opcode.IF_EQZ,
Opcode.IGET,
Opcode.INVOKE_STATIC
Opcode.CONST_4,
Opcode.IF_NE,
Opcode.IGET_OBJECT,
Opcode.SGET_OBJECT,
Opcode.IF_EQ,
Opcode.GOTO,
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_VOID
),
customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("MinimizedPlaybackPolicyController;")
methodDef.implementation!!.instructions.any {
((it as? NarrowLiteralInstruction)?.narrowLiteral == 5)
}
}
)
@@ -2,8 +2,8 @@ package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object MinimizedPlaybackManagerFingerprint : MethodFingerprint(
"Z",
@@ -2,8 +2,8 @@ package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object MinimizedPlaybackSettingsFingerprint : MethodFingerprint(
returnType = "Ljava/lang/String;",
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
/**
* Class fingerprint for [MinimizedPlaybackSettingsFingerprint]
@@ -1,16 +1,13 @@
package app.revanced.patches.youtube.misc.minimizedplayback.patch
import app.revanced.extensions.toErrorResult
import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@@ -24,8 +21,8 @@ import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.Minimize
import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackSettingsParentFingerprint
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@Patch
@Name("Minimized playback")
@@ -39,7 +36,7 @@ class MinimizedPlaybackPatch : BytecodePatch(
KidsMinimizedPlaybackPolicyControllerFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// TODO: remove this empty preference sometime after mid 2023
SettingsPatch.PreferenceScreen.MISC.addPreferences(
NonInteractivePreference(
@@ -57,10 +54,10 @@ class MinimizedPlaybackPatch : BytecodePatch(
return v0
"""
)
} ?: return MinimizedPlaybackManagerFingerprint.toErrorResult()
} ?: throw MinimizedPlaybackManagerFingerprint.exception
// Enable minimized playback option in YouTube settings
MinimizedPlaybackSettingsParentFingerprint.result ?: return MinimizedPlaybackSettingsParentFingerprint.toErrorResult()
MinimizedPlaybackSettingsParentFingerprint.result ?: throw MinimizedPlaybackSettingsParentFingerprint.exception
MinimizedPlaybackSettingsFingerprint.resolve(context, MinimizedPlaybackSettingsParentFingerprint.result!!.classDef)
MinimizedPlaybackSettingsFingerprint.result?.apply {
val booleanCalls = method.implementation!!.instructions.withIndex()
@@ -78,7 +75,7 @@ class MinimizedPlaybackPatch : BytecodePatch(
return v0
"""
)
} ?: return MinimizedPlaybackSettingsFingerprint.toErrorResult()
} ?: throw MinimizedPlaybackSettingsFingerprint.exception
// Force allowing background play for videos labeled for kids.
// Some regions and YouTube accounts do not require this patch.
@@ -87,9 +84,7 @@ class MinimizedPlaybackPatch : BytecodePatch(
0,
"return-void"
)
} ?: return KidsMinimizedPlaybackPolicyControllerFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw KidsMinimizedPlaybackPolicyControllerFingerprint.exception
}
private companion object {
@@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.playercontrols.annotation
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35", "18.29.38", "18.32.39"))])
@Target(AnnotationTarget.CLASS)
internal annotation class PlayerControlsCompatibility
@@ -1,32 +1,39 @@
package app.revanced.patches.youtube.misc.playercontrols.bytecode.patch
import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint
import app.revanced.patches.youtube.misc.playercontrols.annotation.PlayerControlsCompatibility
import app.revanced.patches.youtube.misc.playercontrols.fingerprints.BottomControlsInflateFingerprint
import app.revanced.patches.youtube.misc.playercontrols.fingerprints.PlayerControlsVisibilityFingerprint
import app.revanced.patches.youtube.misc.playercontrols.resource.patch.BottomControlsResourcePatch
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Name("Player controls bytecode patch")
@DependsOn([BottomControlsResourcePatch::class])
@Description("Manages the code for the player controls of the YouTube player.")
@PlayerControlsCompatibility
class PlayerControlsBytecodePatch : BytecodePatch(
listOf(PlayerControlsVisibilityFingerprint, BottomControlsInflateFingerprint)
listOf(
LayoutConstructorFingerprint,
BottomControlsInflateFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
LayoutConstructorFingerprint.result?.let {
if (!PlayerControlsVisibilityFingerprint.resolve(context, it.classDef))
throw LayoutConstructorFingerprint.exception
} ?: throw LayoutConstructorFingerprint.exception
showPlayerControlsFingerprintResult = PlayerControlsVisibilityFingerprint.result!!
inflateFingerprintResult = BottomControlsInflateFingerprint.result!!
return PatchResultSuccess()
}
internal companion object {
@@ -3,8 +3,8 @@ package app.revanced.patches.youtube.misc.playercontrols.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.util.patch.LiteralValueFingerprint
import app.revanced.patches.youtube.misc.playercontrols.resource.patch.BottomControlsResourcePatch
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object BottomControlsInflateFingerprint : LiteralValueFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL or AccessFlags.SYNTHETIC,
@@ -2,13 +2,10 @@ package app.revanced.patches.youtube.misc.playercontrols.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
object PlayerControlsVisibilityFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
returnType = "V",
parameters = listOf("Z", "Z"),
customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("YouTubeControlsOverlay;")
}
parameters = listOf("Z", "Z")
)
@@ -1,9 +1,7 @@
package app.revanced.patches.youtube.misc.playercontrols.resource.patch
import app.revanced.patcher.data.DomFileEditor
import app.revanced.patcher.util.DomFileEditor
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -11,14 +9,12 @@ import java.io.Closeable
@DependsOn([ResourceMappingPatch::class])
class BottomControlsResourcePatch : ResourcePatch, Closeable {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
resourceContext = context
targetXmlEditor = context.xmlEditor[TARGET_RESOURCE]
bottomUiContainerResourceId = ResourceMappingPatch.resourceMappings
.single { it.type == "id" && it.name == "bottom_ui_container_stub" }.id
return PatchResultSuccess()
}
companion object {
@@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.playeroverlay.annotation
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35", "18.29.38", "18.32.39"))])
@Target(AnnotationTarget.CLASS)
internal annotation class PlayerOverlaysHookCompatibility
@@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.playeroverlay.annotation.PlayerOverlaysHookCompatibility
@@ -21,13 +19,12 @@ class PlayerOverlaysHookPatch : BytecodePatch(
PlayerOverlaysOnFinishInflateFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// hook YouTubePlayerOverlaysLayout.onFinishInflate()
val method = PlayerOverlaysOnFinishInflateFingerprint.result!!.mutableMethod
method.addInstruction(
method.implementation!!.instructions.size - 2,
"invoke-static { p0 }, Lapp/revanced/integrations/patches/PlayerOverlaysHookPatch;->YouTubePlayerOverlaysLayout_onFinishInflateHook(Ljava/lang/Object;)V"
)
return PatchResultSuccess()
}
}
@@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.playertype.annotation
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))])
@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35", "18.29.38", "18.32.39"))])
@Target(AnnotationTarget.CLASS)
internal annotation class PlayerTypeHookCompatibility
@@ -2,34 +2,16 @@ package app.revanced.patches.youtube.misc.playertype.fingerprint
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object PlayerTypeFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
opcodes = listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.IGET_OBJECT,
Opcode.IF_NE,
Opcode.RETURN_VOID,
Opcode.IPUT_OBJECT,
Opcode.INVOKE_DIRECT,
Opcode.INVOKE_VIRTUAL,
Opcode.INVOKE_VIRTUAL,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.IF_EQZ,
Opcode.CONST_4,
Opcode.INVOKE_STATIC,
Opcode.RETURN_VOID,
Opcode.CONST_4,
Opcode.INVOKE_STATIC,
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_VOID
),
customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("YouTubePlayerOverlaysLayout;")
}
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/YouTubePlayerOverlaysLayout;") }
)
@@ -2,8 +2,8 @@ package app.revanced.patches.youtube.misc.playertype.fingerprint
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object VideoStateFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
@@ -17,8 +17,5 @@ object VideoStateFingerprint : MethodFingerprint(
Opcode.IF_EQZ,
Opcode.IF_EQZ,
Opcode.IGET_OBJECT, // obfuscated parameter field name
),
customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("YouTubeControlsOverlay;")
}
)
)
@@ -1,6 +1,6 @@
package app.revanced.patches.youtube.misc.playertype.patch
import app.revanced.extensions.toErrorResult
import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
@@ -8,37 +8,29 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
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.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.playertype.annotation.PlayerTypeHookCompatibility
import app.revanced.patches.youtube.misc.playertype.fingerprint.PlayerTypeFingerprint
import app.revanced.patches.youtube.misc.playertype.fingerprint.VideoStateFingerprint
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@Name("Player type hook")
@Description("Hook to get the current player type and video playback state.")
@PlayerTypeHookCompatibility
@DependsOn([IntegrationsPatch::class])
class PlayerTypeHookPatch : BytecodePatch(
listOf(PlayerTypeFingerprint, VideoStateFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
PlayerTypeFingerprint.result?.let {
it.mutableMethod.apply {
addInstruction(
0,
"invoke-static {p1}, $INTEGRATIONS_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V"
)
}
} ?: return PlayerTypeFingerprint.toErrorResult()
override fun execute(context: BytecodeContext) {
PlayerTypeFingerprint.result?.mutableMethod?.addInstruction(
0,
"invoke-static {p1}, $INTEGRATIONS_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V"
) ?: throw PlayerTypeFingerprint.exception
VideoStateFingerprint.result?.let {
it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex
val videoStateFieldName = getInstruction<ReferenceInstruction>(endIndex).reference
addInstructions(
0,
"""
@@ -47,9 +39,7 @@ class PlayerTypeHookPatch : BytecodePatch(
"""
)
}
} ?: return VideoStateFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw VideoStateFingerprint.exception
}
companion object {
@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.settings.bytecode.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
object LicenseActivityFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
@@ -3,8 +3,8 @@ package app.revanced.patches.youtube.misc.settings.bytecode.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.util.patch.LiteralValueFingerprint
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsResourcePatch
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object SetThemeFingerprint : LiteralValueFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
@@ -1,6 +1,6 @@
package app.revanced.patches.youtube.misc.settings.bytecode.patch
import app.revanced.extensions.toErrorResult
import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
@@ -9,8 +9,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.settings.preference.impl.Preference
import app.revanced.patches.shared.settings.util.AbstractPreferenceScreen
@@ -18,9 +16,9 @@ import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.LicenseActivityFingerprint
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.SetThemeFingerprint
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsResourcePatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.util.MethodUtil
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.util.MethodUtil
import java.io.Closeable
@DependsOn([IntegrationsPatch::class, SettingsResourcePatch::class])
@@ -29,7 +27,7 @@ import java.io.Closeable
class SettingsPatch : BytecodePatch(
listOf(LicenseActivityFingerprint, SetThemeFingerprint)
), Closeable {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// TODO: Remove this when it is only required at one place.
fun getSetThemeInstructionString(
registers: String = "v0",
@@ -57,7 +55,7 @@ class SettingsPatch : BytecodePatch(
addInstruction(returnIndex + 1, "return-object v0")
}
}
} ?: return SetThemeFingerprint.toErrorResult()
} ?: throw SetThemeFingerprint.exception
// Modify the license activity and remove all existing layout code.
@@ -88,8 +86,6 @@ class SettingsPatch : BytecodePatch(
}
}
return PatchResultSuccess()
}
internal companion object {
@@ -123,7 +119,7 @@ class SettingsPatch : BytecodePatch(
/**
* Preference screens patches should add their settings to.
*/
internal object PreferenceScreen : AbstractPreferenceScreen() {
object PreferenceScreen : AbstractPreferenceScreen() {
val ADS = Screen("ads", "Ads", "Ad related settings")
val INTERACTIONS = Screen("interactions", "Interaction", "Settings related to interactions")
val LAYOUT = Screen("layout", "Layout", "Settings related to the layout")
@@ -1,10 +1,8 @@
package app.revanced.patches.youtube.misc.settings.resource.patch
import app.revanced.patcher.data.DomFileEditor
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.DomFileEditor
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.shared.settings.preference.addPreference
import app.revanced.patches.shared.settings.preference.impl.*
@@ -21,7 +19,7 @@ class SettingsResourcePatch : AbstractSettingsResourcePatch(
"revanced_prefs",
"settings"
) {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
super.execute(context)
// Used for a fingerprint from SettingsPatch.
@@ -88,8 +86,6 @@ class SettingsResourcePatch : AbstractSettingsResourcePatch(
)
context.mergeStrings("settings/host/values/strings.xml")
return PatchResultSuccess()
}
@@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
@@ -25,7 +23,7 @@ import app.revanced.patches.youtube.misc.zoomhaptics.fingerprints.ZoomHapticsFin
class ZoomHapticsPatch : BytecodePatch(
listOf(ZoomHapticsFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
SwitchPreference(
"revanced_disable_zoom_haptics",
@@ -47,7 +45,5 @@ class ZoomHapticsPatch : BytecodePatch(
""",
ExternalLabel("vibrate", zoomHapticsFingerprintMethod.getInstruction(0))
)
return PatchResultSuccess()
}
}