feat(YouTube): Support version 19.10, 19.11 and 19.12`

This commit is contained in:
LisoUseInAIKyrios 2024-04-01 16:48:46 +04:00
parent c98cb5eec8
commit beb933d8fc
7 changed files with 26 additions and 15 deletions

View File

@ -1819,6 +1819,7 @@ public final class app/revanced/util/BytecodeUtilsKt {
public static final fun containsWideLiteralInstructionValue (Lcom/android/tools/smali/dexlib2/iface/Method;J)Z
public static final fun findIndexForIdResource (Lcom/android/tools/smali/dexlib2/iface/Method;Ljava/lang/String;)I
public static final fun findMutableMethodOf (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;Lcom/android/tools/smali/dexlib2/iface/Method;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
public static final fun firstIndexForIdResource (Lcom/android/tools/smali/dexlib2/iface/Method;Ljava/lang/String;)I
public static final fun getException (Lapp/revanced/patcher/fingerprint/MethodFingerprint;)Lapp/revanced/patcher/patch/PatchException;
public static final fun indexOfFirstInstruction (Lcom/android/tools/smali/dexlib2/iface/Method;Lkotlin/jvm/functions/Function1;)I
public static final fun indexOfFirstWideLiteralInstructionValue (Lcom/android/tools/smali/dexlib2/iface/Method;J)I

View File

@ -14,7 +14,7 @@ import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch
import app.revanced.patches.youtube.shared.fingerprints.LayoutConstructorFingerprint
import app.revanced.util.exception
import app.revanced.util.findIndexForIdResource
import app.revanced.util.firstIndexForIdResource
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
@ -69,7 +69,7 @@ object HideAutoplayButtonPatch : BytecodePatch(
val layoutGenMethodInstructions = implementation!!.instructions
// resolve the offsets of where to insert the branch instructions and ...
val insertIndex = findIndexForIdResource("autonav_preview_stub")
val insertIndex = firstIndexForIdResource("autonav_preview_stub")
// where to branch away
val branchIndex =

View File

@ -16,6 +16,7 @@ import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch
import app.revanced.patches.youtube.misc.navigation.NavigationBarHookPatch
import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch
import app.revanced.util.firstIndexForIdResource
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.TwoRegisterInstruction
@ -159,7 +160,7 @@ object HideShortsComponentsPatch : BytecodePatch(
SHARE("reel_dyn_share", "hideShortsShareButton");
fun injectHideCall(method: MutableMethod) {
val referencedIndex = method.findIndexForIdResource(resourceName)
val referencedIndex = method.firstIndexForIdResource(resourceName)
val setIdIndex = referencedIndex + 1
val viewRegister = method.getInstruction<FiveRegisterInstruction>(setIdIndex).registerC

View File

@ -52,9 +52,8 @@ object HideShortsComponentsResourcePatch : ResourcePatch() {
reelMultipleItemShelfId = it.id
}
reelPlayerRightCellButtonHeight =
ResourceMappingPatch.resourceMappings.single {
it.type == "dimen" && it.name == "reel_player_right_cell_button_height"
}.id
reelPlayerRightCellButtonHeight = ResourceMappingPatch.resourceMappings.first {
it.type == "dimen" && it.name == "reel_player_right_cell_button_height"
}.id
}
}

View File

@ -1,13 +1,10 @@
package app.revanced.patches.youtube.layout.hide.shorts.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.layout.hide.shorts.HideShortsComponentsResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
internal object CreateShortsButtonsFingerprint : LiteralValueFingerprint(
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
// YT 19.12.x moved this code inside another method, and each method has different parameters.
returnType = "V",
parameters = listOf("Z", "Z", "L"),
literalSupplier = { HideShortsComponentsResourcePatch.reelPlayerRightCellButtonHeight }
)

View File

@ -12,7 +12,7 @@ internal object MiniPlayerDimensionsCalculatorParentFingerprint : MethodFingerpr
opcodes = listOf(
Opcode.CONST_HIGH16,
Opcode.ADD_FLOAT_2ADDR,
Opcode.MUL_FLOAT,
null, // Opcode.MUL_FLOAT or Opcode.MUL_FLOAT_2ADDR
Opcode.CONST_4,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT,

View File

@ -70,13 +70,26 @@ fun MutableMethod.injectHideViewCall(
*
* @param resourceName the name of the resource to find the id for.
* @return the index of the first instruction with the id of the given resource name, or -1 if not found.
* @see [firstIndexForIdResource]
*/
fun Method.findIndexForIdResource(resourceName: String): Int {
fun getIdResourceId(resourceName: String) = ResourceMappingPatch.resourceMappings.single {
val resource = ResourceMappingPatch.resourceMappings.find {
it.type == "id" && it.name == resourceName
}.id
} ?: throw PatchException("Could not find resource id: $resourceName")
return indexOfFirstWideLiteralInstructionValue(getIdResourceId(resourceName))
return indexOfFirstWideLiteralInstructionValue(resource.id)
}
/**
* Identical to [findIndexForIdResource], except this throws an exception if the method does not contain
* the resource id literal value.
*
* @throws [PatchException] if the resource is not found, or the method does not contain the resource id literal value.
*/
fun Method.firstIndexForIdResource(resourceName: String): Int {
val index = findIndexForIdResource(resourceName);
if (index < 0) throw PatchException("Found resource id for: '$resourceName' but method does not contain the id: $this")
return index;
}
/**