From f6d4906ec7fa0b12ddaf14fa506eac1bf2154205 Mon Sep 17 00:00:00 2001 From: Denis 'GNUtoo' Carikli Date: Wed, 20 Nov 2019 15:45:27 +0100 Subject: Add script to work with LineageOS list of supported devices Signed-off-by: Denis 'GNUtoo' Carikli --- research/README | 5 ++ research/find_lineageos_devices.py | 94 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 research/README create mode 100755 research/find_lineageos_devices.py diff --git a/research/README b/research/README new file mode 100644 index 0000000..5367826 --- /dev/null +++ b/research/README @@ -0,0 +1,5 @@ +== Usage == +$ git clone git://github.com/LineageOS/lineage_wiki.git +$ cd lineage_wiki +$ ln -s ../find_lineageos_devices.py ./ +$ ./find_lineageos_devices.py 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 +# +# 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 . + +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) -- cgit v1.2.3