From f7311301f6d7b9f392cdcd4d502f0fcedf2b212e Mon Sep 17 00:00:00 2001 From: yuanjinghua Date: Sun, 24 Mar 2024 22:02:53 +0800 Subject: [PATCH] New Feature. bugfix for TDD check state failure Signed-off-by: yuanjinghua Change-Id: If14c8dbcf9e67c1d296aed688f6631fde8a672e3 --- .../server/screen_capture_server.cpp | 37 ++++++++++++------- .../server/screen_capture_server.h | 1 + 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/services/services/screen_capture/server/screen_capture_server.cpp b/services/services/screen_capture/server/screen_capture_server.cpp index 5a8421aca..62b36f4df 100644 --- a/services/services/screen_capture/server/screen_capture_server.cpp +++ b/services/services/screen_capture/server/screen_capture_server.cpp @@ -344,6 +344,15 @@ bool ScreenCaptureServer::CheckScreenCapturePermission() } } +bool ScreenCaptureServer::IsUserPrivacyAuthorityNeeded() +{ + if (appInfo_.appUid == ROOT_UID) { + MEDIA_LOGI("Root user. Privacy Authority Granted automaticly"); + return false; + } + return true; +} + int32_t ScreenCaptureServer::CheckCaptureMode(CaptureMode captureMode) { MEDIA_LOGD("CheckCaptureMode start, captureMode:%{public}d", captureMode); @@ -605,9 +614,8 @@ void ScreenCaptureServer::InitAppInfo() int32_t ScreenCaptureServer::RequestUserPrivacyAuthority() { // If Root is treated as whitelisted, how to guarantee RequestUserPrivacyAuthority function by TDD cases. - // Root users should be whitelisted - if (appInfo_.appUid == ROOT_UID) { - MEDIA_LOGI("Root user. Permission Granted"); + if (!IsUserPrivacyAuthorityNeeded()) { + MEDIA_LOGI("Privacy Authority Granted. uid:%{public}d", appInfo_.appUid); return MSERR_OK; } @@ -863,9 +871,8 @@ int32_t ScreenCaptureServer::InitRecorder() bool ScreenCaptureServer::UpdatePrivacyUsingPermissionState(VideoPermissionState state) { - // Root users should be whitelisted - if (appInfo_.appUid == ROOT_UID) { - MEDIA_LOGI("Root user. Privacy Granted. state: %{public}d", state); + if (!IsUserPrivacyAuthorityNeeded()) { + MEDIA_LOGI("Using Permission Ignored. state: %{public}d, uid: %{public}d", state, appInfo_.appUid); return true; } @@ -899,13 +906,18 @@ int32_t ScreenCaptureServer::StartScreenCaptureInner(bool isPrivacyAuthorityEnab return ret; } + if (IsUserPrivacyAuthorityNeeded()) { #ifdef SUPPORT_SCREEN_CAPTURE_WINDOW_NOTIFICATION - if (isPrivacyAuthorityEnabled_) { - // Wait for user interactions to ALLOW/DENY capture - return MSERR_OK; - } + if (isPrivacyAuthorityEnabled_) { + // Wait for user interactions to ALLOW/DENY capture + MEDIA_LOGI("Wait for user interactions to ALLOW/DENY capture"); + return MSERR_OK; + } #endif - MEDIA_LOGI("privacy notification window not support, app has CAPTURE_SCREEN permission and go on"); + MEDIA_LOGI("privacy notification window not support, app has CAPTURE_SCREEN permission and go on"); + } else { + MEDIA_LOGI("Privacy Authority granted automaticly and go on"); + } ret = OnStartScreenCapture(); PostStartScreenCapture(ret == MSERR_OK); @@ -1051,7 +1063,7 @@ void ScreenCaptureServer::UpdateMicrophoneEnabled() int32_t result = NotificationHelper::PublishNotification(request); MEDIA_LOGI("Screencapture service UpdateMicrophoneEnabled uid %{public}d, result %{public}d", uid, result); - micCount_.store(micCount_.load()+1); + micCount_.store(micCount_.load() + 1); } void ScreenCaptureServer::UpdateLiveViewContent() @@ -1162,7 +1174,6 @@ int32_t ScreenCaptureServer::StartHomeVideoCapture() consumer_->RegisterConsumerListener(surfaceCb_); int32_t ret = CreateVirtualScreen(virtualScreenName, producerSurface); CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, ret, "create virtual screen without input surface failed"); - CANCEL_SCOPE_EXIT_GUARD(0); return MSERR_OK; } diff --git a/services/services/screen_capture/server/screen_capture_server.h b/services/services/screen_capture/server/screen_capture_server.h index 6f4ef8580..8f5dafba1 100644 --- a/services/services/screen_capture/server/screen_capture_server.h +++ b/services/services/screen_capture/server/screen_capture_server.h @@ -192,6 +192,7 @@ private: void DestroyVirtualScreen(); bool CheckScreenCapturePermission(); + bool IsUserPrivacyAuthorityNeeded(); bool UpdatePrivacyUsingPermissionState(VideoPermissionState state); int32_t RequestUserPrivacyAuthority(); int32_t StartPrivacyWindow(); -- Gitee