1 /* 2 * Copyright (c) 2024 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 #ifndef COMMUNICATION_NETMANAGER_BASE_GET_TRAFFIC_STATS_BY_UID_NETWORK_CONTEXT_H 17 #define COMMUNICATION_NETMANAGER_BASE_GET_TRAFFIC_STATS_BY_UID_NETWORK_CONTEXT_H 18 19 #include <cstddef> 20 #include <cstdint> 21 #include <vector> 22 23 #include <napi/native_api.h> 24 25 #include "base_context.h" 26 #include "net_stats_info.h" 27 #include "net_stats_info_sequence.h" 28 29 namespace OHOS { 30 namespace NetManagerStandard { 31 class GetTrafficStatsByUidNetworkContext final : public BaseContext { 32 public: 33 GetTrafficStatsByUidNetworkContext() = delete; 34 explicit GetTrafficStatsByUidNetworkContext(napi_env env, EventManager *manager); 35 36 void SetUid(uint32_t uid); 37 void SetNetBearType(uint32_t bearerType); 38 void SetStartTime(uint32_t startTime); 39 void SetEndTime(uint32_t endTime); 40 void SetSimId(uint32_t simId); 41 uint32_t GetUid() const; 42 uint32_t GetNetBearType() const; 43 uint32_t GetStartTime() const; 44 uint32_t GetEndTime() const; 45 uint32_t GetSimId() const; 46 47 std::vector<NetStatsInfoSequence> &GetNetStatsInfoSequence(); 48 49 void ParseParams(napi_value *params, size_t paramsCount); 50 51 private: 52 bool CheckParamsType(napi_value *params, size_t paramsCount); 53 54 bool CheckNetworkParams(napi_value *params, size_t paramsCount); 55 56 private: 57 uint32_t uid_ = 0; 58 uint32_t netBearType_ = 0; 59 uint32_t startTime_ = 0; 60 uint32_t endTime_ = 0; 61 uint32_t simId_ = UINT32_MAX; 62 63 std::vector<NetStatsInfoSequence> stats_; 64 }; 65 } // namespace NetManagerStandard 66 } // namespace OHOS 67 68 #endif // COMMUNICATION_NETMANAGER_BASE_GET_TRAFFIC_STATS_BY_UID_NETWORK_CONTEXT_H