• 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 "net_stats_history.h"
17 
18 #include "net_mgr_log_wrapper.h"
19 #include "net_stats_constants.h"
20 
21 namespace OHOS {
22 namespace NetManagerStandard {
23 
GetHistory(std::vector<NetStatsInfo> & recv,uint64_t start,uint64_t end)24 int32_t NetStatsHistory::GetHistory(std::vector<NetStatsInfo> &recv, uint64_t start, uint64_t end)
25 {
26     auto handler = std::make_unique<NetStatsDataHandler>();
27     if (handler == nullptr) {
28         NETMGR_LOG_E("NetStatsDataHandler instance is nullptr");
29         return NETMANAGER_ERR_INTERNAL;
30     }
31     return handler->ReadStatsData(recv, start, end);
32 }
33 
GetHistory(std::vector<NetStatsInfo> & recv,uint32_t uid,uint64_t start,uint64_t end)34 int32_t NetStatsHistory::GetHistory(std::vector<NetStatsInfo> &recv, uint32_t uid, uint64_t start, uint64_t end)
35 {
36     auto handler = std::make_unique<NetStatsDataHandler>();
37     if (handler == nullptr) {
38         NETMGR_LOG_E("NetStatsDataHandler instance is nullptr");
39         return NETMANAGER_ERR_INTERNAL;
40     }
41     return handler->ReadStatsData(recv, uid, start, end);
42 }
43 
GetHistory(std::vector<NetStatsInfo> & recv,const std::string & iface,uint64_t start,uint64_t end)44 int32_t NetStatsHistory::GetHistory(std::vector<NetStatsInfo> &recv, const std::string &iface, uint64_t start,
45                                     uint64_t end)
46 {
47     auto handler = std::make_unique<NetStatsDataHandler>();
48     if (handler == nullptr) {
49         NETMGR_LOG_E("NetStatsDataHandler instance is nullptr");
50         return NETMANAGER_ERR_INTERNAL;
51     }
52     return handler->ReadStatsData(recv, iface, start, end);
53 }
54 
GetHistory(std::vector<NetStatsInfo> & recv,const std::string & iface,uint32_t uid,uint64_t start,uint64_t end)55 int32_t NetStatsHistory::GetHistory(std::vector<NetStatsInfo> &recv, const std::string &iface, uint32_t uid,
56                                     uint64_t start, uint64_t end)
57 {
58     auto handler = std::make_unique<NetStatsDataHandler>();
59     if (handler == nullptr) {
60         NETMGR_LOG_E("NetStatsDataHandler instance is nullptr");
61         return NETMANAGER_ERR_INTERNAL;
62     }
63     return handler->ReadStatsData(recv, iface, uid, start, end);
64 }
65 
GetHistoryByIdent(std::vector<NetStatsInfo> & recv,const std::string & ident,uint64_t start,uint64_t end)66 int32_t NetStatsHistory::GetHistoryByIdent(std::vector<NetStatsInfo> &recv, const std::string &ident, uint64_t start,
67                                            uint64_t end)
68 {
69     auto handler = std::make_unique<NetStatsDataHandler>();
70     if (handler == nullptr) {
71         NETMGR_LOG_E("NetStatsDataHandler instance is nullptr");
72         return NETMANAGER_ERR_INTERNAL;
73     }
74     return handler->ReadStatsDataByIdent(recv, ident, start, end);
75 }
76 
GetHistory(std::vector<NetStatsInfo> & recv,uint32_t uid,const std::string & ident,uint64_t start,uint64_t end)77 int32_t NetStatsHistory::GetHistory(std::vector<NetStatsInfo> &recv, uint32_t uid, const std::string &ident,
78                                     uint64_t start, uint64_t end)
79 {
80     auto handler = std::make_unique<NetStatsDataHandler>();
81     if (handler == nullptr) {
82         NETMGR_LOG_E("NetStatsDataHandler instance is nullptr");
83         return NETMANAGER_ERR_INTERNAL;
84     }
85     return handler->ReadStatsData(recv, uid, ident, start, end);
86 }
87 } // namespace NetManagerStandard
88 } // namespace OHOS