From ede954cce2360e670c4d5fafa24cd12d84c10ddb Mon Sep 17 00:00:00 2001 From: lixiangpeng5 Date: Mon, 5 Dec 2022 22:52:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=AD=BB=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lixiangpeng5 Change-Id: Ib9d21b2582fb79532d8a1bbbb1700958d370c5d2 --- frameworks/native/miscdevice/include/light_client.h | 1 - frameworks/native/miscdevice/src/light_client.cpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/frameworks/native/miscdevice/include/light_client.h b/frameworks/native/miscdevice/include/light_client.h index a71bace..77545e3 100755 --- a/frameworks/native/miscdevice/include/light_client.h +++ b/frameworks/native/miscdevice/include/light_client.h @@ -38,7 +38,6 @@ private: int32_t InitLightClient(); bool IsLightAnimationValid(const LightAnimation &animation); bool IsLightIdValid(int32_t lightId); - std::mutex lightInfosMutex_; LightInfo *lightInfos_ {nullptr}; int32_t lightInfoCount_ {-1}; sptr serviceDeathObserver_ = nullptr; diff --git a/frameworks/native/miscdevice/src/light_client.cpp b/frameworks/native/miscdevice/src/light_client.cpp index b753b19..9705d05 100755 --- a/frameworks/native/miscdevice/src/light_client.cpp +++ b/frameworks/native/miscdevice/src/light_client.cpp @@ -91,7 +91,6 @@ int32_t LightClient::GetLightList(LightInfo **lightInfo, int32_t &count) MISC_HILOGE("InitLightClient failed"); return ERROR; } - std::lock_guard lightInfosLock(lightInfosMutex_); if (lightInfos_ == nullptr) { int32_t ret = ConvertLightInfos(); if (ret != ERR_OK) { @@ -176,7 +175,6 @@ int32_t LightClient::ConvertLightInfos() MISC_HILOGE("The number of lights exceed the maximum value"); return ERROR; } - std::lock_guard lightInfosLock(lightInfosMutex_); lightInfos_ = (LightInfo *)malloc(sizeof(LightInfo) * count); CHKPR(lightInfos_, ERROR); for (size_t i = 0; i < count; ++i) { -- Gitee From 16b0a7f3194f4e3d82187d738e8f2c1d811859ff Mon Sep 17 00:00:00 2001 From: lixiangpeng5 Date: Mon, 5 Dec 2022 23:08:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AF=B9=E5=A4=9A=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E6=8F=90=E4=BE=9B=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lixiangpeng5 Change-Id: I26b71698447994bd719b9fb5ec38aa30b97a8b8f --- frameworks/native/miscdevice/include/light_client.h | 1 + frameworks/native/miscdevice/src/light_client.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/frameworks/native/miscdevice/include/light_client.h b/frameworks/native/miscdevice/include/light_client.h index 77545e3..a71bace 100755 --- a/frameworks/native/miscdevice/include/light_client.h +++ b/frameworks/native/miscdevice/include/light_client.h @@ -38,6 +38,7 @@ private: int32_t InitLightClient(); bool IsLightAnimationValid(const LightAnimation &animation); bool IsLightIdValid(int32_t lightId); + std::mutex lightInfosMutex_; LightInfo *lightInfos_ {nullptr}; int32_t lightInfoCount_ {-1}; sptr serviceDeathObserver_ = nullptr; diff --git a/frameworks/native/miscdevice/src/light_client.cpp b/frameworks/native/miscdevice/src/light_client.cpp index 9705d05..7c78a2f 100755 --- a/frameworks/native/miscdevice/src/light_client.cpp +++ b/frameworks/native/miscdevice/src/light_client.cpp @@ -91,6 +91,7 @@ int32_t LightClient::GetLightList(LightInfo **lightInfo, int32_t &count) MISC_HILOGE("InitLightClient failed"); return ERROR; } + std::lock_guard lightInfosLock(lightInfosMutex_); if (lightInfos_ == nullptr) { int32_t ret = ConvertLightInfos(); if (ret != ERR_OK) { -- Gitee