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("../batterymgr.gni")
15
16config("batterysrv_public_config") {
17  include_dirs = [
18    "native/include",
19    "${battery_service_zidl}/include",
20    "${battery_inner_api}/native/include",
21  ]
22}
23
24ohos_shared_library("batteryservice") {
25  sanitize = {
26    cfi = true
27    cfi_cross_dso = true
28    debug = false
29  }
30  branch_protector_ret = "pac_ret"
31
32  sources = [
33    "native/src/battery_callback.cpp",
34    "native/src/battery_config.cpp",
35    "native/src/battery_dump.cpp",
36    "native/src/battery_light.cpp",
37    "native/src/battery_notify.cpp",
38    "native/src/battery_service.cpp",
39  ]
40
41  configs = [
42    "${battery_utils}:utils_config",
43    "${battery_utils}:coverage_flags",
44  ]
45
46  public_configs = [ ":batterysrv_public_config" ]
47
48  deps = [ "${battery_service_zidl}:batterysrv_stub" ]
49
50  external_deps = [ "power_manager:power_permission" ]
51  external_deps += [
52    "ability_runtime:ability_manager",
53    "bundle_framework:appexecfwk_base",
54    "c_utils:utils",
55    "common_event_service:cesfwk_core",
56    "common_event_service:cesfwk_innerkits",
57    "drivers_interface_battery:libbattery_proxy_2.0",
58    "eventhandler:libeventhandler",
59    "ffrt:libffrt",
60    "hdf_core:libhdi",
61    "hdf_core:libpub_utils",
62    "hicollie:libhicollie",
63    "hilog:libhilog",
64    "ipc:ipc_core",
65    "jsoncpp:jsoncpp",
66    "power_manager:power_ffrt",
67    "power_manager:power_sysparam",
68    "power_manager:power_vibrator",
69    "power_manager:powermgr_client",
70    "safwk:system_ability_fwk",
71    "samgr:samgr_proxy",
72  ]
73
74  public_external_deps = [ "ability_base:want" ]
75
76  if (battery_manager_feature_set_low_capacity_threshold) {
77    defines += [ "BATTERY_MANAGER_SET_LOW_CAPACITY_THRESHOLD" ]
78  }
79
80  if (has_sensors_miscdevice_part) {
81    external_deps += [ "miscdevice:light_interface_native" ]
82  }
83
84  if (has_hiviewdfx_hisysevent_part) {
85    external_deps += [ "hisysevent:libhisysevent" ]
86  }
87
88  if (has_battery_config_policy_part) {
89    defines += [ "HAS_BATTERY_CONFIG_POLICY_PART" ]
90    external_deps += [ "config_policy:configpolicy_util" ]
91  }
92
93  if (build_variant == "user") {
94    defines += [ "BATTERY_USER_VERSION" ]
95  }
96
97  subsystem_name = "powermgr"
98  part_name = "battery_manager"
99}
100
101group("service") {
102  deps = [
103    ":batteryservice",
104    "native/profile:battery_config",
105    "native/profile:battery_vibrator_config",
106  ]
107}
108