mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
修改mutex为recursive_mutex 防止同进程调用时无法获取到锁
Signed-off-by: chenqinxin <chenqinxin1@huawei.com> Change-Id: I86aa44b78fbe1e1696d8d6bbb5c956475e7c7c0c
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#define FOUNDATION_DM_DISPLAY_MANAGER_ADAPTER_H
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <surface.h>
|
||||
|
||||
#include "display.h"
|
||||
@@ -61,7 +62,7 @@ private:
|
||||
|
||||
static inline SingletonDelegator<DisplayManagerAdapter> delegator;
|
||||
|
||||
std::mutex mutex_;
|
||||
std::recursive_mutex mutex_;
|
||||
sptr<IDisplayManager> displayManagerServiceProxy_ = nullptr;
|
||||
sptr<DMSDeathRecipient> dmsDeath_ = nullptr;
|
||||
std::map<DisplayId, sptr<Display>> displayMap_;
|
||||
|
||||
@@ -180,7 +180,7 @@ bool DisplayManager::RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventLi
|
||||
WLOGFE("listener is nullptr");
|
||||
return false;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
powerEventListeners_.push_back(listener);
|
||||
bool ret = true;
|
||||
if (powerEventListenerAgent_ == nullptr) {
|
||||
@@ -203,7 +203,7 @@ bool DisplayManager::UnregisterDisplayPowerEventListener(sptr<IDisplayPowerEvent
|
||||
return false;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
auto iter = std::find(powerEventListeners_.begin(), powerEventListeners_.end(), listener);
|
||||
if (iter == powerEventListeners_.end()) {
|
||||
WLOGFE("could not find this listener");
|
||||
@@ -224,7 +224,7 @@ void DisplayManager::NotifyDisplayPowerEvent(DisplayPowerEvent event, EventStatu
|
||||
{
|
||||
WLOGFI("NotifyDisplayPowerEvent event:%{public}u, status:%{public}u, size:%{public}zu", event, status,
|
||||
powerEventListeners_.size());
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
for (auto& listener : powerEventListeners_) {
|
||||
listener->OnDisplayPowerEvent(event, status);
|
||||
}
|
||||
@@ -233,9 +233,10 @@ void DisplayManager::NotifyDisplayPowerEvent(DisplayPowerEvent event, EventStatu
|
||||
void DisplayManager::NotifyDisplayStateChanged(DisplayState state)
|
||||
{
|
||||
WLOGFI("state:%{public}u", state);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (displayStateCallback_) {
|
||||
displayStateCallback_(state);
|
||||
WLOGFW("displayStateCallback_ end");
|
||||
ClearDisplayStateCallback();
|
||||
return;
|
||||
}
|
||||
@@ -276,11 +277,12 @@ bool DisplayManager::SuspendEnd()
|
||||
bool DisplayManager::SetScreenPowerForAll(DisplayPowerState state, PowerStateChangeReason reason)
|
||||
{
|
||||
// TODO: should get all screen ids
|
||||
WLOGFI("state:%{public}u, reason:%{public}u", state, reason);
|
||||
ScreenId defaultId = GetDefaultDisplayId();
|
||||
if (defaultId == DISPLAY_ID_INVALD) {
|
||||
WLOGFI("defaultId invalid!");
|
||||
return false;
|
||||
}
|
||||
WLOGFI("state:%{public}u, reason:%{public}u, defaultId:%{public}" PRIu64".", state, reason, defaultId);
|
||||
ScreenPowerStatus status;
|
||||
switch (state) {
|
||||
case DisplayPowerState::POWER_ON: {
|
||||
@@ -297,6 +299,7 @@ bool DisplayManager::SetScreenPowerForAll(DisplayPowerState state, PowerStateCha
|
||||
}
|
||||
}
|
||||
RSInterfaces::GetInstance().SetScreenPowerStatus(defaultId, status);
|
||||
WLOGFI("SetScreenPowerStatus end");
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().SetScreenPowerForAll(state, reason);
|
||||
}
|
||||
|
||||
@@ -310,7 +313,7 @@ DisplayPowerState DisplayManager::GetScreenPower(uint64_t screenId)
|
||||
bool DisplayManager::SetDisplayState(DisplayState state, DisplayStateCallback callback)
|
||||
{
|
||||
WLOGFI("state:%{public}u", state);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (displayStateCallback_ != nullptr || callback == nullptr) {
|
||||
WLOGFI("previous callback not called or callback invalid");
|
||||
return false;
|
||||
|
||||
@@ -29,7 +29,7 @@ WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManagerAdapter)
|
||||
|
||||
DisplayId DisplayManagerAdapter::GetDefaultDisplayId()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (defaultDisplayId_ != DISPLAY_ID_INVALD) {
|
||||
return defaultDisplayId_;
|
||||
@@ -45,7 +45,7 @@ DisplayId DisplayManagerAdapter::GetDefaultDisplayId()
|
||||
|
||||
sptr<Display> DisplayManagerAdapter::GetDisplayById(DisplayId displayId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
auto iter = displayMap_.find(displayId);
|
||||
if (iter != displayMap_.end()) {
|
||||
@@ -66,7 +66,7 @@ sptr<Display> DisplayManagerAdapter::GetDisplayById(DisplayId displayId)
|
||||
|
||||
std::shared_ptr<Media::PixelMap> DisplayManagerAdapter::GetDisplaySnapshot(DisplayId displayId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitDMSProxyLocked()) {
|
||||
WLOGFE("displayManagerAdapter::GetDisplaySnapshot: InitDMSProxyLocked failed!");
|
||||
@@ -99,7 +99,7 @@ DMError DisplayManagerAdapter::DestroyVirtualScreen(ScreenId screenId)
|
||||
bool DisplayManagerAdapter::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return false;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ bool DisplayManagerAdapter::RegisterDisplayManagerAgent(const sptr<IDisplayManag
|
||||
bool DisplayManagerAdapter::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return false;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ bool DisplayManagerAdapter::UnregisterDisplayManagerAgent(const sptr<IDisplayMan
|
||||
|
||||
bool DisplayManagerAdapter::WakeUpBegin(PowerStateChangeReason reason)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return false;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ bool DisplayManagerAdapter::WakeUpBegin(PowerStateChangeReason reason)
|
||||
|
||||
bool DisplayManagerAdapter::WakeUpEnd()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return false;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ bool DisplayManagerAdapter::WakeUpEnd()
|
||||
|
||||
bool DisplayManagerAdapter::SuspendBegin(PowerStateChangeReason reason)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return false;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ bool DisplayManagerAdapter::SuspendBegin(PowerStateChangeReason reason)
|
||||
|
||||
bool DisplayManagerAdapter::SuspendEnd()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return false;
|
||||
}
|
||||
@@ -154,7 +154,7 @@ bool DisplayManagerAdapter::SuspendEnd()
|
||||
|
||||
bool DisplayManagerAdapter::SetScreenPowerForAll(DisplayPowerState state, PowerStateChangeReason reason)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return false;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ bool DisplayManagerAdapter::SetScreenPowerForAll(DisplayPowerState state, PowerS
|
||||
|
||||
bool DisplayManagerAdapter::SetDisplayState(DisplayState state)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return false;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ bool DisplayManagerAdapter::SetDisplayState(DisplayState state)
|
||||
|
||||
DisplayState DisplayManagerAdapter::GetDisplayState(uint64_t displayId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return DisplayState::UNKNOWN;
|
||||
}
|
||||
@@ -182,7 +182,7 @@ DisplayState DisplayManagerAdapter::GetDisplayState(uint64_t displayId)
|
||||
|
||||
void DisplayManagerAdapter::NotifyDisplayEvent(DisplayEvent event)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return;
|
||||
}
|
||||
@@ -243,7 +243,7 @@ void DMSDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& wptrDeath)
|
||||
|
||||
void DisplayManagerAdapter::Clear()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if ((displayManagerServiceProxy_ != nullptr) && (displayManagerServiceProxy_->AsObject() != nullptr)) {
|
||||
displayManagerServiceProxy_->AsObject()->RemoveDeathRecipient(dmsDeath_);
|
||||
}
|
||||
|
||||
@@ -363,31 +363,20 @@ HWTEST_F(DisplayPowerTest, set_screen_power_for_all_003, Function | MediumTest |
|
||||
|
||||
/**
|
||||
* @tc.name: set_display_state_power_event_callback_001
|
||||
* @tc.desc: Call SetDisplayState OFF and check the OnDisplayPowerEvent callback is called
|
||||
* @tc.desc: Call SetDisplayState with a valid value and check the OnDisplayPowerEvent callback is called
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayPowerTest, set_display_state_power_event_callback_001, Function | MediumTest | Level2)
|
||||
{
|
||||
bool ret = DisplayManager::GetInstance().SetDisplayState(DisplayState::OFF, callback_);
|
||||
DisplayState initialState = DisplayManager::GetInstance().GetDisplayState(defaultId_);
|
||||
DisplayState stateToSet = (initialState == DisplayState::OFF ? DisplayState::ON : DisplayState::OFF);
|
||||
bool ret = DisplayManager::GetInstance().SetDisplayState(stateToSet, callback_);
|
||||
ASSERT_EQ(true, ret);
|
||||
CheckDisplayPowerEventCallback(true);
|
||||
ASSERT_EQ(true, listener_->isCallbackCalled_);
|
||||
ASSERT_EQ(DisplayPowerEvent::DISPLAY_OFF, listener_->event_);
|
||||
ASSERT_EQ(EventStatus::BEGIN, listener_->status_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: set_display_state_power_event_callback_002
|
||||
* @tc.desc: Call SetDisplayState ON and check the OnDisplayPowerEvent callback is called
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayPowerTest, set_display_state_power_event_callback_002, Function | MediumTest | Level2)
|
||||
{
|
||||
bool ret = DisplayManager::GetInstance().SetDisplayState(DisplayState::ON, callback_);
|
||||
ASSERT_EQ(true, ret);
|
||||
CheckDisplayPowerEventCallback(true);
|
||||
ASSERT_EQ(true, listener_->isCallbackCalled_);
|
||||
ASSERT_EQ(DisplayPowerEvent::DISPLAY_ON, listener_->event_);
|
||||
DisplayPowerEvent expectedEvent = (stateToSet == DisplayState::OFF ? DisplayPowerEvent::DISPLAY_OFF :
|
||||
DisplayPowerEvent::DISPLAY_ON);
|
||||
ASSERT_EQ(expectedEvent, listener_->event_);
|
||||
ASSERT_EQ(EventStatus::BEGIN, listener_->status_);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ private:
|
||||
DisplayManagerAgentController() : dmAgentContainer_(mutex_) {}
|
||||
virtual ~DisplayManagerAgentController() = default;
|
||||
|
||||
std::mutex mutex_;
|
||||
std::recursive_mutex mutex_;
|
||||
ClientAgentContainer<IDisplayManagerAgent, DisplayManagerAgentType> dmAgentContainer_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
void NotifyDisplayEvent(DisplayEvent event);
|
||||
|
||||
private:
|
||||
DisplayState displayState_ { DisplayState::ON };
|
||||
DisplayState displayState_ { DisplayState::UNKNOWN };
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,20 +26,20 @@ WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManagerAgentController)
|
||||
bool DisplayManagerAgentController::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
return dmAgentContainer_.RegisterAgentLocked(displayManagerAgent, type);
|
||||
}
|
||||
|
||||
bool DisplayManagerAgentController::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
return dmAgentContainer_.UnregisterAgentLocked(displayManagerAgent, type);
|
||||
}
|
||||
|
||||
bool DisplayManagerAgentController::NotifyDisplayPowerEvent(DisplayPowerEvent event, EventStatus status)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER);
|
||||
if (agents.empty()) {
|
||||
return false;
|
||||
@@ -53,7 +53,7 @@ bool DisplayManagerAgentController::NotifyDisplayPowerEvent(DisplayPowerEvent ev
|
||||
|
||||
bool DisplayManagerAgentController::NotifyDisplayStateChanged(DisplayState state)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::DISPLAY_STATE_LISTENER);
|
||||
if (agents.empty()) {
|
||||
return false;
|
||||
|
||||
@@ -70,6 +70,8 @@ void DisplayPowerController::NotifyDisplayEvent(DisplayEvent event)
|
||||
if (event == DisplayEvent::UNLOCK) {
|
||||
WLOGFI("DisplayEvent UNLOCK");
|
||||
// TODO: WindowManagerServiceInner::GetInstance().RestoreSuspendedWindows();
|
||||
DisplayManagerAgentController::GetInstance().NotifyDisplayPowerEvent(DisplayPowerEvent::DESKTOP_READY,
|
||||
EventStatus::BEGIN);
|
||||
return;
|
||||
}
|
||||
// TODO: set displayState_ ON when keyguard is drawn
|
||||
|
||||
@@ -72,7 +72,7 @@ private:
|
||||
|
||||
static inline SingletonDelegator<DisplayManager> delegator;
|
||||
const int32_t MAX_RESOLUTION_SIZE_SCREENSHOT = 15360; // max resolution, 16K
|
||||
std::mutex mutex_;
|
||||
std::recursive_mutex mutex_;
|
||||
std::vector<sptr<IDisplayPowerEventListener>> powerEventListeners_;
|
||||
sptr<DisplayManagerAgent> powerEventListenerAgent_;
|
||||
sptr<DisplayManagerAgent> displayStateAgent_;
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Rosen {
|
||||
template <typename T1, typename T2>
|
||||
class ClientAgentContainer {
|
||||
public:
|
||||
ClientAgentContainer(std::mutex& mutex);
|
||||
ClientAgentContainer(std::recursive_mutex& mutex);
|
||||
virtual ~ClientAgentContainer() = default;
|
||||
|
||||
bool RegisterAgentLocked(const sptr<T1>& agent, T2 type);
|
||||
@@ -49,13 +49,13 @@ private:
|
||||
sptr<IRemoteObject> remoteObject_;
|
||||
};
|
||||
|
||||
std::mutex& mutex_;
|
||||
std::recursive_mutex& mutex_;
|
||||
std::map<T2, std::vector<sptr<T1>>> agentMap_;
|
||||
sptr<AgentDeathRecipient> deathRecipient_;
|
||||
};
|
||||
|
||||
template<typename T1, typename T2>
|
||||
ClientAgentContainer<T1, T2>::ClientAgentContainer(std::mutex& mutex)
|
||||
ClientAgentContainer<T1, T2>::ClientAgentContainer(std::recursive_mutex& mutex)
|
||||
: mutex_(mutex), deathRecipient_(new AgentDeathRecipient(
|
||||
std::bind(&ClientAgentContainer<T1, T2>::RemoveAgent, this, std::placeholders::_1))) {}
|
||||
|
||||
@@ -111,7 +111,7 @@ template<typename T1, typename T2>
|
||||
void ClientAgentContainer<T1, T2>::RemoveAgent(const sptr<IRemoteObject>& remoteObject)
|
||||
{
|
||||
WLOG_I("ClientAgentContainer RemoveAgent");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
for (auto& elem : agentMap_) {
|
||||
if (UnregisterAgentLocked(elem.second, remoteObject)) {
|
||||
break;
|
||||
|
||||
@@ -60,7 +60,7 @@ private:
|
||||
static inline SingletonDelegator<WindowAdapter> delegator;
|
||||
bool InitWMSProxyLocked();
|
||||
|
||||
std::mutex mutex_;
|
||||
std::recursive_mutex mutex_;
|
||||
sptr<IWindowManager> windowManagerServiceProxy_ = nullptr;
|
||||
sptr<WMSDeathRecipient> wmsDeath_ = nullptr;
|
||||
};
|
||||
|
||||
+16
-16
@@ -28,7 +28,7 @@ WM_IMPLEMENT_SINGLE_INSTANCE(WindowAdapter)
|
||||
|
||||
WMError WindowAdapter::SaveAbilityToken(const sptr<IRemoteObject>& abilityToken, uint32_t windowId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return WMError::WM_ERROR_SAMGR;
|
||||
@@ -39,7 +39,7 @@ WMError WindowAdapter::SaveAbilityToken(const sptr<IRemoteObject>& abilityToken,
|
||||
WMError WindowAdapter::CreateWindow(sptr<IWindow>& window, sptr<WindowProperty>& windowProperty,
|
||||
std::shared_ptr<RSSurfaceNode> surfaceNode, uint32_t& windowId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return WMError::WM_ERROR_SAMGR;
|
||||
@@ -49,7 +49,7 @@ WMError WindowAdapter::CreateWindow(sptr<IWindow>& window, sptr<WindowProperty>&
|
||||
|
||||
WMError WindowAdapter::AddWindow(sptr<WindowProperty>& windowProperty)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return WMError::WM_ERROR_SAMGR;
|
||||
@@ -59,7 +59,7 @@ WMError WindowAdapter::AddWindow(sptr<WindowProperty>& windowProperty)
|
||||
|
||||
WMError WindowAdapter::RemoveWindow(uint32_t windowId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return WMError::WM_ERROR_SAMGR;
|
||||
@@ -69,7 +69,7 @@ WMError WindowAdapter::RemoveWindow(uint32_t windowId)
|
||||
|
||||
WMError WindowAdapter::DestroyWindow(uint32_t windowId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return WMError::WM_ERROR_SAMGR;
|
||||
@@ -79,7 +79,7 @@ WMError WindowAdapter::DestroyWindow(uint32_t windowId)
|
||||
|
||||
WMError WindowAdapter::MoveTo(uint32_t windowId, int32_t x, int32_t y)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return WMError::WM_ERROR_SAMGR;
|
||||
@@ -89,7 +89,7 @@ WMError WindowAdapter::MoveTo(uint32_t windowId, int32_t x, int32_t y)
|
||||
|
||||
WMError WindowAdapter::Resize(uint32_t windowId, uint32_t width, uint32_t height)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return WMError::WM_ERROR_SAMGR;
|
||||
@@ -99,7 +99,7 @@ WMError WindowAdapter::Resize(uint32_t windowId, uint32_t width, uint32_t height
|
||||
|
||||
WMError WindowAdapter::RequestFocus(uint32_t windowId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return WMError::WM_ERROR_SAMGR;
|
||||
@@ -109,7 +109,7 @@ WMError WindowAdapter::RequestFocus(uint32_t windowId)
|
||||
|
||||
WMError WindowAdapter::SetWindowFlags(uint32_t windowId, uint32_t flags)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return WMError::WM_ERROR_SAMGR;
|
||||
@@ -119,7 +119,7 @@ WMError WindowAdapter::SetWindowFlags(uint32_t windowId, uint32_t flags)
|
||||
|
||||
WMError WindowAdapter::SetSystemBarProperty(uint32_t windowId, WindowType type, const SystemBarProperty& property)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return WMError::WM_ERROR_SAMGR;
|
||||
@@ -130,7 +130,7 @@ WMError WindowAdapter::SetSystemBarProperty(uint32_t windowId, WindowType type,
|
||||
void WindowAdapter::RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return;
|
||||
@@ -141,7 +141,7 @@ void WindowAdapter::RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
void WindowAdapter::UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return;
|
||||
@@ -151,7 +151,7 @@ void WindowAdapter::UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
|
||||
WMError WindowAdapter::GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type, std::vector<Rect>& avoidRect)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return WMError::WM_ERROR_SAMGR;
|
||||
@@ -162,7 +162,7 @@ WMError WindowAdapter::GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type,
|
||||
|
||||
WMError WindowAdapter::SetWindowMode(uint32_t windowId, WindowMode mode)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return WMError::WM_ERROR_SAMGR;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ WMError WindowAdapter::SetWindowMode(uint32_t windowId, WindowMode mode)
|
||||
|
||||
WMError WindowAdapter::MinimizeAllAppNodeAbility(uint32_t windowId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitWMSProxyLocked()) {
|
||||
return WMError::WM_ERROR_SAMGR;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ bool WindowAdapter::InitWMSProxyLocked()
|
||||
|
||||
void WindowAdapter::ClearWindowAdapter()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if ((windowManagerServiceProxy_ != nullptr) && (windowManagerServiceProxy_->AsObject() != nullptr)) {
|
||||
windowManagerServiceProxy_->AsObject()->RemoveDeathRecipient(wmsDeath_);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
void NotifySystemBarChanged(uint64_t displayId, const SystemBarProps& props) const;
|
||||
static inline SingletonDelegator<WindowManager> delegator_;
|
||||
|
||||
std::mutex mutex_;
|
||||
std::recursive_mutex mutex_;
|
||||
std::vector<sptr<IFocusChangedListener>> focusChangedListeners_;
|
||||
sptr<WindowManagerAgent> focusChangedListenerAgent_;
|
||||
std::vector<sptr<ISystemBarChangedListener>> systemBarChangedListeners_;
|
||||
@@ -90,7 +90,7 @@ void WindowManager::RegisterFocusChangedListener(const sptr<IFocusChangedListene
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(pImpl_->mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
pImpl_->focusChangedListeners_.push_back(listener);
|
||||
if (pImpl_->focusChangedListenerAgent_ == nullptr) {
|
||||
pImpl_->focusChangedListenerAgent_ = new WindowManagerAgent();
|
||||
@@ -106,7 +106,7 @@ void WindowManager::UnregisterFocusChangedListener(const sptr<IFocusChangedListe
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(pImpl_->mutex_);
|
||||
std::lock_guard<std::recursive_mutex> 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");
|
||||
@@ -127,7 +127,7 @@ void WindowManager::RegisterSystemBarChangedListener(const sptr<ISystemBarChange
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(pImpl_->mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
pImpl_->systemBarChangedListeners_.push_back(listener);
|
||||
if (pImpl_->systemBarChangedListenerAgent_ == nullptr) {
|
||||
pImpl_->systemBarChangedListenerAgent_ = new WindowManagerAgent();
|
||||
@@ -143,7 +143,7 @@ void WindowManager::UnregisterSystemBarChangedListener(const sptr<ISystemBarChan
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(pImpl_->mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
auto iter = std::find(pImpl_->systemBarChangedListeners_.begin(), pImpl_->systemBarChangedListeners_.end(),
|
||||
listener);
|
||||
if (iter == pImpl_->systemBarChangedListeners_.end()) {
|
||||
|
||||
@@ -39,7 +39,7 @@ private:
|
||||
WindowManagerAgentController() : wmAgentContainer_(mutex_) {}
|
||||
virtual ~WindowManagerAgentController() = default;
|
||||
|
||||
std::mutex mutex_;
|
||||
std::recursive_mutex mutex_;
|
||||
ClientAgentContainer<IWindowManagerAgent, WindowManagerAgentType> wmAgentContainer_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -26,21 +26,21 @@ WM_IMPLEMENT_SINGLE_INSTANCE(WindowManagerAgentController)
|
||||
void WindowManagerAgentController::RegisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
|
||||
WindowManagerAgentType type)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
wmAgentContainer_.RegisterAgentLocked(windowManagerAgent, type);
|
||||
}
|
||||
|
||||
void WindowManagerAgentController::UnregisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
|
||||
WindowManagerAgentType type)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
wmAgentContainer_.UnregisterAgentLocked(windowManagerAgent, type);
|
||||
}
|
||||
|
||||
void WindowManagerAgentController::UpdateFocusStatus(uint32_t windowId, const sptr<IRemoteObject>& abilityToken,
|
||||
WindowType windowType, int32_t displayId, bool focused)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
WLOGFI("UpdateFocusStatus");
|
||||
for (auto& agent : wmAgentContainer_.GetAgentsByType(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS)) {
|
||||
agent->UpdateFocusStatus(windowId, abilityToken, windowType, displayId, focused);
|
||||
@@ -52,7 +52,7 @@ void WindowManagerAgentController::UpdateSystemBarProperties(uint64_t displayId,
|
||||
if (props.empty()) {
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
WLOGFI("UpdateSystemBarProperties");
|
||||
for (auto& agent : wmAgentContainer_.GetAgentsByType(
|
||||
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR)) {
|
||||
|
||||
Reference in New Issue
Block a user