mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
fix: no need to bundle assets on manager's side anymore
This commit is contained in:
parent
81107970d1
commit
2abe051483
@ -41,10 +41,10 @@ class MainActivity : FlutterActivity() {
|
|||||||
mainChannel.setMethodCallHandler { call, result ->
|
mainChannel.setMethodCallHandler { call, result ->
|
||||||
when (call.method) {
|
when (call.method) {
|
||||||
"loadPatches" -> {
|
"loadPatches" -> {
|
||||||
val zipPatchBundlePath = call.argument<String>("zipPatchBundlePath")
|
val jarPatchBundlePath = call.argument<String>("jarPatchBundlePath")
|
||||||
val cacheDirPath = call.argument<String>("cacheDirPath")
|
val cacheDirPath = call.argument<String>("cacheDirPath")
|
||||||
if (zipPatchBundlePath != null && cacheDirPath != null) {
|
if (jarPatchBundlePath != null && cacheDirPath != null) {
|
||||||
loadPatches(result, zipPatchBundlePath, cacheDirPath)
|
loadPatches(result, jarPatchBundlePath, cacheDirPath)
|
||||||
} else {
|
} else {
|
||||||
result.notImplemented()
|
result.notImplemented()
|
||||||
}
|
}
|
||||||
@ -103,16 +103,16 @@ class MainActivity : FlutterActivity() {
|
|||||||
|
|
||||||
fun loadPatches(
|
fun loadPatches(
|
||||||
result: MethodChannel.Result,
|
result: MethodChannel.Result,
|
||||||
zipPatchBundlePath: String,
|
jarPatchBundlePath: String,
|
||||||
cacheDirPath: String
|
cacheDirPath: String
|
||||||
) {
|
) {
|
||||||
Thread(
|
Thread(
|
||||||
Runnable {
|
Runnable {
|
||||||
patches.addAll(
|
patches.addAll(
|
||||||
DexPatchBundle(
|
DexPatchBundle(
|
||||||
zipPatchBundlePath,
|
jarPatchBundlePath,
|
||||||
DexClassLoader(
|
DexClassLoader(
|
||||||
zipPatchBundlePath,
|
jarPatchBundlePath,
|
||||||
cacheDirPath,
|
cacheDirPath,
|
||||||
null,
|
null,
|
||||||
javaClass.classLoader
|
javaClass.classLoader
|
||||||
|
@ -2,7 +2,6 @@ import 'dart:io';
|
|||||||
import 'package:app_installer/app_installer.dart';
|
import 'package:app_installer/app_installer.dart';
|
||||||
import 'package:device_apps/device_apps.dart';
|
import 'package:device_apps/device_apps.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_archive/flutter_archive.dart';
|
|
||||||
import 'package:injectable/injectable.dart';
|
import 'package:injectable/injectable.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:revanced_manager/models/patch.dart';
|
import 'package:revanced_manager/models/patch.dart';
|
||||||
@ -22,7 +21,7 @@ class PatcherAPI {
|
|||||||
Directory? _tmpDir;
|
Directory? _tmpDir;
|
||||||
Directory? _workDir;
|
Directory? _workDir;
|
||||||
Directory? _cacheDir;
|
Directory? _cacheDir;
|
||||||
File? _zipPatchBundleFile;
|
File? _jarPatchBundleFile;
|
||||||
File? _integrations;
|
File? _integrations;
|
||||||
File? _inputFile;
|
File? _inputFile;
|
||||||
File? _patchedFile;
|
File? _patchedFile;
|
||||||
@ -42,27 +41,23 @@ class PatcherAPI {
|
|||||||
if (_cacheDir == null) {
|
if (_cacheDir == null) {
|
||||||
await initPatcher();
|
await initPatcher();
|
||||||
}
|
}
|
||||||
if (_zipPatchBundleFile == null) {
|
if (_jarPatchBundleFile == null) {
|
||||||
File? patchBundleDexFile = await _managerAPI.downloadPatches('.dex');
|
_jarPatchBundleFile = await _managerAPI.downloadPatches('.jar');
|
||||||
File? patchBundleJarFile = await _managerAPI.downloadPatches('.jar');
|
if (_jarPatchBundleFile != null) {
|
||||||
if (patchBundleDexFile != null && patchBundleJarFile != null) {
|
await patcherChannel.invokeMethod<bool>(
|
||||||
await joinPatchBundleFiles(patchBundleDexFile, patchBundleJarFile);
|
'loadPatches',
|
||||||
if (_zipPatchBundleFile != null) {
|
{
|
||||||
await patcherChannel.invokeMethod<bool>(
|
'jarPatchBundlePath': _jarPatchBundleFile!.path,
|
||||||
'loadPatches',
|
'cacheDirPath': _cacheDir!.path,
|
||||||
{
|
},
|
||||||
'zipPatchBundlePath': _zipPatchBundleFile!.path,
|
);
|
||||||
'cacheDirPath': _cacheDir!.path,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<ApplicationWithIcon>> getFilteredInstalledApps() async {
|
Future<List<ApplicationWithIcon>> getFilteredInstalledApps() async {
|
||||||
List<ApplicationWithIcon> filteredPackages = [];
|
List<ApplicationWithIcon> filteredPackages = [];
|
||||||
if (_zipPatchBundleFile != null) {
|
if (_jarPatchBundleFile != null) {
|
||||||
try {
|
try {
|
||||||
List<String>? patchesPackages = await patcherChannel
|
List<String>? patchesPackages = await patcherChannel
|
||||||
.invokeListMethod<String>('getCompatiblePackages');
|
.invokeListMethod<String>('getCompatiblePackages');
|
||||||
@ -90,7 +85,7 @@ class PatcherAPI {
|
|||||||
PatchedApplication? selectedApp,
|
PatchedApplication? selectedApp,
|
||||||
) async {
|
) async {
|
||||||
List<Patch> filteredPatches = [];
|
List<Patch> filteredPatches = [];
|
||||||
if (_zipPatchBundleFile != null && selectedApp != null) {
|
if (_jarPatchBundleFile != null && selectedApp != null) {
|
||||||
try {
|
try {
|
||||||
var patches =
|
var patches =
|
||||||
await patcherChannel.invokeListMethod<Map<dynamic, dynamic>>(
|
await patcherChannel.invokeListMethod<Map<dynamic, dynamic>>(
|
||||||
@ -131,7 +126,7 @@ class PatcherAPI {
|
|||||||
PatchedApplication? selectedApp,
|
PatchedApplication? selectedApp,
|
||||||
) async {
|
) async {
|
||||||
List<Patch> appliedPatches = [];
|
List<Patch> appliedPatches = [];
|
||||||
if (_zipPatchBundleFile != null && selectedApp != null) {
|
if (_jarPatchBundleFile != null && selectedApp != null) {
|
||||||
try {
|
try {
|
||||||
var patches =
|
var patches =
|
||||||
await patcherChannel.invokeListMethod<Map<dynamic, dynamic>>(
|
await patcherChannel.invokeListMethod<Map<dynamic, dynamic>>(
|
||||||
@ -248,26 +243,4 @@ class PatcherAPI {
|
|||||||
await _rootAPI.deleteApp(patchedApp.packageName, patchedApp.apkFilePath);
|
await _rootAPI.deleteApp(patchedApp.packageName, patchedApp.apkFilePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> joinPatchBundleFiles(
|
|
||||||
File patchBundleDexFile,
|
|
||||||
File patchBundleJarFile,
|
|
||||||
) async {
|
|
||||||
_zipPatchBundleFile = File('${_workDir!.path}/join.zip');
|
|
||||||
Directory joinDir = Directory('${_cacheDir!.path}/join');
|
|
||||||
try {
|
|
||||||
await ZipFile.extractToDirectory(
|
|
||||||
zipFile: patchBundleJarFile,
|
|
||||||
destinationDir: joinDir,
|
|
||||||
);
|
|
||||||
patchBundleDexFile.copySync('${joinDir.path}/classes.dex');
|
|
||||||
await ZipFile.createFromDirectory(
|
|
||||||
sourceDir: joinDir,
|
|
||||||
zipFile: _zipPatchBundleFile!,
|
|
||||||
recurseSubDirs: true,
|
|
||||||
);
|
|
||||||
} on Exception {
|
|
||||||
_zipPatchBundleFile = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ dependencies:
|
|||||||
file_picker: ^5.0.1
|
file_picker: ^5.0.1
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_archive: ^5.0.0
|
|
||||||
flutter_background: ^1.1.0
|
flutter_background: ^1.1.0
|
||||||
flutter_cache_manager: ^3.3.0
|
flutter_cache_manager: ^3.3.0
|
||||||
flutter_i18n: ^0.32.4
|
flutter_i18n: ^0.32.4
|
||||||
|
Loading…
Reference in New Issue
Block a user