From cbd730a03bca18df0a70d117185db03acc439bcb Mon Sep 17 00:00:00 2001 From: y1585740638 Date: Wed, 3 Jul 2024 14:05:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E7=A7=81=E5=BC=B9=E7=AA=97=E9=9A=94?= =?UTF-8?q?=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: y1585740638 Change-Id: I3c33102da5d190c176926abb47f9ac67acb1541d --- access_token.gni | 8 +++++++- bundle.json | 3 +-- .../privacy_audio_service_ipc_interface_code.h | 8 ++++---- .../privacy_camera_service_ipc_interface_code.h | 4 ++-- services/privacymanager/BUILD.gn | 4 ++++ .../src/record/permission_record_manager.cpp | 13 +++++-------- .../src/service/privacy_manager_service.cpp | 1 + services/privacymanager/test/unittest/BUILD.gn | 9 ++++----- .../unittest/permission_record_manager_test.cpp | 4 ++++ .../test/unittest/sensitive_manager_test.cpp | 3 --- 10 files changed, 32 insertions(+), 25 deletions(-) diff --git a/access_token.gni b/access_token.gni index 59d0f13c6..3c8f3ea55 100644 --- a/access_token.gni +++ b/access_token.gni @@ -141,7 +141,13 @@ if (!defined(global_parts_info) || declare_args() { access_token_camera_float_window_enable = true - access_token_different_feature = true +} + +if (!defined(global_parts_info) || + defined(global_parts_info.appsecurityprivacy_security_privacy_server)) { + access_token_app_security_privacy_service_enable = true +} else { + access_token_app_security_privacy_service_enable = false } if (!defined(global_parts_info) || diff --git a/bundle.json b/bundle.json index 9eafb42e8..2af21ed6a 100644 --- a/bundle.json +++ b/bundle.json @@ -21,8 +21,7 @@ ], "features": [ "access_token_feature_coverage = false", - "access_token_camera_float_window_enable", - "access_token_different_feature" + "access_token_camera_float_window_enable" ], "adapted_system_type": [ "standard" ], "rom": "10000KB", diff --git a/frameworks/privacy/include/privacy_audio_service_ipc_interface_code.h b/frameworks/privacy/include/privacy_audio_service_ipc_interface_code.h index 277c3d5a6..2cbd6fff2 100644 --- a/frameworks/privacy/include/privacy_audio_service_ipc_interface_code.h +++ b/frameworks/privacy/include/privacy_audio_service_ipc_interface_code.h @@ -21,11 +21,11 @@ namespace Security { namespace AccessToken { enum PrivacyAudioPolicyInterfaceCode { #ifdef FEATURE_DTMF_TONE - SET_MICROPHONE_MUTE_PERSISTENT = 119, - GET_MICROPHONE_MUTE_PERSISTENT = 120, + SET_MICROPHONE_MUTE_PERSISTENT = 120, + GET_MICROPHONE_MUTE_PERSISTENT = 121, #else - SET_MICROPHONE_MUTE_PERSISTENT = 117, - GET_MICROPHONE_MUTE_PERSISTENT = 118, + SET_MICROPHONE_MUTE_PERSISTENT = 118, + GET_MICROPHONE_MUTE_PERSISTENT = 119, #endif }; } // namespace AccessToken diff --git a/frameworks/privacy/include/privacy_camera_service_ipc_interface_code.h b/frameworks/privacy/include/privacy_camera_service_ipc_interface_code.h index 254e81b32..2713fe0ea 100644 --- a/frameworks/privacy/include/privacy_camera_service_ipc_interface_code.h +++ b/frameworks/privacy/include/privacy_camera_service_ipc_interface_code.h @@ -20,8 +20,8 @@ namespace OHOS { namespace Security { namespace AccessToken { enum PrivacyCameraServiceInterfaceCode { - CAMERA_SERVICE_IS_CAMERA_MUTED = 13, - CAMERA_SERVICE_MUTE_CAMERA_PERSIST = 22, + CAMERA_SERVICE_IS_CAMERA_MUTED = 14, + CAMERA_SERVICE_MUTE_CAMERA_PERSIST = 23, }; } // namespace AccessToken } // namespace Security diff --git a/services/privacymanager/BUILD.gn b/services/privacymanager/BUILD.gn index 354faf693..5317e8fb0 100644 --- a/services/privacymanager/BUILD.gn +++ b/services/privacymanager/BUILD.gn @@ -150,5 +150,9 @@ if (is_standard_system && ability_base_enable == true) { include_dirs += [ "${access_token_path}/services/common/window_manager/include" ] } + + if (access_token_app_security_privacy_service_enable) { + cflags_cc += [ "-DAPP_SECURITY_PRIVACY_SERVICE" ] + } } } diff --git a/services/privacymanager/src/record/permission_record_manager.cpp b/services/privacymanager/src/record/permission_record_manager.cpp index 5532c6f14..7b03912b4 100644 --- a/services/privacymanager/src/record/permission_record_manager.cpp +++ b/services/privacymanager/src/record/permission_record_manager.cpp @@ -714,7 +714,7 @@ bool PermissionRecordManager::GetGlobalSwitchStatus(const std::string& permissio } return isOpen; } -#ifdef DIFFERENT_FEATURE +#ifndef APP_SECURITY_PRIVACY_SERVICE /* * StartUsing when close and choose open, update status to foreground or background from inactive * StartUsing when open and choose close, update status to inactive and store in database @@ -837,7 +837,7 @@ int32_t PermissionRecordManager::StartUsingPermission(AccessTokenID tokenId, con if (AddRecordToStartList(record)) { return PrivacyError::ERR_PERMISSION_ALREADY_START_USING; } - +#ifndef APP_SECURITY_PRIVACY_SERVICE if (!GetGlobalSwitchStatus(permissionName)) { if (!ShowGlobalDialog(permissionName)) { ACCESSTOKEN_LOG_ERROR(LABEL, "Show permission dialog failed."); @@ -845,12 +845,10 @@ int32_t PermissionRecordManager::StartUsingPermission(AccessTokenID tokenId, con UnRegisterWindowCallback(); return ERR_SERVICE_ABNORMAL; } -#ifdef DIFFERENT_FEATURE } else { CallbackExecute(tokenId, permissionName, record.status); } #else - } CallbackExecute(tokenId, permissionName, record.status); #endif return Constant::SUCCESS; @@ -892,6 +890,7 @@ int32_t PermissionRecordManager::StartUsingPermission(AccessTokenID tokenId, con cameraCallbackMap_.Erase(tokenId); return PrivacyError::ERR_WINDOW_CALLBACK_FAILED; } +#ifndef APP_SECURITY_PRIVACY_SERVICE if (!GetGlobalSwitchStatus(permissionName)) { if (!ShowGlobalDialog(permissionName)) { ACCESSTOKEN_LOG_ERROR(LABEL, "Show permission dialog failed."); @@ -900,12 +899,10 @@ int32_t PermissionRecordManager::StartUsingPermission(AccessTokenID tokenId, con cameraCallbackMap_.Erase(tokenId); return ERR_SERVICE_ABNORMAL; } -#ifdef DIFFERENT_FEATURE } else { CallbackExecute(tokenId, permissionName, record.status); } #else - } CallbackExecute(tokenId, permissionName, record.status); #endif return Constant::SUCCESS; @@ -1075,7 +1072,7 @@ int32_t PermissionRecordManager::SetEdmMutePolicy(const std::string permissionNa if (isMute) { ModifyMuteStatus(permissionName, EDM, isMute); ModifyMuteStatus(permissionName, MIXED, isMute); -#ifdef DIFFERENT_FEATURE +#ifndef APP_SECURITY_PRIVACY_SERVICE ExecuteAndUpdateRecordByPerm(permissionName, false); #endif } else { @@ -1098,7 +1095,7 @@ int32_t PermissionRecordManager::SetPrivacyMutePolicy(const std::string permissi } ModifyMuteStatus(permissionName, MIXED, isMute); } -#ifdef DIFFERENT_FEATURE +#ifndef APP_SECURITY_PRIVACY_SERVICE ExecuteAndUpdateRecordByPerm(permissionName, !isMute); #endif return RET_SUCCESS; diff --git a/services/privacymanager/src/service/privacy_manager_service.cpp b/services/privacymanager/src/service/privacy_manager_service.cpp index 7e181bd1e..4d2fdfc80 100644 --- a/services/privacymanager/src/service/privacy_manager_service.cpp +++ b/services/privacymanager/src/service/privacy_manager_service.cpp @@ -67,6 +67,7 @@ void PrivacyManagerService::OnStart() ACCESSTOKEN_LOG_INFO(LABEL, "PrivacyManagerService has already started!"); return; } + ACCESSTOKEN_LOG_INFO(LABEL, "PrivacyManagerService is starting"); if (!Initialize()) { ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to initialize"); return; diff --git a/services/privacymanager/test/unittest/BUILD.gn b/services/privacymanager/test/unittest/BUILD.gn index 1b1b5d3ed..dd9e614a0 100644 --- a/services/privacymanager/test/unittest/BUILD.gn +++ b/services/privacymanager/test/unittest/BUILD.gn @@ -130,11 +130,6 @@ if (is_standard_system && ability_base_enable == true) { ] } - if (camera_framework_enable) { - cflags_cc += [ "-DCAMERA_FRAMEWORK_ENABLE" ] - external_deps += [ "camera_framework:camera_framework" ] - } - if (ability_runtime_enable) { cflags_cc += [ "-DABILITY_RUNTIME_ENABLE" ] external_deps += [ @@ -148,5 +143,9 @@ if (is_standard_system && ability_base_enable == true) { include_dirs += [ "${access_token_path}/services/common/window_manager/include" ] } + + if (access_token_app_security_privacy_service_enable) { + cflags_cc += [ "-DAPP_SECURITY_PRIVACY_SERVICE" ] + } } } diff --git a/services/privacymanager/test/unittest/permission_record_manager_test.cpp b/services/privacymanager/test/unittest/permission_record_manager_test.cpp index c7764c169..0bc5f8468 100644 --- a/services/privacymanager/test/unittest/permission_record_manager_test.cpp +++ b/services/privacymanager/test/unittest/permission_record_manager_test.cpp @@ -365,7 +365,11 @@ HWTEST_F(PermissionRecordManagerTest, StartUsingPermissionTest004, TestSize.Leve ASSERT_EQ(RET_SUCCESS, PermissionRecordManager::GetInstance().StartUsingPermission(tokenId, permissionName)); usleep(500000); // 500000us = 0.5s +#ifndef APP_SECURITY_PRIVACY_SERVICE ASSERT_EQ(PERM_INACTIVE, callback->type_); +#else + ASSERT_EQ(PERM_ACTIVE_IN_BACKGROUND, callback->type_); +#endif ASSERT_EQ(Constant::SUCCESS, PermissionRecordManager::GetInstance().StopUsingPermission(tokenId, permissionName)); PermissionRecordManager::GetInstance().isMicLoad_ = isMicLoad; } diff --git a/services/privacymanager/test/unittest/sensitive_manager_test.cpp b/services/privacymanager/test/unittest/sensitive_manager_test.cpp index 79df20076..3eedfe002 100644 --- a/services/privacymanager/test/unittest/sensitive_manager_test.cpp +++ b/services/privacymanager/test/unittest/sensitive_manager_test.cpp @@ -33,9 +33,6 @@ #endif #include "camera_manager_privacy_client.h" #include "camera_manager_privacy_proxy.h" -#ifdef CAMERA_FRAMEWORK_ENABLE -#include "camera_service_ipc_interface_code.h" -#endif #include "token_setproc.h" using namespace testing::ext;