diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2019-11-20 15:45:27 +0100 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2019-11-30 00:05:34 +0100 |
commit | f6d4906ec7fa0b12ddaf14fa506eac1bf2154205 (patch) | |
tree | f69f77850b41589ec8543b215200117ecf4808bc /research/find_lineageos_devices.py | |
parent | c6a7ff1d4c61cdb81da5283a0b66458da8c92036 (diff) | |
download | vendor_replicant-scripts-f6d4906ec7fa0b12ddaf14fa506eac1bf2154205.tar.gz vendor_replicant-scripts-f6d4906ec7fa0b12ddaf14fa506eac1bf2154205.tar.bz2 vendor_replicant-scripts-f6d4906ec7fa0b12ddaf14fa506eac1bf2154205.zip |
Add script to work with LineageOS list of supported devices
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Diffstat (limited to 'research/find_lineageos_devices.py')
-rwxr-xr-x | research/find_lineageos_devices.py | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/research/find_lineageos_devices.py b/research/find_lineageos_devices.py new file mode 100755 index 0000000..cb388ca --- /dev/null +++ b/research/find_lineageos_devices.py @@ -0,0 +1,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) |