From 2c40a464a2d2a5d9bac585ff6cd8366626c4faba Mon Sep 17 00:00:00 2001 From: zhdengc <15223574545@163.com> Date: Tue, 11 May 2021 10:30:13 +0800 Subject: [PATCH] IssueNo:#I3QPHC Description:Singleton adjustment Feature or Bugfix:Feature Binary Source:No --- frameworks/ims/input_event_client_proxy.h | 6 +----- frameworks/ims/input_event_listener_proxy.cpp | 6 ++++++ frameworks/wms/lite_wm_requestor.cpp | 6 ++++++ frameworks/wms/lite_wm_requestor.h | 7 +------ frameworks/wms/lite_wms_client.cpp | 6 ++++++ frameworks/wms/lite_wms_client.h | 6 +----- interfaces/innerkits/input_event_listener_proxy.h | 6 +----- services/ims/input_event_client_proxy.cpp | 6 ++++++ services/ims/input_event_hub.cpp | 6 ++++++ services/ims/input_event_hub.h | 6 +----- services/ims/input_manager_service.cpp | 6 ++++++ services/ims/input_manager_service.h | 6 +----- services/wms/lite_wm.cpp | 6 ++++++ services/wms/lite_wm.h | 6 +----- services/wms/lite_wms.cpp | 6 ++++++ services/wms/lite_wms.h | 6 +----- 16 files changed, 56 insertions(+), 41 deletions(-) diff --git a/frameworks/ims/input_event_client_proxy.h b/frameworks/ims/input_event_client_proxy.h index b2d86f4..610280c 100755 --- a/frameworks/ims/input_event_client_proxy.h +++ b/frameworks/ims/input_event_client_proxy.h @@ -28,11 +28,7 @@ namespace OHOS { #define MAX_CLIENT_SIZE 1 class InputEventClientProxy : public InputEventDistributer::RawEventListener { public: - static InputEventClientProxy* GetInstance() - { - static InputEventClientProxy ims; - return &ims; - } + static InputEventClientProxy* GetInstance(); static void ClientRequestHandle(int funcId, void* origin, IpcIo* req, IpcIo* reply); diff --git a/frameworks/ims/input_event_listener_proxy.cpp b/frameworks/ims/input_event_listener_proxy.cpp index 7d39650..6807dc5 100755 --- a/frameworks/ims/input_event_listener_proxy.cpp +++ b/frameworks/ims/input_event_listener_proxy.cpp @@ -27,6 +27,12 @@ InputEventListenerProxy::~InputEventListenerProxy() } } +InputEventListenerProxy* InputEventListenerProxy::GetInstance() +{ + static InputEventListenerProxy client; + return &client; +} + bool InputEventListenerProxy::GetIClientProxy() { if (proxy_ == nullptr) { diff --git a/frameworks/wms/lite_wm_requestor.cpp b/frameworks/wms/lite_wm_requestor.cpp index 66560e1..a652c41 100755 --- a/frameworks/wms/lite_wm_requestor.cpp +++ b/frameworks/wms/lite_wm_requestor.cpp @@ -21,6 +21,12 @@ #include "surface_impl.h" namespace OHOS { +LiteWMRequestor* LiteWMRequestor::GetInstance() +{ + static LiteWMRequestor requestor; + return &requestor; +} + LiteWMRequestor::LiteWMRequestor() : proxy_(nullptr), listener_(nullptr), surface_(nullptr), sid_({}), layerInfo_({}) { proxy_ = LiteWMSClient::GetInstance()->GetClientProxy(); diff --git a/frameworks/wms/lite_wm_requestor.h b/frameworks/wms/lite_wm_requestor.h index 4f88e8c..043a973 100755 --- a/frameworks/wms/lite_wm_requestor.h +++ b/frameworks/wms/lite_wm_requestor.h @@ -26,12 +26,7 @@ namespace OHOS { class LiteWMRequestor : public IBufferConsumerListener { public: - static LiteWMRequestor* GetInstance() - { - static LiteWMRequestor requestor; - return &requestor; - } - + static LiteWMRequestor* GetInstance(); static int Callback(void* owner, int code, IpcIo* reply); static int32_t WmsMsgHandler(const IpcContext* context, void* ipcMsg, IpcIo* io, void* arg); static int32_t SurfaceRequestHandler(const IpcContext* context, void* ipcMsg, IpcIo* io, void* arg); diff --git a/frameworks/wms/lite_wms_client.cpp b/frameworks/wms/lite_wms_client.cpp index 05498d6..0448978 100755 --- a/frameworks/wms/lite_wms_client.cpp +++ b/frameworks/wms/lite_wms_client.cpp @@ -19,6 +19,12 @@ #include "samgr_lite.h" namespace OHOS { +LiteWMSClient* LiteWMSClient::GetInstance() +{ + static LiteWMSClient client; + return &client; +} + LiteWMSClient::~LiteWMSClient() { if (proxy_ != nullptr) { diff --git a/frameworks/wms/lite_wms_client.h b/frameworks/wms/lite_wms_client.h index 11e214d..7db07fa 100755 --- a/frameworks/wms/lite_wms_client.h +++ b/frameworks/wms/lite_wms_client.h @@ -26,11 +26,7 @@ static const int32_t DEFAULT_IPC_SIZE = 100; class LiteWMSClient { public: - static LiteWMSClient* GetInstance() - { - static LiteWMSClient client; - return &client; - } + static LiteWMSClient* GetInstance(); bool InitLiteWMSClient(); diff --git a/interfaces/innerkits/input_event_listener_proxy.h b/interfaces/innerkits/input_event_listener_proxy.h index 66e5eb4..eb35669 100755 --- a/interfaces/innerkits/input_event_listener_proxy.h +++ b/interfaces/innerkits/input_event_listener_proxy.h @@ -23,11 +23,7 @@ namespace OHOS { class InputEventListenerProxy { public: - static InputEventListenerProxy* GetInstance() - { - static InputEventListenerProxy client; - return &client; - } + static InputEventListenerProxy* GetInstance(); class RawEventListener { public: diff --git a/services/ims/input_event_client_proxy.cpp b/services/ims/input_event_client_proxy.cpp index 81f9b63..ce3a5bf 100755 --- a/services/ims/input_event_client_proxy.cpp +++ b/services/ims/input_event_client_proxy.cpp @@ -19,6 +19,12 @@ namespace OHOS { pthread_mutex_t InputEventClientProxy::lock_; +InputEventClientProxy* InputEventClientProxy::GetInstance() +{ + static InputEventClientProxy ims; + return &ims; +} + void InputEventClientProxy::ClientRequestHandle(int funcId, void* origin, IpcIo* req, IpcIo* reply) { switch (funcId) { diff --git a/services/ims/input_event_hub.cpp b/services/ims/input_event_hub.cpp index 9b61747..f96a03c 100755 --- a/services/ims/input_event_hub.cpp +++ b/services/ims/input_event_hub.cpp @@ -26,6 +26,12 @@ IInputInterface* InputEventHub::inputInterface_ = nullptr; InputReportEventCb InputEventHub::callback_ = { 0 }; InputEventHub::ReadCallback InputEventHub::readCallback_ = nullptr; +InputEventHub* InputEventHub::GetInstance() +{ + static InputEventHub instance; + return &instance; +} + InputEventHub::InputEventHub() { for (uint8_t i = 0; i < MAX_INPUT_DEVICE_NUM; i++) { diff --git a/services/ims/input_event_hub.h b/services/ims/input_event_hub.h index f9c5312..e6d612a 100755 --- a/services/ims/input_event_hub.h +++ b/services/ims/input_event_hub.h @@ -29,11 +29,7 @@ namespace OHOS { class InputEventHub { using ReadCallback = void (*)(const RawEvent*); public: - static InputEventHub* GetInstance() - { - static InputEventHub instance; - return &instance; - } + static InputEventHub* GetInstance(); /** * @brief SetUp hub. This operation will open all input devices. diff --git a/services/ims/input_manager_service.cpp b/services/ims/input_manager_service.cpp index f6e4e33..7d647a3 100755 --- a/services/ims/input_manager_service.cpp +++ b/services/ims/input_manager_service.cpp @@ -27,6 +27,12 @@ pthread_mutex_t InputManagerService::lock_; pthread_cond_t InputManagerService::nonEmpty_; pthread_cond_t InputManagerService::nonFull_; +InputManagerService* InputManagerService::GetInstance() +{ + static InputManagerService instance; + return &instance; +} + void InputManagerService::Run() { hub_ = InputEventHub::GetInstance(); diff --git a/services/ims/input_manager_service.h b/services/ims/input_manager_service.h index a0d380c..812439c 100755 --- a/services/ims/input_manager_service.h +++ b/services/ims/input_manager_service.h @@ -30,11 +30,7 @@ public: * * @returns instance of input manager service */ - static InputManagerService* GetInstance() - { - static InputManagerService instance; - return &instance; - } + static InputManagerService* GetInstance(); /** * Init input manager service. diff --git a/services/wms/lite_wm.cpp b/services/wms/lite_wm.cpp index 977f5b3..bafc3d5 100755 --- a/services/wms/lite_wm.cpp +++ b/services/wms/lite_wm.cpp @@ -124,6 +124,12 @@ LiteWM::~LiteWM() { } +LiteWM* LiteWM::GetInstance() +{ + static LiteWM liteWm; + return &liteWm; +} + void LiteWM::MainTaskHandler() { if (layerData_ == nullptr || layerData_->virAddr == nullptr) { diff --git a/services/wms/lite_wm.h b/services/wms/lite_wm.h index a666c8b..1fc8639 100755 --- a/services/wms/lite_wm.h +++ b/services/wms/lite_wm.h @@ -44,11 +44,7 @@ struct CursorInfo { class LiteWM : public InputEventDistributer::RawEventListener { public: - static LiteWM* GetInstance() - { - static LiteWM liteWm; - return &liteWm; - } + static LiteWM* GetInstance(); void MainTaskHandler(); diff --git a/services/wms/lite_wms.cpp b/services/wms/lite_wms.cpp index 0feac13..47fd9b7 100755 --- a/services/wms/lite_wms.cpp +++ b/services/wms/lite_wms.cpp @@ -21,6 +21,12 @@ #include "surface_impl.h" namespace OHOS { +LiteWMS* LiteWMS::GetInstance() +{ + static LiteWMS wms; + return &wms; +} + void LiteWMS::WMSRequestHandle(int funcId, void* origin, IpcIo* req, IpcIo* reply) { switch (funcId) { diff --git a/services/wms/lite_wms.h b/services/wms/lite_wms.h index 52a4882..2bf84d0 100755 --- a/services/wms/lite_wms.h +++ b/services/wms/lite_wms.h @@ -29,11 +29,7 @@ public: SvcIdentity sid; }; - static LiteWMS* GetInstance() - { - static LiteWMS wms; - return &wms; - } + static LiteWMS* GetInstance(); static void WMSRequestHandle(int funcId, void* origin, IpcIo* req, IpcIo* reply); -- Gitee