1 /*
2  * Copyright 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "bta/include/bta_api.h"  // tBTA_DM_SEARCH_CBACK
20 #include "stack/include/bt_hdr.h"
21 #include "types/bt_transport.h"
22 #include "types/raw_address.h"
23 
24 // Bta module start and stop entry points
25 void bta_dm_disc_start(bool delay_close_gatt);
26 void bta_dm_disc_stop();
27 
28 // Bta device discovery start and stop entry points
29 void bta_dm_disc_start_device_discovery(tBTA_DM_SEARCH_CBACK*);
30 void bta_dm_disc_stop_device_discovery();
31 
32 // Bta service discovery start and stop entry points
33 void bta_dm_disc_start_service_discovery(service_discovery_callbacks cbacks,
34                                          const RawAddress& bd_addr,
35                                          tBT_TRANSPORT transport);
36 
37 // Bta subsystem entrypoint and lifecycle
38 // Remove when separate_service_and_device_discovery rolls out
39 void bta_dm_disc_disable_search_and_disc();
40 void bta_dm_disc_disable_disc();
41 void bta_dm_disc_disable_search();
42 // Indication that an acl has gone down and to examine the current
43 // service discovery procedure, if any.
44 void bta_dm_disc_acl_down(const RawAddress& bd_addr, tBT_TRANSPORT transport);
45 
46 // LE observe and scan interface
47 void bta_dm_ble_scan(bool start, uint8_t duration_sec, bool low_latency_scan);
48 void bta_dm_ble_csis_observe(bool observe, tBTA_DM_SEARCH_CBACK* p_cback);
49 
50 // Checks if there is a device discovery request queued
51 bool bta_dm_is_search_request_queued();
52 
53 // Proceed to execute service discovery on next device in queue
54 void bta_dm_disc_discover_next_device();
55 
56 // GATT service discovery
57 void bta_dm_disc_gattc_register();
58 void bta_dm_disc_gatt_cancel_open(const RawAddress& bd_addr);
59 void bta_dm_disc_gatt_refresh(const RawAddress& bd_addr);
60 
61 // Stop service discovery procedure, if any, for removed device
62 void bta_dm_disc_remove_device(const RawAddress& bd_addr);
63 
64 // Provide data for the dumpsys procedure
65 void DumpsysBtaDmDisc(int fd);