1# Copyright (c) 2022-2024 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("../../access_token.gni")
16
17ohos_prebuilt_etc("privacy.rc") {
18  source = "privacy.cfg"
19  relative_install_dir = "init"
20  subsystem_name = "security"
21  part_name = "access_token"
22}
23
24group("privacymanager") {
25  if (is_standard_system && ability_base_enable == true) {
26    deps = [
27      "${access_token_path}/services/privacymanager:privacy_manager_service",
28      "${access_token_path}/services/privacymanager/sa_profile:privacy_sa_profile_standard",
29    ]
30  }
31}
32
33if (is_standard_system && ability_base_enable == true) {
34  ohos_shared_library("privacy_manager_service") {
35    subsystem_name = "security"
36    part_name = "access_token"
37    sanitize = {
38      cfi = true
39      cfi_cross_dso = true
40      debug = false
41    }
42    branch_protector_ret = "pac_ret"
43
44    if (!use_clang_coverage) {
45      version_script = "libprivacy_map"
46      shlib_type = "sa"
47    }
48
49    include_dirs = [
50      "include/active",
51      "include/common",
52      "include/database",
53      "include/record",
54      "include/service",
55      "include/sensitive",
56      "include/sensitive/audio_manager/",
57      "include/sensitive/camera_manager/",
58      "${access_token_path}/frameworks/privacy/include",
59      "${access_token_path}/frameworks/common/include",
60      "${access_token_path}/interfaces/innerkits/accesstoken/include",
61      "${access_token_path}/interfaces/innerkits/privacy/include",
62      "${access_token_path}/interfaces/innerkits/privacy/src",
63      "${access_token_path}/services/common/ability_manager/include",
64      "${access_token_path}/services/common/app_manager/include",
65      "${access_token_path}/services/common/config_policy/include",
66      "${access_token_path}/services/common/database/include",
67      "${access_token_path}/services/common/handler/include",
68      "${access_token_path}/services/common/libraryloader/include",
69      "${access_token_path}/services/common/power_manager/include",
70      "${access_token_path}/services/common/screenlock_manager/include",
71      "${access_token_path}/services/common/utils/include",
72    ]
73
74    sources = [
75      "${access_token_path}/services/common/power_manager/src/power_manager_client.cpp",
76      "${access_token_path}/services/common/power_manager/src/power_manager_proxy.cpp",
77      "src/active/active_status_callback_manager.cpp",
78      "src/active/perm_active_status_callback_death_recipient.cpp",
79      "src/active/perm_active_status_change_callback_proxy.cpp",
80      "src/active/state_change_callback_proxy.cpp",
81      "src/common/constant.cpp",
82      "src/database/data_translator.cpp",
83      "src/database/permission_used_record_db.cpp",
84      "src/database/privacy_field_const.cpp",
85      "src/record/on_permission_used_record_callback_proxy.cpp",
86      "src/record/permission_record.cpp",
87      "src/record/permission_record_manager.cpp",
88      "src/sensitive/audio_manager/audio_manager_privacy_client.cpp",
89      "src/sensitive/audio_manager/audio_manager_privacy_death_recipient.cpp",
90      "src/sensitive/audio_manager/audio_manager_privacy_proxy.cpp",
91      "src/sensitive/camera_manager/camera_manager_privacy_client.cpp",
92      "src/sensitive/camera_manager/camera_manager_privacy_death_recipient.cpp",
93      "src/sensitive/camera_manager/camera_manager_privacy_proxy.cpp",
94      "src/service/privacy_manager_service.cpp",
95      "src/service/privacy_manager_stub.cpp",
96    ]
97
98    cflags_cc = [
99      "-DHILOG_ENABLE",
100      "-fvisibility=hidden",
101    ]
102    configs = [
103      "${access_token_path}/config:access_token_compile_flags",
104      "${access_token_path}/config:coverage_flags",
105    ]
106    defines = [ "FEATURE_DTMF_TONE" ]
107
108    deps = [
109      "${access_token_path}/frameworks/common:accesstoken_common_cxx",
110      "${access_token_path}/frameworks/privacy:privacy_communication_adapter_cxx",
111      "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
112      "${access_token_path}/interfaces/innerkits/accesstoken:libtokenid_sdk",
113      "${access_token_path}/services/common:accesstoken_service_common",
114      "${access_token_path}/services/privacymanager:privacy.rc",
115    ]
116
117    external_deps = [
118      "ability_base:want",
119      "c_utils:utils",
120      "hilog:libhilog",
121      "hisysevent:libhisysevent",
122      "init:libbegetutil",
123      "ipc:ipc_single",
124      "safwk:system_ability_fwk",
125      "samgr:samgr_proxy",
126      "sqlite:sqlite",
127    ]
128
129    if (audio_framework_enable) {
130      include_dirs +=
131          [ "${audio_framework_path}/services/audio_policy/common/include" ]
132    }
133
134    if (ohos_indep_compiler_enable) {
135      external_deps += [
136        "bounds_checking_function:libsec_shared",
137        "json:nlohmann_json_static",
138      ]
139    }
140    if (eventhandler_enable == true) {
141      cflags_cc += [ "-DEVENTHANDLER_ENABLE" ]
142      external_deps += [ "eventhandler:libeventhandler" ]
143    }
144
145    if (common_event_service_enable) {
146      cflags_cc += [ "-DCOMMON_EVENT_SERVICE_ENABLE" ]
147      external_deps += [ "common_event_service:cesfwk_innerkits" ]
148      sources += [ "src/common/privacy_common_event_subscriber.cpp" ]
149    }
150
151    if (security_component_enhance_enable == true) {
152      cflags_cc += [ "-DSECURITY_COMPONENT_ENHANCE_ENABLE" ]
153      include_dirs += [ "include/seccomp" ]
154      sources += [ "src/seccomp/privacy_sec_comp_enhance_agent.cpp" ]
155    }
156
157    if (window_manager_enable && access_token_camera_float_window_enable) {
158      cflags_cc += [ "-DCAMERA_FLOAT_WINDOW_ENABLE" ]
159      include_dirs +=
160          [ "${access_token_path}/services/common/window_manager/include" ]
161      sources += [
162        "${access_token_path}/services/common/window_manager/src/privacy_mock_session_manager_proxy.cpp",
163        "${access_token_path}/services/common/window_manager/src/privacy_scene_session_manager_lite_proxy.cpp",
164        "${access_token_path}/services/common/window_manager/src/privacy_scene_session_manager_proxy.cpp",
165        "${access_token_path}/services/common/window_manager/src/privacy_session_manager_proxy.cpp",
166        "${access_token_path}/services/common/window_manager/src/privacy_window_manager_agent.cpp",
167        "${access_token_path}/services/common/window_manager/src/privacy_window_manager_client.cpp",
168        "${access_token_path}/services/common/window_manager/src/privacy_window_manager_death_recipient.cpp",
169        "${access_token_path}/services/common/window_manager/src/privacy_window_manager_proxy.cpp",
170      ]
171      external_deps += [ "window_manager:libwsutils" ]
172    }
173
174    if (access_token_app_security_privacy_service_enable) {
175      cflags_cc += [ "-DAPP_SECURITY_PRIVACY_SERVICE" ]
176    }
177
178    if (hicollie_enable == true) {
179      external_deps += [ "hicollie:libhicollie" ]
180      cflags_cc += [ "-DHICOLLIE_ENABLE" ]
181    }
182  }
183}
184