Skip to content

Commit

Permalink
feat: Restore previous release
Browse files Browse the repository at this point in the history
This reverts commit ed24a20.
  • Loading branch information
oSumAtrIX committed Aug 27, 2023
1 parent ab08bc9 commit f7352fe
Show file tree
Hide file tree
Showing 496 changed files with 2,429 additions and 2,555 deletions.
22 changes: 10 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ plugins {

group = "app.revanced"

val githubUsername: String = project.findProperty("gpr.user") as? String ?: System.getenv("GITHUB_ACTOR")
val githubPassword: String = project.findProperty("gpr.key") as? String ?: System.getenv("GITHUB_TOKEN")

repositories {
mavenCentral()
mavenLocal()
google()
maven {
url = uri("https://maven.pkg.github.com/revanced/revanced-patcher")
credentials {
username = githubUsername
password = githubPassword
username = project.findProperty("gpr.user") as? String ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") as? String ?: System.getenv("GITHUB_TOKEN")
}
}
// Required for FlexVer-Java
Expand All @@ -27,15 +25,15 @@ repositories {
}

dependencies {
implementation("app.revanced:revanced-patcher:11.0.4")
implementation("app.revanced:multidexlib2:2.5.3-a3836654")
// Required for meta
implementation("app.revanced:revanced-patcher:14.0.0")
implementation("com.android.tools.smali:smali:3.0.3")
// Required because build fails without it.
// TODO: Find a way to remove this dependency.
implementation("com.google.guava:guava:32.1.2-jre")
// Used in JsonGenerator.
implementation("com.google.code.gson:gson:2.10.1")
// Required for FlexVer-Java
implementation("com.unascribed:flexver-java:1.0.2")

// A dependency to the Android library unfortunately fails the build,
// which is why this is required for the patch change-oauth-client-id
// which is why this is required for the patch change-oauth-client-id.
compileOnly(project("dummy"))
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
58 changes: 41 additions & 17 deletions src/main/kotlin/app/revanced/extensions/Extensions.kt
Original file line number Diff line number Diff line change
@@ -1,53 +1,54 @@
package app.revanced.extensions

import app.revanced.patcher.extensions.MethodFingerprintExtensions.name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.MethodFingerprintExtensions.name
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.Method
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import org.jf.dexlib2.util.MethodUtil
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction
import com.android.tools.smali.dexlib2.util.MethodUtil
import org.w3c.dom.Node

// TODO: populate this to all patches
/**
* Convert a [MethodFingerprint] to a [PatchResultError].
* The [PatchException] of failing to resolve a [MethodFingerprint].
*
* @return A [PatchResultError] for the [MethodFingerprint].
* @return The [PatchException].
*/
internal fun MethodFingerprint.toErrorResult() = PatchResultError("Failed to resolve $name")
val MethodFingerprint.exception
get() = PatchException("Failed to resolve $name")

/**
* Find the [MutableMethod] from a given [Method] in a [MutableClass].
*
* @param method The [Method] to find.
* @return The [MutableMethod].
*/
internal fun MutableClass.findMutableMethodOf(method: Method) = this.methods.first {
fun MutableClass.findMutableMethodOf(method: Method) = this.methods.first {
MethodUtil.methodSignaturesMatch(it, method)
}

/**
* apply a transform to all methods of the class
* apply a transform to all methods of the class.
*
* @param transform the transformation function. original method goes in, transformed method goes out
* @param transform the transformation function. original method goes in, transformed method goes out.
*/
internal fun MutableClass.transformMethods(transform: MutableMethod.() -> MutableMethod) {
fun MutableClass.transformMethods(transform: MutableMethod.() -> MutableMethod) {
val transformedMethods = methods.map { it.transform() }
methods.clear()
methods.addAll(transformedMethods)
}

internal fun Node.doRecursively(action: (Node) -> Unit) {
fun Node.doRecursively(action: (Node) -> Unit) {
action(this)
for (i in 0 until this.childNodes.length) this.childNodes.item(i).doRecursively(action)
}

internal fun MutableMethod.injectHideViewCall(
fun MutableMethod.injectHideViewCall(
insertIndex: Int,
viewRegister: Int,
classDescriptor: String,
Expand All @@ -57,7 +58,13 @@ internal fun MutableMethod.injectHideViewCall(
"invoke-static { v$viewRegister }, $classDescriptor->$targetMethod(Landroid/view/View;)V"
)

internal fun Method.findIndexForIdResource(resourceName: String): Int {
/**
* Find the index of the first constant instruction with the id of the given resource name.
*
* @param resourceName the name of the resource to find the id for.
* @return the index of the first constant instruction with the id of the given resource name, or -1 if not found.
*/
fun Method.findIndexForIdResource(resourceName: String): Int {
fun getIdResourceId(resourceName: String) = ResourceMappingPatch.resourceMappings.single {
it.type == "id" && it.name == resourceName
}.id
Expand All @@ -66,6 +73,8 @@ internal fun Method.findIndexForIdResource(resourceName: String): Int {
}

/**
* Find the index of the first constant instruction with the given value.
*
* @return the first constant instruction with the value, or -1 if not found.
*/
fun Method.indexOfFirstConstantInstructionValue(constantValue: Long): Int {
Expand All @@ -77,8 +86,23 @@ fun Method.indexOfFirstConstantInstructionValue(constantValue: Long): Int {
}

/**
* Check if the method contains a constant with the given value.
*
* @return if the method contains a constant with the given value.
*/
fun Method.containsConstantInstructionValue(constantValue: Long): Boolean {
return indexOfFirstConstantInstructionValue(constantValue) >= 0
}

/**
* Traverse the class hierarchy starting from the given root class.
*
* @param targetClass the class to start traversing the class hierarchy from.
* @param callback function that is called for every class in the hierarchy.
*/
fun BytecodeContext.traverseClassHierarchy(targetClass: MutableClass, callback: MutableClass.() -> Unit) {
callback(targetClass)
this.findClass(targetClass.superclass ?: return)?.mutableClass?.let {
traverseClassHierarchy(it, callback)
}
}
3 changes: 0 additions & 3 deletions src/main/kotlin/app/revanced/meta/JsonGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import app.revanced.patcher.extensions.PatchExtensions.description
import app.revanced.patcher.extensions.PatchExtensions.include
import app.revanced.patcher.extensions.PatchExtensions.options
import app.revanced.patcher.extensions.PatchExtensions.patchName
import app.revanced.patcher.extensions.PatchExtensions.version
import app.revanced.patcher.patch.PatchOption
import com.google.gson.GsonBuilder
import java.io.File
Expand All @@ -17,7 +16,6 @@ internal class JsonGenerator : PatchesFileGenerator {
JsonPatch(
it.patchName,
it.description ?: "This patch has no description.",
it.version ?: "0.0.0",
!it.include,
it.options?.map { option ->
JsonPatch.Option(
Expand Down Expand Up @@ -48,7 +46,6 @@ internal class JsonGenerator : PatchesFileGenerator {
private class JsonPatch(
val name: String,
val description: String,
val version: String,
val excluded: Boolean,
val options: Array<Option>,
val dependencies: Array<String>,
Expand Down
19 changes: 8 additions & 11 deletions src/main/kotlin/app/revanced/meta/PatchesFileGenerator.kt
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
package app.revanced.meta

import app.revanced.patcher.data.Context
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.util.patch.PatchBundle
import app.revanced.patcher.PatchBundleLoader
import app.revanced.patcher.patch.PatchClass
import java.io.File

internal typealias PatchBundlePatches = List<Class<out Patch<Context>>>
internal typealias PatchBundlePatches = List<PatchClass>

internal interface PatchesFileGenerator {
fun generate(bundle: PatchBundlePatches)

private companion object {
@JvmStatic
fun main(args: Array<String>) = PatchBundle.Jar(
File("build/libs/").listFiles()!!.first {
it.name.startsWith("revanced-patches-") && it.name.endsWith(".jar")
}.absolutePath
).loadPatches().also {
if (it.isEmpty()) throw IllegalStateException("No patches found")
fun main(args: Array<String>) = PatchBundleLoader.Jar(
File("build/libs/").listFiles { it -> it.name.endsWith(".jar") }!!.first()
).also { loader ->
if (loader.isEmpty()) throw IllegalStateException("No patches found")
}.let { bundle ->
arrayOf(JsonGenerator()).forEach { it.generate(bundle) }
arrayOf(JsonGenerator()).forEach { generator -> generator.generate(bundle) }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package app.revanced.patches.all.activity.exportAll.patch
package app.revanced.patches.all.activity.exportall.patch

import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
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.patch.annotations.Patch

@Patch(false)
@Name("Export all activities")
@Description("Makes all app activities exportable.")
class ExportAllActivitiesPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
context.xmlEditor["AndroidManifest.xml"].use { editor ->
val document = editor.file
val activities = document.getElementsByTagName("activity")
Expand All @@ -33,8 +31,6 @@ class ExportAllActivitiesPatch : ResourcePatch {
}
}
}

return PatchResultSuccess()
}

private companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.annotations.RequiresIntegrations
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.util.patch.*
import org.jf.dexlib2.iface.ClassDef
import org.jf.dexlib2.iface.Method
import org.jf.dexlib2.iface.instruction.Instruction
import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
import java.util.*

@Patch(false)
@Name("Spoof wifi connection")
@Description("Spoofs an existing Wi-Fi connection.")
@RequiresIntegrations
internal class SpoofWifiPatch : AbstractTransformInstructionsPatch<Instruction35cInfo>() {
class SpoofWifiPatch : AbstractTransformInstructionsPatch<Instruction35cInfo>() {

private companion object {
const val INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX = "Lapp/revanced/all/connectivity/wifi/spoof/SpoofWifiPatch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ package app.revanced.patches.all.interaction.gestures.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
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.patch.annotations.Patch

@Patch(false)
@Name("Predictive back gesture")
@Description("Enables the predictive back gesture introduced on Android 13.")
class PredictiveBackGesturePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
context.xmlEditor["AndroidManifest.xml"].use { editor ->
val document = editor.file

Expand All @@ -25,8 +23,6 @@ class PredictiveBackGesturePatch : ResourcePatch {

}
}

return PatchResultSuccess()
}

private companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import org.w3c.dom.Element

@Patch(false)
@Name("Enable android debugging")
@Description("Enables Android debugging capabilities.")
@Description("Enables Android debugging capabilities. This can slow down the app.")
class EnableAndroidDebuggingPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
context.xmlEditor["AndroidManifest.xml"].use { dom ->
val applicationNode = dom
.file
Expand All @@ -21,8 +21,6 @@ class EnableAndroidDebuggingPatch : ResourcePatch {
// set application as debuggable
applicationNode.setAttribute("android:debuggable", "true")
}

return PatchResultSuccess()
}

}
Loading

0 comments on commit f7352fe

Please sign in to comment.