forked from Customrombay/database
-
Notifications
You must be signed in to change notification settings - Fork 0
/
syncWithSuperiorOS.dart
102 lines (100 loc) · 4.4 KB
/
syncWithSuperiorOS.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
102
import 'dart:io';
import 'package:yaml/yaml.dart';
import 'package:http/http.dart' as http;
import 'tools/extended_codename_creator.dart';
import 'tools/is_supported.dart';
import 'tools/add_to_support.dart';
import 'tools/android_version_from_number_name.dart';
void main() async {
int numberOfCovered = 0;
int numberOfNotCovered = 0;
List<String> listOfCovered = [];
List<String> listOfNotCovered = [];
var response1 = await http.get(Uri.parse("https://api.github.com/repos/SuperiorOS-Devices/official_devices/contents/"));
if (response1.statusCode == 200) {
stdout.write("OK\n");
YamlList ydoc = loadYaml(response1.body);
for (YamlMap file in ydoc) {
if (file["name"].toString().endsWith(".json")) {
stdout.write(file["name"] + "\n");
String readCodename = file["name"].toString().replaceAll(".json", "");
String downloadUrl = file["download_url"];
var deviceResponse = await http.get(Uri.parse(downloadUrl));
if (deviceResponse.statusCode == 200) {
YamlMap deviceMap = loadYaml(deviceResponse.body);
YamlList deviceList = deviceMap["response"];
YamlMap deviceInfo = deviceList[0];
String deviceName = deviceInfo["device_name"];
String deviceBrand = deviceName.split(" ")[0];
String superiorOSVersion = deviceInfo["version"];
int androidVersion = androidVersionFromNumberName(androidVersionNumberName: superiorOSVersion.toLowerCase());
String extendedCodename = extendedCodenameCreator(readCodename: readCodename, readVendor: deviceBrand);
if (isSupported(extendedCodename: extendedCodename)) {
numberOfCovered += 1;
listOfCovered += [extendedCodename];
addToSupport(
androidVersion: androidVersion.toString(),
extendedCodename: extendedCodename,
romName: "SuperiorOS",
romState: "Official",
romSupport: true,
romWebpage: "https://sourceforge.net/projects/superioros/",
deviceWebpage: "https://sourceforge.net/projects/superioros/"
);
}
else {
numberOfNotCovered += 1;
listOfNotCovered += [extendedCodename];
}
}
}
}
}
var response2 = await http.get(Uri.parse("https://api.github.com/repos/SuperiorOS-Devices/official_devices-gapps/contents/"));
if (response2.statusCode == 200) {
stdout.write("OK\n");
YamlList ydoc = loadYaml(response2.body);
for (YamlMap file in ydoc) {
if (file["name"].toString().endsWith(".json")) {
stdout.write(file["name"] + "\n");
String readCodename = file["name"].toString().replaceAll(".json", "");
String downloadUrl = file["download_url"];
var deviceResponse = await http.get(Uri.parse(downloadUrl));
if (deviceResponse.statusCode == 200) {
YamlMap deviceMap = loadYaml(deviceResponse.body);
YamlList deviceList = deviceMap["response"];
YamlMap deviceInfo = deviceList[0];
String deviceName = deviceInfo["device_name"];
String deviceBrand = deviceName.split(" ")[0];
String superiorOSVersion = deviceInfo["version"];
int androidVersion = androidVersionFromNumberName(androidVersionNumberName: superiorOSVersion.toLowerCase());
String extendedCodename = extendedCodenameCreator(readCodename: readCodename, readVendor: deviceBrand);
if (!(listOfCovered.contains(extendedCodename))) {
if (isSupported(extendedCodename: extendedCodename)) {
numberOfCovered += 1;
listOfCovered += [extendedCodename];
addToSupport(
androidVersion: androidVersion.toString(),
extendedCodename: extendedCodename,
romName: "SuperiorOS",
romState: "Official",
romSupport: true,
romWebpage: "https://sourceforge.net/projects/superioros/",
deviceWebpage: "https://sourceforge.net/projects/superioros/"
);
}
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");
}
}