1 /* 2 * Copyright (c) 2025 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 "report_hisysevent_data.h" 17 18 namespace OHOS { 19 namespace BackgroundTaskMgr { AddData(const sptr<EfficiencyResourceInfo> & resourceInfo,const std::shared_ptr<ResourceCallbackInfo> & callbackInfo)20bool EfficiencyResourceApplyReportHisysEvent::AddData(const sptr<EfficiencyResourceInfo> &resourceInfo, 21 const std::shared_ptr<ResourceCallbackInfo> &callbackInfo) 22 { 23 if (length_ == MAX_EFFICIENTCY_RESOURCE_HISYSEVCENT_DATA_LENGTH) { 24 return false; 25 } 26 appUid_.push_back(callbackInfo->GetUid()); 27 appPid_.push_back(callbackInfo->GetPid()); 28 appName_.push_back(callbackInfo->GetBundleName()); 29 uiabilityIdentity_.push_back(-1); 30 resourceType_.push_back(callbackInfo->GetResourceNumber()); 31 timeout_.push_back(resourceInfo->GetTimeOut()); 32 persist_.push_back(resourceInfo->IsPersist()); 33 process_.push_back(resourceInfo->IsProcess()); 34 length_++; 35 return true; 36 } 37 ClearData()38void EfficiencyResourceApplyReportHisysEvent::ClearData() 39 { 40 appUid_.clear(); 41 appPid_.clear(); 42 appName_.clear(); 43 uiabilityIdentity_.clear(); 44 resourceType_.clear(); 45 timeout_.clear(); 46 persist_.clear(); 47 process_.clear(); 48 length_ = 0; 49 } 50 AddData(const std::shared_ptr<ResourceCallbackInfo> & callbackInfo,EfficiencyResourcesEventType type)51bool EfficiencyResourceResetReportHisysEvent::AddData(const std::shared_ptr<ResourceCallbackInfo> &callbackInfo, 52 EfficiencyResourcesEventType type) 53 { 54 if (length_ == MAX_EFFICIENTCY_RESOURCE_HISYSEVCENT_DATA_LENGTH) { 55 return false; 56 } 57 appUid_.push_back(callbackInfo->GetUid()); 58 appPid_.push_back(callbackInfo->GetPid()); 59 appName_.push_back(callbackInfo->GetBundleName()); 60 uiabilityIdentity_.push_back(-1); 61 resourceType_.push_back(callbackInfo->GetResourceNumber()); 62 if (type == EfficiencyResourcesEventType::APP_RESOURCE_RESET) { 63 process_.push_back(false); 64 } else { 65 process_.push_back(true); 66 } 67 quota_.push_back(0); 68 allQuota_.push_back(0); 69 length_++; 70 return true; 71 } 72 ClearData()73void EfficiencyResourceResetReportHisysEvent::ClearData() 74 { 75 appUid_.clear(); 76 appPid_.clear(); 77 appName_.clear(); 78 uiabilityIdentity_.clear(); 79 resourceType_.clear(); 80 process_.clear(); 81 quota_.clear(); 82 allQuota_.clear(); 83 length_ = 0; 84 } 85 } // namespace BackgroundTaskMgr 86 } // namespace OHOS