1 /*
2 * Copyright (c) 2022 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 "net_event_report.h"
17
18 namespace OHOS {
19 namespace NetManagerStandard {
20 namespace {
21 // event name
22 constexpr const char *NET_SHARING_SETUP_FAULT = "NET_SHARING_SETUP_FAULT";
23 constexpr const char *NET_SHARING_CANCEL_FAULT = "NET_SHARING_CANCEL_FAULT";
24 constexpr const char *NET_SHARING_TIME_STAT = "NET_SHARING_TIME_STAT";
25 constexpr const char *NET_VPN_CONNECT_FAULT = "NET_VPN_CONNECT_FAULT";
26 // event params
27 constexpr const char *EVENT_KEY_SHARING_TYPE = "SHARING_TYPE";
28 constexpr const char *EVENT_KEY_OPERATION_TYPE = "OPERATION_TYPE";
29 constexpr const char *EVENT_KEY_SHARING_COUNT = "SHARING_COUNT";
30 constexpr const char *EVENT_KEY_ERROR_TYPE = "ERROR_TYPE";
31 constexpr const char *EVENT_KEY_ERROR_MSG = "ERROR_MSG";
32 constexpr const char *EVENT_KEY_VPN_LEGACY = "VPN_LEGACY";
33 constexpr const char *EVENT_KEY_VPN_ERROR_TYPE = "VPN_ERROR_TYPE";
34 constexpr const char *EVENT_KEY_VPN_ERROR_MSG = "VPN_ERROR_MSG";
35 constexpr int32_t NETMANAGER_EXT_SUCCESS = 0;
36 } // namespace
37
SendSetupFaultEvent(const EventInfo & eventInfo)38 int32_t NetEventReport::SendSetupFaultEvent(const EventInfo &eventInfo)
39 {
40 HiSysEventWrite(HiSysEvent::Domain::NETMANAGER_STANDARD, NET_SHARING_SETUP_FAULT, HiSysEvent::EventType::FAULT,
41 EVENT_KEY_SHARING_TYPE, eventInfo.sharingType, EVENT_KEY_OPERATION_TYPE, eventInfo.operatorType,
42 EVENT_KEY_ERROR_TYPE, eventInfo.errorType, EVENT_KEY_ERROR_MSG, eventInfo.errorMsg);
43 return NETMANAGER_EXT_SUCCESS;
44 }
45
SendCancleFaultEvent(const EventInfo & eventInfo)46 int32_t NetEventReport::SendCancleFaultEvent(const EventInfo &eventInfo)
47 {
48 HiSysEventWrite(HiSysEvent::Domain::NETMANAGER_STANDARD, NET_SHARING_CANCEL_FAULT, HiSysEvent::EventType::FAULT,
49 EVENT_KEY_SHARING_TYPE, eventInfo.sharingType, EVENT_KEY_OPERATION_TYPE, eventInfo.operatorType,
50 EVENT_KEY_ERROR_TYPE, eventInfo.errorType, EVENT_KEY_ERROR_MSG, eventInfo.errorMsg);
51 return NETMANAGER_EXT_SUCCESS;
52 }
53
SendTimeBehaviorEvent(const EventInfo & eventInfo)54 int32_t NetEventReport::SendTimeBehaviorEvent(const EventInfo &eventInfo)
55 {
56 HiSysEventWrite(HiSysEvent::Domain::NETMANAGER_STANDARD, NET_SHARING_TIME_STAT, HiSysEvent::EventType::BEHAVIOR,
57 EVENT_KEY_SHARING_COUNT, eventInfo.sharingCount, EVENT_KEY_SHARING_TYPE, eventInfo.sharingType);
58 return NETMANAGER_EXT_SUCCESS;
59 }
60
SendVpnConnectEvent(const VpnEventInfo & eventInfo)61 int32_t NetEventReport::SendVpnConnectEvent(const VpnEventInfo &eventInfo)
62 {
63 HiSysEventWrite(HiSysEvent::Domain::NETMANAGER_STANDARD, NET_VPN_CONNECT_FAULT, HiSysEvent::EventType::FAULT,
64 EVENT_KEY_VPN_LEGACY, eventInfo.legacy, EVENT_KEY_OPERATION_TYPE, eventInfo.operatorType,
65 EVENT_KEY_VPN_ERROR_TYPE, eventInfo.errorType, EVENT_KEY_VPN_ERROR_MSG, eventInfo.errorMsg);
66 return NETMANAGER_EXT_SUCCESS;
67 }
68 } // namespace NetManagerStandard
69 } // namespace OHOS