1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef BLUETOOTH_CALL_SERVICE_H
17 #define BLUETOOTH_CALL_SERVICE_H
18 
19 #include <memory>
20 
21 #include "bluetooth_call_policy.h"
22 #include "bluetooth_call_stub.h"
23 #include "call_control_manager.h"
24 
25 namespace OHOS {
26 namespace Telephony {
27 class BluetoothCallService : public BluetoothCallStub, public BluetoothCallPolicy {
28 public:
29     BluetoothCallService();
30     ~BluetoothCallService();
31     /**
32      * AnswerCall
33      *
34      * @brief Answer a phone call
35      * @return Returns 0 on success, others on failure.
36      */
37     int32_t AnswerCall() override;
38 
39     /**
40      * RejectCall
41      *
42      * @brief Reject a phone call
43      * @return Returns 0 on success, others on failure.
44      */
45     int32_t RejectCall() override;
46 
47     /**
48      * HangUpCall
49      *
50      * @brief Hang up the phone
51      * @return Returns 0 on success, others on failure.
52      */
53     int32_t HangUpCall() override;
54 
55     /**
56      * GetCallState
57      *
58      * @brief Obtain the call status of the device
59      * @return Returns 0 on success, others on failure.
60      */
61     int32_t GetCallState() override;
62 
63     /**
64      * HoldCall
65      *
66      * @brief Park a phone call
67      * @return Returns 0 on success, others on failure.
68      */
69     int32_t HoldCall() override;
70 
71     /**
72      * UnHoldCall
73      *
74      * @brief Activate a phone call
75      * @return Returns 0 on success, others on failure.
76      */
77     int32_t UnHoldCall() override;
78 
79     /**
80      * SwitchCall
81      *
82      * @brief Switch the phone
83      * @return Returns 0 on success, others on failure.
84      */
85     int32_t SwitchCall() override;
86 
87     /**
88      * StartDtmf
89      *
90      * @brief Enable and send DTMF
91      * @param str[in], Characters sent
92      * @return Returns 0 on success, others on failure.
93      */
94     int32_t StartDtmf(char str) override;
95 
96     /**
97      * StopDtmf
98      *
99      * @brief Stop the DTMF
100      * @return Returns 0 on success, others on failure.
101      */
102     int32_t StopDtmf() override;
103 
104     /**
105      * CombineConference
106      *
107      * @brief Merge calls to form a conference
108      * @return Returns 0 on success, others on failure.
109      */
110     int32_t CombineConference() override;
111 
112     /**
113      * SeparateConference
114      *
115      * @brief Separates a specified call from a conference call
116      * @return Returns 0 on success, others on failure.
117      */
118     int32_t SeparateConference() override;
119 
120     /**
121      * KickOutFromConference
122      *
123      * @brief Kick out a specified call from a conference call
124      * @return Returns 0 on success, others on failure.
125      */
126     int32_t KickOutFromConference() override;
127 
128     /**
129      * GetCurrentCallList
130      *
131      * @brief Get current call list
132      * @param slotId[in], The slot id
133      * @return Returns call info list.
134      */
135     std::vector<CallAttributeInfo> GetCurrentCallList(int32_t slotId) override;
136 private:
137     std::shared_ptr<CallControlManager> callControlManagerPtr_;
138     bool sendDtmfState_;
139     int32_t sendDtmfCallId_;
140     std::mutex lock_;
141 };
142 } // namespace Telephony
143 } // namespace OHOS
144 
145 #endif // BLUETOOTH_CALL_SERVICE_H
146