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