build: Bump dependencies

This commit is contained in:
oSumAtrIX 2023-09-26 05:14:27 +02:00
parent 5838550188
commit 62505f2543
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
8 changed files with 51 additions and 127 deletions

View file

@ -85,7 +85,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// ReVanced // ReVanced
implementation "app.revanced:revanced-patcher:14.2.2" implementation "app.revanced:revanced-patcher:15.0.2"
// Signing & aligning // Signing & aligning
implementation("org.bouncycastle:bcpkix-jdk15on:1.70") implementation("org.bouncycastle:bcpkix-jdk15on:1.70")

View file

@ -10,20 +10,18 @@ import app.revanced.manager.flutter.utils.zip.structures.ZipEntry
import app.revanced.patcher.PatchBundleLoader import app.revanced.patcher.PatchBundleLoader
import app.revanced.patcher.Patcher import app.revanced.patcher.Patcher
import app.revanced.patcher.PatcherOptions import app.revanced.patcher.PatcherOptions
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
import app.revanced.patcher.extensions.PatchExtensions.dependencies
import app.revanced.patcher.extensions.PatchExtensions.description
import app.revanced.patcher.extensions.PatchExtensions.include
import app.revanced.patcher.extensions.PatchExtensions.patchName
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResult
import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel
import kotlinx.coroutines.cancel import kotlinx.coroutines.cancel
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import org.json.JSONArray
import org.json.JSONObject
import java.io.File import java.io.File
import java.io.PrintWriter import java.io.PrintWriter
import java.io.StringWriter import java.io.StringWriter
import java.lang.Error
import java.util.logging.LogRecord import java.util.logging.LogRecord
import java.util.logging.Logger import java.util.logging.Logger
@ -93,29 +91,43 @@ class MainActivity : FlutterActivity() {
} }
"getPatches" -> { "getPatches" -> {
val patchBundleFilePath = call.argument<String>("patchBundleFilePath") val patchBundleFilePath = call.argument<String>("patchBundleFilePath")!!
val cacheDirPath = call.argument<String>("cacheDirPath") val cacheDirPath = call.argument<String>("cacheDirPath")!!
if (patchBundleFilePath != null) {
val patches = PatchBundleLoader.Dex( JSONArray().apply {
File(patchBundleFilePath), try {
optimizedDexDirectory = File(cacheDirPath) PatchBundleLoader.Dex(
).map { patch -> File(patchBundleFilePath),
val map = HashMap<String, Any>() optimizedDexDirectory = File(cacheDirPath)
map["\"name\""] = "\"${patch.patchName.replace("\"","\\\"")}\"" )
map["\"description\""] = "\"${patch.description?.replace("\"","\\\"")}\"" } catch (ex: Exception) {
map["\"excluded\""] = !patch.include return@setMethodCallHandler result.notImplemented()
map["\"dependencies\""] = patch.dependencies?.map { "\"${it.java.patchName}\"" } ?: emptyList<Any>() } catch (err: Error) {
map["\"compatiblePackages\""] = patch.compatiblePackages?.map { return@setMethodCallHandler result.notImplemented()
val map2 = HashMap<String, Any>() }.forEach {
map2["\"name\""] = "\"${it.name}\"" JSONObject().apply {
map2["\"versions\""] = it.versions.map { version -> "\"${version}\"" } put("name", it.name)
map2 put("description", it.description)
} ?: emptyList<Any>() put("excluded", !it.use)
map put("compatiblePackages", JSONArray().apply {
it.compatiblePackages?.forEach { compatiblePackage ->
val compatiblePackageJson = JSONObject().apply {
put("name", compatiblePackage.name)
put(
"versions",
JSONArray().apply {
compatiblePackage.versions?.forEach { version ->
put(version)
}
})
}
put(compatiblePackageJson)
}
})
}.let(::put)
} }
result.success(patches) }.toString().let(result::success)
} else result.notImplemented()
} }
else -> result.notImplemented() else -> result.notImplemented()
@ -220,7 +232,7 @@ class MainActivity : FlutterActivity() {
val compatibleOrUniversal = val compatibleOrUniversal =
isCompatible || patch.compatiblePackages.isNullOrEmpty() isCompatible || patch.compatiblePackages.isNullOrEmpty()
compatibleOrUniversal && selectedPatches.any { it == patch.patchName } compatibleOrUniversal && selectedPatches.any { it == patch.name }
} }
if (cancel) { if (cancel) {
@ -251,9 +263,9 @@ class MainActivity : FlutterActivity() {
val msg = patchResult.exception?.let { val msg = patchResult.exception?.let {
val writer = StringWriter() val writer = StringWriter()
it.printStackTrace(PrintWriter(writer)) it.printStackTrace(PrintWriter(writer))
"${patchResult.patchName} failed: $writer" "${patchResult.patch.name} failed: $writer"
} ?: run { } ?: run {
"${patchResult.patchName} succeeded" "${patchResult.patch.name} succeeded"
} }
updateProgress(progress, "", msg) updateProgress(progress, "", msg)

View file

@ -73,7 +73,6 @@
"patchDialogText": "You have selected a resource patch and a split APK installation has been detected, so patching errors may occur.\nAre you sure you want to proceed?", "patchDialogText": "You have selected a resource patch and a split APK installation has been detected, so patching errors may occur.\nAre you sure you want to proceed?",
"armv7WarningDialogText": "Patching on ARMv7 devices is not yet supported and might fail. Proceed anyways?", "armv7WarningDialogText": "Patching on ARMv7 devices is not yet supported and might fail. Proceed anyways?",
"splitApkWarningDialogText": "Patching a split APK is not yet supported and might fail. Proceed anyways?",
"removedPatchesWarningDialogText": "The following patches have been removed since the last time you used them.\n\n{patches}\n\nProceed anyways?" "removedPatchesWarningDialogText": "The following patches have been removed since the last time you used them.\n\n{patches}\n\nProceed anyways?"
}, },
"appSelectorCard": { "appSelectorCard": {

View file

@ -9,26 +9,19 @@ class Patch {
required this.name, required this.name,
required this.description, required this.description,
required this.excluded, required this.excluded,
required this.dependencies,
required this.compatiblePackages, required this.compatiblePackages,
}); });
factory Patch.fromJson(Map<String, dynamic> json) => _$PatchFromJson(json); factory Patch.fromJson(Map<String, dynamic> json) => _$PatchFromJson(json);
final String name; final String name;
final String description; final String? description;
final bool excluded; final bool excluded;
final List<String> dependencies;
final List<Package> compatiblePackages; final List<Package> compatiblePackages;
Map<String, dynamic> toJson() => _$PatchToJson(this); Map<String, dynamic> toJson() => _$PatchToJson(this);
String getSimpleName() { String getSimpleName() {
return name return name;
.replaceAll('-', ' ')
.split('-')
.join(' ')
.toTitleCase()
.replaceFirst('Microg', 'MicroG');
} }
} }

