diff --git a/rosen/modules/render_service/core/pipeline/main_thread/rs_render_service_connection.cpp b/rosen/modules/render_service/core/pipeline/main_thread/rs_client_to_render_connection.cpp similarity index 63% rename from rosen/modules/render_service/core/pipeline/main_thread/rs_render_service_connection.cpp rename to rosen/modules/render_service/core/pipeline/main_thread/rs_client_to_render_connection.cpp index 52a89ed993ed65e65f23229f5906aa84b8d693a2..d65436cd64e51e2208f06ab75e3226029a5fd09c 100644 --- a/rosen/modules/render_service/core/pipeline/main_thread/rs_render_service_connection.cpp +++ b/rosen/modules/render_service/core/pipeline/main_thread/rs_client_to_render_connection.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "rs_render_service_connection.h" +#include "rs_client_to_render_connection.h" #include #include "frame_report.h" @@ -80,6 +80,7 @@ #include "render/rs_typeface_cache.h" #include "transaction/rs_unmarshal_thread.h" #include "transaction/rs_transaction_data_callback_manager.h" +#include "graphic_feature_param_manager.h" #ifdef TP_FEATURE_ENABLE #include "screen_manager/touch_screen.h" @@ -89,8 +90,12 @@ #include "platform/ohos/backend/rs_vulkan_context.h" #endif +#if defined(RS_ENABLE_DVSYNC) +#include "dvsync.h" +#endif + #undef LOG_TAG -#define LOG_TAG "RSRenderServiceConnection" +#define LOG_TAG "RSClientToRenderConnection" namespace OHOS { namespace Rosen { @@ -102,7 +107,7 @@ constexpr uint32_t MEM_BYTE_TO_MB = 1024 * 1024; } // we guarantee that when constructing this object, // all these pointers are valid, so will not check them. -RSRenderServiceConnection::RSRenderServiceConnection( +RSClientToRenderConnection::RSClientToRenderConnection( pid_t remotePid, wptr renderService, RSMainThread* mainThread, @@ -122,23 +127,23 @@ RSRenderServiceConnection::RSRenderServiceConnection( appVSyncDistributor_(distributor) { if (token_ == nullptr || !token_->AddDeathRecipient(connDeathRecipient_)) { - RS_LOGW("RSRenderServiceConnection: Failed to set death recipient."); + RS_LOGW("RSClientToRenderConnection: Failed to set death recipient."); } if (renderService_ == nullptr) { - RS_LOGW("RSRenderServiceConnection: renderService_ is nullptr"); + RS_LOGW("RSClientToRenderConnection: renderService_ is nullptr"); } if (mainThread_ == nullptr) { - RS_LOGW("RSRenderServiceConnection: mainThread_ is nullptr"); + RS_LOGW("RSClientToRenderConnection: mainThread_ is nullptr"); } if (screenManager_ == nullptr) { - RS_LOGW("RSRenderServiceConnection: screenManager_ is nullptr"); + RS_LOGW("RSClientToRenderConnection: screenManager_ is nullptr"); } if (appVSyncDistributor_ == nullptr) { - RS_LOGW("RSRenderServiceConnection: appVSyncDistributor_ is nullptr"); + RS_LOGW("RSClientToRenderConnection: appVSyncDistributor_ is nullptr"); } } -RSRenderServiceConnection::~RSRenderServiceConnection() noexcept +RSClientToRenderConnection::~RSClientToRenderConnection() noexcept { if (token_ && connDeathRecipient_) { token_->RemoveDeathRecipient(connDeathRecipient_); @@ -146,7 +151,7 @@ RSRenderServiceConnection::~RSRenderServiceConnection() noexcept CleanAll(); } -void RSRenderServiceConnection::CleanVirtualScreens() noexcept +void RSClientToRenderConnection::CleanVirtualScreens() noexcept { std::lock_guard lock(mutex_); @@ -163,7 +168,7 @@ void RSRenderServiceConnection::CleanVirtualScreens() noexcept } } -void RSRenderServiceConnection::CleanRenderNodes() noexcept +void RSClientToRenderConnection::CleanRenderNodes() noexcept { if (mainThread_ == nullptr) { return; @@ -174,7 +179,7 @@ void RSRenderServiceConnection::CleanRenderNodes() noexcept nodeMap.FilterNodeByPid(remotePid_); } -void RSRenderServiceConnection::CleanFrameRateLinkers() noexcept +void RSClientToRenderConnection::CleanFrameRateLinkers() noexcept { if (mainThread_ == nullptr) { return; @@ -185,7 +190,7 @@ void RSRenderServiceConnection::CleanFrameRateLinkers() noexcept frameRateLinkerMap.FilterFrameRateLinkerByPid(remotePid_); } -void RSRenderServiceConnection::CleanFrameRateLinkerExpectedFpsCallbacks() noexcept +void RSClientToRenderConnection::CleanFrameRateLinkerExpectedFpsCallbacks() noexcept { if (mainThread_ == nullptr) { return; @@ -195,7 +200,7 @@ void RSRenderServiceConnection::CleanFrameRateLinkerExpectedFpsCallbacks() noexc frameRateLinkerMap.UnRegisterExpectedFpsUpdateCallbackByListener(remotePid_); } -void RSRenderServiceConnection::CleanAll(bool toDelete) noexcept +void RSClientToRenderConnection::CleanAll(bool toDelete) noexcept { { std::lock_guard lock(mutex_); @@ -207,11 +212,11 @@ void RSRenderServiceConnection::CleanAll(bool toDelete) noexcept return; } RS_LOGD("CleanAll() start."); - RS_TRACE_NAME("RSRenderServiceConnection CleanAll begin, remotePid: " + std::to_string(remotePid_)); + RS_TRACE_NAME("RSClientToRenderConnection CleanAll begin, remotePid: " + std::to_string(remotePid_)); RsCommandVerifyHelper::GetInstance().RemoveCntWithPid(remotePid_); mainThread_->ScheduleTask( - [weakThis = wptr(this)]() { - sptr connection = weakThis.promote(); + [weakThis = wptr(this)]() { + sptr connection = weakThis.promote(); if (!connection) { return; } @@ -219,8 +224,8 @@ void RSRenderServiceConnection::CleanAll(bool toDelete) noexcept connection->CleanVirtualScreens(); }).wait(); mainThread_->ScheduleTask( - [weakThis = wptr(this)]() { - sptr connection = weakThis.promote(); + [weakThis = wptr(this)]() { + sptr connection = weakThis.promote(); if (!connection) { return; } @@ -230,8 +235,8 @@ void RSRenderServiceConnection::CleanAll(bool toDelete) noexcept connection->CleanFrameRateLinkerExpectedFpsCallbacks(); }).wait(); mainThread_->ScheduleTask( - [weakThis = wptr(this)]() { - sptr connection = weakThis.promote(); + [weakThis = wptr(this)]() { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -239,8 +244,8 @@ void RSRenderServiceConnection::CleanAll(bool toDelete) noexcept connection->mainThread_->ClearTransactionDataPidInfo(connection->remotePid_); }).wait(); mainThread_->ScheduleTask( - [weakThis = wptr(this)]() { - sptr connection = weakThis.promote(); + [weakThis = wptr(this)]() { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -251,8 +256,8 @@ void RSRenderServiceConnection::CleanAll(bool toDelete) noexcept }).wait(); if (SelfDrawingNodeMonitor::GetInstance().IsListeningEnabled()) { mainThread_->ScheduleTask( - [weakThis = wptr(this)]() { - sptr connection = weakThis.promote(); + [weakThis = wptr(this)]() { + sptr connection = weakThis.promote(); if (connection == nullptr) { return; } @@ -285,15 +290,15 @@ void RSRenderServiceConnection::CleanAll(bool toDelete) noexcept } RS_LOGD("CleanAll() end."); - RS_TRACE_NAME("RSRenderServiceConnection CleanAll end, remotePid: " + std::to_string(remotePid_)); + RS_TRACE_NAME("RSClientToRenderConnection CleanAll end, remotePid: " + std::to_string(remotePid_)); } -RSRenderServiceConnection::RSConnectionDeathRecipient::RSConnectionDeathRecipient( - wptr conn) : conn_(conn) +RSClientToRenderConnection::RSConnectionDeathRecipient::RSConnectionDeathRecipient( + wptr conn) : conn_(conn) { } -void RSRenderServiceConnection::RSConnectionDeathRecipient::OnRemoteDied(const wptr& token) +void RSClientToRenderConnection::RSConnectionDeathRecipient::OnRemoteDied(const wptr& token) { auto tokenSptr = token.promote(); if (tokenSptr == nullptr) { @@ -303,7 +308,7 @@ void RSRenderServiceConnection::RSConnectionDeathRecipient::OnRemoteDied(const w auto rsConn = conn_.promote(); if (rsConn == nullptr) { - RS_LOGW("RSConnectionDeathRecipient::OnRemoteDied: RSRenderServiceConnection was dead, do nothing."); + RS_LOGW("RSConnectionDeathRecipient::OnRemoteDied: RSClientToRenderConnection was dead, do nothing."); return; } @@ -315,11 +320,11 @@ void RSRenderServiceConnection::RSConnectionDeathRecipient::OnRemoteDied(const w rsConn->CleanAll(true); } -RSRenderServiceConnection::RSApplicationRenderThreadDeathRecipient::RSApplicationRenderThreadDeathRecipient( - wptr conn) : conn_(conn) +RSClientToRenderConnection::RSApplicationRenderThreadDeathRecipient::RSApplicationRenderThreadDeathRecipient( + wptr conn) : conn_(conn) {} -void RSRenderServiceConnection::RSApplicationRenderThreadDeathRecipient::OnRemoteDied(const wptr& token) +void RSClientToRenderConnection::RSApplicationRenderThreadDeathRecipient::OnRemoteDied(const wptr& token) { auto tokenSptr = token.promote(); if (tokenSptr == nullptr) { @@ -330,7 +335,7 @@ void RSRenderServiceConnection::RSApplicationRenderThreadDeathRecipient::OnRemot auto rsConn = conn_.promote(); if (rsConn == nullptr) { RS_LOGW("RSApplicationRenderThreadDeathRecipient::OnRemoteDied: " - "RSRenderServiceConnection was dead, do nothing."); + "RSClientToRenderConnection was dead, do nothing."); return; } @@ -339,7 +344,7 @@ void RSRenderServiceConnection::RSApplicationRenderThreadDeathRecipient::OnRemot rsConn->UnRegisterApplicationAgent(app); } -ErrCode RSRenderServiceConnection::CommitTransaction(std::unique_ptr& transactionData) +ErrCode RSClientToRenderConnection::CommitTransaction(std::unique_ptr& transactionData) { if (!mainThread_) { return ERR_INVALID_VALUE; @@ -366,7 +371,7 @@ ErrCode RSRenderServiceConnection::CommitTransaction(std::unique_ptr& task) +ErrCode RSClientToRenderConnection::ExecuteSynchronousTask(const std::shared_ptr& task) { if (task == nullptr || mainThread_ == nullptr) { RS_LOGW("ExecuteSynchronousTask, task or main thread is null!"); @@ -386,13 +391,13 @@ ErrCode RSRenderServiceConnection::ExecuteSynchronousTask(const std::shared_ptr< return ERR_OK; } -ErrCode RSRenderServiceConnection::GetUniRenderEnabled(bool& enable) +ErrCode RSClientToRenderConnection::GetUniRenderEnabled(bool& enable) { enable = RSUniRenderJudgement::IsUniRender(); return ERR_OK; } -ErrCode RSRenderServiceConnection::CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId, +ErrCode RSClientToRenderConnection::CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId, bool& success) { if (!mainThread_) { @@ -426,7 +431,7 @@ ErrCode RSRenderServiceConnection::CreateNode(const RSDisplayNodeConfig& display return ERR_OK; } -ErrCode RSRenderServiceConnection::CreateNode(const RSSurfaceRenderNodeConfig& config, bool& success) +ErrCode RSClientToRenderConnection::CreateNode(const RSSurfaceRenderNodeConfig& config, bool& success) { if (!mainThread_) { success = false; @@ -439,8 +444,8 @@ ErrCode RSRenderServiceConnection::CreateNode(const RSSurfaceRenderNodeConfig& c success = false; return ERR_INVALID_VALUE; } - std::function registerNode = [node, weakThis = wptr(this)]() -> void { - sptr connection = weakThis.promote(); + std::function registerNode = [node, weakThis = wptr(this)]() -> void { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -451,7 +456,7 @@ ErrCode RSRenderServiceConnection::CreateNode(const RSSurfaceRenderNodeConfig& c return ERR_OK; } -ErrCode RSRenderServiceConnection::CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, +ErrCode RSClientToRenderConnection::CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, sptr& sfc, bool unobscured) { if (!mainThread_) { @@ -509,61 +514,7 @@ ErrCode RSRenderServiceConnection::CreateNodeAndSurface(const RSSurfaceRenderNod return ERR_OK; } -ErrCode RSRenderServiceConnection::CreateVSyncConnection(sptr& vsyncConn, - const std::string& name, - const sptr& token, - VSyncConnParam vsyncConnParam) -{ - if (mainThread_ == nullptr || appVSyncDistributor_ == nullptr) { - vsyncConn = nullptr; - return ERR_INVALID_VALUE; - } - uint64_t id = vsyncConnParam.id; - NodeId windowNodeId = vsyncConnParam.windowNodeId; - if (vsyncConnParam.fromXcomponent) { - mainThread_->ScheduleTask([&windowNodeId]() { - auto& node = RSMainThread::Instance()->GetContext().GetNodeMap() - .GetRenderNode(windowNodeId); - if (node == nullptr) { - RS_LOGE("CreateVSyncConnection:node is nullptr"); - return; - } - windowNodeId = node->GetInstanceRootNodeId(); - }).wait(); - } - sptr conn = new VSyncConnection(appVSyncDistributor_, name, token->AsObject(), 0, windowNodeId); - if (ExtractPid(id) == remotePid_) { - auto observer = [] (const RSRenderFrameRateLinker& linker) { - if (auto mainThread = RSMainThread::Instance(); mainThread != nullptr) { - HgmCore::Instance().SetHgmTaskFlag(true); - } - }; - mainThread_->ScheduleTask([weakThis = wptr(this), - id, observer, name, windowNodeId]() { - sptr connection = weakThis.promote(); - if (connection == nullptr || connection->mainThread_ == nullptr) { - return; - } - auto linker = std::make_shared(id, observer); - linker->SetVsyncName(name); - linker->SetWindowNodeId(windowNodeId); - auto& context = connection->mainThread_->GetContext(); - auto& frameRateLinkerMap = context.GetMutableFrameRateLinkerMap(); - frameRateLinkerMap.RegisterFrameRateLinker(linker); - }).wait(); - conn->id_ = id; - RS_LOGD("CreateVSyncConnection connect id: %{public}" PRIu64, id); - } - auto ret = appVSyncDistributor_->AddConnection(conn, windowNodeId); - if (ret != VSYNC_ERROR_OK) { - vsyncConn = nullptr; - return ERR_INVALID_VALUE; - } - vsyncConn = conn; - return ERR_OK; -} - -ErrCode RSRenderServiceConnection::GetPixelMapByProcessId( +ErrCode RSClientToRenderConnection::GetPixelMapByProcessId( std::vector& pixelMapInfoVector, pid_t pid, int32_t& repCode) { if (mainThread_ == nullptr) { @@ -571,13 +522,13 @@ ErrCode RSRenderServiceConnection::GetPixelMapByProcessId( return ERR_INVALID_VALUE; } std::vector, std::string, RectI>> sfBufferInfoVector; - std::function getSurfaceBufferByPidTask = [weakThis = wptr(this), + std::function getSurfaceBufferByPidTask = [weakThis = wptr(this), &sfBufferInfoVector, pid]() -> void { - sptr connection = weakThis.promote(); + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } - RS_TRACE_NAME_FMT("RSRenderServiceConnection::GetPixelMapByProcessId getSurfaceBufferByPidTask pid: %d", pid); + RS_TRACE_NAME_FMT("RSClientToRenderConnection::GetPixelMapByProcessId getSurfaceBufferByPidTask pid: %d", pid); auto selfDrawingNodeVector = connection->mainThread_->GetContext().GetMutableNodeMap().GetSelfDrawingNodeInProcess(pid); for (auto iter = selfDrawingNodeVector.rbegin(); iter != selfDrawingNodeVector.rend(); ++iter) { @@ -614,7 +565,7 @@ ErrCode RSRenderServiceConnection::GetPixelMapByProcessId( return ERR_OK; } -ErrCode RSRenderServiceConnection::CreatePixelMapFromSurface(sptr surface, +ErrCode RSClientToRenderConnection::CreatePixelMapFromSurface(sptr surface, const Rect &srcRect, std::shared_ptr &pixelMap) { OHOS::Media::Rect rect = { @@ -629,7 +580,7 @@ ErrCode RSRenderServiceConnection::CreatePixelMapFromSurface(sptr surfa return ERR_OK; } -ErrCode RSRenderServiceConnection::SetFocusAppInfo(const FocusAppInfo& info, int32_t& repCode) +ErrCode RSClientToRenderConnection::SetFocusAppInfo(const FocusAppInfo& info, int32_t& repCode) { if (mainThread_ == nullptr) { repCode = INVALID_ARGUMENTS; @@ -645,7 +596,7 @@ ErrCode RSRenderServiceConnection::SetFocusAppInfo(const FocusAppInfo& info, int return ERR_OK; } -ErrCode RSRenderServiceConnection::SetWatermark(const std::string& name, std::shared_ptr watermark, +ErrCode RSClientToRenderConnection::SetWatermark(const std::string& name, std::shared_ptr watermark, bool& success) { if (!mainThread_) { @@ -657,62 +608,7 @@ ErrCode RSRenderServiceConnection::SetWatermark(const std::string& name, std::sh return ERR_OK; } -ErrCode RSRenderServiceConnection::GetDefaultScreenId(uint64_t& screenId) -{ - std::lock_guard lock(mutex_); - if (!screenManager_) { - screenId = INVALID_SCREEN_ID; - return ERR_INVALID_VALUE; - } - screenId = screenManager_->GetDefaultScreenId(); - return ERR_OK; -} - -ErrCode RSRenderServiceConnection::GetActiveScreenId(uint64_t& screenId) -{ - std::lock_guard lock(mutex_); - if (!screenManager_) { - screenId = INVALID_SCREEN_ID; - return ERR_INVALID_VALUE; - } - screenId = screenManager_->GetActiveScreenId(); - return ERR_OK; -} - -std::vector RSRenderServiceConnection::GetAllScreenIds() -{ - std::lock_guard lock(mutex_); - if (!screenManager_) { - return std::vector(); - } - return screenManager_->GetAllScreenIds(); -} - -ScreenId RSRenderServiceConnection::CreateVirtualScreen( - const std::string &name, - uint32_t width, - uint32_t height, - sptr surface, - ScreenId mirrorId, - int32_t flags, - std::vector whiteList) -{ - std::lock_guard lock(mutex_); - if (!screenManager_) { - return StatusCode::SCREEN_NOT_FOUND; - } - auto newVirtualScreenId = screenManager_->CreateVirtualScreen( - name, width, height, surface, mirrorId, flags, whiteList); - virtualScreenIds_.insert(newVirtualScreenId); - if (surface != nullptr) { - EventInfo event = { "VOTER_VIRTUALDISPLAY", ADD_VOTE, OLED_60_HZ, OLED_60_HZ, name }; - NotifyRefreshRateEvent(event); - ROSEN_LOGI("%{public}s vote 60hz", __func__); - } - return newVirtualScreenId; -} - -int32_t RSRenderServiceConnection::SetVirtualScreenBlackList(ScreenId id, std::vector& blackListVector) +int32_t RSClientToRenderConnection::SetVirtualScreenBlackList(ScreenId id, std::vector& blackListVector) { if (blackListVector.empty()) { RS_LOGW("SetVirtualScreenBlackList blackList is empty."); @@ -724,7 +620,7 @@ int32_t RSRenderServiceConnection::SetVirtualScreenBlackList(ScreenId id, std::v return screenManager_->SetVirtualScreenBlackList(id, blackListVector); } -ErrCode RSRenderServiceConnection::SetVirtualScreenTypeBlackList( +ErrCode RSClientToRenderConnection::SetVirtualScreenTypeBlackList( ScreenId id, std::vector& typeBlackListVector, int32_t& repCode) { if (typeBlackListVector.empty()) { @@ -739,7 +635,7 @@ ErrCode RSRenderServiceConnection::SetVirtualScreenTypeBlackList( return ERR_OK; } -ErrCode RSRenderServiceConnection::AddVirtualScreenBlackList( +ErrCode RSClientToRenderConnection::AddVirtualScreenBlackList( ScreenId id, std::vector& blackListVector, int32_t& repCode) { if (blackListVector.empty()) { @@ -756,7 +652,7 @@ ErrCode RSRenderServiceConnection::AddVirtualScreenBlackList( return ERR_OK; } -ErrCode RSRenderServiceConnection::RemoveVirtualScreenBlackList( +ErrCode RSClientToRenderConnection::RemoveVirtualScreenBlackList( ScreenId id, std::vector& blackListVector, int32_t& repCode) { if (blackListVector.empty()) { @@ -773,7 +669,7 @@ ErrCode RSRenderServiceConnection::RemoveVirtualScreenBlackList( return ERR_OK; } -int32_t RSRenderServiceConnection::SetVirtualScreenSecurityExemptionList( +int32_t RSClientToRenderConnection::SetVirtualScreenSecurityExemptionList( ScreenId id, const std::vector& securityExemptionList) { @@ -783,7 +679,7 @@ int32_t RSRenderServiceConnection::SetVirtualScreenSecurityExemptionList( return screenManager_->SetVirtualScreenSecurityExemptionList(id, securityExemptionList); } -int32_t RSRenderServiceConnection::SetScreenSecurityMask(ScreenId id, +int32_t RSClientToRenderConnection::SetScreenSecurityMask(ScreenId id, std::shared_ptr securityMask) { if (!screenManager_) { @@ -792,7 +688,7 @@ int32_t RSRenderServiceConnection::SetScreenSecurityMask(ScreenId id, return screenManager_->SetScreenSecurityMask(id, std::move(securityMask)); } -int32_t RSRenderServiceConnection::SetMirrorScreenVisibleRect(ScreenId id, const Rect& mainScreenRect, +int32_t RSClientToRenderConnection::SetMirrorScreenVisibleRect(ScreenId id, const Rect& mainScreenRect, bool supportRotation) { if (screenManager_ == nullptr) { @@ -801,7 +697,7 @@ int32_t RSRenderServiceConnection::SetMirrorScreenVisibleRect(ScreenId id, const return screenManager_->SetMirrorScreenVisibleRect(id, mainScreenRect, supportRotation); } -int32_t RSRenderServiceConnection::SetCastScreenEnableSkipWindow(ScreenId id, bool enable) +int32_t RSClientToRenderConnection::SetCastScreenEnableSkipWindow(ScreenId id, bool enable) { std::lock_guard lock(mutex_); if (!screenManager_) { @@ -810,7 +706,7 @@ int32_t RSRenderServiceConnection::SetCastScreenEnableSkipWindow(ScreenId id, bo return screenManager_->SetCastScreenEnableSkipWindow(id, enable); } -int32_t RSRenderServiceConnection::SetVirtualScreenSurface(ScreenId id, sptr surface) +int32_t RSClientToRenderConnection::SetVirtualScreenSurface(ScreenId id, sptr surface) { std::lock_guard lock(mutex_); if (!screenManager_) { @@ -820,7 +716,7 @@ int32_t RSRenderServiceConnection::SetVirtualScreenSurface(ScreenId id, sptr callback) { if (!callback) { @@ -845,14 +741,14 @@ int32_t RSRenderServiceConnection::RegisterPointerLuminanceChangeCallback( return StatusCode::SUCCESS; } -int32_t RSRenderServiceConnection::UnRegisterPointerLuminanceChangeCallback() +int32_t RSClientToRenderConnection::UnRegisterPointerLuminanceChangeCallback() { RSMagicPointerRenderManager::GetInstance().UnRegisterPointerLuminanceChangeCallback(remotePid_); return StatusCode::SUCCESS; } #endif -void RSRenderServiceConnection::RemoveVirtualScreen(ScreenId id) +void RSClientToRenderConnection::RemoveVirtualScreen(ScreenId id) { std::lock_guard lock(mutex_); if (!screenManager_) { @@ -864,35 +760,7 @@ void RSRenderServiceConnection::RemoveVirtualScreen(ScreenId id) NotifyRefreshRateEvent(event); } -int32_t RSRenderServiceConnection::SetScreenChangeCallback(sptr callback) -{ - if (!callback) { - RS_LOGE("%{public}s: callback is nullptr", __func__); - return INVALID_ARGUMENTS; - } - std::unique_lock lock(mutex_); - if (screenChangeCallback_ == callback) { - RS_LOGE("%{public}s: the callback has been set", __func__); - return INVALID_ARGUMENTS; - } - if (screenManager_ == nullptr) { - RS_LOGE("%{public}s: screenManager_ is nullptr", __func__); - return SCREEN_NOT_FOUND; - } - - if (screenChangeCallback_ != nullptr) { - // remove the old callback - RS_LOGW("%{public}s: last screenChangeCallback_ should be removed", __func__); - screenManager_->RemoveScreenChangeCallback(screenChangeCallback_); - } - - // update - int32_t status = screenManager_->AddScreenChangeCallback(callback); - screenChangeCallback_ = callback; - return status; -} - -void RSRenderServiceConnection::SetScreenActiveMode(ScreenId id, uint32_t modeId) +void RSClientToRenderConnection::SetScreenActiveMode(ScreenId id, uint32_t modeId) { if (!screenManager_) { return; @@ -909,42 +777,15 @@ void RSRenderServiceConnection::SetScreenActiveMode(ScreenId id, uint32_t modeId } } -void RSRenderServiceConnection::SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate) -{ - ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP, "RSRenderService::SetScreenRefreshRate"); - HgmTaskHandleThread::Instance().PostTask([id, sceneId, rate] () { - int32_t setResult = HgmCore::Instance().SetScreenRefreshRate(id, sceneId, rate); - if (setResult != 0) { - RS_LOGW("SetScreenRefreshRate request of screen %{public}" PRIu64 " of rate %{public}d is refused", - id, rate); - return; - } - }); - ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP); -} - -void RSRenderServiceConnection::SetRefreshRateMode(int32_t refreshRateMode) -{ - ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP, "RSRenderService::SetRefreshRateMode"); - HgmTaskHandleThread::Instance().PostTask([refreshRateMode] () { - int32_t setResult = HgmCore::Instance().SetRefreshRateMode(refreshRateMode); - RSSystemProperties::SetHgmRefreshRateModesEnabled(std::to_string(refreshRateMode)); - if (setResult != 0) { - RS_LOGW("SetRefreshRateMode mode %{public}d is not supported", refreshRateMode); - } - }); - ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP); -} - -void RSRenderServiceConnection::SyncFrameRateRange(FrameRateLinkerId id, +void RSClientToRenderConnection::SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range, int32_t animatorExpectedFrameRate) { if (!mainThread_) { return; } mainThread_->ScheduleTask( - [weakThis = wptr(this), id, &range, animatorExpectedFrameRate]() { - sptr connection = weakThis.promote(); + [weakThis = wptr(this), id, &range, animatorExpectedFrameRate]() { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -980,14 +821,14 @@ void RSRenderServiceConnection::SyncFrameRateRange(FrameRateLinkerId id, }).wait(); } -void RSRenderServiceConnection::UnregisterFrameRateLinker(FrameRateLinkerId id) +void RSClientToRenderConnection::UnregisterFrameRateLinker(FrameRateLinkerId id) { if (!mainThread_) { return; } mainThread_->ScheduleTask( - [weakThis = wptr(this), id]() { - sptr connection = weakThis.promote(); + [weakThis = wptr(this), id]() { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -1002,42 +843,7 @@ void RSRenderServiceConnection::UnregisterFrameRateLinker(FrameRateLinkerId id) }).wait(); } -uint32_t RSRenderServiceConnection::GetScreenCurrentRefreshRate(ScreenId id) -{ - uint32_t rate = HgmTaskHandleThread::Instance().ScheduleTask([id] () -> uint32_t { - return HgmCore::Instance().GetScreenCurrentRefreshRate(id); - }).get(); - if (rate == 0) { - RS_LOGW("GetScreenCurrentRefreshRate failed to get current refreshrate of" - " screen : %{public}" PRIu64, id); - } - return rate; -} - -std::vector RSRenderServiceConnection::GetScreenSupportedRefreshRates(ScreenId id) -{ - return HgmTaskHandleThread::Instance().ScheduleTask([id] () -> std::vector { - return HgmCore::Instance().GetScreenComponentRefreshRates(id); - }).get(); -} - -ErrCode RSRenderServiceConnection::GetShowRefreshRateEnabled(bool& enable) -{ - enable = RSRealtimeRefreshRateManager::Instance().GetShowRefreshRateEnabled(); - return ERR_OK; -} - -void RSRenderServiceConnection::SetShowRefreshRateEnabled(bool enabled, int32_t type) -{ - return RSRealtimeRefreshRateManager::Instance().SetShowRefreshRateEnabled(enabled, type); -} - -uint32_t RSRenderServiceConnection::GetRealtimeRefreshRate(ScreenId screenId) -{ - return RSRealtimeRefreshRateManager::Instance().GetRealtimeRefreshRate(screenId); -} - -ErrCode RSRenderServiceConnection::GetRefreshInfo(pid_t pid, std::string& enable) +ErrCode RSClientToRenderConnection::GetRefreshInfo(pid_t pid, std::string& enable) { if (!mainThread_) { enable = ""; @@ -1055,8 +861,8 @@ ErrCode RSRenderServiceConnection::GetRefreshInfo(pid_t pid, std::string& enable if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { #ifdef RS_ENABLE_GPU RSHardwareThread::Instance().ScheduleTask( - [weakThis = wptr(this), &dumpString, &surfaceName]() { - sptr connection = weakThis.promote(); + [weakThis = wptr(this), &dumpString, &surfaceName]() { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->screenManager_ == nullptr) { return; } @@ -1065,8 +871,8 @@ ErrCode RSRenderServiceConnection::GetRefreshInfo(pid_t pid, std::string& enable #endif } else { mainThread_->ScheduleTask( - [weakThis = wptr(this), &dumpString, &surfaceName]() { - sptr connection = weakThis.promote(); + [weakThis = wptr(this), &dumpString, &surfaceName]() { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->screenManager_ == nullptr) { return; } @@ -1077,7 +883,7 @@ ErrCode RSRenderServiceConnection::GetRefreshInfo(pid_t pid, std::string& enable return ERR_OK; } -ErrCode RSRenderServiceConnection::GetRefreshInfoToSP(NodeId id, std::string& enable) +ErrCode RSClientToRenderConnection::GetRefreshInfoToSP(NodeId id, std::string& enable) { if (!mainThread_) { enable = ""; @@ -1085,8 +891,8 @@ ErrCode RSRenderServiceConnection::GetRefreshInfoToSP(NodeId id, std::string& en } std::string dumpString; auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - auto dumpTask = [weakThis = wptr(this), &dumpString, &id]() { - sptr connection = weakThis.promote(); + auto dumpTask = [weakThis = wptr(this), &dumpString, &id]() { + sptr connection = weakThis.promote(); if (connection == nullptr) { RS_LOGE("GetRefreshInfoToSP connection is nullptr"); return; @@ -1108,14 +914,7 @@ ErrCode RSRenderServiceConnection::GetRefreshInfoToSP(NodeId id, std::string& en return ERR_OK; } -int32_t RSRenderServiceConnection::GetCurrentRefreshRateMode() -{ - return HgmTaskHandleThread::Instance().ScheduleTask([] () -> int32_t { - return HgmCore::Instance().GetCurrentRefreshRateMode(); - }).get(); -} - -int32_t RSRenderServiceConnection::SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height) +int32_t RSClientToRenderConnection::SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height) { if (!screenManager_) { return StatusCode::SCREEN_MANAGER_NULL; @@ -1123,7 +922,7 @@ int32_t RSRenderServiceConnection::SetPhysicalScreenResolution(ScreenId id, uint return screenManager_->SetPhysicalScreenResolution(id, width, height); } -int32_t RSRenderServiceConnection::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) +int32_t RSClientToRenderConnection::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) { if (!screenManager_) { return StatusCode::SCREEN_NOT_FOUND; @@ -1144,7 +943,7 @@ int32_t RSRenderServiceConnection::SetVirtualScreenResolution(ScreenId id, uint3 } } -ErrCode RSRenderServiceConnection::MarkPowerOffNeedProcessOneFrame() +ErrCode RSClientToRenderConnection::MarkPowerOffNeedProcessOneFrame() { auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); if (renderType != UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { @@ -1152,8 +951,8 @@ ErrCode RSRenderServiceConnection::MarkPowerOffNeedProcessOneFrame() } #ifdef RS_ENABLE_GPU renderThread_.PostTask( - [weakThis = wptr(this)]() { - sptr connection = weakThis.promote(); + [weakThis = wptr(this)]() { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->screenManager_ == nullptr) { return; } @@ -1164,7 +963,7 @@ ErrCode RSRenderServiceConnection::MarkPowerOffNeedProcessOneFrame() return ERR_OK; } -ErrCode RSRenderServiceConnection::RepaintEverything() +ErrCode RSClientToRenderConnection::RepaintEverything() { if (mainThread_ == nullptr) { RS_LOGE("RepaintEverything, mainThread_ is null, return"); @@ -1179,15 +978,15 @@ ErrCode RSRenderServiceConnection::RepaintEverything() return ERR_OK; } -ErrCode RSRenderServiceConnection::ForceRefreshOneFrameWithNextVSync() +ErrCode RSClientToRenderConnection::ForceRefreshOneFrameWithNextVSync() { if (!mainThread_) { RS_LOGE("%{public}s mainThread_ is nullptr, return", __func__); return ERR_INVALID_VALUE; } - auto task = [weakThis = wptr(this)]() -> void { - sptr connection = weakThis.promote(); + auto task = [weakThis = wptr(this)]() -> void { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -1200,14 +999,14 @@ ErrCode RSRenderServiceConnection::ForceRefreshOneFrameWithNextVSync() return ERR_OK; } -void RSRenderServiceConnection::DisablePowerOffRenderControl(ScreenId id) +void RSClientToRenderConnection::DisablePowerOffRenderControl(ScreenId id) { auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { #ifdef RS_ENABLE_GPU renderThread_.PostTask( - [weakThis = wptr(this), id]() { - sptr connection = weakThis.promote(); + [weakThis = wptr(this), id]() { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->screenManager_ == nullptr) { return; } @@ -1218,31 +1017,6 @@ void RSRenderServiceConnection::DisablePowerOffRenderControl(ScreenId id) } } -void RSRenderServiceConnection::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status) -{ - if (screenManager_ == nullptr || mainThread_ == nullptr) { - RS_LOGE("%{public}s screenManager or mainThread is null, id: %{public}" PRIu64, __func__, id); - return; - } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - RSHardwareThread::Instance().ScheduleTask([=]() { - screenManager_->SetScreenPowerStatus(id, status); - }).wait(); - screenManager_->WaitScreenPowerStatusTask(); - mainThread_->SetDiscardJankFrames(true); - RSJankStatsRenderFrameHelper::GetInstance().SetDiscardJankFrames(true); - HgmTaskHandleThread::Instance().PostTask([id, status]() { - HgmCore::Instance().NotifyScreenPowerStatus(id, status); - }); -#endif - } else { - mainThread_->ScheduleTask( - [=]() { screenManager_->SetScreenPowerStatus(id, status); }).wait(); - } -} - namespace { void TakeSurfaceCaptureForUiParallel( NodeId id, sptr callback, const RSSurfaceCaptureConfig& captureConfig, @@ -1304,7 +1078,7 @@ void TakeSurfaceCaptureForUIWithUni(NodeId id, sptr c } } -void RSRenderServiceConnection::TakeSurfaceCapture(NodeId id, sptr callback, +void RSClientToRenderConnection::TakeSurfaceCapture(NodeId id, sptr callback, const RSSurfaceCaptureConfig& captureConfig, const RSSurfaceCaptureBlurParam& blurParam, const Drawing::Rect& specifiedAreaRect, RSSurfaceCapturePermissions permissions) { @@ -1317,7 +1091,7 @@ void RSRenderServiceConnection::TakeSurfaceCapture(NodeId id, sptr void { - RS_TRACE_NAME_FMT("RSRenderServiceConnection::TakeSurfaceCapture captureTask nodeId:[%" PRIu64 "]", id); + RS_TRACE_NAME_FMT("RSClientToRenderConnection::TakeSurfaceCapture captureTask nodeId:[%" PRIu64 "]", id); RS_LOGD("TakeSurfaceCapture captureTask begin nodeId:[%{public}" PRIu64 "]", id); if (captureConfig.captureType == SurfaceCaptureType::UICAPTURE) { // When the isSync flag in captureConfig is true, UI capture processes commands before capture. @@ -1377,7 +1151,7 @@ void RSRenderServiceConnection::TakeSurfaceCapture(NodeId id, sptrPostTask(captureTask); } -std::vector>> RSRenderServiceConnection::TakeSurfaceCaptureSoloNode( +std::vector>> RSClientToRenderConnection::TakeSurfaceCaptureSoloNode( NodeId id, const RSSurfaceCaptureConfig& captureConfig, RSSurfaceCapturePermissions permissions) { RS_LOGI("TakeSurfaceCaptureSoloNode nodeId:[%{public}" PRIu64 "]", id); @@ -1385,7 +1159,7 @@ std::vector>> RSRenderService std::function captureTask = [id, captureConfig, &pixelMapIdPairVector, isSystemCalling = permissions.isSystemCalling, selfCapture = permissions.selfCapture]() { - RS_TRACE_NAME_FMT("RSRenderServiceConnection::TakeSurfaceCaptureSoloNode captureTask" + RS_TRACE_NAME_FMT("RSClientToRenderConnection::TakeSurfaceCaptureSoloNode captureTask" " nodeId:[%" PRIu64 "]", id); RS_LOGI("TakeSurfaceCaptureSoloNode captureTask begin " "nodeId:[%{public}" PRIu64 "]", id); @@ -1402,7 +1176,7 @@ std::vector>> RSRenderService return pixelMapIdPairVector; } -void RSRenderServiceConnection::TakeSelfSurfaceCapture( +void RSClientToRenderConnection::TakeSelfSurfaceCapture( NodeId id, sptr callback, const RSSurfaceCaptureConfig& captureConfig) { if (!mainThread_) { @@ -1431,7 +1205,7 @@ void RSRenderServiceConnection::TakeSelfSurfaceCapture( mainThread_->PostTask(selfCaptureTask); } -ErrCode RSRenderServiceConnection::SetWindowFreezeImmediately(NodeId id, bool isFreeze, +ErrCode RSClientToRenderConnection::SetWindowFreezeImmediately(NodeId id, bool isFreeze, sptr callback, const RSSurfaceCaptureConfig& captureConfig, const RSSurfaceCaptureBlurParam& blurParam) { @@ -1469,13 +1243,13 @@ ErrCode RSRenderServiceConnection::SetWindowFreezeImmediately(NodeId id, bool is return ERR_OK; } -void RSRenderServiceConnection::TakeUICaptureInRange( +void RSClientToRenderConnection::TakeUICaptureInRange( NodeId id, sptr callback, const RSSurfaceCaptureConfig& captureConfig) { TakeSurfaceCaptureForUiParallel(id, callback, captureConfig, {}); } -ErrCode RSRenderServiceConnection::SetHwcNodeBounds(int64_t rsNodeId, float positionX, float positionY, +ErrCode RSClientToRenderConnection::SetHwcNodeBounds(int64_t rsNodeId, float positionX, float positionY, float positionZ, float positionW) { if (mainThread_ == nullptr || screenManager_ == nullptr) { @@ -1497,14 +1271,14 @@ ErrCode RSRenderServiceConnection::SetHwcNodeBounds(int64_t rsNodeId, float posi return ERR_OK; } -ErrCode RSRenderServiceConnection::RegisterApplicationAgent(uint32_t pid, sptr app) +ErrCode RSClientToRenderConnection::RegisterApplicationAgent(uint32_t pid, sptr app) { if (!mainThread_) { RS_LOGE("RegisterApplicationAgent mainThread_ is nullptr"); return ERR_INVALID_VALUE; } - auto captureTask = [weakThis = wptr(this), pid, app]() -> void { - sptr connection = weakThis.promote(); + auto captureTask = [weakThis = wptr(this), pid, app]() -> void { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { RS_LOGE("RegisterApplicationAgent connection or mainThread_ is nullptr"); return; @@ -1517,15 +1291,7 @@ ErrCode RSRenderServiceConnection::RegisterApplicationAgent(uint32_t pid, sptr app) -{ - auto captureTask = [=]() -> void { - RSMainThread::Instance()->UnRegisterApplicationAgent(app); - }; - RSMainThread::Instance()->ScheduleTask(captureTask).wait(); -} - -RSVirtualScreenResolution RSRenderServiceConnection::GetVirtualScreenResolution(ScreenId id) +RSVirtualScreenResolution RSClientToRenderConnection::GetVirtualScreenResolution(ScreenId id) { RSVirtualScreenResolution virtualScreenResolution; if (!screenManager_) { @@ -1535,7 +1301,7 @@ RSVirtualScreenResolution RSRenderServiceConnection::GetVirtualScreenResolution( return virtualScreenResolution; } -ErrCode RSRenderServiceConnection::GetScreenActiveMode(uint64_t id, RSScreenModeInfo& screenModeInfo) +ErrCode RSClientToRenderConnection::GetScreenActiveMode(uint64_t id, RSScreenModeInfo& screenModeInfo) { if (!screenManager_) { return ERR_INVALID_VALUE; @@ -1555,7 +1321,7 @@ ErrCode RSRenderServiceConnection::GetScreenActiveMode(uint64_t id, RSScreenMode return ERR_OK; } -ErrCode RSRenderServiceConnection::GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize) +ErrCode RSClientToRenderConnection::GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize) { #ifdef RS_ENABLE_GPU RSMainThread::Instance()->GetAppMemoryInMB(cpuMemSize, gpuMemSize); @@ -1564,7 +1330,7 @@ ErrCode RSRenderServiceConnection::GetTotalAppMemSize(float& cpuMemSize, float& return ERR_OK; } -ErrCode RSRenderServiceConnection::GetMemoryGraphic(int pid, MemoryGraphic& memoryGraphic) +ErrCode RSClientToRenderConnection::GetMemoryGraphic(int pid, MemoryGraphic& memoryGraphic) { if (!mainThread_ || !mainThread_->GetContext().GetNodeMap().ContainPid(pid)) { return ERR_INVALID_VALUE; @@ -1572,8 +1338,8 @@ ErrCode RSRenderServiceConnection::GetMemoryGraphic(int pid, MemoryGraphic& memo bool enable; if (GetUniRenderEnabled(enable) == ERR_OK && enable) { renderThread_.PostSyncTask( - [weakThis = wptr(this), &memoryGraphic, &pid] { - sptr connection = weakThis.promote(); + [weakThis = wptr(this), &memoryGraphic, &pid] { + sptr connection = weakThis.promote(); if (connection == nullptr) { return; } @@ -1586,7 +1352,7 @@ ErrCode RSRenderServiceConnection::GetMemoryGraphic(int pid, MemoryGraphic& memo } } -ErrCode RSRenderServiceConnection::GetMemoryGraphics(std::vector& memoryGraphics) +ErrCode RSClientToRenderConnection::GetMemoryGraphics(std::vector& memoryGraphics) { bool res; if (!mainThread_ || GetUniRenderEnabled(res) != ERR_OK || !res) { @@ -1602,8 +1368,8 @@ ErrCode RSRenderServiceConnection::GetMemoryGraphics(std::vector& } }); renderThread_.PostSyncTask( - [weakThis = wptr(this), &memoryGraphics, &pids] { - sptr connection = weakThis.promote(); + [weakThis = wptr(this), &memoryGraphics, &pids] { + sptr connection = weakThis.promote(); if (connection == nullptr) { return; } @@ -1613,494 +1379,213 @@ ErrCode RSRenderServiceConnection::GetMemoryGraphics(std::vector& return ERR_OK; } -std::vector RSRenderServiceConnection::GetScreenSupportedModes(ScreenId id) +ErrCode RSClientToRenderConnection::RegisterBufferClearListener( + NodeId id, sptr callback) +{ + if (!mainThread_) { + return ERR_INVALID_VALUE; + } + auto registerBufferClearListener = + [id, callback, weakThis = wptr(this)]() -> bool { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return false; + } + if (auto node = connection->mainThread_->GetContext().GetNodeMap().GetRenderNode(id)) { + node->RegisterBufferClearListener(callback); + return true; + } + return false; + }; + mainThread_->PostTask(registerBufferClearListener); + return ERR_OK; +} + +ErrCode RSClientToRenderConnection::RegisterBufferAvailableListener( + NodeId id, sptr callback, bool isFromRenderThread) +{ + if (!mainThread_) { + return ERR_INVALID_VALUE; + } + auto registerBufferAvailableListener = + [id, callback, isFromRenderThread, weakThis = wptr(this)]() -> bool { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return false; + } + if (auto node = connection->mainThread_->GetContext().GetNodeMap().GetRenderNode(id)) { + node->RegisterBufferAvailableListener(callback, isFromRenderThread); + return true; + } + return false; + }; + mainThread_->PostTask(registerBufferAvailableListener); + return ERR_OK; +} + +bool RSClientToRenderConnection::SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation) { + std::lock_guard lock(mutex_); if (!screenManager_) { - return std::vector(); + return false; } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - return RSHardwareThread::Instance().ScheduleTask( - [=]() { return screenManager_->GetScreenSupportedModes(id); }).get(); -#else - return std::vector(); -#endif - } else if (mainThread_ != nullptr) { - return mainThread_->ScheduleTask( - [=]() { return screenManager_->GetScreenSupportedModes(id); }).get(); - } else { - return std::vector(); + return screenManager_->SetVirtualMirrorScreenCanvasRotation(id, canvasRotation); +} + +int32_t RSClientToRenderConnection::SetVirtualScreenAutoRotation(ScreenId id, bool isAutoRotation) +{ + if (!screenManager_) { + return StatusCode::SCREEN_MANAGER_NULL; + } + return screenManager_->SetVirtualScreenAutoRotation(id, isAutoRotation); +} + +ErrCode RSClientToRenderConnection::SetGlobalDarkColorMode(bool isDark) +{ + std::lock_guard lock(mutex_); + if (!mainThread_) { + return ERR_INVALID_VALUE; + } + auto task = [weakThis = wptr(this), isDark]() { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + RS_LOGE("SetGlobalDarkColorMode fail"); + return; + } + connection->mainThread_->SetGlobalDarkColorMode(isDark); + }; + mainThread_->PostTask(task); + return ERR_OK; +} + +bool RSClientToRenderConnection::SetVirtualMirrorScreenScaleMode(ScreenId id, ScreenScaleMode scaleMode) +{ + std::lock_guard lock(mutex_); + if (!screenManager_) { + return false; + } + return screenManager_->SetVirtualMirrorScreenScaleMode(id, scaleMode); +} + +int32_t RSClientToRenderConnection::GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability) +{ + std::lock_guard lock(mutex_); + if (!screenManager_) { + return StatusCode::SCREEN_NOT_FOUND; } + return screenManager_->GetScreenHDRCapability(id, screenHdrCapability); } -RSScreenCapability RSRenderServiceConnection::GetScreenCapability(ScreenId id) +ErrCode RSClientToRenderConnection::GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat, int32_t& resCode) { - RSScreenCapability screenCapability; if (!screenManager_) { - return screenCapability; + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; } auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { #ifdef RS_ENABLE_GPU - return RSHardwareThread::Instance().ScheduleTask( - [=]() { return screenManager_->GetScreenCapability(id); }).get(); + resCode = RSHardwareThread::Instance().ScheduleTask( + [=, &pixelFormat]() { return screenManager_->GetPixelFormat(id, pixelFormat); }).get(); + return ERR_OK; #else - return screenCapability; + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; #endif } else if (mainThread_ != nullptr) { - return mainThread_->ScheduleTask( - [=]() { return screenManager_->GetScreenCapability(id); }).get(); + resCode = mainThread_->ScheduleTask( + [=, &pixelFormat]() { return screenManager_->GetPixelFormat(id, pixelFormat); }).get(); + return ERR_OK; } else { - return screenCapability; + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; } } -ErrCode RSRenderServiceConnection::GetScreenPowerStatus(uint64_t screenId, uint32_t& status) +ErrCode RSClientToRenderConnection::SetPixelFormat(ScreenId id, GraphicPixelFormat pixelFormat, int32_t& resCode) { if (!screenManager_) { - status = ScreenPowerStatus::INVALID_POWER_STATUS; + resCode = StatusCode::SCREEN_NOT_FOUND; return ERR_INVALID_VALUE; } auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { #ifdef RS_ENABLE_GPU - status = RSHardwareThread::Instance().ScheduleTask( - [=]() { return screenManager_->GetScreenPowerStatus(screenId); }).get(); + resCode = RSHardwareThread::Instance().ScheduleTask( + [=]() { return screenManager_->SetPixelFormat(id, pixelFormat); }).get(); + return ERR_OK; #else - status = ScreenPowerStatus::INVALID_POWER_STATUS; + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; #endif } else if (mainThread_ != nullptr) { - status = mainThread_->ScheduleTask( - [=]() { return screenManager_->GetScreenPowerStatus(screenId); }).get(); + resCode = mainThread_->ScheduleTask( + [=]() { return screenManager_->SetPixelFormat(id, pixelFormat); }).get(); + return ERR_OK; } else { - status = ScreenPowerStatus::INVALID_POWER_STATUS; + resCode = StatusCode::SCREEN_NOT_FOUND; return ERR_INVALID_VALUE; } - return ERR_OK; } -RSScreenData RSRenderServiceConnection::GetScreenData(ScreenId id) +ErrCode RSClientToRenderConnection::GetScreenSupportedHDRFormats( + ScreenId id, std::vector& hdrFormats, int32_t& resCode) { - RSScreenData screenData; if (!screenManager_) { - return screenData; + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; } auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { #ifdef RS_ENABLE_GPU - return RSHardwareThread::Instance().ScheduleTask( - [=]() { return screenManager_->GetScreenData(id); }).get(); + resCode = RSHardwareThread::Instance().ScheduleTask( + [=, &hdrFormats]() { return screenManager_->GetScreenSupportedHDRFormats(id, hdrFormats); }).get(); + return ERR_OK; #else - return screenData; + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; #endif } else if (mainThread_ != nullptr) { - return mainThread_->ScheduleTask( - [=]() { return screenManager_->GetScreenData(id); }).get(); + resCode = mainThread_->ScheduleTask( + [=, &hdrFormats]() { return screenManager_->GetScreenSupportedHDRFormats(id, hdrFormats); }).get(); + return ERR_OK; } else { - return screenData; + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; } } -ErrCode RSRenderServiceConnection::GetScreenBacklight(uint64_t id, int32_t& level) +ErrCode RSClientToRenderConnection::GetScreenHDRFormat(ScreenId id, ScreenHDRFormat& hdrFormat, int32_t& resCode) { if (!screenManager_) { - level = INVALID_BACKLIGHT_VALUE; + resCode = StatusCode::SCREEN_NOT_FOUND; return ERR_INVALID_VALUE; } auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { #ifdef RS_ENABLE_GPU - level = RSHardwareThread::Instance().ScheduleTask( - [=]() { return screenManager_->GetScreenBacklight(id); }).get(); + resCode = RSHardwareThread::Instance().ScheduleTask( + [=, &hdrFormat]() { return screenManager_->GetScreenHDRFormat(id, hdrFormat); }).get(); + return ERR_OK; #else - level = INVALID_BACKLIGHT_VALUE; + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; #endif } else if (mainThread_ != nullptr) { - level = mainThread_->ScheduleTask( - [=]() { return screenManager_->GetScreenBacklight(id); }).get(); + resCode = mainThread_->ScheduleTask( + [=, &hdrFormat]() { return screenManager_->GetScreenHDRFormat(id, hdrFormat); }).get(); + return ERR_OK; } else { - level = INVALID_BACKLIGHT_VALUE; + resCode = StatusCode::SCREEN_NOT_FOUND; return ERR_INVALID_VALUE; } - return ERR_OK; } -void RSRenderServiceConnection::SetScreenBacklight(ScreenId id, uint32_t level) +ErrCode RSClientToRenderConnection::SetScreenHDRFormat(ScreenId id, int32_t modeIdx, int32_t& resCode) { if (!screenManager_) { - RS_LOGE("%{public}s screenManager_ is nullptr.", __func__); - return; - } - RSLuminanceControl::Get().SetSdrLuminance(id, level); - if (RSLuminanceControl::Get().IsHdrOn(id) && level > 0 && mainThread_ != nullptr) { - auto task = [weakThis = wptr(this), id]() { - sptr connection = weakThis.promote(); - if (connection == nullptr || connection->mainThread_ == nullptr) { - RS_LOGE("SetScreenBacklight fail"); - return; - } - connection->mainThread_->SetLuminanceChangingStatus(id, true); - connection->mainThread_->SetDirtyFlag(); - connection->mainThread_->RequestNextVSync(); - }; - mainThread_->PostTask(task); - return; - } - - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - screenManager_->SetScreenBacklight(id, level); -#endif - } else if (mainThread_ != nullptr) { - mainThread_->ScheduleTask( - [=]() { screenManager_->SetScreenBacklight(id, level); }).wait(); - } -} - -ErrCode RSRenderServiceConnection::RegisterBufferClearListener( - NodeId id, sptr callback) -{ - if (!mainThread_) { - return ERR_INVALID_VALUE; - } - auto registerBufferClearListener = - [id, callback, weakThis = wptr(this)]() -> bool { - sptr connection = weakThis.promote(); - if (connection == nullptr || connection->mainThread_ == nullptr) { - return false; - } - if (auto node = connection->mainThread_->GetContext().GetNodeMap().GetRenderNode(id)) { - node->RegisterBufferClearListener(callback); - return true; - } - return false; - }; - mainThread_->PostTask(registerBufferClearListener); - return ERR_OK; -} - -ErrCode RSRenderServiceConnection::RegisterBufferAvailableListener( - NodeId id, sptr callback, bool isFromRenderThread) -{ - if (!mainThread_) { - return ERR_INVALID_VALUE; - } - auto registerBufferAvailableListener = - [id, callback, isFromRenderThread, weakThis = wptr(this)]() -> bool { - sptr connection = weakThis.promote(); - if (connection == nullptr || connection->mainThread_ == nullptr) { - return false; - } - if (auto node = connection->mainThread_->GetContext().GetNodeMap().GetRenderNode(id)) { - node->RegisterBufferAvailableListener(callback, isFromRenderThread); - return true; - } - return false; - }; - mainThread_->PostTask(registerBufferAvailableListener); - return ERR_OK; -} - -int32_t RSRenderServiceConnection::GetScreenSupportedColorGamuts(ScreenId id, std::vector& mode) -{ - if (!screenManager_) { - return StatusCode::SCREEN_NOT_FOUND; - } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - return RSHardwareThread::Instance().ScheduleTask( - [=, &mode]() { return screenManager_->GetScreenSupportedColorGamuts(id, mode); }).get(); -#else - return StatusCode::SCREEN_NOT_FOUND; -#endif - } else if (mainThread_ != nullptr) { - return mainThread_->ScheduleTask( - [=, &mode]() { return screenManager_->GetScreenSupportedColorGamuts(id, mode); }).get(); - } else { - return StatusCode::SCREEN_NOT_FOUND; - } -} - -int32_t RSRenderServiceConnection::GetScreenSupportedMetaDataKeys(ScreenId id, std::vector& keys) -{ - if (!screenManager_) { - return StatusCode::SCREEN_NOT_FOUND; - } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - return RSHardwareThread::Instance().ScheduleTask( - [=, &keys]() { return screenManager_->GetScreenSupportedMetaDataKeys(id, keys); }).get(); -#else - return StatusCode::SCREEN_NOT_FOUND; -#endif - } else if (mainThread_ != nullptr) { - return mainThread_->ScheduleTask( - [=, &keys]() { return screenManager_->GetScreenSupportedMetaDataKeys(id, keys); }).get(); - } else { - return StatusCode::SCREEN_NOT_FOUND; - } -} - -int32_t RSRenderServiceConnection::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode) -{ - if (!screenManager_) { - return StatusCode::SCREEN_NOT_FOUND; - } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - return RSHardwareThread::Instance().ScheduleTask( - [=, &mode]() { return screenManager_->GetScreenColorGamut(id, mode); }).get(); -#else - return StatusCode::SCREEN_NOT_FOUND; -#endif - } else if (mainThread_ != nullptr) { - return mainThread_->ScheduleTask( - [=, &mode]() { return screenManager_->GetScreenColorGamut(id, mode); }).get(); - } else { - return StatusCode::SCREEN_NOT_FOUND; - } -} - -int32_t RSRenderServiceConnection::SetScreenColorGamut(ScreenId id, int32_t modeIdx) -{ - if (!screenManager_) { - return StatusCode::SCREEN_NOT_FOUND; - } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - return RSHardwareThread::Instance().ScheduleTask( - [=]() { return screenManager_->SetScreenColorGamut(id, modeIdx); }).get(); -#else - return StatusCode::SCREEN_NOT_FOUND; -#endif - } else if (mainThread_ != nullptr) { - return mainThread_->ScheduleTask( - [=]() { return screenManager_->SetScreenColorGamut(id, modeIdx); }).get(); - } else { - return StatusCode::SCREEN_NOT_FOUND; - } -} - -int32_t RSRenderServiceConnection::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode) -{ - if (!screenManager_) { - return StatusCode::SCREEN_NOT_FOUND; - } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - return RSHardwareThread::Instance().ScheduleTask( - [=]() { return screenManager_->SetScreenGamutMap(id, mode); }).get(); -#else - return StatusCode::SCREEN_NOT_FOUND; -#endif - } else if (mainThread_ != nullptr) { - return mainThread_->ScheduleTask( - [=]() { return screenManager_->SetScreenGamutMap(id, mode); }).get(); - } else { - return StatusCode::SCREEN_NOT_FOUND; - } -} - -int32_t RSRenderServiceConnection::SetScreenCorrection(ScreenId id, ScreenRotation screenRotation) -{ - std::lock_guard lock(mutex_); - if (!screenManager_) { - return StatusCode::SCREEN_NOT_FOUND; - } - return screenManager_->SetScreenCorrection(id, screenRotation); -} - -bool RSRenderServiceConnection::SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation) -{ - std::lock_guard lock(mutex_); - if (!screenManager_) { - return false; - } - return screenManager_->SetVirtualMirrorScreenCanvasRotation(id, canvasRotation); -} - -int32_t RSRenderServiceConnection::SetVirtualScreenAutoRotation(ScreenId id, bool isAutoRotation) -{ - if (!screenManager_) { - return StatusCode::SCREEN_MANAGER_NULL; - } - return screenManager_->SetVirtualScreenAutoRotation(id, isAutoRotation); -} - -ErrCode RSRenderServiceConnection::SetGlobalDarkColorMode(bool isDark) -{ - std::lock_guard lock(mutex_); - if (!mainThread_) { - return ERR_INVALID_VALUE; - } - auto task = [weakThis = wptr(this), isDark]() { - sptr connection = weakThis.promote(); - if (connection == nullptr || connection->mainThread_ == nullptr) { - RS_LOGE("SetGlobalDarkColorMode fail"); - return; - } - connection->mainThread_->SetGlobalDarkColorMode(isDark); - }; - mainThread_->PostTask(task); - return ERR_OK; -} - -bool RSRenderServiceConnection::SetVirtualMirrorScreenScaleMode(ScreenId id, ScreenScaleMode scaleMode) -{ - std::lock_guard lock(mutex_); - if (!screenManager_) { - return false; - } - return screenManager_->SetVirtualMirrorScreenScaleMode(id, scaleMode); -} - -int32_t RSRenderServiceConnection::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode) -{ - if (!screenManager_) { - return StatusCode::SCREEN_NOT_FOUND; - } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - return RSHardwareThread::Instance().ScheduleTask( - [=, &mode]() { return screenManager_->GetScreenGamutMap(id, mode); }).get(); -#else - return StatusCode::SCREEN_NOT_FOUND; -#endif - } else if (mainThread_ != nullptr) { - return mainThread_->ScheduleTask( - [=, &mode]() { return screenManager_->GetScreenGamutMap(id, mode); }).get(); - } else { - return StatusCode::SCREEN_NOT_FOUND; - } -} - -int32_t RSRenderServiceConnection::GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability) -{ - std::lock_guard lock(mutex_); - if (!screenManager_) { - return StatusCode::SCREEN_NOT_FOUND; - } - return screenManager_->GetScreenHDRCapability(id, screenHdrCapability); -} - -ErrCode RSRenderServiceConnection::GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat, int32_t& resCode) -{ - if (!screenManager_) { - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; - } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - resCode = RSHardwareThread::Instance().ScheduleTask( - [=, &pixelFormat]() { return screenManager_->GetPixelFormat(id, pixelFormat); }).get(); - return ERR_OK; -#else - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; -#endif - } else if (mainThread_ != nullptr) { - resCode = mainThread_->ScheduleTask( - [=, &pixelFormat]() { return screenManager_->GetPixelFormat(id, pixelFormat); }).get(); - return ERR_OK; - } else { - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; - } -} - -ErrCode RSRenderServiceConnection::SetPixelFormat(ScreenId id, GraphicPixelFormat pixelFormat, int32_t& resCode) -{ - if (!screenManager_) { - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; - } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - resCode = RSHardwareThread::Instance().ScheduleTask( - [=]() { return screenManager_->SetPixelFormat(id, pixelFormat); }).get(); - return ERR_OK; -#else - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; -#endif - } else if (mainThread_ != nullptr) { - resCode = mainThread_->ScheduleTask( - [=]() { return screenManager_->SetPixelFormat(id, pixelFormat); }).get(); - return ERR_OK; - } else { - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; - } -} - -ErrCode RSRenderServiceConnection::GetScreenSupportedHDRFormats( - ScreenId id, std::vector& hdrFormats, int32_t& resCode) -{ - if (!screenManager_) { - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; - } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - resCode = RSHardwareThread::Instance().ScheduleTask( - [=, &hdrFormats]() { return screenManager_->GetScreenSupportedHDRFormats(id, hdrFormats); }).get(); - return ERR_OK; -#else - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; -#endif - } else if (mainThread_ != nullptr) { - resCode = mainThread_->ScheduleTask( - [=, &hdrFormats]() { return screenManager_->GetScreenSupportedHDRFormats(id, hdrFormats); }).get(); - return ERR_OK; - } else { - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; - } -} - -ErrCode RSRenderServiceConnection::GetScreenHDRFormat(ScreenId id, ScreenHDRFormat& hdrFormat, int32_t& resCode) -{ - if (!screenManager_) { - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; - } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - resCode = RSHardwareThread::Instance().ScheduleTask( - [=, &hdrFormat]() { return screenManager_->GetScreenHDRFormat(id, hdrFormat); }).get(); - return ERR_OK; -#else - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; -#endif - } else if (mainThread_ != nullptr) { - resCode = mainThread_->ScheduleTask( - [=, &hdrFormat]() { return screenManager_->GetScreenHDRFormat(id, hdrFormat); }).get(); - return ERR_OK; - } else { - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; - } -} - -ErrCode RSRenderServiceConnection::SetScreenHDRFormat(ScreenId id, int32_t modeIdx, int32_t& resCode) -{ - if (!screenManager_) { - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; } auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { @@ -2122,7 +1607,7 @@ ErrCode RSRenderServiceConnection::SetScreenHDRFormat(ScreenId id, int32_t modeI } } -ErrCode RSRenderServiceConnection::GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus, int32_t& resCode) +ErrCode RSClientToRenderConnection::GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus, int32_t& resCode) { if (mainThread_ == nullptr) { return ERR_INVALID_VALUE; @@ -2164,7 +1649,7 @@ ErrCode RSRenderServiceConnection::GetScreenHDRStatus(ScreenId id, HdrStatus& hd return ERR_OK; } -ErrCode RSRenderServiceConnection::GetScreenSupportedColorSpaces( +ErrCode RSClientToRenderConnection::GetScreenSupportedColorSpaces( ScreenId id, std::vector& colorSpaces, int32_t& resCode) { if (!screenManager_) { @@ -2191,70 +1676,7 @@ ErrCode RSRenderServiceConnection::GetScreenSupportedColorSpaces( } } -ErrCode RSRenderServiceConnection::GetScreenColorSpace( - ScreenId id, GraphicCM_ColorSpaceType& colorSpace, int32_t& resCode) -{ - if (!screenManager_) { - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; - } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - resCode = RSHardwareThread::Instance().ScheduleTask( - [=, &colorSpace]() { return screenManager_->GetScreenColorSpace(id, colorSpace); }).get(); - return ERR_OK; -#else - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; -#endif - } else if (mainThread_ != nullptr) { - resCode = mainThread_->ScheduleTask( - [=, &colorSpace]() { return screenManager_->GetScreenColorSpace(id, colorSpace); }).get(); - return ERR_OK; - } else { - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; - } -} - -ErrCode RSRenderServiceConnection::SetScreenColorSpace( - ScreenId id, GraphicCM_ColorSpaceType colorSpace, int32_t& resCode) -{ - if (!screenManager_) { - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; - } - auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); - if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { -#ifdef RS_ENABLE_GPU - resCode = RSHardwareThread::Instance().ScheduleTask( - [=]() { return screenManager_->SetScreenColorSpace(id, colorSpace); }).get(); - return ERR_OK; -#else - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; -#endif - } else if (mainThread_ != nullptr) { - resCode = mainThread_->ScheduleTask( - [=]() { return screenManager_->SetScreenColorSpace(id, colorSpace); }).get(); - return ERR_OK; - } else { - resCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; - } -} - -int32_t RSRenderServiceConnection::GetScreenType(ScreenId id, RSScreenType& screenType) -{ - std::lock_guard lock(mutex_); - if (!screenManager_) { - return StatusCode::SCREEN_NOT_FOUND; - } - return screenManager_->GetScreenType(id, screenType); -} - -ErrCode RSRenderServiceConnection::GetBitmap(NodeId id, Drawing::Bitmap& bitmap, bool& success) +ErrCode RSClientToRenderConnection::GetBitmap(NodeId id, Drawing::Bitmap& bitmap, bool& success) { if (!mainThread_) { success = false; @@ -2292,7 +1714,7 @@ ErrCode RSRenderServiceConnection::GetBitmap(NodeId id, Drawing::Bitmap& bitmap, return ERR_OK; } -ErrCode RSRenderServiceConnection::GetPixelmap(NodeId id, const std::shared_ptr pixelmap, +ErrCode RSClientToRenderConnection::GetPixelmap(NodeId id, const std::shared_ptr pixelmap, const Drawing::Rect* rect, std::shared_ptr drawCmdList, bool& success) { if (!mainThread_) { @@ -2352,7 +1774,7 @@ ErrCode RSRenderServiceConnection::GetPixelmap(NodeId id, const std::shared_ptr< return ERR_OK; } -bool RSRenderServiceConnection::RegisterTypeface(uint64_t globalUniqueId, +bool RSClientToRenderConnection::RegisterTypeface(uint64_t globalUniqueId, std::shared_ptr& typeface) { RS_LOGI("reg typeface, pid[%{public}d], familyname:%{public}s, uniqueid:%{public}u", @@ -2362,7 +1784,7 @@ bool RSRenderServiceConnection::RegisterTypeface(uint64_t globalUniqueId, return true; } -bool RSRenderServiceConnection::UnRegisterTypeface(uint64_t globalUniqueId) +bool RSClientToRenderConnection::UnRegisterTypeface(uint64_t globalUniqueId) { RS_LOGW("uneg typeface: pid[%{public}d], uniqueid:%{public}u", RSTypefaceCache::GetTypefacePid(globalUniqueId), RSTypefaceCache::GetTypefaceId(globalUniqueId)); @@ -2370,17 +1792,7 @@ bool RSRenderServiceConnection::UnRegisterTypeface(uint64_t globalUniqueId) return true; } -int32_t RSRenderServiceConnection::GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, - std::vector& edidData) -{ - std::lock_guard lock(mutex_); - if (!screenManager_) { - return StatusCode::SCREEN_NOT_FOUND; - } - return screenManager_->GetDisplayIdentificationData(id, outPort, edidData); -} - -ErrCode RSRenderServiceConnection::SetScreenSkipFrameInterval(uint64_t id, uint32_t skipFrameInterval, int32_t& resCode) +ErrCode RSClientToRenderConnection::SetScreenSkipFrameInterval(uint64_t id, uint32_t skipFrameInterval, int32_t& resCode) { if (!screenManager_) { resCode = StatusCode::SCREEN_NOT_FOUND; @@ -2405,7 +1817,7 @@ ErrCode RSRenderServiceConnection::SetScreenSkipFrameInterval(uint64_t id, uint3 return ERR_OK; } -ErrCode RSRenderServiceConnection::SetVirtualScreenRefreshRate( +ErrCode RSClientToRenderConnection::SetVirtualScreenRefreshRate( ScreenId id, uint32_t maxRefreshRate, uint32_t& actualRefreshRate, int32_t& retVal) { if (!screenManager_) { @@ -2416,39 +1828,7 @@ ErrCode RSRenderServiceConnection::SetVirtualScreenRefreshRate( return ERR_OK; } -ErrCode RSRenderServiceConnection::SetScreenActiveRect(ScreenId id, const Rect& activeRect, uint32_t& repCode) -{ - if (!screenManager_) { - repCode = StatusCode::SCREEN_NOT_FOUND; - return ERR_INVALID_VALUE; - } - GraphicIRect dstActiveRect { - .x = activeRect.x, - .y = activeRect.y, - .w = activeRect.w, - .h = activeRect.h, - }; - if (!mainThread_) { - repCode = StatusCode::INVALID_ARGUMENTS; - return ERR_INVALID_VALUE; - } - auto task = [weakScreenManager = wptr(screenManager_), id, dstActiveRect]() -> void { - sptr screenManager = weakScreenManager.promote(); - if (!screenManager) { - return; - } - screenManager->SetScreenActiveRect(id, dstActiveRect); - }; - mainThread_->ScheduleTask(task).wait(); - - HgmTaskHandleThread::Instance().PostTask([id, dstActiveRect]() { - HgmCore::Instance().NotifyScreenRectFrameRateChange(id, dstActiveRect); - }); - repCode = StatusCode::SUCCESS; - return ERR_OK; -} - -void RSRenderServiceConnection::SetScreenOffset(ScreenId id, int32_t offsetX, int32_t offsetY) +void RSClientToRenderConnection::SetScreenOffset(ScreenId id, int32_t offsetX, int32_t offsetY) { if (!screenManager_) { return; @@ -2456,10 +1836,10 @@ void RSRenderServiceConnection::SetScreenOffset(ScreenId id, int32_t offsetX, in screenManager_->SetScreenOffset(id, offsetX, offsetY); } -void RSRenderServiceConnection::SetScreenFrameGravity(ScreenId id, int32_t gravity) +void RSClientToRenderConnection::SetScreenFrameGravity(ScreenId id, int32_t gravity) { - auto task = [weakThis = wptr(this), id, gravity]() -> void { - sptr connection = weakThis.promote(); + auto task = [weakThis = wptr(this), id, gravity]() -> void { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -2473,7 +1853,7 @@ void RSRenderServiceConnection::SetScreenFrameGravity(ScreenId id, int32_t gravi mainThread_->PostTask(task); } -ErrCode RSRenderServiceConnection::RegisterOcclusionChangeCallback( +ErrCode RSClientToRenderConnection::RegisterOcclusionChangeCallback( sptr callback, int32_t& repCode) { std::lock_guard lock(mutex_); @@ -2491,7 +1871,7 @@ ErrCode RSRenderServiceConnection::RegisterOcclusionChangeCallback( return ERR_OK; } -int32_t RSRenderServiceConnection::RegisterSurfaceOcclusionChangeCallback( +int32_t RSClientToRenderConnection::RegisterSurfaceOcclusionChangeCallback( NodeId id, sptr callback, std::vector& partitionPoints) { std::lock_guard lock(mutex_); @@ -2506,7 +1886,7 @@ int32_t RSRenderServiceConnection::RegisterSurfaceOcclusionChangeCallback( return StatusCode::SUCCESS; } -int32_t RSRenderServiceConnection::UnRegisterSurfaceOcclusionChangeCallback(NodeId id) +int32_t RSClientToRenderConnection::UnRegisterSurfaceOcclusionChangeCallback(NodeId id) { std::lock_guard lock(mutex_); if (!mainThread_) { @@ -2516,7 +1896,7 @@ int32_t RSRenderServiceConnection::UnRegisterSurfaceOcclusionChangeCallback(Node return StatusCode::SUCCESS; } -int32_t RSRenderServiceConnection::RegisterHgmConfigChangeCallback(sptr callback) +int32_t RSClientToRenderConnection::RegisterHgmConfigChangeCallback(sptr callback) { std::lock_guard lock(mutex_); if (!callback) { @@ -2530,7 +1910,7 @@ int32_t RSRenderServiceConnection::RegisterHgmConfigChangeCallback(sptr callback) { std::lock_guard lock(mutex_); @@ -2545,7 +1925,7 @@ int32_t RSRenderServiceConnection::RegisterHgmRefreshRateModeChangeCallback( return StatusCode::SUCCESS; } -int32_t RSRenderServiceConnection::RegisterHgmRefreshRateUpdateCallback( +int32_t RSClientToRenderConnection::RegisterHgmRefreshRateUpdateCallback( sptr callback) { std::lock_guard lock(mutex_); @@ -2556,7 +1936,7 @@ int32_t RSRenderServiceConnection::RegisterHgmRefreshRateUpdateCallback( return StatusCode::SUCCESS; } -int32_t RSRenderServiceConnection::RegisterFirstFrameCommitCallback( +int32_t RSClientToRenderConnection::RegisterFirstFrameCommitCallback( sptr callback) { std::lock_guard lock(mutex_); @@ -2564,7 +1944,7 @@ int32_t RSRenderServiceConnection::RegisterFirstFrameCommitCallback( return StatusCode::SUCCESS; } -int32_t RSRenderServiceConnection::RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid, +int32_t RSClientToRenderConnection::RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid, sptr callback) { if (dstPid == 0) { @@ -2579,13 +1959,13 @@ int32_t RSRenderServiceConnection::RegisterFrameRateLinkerExpectedFpsUpdateCallb return StatusCode::SUCCESS; } -ErrCode RSRenderServiceConnection::SetAppWindowNum(uint32_t num) +ErrCode RSClientToRenderConnection::SetAppWindowNum(uint32_t num) { if (!mainThread_) { return ERR_INVALID_VALUE; } - auto task = [weakThis = wptr(this), num]() -> void { - sptr connection = weakThis.promote(); + auto task = [weakThis = wptr(this), num]() -> void { + sptr connection = weakThis.promote(); if (!connection || !connection->mainThread_) { return; } @@ -2596,7 +1976,7 @@ ErrCode RSRenderServiceConnection::SetAppWindowNum(uint32_t num) return ERR_OK; } -ErrCode RSRenderServiceConnection::SetSystemAnimatedScenes( +ErrCode RSClientToRenderConnection::SetSystemAnimatedScenes( SystemAnimatedScenes systemAnimatedScenes, bool isRegularAnimation, bool& success) { std::lock_guard lock(mutex_); @@ -2614,13 +1994,13 @@ ErrCode RSRenderServiceConnection::SetSystemAnimatedScenes( #endif } -void RSRenderServiceConnection::ShowWatermark(const std::shared_ptr &watermarkImg, bool isShow) +void RSClientToRenderConnection::ShowWatermark(const std::shared_ptr &watermarkImg, bool isShow) { if (!mainThread_) { return; } - auto task = [weakThis = wptr(this), watermarkImg, isShow]() -> void { - sptr connection = weakThis.promote(); + auto task = [weakThis = wptr(this), watermarkImg, isShow]() -> void { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -2629,7 +2009,7 @@ void RSRenderServiceConnection::ShowWatermark(const std::shared_ptrPostTask(task); } -int32_t RSRenderServiceConnection::ResizeVirtualScreen(ScreenId id, uint32_t width, uint32_t height) +int32_t RSClientToRenderConnection::ResizeVirtualScreen(ScreenId id, uint32_t width, uint32_t height) { if (!screenManager_) { return StatusCode::SCREEN_NOT_FOUND; @@ -2638,8 +2018,8 @@ int32_t RSRenderServiceConnection::ResizeVirtualScreen(ScreenId id, uint32_t wid if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { #ifdef RS_ENABLE_GPU return RSHardwareThread::Instance().ScheduleTask( - [weakThis = wptr(this), id, width, height]() -> int32_t { - sptr connection = weakThis.promote(); + [weakThis = wptr(this), id, width, height]() -> int32_t { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->screenManager_ == nullptr) { return RS_CONNECTION_ERROR; } @@ -2651,8 +2031,8 @@ int32_t RSRenderServiceConnection::ResizeVirtualScreen(ScreenId id, uint32_t wid #endif } else if (mainThread_ != nullptr) { return mainThread_->ScheduleTask( - [weakThis = wptr(this), id, width, height]() -> int32_t { - sptr connection = weakThis.promote(); + [weakThis = wptr(this), id, width, height]() -> int32_t { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->screenManager_ == nullptr) { return RS_CONNECTION_ERROR; } @@ -2664,7 +2044,7 @@ int32_t RSRenderServiceConnection::ResizeVirtualScreen(ScreenId id, uint32_t wid } } -ErrCode RSRenderServiceConnection::ReportJankStats() +ErrCode RSClientToRenderConnection::ReportJankStats() { #ifdef RS_ENABLE_GPU auto task = []() -> void { RSJankStats::GetInstance().ReportJankStats(); }; @@ -2673,7 +2053,7 @@ ErrCode RSRenderServiceConnection::ReportJankStats() return ERR_OK; } -ErrCode RSRenderServiceConnection::NotifyLightFactorStatus(int32_t lightFactorStatus) +ErrCode RSClientToRenderConnection::NotifyLightFactorStatus(int32_t lightFactorStatus) { HgmTaskHandleThread::Instance().PostTask([pid = remotePid_, lightFactorStatus]() { auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); @@ -2684,7 +2064,7 @@ ErrCode RSRenderServiceConnection::NotifyLightFactorStatus(int32_t lightFactorSt return ERR_OK; } -void RSRenderServiceConnection::NotifyPackageEvent(uint32_t listSize, const std::vector& packageList) +void RSClientToRenderConnection::NotifyPackageEvent(uint32_t listSize, const std::vector& packageList) { if (!mainThread_) { return; @@ -2698,7 +2078,7 @@ void RSRenderServiceConnection::NotifyPackageEvent(uint32_t listSize, const std: }); } -void RSRenderServiceConnection::NotifyAppStrategyConfigChangeEvent(const std::string& pkgName, uint32_t listSize, +void RSClientToRenderConnection::NotifyAppStrategyConfigChangeEvent(const std::string& pkgName, uint32_t listSize, const std::vector>& newConfig) { HgmTaskHandleThread::Instance().PostTask([pid = remotePid_, listSize, pkgName, newConfig] () { @@ -2709,52 +2089,7 @@ void RSRenderServiceConnection::NotifyAppStrategyConfigChangeEvent(const std::st }); } -void RSRenderServiceConnection::NotifyRefreshRateEvent(const EventInfo& eventInfo) -{ - if (VOTER_SCENE_BLUR == eventInfo.eventName) { - RsFrameBlurPredict::GetInstance().TakeEffectBlurScene(eventInfo); - return; - } - - if (VOTER_SCENE_GPU == eventInfo.eventName) { - RsFrameReport::GetInstance().ReportScbSceneInfo(eventInfo.description, eventInfo.eventStatus); - return; - } - HgmTaskHandleThread::Instance().PostTask([pid = remotePid_, eventInfo]() { - auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); - if (frameRateMgr != nullptr) { - frameRateMgr->HandleRefreshRateEvent(pid, eventInfo); - } - }); -} - -void RSRenderServiceConnection::SetWindowExpectedRefreshRate( - const std::unordered_map& eventInfos -) -{ - HgmTaskHandleThread::Instance().PostTask([pid = remotePid_, eventInfos]() { - auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); - if (frameRateMgr != nullptr) { - auto& softVsyncMgr = frameRateMgr->SoftVSyncMgrRef(); - softVsyncMgr.SetWindowExpectedRefreshRate(pid, eventInfos); - } - }); -} - -void RSRenderServiceConnection::SetWindowExpectedRefreshRate( - const std::unordered_map& eventInfos -) -{ - HgmTaskHandleThread::Instance().PostTask([pid = remotePid_, eventInfos]() { - auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); - if (frameRateMgr != nullptr) { - auto& softVsyncMgr = frameRateMgr->SoftVSyncMgrRef(); - softVsyncMgr.SetWindowExpectedRefreshRate(pid, eventInfos); - } - }); -} - -ErrCode RSRenderServiceConnection::NotifySoftVsyncEvent(uint32_t pid, uint32_t rateDiscount) +ErrCode RSClientToRenderConnection::NotifySoftVsyncEvent(uint32_t pid, uint32_t rateDiscount) { if (!appVSyncDistributor_) { return ERR_INVALID_VALUE; @@ -2763,7 +2098,7 @@ ErrCode RSRenderServiceConnection::NotifySoftVsyncEvent(uint32_t pid, uint32_t r return ERR_OK; } -bool RSRenderServiceConnection::NotifySoftVsyncRateDiscountEvent(uint32_t pid, +bool RSClientToRenderConnection::NotifySoftVsyncRateDiscountEvent(uint32_t pid, const std::string &name, uint32_t rateDiscount) { if (!appVSyncDistributor_) { @@ -2800,32 +2135,7 @@ bool RSRenderServiceConnection::NotifySoftVsyncRateDiscountEvent(uint32_t pid, return true; } -ErrCode RSRenderServiceConnection::NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt) -{ - if (mainThread_ != nullptr) { - mainThread_->HandleTouchEvent(touchStatus, touchCnt); - return ERR_INVALID_VALUE; - } - auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); - if (frameRateMgr != nullptr) { - frameRateMgr->HandleTouchEvent(remotePid_, touchStatus, touchCnt); - } - return ERR_OK; -} - -void RSRenderServiceConnection::NotifyDynamicModeEvent(bool enableDynamicModeEvent) -{ - HgmTaskHandleThread::Instance().PostTask([enableDynamicModeEvent] () { - auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); - if (frameRateMgr == nullptr) { - RS_LOGW("NotifyDynamicModeEvent: frameRateMgr is nullptr."); - return; - } - frameRateMgr->HandleDynamicModeEvent(enableDynamicModeEvent); - }); -} - -ErrCode RSRenderServiceConnection::NotifyHgmConfigEvent(const std::string &eventName, bool state) +ErrCode RSClientToRenderConnection::NotifyHgmConfigEvent(const std::string &eventName, bool state) { HgmTaskHandleThread::Instance().PostTask([eventName, state] () { auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); @@ -2846,7 +2156,7 @@ ErrCode RSRenderServiceConnection::NotifyHgmConfigEvent(const std::string &event return ERR_OK; } -ErrCode RSRenderServiceConnection::NotifyXComponentExpectedFrameRate(const std::string& id, int32_t expectedFrameRate) +ErrCode RSClientToRenderConnection::NotifyXComponentExpectedFrameRate(const std::string& id, int32_t expectedFrameRate) { HgmTaskHandleThread::Instance().PostTask([remotePid = remotePid_, id, expectedFrameRate] () { HgmConfigCallbackManager::GetInstance()->SyncXComponentExpectedFrameRateCallback( @@ -2855,7 +2165,7 @@ ErrCode RSRenderServiceConnection::NotifyXComponentExpectedFrameRate(const std:: return ERR_OK; } -ErrCode RSRenderServiceConnection::ReportEventResponse(DataBaseRs info) +ErrCode RSClientToRenderConnection::ReportEventResponse(DataBaseRs info) { auto task = [info]() -> void { RSJankStats::GetInstance().SetReportEventResponse(info); @@ -2868,7 +2178,7 @@ ErrCode RSRenderServiceConnection::ReportEventResponse(DataBaseRs info) return ERR_OK; } -ErrCode RSRenderServiceConnection::ReportEventComplete(DataBaseRs info) +ErrCode RSClientToRenderConnection::ReportEventComplete(DataBaseRs info) { auto task = [info]() -> void { RSJankStats::GetInstance().SetReportEventComplete(info); @@ -2880,7 +2190,7 @@ ErrCode RSRenderServiceConnection::ReportEventComplete(DataBaseRs info) return ERR_OK; } -ErrCode RSRenderServiceConnection::ReportEventJankFrame(DataBaseRs info) +ErrCode RSClientToRenderConnection::ReportEventJankFrame(DataBaseRs info) { #ifdef RS_ENABLE_GPU bool isReportTaskDelayed = renderThread_.IsMainLooping(); @@ -2893,7 +2203,7 @@ ErrCode RSRenderServiceConnection::ReportEventJankFrame(DataBaseRs info) return ERR_OK; } -void RSRenderServiceConnection::ReportRsSceneJankStart(AppInfo info) +void RSClientToRenderConnection::ReportRsSceneJankStart(AppInfo info) { auto task = [info]() -> void { RSJankStats::GetInstance().SetReportRsSceneJankStart(info); @@ -2901,7 +2211,7 @@ void RSRenderServiceConnection::ReportRsSceneJankStart(AppInfo info) renderThread_.PostTask(task); } -void RSRenderServiceConnection::ReportRsSceneJankEnd(AppInfo info) +void RSClientToRenderConnection::ReportRsSceneJankEnd(AppInfo info) { auto task = [info]() -> void { RSJankStats::GetInstance().SetReportRsSceneJankEnd(info); @@ -2909,7 +2219,7 @@ void RSRenderServiceConnection::ReportRsSceneJankEnd(AppInfo info) renderThread_.PostTask(task); } -ErrCode RSRenderServiceConnection::ReportGameStateData(GameStateData info) +ErrCode RSClientToRenderConnection::ReportGameStateData(GameStateData info) { RS_LOGD("ReportGameStateData = %{public}s, uid = %{public}d, state = %{public}d, " "pid = %{public}d renderTid = %{public}d ", @@ -2919,15 +2229,15 @@ ErrCode RSRenderServiceConnection::ReportGameStateData(GameStateData info) return ERR_OK; } -ErrCode RSRenderServiceConnection::SetHardwareEnabled(NodeId id, bool isEnabled, SelfDrawingNodeType selfDrawingType, +ErrCode RSClientToRenderConnection::SetHardwareEnabled(NodeId id, bool isEnabled, SelfDrawingNodeType selfDrawingType, bool dynamicHardwareEnable) { if (!mainThread_) { return ERR_INVALID_VALUE; } - auto task = [weakThis = wptr(this), id, isEnabled, selfDrawingType, + auto task = [weakThis = wptr(this), id, isEnabled, selfDrawingType, dynamicHardwareEnable]() -> void { - sptr connection = weakThis.promote(); + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -2941,14 +2251,14 @@ ErrCode RSRenderServiceConnection::SetHardwareEnabled(NodeId id, bool isEnabled, return ERR_OK; } -ErrCode RSRenderServiceConnection::SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent, uint32_t& resCode) +ErrCode RSClientToRenderConnection::SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent, uint32_t& resCode) { if (!mainThread_) { resCode = static_cast(RSInterfaceErrorCode::UNKNOWN_ERROR); return ERR_INVALID_VALUE; } - auto task = [weakThis = wptr(this), id, needHidePrivacyContent]() -> void { - sptr connection = weakThis.promote(); + auto task = [weakThis = wptr(this), id, needHidePrivacyContent]() -> void { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -2963,7 +2273,7 @@ ErrCode RSRenderServiceConnection::SetHidePrivacyContent(NodeId id, bool needHid return ERR_OK; } -ErrCode RSRenderServiceConnection::SetCacheEnabledForRotation(bool isEnabled) +ErrCode RSClientToRenderConnection::SetCacheEnabledForRotation(bool isEnabled) { if (!mainThread_) { return ERR_INVALID_VALUE; @@ -2975,7 +2285,7 @@ ErrCode RSRenderServiceConnection::SetCacheEnabledForRotation(bool isEnabled) return ERR_OK; } -std::vector RSRenderServiceConnection::GetActiveDirtyRegionInfo() +std::vector RSClientToRenderConnection::GetActiveDirtyRegionInfo() { #ifdef RS_ENABLE_GPU const auto& activeDirtyRegionInfos = GpuDirtyRegionCollection::GetInstance().GetActiveDirtyRegionInfo(); @@ -2986,7 +2296,7 @@ std::vector RSRenderServiceConnection::GetActiveDirtyRegi #endif } -GlobalDirtyRegionInfo RSRenderServiceConnection::GetGlobalDirtyRegionInfo() +GlobalDirtyRegionInfo RSClientToRenderConnection::GetGlobalDirtyRegionInfo() { #ifdef RS_ENABLE_GPU const auto& globalDirtyRegionInfo = GpuDirtyRegionCollection::GetInstance().GetGlobalDirtyRegionInfo(); @@ -2997,19 +2307,7 @@ GlobalDirtyRegionInfo RSRenderServiceConnection::GetGlobalDirtyRegionInfo() #endif } -LayerComposeInfo RSRenderServiceConnection::GetLayerComposeInfo() -{ - const auto& layerComposeInfo = LayerComposeCollection::GetInstance().GetLayerComposeInfo(); - LayerComposeCollection::GetInstance().ResetLayerComposeInfo(); - return layerComposeInfo; -} - -HwcDisabledReasonInfos RSRenderServiceConnection::GetHwcDisabledReasonInfo() -{ - return HwcDisabledReasonCollection::GetInstance().GetHwcDisabledReasonInfo(); -} - -ErrCode RSRenderServiceConnection::GetHdrOnDuration(int64_t& hdrOnDuration) +ErrCode RSClientToRenderConnection::GetHdrOnDuration(int64_t& hdrOnDuration) { auto rsHdrCollection = RsHdrCollection::GetInstance(); if (rsHdrCollection == nullptr) { @@ -3020,7 +2318,7 @@ ErrCode RSRenderServiceConnection::GetHdrOnDuration(int64_t& hdrOnDuration) return ERR_OK; } -ErrCode RSRenderServiceConnection::SetVmaCacheStatus(bool flag) +ErrCode RSClientToRenderConnection::SetVmaCacheStatus(bool flag) { #ifdef RS_ENABLE_GPU renderThread_.SetVmaCacheStatus(flag); @@ -3029,7 +2327,7 @@ ErrCode RSRenderServiceConnection::SetVmaCacheStatus(bool flag) } #ifdef TP_FEATURE_ENABLE -ErrCode RSRenderServiceConnection::SetTpFeatureConfig(int32_t feature, const char* config, +ErrCode RSClientToRenderConnection::SetTpFeatureConfig(int32_t feature, const char* config, TpFeatureConfigType tpFeatureConfigType) { switch (tpFeatureConfigType) { @@ -3056,7 +2354,7 @@ ErrCode RSRenderServiceConnection::SetTpFeatureConfig(int32_t feature, const cha } #endif -void RSRenderServiceConnection::SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus) +void RSClientToRenderConnection::SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus) { if (isVirtualScreenUsingStatus) { EventInfo event = { "VOTER_VIRTUALDISPLAY", ADD_VOTE, OLED_60_HZ, OLED_60_HZ }; @@ -3068,13 +2366,13 @@ void RSRenderServiceConnection::SetVirtualScreenUsingStatus(bool isVirtualScreen return; } -ErrCode RSRenderServiceConnection::SetCurtainScreenUsingStatus(bool isCurtainScreenOn) +ErrCode RSClientToRenderConnection::SetCurtainScreenUsingStatus(bool isCurtainScreenOn) { if (!mainThread_) { return ERR_INVALID_VALUE; } - auto task = [weakThis = wptr(this), isCurtainScreenOn]() -> void { - sptr connection = weakThis.promote(); + auto task = [weakThis = wptr(this), isCurtainScreenOn]() -> void { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -3084,15 +2382,15 @@ ErrCode RSRenderServiceConnection::SetCurtainScreenUsingStatus(bool isCurtainScr return ERR_OK; } -ErrCode RSRenderServiceConnection::DropFrameByPid(const std::vector pidList) +ErrCode RSClientToRenderConnection::DropFrameByPid(const std::vector pidList) { if (!mainThread_) { return ERR_INVALID_VALUE; } mainThread_->ScheduleTask( - [weakThis = wptr(this), pidList]() { + [weakThis = wptr(this), pidList]() { // don't use 'this' directly - sptr connection = weakThis.promote(); + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -3102,7 +2400,7 @@ ErrCode RSRenderServiceConnection::DropFrameByPid(const std::vector pid return ERR_OK; } -int32_t RSRenderServiceConnection::RegisterUIExtensionCallback(uint64_t userId, sptr callback, +int32_t RSClientToRenderConnection::RegisterUIExtensionCallback(uint64_t userId, sptr callback, bool unobscured) { std::lock_guard lock(mutex_); @@ -3117,7 +2415,7 @@ int32_t RSRenderServiceConnection::RegisterUIExtensionCallback(uint64_t userId, return StatusCode::SUCCESS; } -ErrCode RSRenderServiceConnection::SetVirtualScreenStatus(ScreenId id, +ErrCode RSClientToRenderConnection::SetVirtualScreenStatus(ScreenId id, VirtualScreenStatus screenStatus, bool& success) { if (!screenManager_) { @@ -3130,7 +2428,7 @@ ErrCode RSRenderServiceConnection::SetVirtualScreenStatus(ScreenId id, return StatusCode::SUCCESS; } -ErrCode RSRenderServiceConnection::SetAncoForceDoDirect(bool direct, bool& res) +ErrCode RSClientToRenderConnection::SetAncoForceDoDirect(bool direct, bool& res) { std::lock_guard lock(mutex_); if (mainThread_ == nullptr) { @@ -3142,7 +2440,7 @@ ErrCode RSRenderServiceConnection::SetAncoForceDoDirect(bool direct, bool& res) return ERR_OK; } -void RSRenderServiceConnection::SetFreeMultiWindowStatus(bool enable) +void RSClientToRenderConnection::SetFreeMultiWindowStatus(bool enable) { #ifdef RS_ENABLE_GPU if (mainThread_ == nullptr) { @@ -3155,78 +2453,26 @@ void RSRenderServiceConnection::SetFreeMultiWindowStatus(bool enable) #endif } -ErrCode RSRenderServiceConnection::RegisterSurfaceBufferCallback(pid_t pid, uint64_t uid, +ErrCode RSClientToRenderConnection::RegisterSurfaceBufferCallback(pid_t pid, uint64_t uid, sptr callback) { RSSurfaceBufferCallbackManager::Instance().RegisterSurfaceBufferCallback(pid, uid, callback); return ERR_OK; } -ErrCode RSRenderServiceConnection::UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid) +ErrCode RSClientToRenderConnection::UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid) { RSSurfaceBufferCallbackManager::Instance().UnregisterSurfaceBufferCallback(pid, uid); return ERR_OK; } -ErrCode RSRenderServiceConnection::SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder) -{ - if (mainThread_ == nullptr) { - return ERR_INVALID_VALUE; - } - auto task = [weakThis = wptr(this), nodeId, isTop, zOrder]() -> void { - sptr connection = weakThis.promote(); - if (connection == nullptr || connection->mainThread_ == nullptr) { - return; - } - auto& context = connection->mainThread_->GetContext(); - auto surfaceNode = context.GetNodeMap().GetRenderNode(nodeId); - if (surfaceNode == nullptr) { - return; - } - surfaceNode->SetLayerTop(isTop, false); - surfaceNode->SetTopLayerZOrder(zOrder); - // It can be displayed immediately after layer-top changed. - connection->mainThread_->SetDirtyFlag(); - connection->mainThread_->RequestNextVSync(); - }; - mainThread_->PostTask(task); - return ERR_OK; -} - -ErrCode RSRenderServiceConnection::SetLayerTop(const std::string &nodeIdStr, bool isTop) -{ - if (mainThread_ == nullptr) { - return ERR_INVALID_VALUE; - } - auto task = [weakThis = wptr(this), nodeIdStr, isTop]() -> void { - sptr connection = weakThis.promote(); - if (connection == nullptr || connection->mainThread_ == nullptr) { - return; - } - auto& context = connection->mainThread_->GetContext(); - context.GetNodeMap().TraverseSurfaceNodes( - [&nodeIdStr, &isTop](const std::shared_ptr& surfaceNode) mutable { - if ((surfaceNode != nullptr) && (surfaceNode->GetName() == nodeIdStr) && - (surfaceNode->GetSurfaceNodeType() == RSSurfaceNodeType::SELF_DRAWING_NODE)) { - surfaceNode->SetLayerTop(isTop); - return; - } - }); - // It can be displayed immediately after layer-top changed. - connection->mainThread_->SetDirtyFlag(); - connection->mainThread_->RequestNextVSync(); - }; - mainThread_->PostTask(task); - return ERR_OK; -} - -ErrCode RSRenderServiceConnection::SetForceRefresh(const std::string &nodeIdStr, bool isForceRefresh) +ErrCode RSClientToRenderConnection::SetForceRefresh(const std::string &nodeIdStr, bool isForceRefresh) { if (mainThread_ == nullptr) { return ERR_INVALID_VALUE; } - auto task = [weakThis = wptr(this), nodeIdStr, isForceRefresh]() -> void { - sptr connection = weakThis.promote(); + auto task = [weakThis = wptr(this), nodeIdStr, isForceRefresh]() -> void { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -3244,19 +2490,19 @@ ErrCode RSRenderServiceConnection::SetForceRefresh(const std::string &nodeIdStr, return ERR_OK; } -void RSRenderServiceConnection::RegisterTransactionDataCallback(uint64_t token, +void RSClientToRenderConnection::RegisterTransactionDataCallback(uint64_t token, uint64_t timeStamp, sptr callback) { RSTransactionDataCallbackManager::Instance().RegisterTransactionDataCallback(token, timeStamp, callback); } -void RSRenderServiceConnection::SetColorFollow(const std::string &nodeIdStr, bool isColorFollow) +void RSClientToRenderConnection::SetColorFollow(const std::string &nodeIdStr, bool isColorFollow) { if (mainThread_ == nullptr) { return; } - auto task = [weakThis = wptr(this), nodeIdStr, isColorFollow]() -> void { - sptr connection = weakThis.promote(); + auto task = [weakThis = wptr(this), nodeIdStr, isColorFollow]() -> void { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -3275,26 +2521,13 @@ void RSRenderServiceConnection::SetColorFollow(const std::string &nodeIdStr, boo mainThread_->PostTask(task); } -ErrCode RSRenderServiceConnection::NotifyScreenSwitched() -{ - std::lock_guard lock(mutex_); - if (!screenManager_) { - RS_LOGE("NotifyScreenSwitched screenManager_ is nullptr"); - return ERR_INVALID_VALUE; - } - RS_LOGI("NotifyScreenSwitched SetScreenSwitchStatus true"); - RS_TRACE_NAME_FMT("NotifyScreenSwitched"); - screenManager_->SetScreenSwitchStatus(true); - return ERR_OK; -} - -ErrCode RSRenderServiceConnection::SetWindowContainer(NodeId nodeId, bool value) +ErrCode RSClientToRenderConnection::SetWindowContainer(NodeId nodeId, bool value) { if (!mainThread_) { return ERR_INVALID_VALUE; } - auto task = [weakThis = wptr(this), nodeId, value]() -> void { - sptr connection = weakThis.promote(); + auto task = [weakThis = wptr(this), nodeId, value]() -> void { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -3318,84 +2551,32 @@ ErrCode RSRenderServiceConnection::SetWindowContainer(NodeId nodeId, bool value) return ERR_OK; } -int32_t RSRenderServiceConnection::RegisterSelfDrawingNodeRectChangeCallback( - const RectConstraint& constraint, sptr callback) -{ - std::lock_guard lock(mutex_); - - if (!mainThread_) { - return StatusCode::INVALID_ARGUMENTS; - } - if (!callback) { - RS_LOGE("RegisterSelfDrawingNodeRectChangeCallback register null callback, failed."); - return StatusCode::INVALID_ARGUMENTS; - } - - auto task = [pid = remotePid_, constraint, callback]() { - SelfDrawingNodeMonitor::GetInstance().RegisterRectChangeCallback(pid, constraint, callback); - }; - mainThread_->PostTask(task); - return StatusCode::SUCCESS; -} - -int32_t RSRenderServiceConnection::UnRegisterSelfDrawingNodeRectChangeCallback() -{ - std::lock_guard lock(mutex_); - - if (!mainThread_) { - return StatusCode::INVALID_ARGUMENTS; - } - auto task = [pid = remotePid_]() { SelfDrawingNodeMonitor::GetInstance().UnRegisterRectChangeCallback(pid); }; - mainThread_->PostTask(task); - return StatusCode::SUCCESS; -} - -#ifdef RS_ENABLE_OVERLAY_DISPLAY -ErrCode RSRenderServiceConnection::SetOverlayDisplayMode(int32_t mode) -{ - RS_LOGI("SetOverlayDisplayMode: mode: [%{public}d]", mode); - return RSOverlayDisplayManager::Instance().SetOverlayDisplayMode(mode) == 0 ? ERR_OK : ERR_INVALID_VALUE; -} -#endif - -ErrCode RSRenderServiceConnection::NotifyPageName(const std::string &packageName, - const std::string &pageName, bool isEnter) -{ - HgmTaskHandleThread::Instance().PostTask([pid = remotePid_, packageName, pageName, isEnter]() { - auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); - if (frameRateMgr != nullptr) { - frameRateMgr->NotifyPageName(pid, packageName, pageName, isEnter); - } - }); - return StatusCode::SUCCESS; -} - -bool RSRenderServiceConnection::GetHighContrastTextState() +bool RSClientToRenderConnection::GetHighContrastTextState() { return RSBaseRenderEngine::IsHighContrastEnabled(); } -ErrCode RSRenderServiceConnection::AvcodecVideoStart( +ErrCode RSClientToRenderConnection::AvcodecVideoStart( uint64_t uniqueId, std::string& surfaceName, uint32_t fps, uint64_t reportTime) { RSJankStats::GetInstance().AvcodecVideoStart(uniqueId, surfaceName, fps, reportTime); return ERR_OK; } -ErrCode RSRenderServiceConnection::AvcodecVideoStop(uint64_t uniqueId, std::string& surfaceName, uint32_t fps) +ErrCode RSClientToRenderConnection::AvcodecVideoStop(uint64_t uniqueId, std::string& surfaceName, uint32_t fps) { RSJankStats::GetInstance().AvcodecVideoStop(uniqueId, surfaceName, fps); return ERR_OK; } -ErrCode RSRenderServiceConnection::SetBehindWindowFilterEnabled(bool enabled) +ErrCode RSClientToRenderConnection::SetBehindWindowFilterEnabled(bool enabled) { if (!mainThread_) { RS_LOGE("SetBehindWindowFilterEnabled mainThread_ is nullptr."); return ERR_INVALID_VALUE; } - auto task = [weakThis = wptr(this), enabled]() -> void { - sptr connection = weakThis.promote(); + auto task = [weakThis = wptr(this), enabled]() -> void { + sptr connection = weakThis.promote(); if (connection == nullptr || connection->mainThread_ == nullptr) { return; } @@ -3425,27 +2606,27 @@ ErrCode RSRenderServiceConnection::SetBehindWindowFilterEnabled(bool enabled) return ERR_OK; } -ErrCode RSRenderServiceConnection::GetBehindWindowFilterEnabled(bool& enabled) +ErrCode RSClientToRenderConnection::GetBehindWindowFilterEnabled(bool& enabled) { enabled = RSSystemProperties::GetBehindWindowFilterEnabled(); return ERR_OK; } -int32_t RSRenderServiceConnection::GetPidGpuMemoryInMB(pid_t pid, float &gpuMemInMB) +int32_t RSClientToRenderConnection::GetPidGpuMemoryInMB(pid_t pid, float &gpuMemInMB) { MemorySnapshotInfo memorySnapshotInfo; bool ret = MemorySnapshot::Instance().GetMemorySnapshotInfoByPid(pid, memorySnapshotInfo); if (!ret) { - RS_LOGD("RSRenderServiceConnection::GetPidGpuMemoryInMB fail to find pid!"); + RS_LOGD("RSClientToRenderConnection::GetPidGpuMemoryInMB fail to find pid!"); return ERR_INVALID_VALUE; } gpuMemInMB = static_cast(memorySnapshotInfo.gpuMemory) / MEM_BYTE_TO_MB; - RS_LOGD("RSRenderServiceConnection::GetPidGpuMemoryInMB called succ"); + RS_LOGD("RSClientToRenderConnection::GetPidGpuMemoryInMB called succ"); return ERR_OK; } -RetCodeHrpService RSRenderServiceConnection::ProfilerServiceOpenFile(const HrpServiceDirInfo& dirInfo, +RetCodeHrpService RSClientToRenderConnection::ProfilerServiceOpenFile(const HrpServiceDirInfo& dirInfo, const std::string& fileName, int32_t flags, int& outFd) { #ifdef RS_PROFILER_ENABLED @@ -3460,7 +2641,7 @@ RetCodeHrpService RSRenderServiceConnection::ProfilerServiceOpenFile(const HrpSe #endif } -RetCodeHrpService RSRenderServiceConnection::ProfilerServicePopulateFiles(const HrpServiceDirInfo& dirInfo, +RetCodeHrpService RSClientToRenderConnection::ProfilerServicePopulateFiles(const HrpServiceDirInfo& dirInfo, uint32_t firstFileIndex, std::vector& outFiles) { #ifdef RS_PROFILER_ENABLED @@ -3471,7 +2652,7 @@ RetCodeHrpService RSRenderServiceConnection::ProfilerServicePopulateFiles(const #endif } -bool RSRenderServiceConnection::ProfilerIsSecureScreen() +bool RSClientToRenderConnection::ProfilerIsSecureScreen() { #ifdef RS_PROFILER_ENABLED if (!RSSystemProperties::GetProfilerEnabled()) { @@ -3483,7 +2664,7 @@ bool RSRenderServiceConnection::ProfilerIsSecureScreen() #endif } -void RSRenderServiceConnection::ClearUifirstCache(NodeId id) +void RSClientToRenderConnection::ClearUifirstCache(NodeId id) { if (!mainThread_) { return; diff --git a/rosen/modules/render_service/core/pipeline/main_thread/rs_render_service_connection.h b/rosen/modules/render_service/core/pipeline/main_thread/rs_client_to_render_connection.h similarity index 75% rename from rosen/modules/render_service/core/pipeline/main_thread/rs_render_service_connection.h rename to rosen/modules/render_service/core/pipeline/main_thread/rs_client_to_render_connection.h index 76312f1fb2839dbf56f77aac38d5c1870b5f2b4e..86f4c095aa441332b8496e7402520150846016db 100644 --- a/rosen/modules/render_service/core/pipeline/main_thread/rs_render_service_connection.h +++ b/rosen/modules/render_service/core/pipeline/main_thread/rs_client_to_render_connection.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef RENDER_SERVICE_PIPELINE_RS_RENDER_SERVICE_CONNECTION_H -#define RENDER_SERVICE_PIPELINE_RS_RENDER_SERVICE_CONNECTION_H +#ifndef RENDER_SERVICE_PIPELINE_RS_CLIENT_TO_RENDER_CONNECTION_H +#define RENDER_SERVICE_PIPELINE_RS_CLIENT_TO_RENDER_CONNECTION_H #include #include @@ -24,26 +24,26 @@ #include "ipc_callbacks/buffer_clear_callback.h" #include "pipeline/hardware_thread/rs_hardware_thread.h" #include "pipeline/render_thread/rs_uni_render_thread.h" -#include "../../main/server/rs_render_service.h" +#include "pipeline/main_thread/rs_render_service.h" #include "screen_manager/rs_screen_manager.h" -#include "transaction/rs_render_service_connection_stub.h" +#include "transaction/rs_client_to_render_connection_stub.h" #include "vsync_distributor.h" namespace OHOS { namespace Rosen { class HgmFrameRateManager; -class RSRenderServiceConnection : public RSRenderServiceConnectionStub { +class RSClientToRenderConnection : public RSClientToRenderConnectionStub { public: - RSRenderServiceConnection( + RSClientToRenderConnection( pid_t remotePid, wptr renderService, RSMainThread* mainThread, sptr screenManager, sptr token, sptr distributor); - ~RSRenderServiceConnection() noexcept; - RSRenderServiceConnection(const RSRenderServiceConnection&) = delete; - RSRenderServiceConnection& operator=(const RSRenderServiceConnection&) = delete; + ~RSClientToRenderConnection() noexcept; + RSClientToRenderConnection(const RSClientToRenderConnection&) = delete; + RSClientToRenderConnection& operator=(const RSClientToRenderConnection&) = delete; sptr GetToken() const { @@ -57,7 +57,7 @@ private: void CleanFrameRateLinkerExpectedFpsCallbacks() noexcept; void CleanAll(bool toDelete = false) noexcept; - // IPC RSIRenderServiceConnection Interfaces + // IPC RSIClientToRenderConnection Interfaces ErrCode CommitTransaction(std::unique_ptr& transactionData) override; ErrCode ExecuteSynchronousTask(const std::shared_ptr& task) override; ErrCode GetMemoryGraphic(int pid, MemoryGraphic& memoryGraphic) override; @@ -70,11 +70,6 @@ private: ErrCode CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, sptr& sfc, bool unobscured = false) override; - ErrCode CreateVSyncConnection(sptr& vsyncConn, - const std::string& name, - const sptr& token, - VSyncConnParam vsyncConnParam = {0, 0, false}) override; - ErrCode GetPixelMapByProcessId(std::vector& pixelMapInfoVector, pid_t pid, int32_t& repCode) override; ErrCode CreatePixelMapFromSurface(sptr surface, @@ -82,21 +77,6 @@ private: ErrCode SetFocusAppInfo(const FocusAppInfo& info, int32_t& repCode) override; - ErrCode GetDefaultScreenId(uint64_t& screenId) override; - - ErrCode GetActiveScreenId(uint64_t& screenId) override; - - std::vector GetAllScreenIds() override; - - ScreenId CreateVirtualScreen( - const std::string &name, - uint32_t width, - uint32_t height, - sptr surface, - ScreenId mirrorId = 0, - int32_t flags = 0, - std::vector whiteList = {}) override; - int32_t SetVirtualScreenBlackList(ScreenId id, std::vector& blackListVector) override; ErrCode SetVirtualScreenTypeBlackList( @@ -115,7 +95,7 @@ private: int32_t SetMirrorScreenVisibleRect(ScreenId id, const Rect& mainScreenRect, bool supportRotation = false) override; int32_t SetCastScreenEnableSkipWindow(ScreenId id, bool enable) override; - + int32_t SetVirtualScreenSurface(ScreenId id, sptr surface) override; void RemoveVirtualScreen(ScreenId id) override; @@ -131,31 +111,13 @@ private: int32_t UnRegisterPointerLuminanceChangeCallback() override; #endif - int32_t SetScreenChangeCallback(sptr callback) override; - void SetScreenActiveMode(ScreenId id, uint32_t modeId) override; - void SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate) override; - - void SetRefreshRateMode(int32_t refreshRateMode) override; - void SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range, int32_t animatorExpectedFrameRate) override; void UnregisterFrameRateLinker(FrameRateLinkerId id) override; - uint32_t GetScreenCurrentRefreshRate(ScreenId id) override; - - int32_t GetCurrentRefreshRateMode() override; - - std::vector GetScreenSupportedRefreshRates(ScreenId id) override; - - ErrCode GetShowRefreshRateEnabled(bool& enable) override; - - void SetShowRefreshRateEnabled(bool enabled, int32_t type) override; - - uint32_t GetRealtimeRefreshRate(ScreenId screenId) override; - ErrCode GetRefreshInfo(pid_t pid, std::string& enable) override; ErrCode GetRefreshInfoToSP(NodeId id, std::string& enable) override; @@ -171,8 +133,6 @@ private: void DisablePowerOffRenderControl(ScreenId id) override; - void SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status) override; - void TakeSurfaceCapture(NodeId id, sptr callback, const RSSurfaceCaptureConfig& captureConfig, const RSSurfaceCaptureBlurParam& blurParam, const Drawing::Rect& specifiedAreaRect = Drawing::Rect(0.f, 0.f, 0.f, 0.f), @@ -196,42 +156,16 @@ private: ErrCode RegisterApplicationAgent(uint32_t pid, sptr app) override; - void UnRegisterApplicationAgent(sptr app); - RSVirtualScreenResolution GetVirtualScreenResolution(ScreenId id) override; ErrCode GetScreenActiveMode(uint64_t id, RSScreenModeInfo& info) override; - std::vector GetScreenSupportedModes(ScreenId id) override; - - RSScreenCapability GetScreenCapability(ScreenId id) override; - - ErrCode GetScreenPowerStatus(uint64_t screenId, uint32_t& status) override; - - RSScreenData GetScreenData(ScreenId id) override; - - ErrCode GetScreenBacklight(uint64_t id, int32_t& level) override; - - void SetScreenBacklight(ScreenId id, uint32_t level) override; - ErrCode RegisterBufferAvailableListener( NodeId id, sptr callback, bool isFromRenderThread) override; ErrCode RegisterBufferClearListener( NodeId id, sptr callback) override; - int32_t GetScreenSupportedColorGamuts(ScreenId id, std::vector& mode) override; - - int32_t GetScreenSupportedMetaDataKeys(ScreenId id, std::vector& keys) override; - - int32_t GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode) override; - - int32_t SetScreenColorGamut(ScreenId id, int32_t modeIdx) override; - - int32_t SetScreenGamutMap(ScreenId id, ScreenGamutMap mode) override; - - int32_t SetScreenCorrection(ScreenId id, ScreenRotation screenRotation) override; - bool SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation) override; int32_t SetVirtualScreenAutoRotation(ScreenId id, bool isAutoRotation) override; @@ -240,8 +174,6 @@ private: ErrCode SetGlobalDarkColorMode(bool isDark) override; - int32_t GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode) override; - int32_t GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability) override; ErrCode GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat, int32_t& resCode) override; @@ -260,27 +192,17 @@ private: ErrCode GetScreenSupportedColorSpaces( ScreenId id, std::vector& colorSpaces, int32_t& resCode) override; - ErrCode GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace, int32_t& resCode) override; - - ErrCode SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace, int32_t& resCode) override; - - int32_t GetScreenType(ScreenId id, RSScreenType& screenType) override; - ErrCode GetBitmap(NodeId id, Drawing::Bitmap& bitmap, bool& success) override; ErrCode GetPixelmap(NodeId id, std::shared_ptr pixelmap, const Drawing::Rect* rect, std::shared_ptr drawCmdList, bool& success) override; bool RegisterTypeface(uint64_t globalUniqueId, std::shared_ptr& typeface) override; bool UnRegisterTypeface(uint64_t globalUniqueId) override; - int32_t GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, std::vector& edidData) override; - ErrCode SetScreenSkipFrameInterval(uint64_t id, uint32_t skipFrameInterval, int32_t& resCode) override; ErrCode SetVirtualScreenRefreshRate( ScreenId id, uint32_t maxRefreshRate, uint32_t& actualRefreshRate, int32_t& retVal) override; - ErrCode SetScreenActiveRect(ScreenId id, const Rect& activeRect, uint32_t& repCode) override; - void SetScreenOffset(ScreenId id, int32_t offsetX, int32_t offsetY) override; void SetScreenFrameGravity(ScreenId id, int32_t gravity) override; @@ -340,20 +262,10 @@ private: void NotifyAppStrategyConfigChangeEvent(const std::string& pkgName, uint32_t listSize, const std::vector>& newConfig) override; - void NotifyRefreshRateEvent(const EventInfo& eventInfo) override; - - void SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) override; - - void SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) override; - ErrCode NotifySoftVsyncEvent(uint32_t pid, uint32_t rateDiscount) override; bool NotifySoftVsyncRateDiscountEvent(uint32_t pid, const std::string &name, uint32_t rateDiscount) override; - ErrCode NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt) override; - - void NotifyDynamicModeEvent(bool enableDynamicModeEvent) override; - ErrCode NotifyHgmConfigEvent(const std::string &eventName, bool state) override; ErrCode NotifyXComponentExpectedFrameRate(const std::string& id, int32_t expectedFrameRate) override; @@ -366,10 +278,6 @@ private: GlobalDirtyRegionInfo GetGlobalDirtyRegionInfo() override; - LayerComposeInfo GetLayerComposeInfo() override; - - HwcDisabledReasonInfos GetHwcDisabledReasonInfo() override; - ErrCode GetHdrOnDuration(int64_t& hdrOnDuration) override; ErrCode SetVmaCacheStatus(bool flag) override; @@ -390,10 +298,6 @@ private: void SetFreeMultiWindowStatus(bool enable) override; - ErrCode SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder) override; - - ErrCode SetLayerTop(const std::string &nodeIdStr, bool isTop) override; - ErrCode SetForceRefresh(const std::string &nodeIdStr, bool isForceRefresh) override; void RegisterTransactionDataCallback(uint64_t token, @@ -405,21 +309,8 @@ private: sptr callback) override; ErrCode UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid) override; - ErrCode NotifyScreenSwitched() override; - ErrCode SetWindowContainer(NodeId nodeId, bool value) override; - int32_t RegisterSelfDrawingNodeRectChangeCallback( - const RectConstraint& constraint, sptr callback) override; - - int32_t UnRegisterSelfDrawingNodeRectChangeCallback() override; - -#ifdef RS_ENABLE_OVERLAY_DISPLAY - ErrCode SetOverlayDisplayMode(int32_t mode) override; -#endif - - ErrCode NotifyPageName(const std::string &packageName, const std::string &pageName, bool isEnter) override; - bool GetHighContrastTextState() override; ErrCode SetBehindWindowFilterEnabled(bool enabled) override; @@ -451,26 +342,26 @@ private: class RSConnectionDeathRecipient : public IRemoteObject::DeathRecipient { public: - explicit RSConnectionDeathRecipient(wptr conn); + explicit RSConnectionDeathRecipient(wptr conn); virtual ~RSConnectionDeathRecipient() = default; void OnRemoteDied(const wptr& token) override; private: - wptr conn_; + wptr conn_; }; friend class RSConnectionDeathRecipient; sptr connDeathRecipient_; class RSApplicationRenderThreadDeathRecipient : public IRemoteObject::DeathRecipient { public: - explicit RSApplicationRenderThreadDeathRecipient(wptr conn); + explicit RSApplicationRenderThreadDeathRecipient(wptr conn); virtual ~RSApplicationRenderThreadDeathRecipient() = default; void OnRemoteDied(const wptr& token) override; private: - wptr conn_; + wptr conn_; }; friend class RSApplicationRenderThreadDeathRecipient; sptr applicationDeathRecipient_ = nullptr; @@ -492,4 +383,4 @@ private: } // namespace Rosen } // namespace OHOS -#endif // RENDER_SERVICE_PIPELINE_RS_RENDER_SERVICE_CONNECTION_H +#endif // RENDER_SERVICE_PIPELINE_RS_CLIENT_TO_RENDER_CONNECTION_H diff --git a/rosen/modules/render_service/core/pipeline/main_thread/rs_client_to_service_connection.cpp b/rosen/modules/render_service/core/pipeline/main_thread/rs_client_to_service_connection.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a4eb29dfab921346882f1d84ad3329d2b19487fb --- /dev/null +++ b/rosen/modules/render_service/core/pipeline/main_thread/rs_client_to_service_connection.cpp @@ -0,0 +1,2013 @@ +/* + * Copyright (c) 2021-2023 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. + */ + +#include "rs_client_to_service_connection.h" +#include + +#include "frame_report.h" +#include "hgm_command.h" +#include "hgm_core.h" +#include "hgm_frame_rate_manager.h" +#include "offscreen_render/rs_offscreen_render_thread.h" +#include "rs_frame_report.h" +#include "rs_main_thread.h" +#include "rs_trace.h" +#include "rs_profiler.h" +//blur predict +#include "rs_frame_blur_predict.h" +#include "system/rs_system_parameters.h" + +#include "command/rs_command_verify_helper.h" +#include "command/rs_display_node_command.h" +#include "command/rs_surface_node_command.h" +#include "common/rs_background_thread.h" +#include "display_engine/rs_luminance_control.h" +#include "drawable/rs_canvas_drawing_render_node_drawable.h" +#include "feature/capture/rs_ui_capture.h" +#include "feature/capture/rs_uni_ui_capture.h" +#include "feature/capture/rs_surface_capture_task.h" +#include "feature/capture/rs_ui_capture_task_parallel.h" +#include "feature/capture/rs_ui_capture_solo_task_parallel.h" +#include "feature/capture/rs_surface_capture_task_parallel.h" +#include "feature/uifirst/rs_uifirst_frame_rate_control.h" +#include "gfx/fps_info/rs_surface_fps_manager.h" +#include "gfx/first_frame_notifier/rs_first_frame_notifier.h" +#ifdef RS_ENABLE_OVERLAY_DISPLAY +#include "feature/overlay_display/rs_overlay_display_manager.h" +#endif +#ifdef USE_M133_SKIA +#include "include/gpu/ganesh/GrDirectContext.h" +#else +#include "include/gpu/GrDirectContext.h" +#endif +#include "info_collection/rs_hdr_collection.h" +#ifdef RS_ENABLE_GPU +#include "feature/uifirst/rs_sub_thread_manager.h" +#endif +#include "feature/uifirst/rs_uifirst_manager.h" +#include "memory/rs_memory_manager.h" +#include "monitor/self_drawing_node_monitor.h" +#include "pipeline/rs_canvas_drawing_render_node.h" +#include "pipeline/rs_pointer_window_manager.h" +#ifdef OHOS_BUILD_ENABLE_MAGICCURSOR +#include "pipeline/magic_pointer_render/rs_magic_pointer_render_manager.h" +#endif +#include "pipeline/hardware_thread/rs_realtime_refresh_rate_manager.h" +#include "pipeline/rs_render_frame_rate_linker_map.h" +#include "pipeline/rs_render_node_gc.h" +#include "pipeline/rs_render_node_map.h" +#include "pipeline/main_thread/rs_render_service_listener.h" +#include "pipeline/rs_surface_buffer_callback_manager.h" +#include "pipeline/rs_surface_render_node.h" +#include "pipeline/rs_task_dispatcher.h" +#include "pipeline/rs_uni_render_judgement.h" +#include "pixel_map_from_surface.h" +#include "platform/common/rs_log.h" +#include "platform/common/rs_system_properties.h" +#include "platform/ohos/rs_jank_stats_helper.h" +#include "render/rs_typeface_cache.h" +#include "transaction/rs_unmarshal_thread.h" +#include "transaction/rs_transaction_data_callback_manager.h" + +#ifdef TP_FEATURE_ENABLE +#include "screen_manager/touch_screen.h" +#endif + +#ifdef RS_ENABLE_VK +#include "platform/ohos/backend/rs_vulkan_context.h" +#endif + +#undef LOG_TAG +#define LOG_TAG "RSClientToServiceConnection" + +namespace OHOS { +namespace Rosen { +namespace { +constexpr int SLEEP_TIME_US = 1000; +const std::string REGISTER_NODE = "RegisterNode"; +const std::string APS_SET_VSYNC = "APS_SET_VSYNC"; +constexpr uint32_t MEM_BYTE_TO_MB = 1024 * 1024; +} +// we guarantee that when constructing this object, +// all these pointers are valid, so will not check them. +RSClientToServiceConnection::RSClientToServiceConnection( + pid_t remotePid, + wptr renderService, + RSMainThread* mainThread, + sptr screenManager, + sptr token, + sptr distributor) + : remotePid_(remotePid), + renderService_(renderService), + mainThread_(mainThread), +#ifdef RS_ENABLE_GPU + renderThread_(RSUniRenderThread::Instance()), +#endif + screenManager_(screenManager), + token_(token), + connDeathRecipient_(new RSConnectionDeathRecipient(this)), + applicationDeathRecipient_(new RSApplicationRenderThreadDeathRecipient(this)), + appVSyncDistributor_(distributor) +{ + if (token_ == nullptr || !token_->AddDeathRecipient(connDeathRecipient_)) { + RS_LOGW("RSClientToServiceConnection: Failed to set death recipient."); + } + if (renderService_ == nullptr) { + RS_LOGW("RSClientToServiceConnection: renderService_ is nullptr"); + } + if (mainThread_ == nullptr) { + RS_LOGW("RSClientToServiceConnection: mainThread_ is nullptr"); + } + if (screenManager_ == nullptr) { + RS_LOGW("RSClientToServiceConnection: screenManager_ is nullptr"); + } + if (appVSyncDistributor_ == nullptr) { + RS_LOGW("RSClientToServiceConnection: appVSyncDistributor_ is nullptr"); + } +} + +RSClientToServiceConnection::~RSClientToServiceConnection() noexcept +{ + if (token_ && connDeathRecipient_) { + token_->RemoveDeathRecipient(connDeathRecipient_); + } + CleanAll(); +} + +void RSClientToServiceConnection::CleanVirtualScreens() noexcept +{ + std::lock_guard lock(mutex_); + + if (screenManager_ != nullptr) { + for (const auto id : virtualScreenIds_) { + screenManager_->RemoveVirtualScreen(id); + } + } + virtualScreenIds_.clear(); + + if (screenChangeCallback_ != nullptr && screenManager_ != nullptr) { + screenManager_->RemoveScreenChangeCallback(screenChangeCallback_); + screenChangeCallback_ = nullptr; + } +} + +void RSClientToServiceConnection::CleanRenderNodes() noexcept +{ + if (mainThread_ == nullptr) { + return; + } + auto& context = mainThread_->GetContext(); + auto& nodeMap = context.GetMutableNodeMap(); + + nodeMap.FilterNodeByPid(remotePid_); +} + +void RSClientToServiceConnection::CleanFrameRateLinkers() noexcept +{ + if (mainThread_ == nullptr) { + return; + } + auto& context = mainThread_->GetContext(); + auto& frameRateLinkerMap = context.GetMutableFrameRateLinkerMap(); + + frameRateLinkerMap.FilterFrameRateLinkerByPid(remotePid_); +} + +void RSClientToServiceConnection::CleanFrameRateLinkerExpectedFpsCallbacks() noexcept +{ + if (mainThread_ == nullptr) { + return; + } + auto& context = mainThread_->GetContext(); + auto& frameRateLinkerMap = context.GetMutableFrameRateLinkerMap(); + frameRateLinkerMap.UnRegisterExpectedFpsUpdateCallbackByListener(remotePid_); +} + +void RSClientToServiceConnection::CleanAll(bool toDelete) noexcept +{ + { + std::lock_guard lock(mutex_); + if (cleanDone_) { + return; + } + } + if (!mainThread_) { + return; + } + RS_LOGD("CleanAll() start."); + RS_TRACE_NAME("RSClientToServiceConnection CleanAll begin, remotePid: " + std::to_string(remotePid_)); + RsCommandVerifyHelper::GetInstance().RemoveCntWithPid(remotePid_); + mainThread_->ScheduleTask( + [weakThis = wptr(this)]() { + sptr connection = weakThis.promote(); + if (!connection) { + return; + } + RS_TRACE_NAME_FMT("CleanVirtualScreens %d", connection->remotePid_); + connection->CleanVirtualScreens(); + }).wait(); + mainThread_->ScheduleTask( + [weakThis = wptr(this)]() { + sptr connection = weakThis.promote(); + if (!connection) { + return; + } + RS_TRACE_NAME_FMT("CleanRenderNodes %d", connection->remotePid_); + connection->CleanRenderNodes(); + connection->CleanFrameRateLinkers(); + connection->CleanFrameRateLinkerExpectedFpsCallbacks(); + }).wait(); + mainThread_->ScheduleTask( + [weakThis = wptr(this)]() { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return; + } + RS_TRACE_NAME_FMT("ClearTransactionDataPidInfo %d", connection->remotePid_); + connection->mainThread_->ClearTransactionDataPidInfo(connection->remotePid_); + }).wait(); + mainThread_->ScheduleTask( + [weakThis = wptr(this)]() { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return; + } + RS_TRACE_NAME_FMT("UnRegisterCallback %d", connection->remotePid_); + connection->mainThread_->UnRegisterOcclusionChangeCallback(connection->remotePid_); + connection->mainThread_->ClearSurfaceOcclusionChangeCallback(connection->remotePid_); + connection->mainThread_->UnRegisterUIExtensionCallback(connection->remotePid_); + }).wait(); + if (SelfDrawingNodeMonitor::GetInstance().IsListeningEnabled()) { + mainThread_->ScheduleTask( + [weakThis = wptr(this)]() { + sptr connection = weakThis.promote(); + if (connection == nullptr) { + return; + } + auto &monitor = SelfDrawingNodeMonitor::GetInstance(); + monitor.UnRegisterRectChangeCallback(connection->remotePid_); + }).wait(); + } + RSSurfaceBufferCallbackManager::Instance().UnregisterSurfaceBufferCallback(remotePid_); + HgmTaskHandleThread::Instance().ScheduleTask([pid = remotePid_] () { + RS_TRACE_NAME_FMT("CleanHgmEvent %d", pid); + HgmConfigCallbackManager::GetInstance()->UnRegisterHgmConfigChangeCallback(pid); + auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); + if (frameRateMgr != nullptr) { + frameRateMgr->CleanVote(pid); + } + }).wait(); + RSTypefaceCache::Instance().RemoveDrawingTypefacesByPid(remotePid_); + { + std::lock_guard lock(mutex_); + cleanDone_ = true; + } + + if (toDelete) { + auto renderService = renderService_.promote(); + if (renderService == nullptr) { + RS_LOGW("CleanAll() RenderService is dead."); + } else { + renderService->RemoveConnection(GetToken()); + } + } + + RS_LOGD("CleanAll() end."); + RS_TRACE_NAME("RSClientToServiceConnection CleanAll end, remotePid: " + std::to_string(remotePid_)); +} + +RSClientToServiceConnection::RSConnectionDeathRecipient::RSConnectionDeathRecipient( + wptr conn) : conn_(conn) +{ +} + +void RSClientToServiceConnection::RSConnectionDeathRecipient::OnRemoteDied(const wptr& token) +{ + auto tokenSptr = token.promote(); + if (tokenSptr == nullptr) { + RS_LOGW("RSConnectionDeathRecipient::OnRemoteDied: can't promote remote object."); + return; + } + + auto rsConn = conn_.promote(); + if (rsConn == nullptr) { + RS_LOGW("RSConnectionDeathRecipient::OnRemoteDied: RSClientToServiceConnection was dead, do nothing."); + return; + } + + if (rsConn->GetToken() != tokenSptr) { + RS_LOGI("RSConnectionDeathRecipient::OnRemoteDied: token doesn't match, ignore it."); + return; + } + + rsConn->CleanAll(true); +} + +RSClientToServiceConnection::RSApplicationRenderThreadDeathRecipient::RSApplicationRenderThreadDeathRecipient( + wptr conn) : conn_(conn) +{} + +void RSClientToServiceConnection::RSApplicationRenderThreadDeathRecipient::OnRemoteDied(const wptr& token) +{ + auto tokenSptr = token.promote(); + if (tokenSptr == nullptr) { + RS_LOGW("RSApplicationRenderThreadDeathRecipient::OnRemoteDied: can't promote remote object."); + return; + } + + auto rsConn = conn_.promote(); + if (rsConn == nullptr) { + RS_LOGW("RSApplicationRenderThreadDeathRecipient::OnRemoteDied: " + "RSClientToServiceConnection was dead, do nothing."); + return; + } + + RS_LOGD("RSApplicationRenderThreadDeathRecipient::OnRemoteDied: Unregister."); + auto app = iface_cast(tokenSptr); + rsConn->UnRegisterApplicationAgent(app); +} + +ErrCode RSClientToServiceConnection::CommitTransaction(std::unique_ptr& transactionData) +{ + if (!mainThread_) { + return ERR_INVALID_VALUE; + } + pid_t callingPid = GetCallingPid(); + bool isTokenTypeValid = true; + bool isNonSystemAppCalling = false; + RSInterfaceCodeAccessVerifierBase::GetAccessType(isTokenTypeValid, isNonSystemAppCalling); + bool shouldDrop = RSUnmarshalThread::Instance().ReportTransactionDataStatistics( + callingPid, transactionData.get(), isNonSystemAppCalling); + if (shouldDrop) { + RS_LOGW("CommitTransaction data droped"); + return ERR_INVALID_VALUE; + } + if (transactionData && transactionData->GetDVSyncUpdate()) { + mainThread_->DVSyncUpdate(transactionData->GetDVSyncTime(), transactionData->GetTimestamp()); + } + bool isProcessBySingleFrame = mainThread_->IsNeedProcessBySingleFrameComposer(transactionData); + if (isProcessBySingleFrame) { + mainThread_->ProcessDataBySingleFrameComposer(transactionData); + } else { + mainThread_->RecvRSTransactionData(transactionData); + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::ExecuteSynchronousTask(const std::shared_ptr& task) +{ + if (task == nullptr || mainThread_ == nullptr) { + RS_LOGW("ExecuteSynchronousTask, task or main thread is null!"); + return ERR_INVALID_VALUE; + } + // After a synchronous task times out, it will no longer be executed. + auto isTimeout = std::make_shared(0); + std::weak_ptr isTimeoutWeak = isTimeout; + std::chrono::nanoseconds span(task->GetTimeout()); + mainThread_->ScheduleTask([task, mainThread = mainThread_, isTimeoutWeak] { + if (task == nullptr || mainThread == nullptr || isTimeoutWeak.expired()) { + return; + } + task->Process(mainThread->GetContext()); + }).wait_for(span); + isTimeout.reset(); + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::GetUniRenderEnabled(bool& enable) +{ + enable = RSUniRenderJudgement::IsUniRender(); + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId, + bool& success) +{ + if (!mainThread_) { + success = false; + return ERR_INVALID_VALUE; + } + auto node = DisplayNodeCommandHelper::CreateWithConfigInRS(mainThread_->GetContext(), nodeId, displayNodeConfig); + if (node == nullptr) { + RS_LOGE("RSClientToServiceConnection::CreateDisplayNode fail"); + success = false; + return ERR_INVALID_VALUE; + } + std::function registerNode = [this, nodeId, node, &displayNodeConfig]() { + if (mainThread_ == nullptr) { + return; + } + auto& context = mainThread_->GetContext(); + auto& nodeMap = context.GetMutableNodeMap(); + nodeMap.RegisterRenderNode(node); + nodeMap.TraverseScreenNodes([&node, id = node->GetScreenId()](auto& screenNode) { + if (!screenNode || screenNode->GetScreenId() != id) { + return; + } + screenNode->AddChild(node); + }); + + DisplayNodeCommandHelper::SetDisplayMode(context, nodeId, displayNodeConfig); + }; + mainThread_->PostSyncTask(registerNode); + success = true; + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::CreateNode(const RSSurfaceRenderNodeConfig& config, bool& success) +{ + if (!mainThread_) { + success = false; + return ERR_INVALID_VALUE; + } + std::shared_ptr node = + SurfaceNodeCommandHelper::CreateWithConfigInRS(config, mainThread_->GetContext()); + if (node == nullptr) { + RS_LOGE("RSClientToServiceConnection::CreateNode fail"); + success = false; + return ERR_INVALID_VALUE; + } + std::function registerNode = [node, weakThis = wptr(this)]() -> void { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return; + } + connection->mainThread_->GetContext().GetMutableNodeMap().RegisterRenderNode(node); + }; + mainThread_->PostTask(registerNode); + success = true; + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, + sptr& sfc, bool unobscured) +{ + if (!mainThread_) { + return ERR_INVALID_VALUE; + } + std::shared_ptr node = + SurfaceNodeCommandHelper::CreateWithConfigInRS(config, mainThread_->GetContext(), unobscured); + if (node == nullptr) { + RS_LOGE("RSClientToServiceConnection::CreateNodeAndSurface CreateNode fail"); + return ERR_INVALID_VALUE; + } + sptr surface = IConsumerSurface::Create(config.name); + if (surface == nullptr) { + RS_LOGE("RSClientToServiceConnection::CreateNodeAndSurface get consumer surface fail"); + return ERR_INVALID_VALUE; + } + const std::string& surfaceName = surface->GetName(); + RS_LOGI("RsDebug RSClientToServiceConnection::CreateNodeAndSurface node" + "id:%{public}" PRIu64 " name:%{public}s surface id:%{public}" PRIu64 " name:%{public}s", + node->GetId(), node->GetName().c_str(), + surface->GetUniqueId(), surfaceName.c_str()); + auto defaultUsage = surface->GetDefaultUsage(); + surface->SetDefaultUsage(defaultUsage | BUFFER_USAGE_MEM_DMA | BUFFER_USAGE_HW_COMPOSER); + node->GetRSSurfaceHandler()->SetConsumer(surface); + RSMainThread* mainThread = mainThread_; + std::function registerNode = [node, mainThread]() -> void { + if (auto preNode = mainThread->GetContext().GetNodeMap().GetRenderNode(node->GetId())) { + if (auto preSurfaceNode = node->ReinterpretCastTo()) { + RS_LOGE("CreateNodeAndSurface same id node:%{public}" PRIu64 ", name:%{public}s, type:%{public}d", + node->GetId(), preSurfaceNode->GetName().c_str(), preNode->GetType()); + } else { + RS_LOGE("CreateNodeAndSurface same id node:%{public}" PRIu64 ", type:%{public}d", node->GetId(), + preNode->GetType()); + } + usleep(SLEEP_TIME_US); + } + RS_LOGI("CreateNodeAndSurface RegisterRenderNode id:%{public}" PRIu64 ", name:%{public}s", node->GetId(), + node->GetName().c_str()); + mainThread->GetContext().GetMutableNodeMap().RegisterRenderNode(node); + }; + if (config.isSync) { + mainThread_->PostSyncTask(registerNode); + } else { + mainThread_->PostTask(registerNode, REGISTER_NODE, 0, AppExecFwk::EventQueue::Priority::VIP); + } + std::weak_ptr surfaceRenderNode(node); + sptr listener = new RSRenderServiceListener(surfaceRenderNode); + SurfaceError ret = surface->RegisterConsumerListener(listener); + if (ret != SURFACE_ERROR_OK) { + RS_LOGE("RSClientToServiceConnection::CreateNodeAndSurface Register Consumer Listener fail"); + return ERR_INVALID_VALUE; + } + sptr producer = surface->GetProducer(); + sfc = Surface::CreateSurfaceAsProducer(producer); + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::CreateVSyncConnection(sptr& vsyncConn, + const std::string& name, + const sptr& token, + VSyncConnParam vsyncConnParam) +{ + if (mainThread_ == nullptr || appVSyncDistributor_ == nullptr) { + vsyncConn = nullptr; + return ERR_INVALID_VALUE; + } + uint64_t id = vsyncConnParam.id; + NodeId windowNodeId = vsyncConnParam.windowNodeId; + if (vsyncConnParam.fromXcomponent) { + mainThread_->ScheduleTask([&windowNodeId]() { + auto& node = RSMainThread::Instance()->GetContext().GetNodeMap() + .GetRenderNode(windowNodeId); + if (node == nullptr) { + RS_LOGE("CreateVSyncConnection:node is nullptr"); + return; + } + windowNodeId = node->GetInstanceRootNodeId(); + }).wait(); + } + sptr conn = new VSyncConnection(appVSyncDistributor_, name, token->AsObject(), 0, windowNodeId); + if (ExtractPid(id) == remotePid_) { + auto observer = [] (const RSRenderFrameRateLinker& linker) { + if (auto mainThread = RSMainThread::Instance(); mainThread != nullptr) { + HgmCore::Instance().SetHgmTaskFlag(true); + } + }; + mainThread_->ScheduleTask([weakThis = wptr(this), + id, observer, name, windowNodeId]() { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return; + } + auto linker = std::make_shared(id, observer); + linker->SetVsyncName(name); + linker->SetWindowNodeId(windowNodeId); + auto& context = connection->mainThread_->GetContext(); + auto& frameRateLinkerMap = context.GetMutableFrameRateLinkerMap(); + frameRateLinkerMap.RegisterFrameRateLinker(linker); + }).wait(); + conn->id_ = id; + RS_LOGD("CreateVSyncConnection connect id: %{public}" PRIu64, id); + } + auto ret = appVSyncDistributor_->AddConnection(conn, windowNodeId); + if (ret != VSYNC_ERROR_OK) { + vsyncConn = nullptr; + return ERR_INVALID_VALUE; + } + vsyncConn = conn; + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::GetDefaultScreenId(uint64_t& screenId) +{ + std::lock_guard lock(mutex_); + if (!screenManager_) { + screenId = INVALID_SCREEN_ID; + return ERR_INVALID_VALUE; + } + screenId = screenManager_->GetDefaultScreenId(); + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::GetActiveScreenId(uint64_t& screenId) +{ + std::lock_guard lock(mutex_); + if (!screenManager_) { + screenId = INVALID_SCREEN_ID; + return ERR_INVALID_VALUE; + } + screenId = screenManager_->GetActiveScreenId(); + return ERR_OK; +} + +std::vector RSClientToServiceConnection::GetAllScreenIds() +{ + std::lock_guard lock(mutex_); + if (!screenManager_) { + return std::vector(); + } + return screenManager_->GetAllScreenIds(); +} + +ScreenId RSClientToServiceConnection::CreateVirtualScreen( + const std::string &name, + uint32_t width, + uint32_t height, + sptr surface, + ScreenId mirrorId, + int32_t flags, + std::vector whiteList) +{ + std::lock_guard lock(mutex_); + if (!screenManager_) { + return StatusCode::SCREEN_NOT_FOUND; + } + auto newVirtualScreenId = screenManager_->CreateVirtualScreen( + name, width, height, surface, mirrorId, flags, whiteList); + virtualScreenIds_.insert(newVirtualScreenId); + if (surface != nullptr) { + EventInfo event = { "VOTER_VIRTUALDISPLAY", ADD_VOTE, OLED_60_HZ, OLED_60_HZ, name }; + NotifyRefreshRateEvent(event); + ROSEN_LOGI("%{public}s vote 60hz", __func__); + } + return newVirtualScreenId; +} + +int32_t RSClientToServiceConnection::SetVirtualScreenSurface(ScreenId id, sptr surface) +{ + std::lock_guard lock(mutex_); + if (!screenManager_) { + return StatusCode::SCREEN_NOT_FOUND; + } + return screenManager_->SetVirtualScreenSurface(id, surface); +} + +void RSClientToServiceConnection::RemoveVirtualScreen(ScreenId id) +{ + std::lock_guard lock(mutex_); + if (!screenManager_) { + return; + } + screenManager_->RemoveVirtualScreen(id); + virtualScreenIds_.erase(id); + EventInfo event = { "VOTER_VIRTUALDISPLAY", REMOVE_VOTE }; + NotifyRefreshRateEvent(event); +} + +int32_t RSClientToServiceConnection::SetScreenChangeCallback(sptr callback) +{ + if (!callback) { + RS_LOGE("%{public}s: callback is nullptr", __func__); + return INVALID_ARGUMENTS; + } + std::unique_lock lock(mutex_); + if (screenChangeCallback_ == callback) { + RS_LOGE("%{public}s: the callback has been set", __func__); + return INVALID_ARGUMENTS; + } + if (screenManager_ == nullptr) { + RS_LOGE("%{public}s: screenManager_ is nullptr", __func__); + return SCREEN_NOT_FOUND; + } + + if (screenChangeCallback_ != nullptr) { + // remove the old callback + RS_LOGW("%{public}s: last screenChangeCallback_ should be removed", __func__); + screenManager_->RemoveScreenChangeCallback(screenChangeCallback_); + } + + // update + int32_t status = screenManager_->AddScreenChangeCallback(callback); + screenChangeCallback_ = callback; + return status; +} + +void RSClientToServiceConnection::SetScreenActiveMode(ScreenId id, uint32_t modeId) +{ + if (!screenManager_) { + return; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + return RSHardwareThread::Instance().ScheduleTask( + [=]() { screenManager_->SetScreenActiveMode(id, modeId); }).wait(); +#endif + } else if (mainThread_ != nullptr) { + return mainThread_->ScheduleTask( + [=]() { screenManager_->SetScreenActiveMode(id, modeId); }).wait(); + } +} + +void RSClientToServiceConnection::SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate) +{ + ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP, "RSClientToServiceConnection::SetScreenRefreshRate"); + HgmTaskHandleThread::Instance().PostTask([id, sceneId, rate] () { + int32_t setResult = HgmCore::Instance().SetScreenRefreshRate(id, sceneId, rate); + if (setResult != 0) { + RS_LOGW("SetScreenRefreshRate request of screen %{public}" PRIu64 " of rate %{public}d is refused", + id, rate); + return; + } + }); + ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP); +} + +void RSClientToServiceConnection::SetRefreshRateMode(int32_t refreshRateMode) +{ + ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP, "RSClientToServiceConnection::SetRefreshRateMode"); + HgmTaskHandleThread::Instance().PostTask([refreshRateMode] () { + int32_t setResult = HgmCore::Instance().SetRefreshRateMode(refreshRateMode); + RSSystemProperties::SetHgmRefreshRateModesEnabled(std::to_string(refreshRateMode)); + if (setResult != 0) { + RS_LOGW("SetRefreshRateMode mode %{public}d is not supported", refreshRateMode); + } + }); + ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP); +} + +void RSClientToServiceConnection::UnregisterFrameRateLinker(FrameRateLinkerId id) +{ + if (!mainThread_) { + return; + } + mainThread_->ScheduleTask( + [weakThis = wptr(this), id]() { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return; + } + auto& context = connection->mainThread_->GetContext(); + auto& linkerMap = context.GetMutableFrameRateLinkerMap(); + auto linker = linkerMap.GetFrameRateLinker(id); + if (linker == nullptr) { + RS_LOGE("UnregisterFrameRateLinker there is no frameRateLinker for id %{public}" PRIu64, id); + return; + } + linkerMap.UnregisterFrameRateLinker(id); + }).wait(); +} + +uint32_t RSClientToServiceConnection::GetScreenCurrentRefreshRate(ScreenId id) +{ + uint32_t rate = HgmTaskHandleThread::Instance().ScheduleTask([id] () -> uint32_t { + return HgmCore::Instance().GetScreenCurrentRefreshRate(id); + }).get(); + if (rate == 0) { + RS_LOGW("GetScreenCurrentRefreshRate failed to get current refreshrate of" + " screen : %{public}" PRIu64, id); + } + return rate; +} + +std::vector RSClientToServiceConnection::GetScreenSupportedRefreshRates(ScreenId id) +{ + return HgmTaskHandleThread::Instance().ScheduleTask([id] () -> std::vector { + return HgmCore::Instance().GetScreenComponentRefreshRates(id); + }).get(); +} + +ErrCode RSClientToServiceConnection::GetShowRefreshRateEnabled(bool& enable) +{ + enable = RSRealtimeRefreshRateManager::Instance().GetShowRefreshRateEnabled(); + return ERR_OK; +} + +void RSClientToServiceConnection::SetShowRefreshRateEnabled(bool enabled, int32_t type) +{ + return RSRealtimeRefreshRateManager::Instance().SetShowRefreshRateEnabled(enabled, type); +} + +uint32_t RSClientToServiceConnection::GetRealtimeRefreshRate(ScreenId screenId) +{ + return RSRealtimeRefreshRateManager::Instance().GetRealtimeRefreshRate(screenId); +} + +ErrCode RSClientToServiceConnection::GetRefreshInfo(pid_t pid, std::string& enable) +{ + if (!mainThread_) { + enable = ""; + return ERR_INVALID_VALUE; + } + auto& context = mainThread_->GetContext(); + auto& nodeMap = context.GetMutableNodeMap(); + std::string surfaceName = nodeMap.GetSelfDrawSurfaceNameByPid(pid); + if (surfaceName.empty()) { + enable = ""; + return ERR_INVALID_VALUE; + } + std::string dumpString; + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + RSHardwareThread::Instance().ScheduleTask( + [weakThis = wptr(this), &dumpString, &surfaceName]() { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->screenManager_ == nullptr) { + return; + } + connection->screenManager_->FpsDump(dumpString, surfaceName); + }).wait(); +#endif + } else { + mainThread_->ScheduleTask( + [weakThis = wptr(this), &dumpString, &surfaceName]() { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->screenManager_ == nullptr) { + return; + } + connection->screenManager_->FpsDump(dumpString, surfaceName); + }).wait(); + } + enable = dumpString; + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::GetRefreshInfoToSP(NodeId id, std::string& enable) +{ + if (!mainThread_) { + enable = ""; + return ERR_INVALID_VALUE; + } + std::string dumpString; + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + auto dumpTask = [weakThis = wptr(this), &dumpString, &id]() { + sptr connection = weakThis.promote(); + if (connection == nullptr) { + RS_LOGE("GetRefreshInfoToSP connection is nullptr"); + return; + } + if (connection->screenManager_ == nullptr) { + RS_LOGE("GetRefreshInfoToSP connection->screenManager_ is nullptr"); + return; + } + RSSurfaceFpsManager::GetInstance().Dump(dumpString, id); + }; + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + RSHardwareThread::Instance().ScheduleTask(dumpTask).wait(); +#endif + } else { + mainThread_->ScheduleTask(dumpTask).wait(); + } + enable = dumpString; + return ERR_OK; +} + +int32_t RSClientToServiceConnection::GetCurrentRefreshRateMode() +{ + return HgmTaskHandleThread::Instance().ScheduleTask([] () -> int32_t { + return HgmCore::Instance().GetCurrentRefreshRateMode(); + }).get(); +} + +int32_t RSClientToServiceConnection::SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height) +{ + if (!screenManager_) { + return StatusCode::SCREEN_MANAGER_NULL; + } + return screenManager_->SetPhysicalScreenResolution(id, width, height); +} + +int32_t RSClientToServiceConnection::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) +{ + if (!screenManager_) { + return StatusCode::SCREEN_NOT_FOUND; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + return RSHardwareThread::Instance().ScheduleTask( + [=]() { return screenManager_->SetVirtualScreenResolution(id, width, height); }).get(); +#else + return StatusCode::SCREEN_NOT_FOUND; +#endif + } else if (mainThread_ != nullptr) { + return mainThread_->ScheduleTask( + [=]() { return screenManager_->SetVirtualScreenResolution(id, width, height); }).get(); + } else { + return StatusCode::SCREEN_NOT_FOUND; + } +} + +ErrCode RSClientToServiceConnection::RepaintEverything() +{ + if (mainThread_ == nullptr) { + RS_LOGE("RepaintEverything, mainThread_ is null, return"); + return ERR_INVALID_VALUE; + } + auto task = []() -> void { + RS_LOGI("RepaintEverything, setDirtyflag, forceRefresh in mainThread"); + RSMainThread::Instance()->SetDirtyFlag(); + RSMainThread::Instance()->ForceRefreshForUni(); + }; + mainThread_->PostTask(task); + return ERR_OK; +} + +void RSClientToServiceConnection::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status) +{ + if (screenManager_ == nullptr || mainThread_ == nullptr) { + RS_LOGE("%{public}s screenManager or mainThread is null, id: %{public}" PRIu64, __func__, id); + return; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + RSHardwareThread::Instance().ScheduleTask([=]() { + screenManager_->SetScreenPowerStatus(id, status); + }).wait(); + screenManager_->WaitScreenPowerStatusTask(); + mainThread_->SetDiscardJankFrames(true); + RSJankStatsRenderFrameHelper::GetInstance().SetDiscardJankFrames(true); + HgmTaskHandleThread::Instance().PostTask([id, status]() { + HgmCore::Instance().NotifyScreenPowerStatus(id, status); + }); +#endif + } else { + mainThread_->ScheduleTask( + [=]() { screenManager_->SetScreenPowerStatus(id, status); }).wait(); + } +} + +ErrCode RSClientToServiceConnection::RegisterApplicationAgent(uint32_t pid, sptr app) +{ + if (!mainThread_) { + RS_LOGE("RegisterApplicationAgent mainThread_ is nullptr"); + return ERR_INVALID_VALUE; + } + auto captureTask = [weakThis = wptr(this), pid, app]() -> void { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + RS_LOGE("RegisterApplicationAgent connection or mainThread_ is nullptr"); + return; + } + connection->mainThread_->RegisterApplicationAgent(pid, app); + }; + mainThread_->PostTask(captureTask); + + app->AsObject()->AddDeathRecipient(applicationDeathRecipient_); + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::GetScreenActiveMode(uint64_t id, RSScreenModeInfo& screenModeInfo) +{ + if (!screenManager_) { + return ERR_INVALID_VALUE; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + RSHardwareThread::Instance().ScheduleTask( + [=, &screenModeInfo]() { return screenManager_->GetScreenActiveMode(id, screenModeInfo); }).wait(); +#else + return screenModeInfo; +#endif + } else if (mainThread_ != nullptr) { + mainThread_->ScheduleTask( + [=, &screenModeInfo]() { return screenManager_->GetScreenActiveMode(id, screenModeInfo); }).wait(); + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize) +{ +#ifdef RS_ENABLE_GPU + RSMainThread::Instance()->GetAppMemoryInMB(cpuMemSize, gpuMemSize); + gpuMemSize += RSSubThreadManager::Instance()->GetAppGpuMemoryInMB(); +#endif + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::GetMemoryGraphic(int pid, MemoryGraphic& memoryGraphic) +{ + if (!mainThread_ || !mainThread_->GetContext().GetNodeMap().ContainPid(pid)) { + return ERR_INVALID_VALUE; + } + bool enable; + if (GetUniRenderEnabled(enable) == ERR_OK && enable) { + renderThread_.PostSyncTask( + [weakThis = wptr(this), &memoryGraphic, &pid] { + sptr connection = weakThis.promote(); + if (connection == nullptr) { + return; + } + memoryGraphic = MemoryManager::CountPidMemory(pid, + connection->renderThread_.GetRenderEngine()->GetRenderContext()->GetDrGPUContext()); + }); + return ERR_OK; + } else { + return ERR_INVALID_VALUE; + } +} + +ErrCode RSClientToServiceConnection::GetMemoryGraphics(std::vector& memoryGraphics) +{ + bool res; + if (!mainThread_ || GetUniRenderEnabled(res) != ERR_OK || !res) { + return ERR_INVALID_VALUE; + } + + const auto& nodeMap = mainThread_->GetContext().GetNodeMap(); + std::vector pids; + nodeMap.TraverseSurfaceNodes([&pids] (const std::shared_ptr& node) { + auto pid = ExtractPid(node->GetId()); + if (std::find(pids.begin(), pids.end(), pid) == pids.end()) { + pids.emplace_back(pid); + } + }); + renderThread_.PostSyncTask( + [weakThis = wptr(this), &memoryGraphics, &pids] { + sptr connection = weakThis.promote(); + if (connection == nullptr) { + return; + } + MemoryManager::CountMemory(pids, + connection->renderThread_.GetRenderEngine()->GetRenderContext()->GetDrGPUContext(), memoryGraphics); + }); + return ERR_OK; +} + +std::vector RSClientToServiceConnection::GetScreenSupportedModes(ScreenId id) +{ + if (!screenManager_) { + return std::vector(); + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + return RSHardwareThread::Instance().ScheduleTask( + [=]() { return screenManager_->GetScreenSupportedModes(id); }).get(); +#else + return std::vector(); +#endif + } else if (mainThread_ != nullptr) { + return mainThread_->ScheduleTask( + [=]() { return screenManager_->GetScreenSupportedModes(id); }).get(); + } else { + return std::vector(); + } +} + +RSScreenCapability RSClientToServiceConnection::GetScreenCapability(ScreenId id) +{ + RSScreenCapability screenCapability; + if (!screenManager_) { + return screenCapability; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + return RSHardwareThread::Instance().ScheduleTask( + [=]() { return screenManager_->GetScreenCapability(id); }).get(); +#else + return screenCapability; +#endif + } else if (mainThread_ != nullptr) { + return mainThread_->ScheduleTask( + [=]() { return screenManager_->GetScreenCapability(id); }).get(); + } else { + return screenCapability; + } +} + +ErrCode RSClientToServiceConnection::GetScreenPowerStatus(uint64_t screenId, uint32_t& status) +{ + if (!screenManager_) { + status = ScreenPowerStatus::INVALID_POWER_STATUS; + return ERR_INVALID_VALUE; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + status = RSHardwareThread::Instance().ScheduleTask( + [=]() { return screenManager_->GetScreenPowerStatus(screenId); }).get(); +#else + status = ScreenPowerStatus::INVALID_POWER_STATUS; +#endif + } else if (mainThread_ != nullptr) { + status = mainThread_->ScheduleTask( + [=]() { return screenManager_->GetScreenPowerStatus(screenId); }).get(); + } else { + status = ScreenPowerStatus::INVALID_POWER_STATUS; + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +RSScreenData RSClientToServiceConnection::GetScreenData(ScreenId id) +{ + RSScreenData screenData; + if (!screenManager_) { + return screenData; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + return RSHardwareThread::Instance().ScheduleTask( + [=]() { return screenManager_->GetScreenData(id); }).get(); +#else + return screenData; +#endif + } else if (mainThread_ != nullptr) { + return mainThread_->ScheduleTask( + [=]() { return screenManager_->GetScreenData(id); }).get(); + } else { + return screenData; + } +} + +ErrCode RSClientToServiceConnection::GetScreenBacklight(uint64_t id, int32_t& level) +{ + if (!screenManager_) { + level = INVALID_BACKLIGHT_VALUE; + return ERR_INVALID_VALUE; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + level = RSHardwareThread::Instance().ScheduleTask( + [=]() { return screenManager_->GetScreenBacklight(id); }).get(); +#else + level = INVALID_BACKLIGHT_VALUE; +#endif + } else if (mainThread_ != nullptr) { + level = mainThread_->ScheduleTask( + [=]() { return screenManager_->GetScreenBacklight(id); }).get(); + } else { + level = INVALID_BACKLIGHT_VALUE; + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +void RSClientToServiceConnection::SetScreenBacklight(ScreenId id, uint32_t level) +{ + if (!screenManager_) { + RS_LOGE("%{public}s screenManager_ is nullptr.", __func__); + return; + } + RSLuminanceControl::Get().SetSdrLuminance(id, level); + if (RSLuminanceControl::Get().IsHdrOn(id) && level > 0 && mainThread_ != nullptr) { + auto task = [weakThis = wptr(this), id]() { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + RS_LOGE("SetScreenBacklight fail"); + return; + } + connection->mainThread_->SetLuminanceChangingStatus(id, true); + connection->mainThread_->SetDirtyFlag(); + connection->mainThread_->RequestNextVSync(); + }; + mainThread_->PostTask(task); + return; + } + + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + screenManager_->SetScreenBacklight(id, level); +#endif + } else if (mainThread_ != nullptr) { + mainThread_->ScheduleTask( + [=]() { screenManager_->SetScreenBacklight(id, level); }).wait(); + } +} + +ErrCode RSClientToServiceConnection::RegisterBufferClearListener( + NodeId id, sptr callback) +{ + if (!mainThread_) { + return ERR_INVALID_VALUE; + } + auto registerBufferClearListener = + [id, callback, weakThis = wptr(this)]() -> bool { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return false; + } + if (auto node = connection->mainThread_->GetContext().GetNodeMap().GetRenderNode(id)) { + node->RegisterBufferClearListener(callback); + return true; + } + return false; + }; + mainThread_->PostTask(registerBufferClearListener); + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::RegisterBufferAvailableListener( + NodeId id, sptr callback, bool isFromRenderThread) +{ + if (!mainThread_) { + return ERR_INVALID_VALUE; + } + auto registerBufferAvailableListener = + [id, callback, isFromRenderThread, weakThis = wptr(this)]() -> bool { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return false; + } + if (auto node = connection->mainThread_->GetContext().GetNodeMap().GetRenderNode(id)) { + node->RegisterBufferAvailableListener(callback, isFromRenderThread); + return true; + } + return false; + }; + mainThread_->PostTask(registerBufferAvailableListener); + return ERR_OK; +} + +int32_t RSClientToServiceConnection::GetScreenSupportedColorGamuts(ScreenId id, std::vector& mode) +{ + if (!screenManager_) { + return StatusCode::SCREEN_NOT_FOUND; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + return RSHardwareThread::Instance().ScheduleTask( + [=, &mode]() { return screenManager_->GetScreenSupportedColorGamuts(id, mode); }).get(); +#else + return StatusCode::SCREEN_NOT_FOUND; +#endif + } else if (mainThread_ != nullptr) { + return mainThread_->ScheduleTask( + [=, &mode]() { return screenManager_->GetScreenSupportedColorGamuts(id, mode); }).get(); + } else { + return StatusCode::SCREEN_NOT_FOUND; + } +} + +int32_t RSClientToServiceConnection::GetScreenSupportedMetaDataKeys(ScreenId id, std::vector& keys) +{ + if (!screenManager_) { + return StatusCode::SCREEN_NOT_FOUND; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + return RSHardwareThread::Instance().ScheduleTask( + [=, &keys]() { return screenManager_->GetScreenSupportedMetaDataKeys(id, keys); }).get(); +#else + return StatusCode::SCREEN_NOT_FOUND; +#endif + } else if (mainThread_ != nullptr) { + return mainThread_->ScheduleTask( + [=, &keys]() { return screenManager_->GetScreenSupportedMetaDataKeys(id, keys); }).get(); + } else { + return StatusCode::SCREEN_NOT_FOUND; + } +} + +int32_t RSClientToServiceConnection::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode) +{ + if (!screenManager_) { + return StatusCode::SCREEN_NOT_FOUND; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + return RSHardwareThread::Instance().ScheduleTask( + [=, &mode]() { return screenManager_->GetScreenColorGamut(id, mode); }).get(); +#else + return StatusCode::SCREEN_NOT_FOUND; +#endif + } else if (mainThread_ != nullptr) { + return mainThread_->ScheduleTask( + [=, &mode]() { return screenManager_->GetScreenColorGamut(id, mode); }).get(); + } else { + return StatusCode::SCREEN_NOT_FOUND; + } +} + +int32_t RSClientToServiceConnection::SetScreenColorGamut(ScreenId id, int32_t modeIdx) +{ + if (!screenManager_) { + return StatusCode::SCREEN_NOT_FOUND; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + return RSHardwareThread::Instance().ScheduleTask( + [=]() { return screenManager_->SetScreenColorGamut(id, modeIdx); }).get(); +#else + return StatusCode::SCREEN_NOT_FOUND; +#endif + } else if (mainThread_ != nullptr) { + return mainThread_->ScheduleTask( + [=]() { return screenManager_->SetScreenColorGamut(id, modeIdx); }).get(); + } else { + return StatusCode::SCREEN_NOT_FOUND; + } +} + +int32_t RSClientToServiceConnection::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode) +{ + if (!screenManager_) { + return StatusCode::SCREEN_NOT_FOUND; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + return RSHardwareThread::Instance().ScheduleTask( + [=]() { return screenManager_->SetScreenGamutMap(id, mode); }).get(); +#else + return StatusCode::SCREEN_NOT_FOUND; +#endif + } else if (mainThread_ != nullptr) { + return mainThread_->ScheduleTask( + [=]() { return screenManager_->SetScreenGamutMap(id, mode); }).get(); + } else { + return StatusCode::SCREEN_NOT_FOUND; + } +} + +int32_t RSClientToServiceConnection::SetScreenCorrection(ScreenId id, ScreenRotation screenRotation) +{ + std::lock_guard lock(mutex_); + if (!screenManager_) { + return StatusCode::SCREEN_NOT_FOUND; + } + return screenManager_->SetScreenCorrection(id, screenRotation); +} + +ErrCode RSClientToServiceConnection::SetGlobalDarkColorMode(bool isDark) +{ + std::lock_guard lock(mutex_); + if (!mainThread_) { + return ERR_INVALID_VALUE; + } + auto task = [weakThis = wptr(this), isDark]() { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + RS_LOGE("SetGlobalDarkColorMode fail"); + return; + } + connection->mainThread_->SetGlobalDarkColorMode(isDark); + }; + mainThread_->PostTask(task); + return ERR_OK; +} + +int32_t RSClientToServiceConnection::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode) +{ + if (!screenManager_) { + return StatusCode::SCREEN_NOT_FOUND; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + return RSHardwareThread::Instance().ScheduleTask( + [=, &mode]() { return screenManager_->GetScreenGamutMap(id, mode); }).get(); +#else + return StatusCode::SCREEN_NOT_FOUND; +#endif + } else if (mainThread_ != nullptr) { + return mainThread_->ScheduleTask( + [=, &mode]() { return screenManager_->GetScreenGamutMap(id, mode); }).get(); + } else { + return StatusCode::SCREEN_NOT_FOUND; + } +} + +ErrCode RSClientToServiceConnection::GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus, int32_t& resCode) +{ + if (mainThread_ == nullptr) { + return ERR_INVALID_VALUE; + } + HdrStatus hdrStatusRet = HdrStatus::NO_HDR; + StatusCode resCodeRet = StatusCode::SCREEN_NOT_FOUND; + auto isTimeout = std::make_shared(0); + std::weak_ptr isTimeoutWeak = isTimeout; + auto task = [id, mainThread = mainThread_, &resCodeRet, &hdrStatusRet, isTimeoutWeak]() { + if (isTimeoutWeak.expired()) { + RS_LOGE("GetScreenHDRStatus time out, ScreenId: [%{public}" PRIu64 "]", id); + return; + } + std::shared_ptr screenNode = nullptr; + auto& nodeMap = mainThread->GetContext().GetNodeMap(); + nodeMap.TraverseScreenNodes([id, &screenNode](const std::shared_ptr& node) { + if (node && node->GetScreenId() == id) { + screenNode = node; + } + }); + if (screenNode == nullptr) { + resCodeRet = StatusCode::SCREEN_NOT_FOUND; + return; + } + hdrStatusRet = screenNode->GetLastDisplayHDRStatus(); + resCodeRet = StatusCode::SUCCESS; + }; + auto span = std::chrono::duration_cast(std::chrono::milliseconds(100)); // timeout 100 ms + if (mainThread_->ScheduleTask(task).wait_for(span) == std::future_status::timeout) { + isTimeout.reset(); + } + if (isTimeoutWeak.expired() && resCodeRet != StatusCode::SUCCESS) { + return ERR_TIMED_OUT; + } + if (resCodeRet == StatusCode::SUCCESS) { + hdrStatus = hdrStatusRet; + } + resCode = resCodeRet; + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::GetScreenSupportedColorSpaces( + ScreenId id, std::vector& colorSpaces, int32_t& resCode) +{ + if (!screenManager_) { + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + resCode = RSHardwareThread::Instance().ScheduleTask( + [=, &colorSpaces]() { return screenManager_->GetScreenSupportedColorSpaces(id, colorSpaces); }).get(); + return ERR_OK; +#else + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; +#endif + } else if (mainThread_ != nullptr) { + resCode = mainThread_->ScheduleTask( + [=, &colorSpaces]() { return screenManager_->GetScreenSupportedColorSpaces(id, colorSpaces); }).get(); + return ERR_OK; + } else { + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; + } +} + +ErrCode RSClientToServiceConnection::GetScreenColorSpace( + ScreenId id, GraphicCM_ColorSpaceType& colorSpace, int32_t& resCode) +{ + if (!screenManager_) { + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + resCode = RSHardwareThread::Instance().ScheduleTask( + [=, &colorSpace]() { return screenManager_->GetScreenColorSpace(id, colorSpace); }).get(); + return ERR_OK; +#else + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; +#endif + } else if (mainThread_ != nullptr) { + resCode = mainThread_->ScheduleTask( + [=, &colorSpace]() { return screenManager_->GetScreenColorSpace(id, colorSpace); }).get(); + return ERR_OK; + } else { + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; + } +} + +ErrCode RSClientToServiceConnection::SetScreenColorSpace( + ScreenId id, GraphicCM_ColorSpaceType colorSpace, int32_t& resCode) +{ + if (!screenManager_) { + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; + } + auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType(); + if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) { +#ifdef RS_ENABLE_GPU + resCode = RSHardwareThread::Instance().ScheduleTask( + [=]() { return screenManager_->SetScreenColorSpace(id, colorSpace); }).get(); + return ERR_OK; +#else + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; +#endif + } else if (mainThread_ != nullptr) { + resCode = mainThread_->ScheduleTask( + [=]() { return screenManager_->SetScreenColorSpace(id, colorSpace); }).get(); + return ERR_OK; + } else { + resCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; + } +} + +int32_t RSClientToServiceConnection::GetScreenType(ScreenId id, RSScreenType& screenType) +{ + std::lock_guard lock(mutex_); + if (!screenManager_) { + return StatusCode::SCREEN_NOT_FOUND; + } + return screenManager_->GetScreenType(id, screenType); +} + +ErrCode RSClientToServiceConnection::GetBitmap(NodeId id, Drawing::Bitmap& bitmap, bool& success) +{ + if (!mainThread_) { + success = false; + return ERR_INVALID_VALUE; + } + std::promise result; + std::future future = result.get_future(); + RSMainThread* mainThread = mainThread_; +#ifdef RS_ENABLE_GPU + RSUniRenderThread* renderThread = &renderThread_; + auto getBitmapTask = [id, &bitmap, mainThread, renderThread, &result]() { + auto node = mainThread->GetContext().GetNodeMap().GetRenderNode(id); + if (node == nullptr) { + RS_LOGE("GetBitmap cannot find NodeId: [%{public}" PRIu64 "]", id); + result.set_value(false); + return; + } + if (node->GetType() != RSRenderNodeType::CANVAS_DRAWING_NODE) { + RS_LOGE("GetBitmap RenderNodeType != RSRenderNodeType::CANVAS_DRAWING_NODE"); + result.set_value(false); + return; + } + auto grContext = renderThread->GetRenderEngine()->GetRenderContext()->GetDrGPUContext(); + auto drawableNode = DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(node); + auto getDrawableBitmapTask = [drawableNode, &bitmap, grContext, &result]() { + bitmap = std::static_pointer_cast(drawableNode) + ->GetBitmap(grContext); + result.set_value(!bitmap.IsEmpty()); + }; + renderThread->PostTask(getDrawableBitmapTask); + }; + mainThread_->PostTask(getBitmapTask); +#endif + success = future.get(); + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::GetPixelmap(NodeId id, const std::shared_ptr pixelmap, + const Drawing::Rect* rect, std::shared_ptr drawCmdList, bool& success) +{ + if (!mainThread_) { + success = false; + return ERR_INVALID_VALUE; + } + std::promise result; + std::future future = result.get_future(); +#ifdef RS_ENABLE_GPU + RSMainThread* mainThread = mainThread_; + RSUniRenderThread* renderThread = &renderThread_; + auto getPixelMapTask = [id, pixelmap, rect, drawCmdList, mainThread, renderThread, &result]() { + auto node = mainThread->GetContext().GetNodeMap().GetRenderNode(id); + if (node == nullptr) { + RS_LOGD("GetPixelmap: cannot find NodeId: [%{public}" PRIu64 "]", id); + result.set_value(false); + return; + } + if (node->GetType() != RSRenderNodeType::CANVAS_DRAWING_NODE) { + RS_LOGE("GetPixelmap: RenderNodeType != RSRenderNodeType::CANVAS_DRAWING_NODE"); + result.set_value(false); + return; + } + + auto tid = node->GetTid(); // planning: id may change in subthread + auto drawableNode = DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(node); + if (drawableNode) { + tid = std::static_pointer_cast(drawableNode)->GetTid(); + } + auto getDrawablePixelmapTask = [drawableNode, pixelmap, rect, &result, tid, drawCmdList]() { + result.set_value(std::static_pointer_cast(drawableNode)-> + GetPixelmap(pixelmap, rect, tid, drawCmdList)); + }; + if (!node->IsOnTheTree()) { + node->ClearOp(); + } + if (tid == UNI_MAIN_THREAD_INDEX) { + if (!mainThread->IsIdle() && mainThread->GetContext().HasActiveNode(node)) { + result.set_value(false); + return; + } + result.set_value(node->GetPixelmap(pixelmap, rect, tid, drawCmdList)); + } else if (tid == UNI_RENDER_THREAD_INDEX) { + renderThread->PostTask(getDrawablePixelmapTask); + } else { + auto tidMap = RSSubThreadManager::Instance()->GetReThreadIndexMap(); + if (auto found = tidMap.find(tid); found != tidMap.end()) { + RSTaskDispatcher::GetInstance().PostTask(found->second, getDrawablePixelmapTask, false); + } else { + renderThread->PostTask(getDrawablePixelmapTask); + } + } + }; + mainThread_->PostTask(getPixelMapTask); +#endif + success = future.get(); + return ERR_OK; +} + +int32_t RSClientToServiceConnection::GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, + std::vector& edidData) +{ + std::lock_guard lock(mutex_); + if (!screenManager_) { + return StatusCode::SCREEN_NOT_FOUND; + } + return screenManager_->GetDisplayIdentificationData(id, outPort, edidData); +} + +ErrCode RSClientToServiceConnection::SetScreenActiveRect(ScreenId id, const Rect& activeRect, uint32_t& repCode) +{ + if (!screenManager_) { + repCode = StatusCode::SCREEN_NOT_FOUND; + return ERR_INVALID_VALUE; + } + GraphicIRect dstActiveRect { + .x = activeRect.x, + .y = activeRect.y, + .w = activeRect.w, + .h = activeRect.h, + }; + if (!mainThread_) { + repCode = StatusCode::INVALID_ARGUMENTS; + return ERR_INVALID_VALUE; + } + auto task = [weakScreenManager = wptr(screenManager_), id, dstActiveRect]() -> void { + sptr screenManager = weakScreenManager.promote(); + if (!screenManager) { + return; + } + screenManager->SetScreenActiveRect(id, dstActiveRect); + }; + mainThread_->ScheduleTask(task).wait(); + + HgmTaskHandleThread::Instance().PostTask([id, dstActiveRect]() { + HgmCore::Instance().NotifyScreenRectFrameRateChange(id, dstActiveRect); + }); + repCode = StatusCode::SUCCESS; + return ERR_OK; +} + +void RSClientToServiceConnection::SetScreenOffset(ScreenId id, int32_t offsetX, int32_t offsetY) +{ + if (!screenManager_) { + return; + } + screenManager_->SetScreenOffset(id, offsetX, offsetY); +} + +void RSClientToServiceConnection::SetScreenFrameGravity(ScreenId id, int32_t gravity) +{ + auto task = [weakThis = wptr(this), id, gravity]() -> void { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return; + } + auto& context = connection->mainThread_->GetContext(); + context.GetNodeMap().TraverseScreenNodes([id, gravity](auto& node) { + if (node && node->GetScreenId() == id) { + node->GetMutableRenderProperties().SetFrameGravity(static_cast(gravity)); + } + }); + }; + mainThread_->PostTask(task); +} + +void RSClientToServiceConnection::NotifyRefreshRateEvent(const EventInfo& eventInfo) +{ + if (VOTER_SCENE_BLUR == eventInfo.eventName) { + RsFrameBlurPredict::GetInstance().TakeEffectBlurScene(eventInfo); + return; + } + + if (VOTER_SCENE_GPU == eventInfo.eventName) { + RsFrameReport::GetInstance().ReportScbSceneInfo(eventInfo.description, eventInfo.eventStatus); + return; + } + HgmTaskHandleThread::Instance().PostTask([pid = remotePid_, eventInfo]() { + auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); + if (frameRateMgr != nullptr) { + frameRateMgr->HandleRefreshRateEvent(pid, eventInfo); + } + }); +} + +void RSClientToServiceConnection::SetWindowExpectedRefreshRate( + const std::unordered_map& eventInfos +) +{ + HgmTaskHandleThread::Instance().PostTask([pid = remotePid_, eventInfos]() { + auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); + if (frameRateMgr != nullptr) { + auto& softVsyncMgr = frameRateMgr->SoftVSyncMgrRef(); + softVsyncMgr.SetWindowExpectedRefreshRate(pid, eventInfos); + } + }); +} + +void RSClientToServiceConnection::SetWindowExpectedRefreshRate( + const std::unordered_map& eventInfos +) +{ + HgmTaskHandleThread::Instance().PostTask([pid = remotePid_, eventInfos]() { + auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); + if (frameRateMgr != nullptr) { + auto& softVsyncMgr = frameRateMgr->SoftVSyncMgrRef(); + softVsyncMgr.SetWindowExpectedRefreshRate(pid, eventInfos); + } + }); +} + +ErrCode RSClientToServiceConnection::NotifySoftVsyncEvent(uint32_t pid, uint32_t rateDiscount) +{ + if (!appVSyncDistributor_) { + return ERR_INVALID_VALUE; + } + appVSyncDistributor_->SetQosVSyncRateByPidPublic(pid, rateDiscount, true); + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt) +{ + if (mainThread_ != nullptr) { + mainThread_->HandleTouchEvent(touchStatus, touchCnt); + return ERR_INVALID_VALUE; + } + auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); + if (frameRateMgr != nullptr) { + frameRateMgr->HandleTouchEvent(remotePid_, touchStatus, touchCnt); + } + return ERR_OK; +} + +void RSClientToServiceConnection::NotifyDynamicModeEvent(bool enableDynamicModeEvent) +{ + HgmTaskHandleThread::Instance().PostTask([enableDynamicModeEvent] () { + auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); + if (frameRateMgr == nullptr) { + RS_LOGW("NotifyDynamicModeEvent: frameRateMgr is nullptr."); + return; + } + frameRateMgr->HandleDynamicModeEvent(enableDynamicModeEvent); + }); +} + +ErrCode RSClientToServiceConnection::NotifyXComponentExpectedFrameRate(const std::string& id, int32_t expectedFrameRate) +{ + HgmTaskHandleThread::Instance().PostTask([remotePid = remotePid_, id, expectedFrameRate] () { + HgmConfigCallbackManager::GetInstance()->SyncXComponentExpectedFrameRateCallback( + remotePid, id, expectedFrameRate); + }); + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::SetHardwareEnabled(NodeId id, bool isEnabled, SelfDrawingNodeType selfDrawingType, + bool dynamicHardwareEnable) +{ + if (!mainThread_) { + return ERR_INVALID_VALUE; + } + auto task = [weakThis = wptr(this), id, isEnabled, selfDrawingType, + dynamicHardwareEnable]() -> void { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return; + } + auto& context = connection->mainThread_->GetContext(); + auto node = context.GetNodeMap().GetRenderNode(id); + if (node) { + node->SetHardwareEnabled(isEnabled, selfDrawingType, dynamicHardwareEnable); + } + }; + mainThread_->PostTask(task); + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent, uint32_t& resCode) +{ + if (!mainThread_) { + resCode = static_cast(RSInterfaceErrorCode::UNKNOWN_ERROR); + return ERR_INVALID_VALUE; + } + auto task = [weakThis = wptr(this), id, needHidePrivacyContent]() -> void { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return; + } + auto& context = connection->mainThread_->GetContext(); + auto node = context.GetNodeMap().GetRenderNode(id); + if (node) { + node->SetHidePrivacyContent(needHidePrivacyContent); + } + }; + mainThread_->PostTask(task); + resCode = static_cast(RSInterfaceErrorCode::NO_ERROR); + return ERR_OK; +} + +LayerComposeInfo RSClientToServiceConnection::GetLayerComposeInfo() +{ + const auto& layerComposeInfo = LayerComposeCollection::GetInstance().GetLayerComposeInfo(); + LayerComposeCollection::GetInstance().ResetLayerComposeInfo(); + return layerComposeInfo; +} + +HwcDisabledReasonInfos RSClientToServiceConnection::GetHwcDisabledReasonInfo() +{ + return HwcDisabledReasonCollection::GetInstance().GetHwcDisabledReasonInfo(); +} + +#ifdef TP_FEATURE_ENABLE +ErrCode RSClientToServiceConnection::SetTpFeatureConfig(int32_t feature, const char* config, + TpFeatureConfigType tpFeatureConfigType) +{ + switch (tpFeatureConfigType) { + case TpFeatureConfigType::DEFAULT_TP_FEATURE: { + if (TOUCH_SCREEN->SetFeatureConfig(feature, config) < 0) { + RS_LOGW("SetTpFeatureConfig: SetFeatureConfig failed"); + return ERR_INVALID_VALUE; + } + return ERR_OK; + } + case TpFeatureConfigType::AFT_TP_FEATURE: { + if (TOUCH_SCREEN->SetAftConfig(config) < 0) { + RS_LOGW("SetTpFeatureConfig: SetAftConfig failed"); + return ERR_INVALID_VALUE; + } + return ERR_OK; + } + default: { + RS_LOGW("SetTpFeatureConfig: unknown TpFeatureConfigType: %" PRIu8"", + static_cast(tpFeatureConfigType)); + return ERR_INVALID_VALUE; + } + } +} +#endif + +ErrCode RSClientToServiceConnection::SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder) +{ + if (mainThread_ == nullptr) { + return ERR_INVALID_VALUE; + } + auto task = [weakThis = wptr(this), nodeId, isTop, zOrder]() -> void { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return; + } + auto& context = connection->mainThread_->GetContext(); + auto surfaceNode = context.GetNodeMap().GetRenderNode(nodeId); + if (surfaceNode == nullptr) { + return; + } + surfaceNode->SetLayerTop(isTop, false); + surfaceNode->SetTopLayerZOrder(zOrder); + // It can be displayed immediately after layer-top changed. + connection->mainThread_->SetDirtyFlag(); + connection->mainThread_->RequestNextVSync(); + }; + mainThread_->PostTask(task); + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::SetLayerTop(const std::string &nodeIdStr, bool isTop) +{ + if (mainThread_ == nullptr) { + return ERR_INVALID_VALUE; + } + auto task = [weakThis = wptr(this), nodeIdStr, isTop]() -> void { + sptr connection = weakThis.promote(); + if (connection == nullptr || connection->mainThread_ == nullptr) { + return; + } + auto& context = connection->mainThread_->GetContext(); + context.GetNodeMap().TraverseSurfaceNodes( + [&nodeIdStr, &isTop](const std::shared_ptr& surfaceNode) mutable { + if ((surfaceNode != nullptr) && (surfaceNode->GetName() == nodeIdStr) && + (surfaceNode->GetSurfaceNodeType() == RSSurfaceNodeType::SELF_DRAWING_NODE)) { + surfaceNode->SetLayerTop(isTop); + return; + } + }); + // It can be displayed immediately after layer-top changed. + connection->mainThread_->SetDirtyFlag(); + connection->mainThread_->RequestNextVSync(); + }; + mainThread_->PostTask(task); + return ERR_OK; +} + +void RSClientToServiceConnection::RegisterTransactionDataCallback(uint64_t token, + uint64_t timeStamp, sptr callback) +{ + RSTransactionDataCallbackManager::Instance().RegisterTransactionDataCallback(token, timeStamp, callback); +} + +ErrCode RSClientToServiceConnection::NotifyScreenSwitched() +{ + std::lock_guard lock(mutex_); + if (!screenManager_) { + RS_LOGE("NotifyScreenSwitched screenManager_ is nullptr"); + return ERR_INVALID_VALUE; + } + RS_LOGI("NotifyScreenSwitched SetScreenSwitchStatus true"); + RS_TRACE_NAME_FMT("NotifyScreenSwitched"); + screenManager_->SetScreenSwitchStatus(true); + return ERR_OK; +} + +int32_t RSClientToServiceConnection::RegisterSelfDrawingNodeRectChangeCallback( + const RectConstraint& constraint, sptr callback) +{ + std::lock_guard lock(mutex_); + + if (!mainThread_) { + return StatusCode::INVALID_ARGUMENTS; + } + if (!callback) { + RS_LOGE("RegisterSelfDrawingNodeRectChangeCallback register null callback, failed."); + return StatusCode::INVALID_ARGUMENTS; + } + + auto task = [pid = remotePid_, constraint, callback]() { + SelfDrawingNodeMonitor::GetInstance().RegisterRectChangeCallback(pid, constraint, callback); + }; + mainThread_->PostTask(task); + return StatusCode::SUCCESS; +} + +int32_t RSClientToServiceConnection::UnRegisterSelfDrawingNodeRectChangeCallback() +{ + std::lock_guard lock(mutex_); + + if (!mainThread_) { + return StatusCode::INVALID_ARGUMENTS; + } + auto task = [pid = remotePid_]() { SelfDrawingNodeMonitor::GetInstance().UnRegisterRectChangeCallback(pid); }; + mainThread_->PostTask(task); + return StatusCode::SUCCESS; +} + +#ifdef RS_ENABLE_OVERLAY_DISPLAY +ErrCode RSClientToServiceConnection::SetOverlayDisplayMode(int32_t mode) +{ + RS_LOGI("SetOverlayDisplayMode: mode: [%{public}d]", mode); + return RSOverlayDisplayManager::Instance().SetOverlayDisplayMode(mode) == 0 ? ERR_OK : ERR_INVALID_VALUE; +} +#endif + +ErrCode RSClientToServiceConnection::NotifyPageName(const std::string &packageName, + const std::string &pageName, bool isEnter) +{ + HgmTaskHandleThread::Instance().PostTask([pid = remotePid_, packageName, pageName, isEnter]() { + auto frameRateMgr = HgmCore::Instance().GetFrameRateMgr(); + if (frameRateMgr != nullptr) { + frameRateMgr->NotifyPageName(pid, packageName, pageName, isEnter); + } + }); + return StatusCode::SUCCESS; +} + +ErrCode RSClientToServiceConnection::AvcodecVideoStart( + uint64_t uniqueId, std::string& surfaceName, uint32_t fps, uint64_t reportTime) +{ + RSJankStats::GetInstance().AvcodecVideoStart(uniqueId, surfaceName, fps, reportTime); + return ERR_OK; +} + +ErrCode RSClientToServiceConnection::AvcodecVideoStop(uint64_t uniqueId, std::string& surfaceName, uint32_t fps) +{ + RSJankStats::GetInstance().AvcodecVideoStop(uniqueId, surfaceName, fps); + return ERR_OK; +} + +RetCodeHrpService RSClientToServiceConnection::ProfilerServiceOpenFile(const HrpServiceDirInfo& dirInfo, + const std::string& fileName, int32_t flags, int& outFd) +{ +#ifdef RS_PROFILER_ENABLED + if (fileName.length() == 0 || !HrpServiceValidDirOrFileName(fileName)) { + return RET_HRP_SERVICE_ERR_INVALID_PARAM; + } + + return RSProfiler::HrpServiceOpenFile(dirInfo, fileName, flags, outFd); +#else + outFd = -1; + return RET_HRP_SERVICE_ERR_UNSUPPORTED; +#endif +} + +RetCodeHrpService RSClientToServiceConnection::ProfilerServicePopulateFiles(const HrpServiceDirInfo& dirInfo, + uint32_t firstFileIndex, std::vector& outFiles) +{ +#ifdef RS_PROFILER_ENABLED + return RSProfiler::HrpServicePopulateFiles(dirInfo, firstFileIndex, outFiles); +#else + outFiles.clear(); + return RET_HRP_SERVICE_ERR_UNSUPPORTED; +#endif +} + +bool RSClientToServiceConnection::ProfilerIsSecureScreen() +{ +#ifdef RS_PROFILER_ENABLED + if (!RSSystemProperties::GetProfilerEnabled()) { + return false; + } + return RSProfiler::IsSecureScreen(); +#else + return false; +#endif +} + +void RSClientToServiceConnection::ClearUifirstCache(NodeId id) +{ + if (!mainThread_) { + return; + } + auto task = [id]() -> void { + RSUifirstManager::Instance().AddMarkedClearCacheNode(id); + }; + mainThread_->PostTask(task); +} +} // namespace Rosen +} // namespace OHOS diff --git a/rosen/modules/render_service/core/pipeline/main_thread/rs_client_to_service_connection.h b/rosen/modules/render_service/core/pipeline/main_thread/rs_client_to_service_connection.h new file mode 100644 index 0000000000000000000000000000000000000000..89dc758929ea1d1fb82d233e19dc0901044378fa --- /dev/null +++ b/rosen/modules/render_service/core/pipeline/main_thread/rs_client_to_service_connection.h @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2021-2023 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. + */ + +#ifndef RENDER_SERVICE_PIPELINE_RS_CLIENT_TO_SERVICE_CONNECTION_H +#define RENDER_SERVICE_PIPELINE_RS_CLIENT_TO_SERVICE_CONNECTION_H + +#include +#include + +#include "hgm_config_callback_manager.h" +#include "ipc_callbacks/buffer_available_callback.h" +#include "ipc_callbacks/buffer_clear_callback.h" +#include "pipeline/hardware_thread/rs_hardware_thread.h" +#include "pipeline/render_thread/rs_uni_render_thread.h" +#include "../../main/server/rs_render_service.h" +#include "screen_manager/rs_screen_manager.h" +#include "transaction/rs_client_to_service_connection_stub.h" +#include "vsync_distributor.h" + +namespace OHOS { +namespace Rosen { +class HgmFrameRateManager; +class RSClientToServiceConnection : public RSClientToServiceConnectionStub { +public: + RSClientToServiceConnection( + pid_t remotePid, + wptr renderService, + RSMainThread* mainThread, + sptr screenManager, + sptr token, + sptr distributor); + ~RSClientToServiceConnection() noexcept; + RSClientToServiceConnection(const RSClientToServiceConnection&) = delete; + RSClientToServiceConnection& operator=(const RSClientToServiceConnection&) = delete; + + sptr GetToken() const + { + return token_; + } + +private: + void CleanVirtualScreens() noexcept; + void CleanRenderNodes() noexcept; + void CleanFrameRateLinkers() noexcept; + void CleanFrameRateLinkerExpectedFpsCallbacks() noexcept; + void CleanAll(bool toDelete = false) noexcept; + + // IPC RSIClientToServiceConnection Interfaces + ErrCode CommitTransaction(std::unique_ptr& transactionData) override; + ErrCode ExecuteSynchronousTask(const std::shared_ptr& task) override; + ErrCode GetMemoryGraphic(int pid, MemoryGraphic& memoryGraphic) override; + ErrCode GetMemoryGraphics(std::vector& memoryGraphics) override; + ErrCode GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize) override; + ErrCode GetUniRenderEnabled(bool& enable) override; + + ErrCode CreateNode(const RSSurfaceRenderNodeConfig& config, bool& success) override; + ErrCode CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId, bool& success) override; + ErrCode CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, sptr& sfc, + bool unobscured = false) override; + + ErrCode CreateVSyncConnection(sptr& vsyncConn, + const std::string& name, + const sptr& token, + VSyncConnParam vsyncConnParam = {0, 0, false}) override; + + ErrCode GetDefaultScreenId(uint64_t& screenId) override; + + ErrCode GetActiveScreenId(uint64_t& screenId) override; + + std::vector GetAllScreenIds() override; + + ScreenId CreateVirtualScreen( + const std::string &name, + uint32_t width, + uint32_t height, + sptr surface, + ScreenId mirrorId = 0, + int32_t flags = 0, + std::vector whiteList = {}) override; + + int32_t SetVirtualScreenSurface(ScreenId id, sptr surface) override; + + void RemoveVirtualScreen(ScreenId id) override; + + int32_t SetScreenChangeCallback(sptr callback) override; + + void SetScreenActiveMode(ScreenId id, uint32_t modeId) override; + + void SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate) override; + + void SetRefreshRateMode(int32_t refreshRateMode) override; + + void UnregisterFrameRateLinker(FrameRateLinkerId id) override; + + uint32_t GetScreenCurrentRefreshRate(ScreenId id) override; + + int32_t GetCurrentRefreshRateMode() override; + + std::vector GetScreenSupportedRefreshRates(ScreenId id) override; + + ErrCode GetShowRefreshRateEnabled(bool& enable) override; + + void SetShowRefreshRateEnabled(bool enabled, int32_t type) override; + + uint32_t GetRealtimeRefreshRate(ScreenId screenId) override; + + ErrCode GetRefreshInfo(pid_t pid, std::string& enable) override; + ErrCode GetRefreshInfoToSP(NodeId id, std::string& enable) override; + + int32_t SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height) override; + + int32_t SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) override; + + ErrCode RepaintEverything() override; + + void SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status) override; + + ErrCode RegisterApplicationAgent(uint32_t pid, sptr app) override; + + ErrCode GetScreenActiveMode(uint64_t id, RSScreenModeInfo& info) override; + + std::vector GetScreenSupportedModes(ScreenId id) override; + + RSScreenCapability GetScreenCapability(ScreenId id) override; + + ErrCode GetScreenPowerStatus(uint64_t screenId, uint32_t& status) override; + + RSScreenData GetScreenData(ScreenId id) override; + + ErrCode GetScreenBacklight(uint64_t id, int32_t& level) override; + + void SetScreenBacklight(ScreenId id, uint32_t level) override; + + ErrCode RegisterBufferAvailableListener( + NodeId id, sptr callback, bool isFromRenderThread) override; + + ErrCode RegisterBufferClearListener( + NodeId id, sptr callback) override; + + int32_t GetScreenSupportedColorGamuts(ScreenId id, std::vector& mode) override; + + int32_t GetScreenSupportedMetaDataKeys(ScreenId id, std::vector& keys) override; + + int32_t GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode) override; + + int32_t SetScreenColorGamut(ScreenId id, int32_t modeIdx) override; + + int32_t SetScreenGamutMap(ScreenId id, ScreenGamutMap mode) override; + + int32_t SetScreenCorrection(ScreenId id, ScreenRotation screenRotation) override; + + ErrCode SetGlobalDarkColorMode(bool isDark) override; + + int32_t GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode) override; + + ErrCode GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus, int32_t& resCode) override; + + ErrCode GetScreenSupportedColorSpaces( + ScreenId id, std::vector& colorSpaces, int32_t& resCode) override; + + ErrCode GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace, int32_t& resCode) override; + + ErrCode SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace, int32_t& resCode) override; + + int32_t GetScreenType(ScreenId id, RSScreenType& screenType) override; + + ErrCode GetBitmap(NodeId id, Drawing::Bitmap& bitmap, bool& success) override; + ErrCode GetPixelmap(NodeId id, std::shared_ptr pixelmap, + const Drawing::Rect* rect, std::shared_ptr drawCmdList, bool& success) override; + + int32_t GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, std::vector& edidData) override; + + ErrCode SetScreenActiveRect(ScreenId id, const Rect& activeRect, uint32_t& repCode) override; + + void SetScreenOffset(ScreenId id, int32_t offsetX, int32_t offsetY) override; + + void SetScreenFrameGravity(ScreenId id, int32_t gravity) override; + + ErrCode SetHardwareEnabled(NodeId id, bool isEnabled, SelfDrawingNodeType selfDrawingType, + bool dynamicHardwareEnable) override; + + ErrCode SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent, uint32_t& resCode) override; + + void NotifyRefreshRateEvent(const EventInfo& eventInfo) override; + + void SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) override; + + void SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) override; + + ErrCode NotifySoftVsyncEvent(uint32_t pid, uint32_t rateDiscount) override; + + ErrCode NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt) override; + + void NotifyDynamicModeEvent(bool enableDynamicModeEvent) override; + + ErrCode NotifyXComponentExpectedFrameRate(const std::string& id, int32_t expectedFrameRate) override; + + LayerComposeInfo GetLayerComposeInfo() override; + + HwcDisabledReasonInfos GetHwcDisabledReasonInfo() override; + +#ifdef TP_FEATURE_ENABLE + ErrCode SetTpFeatureConfig(int32_t feature, const char* config, TpFeatureConfigType tpFeatureConfigType) override; +#endif + + ErrCode SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder) override; + + ErrCode SetLayerTop(const std::string &nodeIdStr, bool isTop) override; + + void RegisterTransactionDataCallback(uint64_t token, + uint64_t timeStamp, sptr callback) override; + + ErrCode NotifyScreenSwitched() override; + + int32_t RegisterSelfDrawingNodeRectChangeCallback( + const RectConstraint& constraint, sptr callback) override; + + int32_t UnRegisterSelfDrawingNodeRectChangeCallback() override; + +#ifdef RS_ENABLE_OVERLAY_DISPLAY + ErrCode SetOverlayDisplayMode(int32_t mode) override; +#endif + + ErrCode NotifyPageName(const std::string &packageName, const std::string &pageName, bool isEnter) override; + + ErrCode AvcodecVideoStart(uint64_t uniqueId, std::string& surfaceName, uint32_t fps, uint64_t reportTime) override; + + ErrCode AvcodecVideoStop(uint64_t uniqueId, std::string& surfaceName, uint32_t fps) override; + + RetCodeHrpService ProfilerServiceOpenFile(const HrpServiceDirInfo& dirInfo, + const std::string& fileName, int32_t flags, int& outFd) override; + RetCodeHrpService ProfilerServicePopulateFiles(const HrpServiceDirInfo& dirInfo, + uint32_t firstFileIndex, std::vector& outFiles) override; + bool ProfilerIsSecureScreen() override; + + void ClearUifirstCache(NodeId id) override; + + pid_t remotePid_; + wptr renderService_; + RSMainThread* mainThread_ = nullptr; +#ifdef RS_ENABLE_GPU + RSUniRenderThread& renderThread_; +#endif + sptr screenManager_; + sptr token_; + + class RSConnectionDeathRecipient : public IRemoteObject::DeathRecipient { + public: + explicit RSConnectionDeathRecipient(wptr conn); + virtual ~RSConnectionDeathRecipient() = default; + + void OnRemoteDied(const wptr& token) override; + + private: + wptr conn_; + }; + friend class RSConnectionDeathRecipient; + sptr connDeathRecipient_; + + class RSApplicationRenderThreadDeathRecipient : public IRemoteObject::DeathRecipient { + public: + explicit RSApplicationRenderThreadDeathRecipient(wptr conn); + virtual ~RSApplicationRenderThreadDeathRecipient() = default; + + void OnRemoteDied(const wptr& token) override; + + private: + wptr conn_; + }; + friend class RSApplicationRenderThreadDeathRecipient; + sptr applicationDeathRecipient_ = nullptr; + + mutable std::mutex mutex_; + bool cleanDone_ = false; + const std::string VOTER_SCENE_BLUR = "VOTER_SCENE_BLUR"; + const std::string VOTER_SCENE_GPU = "VOTER_SCENE_GPU"; + + // save all virtual screenIds created by this connection. + std::unordered_set virtualScreenIds_; + sptr screenChangeCallback_; + sptr appVSyncDistributor_; + +#ifdef RS_PROFILER_ENABLED + friend class RSProfiler; +#endif +}; +} // namespace Rosen +} // namespace OHOS + +#endif // RENDER_SERVICE_PIPELINE_RS_CLIENT_TO_SERVICE_CONNECTION_H diff --git a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp b/rosen/modules/render_service/core/transaction/rs_client_to_render_connection_stub.cpp similarity index 61% rename from rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp rename to rosen/modules/render_service/core/transaction/rs_client_to_render_connection_stub.cpp index 1a8a08a4c8178bef79e592cedea4c1d610bf505c..80e37932b6b92a64f4dc4d852ea262574bba4387 100644 --- a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp +++ b/rosen/modules/render_service/core/transaction/rs_client_to_render_connection_stub.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "rs_render_service_connection_stub.h" +#include "rs_client_to_render_connection_stub.h" #include #include #include "ivsync_connection.h" @@ -50,18 +50,12 @@ constexpr size_t FILE_DESCRIPTOR_LIMIT = 15; constexpr size_t MAX_OBJECTNUM = 512; constexpr size_t MAX_DATA_SIZE = 1024 * 1024; // 1MB static constexpr int MAX_SECURITY_EXEMPTION_LIST_NUMBER = 1024; // securityExemptionList size not exceed 1024 -const uint32_t MAX_VOTER_SIZE = 100; -constexpr uint32_t MAX_PID_SIZE_NUMBER = 100000; #ifdef RES_SCHED_ENABLE const uint32_t RS_IPC_QOS_LEVEL = 7; -constexpr const char* RS_BUNDLE_NAME = "render_service"; +constexpr const char* RS_BUNDLE_NAME = "client_to_render"; #endif static constexpr std::array descriptorCheckList = { static_cast(RSIRenderServiceConnectionInterfaceCode::SET_FOCUS_APP_INFO), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_DEFAULT_SCREEN_ID), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_SCREEN_ID), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ALL_SCREEN_IDS), - static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_VIRTUAL_SCREEN), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_PHYSICAL_SCREEN_RESOLUTION), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_RESOLUTION), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SURFACE), @@ -73,23 +67,13 @@ static constexpr std::array descriptorCheckList = { static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_SECURITY_MASK), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_MIRROR_SCREEN_VISIBLE_RECT), static_cast(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN), - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CHANGE_CALLBACK), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_MODE), - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_REFRESH_RATE), - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_REFRESH_RATE_MODE), static_cast(RSIRenderServiceConnectionInterfaceCode::SYNC_FRAME_RATE_RANGE), static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_FRAME_RATE_LINKER), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CURRENT_REFRESH_RATE), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_CURRENT_REFRESH_RATE_MODE), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_REFRESH_RATES), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SHOW_REFRESH_RATE_ENABLED), - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REALTIME_REFRESH_RATE), static_cast(RSIRenderServiceConnectionInterfaceCode::MARK_POWER_OFF_NEED_PROCESS_ONE_FRAME), static_cast(RSIRenderServiceConnectionInterfaceCode::REPAINT_EVERYTHING), static_cast(RSIRenderServiceConnectionInterfaceCode::FORCE_REFRESH_ONE_FRAME_WITH_NEXT_VSYNC), static_cast(RSIRenderServiceConnectionInterfaceCode::DISABLE_RENDER_CONTROL_SCREEN), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_DISPLAY_IDENTIFICATION_DATA), static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO_TO_SP), #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR static_cast(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_COLOR_INVERSION_CONFIG), @@ -97,28 +81,14 @@ static constexpr std::array descriptorCheckList = { static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_POINTER_LUMINANCE_CALLBACK), static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_POINTER_LUMINANCE_CALLBACK), #endif - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_POWER_STATUS), - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_BACK_LIGHT), static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_ACTIVE_MODE), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_MODES), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CAPABILITY), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_POWER_STATUS), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_BACK_LIGHT), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_DATA), static_cast(RSIRenderServiceConnectionInterfaceCode::GET_VIRTUAL_SCREEN_RESOLUTION), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_AVAILABLE_LISTENER), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_CLEAR_LISTENER), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_GAMUTS), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_METADATAKEYS), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT), - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT), - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT_MAP), - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CORRECTION), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_MIRROR_SCREEN_CANVAS_ROTATION), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_AUTO_ROTATION), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_MIRROR_SCREEN_SCALE_MODE), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_GLOBAL_DARK_COLOR_MODE), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT_MAP), static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_PIXEL_MAP_FROM_SURFACE), static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_CAPABILITY), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_PIXEL_FORMAT), @@ -128,12 +98,8 @@ static constexpr std::array descriptorCheckList = { static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_HDR_FORMAT), static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_STATUS), static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_COLORSPACES), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_COLORSPACE), - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_COLORSPACE), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_TYPE), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_SKIP_FRAME_INTERVAL), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_REFRESH_RATE), - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_RECT), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_OFFSET), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_FRAME_GRAVITY), static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_OCCLUSION_CHANGE_CALLBACK), @@ -151,9 +117,6 @@ static constexpr std::array descriptorCheckList = { static_cast(RSIRenderServiceConnectionInterfaceCode::EXECUTE_SYNCHRONOUS_TASK), static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_LIGHT_FACTOR_STATUS), static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PACKAGE_EVENT), - static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_REFRESH_RATE_EVENT), - static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_VSYNC_NAME), - static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_WINDOW_ID), static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SOFT_VSYNC_EVENT), static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SOFT_VSYNC_RATE_DISCOUNT_EVENT), static_cast(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_RESPONSE), @@ -162,8 +125,6 @@ static constexpr std::array descriptorCheckList = { static_cast(RSIRenderServiceConnectionInterfaceCode::REPORT_RS_SCENE_JANK_START), static_cast(RSIRenderServiceConnectionInterfaceCode::REPORT_RS_SCENE_JANK_END), static_cast(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_GAMESTATE), - static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_TOUCH_EVENT), - static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_DYNAMIC_MODE_EVENT), static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_HGMCONFIG_EVENT), static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_XCOMPONENT_EXPECTED_FRAMERATE), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_HARDWARE_ENABLED), @@ -172,7 +133,6 @@ static constexpr std::array descriptorCheckList = { static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK), static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_HGM_CFG_CALLBACK), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_ROTATION_CACHE_ENABLED), - static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SCREEN_SWITCHED), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_TP_FEATURE_CONFIG), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_USING_STATUS), static_cast(RSIRenderServiceConnectionInterfaceCode::REFRESH_RATE_MODE_CHANGE_CALLBACK), @@ -185,7 +145,6 @@ static constexpr std::array descriptorCheckList = { static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_FRAME_RATE_LINKER_EXPECTED_FPS_CALLBACK), static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_DIRTY_REGION_INFO), static_cast(RSIRenderServiceConnectionInterfaceCode::GET_GLOBAL_DIRTY_REGION_INFO), - static_cast(RSIRenderServiceConnectionInterfaceCode::GET_LAYER_COMPOSE_INFO), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_CAST_SCREEN_ENABLE_SKIP_WINDOW), static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_UIEXTENSION_CALLBACK), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VMA_CACHE_STATUS), @@ -196,20 +155,12 @@ static constexpr std::array descriptorCheckList = { static_cast(RSIRenderServiceConnectionInterfaceCode::SET_FREE_MULTI_WINDOW_STATUS), static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_SURFACE_BUFFER_CALLBACK), static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SURFACE_BUFFER_CALLBACK), - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP_FOR_HARDWARE_COMPOSER), - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_FORCE_REFRESH), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_COLOR_FOLLOW), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_WINDOW_CONTAINER), - static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK), - static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK), static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_TRANSACTION_DATA_CALLBACK), static_cast(RSIRenderServiceConnectionInterfaceCode::AVCODEC_VIDEO_START), static_cast(RSIRenderServiceConnectionInterfaceCode::AVCODEC_VIDEO_STOP), -#ifdef RS_ENABLE_OVERLAY_DISPLAY - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_OVERLAY_DISPLAY_MODE), -#endif - static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PAGE_NAME), static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BEHIND_WINDOW_FILTER_ENABLED), static_cast(RSIRenderServiceConnectionInterfaceCode::GET_BEHIND_WINDOW_FILTER_ENABLED), static_cast(RSIRenderServiceConnectionInterfaceCode::GET_PID_GPU_MEMORY_IN_MB), @@ -261,7 +212,7 @@ std::shared_ptr CopyParcelIfNeed(MessageParcel& old, pid_t callin } if (old.GetOffsetsSize() > MAX_OBJECTNUM) { - ROSEN_LOGW("RSRenderServiceConnectionStub::CopyParcelIfNeed failed, parcel fdCnt: %{public}zu is too large", + ROSEN_LOGW("RSClientToRenderConnectionStub::CopyParcelIfNeed failed, parcel fdCnt: %{public}zu is too large", old.GetOffsetsSize()); return nullptr; } @@ -269,18 +220,18 @@ std::shared_ptr CopyParcelIfNeed(MessageParcel& old, pid_t callin RS_TRACE_NAME("CopyParcelForUnmarsh: size:" + std::to_string(dataSize)); void* base = malloc(dataSize); if (base == nullptr) { - RS_LOGE("RSRenderServiceConnectionStub::CopyParcelIfNeed malloc failed"); + RS_LOGE("RSClientToRenderConnectionStub::CopyParcelIfNeed malloc failed"); return nullptr; } if (memcpy_s(base, dataSize, reinterpret_cast(old.GetData()), dataSize) != 0) { - RS_LOGE("RSRenderServiceConnectionStub::CopyParcelIfNeed copy parcel data failed"); + RS_LOGE("RSClientToRenderConnectionStub::CopyParcelIfNeed copy parcel data failed"); free(base); return nullptr; } auto parcelCopied = RS_PROFILER_COPY_PARCEL(old); if (!parcelCopied->ParseFrom(reinterpret_cast(base), dataSize)) { - RS_LOGE("RSRenderServiceConnectionStub::CopyParcelIfNeed ParseFrom failed"); + RS_LOGE("RSClientToRenderConnectionStub::CopyParcelIfNeed ParseFrom failed"); free(base); return nullptr; } @@ -292,11 +243,11 @@ std::shared_ptr CopyParcelIfNeed(MessageParcel& old, pid_t callin } int32_t data{0}; if (!parcelCopied->ReadInt32(data)) { - RS_LOGE("RSRenderServiceConnectionStub::CopyParcelIfNeed parcel data Read failed"); + RS_LOGE("RSClientToRenderConnectionStub::CopyParcelIfNeed parcel data Read failed"); return nullptr; } if (data != 0) { - RS_LOGE("RSRenderServiceConnectionStub::CopyParcelIfNeed parcel data not match"); + RS_LOGE("RSClientToRenderConnectionStub::CopyParcelIfNeed parcel data not match"); return nullptr; } return parcelCopied; @@ -366,7 +317,7 @@ static void TypefaceXcollieCallback(void* arg) } } -void RSRenderServiceConnectionStub::SetQos() +void RSClientToRenderConnectionStub::SetQos() { #ifdef RES_SCHED_ENABLE std::string strBundleName = RS_BUNDLE_NAME; @@ -382,14 +333,14 @@ void RSRenderServiceConnectionStub::SetQos() struct sched_param param = {0}; param.sched_priority = 1; if (sched_setscheduler(0, SCHED_FIFO, ¶m) != 0) { - RS_LOGE("RSRenderServiceConnectionStub Couldn't set SCHED_FIFO."); + RS_LOGE("RSClientToRenderConnectionStub Couldn't set SCHED_FIFO."); } else { - RS_LOGI("RSRenderServiceConnectionStub set SCHED_FIFO succeed."); + RS_LOGI("RSClientToRenderConnectionStub set SCHED_FIFO succeed."); } #endif } -int RSRenderServiceConnectionStub::OnRemoteRequest( +int RSClientToRenderConnectionStub::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { uint32_t parcelNumber = RS_PROFILER_ON_REMOTE_REQUEST(this, code, data, reply, option); @@ -408,10 +359,10 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( if (std::find(std::cbegin(descriptorCheckList), std::cend(descriptorCheckList), code) != std::cend(descriptorCheckList)) { auto token = data.ReadInterfaceToken(); - if (token != RSIRenderServiceConnection::GetDescriptor()) { + if (token != RSIClientToRenderConnection::GetDescriptor()) { if (code == static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_PIXEL_MAP_FROM_SURFACE)) { if (!reply.WriteInt32(0)) { - RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest Write failed."); + RS_LOGE("RSClientToRenderConnectionStub::OnRemoteRequest Write failed."); return ERR_INVALID_REPLY; } } @@ -424,7 +375,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( code != static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO) && code != static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_AVAILABLE_LISTENER) && code != static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_CLEAR_LISTENER)) { - RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest no permission code:%{public}d", code); + RS_LOGE("RSClientToRenderConnectionStub::OnRemoteRequest no permission code:%{public}d", code); return ERR_INVALID_STATE; } int ret = ERR_NONE; @@ -434,7 +385,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( bool isNonSystemAppCalling = false; RSInterfaceCodeAccessVerifierBase::GetAccessType(isTokenTypeValid, isNonSystemAppCalling); if (!isTokenTypeValid) { - RS_LOGE("RSRenderServiceConnectionStub::COMMIT_TRANSACTION invalid token type"); + RS_LOGE("RSClientToRenderConnectionStub::COMMIT_TRANSACTION invalid token type"); return ERR_INVALID_STATE; } if (isNonSystemAppCalling) { @@ -447,7 +398,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( std::shared_ptr ashmemFlowControlUnit = nullptr; int32_t readData{0}; if (!data.ReadInt32(readData)) { - RS_LOGE("RSRenderServiceConnectionStub::COMMIT_TRANSACTION read parcel failed"); + RS_LOGE("RSClientToRenderConnectionStub::COMMIT_TRANSACTION read parcel failed"); return ERR_INVALID_DATA; } if (readData == 0) { // indicate normal parcel @@ -467,7 +418,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( if (transactionData && isNonSystemAppCalling) { const auto& nodeMap = RSMainThread::Instance()->GetContext().GetNodeMap(); if (!transactionData->IsCallingPidValid(callingPid, nodeMap)) { - RS_LOGE("RSRenderServiceConnectionStub::COMMIT_TRANSACTION IsCallingPidValid check failed"); + RS_LOGE("RSClientToRenderConnectionStub::COMMIT_TRANSACTION IsCallingPidValid check failed"); } } CommitTransaction(transactionData); @@ -483,7 +434,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } } if (parsedParcel == nullptr) { - RS_LOGE("RSRenderServiceConnectionStub::COMMIT_TRANSACTION failed: parsed parcel is nullptr"); + RS_LOGE("RSClientToRenderConnectionStub::COMMIT_TRANSACTION failed: parsed parcel is nullptr"); return ERR_INVALID_DATA; } RSMarshallingHelper::UnmarshallingTransactionVer(*parsedParcel); @@ -497,7 +448,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( if (transactionData && isNonSystemAppCalling) { const auto& nodeMap = RSMainThread::Instance()->GetContext().GetNodeMap(); if (!transactionData->IsCallingPidValid(callingPid, nodeMap)) { - RS_LOGE("RSRenderServiceConnectionStub::COMMIT_TRANSACTION IsCallingPidValid check failed"); + RS_LOGE("RSClientToRenderConnectionStub::COMMIT_TRANSACTION IsCallingPidValid check failed"); } } CommitTransaction(transactionData); @@ -507,7 +458,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_UNI_RENDER_ENABLED): { bool enable; if (GetUniRenderEnabled(enable) != ERR_OK || !reply.WriteBool(enable)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_UNI_RENDER_ENABLED read enable failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_UNI_RENDER_ENABLED read enable failed!"); ret = ERR_INVALID_REPLY; } break; @@ -515,7 +466,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_NODE): { uint64_t nodeId{0}; if (!data.ReadUint64(nodeId)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_NODE read nodeId failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_NODE read nodeId failed!"); ret = ERR_INVALID_DATA; break; } @@ -530,14 +481,14 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( RS_PROFILER_PATCH_NODE_ID(data, nodeId); std::string surfaceName; if (!data.ReadString(surfaceName)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_NODE read surfaceName failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_NODE read surfaceName failed!"); ret = ERR_INVALID_DATA; break; } RSSurfaceRenderNodeConfig config = {.id = nodeId, .name = surfaceName}; bool success; if (CreateNode(config, success) != ERR_OK || !reply.WriteBool(success)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_NODE Write success failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_NODE Write success failed!"); ret = ERR_INVALID_REPLY; } break; @@ -545,7 +496,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_NODE_AND_SURFACE): { uint64_t nodeId{0}; if (!data.ReadUint64(nodeId)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_NODE_AND_SURFACE read nodeId failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_NODE_AND_SURFACE read nodeId failed!"); ret = ERR_INVALID_DATA; break; } @@ -563,13 +514,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( bool unobscured { false }; if (!data.ReadString(surfaceName) || !data.ReadUint8(type) || !data.ReadBool(isTextureExportNode) || !data.ReadBool(isSync) || !data.ReadUint8(surfaceWindowType) || !data.ReadBool(unobscured)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_NODE_AND_SURFACE read surfaceRenderNodeConfig failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_NODE_AND_SURFACE read surfaceRenderNodeConfig failed!"); ret = ERR_INVALID_DATA; break; } if (!CheckCreateNodeAndSurface(callingPid, static_cast(type), static_cast(surfaceWindowType))) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_NODE_AND_SURFACE CheckCreateNodeAndSurface failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_NODE_AND_SURFACE CheckCreateNodeAndSurface failed!"); ret = ERR_INVALID_DATA; break; } @@ -589,7 +540,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } auto producer = surface->GetProducer(); if (!reply.WriteRemoteObject(producer->AsObject())) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_NODE_AND_SURFACE read RemoteObject failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_NODE_AND_SURFACE read RemoteObject failed!"); ret = ERR_INVALID_REPLY; } break; @@ -597,7 +548,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_FOCUS_APP_INFO): { int32_t pid{0}; if (!data.ReadInt32(pid)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_FOCUS_APP_INFO read pid failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_FOCUS_APP_INFO read pid failed!"); ret = ERR_INVALID_DATA; break; } @@ -608,7 +559,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( uint64_t focusNodeId{0}; if (!data.ReadInt32(uid) || !data.ReadString(bundleName) || !data.ReadString(abilityName) || !RSMarshallingHelper::UnmarshallingPidPlusId(data, focusNodeId)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_FOCUS_APP_INFO read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_FOCUS_APP_INFO read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -620,74 +571,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( .focusNodeId = focusNodeId}; int32_t repCode; if (SetFocusAppInfo(info, repCode) != ERR_OK || !reply.WriteInt32(repCode)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_FOCUS_APP_INFO Write status failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_DEFAULT_SCREEN_ID): { - uint64_t screenId = INVALID_SCREEN_ID; - if (GetDefaultScreenId(screenId) != ERR_OK || !reply.WriteUint64(screenId)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_DEFAULT_SCREEN_ID Write id failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_SCREEN_ID): { - uint64_t screenId = INVALID_SCREEN_ID; - if (GetActiveScreenId(screenId) != ERR_OK || !reply.WriteUint64(screenId)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_ACTIVE_SCREEN_ID Write id failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ALL_SCREEN_IDS): { - std::vector ids = GetAllScreenIds(); - if (!reply.WriteUint32(ids.size())) { - RS_LOGE("RSRenderServiceConnectionStub::GET_ALL_SCREEN_IDS Write idsSize failed!"); - ret = ERR_INVALID_REPLY; - break; - } - for (uint32_t i = 0; i < ids.size(); i++) { - if (!reply.WriteUint64(ids[i])) { - RS_LOGE("RSRenderServiceConnectionStub::GET_ALL_SCREEN_IDS Write ids failed!"); - ret = ERR_INVALID_REPLY; - break; - } - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_VIRTUAL_SCREEN): { - // read the parcel data. - std::string name; - uint32_t width{0}; - uint32_t height{0}; - bool useSurface{false}; - if (!data.ReadString(name) || !data.ReadUint32(width) || - !data.ReadUint32(height) || !data.ReadBool(useSurface)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_VIRTUAL_SCREEN read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - sptr surface = nullptr; - if (useSurface) { - auto remoteObject = data.ReadRemoteObject(); - if (remoteObject != nullptr) { - auto bufferProducer = iface_cast(remoteObject); - surface = Surface::CreateSurfaceAsProducer(bufferProducer); - } - } - ScreenId mirrorId{INVALID_SCREEN_ID}; - int32_t flags{0}; - std::vector whiteList; - if (!data.ReadUint64(mirrorId) || !data.ReadInt32(flags) || !data.ReadUInt64Vector(&whiteList)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_VIRTUAL_SCREEN read ScreenId failed!"); - ret = ERR_INVALID_DATA; - break; - } - ScreenId id = CreateVirtualScreen(name, width, height, surface, mirrorId, flags, whiteList); - if (!reply.WriteUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_VIRTUAL_SCREEN Write id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_FOCUS_APP_INFO Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -697,13 +581,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( ScreenId id{INVALID_SCREEN_ID}; std::vector blackListVector; if (!data.ReadUint64(id) || !data.ReadUInt64Vector(&blackListVector)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_BLACKLIST read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_BLACKLIST read parcel failed!"); ret = ERR_INVALID_DATA; break; } int32_t status = SetVirtualScreenBlackList(id, blackListVector); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_BLACKLIST Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_BLACKLIST Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -713,14 +597,14 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( ScreenId id{INVALID_SCREEN_ID}; std::vector typeBlackListVector; if (!data.ReadUint64(id) || !data.ReadUInt8Vector(&typeBlackListVector)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_TYPE_BLACKLIST read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_TYPE_BLACKLIST read parcel failed!"); ret = ERR_INVALID_DATA; break; } int32_t repCode; SetVirtualScreenTypeBlackList(id, typeBlackListVector, repCode); if (!reply.WriteInt32(repCode)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_TYPE_BLACKLIST Write repCode failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_TYPE_BLACKLIST Write repCode failed!"); ret = ERR_INVALID_REPLY; } break; @@ -730,14 +614,14 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( ScreenId id{INVALID_SCREEN_ID}; std::vector blackListVector; if (!data.ReadUint64(id) || !data.ReadUInt64Vector(&blackListVector)) { - RS_LOGE("RSRenderServiceConnectionStub::ADD_VIRTUAL_SCREEN_BLACKLIST read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ADD_VIRTUAL_SCREEN_BLACKLIST read parcel failed!"); ret = ERR_INVALID_DATA; break; } int32_t repCode; AddVirtualScreenBlackList(id, blackListVector, repCode); if (!reply.WriteInt32(repCode)) { - RS_LOGE("RSRenderServiceConnectionStub::ADD_VIRTUAL_SCREEN_BLACKLIST Write repCode failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ADD_VIRTUAL_SCREEN_BLACKLIST Write repCode failed!"); ret = ERR_INVALID_REPLY; } break; @@ -747,14 +631,14 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( ScreenId id{INVALID_SCREEN_ID}; std::vector blackListVector; if (!data.ReadUint64(id) || !data.ReadUInt64Vector(&blackListVector)) { - RS_LOGE("RSRenderServiceConnectionStub::ADD_VIRTUAL_SCREEN_BLACKLIST read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ADD_VIRTUAL_SCREEN_BLACKLIST read parcel failed!"); ret = ERR_INVALID_DATA; break; } int32_t repCode; RemoveVirtualScreenBlackList(id, blackListVector, repCode); if (!reply.WriteInt32(repCode)) { - RS_LOGE("RSRenderServiceConnectionStub::REMOVE_VIRTUAL_SCREEN_BLACKLIST Write repCode failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REMOVE_VIRTUAL_SCREEN_BLACKLIST Write repCode failed!"); ret = ERR_INVALID_REPLY; } break; @@ -766,12 +650,12 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( std::vector securityExemptionList; if (!data.ReadUint64(id) || !data.ReadUInt64Vector(&securityExemptionList)) { RS_LOGE( - "RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION_LIST read parcel failed!"); + "RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION_LIST read parcel failed!"); ret = ERR_INVALID_DATA; break; } if (securityExemptionList.size() > MAX_SECURITY_EXEMPTION_LIST_NUMBER) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION_LIST" + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION_LIST" " failed: too many lists."); ret = ERR_INVALID_DATA; break; @@ -779,7 +663,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t status = SetVirtualScreenSecurityExemptionList(id, securityExemptionList); if (!reply.WriteInt32(status)) { RS_LOGE( - "RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION_LIST Write status failed!"); + "RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION_LIST Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -790,7 +674,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( ScreenId id{INVALID_SCREEN_ID}; bool enable{false}; if (!data.ReadUint64(id) || !data.ReadBool(enable)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_SECURITY_MASK read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_SCREEN_SECURITY_MASK read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -800,7 +684,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } int32_t result = SetScreenSecurityMask(id, std::move(securityMask)); if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_SECURITY_MASK Write result failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_SCREEN_SECURITY_MASK Write result failed!"); ret = ERR_INVALID_REPLY; } break; @@ -810,7 +694,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( // read the parcel data. ScreenId id = INVALID_SCREEN_ID; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_MIRROR_SCREEN_VISIBLE_RECT Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_MIRROR_SCREEN_VISIBLE_RECT Read id failed!"); ret = ERR_INVALID_REPLY; break; } @@ -820,7 +704,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t h = -1; if (!data.ReadInt32(x) || !data.ReadInt32(y) || !data.ReadInt32(w) || !data.ReadInt32(h)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_MIRROR_SCREEN_VISIBLE_RECT Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_MIRROR_SCREEN_VISIBLE_RECT Read parcel failed!"); ret = ERR_INVALID_REPLY; break; } @@ -832,13 +716,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( }; bool supportRotation{false}; if (!data.ReadBool(supportRotation)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_MIRROR_SCREEN_VISIBLE_RECT Read supportRotation failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_MIRROR_SCREEN_VISIBLE_RECT Read supportRotation failed!"); ret = ERR_INVALID_DATA; break; } int32_t status = SetMirrorScreenVisibleRect(id, mainScreenRect, supportRotation); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_MIRROR_SCREEN_VISIBLE_RECT Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_MIRROR_SCREEN_VISIBLE_RECT Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -848,13 +732,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( ScreenId id{INVALID_SCREEN_ID}; bool enable{false}; if (!data.ReadUint64(id) || !data.ReadBool(enable)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_CAST_SCREEN_ENABLE_SKIP_WINDOW Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_CAST_SCREEN_ENABLE_SKIP_WINDOW Read parcel failed!"); ret = ERR_INVALID_DATA; break; } int32_t result = SetCastScreenEnableSkipWindow(id, enable); if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_MIRROR_SCREEN_VISIBLE_RECT Write result failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_MIRROR_SCREEN_VISIBLE_RECT Write result failed!"); ret = ERR_INVALID_REPLY; } break; @@ -863,7 +747,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( // read the parcel data. ScreenId id{INVALID_SCREEN_ID}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_SURFACE Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_SURFACE Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -880,7 +764,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } int32_t status = SetVirtualScreenSurface(id, surface); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_SURFACE Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_SURFACE Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -888,34 +772,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN): { ScreenId id{INVALID_SCREEN_ID}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::REMOVE_VIRTUAL_SCREEN Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REMOVE_VIRTUAL_SCREEN Read parcel failed!"); ret = ERR_INVALID_DATA; break; } RemoveVirtualScreen(id); break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CHANGE_CALLBACK): { - auto remoteObject = data.ReadRemoteObject(); - if (remoteObject == nullptr) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_CHANGE_CALLBACK remoteObject is nullptr"); - ret = ERR_NULL_OBJECT; - break; - } - sptr cb = iface_cast(remoteObject); - if (cb == nullptr) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_CHANGE_CALLBACK callback is nullptr"); - ret = ERR_NULL_OBJECT; - break; - } - RS_LOGI("RSRenderServiceConnectionStub::SET_SCREEN_CHANGE_CALLBACK"); - int32_t status = SetScreenChangeCallback(cb); - if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_CHANGE_CALLBACK Write status failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_COLOR_INVERSION_CONFIG): { float darkBuffer { 0.f }; @@ -924,13 +787,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t rangeSize { 0 }; if (!data.ReadFloat(darkBuffer) || !data.ReadFloat(brightBuffer) || !data.ReadInt64(interval) || !data.ReadInt32(rangeSize)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_POINTER_COLOR_INVERSION_CONFIG read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_POINTER_COLOR_INVERSION_CONFIG read parcel failed!"); ret = ERR_INVALID_DATA; break; } int32_t status = SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval, rangeSize); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_POINTER_COLOR_INVERSION_CONFIG Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_POINTER_COLOR_INVERSION_CONFIG Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -938,13 +801,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_COLOR_INVERSION_ENABLED): { bool enable { false }; if (!data.ReadBool(enable)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_POINTER_COLOR_INVERSION_ENABLED read enable failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_POINTER_COLOR_INVERSION_ENABLED read enable failed!"); ret = ERR_INVALID_DATA; break; } int32_t status = SetPointerColorInversionEnabled(enable); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_POINTER_COLOR_INVERSION_ENABLED Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_POINTER_COLOR_INVERSION_ENABLED Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -962,7 +825,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } int32_t status = RegisterPointerLuminanceChangeCallback(cb); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_POINTER_LUMINANCE_CALLBACK Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_POINTER_LUMINANCE_CALLBACK Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -970,7 +833,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_POINTER_LUMINANCE_CALLBACK): { int32_t status = UnRegisterPointerLuminanceChangeCallback(); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::UNREGISTER_POINTER_LUMINANCE_CALLBACK Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::UNREGISTER_POINTER_LUMINANCE_CALLBACK Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -980,39 +843,17 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( ScreenId id{INVALID_SCREEN_ID}; uint32_t modeId{0}; if (!data.ReadUint64(id) || !data.ReadUint32(modeId)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_ACTIVE_MODE Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_SCREEN_ACTIVE_MODE Read parcel failed!"); ret = ERR_INVALID_DATA; break; } SetScreenActiveMode(id, modeId); break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_REFRESH_RATE): { - ScreenId id{INVALID_SCREEN_ID}; - int32_t sceneId{0}; - int32_t rate{0}; - if (!data.ReadUint64(id) || !data.ReadInt32(sceneId) || !data.ReadInt32(rate)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_REFRESH_RATE Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - SetScreenRefreshRate(id, sceneId, rate); - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_REFRESH_RATE_MODE): { - int32_t mode{0}; - if (!data.ReadInt32(mode)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_REFRESH_RATE_MODE Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - SetRefreshRateMode(mode); - break; - } case static_cast(RSIRenderServiceConnectionInterfaceCode::SYNC_FRAME_RATE_RANGE): { FrameRateLinkerId id{0}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::SYNC_FRAME_RATE_RANGE Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SYNC_FRAME_RATE_RANGE Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -1031,7 +872,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( if (!data.ReadUint32(min) || !data.ReadUint32(max) || !data.ReadUint32(preferred) || !data.ReadUint32(type) || !data.ReadUint32(componentScene) || !data.ReadInt32(animatorExpectedFrameRate)) { - RS_LOGE("RSRenderServiceConnectionStub::SYNC_FRAME_RATE_RANGE Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SYNC_FRAME_RATE_RANGE Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -1042,7 +883,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_FRAME_RATE_LINKER): { FrameRateLinkerId id{0}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::UNREGISTER_FRAME_RATE_LINKER Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::UNREGISTER_FRAME_RATE_LINKER Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -1055,93 +896,15 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( UnregisterFrameRateLinker(id); break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CURRENT_REFRESH_RATE): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_CURRENT_REFRESH_RATE Read id failed!"); - ret = ERR_INVALID_DATA; - break; - } - uint32_t refreshRate = GetScreenCurrentRefreshRate(id); - if (!reply.WriteUint32(refreshRate)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_CURRENT_REFRESH_RATE Write refreshRate failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_CURRENT_REFRESH_RATE_MODE): { - int32_t refreshRateMode = GetCurrentRefreshRateMode(); - if (!reply.WriteInt32(refreshRateMode)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_CURRENT_REFRESH_RATE_MODE Write refreshRateMode failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_REFRESH_RATES): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_REFRESH_RATES Read id failed!"); - ret = ERR_INVALID_DATA; - break; - } - std::vector rates = GetScreenSupportedRefreshRates(id); - if (!reply.WriteUint64(static_cast(rates.size()))) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_REFRESH_RATES Write rates failed!"); - ret = ERR_INVALID_REPLY; - break; - } - for (auto ratesIter : rates) { - if (!reply.WriteInt32(ratesIter)) { - RS_LOGE( - "RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_REFRESH_RATES Write ratesIter failed!"); - ret = ERR_INVALID_REPLY; - break; - } - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SHOW_REFRESH_RATE_ENABLED): { - bool enabled = false; - if (GetShowRefreshRateEnabled(enabled) != ERR_OK || !reply.WriteBool(enabled)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SHOW_REFRESH_RATE_ENABLED Write enabled failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED): { - bool enabled{false}; - int32_t type{0}; - if (!data.ReadBool(enabled) || !data.ReadInt32(type)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SHOW_REFRESH_RATE_ENABLED Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - SetShowRefreshRateEnabled(enabled, type); - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REALTIME_REFRESH_RATE): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_REALTIME_REFRESH_RATE Read id failed!"); - ret = ERR_INVALID_DATA; - break; - } - uint32_t refreshRate = GetRealtimeRefreshRate(id); - if (!reply.WriteUint32(refreshRate)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_REALTIME_REFRESH_RATE Read refreshRate failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO): { auto token = data.ReadInterfaceToken(); - if (token != RSIRenderServiceConnection::GetDescriptor()) { + if (token != RSIClientToRenderConnection::GetDescriptor()) { ret = ERR_INVALID_STATE; break; } int32_t pid{0}; if (!data.ReadInt32(pid)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_REFRESH_INFO Read pid failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_REFRESH_INFO Read pid failed!"); ret = ERR_INVALID_DATA; break; } @@ -1152,7 +915,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } std::string refreshInfo; if (GetRefreshInfo(pid, refreshInfo) != ERR_OK || !reply.WriteString(refreshInfo)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_REFRESH_INFO Write refreshInfo failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_REFRESH_INFO Write refreshInfo failed!"); ret = ERR_INVALID_REPLY; } break; @@ -1161,13 +924,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO_TO_SP): { uint64_t nodeId{0}; if (!data.ReadUint64(nodeId)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_REFRESH_INFO_TO_SP Read nodeId failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_REFRESH_INFO_TO_SP Read nodeId failed!"); ret = ERR_INVALID_DATA; break; } std::string refreshInfoToSP; if (GetRefreshInfoToSP(nodeId, refreshInfoToSP) != ERR_OK || !reply.WriteString(refreshInfoToSP)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_REFRESH_INFO_TO_SP Write refreshInfoToSP failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_REFRESH_INFO_TO_SP Write refreshInfoToSP failed!"); ret = ERR_INVALID_REPLY; } break; @@ -1177,13 +940,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( uint32_t width{0}; uint32_t height{0}; if (!data.ReadUint64(id) || !data.ReadUint32(width) || !data.ReadUint32(height)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_PHYSICAL_SCREEN_RESOLUTION Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_PHYSICAL_SCREEN_RESOLUTION Read parcel failed!"); ret = ERR_INVALID_DATA; break; } int32_t status = SetPhysicalScreenResolution(id, width, height); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_PHYSICAL_SCREEN_RESOLUTION Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_PHYSICAL_SCREEN_RESOLUTION Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -1193,43 +956,17 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( uint32_t width{0}; uint32_t height{0}; if (!data.ReadUint64(id) || !data.ReadUint32(width) || !data.ReadUint32(height)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_RESOLUTION Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_RESOLUTION Read parcel failed!"); ret = ERR_INVALID_DATA; break; } int32_t status = SetVirtualScreenResolution(id, width, height); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_RESOLUTION Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_RESOLUTION Write status failed!"); ret = ERR_INVALID_REPLY; } break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_DISPLAY_IDENTIFICATION_DATA): { - ScreenId id{INVALID_SCREEN_ID}; - uint8_t outPort{0}; - std::vector edidData{}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_DISPLAY_IDENTIFICATION_DATA Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - int32_t result = GetDisplayIdentificationData(id, outPort, edidData); - if (!reply.WriteUint8(result)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_DISPLAY_IDENTIFICATION_DATA Write result failed!"); - ret = IPC_STUB_WRITE_PARCEL_ERR; - break; - } - if (result != SUCCESS) { - break; - } - if (!reply.WriteUint8(outPort) || - !reply.WriteUint32(static_cast(edidData.size())) || - !reply.WriteBuffer(edidData.data(), edidData.size())) { - RS_LOGE("RSRenderServiceConnectionStub::GET_DISPLAY_IDENTIFICATION_DATA Write parcel failed!"); - ret = IPC_STUB_WRITE_PARCEL_ERR; - } - break; - } case static_cast(RSIRenderServiceConnectionInterfaceCode::MARK_POWER_OFF_NEED_PROCESS_ONE_FRAME): { MarkPowerOffNeedProcessOneFrame(); break; @@ -1245,41 +982,30 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::DISABLE_RENDER_CONTROL_SCREEN): { ScreenId id{INVALID_SCREEN_ID}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::DISABLE_RENDER_CONTROL_SCREEN Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::DISABLE_RENDER_CONTROL_SCREEN Read id failed!"); ret = ERR_INVALID_DATA; break; } DisablePowerOffRenderControl(id); break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_POWER_STATUS): { - ScreenId id{INVALID_SCREEN_ID}; - uint32_t status{0}; - if (!data.ReadUint64(id) || !data.ReadUint32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_POWER_STATUS Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - SetScreenPowerStatus(id, static_cast(status)); - break; - } case static_cast(RSIRenderServiceConnectionInterfaceCode::TAKE_SURFACE_CAPTURE): { NodeId id{0}; if (!RSMarshallingHelper::UnmarshallingPidPlusId(data, id)) { - RS_LOGE("RSRenderServiceConnectionStub::TAKE_SURFACE_CAPTURE Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::TAKE_SURFACE_CAPTURE Read parcel failed!"); ret = ERR_INVALID_DATA; break; } auto remoteObject = data.ReadRemoteObject(); if (remoteObject == nullptr) { ret = ERR_NULL_OBJECT; - RS_LOGE("RSRenderServiceConnectionStub::TakeSurfaceCapture remoteObject is nullptr"); + RS_LOGE("RSClientToRenderConnectionStub::TakeSurfaceCapture remoteObject is nullptr"); break; } sptr cb = iface_cast(remoteObject); if (cb == nullptr) { ret = ERR_NULL_OBJECT; - RS_LOGE("RSRenderServiceConnectionStub::TakeSurfaceCapture cb is nullptr"); + RS_LOGE("RSClientToRenderConnectionStub::TakeSurfaceCapture cb is nullptr"); break; } RSSurfaceCaptureConfig captureConfig; @@ -1287,17 +1013,17 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( Drawing::Rect specifiedAreaRect; if (!ReadSurfaceCaptureConfig(captureConfig, data)) { ret = ERR_INVALID_DATA; - RS_LOGE("RSRenderServiceConnectionStub::TakeSurfaceCapture read captureConfig failed"); + RS_LOGE("RSClientToRenderConnectionStub::TakeSurfaceCapture read captureConfig failed"); break; } if (!ReadSurfaceCaptureBlurParam(blurParam, data)) { ret = ERR_INVALID_DATA; - RS_LOGE("RSRenderServiceConnectionStub::TakeSurfaceCapture read blurParam failed"); + RS_LOGE("RSClientToRenderConnectionStub::TakeSurfaceCapture read blurParam failed"); break; } if (!ReadSurfaceCaptureAreaRect(specifiedAreaRect, data)) { ret = ERR_INVALID_DATA; - RS_LOGE("RSRenderServiceConnectionStub::TakeSurfaceCapture read specifiedAreaRect failed"); + RS_LOGE("RSClientToRenderConnectionStub::TakeSurfaceCapture read specifiedAreaRect failed"); break; } @@ -1315,14 +1041,14 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::TAKE_SURFACE_CAPTURE_SOLO): { NodeId id{0}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::TAKE_SURFACE_CAPTURE_SOLO Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::TAKE_SURFACE_CAPTURE_SOLO Read parcel failed!"); ret = ERR_INVALID_DATA; break; } RSSurfaceCaptureConfig captureConfig; if (!ReadSurfaceCaptureConfig(captureConfig, data)) { ret = ERR_INVALID_DATA; - RS_LOGE("RSRenderServiceConnectionStub::TAKE_SURFACE_CAPTURE_SOLO read captureConfig failed"); + RS_LOGE("RSClientToRenderConnectionStub::TAKE_SURFACE_CAPTURE_SOLO read captureConfig failed"); break; } RSSurfaceCapturePermissions permissions; @@ -1334,7 +1060,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( pixelMapIdPairVector = TakeSurfaceCaptureSoloNode(id, captureConfig, permissions); if (!RSMarshallingHelper::Marshalling(reply, pixelMapIdPairVector)) { ret = ERR_INVALID_REPLY; - RS_LOGE("RSRenderServiceConnectionStub::TAKE_SURFACE_CAPTURE_SOLO Marshalling failed"); + RS_LOGE("RSClientToRenderConnectionStub::TAKE_SURFACE_CAPTURE_SOLO Marshalling failed"); break; } break; @@ -1346,7 +1072,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( break; } if (ExtractPid(id) != callingPid) { - RS_LOGW("RSRenderServiceConnectionStub::TakeSelfSurfaceCapture failed, nodeId:[%{public}" PRIu64 + RS_LOGW("RSClientToRenderConnectionStub::TakeSelfSurfaceCapture failed, nodeId:[%{public}" PRIu64 "], callingPid:[%{public}d], pid:[%{public}d]", id, callingPid, ExtractPid(id)); ret = ERR_INVALID_DATA; break; @@ -1355,19 +1081,19 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( auto remoteObject = data.ReadRemoteObject(); if (remoteObject == nullptr) { ret = ERR_NULL_OBJECT; - RS_LOGE("RSRenderServiceConnectionStub::TakeSelfSurfaceCapture remoteObject is nullptr"); + RS_LOGE("RSClientToRenderConnectionStub::TakeSelfSurfaceCapture remoteObject is nullptr"); break; } sptr cb = iface_cast(remoteObject); if (cb == nullptr) { ret = ERR_NULL_OBJECT; - RS_LOGE("RSRenderServiceConnectionStub::TakeSelfSurfaceCapture cb is nullptr"); + RS_LOGE("RSClientToRenderConnectionStub::TakeSelfSurfaceCapture cb is nullptr"); break; } RSSurfaceCaptureConfig captureConfig; if (!ReadSurfaceCaptureConfig(captureConfig, data)) { ret = ERR_INVALID_DATA; - RS_LOGE("RSRenderServiceConnectionStub::TakeSelfSurfaceCapture read captureConfig failed"); + RS_LOGE("RSClientToRenderConnectionStub::TakeSelfSurfaceCapture read captureConfig failed"); break; } TakeSelfSurfaceCapture(id, cb, captureConfig); @@ -1376,26 +1102,26 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::TAKE_UI_CAPTURE_IN_RANGE): { NodeId id{0}; if (!RSMarshallingHelper::UnmarshallingPidPlusId(data, id)) { - RS_LOGE("RSRenderServiceConnectionStub::TAKE_UI_CAPTURE_IN_RANGE Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::TAKE_UI_CAPTURE_IN_RANGE Read parcel failed!"); ret = ERR_INVALID_DATA; break; } auto remoteObject = data.ReadRemoteObject(); if (remoteObject == nullptr) { ret = ERR_NULL_OBJECT; - RS_LOGE("RSRenderServiceConnectionStub::TAKE_UI_CAPTURE_IN_RANGE remoteObject is nullptr"); + RS_LOGE("RSClientToRenderConnectionStub::TAKE_UI_CAPTURE_IN_RANGE remoteObject is nullptr"); break; } sptr cb = iface_cast(remoteObject); if (cb == nullptr) { ret = ERR_NULL_OBJECT; - RS_LOGE("RSRenderServiceConnectionStub::TAKE_UI_CAPTURE_IN_RANGE cb is nullptr"); + RS_LOGE("RSClientToRenderConnectionStub::TAKE_UI_CAPTURE_IN_RANGE cb is nullptr"); break; } RSSurfaceCaptureConfig captureConfig; if (!ReadSurfaceCaptureConfig(captureConfig, data)) { ret = ERR_INVALID_DATA; - RS_LOGE("RSRenderServiceConnectionStub::TAKE_UI_CAPTURE_IN_RANGE read captureConfig failed"); + RS_LOGE("RSClientToRenderConnectionStub::TAKE_UI_CAPTURE_IN_RANGE read captureConfig failed"); break; } TakeUICaptureInRange(id, cb, captureConfig); @@ -1404,13 +1130,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_WINDOW_FREEZE_IMMEDIATELY): { NodeId id{0}; if (!RSMarshallingHelper::UnmarshallingPidPlusId(data, id)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_WINDOW_FREEZE_IMMEDIATELY Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_WINDOW_FREEZE_IMMEDIATELY Read id failed!"); ret = ERR_INVALID_DATA; break; } bool isFreeze{false}; if (!data.ReadBool(isFreeze)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_WINDOW_FREEZE_IMMEDIATELY Read isFreeze failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_WINDOW_FREEZE_IMMEDIATELY Read isFreeze failed!"); ret = ERR_INVALID_DATA; break; } @@ -1421,23 +1147,23 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( auto remoteObject = data.ReadRemoteObject(); if (remoteObject == nullptr) { ret = ERR_NULL_OBJECT; - RS_LOGE("RSRenderServiceConnectionStub::SET_WINDOW_FREEZE_IMMEDIATELY remoteObject is nullptr"); + RS_LOGE("RSClientToRenderConnectionStub::SET_WINDOW_FREEZE_IMMEDIATELY remoteObject is nullptr"); break; } cb = iface_cast(remoteObject); if (cb == nullptr) { ret = ERR_NULL_OBJECT; - RS_LOGE("RSRenderServiceConnectionStub::SET_WINDOW_FREEZE_IMMEDIATELY cb is nullptr"); + RS_LOGE("RSClientToRenderConnectionStub::SET_WINDOW_FREEZE_IMMEDIATELY cb is nullptr"); break; } if (!ReadSurfaceCaptureConfig(captureConfig, data)) { ret = ERR_INVALID_DATA; - RS_LOGE("RSRenderServiceConnectionStub::SET_WINDOW_FREEZE_IMMEDIATELY write captureConfig failed"); + RS_LOGE("RSClientToRenderConnectionStub::SET_WINDOW_FREEZE_IMMEDIATELY write captureConfig failed"); break; } if (!ReadSurfaceCaptureBlurParam(blurParam, data)) { ret = ERR_INVALID_DATA; - RS_LOGE("RSRenderServiceConnectionStub::TakeSurfaceCapture read blurParam failed"); + RS_LOGE("RSClientToRenderConnectionStub::TakeSurfaceCapture read blurParam failed"); break; } } @@ -1447,7 +1173,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_POSITION): { NodeId id { 0 }; if (!RSMarshallingHelper::UnmarshallingPidPlusId(data, id)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_POINTER_POSITION read nodeId failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_POINTER_POSITION read nodeId failed!"); break; } float positionX { 0.f }; @@ -1456,7 +1182,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( float positionW { 0.f }; if (!data.ReadFloat(positionX) || !data.ReadFloat(positionY) || !data.ReadFloat(positionZ) || !data.ReadFloat(positionW)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_POINTER_POSITION read position failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_POINTER_POSITION read position failed!"); ret = ERR_INVALID_DATA; break; } @@ -1482,13 +1208,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_VIRTUAL_SCREEN_RESOLUTION): { ScreenId id{INVALID_SCREEN_ID}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_VIRTUAL_SCREEN_RESOLUTION Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_VIRTUAL_SCREEN_RESOLUTION Read id failed!"); ret = ERR_INVALID_DATA; break; } RSVirtualScreenResolution virtualScreenResolution = GetVirtualScreenResolution(id); if (!reply.WriteParcelable(&virtualScreenResolution)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_VIRTUAL_SCREEN_RESOLUTION Write virtualScreenResolution " + RS_LOGE("RSClientToRenderConnectionStub::GET_VIRTUAL_SCREEN_RESOLUTION Write virtualScreenResolution " "failed!"); ret = ERR_INVALID_REPLY; } @@ -1497,45 +1223,21 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_ACTIVE_MODE): { ScreenId id{INVALID_SCREEN_ID}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_ACTIVE_MODE Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_ACTIVE_MODE Read id failed!"); ret = ERR_INVALID_DATA; break; } RSScreenModeInfo screenModeInfo; if (GetScreenActiveMode(id, screenModeInfo) != ERR_OK || !reply.WriteParcelable(&screenModeInfo)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_ACTIVE_MODE Write screenModeInfo failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_ACTIVE_MODE Write screenModeInfo failed!"); ret = ERR_INVALID_REPLY; } break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_MODES): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_MODES Read id failed!"); - ret = ERR_INVALID_DATA; - break; - } - std::vector screenSupportedModes = GetScreenSupportedModes(id); - if (!reply.WriteUint64(static_cast(screenSupportedModes.size()))) { - RS_LOGE( - "RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_MODES Write screenSupportedModesSize failed!"); - ret = ERR_INVALID_REPLY; - break; - } - for (uint32_t modeIndex = 0; modeIndex < screenSupportedModes.size(); modeIndex++) { - if (!reply.WriteParcelable(&screenSupportedModes[modeIndex])) { - RS_LOGE( - "RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_MODES Write screenSupportedModes failed!"); - ret = ERR_INVALID_REPLY; - break; - } - } - break; - } case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHIC): { int32_t pid{0}; if (!data.ReadInt32(pid)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_MEMORY_GRAPHIC Read pid failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_MEMORY_GRAPHIC Read pid failed!"); ret = ERR_INVALID_DATA; break; } @@ -1547,7 +1249,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } MemoryGraphic memoryGraphic; if (GetMemoryGraphic(pid, memoryGraphic) != ERR_OK || !reply.WriteParcelable(&memoryGraphic)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_MEMORY_GRAPHIC Write memoryGraphic failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_MEMORY_GRAPHIC Write memoryGraphic failed!"); ret = ERR_INVALID_REPLY; } break; @@ -1556,13 +1258,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( std::vector memoryGraphics; if (GetMemoryGraphics(memoryGraphics) != ERR_OK || !reply.WriteUint64(static_cast(memoryGraphics.size()))) { - RS_LOGE("RSRenderServiceConnectionStub::GET_MEMORY_GRAPHIC Write memoryGraphicsSize failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_MEMORY_GRAPHIC Write memoryGraphicsSize failed!"); ret = ERR_INVALID_REPLY; break; } for (uint32_t index = 0; index < memoryGraphics.size(); index++) { if (!reply.WriteParcelable(&memoryGraphics[index])) { - RS_LOGE("RSRenderServiceConnectionStub::GET_MEMORY_GRAPHIC Write memoryGraphics failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_MEMORY_GRAPHIC Write memoryGraphics failed!"); ret = ERR_INVALID_REPLY; break; } @@ -1574,82 +1276,15 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( float gpuMemSize = 0.f; if (GetTotalAppMemSize(cpuMemSize, gpuMemSize) != ERR_OK || !reply.WriteFloat(cpuMemSize) || !reply.WriteFloat(gpuMemSize)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_TOTAL_APP_MEM_SIZE Write parcel failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CAPABILITY): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_CAPABILITY Read id failed!"); - ret = ERR_INVALID_DATA; - break; - } - RSScreenCapability screenCapability = GetScreenCapability(id); - if (!reply.WriteParcelable(&screenCapability)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_CAPABILITY Write screenCapability failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_POWER_STATUS): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_POWER_STATUS Read id failed!"); - ret = ERR_INVALID_DATA; - break; - } - uint32_t powerStatus{static_cast(INVALID_POWER_STATUS)}; - if (GetScreenPowerStatus(id, powerStatus) != ERR_OK || !reply.WriteUint32(powerStatus)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_POWER_STATUS Write status failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_DATA): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_DATA Read id failed!"); - ret = ERR_INVALID_DATA; - break; - } - RSScreenData screenData = GetScreenData(id); - if (!reply.WriteParcelable(&screenData)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_DATA Write screenData failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_TOTAL_APP_MEM_SIZE Write parcel failed!"); ret = ERR_INVALID_REPLY; } break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_BACK_LIGHT): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_BACK_LIGHT Read id failed!"); - ret = ERR_INVALID_DATA; - break; - } - int32_t backLightLevel{static_cast(INVALID_BACKLIGHT_VALUE)}; - if (GetScreenBacklight(id, backLightLevel) != ERR_OK || !reply.WriteInt32(backLightLevel)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_BACK_LIGHT Write level failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_BACK_LIGHT): { - ScreenId id{INVALID_SCREEN_ID}; - uint32_t level{0}; - if (!data.ReadUint64(id) || !data.ReadUint32(level)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_BACK_LIGHT Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - SetScreenBacklight(id, level); - break; - } case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_AVAILABLE_LISTENER): { NodeId id{0}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_BUFFER_AVAILABLE_LISTENER Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_BUFFER_AVAILABLE_LISTENER Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -1662,7 +1297,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( auto remoteObject = data.ReadRemoteObject(); bool isFromRenderThread{false}; if (!data.ReadBool(isFromRenderThread)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_BUFFER_AVAILABLE_LISTENER read isFromRenderThread failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_BUFFER_AVAILABLE_LISTENER read isFromRenderThread failed!"); ret = ERR_INVALID_DATA; break; } @@ -1681,7 +1316,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_CLEAR_LISTENER): { NodeId id{0}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_BUFFER_CLEAR_LISTENER Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_BUFFER_CLEAR_LISTENER Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -1704,142 +1339,19 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( RegisterBufferClearListener(id, cb); break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_GAMUTS): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_GAMUTS Read id failed!"); - ret = ERR_INVALID_DATA; - break; - } - std::vector modeSend; - std::vector mode; - int32_t result = GetScreenSupportedColorGamuts(id, mode); - if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_GAMUTS Write result failed!"); - ret = ERR_INVALID_REPLY; - break; - } - if (result != StatusCode::SUCCESS) { - ret = ERR_UNKNOWN_REASON; - break; - } - std::copy(mode.begin(), mode.end(), std::back_inserter(modeSend)); - if (!reply.WriteUInt32Vector(modeSend)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_GAMUTS Write modeSend failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_METADATAKEYS): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_METADATAKEYS Read id failed!"); - ret = ERR_INVALID_DATA; - break; - } - std::vector keySend; - std::vector keys; - int32_t result = GetScreenSupportedMetaDataKeys(id, keys); - if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_METADATAKEYS Write result failed!"); - ret = ERR_INVALID_REPLY; - break; - } - if (result != StatusCode::SUCCESS) { - ret = ERR_UNKNOWN_REASON; - break; - } - for (auto i : keys) { - keySend.push_back(i); - } - if (!reply.WriteUInt32Vector(keySend)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_METADATAKEYS Write keySend failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_GAMUT Read id failed!"); - ret = ERR_INVALID_DATA; - break; - } - ScreenColorGamut mode; - int32_t result = GetScreenColorGamut(id, mode); - if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_GAMUT Write result failed!"); - ret = ERR_INVALID_REPLY; - break; - } - if (result != StatusCode::SUCCESS) { - ret = ERR_UNKNOWN_REASON; - break; - } - if (!reply.WriteUint32(mode)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_GAMUT Write mode failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT): { - ScreenId id{INVALID_SCREEN_ID}; - int32_t modeIdx{0}; - if (!data.ReadUint64(id) || !data.ReadInt32(modeIdx)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_GAMUT Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - int32_t result = SetScreenColorGamut(id, modeIdx); - if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_GAMUT Write result failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT_MAP): { - ScreenId id{INVALID_SCREEN_ID}; - int32_t mode{0}; - if (!data.ReadUint64(id) || !data.ReadInt32(mode)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_GAMUT_MAP Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - int32_t result = SetScreenGamutMap(id, static_cast(mode)); - if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_GAMUT_MAP Write parcel failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CORRECTION): { - ScreenId id{INVALID_SCREEN_ID}; - int32_t screenRotation{0}; - if (!data.ReadUint64(id) || !data.ReadInt32(screenRotation)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_CORRECTION Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - int32_t result = SetScreenCorrection(id, static_cast(screenRotation)); - if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_CORRECTION Write parcel failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } case static_cast( RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_MIRROR_SCREEN_CANVAS_ROTATION): { ScreenId id{INVALID_SCREEN_ID}; bool canvasRotation{false}; if (!data.ReadUint64(id) || !data.ReadBool(canvasRotation)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_MIRROR_SCREEN_CANVAS_ROTATION Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_MIRROR_SCREEN_CANVAS_ROTATION Read parcel failed!"); ret = ERR_INVALID_DATA; break; } bool result = SetVirtualMirrorScreenCanvasRotation(id, canvasRotation); if (!reply.WriteBool(result)) { RS_LOGE( - "RSRenderServiceConnectionStub::SET_VIRTUAL_MIRROR_SCREEN_CANVAS_ROTATION Write parcel failed!"); + "RSClientToRenderConnectionStub::SET_VIRTUAL_MIRROR_SCREEN_CANVAS_ROTATION Write parcel failed!"); ret = ERR_INVALID_REPLY; } break; @@ -1849,13 +1361,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( ScreenId id{INVALID_SCREEN_ID}; bool isAutoRotation{false}; if (!data.ReadUint64(id) || !data.ReadBool(isAutoRotation)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_AUTO_ROTATION Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_AUTO_ROTATION Read parcel failed!"); ret = ERR_INVALID_DATA; break; } int32_t result = SetVirtualScreenAutoRotation(id, isAutoRotation); if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_AUTO_ROTATION Write parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_AUTO_ROTATION Write parcel failed!"); ret = ERR_INVALID_REPLY; } break; @@ -1865,13 +1377,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( ScreenId id{INVALID_SCREEN_ID}; uint32_t scaleMode{0}; if (!data.ReadUint64(id) || !data.ReadUint32(scaleMode)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_MIRROR_SCREEN_SCALE_MODE Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_MIRROR_SCREEN_SCALE_MODE Read parcel failed!"); ret = ERR_INVALID_DATA; break; } bool result = SetVirtualMirrorScreenScaleMode(id, static_cast(scaleMode)); if (!reply.WriteBool(result)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_MIRROR_SCREEN_SCALE_MODE Write parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_MIRROR_SCREEN_SCALE_MODE Write parcel failed!"); ret = ERR_INVALID_REPLY; } break; @@ -1880,80 +1392,12 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( RSIRenderServiceConnectionInterfaceCode::SET_GLOBAL_DARK_COLOR_MODE): { bool isDark{false}; if (!data.ReadBool(isDark)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_GLOBAL_DARK_COLOR_MODE Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_GLOBAL_DARK_COLOR_MODE Read parcel failed!"); ret = ERR_INVALID_DATA; break; } if (SetGlobalDarkColorMode(isDark) != ERR_OK) { - RS_LOGE("RSRenderServiceConnectionStub::SET_GLOBAL_DARK_COLOR_MODE Write result failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT_MAP): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_GAMUT_MAP Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - ScreenGamutMap mode; - int32_t result = GetScreenGamutMap(id, mode); - if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_GAMUT_MAP Write result failed!"); - ret = ERR_INVALID_REPLY; - break; - } - if (result != StatusCode::SUCCESS) { - ret = ERR_UNKNOWN_REASON; - break; - } - if (!reply.WriteUint32(mode)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_GAMUT_MAP Write mode failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_VSYNC_CONNECTION): { - std::string name; - if (!data.ReadString(name)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_VSYNC_CONNECTION read name failed!"); - ret = ERR_INVALID_DATA; - break; - } - auto remoteObj = data.ReadRemoteObject(); - uint64_t id{0}; - NodeId windowNodeID{0}; - if (!data.ReadUint64(id) || !data.ReadUint64(windowNodeID)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_VSYNC_CONNECTION read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - if (remoteObj == nullptr) { - ret = ERR_NULL_OBJECT; - break; - } - if (!remoteObj->IsProxyObject()) { - ret = ERR_UNKNOWN_OBJECT; - break; - } - auto token = iface_cast(remoteObj); - if (token == nullptr) { - ret = ERR_UNKNOWN_OBJECT; - break; - } - sptr conn = nullptr; - VSyncConnParam vsyncConnParam = {id, windowNodeID, false}; - CreateVSyncConnection(conn, name, token, vsyncConnParam); - if (conn == nullptr) { - ret = ERR_NULL_OBJECT; - break; - } -#ifdef ENABLE_IPC_SECURITY_ACCESS_COUNTER - securityUtils_.IncreaseAccessCounter(code); -#endif - if (!reply.WriteRemoteObject(conn->AsObject())) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_VSYNC_CONNECTION Write Object failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_GLOBAL_DARK_COLOR_MODE Write result failed!"); ret = ERR_INVALID_REPLY; } break; @@ -1961,7 +1405,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_PIXELMAP_BY_PROCESSID): { uint64_t pid; if (!data.ReadUint64(pid)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_PIXELMAP_BY_PROCESSID Read pid failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_PIXELMAP_BY_PROCESSID Read pid failed!"); ret = ERR_INVALID_DATA; break; } @@ -1969,7 +1413,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t repCode; if (GetPixelMapByProcessId(pixelMapInfoVector, static_cast(pid), repCode) != ERR_OK || !reply.WriteInt32(repCode)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_PIXELMAP_BY_PROCESSID Write repCode failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_PIXELMAP_BY_PROCESSID Write repCode failed!"); ret = ERR_INVALID_REPLY; break; } @@ -1983,7 +1427,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( auto remoteObject = data.ReadRemoteObject(); if (remoteObject == nullptr) { if (!reply.WriteInt32(0)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_PIXEL_MAP_FROM_SURFACE Write Object failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_PIXEL_MAP_FROM_SURFACE Write Object failed!"); ret = ERR_INVALID_REPLY; break; } @@ -1994,7 +1438,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( sptr surface = Surface::CreateSurfaceAsProducer(bufferProducer); if (surface == nullptr) { if (!reply.WriteInt32(0)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_PIXEL_MAP_FROM_SURFACE Write parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_PIXEL_MAP_FROM_SURFACE Write parcel failed!"); ret = ERR_INVALID_REPLY; break; } @@ -2006,7 +1450,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t w = 0; int32_t h = 0; if (!data.ReadInt32(x) || !data.ReadInt32(y) || !data.ReadInt32(w) || !data.ReadInt32(h)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_PIXEL_MAP_FROM_SURFACE Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_PIXEL_MAP_FROM_SURFACE Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -2020,7 +1464,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( CreatePixelMapFromSurface(surface, srcRect, pixelMap); if (pixelMap) { if (!reply.WriteBool(true)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_PIXEL_MAP_FROM_SURFACE Read parcel failed"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_PIXEL_MAP_FROM_SURFACE Read parcel failed"); ret = ERR_INVALID_REPLY; break; } @@ -2030,7 +1474,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } } else { if (!reply.WriteBool(false)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_PIXEL_MAP_FROM_SURFACE Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_PIXEL_MAP_FROM_SURFACE Read parcel failed!"); ret = ERR_INVALID_REPLY; break; } @@ -2040,14 +1484,14 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_CAPABILITY): { ScreenId id{INVALID_SCREEN_ID}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_HDR_CAPABILITY Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_HDR_CAPABILITY Read id failed!"); ret = ERR_INVALID_DATA; break; } RSScreenHDRCapability screenHDRCapability; int32_t result = GetScreenHDRCapability(id, screenHDRCapability); if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_HDR_CAPABILITY Write result failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_HDR_CAPABILITY Write result failed!"); ret = ERR_INVALID_REPLY; break; } @@ -2056,7 +1500,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( break; } if (!reply.WriteParcelable(&screenHDRCapability)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_HDR_CAPABILITY Write screenHDRCapability failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_HDR_CAPABILITY Write screenHDRCapability failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2064,7 +1508,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_PIXEL_FORMAT): { ScreenId id{INVALID_SCREEN_ID}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_PIXEL_FORMAT Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_PIXEL_FORMAT Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -2072,7 +1516,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t resCode; GetPixelFormat(id, pixelFormat, resCode); if (!reply.WriteInt32(resCode)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_PIXEL_FORMAT Write result failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_PIXEL_FORMAT Write result failed!"); ret = ERR_INVALID_REPLY; break; } @@ -2080,7 +1524,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( break; } if (!reply.WriteUint32(static_cast(pixelFormat))) { - RS_LOGE("RSRenderServiceConnectionStub::GET_PIXEL_FORMAT Write pixelFormat failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_PIXEL_FORMAT Write pixelFormat failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2088,13 +1532,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_PIXEL_FORMAT): { ScreenId id{INVALID_SCREEN_ID}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_PIXEL_FORMAT Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_PIXEL_FORMAT Read id failed!"); ret = ERR_INVALID_DATA; break; } int32_t pixel{0}; if (!data.ReadInt32(pixel)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_PIXEL_FORMAT read pixelFormat failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_PIXEL_FORMAT read pixelFormat failed!"); ret = ERR_INVALID_DATA; break; } @@ -2102,7 +1546,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t resCode; SetPixelFormat(id, pixelFormat, resCode); if (!reply.WriteInt32(resCode)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_PIXEL_FORMAT Write result failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_PIXEL_FORMAT Write result failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2110,7 +1554,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_HDR_FORMATS): { ScreenId id{INVALID_SCREEN_ID}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_HDR_FORMATS Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_SUPPORTED_HDR_FORMATS Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -2119,7 +1563,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t resCode; GetScreenSupportedHDRFormats(id, hdrFormats, resCode); if (!reply.WriteInt32(resCode)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_HDR_FORMATS Write result failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_SUPPORTED_HDR_FORMATS Write result failed!"); ret = ERR_INVALID_REPLY; break; } @@ -2128,7 +1572,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } std::copy(hdrFormats.begin(), hdrFormats.end(), std::back_inserter(hdrFormatsSend)); if (!reply.WriteUInt32Vector(hdrFormatsSend)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_HDR_FORMATS Write hdrFormatsSend failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_SUPPORTED_HDR_FORMATS Write hdrFormatsSend failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2136,7 +1580,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_FORMAT): { ScreenId id{INVALID_SCREEN_ID}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_HDR_FORMAT Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_HDR_FORMAT Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -2144,7 +1588,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t resCode; GetScreenHDRFormat(id, hdrFormat, resCode); if (!reply.WriteInt32(resCode)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_HDR_FORMAT Write resCode failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_HDR_FORMAT Write resCode failed!"); ret = ERR_INVALID_REPLY; break; } @@ -2152,7 +1596,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( break; } if (!reply.WriteUint32(hdrFormat)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_HDR_FORMAT Write hdrFormat failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_HDR_FORMAT Write hdrFormat failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2161,14 +1605,14 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( ScreenId id{INVALID_SCREEN_ID}; int32_t modeIdx{0}; if (!data.ReadUint64(id) || !data.ReadInt32(modeIdx)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_HDR_FORMAT Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_SCREEN_HDR_FORMAT Read parcel failed!"); ret = ERR_INVALID_DATA; break; } int32_t resCode; SetScreenHDRFormat(id, modeIdx, resCode); if (!reply.WriteInt32(resCode)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_HDR_FORMAT Write resCode failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_SCREEN_HDR_FORMAT Write resCode failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2176,7 +1620,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_STATUS): { ScreenId id{INVALID_SCREEN_ID}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_HDR_STATUS Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_HDR_STATUS Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -2184,11 +1628,11 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t resCode; ret = GetScreenHDRStatus(id, hdrStatus, resCode); if (ret != ERR_OK) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_HDR_STATUS Business error(%{public}d)!", ret); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_HDR_STATUS Business error(%{public}d)!", ret); resCode = ret; } if (!reply.WriteInt32(resCode)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_HDR_STATUS Write resCode failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_HDR_STATUS Write resCode failed!"); ret = ERR_INVALID_REPLY; break; } @@ -2196,7 +1640,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( break; } if (!reply.WriteUint32(hdrStatus)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_HDR_STATUS Write hdrStatus failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_HDR_STATUS Write hdrStatus failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2204,7 +1648,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_COLORSPACES): { ScreenId id{INVALID_SCREEN_ID}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_COLORSPACES Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_SUPPORTED_COLORSPACES Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -2213,7 +1657,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t resCode; GetScreenSupportedColorSpaces(id, colorSpaces, resCode); if (!reply.WriteInt32(resCode)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_COLORSPACES Write resCode failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_SCREEN_SUPPORTED_COLORSPACES Write resCode failed!"); ret = ERR_INVALID_REPLY; break; } @@ -2223,77 +1667,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( std::copy(colorSpaces.begin(), colorSpaces.end(), std::back_inserter(colorSpacesSend)); if (!reply.WriteUInt32Vector(colorSpacesSend)) { RS_LOGE( - "RSRenderServiceConnectionStub::GET_SCREEN_SUPPORTED_COLORSPACES Write colorSpacesSend failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_COLORSPACE): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_COLORSPACE Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - GraphicCM_ColorSpaceType colorSpace; - int32_t resCode; - GetScreenColorSpace(id, colorSpace, resCode); - if (!reply.WriteInt32(resCode)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_COLORSPACE Write result failed!"); - ret = ERR_INVALID_REPLY; - break; - } - if (resCode != StatusCode::SUCCESS) { - break; - } - if (!reply.WriteUint32(colorSpace)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_COLORSPACE Write colorSpace failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_COLORSPACE): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_COLORSPACE Read id failed!"); - ret = ERR_INVALID_DATA; - break; - } - int32_t color{0}; - if (!data.ReadInt32(color)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_COLORSPACE read colorSpace failed!"); - ret = ERR_INVALID_DATA; - break; - } - GraphicCM_ColorSpaceType colorSpace = static_cast(color); - int32_t resCode; - SetScreenColorSpace(id, colorSpace, resCode); - if (!reply.WriteInt32(resCode)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_COLORSPACE Write result failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_TYPE): { - ScreenId id{INVALID_SCREEN_ID}; - if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_TYPE Read id failed!"); - ret = ERR_INVALID_DATA; - break; - } - RSScreenType type; - int32_t result = GetScreenType(id, type); - if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_TYPE Write result failed!"); - ret = ERR_INVALID_REPLY; - break; - } - if (result != StatusCode::SUCCESS) { - ret = ERR_UNKNOWN_REASON; - break; - } - if (!reply.WriteUint32(type)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_SCREEN_TYPE Write type failed!"); + "RSClientToRenderConnectionStub::GET_SCREEN_SUPPORTED_COLORSPACES Write colorSpacesSend failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2301,7 +1675,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_BITMAP): { NodeId id{0}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_BITMAP Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_BITMAP Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -2314,7 +1688,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( Drawing::Bitmap bm; bool success; if (GetBitmap(id, bm, success) != ERR_OK || !reply.WriteBool(success)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_BITMAP Write success failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_BITMAP Write success failed!"); ret = ERR_INVALID_REPLY; break; } @@ -2326,7 +1700,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_PIXELMAP): { NodeId id{0}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_PIXELMAP Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_PIXELMAP Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -2345,7 +1719,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( bool success; if (GetPixelmap(id, pixelmap, &rect, drawCmdList, success) != ERR_OK || !reply.WriteBool(success)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_PIXELMAP Write id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_PIXELMAP Write id failed!"); ret = ERR_INVALID_REPLY; break; } @@ -2359,7 +1733,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( uint64_t uniqueId{0}; uint32_t hash{0}; if (!data.ReadUint64(uniqueId) || !data.ReadUint32(hash)) { - RS_LOGE("RSRenderServiceConnectionStub::NEED_REGISTER_TYPEFACE read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::NEED_REGISTER_TYPEFACE read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -2367,11 +1741,11 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( if (IsValidCallingPid(ExtractPid(uniqueId), callingPid)) { result = !RSTypefaceCache::Instance().HasTypeface(uniqueId, hash); } else { - RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest callingPid[%{public}d] " + RS_LOGE("RSClientToRenderConnectionStub::OnRemoteRequest callingPid[%{public}d] " "no permission NEED_REGISTER_TYPEFACE", callingPid); } if (!reply.WriteBool(result)) { - RS_LOGE("RSRenderServiceConnectionStub::NEED_REGISTER_TYPEFACE Write result failed!"); + RS_LOGE("RSClientToRenderConnectionStub::NEED_REGISTER_TYPEFACE Write result failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2387,7 +1761,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( uint64_t uniqueId{0}; uint32_t hash{0}; if (!data.ReadUint64(uniqueId) || !data.ReadUint32(hash)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_TYPEFACE read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_TYPEFACE read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -2400,16 +1774,16 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( RegisterTypeface(uniqueId, typeface); } } else { - RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest callingPid[%{public}d] " + RS_LOGE("RSClientToRenderConnectionStub::OnRemoteRequest callingPid[%{public}d] " "no permission REGISTER_TYPEFACE", callingPid); } } if (xcollieFlag && typeface) { - RS_LOGW("RSRenderServiceConnectionStub::OnRemoteRequest callingPid[%{public}d] typeface[%{public}s] " + RS_LOGW("RSClientToRenderConnectionStub::OnRemoteRequest callingPid[%{public}d] typeface[%{public}s] " "size[%{public}u], too big.", callingPid, typeface->GetFamilyName().c_str(), typeface->GetSize()); } if (!reply.WriteBool(result)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_TYPEFACE Write result failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_TYPEFACE Write result failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2417,7 +1791,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_TYPEFACE): { uint64_t uniqueId{0}; if (!data.ReadUint64(uniqueId)) { - RS_LOGE("RSRenderServiceConnectionStub::UNREGISTER_TYPEFACE read uniqueId failed!"); + RS_LOGE("RSClientToRenderConnectionStub::UNREGISTER_TYPEFACE read uniqueId failed!"); ret = ERR_INVALID_DATA; break; } @@ -2426,28 +1800,28 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( RS_PROFILER_PATCH_TYPEFACE_GLOBALID(data, uniqueId); UnRegisterTypeface(uniqueId); } else { - RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest callingPid[%{public}d] " + RS_LOGE("RSClientToRenderConnectionStub::OnRemoteRequest callingPid[%{public}d] " "no permission UNREGISTER_TYPEFACE", callingPid); } break; } case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_SKIP_FRAME_INTERVAL): { if (!securityManager_.IsInterfaceCodeAccessible(code)) { - RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest no permission to access"\ + RS_LOGE("RSClientToRenderConnectionStub::OnRemoteRequest no permission to access"\ "SET_SCREEN_SKIP_FRAME_INTERVAL"); return ERR_INVALID_STATE; } ScreenId id{INVALID_SCREEN_ID}; uint32_t skipFrameInterval{0}; if (!data.ReadUint64(id) || !data.ReadUint32(skipFrameInterval)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_SKIP_FRAME_INTERVAL Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_SCREEN_SKIP_FRAME_INTERVAL Read parcel failed!"); ret = ERR_INVALID_DATA; break; } int32_t statusCode{ SUCCESS }; if (SetScreenSkipFrameInterval(id, skipFrameInterval, statusCode) != ERR_OK || !reply.WriteInt32(statusCode)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_SKIP_FRAME_INTERVAL Write result failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_SCREEN_SKIP_FRAME_INTERVAL Write result failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2456,7 +1830,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( ScreenId id = 0; uint32_t maxRefreshRate = 0; if (!data.ReadUint64(id) || !data.ReadUint32(maxRefreshRate)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_REFRESH_RATE Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_REFRESH_RATE Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -2464,37 +1838,12 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t result = 0; SetVirtualScreenRefreshRate(id, maxRefreshRate, actualRefreshRate, result); if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_REFRESH_RATE Write result failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_REFRESH_RATE Write result failed!"); return ERR_INVALID_REPLY; } if (!reply.WriteUint32(actualRefreshRate)) { RS_LOGE( - "RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_REFRESH_RATE Write actualRefreshRate failed!"); - return ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_RECT): { - ScreenId id{INVALID_SCREEN_ID}; - int32_t x{0}; - int32_t y{0}; - int32_t w{0}; - int32_t h{0}; - if (!data.ReadUint64(id) || !data.ReadInt32(x) || !data.ReadInt32(y) || - !data.ReadInt32(w) || !data.ReadInt32(h)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_ACTIVE_RECT Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - Rect activeRect { - .x = x, - .y = y, - .w = w, - .h = h - }; - uint32_t repCode; - if (SetScreenActiveRect(id, activeRect, repCode) != ERR_OK || !reply.WriteUint32(repCode)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_ACTIVE_RECT Write result failed!"); + "RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_REFRESH_RATE Write actualRefreshRate failed!"); return ERR_INVALID_REPLY; } break; @@ -2504,7 +1853,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t offsetX = 0; int32_t offsetY = 0; if (!data.ReadUint64(id) || !data.ReadInt32(offsetX) || !data.ReadInt32(offsetY)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_OFFSET Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_SCREEN_OFFSET Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -2515,7 +1864,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( ScreenId id = INVALID_SCREEN_ID; int32_t gravity = 0; if (!data.ReadUint64(id) || !data.ReadInt32(gravity)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SCREEN_FRAME_GRAVITY Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_SCREEN_FRAME_GRAVITY Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -2525,7 +1874,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_OCCLUSION_CHANGE_CALLBACK): { auto remoteObject = data.ReadRemoteObject(); if (remoteObject == nullptr) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_OCCLUSION_CHANGE_CALLBACK Read remoteObject failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_OCCLUSION_CHANGE_CALLBACK Read remoteObject failed!"); ret = ERR_NULL_OBJECT; break; } @@ -2536,7 +1885,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } int32_t repCode; if (RegisterOcclusionChangeCallback(callback, repCode) != ERR_OK || !reply.WriteInt32(repCode)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_OCCLUSION_CHANGE_CALLBACK Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_OCCLUSION_CHANGE_CALLBACK Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2545,7 +1894,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( RSIRenderServiceConnectionInterfaceCode::REGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK): { NodeId id{0}; if (!RSMarshallingHelper::UnmarshallingPidPlusId(data, id)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -2557,7 +1906,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } auto remoteObject = data.ReadRemoteObject(); if (remoteObject == nullptr) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK Read remoteObject " + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK Read remoteObject " "failed!"); ret = ERR_NULL_OBJECT; break; @@ -2570,7 +1919,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } std::vector partitionPoints; if (!data.ReadFloatVector(&partitionPoints)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK Read " + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK Read " "partitionPoints failed!"); ret = ERR_TRANSACTION_FAILED; break; @@ -2578,7 +1927,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t status = RegisterSurfaceOcclusionChangeCallback(id, callback, partitionPoints); if (!reply.WriteInt32(status)) { RS_LOGE( - "RSRenderServiceConnectionStub::REGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK Write status failed!"); + "RSClientToRenderConnectionStub::REGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2587,7 +1936,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK): { NodeId id{0}; if (!RSMarshallingHelper::UnmarshallingPidPlusId(data, id)) { - RS_LOGE("RSRenderServiceConnectionStub::UNREGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::UNREGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -2600,7 +1949,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t status = UnRegisterSurfaceOcclusionChangeCallback(id); if (!reply.WriteInt32(status)) { RS_LOGE( - "RSRenderServiceConnectionStub::UNREGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK Write status failed!"); + "RSClientToRenderConnectionStub::UNREGISTER_SURFACE_OCCLUSION_CHANGE_CALLBACK Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2608,7 +1957,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_APP_WINDOW_NUM): { uint32_t num{0}; if (!data.ReadUint32(num)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_APP_WINDOW_NUM Read num failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_APP_WINDOW_NUM Read num failed!"); ret = ERR_INVALID_DATA; break; } @@ -2620,14 +1969,14 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( uint32_t systemAnimatedScenes{0}; bool isRegularAnimation{false}; if (!data.ReadUint32(systemAnimatedScenes) || !data.ReadBool(isRegularAnimation)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SYSTEM_ANIMATED_SCENES Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_SYSTEM_ANIMATED_SCENES Read parcel failed!"); ret = ERR_INVALID_DATA; break; } bool success; if (SetSystemAnimatedScenes(static_cast(systemAnimatedScenes), isRegularAnimation, success) != ERR_OK || !reply.WriteBool(success)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_SYSTEM_ANIMATED_SCENES Write result failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_SYSTEM_ANIMATED_SCENES Write result failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2639,19 +1988,19 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } std::string name; if (!data.ReadString(name)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_WATERMARK Read name failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_WATERMARK Read name failed!"); ret = ERR_INVALID_DATA; break; } auto watermark = std::shared_ptr(data.ReadParcelable()); if (watermark == nullptr) { ret = ERR_NULL_OBJECT; - RS_LOGE("RSRenderServiceConnectionStub::std::shared_ptr watermark == nullptr"); + RS_LOGE("RSClientToRenderConnectionStub::std::shared_ptr watermark == nullptr"); break; } bool success; if (SetWatermark(name, watermark, success) != ERR_OK || !success) { - RS_LOGE("RSRenderServiceConnectionStub::SetWatermark failed"); + RS_LOGE("RSClientToRenderConnectionStub::SetWatermark failed"); } break; } @@ -2660,7 +2009,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( std::shared_ptr(data.ReadParcelable()); bool isShow{false}; if (!data.ReadBool(isShow)) { - RS_LOGE("RSRenderServiceConnectionStub::SHOW_WATERMARK Read isShow failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SHOW_WATERMARK Read isShow failed!"); ret = ERR_INVALID_DATA; break; } @@ -2672,13 +2021,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( uint32_t width{0}; uint32_t height{0}; if (!data.ReadUint64(id) || !data.ReadUint32(width) || !data.ReadUint32(height)) { - RS_LOGE("RSRenderServiceConnectionStub::RESIZE_VIRTUAL_SCREEN Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::RESIZE_VIRTUAL_SCREEN Read parcel failed!"); ret = ERR_INVALID_DATA; break; } int32_t status = ResizeVirtualScreen(id, width, height); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::RESIZE_VIRTUAL_SCREEN Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::RESIZE_VIRTUAL_SCREEN Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2745,7 +2094,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int16_t type{0}; int16_t subType{0}; if (!data.ReadInt16(type) || !data.ReadInt16(subType)) { - RS_LOGE("RSRenderServiceConnectionStub::EXECUTE_SYNCHRONOUS_TASK Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::EXECUTE_SYNCHRONOUS_TASK Read parcel failed!"); ret = ERR_INVALID_STATE; break; } @@ -2778,7 +2127,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_HARDWARE_ENABLED) : { uint64_t id{0}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_HARDWARE_ENABLED Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_HARDWARE_ENABLED Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -2793,7 +2142,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( if (!data.ReadBool(isEnabled) || !data.ReadUint8(selfDrawingType) || !data.ReadBool(dynamicHardwareEnable)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_HARDWARE_ENABLED Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_HARDWARE_ENABLED Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -2803,7 +2152,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_HIDE_PRIVACY_CONTENT) : { uint64_t id{0}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_HIDE_PRIVACY_CONTENT Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_HIDE_PRIVACY_CONTENT Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -2812,7 +2161,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( "::SET_HIDE_PRIVACY_CONTENT"); if (!isSystemCalling) { if (!reply.WriteUint32(static_cast(RSInterfaceErrorCode::NONSYSTEM_CALLING))) { - RS_LOGE("RSRenderServiceConnectionStub::SET_HIDE_PRIVACY_CONTENT Write isSystemCalling failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_HIDE_PRIVACY_CONTENT Write isSystemCalling failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2821,21 +2170,21 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( RS_LOGW("The SetHidePrivacyContent isn't legal, nodeId:%{public}" PRIu64 ", callingPid:%{public}d", id, callingPid); if (!reply.WriteUint32(static_cast(RSInterfaceErrorCode::NOT_SELF_CALLING))) { - RS_LOGE("RSRenderServiceConnectionStub::SET_HIDE_PRIVACY_CONTENT Write ErrorCode failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_HIDE_PRIVACY_CONTENT Write ErrorCode failed!"); ret = ERR_INVALID_REPLY; } break; } bool needHidePrivacyContent{false}; if (!data.ReadBool(needHidePrivacyContent)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_HIDE_PRIVACY_CONTENT read needHidePrivacyContent failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_HIDE_PRIVACY_CONTENT read needHidePrivacyContent failed!"); ret = ERR_INVALID_DATA; break; } uint32_t resCode; if (SetHidePrivacyContent(id, needHidePrivacyContent, resCode) != ERR_OK || !reply.WriteUint32(resCode)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_HIDE_PRIVACY_CONTENT Write resCode failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_HIDE_PRIVACY_CONTENT Write resCode failed!"); ret = ERR_INVALID_REPLY; } break; @@ -2843,7 +2192,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_LIGHT_FACTOR_STATUS) : { int32_t lightFactorStatus{0}; if (!data.ReadInt32(lightFactorStatus)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_LIGHT_FACTOR_STATUS Read lightFactorStatus failed!"); + RS_LOGE("RSClientToRenderConnectionStub::NOTIFY_LIGHT_FACTOR_STATUS Read lightFactorStatus failed!"); ret = ERR_INVALID_DATA; break; } @@ -2853,7 +2202,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PACKAGE_EVENT) : { uint32_t listSize{0}; if (!data.ReadUint32(listSize)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_PACKAGE_EVENT Read listSize failed!"); + RS_LOGE("RSClientToRenderConnectionStub::NOTIFY_PACKAGE_EVENT Read listSize failed!"); ret = ERR_INVALID_DATA; break; } @@ -2867,7 +2216,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( for (uint32_t i = 0; i < listSize; i++) { std::string package; if (!data.ReadString(package)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_PACKAGE_EVENT Read package failed!"); + RS_LOGE("RSClientToRenderConnectionStub::NOTIFY_PACKAGE_EVENT Read package failed!"); errFlag = true; break; } @@ -2884,7 +2233,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( std::string pkgName; uint32_t listSize{0}; if (!data.ReadString(pkgName) || !data.ReadUint32(listSize)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_APP_STRATEGY_CONFIG_CHANGE_EVENT Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::NOTIFY_APP_STRATEGY_CONFIG_CHANGE_EVENT Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -2900,7 +2249,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( std::string key; std::string value; if (!data.ReadString(key) || !data.ReadString(value)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_APP_STRATEGY_CONFIG_CHANGE_EVENT Read newConfig " + RS_LOGE("RSClientToRenderConnectionStub::NOTIFY_APP_STRATEGY_CONFIG_CHANGE_EVENT Read newConfig " "failed!"); errFlag = true; break; @@ -2914,101 +2263,11 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( NotifyAppStrategyConfigChangeEvent(pkgName, listSize, newConfig); break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_REFRESH_RATE_EVENT) : { - std::string eventName; - bool eventStatus{false}; - uint32_t minRefreshRate{0}; - uint32_t maxRefreshRate{0}; - std::string description; - if (!data.ReadString(eventName) || !data.ReadBool(eventStatus) || !data.ReadUint32(minRefreshRate) || - !data.ReadUint32(maxRefreshRate) || !data.ReadString(description)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_REFRESH_RATE_EVENT Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - EventInfo eventInfo = { - eventName, eventStatus, minRefreshRate, maxRefreshRate, description - }; - NotifyRefreshRateEvent(eventInfo); - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_WINDOW_ID) : { - std::unordered_map eventInfos; - - uint32_t mapSize{0}; - if (!data.ReadUint32(mapSize)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_WINDOW_EXPECTED_BY_WINDOW_ID Read mapSize failed!"); - ret = ERR_INVALID_DATA; - break; - } - if (mapSize > MAX_VOTER_SIZE) { - ret = ERR_INVALID_STATE; - break; - } - bool shouldBreak = false; - for (uint32_t i = 0; i < mapSize; ++i) { - uint64_t windowId{0}; - if (!data.ReadUint64(windowId)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_WINDOW_EXPECTED_BY_WINDOW_ID Read parcel failed!"); - ret = ERR_INVALID_DATA; - shouldBreak = true; - break; - } - EventInfo eventInfo; - if (!EventInfo::Deserialize(data, eventInfo)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_WINDOW_EXPECTED_BY_WINDOW_ID Read parcel failed!"); - ret = ERR_INVALID_DATA; - shouldBreak = true; - break; - } - eventInfos[windowId] = eventInfo; - } - if (!shouldBreak) { - SetWindowExpectedRefreshRate(eventInfos); - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_VSYNC_NAME) : { - std::unordered_map eventInfos; - - uint32_t mapSize{0}; - if (!data.ReadUint32(mapSize)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_WINDOW_EXPECTED_BY_VSYNC_NAME Read mapSize failed!"); - ret = ERR_INVALID_DATA; - break; - } - if (mapSize > MAX_VOTER_SIZE) { - ret = ERR_INVALID_STATE; - break; - } - bool shouldBreak = false; - for (uint32_t i = 0; i < mapSize; ++i) { - std::string vsyncName; - if (!data.ReadString(vsyncName)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_WINDOW_EXPECTED_BY_VSYNC_NAME Read parcel failed!"); - ret = ERR_INVALID_DATA; - shouldBreak = true; - break; - } - EventInfo eventInfo; - if (!EventInfo::Deserialize(data, eventInfo)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_WINDOW_EXPECTED_BY_VSYNC_NAME Read parcel failed!"); - ret = ERR_INVALID_DATA; - shouldBreak = true; - break; - } - eventInfos[vsyncName] = eventInfo; - } - if (!shouldBreak) { - SetWindowExpectedRefreshRate(eventInfos); - } - break; - } case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SOFT_VSYNC_EVENT) : { uint32_t pid{0}; uint32_t rateDiscount{0}; if (!data.ReadUint32(pid) || !data.ReadUint32(rateDiscount)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_SOFT_VSYNC_EVENT Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::NOTIFY_SOFT_VSYNC_EVENT Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -3020,7 +2279,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( std::string name; uint32_t rateDiscount{0}; if (!data.ReadUint32(pid) || !data.ReadString(name) || !data.ReadUint32(rateDiscount)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_SOFT_VSYNC_RATE_DISCOUNT_EVENT Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::NOTIFY_SOFT_VSYNC_RATE_DISCOUNT_EVENT Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -3030,32 +2289,11 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_DYNAMIC_MODE_EVENT) : { - bool enableDynamicMode{false}; - if (!data.ReadBool(enableDynamicMode)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_DYNAMIC_MODE_EVENT Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - NotifyDynamicModeEvent(enableDynamicMode); - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_TOUCH_EVENT) : { - int32_t touchStatus{0}; - int32_t touchCnt{0}; - if (!data.ReadInt32(touchStatus) || !data.ReadInt32(touchCnt)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_TOUCH_EVENT Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - NotifyTouchEvent(touchStatus, touchCnt); - break; - } case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_HGMCONFIG_EVENT) : { std::string eventName; bool state{false}; if (!data.ReadString(eventName) || !data.ReadBool(state)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_HGMCONFIG_EVENT Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::NOTIFY_HGMCONFIG_EVENT Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -3066,7 +2304,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( std::string id; int32_t expectedFrameRate; if (!data.ReadString(id) || !data.ReadInt32(expectedFrameRate)) { - RS_LOGE("RSRenderServiceConnectionStub::NOTIFY_XCOMPONENT_EXPECTED_FRAMERATE Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::NOTIFY_XCOMPONENT_EXPECTED_FRAMERATE Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -3076,7 +2314,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_HGM_CFG_CALLBACK) : { auto remoteObject = data.ReadRemoteObject(); if (remoteObject == nullptr) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_HGM_CFG_CALLBACK Read remoteObject failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_HGM_CFG_CALLBACK Read remoteObject failed!"); ret = ERR_NULL_OBJECT; break; } @@ -3087,7 +2325,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } int32_t status = RegisterHgmConfigChangeCallback(callback); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_HGM_CFG_CALLBACK Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_HGM_CFG_CALLBACK Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -3095,7 +2333,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::REFRESH_RATE_MODE_CHANGE_CALLBACK) : { auto remoteObject = data.ReadRemoteObject(); if (remoteObject == nullptr) { - RS_LOGE("RSRenderServiceConnectionStub::REFRESH_RATE_MODE_CHANGE_CALLBACK Read remoteObject failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REFRESH_RATE_MODE_CHANGE_CALLBACK Read remoteObject failed!"); ret = ERR_NULL_OBJECT; break; } @@ -3107,7 +2345,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } int32_t status = RegisterHgmRefreshRateModeChangeCallback(callback); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::REFRESH_RATE_MODE_CHANGE_CALLBACK Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REFRESH_RATE_MODE_CHANGE_CALLBACK Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -3117,7 +2355,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( sptr remoteObject = nullptr; bool readRemoteObject{false}; if (!data.ReadBool(readRemoteObject)) { - RS_LOGE("RSRenderServiceConnectionStub::REFRESH_RATE_UPDATE_CALLBACK Read remoteObject failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REFRESH_RATE_UPDATE_CALLBACK Read remoteObject failed!"); ret = ERR_INVALID_DATA; break; } @@ -3129,7 +2367,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } int32_t status = RegisterHgmRefreshRateUpdateCallback(callback); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::REFRESH_RATE_UPDATE_CALLBACK Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REFRESH_RATE_UPDATE_CALLBACK Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -3161,7 +2399,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t dstPid{0}; bool readRemoteObject{false}; if (!data.ReadInt32(dstPid) || !data.ReadBool(readRemoteObject)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_FRAME_RATE_LINKER_EXPECTED_FPS_CALLBACK Read parcel " + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_FRAME_RATE_LINKER_EXPECTED_FPS_CALLBACK Read parcel " "failed!"); ret = ERR_INVALID_DATA; break; @@ -3174,7 +2412,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } int32_t status = RegisterFrameRateLinkerExpectedFpsUpdateCallback(dstPid, callback); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_FRAME_RATE_LINKER_EXPECTED_FPS_CALLBACK Write status " + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_FRAME_RATE_LINKER_EXPECTED_FPS_CALLBACK Write status " "failed!"); ret = ERR_INVALID_REPLY; } @@ -3183,7 +2421,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_ROTATION_CACHE_ENABLED) : { bool isEnabled = false; if (!data.ReadBool(isEnabled)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_ROTATION_CACHE_ENABLED Read isEnabled failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_ROTATION_CACHE_ENABLED Read isEnabled failed!"); ret = IPC_STUB_INVALID_DATA_ERR; break; } @@ -3193,7 +2431,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_DIRTY_REGION_INFO) : { const auto& activeDirtyRegionInfos = GetActiveDirtyRegionInfo(); if (!reply.WriteInt32(activeDirtyRegionInfos.size())) { - RS_LOGE("RSRenderServiceConnectionStub::GET_ACTIVE_DIRTY_REGION_INFO Write activeDirtyRegionInfosSize " + RS_LOGE("RSClientToRenderConnectionStub::GET_ACTIVE_DIRTY_REGION_INFO Write activeDirtyRegionInfosSize " "failed!"); ret = ERR_INVALID_REPLY; break; @@ -3203,7 +2441,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( !reply.WriteInt32(activeDirtyRegionInfo.activeFramesNumber) || !reply.WriteInt32(activeDirtyRegionInfo.pidOfBelongsApp) || !reply.WriteString(activeDirtyRegionInfo.windowName)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_ACTIVE_DIRTY_REGION_INFO Write activeDirtyRegionInfos " + RS_LOGE("RSClientToRenderConnectionStub::GET_ACTIVE_DIRTY_REGION_INFO Write activeDirtyRegionInfos " "failed!"); ret = ERR_INVALID_REPLY; break; @@ -3218,57 +2456,16 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( !reply.WriteInt32(globalDirtyRegionInfo.skipProcessFramesNumber) || !reply.WriteInt32(globalDirtyRegionInfo.mostSendingPidWhenDisplayNodeSkip)) { RS_LOGE( - "RSRenderServiceConnectionStub::GET_GLOBAL_DIRTY_REGION_INFO Write globalDirtyRegionInfo failed!"); + "RSClientToRenderConnectionStub::GET_GLOBAL_DIRTY_REGION_INFO Write globalDirtyRegionInfo failed!"); ret = ERR_INVALID_REPLY; } break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_LAYER_COMPOSE_INFO) : { - const auto& LayerComposeInfo = GetLayerComposeInfo(); - if (!reply.WriteInt32(LayerComposeInfo.uniformRenderFrameNumber) || - !reply.WriteInt32(LayerComposeInfo.offlineComposeFrameNumber) || - !reply.WriteInt32(LayerComposeInfo.redrawFrameNumber)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_LAYER_COMPOSE_INFO Write LayerComposeInfo failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode:: - GET_HARDWARE_COMPOSE_DISABLED_REASON_INFO) : { - const auto& hwcDisabledReasonInfos = GetHwcDisabledReasonInfo(); - if (!reply.WriteInt32(hwcDisabledReasonInfos.size())) { - RS_LOGE("RSRenderServiceConnectionStub::GET_HARDWARE_COMPOSE_DISABLED_REASON_INFO Write " - "hwcDisabledReasonInfos failed!"); - ret = ERR_INVALID_REPLY; - break; - } - for (const auto& hwcDisabledReasonInfo : hwcDisabledReasonInfos) { - for (const auto& disabledReasonCount : hwcDisabledReasonInfo.disabledReasonStatistics) { - if (!reply.WriteInt32(disabledReasonCount)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_HARDWARE_COMPOSE_DISABLED_REASON_INFO Write " - "disabledReasonCount failed!"); - ret = ERR_INVALID_REPLY; - break; - } - } - if (ret == ERR_INVALID_REPLY) { - break; - } - if (!reply.WriteInt32(hwcDisabledReasonInfo.pidOfBelongsApp) || - !reply.WriteString(hwcDisabledReasonInfo.nodeName)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_HARDWARE_COMPOSE_DISABLED_REASON_INFO Write " - "hwcDisabledReasonInfo failed!"); - ret = ERR_INVALID_REPLY; - break; - } - } - break; - } case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_HDR_ON_DURATION) : { int64_t hdrOnDuration = 0; auto errCode = GetHdrOnDuration(hdrOnDuration); if (errCode != ERR_OK || !reply.WriteInt64(hdrOnDuration)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_HDR_ON_DURATION Write " + RS_LOGE("RSClientToRenderConnectionStub::GET_HDR_ON_DURATION Write " "hdrOnDuration failed!"); ret = ERR_INVALID_REPLY; } @@ -3278,19 +2475,19 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_TP_FEATURE_CONFIG) : { int32_t feature{0}; if (!data.ReadInt32(feature)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_TP_FEATURE_CONFIG Read feature failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_TP_FEATURE_CONFIG Read feature failed!"); ret = ERR_INVALID_DATA; break; } auto config = data.ReadCString(); if (config == nullptr) { - RS_LOGE("RSRenderServiceConnectionStub::SET_TP_FEATURE_CONFIG Read config failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_TP_FEATURE_CONFIG Read config failed!"); ret = ERR_INVALID_DATA; break; } uint8_t tpFeatureConfigType{0}; if (!data.ReadUint8(tpFeatureConfigType)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_TP_FEATURE_CONFIG Read tpFeatureConfigType failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_TP_FEATURE_CONFIG Read tpFeatureConfigType failed!"); ret = ERR_INVALID_DATA; break; } @@ -3301,7 +2498,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_USING_STATUS) : { bool isVirtualScreenUsingStatus{false}; if (!data.ReadBool(isVirtualScreenUsingStatus)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_USING_STATUS Read " + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_USING_STATUS Read " "isVirtualScreenUsingStatus failed!"); ret = ERR_INVALID_DATA; break; @@ -3313,7 +2510,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_CURTAIN_SCREEN_USING_STATUS) : { bool isCurtainScreenOn{false}; if (!data.ReadBool(isCurtainScreenOn)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_CURTAIN_SCREEN_USING_STATUS Read " + RS_LOGE("RSClientToRenderConnectionStub::SET_CURTAIN_SCREEN_USING_STATUS Read " "isCurtainScreenOn failed!"); ret = ERR_INVALID_DATA; break; @@ -3324,7 +2521,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::DROP_FRAME_BY_PID) : { std::vector pidList; if (!data.ReadInt32Vector(&pidList)) { - RS_LOGE("RSRenderServiceConnectionStub::DROP_FRAME_BY_PID Read " + RS_LOGE("RSClientToRenderConnectionStub::DROP_FRAME_BY_PID Read " "pidList failed!"); ret = ERR_INVALID_REPLY; break; @@ -3335,14 +2532,14 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_UIEXTENSION_CALLBACK): { uint64_t userId{0}; if (!data.ReadUint64(userId)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_UIEXTENSION_CALLBACK Read " + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_UIEXTENSION_CALLBACK Read " "userId failed!"); ret = ERR_INVALID_DATA; break; } auto remoteObject = data.ReadRemoteObject(); if (remoteObject == nullptr) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_UIEXTENSION_CALLBACK Read remoteObject failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_UIEXTENSION_CALLBACK Read remoteObject failed!"); ret = ERR_NULL_OBJECT; break; } @@ -3353,13 +2550,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( } bool unobscured{false}; if (!data.ReadBool(unobscured)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_UIEXTENSION_CALLBACK Read unobscured failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_UIEXTENSION_CALLBACK Read unobscured failed!"); ret = ERR_INVALID_DATA; break; } int32_t status = RegisterUIExtensionCallback(userId, callback, unobscured); if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_UIEXTENSION_CALLBACK Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_UIEXTENSION_CALLBACK Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -3368,34 +2565,22 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( ScreenId id{INVALID_SCREEN_ID}; uint8_t screenStatus{0}; if (!data.ReadUint64(id) || !data.ReadUint8(screenStatus)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_STATUS Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_STATUS Read parcel failed!"); ret = ERR_INVALID_DATA; break; } bool success; SetVirtualScreenStatus(id, static_cast(screenStatus), success); if (!reply.WriteBool(success)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VIRTUAL_SCREEN_STATUS Write result failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VIRTUAL_SCREEN_STATUS Write result failed!"); ret = ERR_INVALID_REPLY; } break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PAGE_NAME) : { - std::string packageName; - std::string pageName; - bool isEnter{false}; - if (!data.ReadString(packageName) || !data.ReadString(pageName) || !data.ReadBool(isEnter)) { - RS_LOGE("NOTIFY_PAGE_NAME read data err."); - ret = ERR_INVALID_DATA; - break; - } - NotifyPageName(packageName, pageName, isEnter); - break; - } case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VMA_CACHE_STATUS) : { bool flag{false}; if (!data.ReadBool(flag)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_VMA_CACHE_STATUS read flag failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_VMA_CACHE_STATUS read flag failed!"); ret = ERR_INVALID_DATA; break; } @@ -3405,13 +2590,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_ANCO_FORCE_DO_DIRECT) : { bool direct{false}; if (!data.ReadBool(direct)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_ANCO_FORCE_DO_DIRECT Read direct failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_ANCO_FORCE_DO_DIRECT Read direct failed!"); ret = ERR_INVALID_DATA; break; } bool res; if (SetAncoForceDoDirect(direct, res) != ERR_OK || !reply.WriteBool(res)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_ANCO_FORCE_DO_DIRECT Write result failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_ANCO_FORCE_DO_DIRECT Write result failed!"); ret = ERR_INVALID_REPLY; } break; @@ -3419,7 +2604,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_DISPLAY_NODE) : { uint64_t id{0}; if (!data.ReadUint64(id)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_DISPLAY_NODE Read id failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_DISPLAY_NODE Read id failed!"); ret = ERR_INVALID_DATA; break; } @@ -3437,7 +2622,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( if (!data.ReadUint64(mirroredId) || !data.ReadUint64(screenId) || !data.ReadBool(isMirror)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_DISPLAY_NODE Read config failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_DISPLAY_NODE Read config failed!"); ret = ERR_INVALID_DATA; break; } @@ -3449,7 +2634,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( }; bool success; if (CreateNode(config, id, success) != ERR_OK || reply.WriteBool(success)) { - RS_LOGE("RSRenderServiceConnectionStub::CREATE_DISPLAY_NODE Write success failed!"); + RS_LOGE("RSClientToRenderConnectionStub::CREATE_DISPLAY_NODE Write success failed!"); ret = ERR_INVALID_REPLY; } break; @@ -3457,7 +2642,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_FREE_MULTI_WINDOW_STATUS) : { bool enable{false}; if (!data.ReadBool(enable)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_FREE_MULTI_WINDOW_STATUS Read enable failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_FREE_MULTI_WINDOW_STATUS Read enable failed!"); ret = ERR_INVALID_DATA; break; } @@ -3469,7 +2654,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( uint64_t uid{0}; if (!data.ReadInt32(pid) || !data.ReadUint64(uid)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_SURFACE_BUFFER_CALLBACK Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::REGISTER_SURFACE_BUFFER_CALLBACK Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -3481,13 +2666,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( auto remoteObject = data.ReadRemoteObject(); if (remoteObject == nullptr) { ret = ERR_NULL_OBJECT; - RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest remoteObject == nullptr"); + RS_LOGE("RSClientToRenderConnectionStub::OnRemoteRequest remoteObject == nullptr"); break; } sptr callback = iface_cast(remoteObject); if (callback == nullptr) { ret = ERR_NULL_OBJECT; - RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest remoteObject cast error"); + RS_LOGE("RSClientToRenderConnectionStub::OnRemoteRequest remoteObject cast error"); break; } RegisterSurfaceBufferCallback(pid, uid, callback); @@ -3498,7 +2683,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( uint64_t uid{0}; if (!data.ReadInt32(pid) || !data.ReadUint64(uid)) { - RS_LOGE("RSRenderServiceConnectionStub::UNREGISTER_SURFACE_BUFFER_CALLBACK Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::UNREGISTER_SURFACE_BUFFER_CALLBACK Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -3510,36 +2695,12 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( UnregisterSurfaceBufferCallback(pid, uid); break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP_FOR_HARDWARE_COMPOSER) : { - NodeId nodeId = {}; - bool isTop{false}; - uint32_t topLayerZOrder = 0; - if (!data.ReadUint64(nodeId) || !data.ReadBool(isTop) || !data.ReadUint32(topLayerZOrder)) { - RS_LOGE("RSRenderServiceConntionStub::SET_LAYER_TOP_FOR_HARDWARE_COMPOSER Read parcel failed"); - ret = ERR_INVALID_DATA; - break; - } - SetLayerTopForHWC(nodeId, isTop, topLayerZOrder); - break; - } - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP) : { - std::string nodeIdStr; - bool isTop{false}; - if (!data.ReadString(nodeIdStr) || - !data.ReadBool(isTop)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_LAYER_TOP Read parcel failed!"); - ret = ERR_INVALID_DATA; - break; - } - SetLayerTop(nodeIdStr, isTop); - break; - } case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_FORCE_REFRESH) : { std::string nodeIdStr; bool isForceRefresh{false}; if (!data.ReadString(nodeIdStr) || !data.ReadBool(isForceRefresh)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_FORCE_REFRESH Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_FORCE_REFRESH Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -3551,22 +2712,18 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( bool isColorFollow{false}; if (!data.ReadString(nodeIdStr) || !data.ReadBool(isColorFollow)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_COLOR_FOLLOW Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_COLOR_FOLLOW Read parcel failed!"); ret = ERR_INVALID_DATA; break; } SetColorFollow(nodeIdStr, isColorFollow); break; } - case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SCREEN_SWITCHED) : { - NotifyScreenSwitched(); - break; - } case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_WINDOW_CONTAINER) : { NodeId nodeId = {}; bool isEnabled = {}; if (!data.ReadUint64(nodeId) || !data.ReadBool(isEnabled)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_WINDOW_CONTAINER Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_WINDOW_CONTAINER Read parcel failed!"); ret = ERR_INVALID_DATA; break; } @@ -3578,67 +2735,6 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( SetWindowContainer(nodeId, isEnabled); break; } - case static_cast( - RSIRenderServiceConnectionInterfaceCode::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK): { - uint32_t size; - if (!data.ReadUint32(size)) { - ROSEN_LOGE( - "RSRenderServiceConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Read size failed"); - ret = ERR_INVALID_REPLY; - break; - } - RectConstraint constraint; - if (size > MAX_PID_SIZE_NUMBER) { - ROSEN_LOGE("RSRenderServiceConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK " - "size number is too large."); - break; - } - for (uint32_t i = 0; i < size; ++i) { - pid_t pid; - if (!data.ReadInt32(pid)) { - ROSEN_LOGE("RSRenderServiceConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Read " - "pid failed"); - ret = ERR_INVALID_REPLY; - break; - } - constraint.pids.insert(pid); - } - if (!data.ReadInt32(constraint.range.lowLimit.width) || !data.ReadInt32(constraint.range.lowLimit.height) || - !data.ReadInt32(constraint.range.highLimit.width) || - !data.ReadInt32(constraint.range.highLimit.height)) { - ROSEN_LOGE("RSRenderServiceConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Read " - "rectRange failed"); - ret = ERR_INVALID_REPLY; - break; - } - auto remoteObject = data.ReadRemoteObject(); - if (remoteObject == nullptr) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Read " - "remoteObject failed!"); - ret = ERR_NULL_OBJECT; - break; - } - sptr callback = - iface_cast(remoteObject); - if (callback == nullptr) { - ret = ERR_NULL_OBJECT; - break; - } - int32_t status = RegisterSelfDrawingNodeRectChangeCallback(constraint, callback); - if (!reply.WriteInt32(status)) { - RS_LOGE("RSRenderServiceConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Write status " - "failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } - case static_cast( - RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK): { - int32_t status = UnRegisterSelfDrawingNodeRectChangeCallback(); - if (!reply.WriteInt32(status)) { - ret = ERR_INVALID_REPLY; - } - } case static_cast( RSIRenderServiceConnectionInterfaceCode::REGISTER_TRANSACTION_DATA_CALLBACK): { uint64_t token = data.ReadUint64(); @@ -3646,38 +2742,21 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( auto remoteObject = data.ReadRemoteObject(); if (remoteObject == nullptr) { ret = ERR_NULL_OBJECT; - RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest remoteObject == nullptr"); + RS_LOGE("RSClientToRenderConnectionStub::OnRemoteRequest remoteObject == nullptr"); break; } sptr callback = iface_cast(remoteObject); if (callback == nullptr) { ret = ERR_NULL_OBJECT; - RS_LOGE("RSRenderServiceConnectionStub::OnRemoteRequest callback == nullptr"); + RS_LOGE("RSClientToRenderConnectionStub::OnRemoteRequest callback == nullptr"); break; } - RS_LOGD("RSRenderServiceConnectionStub: already decode unicode, timeStamp: %{public}" + RS_LOGD("RSClientToRenderConnectionStub: already decode unicode, timeStamp: %{public}" PRIu64 " token: %{public}" PRIu64, timeStamp, token); RegisterTransactionDataCallback(token, timeStamp, callback); break; } -#ifdef RS_ENABLE_OVERLAY_DISPLAY - case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_OVERLAY_DISPLAY_MODE) : { - RS_LOGI("RSRenderServicrConnectionStub::OnRemoteRequest SET_OVERLAY_DISPLAY_MODE"); - int32_t mode{0}; - if (!data.ReadInt32(mode)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_OVERLAY_DISPLAY_MODE Read mode failed!"); - ret = ERR_INVALID_DATA; - break; - } - int32_t result = SetOverlayDisplayMode(mode); - if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_OVERLAY_DISPLAY_MODE Write status failed!"); - ret = ERR_INVALID_REPLY; - } - break; - } -#endif case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_HIGH_CONTRAST_TEXT_STATE) : { bool highContrast = GetHighContrastTextState(); if (!reply.WriteBool(highContrast)) { @@ -3688,13 +2767,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BEHIND_WINDOW_FILTER_ENABLED): { bool enabled { false }; if (!data.ReadBool(enabled)) { - RS_LOGE("RSRenderServiceConnectionStub::SET_BEHIND_WINDOW_FILTER_ENABLED read enabled failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_BEHIND_WINDOW_FILTER_ENABLED read enabled failed!"); ret = ERR_INVALID_DATA; break; } auto err = SetBehindWindowFilterEnabled(enabled); if (err != ERR_OK) { - RS_LOGE("RSRenderServiceConnectionStub::SET_BEHIND_WINDOW_FILTER_ENABLED Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::SET_BEHIND_WINDOW_FILTER_ENABLED Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -3702,7 +2781,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_BEHIND_WINDOW_FILTER_ENABLED): { bool enabled; if (GetBehindWindowFilterEnabled(enabled) != ERR_OK || !reply.WriteBool(enabled)) { - RS_LOGE("RSRenderServiceConnectionStub::GET_BEHIND_WINDOW_FILTER_ENABLED write enabled failed!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_BEHIND_WINDOW_FILTER_ENABLED write enabled failed!"); ret = ERR_INVALID_REPLY; } break; @@ -3711,21 +2790,21 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( int32_t pid{0}; float gpuMemInMB{0.0}; if (!data.ReadInt32(pid)) { - RS_LOGE("RenderServiceConnectionStub::GET_PID_GPU_MEMORY_IN_MB : read data err!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_PID_GPU_MEMORY_IN_MB : read data err!"); ret = ERR_INVALID_DATA; break; } ret = GetPidGpuMemoryInMB(pid, gpuMemInMB); if (ret != 0) { - RS_LOGE("RenderServiceConnectionStub::GET_PID_GPU_MEMORY_IN_MB : read ret err!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_PID_GPU_MEMORY_IN_MB : read ret err!"); ret = ERR_INVALID_DATA; break; } if (!reply.WriteFloat(gpuMemInMB)) { - RS_LOGE("RenderServiceConnectionStub::GET_PID_GPU_MEMORY_IN_MB write gpuMemInMB err!"); + RS_LOGE("RSClientToRenderConnectionStub::GET_PID_GPU_MEMORY_IN_MB write gpuMemInMB err!"); ret = ERR_INVALID_REPLY; } - RS_LOGD("RenderServiceConnectionStub::GET_PID_GPU_MEMORY_IN_MB, ret: %{public}d, gpuMemInMB: %{public}f", + RS_LOGD("RSClientToRenderConnectionStub::GET_PID_GPU_MEMORY_IN_MB, ret: %{public}d, gpuMemInMB: %{public}f", ret, gpuMemInMB); break; } @@ -3736,13 +2815,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( uint64_t reportTime{0}; if (!data.ReadUint64(uniqueId) || !data.ReadString(surfaceName) || !data.ReadUint32(fps) || !data.ReadUint64(reportTime)) { - RS_LOGE("RenderServiceConnectionStub::AVCODEC_VIDEO_START : read data err!"); + RS_LOGE("RSClientToRenderConnectionStub::AVCODEC_VIDEO_START : read data err!"); ret = ERR_INVALID_DATA; break; } int32_t result = AvcodecVideoStart(uniqueId, surfaceName, fps, reportTime); if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::AVCODEC_VIDEO_START Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::AVCODEC_VIDEO_START Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -3752,13 +2831,13 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( std::string surfaceName; uint32_t fps{0}; if (!data.ReadUint64(uniqueId) || !data.ReadString(surfaceName) || !data.ReadUint32(fps)) { - RS_LOGE("RSRenderServiceConnectionStub::AVCODEC_VIDEO_STOP : read data err!"); + RS_LOGE("RSClientToRenderConnectionStub::AVCODEC_VIDEO_STOP : read data err!"); ret = ERR_INVALID_DATA; break; } int32_t result = AvcodecVideoStop(uniqueId, surfaceName, fps); if (!reply.WriteInt32(result)) { - RS_LOGE("RSRenderServiceConnectionStub::AVCODEC_VIDEO_STOP Write status failed!"); + RS_LOGE("RSClientToRenderConnectionStub::AVCODEC_VIDEO_STOP Write status failed!"); ret = ERR_INVALID_REPLY; } break; @@ -3811,7 +2890,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( case static_cast(RSIRenderServiceConnectionInterfaceCode::CLEAR_UIFIRST_CACHE) : { NodeId nodeId = {}; if (!data.ReadUint64(nodeId)) { - RS_LOGE("RSRenderServiceConnectionStub::CLEAR_UIFIRST_CACHE : read data err!"); + RS_LOGE("RSClientToRenderConnectionStub::CLEAR_UIFIRST_CACHE : read data err!"); ret = ERR_INVALID_DATA; break; } @@ -3826,7 +2905,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest( return ret; } -bool RSRenderServiceConnectionStub::ReadDataBaseRs(DataBaseRs& info, MessageParcel& data) +bool RSClientToRenderConnectionStub::ReadDataBaseRs(DataBaseRs& info, MessageParcel& data) { if (!data.ReadInt32(info.appPid) || !data.ReadInt32(info.eventType) || !data.ReadInt32(info.versionCode) || !data.ReadInt64(info.uniqueId) || @@ -3836,57 +2915,57 @@ bool RSRenderServiceConnectionStub::ReadDataBaseRs(DataBaseRs& info, MessageParc !data.ReadString(info.bundleName) || !data.ReadString(info.processName) || !data.ReadString(info.abilityName) ||!data.ReadString(info.pageUrl) || !data.ReadString(info.sourceType) || !data.ReadString(info.note)) { - RS_LOGE("RSRenderServiceConnectionStub::ReadDataBaseRs Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ReadDataBaseRs Read parcel failed!"); return false; } return true; } -bool RSRenderServiceConnectionStub::ReadAppInfo(AppInfo& info, MessageParcel& data) +bool RSClientToRenderConnectionStub::ReadAppInfo(AppInfo& info, MessageParcel& data) { if (!data.ReadInt64(info.startTime)) { - RS_LOGE("RSRenderServiceConnectionStub::ReadAppInfo Read startTime failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ReadAppInfo Read startTime failed!"); return false; } if (!data.ReadInt64(info.endTime)) { - RS_LOGE("RSRenderServiceConnectionStub::ReadAppInfo Read endTime failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ReadAppInfo Read endTime failed!"); return false; } if (!data.ReadInt32(info.pid)) { - RS_LOGE("RSRenderServiceConnectionStub::ReadAppInfo Read pid failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ReadAppInfo Read pid failed!"); return false; } if (!data.ReadString(info.versionName)) { - RS_LOGE("RSRenderServiceConnectionStub::ReadAppInfo Read versionName failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ReadAppInfo Read versionName failed!"); return false; } if (!data.ReadInt32(info.versionCode)) { - RS_LOGE("RSRenderServiceConnectionStub::ReadAppInfo Read versionCode failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ReadAppInfo Read versionCode failed!"); return false; } if (!data.ReadString(info.bundleName)) { - RS_LOGE("RSRenderServiceConnectionStub::ReadAppInfo Read bundleName failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ReadAppInfo Read bundleName failed!"); return false; } if (!data.ReadString(info.processName)) { - RS_LOGE("RSRenderServiceConnectionStub::ReadAppInfo Read processName failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ReadAppInfo Read processName failed!"); return false; } return true; } -bool RSRenderServiceConnectionStub::ReadGameStateDataRs(GameStateData& info, MessageParcel& data) +bool RSClientToRenderConnectionStub::ReadGameStateDataRs(GameStateData& info, MessageParcel& data) { if (!data.ReadInt32(info.pid) || !data.ReadInt32(info.uid) || !data.ReadInt32(info.state) || !data.ReadInt32(info.renderTid) || !data.ReadString(info.bundleName)) { - RS_LOGE("RSRenderServiceConnectionStub::ReadGameStateDataRs Read parcel failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ReadGameStateDataRs Read parcel failed!"); return false; } return true; } -bool RSRenderServiceConnectionStub::ReadSurfaceCaptureConfig(RSSurfaceCaptureConfig& captureConfig, MessageParcel& data) +bool RSClientToRenderConnectionStub::ReadSurfaceCaptureConfig(RSSurfaceCaptureConfig& captureConfig, MessageParcel& data) { uint8_t captureType { 0 }; if (!data.ReadFloat(captureConfig.scaleX) || !data.ReadFloat(captureConfig.scaleY) || @@ -3905,35 +2984,35 @@ bool RSRenderServiceConnectionStub::ReadSurfaceCaptureConfig(RSSurfaceCaptureCon !data.ReadFloat(captureConfig.specifiedAreaRect.bottom_) || !data.ReadUInt64Vector(&captureConfig.blackList) || !data.ReadUint32(captureConfig.backGroundColor)) { - RS_LOGE("RSRenderServiceConnectionStub::ReadSurfaceCaptureConfig Read captureType failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ReadSurfaceCaptureConfig Read captureType failed!"); return false; } captureConfig.captureType = static_cast(captureType); return true; } -bool RSRenderServiceConnectionStub::ReadSurfaceCaptureBlurParam( +bool RSClientToRenderConnectionStub::ReadSurfaceCaptureBlurParam( RSSurfaceCaptureBlurParam& blurParam, MessageParcel& data) { if (!data.ReadBool(blurParam.isNeedBlur) || !data.ReadFloat(blurParam.blurRadius)) { - RS_LOGE("RSRenderServiceConnectionStub::ReadSurfaceCaptureBlurParam Read blurParam failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ReadSurfaceCaptureBlurParam Read blurParam failed!"); return false; } return true; } -bool RSRenderServiceConnectionStub::ReadSurfaceCaptureAreaRect( +bool RSClientToRenderConnectionStub::ReadSurfaceCaptureAreaRect( Drawing::Rect& specifiedAreaRect, MessageParcel& data) { if (!data.ReadFloat(specifiedAreaRect.left_) || !data.ReadFloat(specifiedAreaRect.top_) || !data.ReadFloat(specifiedAreaRect.right_) || !data.ReadFloat(specifiedAreaRect.bottom_)) { - RS_LOGE("RSRenderServiceConnectionStub::ReadSurfaceCaptureAreaRect Read specifiedAreaRect failed!"); + RS_LOGE("RSClientToRenderConnectionStub::ReadSurfaceCaptureAreaRect Read specifiedAreaRect failed!"); return false; } return true; } -const RSInterfaceCodeSecurityManager RSRenderServiceConnectionStub::securityManager_ = \ +const RSInterfaceCodeSecurityManager RSClientToRenderConnectionStub::securityManager_ = \ RSInterfaceCodeSecurityManager::CreateInstance(); } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.h b/rosen/modules/render_service/core/transaction/rs_client_to_render_connection_stub.h similarity index 77% rename from rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.h rename to rosen/modules/render_service/core/transaction/rs_client_to_render_connection_stub.h index c871a503ec3f49b03e6b5511c8b8b3a34814728c..f089faaea8b062c8618b04e19a6dae23a444a5ba 100644 --- a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.h +++ b/rosen/modules/render_service/core/transaction/rs_client_to_render_connection_stub.h @@ -13,25 +13,25 @@ * limitations under the License. */ -#ifndef ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_SERVICE_CONNECTION_STUB_H -#define ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_SERVICE_CONNECTION_STUB_H +#ifndef ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_CLIENT_TO_RENDER_CONNECTION_STUB_H +#define ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_CLIENT_TO_RENDER_CONNECTION_STUB_H #include #include #include #include -#include "platform/ohos/rs_irender_service_connection.h" +#include "platform/ohos/rs_iclient_to_render_connection.h" #include "platform/ohos/rs_irender_service_connection_ipc_interface_code_access_verifier.h" #include "ipc_security/rs_ipc_interface_code_security_manager.h" #include "rs_render_service_security_utils.h" namespace OHOS { namespace Rosen { -class RSRenderServiceConnectionStub : public IRemoteStub { +class RSClientToRenderConnectionStub : public IRemoteStub { public: - RSRenderServiceConnectionStub() = default; - ~RSRenderServiceConnectionStub() noexcept = default; + RSClientToRenderConnectionStub() = default; + ~RSClientToRenderConnectionStub() noexcept = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; @@ -48,11 +48,10 @@ private: bool ReadSurfaceCaptureBlurParam(RSSurfaceCaptureBlurParam& blurParam, MessageParcel& data); bool ReadSurfaceCaptureAreaRect(Drawing::Rect& specifiedAreaRect, MessageParcel& data); void SetQos(); - RSRenderServiceSecurityUtils securityUtils_; std::unordered_set tids_; std::mutex mutex_; }; } // namespace Rosen } // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_SERVICE_CONNECTION_STUB_H \ No newline at end of file +#endif // ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_CLIENT_TO_RENDER_CONNECTION_STUB_H \ No newline at end of file diff --git a/rosen/modules/render_service/core/transaction/rs_client_to_service_connection_stub.cpp b/rosen/modules/render_service/core/transaction/rs_client_to_service_connection_stub.cpp new file mode 100644 index 0000000000000000000000000000000000000000..18ef5accfc64f4240e4067816e75c56a244e3d73 --- /dev/null +++ b/rosen/modules/render_service/core/transaction/rs_client_to_service_connection_stub.cpp @@ -0,0 +1,2124 @@ +/* + * Copyright (c) 2021-2023 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. + */ + +#include "rs_client_to_service_connection_stub.h" +#include +#include +#include "ivsync_connection.h" +#ifdef RES_SCHED_ENABLE +#include "res_sched_client.h" +#include "res_type.h" +#include +#endif +#include "securec.h" +#include "sys_binder.h" + +#include "command/rs_command_factory.h" +#include "command/rs_command_verify_helper.h" +#include "common/rs_xcollie.h" +#include "hgm_frame_rate_manager.h" +#include "memory/rs_memory_flow_control.h" +#include "pipeline/render_thread/rs_base_render_util.h" +#include "pipeline/main_thread/rs_main_thread.h" +#include "pipeline/rs_uni_render_judgement.h" +#include "platform/common/rs_log.h" +#include "transaction/rs_ashmem_helper.h" +#include "transaction/rs_unmarshal_thread.h" +#include "transaction/rs_hrp_service.h" +#include "render/rs_typeface_cache.h" +#include "rs_trace.h" +#include "rs_profiler.h" +#include "app_mgr_client.h" + +namespace OHOS { +namespace Rosen { +namespace { +constexpr size_t MAX_DATA_SIZE_FOR_UNMARSHALLING_IN_PLACE = 1024 * 15; // 15kB +constexpr size_t FILE_DESCRIPTOR_LIMIT = 15; +constexpr size_t MAX_OBJECTNUM = 512; +constexpr size_t MAX_DATA_SIZE = 1024 * 1024; // 1MB +const uint32_t MAX_VOTER_SIZE = 100; +constexpr uint32_t MAX_PID_SIZE_NUMBER = 100000; +#ifdef RES_SCHED_ENABLE +const uint32_t RS_IPC_QOS_LEVEL = 7; +constexpr const char* RS_BUNDLE_NAME = "client_to_service"; +#endif +static constexpr std::array descriptorCheckList = { + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_DEFAULT_SCREEN_ID), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_SCREEN_ID), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ALL_SCREEN_IDS), + static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_VIRTUAL_SCREEN), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_PHYSICAL_SCREEN_RESOLUTION), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_RESOLUTION), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SURFACE), + static_cast(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CHANGE_CALLBACK), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_MODE), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_REFRESH_RATE), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_REFRESH_RATE_MODE), + static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_FRAME_RATE_LINKER), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CURRENT_REFRESH_RATE), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_CURRENT_REFRESH_RATE_MODE), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_REFRESH_RATES), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SHOW_REFRESH_RATE_ENABLED), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REALTIME_REFRESH_RATE), + static_cast(RSIRenderServiceConnectionInterfaceCode::REPAINT_EVERYTHING), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_DISPLAY_IDENTIFICATION_DATA), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO_TO_SP), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_POWER_STATUS), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_BACK_LIGHT), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_ACTIVE_MODE), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_MODES), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CAPABILITY), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_POWER_STATUS), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_BACK_LIGHT), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_DATA), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_AVAILABLE_LISTENER), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_CLEAR_LISTENER), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_GAMUTS), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_METADATAKEYS), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT_MAP), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CORRECTION), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_GLOBAL_DARK_COLOR_MODE), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT_MAP), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_STATUS), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_COLORSPACES), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_COLORSPACE), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_COLORSPACE), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_TYPE), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_RECT), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_OFFSET), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_FRAME_GRAVITY), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHIC), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHICS), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_TOTAL_APP_MEM_SIZE), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_BITMAP), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_PIXELMAP), + static_cast(RSIRenderServiceConnectionInterfaceCode::EXECUTE_SYNCHRONOUS_TASK), + static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_REFRESH_RATE_EVENT), + static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_VSYNC_NAME), + static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_WINDOW_ID), + static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SOFT_VSYNC_EVENT), + static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_TOUCH_EVENT), + static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_DYNAMIC_MODE_EVENT), + static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_XCOMPONENT_EXPECTED_FRAMERATE), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_HARDWARE_ENABLED), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_HIDE_PRIVACY_CONTENT), + static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SCREEN_SWITCHED), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_TP_FEATURE_CONFIG), + static_cast(RSIRenderServiceConnectionInterfaceCode::GET_LAYER_COMPOSE_INFO), + static_cast(RSIRenderServiceConnectionInterfaceCode::NEED_REGISTER_TYPEFACE), + static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_DISPLAY_NODE), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP_FOR_HARDWARE_COMPOSER), + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP), + static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK), + static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK), + static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_TRANSACTION_DATA_CALLBACK), + static_cast(RSIRenderServiceConnectionInterfaceCode::AVCODEC_VIDEO_START), + static_cast(RSIRenderServiceConnectionInterfaceCode::AVCODEC_VIDEO_STOP), +#ifdef RS_ENABLE_OVERLAY_DISPLAY + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_OVERLAY_DISPLAY_MODE), +#endif + static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PAGE_NAME), + static_cast(RSIRenderServiceConnectionInterfaceCode::PROFILER_SERVICE_OPEN_FILE), + static_cast(RSIRenderServiceConnectionInterfaceCode::PROFILER_SERVICE_POPULATE_FILES), + static_cast(RSIRenderServiceConnectionInterfaceCode::PROFILER_IS_SECURE_SCREEN), +}; + +void CopyFileDescriptor(MessageParcel& old, MessageParcel& copied) +{ + binder_size_t* object = reinterpret_cast(old.GetObjectOffsets()); + binder_size_t* copiedObject = reinterpret_cast(copied.GetObjectOffsets()); + + size_t objectNum = old.GetOffsetsSize(); + + uintptr_t data = old.GetData(); + uintptr_t copiedData = copied.GetData(); + + for (size_t i = 0; i < objectNum; i++) { + const flat_binder_object* flat = reinterpret_cast(data + object[i]); + flat_binder_object* copiedFlat = reinterpret_cast(copiedData + copiedObject[i]); + + if (flat->hdr.type == BINDER_TYPE_FD && flat->handle >= 0) { + int32_t val = dup(flat->handle); + if (val < 0) { + ROSEN_LOGW("CopyFileDescriptor dup failed, fd:%{public}d, handle:%{public}" PRIu32, val, + static_cast(flat->handle)); + } + copiedFlat->handle = static_cast(val); + } + } +} + +std::shared_ptr CopyParcelIfNeed(MessageParcel& old, pid_t callingPid) +{ + if (RSSystemProperties::GetCacheEnabledForRotation() && + RSMainThread::Instance()->GetDesktopPidForRotationScene() != callingPid) { + return nullptr; + } + auto dataSize = old.GetDataSize(); + if (dataSize <= MAX_DATA_SIZE_FOR_UNMARSHALLING_IN_PLACE && old.GetOffsetsSize() < FILE_DESCRIPTOR_LIMIT) { + return nullptr; + } + if (dataSize > MAX_DATA_SIZE) { + return nullptr; + } + if (dataSize == 0) { + return nullptr; + } + + if (old.GetOffsetsSize() > MAX_OBJECTNUM) { + ROSEN_LOGW("RSClientToServiceConnectionStub::CopyParcelIfNeed failed, parcel fdCnt: %{public}zu is too large", + old.GetOffsetsSize()); + return nullptr; + } + + RS_TRACE_NAME("CopyParcelForUnmarsh: size:" + std::to_string(dataSize)); + void* base = malloc(dataSize); + if (base == nullptr) { + RS_LOGE("RSClientToServiceConnectionStub::CopyParcelIfNeed malloc failed"); + return nullptr; + } + if (memcpy_s(base, dataSize, reinterpret_cast(old.GetData()), dataSize) != 0) { + RS_LOGE("RSClientToServiceConnectionStub::CopyParcelIfNeed copy parcel data failed"); + free(base); + return nullptr; + } + + auto parcelCopied = RS_PROFILER_COPY_PARCEL(old); + if (!parcelCopied->ParseFrom(reinterpret_cast(base), dataSize)) { + RS_LOGE("RSClientToServiceConnectionStub::CopyParcelIfNeed ParseFrom failed"); + free(base); + return nullptr; + } + + auto objectNum = old.GetOffsetsSize(); + if (objectNum != 0) { + parcelCopied->InjectOffsets(old.GetObjectOffsets(), objectNum); + CopyFileDescriptor(old, *parcelCopied); + } + int32_t data{0}; + if (!parcelCopied->ReadInt32(data)) { + RS_LOGE("RSClientToServiceConnectionStub::CopyParcelIfNeed parcel data Read failed"); + return nullptr; + } + if (data != 0) { + RS_LOGE("RSClientToServiceConnectionStub::CopyParcelIfNeed parcel data not match"); + return nullptr; + } + return parcelCopied; +} + +bool CheckCreateNodeAndSurface(pid_t pid, RSSurfaceNodeType nodeType, SurfaceWindowType windowType) +{ + constexpr int nodeTypeMin = static_cast(RSSurfaceNodeType::DEFAULT); + constexpr int nodeTypeMax = static_cast(RSSurfaceNodeType::NODE_MAX); + + int typeNum = static_cast(nodeType); + if (typeNum < nodeTypeMin || typeNum > nodeTypeMax) { + RS_LOGW("CREATE_NODE_AND_SURFACE invalid RSSurfaceNodeType"); + return false; + } + if (windowType != SurfaceWindowType::DEFAULT_WINDOW && !IS_SCB_WINDOW_TYPE(windowType)) { + RS_LOGW("CREATE_NODE_AND_SURFACE invalid SurfaceWindowType"); + return false; + } + + bool isTokenTypeValid = true; + bool isNonSystemAppCalling = false; + RSInterfaceCodeAccessVerifierBase::GetAccessType(isTokenTypeValid, isNonSystemAppCalling); + if (isNonSystemAppCalling) { + if (nodeType != RSSurfaceNodeType::DEFAULT && + nodeType != RSSurfaceNodeType::APP_WINDOW_NODE && + nodeType != RSSurfaceNodeType::SELF_DRAWING_NODE && + nodeType != RSSurfaceNodeType::UI_EXTENSION_COMMON_NODE) { + RS_LOGW("CREATE_NODE_AND_SURFACE NonSystemAppCalling invalid RSSurfaceNodeType %{public}d, pid %d", + typeNum, pid); + return false; + } + if (windowType != SurfaceWindowType::DEFAULT_WINDOW) { + RS_LOGW("CREATE_NODE_AND_SURFACE NonSystemAppCalling invalid SurfaceWindowType %{public}d, pid %d", + static_cast(windowType), pid); + return false; + } + } + + return true; +} + +std::string GetBundleName(pid_t pid) +{ + std::string bundleName; + static const auto appMgrClient = std::make_shared(); + if (appMgrClient == nullptr) { + RS_LOGE("GetBundleName get appMgrClient fail."); + return bundleName; + } + int32_t uid = 0; + appMgrClient->GetBundleNameByPid(pid, bundleName, uid); + return bundleName; +} + +bool IsValidCallingPid(pid_t pid, pid_t callingPid) +{ + return (callingPid == getpid()) || (callingPid == pid); +} +} + +void RSClientToServiceConnectionStub::SetQos() +{ +#ifdef RES_SCHED_ENABLE + std::string strBundleName = RS_BUNDLE_NAME; + std::string strPid = std::to_string(getpid()); + std::string strTid = std::to_string(gettid()); + std::string strQos = std::to_string(RS_IPC_QOS_LEVEL); + std::unordered_map mapPayload; + mapPayload["pid"] = strPid; + mapPayload[strTid] = strQos; + mapPayload["bundleName"] = strBundleName; + OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData( + OHOS::ResourceSchedule::ResType::RES_TYPE_THREAD_QOS_CHANGE, 0, mapPayload); + struct sched_param param = {0}; + param.sched_priority = 1; + if (sched_setscheduler(0, SCHED_FIFO, ¶m) != 0) { + RS_LOGE("RSClientToServiceConnectionStub Couldn't set SCHED_FIFO."); + } else { + RS_LOGI("RSClientToServiceConnectionStub set SCHED_FIFO succeed."); + } +#endif +} + +int RSClientToServiceConnectionStub::OnRemoteRequest( + uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) +{ + uint32_t parcelNumber = RS_PROFILER_ON_REMOTE_REQUEST(this, code, data, reply, option); + + AshmemFdContainer::SetIsUnmarshalThread(false); + pid_t callingPid = GetCallingPid(); + RSMarshallingHelper::SetCallingPid(callingPid); + auto tid = gettid(); + { + std::lock_guard lock(mutex_); + if (tids_.find(tid) == tids_.end()) { + SetQos(); + tids_.insert(tid); + } + } + if (std::find(std::cbegin(descriptorCheckList), std::cend(descriptorCheckList), code) != + std::cend(descriptorCheckList)) { + auto token = data.ReadInterfaceToken(); + if (token != RSIClientToServiceConnection::GetDescriptor()) { + return ERR_INVALID_STATE; + } + } + auto accessible = securityManager_.IsInterfaceCodeAccessible(code); + if (!accessible && code != static_cast(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHIC) && + code != static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO) && + code != static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_AVAILABLE_LISTENER) && + code != static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_CLEAR_LISTENER)) { + RS_LOGE("RSClientToServiceConnectionStub::OnRemoteRequest no permission code:%{public}d", code); + return ERR_INVALID_STATE; + } + int ret = ERR_NONE; + switch (code) { + case static_cast(RSIRenderServiceConnectionInterfaceCode::COMMIT_TRANSACTION): { + bool isTokenTypeValid = true; + bool isNonSystemAppCalling = false; + RSInterfaceCodeAccessVerifierBase::GetAccessType(isTokenTypeValid, isNonSystemAppCalling); + if (!isTokenTypeValid) { + RS_LOGE("RSClientToServiceConnectionStub::COMMIT_TRANSACTION invalid token type"); + return ERR_INVALID_STATE; + } + if (isNonSystemAppCalling) { + RsCommandVerifyHelper::GetInstance().RegisterNonSystemPid(callingPid); + } + RS_TRACE_NAME_FMT("Recv Parcel Size:%zu, fdCnt:%zu", data.GetDataSize(), data.GetOffsetsSize()); + static bool isUniRender = RSUniRenderJudgement::IsUniRender(); + std::shared_ptr parsedParcel; + std::unique_ptr ashmemFdWorker = nullptr; + std::shared_ptr ashmemFlowControlUnit = nullptr; + int32_t readData{0}; + if (!data.ReadInt32(readData)) { + RS_LOGE("RSClientToServiceConnectionStub::COMMIT_TRANSACTION read parcel failed"); + return ERR_INVALID_DATA; + } + if (readData == 0) { // indicate normal parcel + if (isUniRender) { + // in uni render mode, if parcel size over threshold, + // Unmarshalling task will be post to RSUnmarshalThread, + // copy the origin parcel to maintain the parcel lifetime + parsedParcel = CopyParcelIfNeed(data, callingPid); + } + if (parsedParcel == nullptr) { + // no need to copy or copy failed, use original parcel + // execute Unmarshalling immediately + + RSMarshallingHelper::UnmarshallingTransactionVer(data); + + auto transactionData = RSBaseRenderUtil::ParseTransactionData(data, parcelNumber); + if (transactionData && isNonSystemAppCalling) { + const auto& nodeMap = RSMainThread::Instance()->GetContext().GetNodeMap(); + if (!transactionData->IsCallingPidValid(callingPid, nodeMap)) { + RS_LOGE("RSClientToServiceConnectionStub::COMMIT_TRANSACTION IsCallingPidValid check failed"); + } + } + CommitTransaction(transactionData); + break; + } + } else { + // indicate ashmem parcel + // should be parsed to normal parcel before Unmarshalling + parsedParcel = RSAshmemHelper::ParseFromAshmemParcel(&data, ashmemFdWorker, ashmemFlowControlUnit, + callingPid); + if (parsedParcel) { + parcelNumber = RS_PROFILER_ON_REMOTE_REQUEST(this, code, *parsedParcel, reply, option); + } + } + if (parsedParcel == nullptr) { + RS_LOGE("RSClientToServiceConnectionStub::COMMIT_TRANSACTION failed: parsed parcel is nullptr"); + return ERR_INVALID_DATA; + } + RSMarshallingHelper::UnmarshallingTransactionVer(*parsedParcel); + if (isUniRender) { + // post Unmarshalling task to RSUnmarshalThread + RSUnmarshalThread::Instance().RecvParcel(parsedParcel, isNonSystemAppCalling, callingPid, + std::move(ashmemFdWorker), ashmemFlowControlUnit, parcelNumber); + } else { + // execute Unmarshalling immediately + auto transactionData = RSBaseRenderUtil::ParseTransactionData(*parsedParcel, parcelNumber); + if (transactionData && isNonSystemAppCalling) { + const auto& nodeMap = RSMainThread::Instance()->GetContext().GetNodeMap(); + if (!transactionData->IsCallingPidValid(callingPid, nodeMap)) { + RS_LOGE("RSClientToServiceConnectionStub::COMMIT_TRANSACTION IsCallingPidValid check failed"); + } + } + CommitTransaction(transactionData); + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_UNI_RENDER_ENABLED): { + bool enable; + if (GetUniRenderEnabled(enable) != ERR_OK || !reply.WriteBool(enable)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_UNI_RENDER_ENABLED read enable failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_NODE): { + uint64_t nodeId{0}; + if (!data.ReadUint64(nodeId)) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_NODE read nodeId failed!"); + ret = ERR_INVALID_DATA; + break; + } + bool isNonSystemCalling = false; + bool isTokenTypeValid = true; + RSInterfaceCodeAccessVerifierBase::GetAccessType(isTokenTypeValid, isNonSystemCalling); + if (isNonSystemCalling && !IsValidCallingPid(ExtractPid(nodeId), callingPid)) { + RS_LOGW("CREATE_NODE invalid nodeId[%{public}" PRIu64 "] pid[%{public}d]", nodeId, callingPid); + ret = ERR_INVALID_DATA; + break; + } + RS_PROFILER_PATCH_NODE_ID(data, nodeId); + std::string surfaceName; + if (!data.ReadString(surfaceName)) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_NODE read surfaceName failed!"); + ret = ERR_INVALID_DATA; + break; + } + RSSurfaceRenderNodeConfig config = {.id = nodeId, .name = surfaceName}; + bool success; + if (CreateNode(config, success) != ERR_OK || !reply.WriteBool(success)) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_NODE Write success failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_NODE_AND_SURFACE): { + uint64_t nodeId{0}; + if (!data.ReadUint64(nodeId)) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_NODE_AND_SURFACE read nodeId failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (!IsValidCallingPid(ExtractPid(nodeId), callingPid)) { + RS_LOGW("CREATE_NODE_AND_SURFACE invalid nodeId[%" PRIu64 "] pid[%d]", nodeId, callingPid); + ret = ERR_INVALID_DATA; + break; + } + RS_PROFILER_PATCH_NODE_ID(data, nodeId); + std::string surfaceName; + uint8_t type { 0 }; + bool isTextureExportNode { false }; + bool isSync { false }; + uint8_t surfaceWindowType { 0 }; + bool unobscured { false }; + if (!data.ReadString(surfaceName) || !data.ReadUint8(type) || !data.ReadBool(isTextureExportNode) || + !data.ReadBool(isSync) || !data.ReadUint8(surfaceWindowType) || !data.ReadBool(unobscured)) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_NODE_AND_SURFACE read surfaceRenderNodeConfig failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (!CheckCreateNodeAndSurface(callingPid, static_cast(type), + static_cast(surfaceWindowType))) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_NODE_AND_SURFACE CheckCreateNodeAndSurface failed!"); + ret = ERR_INVALID_DATA; + break; + } + bool needGetBundleName = (type == static_cast(RSSurfaceNodeType::SELF_DRAWING_NODE)); + RSSurfaceRenderNodeConfig config = { .id = nodeId, + .name = surfaceName, + .nodeType = static_cast(type), + .isTextureExportNode = isTextureExportNode, + .isSync = isSync, + .surfaceWindowType = static_cast(surfaceWindowType), + .bundleName = needGetBundleName ? GetBundleName(ExtractPid(nodeId)) : "" }; + sptr surface = nullptr; + ErrCode err = CreateNodeAndSurface(config, surface, unobscured); + if ((err != ERR_OK) || (surface == nullptr)) { + ret = ERR_NULL_OBJECT; + break; + } + auto producer = surface->GetProducer(); + if (!reply.WriteRemoteObject(producer->AsObject())) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_NODE_AND_SURFACE read RemoteObject failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_DEFAULT_SCREEN_ID): { + uint64_t screenId = INVALID_SCREEN_ID; + if (GetDefaultScreenId(screenId) != ERR_OK || !reply.WriteUint64(screenId)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_DEFAULT_SCREEN_ID Write id failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_SCREEN_ID): { + uint64_t screenId = INVALID_SCREEN_ID; + if (GetActiveScreenId(screenId) != ERR_OK || !reply.WriteUint64(screenId)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_ACTIVE_SCREEN_ID Write id failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ALL_SCREEN_IDS): { + std::vector ids = GetAllScreenIds(); + if (!reply.WriteUint32(ids.size())) { + RS_LOGE("RSClientToServiceConnectionStub::GET_ALL_SCREEN_IDS Write idsSize failed!"); + ret = ERR_INVALID_REPLY; + break; + } + for (uint32_t i = 0; i < ids.size(); i++) { + if (!reply.WriteUint64(ids[i])) { + RS_LOGE("RSClientToServiceConnectionStub::GET_ALL_SCREEN_IDS Write ids failed!"); + ret = ERR_INVALID_REPLY; + break; + } + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_VIRTUAL_SCREEN): { + // read the parcel data. + std::string name; + uint32_t width{0}; + uint32_t height{0}; + bool useSurface{false}; + if (!data.ReadString(name) || !data.ReadUint32(width) || + !data.ReadUint32(height) || !data.ReadBool(useSurface)) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_VIRTUAL_SCREEN read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + sptr surface = nullptr; + if (useSurface) { + auto remoteObject = data.ReadRemoteObject(); + if (remoteObject != nullptr) { + auto bufferProducer = iface_cast(remoteObject); + surface = Surface::CreateSurfaceAsProducer(bufferProducer); + } + } + ScreenId mirrorId{INVALID_SCREEN_ID}; + int32_t flags{0}; + std::vector whiteList; + if (!data.ReadUint64(mirrorId) || !data.ReadInt32(flags) || !data.ReadUInt64Vector(&whiteList)) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_VIRTUAL_SCREEN read ScreenId failed!"); + ret = ERR_INVALID_DATA; + break; + } + ScreenId id = CreateVirtualScreen(name, width, height, surface, mirrorId, flags, whiteList); + if (!reply.WriteUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_VIRTUAL_SCREEN Write id failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SURFACE): { + // read the parcel data. + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_VIRTUAL_SCREEN_SURFACE Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + auto remoteObject = data.ReadRemoteObject(); + if (remoteObject == nullptr) { + ret = ERR_NULL_OBJECT; + break; + } + auto bufferProducer = iface_cast(remoteObject); + sptr surface = Surface::CreateSurfaceAsProducer(bufferProducer); + if (surface == nullptr) { + ret = ERR_NULL_OBJECT; + break; + } + int32_t status = SetVirtualScreenSurface(id, surface); + if (!reply.WriteInt32(status)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_VIRTUAL_SCREEN_SURFACE Write status failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::REMOVE_VIRTUAL_SCREEN Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + RemoveVirtualScreen(id); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CHANGE_CALLBACK): { + auto remoteObject = data.ReadRemoteObject(); + if (remoteObject == nullptr) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_CHANGE_CALLBACK remoteObject is nullptr"); + ret = ERR_NULL_OBJECT; + break; + } + sptr cb = iface_cast(remoteObject); + if (cb == nullptr) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_CHANGE_CALLBACK callback is nullptr"); + ret = ERR_NULL_OBJECT; + break; + } + RS_LOGI("RSClientToServiceConnectionStub::SET_SCREEN_CHANGE_CALLBACK"); + int32_t status = SetScreenChangeCallback(cb); + if (!reply.WriteInt32(status)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_CHANGE_CALLBACK Write status failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_MODE): { + ScreenId id{INVALID_SCREEN_ID}; + uint32_t modeId{0}; + if (!data.ReadUint64(id) || !data.ReadUint32(modeId)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_ACTIVE_MODE Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + SetScreenActiveMode(id, modeId); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_REFRESH_RATE): { + ScreenId id{INVALID_SCREEN_ID}; + int32_t sceneId{0}; + int32_t rate{0}; + if (!data.ReadUint64(id) || !data.ReadInt32(sceneId) || !data.ReadInt32(rate)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_REFRESH_RATE Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + SetScreenRefreshRate(id, sceneId, rate); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_REFRESH_RATE_MODE): { + int32_t mode{0}; + if (!data.ReadInt32(mode)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_REFRESH_RATE_MODE Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + SetRefreshRateMode(mode); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_FRAME_RATE_LINKER): { + FrameRateLinkerId id{0}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::UNREGISTER_FRAME_RATE_LINKER Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (ExtractPid(id) != callingPid) { + RS_LOGW("The UnregisterFrameRateLinker isn't legal, frameRateLinkerId: %{public}" PRIu64 + ", callingPid:%{public}d", id, callingPid); + ret = ERR_INVALID_DATA; + break; + } + UnregisterFrameRateLinker(id); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CURRENT_REFRESH_RATE): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_CURRENT_REFRESH_RATE Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + uint32_t refreshRate = GetScreenCurrentRefreshRate(id); + if (!reply.WriteUint32(refreshRate)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_CURRENT_REFRESH_RATE Write refreshRate failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_CURRENT_REFRESH_RATE_MODE): { + int32_t refreshRateMode = GetCurrentRefreshRateMode(); + if (!reply.WriteInt32(refreshRateMode)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_CURRENT_REFRESH_RATE_MODE Write refreshRateMode failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_REFRESH_RATES): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_REFRESH_RATES Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + std::vector rates = GetScreenSupportedRefreshRates(id); + if (!reply.WriteUint64(static_cast(rates.size()))) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_REFRESH_RATES Write rates failed!"); + ret = ERR_INVALID_REPLY; + break; + } + for (auto ratesIter : rates) { + if (!reply.WriteInt32(ratesIter)) { + RS_LOGE( + "RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_REFRESH_RATES Write ratesIter failed!"); + ret = ERR_INVALID_REPLY; + break; + } + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SHOW_REFRESH_RATE_ENABLED): { + bool enabled = false; + if (GetShowRefreshRateEnabled(enabled) != ERR_OK || !reply.WriteBool(enabled)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SHOW_REFRESH_RATE_ENABLED Write enabled failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED): { + bool enabled{false}; + int32_t type{0}; + if (!data.ReadBool(enabled) || !data.ReadInt32(type)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SHOW_REFRESH_RATE_ENABLED Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + SetShowRefreshRateEnabled(enabled, type); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REALTIME_REFRESH_RATE): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_REALTIME_REFRESH_RATE Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + uint32_t refreshRate = GetRealtimeRefreshRate(id); + if (!reply.WriteUint32(refreshRate)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_REALTIME_REFRESH_RATE Read refreshRate failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO): { + auto token = data.ReadInterfaceToken(); + if (token != RSIClientToServiceConnection::GetDescriptor()) { + ret = ERR_INVALID_STATE; + break; + } + int32_t pid{0}; + if (!data.ReadInt32(pid)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_REFRESH_INFO Read pid failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (!IsValidCallingPid(pid, callingPid)) { + RS_LOGW("GET_REFRESH_INFO invalid pid[%{public}d]", callingPid); + ret = ERR_INVALID_DATA; + break; + } + std::string refreshInfo; + if (GetRefreshInfo(pid, refreshInfo) != ERR_OK || !reply.WriteString(refreshInfo)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_REFRESH_INFO Write refreshInfo failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO_TO_SP): { + uint64_t nodeId{0}; + if (!data.ReadUint64(nodeId)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_REFRESH_INFO_TO_SP Read nodeId failed!"); + ret = ERR_INVALID_DATA; + break; + } + std::string refreshInfoToSP; + if (GetRefreshInfoToSP(nodeId, refreshInfoToSP) != ERR_OK || !reply.WriteString(refreshInfoToSP)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_REFRESH_INFO_TO_SP Write refreshInfoToSP failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_PHYSICAL_SCREEN_RESOLUTION): { + ScreenId id{INVALID_SCREEN_ID}; + uint32_t width{0}; + uint32_t height{0}; + if (!data.ReadUint64(id) || !data.ReadUint32(width) || !data.ReadUint32(height)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_PHYSICAL_SCREEN_RESOLUTION Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + int32_t status = SetPhysicalScreenResolution(id, width, height); + if (!reply.WriteInt32(status)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_PHYSICAL_SCREEN_RESOLUTION Write status failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_RESOLUTION): { + ScreenId id{INVALID_SCREEN_ID}; + uint32_t width{0}; + uint32_t height{0}; + if (!data.ReadUint64(id) || !data.ReadUint32(width) || !data.ReadUint32(height)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_VIRTUAL_SCREEN_RESOLUTION Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + int32_t status = SetVirtualScreenResolution(id, width, height); + if (!reply.WriteInt32(status)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_VIRTUAL_SCREEN_RESOLUTION Write status failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_DISPLAY_IDENTIFICATION_DATA): { + ScreenId id{INVALID_SCREEN_ID}; + uint8_t outPort{0}; + std::vector edidData{}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_DISPLAY_IDENTIFICATION_DATA Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + int32_t result = GetDisplayIdentificationData(id, outPort, edidData); + if (!reply.WriteUint8(result)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_DISPLAY_IDENTIFICATION_DATA Write result failed!"); + ret = IPC_STUB_WRITE_PARCEL_ERR; + break; + } + if (result != SUCCESS) { + break; + } + if (!reply.WriteUint8(outPort) || + !reply.WriteUint32(static_cast(edidData.size())) || + !reply.WriteBuffer(edidData.data(), edidData.size())) { + RS_LOGE("RSClientToServiceConnectionStub::GET_DISPLAY_IDENTIFICATION_DATA Write parcel failed!"); + ret = IPC_STUB_WRITE_PARCEL_ERR; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::REPAINT_EVERYTHING): { + RepaintEverything(); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_POWER_STATUS): { + ScreenId id{INVALID_SCREEN_ID}; + uint32_t status{0}; + if (!data.ReadUint64(id) || !data.ReadUint32(status)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_POWER_STATUS Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + SetScreenPowerStatus(id, static_cast(status)); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_APPLICATION_AGENT): { + pid_t pid = GetCallingPid(); + RS_PROFILER_PATCH_PID(data, pid); + auto remoteObject = data.ReadRemoteObject(); + if (remoteObject == nullptr) { + ret = ERR_NULL_OBJECT; + break; + } + sptr app = iface_cast(remoteObject); + if (app == nullptr) { + ret = ERR_NULL_OBJECT; + break; + } + RegisterApplicationAgent(pid, app); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_ACTIVE_MODE): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_ACTIVE_MODE Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + RSScreenModeInfo screenModeInfo; + if (GetScreenActiveMode(id, screenModeInfo) != ERR_OK || !reply.WriteParcelable(&screenModeInfo)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_ACTIVE_MODE Write screenModeInfo failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_MODES): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_MODES Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + std::vector screenSupportedModes = GetScreenSupportedModes(id); + if (!reply.WriteUint64(static_cast(screenSupportedModes.size()))) { + RS_LOGE( + "RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_MODES Write screenSupportedModesSize failed!"); + ret = ERR_INVALID_REPLY; + break; + } + for (uint32_t modeIndex = 0; modeIndex < screenSupportedModes.size(); modeIndex++) { + if (!reply.WriteParcelable(&screenSupportedModes[modeIndex])) { + RS_LOGE( + "RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_MODES Write screenSupportedModes failed!"); + ret = ERR_INVALID_REPLY; + break; + } + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHIC): { + int32_t pid{0}; + if (!data.ReadInt32(pid)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_MEMORY_GRAPHIC Read pid failed!"); + ret = ERR_INVALID_DATA; + break; + } + RS_PROFILER_PATCH_PID(data, pid); + if (!IsValidCallingPid(pid, callingPid)) { + RS_LOGW("GET_MEMORY_GRAPHIC invalid pid[%{public}d]", callingPid); + ret = ERR_INVALID_DATA; + break; + } + MemoryGraphic memoryGraphic; + if (GetMemoryGraphic(pid, memoryGraphic) != ERR_OK || !reply.WriteParcelable(&memoryGraphic)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_MEMORY_GRAPHIC Write memoryGraphic failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHICS): { + std::vector memoryGraphics; + if (GetMemoryGraphics(memoryGraphics) != ERR_OK || + !reply.WriteUint64(static_cast(memoryGraphics.size()))) { + RS_LOGE("RSClientToServiceConnectionStub::GET_MEMORY_GRAPHIC Write memoryGraphicsSize failed!"); + ret = ERR_INVALID_REPLY; + break; + } + for (uint32_t index = 0; index < memoryGraphics.size(); index++) { + if (!reply.WriteParcelable(&memoryGraphics[index])) { + RS_LOGE("RSClientToServiceConnectionStub::GET_MEMORY_GRAPHIC Write memoryGraphics failed!"); + ret = ERR_INVALID_REPLY; + break; + } + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_TOTAL_APP_MEM_SIZE): { + float cpuMemSize = 0.f; + float gpuMemSize = 0.f; + if (GetTotalAppMemSize(cpuMemSize, gpuMemSize) != ERR_OK || !reply.WriteFloat(cpuMemSize) + || !reply.WriteFloat(gpuMemSize)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_TOTAL_APP_MEM_SIZE Write parcel failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CAPABILITY): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_CAPABILITY Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + RSScreenCapability screenCapability = GetScreenCapability(id); + if (!reply.WriteParcelable(&screenCapability)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_CAPABILITY Write screenCapability failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_POWER_STATUS): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_POWER_STATUS Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + uint32_t powerStatus{static_cast(INVALID_POWER_STATUS)}; + if (GetScreenPowerStatus(id, powerStatus) != ERR_OK || !reply.WriteUint32(powerStatus)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_POWER_STATUS Write status failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_DATA): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_DATA Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + RSScreenData screenData = GetScreenData(id); + if (!reply.WriteParcelable(&screenData)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_DATA Write screenData failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_BACK_LIGHT): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_BACK_LIGHT Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + int32_t backLightLevel{static_cast(INVALID_BACKLIGHT_VALUE)}; + if (GetScreenBacklight(id, backLightLevel) != ERR_OK || !reply.WriteInt32(backLightLevel)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_BACK_LIGHT Write level failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_BACK_LIGHT): { + ScreenId id{INVALID_SCREEN_ID}; + uint32_t level{0}; + if (!data.ReadUint64(id) || !data.ReadUint32(level)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_BACK_LIGHT Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + SetScreenBacklight(id, level); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_AVAILABLE_LISTENER): { + NodeId id{0}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_BUFFER_AVAILABLE_LISTENER Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (!accessible && (ExtractPid(id) != callingPid)) { + RS_LOGW("The SetBufferAvailableListener isn't legal, nodeId:%{public}" PRIu64 ", callingPid:%{public}d", + id, callingPid); + break; + } + RS_PROFILER_PATCH_NODE_ID(data, id); + auto remoteObject = data.ReadRemoteObject(); + bool isFromRenderThread{false}; + if (!data.ReadBool(isFromRenderThread)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_BUFFER_AVAILABLE_LISTENER read isFromRenderThread failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (remoteObject == nullptr) { + ret = ERR_NULL_OBJECT; + break; + } + sptr cb = iface_cast(remoteObject); + if (cb == nullptr) { + ret = ERR_NULL_OBJECT; + break; + } + RegisterBufferAvailableListener(id, cb, isFromRenderThread); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_CLEAR_LISTENER): { + NodeId id{0}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_BUFFER_CLEAR_LISTENER Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (!accessible && (ExtractPid(id) != callingPid)) { + RS_LOGW("The SetBufferClearListener isn't legal, nodeId:%{public}" PRIu64 ", callingPid:%{public}d", + id, callingPid); + break; + } + RS_PROFILER_PATCH_NODE_ID(data, id); + auto remoteObject = data.ReadRemoteObject(); + if (remoteObject == nullptr) { + ret = ERR_NULL_OBJECT; + break; + } + sptr cb = iface_cast(remoteObject); + if (cb == nullptr) { + ret = ERR_NULL_OBJECT; + break; + } + RegisterBufferClearListener(id, cb); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_GAMUTS): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_GAMUTS Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + std::vector modeSend; + std::vector mode; + int32_t result = GetScreenSupportedColorGamuts(id, mode); + if (!reply.WriteInt32(result)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_GAMUTS Write result failed!"); + ret = ERR_INVALID_REPLY; + break; + } + if (result != StatusCode::SUCCESS) { + ret = ERR_UNKNOWN_REASON; + break; + } + std::copy(mode.begin(), mode.end(), std::back_inserter(modeSend)); + if (!reply.WriteUInt32Vector(modeSend)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_GAMUTS Write modeSend failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_METADATAKEYS): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_METADATAKEYS Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + std::vector keySend; + std::vector keys; + int32_t result = GetScreenSupportedMetaDataKeys(id, keys); + if (!reply.WriteInt32(result)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_METADATAKEYS Write result failed!"); + ret = ERR_INVALID_REPLY; + break; + } + if (result != StatusCode::SUCCESS) { + ret = ERR_UNKNOWN_REASON; + break; + } + for (auto i : keys) { + keySend.push_back(i); + } + if (!reply.WriteUInt32Vector(keySend)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_METADATAKEYS Write keySend failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_GAMUT Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + ScreenColorGamut mode; + int32_t result = GetScreenColorGamut(id, mode); + if (!reply.WriteInt32(result)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_GAMUT Write result failed!"); + ret = ERR_INVALID_REPLY; + break; + } + if (result != StatusCode::SUCCESS) { + ret = ERR_UNKNOWN_REASON; + break; + } + if (!reply.WriteUint32(mode)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_GAMUT Write mode failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT): { + ScreenId id{INVALID_SCREEN_ID}; + int32_t modeIdx{0}; + if (!data.ReadUint64(id) || !data.ReadInt32(modeIdx)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_GAMUT Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + int32_t result = SetScreenColorGamut(id, modeIdx); + if (!reply.WriteInt32(result)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_GAMUT Write result failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT_MAP): { + ScreenId id{INVALID_SCREEN_ID}; + int32_t mode{0}; + if (!data.ReadUint64(id) || !data.ReadInt32(mode)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_GAMUT_MAP Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + int32_t result = SetScreenGamutMap(id, static_cast(mode)); + if (!reply.WriteInt32(result)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_GAMUT_MAP Write parcel failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CORRECTION): { + ScreenId id{INVALID_SCREEN_ID}; + int32_t screenRotation{0}; + if (!data.ReadUint64(id) || !data.ReadInt32(screenRotation)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_CORRECTION Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + int32_t result = SetScreenCorrection(id, static_cast(screenRotation)); + if (!reply.WriteInt32(result)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_CORRECTION Write parcel failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast( + RSIRenderServiceConnectionInterfaceCode::SET_GLOBAL_DARK_COLOR_MODE): { + bool isDark{false}; + if (!data.ReadBool(isDark)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_GLOBAL_DARK_COLOR_MODE Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (SetGlobalDarkColorMode(isDark) != ERR_OK) { + RS_LOGE("RSClientToServiceConnectionStub::SET_GLOBAL_DARK_COLOR_MODE Write result failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT_MAP): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_GAMUT_MAP Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + ScreenGamutMap mode; + int32_t result = GetScreenGamutMap(id, mode); + if (!reply.WriteInt32(result)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_GAMUT_MAP Write result failed!"); + ret = ERR_INVALID_REPLY; + break; + } + if (result != StatusCode::SUCCESS) { + ret = ERR_UNKNOWN_REASON; + break; + } + if (!reply.WriteUint32(mode)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_GAMUT_MAP Write mode failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_VSYNC_CONNECTION): { + std::string name; + if (!data.ReadString(name)) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_VSYNC_CONNECTION read name failed!"); + ret = ERR_INVALID_DATA; + break; + } + auto remoteObj = data.ReadRemoteObject(); + uint64_t id{0}; + NodeId windowNodeID{0}; + if (!data.ReadUint64(id) || !data.ReadUint64(windowNodeID)) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_VSYNC_CONNECTION read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (remoteObj == nullptr) { + ret = ERR_NULL_OBJECT; + break; + } + if (!remoteObj->IsProxyObject()) { + ret = ERR_UNKNOWN_OBJECT; + break; + } + auto token = iface_cast(remoteObj); + if (token == nullptr) { + ret = ERR_UNKNOWN_OBJECT; + break; + } + sptr conn = nullptr; + VSyncConnParam vsyncConnParam = {id, windowNodeID, false}; + CreateVSyncConnection(conn, name, token, vsyncConnParam); + if (conn == nullptr) { + ret = ERR_NULL_OBJECT; + break; + } +#ifdef ENABLE_IPC_SECURITY_ACCESS_COUNTER + securityUtils_.IncreaseAccessCounter(code); +#endif + if (!reply.WriteRemoteObject(conn->AsObject())) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_VSYNC_CONNECTION Write Object failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_STATUS): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_HDR_STATUS Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + HdrStatus hdrStatus; + int32_t resCode; + ret = GetScreenHDRStatus(id, hdrStatus, resCode); + if (ret != ERR_OK) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_HDR_STATUS Business error(%{public}d)!", ret); + resCode = ret; + } + if (!reply.WriteInt32(resCode)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_HDR_STATUS Write resCode failed!"); + ret = ERR_INVALID_REPLY; + break; + } + if (resCode != StatusCode::SUCCESS) { + break; + } + if (!reply.WriteUint32(hdrStatus)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_HDR_STATUS Write hdrStatus failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_COLORSPACES): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_COLORSPACES Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + std::vector colorSpacesSend; + std::vector colorSpaces; + int32_t resCode; + GetScreenSupportedColorSpaces(id, colorSpaces, resCode); + if (!reply.WriteInt32(resCode)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_COLORSPACES Write resCode failed!"); + ret = ERR_INVALID_REPLY; + break; + } + if (resCode != StatusCode::SUCCESS) { + break; + } + std::copy(colorSpaces.begin(), colorSpaces.end(), std::back_inserter(colorSpacesSend)); + if (!reply.WriteUInt32Vector(colorSpacesSend)) { + RS_LOGE( + "RSClientToServiceConnectionStub::GET_SCREEN_SUPPORTED_COLORSPACES Write colorSpacesSend failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_COLORSPACE): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_COLORSPACE Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + GraphicCM_ColorSpaceType colorSpace; + int32_t resCode; + GetScreenColorSpace(id, colorSpace, resCode); + if (!reply.WriteInt32(resCode)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_COLORSPACE Write result failed!"); + ret = ERR_INVALID_REPLY; + break; + } + if (resCode != StatusCode::SUCCESS) { + break; + } + if (!reply.WriteUint32(colorSpace)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_COLORSPACE Write colorSpace failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_COLORSPACE): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_COLORSPACE Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + int32_t color{0}; + if (!data.ReadInt32(color)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_COLORSPACE read colorSpace failed!"); + ret = ERR_INVALID_DATA; + break; + } + GraphicCM_ColorSpaceType colorSpace = static_cast(color); + int32_t resCode; + SetScreenColorSpace(id, colorSpace, resCode); + if (!reply.WriteInt32(resCode)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_COLORSPACE Write result failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_TYPE): { + ScreenId id{INVALID_SCREEN_ID}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_TYPE Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + RSScreenType type; + int32_t result = GetScreenType(id, type); + if (!reply.WriteInt32(result)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_TYPE Write result failed!"); + ret = ERR_INVALID_REPLY; + break; + } + if (result != StatusCode::SUCCESS) { + ret = ERR_UNKNOWN_REASON; + break; + } + if (!reply.WriteUint32(type)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_SCREEN_TYPE Write type failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_BITMAP): { + NodeId id{0}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_BITMAP Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (!IsValidCallingPid(ExtractPid(id), callingPid)) { + RS_LOGW("The GetBitmap isn't legal, nodeId:%{public}" PRIu64 ", callingPid:%{public}d", + id, callingPid); + break; + } + RS_PROFILER_PATCH_NODE_ID(data, id); + Drawing::Bitmap bm; + bool success; + if (GetBitmap(id, bm, success) != ERR_OK || !reply.WriteBool(success)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_BITMAP Write success failed!"); + ret = ERR_INVALID_REPLY; + break; + } + if (success) { + RSMarshallingHelper::Marshalling(reply, bm); + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_PIXELMAP): { + NodeId id{0}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_PIXELMAP Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (!IsValidCallingPid(ExtractPid(id), callingPid)) { + RS_LOGW("The GetPixelmap isn't legal, nodeId:%{public}" PRIu64 ", callingPid:%{public}d", + id, callingPid); + break; + } + RS_PROFILER_PATCH_NODE_ID(data, id); + std::shared_ptr pixelmap = + std::shared_ptr(data.ReadParcelable()); + Drawing::Rect rect; + RSMarshallingHelper::Unmarshalling(data, rect); + std::shared_ptr drawCmdList; + RSMarshallingHelper::Unmarshalling(data, drawCmdList); + bool success; + if (GetPixelmap(id, pixelmap, &rect, drawCmdList, success) != ERR_OK || + !reply.WriteBool(success)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_PIXELMAP Write id failed!"); + ret = ERR_INVALID_REPLY; + break; + } + if (success) { + RSMarshallingHelper::Marshalling(reply, pixelmap); + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::NEED_REGISTER_TYPEFACE): { + bool result = false; + uint64_t uniqueId{0}; + uint32_t hash{0}; + if (!data.ReadUint64(uniqueId) || !data.ReadUint32(hash)) { + RS_LOGE("RSClientToServiceConnectionStub::NEED_REGISTER_TYPEFACE read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + RS_PROFILER_PATCH_TYPEFACE_GLOBALID(data, uniqueId); + if (IsValidCallingPid(ExtractPid(uniqueId), callingPid)) { + result = !RSTypefaceCache::Instance().HasTypeface(uniqueId, hash); + } else { + RS_LOGE("RSClientToServiceConnectionStub::OnRemoteRequest callingPid[%{public}d] " + "no permission NEED_REGISTER_TYPEFACE", callingPid); + } + if (!reply.WriteBool(result)) { + RS_LOGE("RSClientToServiceConnectionStub::NEED_REGISTER_TYPEFACE Write result failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_RECT): { + ScreenId id{INVALID_SCREEN_ID}; + int32_t x{0}; + int32_t y{0}; + int32_t w{0}; + int32_t h{0}; + if (!data.ReadUint64(id) || !data.ReadInt32(x) || !data.ReadInt32(y) || + !data.ReadInt32(w) || !data.ReadInt32(h)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_ACTIVE_RECT Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + Rect activeRect { + .x = x, + .y = y, + .w = w, + .h = h + }; + uint32_t repCode; + if (SetScreenActiveRect(id, activeRect, repCode) != ERR_OK || !reply.WriteUint32(repCode)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_ACTIVE_RECT Write result failed!"); + return ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_OFFSET): { + ScreenId id = INVALID_SCREEN_ID; + int32_t offsetX = 0; + int32_t offsetY = 0; + if (!data.ReadUint64(id) || !data.ReadInt32(offsetX) || !data.ReadInt32(offsetY)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_OFFSET Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + SetScreenOffset(id, offsetX, offsetY); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_FRAME_GRAVITY): { + ScreenId id = INVALID_SCREEN_ID; + int32_t gravity = 0; + if (!data.ReadUint64(id) || !data.ReadInt32(gravity)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_SCREEN_FRAME_GRAVITY Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + SetScreenFrameGravity(id, gravity); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::EXECUTE_SYNCHRONOUS_TASK): { + int16_t type{0}; + int16_t subType{0}; + if (!data.ReadInt16(type) || !data.ReadInt16(subType)) { + RS_LOGE("RSClientToServiceConnectionStub::EXECUTE_SYNCHRONOUS_TASK Read parcel failed!"); + ret = ERR_INVALID_STATE; + break; + } + if (type != RS_NODE_SYNCHRONOUS_READ_PROPERTY && type != RS_NODE_SYNCHRONOUS_GET_VALUE_FRACTION) { + ret = ERR_INVALID_STATE; + break; + } + auto func = RSCommandFactory::Instance().GetUnmarshallingFunc(type, subType); + if (func == nullptr) { + ret = ERR_INVALID_STATE; + break; + } + auto command = static_cast((*func)(data)); + if (command == nullptr) { + ret = ERR_INVALID_STATE; + break; + } + std::shared_ptr task(command); + const auto& nodeMap = RSMainThread::Instance()->GetContext().GetNodeMap(); + if (!task->IsCallingPidValid(callingPid, nodeMap)) { + ret = ERR_INVALID_STATE; + break; + } + ExecuteSynchronousTask(task); + if (!task->Marshalling(reply)) { + ret = ERR_INVALID_STATE; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_HARDWARE_ENABLED) : { + uint64_t id{0}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_HARDWARE_ENABLED Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (!IsValidCallingPid(ExtractPid(id), callingPid)) { + RS_LOGW("The SetHardwareEnabled isn't legal, nodeId:%{public}" PRIu64 ", callingPid:%{public}d", + id, callingPid); + break; + } + bool isEnabled{false}; + uint8_t selfDrawingType{static_cast(SelfDrawingNodeType::DEFAULT)}; + bool dynamicHardwareEnable{false}; + if (!data.ReadBool(isEnabled) || + !data.ReadUint8(selfDrawingType) || + !data.ReadBool(dynamicHardwareEnable)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_HARDWARE_ENABLED Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + SetHardwareEnabled(id, isEnabled, static_cast(selfDrawingType), dynamicHardwareEnable); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_HIDE_PRIVACY_CONTENT) : { + uint64_t id{0}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_HIDE_PRIVACY_CONTENT Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + auto isSystemCalling = RSInterfaceCodeAccessVerifierBase::IsSystemCalling( + RSIRenderServiceConnectionInterfaceCodeAccessVerifier::codeEnumTypeName_ + + "::SET_HIDE_PRIVACY_CONTENT"); + if (!isSystemCalling) { + if (!reply.WriteUint32(static_cast(RSInterfaceErrorCode::NONSYSTEM_CALLING))) { + RS_LOGE("RSClientToServiceConnectionStub::SET_HIDE_PRIVACY_CONTENT Write isSystemCalling failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + if (ExtractPid(id) != callingPid) { + RS_LOGW("The SetHidePrivacyContent isn't legal, nodeId:%{public}" PRIu64 ", callingPid:%{public}d", + id, callingPid); + if (!reply.WriteUint32(static_cast(RSInterfaceErrorCode::NOT_SELF_CALLING))) { + RS_LOGE("RSClientToServiceConnectionStub::SET_HIDE_PRIVACY_CONTENT Write ErrorCode failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + bool needHidePrivacyContent{false}; + if (!data.ReadBool(needHidePrivacyContent)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_HIDE_PRIVACY_CONTENT read needHidePrivacyContent failed!"); + ret = ERR_INVALID_DATA; + break; + } + uint32_t resCode; + if (SetHidePrivacyContent(id, needHidePrivacyContent, resCode) != ERR_OK || + !reply.WriteUint32(resCode)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_HIDE_PRIVACY_CONTENT Write resCode failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_REFRESH_RATE_EVENT) : { + std::string eventName; + bool eventStatus{false}; + uint32_t minRefreshRate{0}; + uint32_t maxRefreshRate{0}; + std::string description; + if (!data.ReadString(eventName) || !data.ReadBool(eventStatus) || !data.ReadUint32(minRefreshRate) || + !data.ReadUint32(maxRefreshRate) || !data.ReadString(description)) { + RS_LOGE("RSClientToServiceConnectionStub::NOTIFY_REFRESH_RATE_EVENT Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + EventInfo eventInfo = { + eventName, eventStatus, minRefreshRate, maxRefreshRate, description + }; + NotifyRefreshRateEvent(eventInfo); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_WINDOW_ID) : { + std::unordered_map eventInfos; + + uint32_t mapSize{0}; + if (!data.ReadUint32(mapSize)) { + RS_LOGE("RSClientToServiceConnectionStub::NOTIFY_WINDOW_EXPECTED_BY_WINDOW_ID Read mapSize failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (mapSize > MAX_VOTER_SIZE) { + ret = ERR_INVALID_STATE; + break; + } + bool shouldBreak = false; + for (uint32_t i = 0; i < mapSize; ++i) { + uint64_t windowId{0}; + if (!data.ReadUint64(windowId)) { + RS_LOGE("RSClientToServiceConnectionStub::NOTIFY_WINDOW_EXPECTED_BY_WINDOW_ID Read parcel failed!"); + ret = ERR_INVALID_DATA; + shouldBreak = true; + break; + } + EventInfo eventInfo; + if (!EventInfo::Deserialize(data, eventInfo)) { + RS_LOGE("RSClientToServiceConnectionStub::NOTIFY_WINDOW_EXPECTED_BY_WINDOW_ID Read parcel failed!"); + ret = ERR_INVALID_DATA; + shouldBreak = true; + break; + } + eventInfos[windowId] = eventInfo; + } + if (!shouldBreak) { + SetWindowExpectedRefreshRate(eventInfos); + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_VSYNC_NAME) : { + std::unordered_map eventInfos; + + uint32_t mapSize{0}; + if (!data.ReadUint32(mapSize)) { + RS_LOGE("RSClientToServiceConnectionStub::NOTIFY_WINDOW_EXPECTED_BY_VSYNC_NAME Read mapSize failed!"); + ret = ERR_INVALID_DATA; + break; + } + if (mapSize > MAX_VOTER_SIZE) { + ret = ERR_INVALID_STATE; + break; + } + bool shouldBreak = false; + for (uint32_t i = 0; i < mapSize; ++i) { + std::string vsyncName; + if (!data.ReadString(vsyncName)) { + RS_LOGE("RSClientToServiceConnectionStub::NOTIFY_WINDOW_EXPECTED_BY_VSYNC_NAME Read parcel failed!"); + ret = ERR_INVALID_DATA; + shouldBreak = true; + break; + } + EventInfo eventInfo; + if (!EventInfo::Deserialize(data, eventInfo)) { + RS_LOGE("RSClientToServiceConnectionStub::NOTIFY_WINDOW_EXPECTED_BY_VSYNC_NAME Read parcel failed!"); + ret = ERR_INVALID_DATA; + shouldBreak = true; + break; + } + eventInfos[vsyncName] = eventInfo; + } + if (!shouldBreak) { + SetWindowExpectedRefreshRate(eventInfos); + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SOFT_VSYNC_EVENT) : { + uint32_t pid{0}; + uint32_t rateDiscount{0}; + if (!data.ReadUint32(pid) || !data.ReadUint32(rateDiscount)) { + RS_LOGE("RSClientToServiceConnectionStub::NOTIFY_SOFT_VSYNC_EVENT Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + NotifySoftVsyncEvent(pid, rateDiscount); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_DYNAMIC_MODE_EVENT) : { + bool enableDynamicMode{false}; + if (!data.ReadBool(enableDynamicMode)) { + RS_LOGE("RSClientToServiceConnectionStub::NOTIFY_DYNAMIC_MODE_EVENT Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + NotifyDynamicModeEvent(enableDynamicMode); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_TOUCH_EVENT) : { + int32_t touchStatus{0}; + int32_t touchCnt{0}; + if (!data.ReadInt32(touchStatus) || !data.ReadInt32(touchCnt)) { + RS_LOGE("RSClientToServiceConnectionStub::NOTIFY_TOUCH_EVENT Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + NotifyTouchEvent(touchStatus, touchCnt); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_XCOMPONENT_EXPECTED_FRAMERATE) : { + std::string id; + int32_t expectedFrameRate; + if (!data.ReadString(id) || !data.ReadInt32(expectedFrameRate)) { + RS_LOGE("RSClientToServiceConnectionStub::NOTIFY_XCOMPONENT_EXPECTED_FRAMERATE Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + NotifyXComponentExpectedFrameRate(id, expectedFrameRate); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::GET_LAYER_COMPOSE_INFO) : { + const auto& LayerComposeInfo = GetLayerComposeInfo(); + if (!reply.WriteInt32(LayerComposeInfo.uniformRenderFrameNumber) || + !reply.WriteInt32(LayerComposeInfo.offlineComposeFrameNumber) || + !reply.WriteInt32(LayerComposeInfo.redrawFrameNumber)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_LAYER_COMPOSE_INFO Write LayerComposeInfo failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode:: + GET_HARDWARE_COMPOSE_DISABLED_REASON_INFO) : { + const auto& hwcDisabledReasonInfos = GetHwcDisabledReasonInfo(); + if (!reply.WriteInt32(hwcDisabledReasonInfos.size())) { + RS_LOGE("RSClientToServiceConnectionStub::GET_HARDWARE_COMPOSE_DISABLED_REASON_INFO Write " + "hwcDisabledReasonInfos failed!"); + ret = ERR_INVALID_REPLY; + break; + } + for (const auto& hwcDisabledReasonInfo : hwcDisabledReasonInfos) { + for (const auto& disabledReasonCount : hwcDisabledReasonInfo.disabledReasonStatistics) { + if (!reply.WriteInt32(disabledReasonCount)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_HARDWARE_COMPOSE_DISABLED_REASON_INFO Write " + "disabledReasonCount failed!"); + ret = ERR_INVALID_REPLY; + break; + } + } + if (ret == ERR_INVALID_REPLY) { + break; + } + if (!reply.WriteInt32(hwcDisabledReasonInfo.pidOfBelongsApp) || + !reply.WriteString(hwcDisabledReasonInfo.nodeName)) { + RS_LOGE("RSClientToServiceConnectionStub::GET_HARDWARE_COMPOSE_DISABLED_REASON_INFO Write " + "hwcDisabledReasonInfo failed!"); + ret = ERR_INVALID_REPLY; + break; + } + } + break; + } +#ifdef TP_FEATURE_ENABLE + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_TP_FEATURE_CONFIG) : { + int32_t feature{0}; + if (!data.ReadInt32(feature)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_TP_FEATURE_CONFIG Read feature failed!"); + ret = ERR_INVALID_DATA; + break; + } + auto config = data.ReadCString(); + if (config == nullptr) { + RS_LOGE("RSClientToServiceConnectionStub::SET_TP_FEATURE_CONFIG Read config failed!"); + ret = ERR_INVALID_DATA; + break; + } + uint8_t tpFeatureConfigType{0}; + if (!data.ReadUint8(tpFeatureConfigType)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_TP_FEATURE_CONFIG Read tpFeatureConfigType failed!"); + ret = ERR_INVALID_DATA; + break; + } + SetTpFeatureConfig(feature, config, static_cast(tpFeatureConfigType)); + break; + } +#endif + case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PAGE_NAME) : { + std::string packageName; + std::string pageName; + bool isEnter{false}; + if (!data.ReadString(packageName) || !data.ReadString(pageName) || !data.ReadBool(isEnter)) { + RS_LOGE("NOTIFY_PAGE_NAME read data err."); + ret = ERR_INVALID_DATA; + break; + } + NotifyPageName(packageName, pageName, isEnter); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_DISPLAY_NODE) : { + uint64_t id{0}; + if (!data.ReadUint64(id)) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_DISPLAY_NODE Read id failed!"); + ret = ERR_INVALID_DATA; + break; + } + bool isNonSystemCalling = false; + bool isTokenTypeValid = true; + RSInterfaceCodeAccessVerifierBase::GetAccessType(isTokenTypeValid, isNonSystemCalling); + if (isNonSystemCalling && !IsValidCallingPid(ExtractPid(id), callingPid)) { + RS_LOGW("CREATE_DISPLAY_NODE invalid nodeId[%{public}" PRIu64 "] pid[%{public}d]", id, callingPid); + ret = ERR_INVALID_DATA; + break; + } + uint64_t mirroredId{0}; + uint64_t screenId{0}; + bool isMirror{false}; + if (!data.ReadUint64(mirroredId) || + !data.ReadUint64(screenId) || + !data.ReadBool(isMirror)) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_DISPLAY_NODE Read config failed!"); + ret = ERR_INVALID_DATA; + break; + } + RSDisplayNodeConfig config = { + .screenId = screenId, + .isMirrored = isMirror, + .mirrorNodeId = mirroredId, + .isSync = true, + }; + bool success; + if (CreateNode(config, id, success) != ERR_OK || reply.WriteBool(success)) { + RS_LOGE("RSClientToServiceConnectionStub::CREATE_DISPLAY_NODE Write success failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP_FOR_HARDWARE_COMPOSER) : { + NodeId nodeId = {}; + bool isTop{false}; + uint32_t topLayerZOrder = 0; + if (!data.ReadUint64(nodeId) || !data.ReadBool(isTop) || !data.ReadUint32(topLayerZOrder)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_LAYER_TOP_FOR_HARDWARE_COMPOSER Read parcel failed"); + ret = ERR_INVALID_DATA; + break; + } + SetLayerTopForHWC(nodeId, isTop, topLayerZOrder); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP) : { + std::string nodeIdStr; + bool isTop{false}; + if (!data.ReadString(nodeIdStr) || + !data.ReadBool(isTop)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_LAYER_TOP Read parcel failed!"); + ret = ERR_INVALID_DATA; + break; + } + SetLayerTop(nodeIdStr, isTop); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SCREEN_SWITCHED) : { + NotifyScreenSwitched(); + break; + } + case static_cast( + RSIRenderServiceConnectionInterfaceCode::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK): { + uint32_t size; + if (!data.ReadUint32(size)) { + ROSEN_LOGE( + "RSClientToServiceConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Read size failed"); + ret = ERR_INVALID_REPLY; + break; + } + RectConstraint constraint; + if (size > MAX_PID_SIZE_NUMBER) { + ROSEN_LOGE("RSClientToServiceConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK " + "size number is too large."); + break; + } + for (uint32_t i = 0; i < size; ++i) { + pid_t pid; + if (!data.ReadInt32(pid)) { + ROSEN_LOGE("RSClientToServiceConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Read " + "pid failed"); + ret = ERR_INVALID_REPLY; + break; + } + constraint.pids.insert(pid); + } + if (!data.ReadInt32(constraint.range.lowLimit.width) || !data.ReadInt32(constraint.range.lowLimit.height) || + !data.ReadInt32(constraint.range.highLimit.width) || + !data.ReadInt32(constraint.range.highLimit.height)) { + ROSEN_LOGE("RSClientToServiceConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Read " + "rectRange failed"); + ret = ERR_INVALID_REPLY; + break; + } + auto remoteObject = data.ReadRemoteObject(); + if (remoteObject == nullptr) { + RS_LOGE("RSClientToServiceConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Read " + "remoteObject failed!"); + ret = ERR_NULL_OBJECT; + break; + } + sptr callback = + iface_cast(remoteObject); + if (callback == nullptr) { + ret = ERR_NULL_OBJECT; + break; + } + int32_t status = RegisterSelfDrawingNodeRectChangeCallback(constraint, callback); + if (!reply.WriteInt32(status)) { + RS_LOGE("RSClientToServiceConnectionStub::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK Write status " + "failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast( + RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK): { + int32_t status = UnRegisterSelfDrawingNodeRectChangeCallback(); + if (!reply.WriteInt32(status)) { + ret = ERR_INVALID_REPLY; + } + } + case static_cast( + RSIRenderServiceConnectionInterfaceCode::REGISTER_TRANSACTION_DATA_CALLBACK): { + uint64_t token = data.ReadUint64(); + uint64_t timeStamp = data.ReadUint64(); + auto remoteObject = data.ReadRemoteObject(); + if (remoteObject == nullptr) { + ret = ERR_NULL_OBJECT; + RS_LOGE("RSClientToServiceConnectionStub::OnRemoteRequest remoteObject == nullptr"); + break; + } + sptr callback = + iface_cast(remoteObject); + if (callback == nullptr) { + ret = ERR_NULL_OBJECT; + RS_LOGE("RSClientToServiceConnectionStub::OnRemoteRequest callback == nullptr"); + break; + } + RS_LOGD("RSClientToServiceConnectionStub: already decode unicode, timeStamp: %{public}" + PRIu64 " token: %{public}" PRIu64, timeStamp, token); + RegisterTransactionDataCallback(token, timeStamp, callback); + break; + } +#ifdef RS_ENABLE_OVERLAY_DISPLAY + case static_cast(RSIRenderServiceConnectionInterfaceCode::SET_OVERLAY_DISPLAY_MODE) : { + RS_LOGI("RSRenderServicrConnectionStub::OnRemoteRequest SET_OVERLAY_DISPLAY_MODE"); + int32_t mode{0}; + if (!data.ReadInt32(mode)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_OVERLAY_DISPLAY_MODE Read mode failed!"); + ret = ERR_INVALID_DATA; + break; + } + int32_t result = SetOverlayDisplayMode(mode); + if (!reply.WriteInt32(result)) { + RS_LOGE("RSClientToServiceConnectionStub::SET_OVERLAY_DISPLAY_MODE Write status failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } +#endif + case static_cast(RSIRenderServiceConnectionInterfaceCode::AVCODEC_VIDEO_START): { + uint64_t uniqueId{0}; + std::string surfaceName; + uint32_t fps{0}; + uint64_t reportTime{0}; + if (!data.ReadUint64(uniqueId) || !data.ReadString(surfaceName) + || !data.ReadUint32(fps) || !data.ReadUint64(reportTime)) { + RS_LOGE("RSClientToServiceConnectionStub::AVCODEC_VIDEO_START : read data err!"); + ret = ERR_INVALID_DATA; + break; + } + int32_t result = AvcodecVideoStart(uniqueId, surfaceName, fps, reportTime); + if (!reply.WriteInt32(result)) { + RS_LOGE("RSClientToServiceConnectionStub::AVCODEC_VIDEO_START Write status failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::AVCODEC_VIDEO_STOP): { + uint64_t uniqueId{0}; + std::string surfaceName; + uint32_t fps{0}; + if (!data.ReadUint64(uniqueId) || !data.ReadString(surfaceName) || !data.ReadUint32(fps)) { + RS_LOGE("RSClientToServiceConnectionStub::AVCODEC_VIDEO_STOP : read data err!"); + ret = ERR_INVALID_DATA; + break; + } + int32_t result = AvcodecVideoStop(uniqueId, surfaceName, fps); + if (!reply.WriteInt32(result)) { + RS_LOGE("RSClientToServiceConnectionStub::AVCODEC_VIDEO_STOP Write status failed!"); + ret = ERR_INVALID_REPLY; + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::PROFILER_SERVICE_OPEN_FILE): { + HrpServiceDir baseDirType = HrpServiceGetDirType(data.ReadUint32()); + std::string subDir = data.ReadString(); + std::string subDir2 = data.ReadString(); + std::string fileName = data.ReadString(); + int32_t flags = data.ReadInt32(); + + int32_t retFd = -1; + HrpServiceDirInfo dirInfo{baseDirType, subDir, subDir2}; + RetCodeHrpService retCode = ProfilerServiceOpenFile(dirInfo, fileName, flags, retFd); + reply.WriteInt32((int32_t)retCode); + reply.WriteFileDescriptor(retFd); + if (retFd != -1) { + close(retFd); // call 'close' due to dup was invoked + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::PROFILER_SERVICE_POPULATE_FILES): { + HrpServiceDir baseDirType = HrpServiceGetDirType(data.ReadUint32()); + std::string subDir = data.ReadString(); + std::string subDir2 = data.ReadString(); + uint32_t firstFileIndex = data.ReadUint32(); + + std::vector retFiles; + HrpServiceDirInfo dirInfo{baseDirType, subDir, subDir2}; + RetCodeHrpService retCode = ProfilerServicePopulateFiles(dirInfo, firstFileIndex, retFiles); + reply.WriteInt32((int32_t)retCode); + reply.WriteUint32((uint32_t)retFiles.size()); + for (const auto& fi : retFiles) { + reply.WriteString(fi.name); + reply.WriteUint32(fi.size); + reply.WriteBool(fi.isDir); + reply.WriteUint32(fi.accessBits); + reply.WriteUint64(fi.accessTime.sec); + reply.WriteUint64(fi.accessTime.nsec); + reply.WriteUint64(fi.modifyTime.sec); + reply.WriteUint64(fi.modifyTime.nsec); + } + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::PROFILER_IS_SECURE_SCREEN): { + bool retValue = ProfilerIsSecureScreen(); + reply.WriteBool(retValue); + break; + } + case static_cast(RSIRenderServiceConnectionInterfaceCode::CLEAR_UIFIRST_CACHE) : { + NodeId nodeId = {}; + if (!data.ReadUint64(nodeId)) { + RS_LOGE("RSClientToServiceConnectionStub::CLEAR_UIFIRST_CACHE : read data err!"); + ret = ERR_INVALID_DATA; + break; + } + ClearUifirstCache(nodeId); + break; + } + default: { + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + } + + return ret; +} + +const RSInterfaceCodeSecurityManager RSClientToServiceConnectionStub::securityManager_ = \ + RSInterfaceCodeSecurityManager::CreateInstance(); +} // namespace Rosen +} // namespace OHOS diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_process_connection_proxy.h b/rosen/modules/render_service/core/transaction/rs_client_to_service_connection_stub.h similarity index 36% rename from rosen/modules/render_service_base/src/platform/ohos/rs_render_process_connection_proxy.h rename to rosen/modules/render_service/core/transaction/rs_client_to_service_connection_stub.h index f0d1293b44d6af24ec0e2903ea2b50bacb64ab71..e8022c92be27f54e3629e81387a25fbacdb1c818 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_process_connection_proxy.h +++ b/rosen/modules/render_service/core/transaction/rs_client_to_service_connection_stub.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025 Huawei Device Co., Ltd. + * Copyright (c) 2021 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 @@ -13,27 +13,37 @@ * limitations under the License. */ -#ifndef ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_PROCESS_CONNECTION_PROXY_H -#define ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_PROCESS_CONNECTION_PROXY_H +#ifndef ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_CLIENT_TO_SERVICE_CONNECTION_STUB_H +#define ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_CLIENT_TO_SERVICE_CONNECTION_STUB_H -#include -#include -#include +#include +#include +#include +#include + +#include "platform/ohos/rs_iclient_to_service_connection.h" +#include "platform/ohos/rs_irender_service_connection_ipc_interface_code_access_verifier.h" +#include "ipc_security/rs_ipc_interface_code_security_manager.h" +#include "rs_render_service_security_utils.h" namespace OHOS { namespace Rosen { -class RSRenderProcessConnectionProxy : public IRemoteProxy { +class RSClientToServiceConnectionStub : public IRemoteStub { public: - explicit RSRenderProcessConnectionProxy(const sptr& impl); - virtual ~RSRenderProcessConnectionProxy() noexcept = default; + RSClientToServiceConnectionStub() = default; + ~RSClientToServiceConnectionStub() noexcept = default; - sptr CreateRenderConnection(const sptr& token, pid_t remotePid) override { return nullptr; } + int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; private: - static inline BrokerDelegator delegator_; -}; + static const RSInterfaceCodeSecurityManager securityManager_; + void SetQos(); + RSRenderServiceSecurityUtils securityUtils_; + std::unordered_set tids_; + std::mutex mutex_; +}; } // namespace Rosen } // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_PROCESS_CONNECTION_PROXY_H \ No newline at end of file +#endif // ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_CLIENT_TO_SERVICE_CONNECTION_STUB_H \ No newline at end of file diff --git a/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection.h b/rosen/modules/render_service_base/include/platform/ohos/rs_iclient_to_render_connection.h similarity index 75% rename from rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection.h rename to rosen/modules/render_service_base/include/platform/ohos/rs_iclient_to_render_connection.h index 81eb3471a66c17c25280d129c9744fa997b15452..fa273e80e29e66281f333e2f22c40614a10923c1 100644 --- a/rosen/modules/render_service_base/include/platform/ohos/rs_irender_service_connection.h +++ b/rosen/modules/render_service_base/include/platform/ohos/rs_iclient_to_render_connection.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_IRENDER_SERVICE_CONNECTION_H -#define ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_IRENDER_SERVICE_CONNECTION_H +#ifndef ROSEN_MODULES_RENDER_SERVICE_BASE_PLATFORM_OHOS_RS_ICLIENT_TO_RENDER_CONNECTION_H +#define ROSEN_MODULES_RENDER_SERVICE_BASE_PLATFORM_OHOS_RS_ICLIENT_TO_RENDER_CONNECTION_H #include #include @@ -52,12 +52,17 @@ namespace OHOS { namespace Rosen { -class RSIRenderServiceConnection : public IRemoteBroker { +class RSIClientToRenderConnection : public IRemoteBroker { public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.rosen.RenderServiceConnection"); + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.rosen.ClientToRenderConnection"); - RSIRenderServiceConnection() = default; - virtual ~RSIRenderServiceConnection() noexcept = default; + RSIClientToRenderConnection() = default; + virtual ~RSIClientToRenderConnection() noexcept = default; + + virtual bool SendMessage() = 0; + + virtual sptr CreateRenderConnection(const sptr& token, + pid_t remotePid) = 0; virtual ErrCode CommitTransaction(std::unique_ptr& transactionData) = 0; virtual ErrCode ExecuteSynchronousTask(const std::shared_ptr& task) = 0; @@ -69,11 +74,6 @@ public: virtual ErrCode CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, sptr& sfc, bool unobscured = false) = 0; - virtual ErrCode CreateVSyncConnection(sptr& vsyncConn, - const std::string& name, - const sptr& token = nullptr, - VSyncConnParam vsyncConnParam = {0, 0, false}) = 0; - virtual ErrCode GetPixelMapByProcessId(std::vector& pixelMapInfoVector, pid_t pid, int32_t& repCode) = 0; @@ -82,22 +82,6 @@ public: virtual ErrCode SetFocusAppInfo(const FocusAppInfo& info, int32_t& repCode) = 0; - virtual ErrCode GetDefaultScreenId(uint64_t& screenId) = 0; - - virtual ErrCode GetActiveScreenId(uint64_t& screenId) = 0; - - virtual std::vector GetAllScreenIds() = 0; - - // mirrorId: decide which screen id to mirror, INVALID_SCREEN_ID means do not mirror any screen. - virtual ScreenId CreateVirtualScreen( - const std::string &name, - uint32_t width, - uint32_t height, - sptr surface, - ScreenId mirrorId = 0, - int32_t flags = 0, - std::vector whiteList = {}) = 0; - virtual int32_t SetVirtualScreenBlackList(ScreenId id, std::vector& blackListVector) = 0; virtual ErrCode SetVirtualScreenTypeBlackList( @@ -137,31 +121,13 @@ public: virtual int32_t UnRegisterPointerLuminanceChangeCallback() = 0; #endif - virtual int32_t SetScreenChangeCallback(sptr callback) = 0; - virtual void SetScreenActiveMode(ScreenId id, uint32_t modeId) = 0; - virtual void SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate) = 0; - - virtual void SetRefreshRateMode(int32_t refreshRateMode) = 0; - virtual void SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range, int32_t animatorExpectedFrameRate) = 0; virtual void UnregisterFrameRateLinker(FrameRateLinkerId id) = 0; - virtual uint32_t GetScreenCurrentRefreshRate(ScreenId id) = 0; - - virtual int32_t GetCurrentRefreshRateMode() = 0; - - virtual std::vector GetScreenSupportedRefreshRates(ScreenId id) = 0; - - virtual ErrCode GetShowRefreshRateEnabled(bool& enable) = 0; - - virtual void SetShowRefreshRateEnabled(bool enabled, int32_t type) = 0; - - virtual uint32_t GetRealtimeRefreshRate(ScreenId screenId) = 0; - virtual ErrCode GetRefreshInfo(pid_t pid, std::string& enable) = 0; virtual ErrCode GetRefreshInfoToSP(NodeId id, std::string& enable) = 0; @@ -177,8 +143,6 @@ public: virtual void DisablePowerOffRenderControl(ScreenId id) = 0; - virtual void SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status) = 0; - virtual void TakeSurfaceCapture(NodeId id, sptr callback, const RSSurfaceCaptureConfig& captureConfig, const RSSurfaceCaptureBlurParam& blurParam = {}, const Drawing::Rect& specifiedAreaRect = Drawing::Rect(0.f, 0.f, 0.f, 0.f), @@ -206,42 +170,18 @@ public: virtual ErrCode GetScreenActiveMode(uint64_t id, RSScreenModeInfo& screenModeInfo) = 0; - virtual std::vector GetScreenSupportedModes(ScreenId id) = 0; - - virtual RSScreenCapability GetScreenCapability(ScreenId id) = 0; - - virtual ErrCode GetScreenPowerStatus(uint64_t screenId, uint32_t& status) = 0; - - virtual RSScreenData GetScreenData(ScreenId id) = 0; - virtual ErrCode GetMemoryGraphic(int pid, MemoryGraphic& memoryGraphic) = 0; virtual ErrCode GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize) = 0; virtual ErrCode GetMemoryGraphics(std::vector& memoryGraphics) = 0; - virtual ErrCode GetScreenBacklight(uint64_t id, int32_t& level) = 0; - - virtual void SetScreenBacklight(ScreenId id, uint32_t level) = 0; - virtual ErrCode RegisterBufferAvailableListener( NodeId id, sptr callback, bool isFromRenderThread) = 0; virtual ErrCode RegisterBufferClearListener( NodeId id, sptr callback) = 0; - virtual int32_t GetScreenSupportedColorGamuts(ScreenId id, std::vector& mode) = 0; - - virtual int32_t GetScreenSupportedMetaDataKeys(ScreenId id, std::vector& keys) = 0; - - virtual int32_t GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode) = 0; - - virtual int32_t SetScreenColorGamut(ScreenId id, int32_t modeIdx) = 0; - - virtual int32_t SetScreenGamutMap(ScreenId id, ScreenGamutMap mode) = 0; - - virtual int32_t SetScreenCorrection(ScreenId id, ScreenRotation screenRotation) = 0; - virtual bool SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation) = 0; virtual int32_t SetVirtualScreenAutoRotation(ScreenId id, bool isAutoRotation) = 0; @@ -250,8 +190,6 @@ public: virtual ErrCode SetGlobalDarkColorMode(bool isDark) = 0; - virtual int32_t GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode) = 0; - virtual int32_t GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability) = 0; virtual ErrCode GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat, int32_t& resCode) = 0; @@ -270,12 +208,6 @@ public: virtual ErrCode GetScreenSupportedColorSpaces( ScreenId id, std::vector& colorSpaces, int32_t& resCode) = 0; - virtual ErrCode GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace, int32_t& resCode) = 0; - - virtual ErrCode SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace, int32_t& resCode) = 0; - - virtual int32_t GetScreenType(ScreenId id, RSScreenType& screenType) = 0; - virtual ErrCode GetBitmap(NodeId id, Drawing::Bitmap& bitmap, bool& success) = 0; virtual ErrCode GetPixelmap(NodeId id, std::shared_ptr pixelmap, const Drawing::Rect* rect, std::shared_ptr drawCmdList, bool& success) = 0; @@ -287,8 +219,6 @@ public: virtual ErrCode SetVirtualScreenRefreshRate( ScreenId id, uint32_t maxRefreshRate, uint32_t& actualRefreshRate, int32_t& retVal) = 0; - virtual ErrCode SetScreenActiveRect(ScreenId id, const Rect& activeRect, uint32_t& repCode) = 0; - virtual void SetScreenOffset(ScreenId id, int32_t offsetX, int32_t offsetY) = 0; virtual void SetScreenFrameGravity(ScreenId id, int32_t gravity) = 0; @@ -329,20 +259,10 @@ public: virtual void NotifyAppStrategyConfigChangeEvent(const std::string& pkgName, uint32_t listSize, const std::vector>& newConfig) = 0; - virtual void NotifyRefreshRateEvent(const EventInfo& eventInfo) = 0; - - virtual void SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) = 0; - - virtual void SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) = 0; - virtual ErrCode NotifySoftVsyncEvent(uint32_t pid, uint32_t rateDiscount) = 0; virtual bool NotifySoftVsyncRateDiscountEvent(uint32_t pid, const std::string &name, uint32_t rateDiscount) = 0; - virtual ErrCode NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt) = 0; - - virtual void NotifyDynamicModeEvent(bool enableDynamicMode) = 0; - virtual ErrCode NotifyHgmConfigEvent(const std::string &eventName, bool state) = 0; virtual ErrCode NotifyXComponentExpectedFrameRate(const std::string& id, int32_t expectedFrameRate) = 0; @@ -380,10 +300,6 @@ public: virtual GlobalDirtyRegionInfo GetGlobalDirtyRegionInfo() = 0; - virtual LayerComposeInfo GetLayerComposeInfo() = 0; - - virtual HwcDisabledReasonInfos GetHwcDisabledReasonInfo() = 0; - virtual ErrCode GetHdrOnDuration(int64_t& hdrOnDuration) = 0; virtual ErrCode SetVmaCacheStatus(bool flag) = 0; @@ -397,16 +313,6 @@ public: virtual void SetFreeMultiWindowStatus(bool enable) = 0; - virtual int32_t GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, std::vector& edidData) = 0; - -#ifdef RS_ENABLE_OVERLAY_DISPLAY - virtual ErrCode SetOverlayDisplayMode(int32_t mode) = 0; -#endif - - virtual ErrCode SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder) = 0; - - virtual ErrCode SetLayerTop(const std::string &nodeIdStr, bool isTop) = 0; - virtual ErrCode SetForceRefresh(const std::string &nodeIdStr, bool isForceRefresh) = 0; virtual void SetColorFollow(const std::string &nodeIdStr, bool isColorFollow) = 0; @@ -423,17 +329,8 @@ public: virtual void RegisterTransactionDataCallback(uint64_t token, uint64_t timeStamp, sptr callback) = 0; - virtual ErrCode NotifyScreenSwitched() = 0; - virtual ErrCode SetWindowContainer(NodeId nodeId, bool value) = 0; - virtual int32_t RegisterSelfDrawingNodeRectChangeCallback( - const RectConstraint& constraint, sptr callback) = 0; - - virtual int32_t UnRegisterSelfDrawingNodeRectChangeCallback() = 0; - - virtual ErrCode NotifyPageName(const std::string &packageName, const std::string &pageName, bool isEnter) = 0; - virtual ErrCode AvcodecVideoStart( uint64_t uniqueId, std::string& surfaceName, uint32_t fps, uint64_t reportTime) = 0; @@ -458,4 +355,4 @@ public: } // namespace Rosen } // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_IRENDER_SERVICE_CONNECTION_H +#endif // ROSEN_MODULES_RENDER_SERVICE_BASE_PLATFORM_OHOS_RS_ICLIENT_TO_RENDER_CONNECTION_H diff --git a/rosen/modules/render_service_base/include/platform/ohos/rs_iclient_to_service_connection.h b/rosen/modules/render_service_base/include/platform/ohos/rs_iclient_to_service_connection.h new file mode 100644 index 0000000000000000000000000000000000000000..743d41025fd90cefbf2ae332e8de07a733d3ce75 --- /dev/null +++ b/rosen/modules/render_service_base/include/platform/ohos/rs_iclient_to_service_connection.h @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2021-2023 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. + */ + +#ifndef ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_ICLIENT_TO_SERVICE_CONNECTION_H +#define ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_ICLIENT_TO_SERVICE_CONNECTION_H + +#include +#include +#include + +#include "command/rs_command.h" +#include "command/rs_node_showing_command.h" +#include "feature/capture/rs_ui_capture.h" +#include "ipc_callbacks/buffer_available_callback.h" +#include "ipc_callbacks/buffer_clear_callback.h" +#include "ipc_callbacks/iapplication_agent.h" +#include "ipc_callbacks/rs_iself_drawing_node_rect_change_callback.h" +#include "ipc_callbacks/rs_isurface_occlusion_change_callback.h" +#include "ipc_callbacks/rs_surface_buffer_callback.h" +#include "ipc_callbacks/rs_iframe_rate_linker_expected_fps_update_callback.h" +#include "ipc_callbacks/screen_change_callback.h" +#include "ipc_callbacks/surface_capture_callback.h" +#include "ipc_callbacks/rs_transaction_data_callback.h" +#include "memory/rs_memory_graphic.h" +#include "screen_manager/rs_screen_capability.h" +#include "screen_manager/rs_screen_data.h" +#include "screen_manager/rs_screen_hdr_capability.h" +#include "screen_manager/rs_screen_mode_info.h" +#include "screen_manager/screen_types.h" +#include "screen_manager/rs_virtual_screen_resolution.h" +#include "transaction/rs_transaction_data.h" +#include "transaction/rs_render_service_client.h" +#include "ivsync_connection.h" +#include "ipc_callbacks/rs_ihgm_config_change_callback.h" +#include "ipc_callbacks/rs_ifirst_frame_commit_callback.h" +#include "ipc_callbacks/rs_iocclusion_change_callback.h" +#include "ipc_callbacks/rs_iuiextension_callback.h" +#include "vsync_iconnection_token.h" + +namespace OHOS { +namespace Rosen { + +class RSIClientToServiceConnection : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.rosen.ClientToServiceConnection"); + + RSIClientToServiceConnection() = default; + virtual ~RSIClientToServiceConnection() noexcept = default; + + virtual ErrCode CommitTransaction(std::unique_ptr& transactionData) = 0; + virtual ErrCode ExecuteSynchronousTask(const std::shared_ptr& task) = 0; + + virtual ErrCode GetUniRenderEnabled(bool& enable) = 0; + + virtual ErrCode CreateNode(const RSSurfaceRenderNodeConfig& config, bool& success) = 0; + virtual ErrCode CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId, bool& success) = 0; + virtual ErrCode CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, sptr& sfc, + bool unobscured = false) = 0; + + virtual ErrCode CreateVSyncConnection(sptr& vsyncConn, + const std::string& name, + const sptr& token = nullptr, + VSyncConnParam vsyncConnParam = {0, 0, false}) = 0; + + virtual ErrCode GetDefaultScreenId(uint64_t& screenId) = 0; + + virtual ErrCode GetActiveScreenId(uint64_t& screenId) = 0; + + virtual std::vector GetAllScreenIds() = 0; + + // mirrorId: decide which screen id to mirror, INVALID_SCREEN_ID means do not mirror any screen. + virtual ScreenId CreateVirtualScreen( + const std::string &name, + uint32_t width, + uint32_t height, + sptr surface, + ScreenId mirrorId = 0, + int32_t flags = 0, + std::vector whiteList = {}) = 0; + + virtual int32_t SetVirtualScreenSurface(ScreenId id, sptr surface) = 0; + + virtual void RemoveVirtualScreen(ScreenId id) = 0; + + virtual int32_t SetScreenChangeCallback(sptr callback) = 0; + + virtual void SetScreenActiveMode(ScreenId id, uint32_t modeId) = 0; + + virtual void SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate) = 0; + + virtual void SetRefreshRateMode(int32_t refreshRateMode) = 0; + + virtual void UnregisterFrameRateLinker(FrameRateLinkerId id) = 0; + + virtual uint32_t GetScreenCurrentRefreshRate(ScreenId id) = 0; + + virtual int32_t GetCurrentRefreshRateMode() = 0; + + virtual std::vector GetScreenSupportedRefreshRates(ScreenId id) = 0; + + virtual ErrCode GetShowRefreshRateEnabled(bool& enable) = 0; + + virtual void SetShowRefreshRateEnabled(bool enabled, int32_t type) = 0; + + virtual uint32_t GetRealtimeRefreshRate(ScreenId screenId) = 0; + + virtual ErrCode GetRefreshInfo(pid_t pid, std::string& enable) = 0; + virtual ErrCode GetRefreshInfoToSP(NodeId id, std::string& enable) = 0; + + virtual int32_t SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height) = 0; + + virtual int32_t SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) = 0; + + virtual ErrCode RepaintEverything() = 0; + + virtual void SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status) = 0; + + virtual ErrCode RegisterApplicationAgent(uint32_t pid, sptr app) = 0; + + virtual ErrCode GetScreenActiveMode(uint64_t id, RSScreenModeInfo& screenModeInfo) = 0; + + virtual std::vector GetScreenSupportedModes(ScreenId id) = 0; + + virtual RSScreenCapability GetScreenCapability(ScreenId id) = 0; + + virtual ErrCode GetScreenPowerStatus(uint64_t screenId, uint32_t& status) = 0; + + virtual RSScreenData GetScreenData(ScreenId id) = 0; + + virtual ErrCode GetMemoryGraphic(int pid, MemoryGraphic& memoryGraphic) = 0; + + virtual ErrCode GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize) = 0; + + virtual ErrCode GetMemoryGraphics(std::vector& memoryGraphics) = 0; + + virtual ErrCode GetScreenBacklight(uint64_t id, int32_t& level) = 0; + + virtual void SetScreenBacklight(ScreenId id, uint32_t level) = 0; + + virtual ErrCode RegisterBufferAvailableListener( + NodeId id, sptr callback, bool isFromRenderThread) = 0; + + virtual ErrCode RegisterBufferClearListener( + NodeId id, sptr callback) = 0; + + virtual int32_t GetScreenSupportedColorGamuts(ScreenId id, std::vector& mode) = 0; + + virtual int32_t GetScreenSupportedMetaDataKeys(ScreenId id, std::vector& keys) = 0; + + virtual int32_t GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode) = 0; + + virtual int32_t SetScreenColorGamut(ScreenId id, int32_t modeIdx) = 0; + + virtual int32_t SetScreenGamutMap(ScreenId id, ScreenGamutMap mode) = 0; + + virtual int32_t SetScreenCorrection(ScreenId id, ScreenRotation screenRotation) = 0; + + virtual ErrCode SetGlobalDarkColorMode(bool isDark) = 0; + + virtual int32_t GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode) = 0; + + virtual ErrCode GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus, int32_t& resCode) = 0; + + virtual ErrCode GetScreenSupportedColorSpaces( + ScreenId id, std::vector& colorSpaces, int32_t& resCode) = 0; + + virtual ErrCode GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace, int32_t& resCode) = 0; + + virtual ErrCode SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace, int32_t& resCode) = 0; + + virtual int32_t GetScreenType(ScreenId id, RSScreenType& screenType) = 0; + + virtual ErrCode GetBitmap(NodeId id, Drawing::Bitmap& bitmap, bool& success) = 0; + virtual ErrCode GetPixelmap(NodeId id, std::shared_ptr pixelmap, + const Drawing::Rect* rect, std::shared_ptr drawCmdList, bool& success) = 0; + + virtual ErrCode SetScreenActiveRect(ScreenId id, const Rect& activeRect, uint32_t& repCode) = 0; + + virtual void SetScreenOffset(ScreenId id, int32_t offsetX, int32_t offsetY) = 0; + + virtual void SetScreenFrameGravity(ScreenId id, int32_t gravity) = 0; + + virtual void NotifyRefreshRateEvent(const EventInfo& eventInfo) = 0; + + virtual void SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) = 0; + + virtual void SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) = 0; + + virtual ErrCode NotifySoftVsyncEvent(uint32_t pid, uint32_t rateDiscount) = 0; + + virtual ErrCode NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt) = 0; + + virtual void NotifyDynamicModeEvent(bool enableDynamicMode) = 0; + + virtual ErrCode NotifyXComponentExpectedFrameRate(const std::string& id, int32_t expectedFrameRate) = 0; + + virtual ErrCode SetHardwareEnabled(NodeId id, bool isEnabled, SelfDrawingNodeType selfDrawingType, + bool dynamicHardwareEnable) = 0; + + virtual ErrCode SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent, uint32_t& resCode) = 0; + + virtual LayerComposeInfo GetLayerComposeInfo() = 0; + + virtual HwcDisabledReasonInfos GetHwcDisabledReasonInfo() = 0; + + virtual int32_t GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, std::vector& edidData) = 0; + +#ifdef RS_ENABLE_OVERLAY_DISPLAY + virtual ErrCode SetOverlayDisplayMode(int32_t mode) = 0; +#endif + + virtual ErrCode SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder) = 0; + + virtual ErrCode SetLayerTop(const std::string &nodeIdStr, bool isTop) = 0; + +#ifdef TP_FEATURE_ENABLE + virtual ErrCode SetTpFeatureConfig( + int32_t feature, const char* config, TpFeatureConfigType tpFeatureConfigType) = 0; +#endif + + virtual void RegisterTransactionDataCallback(uint64_t token, uint64_t timeStamp, + sptr callback) = 0; + + virtual ErrCode NotifyScreenSwitched() = 0; + + virtual int32_t RegisterSelfDrawingNodeRectChangeCallback( + const RectConstraint& constraint, sptr callback) = 0; + + virtual int32_t UnRegisterSelfDrawingNodeRectChangeCallback() = 0; + + virtual ErrCode NotifyPageName(const std::string &packageName, const std::string &pageName, bool isEnter) = 0; + + virtual ErrCode AvcodecVideoStart( + uint64_t uniqueId, std::string& surfaceName, uint32_t fps, uint64_t reportTime) = 0; + + virtual ErrCode AvcodecVideoStop(uint64_t uniqueId, std::string& surfaceName, uint32_t fps) = 0; + + virtual RetCodeHrpService ProfilerServiceOpenFile(const HrpServiceDirInfo& dirInfo, + const std::string& fileName, int32_t flags, int& outFd) = 0; + virtual RetCodeHrpService ProfilerServicePopulateFiles(const HrpServiceDirInfo& dirInfo, + uint32_t firstFileIndex, std::vector& outFiles) = 0; + virtual bool ProfilerIsSecureScreen() = 0; + + virtual void ClearUifirstCache(NodeId id) = 0; +}; +} // namespace Rosen +} // namespace OHOS + +#endif // ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_ICLIENT_TO_SERVICE_CONNECTION_H diff --git a/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h b/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h index 2a6973d095dbec516efeae3bb48fdfc3eb00c006..2d70262349dbb27686155c062e57c740d63346e7 100644 --- a/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h +++ b/rosen/modules/render_service_base/include/transaction/rs_render_service_client.h @@ -511,6 +511,10 @@ private: void TriggerOnFinish(const FinishCallbackRet& ret) const; void TriggerOnAfterAcquireBuffer(const AfterAcquireBufferRet& ret) const; void TriggerTransactionDataCallbackAndErase(uint64_t token, uint64_t timeStamp); + + std::shared_ptr GetClientToServiceConnection(); + std::shared_ptr GetClientToRenderConnection(); + struct RectHash { std::size_t operator()(const Drawing::Rect& rect) const { std::size_t h1 = std::hash()(rect.left_); diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_client_to_render_connection_proxy.cpp similarity index 55% rename from rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp rename to rosen/modules/render_service_base/src/platform/ohos/rs_client_to_render_connection_proxy.cpp index 8a6074dc482775d9d87f14830853943b0c9eb3cf..77edcb76f12cd2f838095b7607f67f7f371d1866 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_client_to_render_connection_proxy.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "rs_render_service_connection_proxy.h" +#include "rs_client_to_render_connection_proxy.h" #include #include @@ -34,20 +34,17 @@ static constexpr size_t ASHMEM_SIZE_THRESHOLD = 200 * 1024; // cannot > 500K in static constexpr int MAX_RETRY_COUNT = 20; static constexpr int RETRY_WAIT_TIME_US = 1000; // wait 1ms before retry SendRequest static constexpr int MAX_SECURITY_EXEMPTION_LIST_NUMBER = 1024; // securityExemptionList size not exceed 1024 -static constexpr uint32_t EDID_DATA_MAX_SIZE = 64 * 1024; -static constexpr int MAX_VOTER_SIZE = 100; // SetWindowExpectedRefreshRate map size not exceed 100 -static constexpr int ZERO = 0; // empty map size } -RSRenderServiceConnectionProxy::RSRenderServiceConnectionProxy(const sptr& impl) - : IRemoteProxy(impl) +RSClientToRenderConnectionProxy::RSClientToRenderConnectionProxy(const sptr& impl) + : IRemoteProxy(impl) { } -ErrCode RSRenderServiceConnectionProxy::CommitTransaction(std::unique_ptr& transactionData) +ErrCode RSClientToRenderConnectionProxy::CommitTransaction(std::unique_ptr& transactionData) { if (!transactionData) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CommitTransaction transactionData nullptr!"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CommitTransaction transactionData nullptr!"); return ERR_INVALID_VALUE; } bool isUniMode = RSSystemProperties::GetUniRenderEnabled(); @@ -92,7 +89,7 @@ ErrCode RSRenderServiceConnectionProxy::CommitTransaction(std::unique_ptrGetDataSize()); return ERR_INVALID_VALUE; @@ -102,7 +99,7 @@ ErrCode RSRenderServiceConnectionProxy::CommitTransaction(std::unique_ptr& task) +ErrCode RSClientToRenderConnectionProxy::ExecuteSynchronousTask(const std::shared_ptr& task) { if (task == nullptr) { return ERR_INVALID_VALUE; @@ -111,7 +108,7 @@ ErrCode RSRenderServiceConnectionProxy::ExecuteSynchronousTask(const std::shared MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSRenderServiceConnectionProxy::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSClientToRenderConnectionProxy::GetDescriptor())) { ROSEN_LOGE("ExecuteSynchronousTask WriteInterfaceToken failed"); return ERR_INVALID_VALUE; } @@ -132,7 +129,7 @@ ErrCode RSRenderServiceConnectionProxy::ExecuteSynchronousTask(const std::shared return ERR_OK; } -bool RSRenderServiceConnectionProxy::FillParcelWithTransactionData( +bool RSClientToRenderConnectionProxy::FillParcelWithTransactionData( std::unique_ptr& transactionData, std::shared_ptr& data) { // write a flag at the begin of parcel to identify parcel type @@ -179,7 +176,7 @@ bool RSRenderServiceConnectionProxy::FillParcelWithTransactionData( return true; } -ErrCode RSRenderServiceConnectionProxy::GetUniRenderEnabled(bool& enable) +ErrCode RSClientToRenderConnectionProxy::GetUniRenderEnabled(bool& enable) { MessageParcel data; MessageParcel reply; @@ -192,41 +189,41 @@ ErrCode RSRenderServiceConnectionProxy::GetUniRenderEnabled(bool& enable) return false; } if (!reply.ReadBool(enable)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetUniRenderEnabled Read enable failed!"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetUniRenderEnabled Read enable failed!"); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId, +ErrCode RSClientToRenderConnectionProxy::CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId, bool& success) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteInterfaceToken err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNode: WriteInterfaceToken err."); success = false; return ERR_INVALID_VALUE; } if (!data.WriteUint64(nodeId)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteUint64 NodeId err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNode: WriteUint64 NodeId err."); success = false; return ERR_INVALID_VALUE; } if (!data.WriteUint64(displayNodeConfig.mirrorNodeId)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteUint64 Config.MirrorNodeId err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNode: WriteUint64 Config.MirrorNodeId err."); success = false; return ERR_INVALID_VALUE; } if (!data.WriteUint64(displayNodeConfig.screenId)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteUint64 Config.ScreenId err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNode: WriteUint64 Config.ScreenId err."); success = false; return ERR_INVALID_VALUE; } if (!data.WriteBool(displayNodeConfig.isMirrored)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode: WriteBool Config.IsMirrored err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNode: WriteBool Config.IsMirrored err."); success = false; return ERR_INVALID_VALUE; } @@ -239,13 +236,13 @@ ErrCode RSRenderServiceConnectionProxy::CreateNode(const RSDisplayNodeConfig& di } if (!reply.ReadBool(success)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode Read success failed!"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNode Read success failed!"); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::CreateNode(const RSSurfaceRenderNodeConfig& config, bool& success) +ErrCode RSClientToRenderConnectionProxy::CreateNode(const RSSurfaceRenderNodeConfig& config, bool& success) { MessageParcel data; MessageParcel reply; @@ -270,13 +267,13 @@ ErrCode RSRenderServiceConnectionProxy::CreateNode(const RSSurfaceRenderNodeConf } if (!reply.ReadBool(success)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNode Read success failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNode Read success failed"); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, +ErrCode RSClientToRenderConnectionProxy::CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, sptr& sfc, bool unobscured) { MessageParcel data; @@ -284,31 +281,31 @@ ErrCode RSRenderServiceConnectionProxy::CreateNodeAndSurface(const RSSurfaceRend MessageOption option; if (!data.WriteUint64(config.id)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteUint64 config.id err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNodeAndSurface: WriteUint64 config.id err."); return ERR_INVALID_VALUE; } if (!data.WriteString(config.name)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteString config.name err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNodeAndSurface: WriteString config.name err."); return ERR_INVALID_VALUE; } if (!data.WriteUint8(static_cast(config.nodeType))) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteUint8 config.nodeType err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNodeAndSurface: WriteUint8 config.nodeType err."); return ERR_INVALID_VALUE; } if (!data.WriteBool(config.isTextureExportNode)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteBool config.isTextureExportNode err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNodeAndSurface: WriteBool config.isTextureExportNode err."); return ERR_INVALID_VALUE; } if (!data.WriteBool(config.isSync)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteBool config.isSync err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNodeAndSurface: WriteBool config.isSync err."); return ERR_INVALID_VALUE; } if (!data.WriteUint8(static_cast(config.surfaceWindowType))) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteUint8 config.surfaceWindowType err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNodeAndSurface: WriteUint8 config.surfaceWindowType err."); return ERR_INVALID_VALUE; } if (!data.WriteBool(unobscured)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateNodeAndSurface: WriteBool unobscured err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreateNodeAndSurface: WriteBool unobscured err."); return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_SYNC); @@ -326,62 +323,7 @@ ErrCode RSRenderServiceConnectionProxy::CreateNodeAndSurface(const RSSurfaceRend return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::CreateVSyncConnection(sptr& vsyncConn, - const std::string& name, - const sptr& token, - VSyncConnParam vsyncConnParam) -{ - if (token == nullptr) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateVSyncConnection: token is nullptr."); - vsyncConn = nullptr; - return ERR_INVALID_VALUE; - } - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteString(name)) { - ROSEN_LOGE("CreateVSyncConnection: WriteString name err."); - vsyncConn = nullptr; - return ERR_INVALID_VALUE; - } - if (!data.WriteRemoteObject(token->AsObject())) { - ROSEN_LOGE("CreateVSyncConnection: WriteRemoteObject token->AsObject() err."); - vsyncConn = nullptr; - return ERR_INVALID_VALUE; - } - if (!data.WriteUint64(vsyncConnParam.id)) { - ROSEN_LOGE("CreateVSyncConnection: WriteUint64 id err."); - vsyncConn = nullptr; - return ERR_INVALID_VALUE; - } - if (!data.WriteUint64(vsyncConnParam.windowNodeId)) { - ROSEN_LOGE("CreateVSyncConnection: WriteUint64 windowNodeId err."); - vsyncConn = nullptr; - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_SYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_VSYNC_CONNECTION); - if (!Remote()) { - vsyncConn = nullptr; - return ERR_INVALID_VALUE; - } - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - vsyncConn = nullptr; - return ERR_INVALID_VALUE; - } - - sptr rObj = reply.ReadRemoteObject(); - if (rObj == nullptr) { - vsyncConn = nullptr; - return ERR_INVALID_VALUE; - } - vsyncConn = iface_cast(rObj); - return ERR_OK; -} - -ErrCode RSRenderServiceConnectionProxy::GetPixelMapByProcessId( +ErrCode RSClientToRenderConnectionProxy::GetPixelMapByProcessId( std::vector& pixelMapInfoVector, pid_t pid, int32_t& repCode) { MessageParcel data; @@ -395,26 +337,26 @@ ErrCode RSRenderServiceConnectionProxy::GetPixelMapByProcessId( uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_PIXELMAP_BY_PROCESSID); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetPixelMapByProcessId: Send Request err"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetPixelMapByProcessId: Send Request err"); repCode = RS_CONNECTION_ERROR; return ERR_INVALID_VALUE; } if (!reply.ReadInt32(repCode)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetPixelMapByProcessId Read repCode failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetPixelMapByProcessId Read repCode failed"); return ERR_INVALID_VALUE; } if (repCode == SUCCESS) { pixelMapInfoVector.clear(); if (!RSMarshallingHelper::Unmarshalling(reply, pixelMapInfoVector)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetPixelMapByProcessId: Unmarshalling failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetPixelMapByProcessId: Unmarshalling failed"); } } else { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetPixelMapByProcessId: Invalid reply"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetPixelMapByProcessId: Invalid reply"); } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::CreatePixelMapFromSurface(sptr surface, +ErrCode RSClientToRenderConnectionProxy::CreatePixelMapFromSurface(sptr surface, const Rect &srcRect, std::shared_ptr &pixelMap) { MessageParcel data; @@ -429,8 +371,8 @@ ErrCode RSRenderServiceConnectionProxy::CreatePixelMapFromSurface(sptr return ERR_INVALID_VALUE; } - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("CreatePixelMapFromSurface: WriteInterfaceToken RSIRenderServiceConnection::GetDescriptor() err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("CreatePixelMapFromSurface: WriteInterfaceToken RSIClientToRenderConnection::GetDescriptor() err."); return ERR_INVALID_VALUE; } if (!data.WriteRemoteObject(producer->AsObject())) { @@ -446,7 +388,7 @@ ErrCode RSRenderServiceConnectionProxy::CreatePixelMapFromSurface(sptr uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_PIXEL_MAP_FROM_SURFACE); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreatePixelMapFromSurface: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::CreatePixelMapFromSurface: Send Request err."); return ERR_INVALID_VALUE; } @@ -458,48 +400,48 @@ ErrCode RSRenderServiceConnectionProxy::CreatePixelMapFromSurface(sptr return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::SetFocusAppInfo(const FocusAppInfo& info, int32_t& repCode) +ErrCode RSClientToRenderConnectionProxy::SetFocusAppInfo(const FocusAppInfo& info, int32_t& repCode) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: WriteInterfaceToken err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetFocusAppInfo: WriteInterfaceToken err."); repCode = WRITE_PARCEL_ERR; return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_ASYNC); if (!data.WriteInt32(info.pid)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: WriteInt32 pid err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetFocusAppInfo: WriteInt32 pid err."); repCode = WRITE_PARCEL_ERR; return ERR_INVALID_VALUE; } if (!data.WriteInt32(info.uid)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: WriteInt32 uid err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetFocusAppInfo: WriteInt32 uid err."); repCode = WRITE_PARCEL_ERR; return ERR_INVALID_VALUE; } if (!data.WriteString(info.bundleName)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: WriteString bundleName err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetFocusAppInfo: WriteString bundleName err."); repCode = WRITE_PARCEL_ERR; return ERR_INVALID_VALUE; } if (!data.WriteString(info.abilityName)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: WriteString abilityName err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetFocusAppInfo: WriteString abilityName err."); repCode = WRITE_PARCEL_ERR; return ERR_INVALID_VALUE; } if (!data.WriteUint64(info.focusNodeId)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: WriteUint64 focusNodeId err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetFocusAppInfo: WriteUint64 focusNodeId err."); repCode = WRITE_PARCEL_ERR; return ERR_INVALID_VALUE; } uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_FOCUS_APP_INFO); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFocusAppInfo: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetFocusAppInfo: Send Request err."); repCode = RS_CONNECTION_ERROR; return ERR_INVALID_VALUE; } @@ -507,188 +449,13 @@ ErrCode RSRenderServiceConnectionProxy::SetFocusAppInfo(const FocusAppInfo& info return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::GetDefaultScreenId(uint64_t& screenId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetDefaultScreenId: WriteInterfaceToken RSIRenderServiceConnection::GetDescriptor() err."); - screenId = INVALID_SCREEN_ID; - return ERR_INVALID_VALUE; - } - - option.SetFlags(MessageOption::TF_SYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_DEFAULT_SCREEN_ID); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("%{public}s: sendrequest error : %{public}d", __func__, err); - screenId = INVALID_SCREEN_ID; - return ERR_INVALID_VALUE; - } - if (!reply.ReadUint64(screenId)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetDefaultScreenId Read id failed"); - screenId = INVALID_SCREEN_ID; - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -ErrCode RSRenderServiceConnectionProxy::GetActiveScreenId(uint64_t& screenId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetActiveScreenId: WriteInterfaceToken RSIRenderServiceConnection::GetDescriptor() err."); - screenId = INVALID_SCREEN_ID; - return ERR_INVALID_VALUE; - } - - option.SetFlags(MessageOption::TF_SYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_SCREEN_ID); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("%{public}s: sendrequest error : %{public}d", __func__, err); - screenId = INVALID_SCREEN_ID; - return ERR_INVALID_VALUE; - } - if (!reply.ReadUint64(screenId)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetActiveScreenId Read id failed"); - screenId = INVALID_SCREEN_ID; - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -std::vector RSRenderServiceConnectionProxy::GetAllScreenIds() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - std::vector screenIds; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetAllScreenIds: WriteInterfaceToken RSIRenderServiceConnection::GetDescriptor() err."); - return std::vector(); - } - - option.SetFlags(MessageOption::TF_SYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ALL_SCREEN_IDS); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return std::vector(); - } - - uint32_t size{0}; - if (!reply.ReadUint32(size)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetAllScreenIds Read size failed"); - return std::vector(); - } - size_t readableSize = reply.GetReadableBytes() / sizeof(ScreenId); - size_t len = static_cast(size); - if (len > readableSize || len > screenIds.max_size()) { - RS_LOGE("RSRenderServiceConnectionProxy GetAllScreenIds Failed read vector, size:%{public}zu," - " readableSize:%{public}zu", len, readableSize); - return screenIds; - } - for (uint32_t i = 0; i < size; i++) { - screenIds.emplace_back(reply.ReadUint64()); - } - - return screenIds; -} - -ScreenId RSRenderServiceConnectionProxy::CreateVirtualScreen( - const std::string &name, - uint32_t width, - uint32_t height, - sptr surface, - ScreenId mirrorId, - int32_t flags, - std::vector whiteList) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("CreateVirtualScreen: WriteInterfaceToken RSIRenderServiceConnection::GetDescriptor() err."); - return INVALID_SCREEN_ID; - } - - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteString(name)) { - ROSEN_LOGE("CreateVirtualScreen: WriteString name err."); - return INVALID_SCREEN_ID; - } - if (!data.WriteUint32(width)) { - ROSEN_LOGE("CreateVirtualScreen: WriteUint32 width err."); - return INVALID_SCREEN_ID; - } - if (!data.WriteUint32(height)) { - ROSEN_LOGE("CreateVirtualScreen: WriteUint32 height err."); - return INVALID_SCREEN_ID; - } - if (surface != nullptr) { - auto producer = surface->GetProducer(); - if (producer != nullptr) { - if (!data.WriteBool(true)) { - ROSEN_LOGE("CreateVirtualScreen: WriteBool [true] err."); - return INVALID_SCREEN_ID; - } - if (!data.WriteRemoteObject(producer->AsObject())) { - ROSEN_LOGE("CreateVirtualScreen: WriteRemoteObject producer->AsObject() err."); - return INVALID_SCREEN_ID; - } - } else { - if (!data.WriteBool(false)) { - ROSEN_LOGE("CreateVirtualScreen: WriteBool [false] err."); - return INVALID_SCREEN_ID; - } - } - } else { - if (!data.WriteBool(false)) { - ROSEN_LOGE("CreateVirtualScreen: WriteBool [false] err."); - return INVALID_SCREEN_ID; - } - } - if (!data.WriteUint64(mirrorId)) { - ROSEN_LOGE("CreateVirtualScreen: WriteUint64 mirrorId err."); - return INVALID_SCREEN_ID; - } - if (!data.WriteInt32(flags)) { - ROSEN_LOGE("CreateVirtualScreen: WriteInt32 flags err."); - return INVALID_SCREEN_ID; - } - if (!data.WriteUInt64Vector(whiteList)) { - ROSEN_LOGE("CreateVirtualScreen: WriteUInt64Vector whiteList err."); - return INVALID_SCREEN_ID; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_VIRTUAL_SCREEN); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::%{public}s: Send Request err.", __func__); - return INVALID_SCREEN_ID; - } - - uint64_t id{0}; - if (!reply.ReadUint64(id)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateVirtualScreen Read id failed"); - return INVALID_SCREEN_ID; - } - return id; -} - -int32_t RSRenderServiceConnectionProxy::SetVirtualScreenBlackList(ScreenId id, std::vector& blackListVector) +int32_t RSClientToRenderConnectionProxy::SetVirtualScreenBlackList(ScreenId id, std::vector& blackListVector) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetVirtualScreenBlackList: WriteInterfaceToken GetDescriptor err."); return WRITE_PARCEL_ERR; } @@ -705,7 +472,7 @@ int32_t RSRenderServiceConnectionProxy::SetVirtualScreenBlackList(ScreenId id, s uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_BLACKLIST); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenBlackList: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualScreenBlackList: Send Request err."); return RS_CONNECTION_ERROR; } @@ -713,14 +480,14 @@ int32_t RSRenderServiceConnectionProxy::SetVirtualScreenBlackList(ScreenId id, s return status; } -ErrCode RSRenderServiceConnectionProxy::SetVirtualScreenTypeBlackList( +ErrCode RSClientToRenderConnectionProxy::SetVirtualScreenTypeBlackList( ScreenId id, std::vector& typeBlackListVector, int32_t& repCode) { MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_ASYNC); - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetVirtualScreenTypeBlackList: WriteInterfaceToken GetDescriptor err."); repCode = WRITE_PARCEL_ERR; return ERR_INVALID_VALUE; @@ -739,7 +506,7 @@ ErrCode RSRenderServiceConnectionProxy::SetVirtualScreenTypeBlackList( uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_TYPE_BLACKLIST); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenTypeBlackList: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualScreenTypeBlackList: Send Request err."); return ERR_INVALID_VALUE; } @@ -747,14 +514,14 @@ ErrCode RSRenderServiceConnectionProxy::SetVirtualScreenTypeBlackList( return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::AddVirtualScreenBlackList( +ErrCode RSClientToRenderConnectionProxy::AddVirtualScreenBlackList( ScreenId id, std::vector& blackListVector, int32_t& repCode) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("AddVirtualScreenBlackList: WriteInterfaceToken GetDescriptor err."); repCode = WRITE_PARCEL_ERR; return ERR_INVALID_VALUE; @@ -774,7 +541,7 @@ ErrCode RSRenderServiceConnectionProxy::AddVirtualScreenBlackList( uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::ADD_VIRTUAL_SCREEN_BLACKLIST); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::AddVirtualScreenBlackList: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::AddVirtualScreenBlackList: Send Request err."); return ERR_INVALID_VALUE; } @@ -782,14 +549,14 @@ ErrCode RSRenderServiceConnectionProxy::AddVirtualScreenBlackList( return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::RemoveVirtualScreenBlackList( +ErrCode RSClientToRenderConnectionProxy::RemoveVirtualScreenBlackList( ScreenId id, std::vector& blackListVector, int32_t& repCode) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("RemoveVirtualScreenBlackList: WriteInterfaceToken GetDescriptor err."); repCode = WRITE_PARCEL_ERR; return ERR_INVALID_VALUE; @@ -809,7 +576,7 @@ ErrCode RSRenderServiceConnectionProxy::RemoveVirtualScreenBlackList( uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN_BLACKLIST); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RemoveVirtualScreenBlackList: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RemoveVirtualScreenBlackList: Send Request err."); return ERR_INVALID_VALUE; } @@ -817,19 +584,19 @@ ErrCode RSRenderServiceConnectionProxy::RemoveVirtualScreenBlackList( return ERR_OK; } -int32_t RSRenderServiceConnectionProxy::SetVirtualScreenSecurityExemptionList( +int32_t RSClientToRenderConnectionProxy::SetVirtualScreenSecurityExemptionList( ScreenId id, const std::vector& securityExemptionList) { if (securityExemptionList.size() > MAX_SECURITY_EXEMPTION_LIST_NUMBER) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenSecurityExemptionList: too many lists."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualScreenSecurityExemptionList: too many lists."); return INVALID_ARGUMENTS; } MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetVirtualScreenSecurityExemptionList: WriteInterfaceToken GetDescriptor err."); return WRITE_PARCEL_ERR; } @@ -847,25 +614,25 @@ int32_t RSRenderServiceConnectionProxy::SetVirtualScreenSecurityExemptionList( RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION_LIST); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenSecurityExemptionList: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualScreenSecurityExemptionList: Send Request err."); return RS_CONNECTION_ERROR; } int32_t status{0}; if (!reply.ReadInt32(status)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenSecurityExemptionList Read status failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualScreenSecurityExemptionList Read status failed"); return READ_PARCEL_ERR; } return status; } -int32_t RSRenderServiceConnectionProxy::SetScreenSecurityMask(ScreenId id, +int32_t RSClientToRenderConnectionProxy::SetScreenSecurityMask(ScreenId id, std::shared_ptr securityMask) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetScreenSecurityMask: WriteInterfaceToken GetDescriptor err."); return WRITE_PARCEL_ERR; } @@ -891,20 +658,20 @@ int32_t RSRenderServiceConnectionProxy::SetScreenSecurityMask(ScreenId id, RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_SECURITY_MASK); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenSecurityMask: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetScreenSecurityMask: Send Request err."); return RS_CONNECTION_ERROR; } return SUCCESS; } -int32_t RSRenderServiceConnectionProxy::SetMirrorScreenVisibleRect( +int32_t RSClientToRenderConnectionProxy::SetMirrorScreenVisibleRect( ScreenId id, const Rect& mainScreenRect, bool supportRotation) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetMirrorScreenVisibleRect: WriteInterfaceToken GetDescriptor err."); return WRITE_PARCEL_ERR; } @@ -927,25 +694,25 @@ int32_t RSRenderServiceConnectionProxy::SetMirrorScreenVisibleRect( RSIRenderServiceConnectionInterfaceCode::SET_MIRROR_SCREEN_VISIBLE_RECT); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetMirrorScreenVisibleRect: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetMirrorScreenVisibleRect: Send Request err."); return RS_CONNECTION_ERROR; } int32_t status{0}; if (!reply.ReadInt32(status)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetMirrorScreenVisibleRect Read status failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetMirrorScreenVisibleRect Read status failed"); return READ_PARCEL_ERR; } return status; } -int32_t RSRenderServiceConnectionProxy::SetCastScreenEnableSkipWindow(ScreenId id, bool enable) +int32_t RSClientToRenderConnectionProxy::SetCastScreenEnableSkipWindow(ScreenId id, bool enable) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetCastScreenEnableSkipWindow: WriteInterfaceToken GetDescriptor err."); return WRITE_PARCEL_ERR; } @@ -962,17 +729,17 @@ int32_t RSRenderServiceConnectionProxy::SetCastScreenEnableSkipWindow(ScreenId i uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_CAST_SCREEN_ENABLE_SKIP_WINDOW); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetCastScreenEnableSkipWindow: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetCastScreenEnableSkipWindow: Send Request err."); return RS_CONNECTION_ERROR; } int32_t result = reply.ReadInt32(); return result; } -int32_t RSRenderServiceConnectionProxy::SetVirtualScreenSurface(ScreenId id, sptr surface) +int32_t RSClientToRenderConnectionProxy::SetVirtualScreenSurface(ScreenId id, sptr surface) { if (surface == nullptr) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenSurface: Send surface is nullptr!"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualScreenSurface: Send surface is nullptr!"); return INVALID_ARGUMENTS; } @@ -980,7 +747,7 @@ int32_t RSRenderServiceConnectionProxy::SetVirtualScreenSurface(ScreenId id, spt MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetVirtualScreenSurface: WriteInterfaceToken GetDescriptor err."); return WRITE_PARCEL_ERR; } @@ -998,7 +765,7 @@ int32_t RSRenderServiceConnectionProxy::SetVirtualScreenSurface(ScreenId id, spt uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SURFACE); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenSurface: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualScreenSurface: Send Request err."); return RS_CONNECTION_ERROR; } @@ -1006,12 +773,12 @@ int32_t RSRenderServiceConnectionProxy::SetVirtualScreenSurface(ScreenId id, spt return status; } -void RSRenderServiceConnectionProxy::RemoveVirtualScreen(ScreenId id) +void RSClientToRenderConnectionProxy::RemoveVirtualScreen(ScreenId id) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("RemoveVirtualScreen: WriteInterfaceToken GetDescriptor err."); return; } @@ -1024,19 +791,19 @@ void RSRenderServiceConnectionProxy::RemoveVirtualScreen(ScreenId id) uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RemoveVirtualScreen: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RemoveVirtualScreen: Send Request err."); return; } } #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR -int32_t RSRenderServiceConnectionProxy::SetPointerColorInversionConfig(float darkBuffer, +int32_t RSClientToRenderConnectionProxy::SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval, int32_t rangeSize) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetPointerColorInversionConfig: WriteInterfaceToken GetDescriptor err."); return WRITE_PARCEL_ERR; } @@ -1060,19 +827,19 @@ int32_t RSRenderServiceConnectionProxy::SetPointerColorInversionConfig(float dar uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_COLOR_INVERSION_CONFIG); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetPointerColorInversionConfig: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetPointerColorInversionConfig: Send Request err."); return RS_CONNECTION_ERROR; } int32_t result = reply.ReadInt32(); return result; } -int32_t RSRenderServiceConnectionProxy::SetPointerColorInversionEnabled(bool enable) +int32_t RSClientToRenderConnectionProxy::SetPointerColorInversionEnabled(bool enable) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetPointerColorInversionEnabled: WriteInterfaceToken GetDescriptor err."); return WRITE_PARCEL_ERR; } @@ -1084,18 +851,18 @@ int32_t RSRenderServiceConnectionProxy::SetPointerColorInversionEnabled(bool ena uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_POINTER_COLOR_INVERSION_ENABLED); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::DisableCursorInvert: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::DisableCursorInvert: Send Request err."); return RS_CONNECTION_ERROR; } int32_t result = reply.ReadInt32(); return result; } -int32_t RSRenderServiceConnectionProxy::RegisterPointerLuminanceChangeCallback( +int32_t RSClientToRenderConnectionProxy::RegisterPointerLuminanceChangeCallback( sptr callback) { if (callback == nullptr) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterPointerLuminanceChangeCallback: callback is nullptr."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterPointerLuminanceChangeCallback: callback is nullptr."); return INVALID_ARGUMENTS; } @@ -1103,7 +870,7 @@ int32_t RSRenderServiceConnectionProxy::RegisterPointerLuminanceChangeCallback( MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("RegisterPointerLuminanceChangeCallback: WriteInterfaceToken GetDescriptor err."); return WRITE_PARCEL_ERR; } @@ -1116,19 +883,19 @@ int32_t RSRenderServiceConnectionProxy::RegisterPointerLuminanceChangeCallback( uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_POINTER_LUMINANCE_CALLBACK); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterPointerLuminanceChangeCallback: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterPointerLuminanceChangeCallback: Send Request err."); return RS_CONNECTION_ERROR; } int32_t result = reply.ReadInt32(); return result; } -int32_t RSRenderServiceConnectionProxy::UnRegisterPointerLuminanceChangeCallback() +int32_t RSClientToRenderConnectionProxy::UnRegisterPointerLuminanceChangeCallback() { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("UnRegisterPointerLuminanceChangeCallback: WriteInterfaceToken GetDescriptor err."); return WRITE_PARCEL_ERR; } @@ -1137,7 +904,7 @@ int32_t RSRenderServiceConnectionProxy::UnRegisterPointerLuminanceChangeCallback RSIRenderServiceConnectionInterfaceCode::UNREGISTER_POINTER_LUMINANCE_CALLBACK); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::UnRegisterPointerLuminanceChangeCallback: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::UnRegisterPointerLuminanceChangeCallback: Send Request err."); return RS_CONNECTION_ERROR; } int32_t result = reply.ReadInt32(); @@ -1145,44 +912,13 @@ int32_t RSRenderServiceConnectionProxy::UnRegisterPointerLuminanceChangeCallback } #endif -int32_t RSRenderServiceConnectionProxy::SetScreenChangeCallback(sptr callback) -{ - if (callback == nullptr) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenChangeCallback: callback is nullptr."); - return INVALID_ARGUMENTS; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetScreenChangeCallback: WriteInterfaceToken GetDescriptor err."); - return WRITE_PARCEL_ERR; - } - - option.SetFlags(MessageOption::TF_ASYNC); - if (!data.WriteRemoteObject(callback->AsObject())) { - ROSEN_LOGE("SetScreenChangeCallback: WriteRemoteObject callback->AsObject() err."); - return WRITE_PARCEL_ERR; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CHANGE_CALLBACK); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenChangeCallback: Send Request err."); - return RS_CONNECTION_ERROR; - } - int32_t result = reply.ReadInt32(); - return result; -} - -void RSRenderServiceConnectionProxy::SetScreenActiveMode(ScreenId id, uint32_t modeId) +void RSClientToRenderConnectionProxy::SetScreenActiveMode(ScreenId id, uint32_t modeId) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetScreenActiveMode: WriteInterfaceToken GetDescriptor err."); return; } @@ -1202,68 +938,14 @@ void RSRenderServiceConnectionProxy::SetScreenActiveMode(ScreenId id, uint32_t m } } -void RSRenderServiceConnectionProxy::SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetScreenRefreshRate: WriteInterfaceToken GetDescriptor err."); - return; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("SetScreenRefreshRate: WriteUint64 id err."); - return; - } - if (!data.WriteInt32(sceneId)) { - ROSEN_LOGE("SetScreenRefreshRate: WriteInt32 sceneId err."); - return; - } - if (!data.WriteInt32(rate)) { - ROSEN_LOGE("SetScreenRefreshRate: WriteInt32 rate err."); - return; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_REFRESH_RATE); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err); - return; - } -} - -void RSRenderServiceConnectionProxy::SetRefreshRateMode(int32_t refreshRateMode) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetRefreshRateMode: WriteInterfaceToken GetDescriptor err."); - return; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteInt32(refreshRateMode)) { - ROSEN_LOGE("SetRefreshRateMode: WriteInt32 refreshRateMode err."); - return; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_REFRESH_RATE_MODE); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err); - return; - } -} - -void RSRenderServiceConnectionProxy::SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range, +void RSClientToRenderConnectionProxy::SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range, int32_t animatorExpectedFrameRate) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SyncFrameRateRange: WriteInterfaceToken GetDescriptor err."); return; } @@ -1286,17 +968,17 @@ void RSRenderServiceConnectionProxy::SyncFrameRateRange(FrameRateLinkerId id, co uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SYNC_FRAME_RATE_RANGE); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err); + ROSEN_LOGE("RSClientToRenderConnectionProxy sendrequest error : %{public}d", err); return; } } -void RSRenderServiceConnectionProxy::UnregisterFrameRateLinker(FrameRateLinkerId id) +void RSClientToRenderConnectionProxy::UnregisterFrameRateLinker(FrameRateLinkerId id) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("UnregisterFrameRateLinker: WriteInterfaceToken GetDescriptor err."); return; } @@ -1309,324 +991,154 @@ void RSRenderServiceConnectionProxy::UnregisterFrameRateLinker(FrameRateLinkerId uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_FRAME_RATE_LINKER); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err); + ROSEN_LOGE("RSClientToRenderConnectionProxy sendrequest error : %{public}d", err); return; } } -uint32_t RSRenderServiceConnectionProxy::GetScreenCurrentRefreshRate(ScreenId id) +ErrCode RSClientToRenderConnectionProxy::GetRefreshInfo(pid_t pid, std::string& enable) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetScreenCurrentRefreshRate: WriteInterfaceToken GetDescriptor err."); - return SUCCESS; + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("GetRefreshInfo: WriteInterfaceToken GetDescriptor err."); + enable = ""; + return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("GetScreenCurrentRefreshRate: WriteUint64 id err."); - return SUCCESS; + if (!data.WriteInt32(pid)) { + ROSEN_LOGE("GetRefreshInfo: WriteInt32 pid err."); + enable = ""; + return ERR_INVALID_VALUE; } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CURRENT_REFRESH_RATE); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err); - return SUCCESS; + ROSEN_LOGE("RSClientToRenderConnectionProxy sendrequest error : %{public}d", err); + enable = ""; + return ERR_INVALID_VALUE; } - uint32_t rate{0}; - if (!reply.ReadUint32(rate)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenCurrentRefreshRate Read rate failed"); - return READ_PARCEL_ERR; + + if (!reply.ReadString(enable)) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetRefreshInfo Read enable failed"); + return ERR_INVALID_VALUE; } - return rate; + return ERR_OK; } -int32_t RSRenderServiceConnectionProxy::GetCurrentRefreshRateMode() +ErrCode RSClientToRenderConnectionProxy::GetRefreshInfoToSP(NodeId id, std::string& enable) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor"); - return SUCCESS; + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("GetRefreshInfoToSP: WriteInterfaceToken GetDescriptor err."); + enable = ""; + return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_SYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_CURRENT_REFRESH_RATE_MODE); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetRefreshInfoToSP: WriteUint64 id err."); + enable = ""; + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO_TO_SP); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err); - return SUCCESS; + ROSEN_LOGE("RSClientToRenderConnectionProxy sendrequest error : %{public}d", err); + enable = ""; + return ERR_INVALID_VALUE; } - int32_t refreshRateMode{0}; - if (!reply.ReadInt32(refreshRateMode)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetCurrentRefreshRateMode Read refreshRateMode failed"); - return READ_PARCEL_ERR; + + if (!reply.ReadString(enable)) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetRefreshInfo Read enable failed"); + return ERR_INVALID_VALUE; } - return refreshRateMode; + return ERR_OK; } -std::vector RSRenderServiceConnectionProxy::GetScreenSupportedRefreshRates(ScreenId id) +int32_t RSClientToRenderConnectionProxy::SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height) { MessageParcel data; MessageParcel reply; - MessageOption option; - std::vector screenSupportedRates; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetScreenSupportedRefreshRates: WriteInterfaceToken GetDescriptor err."); - return screenSupportedRates; + MessageOption option(MessageOption::TF_SYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + ROSEN_LOGE("SetPhysicalScreenResolution: WriteInterfaceToken GetDescriptor err."); + return WRITE_PARCEL_ERR; } - option.SetFlags(MessageOption::TF_SYNC); if (!data.WriteUint64(id)) { - ROSEN_LOGE("GetScreenSupportedRefreshRates: WriteUint64 id err."); - return screenSupportedRates; + ROSEN_LOGE("SetPhysicalScreenResolution: WriteUint64 id err."); + return WRITE_PARCEL_ERR; } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_REFRESH_RATES); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return screenSupportedRates; + if (!data.WriteUint32(width)) { + ROSEN_LOGE("SetPhysicalScreenResolution: WriteUint32 width err."); + return WRITE_PARCEL_ERR; } - uint64_t rateCount{0}; - if (!reply.ReadUint64(rateCount)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenSupportedRefreshRates Read rateCount failed"); - return screenSupportedRates; + if (!data.WriteUint32(height)) { + ROSEN_LOGE("SetPhysicalScreenResolution: WriteUint32 height err."); + return WRITE_PARCEL_ERR; } - size_t readableSize = reply.GetReadableBytes(); - size_t len = static_cast(rateCount); - if (len > readableSize || len > screenSupportedRates.max_size()) { - RS_LOGE("RSRenderServiceConnectionProxy GetScreenSupportedRefreshRates " - "fail read vector, size : %{public}zu, readableSize : %{public}zu", len, readableSize); - return screenSupportedRates; + auto code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_PHYSICAL_SCREEN_RESOLUTION); + if (SendRequest(code, data, reply, option) != ERR_NONE) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetPhysicalScreenResolution: SendRequest error."); + return RS_CONNECTION_ERROR; } - screenSupportedRates.resize(rateCount); - for (uint64_t rateIndex = 0; rateIndex < rateCount; rateIndex++) { - screenSupportedRates[rateIndex] = reply.ReadInt32(); + int32_t status{0}; + if (!reply.ReadInt32(status)) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetPhysicalScreenResolution Read status failed"); + return READ_PARCEL_ERR; } - return screenSupportedRates; + return status; } -ErrCode RSRenderServiceConnectionProxy::GetShowRefreshRateEnabled(bool& enable) +int32_t RSClientToRenderConnectionProxy::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceProxy failed to get descriptor"); - return ERR_INVALID_VALUE; + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("SetVirtualScreenResolution: WriteInterfaceToken GetDescriptor err."); + return WRITE_PARCEL_ERR; } option.SetFlags(MessageOption::TF_SYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SHOW_REFRESH_RATE_ENABLED); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetVirtualScreenResolution: WriteUint64 id err."); + return WRITE_PARCEL_ERR; + } + if (!data.WriteUint32(width)) { + ROSEN_LOGE("SetVirtualScreenResolution: WriteUint32 width err."); + return WRITE_PARCEL_ERR; + } + if (!data.WriteUint32(height)) { + ROSEN_LOGE("SetVirtualScreenResolution: WriteUint32 height err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_RESOLUTION); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err); - return ERR_INVALID_VALUE; - } - if (!reply.ReadBool(enable)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetCurrentRefreshRateMode Read enable failed"); - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -void RSRenderServiceConnectionProxy::SetShowRefreshRateEnabled(bool enabled, int32_t type) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetShowRefreshRateEnabled: WriteInterfaceToken GetDescriptor err."); - return; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteBool(enabled) || !data.WriteInt32(type)) { - ROSEN_LOGE("SetShowRefreshRateEnabled: WriteBool[enable] OR WriteInt32[type] err."); - return; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err); - return; - } -} - -uint32_t RSRenderServiceConnectionProxy::GetRealtimeRefreshRate(ScreenId id) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetRealtimeRefreshRate: WriteInterfaceToken GetDescriptor err."); - return SUCCESS; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("GetRealtimeRefreshRate: WriteUint64 id err."); - return SUCCESS; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REALTIME_REFRESH_RATE); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err); - return SUCCESS; - } - uint32_t rate{0}; - if (!reply.ReadUint32(rate)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetRealtimeRefreshRate Read rate failed"); - return READ_PARCEL_ERR; - } - return rate; -} - -ErrCode RSRenderServiceConnectionProxy::GetRefreshInfo(pid_t pid, std::string& enable) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetRefreshInfo: WriteInterfaceToken GetDescriptor err."); - enable = ""; - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteInt32(pid)) { - ROSEN_LOGE("GetRefreshInfo: WriteInt32 pid err."); - enable = ""; - return ERR_INVALID_VALUE; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err); - enable = ""; - return ERR_INVALID_VALUE; - } - - if (!reply.ReadString(enable)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetRefreshInfo Read enable failed"); - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -ErrCode RSRenderServiceConnectionProxy::GetRefreshInfoToSP(NodeId id, std::string& enable) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetRefreshInfoToSP: WriteInterfaceToken GetDescriptor err."); - enable = ""; - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("GetRefreshInfoToSP: WriteUint64 id err."); - enable = ""; - return ERR_INVALID_VALUE; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO_TO_SP); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceProxy sendrequest error : %{public}d", err); - enable = ""; - return ERR_INVALID_VALUE; - } - - if (!reply.ReadString(enable)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetRefreshInfo Read enable failed"); - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -int32_t RSRenderServiceConnectionProxy::SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!data.WriteInterfaceToken(GetDescriptor())) { - ROSEN_LOGE("SetPhysicalScreenResolution: WriteInterfaceToken GetDescriptor err."); - return WRITE_PARCEL_ERR; - } - if (!data.WriteUint64(id)) { - ROSEN_LOGE("SetPhysicalScreenResolution: WriteUint64 id err."); - return WRITE_PARCEL_ERR; - } - if (!data.WriteUint32(width)) { - ROSEN_LOGE("SetPhysicalScreenResolution: WriteUint32 width err."); - return WRITE_PARCEL_ERR; - } - if (!data.WriteUint32(height)) { - ROSEN_LOGE("SetPhysicalScreenResolution: WriteUint32 height err."); - return WRITE_PARCEL_ERR; - } - auto code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_PHYSICAL_SCREEN_RESOLUTION); - if (SendRequest(code, data, reply, option) != ERR_NONE) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetPhysicalScreenResolution: SendRequest error."); - return RS_CONNECTION_ERROR; - } - int32_t status{0}; - if (!reply.ReadInt32(status)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetPhysicalScreenResolution Read status failed"); - return READ_PARCEL_ERR; - } - return status; -} - -int32_t RSRenderServiceConnectionProxy::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetVirtualScreenResolution: WriteInterfaceToken GetDescriptor err."); - return WRITE_PARCEL_ERR; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("SetVirtualScreenResolution: WriteUint64 id err."); - return WRITE_PARCEL_ERR; - } - if (!data.WriteUint32(width)) { - ROSEN_LOGE("SetVirtualScreenResolution: WriteUint32 width err."); - return WRITE_PARCEL_ERR; - } - if (!data.WriteUint32(height)) { - ROSEN_LOGE("SetVirtualScreenResolution: WriteUint32 height err."); - return WRITE_PARCEL_ERR; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_RESOLUTION); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenResolution: Send Request err."); - return RS_CONNECTION_ERROR; + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualScreenResolution: Send Request err."); + return RS_CONNECTION_ERROR; } int32_t status{0}; if (!reply.ReadInt32(status)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenResolution Read status failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualScreenResolution Read status failed"); return READ_PARCEL_ERR; } return status; } -ErrCode RSRenderServiceConnectionProxy::MarkPowerOffNeedProcessOneFrame() +ErrCode RSClientToRenderConnectionProxy::MarkPowerOffNeedProcessOneFrame() { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::MarkPowerOffNeedProcessOneFrame: Send Request err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::MarkPowerOffNeedProcessOneFrame: Send Request err."); return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_SYNC); @@ -1636,14 +1148,14 @@ ErrCode RSRenderServiceConnectionProxy::MarkPowerOffNeedProcessOneFrame() return err != NO_ERROR ? ERR_INVALID_VALUE : ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::RepaintEverything() +ErrCode RSClientToRenderConnectionProxy::RepaintEverything() { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RepaintEverything: Send Request err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::RepaintEverything: Send Request err."); return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_SYNC); @@ -1656,14 +1168,14 @@ ErrCode RSRenderServiceConnectionProxy::RepaintEverything() return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::ForceRefreshOneFrameWithNextVSync() +ErrCode RSClientToRenderConnectionProxy::ForceRefreshOneFrameWithNextVSync() { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ForceRefreshOneFrameWithNextVSync: Send Request err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::ForceRefreshOneFrameWithNextVSync: Send Request err."); return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_SYNC); @@ -1676,13 +1188,13 @@ ErrCode RSRenderServiceConnectionProxy::ForceRefreshOneFrameWithNextVSync() return ERR_OK; } -void RSRenderServiceConnectionProxy::DisablePowerOffRenderControl(ScreenId id) +void RSClientToRenderConnectionProxy::DisablePowerOffRenderControl(ScreenId id) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("DisablePowerOffRenderControl: WriteInterfaceToken GetDescriptor err."); return; } @@ -1698,34 +1210,7 @@ void RSRenderServiceConnectionProxy::DisablePowerOffRenderControl(ScreenId id) } } -void RSRenderServiceConnectionProxy::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetScreenPowerStatus: WriteInterfaceToken GetDescriptor err."); - return; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("SetScreenPowerStatus: WriteUint64 id err."); - return; - } - if (!data.WriteUint32(static_cast(status))) { - ROSEN_LOGE("SetScreenPowerStatus: WriteUint32 status err."); - return; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_POWER_STATUS); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("SetScreenPowerStatus: SendRequest failed %{public}d", err); - return; - } -} - -ErrCode RSRenderServiceConnectionProxy::RegisterApplicationAgent(uint32_t pid, sptr app) +ErrCode RSClientToRenderConnectionProxy::RegisterApplicationAgent(uint32_t pid, sptr app) { if (app == nullptr) { ROSEN_LOGE("%{public}s callback == nullptr", __func__); @@ -1749,7 +1234,7 @@ ErrCode RSRenderServiceConnectionProxy::RegisterApplicationAgent(uint32_t pid, s return ERR_OK; } -void RSRenderServiceConnectionProxy::TakeSurfaceCapture(NodeId id, sptr callback, +void RSClientToRenderConnectionProxy::TakeSurfaceCapture(NodeId id, sptr callback, const RSSurfaceCaptureConfig& captureConfig, const RSSurfaceCaptureBlurParam& blurParam, const Drawing::Rect& specifiedAreaRect, RSSurfaceCapturePermissions /* permissions */) { @@ -1791,7 +1276,7 @@ void RSRenderServiceConnectionProxy::TakeSurfaceCapture(NodeId id, sptr>> RSRenderServiceConnectionProxy::TakeSurfaceCaptureSoloNode( +std::vector>> RSClientToRenderConnectionProxy::TakeSurfaceCaptureSoloNode( NodeId id, const RSSurfaceCaptureConfig& captureConfig, RSSurfaceCapturePermissions) { MessageParcel data; @@ -1814,12 +1299,12 @@ std::vector>> RSRenderService return pixelMapIdPairVector; } if (!RSMarshallingHelper::Unmarshalling(reply, pixelMapIdPairVector)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::TakeSurfaceCaptureSoloNode Unmarshalling failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::TakeSurfaceCaptureSoloNode Unmarshalling failed"); } return pixelMapIdPairVector; } -void RSRenderServiceConnectionProxy::TakeSelfSurfaceCapture(NodeId id, sptr callback, +void RSClientToRenderConnectionProxy::TakeSelfSurfaceCapture(NodeId id, sptr callback, const RSSurfaceCaptureConfig& captureConfig) { if (callback == nullptr) { @@ -1851,7 +1336,7 @@ void RSRenderServiceConnectionProxy::TakeSelfSurfaceCapture(NodeId id, sptr callback, const RSSurfaceCaptureConfig& captureConfig, const RSSurfaceCaptureBlurParam& blurParam) { @@ -1895,7 +1380,7 @@ ErrCode RSRenderServiceConnectionProxy::SetWindowFreezeImmediately(NodeId id, bo return ERR_OK; } -void RSRenderServiceConnectionProxy::TakeUICaptureInRange( +void RSClientToRenderConnectionProxy::TakeUICaptureInRange( NodeId id, sptr callback, const RSSurfaceCaptureConfig& captureConfig) { if (callback == nullptr) { @@ -1927,7 +1412,7 @@ void RSRenderServiceConnectionProxy::TakeUICaptureInRange( } } -bool RSRenderServiceConnectionProxy::WriteSurfaceCaptureConfig( +bool RSClientToRenderConnectionProxy::WriteSurfaceCaptureConfig( const RSSurfaceCaptureConfig& captureConfig, MessageParcel& data) { if (!data.WriteFloat(captureConfig.scaleX) || !data.WriteFloat(captureConfig.scaleY) || @@ -1952,7 +1437,7 @@ bool RSRenderServiceConnectionProxy::WriteSurfaceCaptureConfig( return true; } -bool RSRenderServiceConnectionProxy::WriteSurfaceCaptureBlurParam( +bool RSClientToRenderConnectionProxy::WriteSurfaceCaptureBlurParam( const RSSurfaceCaptureBlurParam& blurParam, MessageParcel& data) { if (!data.WriteBool(blurParam.isNeedBlur) || !data.WriteFloat(blurParam.blurRadius)) { @@ -1962,7 +1447,7 @@ bool RSRenderServiceConnectionProxy::WriteSurfaceCaptureBlurParam( return true; } -bool RSRenderServiceConnectionProxy::WriteSurfaceCaptureAreaRect( +bool RSClientToRenderConnectionProxy::WriteSurfaceCaptureAreaRect( const Drawing::Rect& specifiedAreaRect, MessageParcel& data) { if (!data.WriteFloat(specifiedAreaRect.left_) || !data.WriteFloat(specifiedAreaRect.top_) || @@ -1973,7 +1458,7 @@ bool RSRenderServiceConnectionProxy::WriteSurfaceCaptureAreaRect( return true; } -ErrCode RSRenderServiceConnectionProxy::SetHwcNodeBounds(int64_t rsNodeId, float positionX, float positionY, +ErrCode RSClientToRenderConnectionProxy::SetHwcNodeBounds(int64_t rsNodeId, float positionX, float positionY, float positionZ, float positionW) { MessageParcel data; @@ -1998,14 +1483,14 @@ ErrCode RSRenderServiceConnectionProxy::SetHwcNodeBounds(int64_t rsNodeId, float return ERR_OK; } -RSVirtualScreenResolution RSRenderServiceConnectionProxy::GetVirtualScreenResolution(ScreenId id) +RSVirtualScreenResolution RSClientToRenderConnectionProxy::GetVirtualScreenResolution(ScreenId id) { MessageParcel data; MessageParcel reply; MessageOption option; RSVirtualScreenResolution virtualScreenResolution; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetVirtualScreenResolution: WriteInterfaceToken GetDescriptor err."); return virtualScreenResolution; } @@ -2028,13 +1513,13 @@ RSVirtualScreenResolution RSRenderServiceConnectionProxy::GetVirtualScreenResolu return virtualScreenResolution; } -ErrCode RSRenderServiceConnectionProxy::GetScreenActiveMode(uint64_t id, RSScreenModeInfo& screenModeInfo) +ErrCode RSClientToRenderConnectionProxy::GetScreenActiveMode(uint64_t id, RSScreenModeInfo& screenModeInfo) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetScreenActiveMode: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -2059,60 +1544,13 @@ ErrCode RSRenderServiceConnectionProxy::GetScreenActiveMode(uint64_t id, RSScree return ERR_OK; } -std::vector RSRenderServiceConnectionProxy::GetScreenSupportedModes(ScreenId id) +ErrCode RSClientToRenderConnectionProxy::GetMemoryGraphics(std::vector& memoryGraphics) { MessageParcel data; MessageParcel reply; MessageOption option; - std::vector screenSupportedModes; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetScreenSupportedModes: WriteInterfaceToken GetDescriptor err."); - return screenSupportedModes; - } - - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("GetScreenSupportedModes: WriteUint64 id err."); - return screenSupportedModes; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_MODES); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return screenSupportedModes; - } - - uint64_t modeCount{0}; - if (!reply.ReadUint64(modeCount)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenSupportedModes Read modeCount failed"); - return screenSupportedModes; - } - size_t readableSize = reply.GetReadableBytes(); - size_t len = static_cast(modeCount); - if (len > readableSize || len > screenSupportedModes.max_size()) { - RS_LOGE("RSRenderServiceConnectionProxy GetScreenSupportedModes Fail read vector, size:%{public}zu," - "readableSize:%{public}zu", len, readableSize); - return screenSupportedModes; - } - screenSupportedModes.resize(modeCount); - for (uint64_t modeIndex = 0; modeIndex < modeCount; modeIndex++) { - sptr itemScreenMode = reply.ReadParcelable(); - if (itemScreenMode == nullptr) { - continue; - } else { - screenSupportedModes[modeIndex] = *itemScreenMode; - } - } - return screenSupportedModes; -} - -ErrCode RSRenderServiceConnectionProxy::GetMemoryGraphics(std::vector& memoryGraphics) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetMemoryGraphics: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -2126,13 +1564,13 @@ ErrCode RSRenderServiceConnectionProxy::GetMemoryGraphics(std::vector(count); if (len > readableSize || len > memoryGraphics.max_size()) { - RS_LOGE("RSRenderServiceConnectionProxy GetMemoryGraphics Failed to read vector, size:%{public}zu," + RS_LOGE("RSClientToRenderConnectionProxy GetMemoryGraphics Failed to read vector, size:%{public}zu," " readableSize:%{public}zu", len, readableSize); return ERR_INVALID_VALUE; } @@ -2148,13 +1586,13 @@ ErrCode RSRenderServiceConnectionProxy::GetMemoryGraphics(std::vector(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CAPABILITY); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return screenCapability; - } - - sptr pScreenCapability(reply.ReadParcelable()); - if (pScreenCapability == nullptr) { - return screenCapability; - } - screenCapability = *pScreenCapability; - return screenCapability; -} - -ErrCode RSRenderServiceConnectionProxy::GetScreenPowerStatus(uint64_t screenId, uint32_t& status) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetScreenPowerStatus: WriteInterfaceToken GetDescriptor err."); - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(screenId)) { - ROSEN_LOGE("GetScreenPowerStatus: WriteUint64 id err."); - return ERR_INVALID_VALUE; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_POWER_STATUS); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return ERR_INVALID_VALUE; - } - status = reply.ReadUint32(); - return ERR_OK; -} - -RSScreenData RSRenderServiceConnectionProxy::GetScreenData(ScreenId id) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - RSScreenData screenData; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetScreenData: WriteInterfaceToken GetDescriptor err."); - return screenData; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("GetScreenData: WriteUint64 id err."); - return screenData; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_DATA); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return screenData; - } - sptr pScreenData(reply.ReadParcelable()); - if (pScreenData == nullptr) { - return screenData; - } - screenData = *pScreenData; - return screenData; -} - -ErrCode RSRenderServiceConnectionProxy::GetScreenBacklight(uint64_t id, int32_t& level) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetScreenBacklight: WriteInterfaceToken GetDescriptor err."); - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("GetScreenBacklight: WriteUint64 id err."); - return ERR_INVALID_VALUE; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_BACK_LIGHT); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return ERR_INVALID_VALUE; - } - if (!reply.ReadInt32(level)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenBacklight Read level failed"); - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -void RSRenderServiceConnectionProxy::SetScreenBacklight(ScreenId id, uint32_t level) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetScreenBacklight: WriteInterfaceToken GetDescriptor err."); - return; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("SetScreenBacklight: WriteUint64 id err."); - return; - } - if (!data.WriteUint32(level)) { - ROSEN_LOGE("SetScreenBacklight: WriteUint32 level err."); - return; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_BACK_LIGHT); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("SetScreenBacklight: SendRequest failed"); - return; - } -} - -ErrCode RSRenderServiceConnectionProxy::RegisterBufferClearListener( +ErrCode RSClientToRenderConnectionProxy::RegisterBufferClearListener( NodeId id, sptr callback) { if (callback == nullptr) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferClearListener: callback is nullptr."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterBufferClearListener: callback is nullptr."); return ERR_INVALID_VALUE; } @@ -2345,7 +1651,7 @@ ErrCode RSRenderServiceConnectionProxy::RegisterBufferClearListener( MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("RegisterBufferClearListener: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -2358,294 +1664,60 @@ ErrCode RSRenderServiceConnectionProxy::RegisterBufferClearListener( ROSEN_LOGE("RegisterBufferClearListener: WriteRemoteObject callback->AsObject() err."); return ERR_INVALID_VALUE; } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_CLEAR_LISTENER); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferClearListener: Send Request err."); - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -ErrCode RSRenderServiceConnectionProxy::RegisterBufferAvailableListener( - NodeId id, sptr callback, bool isFromRenderThread) -{ - if (callback == nullptr) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferAvailableListener: callback is nullptr."); - return ERR_INVALID_VALUE; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RegisterBufferAvailableListener: WriteInterfaceToken GetDescriptor err."); - return ERR_INVALID_VALUE; - } - - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("RegisterBufferAvailableListener: WriteUint64 id err."); - return ERR_INVALID_VALUE; - } - if (!data.WriteRemoteObject(callback->AsObject())) { - ROSEN_LOGE("RegisterBufferAvailableListener: WriteRemoteObject callback->AsObject() err."); - return ERR_INVALID_VALUE; - } - if (!data.WriteBool(isFromRenderThread)) { - ROSEN_LOGE("RegisterBufferAvailableListener: WriteBool isFromRenderThread err."); - return ERR_INVALID_VALUE; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_AVAILABLE_LISTENER); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferAvailableListener: Send Request err."); - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -int32_t RSRenderServiceConnectionProxy::GetScreenSupportedColorGamuts(ScreenId id, std::vector& mode) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetScreenSupportedColorGamuts: WriteInterfaceToken GetDescriptor err."); - return RS_CONNECTION_ERROR; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("GetScreenSupportedColorGamuts: WriteUint64 id err."); - return WRITE_PARCEL_ERR; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_GAMUTS); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return RS_CONNECTION_ERROR; - } - int32_t result{0}; - if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenSupportedColorGamuts Read result failed"); - return READ_PARCEL_ERR; - } - if (result == SUCCESS) { - mode.clear(); - std::vector modeRecv; - reply.ReadUInt32Vector(&modeRecv); - for (auto i : modeRecv) { - mode.push_back(static_cast(i)); - } - } - return result; -} - -int32_t RSRenderServiceConnectionProxy::GetScreenSupportedMetaDataKeys( - ScreenId id, std::vector& keys) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetScreenSupportedMetaDataKeys: WriteInterfaceToken GetDescriptor err."); - return RS_CONNECTION_ERROR; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("GetScreenSupportedMetaDataKeys: WriteUint64 id err."); - return WRITE_PARCEL_ERR; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_METADATAKEYS); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return RS_CONNECTION_ERROR; - } - int32_t result{0}; - if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenSupportedMetaDataKeys Read result failed"); - return READ_PARCEL_ERR; - } - if (result == SUCCESS) { - keys.clear(); - std::vector keyRecv; - reply.ReadUInt32Vector(&keyRecv); - for (auto i : keyRecv) { - keys.push_back(static_cast(i)); - } - } - return result; -} - -int32_t RSRenderServiceConnectionProxy::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetScreenColorGamut: WriteInterfaceToken GetDescriptor err."); - return RS_CONNECTION_ERROR; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("GetScreenColorGamut: WriteUint64 id err."); - return WRITE_PARCEL_ERR; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return RS_CONNECTION_ERROR; - } - int32_t result{0}; - if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenColorGamut Read result failed"); - return READ_PARCEL_ERR; - } - if (result == SUCCESS) { - uint32_t readMode{0}; - if (!reply.ReadUint32(readMode)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenColorGamut Read mode failed"); - return READ_PARCEL_ERR; - } - mode = static_cast(readMode); - } - return result; -} - -int32_t RSRenderServiceConnectionProxy::SetScreenColorGamut(ScreenId id, int32_t modeIdx) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetScreenColorGamut: WriteInterfaceToken GetDescriptor err."); - return RS_CONNECTION_ERROR; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("SetScreenColorGamut: WriteUint64 id err."); - return WRITE_PARCEL_ERR; - } - if (!data.WriteInt32(modeIdx)) { - ROSEN_LOGE("SetScreenColorGamut: WriteInt32 modeIdx err."); - return WRITE_PARCEL_ERR; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return RS_CONNECTION_ERROR; - } - int32_t result{0}; - if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenColorGamut Read result failed"); - return READ_PARCEL_ERR; - } - return result; -} - -int32_t RSRenderServiceConnectionProxy::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetScreenGamutMap: WriteInterfaceToken GetDescriptor err."); - return RS_CONNECTION_ERROR; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("SetScreenGamutMap: WriteUint64 id err."); - return WRITE_PARCEL_ERR; - } - if (!data.WriteUint32(mode)) { - ROSEN_LOGE("SetScreenGamutMap: WriteUint32 mode err."); - return WRITE_PARCEL_ERR; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT_MAP); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return RS_CONNECTION_ERROR; - } - int32_t result{0}; - if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenGamutMap Read result failed"); - return READ_PARCEL_ERR; - } - return result; -} - -int32_t RSRenderServiceConnectionProxy::SetScreenCorrection(ScreenId id, ScreenRotation screenRotation) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetScreenCorrection: WriteInterfaceToken GetDescriptor err."); - return RS_CONNECTION_ERROR; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("SetScreenCorrection: WriteUint64 id err."); - return WRITE_PARCEL_ERR; - } - if (!data.WriteUint32(static_cast(screenRotation))) { - ROSEN_LOGE("SetScreenCorrection: WriteUint32 screenRotation err."); - return WRITE_PARCEL_ERR; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CORRECTION); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_CLEAR_LISTENER); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - return RS_CONNECTION_ERROR; - } - int32_t result{0}; - if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenCorrection Read result failed"); - return READ_PARCEL_ERR; + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterBufferClearListener: Send Request err."); + return ERR_INVALID_VALUE; } - return result; + return ERR_OK; } -int32_t RSRenderServiceConnectionProxy::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode) +ErrCode RSClientToRenderConnectionProxy::RegisterBufferAvailableListener( + NodeId id, sptr callback, bool isFromRenderThread) { + if (callback == nullptr) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterBufferAvailableListener: callback is nullptr."); + return ERR_INVALID_VALUE; + } + MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetScreenGamutMap: WriteInterfaceToken GetDescriptor err."); - return RS_CONNECTION_ERROR; + + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RegisterBufferAvailableListener: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; } + option.SetFlags(MessageOption::TF_SYNC); if (!data.WriteUint64(id)) { - ROSEN_LOGE("GetScreenGamutMap: WriteUint64 id err."); - return WRITE_PARCEL_ERR; + ROSEN_LOGE("RegisterBufferAvailableListener: WriteUint64 id err."); + return ERR_INVALID_VALUE; } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT_MAP); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return RS_CONNECTION_ERROR; + if (!data.WriteRemoteObject(callback->AsObject())) { + ROSEN_LOGE("RegisterBufferAvailableListener: WriteRemoteObject callback->AsObject() err."); + return ERR_INVALID_VALUE; } - int32_t result{0}; - if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenGamutMap Read result failed"); - return READ_PARCEL_ERR; + if (!data.WriteBool(isFromRenderThread)) { + ROSEN_LOGE("RegisterBufferAvailableListener: WriteBool isFromRenderThread err."); + return ERR_INVALID_VALUE; } - if (result == SUCCESS) { - uint32_t readMode{0}; - if (!reply.ReadUint32(readMode)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenGamutMap Read mode failed"); - return READ_PARCEL_ERR; - } - mode = static_cast(readMode); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_AVAILABLE_LISTENER); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterBufferAvailableListener: Send Request err."); + return ERR_INVALID_VALUE; } - return result; + return ERR_OK; } -int32_t RSRenderServiceConnectionProxy::GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability) +int32_t RSClientToRenderConnectionProxy::GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetScreenHDRCapability: WriteInterfaceToken GetDescriptor err."); return RS_CONNECTION_ERROR; } @@ -2661,7 +1733,7 @@ int32_t RSRenderServiceConnectionProxy::GetScreenHDRCapability(ScreenId id, RSSc } int32_t result{0}; if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRCapability Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetScreenHDRCapability Read result failed"); return READ_PARCEL_ERR; } if (result != SUCCESS) { @@ -2675,13 +1747,13 @@ int32_t RSRenderServiceConnectionProxy::GetScreenHDRCapability(ScreenId id, RSSc return SUCCESS; } -ErrCode RSRenderServiceConnectionProxy::GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat, int32_t& resCode) +ErrCode RSClientToRenderConnectionProxy::GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat, int32_t& resCode) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetPixelFormat: WriteInterfaceToken GetDescriptor err."); resCode = WRITE_PARCEL_ERR; return ERR_INVALID_VALUE; @@ -2699,13 +1771,13 @@ ErrCode RSRenderServiceConnectionProxy::GetPixelFormat(ScreenId id, GraphicPixel return ERR_INVALID_VALUE; } if (!reply.ReadInt32(resCode)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetPixelFormat Read resCode failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetPixelFormat Read resCode failed"); return READ_PARCEL_ERR; } if (resCode == SUCCESS) { uint32_t readFormat{0}; if (!reply.ReadUint32(readFormat)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetPixelFormat Read readFormat failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetPixelFormat Read readFormat failed"); return READ_PARCEL_ERR; } pixelFormat = static_cast(readFormat); @@ -2713,13 +1785,13 @@ ErrCode RSRenderServiceConnectionProxy::GetPixelFormat(ScreenId id, GraphicPixel return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::SetPixelFormat(ScreenId id, GraphicPixelFormat pixelFormat, int32_t& resCode) +ErrCode RSClientToRenderConnectionProxy::SetPixelFormat(ScreenId id, GraphicPixelFormat pixelFormat, int32_t& resCode) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetPixelFormat: WriteInterfaceToken GetDescriptor err."); resCode = WRITE_PARCEL_ERR; return ERR_INVALID_VALUE; @@ -2745,13 +1817,13 @@ ErrCode RSRenderServiceConnectionProxy::SetPixelFormat(ScreenId id, GraphicPixel return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::GetScreenSupportedHDRFormats( +ErrCode RSClientToRenderConnectionProxy::GetScreenSupportedHDRFormats( ScreenId id, std::vector& hdrFormats, int32_t& resCode) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetScreenSupportedHDRFormats: WriteInterfaceToken GetDescriptor err."); resCode = RS_CONNECTION_ERROR; return ERR_INVALID_VALUE; @@ -2769,7 +1841,7 @@ ErrCode RSRenderServiceConnectionProxy::GetScreenSupportedHDRFormats( return ERR_INVALID_VALUE; } if (!reply.ReadInt32(resCode)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenSupportedHDRFormats Read resCode failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetScreenSupportedHDRFormats Read resCode failed"); return READ_PARCEL_ERR; } if (resCode == SUCCESS) { @@ -2782,12 +1854,12 @@ ErrCode RSRenderServiceConnectionProxy::GetScreenSupportedHDRFormats( return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::GetScreenHDRFormat(ScreenId id, ScreenHDRFormat& hdrFormat, int32_t& resCode) +ErrCode RSClientToRenderConnectionProxy::GetScreenHDRFormat(ScreenId id, ScreenHDRFormat& hdrFormat, int32_t& resCode) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetScreenHDRFormat: WriteInterfaceToken GetDescriptor err."); resCode = RS_CONNECTION_ERROR; return ERR_INVALID_VALUE; @@ -2805,13 +1877,13 @@ ErrCode RSRenderServiceConnectionProxy::GetScreenHDRFormat(ScreenId id, ScreenHD return ERR_INVALID_VALUE; } if (!reply.ReadInt32(resCode)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRFormat Read resCode failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetScreenHDRFormat Read resCode failed"); return READ_PARCEL_ERR; } if (resCode == SUCCESS) { uint32_t readFormat{0}; if (!reply.ReadUint32(readFormat)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRFormat1 Read readFormat failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetScreenHDRFormat1 Read readFormat failed"); return READ_PARCEL_ERR; } hdrFormat = static_cast(readFormat); @@ -2819,12 +1891,12 @@ ErrCode RSRenderServiceConnectionProxy::GetScreenHDRFormat(ScreenId id, ScreenHD return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::SetScreenHDRFormat(ScreenId id, int32_t modeIdx, int32_t& resCode) +ErrCode RSClientToRenderConnectionProxy::SetScreenHDRFormat(ScreenId id, int32_t modeIdx, int32_t& resCode) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetScreenHDRFormat: WriteInterfaceToken GetDescriptor err."); resCode = RS_CONNECTION_ERROR; return ERR_INVALID_VALUE; @@ -2850,34 +1922,34 @@ ErrCode RSRenderServiceConnectionProxy::SetScreenHDRFormat(ScreenId id, int32_t return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus, int32_t& resCode) +ErrCode RSClientToRenderConnectionProxy::GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus, int32_t& resCode) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRStatus WriteInterfaceToken GetDescriptor err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetScreenHDRStatus WriteInterfaceToken GetDescriptor err."); return WRITE_PARCEL_ERR; } option.SetFlags(MessageOption::TF_SYNC); if (!data.WriteUint64(id)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRStatus WriteUint64 id err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetScreenHDRStatus WriteUint64 id err."); return WRITE_PARCEL_ERR; } uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_STATUS); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRStatus SendRequest error(%{public}d)", err); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetScreenHDRStatus SendRequest error(%{public}d)", err); return RS_CONNECTION_ERROR; } if (!reply.ReadInt32(resCode)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRStatus Read resCode failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetScreenHDRStatus Read resCode failed"); return READ_PARCEL_ERR; } if (resCode == SUCCESS) { uint32_t readHdrStatus{0}; if (!reply.ReadUint32(readHdrStatus)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenHDRStatus Read HDR status failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetScreenHDRStatus Read HDR status failed"); return READ_PARCEL_ERR; } hdrStatus = static_cast(readHdrStatus); @@ -2885,13 +1957,13 @@ ErrCode RSRenderServiceConnectionProxy::GetScreenHDRStatus(ScreenId id, HdrStatu return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::GetScreenSupportedColorSpaces( +ErrCode RSClientToRenderConnectionProxy::GetScreenSupportedColorSpaces( ScreenId id, std::vector& colorSpaces, int32_t& resCode) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetScreenSupportedColorSpaces: WriteInterfaceToken GetDescriptor err."); resCode = RS_CONNECTION_ERROR; return ERR_INVALID_VALUE; @@ -2909,7 +1981,7 @@ ErrCode RSRenderServiceConnectionProxy::GetScreenSupportedColorSpaces( return ERR_INVALID_VALUE; } if (!reply.ReadInt32(resCode)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenSupportedColorSpaces Read resCode failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetScreenSupportedColorSpaces Read resCode failed"); return READ_PARCEL_ERR; } if (resCode == SUCCESS) { @@ -2922,113 +1994,12 @@ ErrCode RSRenderServiceConnectionProxy::GetScreenSupportedColorSpaces( return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::GetScreenColorSpace( - ScreenId id, GraphicCM_ColorSpaceType& colorSpace, int32_t& resCode) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetScreenColorSpace: WriteInterfaceToken GetDescriptor err."); - resCode = RS_CONNECTION_ERROR; - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("GetScreenColorSpace: WriteUint64 id err."); - resCode = WRITE_PARCEL_ERR; - return ERR_INVALID_VALUE; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_COLORSPACE); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - resCode = RS_CONNECTION_ERROR; - return ERR_INVALID_VALUE; - } - if (!reply.ReadInt32(resCode)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenColorSpace Read resCode failed"); - return READ_PARCEL_ERR; - } - if (resCode == SUCCESS) { - uint32_t type{0}; - if (!reply.ReadUint32(type)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenColorSpace Read type failed"); - return READ_PARCEL_ERR; - } - colorSpace = static_cast(type); - } - return ERR_OK; -} - -ErrCode RSRenderServiceConnectionProxy::SetScreenColorSpace( - ScreenId id, GraphicCM_ColorSpaceType colorSpace, int32_t& resCode) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetScreenColorSpace: WriteInterfaceToken GetDescriptor err."); - resCode = RS_CONNECTION_ERROR; - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("SetScreenColorSpace: WriteUint64 id err."); - resCode = WRITE_PARCEL_ERR; - return ERR_INVALID_VALUE; - } - if (!data.WriteInt32(colorSpace)) { - ROSEN_LOGE("SetScreenColorSpace: WriteInt32 colorSpace err."); - resCode = WRITE_PARCEL_ERR; - return ERR_INVALID_VALUE; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_COLORSPACE); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - resCode = RS_CONNECTION_ERROR; - return ERR_INVALID_VALUE; - } - resCode = reply.ReadInt32(); - return ERR_OK; -} - -int32_t RSRenderServiceConnectionProxy::GetScreenType(ScreenId id, RSScreenType& screenType) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetScreenType: WriteInterfaceToken GetDescriptor err."); - return RS_CONNECTION_ERROR; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("GetScreenType: WriteUint64 id err."); - return WRITE_PARCEL_ERR; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_TYPE); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return RS_CONNECTION_ERROR; - } - int32_t result = reply.ReadInt32(); - if (result == SUCCESS) { - uint32_t type{0}; - if (!reply.ReadUint32(type)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetScreenType Read type failed"); - return READ_PARCEL_ERR; - } - screenType = static_cast(type); - } - return result; -} - -ErrCode RSRenderServiceConnectionProxy::GetBitmap(NodeId id, Drawing::Bitmap& bitmap, bool& success) +ErrCode RSClientToRenderConnectionProxy::GetBitmap(NodeId id, Drawing::Bitmap& bitmap, bool& success) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetBitmap: WriteInterfaceToken GetDescriptor err."); success = false; return ERR_INVALID_VALUE; @@ -3047,11 +2018,11 @@ ErrCode RSRenderServiceConnectionProxy::GetBitmap(NodeId id, Drawing::Bitmap& bi } bool result{false}; if (!reply.ReadBool(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetBitmap Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetBitmap Read result failed"); return READ_PARCEL_ERR; } if (!result || !RSMarshallingHelper::Unmarshalling(reply, bitmap)) { - RS_LOGE("RSRenderServiceConnectionProxy::GetBitmap: Unmarshalling failed"); + RS_LOGE("RSClientToRenderConnectionProxy::GetBitmap: Unmarshalling failed"); success = false; return ERR_INVALID_VALUE; } @@ -3059,12 +2030,12 @@ ErrCode RSRenderServiceConnectionProxy::GetBitmap(NodeId id, Drawing::Bitmap& bi return ERR_OK; } -bool RSRenderServiceConnectionProxy::SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation) +bool RSClientToRenderConnectionProxy::SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetVirtualMirrorScreenCanvasRotation: WriteInterfaceToken GetDescriptor err."); return false; } @@ -3085,18 +2056,18 @@ bool RSRenderServiceConnectionProxy::SetVirtualMirrorScreenCanvasRotation(Screen } bool result{false}; if (!reply.ReadBool(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualMirrorScreenCanvasRotation Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualMirrorScreenCanvasRotation Read result failed"); return READ_PARCEL_ERR; } return result; } -int32_t RSRenderServiceConnectionProxy::SetVirtualScreenAutoRotation(ScreenId id, bool isAutoRotation) +int32_t RSClientToRenderConnectionProxy::SetVirtualScreenAutoRotation(ScreenId id, bool isAutoRotation) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetVirtualScreenAutoRotation: WriteInterfaceToken GetDescriptor err."); return RS_CONNECTION_ERROR; } @@ -3112,23 +2083,23 @@ int32_t RSRenderServiceConnectionProxy::SetVirtualScreenAutoRotation(ScreenId id uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_AUTO_ROTATION); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::%{public}s: Send Request err.", __func__); + ROSEN_LOGE("RSClientToRenderConnectionProxy::%{public}s: Send Request err.", __func__); return RS_CONNECTION_ERROR; } int32_t result{-1}; if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::%{public}s Read result failed", __func__); + ROSEN_LOGE("RSClientToRenderConnectionProxy::%{public}s Read result failed", __func__); return READ_PARCEL_ERR; } return result; } -bool RSRenderServiceConnectionProxy::SetVirtualMirrorScreenScaleMode(ScreenId id, ScreenScaleMode scaleMode) +bool RSClientToRenderConnectionProxy::SetVirtualMirrorScreenScaleMode(ScreenId id, ScreenScaleMode scaleMode) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetVirtualMirrorScreenScaleMode: WriteInterfaceToken GetDescriptor err."); return false; } @@ -3149,18 +2120,18 @@ bool RSRenderServiceConnectionProxy::SetVirtualMirrorScreenScaleMode(ScreenId id } bool result{false}; if (!reply.ReadBool(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualMirrorScreenScaleMode Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualMirrorScreenScaleMode Read result failed"); return READ_PARCEL_ERR; } return result; } -ErrCode RSRenderServiceConnectionProxy::SetGlobalDarkColorMode(bool isDark) +ErrCode RSClientToRenderConnectionProxy::SetGlobalDarkColorMode(bool isDark) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetGlobalDarkColorMode: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -3178,13 +2149,13 @@ ErrCode RSRenderServiceConnectionProxy::SetGlobalDarkColorMode(bool isDark) return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::GetPixelmap(NodeId id, std::shared_ptr pixelmap, +ErrCode RSClientToRenderConnectionProxy::GetPixelmap(NodeId id, std::shared_ptr pixelmap, const Drawing::Rect* rect, std::shared_ptr drawCmdList, bool& success) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetPixelmap: WriteInterfaceToken GetDescriptor err."); success = false; return ERR_INVALID_VALUE; @@ -3210,11 +2181,11 @@ ErrCode RSRenderServiceConnectionProxy::GetPixelmap(NodeId id, std::shared_ptr& typeface) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("RegisterTypeface: WriteInterfaceToken GetDescriptor err."); return false; } @@ -3261,23 +2232,23 @@ bool RSRenderServiceConnectionProxy::RegisterTypeface(uint64_t globalUniqueId, uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_TYPEFACE); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - RS_LOGD("RSRenderServiceConnectionProxy::RegisterTypeface: RegisterTypeface failed"); + RS_LOGD("RSClientToRenderConnectionProxy::RegisterTypeface: RegisterTypeface failed"); return false; } bool result{false}; if (!reply.ReadBool(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTypeface Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterTypeface Read result failed"); return READ_PARCEL_ERR; } return result; } -bool RSRenderServiceConnectionProxy::UnRegisterTypeface(uint64_t globalUniqueId) +bool RSClientToRenderConnectionProxy::UnRegisterTypeface(uint64_t globalUniqueId) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("UnRegisterTypeface: WriteInterfaceToken GetDescriptor err."); return false; } @@ -3289,67 +2260,20 @@ bool RSRenderServiceConnectionProxy::UnRegisterTypeface(uint64_t globalUniqueId) uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_TYPEFACE); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - RS_LOGD("RSRenderServiceConnectionProxy::UnRegisterTypeface: send request failed"); + RS_LOGD("RSClientToRenderConnectionProxy::UnRegisterTypeface: send request failed"); return false; } return true; } -int32_t RSRenderServiceConnectionProxy::GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, - std::vector& edidData) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - return RS_CONNECTION_ERROR; - } - if (!data.WriteUint64(id)) { - return WRITE_PARCEL_ERR; - } - option.SetFlags(MessageOption::TF_SYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_DISPLAY_IDENTIFICATION_DATA); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - return RS_CONNECTION_ERROR; - } - int32_t result{0}; - if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetDisplayIdentificationData Read result failed"); - return READ_PARCEL_ERR; - } - if (result != SUCCESS) { - RS_LOGE("RSRenderServiceConnectionProxy::GetDisplayIdentificationData: failed"); - return result; - } - if (!reply.ReadUint8(outPort)) { - return READ_PARCEL_ERR; - } - uint32_t edidSize = reply.ReadUint32(); - if (edidSize == 0 || edidSize > EDID_DATA_MAX_SIZE) { - RS_LOGE("RSRenderServiceConnectionProxy::GetDisplayIdentificationData: EdidSize failed"); - return READ_PARCEL_ERR; - } - edidData.resize(edidSize); - const uint8_t *editpnt = reply.ReadBuffer(edidSize); - if (editpnt == nullptr) { - RS_LOGE("RSRenderServiceConnectionProxy::GetDisplayIdentificationData: ReadBuffer failed"); - return READ_PARCEL_ERR; - } - RS_LOGD("RSRenderServiceConnectionProxy::GetDisplayIdentificationData: EdidSize: %{public}u", edidSize); - edidData.assign(editpnt, editpnt + edidSize); - - return result; -} - -ErrCode RSRenderServiceConnectionProxy::SetScreenSkipFrameInterval(uint64_t id, uint32_t skipFrameInterval, +ErrCode RSClientToRenderConnectionProxy::SetScreenSkipFrameInterval(uint64_t id, uint32_t skipFrameInterval, int32_t& resCode) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetScreenSkipFrameInterval: WriteInterfaceToken GetDescriptor err."); resCode = RS_CONNECTION_ERROR; return ERR_INVALID_VALUE; @@ -3372,20 +2296,20 @@ ErrCode RSRenderServiceConnectionProxy::SetScreenSkipFrameInterval(uint64_t id, return ERR_INVALID_VALUE; } if (!reply.ReadInt32(resCode)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetPixelFormat Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetPixelFormat Read result failed"); resCode = READ_PARCEL_ERR; return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::SetVirtualScreenRefreshRate( +ErrCode RSClientToRenderConnectionProxy::SetVirtualScreenRefreshRate( ScreenId id, uint32_t maxRefreshRate, uint32_t& actualRefreshRate, int32_t& retVal) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetVirtualScreenRefreshRate: WriteInterfaceToken GetDescriptor err."); retVal = RS_CONNECTION_ERROR; return ERR_INVALID_VALUE; @@ -3409,13 +2333,13 @@ ErrCode RSRenderServiceConnectionProxy::SetVirtualScreenRefreshRate( } int32_t result{0}; if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenRefreshRate Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualScreenRefreshRate Read result failed"); retVal = READ_PARCEL_ERR; return ERR_INVALID_VALUE; } if (result == SUCCESS) { if (!reply.ReadUint32(actualRefreshRate)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenRefreshRate Read actualRefreshRate failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualScreenRefreshRate Read actualRefreshRate failed"); retVal = READ_PARCEL_ERR; return ERR_INVALID_VALUE; } @@ -3424,48 +2348,12 @@ ErrCode RSRenderServiceConnectionProxy::SetVirtualScreenRefreshRate( return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::SetScreenActiveRect(ScreenId id, const Rect& activeRect, uint32_t& repCode) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetScreenActiveRect: WriteInterfaceToken GetDescriptor err."); - repCode = RS_CONNECTION_ERROR; - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteUint64(id)) { - ROSEN_LOGE("SetScreenActiveRect: WriteUint64 id err."); - repCode = WRITE_PARCEL_ERR; - return ERR_INVALID_VALUE; - } - if (!data.WriteInt32(activeRect.x) || !data.WriteInt32(activeRect.y) || - !data.WriteInt32(activeRect.w) || !data.WriteInt32(activeRect.h)) { - ROSEN_LOGE("SetScreenActiveRect: WriteInt32 activeRect err."); - repCode = WRITE_PARCEL_ERR; - return ERR_INVALID_VALUE; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_RECT); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - repCode = RS_CONNECTION_ERROR; - return ERR_INVALID_VALUE; - } - if (!reply.ReadUint32(repCode)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenActiveRect Read result failed"); - repCode = READ_PARCEL_ERR; - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -void RSRenderServiceConnectionProxy::SetScreenOffset(ScreenId id, int32_t offSetX, int32_t offSetY) +void RSClientToRenderConnectionProxy::SetScreenOffset(ScreenId id, int32_t offSetX, int32_t offSetY) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("%{public}s: WriteInterfaceToken GetDescriptor err.", __func__); return; } @@ -3481,12 +2369,12 @@ void RSRenderServiceConnectionProxy::SetScreenOffset(ScreenId id, int32_t offSet } } -void RSRenderServiceConnectionProxy::SetScreenFrameGravity(ScreenId id, int32_t gravity) +void RSClientToRenderConnectionProxy::SetScreenFrameGravity(ScreenId id, int32_t gravity) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("%{public}s: WriteInterfaceToken GetDescriptor err.", __func__); return; } @@ -3503,18 +2391,18 @@ void RSRenderServiceConnectionProxy::SetScreenFrameGravity(ScreenId id, int32_t } } -ErrCode RSRenderServiceConnectionProxy::RegisterOcclusionChangeCallback( +ErrCode RSClientToRenderConnectionProxy::RegisterOcclusionChangeCallback( sptr callback, int32_t& repCode) { if (callback == nullptr) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterOcclusionChangeCallback: callback is nullptr."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterOcclusionChangeCallback: callback is nullptr."); repCode = INVALID_ARGUMENTS; return ERR_INVALID_VALUE; } MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("RegisterOcclusionChangeCallback: WriteInterfaceToken GetDescriptor err."); repCode = RS_CONNECTION_ERROR; return ERR_INVALID_VALUE; @@ -3535,18 +2423,18 @@ ErrCode RSRenderServiceConnectionProxy::RegisterOcclusionChangeCallback( return ERR_OK; } -int32_t RSRenderServiceConnectionProxy::RegisterSurfaceOcclusionChangeCallback( +int32_t RSClientToRenderConnectionProxy::RegisterSurfaceOcclusionChangeCallback( NodeId id, sptr callback, std::vector& partitionPoints) { if (callback == nullptr) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceOcclusionChangeCallback: callback is nullptr."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterSurfaceOcclusionChangeCallback: callback is nullptr."); return INVALID_ARGUMENTS; } MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("RegisterSurfaceOcclusionChangeCallback: WriteInterfaceToken GetDescriptor err."); return RS_CONNECTION_ERROR; } @@ -3572,18 +2460,18 @@ int32_t RSRenderServiceConnectionProxy::RegisterSurfaceOcclusionChangeCallback( } int32_t result{0}; if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenHDRFormat Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetScreenHDRFormat Read result failed"); return READ_PARCEL_ERR; } return result; } -int32_t RSRenderServiceConnectionProxy::UnRegisterSurfaceOcclusionChangeCallback(NodeId id) +int32_t RSClientToRenderConnectionProxy::UnRegisterSurfaceOcclusionChangeCallback(NodeId id) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("UnRegisterSurfaceOcclusionChangeCallback: WriteInterfaceToken GetDescriptor err."); return RS_CONNECTION_ERROR; } @@ -3601,18 +2489,18 @@ int32_t RSRenderServiceConnectionProxy::UnRegisterSurfaceOcclusionChangeCallback } int32_t result{0}; if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetScreenColorSpace Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetScreenColorSpace Read result failed"); return READ_PARCEL_ERR; } return result; } -int32_t RSRenderServiceConnectionProxy::RegisterHgmConfigChangeCallback(sptr callback) +int32_t RSClientToRenderConnectionProxy::RegisterHgmConfigChangeCallback(sptr callback) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("RegisterHgmConfigChangeCallback: WriteInterfaceToken GetDescriptor err."); return RS_CONNECTION_ERROR; } @@ -3624,24 +2512,24 @@ int32_t RSRenderServiceConnectionProxy::RegisterHgmConfigChangeCallback(sptr(RSIRenderServiceConnectionInterfaceCode::REGISTER_HGM_CFG_CALLBACK); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmConfigChangeCallback: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterHgmConfigChangeCallback: Send Request err."); return RS_CONNECTION_ERROR; } int32_t result{0}; if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmConfigChangeCallback Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterHgmConfigChangeCallback Read result failed"); return READ_PARCEL_ERR; } return result; } -int32_t RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback( +int32_t RSClientToRenderConnectionProxy::RegisterHgmRefreshRateModeChangeCallback( sptr callback) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("RegisterHgmRefreshRateModeChangeCallback: WriteInterfaceToken GetDescriptor err."); return RS_CONNECTION_ERROR; } @@ -3653,24 +2541,24 @@ int32_t RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REFRESH_RATE_MODE_CHANGE_CALLBACK); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterHgmRefreshRateModeChangeCallback: Send Request err."); return RS_CONNECTION_ERROR; } int32_t result{0}; if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterHgmRefreshRateModeChangeCallback Read result failed"); return READ_PARCEL_ERR; } return result; } -int32_t RSRenderServiceConnectionProxy::RegisterHgmRefreshRateUpdateCallback( +int32_t RSClientToRenderConnectionProxy::RegisterHgmRefreshRateUpdateCallback( sptr callback) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("RegisterHgmRefreshRateUpdateCallback: WriteInterfaceToken GetDescriptor err."); return RS_CONNECTION_ERROR; } @@ -3693,24 +2581,24 @@ int32_t RSRenderServiceConnectionProxy::RegisterHgmRefreshRateUpdateCallback( uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REFRESH_RATE_UPDATE_CALLBACK); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterHgmRefreshRateModeChangeCallback: Send Request err."); return RS_CONNECTION_ERROR; } int32_t result{0}; if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterHgmRefreshRateModeChangeCallback Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterHgmRefreshRateModeChangeCallback Read result failed"); return READ_PARCEL_ERR; } return result; } -int32_t RSRenderServiceConnectionProxy::RegisterFirstFrameCommitCallback( +int32_t RSClientToRenderConnectionProxy::RegisterFirstFrameCommitCallback( sptr callback) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("RegisterFirstFrameCommitCallback: WriteInterfaceToken GetDescriptor err."); return RS_CONNECTION_ERROR; } @@ -3733,21 +2621,21 @@ int32_t RSRenderServiceConnectionProxy::RegisterFirstFrameCommitCallback( uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::ON_FIRST_FRAME_COMMIT); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterFirstFrameCommitCallback: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterFirstFrameCommitCallback: Send Request err."); return RS_CONNECTION_ERROR; } int32_t result = reply.ReadInt32(); return result; } -ErrCode RSRenderServiceConnectionProxy::AvcodecVideoStart( +ErrCode RSClientToRenderConnectionProxy::AvcodecVideoStart( uint64_t uniqueId, std::string& surfaceName, uint32_t fps, uint64_t reportTime) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("AvcodecVideoStart: WriteInterfaceToken GetDescriptor err."); return RS_CONNECTION_ERROR; } @@ -3771,24 +2659,24 @@ ErrCode RSRenderServiceConnectionProxy::AvcodecVideoStart( uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::AVCODEC_VIDEO_START); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::AvcodecVideoStart: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::AvcodecVideoStart: Send Request err."); return RS_CONNECTION_ERROR; } int32_t result{0}; if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::AvcodecVideoStart Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::AvcodecVideoStart Read result failed"); return READ_PARCEL_ERR; } return result; } -ErrCode RSRenderServiceConnectionProxy::AvcodecVideoStop(uint64_t uniqueId, std::string& surfaceName, uint32_t fps) +ErrCode RSClientToRenderConnectionProxy::AvcodecVideoStop(uint64_t uniqueId, std::string& surfaceName, uint32_t fps) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("AvcodecVideoStop: WriteInterfaceToken GetDescriptor err."); return RS_CONNECTION_ERROR; } @@ -3808,25 +2696,25 @@ ErrCode RSRenderServiceConnectionProxy::AvcodecVideoStop(uint64_t uniqueId, std: uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::AVCODEC_VIDEO_STOP); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::AvcodecVideoStop: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::AvcodecVideoStop: Send Request err."); return RS_CONNECTION_ERROR; } int32_t result{0}; if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::AvcodecVideoStop Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::AvcodecVideoStop Read result failed"); return READ_PARCEL_ERR; } return result; } -int32_t RSRenderServiceConnectionProxy::RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid, +int32_t RSClientToRenderConnectionProxy::RegisterFrameRateLinkerExpectedFpsUpdateCallback(int32_t dstPid, sptr callback) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("RegisterFrameRateLinkerExpectedFpsUpdateCallback: WriteInterfaceToken GetDescriptor err."); return WRITE_PARCEL_ERR; } @@ -3851,25 +2739,25 @@ int32_t RSRenderServiceConnectionProxy::RegisterFrameRateLinkerExpectedFpsUpdate RSIRenderServiceConnectionInterfaceCode::REGISTER_FRAME_RATE_LINKER_EXPECTED_FPS_CALLBACK); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterFrameRateLinkerExpectedFpsUpdateCallback: " + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterFrameRateLinkerExpectedFpsUpdateCallback: " "Send Request err."); return RS_CONNECTION_ERROR; } int32_t result{0}; if (!reply.ReadInt32(result)) { ROSEN_LOGE( - "RSRenderServiceConnectionProxy::RegisterFrameRateLinkerExpectedFpsUpdateCallback Read result failed"); + "RSClientToRenderConnectionProxy::RegisterFrameRateLinkerExpectedFpsUpdateCallback Read result failed"); return READ_PARCEL_ERR; } return result; } -ErrCode RSRenderServiceConnectionProxy::SetAppWindowNum(uint32_t num) +ErrCode RSClientToRenderConnectionProxy::SetAppWindowNum(uint32_t num) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetAppWindowNum: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -3881,20 +2769,20 @@ ErrCode RSRenderServiceConnectionProxy::SetAppWindowNum(uint32_t num) uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_APP_WINDOW_NUM); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetAppWindowNum: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetAppWindowNum: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::SetSystemAnimatedScenes( +ErrCode RSClientToRenderConnectionProxy::SetSystemAnimatedScenes( SystemAnimatedScenes systemAnimatedScenes, bool isRegularAnimation, bool& success) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetSystemAnimatedScenes: WriteInterfaceToken GetDescriptor err."); success = false; return ERR_INVALID_VALUE; @@ -3918,20 +2806,20 @@ ErrCode RSRenderServiceConnectionProxy::SetSystemAnimatedScenes( return ERR_INVALID_VALUE; } if (!reply.ReadBool(success)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetSystemAnimatedScenes Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetSystemAnimatedScenes Read result failed"); success = READ_PARCEL_ERR; return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::SetWatermark(const std::string& name, +ErrCode RSClientToRenderConnectionProxy::SetWatermark(const std::string& name, std::shared_ptr watermark, bool& success) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetWatermark: WriteInterfaceToken GetDescriptor err."); success = false; return ERR_INVALID_VALUE; @@ -3950,7 +2838,7 @@ ErrCode RSRenderServiceConnectionProxy::SetWatermark(const std::string& name, uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_WATERMARK); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWatermark: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetWatermark: Send Request err."); success = false; return ERR_INVALID_VALUE; } @@ -3958,16 +2846,16 @@ ErrCode RSRenderServiceConnectionProxy::SetWatermark(const std::string& name, return ERR_OK; } -void RSRenderServiceConnectionProxy::ShowWatermark(const std::shared_ptr &watermarkImg, bool isShow) +void RSClientToRenderConnectionProxy::ShowWatermark(const std::shared_ptr &watermarkImg, bool isShow) { if (watermarkImg == nullptr) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ShowWatermark: watermarkImg is nullptr."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ShowWatermark: watermarkImg is nullptr."); return; } MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("ShowWatermark: WriteInterfaceToken GetDescriptor err."); return; } @@ -3983,18 +2871,18 @@ void RSRenderServiceConnectionProxy::ShowWatermark(const std::shared_ptr(RSIRenderServiceConnectionInterfaceCode::SHOW_WATERMARK); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ShowWatermark: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ShowWatermark: Send Request err."); return; } } -int32_t RSRenderServiceConnectionProxy::ResizeVirtualScreen(ScreenId id, uint32_t width, uint32_t height) +int32_t RSClientToRenderConnectionProxy::ResizeVirtualScreen(ScreenId id, uint32_t width, uint32_t height) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("ResizeVirtualScreen: WriteInterfaceToken GetDescriptor err."); return WRITE_PARCEL_ERR; } @@ -4014,23 +2902,23 @@ int32_t RSRenderServiceConnectionProxy::ResizeVirtualScreen(ScreenId id, uint32_ uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::RESIZE_VIRTUAL_SCREEN); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ResizeVirtualScreen: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ResizeVirtualScreen: Send Request err."); return RS_CONNECTION_ERROR; } int32_t status{0}; if (!reply.ReadInt32(status)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ResizeVirtualScreen Read status failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ResizeVirtualScreen Read status failed"); return READ_PARCEL_ERR; } return status; } -ErrCode RSRenderServiceConnectionProxy::ReportJankStats() +ErrCode RSClientToRenderConnectionProxy::ReportJankStats() { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("ReportJankStats: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -4038,18 +2926,18 @@ ErrCode RSRenderServiceConnectionProxy::ReportJankStats() uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REPORT_JANK_STATS); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportJankStats: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ReportJankStats: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::ReportEventResponse(DataBaseRs info) +ErrCode RSClientToRenderConnectionProxy::ReportEventResponse(DataBaseRs info) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("ReportEventResponse: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -4057,18 +2945,18 @@ ErrCode RSRenderServiceConnectionProxy::ReportEventResponse(DataBaseRs info) uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_RESPONSE); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportEventResponse: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ReportEventResponse: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::ReportEventComplete(DataBaseRs info) +ErrCode RSClientToRenderConnectionProxy::ReportEventComplete(DataBaseRs info) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("ReportEventComplete: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -4076,18 +2964,18 @@ ErrCode RSRenderServiceConnectionProxy::ReportEventComplete(DataBaseRs info) uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_COMPLETE); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportEventComplete: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ReportEventComplete: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::ReportEventJankFrame(DataBaseRs info) +ErrCode RSClientToRenderConnectionProxy::ReportEventJankFrame(DataBaseRs info) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("ReportEventJankFrame: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -4095,18 +2983,18 @@ ErrCode RSRenderServiceConnectionProxy::ReportEventJankFrame(DataBaseRs info) uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_JANK_FRAME); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportEventJankFrame: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ReportEventJankFrame: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -void RSRenderServiceConnectionProxy::ReportRsSceneJankStart(AppInfo info) +void RSClientToRenderConnectionProxy::ReportRsSceneJankStart(AppInfo info) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("ReportRsSceneJankStart: WriteInterfaceToken GetDescriptor err."); return; } @@ -4114,17 +3002,17 @@ void RSRenderServiceConnectionProxy::ReportRsSceneJankStart(AppInfo info) uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REPORT_RS_SCENE_JANK_START); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportRsSceneJankStart: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ReportRsSceneJankStart: Send Request err."); return; } } -void RSRenderServiceConnectionProxy::ReportRsSceneJankEnd(AppInfo info) +void RSClientToRenderConnectionProxy::ReportRsSceneJankEnd(AppInfo info) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("ReportRsSceneJankEnd: WriteInterfaceToken GetDescriptor err."); return; } @@ -4132,12 +3020,12 @@ void RSRenderServiceConnectionProxy::ReportRsSceneJankEnd(AppInfo info) uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REPORT_RS_SCENE_JANK_END); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportRsSceneJankEnd: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ReportRsSceneJankEnd: Send Request err."); return; } } -void RSRenderServiceConnectionProxy::ReportDataBaseRs( +void RSClientToRenderConnectionProxy::ReportDataBaseRs( MessageParcel& data, MessageParcel& reply, MessageOption& option, DataBaseRs info) { if (!data.WriteInt32(info.appPid)) { @@ -4203,7 +3091,7 @@ void RSRenderServiceConnectionProxy::ReportDataBaseRs( option.SetFlags(MessageOption::TF_ASYNC); } -void RSRenderServiceConnectionProxy::WriteAppInfo( +void RSClientToRenderConnectionProxy::WriteAppInfo( MessageParcel& data, MessageParcel& reply, MessageOption& option, AppInfo info) { if (!data.WriteInt64(info.startTime)) { @@ -4237,7 +3125,7 @@ void RSRenderServiceConnectionProxy::WriteAppInfo( option.SetFlags(MessageOption::TF_ASYNC); } -void RSRenderServiceConnectionProxy::ReportGameStateDataRs( +void RSClientToRenderConnectionProxy::ReportGameStateDataRs( MessageParcel& data, MessageParcel& reply, MessageOption& option, GameStateData info) { if (!data.WriteInt32(info.pid)) { @@ -4263,12 +3151,12 @@ void RSRenderServiceConnectionProxy::ReportGameStateDataRs( option.SetFlags(MessageOption::TF_ASYNC); } -ErrCode RSRenderServiceConnectionProxy::ReportGameStateData(GameStateData info) +ErrCode RSClientToRenderConnectionProxy::ReportGameStateData(GameStateData info) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("ReportGameStateData: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -4276,19 +3164,19 @@ ErrCode RSRenderServiceConnectionProxy::ReportGameStateData(GameStateData info) uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REPORT_EVENT_GAMESTATE); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ReportGameStateData: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ReportGameStateData: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::SetHardwareEnabled(NodeId id, bool isEnabled, +ErrCode RSClientToRenderConnectionProxy::SetHardwareEnabled(NodeId id, bool isEnabled, SelfDrawingNodeType selfDrawingType, bool dynamicHardwareEnable) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetHardwareEnabled: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -4312,18 +3200,18 @@ ErrCode RSRenderServiceConnectionProxy::SetHardwareEnabled(NodeId id, bool isEna uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_HARDWARE_ENABLED); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetHardwareEnabled: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetHardwareEnabled: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent, uint32_t& resCode) +ErrCode RSClientToRenderConnectionProxy::SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent, uint32_t& resCode) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetHidePrivacyContent: WriteInterfaceToken GetDescriptor err."); resCode = static_cast(RSInterfaceErrorCode::WRITE_PARCEL_ERROR); return ERR_INVALID_VALUE; @@ -4342,232 +3230,112 @@ ErrCode RSRenderServiceConnectionProxy::SetHidePrivacyContent(NodeId id, bool ne uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_HIDE_PRIVACY_CONTENT); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetHidePrivacyContent: Send Request err."); - resCode = static_cast(RSInterfaceErrorCode::UNKNOWN_ERROR); - return ERR_INVALID_VALUE; - } - resCode = reply.ReadUint32(); - return ERR_OK; -} - -ErrCode RSRenderServiceConnectionProxy::NotifyLightFactorStatus(int32_t lightFactorStatus) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("NotifyLightFactorStatus: WriteInterfaceToken GetDescriptor err."); - return ERR_INVALID_VALUE; - } - if (!data.WriteInt32(lightFactorStatus)) { - ROSEN_LOGE("NotifyLightFactorStatus: WriteInt32 lightFactorStatus err."); - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_ASYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_LIGHT_FACTOR_STATUS); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyLightFactorStatus: Send Request err."); - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -void RSRenderServiceConnectionProxy::NotifyPackageEvent(uint32_t listSize, const std::vector& packageList) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("NotifyPackageEvent: WriteInterfaceToken GetDescriptor err."); - return; - } - if (listSize != packageList.size()) { - ROSEN_LOGE("input size doesn't match"); - return; - } - if (!data.WriteUint32(listSize)) { - ROSEN_LOGE("NotifyPackageEvent: WriteUint32 listSize err."); - return; - } - for (auto pkg : packageList) { - if (!data.WriteString(pkg)) { - ROSEN_LOGE("NotifyPackageEvent: WriteString pkg err."); - return; - } - } - option.SetFlags(MessageOption::TF_ASYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PACKAGE_EVENT); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyPackageEvent: Send Request err."); - return; - } -} - -void RSRenderServiceConnectionProxy::NotifyAppStrategyConfigChangeEvent(const std::string& pkgName, uint32_t listSize, - const std::vector>& newConfig) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - return; - } - - if (listSize != newConfig.size()) { - ROSEN_LOGE("input size doesn't match"); - return; - } - - if (!data.WriteString(pkgName) || !data.WriteUint32(listSize)) { - ROSEN_LOGE( - "RSRenderServiceConnectionProxy::NotifyAppStrategyConfigChangeEvent Write pakName or listSize failed."); - return; - } - - for (const auto& [key, value] : newConfig) { - if (!data.WriteString(key) || !data.WriteString(value)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyAppStrategyConfigChangeEvent Write key or value failed."); - return; - } - } - option.SetFlags(MessageOption::TF_ASYNC); - uint32_t code = static_cast( - RSIRenderServiceConnectionInterfaceCode::NOTIFY_APP_STRATEGY_CONFIG_CHANGE_EVENT); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyAppStrategyConfigChangeEvent: Send Request err."); - return; + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetHidePrivacyContent: Send Request err."); + resCode = static_cast(RSInterfaceErrorCode::UNKNOWN_ERROR); + return ERR_INVALID_VALUE; } + resCode = reply.ReadUint32(); + return ERR_OK; } -void RSRenderServiceConnectionProxy::SetWindowExpectedRefreshRate( - const std::unordered_map& eventInfos -) +ErrCode RSClientToRenderConnectionProxy::NotifyLightFactorStatus(int32_t lightFactorStatus) { - auto mapSize = eventInfos.size(); - if (mapSize <= ZERO || mapSize > MAX_VOTER_SIZE) { - ROSEN_LOGE("SetWindowExpectedRefreshRate: map size err."); - return; - } - MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteInterfaceToken GetDescriptor err."); - return; - } - if (!data.WriteUint32(mapSize)) { - ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteUint32 mapSize err."); - return; + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("NotifyLightFactorStatus: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; } - for (const auto& [key, eventInfo] : eventInfos) { - if (!data.WriteUint64(key)) { - ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteUint64 key err."); - return; - } - if (!eventInfo.Serialize(data)) { - ROSEN_LOGE("SetWindowExpectedRefreshRate: Write eventInfo err."); - return; - } + if (!data.WriteInt32(lightFactorStatus)) { + ROSEN_LOGE("NotifyLightFactorStatus: WriteInt32 lightFactorStatus err."); + return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_ASYNC); - uint32_t code = - static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_WINDOW_ID); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_LIGHT_FACTOR_STATUS); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWindowExpectedRefreshRate: Send Request err."); - return; + ROSEN_LOGE("RSClientToRenderConnectionProxy::NotifyLightFactorStatus: Send Request err."); + return ERR_INVALID_VALUE; } + return ERR_OK; } -void RSRenderServiceConnectionProxy::SetWindowExpectedRefreshRate( - const std::unordered_map& eventInfos -) +void RSClientToRenderConnectionProxy::NotifyPackageEvent(uint32_t listSize, const std::vector& packageList) { - auto mapSize = eventInfos.size(); - if (mapSize <= ZERO || mapSize > MAX_VOTER_SIZE) { - ROSEN_LOGE("SetWindowExpectedRefreshRate: map size err."); - return; - } - MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteInterfaceToken GetDescriptor err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("NotifyPackageEvent: WriteInterfaceToken GetDescriptor err."); return; } - if (!data.WriteUint32(mapSize)) { - ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteUint32 mapSize err."); + if (listSize != packageList.size()) { + ROSEN_LOGE("input size doesn't match"); return; } - for (const auto& [key, eventInfo] : eventInfos) { - if (!data.WriteString(key)) { - ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteString key err."); - return; - } - if (!eventInfo.Serialize(data)) { - ROSEN_LOGE("SetWindowExpectedRefreshRate: Write eventInfo err."); + if (!data.WriteUint32(listSize)) { + ROSEN_LOGE("NotifyPackageEvent: WriteUint32 listSize err."); + return; + } + for (auto pkg : packageList) { + if (!data.WriteString(pkg)) { + ROSEN_LOGE("NotifyPackageEvent: WriteString pkg err."); return; } } option.SetFlags(MessageOption::TF_ASYNC); - uint32_t code = - static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_VSYNC_NAME); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PACKAGE_EVENT); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWindowExpectedRefreshRate: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::NotifyPackageEvent: Send Request err."); return; } } -void RSRenderServiceConnectionProxy::NotifyRefreshRateEvent(const EventInfo& eventInfo) +void RSClientToRenderConnectionProxy::NotifyAppStrategyConfigChangeEvent(const std::string& pkgName, uint32_t listSize, + const std::vector>& newConfig) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("NotifyRefreshRateEvent: WriteInterfaceToken GetDescriptor err."); - return; - } - if (!data.WriteString(eventInfo.eventName)) { - ROSEN_LOGE("NotifyRefreshRateEvent: WriteString eventInfo.eventName err."); - return; - } - if (!data.WriteBool(eventInfo.eventStatus)) { - ROSEN_LOGE("NotifyRefreshRateEvent: WriteBool eventInfo.eventStatus err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { return; } - if (!data.WriteUint32(eventInfo.minRefreshRate)) { - ROSEN_LOGE("NotifyRefreshRateEvent: WriteUint32 eventInfo.minRefreshRate err."); + + if (listSize != newConfig.size()) { + ROSEN_LOGE("input size doesn't match"); return; } - if (!data.WriteUint32(eventInfo.maxRefreshRate)) { - ROSEN_LOGE("NotifyRefreshRateEvent: WriteUint32 eventInfo.maxRefreshRate err."); + + if (!data.WriteString(pkgName) || !data.WriteUint32(listSize)) { + ROSEN_LOGE( + "RSClientToRenderConnectionProxy::NotifyAppStrategyConfigChangeEvent Write pakName or listSize failed."); return; } - if (!data.WriteString(eventInfo.description)) { - ROSEN_LOGE("NotifyRefreshRateEvent: WriteString eventInfo.description err."); - return; + + for (const auto& [key, value] : newConfig) { + if (!data.WriteString(key) || !data.WriteString(value)) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::NotifyAppStrategyConfigChangeEvent Write key or value failed."); + return; + } } option.SetFlags(MessageOption::TF_ASYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_REFRESH_RATE_EVENT); + uint32_t code = static_cast( + RSIRenderServiceConnectionInterfaceCode::NOTIFY_APP_STRATEGY_CONFIG_CHANGE_EVENT); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyRefreshRateEvent: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::NotifyAppStrategyConfigChangeEvent: Send Request err."); return; } } -ErrCode RSRenderServiceConnectionProxy::NotifySoftVsyncEvent(uint32_t pid, uint32_t rateDiscount) +ErrCode RSClientToRenderConnectionProxy::NotifySoftVsyncEvent(uint32_t pid, uint32_t rateDiscount) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("NotifySoftVsyncEvent: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -4583,19 +3351,19 @@ ErrCode RSRenderServiceConnectionProxy::NotifySoftVsyncEvent(uint32_t pid, uint3 uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SOFT_VSYNC_EVENT); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifySoftVsyncEvent: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::NotifySoftVsyncEvent: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -bool RSRenderServiceConnectionProxy::NotifySoftVsyncRateDiscountEvent(uint32_t pid, const std::string &name, +bool RSClientToRenderConnectionProxy::NotifySoftVsyncRateDiscountEvent(uint32_t pid, const std::string &name, uint32_t rateDiscount) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("NotifySoftVsyncRateDiscountEvent: WriteInterfaceToken GetDescriptor err."); return false; } @@ -4616,72 +3384,23 @@ bool RSRenderServiceConnectionProxy::NotifySoftVsyncRateDiscountEvent(uint32_t p RSIRenderServiceConnectionInterfaceCode::NOTIFY_SOFT_VSYNC_RATE_DISCOUNT_EVENT); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifySoftVsyncRateDiscountEvent: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::NotifySoftVsyncRateDiscountEvent: Send Request err."); return false; } bool enable{false}; if (!reply.ReadBool(enable)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifySoftVsyncRateDiscountEvent: Read enable failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::NotifySoftVsyncRateDiscountEvent: Read enable failed"); return false; } return enable; } -ErrCode RSRenderServiceConnectionProxy::NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("NotifyTouchEvent: WriteInterfaceToken GetDescriptor err."); - return ERR_INVALID_VALUE; - } - if (!data.WriteInt32(touchStatus)) { - ROSEN_LOGE("NotifyTouchEvent: WriteInt32 touchStatus err."); - return ERR_INVALID_VALUE; - } - if (!data.WriteInt32(touchCnt)) { - ROSEN_LOGE("NotifyTouchEvent: WriteInt32 touchCnt err."); - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_ASYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_TOUCH_EVENT); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyTouchEvent: Send Request err."); - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -void RSRenderServiceConnectionProxy::NotifyDynamicModeEvent(bool enableDynamicMode) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("NotifyDynamicModeEvent: WriteInterfaceToken GetDescriptor err."); - return; - } - if (!data.WriteBool(enableDynamicMode)) { - ROSEN_LOGE("NotifyDynamicModeEvent: WriteBool enableDynamicMode err."); - return; - } - option.SetFlags(MessageOption::TF_ASYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_DYNAMIC_MODE_EVENT); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyDynamicModeEvent: Send Request err."); - return; - } -} - -ErrCode RSRenderServiceConnectionProxy::NotifyHgmConfigEvent(const std::string &eventName, bool state) +ErrCode RSClientToRenderConnectionProxy::NotifyHgmConfigEvent(const std::string &eventName, bool state) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("NotifyHgmConfigEvent: GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -4695,19 +3414,19 @@ ErrCode RSRenderServiceConnectionProxy::NotifyHgmConfigEvent(const std::string & uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_HGMCONFIG_EVENT); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyHgmConfigEvent: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::NotifyHgmConfigEvent: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::NotifyXComponentExpectedFrameRate( +ErrCode RSClientToRenderConnectionProxy::NotifyXComponentExpectedFrameRate( const std::string& id, int32_t expectedFrameRate) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("NotifyXComponentExpectedFrameRate: GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -4722,18 +3441,18 @@ ErrCode RSRenderServiceConnectionProxy::NotifyXComponentExpectedFrameRate( RSIRenderServiceConnectionInterfaceCode::NOTIFY_XCOMPONENT_EXPECTED_FRAMERATE); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyXComponentExpectedFrameRate: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::NotifyXComponentExpectedFrameRate: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::SetCacheEnabledForRotation(bool isEnabled) +ErrCode RSClientToRenderConnectionProxy::SetCacheEnabledForRotation(bool isEnabled) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetCacheEnabledForRotation: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -4745,31 +3464,31 @@ ErrCode RSRenderServiceConnectionProxy::SetCacheEnabledForRotation(bool isEnable uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_ROTATION_CACHE_ENABLED); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetCacheEnabledForRotation: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetCacheEnabledForRotation: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -void RSRenderServiceConnectionProxy::SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback) +void RSClientToRenderConnectionProxy::SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback) { OnRemoteDiedCallback_ = callback; } -void RSRenderServiceConnectionProxy::RunOnRemoteDiedCallback() +void RSClientToRenderConnectionProxy::RunOnRemoteDiedCallback() { if (OnRemoteDiedCallback_) { OnRemoteDiedCallback_(); } } -std::vector RSRenderServiceConnectionProxy::GetActiveDirtyRegionInfo() +std::vector RSClientToRenderConnectionProxy::GetActiveDirtyRegionInfo() { MessageParcel data; MessageParcel reply; MessageOption option; std::vector activeDirtyRegionInfos; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetActiveDirtyRegionInfo: WriteInterfaceToken GetDescriptor err."); return activeDirtyRegionInfos; } @@ -4777,12 +3496,12 @@ std::vector RSRenderServiceConnectionProxy::GetActiveDirt uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_DIRTY_REGION_INFO); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetActiveDirtyRegionInfo: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetActiveDirtyRegionInfo: Send Request err."); return activeDirtyRegionInfos; } int32_t activeDirtyRegionInfosSize{0}; if (!reply.ReadInt32(activeDirtyRegionInfosSize)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetActiveDirtyRegionInfo Read activeDirtyRegionInfosSize failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetActiveDirtyRegionInfo Read activeDirtyRegionInfosSize failed"); return activeDirtyRegionInfos; } while (activeDirtyRegionInfosSize--) { @@ -4793,7 +3512,7 @@ std::vector RSRenderServiceConnectionProxy::GetActiveDirt if (!reply.ReadInt64(activeDirtyRegionArea) || !reply.ReadInt32(activeFramesNumber) || !reply.ReadInt32(pidOfBelongsApp) || !reply.ReadString(windowName)) { ROSEN_LOGE( - "RSRenderServiceConnectionProxy::GetActiveDirtyRegionInfo Read parcel failed"); + "RSClientToRenderConnectionProxy::GetActiveDirtyRegionInfo Read parcel failed"); return activeDirtyRegionInfos; } activeDirtyRegionInfos.emplace_back( @@ -4802,13 +3521,13 @@ std::vector RSRenderServiceConnectionProxy::GetActiveDirt return activeDirtyRegionInfos; } -GlobalDirtyRegionInfo RSRenderServiceConnectionProxy::GetGlobalDirtyRegionInfo() +GlobalDirtyRegionInfo RSClientToRenderConnectionProxy::GetGlobalDirtyRegionInfo() { MessageParcel data; MessageParcel reply; MessageOption option; GlobalDirtyRegionInfo globalDirtyRegionInfo; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetGlobalDirtyRegionInfo: WriteInterfaceToken GetDescriptor err."); return globalDirtyRegionInfo; } @@ -4816,7 +3535,7 @@ GlobalDirtyRegionInfo RSRenderServiceConnectionProxy::GetGlobalDirtyRegionInfo() uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_GLOBAL_DIRTY_REGION_INFO); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetGlobalDirtyRegionInfo: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetGlobalDirtyRegionInfo: Send Request err."); return globalDirtyRegionInfo; } int64_t globalDirtyRegionAreas{0}; @@ -4825,90 +3544,19 @@ GlobalDirtyRegionInfo RSRenderServiceConnectionProxy::GetGlobalDirtyRegionInfo() int32_t mostSendingPidWhenDisplayNodeSkip{0}; if (!reply.ReadInt64(globalDirtyRegionAreas) || !reply.ReadInt32(globalFramesNumber) || !reply.ReadInt32(skipProcessFramesNumber) || !reply.ReadInt32(mostSendingPidWhenDisplayNodeSkip)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetGlobalDirtyRegionInfo Read parcel failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetGlobalDirtyRegionInfo Read parcel failed"); return globalDirtyRegionInfo; } return GlobalDirtyRegionInfo( globalDirtyRegionAreas, globalFramesNumber, skipProcessFramesNumber, mostSendingPidWhenDisplayNodeSkip); } -LayerComposeInfo RSRenderServiceConnectionProxy::GetLayerComposeInfo() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - LayerComposeInfo layerComposeInfo; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetLayerComposeInfo: WriteInterfaceToken GetDescriptor err."); - return layerComposeInfo; - } - option.SetFlags(MessageOption::TF_SYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_LAYER_COMPOSE_INFO); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetLayerComposeInfo: Send Request err."); - return layerComposeInfo; - } - int32_t uniformRenderFrameNumber{0}; - int32_t offlineComposeFrameNumber{0}; - int32_t redrawFrameNumber{0}; - if (!reply.ReadInt32(uniformRenderFrameNumber) || !reply.ReadInt32(offlineComposeFrameNumber) || - !reply.ReadInt32(redrawFrameNumber)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetLayerComposeInfo Read parcel failed"); - return layerComposeInfo; - } - return LayerComposeInfo(uniformRenderFrameNumber, offlineComposeFrameNumber, redrawFrameNumber); -} - -HwcDisabledReasonInfos RSRenderServiceConnectionProxy::GetHwcDisabledReasonInfo() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - HwcDisabledReasonInfos hwcDisabledReasonInfos; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("GetHwcDisabledReasonInfo: WriteInterfaceToken GetDescriptor err."); - return hwcDisabledReasonInfos; - } - option.SetFlags(MessageOption::TF_SYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode:: - GET_HARDWARE_COMPOSE_DISABLED_REASON_INFO); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetHwcDisabledReasonInfo: Send Request err."); - return hwcDisabledReasonInfos; - } - int32_t size{0}; - if (!reply.ReadInt32(size)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetHwcDisabledReasonInfo Read size failed"); - return hwcDisabledReasonInfos; - } - size_t readableSize = reply.GetReadableBytes() / HWC_DISABLED_REASON_INFO_MINIMUM_SIZE; - size_t len = static_cast(size); - if (len > readableSize || len > hwcDisabledReasonInfos.max_size()) { - RS_LOGE("RSRenderServiceConnectionProxy GetHwcDisabledReasonInfo Failed read vector, size:%{public}zu," - " readableSize:%{public}zu", len, readableSize); - return hwcDisabledReasonInfos; - } - - HwcDisabledReasonInfo hwcDisabledReasonInfo; - while (size--) { - for (int32_t pos = 0; pos < HwcDisabledReasons::DISABLED_REASON_LENGTH; pos++) { - hwcDisabledReasonInfo.disabledReasonStatistics[pos] = reply.ReadInt32(); - } - hwcDisabledReasonInfo.pidOfBelongsApp = reply.ReadInt32(); - hwcDisabledReasonInfo.nodeName = reply.ReadString(); - hwcDisabledReasonInfos.emplace_back(hwcDisabledReasonInfo); - } - return hwcDisabledReasonInfos; -} - -ErrCode RSRenderServiceConnectionProxy::GetHdrOnDuration(int64_t& hdrOnDuration) +ErrCode RSClientToRenderConnectionProxy::GetHdrOnDuration(int64_t& hdrOnDuration) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("GetHdrOnDuration: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -4923,12 +3571,12 @@ ErrCode RSRenderServiceConnectionProxy::GetHdrOnDuration(int64_t& hdrOnDuration) return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::SetVmaCacheStatus(bool flag) +ErrCode RSClientToRenderConnectionProxy::SetVmaCacheStatus(bool flag) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetVmaCacheStatus: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -4940,21 +3588,21 @@ ErrCode RSRenderServiceConnectionProxy::SetVmaCacheStatus(bool flag) uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VMA_CACHE_STATUS); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVmaCacheStatus %d: Send Request err.", flag); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVmaCacheStatus %d: Send Request err.", flag); return ERR_INVALID_VALUE; } return ERR_OK; } #ifdef TP_FEATURE_ENABLE -EErrCode RSRenderServiceConnectionProxy::SetTpFeatureConfig(int32_t feature, const char* config, +EErrCode RSClientToRenderConnectionProxy::SetTpFeatureConfig(int32_t feature, const char* config, TpFeatureConfigType tpFeatureConfigType) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetTpFeatureConfig: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -4984,12 +3632,12 @@ EErrCode RSRenderServiceConnectionProxy::SetTpFeatureConfig(int32_t feature, con } #endif -void RSRenderServiceConnectionProxy::SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus) +void RSClientToRenderConnectionProxy::SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetVirtualScreenUsingStatus: WriteInterfaceToken GetDescriptor err."); return; } @@ -5001,17 +3649,17 @@ void RSRenderServiceConnectionProxy::SetVirtualScreenUsingStatus(bool isVirtualS uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_USING_STATUS); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenUsingStatus: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualScreenUsingStatus: Send Request err."); return; } } -ErrCode RSRenderServiceConnectionProxy::SetCurtainScreenUsingStatus(bool isCurtainScreenOn) +ErrCode RSClientToRenderConnectionProxy::SetCurtainScreenUsingStatus(bool isCurtainScreenOn) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetCurtainScreenUsingStatus: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -5023,18 +3671,18 @@ ErrCode RSRenderServiceConnectionProxy::SetCurtainScreenUsingStatus(bool isCurta uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_CURTAIN_SCREEN_USING_STATUS); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetCurtainScreenUsingStatus: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetCurtainScreenUsingStatus: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::DropFrameByPid(const std::vector pidList) +ErrCode RSClientToRenderConnectionProxy::DropFrameByPid(const std::vector pidList) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("DropFrameByPid: WriteInterfaceToken GetDescriptor err."); return ERR_INVALID_VALUE; } @@ -5046,23 +3694,23 @@ ErrCode RSRenderServiceConnectionProxy::DropFrameByPid(const std::vector(RSIRenderServiceConnectionInterfaceCode::DROP_FRAME_BY_PID); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::DropFrameByPid: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::DropFrameByPid: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -int32_t RSRenderServiceConnectionProxy::RegisterUIExtensionCallback( +int32_t RSClientToRenderConnectionProxy::RegisterUIExtensionCallback( uint64_t userId, sptr callback, bool unobscured) { if (callback == nullptr) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterUIExtensionCallback: callback is nullptr."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterUIExtensionCallback: callback is nullptr."); return INVALID_ARGUMENTS; } MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("RegisterUIExtensionCallback: WriteInterfaceToken GetDescriptor err."); return RS_CONNECTION_ERROR; } @@ -5075,7 +3723,7 @@ int32_t RSRenderServiceConnectionProxy::RegisterUIExtensionCallback( } int32_t result{0}; if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterUIExtensionCallback Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterUIExtensionCallback Read result failed"); return READ_PARCEL_ERR; } return result; @@ -5085,13 +3733,13 @@ int32_t RSRenderServiceConnectionProxy::RegisterUIExtensionCallback( } } -ErrCode RSRenderServiceConnectionProxy::SetVirtualScreenStatus(ScreenId id, +ErrCode RSClientToRenderConnectionProxy::SetVirtualScreenStatus(ScreenId id, VirtualScreenStatus screenStatus, bool& success) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetVirtualScreenStatus: WriteInterfaceToken GetDescriptor err."); success = false; return ERR_INVALID_VALUE; @@ -5114,18 +3762,18 @@ ErrCode RSRenderServiceConnectionProxy::SetVirtualScreenStatus(ScreenId id, return ERR_INVALID_VALUE; } if (!reply.ReadBool(success)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetVirtualScreenStatus Read result failed"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetVirtualScreenStatus Read result failed"); return READ_PARCEL_ERR; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::SetAncoForceDoDirect(bool direct, bool& res) +ErrCode RSClientToRenderConnectionProxy::SetAncoForceDoDirect(bool direct, bool& res) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { ROSEN_LOGE("SetAncoForceDoDirect: WriteInterfaceToken GetDescriptor err."); res = false; return ERR_INVALID_VALUE; @@ -5147,182 +3795,139 @@ ErrCode RSRenderServiceConnectionProxy::SetAncoForceDoDirect(bool direct, bool& } } -void RSRenderServiceConnectionProxy::SetFreeMultiWindowStatus(bool enable) +void RSClientToRenderConnectionProxy::SetFreeMultiWindowStatus(bool enable) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFreeMultiWindowStatus: write token err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetFreeMultiWindowStatus: write token err."); return; } option.SetFlags(MessageOption::TF_ASYNC); if (!data.WriteBool(enable)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFreeMultiWindowStatus: write bool val err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetFreeMultiWindowStatus: write bool val err."); return; } uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_FREE_MULTI_WINDOW_STATUS); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetFreeMultiWindowStatus: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetFreeMultiWindowStatus: Send Request err."); } } -void RSRenderServiceConnectionProxy::RegisterTransactionDataCallback(uint64_t token, +void RSClientToRenderConnectionProxy::RegisterTransactionDataCallback(uint64_t token, uint64_t timeStamp, sptr callback) { if (callback == nullptr) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback callback == nullptr."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterTransactionDataCallback callback == nullptr."); return; } MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback: write token err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterTransactionDataCallback: write token err."); return; } option.SetFlags(MessageOption::TF_ASYNC); static_assert(std::is_same_v, "pid_t is not int32_t on this platform."); if (!data.WriteUint64(token)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback: write multi token val err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterTransactionDataCallback: write multi token val err."); return; } if (!data.WriteUint64(timeStamp)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback: write timeStamp val err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterTransactionDataCallback: write timeStamp val err."); return; } if (!data.WriteRemoteObject(callback->AsObject())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback: write Callback val err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterTransactionDataCallback: write Callback val err."); return; } uint32_t code = static_cast( RSIRenderServiceConnectionInterfaceCode::REGISTER_TRANSACTION_DATA_CALLBACK); - RS_LOGD("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback: timeStamp: %{public}" + RS_LOGD("RSClientToRenderConnectionProxy::RegisterTransactionDataCallback: timeStamp: %{public}" PRIu64 " token: %{public}" PRIu64, timeStamp, token); int32_t err = Remote()->SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterTransactionDataCallback: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterTransactionDataCallback: Send Request err."); return; } } -ErrCode RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback( +ErrCode RSClientToRenderConnectionProxy::RegisterSurfaceBufferCallback( pid_t pid, uint64_t uid, sptr callback) { if (callback == nullptr) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback callback == nullptr"); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterSurfaceBufferCallback callback == nullptr"); return ERR_INVALID_VALUE; } MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: write token err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterSurfaceBufferCallback: write token err."); return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_ASYNC); static_assert(std::is_same_v, "pid_t is not int32_t on this platform."); if (!data.WriteInt32(pid)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: write Int32 val err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterSurfaceBufferCallback: write Int32 val err."); return ERR_INVALID_VALUE; } if (!data.WriteUint64(uid)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: write Uint64 val err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterSurfaceBufferCallback: write Uint64 val err."); return ERR_INVALID_VALUE; } if (!data.WriteRemoteObject(callback->AsObject())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: write RemoteObject val err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterSurfaceBufferCallback: write RemoteObject val err."); return ERR_INVALID_VALUE; } uint32_t code = static_cast( RSIRenderServiceConnectionInterfaceCode::REGISTER_SURFACE_BUFFER_CALLBACK); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSurfaceBufferCallback: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::RegisterSurfaceBufferCallback: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid) +ErrCode RSClientToRenderConnectionProxy::UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback: write token err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::UnregisterSurfaceBufferCallback: write token err."); return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_ASYNC); static_assert(std::is_same_v, "pid_t is not int32_t on this platform."); if (!data.WriteInt32(pid)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback: write Int32 val err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::UnregisterSurfaceBufferCallback: write Int32 val err."); return ERR_INVALID_VALUE; } if (!data.WriteUint64(uid)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback: write Uint64 val err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::UnregisterSurfaceBufferCallback: write Uint64 val err."); return ERR_INVALID_VALUE; } uint32_t code = static_cast( RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SURFACE_BUFFER_CALLBACK); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::UnregisterSurfaceBufferCallback: Send Request err."); - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -ErrCode RSRenderServiceConnectionProxy::SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetLayerTopForHWC: write token err."); - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_ASYNC); - if (data.WriteUint64(nodeId) && data.WriteBool(isTop) && data.WriteUint32(zOrder)) { - uint32_t code = - static_cast(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP_FOR_HARDWARE_COMPOSER); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetLayerTopForHWC: Send Request err."); - return ERR_INVALID_VALUE; - } - } - return ERR_OK; -} - -ErrCode RSRenderServiceConnectionProxy::SetLayerTop(const std::string &nodeIdStr, bool isTop) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetLayerTop: write token err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::UnregisterSurfaceBufferCallback: Send Request err."); return ERR_INVALID_VALUE; } - option.SetFlags(MessageOption::TF_ASYNC); - if (data.WriteString(nodeIdStr) && data.WriteBool(isTop)) { - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetLayerTop: Send Request err."); - return ERR_INVALID_VALUE; - } - } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::SetForceRefresh(const std::string &nodeIdStr, bool isForceRefresh) +ErrCode RSClientToRenderConnectionProxy::SetForceRefresh(const std::string &nodeIdStr, bool isForceRefresh) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetForceRefresh: write token err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetForceRefresh: write token err."); return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_ASYNC); @@ -5330,20 +3935,20 @@ ErrCode RSRenderServiceConnectionProxy::SetForceRefresh(const std::string &nodeI uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_FORCE_REFRESH); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetForceRefresh: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetForceRefresh: Send Request err."); return ERR_INVALID_VALUE; } } return ERR_OK; } -void RSRenderServiceConnectionProxy::SetColorFollow(const std::string &nodeIdStr, bool isColorFollow) +void RSClientToRenderConnectionProxy::SetColorFollow(const std::string &nodeIdStr, bool isColorFollow) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetColorFollow: write token err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetColorFollow: write token err."); return; } option.SetFlags(MessageOption::TF_ASYNC); @@ -5351,120 +3956,40 @@ void RSRenderServiceConnectionProxy::SetColorFollow(const std::string &nodeIdStr uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_COLOR_FOLLOW); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetColorFollow: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetColorFollow: Send Request err."); return; } } } -ErrCode RSRenderServiceConnectionProxy::SetWindowContainer(NodeId nodeId, bool value) +ErrCode RSClientToRenderConnectionProxy::SetWindowContainer(NodeId nodeId, bool value) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWindowContainer: write token err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetWindowContainer: write token err."); return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_ASYNC); if (!data.WriteUint64(nodeId)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWindowContainer: write Uint64 val err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetWindowContainer: write Uint64 val err."); return ERR_INVALID_VALUE; } if (!data.WriteBool(value)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWindowContainer: write Bool val err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetWindowContainer: write Bool val err."); return ERR_INVALID_VALUE; } uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_WINDOW_CONTAINER); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetWindowContainer: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetWindowContainer: Send Request err."); return ERR_INVALID_VALUE; } return ERR_OK; } -int32_t RSRenderServiceConnectionProxy::RegisterSelfDrawingNodeRectChangeCallback( - const RectConstraint& constraint, sptr callback) -{ - if (!callback) { - ROSEN_LOGE("%{public}s callback is nullptr", __func__); - return ERR_INVALID_VALUE; - } - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: WriteInterfaceToken GetDescriptor err."); - return WRITE_PARCEL_ERR; - } - option.SetFlags(MessageOption::TF_SYNC); - - uint32_t size = constraint.pids.size(); - if (!data.WriteUint32(size)) { - ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Write size err."); - return WRITE_PARCEL_ERR; - } - for (int32_t pid : constraint.pids) { - if (!data.WriteInt32(pid)) { - ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Write pid err."); - return WRITE_PARCEL_ERR; - } - } - - if (!data.WriteInt32(constraint.range.lowLimit.width) || !data.WriteInt32(constraint.range.lowLimit.height) || - !data.WriteInt32(constraint.range.highLimit.width) || !data.WriteInt32(constraint.range.highLimit.height)) { - ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Write rectRange err."); - return WRITE_PARCEL_ERR; - } - if (!data.WriteRemoteObject(callback->AsObject())) { - ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: WriteRemoteObject callback->AsObject() err."); - return WRITE_PARCEL_ERR; - } - uint32_t code = - static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Send request err."); - return RS_CONNECTION_ERROR; - } - int32_t result{0}; - if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterSelfDrawingNodeRectChangeCallback Read result failed"); - return READ_PARCEL_ERR; - } - return result; -} - -int32_t RSRenderServiceConnectionProxy::UnRegisterSelfDrawingNodeRectChangeCallback() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("UnRegisterSelfDrawingNodeRectChangeCallback: WriteInterfaceToken GetDescriptor err."); - return WRITE_PARCEL_ERR; - } - option.SetFlags(MessageOption::TF_SYNC); - - uint32_t code = static_cast( - RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("UnRegisterSelfDrawingNodeRectChangeCallback: Send request err."); - return RS_CONNECTION_ERROR; - } - int32_t result{0}; - if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::UnRegisterSelfDrawingNodeRectChangeCallback Read result failed"); - return READ_PARCEL_ERR; - } - return result; -} - -bool RSRenderServiceConnectionProxy::GetHighContrastTextState() +bool RSClientToRenderConnectionProxy::GetHighContrastTextState() { MessageParcel data; MessageParcel reply; @@ -5472,13 +3997,13 @@ bool RSRenderServiceConnectionProxy::GetHighContrastTextState() uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_HIGH_CONTRAST_TEXT_STATE); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetHighContrastTextState: Send Request err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetHighContrastTextState: Send Request err."); return false; } return reply.ReadBool(); } -int32_t RSRenderServiceConnectionProxy::SendRequest(uint32_t code, MessageParcel &data, +int32_t RSClientToRenderConnectionProxy::SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { if (!Remote()) { @@ -5487,134 +4012,59 @@ int32_t RSRenderServiceConnectionProxy::SendRequest(uint32_t code, MessageParcel return Remote()->SendRequest(code, data, reply, option); } -ErrCode RSRenderServiceConnectionProxy::NotifyScreenSwitched() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("%{public}s: Write InterfaceToken val err.", __func__); - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_ASYNC); - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SCREEN_SWITCHED); - int32_t err = SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("%{public}s: Send Request error.", __func__); - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -#ifdef RS_ENABLE_OVERLAY_DISPLAY -ErrCode RSRenderServiceConnectionProxy::SetOverlayDisplayMode(int32_t mode) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("%{public}s: Write InterfaceToken val err.", __func__); - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_SYNC); - if (!data.WriteInt32(mode)) { - ROSEN_LOGE("%{public}s: Write Int32 val err.", __func__); - return ERR_INVALID_VALUE; - } - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_OVERLAY_DISPLAY_MODE); - int32_t err = Remote()->SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("%{public}s: SendRequest failed. err:%{public}d.", __func__, err); - return ERR_INVALID_VALUE; - } - int32_t result{0}; - if (!reply.ReadInt32(result)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetOverlayDisplayMode Read result failed"); - return READ_PARCEL_ERR; - } - ROSEN_LOGI("%{public}s: mode:%{public}d, result:%{public}d.", __func__, mode, result); - return result == 0 ? ERR_OK : ERR_INVALID_VALUE; -} -#endif - -ErrCode RSRenderServiceConnectionProxy::NotifyPageName(const std::string &packageName, - const std::string &pageName, bool isEnter) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyPageName: write token err."); - return ERR_INVALID_VALUE; - } - option.SetFlags(MessageOption::TF_ASYNC); - if (data.WriteString(packageName) && data.WriteString(pageName) && data.WriteBool(isEnter)) { - uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PAGE_NAME); - int32_t err = Remote()->SendRequest(code, data, reply, option); - if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyPageName: Send Request err."); - return ERR_INVALID_VALUE; - } - } else { - ROSEN_LOGE("RSRenderServiceConnectionProxy::NotifyPageName: write data err."); - return ERR_INVALID_VALUE; - } - return ERR_OK; -} - -ErrCode RSRenderServiceConnectionProxy::SetBehindWindowFilterEnabled(bool enabled) +ErrCode RSClientToRenderConnectionProxy::SetBehindWindowFilterEnabled(bool enabled) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetBehindWindowFilterEnabled WriteInterfaceToken err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetBehindWindowFilterEnabled WriteInterfaceToken err."); return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_SYNC); if (!data.WriteBool(enabled)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetBehindWindowFilterEnabled WriteBool err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetBehindWindowFilterEnabled WriteBool err."); return ERR_INVALID_VALUE; } uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BEHIND_WINDOW_FILTER_ENABLED); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetBehindWindowFilterEnabled sendrequest error : %{public}d", err); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetBehindWindowFilterEnabled sendrequest error : %{public}d", err); return ERR_INVALID_VALUE; } return ERR_OK; } -ErrCode RSRenderServiceConnectionProxy::GetBehindWindowFilterEnabled(bool& enabled) +ErrCode RSClientToRenderConnectionProxy::GetBehindWindowFilterEnabled(bool& enabled) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetBehindWindowFilterEnabled WriteInterfaceToken err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetBehindWindowFilterEnabled WriteInterfaceToken err."); return ERR_INVALID_VALUE; } option.SetFlags(MessageOption::TF_SYNC); uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_BEHIND_WINDOW_FILTER_ENABLED); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::GetBehindWindowFilterEnabled sendrequest error : %{public}d", err); + ROSEN_LOGE("RSClientToRenderConnectionProxy::GetBehindWindowFilterEnabled sendrequest error : %{public}d", err); return ERR_INVALID_VALUE; } if (!reply.ReadBool(enabled)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::SetBehindWindowFilterEnabled ReadBool err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::SetBehindWindowFilterEnabled ReadBool err."); return ERR_INVALID_VALUE; } return ERR_OK; } -int32_t RSRenderServiceConnectionProxy::GetPidGpuMemoryInMB(pid_t pid, float &gpuMemInMB) +int32_t RSClientToRenderConnectionProxy::GetPidGpuMemoryInMB(pid_t pid, float &gpuMemInMB) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { return RS_CONNECTION_ERROR; } @@ -5635,15 +4085,15 @@ int32_t RSRenderServiceConnectionProxy::GetPidGpuMemoryInMB(pid_t pid, float &gp return err; } -RetCodeHrpService RSRenderServiceConnectionProxy::ProfilerServiceOpenFile(const HrpServiceDirInfo& dirInfo, +RetCodeHrpService RSClientToRenderConnectionProxy::ProfilerServiceOpenFile(const HrpServiceDirInfo& dirInfo, const std::string& fileName, int32_t flags, int& outFd) { const uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::PROFILER_SERVICE_OPEN_FILE); MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerServiceOpenFile WriteInterfaceToken err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::ProfilerServiceOpenFile WriteInterfaceToken err."); return RET_HRP_SERVICE_ERR_UNKNOWN; } option.SetFlags(MessageOption::TF_SYNC); @@ -5655,7 +4105,7 @@ RetCodeHrpService RSRenderServiceConnectionProxy::ProfilerServiceOpenFile(const int32_t err = SendRequest(code, data, reply, option); if (err != ERR_NONE) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerServiceOpenFile sendrequest error : %{public}d", err); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ProfilerServiceOpenFile sendrequest error : %{public}d", err); return RET_HRP_SERVICE_ERR_PROXY_SEND_REQUEST; } @@ -5673,7 +4123,7 @@ RetCodeHrpService RSRenderServiceConnectionProxy::ProfilerServiceOpenFile(const return (RetCodeHrpService)retCode; } -RetCodeHrpService RSRenderServiceConnectionProxy::ProfilerServicePopulateFiles(const HrpServiceDirInfo& dirInfo, +RetCodeHrpService RSClientToRenderConnectionProxy::ProfilerServicePopulateFiles(const HrpServiceDirInfo& dirInfo, uint32_t firstFileIndex, std::vector& outFiles) { const uint32_t code = @@ -5681,8 +4131,8 @@ RetCodeHrpService RSRenderServiceConnectionProxy::ProfilerServicePopulateFiles(c MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerServicePopulateFiles WriteInterfaceToken err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::ProfilerServicePopulateFiles WriteInterfaceToken err."); return RET_HRP_SERVICE_ERR_UNKNOWN; } option.SetFlags(MessageOption::TF_SYNC); @@ -5693,7 +4143,7 @@ RetCodeHrpService RSRenderServiceConnectionProxy::ProfilerServicePopulateFiles(c int32_t err = SendRequest(code, data, reply, option); if (err != ERR_NONE) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerServicePopulateFiles sendrequest error : %{public}d", err); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ProfilerServicePopulateFiles sendrequest error : %{public}d", err); return RET_HRP_SERVICE_ERR_PROXY_SEND_REQUEST; } @@ -5725,38 +4175,38 @@ RetCodeHrpService RSRenderServiceConnectionProxy::ProfilerServicePopulateFiles(c return (RetCodeHrpService)retCode; } -bool RSRenderServiceConnectionProxy::ProfilerIsSecureScreen() +bool RSClientToRenderConnectionProxy::ProfilerIsSecureScreen() { const uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::PROFILER_IS_SECURE_SCREEN); MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerIsSecureScreen WriteInterfaceToken err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::ProfilerIsSecureScreen WriteInterfaceToken err."); return false; } option.SetFlags(MessageOption::TF_SYNC); int32_t err = SendRequest(code, data, reply, option); if (err != ERR_NONE) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerIsSecureScreen sendrequest error : %{public}d", err); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ProfilerIsSecureScreen sendrequest error : %{public}d", err); return false; } bool retValue = false; if (!reply.ReadBool(retValue)) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ProfilerIsSecureScreen ReadBool err."); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ProfilerIsSecureScreen ReadBool err."); return false; } return retValue; } -void RSRenderServiceConnectionProxy::ClearUifirstCache(NodeId id) +void RSClientToRenderConnectionProxy::ClearUifirstCache(NodeId id) { MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ClearUifirstCache: write token err."); + if (!data.WriteInterfaceToken(RSIClientToRenderConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToRenderConnectionProxy::ClearUifirstCache: write token err."); return; } option.SetFlags(MessageOption::TF_ASYNC); @@ -5767,7 +4217,7 @@ void RSRenderServiceConnectionProxy::ClearUifirstCache(NodeId id) uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::CLEAR_UIFIRST_CACHE); int32_t err = SendRequest(code, data, reply, option); if (err != NO_ERROR) { - ROSEN_LOGE("RSRenderServiceConnectionProxy::ClearUifirstCache sendrequest error : %{public}d", err); + ROSEN_LOGE("RSClientToRenderConnectionProxy::ClearUifirstCache sendrequest error : %{public}d", err); return; } } diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.h b/rosen/modules/render_service_base/src/platform/ohos/rs_client_to_render_connection_proxy.h similarity index 74% rename from rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.h rename to rosen/modules/render_service_base/src/platform/ohos/rs_client_to_render_connection_proxy.h index 5bdb6789612abdc51b4abf0953b9aca5568fe7c0..8d3b8201a0f5d23b697355ae65d26ef013e3ebb8 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.h +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_client_to_render_connection_proxy.h @@ -13,22 +13,28 @@ * limitations under the License. */ -#ifndef ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_SERVICE_CONNECTION_PROXY_H -#define ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_SERVICE_CONNECTION_PROXY_H +#ifndef ROSEN_MODULES_RENDER_SERVICE_BASE_PLATFORM_OHOS_RS_CLIENT_TO_RENDER_CONNECTION_PROXY_H +#define ROSEN_MODULES_RENDER_SERVICE_BASE_PLATFORM_OHOS_RS_CLIENT_TO_RENDER_CONNECTION_PROXY_H #include "command/rs_node_showing_command.h" #include #include -#include +#include #include #include "sandbox_utils.h" namespace OHOS { namespace Rosen { -class RSRenderServiceConnectionProxy : public IRemoteProxy { +class RSClientToRenderConnectionProxy : public IRemoteProxy { public: - explicit RSRenderServiceConnectionProxy(const sptr& impl); - virtual ~RSRenderServiceConnectionProxy() noexcept = default; + explicit RSClientToRenderConnectionProxy(const sptr& impl); + virtual ~RSClientToRenderConnectionProxy() noexcept = default; + + sptr CreateRenderConnection( + const sptr& token, pid_t remotePid) override + { + return nullptr; + } ErrCode CommitTransaction(std::unique_ptr& transactionData) override; ErrCode ExecuteSynchronousTask(const std::shared_ptr& task) override; @@ -44,11 +50,6 @@ public: ErrCode CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, sptr& sfc, bool unobscured = false) override; - virtual ErrCode CreateVSyncConnection(sptr& vsyncConn, - const std::string& name, - const sptr& token, - VSyncConnParam vsyncConnParam = {0, 0, false}) override; - ErrCode GetPixelMapByProcessId(std::vector& pixelMapInfoVector, pid_t pid, int32_t& repCode) override; @@ -57,21 +58,6 @@ public: ErrCode SetFocusAppInfo(const FocusAppInfo& info, int32_t& repCode)override; - ErrCode GetDefaultScreenId(uint64_t& screenId) override; - ErrCode GetActiveScreenId(uint64_t& screenId) override; - - std::vector GetAllScreenIds() override; - - // mirrorId: decide which screen id to mirror, INVALID_SCREEN_ID means do not mirror any screen. - ScreenId CreateVirtualScreen( - const std::string &name, - uint32_t width, - uint32_t height, - sptr surface, - ScreenId mirrorId = 0, - int32_t flags = 0, - std::vector whiteList = {}) override; - int32_t SetVirtualScreenSurface(ScreenId id, sptr surface) override; int32_t SetVirtualScreenBlackList(ScreenId id, std::vector& blackListVector) override; @@ -107,32 +93,15 @@ public: int32_t UnRegisterPointerLuminanceChangeCallback() override; #endif - int32_t SetScreenChangeCallback(sptr callback) override; - void SetScreenActiveMode(ScreenId id, uint32_t modeId) override; - void SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate) override; - - void SetRefreshRateMode(int32_t refreshRateMode) override; - void SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range, int32_t animatorExpectedFrameRate) override; void UnregisterFrameRateLinker(FrameRateLinkerId id) override; - uint32_t GetScreenCurrentRefreshRate(ScreenId id) override; - - int32_t GetCurrentRefreshRateMode() override; - - std::vector GetScreenSupportedRefreshRates(ScreenId id) override; - - ErrCode GetShowRefreshRateEnabled(bool& enable) override; - - void SetShowRefreshRateEnabled(bool enabled, int32_t type) override; - - uint32_t GetRealtimeRefreshRate(ScreenId id) override; - ErrCode GetRefreshInfo(pid_t pid, std::string& enable) override; + ErrCode GetRefreshInfoToSP(NodeId id, std::string& enable) override; int32_t SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height) override; @@ -147,8 +116,6 @@ public: void DisablePowerOffRenderControl(ScreenId id) override; - void SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status) override; - ErrCode RegisterApplicationAgent(uint32_t pid, sptr app) override; void TakeSurfaceCapture(NodeId id, sptr callback, @@ -182,36 +149,12 @@ public: ErrCode GetScreenActiveMode(uint64_t id, RSScreenModeInfo& screenModeInfo) override; - std::vector GetScreenSupportedModes(ScreenId id) override; - - RSScreenCapability GetScreenCapability(ScreenId id) override; - - ErrCode GetScreenPowerStatus(uint64_t screenId, uint32_t& status) override; - - RSScreenData GetScreenData(ScreenId id) override; - - ErrCode GetScreenBacklight(uint64_t id, int32_t& level) override; - - void SetScreenBacklight(ScreenId id, uint32_t level) override; - ErrCode RegisterBufferAvailableListener( NodeId id, sptr callback, bool isFromRenderThread) override; ErrCode RegisterBufferClearListener( NodeId id, sptr callback) override; - int32_t GetScreenSupportedColorGamuts(ScreenId id, std::vector& mode) override; - - int32_t GetScreenSupportedMetaDataKeys(ScreenId id, std::vector& keys) override; - - int32_t GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode) override; - - int32_t SetScreenColorGamut(ScreenId id, int32_t modeIdx) override; - - int32_t SetScreenGamutMap(ScreenId id, ScreenGamutMap mode) override; - - int32_t SetScreenCorrection(ScreenId id, ScreenRotation screenRotation) override; - bool SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation) override; int32_t SetVirtualScreenAutoRotation(ScreenId id, bool isAutoRotation) override; @@ -220,8 +163,6 @@ public: ErrCode SetGlobalDarkColorMode(bool isDark) override; - int32_t GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode) override; - int32_t GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability) override; ErrCode GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat, int32_t& resCode) override; @@ -240,27 +181,17 @@ public: ErrCode GetScreenSupportedColorSpaces( ScreenId id, std::vector& colorSpaces, int32_t& resCode) override; - ErrCode GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace, int32_t& resCode) override; - - ErrCode SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace, int32_t& resCode) override; - - int32_t GetScreenType(ScreenId id, RSScreenType& screenType) override; - ErrCode GetBitmap(NodeId id, Drawing::Bitmap& bitmap, bool& success) override; ErrCode GetPixelmap(NodeId id, std::shared_ptr pixelmap, const Drawing::Rect* rect, std::shared_ptr drawCmdList, bool& success) override; bool RegisterTypeface(uint64_t globalUniqueId, std::shared_ptr& typeface) override; bool UnRegisterTypeface(uint64_t globalUniqueId) override; - int32_t GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, std::vector& edidData) override; - ErrCode SetScreenSkipFrameInterval(uint64_t id, uint32_t skipFrameInterval, int32_t& resCode) override; ErrCode SetVirtualScreenRefreshRate( ScreenId id, uint32_t maxRefreshRate, uint32_t& actualRefreshRate, int32_t& retVal) override; - ErrCode SetScreenActiveRect(ScreenId id, const Rect& activeRect, uint32_t& repCode) override; - void SetScreenOffset(ScreenId id, int32_t offSetX, int32_t offSetY) override; void SetScreenFrameGravity(ScreenId id, int32_t gravity) override; @@ -305,20 +236,10 @@ public: void NotifyAppStrategyConfigChangeEvent(const std::string& pkgName, uint32_t listSize, const std::vector>& newConfig) override; - void NotifyRefreshRateEvent(const EventInfo& eventInfo) override; - - void SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) override; - - void SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) override; - ErrCode NotifySoftVsyncEvent(uint32_t pid, uint32_t rateDiscount) override; bool NotifySoftVsyncRateDiscountEvent(uint32_t pid, const std::string &name, uint32_t rateDiscount) override; - ErrCode NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt) override; - - void NotifyDynamicModeEvent(bool enableDynamicMode) override; - ErrCode NotifyHgmConfigEvent(const std::string &eventName, bool state) override; ErrCode NotifyXComponentExpectedFrameRate(const std::string& id, int32_t expectedFrameRate) override; @@ -350,10 +271,6 @@ public: GlobalDirtyRegionInfo GetGlobalDirtyRegionInfo() override; - LayerComposeInfo GetLayerComposeInfo() override; - - HwcDisabledReasonInfos GetHwcDisabledReasonInfo() override; - ErrCode GetHdrOnDuration(int64_t& hdrOnDuration) override; ErrCode SetVmaCacheStatus(bool flag) override; @@ -382,17 +299,8 @@ public: void RegisterTransactionDataCallback(uint64_t token, uint64_t timeStamp, sptr callback) override; - ErrCode NotifyScreenSwitched() override; - ErrCode SetWindowContainer(NodeId nodeId, bool value) override; - int32_t RegisterSelfDrawingNodeRectChangeCallback( - const RectConstraint& constraint, sptr callback) override; - - int32_t UnRegisterSelfDrawingNodeRectChangeCallback() override; - - ErrCode NotifyPageName(const std::string &packageName, const std::string &pageName, bool isEnter) override; - bool GetHighContrastTextState() override; ErrCode SetBehindWindowFilterEnabled(bool enabled) override; @@ -422,19 +330,11 @@ private: ErrCode SetAncoForceDoDirect(bool direct, bool& res) override; - ErrCode SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder) override; - - ErrCode SetLayerTop(const std::string &nodeIdStr, bool isTop) override; - ErrCode SetForceRefresh(const std::string &nodeIdStr, bool isForceRefresh) override; void SetColorFollow(const std::string &nodeIdStr, bool isColorFollow) override; -#ifdef RS_ENABLE_OVERLAY_DISPLAY - ErrCode SetOverlayDisplayMode(int32_t mode) override; -#endif - - static inline BrokerDelegator delegator_; + static inline BrokerDelegator delegator_; pid_t pid_ = GetRealPid(); uint32_t transactionDataIndex_ = 0; @@ -443,4 +343,4 @@ private: } // namespace Rosen } // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_SERVICE_CONNECTION_PROXY_H +#endif // ROSEN_MODULES_RENDER_SERVICE_BASE_PLATFORM_OHOS_RS_CLIENT_TO_RENDER_CONNECTION_PROXY_H diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_client_to_service_connection_proxy.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_client_to_service_connection_proxy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..74724a615bc38b14863edf383f9a08cb4fdd08c8 --- /dev/null +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_client_to_service_connection_proxy.cpp @@ -0,0 +1,3051 @@ +/* + * Copyright (c) 2021-2023 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. + */ + +#include "rs_client_to_service_connection_proxy.h" + +#include +#include +#include +#include +#include +#include "platform/common/rs_log.h" +#include "platform/common/rs_system_properties.h" +#include "transaction/rs_ashmem_helper.h" +#include "transaction/rs_hrp_service.h" +#include "transaction/rs_marshalling_helper.h" +#include "rs_trace.h" + +namespace OHOS { +namespace Rosen { +namespace { +static constexpr size_t ASHMEM_SIZE_THRESHOLD = 200 * 1024; // cannot > 500K in TF_ASYNC mode +static constexpr int MAX_RETRY_COUNT = 20; +static constexpr int RETRY_WAIT_TIME_US = 1000; // wait 1ms before retry SendRequest +static constexpr uint32_t EDID_DATA_MAX_SIZE = 64 * 1024; +static constexpr int MAX_VOTER_SIZE = 100; // SetWindowExpectedRefreshRate map size not exceed 100 +static constexpr int ZERO = 0; // empty map size +} + +RSClientToServiceConnectionProxy::RSClientToServiceConnectionProxy(const sptr& impl) + : IRemoteProxy(impl) +{ +} + +ErrCode RSClientToServiceConnectionProxy::CommitTransaction(std::unique_ptr& transactionData) +{ + if (!transactionData) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CommitTransaction transactionData nullptr!"); + return ERR_INVALID_VALUE; + } + bool isUniMode = RSSystemProperties::GetUniRenderEnabled(); + transactionData->SetSendingPid(pid_); + + // split to several parcels if parcel size > PARCEL_SPLIT_THRESHOLD during marshalling + std::vector> parcelVector; + auto func = [isUniMode, &parcelVector, &transactionData, this]() -> bool { + if (isUniMode) { + ++transactionDataIndex_; + } + transactionData->SetIndex(transactionDataIndex_); + std::shared_ptr parcel = std::make_shared(); + if (!FillParcelWithTransactionData(transactionData, parcel)) { + ROSEN_LOGE("FillParcelWithTransactionData failed!"); + return false; + } + parcelVector.emplace_back(parcel); + return true; + }; + if (transactionData->IsNeedSync() && transactionData->IsEmpty()) { + RS_TRACE_NAME("Commit empty syncTransaction"); + func(); + } else { + while (transactionData->GetMarshallingIndex() < transactionData->GetCommandCount()) { + if (!func()) { + return ERR_INVALID_VALUE; + } + } + } + + MessageOption option; + option.SetFlags(MessageOption::TF_ASYNC); + for (const auto& parcel : parcelVector) { + MessageParcel reply; + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::COMMIT_TRANSACTION); + int retryCount = 0; + int32_t err = NO_ERROR; + do { + err = SendRequest(code, *parcel, reply, option); + if (err != NO_ERROR && retryCount < MAX_RETRY_COUNT) { + retryCount++; + usleep(RETRY_WAIT_TIME_US); + } else if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CommitTransaction SendRequest failed, " + "err = %{public}d, retryCount = %{public}d, data size:%{public}zu", err, retryCount, + parcel->GetDataSize()); + return ERR_INVALID_VALUE; + } + } while (err != NO_ERROR); + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::ExecuteSynchronousTask(const std::shared_ptr& task) +{ + if (task == nullptr) { + return ERR_INVALID_VALUE; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSClientToServiceConnectionProxy::GetDescriptor())) { + ROSEN_LOGE("ExecuteSynchronousTask WriteInterfaceToken failed"); + return ERR_INVALID_VALUE; + } + if (!task->Marshalling(data)) { + ROSEN_LOGE("ExecuteSynchronousTask Marshalling failed"); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::EXECUTE_SYNCHRONOUS_TASK); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return ERR_INVALID_VALUE; + } + + if (task->CheckHeader(reply)) { + task->ReadFromParcel(reply); + } + return ERR_OK; +} + +bool RSClientToServiceConnectionProxy::FillParcelWithTransactionData( + std::unique_ptr& transactionData, std::shared_ptr& data) +{ + // write a flag at the begin of parcel to identify parcel type + // 0: indicate normal parcel + // 1: indicate ashmem parcel + if (!data->WriteInt32(0)) { + ROSEN_LOGE("FillParcelWithTransactionData WriteInt32 failed"); + return false; + } + + if (!RSMarshallingHelper::MarshallingTransactionVer(*data)) { + ROSEN_LOGE("FillParcelWithTransactionData WriteVersionHeader failed!"); + return false; + } + + { + // 1. marshalling RSTransactionData +#ifdef RS_ENABLE_VK + RS_TRACE_NAME_FMT("MarshRSTransactionData cmdCount: %lu, transactionFlag:[%d,%" PRIu64 "], tid:%d, " + "timestamp:%ld", transactionData->GetCommandCount(), pid_, transactionData->GetIndex(), + transactionData->GetSendingTid(), transactionData->GetTimestamp()); +#else + RS_TRACE_NAME_FMT("MarshRSTransactionData cmdCount: %lu, transactionFlag:[%d,%" PRIu64 "], timestamp:%ld", + transactionData->GetCommandCount(), pid_, transactionData->GetIndex(), transactionData->GetTimestamp()); +#endif + ROSEN_LOGI_IF(DEBUG_PIPELINE, + "MarshRSTransactionData cmdCount:%{public}lu transactionFlag:[pid:%{public}d index:%{public}" PRIu64 "]", + transactionData->GetCommandCount(), pid_, transactionData->GetIndex()); + bool success = data->WriteParcelable(transactionData.get()); + if (!success) { + ROSEN_LOGE("FillParcelWithTransactionData data.WriteParcelable failed!"); + return false; + } + } + + // 2. convert data to new ashmem parcel if size over threshold + std::shared_ptr ashmemParcel = nullptr; + if (data->GetDataSize() > ASHMEM_SIZE_THRESHOLD) { + ashmemParcel = RSAshmemHelper::CreateAshmemParcel(data); + } + if (ashmemParcel != nullptr) { + data = ashmemParcel; + } + return true; +} + +ErrCode RSClientToServiceConnectionProxy::GetUniRenderEnabled(bool& enable) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_UNI_RENDER_ENABLED); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return false; + } + if (!reply.ReadBool(enable)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetUniRenderEnabled Read enable failed!"); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId, + bool& success) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNode: WriteInterfaceToken err."); + success = false; + return ERR_INVALID_VALUE; + } + if (!data.WriteUint64(nodeId)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNode: WriteUint64 NodeId err."); + success = false; + return ERR_INVALID_VALUE; + } + if (!data.WriteUint64(displayNodeConfig.mirrorNodeId)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNode: WriteUint64 Config.MirrorNodeId err."); + success = false; + return ERR_INVALID_VALUE; + } + if (!data.WriteUint64(displayNodeConfig.screenId)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNode: WriteUint64 Config.ScreenId err."); + success = false; + return ERR_INVALID_VALUE; + } + if (!data.WriteBool(displayNodeConfig.isMirrored)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNode: WriteBool Config.IsMirrored err."); + success = false; + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_DISPLAY_NODE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + success = false; + return ERR_INVALID_VALUE; + } + + if (!reply.ReadBool(success)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNode Read success failed!"); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::CreateNode(const RSSurfaceRenderNodeConfig& config, bool& success) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteUint64(config.id)) { + ROSEN_LOGE("CreateNode: WriteUint64 Config.id err."); + success = false; + return ERR_INVALID_VALUE; + } + if (!data.WriteString(config.name)) { + ROSEN_LOGE("CreateNode: WriteString Config.name err."); + success = false; + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_NODE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + success = false; + return ERR_INVALID_VALUE; + } + + if (!reply.ReadBool(success)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNode Read success failed"); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, + sptr& sfc, bool unobscured) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteUint64(config.id)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNodeAndSurface: WriteUint64 config.id err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteString(config.name)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNodeAndSurface: WriteString config.name err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteUint8(static_cast(config.nodeType))) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNodeAndSurface: WriteUint8 config.nodeType err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteBool(config.isTextureExportNode)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNodeAndSurface: WriteBool config.isTextureExportNode err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteBool(config.isSync)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNodeAndSurface: WriteBool config.isSync err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteUint8(static_cast(config.surfaceWindowType))) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNodeAndSurface: WriteUint8 config.surfaceWindowType err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteBool(unobscured)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateNodeAndSurface: WriteBool unobscured err."); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_NODE_AND_SURFACE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return ERR_INVALID_VALUE; + } + sptr surfaceObject = reply.ReadRemoteObject(); + sptr bp = iface_cast(surfaceObject); + if (bp == nullptr) { + return ERR_INVALID_VALUE; + } + sfc = Surface::CreateSurfaceAsProducer(bp); + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::CreateVSyncConnection(sptr& vsyncConn, + const std::string& name, + const sptr& token, + VSyncConnParam vsyncConnParam) +{ + if (token == nullptr) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateVSyncConnection: token is nullptr."); + vsyncConn = nullptr; + return ERR_INVALID_VALUE; + } + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteString(name)) { + ROSEN_LOGE("CreateVSyncConnection: WriteString name err."); + vsyncConn = nullptr; + return ERR_INVALID_VALUE; + } + if (!data.WriteRemoteObject(token->AsObject())) { + ROSEN_LOGE("CreateVSyncConnection: WriteRemoteObject token->AsObject() err."); + vsyncConn = nullptr; + return ERR_INVALID_VALUE; + } + if (!data.WriteUint64(vsyncConnParam.id)) { + ROSEN_LOGE("CreateVSyncConnection: WriteUint64 id err."); + vsyncConn = nullptr; + return ERR_INVALID_VALUE; + } + if (!data.WriteUint64(vsyncConnParam.windowNodeId)) { + ROSEN_LOGE("CreateVSyncConnection: WriteUint64 windowNodeId err."); + vsyncConn = nullptr; + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_VSYNC_CONNECTION); + if (!Remote()) { + vsyncConn = nullptr; + return ERR_INVALID_VALUE; + } + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + vsyncConn = nullptr; + return ERR_INVALID_VALUE; + } + + sptr rObj = reply.ReadRemoteObject(); + if (rObj == nullptr) { + vsyncConn = nullptr; + return ERR_INVALID_VALUE; + } + vsyncConn = iface_cast(rObj); + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::GetDefaultScreenId(uint64_t& screenId) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetDefaultScreenId: WriteInterfaceToken RSIClientToServiceConnection::GetDescriptor() err."); + screenId = INVALID_SCREEN_ID; + return ERR_INVALID_VALUE; + } + + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_DEFAULT_SCREEN_ID); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("%{public}s: sendrequest error : %{public}d", __func__, err); + screenId = INVALID_SCREEN_ID; + return ERR_INVALID_VALUE; + } + if (!reply.ReadUint64(screenId)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetDefaultScreenId Read id failed"); + screenId = INVALID_SCREEN_ID; + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::GetActiveScreenId(uint64_t& screenId) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetActiveScreenId: WriteInterfaceToken RSIClientToServiceConnection::GetDescriptor() err."); + screenId = INVALID_SCREEN_ID; + return ERR_INVALID_VALUE; + } + + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ACTIVE_SCREEN_ID); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("%{public}s: sendrequest error : %{public}d", __func__, err); + screenId = INVALID_SCREEN_ID; + return ERR_INVALID_VALUE; + } + if (!reply.ReadUint64(screenId)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetActiveScreenId Read id failed"); + screenId = INVALID_SCREEN_ID; + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +std::vector RSClientToServiceConnectionProxy::GetAllScreenIds() +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + std::vector screenIds; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetAllScreenIds: WriteInterfaceToken RSIClientToServiceConnection::GetDescriptor() err."); + return std::vector(); + } + + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_ALL_SCREEN_IDS); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return std::vector(); + } + + uint32_t size{0}; + if (!reply.ReadUint32(size)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetAllScreenIds Read size failed"); + return std::vector(); + } + size_t readableSize = reply.GetReadableBytes() / sizeof(ScreenId); + size_t len = static_cast(size); + if (len > readableSize || len > screenIds.max_size()) { + RS_LOGE("RSClientToServiceConnectionProxy GetAllScreenIds Failed read vector, size:%{public}zu," + " readableSize:%{public}zu", len, readableSize); + return screenIds; + } + for (uint32_t i = 0; i < size; i++) { + screenIds.emplace_back(reply.ReadUint64()); + } + + return screenIds; +} + +ScreenId RSClientToServiceConnectionProxy::CreateVirtualScreen( + const std::string &name, + uint32_t width, + uint32_t height, + sptr surface, + ScreenId mirrorId, + int32_t flags, + std::vector whiteList) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("CreateVirtualScreen: WriteInterfaceToken RSIClientToServiceConnection::GetDescriptor() err."); + return INVALID_SCREEN_ID; + } + + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteString(name)) { + ROSEN_LOGE("CreateVirtualScreen: WriteString name err."); + return INVALID_SCREEN_ID; + } + if (!data.WriteUint32(width)) { + ROSEN_LOGE("CreateVirtualScreen: WriteUint32 width err."); + return INVALID_SCREEN_ID; + } + if (!data.WriteUint32(height)) { + ROSEN_LOGE("CreateVirtualScreen: WriteUint32 height err."); + return INVALID_SCREEN_ID; + } + if (surface != nullptr) { + auto producer = surface->GetProducer(); + if (producer != nullptr) { + if (!data.WriteBool(true)) { + ROSEN_LOGE("CreateVirtualScreen: WriteBool [true] err."); + return INVALID_SCREEN_ID; + } + if (!data.WriteRemoteObject(producer->AsObject())) { + ROSEN_LOGE("CreateVirtualScreen: WriteRemoteObject producer->AsObject() err."); + return INVALID_SCREEN_ID; + } + } else { + if (!data.WriteBool(false)) { + ROSEN_LOGE("CreateVirtualScreen: WriteBool [false] err."); + return INVALID_SCREEN_ID; + } + } + } else { + if (!data.WriteBool(false)) { + ROSEN_LOGE("CreateVirtualScreen: WriteBool [false] err."); + return INVALID_SCREEN_ID; + } + } + if (!data.WriteUint64(mirrorId)) { + ROSEN_LOGE("CreateVirtualScreen: WriteUint64 mirrorId err."); + return INVALID_SCREEN_ID; + } + if (!data.WriteInt32(flags)) { + ROSEN_LOGE("CreateVirtualScreen: WriteInt32 flags err."); + return INVALID_SCREEN_ID; + } + if (!data.WriteUInt64Vector(whiteList)) { + ROSEN_LOGE("CreateVirtualScreen: WriteUInt64Vector whiteList err."); + return INVALID_SCREEN_ID; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::CREATE_VIRTUAL_SCREEN); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::%{public}s: Send Request err.", __func__); + return INVALID_SCREEN_ID; + } + + uint64_t id{0}; + if (!reply.ReadUint64(id)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::CreateVirtualScreen Read id failed"); + return INVALID_SCREEN_ID; + } + return id; +} + +int32_t RSClientToServiceConnectionProxy::SetVirtualScreenSurface(ScreenId id, sptr surface) +{ + if (surface == nullptr) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetVirtualScreenSurface: Send surface is nullptr!"); + return INVALID_ARGUMENTS; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetVirtualScreenSurface: WriteInterfaceToken GetDescriptor err."); + return WRITE_PARCEL_ERR; + } + + option.SetFlags(MessageOption::TF_ASYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetVirtualScreenSurface: WriteUint64 MessageOption::TF_ASYNC err."); + return WRITE_PARCEL_ERR; + } + auto producer = surface->GetProducer(); + if (!data.WriteRemoteObject(producer->AsObject())) { + ROSEN_LOGE("SetVirtualScreenSurface: WriteRemoteObject producer->AsObject() err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_SURFACE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetVirtualScreenSurface: Send Request err."); + return RS_CONNECTION_ERROR; + } + + int32_t status = reply.ReadInt32(); + return status; +} + +void RSClientToServiceConnectionProxy::RemoveVirtualScreen(ScreenId id) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RemoveVirtualScreen: WriteInterfaceToken GetDescriptor err."); + return; + } + + option.SetFlags(MessageOption::TF_ASYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("RemoveVirtualScreen: WriteUint64 id err."); + return; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REMOVE_VIRTUAL_SCREEN); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::RemoveVirtualScreen: Send Request err."); + return; + } +} + +int32_t RSClientToServiceConnectionProxy::SetScreenChangeCallback(sptr callback) +{ + if (callback == nullptr) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetScreenChangeCallback: callback is nullptr."); + return INVALID_ARGUMENTS; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetScreenChangeCallback: WriteInterfaceToken GetDescriptor err."); + return WRITE_PARCEL_ERR; + } + + option.SetFlags(MessageOption::TF_ASYNC); + if (!data.WriteRemoteObject(callback->AsObject())) { + ROSEN_LOGE("SetScreenChangeCallback: WriteRemoteObject callback->AsObject() err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CHANGE_CALLBACK); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetScreenChangeCallback: Send Request err."); + return RS_CONNECTION_ERROR; + } + int32_t result = reply.ReadInt32(); + return result; +} + +void RSClientToServiceConnectionProxy::SetScreenActiveMode(ScreenId id, uint32_t modeId) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetScreenActiveMode: WriteInterfaceToken GetDescriptor err."); + return; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetScreenActiveMode: WriteUint64 id err."); + return; + } + if (!data.WriteUint32(modeId)) { + ROSEN_LOGE("SetScreenActiveMode: WriteUint32 modeId err."); + return; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_MODE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return; + } +} + +void RSClientToServiceConnectionProxy::SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetScreenRefreshRate: WriteInterfaceToken GetDescriptor err."); + return; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetScreenRefreshRate: WriteUint64 id err."); + return; + } + if (!data.WriteInt32(sceneId)) { + ROSEN_LOGE("SetScreenRefreshRate: WriteInt32 sceneId err."); + return; + } + if (!data.WriteInt32(rate)) { + ROSEN_LOGE("SetScreenRefreshRate: WriteInt32 rate err."); + return; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_REFRESH_RATE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy sendrequest error : %{public}d", err); + return; + } +} + +void RSClientToServiceConnectionProxy::SetRefreshRateMode(int32_t refreshRateMode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetRefreshRateMode: WriteInterfaceToken GetDescriptor err."); + return; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteInt32(refreshRateMode)) { + ROSEN_LOGE("SetRefreshRateMode: WriteInt32 refreshRateMode err."); + return; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_REFRESH_RATE_MODE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy sendrequest error : %{public}d", err); + return; + } +} + +void RSClientToServiceConnectionProxy::UnregisterFrameRateLinker(FrameRateLinkerId id) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("UnregisterFrameRateLinker: WriteInterfaceToken GetDescriptor err."); + return; + } + + option.SetFlags(MessageOption::TF_ASYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("UnregisterFrameRateLinker: WriteUint64 id err."); + return; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::UNREGISTER_FRAME_RATE_LINKER); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy sendrequest error : %{public}d", err); + return; + } +} + +uint32_t RSClientToServiceConnectionProxy::GetScreenCurrentRefreshRate(ScreenId id) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenCurrentRefreshRate: WriteInterfaceToken GetDescriptor err."); + return SUCCESS; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenCurrentRefreshRate: WriteUint64 id err."); + return SUCCESS; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CURRENT_REFRESH_RATE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy sendrequest error : %{public}d", err); + return SUCCESS; + } + uint32_t rate{0}; + if (!reply.ReadUint32(rate)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenCurrentRefreshRate Read rate failed"); + return READ_PARCEL_ERR; + } + return rate; +} + +int32_t RSClientToServiceConnectionProxy::GetCurrentRefreshRateMode() +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy failed to get descriptor"); + return SUCCESS; + } + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_CURRENT_REFRESH_RATE_MODE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy sendrequest error : %{public}d", err); + return SUCCESS; + } + int32_t refreshRateMode{0}; + if (!reply.ReadInt32(refreshRateMode)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetCurrentRefreshRateMode Read refreshRateMode failed"); + return READ_PARCEL_ERR; + } + return refreshRateMode; +} + +std::vector RSClientToServiceConnectionProxy::GetScreenSupportedRefreshRates(ScreenId id) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + std::vector screenSupportedRates; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenSupportedRefreshRates: WriteInterfaceToken GetDescriptor err."); + return screenSupportedRates; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenSupportedRefreshRates: WriteUint64 id err."); + return screenSupportedRates; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_REFRESH_RATES); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return screenSupportedRates; + } + uint64_t rateCount{0}; + if (!reply.ReadUint64(rateCount)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenSupportedRefreshRates Read rateCount failed"); + return screenSupportedRates; + } + size_t readableSize = reply.GetReadableBytes(); + size_t len = static_cast(rateCount); + if (len > readableSize || len > screenSupportedRates.max_size()) { + RS_LOGE("RSClientToServiceConnectionProxy GetScreenSupportedRefreshRates " + "fail read vector, size : %{public}zu, readableSize : %{public}zu", len, readableSize); + return screenSupportedRates; + } + screenSupportedRates.resize(rateCount); + for (uint64_t rateIndex = 0; rateIndex < rateCount; rateIndex++) { + screenSupportedRates[rateIndex] = reply.ReadInt32(); + } + return screenSupportedRates; +} + +ErrCode RSClientToServiceConnectionProxy::GetShowRefreshRateEnabled(bool& enable) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy failed to get descriptor"); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SHOW_REFRESH_RATE_ENABLED); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy sendrequest error : %{public}d", err); + return ERR_INVALID_VALUE; + } + if (!reply.ReadBool(enable)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetCurrentRefreshRateMode Read enable failed"); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +void RSClientToServiceConnectionProxy::SetShowRefreshRateEnabled(bool enabled, int32_t type) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetShowRefreshRateEnabled: WriteInterfaceToken GetDescriptor err."); + return; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteBool(enabled) || !data.WriteInt32(type)) { + ROSEN_LOGE("SetShowRefreshRateEnabled: WriteBool[enable] OR WriteInt32[type] err."); + return; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SHOW_REFRESH_RATE_ENABLED); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy sendrequest error : %{public}d", err); + return; + } +} + +uint32_t RSClientToServiceConnectionProxy::GetRealtimeRefreshRate(ScreenId id) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetRealtimeRefreshRate: WriteInterfaceToken GetDescriptor err."); + return SUCCESS; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetRealtimeRefreshRate: WriteUint64 id err."); + return SUCCESS; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REALTIME_REFRESH_RATE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy sendrequest error : %{public}d", err); + return SUCCESS; + } + uint32_t rate{0}; + if (!reply.ReadUint32(rate)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetRealtimeRefreshRate Read rate failed"); + return READ_PARCEL_ERR; + } + return rate; +} + +ErrCode RSClientToServiceConnectionProxy::GetRefreshInfo(pid_t pid, std::string& enable) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetRefreshInfo: WriteInterfaceToken GetDescriptor err."); + enable = ""; + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteInt32(pid)) { + ROSEN_LOGE("GetRefreshInfo: WriteInt32 pid err."); + enable = ""; + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy sendrequest error : %{public}d", err); + enable = ""; + return ERR_INVALID_VALUE; + } + + if (!reply.ReadString(enable)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetRefreshInfo Read enable failed"); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::GetRefreshInfoToSP(NodeId id, std::string& enable) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetRefreshInfoToSP: WriteInterfaceToken GetDescriptor err."); + enable = ""; + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetRefreshInfoToSP: WriteUint64 id err."); + enable = ""; + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_REFRESH_INFO_TO_SP); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy sendrequest error : %{public}d", err); + enable = ""; + return ERR_INVALID_VALUE; + } + + if (!reply.ReadString(enable)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetRefreshInfo Read enable failed"); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +int32_t RSClientToServiceConnectionProxy::SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + ROSEN_LOGE("SetPhysicalScreenResolution: WriteInterfaceToken GetDescriptor err."); + return WRITE_PARCEL_ERR; + } + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetPhysicalScreenResolution: WriteUint64 id err."); + return WRITE_PARCEL_ERR; + } + if (!data.WriteUint32(width)) { + ROSEN_LOGE("SetPhysicalScreenResolution: WriteUint32 width err."); + return WRITE_PARCEL_ERR; + } + if (!data.WriteUint32(height)) { + ROSEN_LOGE("SetPhysicalScreenResolution: WriteUint32 height err."); + return WRITE_PARCEL_ERR; + } + auto code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_PHYSICAL_SCREEN_RESOLUTION); + if (SendRequest(code, data, reply, option) != ERR_NONE) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetPhysicalScreenResolution: SendRequest error."); + return RS_CONNECTION_ERROR; + } + int32_t status{0}; + if (!reply.ReadInt32(status)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetPhysicalScreenResolution Read status failed"); + return READ_PARCEL_ERR; + } + return status; +} + +int32_t RSClientToServiceConnectionProxy::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetVirtualScreenResolution: WriteInterfaceToken GetDescriptor err."); + return WRITE_PARCEL_ERR; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetVirtualScreenResolution: WriteUint64 id err."); + return WRITE_PARCEL_ERR; + } + if (!data.WriteUint32(width)) { + ROSEN_LOGE("SetVirtualScreenResolution: WriteUint32 width err."); + return WRITE_PARCEL_ERR; + } + if (!data.WriteUint32(height)) { + ROSEN_LOGE("SetVirtualScreenResolution: WriteUint32 height err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_VIRTUAL_SCREEN_RESOLUTION); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetVirtualScreenResolution: Send Request err."); + return RS_CONNECTION_ERROR; + } + int32_t status{0}; + if (!reply.ReadInt32(status)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetVirtualScreenResolution Read status failed"); + return READ_PARCEL_ERR; + } + return status; +} + +ErrCode RSClientToServiceConnectionProxy::RepaintEverything() +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::RepaintEverything: Send Request err."); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = + static_cast(RSIRenderServiceConnectionInterfaceCode::REPAINT_EVERYTHING); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +void RSClientToServiceConnectionProxy::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetScreenPowerStatus: WriteInterfaceToken GetDescriptor err."); + return; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetScreenPowerStatus: WriteUint64 id err."); + return; + } + if (!data.WriteUint32(static_cast(status))) { + ROSEN_LOGE("SetScreenPowerStatus: WriteUint32 status err."); + return; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_POWER_STATUS); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("SetScreenPowerStatus: SendRequest failed %{public}d", err); + return; + } +} + +ErrCode RSClientToServiceConnectionProxy::RegisterApplicationAgent(uint32_t pid, sptr app) +{ + if (app == nullptr) { + ROSEN_LOGE("%{public}s callback == nullptr", __func__); + return ERR_INVALID_VALUE; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + option.SetFlags(MessageOption::TF_ASYNC); + if (!data.WriteRemoteObject(app->AsObject())) { + ROSEN_LOGE("%{public}s WriteRemoteObject failed", __func__); + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_APPLICATION_AGENT); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("%{public}s SendRequest() error[%{public}d]", __func__, err); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +bool RSClientToServiceConnectionProxy::WriteSurfaceCaptureConfig( + const RSSurfaceCaptureConfig& captureConfig, MessageParcel& data) +{ + if (!data.WriteFloat(captureConfig.scaleX) || !data.WriteFloat(captureConfig.scaleY) || + !data.WriteBool(captureConfig.useDma) || !data.WriteBool(captureConfig.useCurWindow) || + !data.WriteUint8(static_cast(captureConfig.captureType)) || !data.WriteBool(captureConfig.isSync) || + !data.WriteBool(captureConfig.isHdrCapture) || + !data.WriteFloat(captureConfig.mainScreenRect.left_) || + !data.WriteFloat(captureConfig.mainScreenRect.top_) || + !data.WriteFloat(captureConfig.mainScreenRect.right_) || + !data.WriteFloat(captureConfig.mainScreenRect.bottom_) || + !data.WriteUint64(captureConfig.uiCaptureInRangeParam.endNodeId) || + !data.WriteBool(captureConfig.uiCaptureInRangeParam.useBeginNodeSize) || + !data.WriteFloat(captureConfig.specifiedAreaRect.left_) || + !data.WriteFloat(captureConfig.specifiedAreaRect.top_) || + !data.WriteFloat(captureConfig.specifiedAreaRect.right_) || + !data.WriteFloat(captureConfig.specifiedAreaRect.bottom_) || + !data.WriteUInt64Vector(captureConfig.blackList) || + !data.WriteUint32(captureConfig.backGroundColor)) { + ROSEN_LOGE("WriteSurfaceCaptureConfig: WriteSurfaceCaptureConfig captureConfig err."); + return false; + } + return true; +} + +bool RSClientToServiceConnectionProxy::WriteSurfaceCaptureBlurParam( + const RSSurfaceCaptureBlurParam& blurParam, MessageParcel& data) +{ + if (!data.WriteBool(blurParam.isNeedBlur) || !data.WriteFloat(blurParam.blurRadius)) { + ROSEN_LOGE("WriteSurfaceCaptureBlurParam: WriteBool OR WriteFloat [blurParam] err."); + return false; + } + return true; +} + +bool RSClientToServiceConnectionProxy::WriteSurfaceCaptureAreaRect( + const Drawing::Rect& specifiedAreaRect, MessageParcel& data) +{ + if (!data.WriteFloat(specifiedAreaRect.left_) || !data.WriteFloat(specifiedAreaRect.top_) || + !data.WriteFloat(specifiedAreaRect.right_) || !data.WriteFloat(specifiedAreaRect.bottom_)) { + ROSEN_LOGE("WriteSurfaceCaptureAreaRect: WriteFloat specifiedAreaRect err."); + return false; + } + return true; +} + +ErrCode RSClientToServiceConnectionProxy::GetScreenActiveMode(uint64_t id, RSScreenModeInfo& screenModeInfo) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenActiveMode: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenActiveMode: WriteUint64 id err."); + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_ACTIVE_MODE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("%{public}s: sendrequest error : %{public}d", __func__, err); + return ERR_INVALID_VALUE; + } + + sptr pScreenModeInfo(reply.ReadParcelable()); + if (pScreenModeInfo == nullptr) { + ROSEN_LOGE("%{public}s: ScreenModeInfo is null", __func__); + return ERR_INVALID_VALUE; + } + screenModeInfo = *pScreenModeInfo; + return ERR_OK; +} + +std::vector RSClientToServiceConnectionProxy::GetScreenSupportedModes(ScreenId id) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + std::vector screenSupportedModes; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenSupportedModes: WriteInterfaceToken GetDescriptor err."); + return screenSupportedModes; + } + + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenSupportedModes: WriteUint64 id err."); + return screenSupportedModes; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_MODES); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return screenSupportedModes; + } + + uint64_t modeCount{0}; + if (!reply.ReadUint64(modeCount)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenSupportedModes Read modeCount failed"); + return screenSupportedModes; + } + size_t readableSize = reply.GetReadableBytes(); + size_t len = static_cast(modeCount); + if (len > readableSize || len > screenSupportedModes.max_size()) { + RS_LOGE("RSClientToServiceConnectionProxy GetScreenSupportedModes Fail read vector, size:%{public}zu," + "readableSize:%{public}zu", len, readableSize); + return screenSupportedModes; + } + screenSupportedModes.resize(modeCount); + for (uint64_t modeIndex = 0; modeIndex < modeCount; modeIndex++) { + sptr itemScreenMode = reply.ReadParcelable(); + if (itemScreenMode == nullptr) { + continue; + } else { + screenSupportedModes[modeIndex] = *itemScreenMode; + } + } + return screenSupportedModes; +} + +ErrCode RSClientToServiceConnectionProxy::GetMemoryGraphics(std::vector& memoryGraphics) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetMemoryGraphics: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; + } + + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHICS); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return ERR_INVALID_VALUE; + } + + uint64_t count{0}; + if (!reply.ReadUint64(count)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetMemoryGraphics Read count failed"); + return ERR_INVALID_VALUE; + } + size_t readableSize = reply.GetReadableBytes(); + size_t len = static_cast(count); + if (len > readableSize || len > memoryGraphics.max_size()) { + RS_LOGE("RSClientToServiceConnectionProxy GetMemoryGraphics Failed to read vector, size:%{public}zu," + " readableSize:%{public}zu", len, readableSize); + return ERR_INVALID_VALUE; + } + memoryGraphics.resize(count); + for (uint64_t index = 0; index < count; index++) { + sptr item = reply.ReadParcelable(); + if (item == nullptr) { + continue; + } else { + memoryGraphics[index] = *item; + } + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + MemoryGraphic memoryGraphic; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetTotalAppMemSize: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; + } + + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_TOTAL_APP_MEM_SIZE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return ERR_INVALID_VALUE; + } + + if (!reply.ReadFloat(cpuMemSize) || !reply.ReadFloat(gpuMemSize)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetTotalAppMemSize Read MemSize failed"); + return READ_PARCEL_ERR; + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::GetMemoryGraphic(int pid, MemoryGraphic& memoryGraphic) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetMemoryGraphic: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; + } + + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteInt32(pid)) { + ROSEN_LOGE("GetMemoryGraphic: WriteInt32 pid err."); + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_MEMORY_GRAPHIC); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return ERR_INVALID_VALUE; + } + sptr pMemoryGraphic(reply.ReadParcelable()); + if (pMemoryGraphic == nullptr) { + return ERR_INVALID_VALUE; + } + memoryGraphic = *pMemoryGraphic; + return ERR_OK; +} + +RSScreenCapability RSClientToServiceConnectionProxy::GetScreenCapability(ScreenId id) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + RSScreenCapability screenCapability; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenCapability: WriteInterfaceToken GetDescriptor err."); + return screenCapability; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenCapability: WriteUint64 id err."); + return screenCapability; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_CAPABILITY); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return screenCapability; + } + + sptr pScreenCapability(reply.ReadParcelable()); + if (pScreenCapability == nullptr) { + return screenCapability; + } + screenCapability = *pScreenCapability; + return screenCapability; +} + +ErrCode RSClientToServiceConnectionProxy::GetScreenPowerStatus(uint64_t screenId, uint32_t& status) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenPowerStatus: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(screenId)) { + ROSEN_LOGE("GetScreenPowerStatus: WriteUint64 id err."); + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_POWER_STATUS); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return ERR_INVALID_VALUE; + } + status = reply.ReadUint32(); + return ERR_OK; +} + +RSScreenData RSClientToServiceConnectionProxy::GetScreenData(ScreenId id) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + RSScreenData screenData; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenData: WriteInterfaceToken GetDescriptor err."); + return screenData; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenData: WriteUint64 id err."); + return screenData; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_DATA); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return screenData; + } + sptr pScreenData(reply.ReadParcelable()); + if (pScreenData == nullptr) { + return screenData; + } + screenData = *pScreenData; + return screenData; +} + +ErrCode RSClientToServiceConnectionProxy::GetScreenBacklight(uint64_t id, int32_t& level) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenBacklight: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenBacklight: WriteUint64 id err."); + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_BACK_LIGHT); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return ERR_INVALID_VALUE; + } + if (!reply.ReadInt32(level)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenBacklight Read level failed"); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +void RSClientToServiceConnectionProxy::SetScreenBacklight(ScreenId id, uint32_t level) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetScreenBacklight: WriteInterfaceToken GetDescriptor err."); + return; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetScreenBacklight: WriteUint64 id err."); + return; + } + if (!data.WriteUint32(level)) { + ROSEN_LOGE("SetScreenBacklight: WriteUint32 level err."); + return; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_BACK_LIGHT); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("SetScreenBacklight: SendRequest failed"); + return; + } +} + +ErrCode RSClientToServiceConnectionProxy::RegisterBufferClearListener( + NodeId id, sptr callback) +{ + if (callback == nullptr) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::RegisterBufferClearListener: callback is nullptr."); + return ERR_INVALID_VALUE; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RegisterBufferClearListener: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("RegisterBufferClearListener: WriteUint64 id err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteRemoteObject(callback->AsObject())) { + ROSEN_LOGE("RegisterBufferClearListener: WriteRemoteObject callback->AsObject() err."); + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_CLEAR_LISTENER); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::RegisterBufferClearListener: Send Request err."); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::RegisterBufferAvailableListener( + NodeId id, sptr callback, bool isFromRenderThread) +{ + if (callback == nullptr) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::RegisterBufferAvailableListener: callback is nullptr."); + return ERR_INVALID_VALUE; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RegisterBufferAvailableListener: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; + } + + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("RegisterBufferAvailableListener: WriteUint64 id err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteRemoteObject(callback->AsObject())) { + ROSEN_LOGE("RegisterBufferAvailableListener: WriteRemoteObject callback->AsObject() err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteBool(isFromRenderThread)) { + ROSEN_LOGE("RegisterBufferAvailableListener: WriteBool isFromRenderThread err."); + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_BUFFER_AVAILABLE_LISTENER); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::RegisterBufferAvailableListener: Send Request err."); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +int32_t RSClientToServiceConnectionProxy::GetScreenSupportedColorGamuts(ScreenId id, std::vector& mode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenSupportedColorGamuts: WriteInterfaceToken GetDescriptor err."); + return RS_CONNECTION_ERROR; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenSupportedColorGamuts: WriteUint64 id err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_GAMUTS); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return RS_CONNECTION_ERROR; + } + int32_t result{0}; + if (!reply.ReadInt32(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenSupportedColorGamuts Read result failed"); + return READ_PARCEL_ERR; + } + if (result == SUCCESS) { + mode.clear(); + std::vector modeRecv; + reply.ReadUInt32Vector(&modeRecv); + for (auto i : modeRecv) { + mode.push_back(static_cast(i)); + } + } + return result; +} + +int32_t RSClientToServiceConnectionProxy::GetScreenSupportedMetaDataKeys( + ScreenId id, std::vector& keys) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenSupportedMetaDataKeys: WriteInterfaceToken GetDescriptor err."); + return RS_CONNECTION_ERROR; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenSupportedMetaDataKeys: WriteUint64 id err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_METADATAKEYS); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return RS_CONNECTION_ERROR; + } + int32_t result{0}; + if (!reply.ReadInt32(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenSupportedMetaDataKeys Read result failed"); + return READ_PARCEL_ERR; + } + if (result == SUCCESS) { + keys.clear(); + std::vector keyRecv; + reply.ReadUInt32Vector(&keyRecv); + for (auto i : keyRecv) { + keys.push_back(static_cast(i)); + } + } + return result; +} + +int32_t RSClientToServiceConnectionProxy::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenColorGamut: WriteInterfaceToken GetDescriptor err."); + return RS_CONNECTION_ERROR; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenColorGamut: WriteUint64 id err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return RS_CONNECTION_ERROR; + } + int32_t result{0}; + if (!reply.ReadInt32(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenColorGamut Read result failed"); + return READ_PARCEL_ERR; + } + if (result == SUCCESS) { + uint32_t readMode{0}; + if (!reply.ReadUint32(readMode)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenColorGamut Read mode failed"); + return READ_PARCEL_ERR; + } + mode = static_cast(readMode); + } + return result; +} + +int32_t RSClientToServiceConnectionProxy::SetScreenColorGamut(ScreenId id, int32_t modeIdx) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetScreenColorGamut: WriteInterfaceToken GetDescriptor err."); + return RS_CONNECTION_ERROR; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetScreenColorGamut: WriteUint64 id err."); + return WRITE_PARCEL_ERR; + } + if (!data.WriteInt32(modeIdx)) { + ROSEN_LOGE("SetScreenColorGamut: WriteInt32 modeIdx err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return RS_CONNECTION_ERROR; + } + int32_t result{0}; + if (!reply.ReadInt32(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetScreenColorGamut Read result failed"); + return READ_PARCEL_ERR; + } + return result; +} + +int32_t RSClientToServiceConnectionProxy::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetScreenGamutMap: WriteInterfaceToken GetDescriptor err."); + return RS_CONNECTION_ERROR; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetScreenGamutMap: WriteUint64 id err."); + return WRITE_PARCEL_ERR; + } + if (!data.WriteUint32(mode)) { + ROSEN_LOGE("SetScreenGamutMap: WriteUint32 mode err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_GAMUT_MAP); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return RS_CONNECTION_ERROR; + } + int32_t result{0}; + if (!reply.ReadInt32(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetScreenGamutMap Read result failed"); + return READ_PARCEL_ERR; + } + return result; +} + +int32_t RSClientToServiceConnectionProxy::SetScreenCorrection(ScreenId id, ScreenRotation screenRotation) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetScreenCorrection: WriteInterfaceToken GetDescriptor err."); + return RS_CONNECTION_ERROR; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetScreenCorrection: WriteUint64 id err."); + return WRITE_PARCEL_ERR; + } + if (!data.WriteUint32(static_cast(screenRotation))) { + ROSEN_LOGE("SetScreenCorrection: WriteUint32 screenRotation err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_CORRECTION); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return RS_CONNECTION_ERROR; + } + int32_t result{0}; + if (!reply.ReadInt32(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetScreenCorrection Read result failed"); + return READ_PARCEL_ERR; + } + return result; +} + +int32_t RSClientToServiceConnectionProxy::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenGamutMap: WriteInterfaceToken GetDescriptor err."); + return RS_CONNECTION_ERROR; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenGamutMap: WriteUint64 id err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_GAMUT_MAP); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return RS_CONNECTION_ERROR; + } + int32_t result{0}; + if (!reply.ReadInt32(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenGamutMap Read result failed"); + return READ_PARCEL_ERR; + } + if (result == SUCCESS) { + uint32_t readMode{0}; + if (!reply.ReadUint32(readMode)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenGamutMap Read mode failed"); + return READ_PARCEL_ERR; + } + mode = static_cast(readMode); + } + return result; +} + +ErrCode RSClientToServiceConnectionProxy::GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus, int32_t& resCode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenHDRStatus WriteInterfaceToken GetDescriptor err."); + return WRITE_PARCEL_ERR; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenHDRStatus WriteUint64 id err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_HDR_STATUS); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenHDRStatus SendRequest error(%{public}d)", err); + return RS_CONNECTION_ERROR; + } + if (!reply.ReadInt32(resCode)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenHDRStatus Read resCode failed"); + return READ_PARCEL_ERR; + } + if (resCode == SUCCESS) { + uint32_t readHdrStatus{0}; + if (!reply.ReadUint32(readHdrStatus)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenHDRStatus Read HDR status failed"); + return READ_PARCEL_ERR; + } + hdrStatus = static_cast(readHdrStatus); + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::GetScreenSupportedColorSpaces( + ScreenId id, std::vector& colorSpaces, int32_t& resCode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenSupportedColorSpaces: WriteInterfaceToken GetDescriptor err."); + resCode = RS_CONNECTION_ERROR; + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenSupportedColorSpaces: WriteUint64 id err."); + resCode = WRITE_PARCEL_ERR; + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_SUPPORTED_COLORSPACES); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + resCode = RS_CONNECTION_ERROR; + return ERR_INVALID_VALUE; + } + if (!reply.ReadInt32(resCode)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenSupportedColorSpaces Read resCode failed"); + return READ_PARCEL_ERR; + } + if (resCode == SUCCESS) { + colorSpaces.clear(); + std::vector colorSpacesRecv; + reply.ReadUInt32Vector(&colorSpacesRecv); + std::transform(colorSpacesRecv.begin(), colorSpacesRecv.end(), back_inserter(colorSpaces), + [](uint32_t i) -> GraphicCM_ColorSpaceType {return static_cast(i);}); + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::GetScreenColorSpace( + ScreenId id, GraphicCM_ColorSpaceType& colorSpace, int32_t& resCode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenColorSpace: WriteInterfaceToken GetDescriptor err."); + resCode = RS_CONNECTION_ERROR; + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenColorSpace: WriteUint64 id err."); + resCode = WRITE_PARCEL_ERR; + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_COLORSPACE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + resCode = RS_CONNECTION_ERROR; + return ERR_INVALID_VALUE; + } + if (!reply.ReadInt32(resCode)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenColorSpace Read resCode failed"); + return READ_PARCEL_ERR; + } + if (resCode == SUCCESS) { + uint32_t type{0}; + if (!reply.ReadUint32(type)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenColorSpace Read type failed"); + return READ_PARCEL_ERR; + } + colorSpace = static_cast(type); + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::SetScreenColorSpace( + ScreenId id, GraphicCM_ColorSpaceType colorSpace, int32_t& resCode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetScreenColorSpace: WriteInterfaceToken GetDescriptor err."); + resCode = RS_CONNECTION_ERROR; + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetScreenColorSpace: WriteUint64 id err."); + resCode = WRITE_PARCEL_ERR; + return ERR_INVALID_VALUE; + } + if (!data.WriteInt32(colorSpace)) { + ROSEN_LOGE("SetScreenColorSpace: WriteInt32 colorSpace err."); + resCode = WRITE_PARCEL_ERR; + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_COLORSPACE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + resCode = RS_CONNECTION_ERROR; + return ERR_INVALID_VALUE; + } + resCode = reply.ReadInt32(); + return ERR_OK; +} + +int32_t RSClientToServiceConnectionProxy::GetScreenType(ScreenId id, RSScreenType& screenType) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetScreenType: WriteInterfaceToken GetDescriptor err."); + return RS_CONNECTION_ERROR; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetScreenType: WriteUint64 id err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_SCREEN_TYPE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return RS_CONNECTION_ERROR; + } + int32_t result = reply.ReadInt32(); + if (result == SUCCESS) { + uint32_t type{0}; + if (!reply.ReadUint32(type)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetScreenType Read type failed"); + return READ_PARCEL_ERR; + } + screenType = static_cast(type); + } + return result; +} + +ErrCode RSClientToServiceConnectionProxy::GetBitmap(NodeId id, Drawing::Bitmap& bitmap, bool& success) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetBitmap: WriteInterfaceToken GetDescriptor err."); + success = false; + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetBitmap: WriteUint64 id err."); + success = false; + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_BITMAP); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + success = false; + return ERR_INVALID_VALUE; + } + bool result{false}; + if (!reply.ReadBool(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetBitmap Read result failed"); + return READ_PARCEL_ERR; + } + if (!result || !RSMarshallingHelper::Unmarshalling(reply, bitmap)) { + RS_LOGE("RSClientToServiceConnectionProxy::GetBitmap: Unmarshalling failed"); + success = false; + return ERR_INVALID_VALUE; + } + success = true; + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::SetGlobalDarkColorMode(bool isDark) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetGlobalDarkColorMode: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_ASYNC); + if (!data.WriteBool(isDark)) { + ROSEN_LOGE("SetGlobalDarkColorMode: WriteBool isDark err."); + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast( + RSIRenderServiceConnectionInterfaceCode::SET_GLOBAL_DARK_COLOR_MODE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::GetPixelmap(NodeId id, std::shared_ptr pixelmap, + const Drawing::Rect* rect, std::shared_ptr drawCmdList, bool& success) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetPixelmap: WriteInterfaceToken GetDescriptor err."); + success = false; + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("GetPixelmap: WriteUint64 id err."); + success = false; + return ERR_INVALID_VALUE; + } + if (!data.WriteParcelable(pixelmap.get())) { + ROSEN_LOGE("GetPixelmap: WriteParcelable pixelmap.get() err."); + success = false; + return ERR_INVALID_VALUE; + } + RSMarshallingHelper::Marshalling(data, *rect); + RSMarshallingHelper::Marshalling(data, drawCmdList); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_PIXELMAP); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + success = false; + return ERR_INVALID_VALUE; + } + bool result{false}; + if (!reply.ReadBool(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetPixelmap Read result failed"); + return READ_PARCEL_ERR; + } + if (!result || !RSMarshallingHelper::Unmarshalling(reply, pixelmap)) { + RS_LOGD("RSClientToServiceConnectionProxy::GetPixelmap: GetPixelmap failed"); + success = false; + return ERR_INVALID_VALUE; + } + success = true; + return ERR_OK; +} + +int32_t RSClientToServiceConnectionProxy::GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, + std::vector& edidData) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + return RS_CONNECTION_ERROR; + } + if (!data.WriteUint64(id)) { + return WRITE_PARCEL_ERR; + } + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_DISPLAY_IDENTIFICATION_DATA); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return RS_CONNECTION_ERROR; + } + int32_t result{0}; + if (!reply.ReadInt32(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetDisplayIdentificationData Read result failed"); + return READ_PARCEL_ERR; + } + if (result != SUCCESS) { + RS_LOGE("RSClientToServiceConnectionProxy::GetDisplayIdentificationData: failed"); + return result; + } + if (!reply.ReadUint8(outPort)) { + return READ_PARCEL_ERR; + } + uint32_t edidSize = reply.ReadUint32(); + if (edidSize == 0 || edidSize > EDID_DATA_MAX_SIZE) { + RS_LOGE("RSClientToServiceConnectionProxy::GetDisplayIdentificationData: EdidSize failed"); + return READ_PARCEL_ERR; + } + edidData.resize(edidSize); + const uint8_t *editpnt = reply.ReadBuffer(edidSize); + if (editpnt == nullptr) { + RS_LOGE("RSClientToServiceConnectionProxy::GetDisplayIdentificationData: ReadBuffer failed"); + return READ_PARCEL_ERR; + } + RS_LOGD("RSClientToServiceConnectionProxy::GetDisplayIdentificationData: EdidSize: %{public}u", edidSize); + edidData.assign(editpnt, editpnt + edidSize); + + return result; +} + +ErrCode RSClientToServiceConnectionProxy::SetScreenActiveRect(ScreenId id, const Rect& activeRect, uint32_t& repCode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetScreenActiveRect: WriteInterfaceToken GetDescriptor err."); + repCode = RS_CONNECTION_ERROR; + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetScreenActiveRect: WriteUint64 id err."); + repCode = WRITE_PARCEL_ERR; + return ERR_INVALID_VALUE; + } + if (!data.WriteInt32(activeRect.x) || !data.WriteInt32(activeRect.y) || + !data.WriteInt32(activeRect.w) || !data.WriteInt32(activeRect.h)) { + ROSEN_LOGE("SetScreenActiveRect: WriteInt32 activeRect err."); + repCode = WRITE_PARCEL_ERR; + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_ACTIVE_RECT); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + repCode = RS_CONNECTION_ERROR; + return ERR_INVALID_VALUE; + } + if (!reply.ReadUint32(repCode)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetScreenActiveRect Read result failed"); + repCode = READ_PARCEL_ERR; + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +void RSClientToServiceConnectionProxy::SetScreenOffset(ScreenId id, int32_t offSetX, int32_t offSetY) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("%{public}s: WriteInterfaceToken GetDescriptor err.", __func__); + return; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(id) || !data.WriteInt32(offSetX) || !data.WriteInt32(offSetY)) { + ROSEN_LOGE("%{public}s: write error.", __func__); + return; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_OFFSET); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("%{public}s: Send Request err.", __func__); + } +} + +void RSClientToServiceConnectionProxy::SetScreenFrameGravity(ScreenId id, int32_t gravity) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("%{public}s: WriteInterfaceToken GetDescriptor err.", __func__); + return; + } + option.SetFlags(MessageOption::TF_ASYNC); + + if (!data.WriteUint64(id) || !data.WriteInt32(gravity)) { + ROSEN_LOGE("%{public}s: write error.", __func__); + return; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_SCREEN_FRAME_GRAVITY); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("%{public}s: Send Request err.", __func__); + } +} + +ErrCode RSClientToServiceConnectionProxy::AvcodecVideoStart( + uint64_t uniqueId, std::string& surfaceName, uint32_t fps, uint64_t reportTime) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("AvcodecVideoStart: WriteInterfaceToken GetDescriptor err."); + return RS_CONNECTION_ERROR; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(uniqueId)) { + ROSEN_LOGE("AvcodecVideoStart: WriteUint64 uniqueId err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteString(surfaceName)) { + ROSEN_LOGE("AvcodecVideoStart: WriteString surfaceName err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteUint32(fps)) { + ROSEN_LOGE("AvcodecVideoStart: WriteUint32 fps err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteUint64(reportTime)) { + ROSEN_LOGE("AvcodecVideoStart: WriteUint64 reportTime err."); + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::AVCODEC_VIDEO_START); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::AvcodecVideoStart: Send Request err."); + return RS_CONNECTION_ERROR; + } + int32_t result{0}; + if (!reply.ReadInt32(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::AvcodecVideoStart Read result failed"); + return READ_PARCEL_ERR; + } + return result; +} + +ErrCode RSClientToServiceConnectionProxy::AvcodecVideoStop(uint64_t uniqueId, std::string& surfaceName, uint32_t fps) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("AvcodecVideoStop: WriteInterfaceToken GetDescriptor err."); + return RS_CONNECTION_ERROR; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteUint64(uniqueId)) { + ROSEN_LOGE("AvcodecVideoStop: WriteUint64 uniqueId err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteString(surfaceName)) { + ROSEN_LOGE("AvcodecVideoStop: WriteString surfaceName err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteUint32(fps)) { + ROSEN_LOGE("AvcodecVideoStop: WriteUint32 fps err."); + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::AVCODEC_VIDEO_STOP); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::AvcodecVideoStop: Send Request err."); + return RS_CONNECTION_ERROR; + } + int32_t result{0}; + if (!reply.ReadInt32(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::AvcodecVideoStop Read result failed"); + return READ_PARCEL_ERR; + } + return result; +} + +ErrCode RSClientToServiceConnectionProxy::SetHardwareEnabled(NodeId id, bool isEnabled, + SelfDrawingNodeType selfDrawingType, bool dynamicHardwareEnable) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetHardwareEnabled: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetHardwareEnabled: WriteUint64 id err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteBool(isEnabled)) { + ROSEN_LOGE("SetHardwareEnabled: WriteBool isEnabled err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteUint8(static_cast(selfDrawingType))) { + ROSEN_LOGE("SetHardwareEnabled: WriteUint8 selfDrawingType err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteBool(dynamicHardwareEnable)) { + ROSEN_LOGE("SetHardwareEnabled: WriteBool dynamicHardwareEnable err."); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_ASYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_HARDWARE_ENABLED); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetHardwareEnabled: Send Request err."); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent, uint32_t& resCode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetHidePrivacyContent: WriteInterfaceToken GetDescriptor err."); + resCode = static_cast(RSInterfaceErrorCode::WRITE_PARCEL_ERROR); + return ERR_INVALID_VALUE; + } + if (!data.WriteUint64(id)) { + ROSEN_LOGE("SetHidePrivacyContent: WriteUint64 id err."); + resCode = static_cast(RSInterfaceErrorCode::WRITE_PARCEL_ERROR); + return ERR_INVALID_VALUE; + } + if (!data.WriteBool(needHidePrivacyContent)) { + ROSEN_LOGE("SetHidePrivacyContent: WriteBool needHidePrivacyContent err."); + resCode = static_cast(RSInterfaceErrorCode::WRITE_PARCEL_ERROR); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_HIDE_PRIVACY_CONTENT); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetHidePrivacyContent: Send Request err."); + resCode = static_cast(RSInterfaceErrorCode::UNKNOWN_ERROR); + return ERR_INVALID_VALUE; + } + resCode = reply.ReadUint32(); + return ERR_OK; +} + +void RSClientToServiceConnectionProxy::SetWindowExpectedRefreshRate( + const std::unordered_map& eventInfos +) +{ + auto mapSize = eventInfos.size(); + if (mapSize <= ZERO || mapSize > MAX_VOTER_SIZE) { + ROSEN_LOGE("SetWindowExpectedRefreshRate: map size err."); + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteInterfaceToken GetDescriptor err."); + return; + } + if (!data.WriteUint32(mapSize)) { + ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteUint32 mapSize err."); + return; + } + for (const auto& [key, eventInfo] : eventInfos) { + if (!data.WriteUint64(key)) { + ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteUint64 key err."); + return; + } + if (!eventInfo.Serialize(data)) { + ROSEN_LOGE("SetWindowExpectedRefreshRate: Write eventInfo err."); + return; + } + } + option.SetFlags(MessageOption::TF_ASYNC); + uint32_t code = + static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_WINDOW_ID); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetWindowExpectedRefreshRate: Send Request err."); + return; + } +} + +void RSClientToServiceConnectionProxy::SetWindowExpectedRefreshRate( + const std::unordered_map& eventInfos +) +{ + auto mapSize = eventInfos.size(); + if (mapSize <= ZERO || mapSize > MAX_VOTER_SIZE) { + ROSEN_LOGE("SetWindowExpectedRefreshRate: map size err."); + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteInterfaceToken GetDescriptor err."); + return; + } + if (!data.WriteUint32(mapSize)) { + ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteUint32 mapSize err."); + return; + } + for (const auto& [key, eventInfo] : eventInfos) { + if (!data.WriteString(key)) { + ROSEN_LOGE("SetWindowExpectedRefreshRate: WriteString key err."); + return; + } + if (!eventInfo.Serialize(data)) { + ROSEN_LOGE("SetWindowExpectedRefreshRate: Write eventInfo err."); + return; + } + } + option.SetFlags(MessageOption::TF_ASYNC); + uint32_t code = + static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_WINDOW_EXPECTED_BY_VSYNC_NAME); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetWindowExpectedRefreshRate: Send Request err."); + return; + } +} + +void RSClientToServiceConnectionProxy::NotifyRefreshRateEvent(const EventInfo& eventInfo) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("NotifyRefreshRateEvent: WriteInterfaceToken GetDescriptor err."); + return; + } + if (!data.WriteString(eventInfo.eventName)) { + ROSEN_LOGE("NotifyRefreshRateEvent: WriteString eventInfo.eventName err."); + return; + } + if (!data.WriteBool(eventInfo.eventStatus)) { + ROSEN_LOGE("NotifyRefreshRateEvent: WriteBool eventInfo.eventStatus err."); + return; + } + if (!data.WriteUint32(eventInfo.minRefreshRate)) { + ROSEN_LOGE("NotifyRefreshRateEvent: WriteUint32 eventInfo.minRefreshRate err."); + return; + } + if (!data.WriteUint32(eventInfo.maxRefreshRate)) { + ROSEN_LOGE("NotifyRefreshRateEvent: WriteUint32 eventInfo.maxRefreshRate err."); + return; + } + if (!data.WriteString(eventInfo.description)) { + ROSEN_LOGE("NotifyRefreshRateEvent: WriteString eventInfo.description err."); + return; + } + option.SetFlags(MessageOption::TF_ASYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_REFRESH_RATE_EVENT); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::NotifyRefreshRateEvent: Send Request err."); + return; + } +} + +ErrCode RSClientToServiceConnectionProxy::NotifySoftVsyncEvent(uint32_t pid, uint32_t rateDiscount) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("NotifySoftVsyncEvent: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteUint32(pid)) { + ROSEN_LOGE("NotifySoftVsyncEvent: WriteUint32 pid err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteUint32(rateDiscount)) { + ROSEN_LOGE("NotifySoftVsyncEvent: WriteUint32 rateDiscount err."); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_ASYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SOFT_VSYNC_EVENT); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::NotifySoftVsyncEvent: Send Request err."); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("NotifyTouchEvent: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteInt32(touchStatus)) { + ROSEN_LOGE("NotifyTouchEvent: WriteInt32 touchStatus err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteInt32(touchCnt)) { + ROSEN_LOGE("NotifyTouchEvent: WriteInt32 touchCnt err."); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_ASYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_TOUCH_EVENT); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::NotifyTouchEvent: Send Request err."); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +void RSClientToServiceConnectionProxy::NotifyDynamicModeEvent(bool enableDynamicMode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("NotifyDynamicModeEvent: WriteInterfaceToken GetDescriptor err."); + return; + } + if (!data.WriteBool(enableDynamicMode)) { + ROSEN_LOGE("NotifyDynamicModeEvent: WriteBool enableDynamicMode err."); + return; + } + option.SetFlags(MessageOption::TF_ASYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_DYNAMIC_MODE_EVENT); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::NotifyDynamicModeEvent: Send Request err."); + return; + } +} + +ErrCode RSClientToServiceConnectionProxy::NotifyXComponentExpectedFrameRate( + const std::string& id, int32_t expectedFrameRate) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("NotifyXComponentExpectedFrameRate: GetDescriptor err."); + return ERR_INVALID_VALUE; + } + if (!data.WriteString(id)) { + return ERR_INVALID_VALUE; + } + if (!data.WriteInt32(expectedFrameRate)) { + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_ASYNC); + uint32_t code = static_cast( + RSIRenderServiceConnectionInterfaceCode::NOTIFY_XCOMPONENT_EXPECTED_FRAMERATE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::NotifyXComponentExpectedFrameRate: Send Request err."); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +LayerComposeInfo RSClientToServiceConnectionProxy::GetLayerComposeInfo() +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + LayerComposeInfo layerComposeInfo; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetLayerComposeInfo: WriteInterfaceToken GetDescriptor err."); + return layerComposeInfo; + } + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::GET_LAYER_COMPOSE_INFO); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetLayerComposeInfo: Send Request err."); + return layerComposeInfo; + } + int32_t uniformRenderFrameNumber{0}; + int32_t offlineComposeFrameNumber{0}; + int32_t redrawFrameNumber{0}; + if (!reply.ReadInt32(uniformRenderFrameNumber) || !reply.ReadInt32(offlineComposeFrameNumber) || + !reply.ReadInt32(redrawFrameNumber)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetLayerComposeInfo Read parcel failed"); + return layerComposeInfo; + } + return LayerComposeInfo(uniformRenderFrameNumber, offlineComposeFrameNumber, redrawFrameNumber); +} + +HwcDisabledReasonInfos RSClientToServiceConnectionProxy::GetHwcDisabledReasonInfo() +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + HwcDisabledReasonInfos hwcDisabledReasonInfos; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("GetHwcDisabledReasonInfo: WriteInterfaceToken GetDescriptor err."); + return hwcDisabledReasonInfos; + } + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode:: + GET_HARDWARE_COMPOSE_DISABLED_REASON_INFO); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetHwcDisabledReasonInfo: Send Request err."); + return hwcDisabledReasonInfos; + } + int32_t size{0}; + if (!reply.ReadInt32(size)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::GetHwcDisabledReasonInfo Read size failed"); + return hwcDisabledReasonInfos; + } + size_t readableSize = reply.GetReadableBytes() / HWC_DISABLED_REASON_INFO_MINIMUM_SIZE; + size_t len = static_cast(size); + if (len > readableSize || len > hwcDisabledReasonInfos.max_size()) { + RS_LOGE("RSClientToServiceConnectionProxy GetHwcDisabledReasonInfo Failed read vector, size:%{public}zu," + " readableSize:%{public}zu", len, readableSize); + return hwcDisabledReasonInfos; + } + + HwcDisabledReasonInfo hwcDisabledReasonInfo; + while (size--) { + for (int32_t pos = 0; pos < HwcDisabledReasons::DISABLED_REASON_LENGTH; pos++) { + hwcDisabledReasonInfo.disabledReasonStatistics[pos] = reply.ReadInt32(); + } + hwcDisabledReasonInfo.pidOfBelongsApp = reply.ReadInt32(); + hwcDisabledReasonInfo.nodeName = reply.ReadString(); + hwcDisabledReasonInfos.emplace_back(hwcDisabledReasonInfo); + } + return hwcDisabledReasonInfos; +} + +#ifdef TP_FEATURE_ENABLE +EErrCode RSClientToServiceConnectionProxy::SetTpFeatureConfig(int32_t feature, const char* config, + TpFeatureConfigType tpFeatureConfigType) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("SetTpFeatureConfig: WriteInterfaceToken GetDescriptor err."); + return ERR_INVALID_VALUE; + } + + if (!data.WriteInt32(feature)) { + ROSEN_LOGE("SetTpFeatureConfig: WriteInt32 feature err."); + return ERR_INVALID_VALUE; + } + + if (!data.WriteCString(config)) { + ROSEN_LOGE("SetTpFeatureConfig: WriteCString config err."); + return ERR_INVALID_VALUE; + } + + if (!data.WriteUint8(static_cast(tpFeatureConfigType))) { + ROSEN_LOGE("SetTpFeatureConfig: WriteUint8 tpFeatureConfigType err."); + return ERR_INVALID_VALUE; + } + + option.SetFlags(MessageOption::TF_SYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_TP_FEATURE_CONFIG); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + return ERR_INVALID_VALUE; + } + return ERR_OK; +} +#endif + +void RSClientToServiceConnectionProxy::RegisterTransactionDataCallback(uint64_t token, + uint64_t timeStamp, sptr callback) +{ + if (callback == nullptr) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::RegisterTransactionDataCallback callback == nullptr."); + return; + } + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::RegisterTransactionDataCallback: write token err."); + return; + } + option.SetFlags(MessageOption::TF_ASYNC); + static_assert(std::is_same_v, "pid_t is not int32_t on this platform."); + if (!data.WriteUint64(token)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::RegisterTransactionDataCallback: write multi token val err."); + return; + } + if (!data.WriteUint64(timeStamp)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::RegisterTransactionDataCallback: write timeStamp val err."); + return; + } + if (!data.WriteRemoteObject(callback->AsObject())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::RegisterTransactionDataCallback: write Callback val err."); + return; + } + uint32_t code = static_cast( + RSIRenderServiceConnectionInterfaceCode::REGISTER_TRANSACTION_DATA_CALLBACK); + RS_LOGD("RSClientToServiceConnectionProxy::RegisterTransactionDataCallback: timeStamp: %{public}" + PRIu64 " token: %{public}" PRIu64, timeStamp, token); + int32_t err = Remote()->SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::RegisterTransactionDataCallback: Send Request err."); + return; + } +} + +ErrCode RSClientToServiceConnectionProxy::SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetLayerTopForHWC: write token err."); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_ASYNC); + if (data.WriteUint64(nodeId) && data.WriteBool(isTop) && data.WriteUint32(zOrder)) { + uint32_t code = + static_cast(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP_FOR_HARDWARE_COMPOSER); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetLayerTopForHWC: Send Request err."); + return ERR_INVALID_VALUE; + } + } + return ERR_OK; +} + +ErrCode RSClientToServiceConnectionProxy::SetLayerTop(const std::string &nodeIdStr, bool isTop) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetLayerTop: write token err."); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_ASYNC); + if (data.WriteString(nodeIdStr) && data.WriteBool(isTop)) { + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_LAYER_TOP); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetLayerTop: Send Request err."); + return ERR_INVALID_VALUE; + } + } + return ERR_OK; +} + +int32_t RSClientToServiceConnectionProxy::RegisterSelfDrawingNodeRectChangeCallback( + const RectConstraint& constraint, sptr callback) +{ + if (!callback) { + ROSEN_LOGE("%{public}s callback is nullptr", __func__); + return ERR_INVALID_VALUE; + } + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: WriteInterfaceToken GetDescriptor err."); + return WRITE_PARCEL_ERR; + } + option.SetFlags(MessageOption::TF_SYNC); + + uint32_t size = constraint.pids.size(); + if (!data.WriteUint32(size)) { + ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Write size err."); + return WRITE_PARCEL_ERR; + } + for (int32_t pid : constraint.pids) { + if (!data.WriteInt32(pid)) { + ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Write pid err."); + return WRITE_PARCEL_ERR; + } + } + + if (!data.WriteInt32(constraint.range.lowLimit.width) || !data.WriteInt32(constraint.range.lowLimit.height) || + !data.WriteInt32(constraint.range.highLimit.width) || !data.WriteInt32(constraint.range.highLimit.height)) { + ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Write rectRange err."); + return WRITE_PARCEL_ERR; + } + if (!data.WriteRemoteObject(callback->AsObject())) { + ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: WriteRemoteObject callback->AsObject() err."); + return WRITE_PARCEL_ERR; + } + uint32_t code = + static_cast(RSIRenderServiceConnectionInterfaceCode::REGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RegisterSelfDrawingNodeRectChangeCallback: Send request err."); + return RS_CONNECTION_ERROR; + } + int32_t result{0}; + if (!reply.ReadInt32(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::RegisterSelfDrawingNodeRectChangeCallback Read result failed"); + return READ_PARCEL_ERR; + } + return result; +} + +int32_t RSClientToServiceConnectionProxy::UnRegisterSelfDrawingNodeRectChangeCallback() +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("UnRegisterSelfDrawingNodeRectChangeCallback: WriteInterfaceToken GetDescriptor err."); + return WRITE_PARCEL_ERR; + } + option.SetFlags(MessageOption::TF_SYNC); + + uint32_t code = static_cast( + RSIRenderServiceConnectionInterfaceCode::UNREGISTER_SELF_DRAWING_NODE_RECT_CHANGE_CALLBACK); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("UnRegisterSelfDrawingNodeRectChangeCallback: Send request err."); + return RS_CONNECTION_ERROR; + } + int32_t result{0}; + if (!reply.ReadInt32(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::UnRegisterSelfDrawingNodeRectChangeCallback Read result failed"); + return READ_PARCEL_ERR; + } + return result; +} + +int32_t RSClientToServiceConnectionProxy::SendRequest(uint32_t code, MessageParcel &data, + MessageParcel &reply, MessageOption &option) +{ + if (!Remote()) { + return static_cast(RSInterfaceErrorCode::NULLPTR_ERROR); + } + return Remote()->SendRequest(code, data, reply, option); +} + +ErrCode RSClientToServiceConnectionProxy::NotifyScreenSwitched() +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("%{public}s: Write InterfaceToken val err.", __func__); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_ASYNC); + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_SCREEN_SWITCHED); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("%{public}s: Send Request error.", __func__); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +#ifdef RS_ENABLE_OVERLAY_DISPLAY +ErrCode RSClientToServiceConnectionProxy::SetOverlayDisplayMode(int32_t mode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("%{public}s: Write InterfaceToken val err.", __func__); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_SYNC); + if (!data.WriteInt32(mode)) { + ROSEN_LOGE("%{public}s: Write Int32 val err.", __func__); + return ERR_INVALID_VALUE; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::SET_OVERLAY_DISPLAY_MODE); + int32_t err = Remote()->SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("%{public}s: SendRequest failed. err:%{public}d.", __func__, err); + return ERR_INVALID_VALUE; + } + int32_t result{0}; + if (!reply.ReadInt32(result)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::SetOverlayDisplayMode Read result failed"); + return READ_PARCEL_ERR; + } + ROSEN_LOGI("%{public}s: mode:%{public}d, result:%{public}d.", __func__, mode, result); + return result == 0 ? ERR_OK : ERR_INVALID_VALUE; +} +#endif + +ErrCode RSClientToServiceConnectionProxy::NotifyPageName(const std::string &packageName, + const std::string &pageName, bool isEnter) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::NotifyPageName: write token err."); + return ERR_INVALID_VALUE; + } + option.SetFlags(MessageOption::TF_ASYNC); + if (data.WriteString(packageName) && data.WriteString(pageName) && data.WriteBool(isEnter)) { + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::NOTIFY_PAGE_NAME); + int32_t err = Remote()->SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::NotifyPageName: Send Request err."); + return ERR_INVALID_VALUE; + } + } else { + ROSEN_LOGE("RSClientToServiceConnectionProxy::NotifyPageName: write data err."); + return ERR_INVALID_VALUE; + } + return ERR_OK; +} + +RetCodeHrpService RSClientToServiceConnectionProxy::ProfilerServiceOpenFile(const HrpServiceDirInfo& dirInfo, + const std::string& fileName, int32_t flags, int& outFd) +{ + const uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::PROFILER_SERVICE_OPEN_FILE); + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::ProfilerServiceOpenFile WriteInterfaceToken err."); + return RET_HRP_SERVICE_ERR_UNKNOWN; + } + option.SetFlags(MessageOption::TF_SYNC); + data.WriteUint32((uint32_t)dirInfo.baseDirType); + data.WriteString(dirInfo.subDir); + data.WriteString(dirInfo.subDir2); + data.WriteString(fileName); + data.WriteInt32(flags); + + int32_t err = SendRequest(code, data, reply, option); + if (err != ERR_NONE) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::ProfilerServiceOpenFile sendrequest error : %{public}d", err); + return RET_HRP_SERVICE_ERR_PROXY_SEND_REQUEST; + } + + int32_t retCode = RET_HRP_SERVICE_ERR_UNKNOWN; + if (!reply.ReadInt32(retCode)) { + return RET_HRP_SERVICE_ERR_PROXY_INVALID_RESULT; + } + + int retFd = reply.ReadFileDescriptor(); + if (retFd == -1) { + return retCode < 0 ? (RetCodeHrpService)retCode : RET_HRP_SERVICE_ERR_INVALID_FILE_DESCRIPTOR; + } + + outFd = retFd; + return (RetCodeHrpService)retCode; +} + +RetCodeHrpService RSClientToServiceConnectionProxy::ProfilerServicePopulateFiles(const HrpServiceDirInfo& dirInfo, + uint32_t firstFileIndex, std::vector& outFiles) +{ + const uint32_t code = + static_cast(RSIRenderServiceConnectionInterfaceCode::PROFILER_SERVICE_POPULATE_FILES); + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::ProfilerServicePopulateFiles WriteInterfaceToken err."); + return RET_HRP_SERVICE_ERR_UNKNOWN; + } + option.SetFlags(MessageOption::TF_SYNC); + data.WriteUint32((uint32_t)dirInfo.baseDirType); + data.WriteString(dirInfo.subDir); + data.WriteString(dirInfo.subDir2); + data.WriteUint32(firstFileIndex); + + int32_t err = SendRequest(code, data, reply, option); + if (err != ERR_NONE) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::ProfilerServicePopulateFiles sendrequest error : %{public}d", err); + return RET_HRP_SERVICE_ERR_PROXY_SEND_REQUEST; + } + + int32_t retCode = RET_HRP_SERVICE_ERR_UNKNOWN; + if (!reply.ReadInt32(retCode)) { + return RET_HRP_SERVICE_ERR_PROXY_INVALID_RESULT; + } + if (retCode < RET_HRP_SERVICE_SUCCESS) { + return (RetCodeHrpService)retCode; + } + + uint32_t retCount = 0; + if (!reply.ReadUint32(retCount)) { + return RET_HRP_SERVICE_ERR_PROXY_INVALID_RESULT; + } + + std::vector retFiles; + for (uint32_t i = 0; i < retCount; i++) { + HrpServiceFileInfo fi {}; + if (!reply.ReadString(fi.name) || !reply.ReadUint32(fi.size) || !reply.ReadBool(fi.isDir) || + !reply.ReadUint32(fi.accessBits) || !reply.ReadUint64(fi.accessTime.sec) || + !reply.ReadUint64(fi.accessTime.nsec) || !reply.ReadUint64(fi.modifyTime.sec) || + !reply.ReadUint64(fi.modifyTime.nsec)) { + return RET_HRP_SERVICE_ERR_PROXY_INVALID_RESULT_DATA; + } + retFiles.emplace_back(fi); + } + outFiles.swap(retFiles); + return (RetCodeHrpService)retCode; +} + +bool RSClientToServiceConnectionProxy::ProfilerIsSecureScreen() +{ + const uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::PROFILER_IS_SECURE_SCREEN); + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::ProfilerIsSecureScreen WriteInterfaceToken err."); + return false; + } + option.SetFlags(MessageOption::TF_SYNC); + int32_t err = SendRequest(code, data, reply, option); + if (err != ERR_NONE) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::ProfilerIsSecureScreen sendrequest error : %{public}d", err); + return false; + } + + bool retValue = false; + if (!reply.ReadBool(retValue)) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::ProfilerIsSecureScreen ReadBool err."); + return false; + } + return retValue; +} + +void RSClientToServiceConnectionProxy::ClearUifirstCache(NodeId id) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(RSIClientToServiceConnection::GetDescriptor())) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::ClearUifirstCache: write token err."); + return; + } + option.SetFlags(MessageOption::TF_ASYNC); + if (!data.WriteUint64(id)) { + ROSEN_LOGE("ClearUifirstCache: WriteUint64 id err."); + return; + } + uint32_t code = static_cast(RSIRenderServiceConnectionInterfaceCode::CLEAR_UIFIRST_CACHE); + int32_t err = SendRequest(code, data, reply, option); + if (err != NO_ERROR) { + ROSEN_LOGE("RSClientToServiceConnectionProxy::ClearUifirstCache sendrequest error : %{public}d", err); + return; + } +} +} // namespace Rosen +} // namespace OHOS diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_client_to_service_connection_proxy.h b/rosen/modules/render_service_base/src/platform/ohos/rs_client_to_service_connection_proxy.h new file mode 100644 index 0000000000000000000000000000000000000000..4ab33ba7384073c6391a467bc5e58fbfc3be0a89 --- /dev/null +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_client_to_service_connection_proxy.h @@ -0,0 +1,244 @@ +/* + * Copyright (c) 2021-2023 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. + */ + +#ifndef ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_CLIENT_TO_SERVICE_CONNECTION_PROXY_H +#define ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_CLIENT_TO_SERVICE_CONNECTION_PROXY_H + +#include "command/rs_node_showing_command.h" +#include +#include +#include +#include +#include "sandbox_utils.h" + +namespace OHOS { +namespace Rosen { +class RSClientToServiceConnectionProxy : public IRemoteProxy { +public: + explicit RSClientToServiceConnectionProxy(const sptr& impl); + virtual ~RSClientToServiceConnectionProxy() noexcept = default; + + ErrCode CommitTransaction(std::unique_ptr& transactionData) override; + ErrCode ExecuteSynchronousTask(const std::shared_ptr& task) override; + + ErrCode GetMemoryGraphic(int pid, MemoryGraphic& memoryGraphic) override; + ErrCode GetMemoryGraphics(std::vector& memoryGraphics) override; + ErrCode GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize) override; + + ErrCode GetUniRenderEnabled(bool& enable) override; + + ErrCode CreateNode(const RSSurfaceRenderNodeConfig& configg, bool& success) override; + ErrCode CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeIdg, bool& success) override; + ErrCode CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, sptr& sfc, + bool unobscured = false) override; + + virtual ErrCode CreateVSyncConnection(sptr& vsyncConn, + const std::string& name, + const sptr& token, + VSyncConnParam vsyncConnParam = {0, 0, false}) override; + + ErrCode GetDefaultScreenId(uint64_t& screenId) override; + ErrCode GetActiveScreenId(uint64_t& screenId) override; + + std::vector GetAllScreenIds() override; + + // mirrorId: decide which screen id to mirror, INVALID_SCREEN_ID means do not mirror any screen. + ScreenId CreateVirtualScreen( + const std::string &name, + uint32_t width, + uint32_t height, + sptr surface, + ScreenId mirrorId = 0, + int32_t flags = 0, + std::vector whiteList = {}) override; + + int32_t SetVirtualScreenSurface(ScreenId id, sptr surface) override; + + void RemoveVirtualScreen(ScreenId id) override; + + int32_t SetScreenChangeCallback(sptr callback) override; + + void SetScreenActiveMode(ScreenId id, uint32_t modeId) override; + + void SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate) override; + + void SetRefreshRateMode(int32_t refreshRateMode) override; + + void UnregisterFrameRateLinker(FrameRateLinkerId id) override; + + uint32_t GetScreenCurrentRefreshRate(ScreenId id) override; + + int32_t GetCurrentRefreshRateMode() override; + + std::vector GetScreenSupportedRefreshRates(ScreenId id) override; + + ErrCode GetShowRefreshRateEnabled(bool& enable) override; + + void SetShowRefreshRateEnabled(bool enabled, int32_t type) override; + + uint32_t GetRealtimeRefreshRate(ScreenId id) override; + + ErrCode GetRefreshInfo(pid_t pid, std::string& enable) override; + ErrCode GetRefreshInfoToSP(NodeId id, std::string& enable) override; + + int32_t SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height) override; + + int32_t SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) override; + + ErrCode RepaintEverything() override; + + void SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status) override; + + ErrCode RegisterApplicationAgent(uint32_t pid, sptr app) override; + + bool WriteSurfaceCaptureConfig(const RSSurfaceCaptureConfig& captureConfig, MessageParcel& data); + + bool WriteSurfaceCaptureBlurParam(const RSSurfaceCaptureBlurParam& blurParam, MessageParcel& data); + + bool WriteSurfaceCaptureAreaRect(const Drawing::Rect& specifiedAreaRect, MessageParcel& data); + + ErrCode GetScreenActiveMode(uint64_t id, RSScreenModeInfo& screenModeInfo) override; + + std::vector GetScreenSupportedModes(ScreenId id) override; + + RSScreenCapability GetScreenCapability(ScreenId id) override; + + ErrCode GetScreenPowerStatus(uint64_t screenId, uint32_t& status) override; + + RSScreenData GetScreenData(ScreenId id) override; + + ErrCode GetScreenBacklight(uint64_t id, int32_t& level) override; + + void SetScreenBacklight(ScreenId id, uint32_t level) override; + + ErrCode RegisterBufferAvailableListener( + NodeId id, sptr callback, bool isFromRenderThread) override; + + ErrCode RegisterBufferClearListener( + NodeId id, sptr callback) override; + + int32_t GetScreenSupportedColorGamuts(ScreenId id, std::vector& mode) override; + + int32_t GetScreenSupportedMetaDataKeys(ScreenId id, std::vector& keys) override; + + int32_t GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode) override; + + int32_t SetScreenColorGamut(ScreenId id, int32_t modeIdx) override; + + int32_t SetScreenGamutMap(ScreenId id, ScreenGamutMap mode) override; + + int32_t SetScreenCorrection(ScreenId id, ScreenRotation screenRotation) override; + + ErrCode SetGlobalDarkColorMode(bool isDark) override; + + int32_t GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode) override; + + ErrCode GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus, int32_t& resCode) override; + + ErrCode GetScreenSupportedColorSpaces( + ScreenId id, std::vector& colorSpaces, int32_t& resCode) override; + + ErrCode GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace, int32_t& resCode) override; + + ErrCode SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace, int32_t& resCode) override; + + int32_t GetScreenType(ScreenId id, RSScreenType& screenType) override; + + ErrCode GetBitmap(NodeId id, Drawing::Bitmap& bitmap, bool& success) override; + ErrCode GetPixelmap(NodeId id, std::shared_ptr pixelmap, + const Drawing::Rect* rect, std::shared_ptr drawCmdList, bool& success) override; + + int32_t GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, std::vector& edidData) override; + + ErrCode SetScreenActiveRect(ScreenId id, const Rect& activeRect, uint32_t& repCode) override; + + void SetScreenOffset(ScreenId id, int32_t offSetX, int32_t offSetY) override; + + void SetScreenFrameGravity(ScreenId id, int32_t gravity) override; + + ErrCode AvcodecVideoStart(uint64_t uniqueId, std::string& surfaceName, uint32_t fps, uint64_t reportTime) override; + + ErrCode AvcodecVideoStop(uint64_t uniqueId, std::string& surfaceName, uint32_t fps) override; + + void NotifyRefreshRateEvent(const EventInfo& eventInfo) override; + + void SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) override; + + void SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) override; + + ErrCode NotifySoftVsyncEvent(uint32_t pid, uint32_t rateDiscount) override; + + ErrCode NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt) override; + + void NotifyDynamicModeEvent(bool enableDynamicMode) override; + + ErrCode NotifyXComponentExpectedFrameRate(const std::string& id, int32_t expectedFrameRate) override; + + ErrCode SetHardwareEnabled(NodeId id, bool isEnabled, SelfDrawingNodeType selfDrawingType, + bool dynamicHardwareEnable) override; + + ErrCode SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent, uint32_t& resCode) override; + + LayerComposeInfo GetLayerComposeInfo() override; + + HwcDisabledReasonInfos GetHwcDisabledReasonInfo() override; + +#ifdef TP_FEATURE_ENABLE + ErrCode SetTpFeatureConfig(int32_t feature, const char* config, + TpFeatureConfigType tpFeatureConfigType = TpFeatureConfigType::DEFAULT_TP_FEATURE) override; +#endif + + void RegisterTransactionDataCallback(uint64_t token, + uint64_t timeStamp, sptr callback) override; + + ErrCode NotifyScreenSwitched() override; + + int32_t RegisterSelfDrawingNodeRectChangeCallback( + const RectConstraint& constraint, sptr callback) override; + + int32_t UnRegisterSelfDrawingNodeRectChangeCallback() override; + + ErrCode NotifyPageName(const std::string &packageName, const std::string &pageName, bool isEnter) override; + + RetCodeHrpService ProfilerServiceOpenFile(const HrpServiceDirInfo& dirInfo, + const std::string& fileName, int32_t flags, int& outFd) override; + RetCodeHrpService ProfilerServicePopulateFiles(const HrpServiceDirInfo& dirInfo, + uint32_t firstFileIndex, std::vector& outFiles) override; + bool ProfilerIsSecureScreen() override; + + void ClearUifirstCache(NodeId id) override; +private: + bool FillParcelWithTransactionData( + std::unique_ptr& transactionData, std::shared_ptr& data); + + int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); + + ErrCode SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder) override; + + ErrCode SetLayerTop(const std::string &nodeIdStr, bool isTop) override; + +#ifdef RS_ENABLE_OVERLAY_DISPLAY + ErrCode SetOverlayDisplayMode(int32_t mode) override; +#endif + + static inline BrokerDelegator delegator_; + + pid_t pid_ = GetRealPid(); + uint32_t transactionDataIndex_ = 0; +}; +} // namespace Rosen +} // namespace OHOS + +#endif // ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_CLIENT_TO_SERVICE_CONNECTION_PROXY_H diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp index b85c726723b56fb4a464aa1123f3cf0310a307ee..0b73192d645cbce960b0d3d3bb16d5f95a64a5d3 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_client.cpp @@ -64,11 +64,11 @@ std::shared_ptr RSIRenderClient::CreateRenderServiceClient() void RSRenderServiceClient::CommitTransaction(std::unique_ptr& transactionData) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->CommitTransaction(transactionData); + auto clientToService = GetClientToServiceConnection(); + if (clientToService != nullptr) { + clientToService->CommitTransaction(transactionData); } else { - RS_LOGE_LIMIT(__func__, __line__, "RSRenderServiceClient::CommitTransaction failed, renderService is nullptr"); + RS_LOGE_LIMIT(__func__, __line__, "RSRenderServiceClient::CommitTransaction failed, clientToService is nullptr"); } } @@ -78,85 +78,85 @@ void RSRenderServiceClient::ExecuteSynchronousTask(const std::shared_ptrExecuteSynchronousTask(task); + auto clientToService = GetClientToServiceConnection(); + if (clientToService != nullptr) { + clientToService->ExecuteSynchronousTask(task); } } bool RSRenderServiceClient::GetUniRenderEnabled() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return false; } bool enable; - return renderService->GetUniRenderEnabled(enable) == ERR_OK && enable; + return clientToService->GetUniRenderEnabled(enable) == ERR_OK && enable; } MemoryGraphic RSRenderServiceClient::GetMemoryGraphic(int pid) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return MemoryGraphic {}; } MemoryGraphic memoryGraphic; - renderService->GetMemoryGraphic(pid, memoryGraphic); + clientToService->GetMemoryGraphic(pid, memoryGraphic); return memoryGraphic; } std::vector RSRenderServiceClient::GetMemoryGraphics() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return {}; } std::vector memoryGraphics; - renderService->GetMemoryGraphics(memoryGraphics); + clientToService->GetMemoryGraphics(memoryGraphics); return memoryGraphics; } bool RSRenderServiceClient::GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return false; } - return renderService->GetTotalAppMemSize(cpuMemSize, gpuMemSize) == ERR_OK; + return clientToService->GetTotalAppMemSize(cpuMemSize, gpuMemSize) == ERR_OK; } bool RSRenderServiceClient::CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return false; } bool success; - renderService->CreateNode(displayNodeConfig, nodeId, success); + clientToService->CreateNode(displayNodeConfig, nodeId, success); return success; } bool RSRenderServiceClient::CreateNode(const RSSurfaceRenderNodeConfig& config) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return false; } bool success; - renderService->CreateNode(config, success); + clientToService->CreateNode(config, success); return success; } std::shared_ptr RSRenderServiceClient::CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config, bool unobscured) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return nullptr; } sptr surface = nullptr; - ErrCode err = renderService->CreateNodeAndSurface(config, surface, unobscured); + ErrCode err = clientToService->CreateNodeAndSurface(config, surface, unobscured); if ((err != ERR_OK) || (surface == nullptr)) { ROSEN_LOGE("RSRenderServiceClient::CreateNodeAndSurface surface is nullptr."); return nullptr; @@ -195,14 +195,14 @@ std::shared_ptr RSRenderServiceClient::CreateVSyncReceiver( bool fromXcomponent) { ROSEN_LOGD("RSRenderServiceClient::CreateVSyncReceiver Start"); - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return nullptr; } sptr token = new IRemoteStub(); sptr conn = nullptr; VSyncConnParam vsyncConnParam = {id, windowNodeId, fromXcomponent}; - renderService->CreateVSyncConnection(conn, name, token, vsyncConnParam); + clientToService->CreateVSyncConnection(conn, name, token, vsyncConnParam); if (conn == nullptr) { ROSEN_LOGE("RSRenderServiceClient::CreateVSyncReceiver Failed"); return nullptr; @@ -212,20 +212,20 @@ std::shared_ptr RSRenderServiceClient::CreateVSyncReceiver( int32_t RSRenderServiceClient::GetPixelMapByProcessId(std::vector& pixelMapInfoVector, pid_t pid) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } int32_t repCode; - renderService->GetPixelMapByProcessId(pixelMapInfoVector, pid, repCode); + clientToService->GetPixelMapByProcessId(pixelMapInfoVector, pid, repCode); //TODO return repCode; } std::shared_ptr RSRenderServiceClient::CreatePixelMapFromSurfaceId(uint64_t surfaceId, const Rect &srcRect) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return nullptr; } sptr surface = SurfaceUtils::GetInstance()->GetSurface(surfaceId); @@ -233,7 +233,7 @@ std::shared_ptr RSRenderServiceClient::CreatePixelMapFromSurfac return nullptr; } std::shared_ptr pixelMap = nullptr; - return renderService->CreatePixelMapFromSurface(surface, srcRect, pixelMap) == ERR_OK ? pixelMap : nullptr; + return clientToRender->CreatePixelMapFromSurface(surface, srcRect, pixelMap) == ERR_OK ? pixelMap : nullptr; } void RSRenderServiceClient::TriggerSurfaceCaptureCallback(NodeId id, const RSSurfaceCaptureConfig& captureConfig, @@ -307,9 +307,9 @@ bool RSRenderServiceClient::TakeSurfaceCapture(NodeId id, std::shared_ptrTakeSurfaceCapture(id, surfaceCaptureCbDirector_, captureConfig, blurParam, specifiedAreaRect); + clientToRender->TakeSurfaceCapture(id, surfaceCaptureCbDirector_, captureConfig, blurParam, specifiedAreaRect); return true; } std::vector>> RSRenderServiceClient::TakeSurfaceCaptureSoloNode( NodeId id, const RSSurfaceCaptureConfig& captureConfig) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); + auto clientToRender = GetClientToRenderConnection(); std::vector>> pixelMapIdPairVector; - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::TakeSurfaceCaptureSoloNode renderService == nullptr!"); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::TakeSurfaceCaptureSoloNode clientToRender == nullptr!"); return pixelMapIdPairVector; } - pixelMapIdPairVector = renderService->TakeSurfaceCaptureSoloNode(id, captureConfig); + pixelMapIdPairVector = clientToRender->TakeSurfaceCaptureSoloNode(id, captureConfig); return pixelMapIdPairVector; } bool RSRenderServiceClient::TakeSelfSurfaceCapture(NodeId id, std::shared_ptr callback, const RSSurfaceCaptureConfig& captureConfig) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::TakeSelfSurfaceCapture renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::TakeSelfSurfaceCapture clientToRender == nullptr!"); return false; } if (callback == nullptr) { @@ -375,7 +375,7 @@ bool RSRenderServiceClient::TakeSelfSurfaceCapture(NodeId id, std::shared_ptrTakeSelfSurfaceCapture(id, surfaceCaptureCbDirector_, captureConfig); + clientToRender->TakeSelfSurfaceCapture(id, surfaceCaptureCbDirector_, captureConfig); return true; } @@ -383,13 +383,13 @@ bool RSRenderServiceClient::SetWindowFreezeImmediately(NodeId id, bool isFreeze, std::shared_ptr callback, const RSSurfaceCaptureConfig& captureConfig, const RSSurfaceCaptureBlurParam& blurParam) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::SetWindowFreezeImmediately renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::SetWindowFreezeImmediately clientToRender == nullptr!"); return false; } if (!isFreeze) { - renderService->SetWindowFreezeImmediately(id, isFreeze, nullptr, captureConfig, blurParam); + clientToRender->SetWindowFreezeImmediately(id, isFreeze, nullptr, captureConfig, blurParam); return true; } if (callback == nullptr) { @@ -411,16 +411,16 @@ bool RSRenderServiceClient::SetWindowFreezeImmediately(NodeId id, bool isFreeze, if (surfaceCaptureCbDirector_ == nullptr) { surfaceCaptureCbDirector_ = new SurfaceCaptureCallbackDirector(this); } - renderService->SetWindowFreezeImmediately(id, isFreeze, surfaceCaptureCbDirector_, captureConfig, blurParam); + clientToRender->SetWindowFreezeImmediately(id, isFreeze, surfaceCaptureCbDirector_, captureConfig, blurParam); return true; } bool RSRenderServiceClient::TakeUICaptureInRange( NodeId id, std::shared_ptr callback, const RSSurfaceCaptureConfig& captureConfig) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::TakeUICaptureInRange renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::TakeUICaptureInRange clientToRender == nullptr!"); return false; } if (callback == nullptr) { @@ -443,65 +443,65 @@ bool RSRenderServiceClient::TakeUICaptureInRange( if (surfaceCaptureCbDirector_ == nullptr) { surfaceCaptureCbDirector_ = new SurfaceCaptureCallbackDirector(this); } - renderService->TakeUICaptureInRange(id, surfaceCaptureCbDirector_, captureConfig); + clientToRender->TakeUICaptureInRange(id, surfaceCaptureCbDirector_, captureConfig); return true; } bool RSRenderServiceClient::SetHwcNodeBounds(int64_t rsNodeId, float positionX, float positionY, float positionZ, float positionW) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - RS_LOGE("RSRenderServiceClient::SetHwcNodeBounds renderService is null!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + RS_LOGE("RSRenderServiceClient::SetHwcNodeBounds clientToRender is null!"); return false; } - renderService->SetHwcNodeBounds(rsNodeId, positionX, positionY, positionZ, positionW); + clientToRender->SetHwcNodeBounds(rsNodeId, positionX, positionY, positionZ, positionW); return true; } int32_t RSRenderServiceClient::SetFocusAppInfo(const FocusAppInfo& info) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } int32_t repCode; - renderService->SetFocusAppInfo(info, repCode); + clientToRender->SetFocusAppInfo(info, repCode); return repCode; } ScreenId RSRenderServiceClient::GetDefaultScreenId() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return INVALID_SCREEN_ID; } ScreenId screenId{INVALID_SCREEN_ID}; - renderService->GetDefaultScreenId(screenId); + clientToService->GetDefaultScreenId(screenId); return screenId; } ScreenId RSRenderServiceClient::GetActiveScreenId() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return INVALID_SCREEN_ID; } ScreenId screenId{INVALID_SCREEN_ID}; - renderService->GetActiveScreenId(screenId); + clientToService->GetActiveScreenId(screenId); return screenId; } std::vector RSRenderServiceClient::GetAllScreenIds() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return std::vector(); } - return renderService->GetAllScreenIds(); + return clientToService->GetAllScreenIds(); } ScreenId RSRenderServiceClient::CreateVirtualScreen( @@ -513,69 +513,69 @@ ScreenId RSRenderServiceClient::CreateVirtualScreen( int32_t flags, std::vector whiteList) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - RS_LOGE("RSRenderServiceClient::%{public}s renderService is null!", __func__); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + RS_LOGE("RSRenderServiceClient::%{public}s clientToService is null!", __func__); return INVALID_SCREEN_ID; } - return renderService->CreateVirtualScreen(name, width, height, surface, mirrorId, flags, whiteList); + return clientToService->CreateVirtualScreen(name, width, height, surface, mirrorId, flags, whiteList); } int32_t RSRenderServiceClient::SetVirtualScreenBlackList(ScreenId id, std::vector& blackListVector) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - RS_LOGE("RSRenderServiceClient::%{public}s renderService is null!", __func__); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + RS_LOGE("RSRenderServiceClient::%{public}s clientToRender is null!", __func__); return RENDER_SERVICE_NULL; } - return renderService->SetVirtualScreenBlackList(id, blackListVector); + return clientToRender->SetVirtualScreenBlackList(id, blackListVector); } int32_t RSRenderServiceClient::SetVirtualScreenTypeBlackList(ScreenId id, std::vector& typeBlackListVector) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } int32_t repCode; - renderService->SetVirtualScreenTypeBlackList(id, typeBlackListVector, repCode); + clientToRender->SetVirtualScreenTypeBlackList(id, typeBlackListVector, repCode); return repCode; } int32_t RSRenderServiceClient::AddVirtualScreenBlackList(ScreenId id, std::vector& blackListVector) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - RS_LOGE("RSRenderServiceClient::%{public}s renderService is null!", __func__); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + RS_LOGE("RSRenderServiceClient::%{public}s clientToRender is null!", __func__); return RENDER_SERVICE_NULL; } int32_t repCode; - renderService->AddVirtualScreenBlackList(id, blackListVector, repCode); + clientToRender->AddVirtualScreenBlackList(id, blackListVector, repCode); return repCode; } int32_t RSRenderServiceClient::RemoveVirtualScreenBlackList(ScreenId id, std::vector& blackListVector) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - RS_LOGE("RSRenderServiceClient::%{public}s renderService is null!", __func__); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + RS_LOGE("RSRenderServiceClient::%{public}s clientToRender is null!", __func__); return RENDER_SERVICE_NULL; } int32_t repCode; - renderService->RemoveVirtualScreenBlackList(id, blackListVector, repCode); + clientToRender->RemoveVirtualScreenBlackList(id, blackListVector, repCode); return repCode; } bool RSRenderServiceClient::SetWatermark(const std::string& name, std::shared_ptr watermark) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return false; } bool success; - renderService->SetWatermark(name, watermark, success); + clientToRender->SetWatermark(name, watermark, success); return success; } @@ -583,85 +583,85 @@ int32_t RSRenderServiceClient::SetVirtualScreenSecurityExemptionList( ScreenId id, const std::vector& securityExemptionList) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->SetVirtualScreenSecurityExemptionList(id, securityExemptionList); + return clientToRender->SetVirtualScreenSecurityExemptionList(id, securityExemptionList); } int32_t RSRenderServiceClient::SetScreenSecurityMask(ScreenId id, std::shared_ptr securityMask) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->SetScreenSecurityMask(id, std::move(securityMask)); + return clientToRender->SetScreenSecurityMask(id, std::move(securityMask)); } int32_t RSRenderServiceClient::SetMirrorScreenVisibleRect(ScreenId id, const Rect& mainScreenRect, bool supportRotation) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->SetMirrorScreenVisibleRect(id, mainScreenRect, supportRotation); + return clientToRender->SetMirrorScreenVisibleRect(id, mainScreenRect, supportRotation); } int32_t RSRenderServiceClient::SetCastScreenEnableSkipWindow(ScreenId id, bool enable) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->SetCastScreenEnableSkipWindow(id, enable); + return clientToRender->SetCastScreenEnableSkipWindow(id, enable); } int32_t RSRenderServiceClient::SetVirtualScreenSurface(ScreenId id, sptr surface) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->SetVirtualScreenSurface(id, surface); + return clientToService->SetVirtualScreenSurface(id, surface); } void RSRenderServiceClient::RemoveVirtualScreen(ScreenId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return; } - renderService->RemoveVirtualScreen(id); + clientToService->RemoveVirtualScreen(id); } #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR int32_t RSRenderServiceClient::SetPointerColorInversionConfig(float darkBuffer, float brightBuffer, int64_t interval, int32_t rangeSize) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval, rangeSize); + return clientToRender->SetPointerColorInversionConfig(darkBuffer, brightBuffer, interval, rangeSize); } int32_t RSRenderServiceClient::SetPointerColorInversionEnabled(bool enable) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->SetPointerColorInversionEnabled(enable); + return clientToRender->SetPointerColorInversionEnabled(enable); } class CustomPointerLuminanceChangeCallback : public RSPointerLuminanceChangeCallbackStub @@ -683,22 +683,22 @@ private: int32_t RSRenderServiceClient::RegisterPointerLuminanceChangeCallback(const PointerLuminanceChangeCallback &callback) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } sptr cb = new CustomPointerLuminanceChangeCallback(callback); - return renderService->RegisterPointerLuminanceChangeCallback(cb); + return clientToRender->RegisterPointerLuminanceChangeCallback(cb); } int32_t RSRenderServiceClient::UnRegisterPointerLuminanceChangeCallback() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->UnRegisterPointerLuminanceChangeCallback(); + return clientToRender->UnRegisterPointerLuminanceChangeCallback(); } #endif @@ -722,321 +722,321 @@ private: int32_t RSRenderServiceClient::SetScreenChangeCallback(const ScreenChangeCallback &callback) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::%{public}s renderService is null", __func__); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::%{public}s clientToService is null", __func__); return RENDER_SERVICE_NULL; } screenChangeCb_ = new CustomScreenChangeCallback(callback); - return renderService->SetScreenChangeCallback(screenChangeCb_); + return clientToService->SetScreenChangeCallback(screenChangeCb_); } void RSRenderServiceClient::SetScreenActiveMode(ScreenId id, uint32_t modeId) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return; } - renderService->SetScreenActiveMode(id, modeId); + clientToService->SetScreenActiveMode(id, modeId); } void RSRenderServiceClient::SetScreenRefreshRate(ScreenId id, int32_t sceneId, int32_t rate) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGW("RSRenderServiceClient renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGW("RSRenderServiceClient clientToService == nullptr!"); return; } - renderService->SetScreenRefreshRate(id, sceneId, rate); + clientToService->SetScreenRefreshRate(id, sceneId, rate); } void RSRenderServiceClient::SetRefreshRateMode(int32_t refreshRateMode) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGW("RSRenderServiceClient renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGW("RSRenderServiceClient clientToService == nullptr!"); return; } - renderService->SetRefreshRateMode(refreshRateMode); + clientToService->SetRefreshRateMode(refreshRateMode); } void RSRenderServiceClient::SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range, int32_t animatorExpectedFrameRate) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGW("RSRenderServiceClient renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGW("RSRenderServiceClient clientToRender == nullptr!"); return; } - return renderService->SyncFrameRateRange(id, range, animatorExpectedFrameRate); + return clientToRender->SyncFrameRateRange(id, range, animatorExpectedFrameRate); } void RSRenderServiceClient::UnregisterFrameRateLinker(FrameRateLinkerId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGW("RSRenderServiceClient renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGW("RSRenderServiceClient clientToService == nullptr!"); return; } - renderService->UnregisterFrameRateLinker(id); + clientToService->UnregisterFrameRateLinker(id); } uint32_t RSRenderServiceClient::GetScreenCurrentRefreshRate(ScreenId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGW("RSRenderServiceClient renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGW("RSRenderServiceClient clientToService == nullptr!"); return RENDER_SERVICE_NULL; } - return renderService->GetScreenCurrentRefreshRate(id); + return clientToService->GetScreenCurrentRefreshRate(id); } int32_t RSRenderServiceClient::GetCurrentRefreshRateMode() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGW("RSRenderServiceClient renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGW("RSRenderServiceClient clientToService == nullptr!"); return RENDER_SERVICE_NULL; } - return renderService->GetCurrentRefreshRateMode(); + return clientToService->GetCurrentRefreshRateMode(); } std::vector RSRenderServiceClient::GetScreenSupportedRefreshRates(ScreenId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGW("RSRenderServiceClient renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGW("RSRenderServiceClient clientToService == nullptr!"); return {}; } - return renderService->GetScreenSupportedRefreshRates(id); + return clientToService->GetScreenSupportedRefreshRates(id); } bool RSRenderServiceClient::GetShowRefreshRateEnabled() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGW("RSRenderServiceClient renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGW("RSRenderServiceClient clientToService == nullptr!"); return false; } bool enable = false; - renderService->GetShowRefreshRateEnabled(enable); + clientToService->GetShowRefreshRateEnabled(enable); return enable; } std::string RSRenderServiceClient::GetRefreshInfo(pid_t pid) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGW("RSRenderServiceClient renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGW("RSRenderServiceClient clientToService == nullptr!"); return ""; } std::string enable; - renderService->GetRefreshInfo(pid, enable); + clientToService->GetRefreshInfo(pid, enable); return enable; } std::string RSRenderServiceClient::GetRefreshInfoToSP(NodeId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGW("RSRenderServiceClient renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGW("RSRenderServiceClient clientToService == nullptr!"); return ""; } std::string enable; - renderService->GetRefreshInfoToSP(id, enable); + clientToService->GetRefreshInfoToSP(id, enable); return enable; } void RSRenderServiceClient::SetShowRefreshRateEnabled(bool enabled, int32_t type) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGW("RSRenderServiceClient renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGW("RSRenderServiceClient clientToService == nullptr!"); return; } - return renderService->SetShowRefreshRateEnabled(enabled, type); + return clientToService->SetShowRefreshRateEnabled(enabled, type); } uint32_t RSRenderServiceClient::GetRealtimeRefreshRate(ScreenId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGW("RSRenderServiceClient renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGW("RSRenderServiceClient clientToService == nullptr!"); return RENDER_SERVICE_NULL; } - return renderService->GetRealtimeRefreshRate(id); + return clientToService->GetRealtimeRefreshRate(id); } int32_t RSRenderServiceClient::SetPhysicalScreenResolution(ScreenId id, uint32_t width, uint32_t height) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { ROSEN_LOGE("%{public}s: render service is null", __func__); return RENDER_SERVICE_NULL; } - return renderService->SetPhysicalScreenResolution(id, width, height); + return clientToService->SetPhysicalScreenResolution(id, width, height); } int32_t RSRenderServiceClient::SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::SetVirtualScreenResolution renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::SetVirtualScreenResolution clientToService == nullptr!"); return RENDER_SERVICE_NULL; } - return renderService->SetVirtualScreenResolution(id, width, height); + return clientToService->SetVirtualScreenResolution(id, width, height); } RSVirtualScreenResolution RSRenderServiceClient::GetVirtualScreenResolution(ScreenId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RSVirtualScreenResolution {}; // return empty RSVirtualScreenResolution. } - return renderService->GetVirtualScreenResolution(id); + return clientToRender->GetVirtualScreenResolution(id); } void RSRenderServiceClient::MarkPowerOffNeedProcessOneFrame() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return; } - renderService->MarkPowerOffNeedProcessOneFrame(); + clientToRender->MarkPowerOffNeedProcessOneFrame(); } void RSRenderServiceClient::RepaintEverything() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RepaintEverything renderService is null, return"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RepaintEverything clientToService is null, return"); return; } - renderService->RepaintEverything(); + clientToService->RepaintEverything(); } void RSRenderServiceClient::ForceRefreshOneFrameWithNextVSync() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("ForceRefreshOneFrameWithNextVSync renderService is nullptr, return"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("ForceRefreshOneFrameWithNextVSync clientToRender is nullptr, return"); return; } - renderService->ForceRefreshOneFrameWithNextVSync(); + clientToRender->ForceRefreshOneFrameWithNextVSync(); } void RSRenderServiceClient::DisablePowerOffRenderControl(ScreenId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return; } - renderService->DisablePowerOffRenderControl(id); + clientToRender->DisablePowerOffRenderControl(id); } void RSRenderServiceClient::SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::%{public}s renderService is nullptr", __func__); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::%{public}s clientToService is nullptr", __func__); return; } - renderService->SetScreenPowerStatus(id, status); + clientToService->SetScreenPowerStatus(id, status); } RSScreenModeInfo RSRenderServiceClient::GetScreenActiveMode(ScreenId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RSScreenModeInfo {}; // return empty RSScreenModeInfo. } RSScreenModeInfo screenModeInfo; - renderService->GetScreenActiveMode(id, screenModeInfo); + clientToService->GetScreenActiveMode(id, screenModeInfo); return screenModeInfo; } std::vector RSRenderServiceClient::GetScreenSupportedModes(ScreenId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return {}; } - return renderService->GetScreenSupportedModes(id); + return clientToService->GetScreenSupportedModes(id); } RSScreenCapability RSRenderServiceClient::GetScreenCapability(ScreenId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RSScreenCapability {}; } - return renderService->GetScreenCapability(id); + return clientToService->GetScreenCapability(id); } ScreenPowerStatus RSRenderServiceClient::GetScreenPowerStatus(ScreenId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return ScreenPowerStatus::INVALID_POWER_STATUS; } uint32_t status {static_cast(ScreenPowerStatus::INVALID_POWER_STATUS)}; - renderService->GetScreenPowerStatus(id, status); + clientToService->GetScreenPowerStatus(id, status); return static_cast(status); } RSScreenData RSRenderServiceClient::GetScreenData(ScreenId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RSScreenData {}; } - return renderService->GetScreenData(id); + return clientToService->GetScreenData(id); } int32_t RSRenderServiceClient::GetScreenBacklight(ScreenId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::%{public}s renderService is nullptr", __func__); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::%{public}s clientToService is nullptr", __func__); return INVALID_BACKLIGHT_VALUE; } int32_t backLightLevel = INVALID_BACKLIGHT_VALUE; - renderService->GetScreenBacklight(id, backLightLevel); + clientToService->GetScreenBacklight(id, backLightLevel); return backLightLevel; } void RSRenderServiceClient::SetScreenBacklight(ScreenId id, uint32_t level) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::%{public}s renderService is nullptr", __func__); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::%{public}s clientToService is nullptr", __func__); return; } - renderService->SetScreenBacklight(id, level); + clientToService->SetScreenBacklight(id, level); } class CustomBufferAvailableCallback : public RSBufferAvailableCallbackStub @@ -1076,8 +1076,8 @@ private: bool RSRenderServiceClient::RegisterBufferAvailableListener( NodeId id, const BufferAvailableCallback &callback, bool isFromRenderThread) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return false; } std::lock_guard lock(mapMutex_); @@ -1094,7 +1094,7 @@ bool RSRenderServiceClient::RegisterBufferAvailableListener( } sptr bufferAvailableCb = new CustomBufferAvailableCallback(callback); - renderService->RegisterBufferAvailableListener(id, bufferAvailableCb, isFromRenderThread); + clientToService->RegisterBufferAvailableListener(id, bufferAvailableCb, isFromRenderThread); if (isFromRenderThread) { bufferAvailableCbRTMap_.emplace(id, bufferAvailableCb); } else { @@ -1105,12 +1105,12 @@ bool RSRenderServiceClient::RegisterBufferAvailableListener( bool RSRenderServiceClient::RegisterBufferClearListener(NodeId id, const BufferClearCallback& callback) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return false; } sptr bufferClearCb = new CustomBufferClearCallback(callback); - renderService->RegisterBufferClearListener(id, bufferClearCb); + clientToService->RegisterBufferClearListener(id, bufferClearCb); return true; } @@ -1137,183 +1137,183 @@ bool RSRenderServiceClient::UnregisterBufferAvailableListener(NodeId id) int32_t RSRenderServiceClient::GetScreenSupportedColorGamuts(ScreenId id, std::vector& mode) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->GetScreenSupportedColorGamuts(id, mode); + return clientToService->GetScreenSupportedColorGamuts(id, mode); } int32_t RSRenderServiceClient::GetScreenSupportedMetaDataKeys(ScreenId id, std::vector& keys) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::RequestRotation renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::RequestRotation clientToService == nullptr!"); return RENDER_SERVICE_NULL; } - return renderService->GetScreenSupportedMetaDataKeys(id, keys); + return clientToService->GetScreenSupportedMetaDataKeys(id, keys); } int32_t RSRenderServiceClient::GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->GetScreenColorGamut(id, mode); + return clientToService->GetScreenColorGamut(id, mode); } int32_t RSRenderServiceClient::SetScreenColorGamut(ScreenId id, int32_t modeIdx) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->SetScreenColorGamut(id, modeIdx); + return clientToService->SetScreenColorGamut(id, modeIdx); } int32_t RSRenderServiceClient::SetScreenGamutMap(ScreenId id, ScreenGamutMap mode) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->SetScreenGamutMap(id, mode); + return clientToService->SetScreenGamutMap(id, mode); } int32_t RSRenderServiceClient::SetScreenCorrection(ScreenId id, ScreenRotation screenRotation) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->SetScreenCorrection(id, screenRotation); + return clientToService->SetScreenCorrection(id, screenRotation); } bool RSRenderServiceClient::SetVirtualMirrorScreenCanvasRotation(ScreenId id, bool canvasRotation) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::SetVirtualMirrorScreenCanvasRotation: renderService is nullptr"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::SetVirtualMirrorScreenCanvasRotation: clientToRender is nullptr"); return false; } - return renderService->SetVirtualMirrorScreenCanvasRotation(id, canvasRotation); + return clientToRender->SetVirtualMirrorScreenCanvasRotation(id, canvasRotation); } int32_t RSRenderServiceClient::SetVirtualScreenAutoRotation(ScreenId id, bool isAutoRotation) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::SetVirtualScreenAutoRotation: renderService is nullptr"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::SetVirtualScreenAutoRotation: clientToRender is nullptr"); return RENDER_SERVICE_NULL; } - return renderService->SetVirtualScreenAutoRotation(id, isAutoRotation); + return clientToRender->SetVirtualScreenAutoRotation(id, isAutoRotation); } bool RSRenderServiceClient::SetVirtualMirrorScreenScaleMode(ScreenId id, ScreenScaleMode scaleMode) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::SetVirtualMirrorScreenScaleMode: renderService is nullptr"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::SetVirtualMirrorScreenScaleMode: clientToRender is nullptr"); return false; } - return renderService->SetVirtualMirrorScreenScaleMode(id, scaleMode); + return clientToRender->SetVirtualMirrorScreenScaleMode(id, scaleMode); } bool RSRenderServiceClient::SetGlobalDarkColorMode(bool isDark) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::SetGlobalDarkColorMode: renderService is nullptr"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::SetGlobalDarkColorMode: clientToService is nullptr"); return false; } - return renderService->SetGlobalDarkColorMode(isDark) == ERR_OK; + return clientToService->SetGlobalDarkColorMode(isDark) == ERR_OK; } int32_t RSRenderServiceClient::GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->GetScreenGamutMap(id, mode); + return clientToService->GetScreenGamutMap(id, mode); } int32_t RSRenderServiceClient::GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::GetScreenHDRCapability renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::GetScreenHDRCapability clientToRender == nullptr!"); return RENDER_SERVICE_NULL; } - return renderService->GetScreenHDRCapability(id, screenHdrCapability); + return clientToRender->GetScreenHDRCapability(id, screenHdrCapability); } int32_t RSRenderServiceClient::GetPixelFormat(ScreenId id, GraphicPixelFormat& pixelFormat) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::GetPixelFormat renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::GetPixelFormat clientToRender == nullptr!"); return RENDER_SERVICE_NULL; } int32_t resCode; - renderService->GetPixelFormat(id, pixelFormat, resCode); + clientToRender->GetPixelFormat(id, pixelFormat, resCode); return resCode; } int32_t RSRenderServiceClient::SetPixelFormat(ScreenId id, GraphicPixelFormat pixelFormat) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::SetPixelFormat renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::SetPixelFormat clientToRender == nullptr!"); return RENDER_SERVICE_NULL; } int32_t resCode; - renderService->SetPixelFormat(id, pixelFormat, resCode); + clientToRender->SetPixelFormat(id, pixelFormat, resCode); return resCode; } int32_t RSRenderServiceClient::GetScreenSupportedHDRFormats(ScreenId id, std::vector& hdrFormats) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } int32_t resCode; - renderService->GetScreenSupportedHDRFormats(id, hdrFormats, resCode); + clientToRender->GetScreenSupportedHDRFormats(id, hdrFormats, resCode); return resCode; } int32_t RSRenderServiceClient::GetScreenHDRFormat(ScreenId id, ScreenHDRFormat& hdrFormat) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } int32_t resCode; - renderService->GetScreenHDRFormat(id, hdrFormat, resCode); + clientToRender->GetScreenHDRFormat(id, hdrFormat, resCode); return resCode; } int32_t RSRenderServiceClient::SetScreenHDRFormat(ScreenId id, int32_t modeIdx) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } int32_t resCode; - renderService->SetScreenHDRFormat(id, modeIdx, resCode); + clientToRender->SetScreenHDRFormat(id, modeIdx, resCode); return resCode; } int32_t RSRenderServiceClient::GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } int32_t resCode; - auto err = renderService->GetScreenHDRStatus(id, hdrStatus, resCode); + auto err = clientToService->GetScreenHDRStatus(id, hdrStatus, resCode); if (err != ERR_OK) { ROSEN_LOGE("RSRenderServiceClient::GetScreenHDRStatus err(%{public}d)!", err); resCode = err; @@ -1324,77 +1324,77 @@ int32_t RSRenderServiceClient::GetScreenHDRStatus(ScreenId id, HdrStatus& hdrSta int32_t RSRenderServiceClient::GetScreenSupportedColorSpaces( ScreenId id, std::vector& colorSpaces) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } int32_t resCode; - renderService->GetScreenSupportedColorSpaces(id, colorSpaces, resCode); + clientToService->GetScreenSupportedColorSpaces(id, colorSpaces, resCode); return resCode; } int32_t RSRenderServiceClient::GetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType& colorSpace) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } int32_t resCode; - renderService->GetScreenColorSpace(id, colorSpace, resCode); + clientToService->GetScreenColorSpace(id, colorSpace, resCode); return resCode; } int32_t RSRenderServiceClient::SetScreenColorSpace(ScreenId id, GraphicCM_ColorSpaceType colorSpace) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } int32_t resCode; - renderService->SetScreenColorSpace(id, colorSpace, resCode); + clientToService->SetScreenColorSpace(id, colorSpace, resCode); return resCode; } int32_t RSRenderServiceClient::GetScreenType(ScreenId id, RSScreenType& screenType) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::GetScreenType renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::GetScreenType clientToService == nullptr!"); return RENDER_SERVICE_NULL; } - return renderService->GetScreenType(id, screenType); + return clientToService->GetScreenType(id, screenType); } bool RSRenderServiceClient::GetBitmap(NodeId id, Drawing::Bitmap& bitmap) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::GetBitmap renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::GetBitmap clientToService == nullptr!"); return false; } bool success; - renderService->GetBitmap(id, bitmap, success); + clientToService->GetBitmap(id, bitmap, success); return success; } bool RSRenderServiceClient::GetPixelmap(NodeId id, std::shared_ptr pixelmap, const Drawing::Rect* rect, std::shared_ptr drawCmdList) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::GetPixelmap: renderService is nullptr"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::GetPixelmap: clientToService is nullptr"); return false; } bool success; - renderService->GetPixelmap(id, pixelmap, rect, drawCmdList, success); + clientToService->GetPixelmap(id, pixelmap, rect, drawCmdList, success); return success; } bool RSRenderServiceClient::RegisterTypeface(std::shared_ptr& typeface) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::RegisterTypeface: renderService is nullptr"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::RegisterTypeface: clientToRender is nullptr"); return false; } uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID()); @@ -1402,82 +1402,82 @@ bool RSRenderServiceClient::RegisterTypeface(std::shared_ptr& RSTypefaceCache::GetTypefacePid(globalUniqueId), RSTypefaceCache::GetTypefaceId(globalUniqueId)); // timer: 3s OHOS::Rosen::RSXCollie registerTypefaceXCollie("registerTypefaceXCollie_" + typeface->GetFamilyName(), 3); - return renderService->RegisterTypeface(globalUniqueId, typeface); + return clientToRender->RegisterTypeface(globalUniqueId, typeface); } bool RSRenderServiceClient::UnRegisterTypeface(std::shared_ptr& typeface) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::UnRegisterTypeface: renderService is nullptr"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::UnRegisterTypeface: clientToRender is nullptr"); return false; } uint64_t globalUniqueId = RSTypefaceCache::GenGlobalUniqueId(typeface->GetUniqueID()); ROSEN_LOGD("RSRenderServiceClient::UnRegisterTypeface: pid[%{public}d] unregister typface[%{public}u]", RSTypefaceCache::GetTypefacePid(globalUniqueId), RSTypefaceCache::GetTypefaceId(globalUniqueId)); - return renderService->UnRegisterTypeface(globalUniqueId); + return clientToRender->UnRegisterTypeface(globalUniqueId); } int32_t RSRenderServiceClient::GetDisplayIdentificationData(ScreenId id, uint8_t& outPort, std::vector& edidData) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->GetDisplayIdentificationData(id, outPort, edidData); + return clientToService->GetDisplayIdentificationData(id, outPort, edidData); } int32_t RSRenderServiceClient::SetScreenSkipFrameInterval(ScreenId id, uint32_t skipFrameInterval) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } int32_t statusCode = SUCCESS; - renderService->SetScreenSkipFrameInterval(id, skipFrameInterval, statusCode); + clientToRender->SetScreenSkipFrameInterval(id, skipFrameInterval, statusCode); return statusCode; } int32_t RSRenderServiceClient::SetVirtualScreenRefreshRate( ScreenId id, uint32_t maxRefreshRate, uint32_t& actualRefreshRate) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); + auto clientToRender = GetClientToRenderConnection(); int32_t resCode = RENDER_SERVICE_NULL; - if (renderService == nullptr) { + if (clientToRender == nullptr) { return RENDER_SERVICE_NULL; } - renderService->SetVirtualScreenRefreshRate(id, maxRefreshRate, actualRefreshRate, resCode); + clientToRender->SetVirtualScreenRefreshRate(id, maxRefreshRate, actualRefreshRate, resCode); return resCode; } uint32_t RSRenderServiceClient::SetScreenActiveRect(ScreenId id, const Rect& activeRect) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } uint32_t repCode; - return renderService->SetScreenActiveRect(id, activeRect, repCode); + return clientToService->SetScreenActiveRect(id, activeRect, repCode); return repCode; } void RSRenderServiceClient::SetScreenOffset(ScreenId id, int32_t offSetX, int32_t offSetY) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return; } - renderService->SetScreenOffset(id, offSetX, offSetY); + clientToService->SetScreenOffset(id, offSetX, offSetY); } void RSRenderServiceClient::SetScreenFrameGravity(ScreenId id, int32_t gravity) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return; } - renderService->SetScreenFrameGravity(id, gravity); + clientToService->SetScreenFrameGravity(id, gravity); } class CustomOcclusionChangeCallback : public RSOcclusionChangeCallbackStub @@ -1499,14 +1499,14 @@ private: int32_t RSRenderServiceClient::RegisterOcclusionChangeCallback(const OcclusionChangeCallback& callback) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::RegisterOcclusionChangeCallback renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::RegisterOcclusionChangeCallback clientToRender == nullptr!"); return RENDER_SERVICE_NULL; } sptr cb = new CustomOcclusionChangeCallback(callback); int32_t repCode; - renderService->RegisterOcclusionChangeCallback(cb, repCode); + clientToRender->RegisterOcclusionChangeCallback(cb, repCode); return repCode; } @@ -1530,23 +1530,23 @@ private: int32_t RSRenderServiceClient::RegisterSurfaceOcclusionChangeCallback( NodeId id, const SurfaceOcclusionChangeCallback& callback, std::vector& partitionPoints) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::RegisterSurfaceOcclusionChangeCallback renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::RegisterSurfaceOcclusionChangeCallback clientToRender == nullptr!"); return RENDER_SERVICE_NULL; } sptr cb = new CustomSurfaceOcclusionChangeCallback(callback); - return renderService->RegisterSurfaceOcclusionChangeCallback(id, cb, partitionPoints); + return clientToRender->RegisterSurfaceOcclusionChangeCallback(id, cb, partitionPoints); } int32_t RSRenderServiceClient::UnRegisterSurfaceOcclusionChangeCallback(NodeId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::UnRegisterSurfaceOcclusionChangeCallback renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::UnRegisterSurfaceOcclusionChangeCallback clientToRender == nullptr!"); return RENDER_SERVICE_NULL; } - return renderService->UnRegisterSurfaceOcclusionChangeCallback(id); + return clientToRender->UnRegisterSurfaceOcclusionChangeCallback(id); } class CustomHgmConfigChangeCallback : public RSHgmConfigChangeCallbackStub @@ -1575,13 +1575,13 @@ private: int32_t RSRenderServiceClient::RegisterHgmConfigChangeCallback(const HgmConfigChangeCallback& callback) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::RegisterHgmConfigChangeCallback renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::RegisterHgmConfigChangeCallback clientToRender == nullptr!"); return RENDER_SERVICE_NULL; } sptr cb = new CustomHgmConfigChangeCallback(callback); - return renderService->RegisterHgmConfigChangeCallback(cb); + return clientToRender->RegisterHgmConfigChangeCallback(cb); } class CustomHgmRefreshRateModeChangeCallback : public RSHgmConfigChangeCallbackStub @@ -1611,13 +1611,13 @@ private: int32_t RSRenderServiceClient::RegisterHgmRefreshRateModeChangeCallback( const HgmRefreshRateModeChangeCallback& callback) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::RegisterHgmRefreshRateModeChangeCallback renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::RegisterHgmRefreshRateModeChangeCallback clientToRender == nullptr!"); return RENDER_SERVICE_NULL; } sptr cb = new CustomHgmRefreshRateModeChangeCallback(callback); - return renderService->RegisterHgmRefreshRateModeChangeCallback(cb); + return clientToRender->RegisterHgmRefreshRateModeChangeCallback(cb); } class CustomHgmRefreshRateUpdateCallback : public RSHgmConfigChangeCallbackStub @@ -1650,9 +1650,9 @@ int32_t RSRenderServiceClient::RegisterHgmRefreshRateUpdateCallback( const HgmRefreshRateUpdateCallback& callback) { sptr cb = nullptr; - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::RegisterHgmRefreshRateUpdateCallback renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::RegisterHgmRefreshRateUpdateCallback clientToRender == nullptr!"); return RENDER_SERVICE_NULL; } @@ -1661,7 +1661,7 @@ int32_t RSRenderServiceClient::RegisterHgmRefreshRateUpdateCallback( } ROSEN_LOGD("RSRenderServiceClient::RegisterHgmRefreshRateUpdateCallback called"); - return renderService->RegisterHgmRefreshRateUpdateCallback(cb); + return clientToRender->RegisterHgmRefreshRateUpdateCallback(cb); } class CustomFirstFrameCommitCallback : public RSFirstFrameCommitCallbackStub @@ -1686,9 +1686,9 @@ int32_t RSRenderServiceClient::RegisterFirstFrameCommitCallback( const FirstFrameCommitCallback& callback) { sptr cb = nullptr; - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::RegisterFirstFrameCommitCallback renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::RegisterFirstFrameCommitCallback clientToRender == nullptr!"); return RENDER_SERVICE_NULL; } @@ -1697,7 +1697,7 @@ int32_t RSRenderServiceClient::RegisterFirstFrameCommitCallback( } ROSEN_LOGD("RSRenderServiceClient::RegisterFirstFrameCommitCallback called"); - return renderService->RegisterFirstFrameCommitCallback(cb); + return clientToRender->RegisterFirstFrameCommitCallback(cb); } class CustomFrameRateLinkerExpectedFpsUpdateCallback : public RSFrameRateLinkerExpectedFpsUpdateCallbackStub @@ -1723,9 +1723,9 @@ private: int32_t RSRenderServiceClient::RegisterFrameRateLinkerExpectedFpsUpdateCallback( int32_t dstPid, const FrameRateLinkerExpectedFpsUpdateCallback& callback) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::RegisterFrameRateLinkerExpectedFpsUpdateCallback renderService == nullptr"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::RegisterFrameRateLinkerExpectedFpsUpdateCallback clientToRender == nullptr"); return RENDER_SERVICE_NULL; } @@ -1735,120 +1735,120 @@ int32_t RSRenderServiceClient::RegisterFrameRateLinkerExpectedFpsUpdateCallback( } ROSEN_LOGD("RSRenderServiceClient::RegisterFrameRateLinkerExpectedFpsUpdateCallback called"); - return renderService->RegisterFrameRateLinkerExpectedFpsUpdateCallback(dstPid, cb); + return clientToRender->RegisterFrameRateLinkerExpectedFpsUpdateCallback(dstPid, cb); } void RSRenderServiceClient::SetAppWindowNum(uint32_t num) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->SetAppWindowNum(num); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->SetAppWindowNum(num); } } bool RSRenderServiceClient::SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes, bool isRegularAnimation) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::SetSystemAnimatedScenes renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::SetSystemAnimatedScenes clientToRender == nullptr!"); return false; } bool success; - renderService->SetSystemAnimatedScenes(systemAnimatedScenes, isRegularAnimation, success); + clientToRender->SetSystemAnimatedScenes(systemAnimatedScenes, isRegularAnimation, success); return success; } void RSRenderServiceClient::ShowWatermark(const std::shared_ptr &watermarkImg, bool isShow) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->ShowWatermark(watermarkImg, isShow); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->ShowWatermark(watermarkImg, isShow); } } int32_t RSRenderServiceClient::ResizeVirtualScreen(ScreenId id, uint32_t width, uint32_t height) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::ResizeVirtualScreen renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::ResizeVirtualScreen clientToRender == nullptr!"); return RENDER_SERVICE_NULL; } ROSEN_LOGI("RSRenderServiceClient::ResizeVirtualScreen, width:%{public}u, height:%{public}u", width, height); - return renderService->ResizeVirtualScreen(id, width, height); + return clientToRender->ResizeVirtualScreen(id, width, height); } void RSRenderServiceClient::ReportJankStats() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->ReportJankStats(); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->ReportJankStats(); } } void RSRenderServiceClient::ReportEventResponse(DataBaseRs info) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->ReportEventResponse(info); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->ReportEventResponse(info); } } void RSRenderServiceClient::ReportEventComplete(DataBaseRs info) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->ReportEventComplete(info); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->ReportEventComplete(info); } } void RSRenderServiceClient::ReportEventJankFrame(DataBaseRs info) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->ReportEventJankFrame(info); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->ReportEventJankFrame(info); } } void RSRenderServiceClient::ReportRsSceneJankStart(AppInfo info) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->ReportRsSceneJankStart(info); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->ReportRsSceneJankStart(info); } } void RSRenderServiceClient::ReportRsSceneJankEnd(AppInfo info) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->ReportRsSceneJankEnd(info); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->ReportRsSceneJankEnd(info); } } void RSRenderServiceClient::ReportGameStateData(GameStateData info) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->ReportGameStateData(info); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->ReportGameStateData(info); } } void RSRenderServiceClient::SetHardwareEnabled(NodeId id, bool isEnabled, SelfDrawingNodeType selfDrawingType, bool dynamicHardwareEnable) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->SetHardwareEnabled(id, isEnabled, selfDrawingType, dynamicHardwareEnable); + auto clientToService = GetClientToServiceConnection(); + if (clientToService != nullptr) { + clientToService->SetHardwareEnabled(id, isEnabled, selfDrawingType, dynamicHardwareEnable); } } uint32_t RSRenderServiceClient::SetHidePrivacyContent(NodeId id, bool needHidePrivacyContent) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService != nullptr) { uint32_t resCode; - renderService->SetHidePrivacyContent(id, needHidePrivacyContent, resCode); + clientToService->SetHidePrivacyContent(id, needHidePrivacyContent, resCode); return resCode; } return static_cast(RSInterfaceErrorCode::UNKNOWN_ERROR); @@ -1856,155 +1856,155 @@ uint32_t RSRenderServiceClient::SetHidePrivacyContent(NodeId id, bool needHidePr void RSRenderServiceClient::NotifyLightFactorStatus(int32_t lightFactorStatus) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->NotifyLightFactorStatus(lightFactorStatus); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->NotifyLightFactorStatus(lightFactorStatus); } } void RSRenderServiceClient::NotifyPackageEvent(uint32_t listSize, const std::vector& packageList) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->NotifyPackageEvent(listSize, packageList); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->NotifyPackageEvent(listSize, packageList); } } void RSRenderServiceClient::NotifyAppStrategyConfigChangeEvent(const std::string& pkgName, uint32_t listSize, const std::vector>& newConfig) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->NotifyAppStrategyConfigChangeEvent(pkgName, listSize, newConfig); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->NotifyAppStrategyConfigChangeEvent(pkgName, listSize, newConfig); } } void RSRenderServiceClient::NotifyRefreshRateEvent(const EventInfo& eventInfo) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->NotifyRefreshRateEvent(eventInfo); + auto clientToService = GetClientToServiceConnection(); + if (clientToService != nullptr) { + clientToService->NotifyRefreshRateEvent(eventInfo); } } void RSRenderServiceClient::SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->SetWindowExpectedRefreshRate(eventInfos); + auto clientToService = GetClientToServiceConnection(); + if (clientToService != nullptr) { + clientToService->SetWindowExpectedRefreshRate(eventInfos); } } void RSRenderServiceClient::SetWindowExpectedRefreshRate(const std::unordered_map& eventInfos) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->SetWindowExpectedRefreshRate(eventInfos); + auto clientToService = GetClientToServiceConnection(); + if (clientToService != nullptr) { + clientToService->SetWindowExpectedRefreshRate(eventInfos); } } bool RSRenderServiceClient::NotifySoftVsyncRateDiscountEvent(uint32_t pid, const std::string &name, uint32_t rateDiscount) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - return renderService->NotifySoftVsyncRateDiscountEvent(pid, name, rateDiscount); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + return clientToRender->NotifySoftVsyncRateDiscountEvent(pid, name, rateDiscount); } return false; } void RSRenderServiceClient::NotifyHgmConfigEvent(const std::string &eventName, bool state) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->NotifyHgmConfigEvent(eventName, state); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->NotifyHgmConfigEvent(eventName, state); } } void RSRenderServiceClient::NotifyXComponentExpectedFrameRate(const std::string& id, int32_t expectedFrameRate) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->NotifyXComponentExpectedFrameRate(id, expectedFrameRate); + auto clientToService = GetClientToServiceConnection(); + if (clientToService != nullptr) { + clientToService->NotifyXComponentExpectedFrameRate(id, expectedFrameRate); } } void RSRenderServiceClient::NotifyTouchEvent(int32_t touchStatus, int32_t touchCnt) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->NotifyTouchEvent(touchStatus, touchCnt); + auto clientToService = GetClientToServiceConnection(); + if (clientToService != nullptr) { + clientToService->NotifyTouchEvent(touchStatus, touchCnt); } } void RSRenderServiceClient::NotifyDynamicModeEvent(bool enableDynamicMode) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->NotifyDynamicModeEvent(enableDynamicMode); + auto clientToService = GetClientToServiceConnection(); + if (clientToService != nullptr) { + clientToService->NotifyDynamicModeEvent(enableDynamicMode); } } void RSRenderServiceClient::SetCacheEnabledForRotation(bool isEnabled) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->SetCacheEnabledForRotation(isEnabled); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->SetCacheEnabledForRotation(isEnabled); } } void RSRenderServiceClient::SetOnRemoteDiedCallback(const OnRemoteDiedCallback& callback) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->SetOnRemoteDiedCallback(callback); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->SetOnRemoteDiedCallback(callback); } } std::vector RSRenderServiceClient::GetActiveDirtyRegionInfo() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return {}; } - return renderService->GetActiveDirtyRegionInfo(); + return clientToRender->GetActiveDirtyRegionInfo(); } GlobalDirtyRegionInfo RSRenderServiceClient::GetGlobalDirtyRegionInfo() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return GlobalDirtyRegionInfo {}; } - return renderService->GetGlobalDirtyRegionInfo(); + return clientToRender->GetGlobalDirtyRegionInfo(); } LayerComposeInfo RSRenderServiceClient::GetLayerComposeInfo() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return LayerComposeInfo {}; } - return renderService->GetLayerComposeInfo(); + return clientToService->GetLayerComposeInfo(); } HwcDisabledReasonInfos RSRenderServiceClient::GetHwcDisabledReasonInfo() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return {}; } - return renderService->GetHwcDisabledReasonInfo(); + return clientToService->GetHwcDisabledReasonInfo(); } int64_t RSRenderServiceClient::GetHdrOnDuration() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return 0; } int64_t hdrOnDuration = 0; - auto ret = renderService->GetHdrOnDuration(hdrOnDuration); + auto ret = clientToRender->GetHdrOnDuration(hdrOnDuration); if (ret != ERR_OK) { ROSEN_LOGE("Failed to get HdrOnDuration, ret=%{public}d", ret); } @@ -2013,46 +2013,46 @@ int64_t RSRenderServiceClient::GetHdrOnDuration() void RSRenderServiceClient::SetVmaCacheStatus(bool flag) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { return; } - renderService->SetVmaCacheStatus(flag); + clientToRender->SetVmaCacheStatus(flag); } #ifdef TP_FEATURE_ENABLE void RSRenderServiceClient::SetTpFeatureConfig(int32_t feature, const char* config, TpFeatureConfigType tpFeatureConfigType) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return; } - renderService->SetTpFeatureConfig(feature, config, tpFeatureConfigType); + clientToService->SetTpFeatureConfig(feature, config, tpFeatureConfigType); } #endif void RSRenderServiceClient::SetVirtualScreenUsingStatus(bool isVirtualScreenUsingStatus) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->SetVirtualScreenUsingStatus(isVirtualScreenUsingStatus); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->SetVirtualScreenUsingStatus(isVirtualScreenUsingStatus); } } void RSRenderServiceClient::SetCurtainScreenUsingStatus(bool isCurtainScreenOn) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->SetCurtainScreenUsingStatus(isCurtainScreenOn); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->SetCurtainScreenUsingStatus(isCurtainScreenOn); } } void RSRenderServiceClient::DropFrameByPid(const std::vector pidList) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->DropFrameByPid(pidList); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->DropFrameByPid(pidList); } } @@ -2076,45 +2076,45 @@ private: int32_t RSRenderServiceClient::RegisterUIExtensionCallback(uint64_t userId, const UIExtensionCallback& callback, bool unobscured) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::RegisterUIExtensionCallback renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::RegisterUIExtensionCallback clientToRender == nullptr!"); return RENDER_SERVICE_NULL; } sptr cb = new CustomUIExtensionCallback(callback); - return renderService->RegisterUIExtensionCallback(userId, cb, unobscured); + return clientToRender->RegisterUIExtensionCallback(userId, cb, unobscured); } bool RSRenderServiceClient::SetAncoForceDoDirect(bool direct) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { bool res; - renderService->SetAncoForceDoDirect(direct, res); + clientToRender->SetAncoForceDoDirect(direct, res); return res; } - ROSEN_LOGE("RSRenderServiceClient::SetAncoForceDoDirect renderService is null"); + ROSEN_LOGE("RSRenderServiceClient::SetAncoForceDoDirect clientToRender is null"); return false; } bool RSRenderServiceClient::SetVirtualScreenStatus(ScreenId id, VirtualScreenStatus screenStatus) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); + auto clientToRender = GetClientToRenderConnection(); bool success = false; - if (renderService != nullptr) { - renderService->SetVirtualScreenStatus(id, screenStatus, success); + if (clientToRender != nullptr) { + clientToRender->SetVirtualScreenStatus(id, screenStatus, success); } return success; } void RSRenderServiceClient::SetFreeMultiWindowStatus(bool enable) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::SetFreeMultiWindowStatus renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::SetFreeMultiWindowStatus clientToRender == nullptr!"); return; } - renderService->SetFreeMultiWindowStatus(enable); + clientToRender->SetFreeMultiWindowStatus(enable); } class SurfaceBufferCallbackDirector : public RSSurfaceBufferCallbackStub { @@ -2138,9 +2138,9 @@ private: bool RSRenderServiceClient::RegisterSurfaceBufferCallback( pid_t pid, uint64_t uid, std::shared_ptr callback) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::RegisterSurfaceBufferCallback renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::RegisterSurfaceBufferCallback clientToRender == nullptr!"); return false; } if (callback == nullptr) { @@ -2160,15 +2160,15 @@ bool RSRenderServiceClient::RegisterSurfaceBufferCallback( surfaceBufferCbDirector_ = new SurfaceBufferCallbackDirector(this); } } - renderService->RegisterSurfaceBufferCallback(pid, uid, surfaceBufferCbDirector_); + clientToRender->RegisterSurfaceBufferCallback(pid, uid, surfaceBufferCbDirector_); return true; } bool RSRenderServiceClient::UnregisterSurfaceBufferCallback(pid_t pid, uint64_t uid) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::UnregisterSurfaceBufferCallback renderService == nullptr!"); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::UnregisterSurfaceBufferCallback clientToRender == nullptr!"); return false; } { @@ -2180,7 +2180,7 @@ bool RSRenderServiceClient::UnregisterSurfaceBufferCallback(pid_t pid, uint64_t } surfaceBufferCallbacks_.erase(iter); } - renderService->UnregisterSurfaceBufferCallback(pid, uid); + clientToRender->UnregisterSurfaceBufferCallback(pid, uid); return true; } @@ -2216,25 +2216,25 @@ void RSRenderServiceClient::TriggerOnAfterAcquireBuffer(const AfterAcquireBuffer void RSRenderServiceClient::SetLayerTopForHWC(NodeId nodeId, bool isTop, uint32_t zOrder) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->SetLayerTopForHWC(nodeId, isTop, zOrder); + auto clientToService = GetClientToServiceConnection(); + if (clientToService != nullptr) { + clientToService->SetLayerTopForHWC(nodeId, isTop, zOrder); } } void RSRenderServiceClient::SetLayerTop(const std::string &nodeIdStr, bool isTop) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->SetLayerTop(nodeIdStr, isTop); + auto clientToService = GetClientToServiceConnection(); + if (clientToService != nullptr) { + clientToService->SetLayerTop(nodeIdStr, isTop); } } void RSRenderServiceClient::SetForceRefresh(const std::string &nodeIdStr, bool isForceRefresh) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->SetForceRefresh(nodeIdStr, isForceRefresh); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->SetForceRefresh(nodeIdStr, isForceRefresh); } } @@ -2256,9 +2256,9 @@ private: bool RSRenderServiceClient::RegisterTransactionDataCallback(uint64_t token, uint64_t timeStamp, std::function callback) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::RegisterTransactionDataCallback renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::RegisterTransactionDataCallback clientToService == nullptr!"); return false; } if (callback == nullptr) { @@ -2280,7 +2280,7 @@ bool RSRenderServiceClient::RegisterTransactionDataCallback(uint64_t token, uint } RS_LOGD("RSRenderServiceClient::RegisterTransactionDataCallback, timeStamp: %{public}" PRIu64 " token: %{public}" PRIu64, timeStamp, token); - renderService->RegisterTransactionDataCallback(token, timeStamp, transactionDataCbDirector_); + clientToService->RegisterTransactionDataCallback(token, timeStamp, transactionDataCbDirector_); return true; } @@ -2304,27 +2304,27 @@ void RSRenderServiceClient::TriggerTransactionDataCallbackAndErase(uint64_t toke void RSRenderServiceClient::SetColorFollow(const std::string &nodeIdStr, bool isColorFollow) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->SetColorFollow(nodeIdStr, isColorFollow); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->SetColorFollow(nodeIdStr, isColorFollow); } } void RSRenderServiceClient::NotifyScreenSwitched() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::%{public}s renderService is nullptr", __func__); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::%{public}s clientToService is nullptr", __func__); return; } - renderService->NotifyScreenSwitched(); + clientToService->NotifyScreenSwitched(); } void RSRenderServiceClient::SetWindowContainer(NodeId nodeId, bool value) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - renderService->SetWindowContainer(nodeId, value); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + clientToRender->SetWindowContainer(nodeId, value); } } @@ -2349,9 +2349,9 @@ private: int32_t RSRenderServiceClient::RegisterSelfDrawingNodeRectChangeCallback( const RectConstraint& constraint, const SelfDrawingNodeRectChangeCallback& callback) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::RegisterSelfDrawingNodeRectChangeCallback renderService == nullptr"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::RegisterSelfDrawingNodeRectChangeCallback clientToService == nullptr"); return RENDER_SERVICE_NULL; } @@ -2360,57 +2360,57 @@ int32_t RSRenderServiceClient::RegisterSelfDrawingNodeRectChangeCallback( cb = new CustomSelfDrawingNodeRectChangeCallback(callback); } - return renderService->RegisterSelfDrawingNodeRectChangeCallback(constraint, cb); + return clientToService->RegisterSelfDrawingNodeRectChangeCallback(constraint, cb); } int32_t RSRenderServiceClient::UnRegisterSelfDrawingNodeRectChangeCallback() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::UnRegisterSelfDrawingNodeRectChangeCallback renderService == nullptr"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::UnRegisterSelfDrawingNodeRectChangeCallback clientToService == nullptr"); return RENDER_SERVICE_NULL; } - return renderService->UnRegisterSelfDrawingNodeRectChangeCallback(); + return clientToService->UnRegisterSelfDrawingNodeRectChangeCallback(); } #ifdef RS_ENABLE_OVERLAY_DISPLAY int32_t RSRenderServiceClient::SetOverlayDisplayMode(int32_t mode) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RENDER_SERVICE_NULL; } - return renderService->SetOverlayDisplayMode(mode); + return clientToService->SetOverlayDisplayMode(mode); } #endif void RSRenderServiceClient::NotifyPageName(const std::string &packageName, const std::string &pageName, bool isEnter) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { - ROSEN_LOGE("RSRenderServiceClient::NotifyPageName renderService == nullptr!"); + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { + ROSEN_LOGE("RSRenderServiceClient::NotifyPageName clientToService == nullptr!"); return; } - renderService->NotifyPageName(packageName, pageName, isEnter); + clientToService->NotifyPageName(packageName, pageName, isEnter); } bool RSRenderServiceClient::GetHighContrastTextState() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - return renderService->GetHighContrastTextState(); + auto clientToRender = GetClientToRenderConnection(); + if (clientToRender != nullptr) { + return clientToRender->GetHighContrastTextState(); } return false; } bool RSRenderServiceClient::SetBehindWindowFilterEnabled(bool enabled) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (!renderService) { + auto clientToRender = GetClientToRenderConnection(); + if (!clientToRender) { return false; } - auto ret = renderService->SetBehindWindowFilterEnabled(enabled); + auto ret = clientToRender->SetBehindWindowFilterEnabled(enabled); if (ret != ERR_OK) { ROSEN_LOGE("RSRenderServiceClient::SetBehindWindowFilterEnabled fail, ret[%{public}d]", ret); return false; @@ -2420,11 +2420,11 @@ bool RSRenderServiceClient::SetBehindWindowFilterEnabled(bool enabled) bool RSRenderServiceClient::GetBehindWindowFilterEnabled(bool& enabled) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (!renderService) { + auto clientToRender = GetClientToRenderConnection(); + if (!clientToRender) { return false; } - auto ret = renderService->GetBehindWindowFilterEnabled(enabled); + auto ret = clientToRender->GetBehindWindowFilterEnabled(enabled); if (ret != ERR_OK) { ROSEN_LOGE("RSRenderServiceClient::GetBehindWindowFilterEnabled fail, ret[%{public}d]", ret); return false; @@ -2434,11 +2434,11 @@ bool RSRenderServiceClient::GetBehindWindowFilterEnabled(bool& enabled) int32_t RSRenderServiceClient::GetPidGpuMemoryInMB(pid_t pid, float &gpuMemInMB) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (!renderService) { + auto clientToRender = GetClientToRenderConnection(); + if (!clientToRender) { return ERR_INVALID_DATA; } - auto ret = renderService->GetPidGpuMemoryInMB(pid, gpuMemInMB); + auto ret = clientToRender->GetPidGpuMemoryInMB(pid, gpuMemInMB); if (ret != ERR_OK) { ROSEN_LOGE("RSRenderServiceClient::GetPidGpuMemoryInMB fail, ret[%{public}d]", ret); } @@ -2447,8 +2447,8 @@ int32_t RSRenderServiceClient::GetPidGpuMemoryInMB(pid_t pid, float &gpuMemInMB) RetCodeHrpService RSRenderServiceClient::ProfilerServiceOpenFile(const HrpServiceDirInfo& dirInfo, const std::string& fileName, int32_t flags, int& fd) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RET_HRP_SERVICE_ERR_UNKNOWN; } @@ -2457,38 +2457,48 @@ RetCodeHrpService RSRenderServiceClient::ProfilerServiceOpenFile(const HrpServic return RET_HRP_SERVICE_ERR_INVALID_PARAM; } fd = -1; - return renderService->ProfilerServiceOpenFile(dirInfo, fileName, flags, fd); + return clientToService->ProfilerServiceOpenFile(dirInfo, fileName, flags, fd); } RetCodeHrpService RSRenderServiceClient::ProfilerServicePopulateFiles(const HrpServiceDirInfo& dirInfo, uint32_t firstFileIndex, std::vector& outFiles) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService == nullptr) { + auto clientToService = GetClientToServiceConnection(); + if (clientToService == nullptr) { return RET_HRP_SERVICE_ERR_UNKNOWN; } if (!HrpServiceValidDirOrFileName(dirInfo.subDir) || !HrpServiceValidDirOrFileName(dirInfo.subDir2)) { return RET_HRP_SERVICE_ERR_INVALID_PARAM; } - return renderService->ProfilerServicePopulateFiles(dirInfo, firstFileIndex, outFiles); + return clientToService->ProfilerServicePopulateFiles(dirInfo, firstFileIndex, outFiles); } bool RSRenderServiceClient::ProfilerIsSecureScreen() { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (renderService != nullptr) { - return renderService->ProfilerIsSecureScreen(); + auto clientToService = GetClientToServiceConnection(); + if (clientToService != nullptr) { + return clientToService->ProfilerIsSecureScreen(); } return false; } void RSRenderServiceClient::ClearUifirstCache(NodeId id) { - auto renderService = RSRenderServiceConnectHub::GetRenderService(); - if (!renderService) { + auto clientToService = GetClientToServiceConnection(); + if (!clientToService) { return; } - renderService->ClearUifirstCache(id); + clientToService->ClearUifirstCache(id); +} + +std::shared_ptr RSRenderServiceClient::GetClientToServiceConnection() +{ + return RSRenderServiceConnectHub::GetRenderService().first; +} + +std::shared_ptr RSRenderServiceClient::GetClientToRenderConnection() +{ + return RSRenderServiceConnectHub::GetRenderService().second; } } // namespace Rosen } // namespace OHOS