2021-12-16 15:31:53 +01:00
|
|
|
from abc import abstractmethod, ABC
|
2021-02-23 17:04:10 +01:00
|
|
|
from collections import namedtuple
|
2020-08-26 14:57:17 +02:00
|
|
|
|
2021-11-23 16:08:20 -08:00
|
|
|
ThermalConfig = namedtuple('ThermalConfig', ['cpu', 'gpu', 'mem', 'bat', 'ambient', 'pmic'])
|
2020-09-17 13:36:42 +02:00
|
|
|
|
2021-12-16 15:31:53 +01:00
|
|
|
class HardwareBase(ABC):
|
2020-09-17 13:36:42 +02:00
|
|
|
@staticmethod
|
|
|
|
|
def get_cmdline():
|
|
|
|
|
with open('/proc/cmdline') as f:
|
|
|
|
|
cmdline = f.read()
|
|
|
|
|
return {kv[0]: kv[1] for kv in [s.split('=') for s in cmdline.split(' ')] if len(kv) == 2}
|
|
|
|
|
|
2020-12-02 15:20:57 +01:00
|
|
|
@staticmethod
|
|
|
|
|
def read_param_file(path, parser, default=0):
|
|
|
|
|
try:
|
|
|
|
|
with open(path) as f:
|
|
|
|
|
return parser(f.read())
|
|
|
|
|
except Exception:
|
|
|
|
|
return default
|
|
|
|
|
|
2020-12-17 11:45:41 -08:00
|
|
|
@abstractmethod
|
|
|
|
|
def reboot(self, reason=None):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def uninstall(self):
|
|
|
|
|
pass
|
|
|
|
|
|
2020-12-18 04:17:12 -08:00
|
|
|
@abstractmethod
|
|
|
|
|
def get_os_version(self):
|
|
|
|
|
pass
|
|
|
|
|
|
2021-01-22 20:02:48 -08:00
|
|
|
@abstractmethod
|
|
|
|
|
def get_device_type(self):
|
|
|
|
|
pass
|
|
|
|
|
|
2020-08-26 14:57:17 +02:00
|
|
|
@abstractmethod
|
|
|
|
|
def get_sound_card_online(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_imei(self, slot):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_serial(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_subscriber_info(self):
|
|
|
|
|
pass
|
|
|
|
|
|
2021-05-17 13:10:08 +02:00
|
|
|
@abstractmethod
|
|
|
|
|
def get_network_info(self):
|
|
|
|
|
pass
|
|
|
|
|
|
2020-08-26 14:57:17 +02:00
|
|
|
@abstractmethod
|
|
|
|
|
def get_network_type(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_sim_info(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_network_strength(self, network_type):
|
|
|
|
|
pass
|
2020-12-02 15:20:57 +01:00
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_battery_capacity(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_battery_status(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_battery_current(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_battery_voltage(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_battery_charging(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def set_battery_charging(self, on):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_usb_present(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_current_power_draw(self):
|
|
|
|
|
pass
|
2021-02-23 17:04:10 +01:00
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def shutdown(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_thermal_config(self):
|
|
|
|
|
pass
|
2021-02-24 15:25:06 +01:00
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def set_screen_brightness(self, percentage):
|
|
|
|
|
pass
|
2021-04-12 01:40:58 -07:00
|
|
|
|
2021-10-15 17:19:45 -07:00
|
|
|
@abstractmethod
|
|
|
|
|
def get_screen_brightness(self):
|
|
|
|
|
pass
|
|
|
|
|
|
2021-04-12 01:40:58 -07:00
|
|
|
@abstractmethod
|
2021-07-14 15:53:39 +02:00
|
|
|
def set_power_save(self, powersave_enabled):
|
2021-04-12 01:40:58 -07:00
|
|
|
pass
|
2021-06-29 22:55:18 +02:00
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_gpu_usage_percent(self):
|
|
|
|
|
pass
|
2021-07-12 15:52:09 +02:00
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_modem_version(self):
|
|
|
|
|
pass
|
2021-07-14 15:53:39 +02:00
|
|
|
|
2021-09-21 14:40:05 +02:00
|
|
|
@abstractmethod
|
|
|
|
|
def get_modem_temperatures(self):
|
|
|
|
|
pass
|
|
|
|
|
|
2021-10-06 20:32:22 -07:00
|
|
|
@abstractmethod
|
|
|
|
|
def get_nvme_temperatures(self):
|
|
|
|
|
pass
|
|
|
|
|
|
2021-07-14 15:53:39 +02:00
|
|
|
@abstractmethod
|
|
|
|
|
def initialize_hardware(self):
|
|
|
|
|
pass
|
2021-07-14 16:16:45 +02:00
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_networks(self):
|
|
|
|
|
pass
|