diff --git a/android/app/build.gradle b/android/app/build.gradle
index ba45320a..ade5350c 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -44,11 +44,10 @@ android {
defaultConfig {
applicationId "app.revanced.manager"
- minSdkVersion flutter.minSdkVersion
+ minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
- multiDexEnabled true
}
buildTypes {
@@ -64,8 +63,11 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
- implementation "com.android.support:multidex:1.0.3"
// ReVanced
implementation "app.revanced:revanced-patcher:3.3.1"
+
+ // Signing & aligning
+ implementation("org.bouncycastle:bcpkix-jdk15on:1.70")
+ implementation("com.android.tools.build:apksig:7.2.1")
}
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index c50efe30..4ae965b5 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -4,6 +4,10 @@
+
+
+
+
+
+
+
+
diff --git a/android/app/src/main/jniLibs/arm64-v8a/aapt.so b/android/app/src/main/jniLibs/arm64-v8a/aapt.so
new file mode 100644
index 00000000..4014ef05
Binary files /dev/null and b/android/app/src/main/jniLibs/arm64-v8a/aapt.so differ
diff --git a/android/app/src/main/jniLibs/armeabi-v7a/to_be_removed.so b/android/app/src/main/jniLibs/armeabi-v7a/to_be_removed.so
new file mode 100644
index 00000000..797d416c
Binary files /dev/null and b/android/app/src/main/jniLibs/armeabi-v7a/to_be_removed.so differ
diff --git a/android/app/src/main/jniLibs/x86/aapt2.so b/android/app/src/main/jniLibs/x86/aapt2.so
new file mode 100644
index 00000000..097b817e
Binary files /dev/null and b/android/app/src/main/jniLibs/x86/aapt2.so differ
diff --git a/android/app/src/main/jniLibs/x86_64/to_be_removed.so b/android/app/src/main/jniLibs/x86_64/to_be_removed.so
new file mode 100644
index 00000000..b86c3970
Binary files /dev/null and b/android/app/src/main/jniLibs/x86_64/to_be_removed.so differ
diff --git a/android/app/src/main/kotlin/app/revanced/manager/MainActivity.kt b/android/app/src/main/kotlin/app/revanced/manager/MainActivity.kt
index 1ea8e03d..d8714fcf 100644
--- a/android/app/src/main/kotlin/app/revanced/manager/MainActivity.kt
+++ b/android/app/src/main/kotlin/app/revanced/manager/MainActivity.kt
@@ -1,6 +1,13 @@
package app.revanced.manager
import androidx.annotation.NonNull
+import app.revanced.manager.utils.Aapt
+import app.revanced.manager.utils.aligning.ZipAligner
+import app.revanced.manager.utils.signing.Signer
+import app.revanced.manager.utils.zip.ZipFile
+import app.revanced.manager.utils.zip.structures.ZipEntry
+import app.revanced.patcher.Patcher
+import app.revanced.patcher.PatcherOptions
import app.revanced.patcher.data.Data
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
import app.revanced.patcher.extensions.PatchExtensions.description
@@ -12,20 +19,26 @@ import dalvik.system.DexClassLoader
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
+import java.io.File
+import java.nio.file.Files
+import java.nio.file.StandardCopyOption
class MainActivity : FlutterActivity() {
- private val CHANNEL = "app.revanced/patcher"
+ private val CHANNEL = "app.revanced.manager/patcher"
private var patches = mutableListOf>>()
+ private val tag = "Patcher"
+ private lateinit var methodChannel: MethodChannel
+ private lateinit var patcher: Patcher
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
- MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result ->
+ methodChannel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
+ methodChannel.setMethodCallHandler { call, result ->
when (call.method) {
"loadPatches" -> {
val pathBundlesPaths = call.argument>("pathBundlesPaths")
if (pathBundlesPaths != null) {
- loadPatches(pathBundlesPaths)
- result.success("OK")
+ result.success(loadPatches(pathBundlesPaths))
} else {
result.notImplemented()
}
@@ -36,7 +49,61 @@ class MainActivity : FlutterActivity() {
val targetVersion = call.argument("targetVersion")
val ignoreVersion = call.argument("ignoreVersion")
if (targetPackage != null && targetVersion != null && ignoreVersion != null) {
- result.success(getFilteredPatches(targetPackage, targetVersion, ignoreVersion))
+ result.success(
+ getFilteredPatches(targetPackage, targetVersion, ignoreVersion)
+ )
+ } else {
+ result.notImplemented()
+ }
+ }
+ "copyInputFile" -> {
+ val originalFilePath = call.argument("originalFilePath")
+ val inputFilePath = call.argument("inputFilePath")
+ if (originalFilePath != null && inputFilePath != null) {
+ result.success(copyInputFile(originalFilePath, inputFilePath))
+ } else {
+ result.notImplemented()
+ }
+ }
+ "createPatcher" -> {
+ val inputFilePath = call.argument("inputFilePath")
+ val cacheDirPath = call.argument("cacheDirPath")
+ if (inputFilePath != null && cacheDirPath != null) {
+ result.success(createPatcher(inputFilePath, cacheDirPath))
+ } else {
+ result.notImplemented()
+ }
+ }
+ "mergeIntegrations" -> {
+ val integrationsPath = call.argument("integrationsPath")
+ if (integrationsPath != null) {
+ result.success(mergeIntegrations(integrationsPath))
+ } else {
+ result.notImplemented()
+ }
+ }
+ "applyPatches" -> {
+ val selectedPatches = call.argument>("selectedPatches")
+ if (selectedPatches != null) {
+ result.success(applyPatches(selectedPatches))
+ } else {
+ result.notImplemented()
+ }
+ }
+ "repackPatchedFile" -> {
+ val inputFilePath = call.argument("inputFilePath")
+ val patchedFilePath = call.argument("patchedFilePath")
+ if (inputFilePath != null && patchedFilePath != null) {
+ result.success(repackPatchedFile(inputFilePath, patchedFilePath))
+ } else {
+ result.notImplemented()
+ }
+ }
+ "signPatchedFile" -> {
+ val patchedFilePath = call.argument("patchedFilePath")
+ val outFilePath = call.argument("outFilePath")
+ if (patchedFilePath != null && outFilePath != null) {
+ result.success(signPatchedFile(patchedFilePath, outFilePath))
} else {
result.notImplemented()
}
@@ -46,42 +113,126 @@ class MainActivity : FlutterActivity() {
}
}
- fun loadPatches(pathBundlesPaths: List) {
- pathBundlesPaths.forEach { path ->
- patches.addAll(DexPatchBundle(
- path, DexClassLoader(
- path,
- context.cacheDir.path,
- null,
- javaClass.classLoader
+ fun loadPatches(pathBundlesPaths: List): Boolean {
+ try {
+ pathBundlesPaths.forEach { path ->
+ patches.addAll(
+ DexPatchBundle(
+ path,
+ DexClassLoader(
+ path,
+ context.cacheDir.path,
+ null,
+ javaClass.classLoader
+ )
+ )
+ .loadPatches()
)
- ).loadPatches())
+ }
+ } catch (e: Exception) {
+ return false
}
+ return true
}
fun getCompatiblePackages(): List {
val filteredPackages = mutableListOf()
patches.forEach patch@{ patch ->
- patch.compatiblePackages?.forEach { pkg ->
- filteredPackages.add(pkg.name)
- }
+ patch.compatiblePackages?.forEach { pkg -> filteredPackages.add(pkg.name) }
}
return filteredPackages.distinct()
}
- fun getFilteredPatches(targetPackage: String, targetVersion: String, ignoreVersion: Boolean): List