diff --git a/build/android/adb_install_apk.py b/build/android/adb_install_apk.py index 4f299efaac40da..e00981fb8b8420 100755 --- a/build/android/adb_install_apk.py +++ b/build/android/adb_install_apk.py @@ -83,9 +83,12 @@ def main(): and helper.GetSplitName()): splits.append(f) - blacklist = (device_blacklist.Blacklist(args.blacklist_file) - if args.blacklist_file - else None) + if args.blacklist_file: + blacklist = device_blacklist.Blacklist(args.blacklist_file) + else: + # TODO(jbudorick): Remove this once the bots are converted. + blacklist = device_blacklist.Blacklist(device_blacklist.BLACKLIST_JSON) + devices = device_utils.DeviceUtils.HealthyDevices(blacklist) if args.device: diff --git a/build/android/adb_reverse_forwarder.py b/build/android/adb_reverse_forwarder.py index d85a8aa144b1ad..44b1b971464af4 100755 --- a/build/android/adb_reverse_forwarder.py +++ b/build/android/adb_reverse_forwarder.py @@ -56,9 +56,11 @@ def main(argv): parser.error('Bad port number') sys.exit(1) - blacklist = (device_blacklist.Blacklist(options.blacklist_file) - if options.blacklist_file - else None) + if options.blacklist_file: + blacklist = device_blacklist.Blacklist(options.blacklist_file) + else: + blacklist = None + devices = device_utils.DeviceUtils.HealthyDevices(blacklist) if options.device: diff --git a/build/android/buildbot/bb_device_status_check.py b/build/android/buildbot/bb_device_status_check.py index 9d54fe3747733c..7cd6cd044f2634 100755 --- a/build/android/buildbot/bb_device_status_check.py +++ b/build/android/buildbot/bb_device_status_check.py @@ -295,9 +295,11 @@ def main(): run_tests_helper.SetLogLevel(args.verbose) - blacklist = (device_blacklist.Blacklist(args.blacklist_file) - if args.blacklist_file - else None) + if args.blacklist_file: + blacklist = device_blacklist.Blacklist(args.blacklist_file) + else: + # TODO(jbudorick): Remove this once bots pass the blacklist file. + blacklist = device_blacklist.Blacklist(device_blacklist.BLACKLIST_JSON) last_devices_path = os.path.join( args.out_dir, device_list.LAST_DEVICES_FILENAME) diff --git a/build/android/devil/android/device_blacklist.py b/build/android/devil/android/device_blacklist.py index 615b3e6bea5fef..0724654be7b9b5 100644 --- a/build/android/devil/android/device_blacklist.py +++ b/build/android/devil/android/device_blacklist.py @@ -3,7 +3,6 @@ # found in the LICENSE file. import json -import logging import os import threading @@ -50,16 +49,34 @@ def Extend(self, devices): Args: devices: list of bad devices to be added to the blacklist file. """ - logging.info('Adding %s to blacklist %s', ','.join(devices), self._path) with self._blacklist_lock: - blacklist = self.Read() + blacklist = ReadBlacklist() blacklist.extend(devices) - self.Write(blacklist) + WriteBlacklist(blacklist) def Reset(self): """Erases the blacklist file if it exists.""" - logging.info('Resetting blacklist %s', self._path) with self._blacklist_lock: if os.path.exists(self._path): os.remove(self._path) + +def ReadBlacklist(): + # TODO(jbudorick): Phase out once all clients have migrated. + return Blacklist(BLACKLIST_JSON).Read() + + +def WriteBlacklist(blacklist): + # TODO(jbudorick): Phase out once all clients have migrated. + Blacklist(BLACKLIST_JSON).Write(blacklist) + + +def ExtendBlacklist(devices): + # TODO(jbudorick): Phase out once all clients have migrated. + Blacklist(BLACKLIST_JSON).Extend(devices) + + +def ResetBlacklist(): + # TODO(jbudorick): Phase out once all clients have migrated. + Blacklist(BLACKLIST_JSON).Reset() + diff --git a/build/android/devil/android/device_utils.py b/build/android/devil/android/device_utils.py index 6109341b98e502..416009a2d29331 100644 --- a/build/android/devil/android/device_utils.py +++ b/build/android/devil/android/device_utils.py @@ -1922,7 +1922,11 @@ def parallel(cls, devices, async=False): @classmethod def HealthyDevices(cls, blacklist=None, **kwargs): - blacklisted_devices = blacklist.Read() if blacklist else [] + if not blacklist: + # TODO(jbudorick): Remove once clients pass in the blacklist. + blacklist = device_blacklist.Blacklist(device_blacklist.BLACKLIST_JSON) + + blacklisted_devices = blacklist.Read() def blacklisted(adb): if adb.GetDeviceSerial() in blacklisted_devices: logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) diff --git a/build/android/enable_asserts.py b/build/android/enable_asserts.py index 0616567acbdae8..1c6027744b5bb4 100755 --- a/build/android/enable_asserts.py +++ b/build/android/enable_asserts.py @@ -28,9 +28,10 @@ def main(): args = parser.parse_args() - blacklist = (device_blacklist.Blacklist(args.blacklist_file) - if args.blacklist_file - else None) + if args.blacklist_file: + blacklist = device_blacklist.Blacklist(args.blacklist_file) + else: + blacklist = None # TODO(jbudorick): Accept optional serial number and run only for the # specified device when present. diff --git a/build/android/provision_devices.py b/build/android/provision_devices.py index 137937762e1426..0a7f8fd770f8b2 100755 --- a/build/android/provision_devices.py +++ b/build/android/provision_devices.py @@ -53,9 +53,11 @@ class _PHASES(object): def ProvisionDevices(args): - blacklist = (device_blacklist.Blacklist(args.blacklist_file) - if args.blacklist_file - else None) + if args.blacklist_file: + blacklist = device_blacklist.Blacklist(args.blacklist_file) + else: + # TODO(jbudorick): Remove once the bots have switched over. + blacklist = device_blacklist.Blacklist(device_blacklist.BLACKLIST_JSON) devices = device_utils.DeviceUtils.HealthyDevices(blacklist) if args.device: diff --git a/build/android/pylib/local/device/local_device_environment.py b/build/android/pylib/local/device/local_device_environment.py index f146f7a162a663..7a20903998b977 100644 --- a/build/android/pylib/local/device/local_device_environment.py +++ b/build/android/pylib/local/device/local_device_environment.py @@ -14,9 +14,8 @@ class LocalDeviceEnvironment(environment.Environment): def __init__(self, args, _error_func): super(LocalDeviceEnvironment, self).__init__() - self._blacklist = (device_blacklist.Blacklist(args.blacklist_file) - if args.blacklist_file - else None) + self._blacklist = device_blacklist.Blacklist( + args.blacklist_file or device_blacklist.BLACKLIST_JSON) self._device_serial = args.test_device self._devices = [] self._max_tries = 1 + args.num_retries diff --git a/build/android/screenshot.py b/build/android/screenshot.py index 902e06808ce056..b03979663633df 100755 --- a/build/android/screenshot.py +++ b/build/android/screenshot.py @@ -75,9 +75,10 @@ def main(): if options.verbose: logging.getLogger().setLevel(logging.DEBUG) - blacklist = (device_blacklist.Blacklist(options.blacklist_file) - if options.blacklist_file - else None) + if options.blacklist_file: + blacklist = device_blacklist.Blacklist(options.blacklist_file) + else: + blacklist = None devices = device_utils.DeviceUtils.HealthyDevices(blacklist) if options.device: diff --git a/build/android/test_runner.py b/build/android/test_runner.py index 18b87adec8993a..204c81c0e6bbac 100755 --- a/build/android/test_runner.py +++ b/build/android/test_runner.py @@ -895,10 +895,13 @@ def _GetAttachedDevices(blacklist_file, test_device): Returns: A list of attached devices. """ - blacklist = (device_blacklist.Blacklist(blacklist_file) - if blacklist_file - else None) + if not blacklist_file: + # TODO(jbudorick): Remove this once bots pass the blacklist file. + blacklist_file = device_blacklist.BLACKLIST_JSON + logging.warning('Using default device blacklist %s', + device_blacklist.BLACKLIST_JSON) + blacklist = device_blacklist.Blacklist(blacklist_file) attached_devices = device_utils.DeviceUtils.HealthyDevices(blacklist) if test_device: test_device = [d for d in attached_devices if d == test_device] diff --git a/build/android/tombstones.py b/build/android/tombstones.py index f7f5bdce22f49b..b1c79d3ff3d404 100755 --- a/build/android/tombstones.py +++ b/build/android/tombstones.py @@ -237,9 +237,10 @@ def main(): 'crash stacks.') options, _ = parser.parse_args() - blacklist = (device_blacklist.Blacklist(options.blacklist_file) - if options.blacklist_file - else None) + if options.blacklist_file: + blacklist = device_blacklist.Blacklist(options.blacklist_file) + else: + blacklist = None if options.device: devices = [device_utils.DeviceUtils(options.device)] diff --git a/build/android/update_verification.py b/build/android/update_verification.py index b25ea493098a4f..c73a06156fb8ba 100755 --- a/build/android/update_verification.py +++ b/build/android/update_verification.py @@ -90,9 +90,10 @@ def main(): args = parser.parse_args() run_tests_helper.SetLogLevel(args.verbose) - blacklist = (device_blacklist.Blacklist(args.blacklist_file) - if args.blacklist_file - else None) + if args.blacklist_file: + blacklist = device_blacklist.Blacklist(args.blacklist_file) + else: + blacklist = None devices = device_utils.DeviceUtils.HealthyDevices(blacklist) if not devices: