1 /*
2  * Copyright (c) 2023-2023 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 "thermal_strategy.h"
17 
18 #include "dps_event_report.h"
19 #include "events_monitor.h"
20 
21 namespace OHOS {
22 namespace CameraStandard {
23 namespace DeferredProcessing {
24 namespace {
25     const std::string THERMAL_EVENT_ID = "0";
26     constexpr int32_t DEFAULT_LEVEL = 0;
27 }
28 
ThermalStrategy()29 ThermalStrategy::ThermalStrategy()
30 {
31     DP_DEBUG_LOG("entered.");
32 }
33 
~ThermalStrategy()34 ThermalStrategy::~ThermalStrategy()
35 {
36     DP_DEBUG_LOG("entered.");
37 }
38 
handleEvent(const EventFwk::CommonEventData & data)39 void ThermalStrategy::handleEvent(const EventFwk::CommonEventData& data)
40 {
41     AAFwk::Want want = data.GetWant();
42     int level = want.GetIntParam(THERMAL_EVENT_ID, DEFAULT_LEVEL);
43     DPSEventReport::GetInstance().SetTemperatureLevel(level);
44     DP_INFO_LOG("OnThermalLevelChanged level:%{public}d", level);
45     // 需要整改归一化图片和视频接收到温度事件的出来
46     EventsMonitor::GetInstance().NotifySystemPressureLevel(MapEventThermalLevel(level));
47     EventsMonitor::GetInstance().NotifyThermalLevel(level);
48 }
49 } // namespace DeferredProcessing
50 } // namespace CameraStandard
51 } // namespace OHOS