Path: blob/master/AndroidRunner/Plugins/batterymanager/README.md
907 views
BatteryManager Plugin
This plugin uses the Android BatteryManager API to gather battery related data. The plugin works using the BatteryManager companion app.
Dependencies and Requirements
BatteryManager companion app has to be installed on the device with all permissions granted.
BATTERY_PLUGGED_DOCKdata point is available for Android version Tiramisu (API Level 33) and above.EXTRA_BATTERY_LOWdata point is available for Android version P (Pie) (API Level 28) and above.The
EXTRA_*values do not update between runs with the initial Android Runner version. In order to have the values update as intended, thedevice.unplug(restart)line in AndroidRunner/Experiment.py,prepare_devicefunction should be removed.
Configuration
The following is an example configuration that contains possible values for the data_points and persistency strategy fields.
experiment_aggregation string Aggregates the results of each run of each app into one csv file (Aggregated_Results_Batterymanager.csv). Column descriptions
devicename of the device.subjectname of the application.runrun number of the application in the experiment.UPPERCASE_COLUMN_NAMEScontain the average of the matching column name that was specified in the config for that particular run.If the config.json contains both
BATTERY_PROPERTY_CURRENT_NOWandEXTRA_VOLTAGEfields, then the following columns will also be created:Energy trapz (J)energy consumption of the run computed with the trapezoid method.Energy simple (J)energy consumption of the run computed simply by multiplying the average power by time.Avg power (W)average power consumption of the run.
sample_interval int How often the data should be gathered in milliseconds. (can be equal to 0, in which case the companion app will record continuously, see Limitations and Known Issues section for more information on recording continuously).
data_points Array The data points that should be gathered. All the available data points are listed above in the config sample. For further information on each of the data points, please refer to the Android BatteryManager API documentation (https://developer.android.com/reference/android/os/BatteryManager#summary).
BATTERY_PLUGGED_DOCKdata point is available for Android version Tiramisu (API Level 33) and above.EXTRA_BATTERY_LOWdata point is available for Android version P (Pie) (API Level 28) and above.
persistency_strategy Array The persistency strategy that should be used. The available options are:
adb_log- uses the Android logs to extract the data from the companion app.csv- stores the data in a CSV file on the device, then pulls the file from the device and stores it on the computer. Flaky on old devices!! Fix needed in the companion app.
Limitations and Known Issues
The companion app keeps everything in memory and then dumps it to a csv file. This means that if the user wants to use memory as a dependent variable, they should not use the
csvpersistency strategy.Very low
sample_intervalvalues causes the number of observations from the companion app to be inconsistent between runs. (i.e., one run might have 1000 rows, next run could have 800, or 1200 rows).Running the BatteryManager app, using the
csvpersistency strategy can crash on older devices. We recommend usingadb_logstrategy.