• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3#   Copyright 2019 - The Android Open Source Project
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17from acts.controllers.fuchsia_lib.base_lib import BaseLib
18
19
20class FuchsiaProfileServerLib(BaseLib):
21
22    def __init__(self, addr: str) -> None:
23        super().__init__(addr, "profile_server")
24
25    def addService(self, record):
26        """Publishes an SDP service record specified by input args
27
28        Args:
29            record: A database that represents an SDP record to
30                be published.
31
32        Returns:
33            Dictionary, service id if success, error if error.
34        """
35        test_cmd = "profile_server_facade.ProfileServerAddService"
36        test_args = {
37            "record": record,
38        }
39
40        return self.send_command(test_cmd, test_args)
41
42    def addSearch(self, attribute_list, profile_id):
43        """Publishes services specified by input args
44
45        Args:
46            attribute_list: The list of attributes to set
47            profile_id: The profile ID to set.
48        Returns:
49            Dictionary, None if success, error if error.
50        """
51        test_cmd = "profile_server_facade.ProfileServerAddSearch"
52        test_args = {
53            "attribute_list": attribute_list,
54            "profile_id": profile_id
55        }
56
57        return self.send_command(test_cmd, test_args)
58
59    def removeService(self, service_id):
60        """Removes a service.
61
62        Args:
63            record: A database that represents an SDP record to
64                be published.
65
66        Returns:
67            Dictionary, None if success, error if error.
68        """
69        test_cmd = "profile_server_facade.ProfileServerRemoveService"
70        test_args = {
71            "service_id": service_id,
72        }
73
74        return self.send_command(test_cmd, test_args)
75
76    def init(self):
77        """Initializes the ProfileServerFacade's proxy object.
78
79        No operations for SDP can be performed until this is initialized.
80
81        Returns:
82            Dictionary, None if success, error if error.
83        """
84        test_cmd = "profile_server_facade.ProfileServerInit"
85        test_args = {}
86
87        return self.send_command(test_cmd, test_args)
88
89    def cleanUp(self):
90        """Cleans up all objects related to SDP.
91
92        Returns:
93            Dictionary, None if success, error if error.
94        """
95        test_cmd = "profile_server_facade.ProfileServerCleanup"
96        test_args = {}
97
98        return self.send_command(test_cmd, test_args)
99
100    def connectL2cap(self, identifier, psm, mode):
101        """ Sends an outgoing l2cap connection to a connected peer device.
102
103        Args:
104            psm: The psm value to connect over. Available PSMs:
105                SDP 0x0001  See Bluetooth Service Discovery Protocol (SDP)
106                RFCOMM  0x0003  See RFCOMM with TS 07.10
107                TCS-BIN 0x0005  See Bluetooth Telephony Control Specification /
108                    TCS Binary
109                TCS-BIN-CORDLESS    0x0007  See Bluetooth Telephony Control
110                    Specification / TCS Binary
111                BNEP    0x000F  See Bluetooth Network Encapsulation Protocol
112                HID_Control 0x0011  See Human Interface Device
113                HID_Interrupt   0x0013  See Human Interface Device
114                UPnP    0x0015  See [ESDP]
115                AVCTP   0x0017  See Audio/Video Control Transport Protocol
116                AVDTP   0x0019  See Audio/Video Distribution Transport Protocol
117                AVCTP_Browsing  0x001B  See Audio/Video Remote Control Profile
118                UDI_C-Plane 0x001D  See the Unrestricted Digital Information
119                    Profile [UDI]
120                ATT 0x001F  See Bluetooth Core Specification​
121                ​3DSP   0x0021​ ​​See 3D Synchronization Profile.
122                ​LE_PSM_IPSP    ​0x0023 ​See Internet Protocol Support Profile
123                    (IPSP)
124                OTS 0x0025  See Object Transfer Service (OTS)
125                EATT    0x0027  See Bluetooth Core Specification
126            mode: String - The channel mode to connect to. Available values:
127                Basic mode: BASIC
128                Enhanced Retransmission mode: ERTM
129
130        Returns:
131            Dictionary, None if success, error if error.
132        """
133        test_cmd = "profile_server_facade.ProfileServerConnectL2cap"
134        test_args = {"identifier": identifier, "psm": psm, "mode": mode}
135
136        return self.send_command(test_cmd, test_args)
137