forked from Customrombay/database
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync_with_paranoid_android.dart
82 lines (71 loc) · 2.66 KB
/
sync_with_paranoid_android.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import 'dart:io';
import 'package:yaml/yaml.dart';
import 'tools/add_to_support.dart';
import 'tools/extended_codename_creator.dart';
import 'tools/is_supported.dart';
void main() async {
stdout.write("Cloning https://github.com/AOSPA/ota.git...");
int numberOfCovered = 0;
int numberOfNotCovered = 0;
List<String> listOfNotCovered = [];
List<String> listOfCovered = [];
Directory cacheDir = Directory(".cache/ParanoidAndroidSync");
if (cacheDir.existsSync()) {
cacheDir.deleteSync(recursive: true);
}
cacheDir.createSync(recursive: true);
Process.runSync("git", ["clone", "https://github.com/AOSPA/ota.git", cacheDir.path]);
stdout.write("OK\n");
File devicesFile = File("${cacheDir.path}/devices");
YamlMap ydoc = loadYaml(devicesFile.readAsStringSync());
YamlList ylist = ydoc["devices"];
for (YamlMap device in ylist) {
String readName = device["name"];
String readCodename = device["codename"];
String readVendor = device["manufacturer"];
bool isActive = device["active"] ?? false;
String vendor = readVendor == "Redmi" || readVendor == "POCO" ? "xiaomi" : readVendor;
print(readName);
String extendedCodename = extendedCodenameCreator(
readCodename: readCodename,
readVendor: vendor
);
File updateFile = File("${cacheDir.path}/updates/$readCodename");
int maxAndroidVersion = 0;
if (updateFile.existsSync()) {
YamlMap uydoc = loadYaml(updateFile.readAsStringSync());
YamlList listOfUpdates = uydoc["updates"];
for (YamlMap update in listOfUpdates) {
int androidVersion = int.parse(update["android_version"]);
if (androidVersion > maxAndroidVersion) {
maxAndroidVersion = androidVersion;
}
}
}
else {
throw Exception();
}
if (isSupported(extendedCodename: extendedCodename) && !listOfCovered.contains(extendedCodename)) {
numberOfCovered += 1;
listOfCovered += [extendedCodename];
addToSupport(
extendedCodename: extendedCodename,
romName: "Paranoid Android",
romState: isActive ? "Official" : "Discontinued",
romSupport: true,
androidVersion: maxAndroidVersion.toString(),
romWebpage: "https://paranoidandroid.co/",
deviceWebpage: "https://paranoidandroid.co/$readCodename"
);
}
else if (!listOfNotCovered.contains(extendedCodename) && !listOfCovered.contains(extendedCodename)) {
numberOfNotCovered += 1;
listOfNotCovered += [extendedCodename];
}
}
stdout.write("Covered: $numberOfCovered\n");
stdout.write("Not covered: $numberOfNotCovered\n");
for (var device in listOfNotCovered) {
stdout.write("$device\n");
}
}