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 #include "info_collection/rs_hardware_compose_disabled_reason_collection.h" 17 18 namespace OHOS { 19 namespace Rosen { GetInstance()20HwcDisabledReasonCollection& HwcDisabledReasonCollection::GetInstance() 21 { 22 static HwcDisabledReasonCollection instance; 23 return instance; 24 } 25 HwcDisabledReasonCollection()26HwcDisabledReasonCollection::HwcDisabledReasonCollection() 27 { 28 } 29 ~HwcDisabledReasonCollection()30HwcDisabledReasonCollection::~HwcDisabledReasonCollection() noexcept 31 { 32 } 33 UpdateHwcDisabledReasonForDFX(NodeId id,int32_t disabledReason,const std::string & nodeName)34void HwcDisabledReasonCollection::UpdateHwcDisabledReasonForDFX(NodeId id, 35 int32_t disabledReason, const std::string& nodeName) 36 { 37 std::lock_guard<std::mutex> lock(hwcDisabledReasonMtx_); 38 auto& hwcDisabledReasonInfo = hwcDisabledReasonInfoMap_[id]; 39 ++hwcDisabledReasonInfo.disabledReasonStatistics[disabledReason]; 40 hwcDisabledReasonInfo.pidOfBelongsApp = ExtractPid(id); 41 hwcDisabledReasonInfo.nodeName = nodeName; 42 } 43 GetHwcDisabledReasonInfo()44HwcDisabledReasonInfos HwcDisabledReasonCollection::GetHwcDisabledReasonInfo() 45 { 46 std::lock_guard<std::mutex> lock(hwcDisabledReasonMtx_); 47 HwcDisabledReasonInfos hwcDisabledReasonInfos; 48 for (const auto& hwcDisabledReasonInfo : hwcDisabledReasonInfoMap_) { 49 hwcDisabledReasonInfos.emplace_back(hwcDisabledReasonInfo.second); 50 } 51 hwcDisabledReasonInfoMap_.clear(); 52 return hwcDisabledReasonInfos; 53 } 54 } // namespace Rosen 55 } // namespace OHOS