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 #include "hfp_hf_gap_client.h"
17
18 #include "hfp_hf_defines.h"
19
20 namespace OHOS {
21 namespace bluetooth {
RegisterServiceSecurity(const BtAddr & address,uint8_t scn)22 int HfpHfGapClient::RegisterServiceSecurity(const BtAddr &address, uint8_t scn)
23 {
24 GapSecChannel secChan {scn};
25 securityInfo_.direction = OUTGOING;
26 securityInfo_.protocolId = SEC_PROTOCOL_RFCOMM;
27 securityInfo_.channelId = secChan;
28 securityInfo_.serviceId = HFP_HF;
29
30 int ret = GAPIF_RegisterServiceSecurity(&address,
31 &securityInfo_,
32 GAP_SEC_IN_ENCRYPTION | GAP_SEC_IN_AUTHENTICATION | GAP_SEC_OUT_ENCRYPTION | GAP_SEC_OUT_AUTHENTICATION);
33 HFP_HF_RETURN_IF_FAIL(ret);
34 return BT_SUCCESS;
35 }
36
DeregisterServiceSecurity(const BtAddr & address) const37 int HfpHfGapClient::DeregisterServiceSecurity(const BtAddr &address) const
38 {
39 int ret = GAPIF_DeregisterServiceSecurity(&address, &securityInfo_);
40 HFP_HF_RETURN_IF_FAIL(ret);
41 return BT_SUCCESS;
42 }
43 } // namespace bluetooth
44 } // namespace OHOS