1 /*
2  * Copyright (C) 2021 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 <memory>
20 
21 #include "btif/include/btif_hf.h"
22 #include "include/hardware/bluetooth_headset_callbacks.h"
23 #include "rust/cxx.h"
24 #include "types/raw_address.h"
25 
26 namespace bluetooth {
27 namespace topshim {
28 namespace rust {
29 
30 struct TelephonyDeviceStatus;
31 struct CallInfo;
32 struct PhoneState;
33 
34 class HfpIntf {
35  public:
HfpIntf(headset::Interface * intf)36   HfpIntf(headset::Interface* intf) : intf_(intf){};
37 
38   int init();
39   uint32_t connect(RawAddress addr);
40   int connect_audio(RawAddress addr, bool sco_offload, int disabled_codecs);
41   int set_active_device(RawAddress addr);
42   int set_volume(int8_t volume, RawAddress addr);
43   uint32_t set_mic_volume(int8_t volume, RawAddress addr);
44   uint32_t disconnect(RawAddress addr);
45   int disconnect_audio(RawAddress addr);
46   uint32_t device_status_notification(TelephonyDeviceStatus status, RawAddress addr);
47   uint32_t indicator_query_response(
48       TelephonyDeviceStatus device_status, PhoneState phone_state, RawAddress addr);
49   uint32_t current_calls_query_response(const ::rust::Vec<CallInfo>& call_list, RawAddress addr);
50   uint32_t phone_state_change(
51       PhoneState phone_state, const ::rust::String& number, RawAddress addr);
52   uint32_t simple_at_response(bool ok, RawAddress addr);
53   void debug_dump();
54   void cleanup();
55 
56  private:
57   headset::Interface* intf_;
58 };
59 
60 std::unique_ptr<HfpIntf> GetHfpProfile(const unsigned char* btif);
61 bool interop_insert_call_when_sco_start(RawAddress addr);
62 
63 }  // namespace rust
64 }  // namespace topshim
65 }  // namespace bluetooth
66