1# Copyright (c) 2022 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("//build/ohos/sa_profile/sa_profile.gni") 15import("device_usage_statistics.gni") 16 17ohos_sa_profile("device_usage_statistics_sa_profile") { 18 sources = [ "sa_profile/1907.json" ] 19 part_name = "${device_usage_statistics_part_name}" 20} 21 22config("usagestats_public_config") { 23 include_dirs = [ 24 "interfaces/innerkits/include", 25 "interfaces/kits/bundlestats/napi/include", 26 "services/common/include", 27 "services/packagegroup/include", 28 "services/packageusage/include", 29 ] 30} 31 32config("usagestatsutils_config") { 33 include_dirs = [ "utils/include" ] 34} 35 36ohos_shared_library("usagestatsinner") { 37 sources = [ 38 "interfaces/innerkits/src/app_group_callback_info.cpp", 39 "interfaces/innerkits/src/app_group_callback_proxy.cpp", 40 "interfaces/innerkits/src/app_group_callback_stub.cpp", 41 "interfaces/innerkits/src/bundle_active_client.cpp", 42 "interfaces/innerkits/src/bundle_active_event.cpp", 43 "interfaces/innerkits/src/bundle_active_event_stats.cpp", 44 "interfaces/innerkits/src/bundle_active_form_record.cpp", 45 "interfaces/innerkits/src/bundle_active_module_record.cpp", 46 "interfaces/innerkits/src/bundle_active_package_stats.cpp", 47 "interfaces/innerkits/src/bundle_active_proxy.cpp", 48 ] 49 public_configs = [ ":usagestats_public_config" ] 50 deps = [ ":usagestatsutils" ] 51 external_deps = [ 52 "c_utils:utils", 53 "eventhandler:libeventhandler", 54 "hilog:libhilog", 55 "ipc:ipc_single", 56 "samgr:samgr_proxy", 57 ] 58 public_external_deps = [ "ffrt:libffrt" ] 59 part_name = "${device_usage_statistics_part_name}" 60 subsystem_name = "resourceschedule" 61 innerapi_tags = [ "platformsdk" ] 62 version_script = "libusagestatsinner.versionscript" 63 branch_protector_ret = "pac_ret" 64 65 sanitize = { 66 cfi = true 67 cfi_cross_dso = true 68 debug = false 69 } 70} 71 72ohos_prebuilt_etc("device_usage_statistics_service_init") { 73 source = "init/device_usage_statistics_service.cfg" 74 relative_install_dir = "init" 75 part_name = "${device_usage_statistics_part_name}" 76 subsystem_name = "resourceschedule" 77} 78 79ohos_shared_library("bundlestate") { 80 sources = [ 81 "frameworks/src/bundle_state_common.cpp", 82 "frameworks/src/bundle_state_init.cpp", 83 "frameworks/src/bundle_state_query.cpp", 84 ] 85 include_dirs = [ 86 "interfaces/innerkits/include", 87 "interfaces/kits/bundlestats/napi/include", 88 "services/common/include", 89 "services/packagegroup/include", 90 "services/packageusage/include", 91 ] 92 93 deps = [ 94 ":usagestatsinner", 95 ":usagestatsutils", 96 ] 97 98 external_deps = [ 99 "c_utils:utils", 100 "hilog:libhilog", 101 "ipc:ipc_single", 102 "napi:ace_napi", 103 ] 104 public_external_deps = [ "ffrt:libffrt" ] 105 relative_install_dir = "module" 106 part_name = "${device_usage_statistics_part_name}" 107 subsystem_name = "resourceschedule" 108 branch_protector_ret = "pac_ret" 109 110 sanitize = { 111 cfi = true 112 cfi_cross_dso = true 113 debug = false 114 } 115} 116 117ohos_shared_library("usagestatistics") { 118 sources = [ 119 "frameworks/src/app_group_observer_napi.cpp", 120 "frameworks/src/bundle_active_app_group_napi.cpp", 121 "frameworks/src/bundle_state_common.cpp", 122 "frameworks/src/bundle_state_query_napi.cpp", 123 "frameworks/src/usage_statistics_init.cpp", 124 ] 125 include_dirs = [ 126 "interfaces/innerkits/include", 127 "interfaces/kits/bundlestats/napi/include", 128 "services/common/include", 129 "services/packagegroup/include", 130 "services/packageusage/include", 131 ] 132 133 deps = [ 134 ":usagestatsinner", 135 ":usagestatsutils", 136 ] 137 138 external_deps = [ 139 "c_utils:utils", 140 "ffrt:libffrt", 141 "hilog:libhilog", 142 "ipc:ipc_single", 143 "napi:ace_napi", 144 ] 145 relative_install_dir = "module/resourceschedule" 146 part_name = "${device_usage_statistics_part_name}" 147 subsystem_name = "resourceschedule" 148 branch_protector_ret = "pac_ret" 149 150 sanitize = { 151 cfi = true 152 cfi_cross_dso = true 153 debug = false 154 } 155} 156 157ohos_shared_library("usagestatservice") { 158 if (!use_clang_coverage) { 159 shlib_type = "sa" 160 } 161 162 cflags_cc = [] 163 sources = [ 164 "services/common/src/bundle_active_account_helper.cpp", 165 "services/common/src/bundle_active_app_state_obsever.cpp", 166 "services/common/src/bundle_active_binary_search.cpp", 167 "services/common/src/bundle_active_bundle_mgr_helper.cpp", 168 "services/common/src/bundle_active_config_reader.cpp", 169 "services/common/src/bundle_active_continuous_task_observer.cpp", 170 "services/common/src/bundle_active_core.cpp", 171 "services/common/src/bundle_active_debug_mode.cpp", 172 "services/common/src/bundle_active_open_callback.cpp", 173 "services/common/src/bundle_active_power_state_callback_service.cpp", 174 "services/common/src/bundle_active_service.cpp", 175 "services/common/src/bundle_active_shutdown_callback_service.cpp", 176 "services/common/src/bundle_active_stub.cpp", 177 "services/common/src/bundle_active_usage_database.cpp", 178 "services/packagegroup/src/bundle_active_group_controller.cpp", 179 "services/packagegroup/src/bundle_active_group_handler.cpp", 180 "services/packagegroup/src/bundle_active_user_history.cpp", 181 "services/packageusage/src/bundle_active_calendar.cpp", 182 "services/packageusage/src/bundle_active_event_list.cpp", 183 "services/packageusage/src/bundle_active_event_tracker.cpp", 184 "services/packageusage/src/bundle_active_period_stats.cpp", 185 "services/packageusage/src/bundle_active_report_handler.cpp", 186 "services/packageusage/src/bundle_active_stats_combiner.cpp", 187 "services/packageusage/src/bundle_active_user_service.cpp", 188 ] 189 public_configs = [ ":usagestats_public_config" ] 190 191 deps = [ 192 ":usagestatsinner", 193 ":usagestatsutils", 194 ] 195 196 external_deps = [ 197 "ability_base:want", 198 "ability_runtime:app_manager", 199 "ability_runtime:wantagent_innerkits", 200 "access_token:libaccesstoken_sdk", 201 "access_token:libtokenid_sdk", 202 "bundle_framework:appexecfwk_base", 203 "bundle_framework:appexecfwk_core", 204 "c_utils:utils", 205 "common_event_service:cesfwk_innerkits", 206 "config_policy:configpolicy_util", 207 "eventhandler:libeventhandler", 208 "ffrt:libffrt", 209 "hicollie:libhicollie", 210 "hilog:libhilog", 211 "init:libbegetutil", 212 "ipc:ipc_single", 213 "relational_store:native_rdb", 214 "safwk:system_ability_fwk", 215 "samgr:samgr_proxy", 216 "time_service:time_client", 217 ] 218 219 public_external_deps = [ "jsoncpp:jsoncpp" ] 220 221 if (os_account_part_enabled) { 222 cflags_cc += [ "-DOS_ACCOUNT_PART_ENABLED" ] 223 external_deps += [ "os_account:os_account_innerkits" ] 224 } 225 226 defines = [] 227 if (bgtaskmgr_enable) { 228 external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] 229 defines += [ "BGTASKMGR_ENABLE" ] 230 } 231 if (device_usage_statistics_with_powermgr_power_manager_enable) { 232 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 233 external_deps += [ "power_manager:powermgr_client" ] 234 } 235 part_name = "${device_usage_statistics_part_name}" 236 subsystem_name = "resourceschedule" 237 branch_protector_ret = "pac_ret" 238 239 sanitize = { 240 cfi = true 241 cfi_cross_dso = true 242 debug = false 243 } 244} 245 246ohos_static_library("usagestatservice_static") { 247 cflags_cc = [ "-DDEVICE_USAGE_UNIT_TEST" ] 248 249 sources = [ 250 "services/common/src/bundle_active_account_helper.cpp", 251 "services/common/src/bundle_active_app_state_obsever.cpp", 252 "services/common/src/bundle_active_binary_search.cpp", 253 "services/common/src/bundle_active_bundle_mgr_helper.cpp", 254 "services/common/src/bundle_active_config_reader.cpp", 255 "services/common/src/bundle_active_continuous_task_observer.cpp", 256 "services/common/src/bundle_active_core.cpp", 257 "services/common/src/bundle_active_debug_mode.cpp", 258 "services/common/src/bundle_active_open_callback.cpp", 259 "services/common/src/bundle_active_power_state_callback_service.cpp", 260 "services/common/src/bundle_active_service.cpp", 261 "services/common/src/bundle_active_shutdown_callback_service.cpp", 262 "services/common/src/bundle_active_stub.cpp", 263 "services/common/src/bundle_active_usage_database.cpp", 264 "services/packagegroup/src/bundle_active_group_controller.cpp", 265 "services/packagegroup/src/bundle_active_group_handler.cpp", 266 "services/packagegroup/src/bundle_active_user_history.cpp", 267 "services/packageusage/src/bundle_active_calendar.cpp", 268 "services/packageusage/src/bundle_active_event_list.cpp", 269 "services/packageusage/src/bundle_active_event_tracker.cpp", 270 "services/packageusage/src/bundle_active_period_stats.cpp", 271 "services/packageusage/src/bundle_active_report_handler.cpp", 272 "services/packageusage/src/bundle_active_stats_combiner.cpp", 273 "services/packageusage/src/bundle_active_user_service.cpp", 274 ] 275 public_configs = [ ":usagestats_public_config" ] 276 277 deps = [ 278 ":usagestatsinner", 279 ":usagestatsutils", 280 ] 281 282 external_deps = [ 283 "ability_base:want", 284 "ability_runtime:app_manager", 285 "ability_runtime:wantagent_innerkits", 286 "access_token:libaccesstoken_sdk", 287 "access_token:libtokenid_sdk", 288 "bundle_framework:appexecfwk_base", 289 "bundle_framework:appexecfwk_core", 290 "c_utils:utils", 291 "common_event_service:cesfwk_innerkits", 292 "config_policy:configpolicy_util", 293 "eventhandler:libeventhandler", 294 "ffrt:libffrt", 295 "hicollie:libhicollie", 296 "hilog:libhilog", 297 "init:libbegetutil", 298 "ipc:ipc_single", 299 "relational_store:native_rdb", 300 "safwk:system_ability_fwk", 301 "samgr:samgr_proxy", 302 "time_service:time_client", 303 ] 304 305 public_external_deps = [ "jsoncpp:jsoncpp" ] 306 307 if (os_account_part_enabled) { 308 cflags_cc += [ "-DOS_ACCOUNT_PART_ENABLED" ] 309 external_deps += [ "os_account:os_account_innerkits" ] 310 } 311 312 defines = [] 313 if (bgtaskmgr_enable) { 314 external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] 315 defines += [ "BGTASKMGR_ENABLE" ] 316 } 317 if (device_usage_statistics_with_powermgr_power_manager_enable) { 318 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 319 external_deps += [ "power_manager:powermgr_client" ] 320 } 321 part_name = "${device_usage_statistics_part_name}" 322 subsystem_name = "resourceschedule" 323 branch_protector_ret = "pac_ret" 324 325 sanitize = { 326 cfi = true 327 cfi_cross_dso = true 328 debug = false 329 } 330} 331 332ohos_shared_library("usagestatsutils") { 333 sources = [ 334 "utils/src/bundle_active_log.cpp", 335 "utils/src/bundle_active_util.cpp", 336 ] 337 public_configs = [ ":usagestatsutils_config" ] 338 339 external_deps = [ 340 "c_utils:utils", 341 "hilog:libhilog", 342 ] 343 innerapi_tags = [ "platformsdk" ] 344 part_name = "${device_usage_statistics_part_name}" 345 subsystem_name = "resourceschedule" 346 branch_protector_ret = "pac_ret" 347 348 sanitize = { 349 cfi = true 350 cfi_cross_dso = true 351 debug = false 352 } 353} 354 355group("bfwk_group_all") { 356 if (device_usage_statistics_device_enable) { 357 deps = [ 358 "${usage_statistics_path}:bundlestate", 359 "${usage_statistics_path}:usagestatsinner", 360 "${usage_statistics_path}:usagestatsutils", 361 ] 362 } 363} 364 365group("service_group_all") { 366 if (device_usage_statistics_device_enable) { 367 deps = [ 368 "${usage_statistics_path}:device_usage_statistics_sa_profile", 369 "${usage_statistics_path}:device_usage_statistics_service_init", 370 "${usage_statistics_path}:usagestatistics", 371 "${usage_statistics_path}:usagestatservice", 372 ] 373 } 374} 375 376group("test_all") { 377 testonly = true 378 if (device_usage_statistics_device_enable) { 379 deps = [ 380 "${usage_statistics_path}/interfaces/test/unittest/device_usage_statistics_jsunittest:js_unittest", 381 "${usage_statistics_path}/test/fuzztest/appgroupcallbackstub_fuzzer:fuzztest", 382 "${usage_statistics_path}/test/fuzztest/bundleactiveobserver_fuzzer:fuzztest", 383 "${usage_statistics_path}/test/fuzztest/bundleactiveonremoterequest_fuzzer:fuzztest", 384 "${usage_statistics_path}/test/fuzztest/bundleactivepowerstatecallbackproxy_fuzzer:fuzztest", 385 "${usage_statistics_path}/test/unittest:unittest", 386 ] 387 } 388} 389