build(Needs bump): Bump ReVanced Patcher (#2242)

Co-authored-by: aAbed <aabedhkhan@gmail.com>
This commit is contained in:
oSumAtrIX
2024-10-26 17:41:49 +02:00
committed by GitHub
parent 4db4789a06
commit 8d0d782ab5
20 changed files with 135 additions and 291 deletions

View File

@@ -9,14 +9,15 @@ import android.os.Handler
import android.os.Looper
import app.revanced.library.ApkUtils
import app.revanced.library.ApkUtils.applyTo
import app.revanced.library.installation.installer.LocalInstaller
import app.revanced.manager.flutter.utils.Aapt
import app.revanced.manager.flutter.utils.packageInstaller.InstallerReceiver
import app.revanced.manager.flutter.utils.packageInstaller.UninstallerReceiver
import app.revanced.patcher.PatchBundleLoader
import app.revanced.patcher.PatchSet
import app.revanced.patcher.Patcher
import app.revanced.patcher.PatcherConfig
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.loadPatchesFromDex
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
@@ -37,7 +38,7 @@ class MainActivity : FlutterActivity() {
private var cancel: Boolean = false
private var stopResult: MethodChannel.Result? = null
private lateinit var patches: PatchSet
private lateinit var patches: Set<Patch<*>>
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
@@ -70,7 +71,6 @@ class MainActivity : FlutterActivity() {
"runPatcher" -> {
val inFilePath = call.argument<String>("inFilePath")
val outFilePath = call.argument<String>("outFilePath")
val integrationsPath = call.argument<String>("integrationsPath")
val selectedPatches = call.argument<List<String>>("selectedPatches")
val options = call.argument<Map<String, Map<String, Any>>>("options")
val tmpDirPath = call.argument<String>("tmpDirPath")
@@ -80,7 +80,6 @@ class MainActivity : FlutterActivity() {
if (
inFilePath != null &&
outFilePath != null &&
integrationsPath != null &&
selectedPatches != null &&
options != null &&
tmpDirPath != null &&
@@ -92,14 +91,17 @@ class MainActivity : FlutterActivity() {
result,
inFilePath,
outFilePath,
integrationsPath,
selectedPatches,
options,
tmpDirPath,
keyStoreFilePath,
keystorePassword
)
} else result.notImplemented()
} else result.error(
"INVALID_ARGUMENTS",
"Invalid arguments",
"One or more arguments are missing"
)
}
"stopPatcher" -> {
@@ -113,14 +115,16 @@ class MainActivity : FlutterActivity() {
try {
val patchBundleFile = File(patchBundleFilePath)
patchBundleFile.setWritable(false)
patches = PatchBundleLoader.Dex(
patchBundleFile,
patches = loadPatchesFromDex(
setOf(patchBundleFile),
optimizedDexDirectory = codeCacheDir
)
} catch (ex: Exception) {
return@setMethodCallHandler result.notImplemented()
} catch (err: Error) {
return@setMethodCallHandler result.notImplemented()
} catch (t: Throwable) {
return@setMethodCallHandler result.error(
"PATCH_BUNDLE_ERROR",
"Failed to load patch bundle",
t.stackTraceToString()
)
}
JSONArray().apply {
@@ -130,13 +134,13 @@ class MainActivity : FlutterActivity() {
put("description", it.description)
put("excluded", !it.use)
put("compatiblePackages", JSONArray().apply {
it.compatiblePackages?.forEach { compatiblePackage ->
it.compatiblePackages?.forEach { (name, versions) ->
val compatiblePackageJson = JSONObject().apply {
put("name", compatiblePackage.name)
put("name", name)
put(
"versions",
JSONArray().apply {
compatiblePackage.versions?.forEach { version ->
versions?.forEach { version ->
put(version)
}
})
@@ -172,7 +176,7 @@ class MainActivity : FlutterActivity() {
}
})
} ?: put("values", null)
put("valueType", option.valueType)
put("type", option.type)
}.let(::put)
}
})
@@ -211,7 +215,6 @@ class MainActivity : FlutterActivity() {
result: MethodChannel.Result,
inFilePath: String,
outFilePath: String,
integrationsPath: String,
selectedPatches: List<String>,
options: Map<String, Map<String, Any>>,
tmpDirPath: String,
@@ -223,7 +226,6 @@ class MainActivity : FlutterActivity() {
inFile.setWritable(true)
inFile.setReadable(true)
val outFile = File(outFilePath)
val integrations = File(integrationsPath)
val keyStoreFile = File(keyStoreFilePath)
val tmpDir = File(tmpDirPath)
@@ -289,8 +291,8 @@ class MainActivity : FlutterActivity() {
updateProgress(0.02, "Loading patches...", "Loading patches")
val patches = patches.filter { patch ->
val isCompatible = patch.compatiblePackages?.any {
it.name == patcher.context.packageMetadata.packageName
val isCompatible = patch.compatiblePackages?.any { (name, _) ->
name == patcher.context.packageMetadata.packageName
} ?: false
val compatibleOrUniversal =
@@ -307,10 +309,7 @@ class MainActivity : FlutterActivity() {
updateProgress(0.05, "Executing...", "")
val patcherResult = patcher.use {
patcher.apply {
acceptIntegrations(setOf(integrations))
acceptPatches(patches)
}
it += patches
runBlocking {
// Update the progress bar every time a patch is executed from 0.15 to 0.7
@@ -318,7 +317,7 @@ class MainActivity : FlutterActivity() {
val progressStep = 0.55 / totalPatchesCount
var progress = 0.05
patcher.apply(false).collect(FlowCollector { patchResult: PatchResult ->
patcher().collect(FlowCollector { patchResult: PatchResult ->
if (cancel(patcher::close)) return@FlowCollector
val msg = patchResult.exception?.let {
@@ -346,10 +345,11 @@ class MainActivity : FlutterActivity() {
if (cancel(patcher::close)) return@Thread
ApkUtils.sign(
ApkUtils.signApk(
inFile,
outFile,
ApkUtils.SigningOptions(
"ReVanced",
ApkUtils.KeyStoreDetails(
keyStoreFile,
keystorePassword,
"alias",

View File

@@ -21,7 +21,8 @@ subprojects {
afterEvaluate {
extensions.findByName("android")?.let {
it as CommonExtension<*, *, *, *, *, *>
it.compileSdk = 34
if (it.compileSdk != null && it.compileSdk!! < 31)
it.compileSdk = 34
}
}

View File

@@ -1,6 +1,6 @@
[versions]
revanced-patcher = "19.3.1" # TODO: Update to non-dev
revanced-library = "2.2.1"
revanced-patcher = "20.0.2"
revanced-library = "3.0.1"
desugar_jdk_libs = "2.1.2"
[libraries]

View File

@@ -17,7 +17,7 @@ pluginManagement {
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.7.0" apply false
id("com.android.application") version "8.5.0" apply false
id("org.jetbrains.kotlin.android") version "2.0.20" apply false
}