xref: /aosp_15_r20/external/autotest/client/cros/bluetooth/bluetooth_device_xmlrpc_server.py (revision 9c5db1993ded3edbeafc8092d69fe5de2ee02df7)
1#!/usr/bin/env python
2# Lint as: python2, python3
3# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7from __future__ import absolute_import
8from __future__ import division
9from __future__ import print_function
10
11import logging
12import logging.handlers
13
14import common
15from autotest_lib.client.cros import constants
16from autotest_lib.client.cros import xmlrpc_server
17from autotest_lib.client.cros.multimedia import bluetooth_facade
18
19
20class BluetoothDeviceXmlRpcDelegate(xmlrpc_server.XmlRpcDelegate,
21                                    bluetooth_facade.BluezFacadeLocal):
22    """Exposes DUT methods called remotely during Bluetooth autotests.
23
24    The delegate inherits from BluezFacadeLocal where all native calls
25    should be kept. This XmlRpcDelegate is kept around for when Bluetooth needs
26    to be called without using the MultimediaRpcDelegate.
27
28    TODO(abps): Remove this xmlrpc delegate once it's no longer used.
29    """
30
31    def __init__(self):
32        super(BluetoothDeviceXmlRpcDelegate, self).__init__()
33
34if __name__ == '__main__':
35    logging.basicConfig(level=logging.DEBUG)
36    handler = logging.handlers.SysLogHandler(address='/dev/log')
37    formatter = logging.Formatter(
38            'bluetooth_device_xmlrpc_server: [%(levelname)s] %(message)s')
39    handler.setFormatter(formatter)
40    logging.getLogger().addHandler(handler)
41    logging.debug('bluetooth_device_xmlrpc_server main...')
42    server = xmlrpc_server.XmlRpcServer(
43            'localhost', constants.BLUETOOTH_DEVICE_XMLRPC_SERVER_PORT)
44    server.register_delegate(BluetoothDeviceXmlRpcDelegate())
45    server.run()
46