feat: Restore previous release

This reverts commit ed24a201a9.
This commit is contained in:
oSumAtrIX
2023-08-27 21:40:49 +02:00
parent ab08bc92d9
commit f7352feb6e
496 changed files with 2425 additions and 2551 deletions

View File

@ -0,0 +1,12 @@
package app.revanced.patches.shared.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
object LayoutConstructorFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = emptyList(),
strings = listOf("1.0x")
)

View File

@ -2,7 +2,7 @@ package app.revanced.patches.shared.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.AccessFlags
object WatchWhileActivityFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,

View File

@ -5,13 +5,11 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint.RegisterResolver
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.ClassDef
import org.jf.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method
@Description("Applies mandatory patches to implement the ReVanced integrations into the application.")
abstract class AbstractIntegrationsPatch(
@ -40,7 +38,7 @@ abstract class AbstractIntegrationsPatch(
strings,
customFingerprint
) {
fun invoke(integrationsDescriptor: String): PatchResult {
fun invoke(integrationsDescriptor: String) {
result?.mutableMethod?.let { method ->
val contextRegister = contextRegisterResolver(method)
@ -49,9 +47,7 @@ abstract class AbstractIntegrationsPatch(
"sput-object v$contextRegister, " +
"$integrationsDescriptor->context:Landroid/content/Context;"
)
} ?: return PatchResultError("Could not find hook target fingerprint.")
return PatchResultSuccess()
} ?: throw PatchException("Could not find hook target fingerprint.")
}
interface RegisterResolver : (Method) -> Int {
@ -59,20 +55,11 @@ abstract class AbstractIntegrationsPatch(
}
}
override fun execute(context: BytecodeContext): PatchResult {
if (context.findClass(integrationsDescriptor) == null) return MISSING_INTEGRATIONS
for (hook in hooks) hook.invoke(integrationsDescriptor).let {
if (it is PatchResultError) return it
}
return PatchResultSuccess()
}
private companion object {
val MISSING_INTEGRATIONS = PatchResultError(
"Integrations have not been merged yet. " +
"This patch can not succeed without merging the integrations."
override fun execute(context: BytecodeContext) {
if (context.findClass(integrationsDescriptor) == null) throw PatchException(
"Integrations have not been merged yet. This patch can not succeed without merging the integrations."
)
for (hook in hooks) hook.invoke(integrationsDescriptor)
}
}

View File

@ -1,8 +1,6 @@
package app.revanced.patches.shared.mapping.misc.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import org.w3c.dom.Element
import java.util.*
@ -19,7 +17,7 @@ class ResourceMappingPatch : ResourcePatch {
private val threadPoolExecutor = Executors.newFixedThreadPool(THREAD_COUNT)
}
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
// save the file in memory to concurrently read from
val resourceXmlFile = context["res/values/public.xml"].readBytes()
@ -59,8 +57,6 @@ class ResourceMappingPatch : ResourcePatch {
.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS)
resourceMappings = mappings
return PatchResultSuccess()
}
}

View File

@ -3,8 +3,8 @@ package app.revanced.patches.shared.misc.fix.verticalscroll.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object CanScrollVerticallyFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,

View File

@ -1,23 +1,21 @@
package app.revanced.patches.shared.misc.fix.verticalscroll.patch
import app.revanced.extensions.toErrorResult
import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.shared.misc.fix.verticalscroll.annotations.VerticalScrollCompatibility
import app.revanced.patches.shared.misc.fix.verticalscroll.fingerprints.CanScrollVerticallyFingerprint
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Description("Fixes issues with refreshing the feed when the first component is of type EmptyComponent.")
@VerticalScrollCompatibility
class VerticalScrollPatch : BytecodePatch(
listOf(CanScrollVerticallyFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
CanScrollVerticallyFingerprint.result?.let {
it.mutableMethod.apply {
val moveResultIndex = it.scanResult.patternScanResult!!.endIndex
@ -29,8 +27,6 @@ class VerticalScrollPatch : BytecodePatch(
"const/4 v$moveResultRegister, 0x0"
)
}
} ?: return CanScrollVerticallyFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw CanScrollVerticallyFingerprint.exception
}
}

View File

@ -12,7 +12,7 @@ import org.w3c.dom.Element
* @param tag The tag of the preference.
* @param summary The summary of the preference.
*/
internal abstract class BasePreference(
abstract class BasePreference(
val key: String?,
val title: StringResource,
val summary: StringResource? = null,

View File

@ -9,7 +9,7 @@ import org.w3c.dom.Element
* @param name The name of the resource.
* @param tag The tag of the resource.
*/
internal abstract class BaseResource(
abstract class BaseResource(
val name: String,
val tag: String
) {

View File

@ -12,7 +12,7 @@ import org.w3c.dom.Document
* @param summary The summary of the preference.
* @param default The default value of the preference.
*/
internal abstract class DefaultBasePreference<T>(
abstract class DefaultBasePreference<T>(
key: String?,
title: StringResource,
summary: StringResource? = null,

View File

@ -10,7 +10,7 @@ import org.w3c.dom.Document
* @param name The name of the array resource.
* @param items The items of the array resource.
*/
internal class ArrayResource(
class ArrayResource(
name: String,
val items: List<StringResource>
) : BaseResource(name, "string-array") {

View File

@ -15,7 +15,7 @@ import org.w3c.dom.Document
* @param summary The summary of the list preference.
* @param default The default entry value of the list preference.
*/
internal class ListPreference(
class ListPreference(
key: String,
title: StringResource,
val entries: ArrayResource,

View File

@ -15,7 +15,7 @@ import org.w3c.dom.Element
* @param title The title of the preference.
* @param summary The summary of the text preference.
*/
internal class NonInteractivePreference(
class NonInteractivePreference(
title: StringResource,
summary: StringResource,
) : BasePreference(null, title, summary, "Preference") {

View File

@ -12,7 +12,7 @@ import org.w3c.dom.Document
* @param summary The summary of the text preference.
* @param intent The intent of the preference.
*/
internal class Preference(
class Preference(
key: String,
title: StringResource,
summary: StringResource,
@ -33,7 +33,7 @@ internal class Preference(
})
}
internal class Intent(
class Intent(
internal val targetPackage: String,
internal val data: String,
internal val targetClass: String

View File

@ -11,7 +11,7 @@ import org.w3c.dom.Document
* @param title The title of the preference.
* @param preferences Child preferences of this category.
*/
internal open class PreferenceCategory(
open class PreferenceCategory(
key: String,
title: StringResource,
var preferences: List<BasePreference>,

View File

@ -13,7 +13,7 @@ import org.w3c.dom.Document
* @param preferences Child preferences of this screen.
* @param summary The summary of the text preference.
*/
internal open class PreferenceScreen(
open class PreferenceScreen(
key: String,
title: StringResource,
var preferences: List<BasePreference>,

View File

@ -11,7 +11,7 @@ import org.w3c.dom.Document
* @param value The value of the string.
* @param formatted If the string is formatted. If false, the attribute will be set.
*/
internal class StringResource(
class StringResource(
name: String,
val value: String,
val formatted: Boolean = true

View File

@ -18,7 +18,7 @@ import org.w3c.dom.Element
* @param userDialogMessage The message to show in a dialog when the user toggles the preference.
* @param default The default value of the switch.
*/
internal class SwitchPreference(
class SwitchPreference(
key: String, title: StringResource,
val summaryOn: StringResource,
val summaryOff: StringResource,

View File

@ -13,7 +13,7 @@ import org.w3c.dom.Document
* @param summary The summary of the text preference.
* @param default The default value of the text preference.
*/
internal class TextPreference(
class TextPreference(
key: String?,
title: StringResource,
summary: StringResource?,

View File

@ -1,10 +1,8 @@
package app.revanced.patches.shared.settings.resource.patch
import app.revanced.patcher.data.DomFileEditor
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.util.DomFileEditor
import app.revanced.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.BaseResource
import app.revanced.patches.shared.settings.preference.addPreference
@ -26,7 +24,7 @@ abstract class AbstractSettingsResourcePatch(
private val preferenceFileName: String,
private val sourceDirectory: String,
) : ResourcePatch, Closeable {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
/*
* used for self-restart
* TODO: do this only, when necessary
@ -51,8 +49,6 @@ abstract class AbstractSettingsResourcePatch(
stringsEditor = context.xmlEditor["res/values/strings.xml"]
arraysEditor = context.xmlEditor["res/values/arrays.xml"]
revancedPreferencesEditor = context.xmlEditor["res/xml/$preferenceFileName.xml"]
return PatchResultSuccess()
}
internal companion object {

View File

@ -6,7 +6,7 @@ import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
import app.revanced.patches.shared.settings.preference.impl.StringResource
import java.io.Closeable
internal abstract class AbstractPreferenceScreen(
abstract class AbstractPreferenceScreen(
private val root: MutableList<Screen> = mutableListOf()
) : Closeable {