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 ] 80 public_configs = [ ":usagestats_public_config" ] 81 deps = [ 82 ":app_group_callback_interface", 83 ":bundle_active_interface", 84 ":usagestatsutils", 85 ] 86 external_deps = [ 87 "c_utils:utils", 88 "eventhandler:libeventhandler", 89 "hilog:libhilog", 90 "ipc:ipc_core", 91 "ipc:ipc_single", 92 "samgr:samgr_proxy", 93 ] 94 95 bundle_active_output_values = get_target_outputs(":bundle_active_interface") 96 sources += filter_include(bundle_active_output_values, [ "*.cpp" ]) 97 app_group_callback_output_values = 98 get_target_outputs(":app_group_callback_interface") 99 sources += filter_include(app_group_callback_output_values, [ "*.cpp" ]) 100 101 public_external_deps = [ "ffrt:libffrt" ] 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 "hilog:libhilog", 151 "ipc:ipc_single", 152 "napi:ace_napi", 153 ] 154 public_external_deps = [ "ffrt:libffrt" ] 155 relative_install_dir = "module" 156 part_name = "${device_usage_statistics_part_name}" 157 subsystem_name = "resourceschedule" 158 branch_protector_ret = "pac_ret" 159 160 sanitize = { 161 cfi = true 162 cfi_cross_dso = true 163 debug = false 164 } 165} 166 167ohos_shared_library("usagestatistics") { 168 cflags_cc = [ 169 "-fdata-sections", 170 "-ffunction-sections", 171 "-fvisibility=hidden", 172 "-fstack-protector-strong", 173 "-Os", 174 ] 175 sources = [ 176 "frameworks/src/app_group_observer_napi.cpp", 177 "frameworks/src/bundle_active_app_group_napi.cpp", 178 "frameworks/src/bundle_state_common.cpp", 179 "frameworks/src/bundle_state_query_napi.cpp", 180 "frameworks/src/usage_statistics_init.cpp", 181 ] 182 include_dirs = [ 183 "interfaces/innerkits/include", 184 "interfaces/kits/bundlestats/napi/include", 185 "services/common/include", 186 "services/packagegroup/include", 187 "services/packageusage/include", 188 ] 189 190 deps = [ 191 ":usagestatsinner", 192 ":usagestatsutils", 193 ] 194 195 external_deps = [ 196 "c_utils:utils", 197 "ffrt:libffrt", 198 "hilog:libhilog", 199 "ipc:ipc_single", 200 "napi:ace_napi", 201 ] 202 relative_install_dir = "module/resourceschedule" 203 part_name = "${device_usage_statistics_part_name}" 204 subsystem_name = "resourceschedule" 205 branch_protector_ret = "pac_ret" 206 207 sanitize = { 208 cfi = true 209 cfi_cross_dso = true 210 debug = false 211 } 212} 213 214ohos_shared_library("usagestatservice") { 215 if (!use_clang_coverage) { 216 shlib_type = "sa" 217 } 218 219 cflags_cc = [ 220 "-fdata-sections", 221 "-ffunction-sections", 222 "-fvisibility=hidden", 223 "-fstack-protector-strong", 224 "-Os", 225 ] 226 sources = [ 227 "services/common/src/bundle_active_account_helper.cpp", 228 "services/common/src/bundle_active_app_state_obsever.cpp", 229 "services/common/src/bundle_active_binary_search.cpp", 230 "services/common/src/bundle_active_bundle_mgr_helper.cpp", 231 "services/common/src/bundle_active_config_reader.cpp", 232 "services/common/src/bundle_active_continuous_task_observer.cpp", 233 "services/common/src/bundle_active_core.cpp", 234 "services/common/src/bundle_active_debug_mode.cpp", 235 "services/common/src/bundle_active_open_callback.cpp", 236 "services/common/src/bundle_active_power_state_callback_service.cpp", 237 "services/common/src/bundle_active_service.cpp", 238 "services/common/src/bundle_active_shutdown_callback_service.cpp", 239 "services/common/src/bundle_active_usage_database.cpp", 240 "services/packagegroup/src/bundle_active_group_controller.cpp", 241 "services/packagegroup/src/bundle_active_group_handler.cpp", 242 "services/packagegroup/src/bundle_active_user_history.cpp", 243 "services/packageusage/src/bundle_active_calendar.cpp", 244 "services/packageusage/src/bundle_active_event_list.cpp", 245 "services/packageusage/src/bundle_active_event_tracker.cpp", 246 "services/packageusage/src/bundle_active_period_stats.cpp", 247 "services/packageusage/src/bundle_active_report_handler.cpp", 248 "services/packageusage/src/bundle_active_stats_combiner.cpp", 249 "services/packageusage/src/bundle_active_user_service.cpp", 250 ] 251 public_configs = [ ":usagestats_public_config" ] 252 253 deps = [ 254 ":usagestatsinner", 255 ":usagestatsutils", 256 ] 257 258 external_deps = [ 259 "ability_base:want", 260 "ability_runtime:app_manager", 261 "ability_runtime:wantagent_innerkits", 262 "access_token:libaccesstoken_sdk", 263 "access_token:libtokenid_sdk", 264 "bundle_framework:appexecfwk_base", 265 "bundle_framework:appexecfwk_core", 266 "c_utils:utils", 267 "common_event_service:cesfwk_innerkits", 268 "config_policy:configpolicy_util", 269 "eventhandler:libeventhandler", 270 "ffrt:libffrt", 271 "hicollie:libhicollie", 272 "hilog:libhilog", 273 "init:libbegetutil", 274 "ipc:ipc_single", 275 "relational_store:native_rdb", 276 "safwk:system_ability_fwk", 277 "samgr:samgr_proxy", 278 "time_service:time_client", 279 ] 280 281 public_external_deps = [ "jsoncpp:jsoncpp" ] 282 283 if (os_account_part_enabled) { 284 cflags_cc += [ "-DOS_ACCOUNT_PART_ENABLED" ] 285 external_deps += [ "os_account:os_account_innerkits" ] 286 } 287 288 defines = [] 289 if (bgtaskmgr_enable) { 290 external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] 291 defines += [ "BGTASKMGR_ENABLE" ] 292 } 293 if (device_usage_statistics_with_powermgr_power_manager_enable) { 294 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 295 external_deps += [ "power_manager:powermgr_client" ] 296 } 297 part_name = "${device_usage_statistics_part_name}" 298 subsystem_name = "resourceschedule" 299 branch_protector_ret = "pac_ret" 300 301 sanitize = { 302 cfi = true 303 cfi_cross_dso = true 304 debug = false 305 } 306} 307 308ohos_static_library("usagestatservice_static") { 309 cflags_cc = [ "-DDEVICE_USAGE_UNIT_TEST" ] 310 311 sources = [ 312 "services/common/src/bundle_active_account_helper.cpp", 313 "services/common/src/bundle_active_app_state_obsever.cpp", 314 "services/common/src/bundle_active_binary_search.cpp", 315 "services/common/src/bundle_active_bundle_mgr_helper.cpp", 316 "services/common/src/bundle_active_config_reader.cpp", 317 "services/common/src/bundle_active_continuous_task_observer.cpp", 318 "services/common/src/bundle_active_core.cpp", 319 "services/common/src/bundle_active_debug_mode.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/packagegroup/src/bundle_active_group_controller.cpp", 326 "services/packagegroup/src/bundle_active_group_handler.cpp", 327 "services/packagegroup/src/bundle_active_user_history.cpp", 328 "services/packageusage/src/bundle_active_calendar.cpp", 329 "services/packageusage/src/bundle_active_event_list.cpp", 330 "services/packageusage/src/bundle_active_event_tracker.cpp", 331 "services/packageusage/src/bundle_active_period_stats.cpp", 332 "services/packageusage/src/bundle_active_report_handler.cpp", 333 "services/packageusage/src/bundle_active_stats_combiner.cpp", 334 "services/packageusage/src/bundle_active_user_service.cpp", 335 ] 336 public_configs = [ ":usagestats_public_config" ] 337 338 deps = [ 339 ":usagestatsinner", 340 ":usagestatsutils", 341 ] 342 343 external_deps = [ 344 "ability_base:want", 345 "ability_runtime:app_manager", 346 "ability_runtime:wantagent_innerkits", 347 "access_token:libaccesstoken_sdk", 348 "access_token:libtokenid_sdk", 349 "bundle_framework:appexecfwk_base", 350 "bundle_framework:appexecfwk_core", 351 "c_utils:utils", 352 "common_event_service:cesfwk_innerkits", 353 "config_policy:configpolicy_util", 354 "eventhandler:libeventhandler", 355 "ffrt:libffrt", 356 "hicollie:libhicollie", 357 "hilog:libhilog", 358 "init:libbegetutil", 359 "ipc:ipc_single", 360 "relational_store:native_rdb", 361 "safwk:system_ability_fwk", 362 "samgr:samgr_proxy", 363 "time_service:time_client", 364 ] 365 366 public_external_deps = [ "jsoncpp:jsoncpp" ] 367 368 if (os_account_part_enabled) { 369 cflags_cc += [ "-DOS_ACCOUNT_PART_ENABLED" ] 370 external_deps += [ "os_account:os_account_innerkits" ] 371 } 372 373 defines = [] 374 if (bgtaskmgr_enable) { 375 external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] 376 defines += [ "BGTASKMGR_ENABLE" ] 377 } 378 if (device_usage_statistics_with_powermgr_power_manager_enable) { 379 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 380 external_deps += [ "power_manager:powermgr_client" ] 381 } 382 part_name = "${device_usage_statistics_part_name}" 383 subsystem_name = "resourceschedule" 384 branch_protector_ret = "pac_ret" 385 386 sanitize = { 387 cfi = true 388 cfi_cross_dso = true 389 debug = false 390 } 391} 392 393ohos_shared_library("usagestatsutils") { 394 cflags_cc = [ 395 "-fdata-sections", 396 "-ffunction-sections", 397 "-fstack-protector-strong", 398 "-Os", 399 ] 400 sources = [ 401 "utils/src/bundle_active_log.cpp", 402 "utils/src/bundle_active_util.cpp", 403 ] 404 public_configs = [ ":usagestatsutils_config" ] 405 406 external_deps = [ 407 "c_utils:utils", 408 "hilog:libhilog", 409 ] 410 innerapi_tags = [ "platformsdk" ] 411 part_name = "${device_usage_statistics_part_name}" 412 subsystem_name = "resourceschedule" 413 branch_protector_ret = "pac_ret" 414 415 sanitize = { 416 cfi = true 417 cfi_cross_dso = true 418 debug = false 419 } 420} 421 422group("bfwk_group_all") { 423 if (device_usage_statistics_device_enable) { 424 deps = [ 425 "${usage_statistics_path}:bundlestate", 426 "${usage_statistics_path}:usagestatsinner", 427 "${usage_statistics_path}:usagestatsutils", 428 ] 429 } 430} 431 432group("service_group_all") { 433 if (device_usage_statistics_device_enable) { 434 deps = [ 435 "${usage_statistics_path}:device_usage_statistics_sa_profile", 436 "${usage_statistics_path}:device_usage_statistics_service_init", 437 "${usage_statistics_path}:usagestatistics", 438 "${usage_statistics_path}:usagestatservice", 439 ] 440 } 441} 442 443group("test_all") { 444 testonly = true 445 if (device_usage_statistics_device_enable) { 446 deps = [ 447 "${usage_statistics_path}/interfaces/test/unittest/device_usage_statistics_jsunittest:js_unittest", 448 "${usage_statistics_path}/test/fuzztest/appgroupcallbackstub_fuzzer:fuzztest", 449 "${usage_statistics_path}/test/fuzztest/bundleactiveobserver_fuzzer:fuzztest", 450 "${usage_statistics_path}/test/fuzztest/bundleactiveonremoterequest_fuzzer:fuzztest", 451 "${usage_statistics_path}/test/fuzztest/bundleactivepowerstatecallbackproxy_fuzzer:fuzztest", 452 "${usage_statistics_path}/test/unittest:unittest", 453 ] 454 } 455} 456