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_base:want",
53    "ability_runtime:ability_manager",
54    "bundle_framework:appexecfwk_base",
55    "c_utils:utils",
56    "common_event_service:cesfwk_core",
57    "common_event_service:cesfwk_innerkits",
58    "config_policy:configpolicy_util",
59    "drivers_interface_battery:libbattery_proxy_2.0",
60    "ffrt:libffrt",
61    "hdf_core:libhdi",
62    "hdf_core:libpub_utils",
63    "hicollie:libhicollie",
64    "hilog:libhilog",
65    "hisysevent:libhisysevent",
66    "ipc:ipc_core",
67    "jsoncpp:jsoncpp",
68    "miscdevice:light_interface_native",
69    "power_manager:power_ffrt",
70    "power_manager:power_sysparam",
71    "power_manager:power_vibrator",
72    "power_manager:powermgr_client",
73    "safwk:system_ability_fwk",
74    "samgr:samgr_proxy",
75  ]
76
77  defines = []
78
79  if (battery_manager_feature_enable_charging_sound) {
80    defines += [ "BATTERY_MANAGER_ENABLE_CHARGING_SOUND" ]
81    sources += [ "native/src/charging_sound.cpp" ]
82    external_deps += [
83      "audio_framework:audio_client",
84      "config_policy:configpolicy_util",
85      "player_framework:audio_haptic",
86    ]
87  }
88
89  if (battery_manager_feature_set_low_capacity_threshold) {
90    defines += [ "BATTERY_MANAGER_SET_LOW_CAPACITY_THRESHOLD" ]
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