feat(youtube/hide-shorts-button): bump compatibility to v17.45.36
This commit is contained in:
parent
ccab3b1e9e
commit
18ce2cb08a
|
@ -1,13 +1,13 @@
|
||||||
package app.revanced.patches.youtube.layout.pivotbar.shortsbutton.annotations
|
package app.revanced.patches.youtube.layout.pivotbar.annotations
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Compatibility
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
import app.revanced.patcher.annotation.Package
|
import app.revanced.patcher.annotation.Package
|
||||||
|
|
||||||
@Compatibility(
|
@Compatibility(
|
||||||
[Package(
|
[Package(
|
||||||
"com.google.android.youtube", arrayOf("17.36.37", "17.41.37", "17.42.35", "17.43.36")
|
"com.google.android.youtube", arrayOf("17.36.37", "17.41.37", "17.42.35", "17.43.36", "17.45.36")
|
||||||
)]
|
)]
|
||||||
)
|
)
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
internal annotation class ShortsButtonCompatibility
|
internal annotation class PivotBarCompatibility
|
|
@ -0,0 +1,15 @@
|
||||||
|
package app.revanced.patches.youtube.layout.pivotbar.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import app.revanced.patches.youtube.layout.pivotbar.resource.patch.ResolvePivotBarFingerprintsPatch
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||||
|
|
||||||
|
object InitializeButtonsFingerprint : MethodFingerprint(
|
||||||
|
customFingerprint = { methodDef ->
|
||||||
|
methodDef.implementation?.instructions?.any {
|
||||||
|
it.opcode == Opcode.CONST && (it as WideLiteralInstruction).wideLiteral ==
|
||||||
|
ResolvePivotBarFingerprintsPatch.imageOnlyTabResourceId
|
||||||
|
} == true
|
||||||
|
}
|
||||||
|
)
|
|
@ -0,0 +1,10 @@
|
||||||
|
package app.revanced.patches.youtube.layout.pivotbar.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
object PivotBarConstructorFingerprint : MethodFingerprint(
|
||||||
|
access = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||||
|
strings = listOf("com.google.android.apps.youtube.app.endpoint.flags")
|
||||||
|
)
|
|
@ -1,44 +0,0 @@
|
||||||
package app.revanced.patches.youtube.layout.pivotbar.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
|
|
||||||
@FuzzyPatternScanMethod(2)
|
|
||||||
object PivotBarFingerprint : MethodFingerprint(
|
|
||||||
"V",
|
|
||||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
|
||||||
listOf("Z"),
|
|
||||||
listOf(
|
|
||||||
Opcode.IGET,
|
|
||||||
Opcode.INVOKE_STATIC,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.IF_NEZ,
|
|
||||||
Opcode.SGET_OBJECT,
|
|
||||||
Opcode.INVOKE_INTERFACE,
|
|
||||||
Opcode.MOVE_RESULT,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.IF_NEZ,
|
|
||||||
Opcode.SGET_OBJECT,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.IF_NEZ,
|
|
||||||
Opcode.SGET_OBJECT,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.INVOKE_STATIC,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.NEW_INSTANCE,
|
|
||||||
Opcode.NEW_INSTANCE,
|
|
||||||
Opcode.INVOKE_DIRECT,
|
|
||||||
Opcode.CONST,
|
|
||||||
Opcode.INVOKE_STATIC,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.MOVE_OBJECT,
|
|
||||||
Opcode.MOVE_OBJECT,
|
|
||||||
Opcode.INVOKE_DIRECT_RANGE,
|
|
||||||
)
|
|
||||||
)
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package app.revanced.patches.youtube.layout.pivotbar.resource.patch
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Description
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
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.annotations.DependsOn
|
||||||
|
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
||||||
|
import app.revanced.patches.youtube.layout.pivotbar.annotations.PivotBarCompatibility
|
||||||
|
import app.revanced.patches.youtube.layout.pivotbar.fingerprints.InitializeButtonsFingerprint
|
||||||
|
import app.revanced.patches.youtube.layout.pivotbar.fingerprints.PivotBarConstructorFingerprint
|
||||||
|
import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.toErrorResult
|
||||||
|
|
||||||
|
@DependsOn([ResourceMappingPatch::class])
|
||||||
|
@PivotBarCompatibility
|
||||||
|
@Description("Resolves necessary fingerprints.")
|
||||||
|
@Version("0.0.1")
|
||||||
|
class ResolvePivotBarFingerprintsPatch : BytecodePatch(
|
||||||
|
listOf(PivotBarConstructorFingerprint)
|
||||||
|
) {
|
||||||
|
internal companion object {
|
||||||
|
var imageOnlyTabResourceId: Long = -1
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
// imageOnlyTabResourceId is used in InitializeButtonsFingerprint fingerprint
|
||||||
|
ResourceMappingPatch.resourceMappings.find { it.type == "layout" && it.name == "image_only_tab" }
|
||||||
|
?.let { imageOnlyTabResourceId = it.id } ?: return PatchResultError("Failed to find resource")
|
||||||
|
|
||||||
|
PivotBarConstructorFingerprint.result?.let {
|
||||||
|
// Resolve InitializeButtonsFingerprint on the class of the method
|
||||||
|
// which PivotBarConstructorFingerprint resolved to
|
||||||
|
if (!InitializeButtonsFingerprint.resolve(
|
||||||
|
context,
|
||||||
|
it.classDef
|
||||||
|
)
|
||||||
|
) return InitializeButtonsFingerprint.toErrorResult()
|
||||||
|
} ?: return PivotBarConstructorFingerprint.toErrorResult()
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,34 +4,36 @@ import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.MethodFingerprintExtensions.name
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultError
|
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patches.youtube.layout.pivotbar.fingerprints.PivotBarFingerprint
|
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||||
import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.annotations.ShortsButtonCompatibility
|
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||||
|
import app.revanced.patches.youtube.layout.pivotbar.annotations.PivotBarCompatibility
|
||||||
|
import app.revanced.patches.youtube.layout.pivotbar.fingerprints.InitializeButtonsFingerprint
|
||||||
|
import app.revanced.patches.youtube.layout.pivotbar.resource.patch.ResolvePivotBarFingerprintsPatch
|
||||||
import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.fingerprints.PivotBarEnumFingerprint
|
import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.fingerprints.PivotBarEnumFingerprint
|
||||||
import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.fingerprints.PivotBarShortsButtonViewFingerprint
|
import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.fingerprints.PivotBarShortsButtonViewFingerprint
|
||||||
import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
|
import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
|
||||||
import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.injectHook
|
import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.injectHook
|
||||||
|
import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.toErrorResult
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
|
||||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
@DependsOn([IntegrationsPatch::class, SettingsPatch::class, ResolvePivotBarFingerprintsPatch::class])
|
||||||
@Name("hide-shorts-button")
|
@Name("hide-shorts-button")
|
||||||
@Description("Hides the shorts button on the navigation bar.")
|
@Description("Hides the shorts button on the navigation bar.")
|
||||||
@ShortsButtonCompatibility
|
@PivotBarCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class ShortsButtonRemoverPatch : BytecodePatch(
|
class ShortsButtonRemoverPatch : BytecodePatch() {
|
||||||
listOf(PivotBarFingerprint)
|
private companion object {
|
||||||
) {
|
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/HideShortsButtonPatch;"
|
||||||
|
}
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||||
SwitchPreference(
|
SwitchPreference(
|
||||||
|
@ -47,18 +49,21 @@ class ShortsButtonRemoverPatch : BytecodePatch(
|
||||||
* Resolve fingerprints
|
* Resolve fingerprints
|
||||||
*/
|
*/
|
||||||
|
|
||||||
val pivotBarResult = PivotBarFingerprint.result ?: return PatchResultError("PivotBarFingerprint failed")
|
val initializeButtonsResult = InitializeButtonsFingerprint.result!!
|
||||||
val fingerprintResults = arrayOf(PivotBarEnumFingerprint, PivotBarShortsButtonViewFingerprint)
|
|
||||||
.onEach {
|
val fingerprintResults =
|
||||||
val resolutionSucceeded = it.resolve(
|
arrayOf(PivotBarEnumFingerprint, PivotBarShortsButtonViewFingerprint)
|
||||||
context,
|
.onEach {
|
||||||
pivotBarResult.mutableMethod,
|
if (!it.resolve(
|
||||||
pivotBarResult.mutableClass
|
context,
|
||||||
)
|
initializeButtonsResult.mutableMethod,
|
||||||
|
initializeButtonsResult.mutableClass
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return it.toErrorResult()
|
||||||
|
}
|
||||||
|
.map { it.result!!.scanResult.patternScanResult!! }
|
||||||
|
|
||||||
if (!resolutionSucceeded) return PatchResultError("${it.name} failed")
|
|
||||||
}
|
|
||||||
.map { it.result!!.scanResult.patternScanResult!! }
|
|
||||||
|
|
||||||
val enumScanResult = fingerprintResults[0]
|
val enumScanResult = fingerprintResults[0]
|
||||||
val buttonViewResult = fingerprintResults[1]
|
val buttonViewResult = fingerprintResults[1]
|
||||||
|
@ -70,19 +75,17 @@ class ShortsButtonRemoverPatch : BytecodePatch(
|
||||||
* Inject hooks
|
* Inject hooks
|
||||||
*/
|
*/
|
||||||
|
|
||||||
val integrationsClass = "Lapp/revanced/integrations/patches/HideShortsButtonPatch;"
|
val enumHook = "sput-object v$REGISTER_TEMPLATE_REPLACEMENT, " +
|
||||||
|
"$INTEGRATIONS_CLASS_DESCRIPTOR->lastPivotTab:Ljava/lang/Enum;"
|
||||||
val enumHook =
|
val buttonHook = "invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, " +
|
||||||
"sput-object v$REGISTER_TEMPLATE_REPLACEMENT, $integrationsClass->lastPivotTab:Ljava/lang/Enum;"
|
"$INTEGRATIONS_CLASS_DESCRIPTOR->hideShortsButton(Landroid/view/View;)V"
|
||||||
val buttonHook =
|
|
||||||
"invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $integrationsClass->hideShortsButton(Landroid/view/View;)V"
|
|
||||||
|
|
||||||
// Inject bottom to top to not mess up the indices
|
// Inject bottom to top to not mess up the indices
|
||||||
mapOf(
|
mapOf(
|
||||||
buttonHook to buttonHookInsertIndex,
|
buttonHook to buttonHookInsertIndex,
|
||||||
enumHook to enumHookInsertIndex
|
enumHook to enumHookInsertIndex
|
||||||
).forEach { (hook, insertIndex) ->
|
).forEach { (hook, insertIndex) ->
|
||||||
pivotBarResult.mutableMethod.injectHook(hook, insertIndex)
|
initializeButtonsResult.mutableMethod.injectHook(hook, insertIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package app.revanced.patches.youtube.layout.pivotbar.utils
|
package app.revanced.patches.youtube.layout.pivotbar.utils
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.MethodFingerprintExtensions.name
|
||||||
import app.revanced.patcher.extensions.addInstruction
|
import app.revanced.patcher.extensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.instruction
|
import app.revanced.patcher.extensions.instruction
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import app.revanced.patcher.patch.PatchResultError
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import org.jf.dexlib2.Opcode.MOVE_RESULT_OBJECT
|
import org.jf.dexlib2.Opcode.MOVE_RESULT_OBJECT
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
@ -27,4 +30,7 @@ internal object InjectionUtils {
|
||||||
hook.replace("REGISTER_INDEX", register.toString()),
|
hook.replace("REGISTER_INDEX", register.toString()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move this to a global extension class and use it in all patches
|
||||||
|
fun MethodFingerprint.toErrorResult() = PatchResultError("Failed to resolve $name")
|
||||||
}
|
}
|
Loading…
Reference in a new issue