mirror of
https://github.com/revanced/revanced-patches
synced 2024-11-10 13:49:25 +01:00
fix(hdr-auto-brightness): increase patching compatibility across versions
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
136e1b7124
commit
f883e72dce
@ -2,30 +2,17 @@ package app.revanced.patches.youtube.misc.hdrbrightness.fingerprints
|
|||||||
|
|
||||||
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.fingerprint.method.annotation.FuzzyPatternScanMethod
|
|
||||||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
|
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import app.revanced.patches.youtube.misc.hdrbrightness.annotations.HDRBrightnessCompatibility
|
import app.revanced.patches.youtube.misc.hdrbrightness.annotations.HDRBrightnessCompatibility
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
|
|
||||||
@Name("hdr-brightness-fingerprint-xxz")
|
@Name("hdr-brightness-fingerprint")
|
||||||
@MatchingMethod(
|
@MatchingMethod(
|
||||||
"Lyjk;", "D"
|
"Lyls;", "c"
|
||||||
)
|
)
|
||||||
@FuzzyPatternScanMethod(3)
|
|
||||||
@HDRBrightnessCompatibility
|
@HDRBrightnessCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
object HDRBrightnessFingerprintYJK : MethodFingerprint(
|
object HDRBrightnessFingerprint : MethodFingerprint(
|
||||||
"V",
|
"V",
|
||||||
opcodes = listOf(
|
strings = listOf("c.SettingNotFound;", "screen_brightness", "android.mediaview", "lux"),
|
||||||
Opcode.SGET_OBJECT,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.IGET,
|
|
||||||
Opcode.IPUT,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.INVOKE_VIRTUAL
|
|
||||||
),
|
|
||||||
strings = listOf("c.SettingNotFound;", "screen_brightness", "android.mediaview"),
|
|
||||||
)
|
)
|
@ -1,43 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.misc.hdrbrightness.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
|
||||||
import app.revanced.patcher.annotation.Version
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
|
||||||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
import app.revanced.patches.youtube.misc.hdrbrightness.annotations.HDRBrightnessCompatibility
|
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
|
||||||
import org.jf.dexlib2.iface.reference.FieldReference
|
|
||||||
|
|
||||||
@Name("hdr-brightness-fingerprint-xxz")
|
|
||||||
@MatchingMethod(
|
|
||||||
"Lyel;", "G"
|
|
||||||
)
|
|
||||||
@FuzzyPatternScanMethod(3)
|
|
||||||
@HDRBrightnessCompatibility
|
|
||||||
@Version("0.0.1")
|
|
||||||
object HDRBrightnessFingerprintYEL : MethodFingerprint(
|
|
||||||
"V", AccessFlags.PUBLIC or AccessFlags.FINAL,
|
|
||||||
listOf("I", "I", "I", "I"),
|
|
||||||
listOf(
|
|
||||||
Opcode.SGET_OBJECT,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.IGET,
|
|
||||||
Opcode.IPUT,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.INVOKE_VIRTUAL
|
|
||||||
),
|
|
||||||
customFingerprint = { methodDef ->
|
|
||||||
methodDef.implementation!!.instructions.any {
|
|
||||||
((it as? ReferenceInstruction)?.reference as? FieldReference)?.let { field ->
|
|
||||||
// iput vx, vy, Landroid/view/WindowManager$LayoutParams;->screenBrightness:F
|
|
||||||
field.definingClass == "Landroid/view/WindowManager\$LayoutParams;" && field.name == "screenBrightness"
|
|
||||||
} == true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
@ -11,8 +11,7 @@ import app.revanced.patcher.patch.annotations.DependsOn
|
|||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patcher.patch.impl.BytecodePatch
|
import app.revanced.patcher.patch.impl.BytecodePatch
|
||||||
import app.revanced.patches.youtube.misc.hdrbrightness.annotations.HDRBrightnessCompatibility
|
import app.revanced.patches.youtube.misc.hdrbrightness.annotations.HDRBrightnessCompatibility
|
||||||
import app.revanced.patches.youtube.misc.hdrbrightness.fingerprints.HDRBrightnessFingerprintYEL
|
import app.revanced.patches.youtube.misc.hdrbrightness.fingerprints.HDRBrightnessFingerprint
|
||||||
import app.revanced.patches.youtube.misc.hdrbrightness.fingerprints.HDRBrightnessFingerprintYJK
|
|
||||||
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.youtube.misc.settings.framework.components.impl.StringResource
|
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||||
@ -28,10 +27,7 @@ import org.jf.dexlib2.iface.reference.FieldReference
|
|||||||
@Version("0.0.2")
|
@Version("0.0.2")
|
||||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
||||||
class HDRBrightnessPatch : BytecodePatch(
|
class HDRBrightnessPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(HDRBrightnessFingerprint)
|
||||||
HDRBrightnessFingerprintYEL,
|
|
||||||
HDRBrightnessFingerprintYJK
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
override fun execute(data: BytecodeData): PatchResult {
|
override fun execute(data: BytecodeData): PatchResult {
|
||||||
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
||||||
@ -44,32 +40,25 @@ class HDRBrightnessPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val result = try {
|
val method = HDRBrightnessFingerprint.result!!.mutableMethod
|
||||||
HDRBrightnessFingerprintYEL.result!!
|
|
||||||
} catch (e: Exception) {
|
|
||||||
HDRBrightnessFingerprintYJK.result!!
|
|
||||||
}
|
|
||||||
|
|
||||||
val method = result.mutableMethod
|
method.implementation!!.instructions.filter { instruction ->
|
||||||
|
val fieldReference = (instruction as? ReferenceInstruction)?.reference as? FieldReference
|
||||||
method.implementation!!.instructions.filter {
|
fieldReference?.let { it.name == "screenBrightness" } == true
|
||||||
((it as? ReferenceInstruction)?.reference as? FieldReference)?.let { field ->
|
|
||||||
// iput vx, vy, Landroid/view/WindowManager$LayoutParams;->screenBrightness:F
|
|
||||||
field.definingClass == "Landroid/view/WindowManager\$LayoutParams;" && field.name == "screenBrightness"
|
|
||||||
} == true
|
|
||||||
}.forEach { instruction ->
|
}.forEach { instruction ->
|
||||||
// inject right before the call that sets 'screenBrightness'
|
val brightnessRegisterIndex = method.implementation!!.instructions.indexOf(instruction)
|
||||||
val index = method.implementation!!.instructions.indexOf(instruction)
|
|
||||||
val register = (instruction as TwoRegisterInstruction).registerA
|
val register = (instruction as TwoRegisterInstruction).registerA
|
||||||
|
|
||||||
// inject the call to
|
val insertIndex = brightnessRegisterIndex + 1
|
||||||
method.addInstructions(
|
method.addInstructions(
|
||||||
index, """
|
insertIndex,
|
||||||
invoke-static {v$register}, Lapp/revanced/integrations/patches/HDRAutoBrightnessPatch;->getHDRBrightness(F)F
|
"""
|
||||||
move-result v$register
|
invoke-static {v$register}, Lapp/revanced/integrations/patches/HDRAutoBrightnessPatch;->getHDRBrightness(F)F
|
||||||
"""
|
move-result v$register
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user