# Copyright (c) 2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//build/ohos/sa_profile/sa_profile.gni") import("device_usage_statistics.gni") ohos_sa_profile("device_usage_statistics_sa_profile") { sources = [ "sa_profile/1907.json" ] part_name = "${device_usage_statistics_part_name}" } config("usagestats_public_config") { include_dirs = [ "interfaces/innerkits/include", "interfaces/kits/bundlestats/napi/include", "services/common/include", "services/packagegroup/include", "services/packageusage/include", ] } config("usagestatsutils_config") { include_dirs = [ "utils/include" ] } ohos_shared_library("usagestatsinner") { sources = [ "interfaces/innerkits/src/app_group_callback_info.cpp", "interfaces/innerkits/src/app_group_callback_proxy.cpp", "interfaces/innerkits/src/app_group_callback_stub.cpp", "interfaces/innerkits/src/bundle_active_client.cpp", "interfaces/innerkits/src/bundle_active_event.cpp", "interfaces/innerkits/src/bundle_active_event_stats.cpp", "interfaces/innerkits/src/bundle_active_form_record.cpp", "interfaces/innerkits/src/bundle_active_module_record.cpp", "interfaces/innerkits/src/bundle_active_package_stats.cpp", "interfaces/innerkits/src/bundle_active_proxy.cpp", ] public_configs = [ ":usagestats_public_config" ] deps = [ ":usagestatsutils" ] external_deps = [ "c_utils:utils", "eventhandler:libeventhandler", "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", ] public_external_deps = [ "ffrt:libffrt" ] part_name = "${device_usage_statistics_part_name}" subsystem_name = "resourceschedule" innerapi_tags = [ "platformsdk" ] version_script = "libusagestatsinner.versionscript" branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true debug = false } } ohos_prebuilt_etc("device_usage_statistics_service_init") { source = "init/device_usage_statistics_service.cfg" relative_install_dir = "init" part_name = "${device_usage_statistics_part_name}" subsystem_name = "resourceschedule" } ohos_shared_library("bundlestate") { sources = [ "frameworks/src/bundle_state_common.cpp", "frameworks/src/bundle_state_init.cpp", "frameworks/src/bundle_state_query.cpp", ] include_dirs = [ "interfaces/innerkits/include", "interfaces/kits/bundlestats/napi/include", "services/common/include", "services/packagegroup/include", "services/packageusage/include", ] deps = [ ":usagestatsinner", ":usagestatsutils", ] external_deps = [ "c_utils:utils", "hilog:libhilog", "ipc:ipc_single", "napi:ace_napi", ] public_external_deps = [ "ffrt:libffrt" ] relative_install_dir = "module" part_name = "${device_usage_statistics_part_name}" subsystem_name = "resourceschedule" branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true debug = false } } ohos_shared_library("usagestatistics") { sources = [ "frameworks/src/app_group_observer_napi.cpp", "frameworks/src/bundle_active_app_group_napi.cpp", "frameworks/src/bundle_state_common.cpp", "frameworks/src/bundle_state_query_napi.cpp", "frameworks/src/usage_statistics_init.cpp", ] include_dirs = [ "interfaces/innerkits/include", "interfaces/kits/bundlestats/napi/include", "services/common/include", "services/packagegroup/include", "services/packageusage/include", ] deps = [ ":usagestatsinner", ":usagestatsutils", ] external_deps = [ "c_utils:utils", "ffrt:libffrt", "hilog:libhilog", "ipc:ipc_single", "napi:ace_napi", ] relative_install_dir = "module/resourceschedule" part_name = "${device_usage_statistics_part_name}" subsystem_name = "resourceschedule" branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true debug = false } } ohos_shared_library("usagestatservice") { if (!use_clang_coverage) { shlib_type = "sa" } cflags_cc = [] sources = [ "services/common/src/bundle_active_account_helper.cpp", "services/common/src/bundle_active_app_state_obsever.cpp", "services/common/src/bundle_active_binary_search.cpp", "services/common/src/bundle_active_bundle_mgr_helper.cpp", "services/common/src/bundle_active_config_reader.cpp", "services/common/src/bundle_active_continuous_task_observer.cpp", "services/common/src/bundle_active_core.cpp", "services/common/src/bundle_active_debug_mode.cpp", "services/common/src/bundle_active_open_callback.cpp", "services/common/src/bundle_active_power_state_callback_service.cpp", "services/common/src/bundle_active_service.cpp", "services/common/src/bundle_active_shutdown_callback_service.cpp", "services/common/src/bundle_active_stub.cpp", "services/common/src/bundle_active_usage_database.cpp", "services/packagegroup/src/bundle_active_group_controller.cpp", "services/packagegroup/src/bundle_active_group_handler.cpp", "services/packagegroup/src/bundle_active_user_history.cpp", "services/packageusage/src/bundle_active_calendar.cpp", "services/packageusage/src/bundle_active_event_list.cpp", "services/packageusage/src/bundle_active_event_tracker.cpp", "services/packageusage/src/bundle_active_period_stats.cpp", "services/packageusage/src/bundle_active_report_handler.cpp", "services/packageusage/src/bundle_active_stats_combiner.cpp", "services/packageusage/src/bundle_active_user_service.cpp", ] public_configs = [ ":usagestats_public_config" ] deps = [ ":usagestatsinner", ":usagestatsutils", ] external_deps = [ "ability_base:want", "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", "eventhandler:libeventhandler", "ffrt:libffrt", "hicollie:libhicollie", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_single", "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", "time_service:time_client", ] public_external_deps = [ "jsoncpp:jsoncpp" ] if (os_account_part_enabled) { cflags_cc += [ "-DOS_ACCOUNT_PART_ENABLED" ] external_deps += [ "os_account:os_account_innerkits" ] } defines = [] if (bgtaskmgr_enable) { external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] defines += [ "BGTASKMGR_ENABLE" ] } if (device_usage_statistics_with_powermgr_power_manager_enable) { defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] external_deps += [ "power_manager:powermgr_client" ] } part_name = "${device_usage_statistics_part_name}" subsystem_name = "resourceschedule" branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true debug = false } } ohos_static_library("usagestatservice_static") { cflags_cc = [ "-DDEVICE_USAGE_UNIT_TEST" ] sources = [ "services/common/src/bundle_active_account_helper.cpp", "services/common/src/bundle_active_app_state_obsever.cpp", "services/common/src/bundle_active_binary_search.cpp", "services/common/src/bundle_active_bundle_mgr_helper.cpp", "services/common/src/bundle_active_config_reader.cpp", "services/common/src/bundle_active_continuous_task_observer.cpp", "services/common/src/bundle_active_core.cpp", "services/common/src/bundle_active_debug_mode.cpp", "services/common/src/bundle_active_open_callback.cpp", "services/common/src/bundle_active_power_state_callback_service.cpp", "services/common/src/bundle_active_service.cpp", "services/common/src/bundle_active_shutdown_callback_service.cpp", "services/common/src/bundle_active_stub.cpp", "services/common/src/bundle_active_usage_database.cpp", "services/packagegroup/src/bundle_active_group_controller.cpp", "services/packagegroup/src/bundle_active_group_handler.cpp", "services/packagegroup/src/bundle_active_user_history.cpp", "services/packageusage/src/bundle_active_calendar.cpp", "services/packageusage/src/bundle_active_event_list.cpp", "services/packageusage/src/bundle_active_event_tracker.cpp", "services/packageusage/src/bundle_active_period_stats.cpp", "services/packageusage/src/bundle_active_report_handler.cpp", "services/packageusage/src/bundle_active_stats_combiner.cpp", "services/packageusage/src/bundle_active_user_service.cpp", ] public_configs = [ ":usagestats_public_config" ] deps = [ ":usagestatsinner", ":usagestatsutils", ] external_deps = [ "ability_base:want", "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", "eventhandler:libeventhandler", "ffrt:libffrt", "hicollie:libhicollie", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_single", "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", "time_service:time_client", ] public_external_deps = [ "jsoncpp:jsoncpp" ] if (os_account_part_enabled) { cflags_cc += [ "-DOS_ACCOUNT_PART_ENABLED" ] external_deps += [ "os_account:os_account_innerkits" ] } defines = [] if (bgtaskmgr_enable) { external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] defines += [ "BGTASKMGR_ENABLE" ] } if (device_usage_statistics_with_powermgr_power_manager_enable) { defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] external_deps += [ "power_manager:powermgr_client" ] } part_name = "${device_usage_statistics_part_name}" subsystem_name = "resourceschedule" branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true debug = false } } ohos_shared_library("usagestatsutils") { sources = [ "utils/src/bundle_active_log.cpp", "utils/src/bundle_active_util.cpp", ] public_configs = [ ":usagestatsutils_config" ] external_deps = [ "c_utils:utils", "hilog:libhilog", ] innerapi_tags = [ "platformsdk" ] part_name = "${device_usage_statistics_part_name}" subsystem_name = "resourceschedule" branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true debug = false } } group("bfwk_group_all") { if (device_usage_statistics_device_enable) { deps = [ "${usage_statistics_path}:bundlestate", "${usage_statistics_path}:usagestatsinner", "${usage_statistics_path}:usagestatsutils", ] } } group("service_group_all") { if (device_usage_statistics_device_enable) { deps = [ "${usage_statistics_path}:device_usage_statistics_sa_profile", "${usage_statistics_path}:device_usage_statistics_service_init", "${usage_statistics_path}:usagestatistics", "${usage_statistics_path}:usagestatservice", ] } } group("test_all") { testonly = true if (device_usage_statistics_device_enable) { deps = [ "${usage_statistics_path}/interfaces/test/unittest/device_usage_statistics_jsunittest:js_unittest", "${usage_statistics_path}/test/fuzztest/appgroupcallbackstub_fuzzer:fuzztest", "${usage_statistics_path}/test/fuzztest/bundleactiveobserver_fuzzer:fuzztest", "${usage_statistics_path}/test/fuzztest/bundleactiveonremoterequest_fuzzer:fuzztest", "${usage_statistics_path}/test/fuzztest/bundleactivepowerstatecallbackproxy_fuzzer:fuzztest", "${usage_statistics_path}/test/unittest:unittest", ] } }