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
|
#!/bin/env python
# Program to find devices to support in LineageOS
# Copyright (C) 2019 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import os
import re
import yaml
basedir = '_data' + os.sep + 'devices'
results = {}
last_lineageos_version = 16.0
def still_supported(document):
if not last_lineageos_version in document['versions']:
return False
if 'discontinued' in document['channels']:
return False
return True
def interesting_for_replicant(document):
# For smartphones or tablets with a modem, since the modem is in
# the same SOC, we would need to do some extensive review of the SOC
# architecture to understand if the modem can be isolated with an IOMMU
# We would also need to make sure that the IOMMU is correctly setup (hard)
# and that the setup happens before the modem core are booted.
# For devices without a modem, we would still need to make sure that the
# sound card and the microphone is completely under the control of free
# software and that there aren't too much proprietary libraries to replace
if re.search("Qualcomm", document['soc']):
return False
# Non removable batteries causes too much issues for both users
# and developers as once you buy a device second hand, the battery
# doesn't last as much as when the device is new. On some devices,
# replicing non-replacable batteries can be very difficult and damage
# the device along the way
removable_battery = document.get('battery', {}).get('removable', None)
if removable_battery == None:
pass # Unknown
elif removable_battery == False:
return False
return True
def store_infos(results, document):
fields = ['vendor', 'name', 'type']
device_dict = {}
for field in fields:
device_dict[field] = document[field]
removable_battery = document.get('battery', {}).get('removable', None)
if removable_battery == None:
device_dict['removable_battery'] = 'Unknown'
else:
device_dict['removable_battery'] = removable_battery
soc = document['soc']
if not soc in results:
results[soc] = []
results[soc].append(device_dict)
def print_results(results):
socs = list(results.keys())
socs.sort()
for soc in socs:
print ("{0}:".format(soc))
for device in results[soc]:
print ("- {0}:".format(device))
for filename in os.listdir(basedir):
filepath = basedir + os.sep + filename
if re.search("\.yml$", filepath):
yaml_file = open(filepath, 'r')
document = yaml.load(yaml_file)
if still_supported(document) and interesting_for_replicant(document):
store_infos(results, document)
print_results(results)
|