feat(androidtwelvewidgets): unlock-paid-widgets patch (#1641)

This commit is contained in:
fe 2023-02-18 00:32:49 +00:00 committed by oSumAtrIX
parent fe64881c83
commit 44b74ae268
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
8 changed files with 94 additions and 0 deletions

View File

@ -0,0 +1,5 @@
package app.revanced.patches.twelvewidgets.unlock.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object AgendaDaysWidgetUnlockFingerprint : MethodUnlockFingerprint("AgendaDaysWidgetConfigureActivity")

View File

@ -0,0 +1,5 @@
package app.revanced.patches.twelvewidgets.unlock.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object CalendarBigWidgetUnlockFingerprint : MethodUnlockFingerprint("CalendarBigWidgetConfigureActivity")

View File

@ -0,0 +1,4 @@
package app.revanced.patches.twelvewidgets.unlock.fingerprints
object CalendarWideDayEventsWidgetUnlockFingerprint :
MethodUnlockFingerprint("CalendarWideDayEventsWidgetConfigureActivity")

View File

@ -0,0 +1,6 @@
package app.revanced.patches.twelvewidgets.unlock.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object CalendarWideTimelineWidgetUnlockFingerprint :
MethodUnlockFingerprint("CalendarWideTimelineWidgetConfigureActivity")

View File

@ -0,0 +1,12 @@
package app.revanced.patches.twelvewidgets.unlock.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
abstract class MethodUnlockFingerprint(private val className: String) : MethodFingerprint(
"L",
strings = listOf("binding.addButton"),
customFingerprint = { methodDef ->
methodDef.definingClass.endsWith("/$className;")
}
)

View File

@ -0,0 +1,5 @@
package app.revanced.patches.twelvewidgets.unlock.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object ScreentimeSmallWidgetUnlockFingerprint : MethodUnlockFingerprint("ScreentimeSmallWidgetConfigureActivity")

View File

@ -0,0 +1,3 @@
package app.revanced.patches.twelvewidgets.unlock.fingerprints
object WeatherWidgetUnlockFingerprint : MethodUnlockFingerprint("WeatherWidgetConfigureActivity")

View File

@ -0,0 +1,54 @@
package app.revanced.patches.twelvewidgets.unlock.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.*
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.removeInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.twelvewidgets.unlock.fingerprints.*
@Patch
@Name("unlock-paid-widgets")
@Description("Unlocks paid widgets of the app")
@Compatibility([Package("com.dci.dev.androidtwelvewidgets")])
@Version("0.0.1")
class UnlockPaidWidgetsPatch : BytecodePatch(
listOf(
AgendaDaysWidgetUnlockFingerprint,
CalendarBigWidgetUnlockFingerprint,
CalendarWideDayEventsWidgetUnlockFingerprint,
CalendarWideTimelineWidgetUnlockFingerprint,
ScreentimeSmallWidgetUnlockFingerprint,
WeatherWidgetUnlockFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
listOf(
AgendaDaysWidgetUnlockFingerprint,
CalendarBigWidgetUnlockFingerprint,
CalendarWideDayEventsWidgetUnlockFingerprint,
CalendarWideTimelineWidgetUnlockFingerprint,
ScreentimeSmallWidgetUnlockFingerprint,
WeatherWidgetUnlockFingerprint
).map { fingerprint ->
fingerprint.result?.mutableMethod ?: return fingerprint.toErrorResult()
}.forEach { method ->
method.apply {
removeInstructions(4, 2)
addInstructions(
implementation?.instructions?.size!!, """
const/4 v1, 0x0
invoke-virtual {v0, v1}, Landroid/view/View;->setVisibility(I)V
return-object v0
"""
)
}
}
return PatchResultSuccess()
}
}