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 } // namespace
36
SendSetupFaultEvent(const EventInfo & eventInfo)37 void NetEventReport::SendSetupFaultEvent(const EventInfo &eventInfo)
38 {
39 HiSysEventWrite(HiSysEvent::Domain::NETMANAGER_STANDARD, NET_SHARING_SETUP_FAULT, HiSysEvent::EventType::FAULT,
40 EVENT_KEY_SHARING_TYPE, eventInfo.sharingType, EVENT_KEY_OPERATION_TYPE, eventInfo.operatorType,
41 EVENT_KEY_ERROR_TYPE, eventInfo.errorType, EVENT_KEY_ERROR_MSG, eventInfo.errorMsg);
42 }
43
SendCancleFaultEvent(const EventInfo & eventInfo)44 void NetEventReport::SendCancleFaultEvent(const EventInfo &eventInfo)
45 {
46 HiSysEventWrite(HiSysEvent::Domain::NETMANAGER_STANDARD, NET_SHARING_CANCEL_FAULT, HiSysEvent::EventType::FAULT,
47 EVENT_KEY_SHARING_TYPE, eventInfo.sharingType, EVENT_KEY_OPERATION_TYPE, eventInfo.operatorType,
48 EVENT_KEY_ERROR_TYPE, eventInfo.errorType, EVENT_KEY_ERROR_MSG, eventInfo.errorMsg);
49 }
50
SendTimeBehaviorEvent(const EventInfo & eventInfo)51 void NetEventReport::SendTimeBehaviorEvent(const EventInfo &eventInfo)
52 {
53 HiSysEventWrite(HiSysEvent::Domain::NETMANAGER_STANDARD, NET_SHARING_TIME_STAT, HiSysEvent::EventType::BEHAVIOR,
54 EVENT_KEY_SHARING_COUNT, eventInfo.sharingCount, EVENT_KEY_SHARING_TYPE, eventInfo.sharingType);
55 }
56
SendVpnConnectEvent(const VpnEventInfo & eventInfo)57 void NetEventReport::SendVpnConnectEvent(const VpnEventInfo &eventInfo)
58 {
59 HiSysEventWrite(HiSysEvent::Domain::NETMANAGER_STANDARD, NET_VPN_CONNECT_FAULT, HiSysEvent::EventType::FAULT,
60 EVENT_KEY_VPN_LEGACY, eventInfo.legacy, EVENT_KEY_OPERATION_TYPE, eventInfo.operatorType,
61 EVENT_KEY_VPN_ERROR_TYPE, eventInfo.errorType, EVENT_KEY_VPN_ERROR_MSG, eventInfo.errorMsg);
62 }
63 } // namespace NetManagerStandard
64 } // namespace OHOS