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.PatchException
|
||||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
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.misc.ambientmode.fingerprints.PowerSaveModeFingerprint
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
import app.revanced.util.integrations.Constants.MISC_PATH
|
import app.revanced.util.integrations.Constants.MISC_PATH
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
@ -21,10 +19,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
|||||||
@Patch(
|
@Patch(
|
||||||
name = "Bypass ambient mode restrictions",
|
name = "Bypass ambient mode restrictions",
|
||||||
description = "Bypass ambient mode restrictions in battery saver mode.",
|
description = "Bypass ambient mode restrictions in battery saver mode.",
|
||||||
dependencies = [
|
dependencies = [SettingsPatch::class],
|
||||||
SettingsPatch::class,
|
|
||||||
SharedResourceIdPatch::class
|
|
||||||
],
|
|
||||||
compatiblePackages = [
|
compatiblePackages = [
|
||||||
CompatiblePackage(
|
CompatiblePackage(
|
||||||
"com.google.android.youtube",
|
"com.google.android.youtube",
|
||||||
@ -46,19 +41,11 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
|||||||
)
|
)
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object PowerSaveModePatch : BytecodePatch(
|
object PowerSaveModePatch : BytecodePatch(
|
||||||
setOf(
|
setOf(PowerSaveModeFingerprint)
|
||||||
PowerSaveModeAlternativeFingerprint,
|
|
||||||
PowerSaveModeFingerprint
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
val result =
|
PowerSaveModeFingerprint.result?.let {
|
||||||
PowerSaveModeFingerprint.result
|
|
||||||
?: PowerSaveModeAlternativeFingerprint.result
|
|
||||||
?: throw PowerSaveModeFingerprint.exception
|
|
||||||
|
|
||||||
result.let {
|
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
var insertIndex = -1
|
var insertIndex = -1
|
||||||
|
|
||||||
@ -82,7 +69,7 @@ object PowerSaveModePatch : BytecodePatch(
|
|||||||
if (insertIndex == -1)
|
if (insertIndex == -1)
|
||||||
throw PatchException("Couldn't find PowerManager reference")
|
throw PatchException("Couldn't find PowerManager reference")
|
||||||
}
|
}
|
||||||
}
|
} ?: throw PowerSaveModeFingerprint.exception
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add settings
|
* 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.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
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.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
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(
|
object PowerSaveModeFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
parameters = listOf("Ljava/lang/Object;"),
|
parameters = listOf("Ljava/lang/Object;"),
|
||||||
opcodes = listOf(
|
customFingerprint = custom@{ methodDef, _ ->
|
||||||
Opcode.IF_GT,
|
if (methodDef.name != "accept")
|
||||||
Opcode.IGET,
|
return@custom false
|
||||||
Opcode.ADD_INT_2ADDR
|
|
||||||
),
|
val instructions = methodDef.implementation?.instructions!!
|
||||||
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(YtBrandBackgroundSolid) && methodDef.name == "accept" }
|
|
||||||
|
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 VideoZoomIndicatorLayout: Long = -1
|
||||||
var WordMarkHeader: Long = -1
|
var WordMarkHeader: Long = -1
|
||||||
var YoutubeControlsOverlay: Long = -1
|
var YoutubeControlsOverlay: Long = -1
|
||||||
var YtBrandBackgroundSolid: Long = -1
|
|
||||||
var YtOutlineArrowTimeBlack: Long = -1
|
var YtOutlineArrowTimeBlack: Long = -1
|
||||||
var YtOutlineFireBlack: Long = -1
|
var YtOutlineFireBlack: Long = -1
|
||||||
var YtOutlineSearchBlack: Long = -1
|
var YtOutlineSearchBlack: Long = -1
|
||||||
@ -163,7 +162,6 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
VideoZoomIndicatorLayout = find(ID, "video_zoom_indicator_layout")
|
VideoZoomIndicatorLayout = find(ID, "video_zoom_indicator_layout")
|
||||||
WordMarkHeader = find(ATTR, "ytWordmarkHeader")
|
WordMarkHeader = find(ATTR, "ytWordmarkHeader")
|
||||||
YoutubeControlsOverlay = find(ID, "youtube_controls_overlay")
|
YoutubeControlsOverlay = find(ID, "youtube_controls_overlay")
|
||||||
YtBrandBackgroundSolid = find(ATTR, "ytBrandBackgroundSolid")
|
|
||||||
YtOutlineArrowTimeBlack = find(DRAWABLE, "yt_outline_arrow_time_black_24")
|
YtOutlineArrowTimeBlack = find(DRAWABLE, "yt_outline_arrow_time_black_24")
|
||||||
YtOutlineFireBlack = find(DRAWABLE, "yt_outline_fire_black_24")
|
YtOutlineFireBlack = find(DRAWABLE, "yt_outline_fire_black_24")
|
||||||
YtOutlineSearchBlack = find(DRAWABLE, "yt_outline_search_black_24")
|
YtOutlineSearchBlack = find(DRAWABLE, "yt_outline_search_black_24")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user