-
-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
838 additions
and
800 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
org.gradle.parallel = true | ||
org.gradle.caching = true | ||
kotlin.code.style = official | ||
version = 13.0.0 | ||
version = 14.0.0-dev.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package app.revanced.patcher | ||
|
||
import java.io.File | ||
|
||
@FunctionalInterface | ||
interface IntegrationsConsumer { | ||
fun acceptIntegrations(integrations: List<File>) | ||
} |
7 changes: 3 additions & 4 deletions
7
.../revanced/patcher/data/PackageMetadata.kt → ...n/app/revanced/patcher/PackageMetadata.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
package app.revanced.patcher.data | ||
package app.revanced.patcher | ||
|
||
import brut.androlib.apk.ApkInfo | ||
|
||
/** | ||
* Metadata about a package. | ||
*/ | ||
class PackageMetadata { | ||
class PackageMetadata internal constructor(internal val apkInfo: ApkInfo) { | ||
lateinit var packageName: String | ||
internal set | ||
|
||
lateinit var packageVersion: String | ||
internal set | ||
|
||
internal lateinit var apkInfo: ApkInfo | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
@file:Suppress("unused") | ||
|
||
package app.revanced.patcher | ||
|
||
import app.revanced.patcher.extensions.AnnotationExtensions.findAnnotationRecursively | ||
import app.revanced.patcher.patch.Patch | ||
import app.revanced.patcher.patch.PatchClass | ||
import dalvik.system.DexClassLoader | ||
import lanchon.multidexlib2.BasicDexFileNamer | ||
import lanchon.multidexlib2.MultiDexIO | ||
import java.io.File | ||
import java.net.URLClassLoader | ||
import java.util.jar.JarFile | ||
|
||
/** | ||
* A patch bundle. | ||
* | ||
* @param fromClasses The classes to get [Patch]es from. | ||
*/ | ||
sealed class PatchBundleLoader private constructor( | ||
fromClasses: Iterable<Class<*>> | ||
) : MutableList<PatchClass> by mutableListOf() { | ||
init { | ||
fromClasses.filter { | ||
if (it.isAnnotation) return@filter false | ||
|
||
it.findAnnotationRecursively(app.revanced.patcher.patch.annotations.Patch::class) != null | ||
}.map { | ||
@Suppress("UNCHECKED_CAST") | ||
it as PatchClass | ||
}.let { addAll(it) } | ||
} | ||
|
||
/** | ||
* A [PatchBundleLoader] for JAR files. | ||
* | ||
* @param patchBundles The path to patch bundles of JAR format. | ||
*/ | ||
class Jar(vararg patchBundles: File) : | ||
PatchBundleLoader(with(URLClassLoader(patchBundles.map { it.toURI().toURL() }.toTypedArray())) { | ||
patchBundles.flatMap { patchBundle -> | ||
// Get the names of all classes in the DEX file. | ||
|
||
JarFile(patchBundle).entries().asSequence() | ||
.filter { it.name.endsWith(".class") } | ||
.map { it.name.replace('/', '.').replace(".class", "") } | ||
.map { loadClass(it) } | ||
} | ||
}) | ||
|
||
/** | ||
* A [PatchBundleLoader] for [Dex] files. | ||
* | ||
* @param patchBundles The path to patch bundles of DEX format. | ||
*/ | ||
class Dex(vararg patchBundles: File) : PatchBundleLoader(with( | ||
DexClassLoader( | ||
patchBundles.joinToString(File.pathSeparator) { it.absolutePath }, | ||
null, | ||
null, | ||
PatchBundleLoader::class.java.classLoader | ||
) | ||
) { | ||
patchBundles | ||
.flatMap { | ||
MultiDexIO.readDexFile(true, it, BasicDexFileNamer(), null, null).classes | ||
} | ||
.map { classDef -> classDef.type.substring(1, classDef.length - 1) } | ||
.map { loadClass(it) } | ||
}) | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/app/revanced/patcher/PatchExecutorFunction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package app.revanced.patcher | ||
|
||
import app.revanced.patcher.patch.PatchResult | ||
import kotlinx.coroutines.flow.Flow | ||
import java.util.function.Function | ||
|
||
@FunctionalInterface | ||
interface PatchExecutorFunction : Function<Boolean, Flow<PatchResult>> |
Oops, something went wrong.