From 34ffcbe1d235d177e92b2b39af2f345eb4f953c5 Mon Sep 17 00:00:00 2001 From: chen0088 Date: Wed, 29 Nov 2023 09:37:13 +0800 Subject: [PATCH] modify page Signed-off-by: chen0088 --- .../dcamera_sink_controller.h | 1 + .../dcamera_sink_controller.cpp | 59 +++++++++++-------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/services/cameraservice/sinkservice/include/distributedcameramgr/dcamera_sink_controller.h b/services/cameraservice/sinkservice/include/distributedcameramgr/dcamera_sink_controller.h index beee7451..e965970d 100644 --- a/services/cameraservice/sinkservice/include/distributedcameramgr/dcamera_sink_controller.h +++ b/services/cameraservice/sinkservice/include/distributedcameramgr/dcamera_sink_controller.h @@ -75,6 +75,7 @@ private: bool CheckDeviceSecurityLevel(const std::string &srcDeviceId, const std::string &dstDeviceId); int32_t GetDeviceSecurityLevel(const std::string &udid); std::string GetUdidByNetworkId(const std::string &networkId); + int32_t PullUpPage(); bool isInit_; int32_t sessionState_; diff --git a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp index a97b7cec..ec7d46ea 100644 --- a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp +++ b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp @@ -44,6 +44,7 @@ namespace OHOS { namespace DistributedHardware { const int DEFAULT_DEVICE_SECURITY_LEVEL = -1; +const std::string PAGE_SUBTYPE = "camera"; DCameraSinkController::DCameraSinkController(std::shared_ptr& accessControl, const sptr &sinkCallback) @@ -99,17 +100,6 @@ int32_t DCameraSinkController::StopCapture() DCameraNotifyInner(DCAMERA_MESSAGE, DCAMERA_EVENT_DEVICE_ERROR, std::string("output stop capture failed")); return ret; } - if (isPageStatus_.load()) { - std::string subtype = "camera"; - bool isSensitive = false; - bool isSameAccout = false; - ret = sinkCallback_->OnNotifyResourceInfo(ResourceEventType::EVENT_TYPE_CLOSE_PAGE, subtype, srcDevId_, - isSensitive, isSameAccout); - if (ret != DCAMERA_OK) { - DHLOGE("close page failed, ret: %d", ret); - } - } - isPageStatus_.store(false); DHLOGI("StopCapture %s success", GetAnonyString(dhId_).c_str()); return DCAMERA_OK; } @@ -202,9 +192,8 @@ int32_t DCameraSinkController::OpenChannel(std::shared_ptr& ope return DCAMERA_WRONG_STATE; } srcDevId_ = openInfo->sourceDevId_; - std::string subtype = "camera"; - int32_t ret = sinkCallback_->OnNotifyResourceInfo(ResourceEventType::EVENT_TYPE_QUERY_RESOURCE, subtype, srcDevId_, - isSensitive_, isSameAccount_); + int32_t ret = sinkCallback_->OnNotifyResourceInfo(ResourceEventType::EVENT_TYPE_QUERY_RESOURCE, PAGE_SUBTYPE, + srcDevId_, isSensitive_, isSameAccount_); if (ret != DCAMERA_OK) { DHLOGE("Query resource failed, ret: %d", ret); return ret; @@ -236,10 +225,30 @@ int32_t DCameraSinkController::OpenChannel(std::shared_ptr& ope DHLOGE("channel create session failed, dhId: %s, ret: %d", GetAnonyString(dhId_).c_str(), ret); return ret; } + ret = PullUpPage(); + if (ret != DCAMERA_OK) { + return ret; + } DHLOGI("OpenChannel %s success", GetAnonyString(dhId_).c_str()); return DCAMERA_OK; } +int32_t DCameraSinkController::PullUpPage() +{ + if (isSensitive_) { + bool isSensitive = false; + bool isSameAccout = false; + int32_t ret = sinkCallback_->OnNotifyResourceInfo(ResourceEventType::EVENT_TYPE_PULL_UP_PAGE, PAGE_SUBTYPE, + srcDevId_, isSensitive, isSameAccout); + if (ret != DCAMERA_OK) { + DHLOGE("pull up page failed, ret %d", ret); + return ret; + } + isPageStatus_.store(true); + } + return DCAMERA_OK; +} + int32_t DCameraSinkController::CloseChannel() { DHLOGI("CloseChannel dhId: %s", GetAnonyString(dhId_).c_str()); @@ -259,6 +268,16 @@ int32_t DCameraSinkController::CloseChannel() GetAnonyString(dhId_).c_str(), ret); } sessionState_ = DCAMERA_CHANNEL_STATE_DISCONNECTED; + if (isPageStatus_.load()) { + bool isSensitive = false; + bool isSameAccout = false; + ret = sinkCallback_->OnNotifyResourceInfo(ResourceEventType::EVENT_TYPE_CLOSE_PAGE, PAGE_SUBTYPE, srcDevId_, + isSensitive, isSameAccout); + if (ret != DCAMERA_OK) { + DHLOGE("close page failed, ret: %d", ret); + } + } + isPageStatus_.store(false); DHLOGI("CloseChannel %s success", GetAnonyString(dhId_).c_str()); return DCAMERA_OK; } @@ -481,18 +500,6 @@ int32_t DCameraSinkController::StartCaptureInner(std::vectorOnNotifyResourceInfo(ResourceEventType::EVENT_TYPE_PULL_UP_PAGE, subtype, srcDevId_, - isSensitive, isSameAccout); - if (ret != DCAMERA_OK) { - DHLOGE("pull up page failed, ret %d", ret); - return ret; - } - isPageStatus_.store(true); - } DHLOGI("DCameraSinkController::StartCaptureInner %s success", GetAnonyString(dhId_).c_str()); return DCAMERA_OK; } -- Gitee