chore: bump patcher version to 6.0.0

This commit is contained in:
Canny 2022-10-06 20:35:08 +03:00
parent 1211fc42a9
commit 9ead261da4
No known key found for this signature in database
GPG Key ID: 395CCB0AA979F27B
4 changed files with 9 additions and 27 deletions

View File

@ -119,7 +119,7 @@ dependencies {
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
// ReVanced
implementation("app.revanced:revanced-patcher:5.1.0")
implementation("app.revanced:revanced-patcher:6.0.0")
// Coil for network image
implementation("io.coil-kt:coil-compose:2.1.0")

View File

@ -5,7 +5,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import app.revanced.manager.ui.Resource
import app.revanced.patcher.data.Data
import app.revanced.patcher.data.Context
import app.revanced.patcher.patch.Patch
import java.util.*
@ -13,7 +13,7 @@ import java.util.*
object Variables {
val selectedAppPackage = mutableStateOf(Optional.empty<String>())
val selectedPatches = mutableStateListOf<String>()
val patches = mutableStateOf<Resource<List<Class<out Patch<Data>>>>>(Resource.Loading)
val patches = mutableStateOf<Resource<List<Class<out Patch<Context>>>>>(Resource.Loading)
val patchesState by patches
val filteredApps = mutableListOf<ApplicationInfo>()
}

View File

@ -26,12 +26,9 @@ import app.revanced.manager.ui.Resource
import app.revanced.manager.ui.viewmodel.Logging
import app.revanced.patcher.Patcher
import app.revanced.patcher.PatcherOptions
import app.revanced.patcher.data.Data
import app.revanced.patcher.extensions.PatchExtensions.dependencies
import app.revanced.patcher.extensions.PatchExtensions.patchName
import app.revanced.patcher.logging.Logger
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.impl.ResourcePatch
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.koin.core.component.KoinComponent
@ -123,7 +120,6 @@ class PatcherWorker(context: Context, parameters: WorkerParameters, private val
PatcherOptions(
inputFile,
cacheDirectory.absolutePath,
patchResources = checkForResourcePatch(patches),
aaptPath = aaptPath,
frameworkFolderLocation = frameworkPath,
logger = object : Logger {
@ -153,7 +149,7 @@ class PatcherWorker(context: Context, parameters: WorkerParameters, private val
Logging.log += "Merging integrations\n"
patcher.addFiles(listOf(integrations)) {}
patcher.applyPatches().forEach { (patch, result) ->
patcher.executePatches().forEach { (patch, result) ->
Logging.log += "Applying $patch\n"
if (result.isSuccess) {
Logging.log += "$patch has been applied successfully\n"
@ -190,24 +186,10 @@ class PatcherWorker(context: Context, parameters: WorkerParameters, private val
return false
}
private fun findPatchesByIds(ids: Iterable<String>): List<Class<out Patch<Data>>> {
private fun findPatchesByIds(ids: Iterable<String>): List<Class<out Patch<app.revanced.patcher.data.Context>>> {
val (patches) = patches.value as? Resource.Success ?: return listOf()
return patches.filter { patch -> ids.any { it == patch.patchName } }
}
private fun checkForResourcePatch(patches: List<Class<out Patch<Data>>>): Boolean {
patches.forEach { patch ->
patch.dependencies?.forEach {
if (ResourcePatch::class.java.isAssignableFrom(patch)) { // check for resource patches in normal patches
return true
}
if (ResourcePatch::class.java.isAssignableFrom(it.java)) { // do the same thing in dependency patches
return true
}
}
}
return false
}
private fun createWorkDir(): File {
return applicationContext.filesDir.resolve("tmp-${System.currentTimeMillis()}")
.also { it.mkdirs() }

View File

@ -11,12 +11,12 @@ import app.revanced.manager.Variables.selectedAppPackage
import app.revanced.manager.Variables.selectedPatches
import app.revanced.manager.api.API
import app.revanced.manager.ui.Resource
import app.revanced.patcher.data.Data
import app.revanced.patcher.data.Context
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
import app.revanced.patcher.extensions.PatchExtensions.options
import app.revanced.patcher.extensions.PatchExtensions.patchName
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.util.patch.impl.DexPatchBundle
import app.revanced.patcher.util.patch.PatchBundle
import dalvik.system.DexClassLoader
import kotlinx.coroutines.launch
import kotlinx.parcelize.Parcelize
@ -91,7 +91,7 @@ class PatcherScreenViewModel(private val app: Application, private val api: API)
}
private fun loadPatches0(path: String) {
val patchClasses = DexPatchBundle(
val patchClasses = PatchBundle.Dex(
path, DexClassLoader(
path,
app.codeCacheDir.absolutePath,
@ -130,7 +130,7 @@ class PatcherScreenViewModel(private val app: Application, private val api: API)
@Parcelize
data class PatchClass(
val patch: Class<out Patch<Data>>,
val patch: Class<out Patch<Context>>,
val unsupported: Boolean,
val hasPatchOptions: Boolean,
) : Parcelable