1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. 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 #ifndef NETWORK_H 17 #define NETWORK_H 18 #include "sp_profiler.h" 19 namespace OHOS { 20 namespace SmartPerf { 21 class Network : public SpProfiler { 22 public: 23 std::map<std::string, std::string> ItemData() override; GetInstance()24 static Network &GetInstance() 25 { 26 static Network instance; 27 return instance; 28 } 29 std::map<std::string, std::string> GetNetworkInfo(); 30 void GetCurNetwork(long long &networkCurRx, long long &networkCurTx); 31 void IsFindHap(); 32 void IsStopFindHap(); 33 void ThreadGetHapNetwork(); 34 void ClearHapFlag(); 35 void ThreadFunctions(); 36 std::map<std::string, std::string> GetNetworkInfoDev(); 37 private: Network()38 Network() {}; 39 Network(const Network &); 40 Network &operator = (const Network &); 41 std::map<std::string, std::string> result; 42 long long rmnetCurRx = 0; 43 long long rmnetCurTx = 0; 44 long long ethCurRx = 0; 45 long long ethCurTx = 0; 46 long long wlanCurRx = 0; 47 long long wlanCurTx = 0; 48 long long allTx = 0; 49 long long allRx = 0; 50 long long curTx = 0; 51 long long curRx = 0; 52 long long diffTx = 0; 53 long long diffRx = 0; 54 bool isFirst = true; 55 bool hapFlag = false; 56 bool stophapFlag = false; 57 }; 58 } 59 } 60 #endif // NETWORK_H 61