1# Copyright 2016 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5"""This class defines the ADBHost Label class.""" 6 7import common 8 9from autotest_lib.client.common_lib.brillo import hal_utils 10from autotest_lib.server.cros.dynamic_suite import constants 11from autotest_lib.server.hosts import base_label 12from autotest_lib.server.hosts import common_label 13 14 15BOARD_FILE = 'ro.product.device' 16 17 18class BoardLabel(base_label.StringPrefixLabel): 19 """Determine the correct board label for the device.""" 20 21 _NAME = constants.BOARD_PREFIX.rstrip(':') 22 23 # pylint: disable=missing-docstring 24 def generate_labels(self, host): 25 return [host.get_board_name()] 26 27 28class CameraHalLabel(base_label.BaseLabel): 29 """Determine whether a host has a camera HAL in the image.""" 30 31 _NAME = 'camera-hal' 32 33 def exists(self, host): 34 return hal_utils.has_hal('camera', host=host) 35 36 37class LoopbackDongleLabel(base_label.BaseLabel): 38 """Determines if an audio loopback dongle is connected to the device.""" 39 40 _NAME = 'loopback-dongle' 41 42 def exists(self, host): 43 results = host.run('cat /sys/class/switch/h2w/state', 44 ignore_status=True) 45 return results and '0' not in results.stdout 46 47 48ADB_LABELS = [ 49 BoardLabel(), 50 CameraHalLabel(), 51 LoopbackDongleLabel(), 52 common_label.OSLabel(), 53] 54