• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "wifi_hisysevent.h"
17 #include "hisysevent.h"
18 #include "wifi_logger.h"
19 
20 namespace OHOS {
21 namespace Wifi {
22 DEFINE_WIFILOG_LABEL("WifiHiSysEvent");
23 
24 template<typename... Types>
WriteEvent(const std::string & eventType,Types...args)25 static void WriteEvent(const std::string& eventType, Types... args)
26 {
27     int ret = HiviewDFX::HiSysEvent::Write(HiviewDFX::HiSysEvent::Domain::COMMUNICATION, eventType,
28         HiviewDFX::HiSysEvent::EventType::STATISTIC, args...);
29     if (ret != 0) {
30         WIFI_LOGE("Write event fail: %{public}s", eventType.c_str());
31     }
32 }
33 
WriteWifiStateHiSysEvent(const std::string & serviceType,WifiOperType operType)34 void WriteWifiStateHiSysEvent(const std::string& serviceType, WifiOperType operType)
35 {
36     WriteEvent("WIFI_STATE", "TYPE", serviceType, "OPER_TYPE", static_cast<int>(operType));
37 }
38 
WriteWifiConnectionHiSysEvent(const WifiConnectionType & type,const std::string & pkgName)39 void WriteWifiConnectionHiSysEvent(const WifiConnectionType& type, const std::string& pkgName)
40 {
41     WriteEvent("WIFI_CONNECTION", "TYPE", static_cast<int>(type), "PACKAGE_NAME", pkgName);
42 }
43 
WriteWifiScanHiSysEvent(const int result,const std::string & pkgName)44 void WriteWifiScanHiSysEvent(const int result, const std::string& pkgName)
45 {
46     WriteEvent("WIFI_SCAN", "EXECUTE_RESULT", result, "PACKAGE_NAME", pkgName);
47 }
48 
WriteWifiEventReceivedHiSysEvent(const std::string & eventType,int value)49 void WriteWifiEventReceivedHiSysEvent(const std::string& eventType, int value)
50 {
51     WriteEvent("WIFI_EVENT_RECEIVED", "EVENT_TYPE", eventType, "VALUE", value);
52 }
53 }  // namespace Wifi
54 }  // namespace OHOS