diff --git a/services/cameraservice/sinkservice/include/distributedcameramgr/dcamera_sink_controller.h b/services/cameraservice/sinkservice/include/distributedcameramgr/dcamera_sink_controller.h index 7e9b449193ceb27f26db8ae031c060cad104ec65..ea61983adf51183d97246a85f3837be108af1e70 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 CheckPermission(); bool isInit_; diff --git a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp index 184995989d9b7fa95f1ddbb8628b9f8e2c80500f..7ef3332bee8b75a48dad92be85af44eaea9f613d 100644 --- a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp +++ b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp @@ -45,6 +45,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) @@ -100,17 +101,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; } @@ -211,9 +201,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; @@ -245,10 +234,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()); @@ -268,6 +277,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; } @@ -490,18 +509,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; }