From e6b1e80a4125e737bb32ab427358adf7c180be56 Mon Sep 17 00:00:00 2001 From: lishuo Date: Tue, 27 May 2025 17:52:34 +0800 Subject: [PATCH 1/6] fix: null check token Signed-off-by: lishuo --- frameworks/native/running_lock.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frameworks/native/running_lock.cpp b/frameworks/native/running_lock.cpp index 56ea986f..52aebb4c 100644 --- a/frameworks/native/running_lock.cpp +++ b/frameworks/native/running_lock.cpp @@ -93,6 +93,10 @@ ErrCode RunningLock::Lock(int32_t timeOutMs) POWER_HILOGE(FEATURE_RUNNING_LOCK, "LProxy=null"); return E_GET_POWER_SERVICE_FAILED; } + if (token_ == nullptr) { + POWER_HILOGE(FEATURE_RUNNING_LOCK, "token_=nullptr"); + return PowerErrors::ERR_CONNECTION_FAIL; + } POWER_HILOGD(FEATURE_RUNNING_LOCK, "Service side Lock call, timeOutMs=%{public}d", timeOutMs); if (runningLockInfo_.type == RunningLockType::RUNNINGLOCK_PROXIMITY_SCREEN_CONTROL) { timeOutMs = NOT_USE_TIMEOUT; -- Gitee From 2f9880f38e617f5c59fcbc6363ce373e126a9e28 Mon Sep 17 00:00:00 2001 From: lishuo Date: Tue, 27 May 2025 11:27:21 +0000 Subject: [PATCH 2/6] fix: null check token Signed-off-by: lishuo --- frameworks/native/running_lock.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/frameworks/native/running_lock.cpp b/frameworks/native/running_lock.cpp index 52aebb4c..ad3f0709 100644 --- a/frameworks/native/running_lock.cpp +++ b/frameworks/native/running_lock.cpp @@ -89,14 +89,10 @@ ErrCode RunningLock::UpdateWorkSource(const std::vector& workSources) ErrCode RunningLock::Lock(int32_t timeOutMs) { sptr proxy = proxy_.promote(); - if (proxy == nullptr) { - POWER_HILOGE(FEATURE_RUNNING_LOCK, "LProxy=null"); + if (proxy == nullptr || token_ == nullptr) { + POWER_HILOGE(FEATURE_RUNNING_LOCK, "LProxy=null or token_=nullptr"); return E_GET_POWER_SERVICE_FAILED; } - if (token_ == nullptr) { - POWER_HILOGE(FEATURE_RUNNING_LOCK, "token_=nullptr"); - return PowerErrors::ERR_CONNECTION_FAIL; - } POWER_HILOGD(FEATURE_RUNNING_LOCK, "Service side Lock call, timeOutMs=%{public}d", timeOutMs); if (runningLockInfo_.type == RunningLockType::RUNNINGLOCK_PROXIMITY_SCREEN_CONTROL) { timeOutMs = NOT_USE_TIMEOUT; -- Gitee From 615dc2aca73565ee64ff8fac5a6737f2d94717ee Mon Sep 17 00:00:00 2001 From: lishuo Date: Wed, 28 May 2025 06:18:39 +0000 Subject: [PATCH 3/6] fix: null check token Signed-off-by: lishuo --- services/zidl/src/power_mgr_proxy.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/zidl/src/power_mgr_proxy.cpp b/services/zidl/src/power_mgr_proxy.cpp index 745ce4e4..574972bb 100644 --- a/services/zidl/src/power_mgr_proxy.cpp +++ b/services/zidl/src/power_mgr_proxy.cpp @@ -165,9 +165,11 @@ PowerErrors PowerMgrProxy::Lock(const sptr& remoteObj, int32_t ti POWER_HILOGE(FEATURE_RUNNING_LOCK, "Write descriptor failed"); return PowerErrors::ERR_CONNECTION_FAIL; } - - RETURN_IF_WRITE_PARCEL_FAILED_WITH_RET( - data, RemoteObject, remoteObj.GetRefPtr(), PowerErrors::ERR_CONNECTION_FAIL); + { + std::lock_guard lock(mutex_) + RETURN_IF_WRITE_PARCEL_FAILED_WITH_RET( + data, RemoteObject, remoteObj.GetRefPtr(), PowerErrors::ERR_CONNECTION_FAIL); + } RETURN_IF_WRITE_PARCEL_FAILED_WITH_RET(data, Int32, timeOutMs, PowerErrors::ERR_CONNECTION_FAIL); int ret = remote->SendRequest( -- Gitee From de18756adf9928fe7921c8460648088bdbf7269a Mon Sep 17 00:00:00 2001 From: lishuo Date: Wed, 28 May 2025 06:19:58 +0000 Subject: [PATCH 4/6] fix: null check token Signed-off-by: lishuo --- services/zidl/include/power_mgr_proxy.h | 1 + 1 file changed, 1 insertion(+) diff --git a/services/zidl/include/power_mgr_proxy.h b/services/zidl/include/power_mgr_proxy.h index eef8d4e5..5cc0204c 100644 --- a/services/zidl/include/power_mgr_proxy.h +++ b/services/zidl/include/power_mgr_proxy.h @@ -111,6 +111,7 @@ public: private: static inline BrokerDelegator delegator_; + std::mutex mutex_ }; } // namespace PowerMgr } // namespace OHOS -- Gitee From 1f13461bcf619b8aeef7d62e59f17e488d845e5f Mon Sep 17 00:00:00 2001 From: lishuo Date: Wed, 28 May 2025 06:52:07 +0000 Subject: [PATCH 5/6] fix: null check token Signed-off-by: lishuo --- services/zidl/include/power_mgr_proxy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/zidl/include/power_mgr_proxy.h b/services/zidl/include/power_mgr_proxy.h index 5cc0204c..0ea824b2 100644 --- a/services/zidl/include/power_mgr_proxy.h +++ b/services/zidl/include/power_mgr_proxy.h @@ -111,7 +111,7 @@ public: private: static inline BrokerDelegator delegator_; - std::mutex mutex_ + std::mutex mutex_; }; } // namespace PowerMgr } // namespace OHOS -- Gitee From a9451c27cc696f2198a667abd44bd3a485a2a3e8 Mon Sep 17 00:00:00 2001 From: lishuo Date: Wed, 28 May 2025 10:51:12 +0000 Subject: [PATCH 6/6] fix: null check token Signed-off-by: lishuo --- services/zidl/src/power_mgr_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/zidl/src/power_mgr_proxy.cpp b/services/zidl/src/power_mgr_proxy.cpp index 574972bb..cb0a601c 100644 --- a/services/zidl/src/power_mgr_proxy.cpp +++ b/services/zidl/src/power_mgr_proxy.cpp @@ -166,7 +166,7 @@ PowerErrors PowerMgrProxy::Lock(const sptr& remoteObj, int32_t ti return PowerErrors::ERR_CONNECTION_FAIL; } { - std::lock_guard lock(mutex_) + std::lock_guard lock(mutex_); RETURN_IF_WRITE_PARCEL_FAILED_WITH_RET( data, RemoteObject, remoteObj.GetRefPtr(), PowerErrors::ERR_CONNECTION_FAIL); } -- Gitee