1# Copyright (c) 2021-2023 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("../thermalmgr.gni")
15
16config("thermalsrv_public_config") {
17  include_dirs = [
18    "native/include/",
19    "native/include/thermal_action",
20    "native/include/thermal_observer",
21    "native/include/thermal_policy",
22    "native/include/thermal_observer/state_machine",
23    "native/include/thermal_action/action",
24    "native/include/thermal_action/action/action_soc",
25    "${thermal_inner_api}/native/include",
26  ]
27}
28
29ohos_shared_library("thermalservice") {
30  sanitize = {
31    cfi = true
32    cfi_cross_dso = true
33    debug = false
34  }
35  branch_protector_ret = "pac_ret"
36
37  sources = [
38    "native/src/fan_callback.cpp",
39    "native/src/thermal_action/action/action_airplane.cpp",
40    "native/src/thermal_action/action/action_application_process.cpp",
41    "native/src/thermal_action/action/action_charger.cpp",
42    "native/src/thermal_action/action/action_display.cpp",
43    "native/src/thermal_action/action/action_node.cpp",
44    "native/src/thermal_action/action/action_popup.cpp",
45    "native/src/thermal_action/action/action_shutdown.cpp",
46    "native/src/thermal_action/action/action_soc/action_cpu_big.cpp",
47    "native/src/thermal_action/action/action_soc/action_cpu_boost.cpp",
48    "native/src/thermal_action/action/action_soc/action_cpu_isolate.cpp",
49    "native/src/thermal_action/action/action_soc/action_cpu_lit.cpp",
50    "native/src/thermal_action/action/action_soc/action_cpu_med.cpp",
51    "native/src/thermal_action/action/action_soc/action_gpu.cpp",
52    "native/src/thermal_action/action/action_soc/soc_action_base.cpp",
53    "native/src/thermal_action/action/action_thermal_level.cpp",
54    "native/src/thermal_action/action/action_voltage.cpp",
55    "native/src/thermal_action/action/action_volume.cpp",
56    "native/src/thermal_action/thermal_action_factory.cpp",
57    "native/src/thermal_action/thermal_action_manager.cpp",
58    "native/src/thermal_action/thermal_timer.cpp",
59    "native/src/thermal_callback.cpp",
60    "native/src/thermal_mgr_dumper.cpp",
61    "native/src/thermal_observer/state_machine/charger_state_collection.cpp",
62    "native/src/thermal_observer/state_machine/extend_state_collection.cpp",
63    "native/src/thermal_observer/state_machine/scene_state_collection.cpp",
64    "native/src/thermal_observer/state_machine/screen_state_collection.cpp",
65    "native/src/thermal_observer/state_machine/state_collection_factory.cpp",
66    "native/src/thermal_observer/state_machine/state_machine.cpp",
67    "native/src/thermal_observer/thermal_common_event_receiver.cpp",
68    "native/src/thermal_observer/thermal_observer.cpp",
69    "native/src/thermal_observer/thermal_sensor_info.cpp",
70    "native/src/thermal_observer/thermal_service_subscriber.cpp",
71    "native/src/thermal_policy/fan_fault_detect.cpp",
72    "native/src/thermal_policy/thermal_config_base_info.cpp",
73    "native/src/thermal_policy/thermal_config_sensor_cluster.cpp",
74    "native/src/thermal_policy/thermal_policy.cpp",
75    "native/src/thermal_policy/thermal_srv_config_parser.cpp",
76    "native/src/thermal_service.cpp",
77  ]
78
79  configs = [
80    "${utils_path}:utils_config",
81    "${utils_path}:coverage_flags",
82  ]
83
84  if (use_libfuzzer) {
85    defines += [ "FUZZ_TEST" ]
86  }
87
88  public_configs = [ ":thermalsrv_public_config" ]
89
90  deps = [
91    "${thermal_service_zidl}:thermalmgr_proxy",
92    "${thermal_service_zidl}:thermalmgr_stub",
93    "${utils_path}:thermal_utils",
94  ]
95
96  external_deps = [ "power_manager:power_permission" ]
97  external_deps += [
98    "ability_runtime:app_manager",
99    "ability_runtime:wantagent_innerkits",
100    "bundle_framework:appexecfwk_core",
101    "c_utils:utils",
102    "common_event_service:cesfwk_innerkits",
103    "drivers_interface_battery:libbattery_proxy_2.0",
104    "drivers_interface_thermal:libthermal_proxy_1.1",
105    "ffrt:libffrt",
106    "hdf_core:libhdi",
107    "hdf_core:libpub_utils",
108    "hicollie:libhicollie",
109    "hilog:libhilog",
110    "image_framework:image_native",
111    "init:libbegetutil",
112    "ipc:ipc_core",
113    "libxml2:libxml2",
114    "power_manager:power_ffrt",
115    "power_manager:power_sysparam",
116    "power_manager:powermgr_client",
117    "safwk:system_ability_fwk",
118    "samgr:samgr_proxy",
119    "time_service:time_client",
120  ]
121
122  public_external_deps = [ "ability_base:want" ]
123
124  if (has_thermal_airplane_manager_part) {
125    defines += [ "HAS_THERMAL_AIRPLANE_MANAGER_PART" ]
126    external_deps += [ "netmanager_base:net_conn_manager_if" ]
127  }
128
129  if (has_thermal_audio_framework_part) {
130    defines += [ "HAS_THERMAL_AUDIO_FRAMEWORK_PART" ]
131    external_deps += [ "audio_framework:audio_client" ]
132  }
133
134  if (has_thermal_config_policy_part) {
135    defines += [ "HAS_THERMAL_CONFIG_POLICY_PART" ]
136    external_deps += [ "config_policy:configpolicy_util" ]
137  }
138
139  if (has_thermal_display_manager_part) {
140    external_deps += [ "display_manager:displaymgr" ]
141  }
142
143  if (defined(global_parts_info) &&
144      defined(global_parts_info.resourceschedule_soc_perf)) {
145    external_deps += [ "soc_perf:socperf_client" ]
146    defines += [ "SOC_PERF_ENABLE" ]
147  }
148
149  if (defined(global_parts_info) &&
150      defined(global_parts_info.powermgr_battery_manager)) {
151    defines += [ "BATTERY_MANAGER_ENABLE" ]
152    external_deps += [ "battery_manager:batterysrv_client" ]
153  }
154
155  if (build_variant == "user") {
156    defines += [ "THERMAL_USER_VERSION" ]
157  }
158
159  if (has_hiviewdfx_hisysevent_part) {
160    external_deps += [ "hisysevent:libhisysevent" ]
161  }
162
163  subsystem_name = "powermgr"
164  part_name = "thermal_manager"
165}
166
167group("service") {
168  deps = [
169    ":thermalservice",
170    "${thermal_manager_path}/sa_profile:thermalmgr_sa_profile",
171    "native/profile:thermal_service_config",
172  ]
173}
174