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_CANCLE_FAULT = "NET_SHARING_CANCLE_FAULT";
24 constexpr const char *NET_SHARING_TIME_STAT = "NET_SHARING_TIME_STAT";
25 // event params
26 constexpr const char *EVENT_KEY_SHARING_TYPE = "SHARING_TYPE";
27 constexpr const char *EVENT_KEY_OPERATION_TYPE = "OPERATION_TYPE";
28 constexpr const char *EVENT_KEY_SHARING_COUNT = "SHARING_COUNT";
29 constexpr const char *EVENT_KEY_ERROR_TYPE = "ERROR_TYPE";
30 constexpr const char *EVENT_KEY_ERROR_MSG = "ERROR_MSG";
31 } // namespace
32
SendSetupFaultEvent(const EventInfo & eventInfo)33 void NetEventReport::SendSetupFaultEvent(const EventInfo &eventInfo)
34 {
35 HiSysEvent::Write(
36 HiSysEvent::Domain::NETMANAGER_STANDARD,
37 NET_SHARING_SETUP_FAULT,
38 HiSysEvent::EventType::FAULT,
39 EVENT_KEY_SHARING_TYPE, eventInfo.sharingType,
40 EVENT_KEY_OPERATION_TYPE, eventInfo.operatorType,
41 EVENT_KEY_ERROR_TYPE, eventInfo.errorType,
42 EVENT_KEY_ERROR_MSG, eventInfo.errorMsg);
43 }
44
SendCancleFaultEvent(const EventInfo & eventInfo)45 void NetEventReport::SendCancleFaultEvent(const EventInfo &eventInfo)
46 {
47 HiSysEvent::Write(
48 HiSysEvent::Domain::NETMANAGER_STANDARD,
49 NET_SHARING_CANCLE_FAULT,
50 HiSysEvent::EventType::FAULT,
51 EVENT_KEY_SHARING_TYPE, eventInfo.sharingType,
52 EVENT_KEY_OPERATION_TYPE, eventInfo.operatorType,
53 EVENT_KEY_ERROR_TYPE, eventInfo.errorType,
54 EVENT_KEY_ERROR_MSG, eventInfo.errorMsg);
55 }
56
SendTimeBehaviorEvent(const EventInfo & eventInfo)57 void NetEventReport::SendTimeBehaviorEvent(const EventInfo &eventInfo)
58 {
59 HiSysEvent::Write(
60 HiSysEvent::Domain::NETMANAGER_STANDARD,
61 NET_SHARING_TIME_STAT,
62 HiSysEvent::EventType::BEHAVIOR,
63 EVENT_KEY_SHARING_COUNT, eventInfo.sharingCount,
64 EVENT_KEY_SHARING_TYPE, eventInfo.sharingType);
65 }
66 } // namespace NetManagerStandard
67 } // namespace OHOS