• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2025 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.gni")
15import("//build/ohos/sa_profile/sa_profile.gni")
16import("//foundation/filemanagement/storage_service/storage_service_aafwk.gni")
17
18config("storage_manager_config") {
19  include_dirs = [
20    "include",
21    "${storage_interface_path}/innerkits/storage_manager/native",
22    "${storage_daemon_path}/include",
23    "${storage_service_common_path}/include",
24  ]
25
26  cflags = [
27    "-D_FORTIFY_SOURCE=2",
28    "-fstack-protector-strong",
29    "-O2",
30  ]
31}
32
33ohos_shared_library("storage_manager") {
34  branch_protector_ret = "pac_ret"
35  sanitize = {
36    integer_overflow = true
37    ubsan = true
38    boundary_sanitize = true
39    cfi = true
40    cfi_cross_dso = true
41    debug = false
42  }
43
44  sources = [
45    "ipc/src/storage_manager.cpp",
46    "ipc/src/storage_manager_provider.cpp",
47    "storage_daemon_communication/src/storage_daemon_communication.cpp",
48    "user/src/multi_user_manager_service.cpp",
49    "utils/src/storage_utils.cpp",
50  ]
51
52  defines = [
53    "STORAGE_LOG_TAG = \"StorageManager\"",
54    "LOG_DOMAIN = 0xD004300",
55  ]
56
57  if (storage_service_user_crypto_manager) {
58    defines += [ "USER_CRYPTO_MANAGER" ]
59    sources += [ "crypto/filesystem_crypto.cpp" ]
60  }
61
62  if (storage_service_external_storage_manager) {
63    defines += [ "EXTERNAL_STORAGE_MANAGER" ]
64    sources += [
65      "disk/src/disk_manager_service.cpp",
66      "volume/src/notification.cpp",
67      "volume/src/volume_manager_service.cpp",
68      "volume/src/volume_manager_service_ext.cpp",
69    ]
70  }
71
72  if (storage_service_media_fuse) {
73    defines += [ "STORAGE_SERVICE_MEDIA_FUSE" ]
74  }
75
76  configs = [ ":storage_manager_config" ]
77
78  deps = [
79    "${storage_daemon_path}:storage_common_utils",
80    "${storage_daemon_path}:storage_daemon_ipc",
81    "${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy",
82  ]
83
84  external_deps = [
85    "ability_base:base",
86    "ability_base:want",
87    "ability_base:zuri",
88    "ability_runtime:extensionkit_native",
89    "access_token:libaccesstoken_sdk",
90    "appspawn:appspawn_client",
91    "cJSON:cjson",
92    "c_utils:utils",
93    "common_event_service:cesfwk_innerkits",
94    "hilog:libhilog",
95    "hitrace:hitrace_meter",
96    "ipc:ipc_single",
97    "os_account:os_account_innerkits",
98    "safwk:system_ability_fwk",
99    "samgr:samgr_proxy",
100  ]
101
102  if (storage_service_storage_statistics_manager) {
103    defines += [ "STORAGE_STATISTICS_MANAGER" ]
104    sources += [
105      "account_subscriber/account_subscriber.cpp",
106      "storage/src/bundle_manager_connector.cpp",
107      "storage/src/storage_monitor_service.cpp",
108      "storage/src/storage_status_service.cpp",
109      "storage/src/storage_total_status_service.cpp",
110      "storage/src/volume_storage_status_service.cpp",
111    ]
112    external_deps += [
113      "ability_runtime:abilitykit_native",
114      "ability_runtime:dataobs_manager",
115      "bundle_framework:appexecfwk_base",
116      "bundle_framework:appexecfwk_core",
117      "data_share:datashare_consumer",
118      "eventhandler:libeventhandler",
119      "init:libbegetutil",
120      "relational_store:native_rdb",
121    ]
122    deps += [ ":storage_manager_monitor_config" ]
123
124    if (storage_service_graphic) {
125      defines += [ "STORAGE_SERVICE_GRAPHIC" ]
126      external_deps += [ "data_share:datashare_common" ]
127    }
128  }
129
130  if (storage_service_el5_filekey_manager) {
131    defines += [ "EL5_FILEKEY_MANAGER" ]
132    external_deps += [ "access_token:el5_filekey_manager_sdk" ]
133  }
134
135  if (enable_screenlock_manager) {
136    defines += [ "ENABLE_SCREENLOCK_MANAGER" ]
137    external_deps += [ "screenlock_mgr:screenlock_client" ]
138  }
139
140  subsystem_name = "filemanagement"
141  part_name = "storage_service"
142  install_enable = true
143}
144
145ohos_prebuilt_etc("storage_manager_config.para") {
146  source = "storage_manager_config.para"
147  part_name = "storage_service"
148  subsystem_name = "filemanagement"
149  module_install_dir = "etc/param"
150}
151
152ohos_prebuilt_etc("storage_manager_config.para.dac") {
153  source = "storage_manager_config.para.dac"
154  part_name = "storage_service"
155  subsystem_name = "filemanagement"
156  module_install_dir = "etc/param"
157}
158
159group("storage_manager_monitor_config") {
160  deps = [
161    ":storage_manager_config.para",
162    ":storage_manager_config.para.dac",
163  ]
164}
165
166group("storage_manager_unit_test") {
167  testonly = true
168  deps = [
169    "account_subscriber/test:storage_account_subscriber_test",
170    "client/test:storage_manager_client_test",
171    "innerkits_impl/test:storage_manager_innerkits_test",
172    "ipc/test:storage_manager_ipc_test",
173    "storage_daemon_communication/test:storage_manager_communication_test",
174    "user/test:storage_manager_user_test",
175  ]
176
177  if (storage_service_user_crypto_manager) {
178    deps += [ "crypto/test:storage_manager_crypto_test" ]
179  }
180
181  if (storage_service_storage_statistics_manager) {
182    deps += [ "storage/test:storage_manager_storage_test" ]
183  }
184
185  if (storage_service_external_storage_manager) {
186    deps += [
187      "disk/test:storage_manager_disk_test",
188      "volume/test:storage_manager_volume_test",
189    ]
190  }
191}
192