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 "avrcp_ct_gap.h"
17 #include "avrcp_ct_internal.h"
18 #include "gap_if.h"
19
20 namespace OHOS {
21 namespace bluetooth {
AvrcCtGapManager()22 AvrcCtGapManager::AvrcCtGapManager()
23 {
24 HILOGI("enter");
25 }
26
~AvrcCtGapManager()27 AvrcCtGapManager::~AvrcCtGapManager()
28 {
29 HILOGI("enter");
30 }
31
RegisterSecurity(void)32 int AvrcCtGapManager::RegisterSecurity(void)
33 {
34 HILOGI("enter");
35
36 int result = BT_SUCCESS;
37
38 GapServiceSecurityInfo avctInfo = {INCOMING, AVRCP_CT, SEC_PROTOCOL_L2CAP, {AVCT_PSM}};
39 result |= GAPIF_RegisterServiceSecurity(nullptr, &avctInfo, GAP_SEC_IN_AUTHENTICATION | GAP_SEC_OUT_AUTHENTICATION);
40 avctInfo.direction = OUTGOING;
41 result |= GAPIF_RegisterServiceSecurity(nullptr, &avctInfo, GAP_SEC_IN_AUTHENTICATION | GAP_SEC_OUT_AUTHENTICATION);
42
43 GapServiceSecurityInfo avctBrinfo = {INCOMING, AVRCP_CT_BROWSING, SEC_PROTOCOL_L2CAP, {AVCT_BR_PSM}};
44 result |=
45 GAPIF_RegisterServiceSecurity(nullptr, &avctBrinfo, GAP_SEC_IN_AUTHENTICATION | GAP_SEC_OUT_AUTHENTICATION);
46 avctBrinfo.direction = OUTGOING;
47 result |=
48 GAPIF_RegisterServiceSecurity(nullptr, &avctBrinfo, GAP_SEC_IN_AUTHENTICATION | GAP_SEC_OUT_AUTHENTICATION);
49
50 (result == BT_SUCCESS) ? (result = BT_SUCCESS) : (result = RET_BAD_STATUS);
51
52 return result;
53 }
54
UnregisterSecurity(void)55 int AvrcCtGapManager::UnregisterSecurity(void)
56 {
57 HILOGI("enter");
58
59 int result = BT_SUCCESS;
60
61 GapServiceSecurityInfo avctInfo = {INCOMING, AVRCP_CT, SEC_PROTOCOL_L2CAP, {AVCT_PSM}};
62 result |= GAPIF_DeregisterServiceSecurity(nullptr, &avctInfo);
63 avctInfo.direction = OUTGOING;
64 result |= GAPIF_DeregisterServiceSecurity(nullptr, &avctInfo);
65
66 GapServiceSecurityInfo avctBrinfo = {INCOMING, AVRCP_CT_BROWSING, SEC_PROTOCOL_L2CAP, {AVCT_BR_PSM}};
67 result |= GAPIF_DeregisterServiceSecurity(nullptr, &avctBrinfo);
68 avctBrinfo.direction = OUTGOING;
69 result |= GAPIF_DeregisterServiceSecurity(nullptr, &avctBrinfo);
70
71 (result == BT_SUCCESS) ? (result = BT_SUCCESS) : (result = RET_BAD_STATUS);
72
73 return result;
74 }
75 } // namespace bluetooth
76 } // namespace OHOS