1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

AndroidTarget: Add charging_enabled property

Disabling battery charging can be useful for measuring power efficiency of
Android devices with hardware modified for this purpose.
This commit is contained in:
Brendan Jackman 2017-02-09 11:53:11 +00:00 committed by Patrick Bellasi
parent 9ce57c0875
commit baa32ec716

View File

@ -1084,6 +1084,31 @@ class AndroidTarget(Target):
message = 'Could not find mount point for executables directory {}'
raise TargetError(message.format(self.executables_directory))
_charging_enabled_path = '/sys/class/power_supply/battery/charging_enabled'
@property
def charging_enabled(self):
"""
Whether drawing power to charge the battery is enabled
Not all devices have the ability to enable/disable battery charging
(e.g. because they don't have a battery). In that case,
``charging_enabled`` is None.
"""
if not self.file_exists(self._charging_enabled_path):
return None
return self.read_bool(self._charging_enabled_path)
@charging_enabled.setter
def charging_enabled(self, enabled):
"""
Enable/disable drawing power to charge the battery
Not all devices have this facility. In that case, do nothing.
"""
if not self.file_exists(self._charging_enabled_path):
return
self.write_value(self._charging_enabled_path, int(bool(enabled)))
FstabEntry = namedtuple('FstabEntry', ['device', 'mount_point', 'fs_type', 'options', 'dump_freq', 'pass_num'])
PsEntry = namedtuple('PsEntry', 'user pid ppid vsize rss wchan pc state name')