/* * Copyright (c) 2021-2022 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 "window_manager.h" #include #include #include "marshalling_helper.h" #include "window_adapter.h" #include "window_manager_agent.h" #include "window_manager_hilog.h" #include "wm_common.h" #ifdef EFFICIENCY_MANAGER_ENABLE #include "suspend_manager_client.h" #endif // EFFICIENCY_MANAGER_ENABLE namespace OHOS { namespace Rosen { namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowManager"}; } WM_IMPLEMENT_SINGLE_INSTANCE(WindowManager) class WindowManager::Impl { public: explicit Impl(std::recursive_mutex& mutex) : mutex_(mutex) {} void NotifyFocused(uint32_t windowId, const sptr& abilityToken, WindowType windowType, DisplayId displayId); void NotifyUnfocused(uint32_t windowId, const sptr& abilityToken, WindowType windowType, DisplayId displayId); void NotifyFocused(const sptr& focusChangeInfo); void NotifyUnfocused(const sptr& focusChangeInfo); void NotifySystemBarChanged(DisplayId displayId, const SystemBarRegionTints& tints); void NotifyAccessibilityWindowInfo(const std::vector>& infos, WindowUpdateType type); void NotifyWindowVisibilityInfoChanged(const std::vector>& windowVisibilityInfos); void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing); void NotifyWaterMarkFlagChangedResult(bool showWaterMark); void NotifyGestureNavigationEnabledResult(bool enable); static inline SingletonDelegator delegator_; std::recursive_mutex& mutex_; std::vector> focusChangedListeners_; sptr focusChangedListenerAgent_; std::vector> systemBarChangedListeners_; sptr systemBarChangedListenerAgent_; std::vector> windowUpdateListeners_; sptr windowUpdateListenerAgent_; std::vector> windowVisibilityListeners_; sptr windowVisibilityListenerAgent_; std::vector> cameraFloatWindowChangedListeners_; sptr cameraFloatWindowChangedListenerAgent_; std::vector> waterMarkFlagChangeListeners_; sptr waterMarkFlagChangeAgent_; std::vector> gestureNavigationEnabledListeners_; sptr gestureNavigationEnabledAgent_; }; void WindowManager::Impl::NotifyFocused(const sptr& focusChangeInfo) { WLOGFD("NotifyFocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, static_cast(focusChangeInfo->windowType_)); std::vector> focusChangeListeners; { std::lock_guard lock(mutex_); focusChangeListeners = focusChangedListeners_; } for (auto& listener : focusChangeListeners) { listener->OnFocused(focusChangeInfo); } } void WindowManager::Impl::NotifyUnfocused(const sptr& focusChangeInfo) { WLOGFD("NotifyUnfocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, static_cast(focusChangeInfo->windowType_)); std::vector> focusChangeListeners; { std::lock_guard lock(mutex_); focusChangeListeners = focusChangedListeners_; } for (auto& listener : focusChangeListeners) { listener->OnUnfocused(focusChangeInfo); } } void WindowManager::Impl::NotifySystemBarChanged(DisplayId displayId, const SystemBarRegionTints& tints) { for (auto tint : tints) { WLOGFD("type:%{public}d, enable:%{public}d," \ "backgroundColor:%{public}x, contentColor:%{public}x " \ "region:[%{public}d, %{public}d, %{public}d, %{public}d]", tint.type_, tint.prop_.enable_, tint.prop_.backgroundColor_, tint.prop_.contentColor_, tint.region_.posX_, tint.region_.posY_, tint.region_.width_, tint.region_.height_); } std::vector> systemBarChangeListeners; { std::lock_guard lock(mutex_); systemBarChangeListeners = systemBarChangedListeners_; } for (auto& listener : systemBarChangeListeners) { listener->OnSystemBarPropertyChange(displayId, tints); } } void WindowManager::Impl::NotifyAccessibilityWindowInfo(const std::vector>& infos, WindowUpdateType type) { if (infos.empty()) { WLOGFE("infos is empty"); return; } for (auto& info : infos) { WLOGFD("NotifyAccessibilityWindowInfo: wid[%{public}u], innerWid_[%{public}u], uiNodeId_[%{public}u]," \ "rect[%{public}d %{public}d %{public}d %{public}d]," \ "isFocused[%{public}d], isDecorEnable[%{public}d], displayId[%{public}" PRIu64"], layer[%{public}u]," \ "mode[%{public}u], type[%{public}u, updateType[%{public}d]", info->wid_, info->innerWid_, info->uiNodeId_, info->windowRect_.width_, info->windowRect_.height_, info->windowRect_.posX_, info->windowRect_.posY_, info->focused_, info->isDecorEnable_, info->displayId_, info->layer_, info->mode_, info->type_, type); } std::vector> windowUpdateListeners; { std::lock_guard lock(mutex_); windowUpdateListeners = windowUpdateListeners_; } for (auto& listener : windowUpdateListeners) { listener->OnWindowUpdate(infos, type); } } void WindowManager::Impl::NotifyWindowVisibilityInfoChanged( const std::vector>& windowVisibilityInfos) { std::vector> visibilityChangeListeners; { std::lock_guard lock(mutex_); visibilityChangeListeners = windowVisibilityListeners_; } for (auto& listener : visibilityChangeListeners) { WLOGI("Notify WindowVisibilityInfo to caller"); listener->OnWindowVisibilityChanged(windowVisibilityInfos); } } void WindowManager::Impl::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) { WLOGFD("Camera float window, accessTokenId = %{public}u, isShowing = %{public}u", accessTokenId, isShowing); std::vector> cameraFloatWindowChangeListeners; { std::lock_guard lock(mutex_); cameraFloatWindowChangeListeners = cameraFloatWindowChangedListeners_; } for (auto& listener : cameraFloatWindowChangeListeners) { listener->OnCameraFloatWindowChange(accessTokenId, isShowing); } } void WindowManager::Impl::NotifyWaterMarkFlagChangedResult(bool showWaterMark) { WLOGFI("Notify water mark flag changed result, showWaterMark = %{public}d", showWaterMark); std::vector> waterMarkFlagChangeListeners; { std::lock_guard lock(mutex_); waterMarkFlagChangeListeners = waterMarkFlagChangeListeners_; } for (auto& listener : waterMarkFlagChangeListeners) { listener->OnWaterMarkFlagUpdate(showWaterMark); } } void WindowManager::Impl::NotifyGestureNavigationEnabledResult(bool enable) { WLOGFI("Notify gesture navigation enable result, enable = %{public}d", enable); std::vector> gestureNavigationEnabledListeners; { std::lock_guard lock(mutex_); gestureNavigationEnabledListeners = gestureNavigationEnabledListeners_; } for (auto& listener : gestureNavigationEnabledListeners) { listener->OnGestureNavigationEnabledUpdate(enable); } } WindowManager::WindowManager() : pImpl_(std::make_unique(mutex_)) {} WindowManager::~WindowManager() { std::lock_guard lock(mutex_); destroyed_ = true; } WMError WindowManager::RegisterFocusChangedListener(const sptr& listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); WMError ret = WMError::WM_OK; if (pImpl_->focusChangedListenerAgent_ == nullptr) { pImpl_->focusChangedListenerAgent_ = new WindowManagerAgent(); ret = SingletonContainer::Get().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS, pImpl_->focusChangedListenerAgent_); } if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed !"); pImpl_->focusChangedListenerAgent_ = nullptr; } else { auto iter = std::find(pImpl_->focusChangedListeners_.begin(), pImpl_->focusChangedListeners_.end(), listener); if (iter != pImpl_->focusChangedListeners_.end()) { WLOGFW("Listener is already registered."); return WMError::WM_OK; } pImpl_->focusChangedListeners_.push_back(listener); } return ret; } WMError WindowManager::UnregisterFocusChangedListener(const sptr& listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); auto iter = std::find(pImpl_->focusChangedListeners_.begin(), pImpl_->focusChangedListeners_.end(), listener); if (iter == pImpl_->focusChangedListeners_.end()) { WLOGFE("could not find this listener"); return WMError::WM_OK; } pImpl_->focusChangedListeners_.erase(iter); WMError ret = WMError::WM_OK; if (pImpl_->focusChangedListeners_.empty() && pImpl_->focusChangedListenerAgent_ != nullptr) { ret = SingletonContainer::Get().UnregisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS, pImpl_->focusChangedListenerAgent_); if (ret == WMError::WM_OK) { pImpl_->focusChangedListenerAgent_ = nullptr; } } return ret; } WMError WindowManager::RegisterSystemBarChangedListener(const sptr& listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); WMError ret = WMError::WM_OK; if (pImpl_->systemBarChangedListenerAgent_ == nullptr) { pImpl_->systemBarChangedListenerAgent_ = new WindowManagerAgent(); ret = SingletonContainer::Get().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR, pImpl_->systemBarChangedListenerAgent_); } if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed !"); pImpl_->systemBarChangedListenerAgent_ = nullptr; } else { auto iter = std::find(pImpl_->systemBarChangedListeners_.begin(), pImpl_->systemBarChangedListeners_.end(), listener); if (iter != pImpl_->systemBarChangedListeners_.end()) { WLOGFW("Listener is already registered."); return WMError::WM_OK; } pImpl_->systemBarChangedListeners_.push_back(listener); } return ret; } WMError WindowManager::UnregisterSystemBarChangedListener(const sptr& listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); auto iter = std::find(pImpl_->systemBarChangedListeners_.begin(), pImpl_->systemBarChangedListeners_.end(), listener); if (iter == pImpl_->systemBarChangedListeners_.end()) { WLOGFE("could not find this listener"); return WMError::WM_OK; } pImpl_->systemBarChangedListeners_.erase(iter); WMError ret = WMError::WM_OK; if (pImpl_->systemBarChangedListeners_.empty() && pImpl_->systemBarChangedListenerAgent_ != nullptr) { ret = SingletonContainer::Get().UnregisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR, pImpl_->systemBarChangedListenerAgent_); if (ret == WMError::WM_OK) { pImpl_->systemBarChangedListenerAgent_ = nullptr; } } return ret; } WMError WindowManager::MinimizeAllAppWindows(DisplayId displayId) { WLOGFD("displayId %{public}" PRIu64"", displayId); return SingletonContainer::Get().MinimizeAllAppWindows(displayId); } WMError WindowManager::ToggleShownStateForAllAppWindows() { WLOGFD("ToggleShownStateForAllAppWindows"); return SingletonContainer::Get().ToggleShownStateForAllAppWindows(); } WMError WindowManager::SetWindowLayoutMode(WindowLayoutMode mode) { WLOGFD("set window layout mode: %{public}u", mode); WMError ret = SingletonContainer::Get().SetWindowLayoutMode(mode); if (ret != WMError::WM_OK) { WLOGFE("set layout mode failed"); } return ret; } WMError WindowManager::RegisterWindowUpdateListener(const sptr &listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); WMError ret = WMError::WM_OK; if (pImpl_->windowUpdateListenerAgent_ == nullptr) { pImpl_->windowUpdateListenerAgent_ = new WindowManagerAgent(); ret = SingletonContainer::Get().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE, pImpl_->windowUpdateListenerAgent_); } if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed !"); pImpl_->windowUpdateListenerAgent_ = nullptr; } else { auto iter = std::find(pImpl_->windowUpdateListeners_.begin(), pImpl_->windowUpdateListeners_.end(), listener); if (iter != pImpl_->windowUpdateListeners_.end()) { WLOGI("Listener is already registered."); return WMError::WM_OK; } pImpl_->windowUpdateListeners_.emplace_back(listener); } return ret; } WMError WindowManager::UnregisterWindowUpdateListener(const sptr& listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); auto iter = std::find(pImpl_->windowUpdateListeners_.begin(), pImpl_->windowUpdateListeners_.end(), listener); if (iter == pImpl_->windowUpdateListeners_.end()) { WLOGFE("could not find this listener"); return WMError::WM_OK; } pImpl_->windowUpdateListeners_.erase(iter); WMError ret = WMError::WM_OK; if (pImpl_->windowUpdateListeners_.empty() && pImpl_->windowUpdateListenerAgent_ != nullptr) { ret = SingletonContainer::Get().UnregisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE, pImpl_->windowUpdateListenerAgent_); if (ret == WMError::WM_OK) { pImpl_->windowUpdateListenerAgent_ = nullptr; } } return ret; } WMError WindowManager::RegisterVisibilityChangedListener(const sptr& listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); WMError ret = WMError::WM_OK; if (pImpl_->windowVisibilityListenerAgent_ == nullptr) { pImpl_->windowVisibilityListenerAgent_ = new WindowManagerAgent(); ret = SingletonContainer::Get().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY, pImpl_->windowVisibilityListenerAgent_); } if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed !"); pImpl_->windowVisibilityListenerAgent_ = nullptr; } else { auto iter = std::find(pImpl_->windowVisibilityListeners_.begin(), pImpl_->windowVisibilityListeners_.end(), listener); if (iter != pImpl_->windowVisibilityListeners_.end()) { WLOGFW("Listener is already registered."); return WMError::WM_OK; } pImpl_->windowVisibilityListeners_.emplace_back(listener); } return ret; } WMError WindowManager::UnregisterVisibilityChangedListener(const sptr& listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); pImpl_->windowVisibilityListeners_.erase(std::remove_if(pImpl_->windowVisibilityListeners_.begin(), pImpl_->windowVisibilityListeners_.end(), [listener](sptr registeredListener) { return registeredListener == listener; }), pImpl_->windowVisibilityListeners_.end()); WMError ret = WMError::WM_OK; if (pImpl_->windowVisibilityListeners_.empty() && pImpl_->windowVisibilityListenerAgent_ != nullptr) { ret = SingletonContainer::Get().UnregisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY, pImpl_->windowVisibilityListenerAgent_); if (ret == WMError::WM_OK) { pImpl_->windowVisibilityListenerAgent_ = nullptr; } } return ret; } WMError WindowManager::RegisterCameraFloatWindowChangedListener(const sptr& listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); WMError ret = WMError::WM_OK; if (pImpl_->cameraFloatWindowChangedListenerAgent_ == nullptr) { pImpl_->cameraFloatWindowChangedListenerAgent_ = new WindowManagerAgent(); ret = SingletonContainer::Get().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT, pImpl_->cameraFloatWindowChangedListenerAgent_); } if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed !"); pImpl_->cameraFloatWindowChangedListenerAgent_ = nullptr; } else { auto iter = std::find(pImpl_->cameraFloatWindowChangedListeners_.begin(), pImpl_->cameraFloatWindowChangedListeners_.end(), listener); if (iter != pImpl_->cameraFloatWindowChangedListeners_.end()) { WLOGFW("Listener is already registered."); return WMError::WM_OK; } pImpl_->cameraFloatWindowChangedListeners_.push_back(listener); } return ret; } WMError WindowManager::UnregisterCameraFloatWindowChangedListener( const sptr& listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); auto iter = std::find(pImpl_->cameraFloatWindowChangedListeners_.begin(), pImpl_->cameraFloatWindowChangedListeners_.end(), listener); if (iter == pImpl_->cameraFloatWindowChangedListeners_.end()) { WLOGFE("could not find this listener"); return WMError::WM_OK; } pImpl_->cameraFloatWindowChangedListeners_.erase(iter); WMError ret = WMError::WM_OK; if (pImpl_->cameraFloatWindowChangedListeners_.empty() && pImpl_->cameraFloatWindowChangedListenerAgent_ != nullptr) { ret = SingletonContainer::Get().UnregisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT, pImpl_->cameraFloatWindowChangedListenerAgent_); if (ret == WMError::WM_OK) { pImpl_->cameraFloatWindowChangedListenerAgent_ = nullptr; } } return ret; } WMError WindowManager::RegisterWaterMarkFlagChangedListener(const sptr& listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); WMError ret = WMError::WM_OK; if (pImpl_->waterMarkFlagChangeAgent_ == nullptr) { pImpl_->waterMarkFlagChangeAgent_ = new WindowManagerAgent(); ret = SingletonContainer::Get().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG, pImpl_->waterMarkFlagChangeAgent_); } if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed !"); pImpl_->waterMarkFlagChangeAgent_ = nullptr; } else { auto iter = std::find(pImpl_->waterMarkFlagChangeListeners_.begin(), pImpl_->waterMarkFlagChangeListeners_.end(), listener); if (iter != pImpl_->waterMarkFlagChangeListeners_.end()) { WLOGFW("Listener is already registered."); return WMError::WM_OK; } pImpl_->waterMarkFlagChangeListeners_.push_back(listener); } WLOGFD("Try to registerWaterMarkFlagChangedListener && result : %{public}u", static_cast(ret)); return ret; } WMError WindowManager::UnregisterWaterMarkFlagChangedListener(const sptr& listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); auto iter = std::find(pImpl_->waterMarkFlagChangeListeners_.begin(), pImpl_->waterMarkFlagChangeListeners_.end(), listener); if (iter == pImpl_->waterMarkFlagChangeListeners_.end()) { WLOGFE("could not find this listener"); return WMError::WM_OK; } pImpl_->waterMarkFlagChangeListeners_.erase(iter); WMError ret = WMError::WM_OK; if (pImpl_->waterMarkFlagChangeListeners_.empty() && pImpl_->waterMarkFlagChangeAgent_ != nullptr) { ret = SingletonContainer::Get().UnregisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG, pImpl_->waterMarkFlagChangeAgent_); if (ret == WMError::WM_OK) { pImpl_->waterMarkFlagChangeAgent_ = nullptr; } } WLOGFD("Try to unregisterWaterMarkFlagChangedListener && result : %{public}u", static_cast(ret)); return ret; } WMError WindowManager::RegisterGestureNavigationEnabledChangedListener( const sptr& listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); WMError ret = WMError::WM_OK; if (pImpl_->gestureNavigationEnabledAgent_ == nullptr) { pImpl_->gestureNavigationEnabledAgent_ = new (std::nothrow)WindowManagerAgent(); if (pImpl_->gestureNavigationEnabledAgent_ != nullptr) { ret = SingletonContainer::Get().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_GESTURE_NAVIGATION_ENABLED, pImpl_->gestureNavigationEnabledAgent_); } else { WLOGFE("Create windowManagerAgent object failed !"); ret = WMError::WM_ERROR_NULLPTR; } } if (ret != WMError::WM_OK) { WLOGFE("RegisterWindowManagerAgent failed !"); pImpl_->gestureNavigationEnabledAgent_ = nullptr; } else { auto iter = std::find(pImpl_->gestureNavigationEnabledListeners_.begin(), pImpl_->gestureNavigationEnabledListeners_.end(), listener); if (iter != pImpl_->gestureNavigationEnabledListeners_.end()) { WLOGFW("Listener is already registered."); return WMError::WM_OK; } pImpl_->gestureNavigationEnabledListeners_.push_back(listener); } WLOGFD("Try to registerGestureNavigationEnabledChangedListener and result is %{public}u", static_cast(ret)); return ret; } WMError WindowManager::UnregisterGestureNavigationEnabledChangedListener( const sptr& listener) { if (listener == nullptr) { WLOGFE("listener could not be null"); return WMError::WM_ERROR_NULLPTR; } std::lock_guard lock(pImpl_->mutex_); auto iter = std::find(pImpl_->gestureNavigationEnabledListeners_.begin(), pImpl_->gestureNavigationEnabledListeners_.end(), listener); if (iter == pImpl_->gestureNavigationEnabledListeners_.end()) { WLOGFE("could not find this listener"); return WMError::WM_ERROR_INVALID_PARAM; } pImpl_->gestureNavigationEnabledListeners_.erase(iter); WMError ret = WMError::WM_OK; if (pImpl_->gestureNavigationEnabledListeners_.empty() && pImpl_->gestureNavigationEnabledAgent_ != nullptr) { ret = SingletonContainer::Get().UnregisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_GESTURE_NAVIGATION_ENABLED, pImpl_->gestureNavigationEnabledAgent_); if (ret == WMError::WM_OK) { pImpl_->gestureNavigationEnabledAgent_ = nullptr; } } WLOGFD("Try to unregisterGestureNavigationEnabledChangedListener and result is %{public}u", static_cast(ret)); return ret; } void WindowManager::GetFocusWindowInfo(FocusChangeInfo& focusInfo) { SingletonContainer::Get().GetFocusWindowInfo(focusInfo); } void WindowManager::UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused) const { if (focusChangeInfo == nullptr) { WLOGFE("focusChangeInfo is nullptr."); return; } WLOGFD("window focus change: %{public}d, id: %{public}u", focused, focusChangeInfo->windowId_); if (focused) { #ifdef EFFICIENCY_MANAGER_ENABLE SuspendManager::SuspendManagerClient::GetInstance().ThawOneApplication(focusChangeInfo->uid_, "", "THAW_BY_FOCUS_CHANGED"); #endif // EFFICIENCY_MANAGER_ENABLE pImpl_->NotifyFocused(focusChangeInfo); } else { pImpl_->NotifyUnfocused(focusChangeInfo); } } void WindowManager::UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints) const { pImpl_->NotifySystemBarChanged(displayId, tints); } void WindowManager::NotifyAccessibilityWindowInfo(const std::vector>& infos, WindowUpdateType type) const { pImpl_->NotifyAccessibilityWindowInfo(infos, type); } void WindowManager::UpdateWindowVisibilityInfo( const std::vector>& windowVisibilityInfos) const { pImpl_->NotifyWindowVisibilityInfoChanged(windowVisibilityInfos); } WMError WindowManager::GetAccessibilityWindowInfo(std::vector>& infos) const { WMError ret = SingletonContainer::Get().GetAccessibilityWindowInfo(infos); if (ret != WMError::WM_OK) { WLOGFE("get window info failed"); } return ret; } WMError WindowManager::GetVisibilityWindowInfo(std::vector>& infos) const { WMError ret = SingletonContainer::Get().GetVisibilityWindowInfo(infos); if (ret != WMError::WM_OK) { WLOGFE("get window visibility info failed"); } return ret; } WMError WindowManager::SetGestureNavigaionEnabled(bool enable) const { WMError ret = SingletonContainer::Get().SetGestureNavigaionEnabled(enable); if (ret != WMError::WM_OK) { WLOGFE("set gesture navigaion enabled failed"); } return ret; } void WindowManager::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) const { pImpl_->UpdateCameraFloatWindowStatus(accessTokenId, isShowing); } void WindowManager::NotifyWaterMarkFlagChangedResult(bool showWaterMark) const { pImpl_->NotifyWaterMarkFlagChangedResult(showWaterMark); } void WindowManager::NotifyGestureNavigationEnabledResult(bool enable) const { pImpl_->NotifyGestureNavigationEnabledResult(enable); } void WindowManager::OnRemoteDied() { WLOGI("wms is died"); std::lock_guard lock(mutex_); if (destroyed_) { WLOGE("Already destroyed"); return; } pImpl_->focusChangedListenerAgent_ = nullptr; pImpl_->systemBarChangedListenerAgent_ = nullptr; pImpl_->windowUpdateListenerAgent_ = nullptr; pImpl_->windowVisibilityListenerAgent_ = nullptr; pImpl_->cameraFloatWindowChangedListenerAgent_ = nullptr; } } // namespace Rosen } // namespace OHOS