forked from Customrombay/database
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync_with_cr_droid.dart
101 lines (98 loc) · 3.36 KB
/
sync_with_cr_droid.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:yaml/yaml.dart';
import 'tools/add_to_support.dart';
import 'tools/android_version_from_crdroid_version.dart';
import 'tools/extended_codename_creator.dart';
import 'tools/is_supported.dart';
void main() async {
var response = await http.get(Uri.parse("https://crdroid.net/devices_handler/compiled.json"));
if (response.statusCode == 200) {
print("OK");
int numberOfCovered = 0;
int numberOfNotCovered = 0;
List<String> listOfNotCovered = [];
List<String> listOfCovered = [];
String cleanBody = response.body.replaceAll("\\ud835\\udd71\\ud835\\udd97\\ud835\\udd94\\ud835\\udd98\\ud835\\udd99", "ok");
YamlMap ydoc = loadYaml(cleanBody);
print(ydoc.runtimeType);
for (var entry in ydoc.entries) {
print(entry.key);
String readVendor = entry.key;
YamlMap devices = entry.value;
for (var readCodename in devices.keys) {
if (readCodename == "tulip") {
continue;
}
else if (readCodename == "olives") {
continue;
}
else if (readCodename == "olive") {
continue;
}
else if (readCodename == "rova") {
continue;
}
else if (readCodename == "Mi439" && readVendor.toLowerCase() == "redmi") {
continue;
}
else if (readCodename == "RMX2001") {
continue;
}
else if (readCodename == "RMX2151") {
continue;
}
String extendedCodename = extendedCodenameCreator(readCodename: readCodename, readVendor: readVendor);
print(extendedCodename);
int newestVersion = 0;
YamlMap versions = devices[readCodename];
bool isMaintained = false;
for (var version in versions.keys) {
print(version);
int thisVersion = int.parse(version.toString());
if (thisVersion > newestVersion) {
newestVersion = thisVersion;
}
YamlMap finals = versions[version];
// String deviceName = finals["device"];
String maintainers = finals["maintainer"];
if (maintainers != "") {
isMaintained = true;
}
}
String state = isMaintained ? "Official" : "Discontinued";
String phoneWebpage = "https://crdroid.net/downloads#$readCodename";
print(newestVersion);
String androidVersion = androidVersionFromCrDroidVersion(newestVersion.toString());
if (isSupported(extendedCodename: extendedCodename)) {
if (listOfCovered.contains(extendedCodename)) {
throw Exception();
}
addToSupport(
androidVersion: androidVersion,
extendedCodename: extendedCodename,
romName: "crDroid",
romState: state,
romSupport: true,
romWebpage: "https://crdroid.net/",
deviceWebpage: phoneWebpage,
);
numberOfCovered += 1;
listOfCovered += [extendedCodename];
}
else {
numberOfNotCovered += 1;
listOfNotCovered += [extendedCodename];
}
}
}
stdout.write("Covered: $numberOfCovered\n");
stdout.write("Not covered: $numberOfNotCovered\n");
for (var deviceNotCovered in listOfNotCovered) {
stdout.write("$deviceNotCovered\n");
}
}
else {
throw Exception();
}
}