mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-06 17:44:36 +02:00
fix(YouTube/Bypass ambient mode restrictions): apply fingerprint compatible with wider version
This commit is contained in:
parent
64758d5178
commit
df8af2838d
@ -8,9 +8,7 @@ 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.patches.youtube.misc.ambientmode.fingerprints.PowerSaveModeAlternativeFingerprint
|
||||
import app.revanced.patches.youtube.misc.ambientmode.fingerprints.PowerSaveModeFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.MISC_PATH
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -21,10 +19,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
@Patch(
|
||||
name = "Bypass ambient mode restrictions",
|
||||
description = "Bypass ambient mode restrictions in battery saver mode.",
|
||||
dependencies = [
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
],
|
||||
dependencies = [SettingsPatch::class],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
"com.google.android.youtube",
|
||||
@ -46,19 +41,11 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
)
|
||||
@Suppress("unused")
|
||||
object PowerSaveModePatch : BytecodePatch(
|
||||
setOf(
|
||||
PowerSaveModeAlternativeFingerprint,
|
||||
PowerSaveModeFingerprint
|
||||
)
|
||||
setOf(PowerSaveModeFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
val result =
|
||||
PowerSaveModeFingerprint.result
|
||||
?: PowerSaveModeAlternativeFingerprint.result
|
||||
?: throw PowerSaveModeFingerprint.exception
|
||||
|
||||
result.let {
|
||||
PowerSaveModeFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
var insertIndex = -1
|
||||
|
||||
@ -82,7 +69,7 @@ object PowerSaveModePatch : BytecodePatch(
|
||||
if (insertIndex == -1)
|
||||
throw PatchException("Couldn't find PowerManager reference")
|
||||
}
|
||||
}
|
||||
} ?: throw PowerSaveModeFingerprint.exception
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
|
@ -1,23 +0,0 @@
|
||||
package app.revanced.patches.youtube.misc.ambientmode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.util.bytecode.isNarrowLiteralExists
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object PowerSaveModeAlternativeFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Ljava/lang/Object;"),
|
||||
opcodes = listOf(
|
||||
Opcode.IF_GT,
|
||||
Opcode.IGET,
|
||||
Opcode.ADD_INT_2ADDR
|
||||
),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.isNarrowLiteralExists(107243) && methodDef.isNarrowLiteralExists(
|
||||
140796
|
||||
) && methodDef.name == "accept"
|
||||
}
|
||||
)
|
@ -2,19 +2,38 @@ package app.revanced.patches.youtube.misc.ambientmode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.YtBrandBackgroundSolid
|
||||
import app.revanced.util.bytecode.isWideLiteralExists
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
object PowerSaveModeFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Ljava/lang/Object;"),
|
||||
opcodes = listOf(
|
||||
Opcode.IF_GT,
|
||||
Opcode.IGET,
|
||||
Opcode.ADD_INT_2ADDR
|
||||
),
|
||||
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(YtBrandBackgroundSolid) && methodDef.name == "accept" }
|
||||
customFingerprint = custom@{ methodDef, _ ->
|
||||
if (methodDef.name != "accept")
|
||||
return@custom false
|
||||
|
||||
val instructions = methodDef.implementation?.instructions!!
|
||||
|
||||
if (instructions.count() < 20)
|
||||
return@custom false
|
||||
|
||||
var count = 0;
|
||||
for (instruction in instructions) {
|
||||
if (instruction.opcode != Opcode.INVOKE_VIRTUAL)
|
||||
continue
|
||||
|
||||
val invokeInstruction = instruction as Instruction35c
|
||||
if ((invokeInstruction.reference as MethodReference).name != "isPowerSaveMode")
|
||||
continue
|
||||
|
||||
count++
|
||||
}
|
||||
if (count < 2)
|
||||
return@custom false
|
||||
|
||||
count == 2
|
||||
}
|
||||
)
|
@ -82,7 +82,6 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
var VideoZoomIndicatorLayout: Long = -1
|
||||
var WordMarkHeader: Long = -1
|
||||
var YoutubeControlsOverlay: Long = -1
|
||||
var YtBrandBackgroundSolid: Long = -1
|
||||
var YtOutlineArrowTimeBlack: Long = -1
|
||||
var YtOutlineFireBlack: Long = -1
|
||||
var YtOutlineSearchBlack: Long = -1
|
||||
@ -163,7 +162,6 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
VideoZoomIndicatorLayout = find(ID, "video_zoom_indicator_layout")
|
||||
WordMarkHeader = find(ATTR, "ytWordmarkHeader")
|
||||
YoutubeControlsOverlay = find(ID, "youtube_controls_overlay")
|
||||
YtBrandBackgroundSolid = find(ATTR, "ytBrandBackgroundSolid")
|
||||
YtOutlineArrowTimeBlack = find(DRAWABLE, "yt_outline_arrow_time_black_24")
|
||||
YtOutlineFireBlack = find(DRAWABLE, "yt_outline_fire_black_24")
|
||||
YtOutlineSearchBlack = find(DRAWABLE, "yt_outline_search_black_24")
|
||||
|
Loading…
x
Reference in New Issue
Block a user