1# Copyright 2020 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 5import itertools 6 7from autotest_lib.client.common_lib import utils 8from autotest_lib.client.common_lib.cros import cros_config 9 10 11def detect_camera(iface): 12 """ 13 Checks whether the device has a built-in camera of specified interface by 14 CrOS config. 15 16 @param iface: string, either 'usb' or 'mipi', indicating the interface of 17 camera module. 18 @returns boolean indicating whether there's a matching camera. 19 """ 20 for i in itertools.count(0): 21 queried = cros_config.call_cros_config_get_output( 22 '/camera/devices/{} interface'.format(i), utils.run) 23 if queried == '': 24 break 25 if queried == iface: 26 return True 27 return False 28