• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2022-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("../../common/config/common.gni")
16
17config("edm_config") {
18  cflags = [ "-Wno-error=implicit-fallthrough" ]
19  include_dirs = [
20    "include",
21    "include/connection",
22    "include/database",
23    "include/query_policy",
24    "include/strategy",
25    "include/watermark",
26    "../../framework/extension/include",
27  ]
28}
29
30ohos_shared_library("edmservice") {
31  sources = [ "./src/enterprise_device_mgr_stub.cpp" ]
32  public_configs = [
33    ":edm_config",
34    "../idl:enterprise_device_mgr_idl_gen_config",
35    "../../common/config:coverage_flags",
36  ]
37
38  defines = []
39
40  if (target_cpu == "arm64") {
41    defines += [ "_ARM64_" ]
42    print("defines _ARM64_")
43  }
44
45  if (target_cpu == "x86_64") {
46    defines += [ "_X86_64_" ]
47    print("defines _X86_64_")
48  }
49
50  external_deps = [
51    "ability_base:want",
52    "ability_runtime:ability_connect_callback_stub",
53    "ability_runtime:app_manager",
54    "ability_runtime:extension_manager",
55    "ability_runtime:wantagent_innerkits",
56    "access_token:libaccesstoken_sdk",
57    "access_token:libtokenid_sdk",
58    "bundle_framework:appexecfwk_base",
59    "bundle_framework:appexecfwk_core",
60    "cJSON:cjson",
61    "c_utils:utils",
62    "file_api:securitylabel",
63    "hilog:libhilog",
64    "hisysevent:libhisysevent",
65    "init:libbegetutil",
66    "ipc:ipc_core",
67    "relational_store:native_rdb",
68    "safwk:system_ability_fwk",
69    "samgr:samgr_proxy",
70    "window_manager:libwm",
71  ]
72
73  if (enterprise_device_management_support_all) {
74    defines += [ "EDM_SUPPORT_ALL_ENABLE" ]
75
76    sources += [
77      "./src/admin.cpp",
78      "./src/admin_container.cpp",
79      "./src/admin_manager.cpp",
80      "./src/admin_policies_storage_rdb.cpp",
81      "./src/application_state_observer.cpp",
82      "./src/connection/enterprise_account_connection.cpp",
83      "./src/connection/enterprise_admin_connection.cpp",
84      "./src/connection/enterprise_admin_proxy.cpp",
85      "./src/connection/enterprise_bundle_connection.cpp",
86      "./src/connection/enterprise_conn_manager.cpp",
87      "./src/connection/enterprise_kiosk_connection.cpp",
88      "./src/connection/enterprise_update_connection.cpp",
89      "./src/database/edm_rdb_data_manager.cpp",
90      "./src/database/edm_rdb_open_callback.cpp",
91      "./src/device_policies_storage_rdb.cpp",
92      "./src/enterprise_device_mgr_ability.cpp",
93      "./src/hisysevent_adapter.cpp",
94      "./src/permission_checker.cpp",
95      "./src/permission_manager.cpp",
96      "./src/plugin_manager.cpp",
97      "./src/policy_manager.cpp",
98      "./src/query_policy/allowed_app_distribution_types_query.cpp",
99      "./src/query_policy/allowed_install_bundles_query.cpp",
100      "./src/query_policy/disable_maintenance_mode_query.cpp",
101      "./src/query_policy/disable_mtp_client_query.cpp",
102      "./src/query_policy/disable_mtp_server_query.cpp",
103      "./src/query_policy/disable_user_mtp_client_query.cpp",
104      "./src/query_policy/disable_set_biometrics_and_screenLock_query.cpp",
105      "./src/query_policy/disable_set_device_name_query.cpp",
106      "./src/query_policy/disallow_distributed_transmission_query.cpp",
107      "./src/query_policy/disallow_modify_datetime_query.cpp",
108      "./src/query_policy/disallowed_install_bundles_query.cpp",
109      "./src/query_policy/disallowed_tethering_query.cpp",
110      "./src/query_policy/disallowed_uninstall_bundles_query.cpp",
111      "./src/query_policy/get_device_encryption_status_query.cpp",
112      "./src/query_policy/get_display_version_query.cpp",
113      "./src/query_policy/get_security_patch_tag_query.cpp",
114      "./src/query_policy/inactive_user_freeze_query.cpp",
115      "./src/query_policy/installed_bundle_info_list_query.cpp",
116      "./src/query_policy/ipolicy_query.cpp",
117      "./src/query_policy/is_app_kiosk_allowed_query.cpp",
118      "./src/query_policy/ntp_server_query.cpp",
119      "./src/query_policy/permission_managed_state_query.cpp",
120      "./src/query_policy/plugin_policy_reader.cpp",
121      "./src/query_policy/snapshot_skip_query.cpp",
122      "./src/strategy/enhance_execute_strategy.cpp",
123      "./src/strategy/replace_execute_strategy.cpp",
124      "./src/strategy/single_execute_strategy.cpp",
125      "./src/user_policy_manager.cpp",
126    ]
127  }
128
129  if (wifi_edm_enable) {
130    sources += [
131      "./src/query_policy/allowed_wifi_list_query.cpp",
132      "./src/query_policy/disallowed_wifi_list_query.cpp",
133      "./src/query_policy/set_wifi_disabled_query.cpp",
134    ]
135    defines += [ "WIFI_EDM_ENABLE" ]
136  }
137
138  if (location_edm_enable) {
139    sources += [ "./src/query_policy/location_policy_query.cpp" ]
140    defines += [ "LOCATION_EDM_ENABLE" ]
141  }
142
143  if (useriam_edm_enable) {
144    sources += [
145      "./src/query_policy/fingerprint_auth_query.cpp",
146      "./src/query_policy/password_policy_query.cpp",
147    ]
148    defines += [ "USERIAM_EDM_ENABLE" ]
149  }
150
151  if (enterprise_device_management_feature_pc_only) {
152    sources += [
153      "./src/query_policy/disable_samba_client_query.cpp",
154      "./src/query_policy/disable_samba_server_query.cpp",
155      "./src/query_policy/disable_usb_storage_device_write_query.cpp",
156      "./src/query_policy/disallow_export_recovery_key_query.cpp",
157      "./src/query_policy/disallow_modify_ethernet_ip_query.cpp",
158      "./src/query_policy/get_auto_unlock_after_reboot_query.cpp",
159      "./src/query_policy/install_local_enterprise_app_enabled_query.cpp",
160    ]
161    defines += [
162      "SAMBA_EDM_ENABLE",
163      "FEATURE_PC_ONLY"
164    ]
165  }
166
167  if (ability_runtime_edm_enable) {
168    sources += [ "./src/query_policy/disallowed_running_bundles_query.cpp" ]
169    defines += [ "ABILITY_RUNTIME_EDM_ENABLE" ]
170  }
171
172  if (bluetooth_edm_enable) {
173    sources += [
174      "./src/query_policy/allowed_bluetooth_devices_query.cpp",
175      "./src/query_policy/disable_bluetooth_query.cpp",
176      "./src/query_policy/disallowed_bluetooth_devices_query.cpp",
177    ]
178    defines += [ "BLUETOOTH_EDM_ENABLE" ]
179  }
180
181  if (camera_framework_edm_enable) {
182    sources += [ "./src/query_policy/disable_camera_query.cpp" ]
183    defines += [ "CAMERA_FRAMEWORK_EDM_ENABLE" ]
184  }
185
186  if (audio_framework_edm_enable) {
187    sources += [
188      "./src/query_policy/disable_hdc_query.cpp",
189      "./src/query_policy/disable_microphone_query.cpp",
190      "./src/query_policy/disable_printer_query.cpp",
191    ]
192    defines += [ "AUDIO_FRAMEWORK_EDM_ENABLE" ]
193  }
194
195  if (drivers_interface_usb_edm_enable && usb_manager_edm_enable) {
196    sources += [
197      "./src/query_policy/allowed_usb_devices_query.cpp",
198      "./src/query_policy/disable_usb_query.cpp",
199    ]
200    defines += [ "USB_SERVICE_EDM_ENABLE" ]
201  }
202
203  if (drivers_interface_usb_edm_enable && storage_service_edm_enable &&
204      usb_manager_edm_enable) {
205    sources += [ "./src/query_policy/usb_read_only_query.cpp" ]
206    defines += [ "USB_STORAGE_SERVICE_EDM_ENABLE" ]
207  }
208
209  if (pasteboard_edm_enable) {
210    sources += [ "./src/query_policy/clipboard_policy_query.cpp" ]
211    defines += [ "PASTEBOARD_EDM_ENABLE" ]
212  }
213
214  if (os_account_edm_enable) {
215    external_deps += [
216      "os_account:libaccountkits",
217      "os_account:os_account_innerkits",
218    ]
219
220    sources += [
221      "./src/query_policy/disallow_add_local_account_query.cpp",
222      "./src/watermark/watermark_application_observer.cpp",
223      "./src/watermark/watermark_observer_manager.cpp",
224    ]
225    defines += [ "OS_ACCOUNT_EDM_ENABLE" ]
226  }
227
228  if (os_account_edm_enable && enterprise_device_management_feature_pc_only) {
229    external_deps += [
230      "os_account:libaccountkits",
231      "os_account:os_account_innerkits",
232    ]
233
234    sources += [
235      "./src/query_policy/disable_print_query.cpp",
236      "./src/query_policy/disable_sudo_query.cpp",
237    ]
238    defines += [
239      "FEATURE_PC_ONLY",
240      "SUDO_EDM_ENABLE"
241    ]
242  }
243
244  if (netmanager_base_edm_enable) {
245    sources += [ "./src/query_policy/disallowed_airplane_mode_query.cpp" ]
246    defines += [ "NET_MANAGER_BASE_EDM_ENABLE" ]
247  }
248
249  if (common_event_service_edm_enable) {
250    external_deps += [ "common_event_service:cesfwk_innerkits" ]
251    sources += [ "./src/query_policy/set_browser_policies_query.cpp" ]
252    defines += [ "COMMON_EVENT_SERVICE_EDM_ENABLE" ]
253  }
254
255  if (!enterprise_device_management_feature_pc_only && sms_mms_edm_enable) {
256    sources += [
257      "./src/query_policy/disallowed_mms_query.cpp",
258      "./src/query_policy/disallowed_sms_query.cpp",
259    ]
260    defines += [
261      "SMS_EDM_ENABLE",
262      "MMS_EDM_ENABLE",
263    ]
264  }
265
266  if (!enterprise_device_management_feature_pc_only) {
267    sources += [
268      "./src/query_policy/disable_backup_and_restore_query.cpp",
269      "./src/query_policy/disable_private_space_query.cpp",
270    ]
271    defines += [
272      "BACKUP_AND_RESTORE_EDM_ENABLE",
273      "PRIVATE_SPACE_EDM_ENABLE",
274    ]
275  }
276
277  if (!enterprise_device_management_feature_pc_only &&
278      cellular_data_edm_enable) {
279    sources += [
280      "./src/query_policy/disallow_modify_apn_query.cpp",
281      "./src/query_policy/disallowed_mobile_data_query.cpp",
282      "./src/query_policy/disallowed_telephony_call_query.cpp",
283      "./src/query_policy/telephony_call_policy_query.cpp",
284    ]
285    defines += [
286      "APN_EDM_ENABLE",
287      "MOBILE_DATA_ENABLE",
288      "TELEPHONY_EDM_ENABLE"
289    ]
290  }
291
292  if (!enterprise_device_management_feature_pc_only && power_manager_edm_enable) {
293    sources += [ "./src/query_policy/disallow_power_long_press_query.cpp" ]
294    defines += [ "POWER_MANAGER_EDM_ENABLE" ]
295  }
296
297  if (notification_edm_enable) {
298    sources += [ "./src/query_policy/disallowed_notification_query.cpp" ]
299    defines += [ "NOTIFICATION_EDM_ENABLE" ]
300  }
301
302  if (netmanager_ext_edm_enable) {
303    sources += [ "./src/query_policy/disallow_vpn_query.cpp" ]
304    defines += [ "NETMANAGER_EXT_EDM_ENABLE" ]
305  }
306
307  deps = [
308    "../../common/external:edm_external_adapters",
309    "../../common/native:edm_commom",
310    "../../interfaces/inner_api:edmservice_kits",
311    "../../interfaces/inner_api/plugin_kits:plugin_kits",
312    "../idl:enterprise_device_mgr_idl_stub",
313  ]
314
315  shlib_type = "sa"
316
317  sanitize = {
318    boundary_sanitize = true
319    cfi = true
320    cfi_cross_dso = true
321    debug = false
322    integer_overflow = true
323    ubsan = true
324  }
325  branch_protector_ret = "pac_ret"
326  subsystem_name = "customization"
327  part_name = "enterprise_device_management"
328}
329