forked from Customrombay/database
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync_with_libre_mobile_os.dart
55 lines (53 loc) · 2.29 KB
/
sync_with_libre_mobile_os.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
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:yaml/yaml.dart';
import 'tools/android_version_from_number_name.dart';
import 'tools/extended_codename_creator.dart';
import 'tools/is_supported.dart';
import 'tools/add_to_support.dart';
void main() async {
int numberOfCovered = 0;
int numberOfNotCovered = 0;
List<String> listOfNotCovered = [];
var baseFileResponse = await http.get(Uri.parse("https://git.libremobileos.com/infrastructure/builder/-/raw/main/lmodroid-build-targets"));
var devicesFileResponse = await http.get(Uri.parse("https://git.libremobileos.com/infrastructure/builder/-/raw/main/devices.json"));
if (baseFileResponse.statusCode == 200 && devicesFileResponse.statusCode == 200) {
stdout.write("OK\n");
String baseFileContent = baseFileResponse.body;
YamlList ydoc = loadYaml(devicesFileResponse.body);
for (String line in baseFileContent.split("\n")) {
if (line.trim() != "" && !line.trim().startsWith("#")) {
List<String> props = line.trim().split(" ");
String readCodename = props[0];
String androidVersion = androidVersionFromNumberName(androidVersionNumberName: props[2]).toString();
for (YamlMap device in ydoc) {
if (device["model"] == readCodename) {
String readVendor = device["oem"];
String extendedCodename = extendedCodenameCreator(readCodename: readCodename, readVendor: readVendor);
if (isSupported(extendedCodename: extendedCodename)) {
numberOfCovered += 1;
addToSupport(
androidVersion: androidVersion,
extendedCodename: extendedCodename,
romName: "LibreMobileOS",
romState: "Official",
romSupport: true,
romWebpage: "https://libremobileos.com/",
deviceWebpage: "https://get.libremobileos.com/devices/$readCodename/",
);
}
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");
}
}
}