| Index: build/android/pylib/device/device_list.py
|
| diff --git a/build/android/pylib/device/device_list.py b/build/android/pylib/device/device_list.py
|
| index 0eb6acba2b28b66c0c473f6ecd615f70f39f73b9..d24f21e90997dabe1d73308493cd960e5ad7ebdc 100644
|
| --- a/build/android/pylib/device/device_list.py
|
| +++ b/build/android/pylib/device/device_list.py
|
| @@ -4,27 +4,32 @@
|
|
|
| """A module to keep track of devices across builds."""
|
|
|
| +import json
|
| import os
|
|
|
| LAST_DEVICES_FILENAME = '.last_devices'
|
| -LAST_MISSING_DEVICES_FILENAME = '.last_missing'
|
|
|
|
|
| -def GetPersistentDeviceList(file_name):
|
| - """Returns a list of devices.
|
| +def ReadDeviceOfflineCountMap(file_name):
|
| + """Returns a dictionary of devices to the number of runs we have seen them
|
| + offline. So 0 indicates that they were last seen online.
|
|
|
| Args:
|
| file_name: the file name containing a list of devices.
|
|
|
| - Returns: List of device serial numbers that were on the bot.
|
| + Returns: Dictionary mapping device ID to integer.
|
| """
|
| with open(file_name) as f:
|
| - return f.read().splitlines()
|
| + contents = f.read()
|
| + try:
|
| + return json.loads(contents)
|
| + except ValueError: # This might happen in old to new format transition.
|
| + return []
|
|
|
|
|
| -def WritePersistentDeviceList(file_name, device_list):
|
| +def WriteDeviceOfflineCountMap(file_name, device_map):
|
| path = os.path.dirname(file_name)
|
| if not os.path.exists(path):
|
| os.makedirs(path)
|
| with open(file_name, 'w') as f:
|
| - f.write('\n'.join(set(device_list)))
|
| + f.write(json.dumps(device_map))
|
|
|