mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-13 04:57:37 +02:00
fix: no need to bundle assets on manager's side anymore
This commit is contained in:
@ -2,7 +2,6 @@ import 'dart:io';
|
||||
import 'package:app_installer/app_installer.dart';
|
||||
import 'package:device_apps/device_apps.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_archive/flutter_archive.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:revanced_manager/models/patch.dart';
|
||||
@ -22,7 +21,7 @@ class PatcherAPI {
|
||||
Directory? _tmpDir;
|
||||
Directory? _workDir;
|
||||
Directory? _cacheDir;
|
||||
File? _zipPatchBundleFile;
|
||||
File? _jarPatchBundleFile;
|
||||
File? _integrations;
|
||||
File? _inputFile;
|
||||
File? _patchedFile;
|
||||
@ -42,27 +41,23 @@ class PatcherAPI {
|
||||
if (_cacheDir == null) {
|
||||
await initPatcher();
|
||||
}
|
||||
if (_zipPatchBundleFile == null) {
|
||||
File? patchBundleDexFile = await _managerAPI.downloadPatches('.dex');
|
||||
File? patchBundleJarFile = await _managerAPI.downloadPatches('.jar');
|
||||
if (patchBundleDexFile != null && patchBundleJarFile != null) {
|
||||
await joinPatchBundleFiles(patchBundleDexFile, patchBundleJarFile);
|
||||
if (_zipPatchBundleFile != null) {
|
||||
await patcherChannel.invokeMethod<bool>(
|
||||
'loadPatches',
|
||||
{
|
||||
'zipPatchBundlePath': _zipPatchBundleFile!.path,
|
||||
'cacheDirPath': _cacheDir!.path,
|
||||
},
|
||||
);
|
||||
}
|
||||
if (_jarPatchBundleFile == null) {
|
||||
_jarPatchBundleFile = await _managerAPI.downloadPatches('.jar');
|
||||
if (_jarPatchBundleFile != null) {
|
||||
await patcherChannel.invokeMethod<bool>(
|
||||
'loadPatches',
|
||||
{
|
||||
'jarPatchBundlePath': _jarPatchBundleFile!.path,
|
||||
'cacheDirPath': _cacheDir!.path,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<ApplicationWithIcon>> getFilteredInstalledApps() async {
|
||||
List<ApplicationWithIcon> filteredPackages = [];
|
||||
if (_zipPatchBundleFile != null) {
|
||||
if (_jarPatchBundleFile != null) {
|
||||
try {
|
||||
List<String>? patchesPackages = await patcherChannel
|
||||
.invokeListMethod<String>('getCompatiblePackages');
|
||||
@ -90,7 +85,7 @@ class PatcherAPI {
|
||||
PatchedApplication? selectedApp,
|
||||
) async {
|
||||
List<Patch> filteredPatches = [];
|
||||
if (_zipPatchBundleFile != null && selectedApp != null) {
|
||||
if (_jarPatchBundleFile != null && selectedApp != null) {
|
||||
try {
|
||||
var patches =
|
||||
await patcherChannel.invokeListMethod<Map<dynamic, dynamic>>(
|
||||
@ -131,7 +126,7 @@ class PatcherAPI {
|
||||
PatchedApplication? selectedApp,
|
||||
) async {
|
||||
List<Patch> appliedPatches = [];
|
||||
if (_zipPatchBundleFile != null && selectedApp != null) {
|
||||
if (_jarPatchBundleFile != null && selectedApp != null) {
|
||||
try {
|
||||
var patches =
|
||||
await patcherChannel.invokeListMethod<Map<dynamic, dynamic>>(
|
||||
@ -248,26 +243,4 @@ class PatcherAPI {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user