forked from Customrombay/database
-
Notifications
You must be signed in to change notification settings - Fork 0
/
syncWithPixelExperience.dart
105 lines (98 loc) · 3.62 KB
/
syncWithPixelExperience.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
103
104
105
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:yaml/yaml.dart';
import 'tools/extended_codename_creator.dart';
import 'tools/android_version_from_pixel_experience_version.dart';
import 'tools/is_supported.dart';
import 'tools/add_to_support.dart';
void main() async {
int numberOfCovered = 0;
int numberOfNotCovered = 0;
List<String> listOfNotCovered = [];
http.Response response = await http.get(Uri.parse("https://raw.githubusercontent.com/PixelExperience/official_devices/master/devices.json"));
if (response.statusCode == 200) {
String content = response.body;
YamlList ydoc = loadYaml(content);
for (YamlMap device in ydoc) {
String readName = device["name"];
String readBrand = device["brand"];
String readCodename = device["codename"];
YamlList readSupportedVersions = device["supported_versions"];
String extendedCodename = extendedCodenameCreator(readCodename: readCodename, readVendor: readBrand);
stdout.write("$extendedCodename\n");
int maxRegularVersion = 0;
int maxPlusVersion = 0;
String regularState = "";
String plusState = "";
for (YamlMap version in readSupportedVersions) {
String readVersionCode = version["version_code"];
bool isStable = version["stable"] ?? true;
bool isDeprecated = version["deprecated"];
if (readVersionCode.endsWith("plus")) {
int thisPlusVersion = androidVersionFromPixelExperienceVersion(pixelExperienceVersion: readVersionCode);
if (thisPlusVersion > maxPlusVersion) {
maxPlusVersion = thisPlusVersion;
plusState = pixelExperienceState(isStable: isStable, isDeprecated: isDeprecated);
}
}
else {
int thisRegularVersion = androidVersionFromPixelExperienceVersion(pixelExperienceVersion: readVersionCode);
if (thisRegularVersion > maxRegularVersion) {
maxRegularVersion = thisRegularVersion;
regularState = pixelExperienceState(isStable: isStable, isDeprecated: isDeprecated);
}
}
}
print(maxRegularVersion);
print(maxPlusVersion);
if (isSupported(extendedCodename: extendedCodename)) {
numberOfCovered += 1;
print(extendedCodename);
addToSupport(
androidVersion: maxRegularVersion.toString(),
extendedCodename: extendedCodename,
romName: "PixelExperience",
romState: regularState,
romSupport: true,
romWebpage: "https://download.pixelexperience.org/",
deviceWebpage: "https://download.pixelexperience.org/$readCodename/"
);
if (maxPlusVersion > 0) {
print(extendedCodename);
addToSupport(
androidVersion: maxPlusVersion.toString(),
extendedCodename: extendedCodename,
romName: "PixelExperience Plus",
romState: plusState,
romSupport: true,
romWebpage: "https://download.pixelexperience.org/",
deviceWebpage: "https://download.pixelexperience.org/$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");
}
}
}
String pixelExperienceState({
required bool isStable,
required bool isDeprecated
}) {
if (isDeprecated) {
return "Discontinued";
}
else if (isStable) {
return "Official";
}
else {
return "Beta";
}
}