thermald: fetch more detailed network info (#20928)
parent
0495426535
commit
f6cf350d3a
2
cereal
2
cereal
|
@ -1 +1 @@
|
||||||
Subproject commit 3c895e7b33a06a4c087c7728a3e44986b360f3ab
|
Subproject commit 5514625137b1c736f7ce61a647f57273482cebd4
|
|
@ -50,6 +50,10 @@ class HardwareBase:
|
||||||
def get_subscriber_info(self):
|
def get_subscriber_info(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_network_info(self):
|
||||||
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_network_type(self):
|
def get_network_type(self):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -130,6 +130,9 @@ class Android(HardwareBase):
|
||||||
'data_connected': cell_data_connected
|
'data_connected': cell_data_connected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_network_info(self):
|
||||||
|
return None
|
||||||
|
|
||||||
def get_network_type(self):
|
def get_network_type(self):
|
||||||
wifi_check = parse_service_call_string(service_call(["connectivity", "2"]))
|
wifi_check = parse_service_call_string(service_call(["connectivity", "2"]))
|
||||||
if wifi_check is None:
|
if wifi_check is None:
|
||||||
|
|
|
@ -32,6 +32,9 @@ class Pc(HardwareBase):
|
||||||
def get_subscriber_info(self):
|
def get_subscriber_info(self):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
def get_network_info(self):
|
||||||
|
return None
|
||||||
|
|
||||||
def get_network_type(self):
|
def get_network_type(self):
|
||||||
return NetworkType.wifi
|
return NetworkType.wifi
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,26 @@ class Tici(HardwareBase):
|
||||||
|
|
||||||
return str(self.get_modem().Get(MM_MODEM, 'EquipmentIdentifier', dbus_interface=DBUS_PROPS, timeout=TIMEOUT))
|
return str(self.get_modem().Get(MM_MODEM, 'EquipmentIdentifier', dbus_interface=DBUS_PROPS, timeout=TIMEOUT))
|
||||||
|
|
||||||
|
def get_network_info(self):
|
||||||
|
modem = self.get_modem()
|
||||||
|
try:
|
||||||
|
info = modem.Command("AT+QNWINFO", int(TIMEOUT * 1000), dbus_interface=MM_MODEM, timeout=TIMEOUT)
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if info and info.startswith('+QNWINFO: '):
|
||||||
|
info = info.replace('+QNWINFO: ', '').replace('"', '')
|
||||||
|
technology, operator, band, channel = info.split(',')
|
||||||
|
|
||||||
|
return({
|
||||||
|
'technology': technology,
|
||||||
|
'operator': operator,
|
||||||
|
'band': band,
|
||||||
|
'channel': int(channel)
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def parse_strength(self, percentage):
|
def parse_strength(self, percentage):
|
||||||
if percentage < 25:
|
if percentage < 25:
|
||||||
return NetworkStrength.poor
|
return NetworkStrength.poor
|
||||||
|
|
|
@ -155,6 +155,7 @@ def thermald_thread():
|
||||||
|
|
||||||
network_type = NetworkType.none
|
network_type = NetworkType.none
|
||||||
network_strength = NetworkStrength.unknown
|
network_strength = NetworkStrength.unknown
|
||||||
|
network_info = None
|
||||||
|
|
||||||
current_filter = FirstOrderFilter(0., CURRENT_TAU, DT_TRML)
|
current_filter = FirstOrderFilter(0., CURRENT_TAU, DT_TRML)
|
||||||
cpu_temp_filter = FirstOrderFilter(0., CPU_TEMP_TAU, DT_TRML)
|
cpu_temp_filter = FirstOrderFilter(0., CPU_TEMP_TAU, DT_TRML)
|
||||||
|
@ -230,6 +231,7 @@ def thermald_thread():
|
||||||
try:
|
try:
|
||||||
network_type = HARDWARE.get_network_type()
|
network_type = HARDWARE.get_network_type()
|
||||||
network_strength = HARDWARE.get_network_strength(network_type)
|
network_strength = HARDWARE.get_network_strength(network_type)
|
||||||
|
network_info = HARDWARE.get_network_info() # pylint: disable=assignment-from-none
|
||||||
except Exception:
|
except Exception:
|
||||||
cloudlog.exception("Error getting network status")
|
cloudlog.exception("Error getting network status")
|
||||||
|
|
||||||
|
@ -238,6 +240,9 @@ def thermald_thread():
|
||||||
msg.deviceState.cpuUsagePercent = int(round(psutil.cpu_percent()))
|
msg.deviceState.cpuUsagePercent = int(round(psutil.cpu_percent()))
|
||||||
msg.deviceState.networkType = network_type
|
msg.deviceState.networkType = network_type
|
||||||
msg.deviceState.networkStrength = network_strength
|
msg.deviceState.networkStrength = network_strength
|
||||||
|
if network_info is not None:
|
||||||
|
msg.deviceState.networkInfo = network_info
|
||||||
|
|
||||||
msg.deviceState.batteryPercent = HARDWARE.get_battery_capacity()
|
msg.deviceState.batteryPercent = HARDWARE.get_battery_capacity()
|
||||||
msg.deviceState.batteryStatus = HARDWARE.get_battery_status()
|
msg.deviceState.batteryStatus = HARDWARE.get_battery_status()
|
||||||
msg.deviceState.batteryCurrent = HARDWARE.get_battery_current()
|
msg.deviceState.batteryCurrent = HARDWARE.get_battery_current()
|
||||||
|
|
Loading…
Reference in New Issue