View file

@ -315,18 +315,16 @@ class ManagerAPI {
if (patchBundleFile != null) { if (patchBundleFile != null) {
try { try {
final patchesObject = await PatcherAPI.patcherChannel.invokeMethod( final String patchesJson = await PatcherAPI.patcherChannel.invokeMethod(
'getPatches', 'getPatches',
{ {
'patchBundleFilePath': patchBundleFile.path, 'patchBundleFilePath': patchBundleFile.path,
'cacheDirPath': cacheDir.path, 'cacheDirPath': cacheDir.path,
}, },
); );
final List<Map<String, dynamic>> patchesMap = [];
patchesObject.forEach((patch) { final List<dynamic> patchesJsonList = jsonDecode(patchesJson);
patchesMap.add(jsonDecode('$patch')); patches = patchesJsonList.map((patchJson) => Patch.fromJson(patchJson)).toList();
});
patches = patchesMap.map((patch) => Patch.fromJson(patch)).toList();
return patches; return patches;
} on Exception catch (e) { } on Exception catch (e) {
if (kDebugMode) { if (kDebugMode) {

View file

@ -149,46 +149,11 @@ class PatcherAPI {
.toList(); .toList();
} }
Future<bool> needsResourcePatching(
List<Patch> selectedPatches,
) async {
return selectedPatches.any(
(patch) => patch.dependencies.any(
(dep) => dep.contains('resource-'),
),
);
}
Future<bool> needsSettingsPatch(List<Patch> selectedPatches) async {
return selectedPatches.any(
(patch) => patch.dependencies.any(
(dep) => dep.contains('settings'),
),
);
}
Future<void> runPatcher( Future<void> runPatcher(
String packageName, String packageName,
String apkFilePath, String apkFilePath,
List<Patch> selectedPatches, List<Patch> selectedPatches,
) async { ) async {
final bool includeSettings = await needsSettingsPatch(selectedPatches);
if (includeSettings) {
try {
final Patch? settingsPatch = _patches.firstWhereOrNull(
(patch) =>
patch.name.contains('settings') &&
patch.compatiblePackages.any((pack) => pack.name == packageName),
);
if (settingsPatch != null) {
selectedPatches.add(settingsPatch);
}
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
}
final File? patchBundleFile = await _managerAPI.downloadPatches(); final File? patchBundleFile = await _managerAPI.downloadPatches();
final File? integrationsFile = await _managerAPI.downloadIntegrations(); final File? integrationsFile = await _managerAPI.downloadIntegrations();
if (patchBundleFile != null) { if (patchBundleFile != null) {

View file

@ -44,49 +44,6 @@ class PatcherViewModel extends BaseViewModel {
return selectedApp == null; return selectedApp == null;
} }
Future<bool> isValidPatchConfig() async {
final bool needsResourcePatching = await _patcherAPI.needsResourcePatching(
selectedPatches,
);
if (needsResourcePatching && selectedApp != null) {
final bool isSplit = await _managerAPI.isSplitApk(selectedApp!);
return !isSplit;
}
return true;
}
Future<void> showPatchConfirmationDialog(BuildContext context) async {
final bool isValid = await isValidPatchConfig();
if (context.mounted) {
if (isValid) {
showArmv7WarningDialog(context);
} else {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText('warning'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText('patcherView.splitApkWarningDialogText'),
actions: <Widget>[
CustomMaterialButton(
label: I18nText('noButton'),
onPressed: () => Navigator.of(context).pop(),
),
CustomMaterialButton(
label: I18nText('yesButton'),
isFilled: false,
onPressed: () {
Navigator.of(context).pop();
showArmv7WarningDialog(context);
},
),
],
),
);
}
}
}
Future<void> showRemovedPatchesDialog(BuildContext context) async { Future<void> showRemovedPatchesDialog(BuildContext context) async {
if (removedPatches.isNotEmpty) { if (removedPatches.isNotEmpty) {
return showDialog( return showDialog(
@ -115,7 +72,7 @@ class PatcherViewModel extends BaseViewModel {
), ),
); );
} else { } else {
showArmv7WarningDialog(context); showArmv7WarningDialog(context); // TODO(aabed): Find out why this is here
} }
} }

View file

@ -194,7 +194,7 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
return PatchItem( return PatchItem(
name: patch.name, name: patch.name,
simpleName: patch.getSimpleName(), simpleName: patch.getSimpleName(),
description: patch.description, description: patch.description ?? '',
packageVersion: model.getAppInfo().version, packageVersion: model.getAppInfo().version,
supportedPackageVersions: supportedPackageVersions:
model.getSupportedVersions(patch), model.getSupportedVersions(patch),
@ -246,7 +246,7 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
return PatchItem( return PatchItem(
name: patch.name, name: patch.name,
simpleName: patch.getSimpleName(), simpleName: patch.getSimpleName(),
description: patch.description, description: patch.description ?? '',
packageVersion: packageVersion:
model.getAppInfo().version, model.getAppInfo().version,
supportedPackageVersions: supportedPackageVersions: