blob: 5c473f2e0bca63213291e1a10bbbe40f736f0296 [file] [log] [blame]
Myles Watsonefa25d72022-10-03 16:27:32 -07001/*
2 * Copyright 2022 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 <unistd.h>
20
21namespace aidl::android::hardware::bluetooth::impl {
22
23class NetBluetoothMgmt {
24 public:
25 NetBluetoothMgmt() {}
26 ~NetBluetoothMgmt() {
27 ::close(rfkill_fd_);
28 ::close(bt_fd_);
29 }
30
31 int openHci(int hci_interface = 0);
32 void closeHci();
33
34 private:
35 int waitHciDev(int hci_interface);
36 int openRfkill();
37 int rfkill(int block);
38
39 // Index of the first rfkill device of type bluetooth.
40 int rfkill_bt_index_{-1};
41 // File descriptor opened to /dev/rfkill.
42 int rfkill_fd_{-1};
43 // File descriptor opened to the bluetooth user channel.
44 int bt_fd_{-1};
45};
46
47} // namespace aidl::android::hardware::bluetooth::impl