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/config/components/idl_tool/idl.gni") 15import("//build/ohos/sa_profile/sa_profile.gni") 16import("device_usage_statistics.gni") 17 18idl_gen_interface("bundle_active_interface") { 19 src_idl = rebase_path("IBundleActiveService.idl") 20 log_domainid = "0xD001710" 21 log_tag = "BUNDLE_ACTIVE" 22} 23 24idl_gen_interface("app_group_callback_interface") { 25 src_idl = rebase_path("IAppGroupCallback.idl") 26 log_domainid = "0xD001710" 27 log_tag = "BUNDLE_ACTIVE" 28} 29 30ohos_sa_profile("device_usage_statistics_sa_profile") { 31 sources = [ "sa_profile/1907.json" ] 32 part_name = "${device_usage_statistics_part_name}" 33} 34 35config("usagestats_public_config") { 36 include_dirs = [ 37 "${target_gen_dir}", 38 "interfaces/innerkits/include", 39 "interfaces/kits/bundlestats/napi/include", 40 "services/common/include", 41 "services/packagegroup/include", 42 "services/packageusage/include", 43 ] 44} 45 46config("usagestatsutils_config") { 47 include_dirs = [ "utils/include" ] 48} 49 50ohos_source_set("bundle_active_service_stub") { 51 sanitize = { 52 cfi = true 53 cfi_cross_dso = true 54 debug = false 55 } 56 output_values = get_target_outputs(":bundle_active_interface") 57 sources = filter_include(output_values, [ "*_stub.cpp" ]) 58 public_configs = [] 59 deps = [ ":bundle_active_interface" ] 60 external_deps = [ 61 "c_utils:utils", 62 "hilog:libhilog", 63 "ipc:ipc_single", 64 "samgr:samgr_proxy", 65 ] 66 subsystem_name = "resourceschedule" 67 part_name = "${device_usage_statistics_part_name}" 68} 69 70ohos_shared_library("usagestatsinner") { 71 sources = [ 72 "interfaces/innerkits/src/app_group_callback_info.cpp", 73 "interfaces/innerkits/src/bundle_active_client.cpp", 74 "interfaces/innerkits/src/bundle_active_event.cpp", 75 "interfaces/innerkits/src/bundle_active_event_stats.cpp", 76 "interfaces/innerkits/src/bundle_active_form_record.cpp", 77 "interfaces/innerkits/src/bundle_active_module_record.cpp", 78 "interfaces/innerkits/src/bundle_active_package_stats.cpp", 79 "interfaces/innerkits/src/bundle_active_high_frequency_period.cpp", 80 ] 81 public_configs = [ ":usagestats_public_config" ] 82 deps = [ 83 ":app_group_callback_interface", 84 ":bundle_active_interface", 85 ":usagestatsutils", 86 ] 87 external_deps = [ 88 "c_utils:utils", 89 "ffrt:libffrt", 90 "hilog:libhilog", 91 "ipc:ipc_core", 92 "ipc:ipc_single", 93 "samgr:samgr_proxy", 94 ] 95 96 bundle_active_output_values = get_target_outputs(":bundle_active_interface") 97 sources += filter_include(bundle_active_output_values, [ "*.cpp" ]) 98 app_group_callback_output_values = 99 get_target_outputs(":app_group_callback_interface") 100 sources += filter_include(app_group_callback_output_values, [ "*.cpp" ]) 101 102 part_name = "${device_usage_statistics_part_name}" 103 subsystem_name = "resourceschedule" 104 innerapi_tags = [ "platformsdk" ] 105 version_script = "libusagestatsinner.versionscript" 106 branch_protector_ret = "pac_ret" 107 108 sanitize = { 109 cfi = true 110 cfi_cross_dso = true 111 debug = false 112 } 113} 114 115ohos_prebuilt_etc("device_usage_statistics_service_init") { 116 source = "init/device_usage_statistics_service.cfg" 117 relative_install_dir = "init" 118 part_name = "${device_usage_statistics_part_name}" 119 subsystem_name = "resourceschedule" 120} 121 122ohos_shared_library("bundlestate") { 123 cflags_cc = [ 124 "-fdata-sections", 125 "-ffunction-sections", 126 "-fvisibility=hidden", 127 "-fstack-protector-strong", 128 "-Os", 129 ] 130 sources = [ 131 "frameworks/src/bundle_state_common.cpp", 132 "frameworks/src/bundle_state_init.cpp", 133 "frameworks/src/bundle_state_query.cpp", 134 ] 135 include_dirs = [ 136 "interfaces/innerkits/include", 137 "interfaces/kits/bundlestats/napi/include", 138 "services/common/include", 139 "services/packagegroup/include", 140 "services/packageusage/include", 141 ] 142 143 deps = [ 144 ":usagestatsinner", 145 ":usagestatsutils", 146 ] 147 148 external_deps = [ 149 "c_utils:utils", 150 "ffrt:libffrt", 151 "hilog:libhilog", 152 "ipc:ipc_single", 153 "napi:ace_napi", 154 "samgr:samgr_proxy", 155 ] 156 relative_install_dir = "module" 157 part_name = "${device_usage_statistics_part_name}" 158 subsystem_name = "resourceschedule" 159 branch_protector_ret = "pac_ret" 160 161 sanitize = { 162 cfi = true 163 cfi_cross_dso = true 164 debug = false 165 } 166} 167 168ohos_shared_library("usagestatistics") { 169 cflags_cc = [ 170 "-fdata-sections", 171 "-ffunction-sections", 172 "-fvisibility=hidden", 173 "-fstack-protector-strong", 174 "-Os", 175 ] 176 sources = [ 177 "frameworks/src/app_group_observer_napi.cpp", 178 "frameworks/src/bundle_active_app_group_napi.cpp", 179 "frameworks/src/bundle_state_common.cpp", 180 "frameworks/src/bundle_state_query_napi.cpp", 181 "frameworks/src/usage_statistics_init.cpp", 182 ] 183 include_dirs = [ 184 "interfaces/innerkits/include", 185 "interfaces/kits/bundlestats/napi/include", 186 "services/common/include", 187 "services/packagegroup/include", 188 "services/packageusage/include", 189 ] 190 191 deps = [ 192 ":usagestatsinner", 193 ":usagestatsutils", 194 ] 195 196 external_deps = [ 197 "c_utils:utils", 198 "ffrt:libffrt", 199 "hilog:libhilog", 200 "ipc:ipc_single", 201 "napi:ace_napi", 202 "samgr:samgr_proxy", 203 ] 204 relative_install_dir = "module/resourceschedule" 205 part_name = "${device_usage_statistics_part_name}" 206 subsystem_name = "resourceschedule" 207 branch_protector_ret = "pac_ret" 208 209 sanitize = { 210 cfi = true 211 cfi_cross_dso = true 212 debug = false 213 } 214} 215 216ohos_shared_library("usagestatservice") { 217 if (!use_clang_coverage) { 218 shlib_type = "sa" 219 } 220 221 cflags_cc = [ 222 "-fdata-sections", 223 "-ffunction-sections", 224 "-fvisibility=hidden", 225 "-fstack-protector-strong", 226 "-Os", 227 ] 228 sources = [ 229 "services/common/src/bundle_active_account_helper.cpp", 230 "services/common/src/bundle_active_app_state_obsever.cpp", 231 "services/common/src/bundle_active_binary_search.cpp", 232 "services/common/src/bundle_active_bundle_mgr_helper.cpp", 233 "services/common/src/bundle_active_config_reader.cpp", 234 "services/common/src/bundle_active_continuous_task_observer.cpp", 235 "services/common/src/bundle_active_core.cpp", 236 "services/common/src/bundle_active_debug_mode.cpp", 237 "services/common/src/bundle_active_event_reporter.cpp", 238 "services/common/src/bundle_active_open_callback.cpp", 239 "services/common/src/bundle_active_power_state_callback_service.cpp", 240 "services/common/src/bundle_active_service.cpp", 241 "services/common/src/bundle_active_shutdown_callback_service.cpp", 242 "services/common/src/bundle_active_usage_database.cpp", 243 "services/common/src/bundle_active_usage_database_upgrade.cpp", 244 "services/packagegroup/src/bundle_active_group_controller.cpp", 245 "services/packagegroup/src/bundle_active_group_handler.cpp", 246 "services/packagegroup/src/bundle_active_user_history.cpp", 247 "services/packageusage/src/bundle_active_calendar.cpp", 248 "services/packageusage/src/bundle_active_event_list.cpp", 249 "services/packageusage/src/bundle_active_event_tracker.cpp", 250 "services/packageusage/src/bundle_active_period_stats.cpp", 251 "services/packageusage/src/bundle_active_report_controller.cpp", 252 "services/packageusage/src/bundle_active_report_handler.cpp", 253 "services/packageusage/src/bundle_active_stats_combiner.cpp", 254 "services/packageusage/src/bundle_active_user_service.cpp", 255 ] 256 public_configs = [ ":usagestats_public_config" ] 257 258 deps = [ 259 ":usagestatsinner", 260 ":usagestatsutils", 261 ] 262 263 external_deps = [ 264 "ability_runtime:app_manager", 265 "ability_runtime:wantagent_innerkits", 266 "access_token:libaccesstoken_sdk", 267 "access_token:libtokenid_sdk", 268 "cJSON:cjson", 269 "config_policy:configpolicy_util", 270 "ffrt:libffrt", 271 "hicollie:libhicollie", 272 "hilog:libhilog", 273 "hisysevent:libhisysevent", 274 "init:libbegetutil", 275 "ipc:ipc_single", 276 "relational_store:native_rdb", 277 "safwk:system_ability_fwk", 278 "samgr:samgr_proxy", 279 "time_service:time_client", 280 ] 281 282 if (os_account_part_enabled) { 283 cflags_cc += [ "-DOS_ACCOUNT_PART_ENABLED" ] 284 external_deps += [ "os_account:os_account_innerkits" ] 285 } 286 287 defines = [] 288 if (bgtaskmgr_enable) { 289 external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] 290 defines += [ "BGTASKMGR_ENABLE" ] 291 } 292 if (device_usage_statistics_with_powermgr_power_manager_enable) { 293 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 294 external_deps += [ "power_manager:powermgr_client" ] 295 } 296 part_name = "${device_usage_statistics_part_name}" 297 subsystem_name = "resourceschedule" 298 branch_protector_ret = "pac_ret" 299 300 sanitize = { 301 cfi = true 302 cfi_cross_dso = true 303 debug = false 304 } 305} 306 307ohos_static_library("usagestatservice_static") { 308 cflags_cc = [ "-DDEVICE_USAGE_UNIT_TEST" ] 309 310 sources = [ 311 "services/common/src/bundle_active_account_helper.cpp", 312 "services/common/src/bundle_active_app_state_obsever.cpp", 313 "services/common/src/bundle_active_binary_search.cpp", 314 "services/common/src/bundle_active_bundle_mgr_helper.cpp", 315 "services/common/src/bundle_active_config_reader.cpp", 316 "services/common/src/bundle_active_continuous_task_observer.cpp", 317 "services/common/src/bundle_active_core.cpp", 318 "services/common/src/bundle_active_debug_mode.cpp", 319 "services/common/src/bundle_active_event_reporter.cpp", 320 "services/common/src/bundle_active_open_callback.cpp", 321 "services/common/src/bundle_active_power_state_callback_service.cpp", 322 "services/common/src/bundle_active_service.cpp", 323 "services/common/src/bundle_active_shutdown_callback_service.cpp", 324 "services/common/src/bundle_active_usage_database.cpp", 325 "services/common/src/bundle_active_usage_database_upgrade.cpp", 326 "services/packagegroup/src/bundle_active_group_controller.cpp", 327 "services/packagegroup/src/bundle_active_group_handler.cpp", 328 "services/packagegroup/src/bundle_active_user_history.cpp", 329 "services/packageusage/src/bundle_active_calendar.cpp", 330 "services/packageusage/src/bundle_active_event_list.cpp", 331 "services/packageusage/src/bundle_active_event_tracker.cpp", 332 "services/packageusage/src/bundle_active_period_stats.cpp", 333 "services/packageusage/src/bundle_active_report_controller.cpp", 334 "services/packageusage/src/bundle_active_report_handler.cpp", 335 "services/packageusage/src/bundle_active_stats_combiner.cpp", 336 "services/packageusage/src/bundle_active_user_service.cpp", 337 ] 338 public_configs = [ ":usagestats_public_config" ] 339 340 deps = [ 341 ":usagestatsinner", 342 ":usagestatsutils", 343 ] 344 345 external_deps = [ 346 "ability_runtime:app_manager", 347 "ability_runtime:wantagent_innerkits", 348 "access_token:libaccesstoken_sdk", 349 "access_token:libtokenid_sdk", 350 "cJSON:cjson", 351 "config_policy:configpolicy_util", 352 "ffrt:libffrt", 353 "hicollie:libhicollie", 354 "hilog:libhilog", 355 "hisysevent:libhisysevent", 356 "init:libbegetutil", 357 "ipc:ipc_single", 358 "relational_store:native_rdb", 359 "safwk:system_ability_fwk", 360 "samgr:samgr_proxy", 361 "time_service:time_client", 362 ] 363 364 if (os_account_part_enabled) { 365 cflags_cc += [ "-DOS_ACCOUNT_PART_ENABLED" ] 366 external_deps += [ "os_account:os_account_innerkits" ] 367 } 368 369 defines = [] 370 if (bgtaskmgr_enable) { 371 external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] 372 defines += [ "BGTASKMGR_ENABLE" ] 373 } 374 if (device_usage_statistics_with_powermgr_power_manager_enable) { 375 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 376 external_deps += [ "power_manager:powermgr_client" ] 377 } 378 if (use_libfuzzer) { 379 defines += [ "DEVICE_USAGES_STATISTICS_TEST_ENABLE" ] 380 } 381 part_name = "${device_usage_statistics_part_name}" 382 subsystem_name = "resourceschedule" 383 branch_protector_ret = "pac_ret" 384 385 sanitize = { 386 cfi = true 387 cfi_cross_dso = true 388 debug = false 389 } 390} 391 392ohos_static_library("usagestatsinner_static") { 393 cflags_cc = [ "-DDEVICE_USAGE_UNIT_TEST" ] 394 sources = [ 395 "interfaces/innerkits/src/app_group_callback_info.cpp", 396 "interfaces/innerkits/src/bundle_active_client.cpp", 397 "interfaces/innerkits/src/bundle_active_event.cpp", 398 "interfaces/innerkits/src/bundle_active_event_stats.cpp", 399 "interfaces/innerkits/src/bundle_active_form_record.cpp", 400 "interfaces/innerkits/src/bundle_active_module_record.cpp", 401 "interfaces/innerkits/src/bundle_active_package_stats.cpp", 402 ] 403 public_configs = [ ":usagestats_public_config" ] 404 deps = [ 405 ":app_group_callback_interface", 406 ":bundle_active_interface", 407 ":usagestatsutils", 408 ] 409 external_deps = [ 410 "c_utils:utils", 411 "ffrt:libffrt", 412 "hilog:libhilog", 413 "hitrace:hitrace_meter", 414 "ipc:ipc_core", 415 "ipc:ipc_single", 416 "samgr:samgr_proxy", 417 ] 418 419 bundle_active_output_values = get_target_outputs(":bundle_active_interface") 420 sources += filter_include(bundle_active_output_values, [ "*.cpp" ]) 421 app_group_callback_output_values = 422 get_target_outputs(":app_group_callback_interface") 423 sources += filter_include(app_group_callback_output_values, [ "*.cpp" ]) 424 425 part_name = "${device_usage_statistics_part_name}" 426 subsystem_name = "resourceschedule" 427 branch_protector_ret = "pac_ret" 428 sanitize = { 429 cfi = true 430 cfi_cross_dso = true 431 debug = false 432 } 433} 434 435ohos_shared_library("usagestatsutils") { 436 cflags_cc = [ 437 "-fdata-sections", 438 "-ffunction-sections", 439 "-fstack-protector-strong", 440 "-Os", 441 ] 442 sources = [ 443 "utils/src/bundle_active_log.cpp", 444 "utils/src/bundle_active_util.cpp", 445 ] 446 public_configs = [ ":usagestatsutils_config" ] 447 448 external_deps = [ 449 "c_utils:utils", 450 "hilog:libhilog", 451 ] 452 innerapi_tags = [ "platformsdk" ] 453 part_name = "${device_usage_statistics_part_name}" 454 subsystem_name = "resourceschedule" 455 branch_protector_ret = "pac_ret" 456 457 sanitize = { 458 cfi = true 459 cfi_cross_dso = true 460 debug = false 461 } 462} 463 464group("bfwk_group_all") { 465 if (device_usage_statistics_device_enable) { 466 deps = [ 467 "${usage_statistics_path}:bundlestate", 468 "${usage_statistics_path}:usagestatsinner", 469 "${usage_statistics_path}:usagestatsutils", 470 ] 471 } 472} 473 474group("service_group_all") { 475 if (device_usage_statistics_device_enable) { 476 deps = [ 477 "${usage_statistics_path}:device_usage_statistics_sa_profile", 478 "${usage_statistics_path}:device_usage_statistics_service_init", 479 "${usage_statistics_path}:usagestatistics", 480 "${usage_statistics_path}:usagestatservice", 481 ] 482 } 483} 484 485group("test_all") { 486 testonly = true 487 if (device_usage_statistics_device_enable) { 488 deps = [ 489 "${usage_statistics_path}/interfaces/test/unittest/device_usage_statistics_jsunittest:js_unittest", 490 "${usage_statistics_path}/test/fuzztest/appgroupcallbackstub_fuzzer:fuzztest", 491 "${usage_statistics_path}/test/fuzztest/bundleactivecommon_fuzzer:fuzztest", 492 "${usage_statistics_path}/test/fuzztest/bundleactiveobserver_fuzzer:fuzztest", 493 "${usage_statistics_path}/test/fuzztest/bundleactiveonremoterequest_fuzzer:fuzztest", 494 "${usage_statistics_path}/test/fuzztest/bundleactivepowerstatecallbackproxy_fuzzer:fuzztest", 495 "${usage_statistics_path}/test/unittest:unittest", 496 ] 497 } 498} 499