1 /*
2  * Copyright (C) 2021-2023 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_PROXY_H
17 #define BLUETOOTH_CALL_PROXY_H
18 
19 #include <cstdio>
20 #include <string>
21 
22 #include "iremote_broker.h"
23 #include "iremote_proxy.h"
24 #include "pac_map.h"
25 
26 #include "bluetooth_call_ipc_interface_code.h"
27 #include "call_manager_inner_type.h"
28 #include "i_bluetooth_call.h"
29 #include "telephony_log_wrapper.h"
30 
31 namespace OHOS {
32 namespace Telephony {
33 class BluetoothCallProxy : public IRemoteProxy<IBluetoothCall> {
34 public:
35     /**
36      * BluetoothCallProxy
37      *
38      * @param impl
39      */
40     explicit BluetoothCallProxy(const sptr<IRemoteObject> &impl);
41     virtual ~BluetoothCallProxy() = default;
42 
43     /**
44      * AnswerCall
45      *
46      * @brief Answer a phone call
47      * @return Returns 0 on success, others on failure.
48      */
49     int32_t AnswerCall() override;
50 
51     /**
52      * RejectCall
53      *
54      * @brief Reject a phone call
55      * @return Returns 0 on success, others on failure.
56      */
57     int32_t RejectCall() override;
58 
59     /**
60      * HangUpCall
61      *
62      * @brief Hang up the phone
63      * @return Returns 0 on success, others on failure.
64      */
65     int32_t HangUpCall() override;
66 
67     /**
68      * GetCallState
69      *
70      * @brief Obtain the call status of the device
71      * @return Returns 0 on success, others on failure.
72      */
73     int32_t GetCallState() override;
74 
75     /**
76      * HoldCall
77      *
78      * @brief Park a phone call
79      * @return Returns 0 on success, others on failure.
80      */
81     int32_t HoldCall() override;
82 
83     /**
84      * UnHoldCall
85      *
86      * @brief Activate a phone call
87      * @return Returns 0 on success, others on failure.
88      */
89     int32_t UnHoldCall() override;
90 
91     /**
92      * SwitchCall
93      *
94      * @brief Switch the phone
95      * @return Returns 0 on success, others on failure.
96      */
97     int32_t SwitchCall() override;
98 
99     /**
100      * StartDtmf
101      *
102      * @brief Enable and send DTMF
103      * @param str[in], Characters sent
104      * @return Returns 0 on success, others on failure.
105      */
106     int32_t StartDtmf(char str) override;
107 
108     /**
109      * StopDtmf
110      *
111      * @brief Stop the DTMF
112      * @return Returns 0 on success, others on failure.
113      */
114     int32_t StopDtmf() override;
115 
116     /**
117      * CombineConference
118      *
119      * @brief Merge calls to form a conference
120      * @return Returns 0 on success, others on failure.
121      */
122     int32_t CombineConference() override;
123 
124     /**
125      * SeparateConference
126      *
127      * @brief Separates a specified call from a conference call
128      * @return Returns 0 on success, others on failure.
129      */
130     int32_t SeparateConference() override;
131 
132     /**
133      * KickOutFromConference
134      *
135      * @brief Hangup a specified call from a conference call
136      * @return Returns 0 on success, others on failure.
137      */
138     int32_t KickOutFromConference() override;
139 
140     /**
141      * GetCurrentCallList
142      *
143      * @brief Get current call list
144      * @param slotId[in], The slot id
145      * @return Returns call info list.
146      */
147     std::vector<CallAttributeInfo> GetCurrentCallList(int32_t slotId) override;
148 
149 private:
150     int32_t SendRequest(BluetoothCallInterfaceCode code);
151     int32_t SendRequest(BluetoothCallInterfaceCode code, MessageParcel &dataParcel, MessageParcel &replyParcel);
152 
153 private:
154     static inline BrokerDelegator<BluetoothCallProxy> delegator_;
155 };
156 } // namespace Telephony
157 } // namespace OHOS
158 
159 #endif // BLUETOOTH_CALL_PROXY_H