• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
137     /**
138      * AddAudioDeviceList
139      *
140      * @brief Add an audio device
141      * @param address[in], The device address
142      * @param deviceType[in], The device type, only support nearing and bt hearing aid
143      * @param name[in], The device name
144      * @return Returns 0 on success, others on failure.
145      */
146     int32_t AddAudioDeviceList(const std::string &address, int32_t deviceType, const std::string &name) override;
147 
148     /**
149      * RemoveAudioDeviceList
150      *
151      * @brief Remove an audio device
152      * @param address[in], The device address
153      * @param deviceType[in], The device type, only support nearing and bt hearing aid
154      * @return Returns 0 on success, others on failure.
155      */
156     int32_t RemoveAudioDeviceList(const std::string &address, int32_t deviceType) override;
157 
158     /**
159      * ResetNearlinkDeviceList
160      *
161      * @brief Reset all nearlink devices
162      * @return Returns 0 on success, others on failure.
163      */
164     int32_t ResetNearlinkDeviceList() override;
165 
166     /**
167      * ResetBtHearingAidDeviceList
168      *
169      * @brief Reset all bt hearing aid devices
170      * @return Returns 0 on success, others on failure.
171      */
172     int32_t ResetBtHearingAidDeviceList() override;
173 
174 private:
175     std::vector<int32_t> getCarrierCallInfoNum(int32_t &callState, std::string &number);
176     void sendEventToVoip(CallAbilityEventId eventId);
177 private:
178     void GetVoipCallState(int32_t &numActive, int32_t &callState, std::string &number);
179     std::shared_ptr<CallControlManager> callControlManagerPtr_;
180     bool sendDtmfState_;
181     int32_t sendDtmfCallId_;
182     std::mutex lock_;
183 };
184 } // namespace Telephony
185 } // namespace OHOS
186 
187 #endif // BLUETOOTH_CALL_SERVICE_H
188