You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					143 lines
				
				2.5 KiB
			
		
		
			
		
	
	
					143 lines
				
				2.5 KiB
			| 
											4 years ago
										 | from abc import abstractmethod, ABC
 | ||
| 
											5 years ago
										 | from collections import namedtuple
 | ||
| 
											4 years ago
										 | from typing import Dict
 | ||
| 
											5 years ago
										 | 
 | ||
| 
											4 years ago
										 | from cereal import log
 | ||
|  | 
 | ||
| 
											4 years ago
										 | ThermalConfig = namedtuple('ThermalConfig', ['cpu', 'gpu', 'mem', 'bat', 'ambient', 'pmic'])
 | ||
| 
											4 years ago
										 | NetworkType = log.DeviceState.NetworkType
 | ||
|  | 
 | ||
| 
											5 years ago
										 | 
 | ||
| 
											4 years ago
										 | class HardwareBase(ABC):
 | ||
| 
											5 years ago
										 |   @staticmethod
 | ||
| 
											4 years ago
										 |   def get_cmdline() -> Dict[str, str]:
 | ||
| 
											5 years ago
										 |     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}
 | ||
|  | 
 | ||
| 
											5 years ago
										 |   @staticmethod
 | ||
|  |   def read_param_file(path, parser, default=0):
 | ||
|  |     try:
 | ||
|  |       with open(path) as f:
 | ||
|  |         return parser(f.read())
 | ||
|  |     except Exception:
 | ||
|  |       return default
 | ||
|  | 
 | ||
| 
											5 years ago
										 |   @abstractmethod
 | ||
|  |   def reboot(self, reason=None):
 | ||
|  |     pass
 | ||
|  | 
 | ||
|  |   @abstractmethod
 | ||
|  |   def uninstall(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
| 
											5 years ago
										 |   @abstractmethod
 | ||
|  |   def get_os_version(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
| 
											5 years ago
										 |   @abstractmethod
 | ||
|  |   def get_device_type(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
| 
											5 years ago
										 |   @abstractmethod
 | ||
|  |   def get_sound_card_online(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
|  |   @abstractmethod
 | ||
| 
											4 years ago
										 |   def get_imei(self, slot) -> str:
 | ||
| 
											5 years ago
										 |     pass
 | ||
|  | 
 | ||
|  |   @abstractmethod
 | ||
|  |   def get_serial(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
|  |   @abstractmethod
 | ||
|  |   def get_subscriber_info(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
| 
											5 years ago
										 |   @abstractmethod
 | ||
|  |   def get_network_info(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
| 
											5 years ago
										 |   @abstractmethod
 | ||
|  |   def get_network_type(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
|  |   @abstractmethod
 | ||
|  |   def get_sim_info(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
|  |   @abstractmethod
 | ||
|  |   def get_network_strength(self, network_type):
 | ||
|  |     pass
 | ||
| 
											5 years ago
										 | 
 | ||
| 
											4 years ago
										 |   def get_network_metered(self, network_type) -> bool:
 | ||
|  |     return network_type not in (NetworkType.none, NetworkType.wifi, NetworkType.ethernet)
 | ||
|  | 
 | ||
| 
											4 years ago
										 |   @staticmethod
 | ||
| 
											4 years ago
										 |   def set_bandwidth_limit(upload_speed_kbps: int, download_speed_kbps: int) -> None:
 | ||
| 
											4 years ago
										 |     pass
 | ||
|  | 
 | ||
| 
											5 years ago
										 |   @abstractmethod
 | ||
|  |   def get_usb_present(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
|  |   @abstractmethod
 | ||
|  |   def get_current_power_draw(self):
 | ||
|  |     pass
 | ||
| 
											5 years ago
										 | 
 | ||
|  |   @abstractmethod
 | ||
|  |   def shutdown(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
|  |   @abstractmethod
 | ||
|  |   def get_thermal_config(self):
 | ||
|  |     pass
 | ||
| 
											5 years ago
										 | 
 | ||
|  |   @abstractmethod
 | ||
|  |   def set_screen_brightness(self, percentage):
 | ||
|  |     pass
 | ||
| 
											5 years ago
										 | 
 | ||
| 
											4 years ago
										 |   @abstractmethod
 | ||
|  |   def get_screen_brightness(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
| 
											5 years ago
										 |   @abstractmethod
 | ||
| 
											4 years ago
										 |   def set_power_save(self, powersave_enabled):
 | ||
| 
											5 years ago
										 |     pass
 | ||
| 
											4 years ago
										 | 
 | ||
|  |   @abstractmethod
 | ||
|  |   def get_gpu_usage_percent(self):
 | ||
|  |     pass
 | ||
| 
											4 years ago
										 | 
 | ||
|  |   def get_modem_version(self):
 | ||
| 
											4 years ago
										 |     return None
 | ||
|  | 
 | ||
|  |   def get_modem_nv(self):
 | ||
|  |     return None
 | ||
| 
											4 years ago
										 | 
 | ||
| 
											4 years ago
										 |   @abstractmethod
 | ||
|  |   def get_modem_temperatures(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
| 
											4 years ago
										 |   @abstractmethod
 | ||
|  |   def get_nvme_temperatures(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
| 
											4 years ago
										 |   @abstractmethod
 | ||
|  |   def initialize_hardware(self):
 | ||
|  |     pass
 | ||
| 
											4 years ago
										 | 
 | ||
| 
											4 years ago
										 |   def configure_modem(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
| 
											4 years ago
										 |   @abstractmethod
 | ||
|  |   def get_networks(self):
 | ||
|  |     pass
 | ||
| 
											4 years ago
										 | 
 | ||
|  |   def reset_internal_panda(self):
 | ||
|  |     pass
 | ||
|  | 
 | ||
|  |   def recover_internal_panda(self):
 | ||
|  |     pass
 |