137a09cd7Sopenharmony_ci# Copyright (c) 2021-2023 Huawei Device Co., Ltd.
237a09cd7Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
337a09cd7Sopenharmony_ci# you may not use this file except in compliance with the License.
437a09cd7Sopenharmony_ci# You may obtain a copy of the License at
537a09cd7Sopenharmony_ci#
637a09cd7Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
737a09cd7Sopenharmony_ci#
837a09cd7Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
937a09cd7Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1037a09cd7Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1137a09cd7Sopenharmony_ci# See the License for the specific language governing permissions and
1237a09cd7Sopenharmony_ci# limitations under the License.
1337a09cd7Sopenharmony_ci
1437a09cd7Sopenharmony_ciimport("../thermalmgr.gni")
1537a09cd7Sopenharmony_ci
1637a09cd7Sopenharmony_ciconfig("thermalsrv_public_config") {
1737a09cd7Sopenharmony_ci  include_dirs = [
1837a09cd7Sopenharmony_ci    "native/include/",
1937a09cd7Sopenharmony_ci    "native/include/thermal_action",
2037a09cd7Sopenharmony_ci    "native/include/thermal_observer",
2137a09cd7Sopenharmony_ci    "native/include/thermal_policy",
2237a09cd7Sopenharmony_ci    "native/include/thermal_observer/state_machine",
2337a09cd7Sopenharmony_ci    "native/include/thermal_action/action",
2437a09cd7Sopenharmony_ci    "native/include/thermal_action/action/action_soc",
2537a09cd7Sopenharmony_ci    "${thermal_inner_api}/native/include",
2637a09cd7Sopenharmony_ci  ]
2737a09cd7Sopenharmony_ci}
2837a09cd7Sopenharmony_ci
2937a09cd7Sopenharmony_ciohos_shared_library("thermalservice") {
3037a09cd7Sopenharmony_ci  sanitize = {
3137a09cd7Sopenharmony_ci    cfi = true
3237a09cd7Sopenharmony_ci    cfi_cross_dso = true
3337a09cd7Sopenharmony_ci    debug = false
3437a09cd7Sopenharmony_ci  }
3537a09cd7Sopenharmony_ci  branch_protector_ret = "pac_ret"
3637a09cd7Sopenharmony_ci
3737a09cd7Sopenharmony_ci  sources = [
3837a09cd7Sopenharmony_ci    "native/src/fan_callback.cpp",
3937a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_airplane.cpp",
4037a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_application_process.cpp",
4137a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_charger.cpp",
4237a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_display.cpp",
4337a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_node.cpp",
4437a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_popup.cpp",
4537a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_shutdown.cpp",
4637a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_soc/action_cpu_big.cpp",
4737a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_soc/action_cpu_boost.cpp",
4837a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_soc/action_cpu_isolate.cpp",
4937a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_soc/action_cpu_lit.cpp",
5037a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_soc/action_cpu_med.cpp",
5137a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_soc/action_gpu.cpp",
5237a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_soc/soc_action_base.cpp",
5337a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_thermal_level.cpp",
5437a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_voltage.cpp",
5537a09cd7Sopenharmony_ci    "native/src/thermal_action/action/action_volume.cpp",
5637a09cd7Sopenharmony_ci    "native/src/thermal_action/thermal_action_factory.cpp",
5737a09cd7Sopenharmony_ci    "native/src/thermal_action/thermal_action_manager.cpp",
5837a09cd7Sopenharmony_ci    "native/src/thermal_action/thermal_timer.cpp",
5937a09cd7Sopenharmony_ci    "native/src/thermal_callback.cpp",
6037a09cd7Sopenharmony_ci    "native/src/thermal_mgr_dumper.cpp",
6137a09cd7Sopenharmony_ci    "native/src/thermal_observer/state_machine/charger_state_collection.cpp",
6237a09cd7Sopenharmony_ci    "native/src/thermal_observer/state_machine/extend_state_collection.cpp",
6337a09cd7Sopenharmony_ci    "native/src/thermal_observer/state_machine/scene_state_collection.cpp",
6437a09cd7Sopenharmony_ci    "native/src/thermal_observer/state_machine/screen_state_collection.cpp",
6537a09cd7Sopenharmony_ci    "native/src/thermal_observer/state_machine/state_collection_factory.cpp",
6637a09cd7Sopenharmony_ci    "native/src/thermal_observer/state_machine/state_machine.cpp",
6737a09cd7Sopenharmony_ci    "native/src/thermal_observer/thermal_common_event_receiver.cpp",
6837a09cd7Sopenharmony_ci    "native/src/thermal_observer/thermal_observer.cpp",
6937a09cd7Sopenharmony_ci    "native/src/thermal_observer/thermal_sensor_info.cpp",
7037a09cd7Sopenharmony_ci    "native/src/thermal_observer/thermal_service_subscriber.cpp",
7137a09cd7Sopenharmony_ci    "native/src/thermal_policy/fan_fault_detect.cpp",
7237a09cd7Sopenharmony_ci    "native/src/thermal_policy/thermal_config_base_info.cpp",
7337a09cd7Sopenharmony_ci    "native/src/thermal_policy/thermal_config_sensor_cluster.cpp",
7437a09cd7Sopenharmony_ci    "native/src/thermal_policy/thermal_policy.cpp",
7537a09cd7Sopenharmony_ci    "native/src/thermal_policy/thermal_srv_config_parser.cpp",
7637a09cd7Sopenharmony_ci    "native/src/thermal_service.cpp",
7737a09cd7Sopenharmony_ci  ]
7837a09cd7Sopenharmony_ci
7937a09cd7Sopenharmony_ci  configs = [
8037a09cd7Sopenharmony_ci    "${utils_path}:utils_config",
8137a09cd7Sopenharmony_ci    "${utils_path}:coverage_flags",
8237a09cd7Sopenharmony_ci  ]
8337a09cd7Sopenharmony_ci
8437a09cd7Sopenharmony_ci  if (use_libfuzzer) {
8537a09cd7Sopenharmony_ci    defines += [ "FUZZ_TEST" ]
8637a09cd7Sopenharmony_ci  }
8737a09cd7Sopenharmony_ci
8837a09cd7Sopenharmony_ci  public_configs = [ ":thermalsrv_public_config" ]
8937a09cd7Sopenharmony_ci
9037a09cd7Sopenharmony_ci  deps = [
9137a09cd7Sopenharmony_ci    "${thermal_service_zidl}:thermalmgr_proxy",
9237a09cd7Sopenharmony_ci    "${thermal_service_zidl}:thermalmgr_stub",
9337a09cd7Sopenharmony_ci    "${utils_path}:thermal_utils",
9437a09cd7Sopenharmony_ci  ]
9537a09cd7Sopenharmony_ci
9637a09cd7Sopenharmony_ci  external_deps = [ "power_manager:power_permission" ]
9737a09cd7Sopenharmony_ci  external_deps += [
9837a09cd7Sopenharmony_ci    "ability_runtime:app_manager",
9937a09cd7Sopenharmony_ci    "ability_runtime:wantagent_innerkits",
10037a09cd7Sopenharmony_ci    "bundle_framework:appexecfwk_core",
10137a09cd7Sopenharmony_ci    "c_utils:utils",
10237a09cd7Sopenharmony_ci    "common_event_service:cesfwk_innerkits",
10337a09cd7Sopenharmony_ci    "drivers_interface_battery:libbattery_proxy_2.0",
10437a09cd7Sopenharmony_ci    "drivers_interface_thermal:libthermal_proxy_1.1",
10537a09cd7Sopenharmony_ci    "ffrt:libffrt",
10637a09cd7Sopenharmony_ci    "hdf_core:libhdi",
10737a09cd7Sopenharmony_ci    "hdf_core:libpub_utils",
10837a09cd7Sopenharmony_ci    "hicollie:libhicollie",
10937a09cd7Sopenharmony_ci    "hilog:libhilog",
11037a09cd7Sopenharmony_ci    "image_framework:image_native",
11137a09cd7Sopenharmony_ci    "init:libbegetutil",
11237a09cd7Sopenharmony_ci    "ipc:ipc_core",
11337a09cd7Sopenharmony_ci    "libxml2:libxml2",
11437a09cd7Sopenharmony_ci    "power_manager:power_ffrt",
11537a09cd7Sopenharmony_ci    "power_manager:power_sysparam",
11637a09cd7Sopenharmony_ci    "power_manager:powermgr_client",
11737a09cd7Sopenharmony_ci    "safwk:system_ability_fwk",
11837a09cd7Sopenharmony_ci    "samgr:samgr_proxy",
11937a09cd7Sopenharmony_ci    "time_service:time_client",
12037a09cd7Sopenharmony_ci  ]
12137a09cd7Sopenharmony_ci
12237a09cd7Sopenharmony_ci  public_external_deps = [ "ability_base:want" ]
12337a09cd7Sopenharmony_ci
12437a09cd7Sopenharmony_ci  if (has_thermal_airplane_manager_part) {
12537a09cd7Sopenharmony_ci    defines += [ "HAS_THERMAL_AIRPLANE_MANAGER_PART" ]
12637a09cd7Sopenharmony_ci    external_deps += [ "netmanager_base:net_conn_manager_if" ]
12737a09cd7Sopenharmony_ci  }
12837a09cd7Sopenharmony_ci
12937a09cd7Sopenharmony_ci  if (has_thermal_audio_framework_part) {
13037a09cd7Sopenharmony_ci    defines += [ "HAS_THERMAL_AUDIO_FRAMEWORK_PART" ]
13137a09cd7Sopenharmony_ci    external_deps += [ "audio_framework:audio_client" ]
13237a09cd7Sopenharmony_ci  }
13337a09cd7Sopenharmony_ci
13437a09cd7Sopenharmony_ci  if (has_thermal_config_policy_part) {
13537a09cd7Sopenharmony_ci    defines += [ "HAS_THERMAL_CONFIG_POLICY_PART" ]
13637a09cd7Sopenharmony_ci    external_deps += [ "config_policy:configpolicy_util" ]
13737a09cd7Sopenharmony_ci  }
13837a09cd7Sopenharmony_ci
13937a09cd7Sopenharmony_ci  if (has_thermal_display_manager_part) {
14037a09cd7Sopenharmony_ci    external_deps += [ "display_manager:displaymgr" ]
14137a09cd7Sopenharmony_ci  }
14237a09cd7Sopenharmony_ci
14337a09cd7Sopenharmony_ci  if (defined(global_parts_info) &&
14437a09cd7Sopenharmony_ci      defined(global_parts_info.resourceschedule_soc_perf)) {
14537a09cd7Sopenharmony_ci    external_deps += [ "soc_perf:socperf_client" ]
14637a09cd7Sopenharmony_ci    defines += [ "SOC_PERF_ENABLE" ]
14737a09cd7Sopenharmony_ci  }
14837a09cd7Sopenharmony_ci
14937a09cd7Sopenharmony_ci  if (defined(global_parts_info) &&
15037a09cd7Sopenharmony_ci      defined(global_parts_info.powermgr_battery_manager)) {
15137a09cd7Sopenharmony_ci    defines += [ "BATTERY_MANAGER_ENABLE" ]
15237a09cd7Sopenharmony_ci    external_deps += [ "battery_manager:batterysrv_client" ]
15337a09cd7Sopenharmony_ci  }
15437a09cd7Sopenharmony_ci
15537a09cd7Sopenharmony_ci  if (build_variant == "user") {
15637a09cd7Sopenharmony_ci    defines += [ "THERMAL_USER_VERSION" ]
15737a09cd7Sopenharmony_ci  }
15837a09cd7Sopenharmony_ci
15937a09cd7Sopenharmony_ci  if (has_hiviewdfx_hisysevent_part) {
16037a09cd7Sopenharmony_ci    external_deps += [ "hisysevent:libhisysevent" ]
16137a09cd7Sopenharmony_ci  }
16237a09cd7Sopenharmony_ci
16337a09cd7Sopenharmony_ci  subsystem_name = "powermgr"
16437a09cd7Sopenharmony_ci  part_name = "thermal_manager"
16537a09cd7Sopenharmony_ci}
16637a09cd7Sopenharmony_ci
16737a09cd7Sopenharmony_cigroup("service") {
16837a09cd7Sopenharmony_ci  deps = [
16937a09cd7Sopenharmony_ci    ":thermalservice",
17037a09cd7Sopenharmony_ci    "${thermal_manager_path}/sa_profile:thermalmgr_sa_profile",
17137a09cd7Sopenharmony_ci    "native/profile:thermal_service_config",
17237a09cd7Sopenharmony_ci  ]
17337a09cd7Sopenharmony_ci}
174