mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-05-01 14:34:24 +02:00
fix: Retrieve app information from patched app
This commit is contained in:
parent
c4a795418f
commit
2b4b3ca0a5
@ -28,7 +28,7 @@ class PatcherAPI {
|
|||||||
List<Patch> _universalPatches = [];
|
List<Patch> _universalPatches = [];
|
||||||
List<String> _compatiblePackages = [];
|
List<String> _compatiblePackages = [];
|
||||||
Map filteredPatches = <String, List<Patch>>{};
|
Map filteredPatches = <String, List<Patch>>{};
|
||||||
File? _outFile;
|
File? outFile;
|
||||||
|
|
||||||
Future<void> initialize() async {
|
Future<void> initialize() async {
|
||||||
await _loadPatches();
|
await _loadPatches();
|
||||||
@ -162,7 +162,7 @@ class PatcherAPI {
|
|||||||
final Directory workDir = _tmpDir.createTempSync('tmp-');
|
final Directory workDir = _tmpDir.createTempSync('tmp-');
|
||||||
final File inputFile = File('${workDir.path}/base.apk');
|
final File inputFile = File('${workDir.path}/base.apk');
|
||||||
final File patchedFile = File('${workDir.path}/patched.apk');
|
final File patchedFile = File('${workDir.path}/patched.apk');
|
||||||
_outFile = File('${workDir.path}/out.apk');
|
outFile = File('${workDir.path}/out.apk');
|
||||||
final Directory cacheDir = Directory('${workDir.path}/cache');
|
final Directory cacheDir = Directory('${workDir.path}/cache');
|
||||||
cacheDir.createSync();
|
cacheDir.createSync();
|
||||||
final String originalFilePath = apkFilePath;
|
final String originalFilePath = apkFilePath;
|
||||||
@ -174,7 +174,7 @@ class PatcherAPI {
|
|||||||
'originalFilePath': originalFilePath,
|
'originalFilePath': originalFilePath,
|
||||||
'inputFilePath': inputFile.path,
|
'inputFilePath': inputFile.path,
|
||||||
'patchedFilePath': patchedFile.path,
|
'patchedFilePath': patchedFile.path,
|
||||||
'outFilePath': _outFile!.path,
|
'outFilePath': outFile!.path,
|
||||||
'integrationsPath': integrationsFile!.path,
|
'integrationsPath': integrationsFile!.path,
|
||||||
'selectedPatches': selectedPatches.map((p) => p.name).toList(),
|
'selectedPatches': selectedPatches.map((p) => p.name).toList(),
|
||||||
'cacheDirPath': cacheDir.path,
|
'cacheDirPath': cacheDir.path,
|
||||||
@ -201,7 +201,7 @@ class PatcherAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> installPatchedFile(PatchedApplication patchedApp) async {
|
Future<bool> installPatchedFile(PatchedApplication patchedApp) async {
|
||||||
if (_outFile != null) {
|
if (outFile != null) {
|
||||||
try {
|
try {
|
||||||
if (patchedApp.isRooted) {
|
if (patchedApp.isRooted) {
|
||||||
final bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
final bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
||||||
@ -209,11 +209,11 @@ class PatcherAPI {
|
|||||||
return _rootAPI.installApp(
|
return _rootAPI.installApp(
|
||||||
patchedApp.packageName,
|
patchedApp.packageName,
|
||||||
patchedApp.apkFilePath,
|
patchedApp.apkFilePath,
|
||||||
_outFile!.path,
|
outFile!.path,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final install = await InstallPlugin.installApk(_outFile!.path);
|
final install = await InstallPlugin.installApk(outFile!.path);
|
||||||
return install['isSuccess'];
|
return install['isSuccess'];
|
||||||
}
|
}
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
@ -228,11 +228,11 @@ class PatcherAPI {
|
|||||||
|
|
||||||
void exportPatchedFile(String appName, String version) {
|
void exportPatchedFile(String appName, String version) {
|
||||||
try {
|
try {
|
||||||
if (_outFile != null) {
|
if (outFile != null) {
|
||||||
final String newName = _getFileName(appName, version);
|
final String newName = _getFileName(appName, version);
|
||||||
CRFileSaver.saveFileWithDialog(
|
CRFileSaver.saveFileWithDialog(
|
||||||
SaveFileDialogParams(
|
SaveFileDialogParams(
|
||||||
sourceFilePath: _outFile!.path,
|
sourceFilePath: outFile!.path,
|
||||||
destinationFileName: newName,
|
destinationFileName: newName,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -246,12 +246,12 @@ class PatcherAPI {
|
|||||||
|
|
||||||
void sharePatchedFile(String appName, String version) {
|
void sharePatchedFile(String appName, String version) {
|
||||||
try {
|
try {
|
||||||
if (_outFile != null) {
|
if (outFile != null) {
|
||||||
final String newName = _getFileName(appName, version);
|
final String newName = _getFileName(appName, version);
|
||||||
final int lastSeparator = _outFile!.path.lastIndexOf('/');
|
final int lastSeparator = outFile!.path.lastIndexOf('/');
|
||||||
final String newPath =
|
final String newPath =
|
||||||
_outFile!.path.substring(0, lastSeparator + 1) + newName;
|
outFile!.path.substring(0, lastSeparator + 1) + newName;
|
||||||
final File shareFile = _outFile!.copySync(newPath);
|
final File shareFile = outFile!.copySync(newPath);
|
||||||
ShareExtend.share(shareFile.path, 'file');
|
ShareExtend.share(shareFile.path, 'file');
|
||||||
}
|
}
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
|
@ -285,7 +285,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
|
|
||||||
// In case a patch changed the app name or package name,
|
// In case a patch changed the app name or package name,
|
||||||
// update the app info.
|
// update the app info.
|
||||||
final app = await DeviceApps.getAppFromStorage(_app.apkFilePath);
|
final app = await DeviceApps.getAppFromStorage(_patcherAPI.outFile!.path);
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
_app.name = app.appName;
|
_app.name = app.appName;
|
||||||
_app.packageName = app.packageName;
|
_app.packageName = app.packageName;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user