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_ag_gap_server.h"
17 
18 #include "hfp_ag_defines.h"
19 
20 namespace OHOS {
21 namespace bluetooth {
22 GapServiceSecurityInfo HfpAgGapServer::g_securityInfo;
23 
RegisterServiceSecurity(uint8_t scn)24 int HfpAgGapServer::RegisterServiceSecurity(uint8_t scn)
25 {
26     GapSecChannel secChan {scn};
27     g_securityInfo.direction = INCOMING;
28     g_securityInfo.protocolId = SEC_PROTOCOL_RFCOMM;
29     g_securityInfo.channelId = secChan;
30     g_securityInfo.serviceId = HFP_AG;
31 
32     int ret = GAPIF_RegisterServiceSecurity(nullptr,
33         &g_securityInfo,
34         GAP_SEC_IN_ENCRYPTION | GAP_SEC_IN_AUTHENTICATION | GAP_SEC_OUT_ENCRYPTION | GAP_SEC_OUT_AUTHENTICATION);
35     HFP_AG_RETURN_IF_FAIL(ret);
36     return BT_SUCCESS;
37 }
38 
DeregisterServiceSecurity()39 int HfpAgGapServer::DeregisterServiceSecurity()
40 {
41     int ret = GAPIF_DeregisterServiceSecurity(nullptr, &g_securityInfo);
42     HFP_AG_RETURN_IF_FAIL(ret);
43     return BT_SUCCESS;
44 }
45 }  // namespace bluetooth
46 }  // namespace OHOS