# Copyright (c) 2022-2026 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.gni")
access_token_path = "//base/security/access_token"
access_token_innerkit_path =
"//base/security/access_token/interfaces/innerkits/accesstoken"
module_output_path_interface_privacy =
"access_token/access_token/interface_privacy"
module_output_path_interface_access_token =
"access_token/access_token/interface_access_token"
module_output_path_service_privacy = "access_token/access_token/service_privacy"
module_output_path_service_access_token =
"access_token/access_token/service_access_token"
module_output_path_unittest_accesstoken = "access_token/access_token"
module_output_path_unittest_privacy = "access_token/privacy"
module_output_path_unittest_atm_tools = "access_token/tools"
declare_args() {
access_token_camera_float_window_enable = true
access_token_with_distributed_capability = true
access_token_enhance_capability = true
access_token_enable_manual_test = false
access_token_support_subprofile = false
}
# External dependencies for each feature flag
access_token_external_deps = []
access_token_cflags_cc = [ "-DHILOG_ENABLE" ]
# TEMP_PERMISSION_BACKGROUND_REVOKE_CAMERA_MIC_ENABLE is intentionally not enabled by default.
# Define it only when camera/microphone PERMISSION_ALLOW_THIS_TIME should be revoked
# on background transition and continuous-task state changes.
if (defined(product_name) &&
(product_name == "rk3568" || product_name == "standard")) {
access_token_cflags_cc +=
[ "-DACCESS_TOKEN_DEFAULT_MAX_QUERY_RESULT_SIZE=10000" ]
} else {
access_token_cflags_cc +=
[ "-DACCESS_TOKEN_DEFAULT_MAX_QUERY_RESULT_SIZE=20000" ]
}
if (use_libfuzzer) {
access_token_cflags_cc += [ "-DFUZZ_ENABLE" ]
}
if (access_token_enhance_capability == true) {
access_token_cflags_cc += [ "-DENHANCE_CAPABILITY" ]
}
if (access_token_enable_manual_test == true) {
access_token_cflags_cc += [ "-DENHANCE_MANUAL_TEST" ]
}
if (access_token_camera_float_window_enable == true) {
access_token_cflags_cc += [ "-DCAMERA_FLOAT_WINDOW_ENABLE" ]
}
if (target_platform == "car" &&
(!defined(global_parts_info) || defined(global_parts_info.os_account))) {
access_token_support_subprofile = true
access_token_cflags_cc += [ "-DACCESS_TOKEN_SUPPORT_SUBPROFILE" ]
}
if (!defined(global_parts_info) ||
(defined(global_parts_info.distributedhardware_device_manager) &&
access_token_with_distributed_capability == true)) {
token_sync_enable = true
access_token_cflags_cc += [ "-DTOKEN_SYNC_ENABLE" ]
access_token_external_deps += [ "device_manager:devicemanagersdk" ]
} else {
token_sync_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.security_dlp_permission_service)) {
dlp_permission_enable = true
access_token_cflags_cc += [ "-DSUPPORT_SANDBOX_APP" ]
} else {
dlp_permission_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.ability_ability_base)) {
ability_base_enable = true
} else {
ability_base_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.hiviewdfx_hicollie)) {
hicollie_enable = true
access_token_cflags_cc += [ "-DHICOLLIE_ENABLE" ]
access_token_external_deps += [ "hicollie:libhicollie" ]
} else {
hicollie_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.hiviewdfx_hitrace_native)) {
hiviewdfx_hitrace_native_enable = true
access_token_cflags_cc += [ "-DHITRACE_NATIVE_ENABLE" ]
access_token_external_deps += [ "hitrace:hitrace_meter" ]
} else {
hiviewdfx_hitrace_native_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.multimedia_audio_framework)) {
audio_framework_enable = true
access_token_cflags_cc += [ "-DAUDIO_FRAMEWORK_ENABLE" ]
access_token_external_deps += [ "audio_framework:audio_client" ]
} else {
audio_framework_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.multimedia_camera_framework)) {
camera_framework_enable = true
access_token_cflags_cc += [ "-DCAMERA_FRAMEWORK_ENABLE" ]
access_token_external_deps += [ "camera_framework:camera_framework" ]
} else {
camera_framework_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.ability_ability_runtime)) {
ability_runtime_enable = true
access_token_cflags_cc += [ "-DABILITY_RUNTIME_ENABLE" ]
} else {
ability_runtime_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.security_security_component_enhance)) {
security_component_enhance_enable = true
access_token_cflags_cc += [ "-DSECURITY_COMPONENT_ENHANCE_ENABLE" ]
access_token_external_deps += [ "ipc:ipc_single" ]
} else {
security_component_enhance_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.customization_config_policy)) {
customization_config_policy_enable = true
access_token_cflags_cc += [ "-DCUSTOMIZATION_CONFIG_POLICY_ENABLE" ]
access_token_external_deps += [ "config_policy:configpolicy_util" ]
} else {
customization_config_policy_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.theme_screenlock_mgr)) {
theme_screenlock_mgr_enable = true
access_token_cflags_cc += [ "-DTHEME_SCREENLOCK_MGR_ENABLE" ]
access_token_external_deps += [ "screenlock_mgr:screenlock_client" ]
} else {
theme_screenlock_mgr_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.notification_common_event_service)) {
common_event_service_enable = true
access_token_cflags_cc += [ "-DCOMMON_EVENT_SERVICE_ENABLE" ]
access_token_external_deps += [ "common_event_service:cesfwk_innerkits" ]
} else {
common_event_service_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.notification_eventhandler)) {
eventhandler_enable = true
access_token_cflags_cc += [ "-DEVENTHANDLER_ENABLE" ]
access_token_external_deps += [ "eventhandler:libeventhandler" ]
} else {
eventhandler_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.resourceschedule_background_task_mgr)) {
access_token_background_task_mgr_continuous_task_enable = true
access_token_cflags_cc += [ "-DBGTASKMGR_CONTINUOUS_TASK_ENABLE" ]
} else {
access_token_background_task_mgr_continuous_task_enable = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.appsecurityprivacy_security_privacy_server)) {
access_token_app_security_privacy_service_enable = true
access_token_cflags_cc += [ "-DAPP_SECURITY_PRIVACY_SERVICE" ]
} else {
access_token_app_security_privacy_service_enable = false
}
if (defined(global_parts_info) &&
defined(global_parts_info.resourceschedule_memmgr_override)) {
memory_manager_enable = true
access_token_cflags_cc += [ "-DMEMORY_MANAGER_ENABLE" ]
access_token_external_deps += [ "memmgr:memmgrclient" ]
} else {
memory_manager_enable = false
}
if (defined(global_parts_info) &&
defined(global_parts_info.security_security_guard)) {
security_guard_enable = true
access_token_cflags_cc += [ "-DSECURITY_GUARD_ENABLE" ]
access_token_external_deps += [ "security_guard:libsg_collect_sdk" ]
} else {
security_guard_enable = false
}
if ("${target_platform}" == "watch" || "${target_platform}" == "wearable") {
lite_device_enable = true
access_token_cflags_cc += [ "-DDYNAMIC_CLOSE_LIBS" ]
} else {
lite_device_enable = false
access_token_cflags_cc += [ "-DREMOTE_PRIVACY_ENABLE" ]
}
if ("${target_platform}" == "pc" || "${target_platform}" == "tablet" ||
"${target_platform}" == "phone" || use_libfuzzer) {
access_token_manage_user_policy_enable = true
access_token_cflags_cc += [ "-DSUPPORT_MANAGE_USER_POLICY" ]
} else {
access_token_manage_user_policy_enable = false
}
if ("${target_platform}" == "phone" || "${target_platform}" == "tablet" ||
"${target_platform}" == "pc") {
privacy_bundle_start_stop_enable = true
access_token_cflags_cc += [ "-DPRIVACY_BUNDLE_START_STOP_ENABLE" ]
} else {
privacy_bundle_start_stop_enable = false
}
if (is_emulator) {
access_token_cflags_cc += [ "-DX86_EMULATOR_MODE" ]
}
if (defined(global_parts_info) &&
defined(global_parts_info.security_appverify)) {
access_token_cflags_cc += [ "-DIS_SUPPORT_HAP_RUNNING" ]
access_token_manager_hapverify_enable = true
access_token_external_deps += [ "appverify:libhapverify" ]
} else {
access_token_manager_hapverify_enable = false
}
if (defined(global_parts_info) && defined(global_parts_info.security_asset)) {
access_token_cflags_cc += [ "-DSAF_AGENT_FENCE_ENABLE" ]
saf_agent_fence_enable = true
access_token_external_deps += [ "asset:saf_agent_fence" ]
} else {
saf_agent_fence_enable = false
}