From 65f70558066d4ea0ef6cacc599f5a7964261c567 Mon Sep 17 00:00:00 2001 From: shenpeixing Date: Thu, 26 Jun 2025 15:40:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=81=B6=E7=8E=B0clear?= =?UTF-8?q?=E5=85=8D=E6=89=93=E6=89=B0=E7=99=BD=E5=90=8D=E5=8D=95crash?= =?UTF-8?q?=E4=B8=8Etdd=E4=B8=AD=E6=9C=89crash=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shenpeixing --- .../include/vibration_priority_manager.h | 1 + .../src/vibration_priority_manager.cpp | 2 ++ utils/common/src/file_utils.cpp | 15 +++++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/services/miscdevice_service/include/vibration_priority_manager.h b/services/miscdevice_service/include/vibration_priority_manager.h index 3f5bd43..f727f86 100644 --- a/services/miscdevice_service/include/vibration_priority_manager.h +++ b/services/miscdevice_service/include/vibration_priority_manager.h @@ -135,6 +135,7 @@ private: std::vector doNotDisturbWhiteList_; sptr currentUserObserver_; std::mutex currentUserObserverMutex_; + std::mutex whiteListMutex_; #endif // OHOS_BUILD_ENABLE_DO_NOT_DISTURB #ifdef OHOS_BUILD_ENABLE_VIBRATOR_CROWN std::atomic_int32_t miscCrownFeedback_ = FEEDBACK_MODE_INVALID; diff --git a/services/miscdevice_service/src/vibration_priority_manager.cpp b/services/miscdevice_service/src/vibration_priority_manager.cpp index 2cada5a..865fb5f 100644 --- a/services/miscdevice_service/src/vibration_priority_manager.cpp +++ b/services/miscdevice_service/src/vibration_priority_manager.cpp @@ -151,6 +151,7 @@ void VibrationPriorityManager::InitDoNotDisturbData() doNotDisturbSwitch_ = switchTemp; MISC_HILOGI("doNotDisturbSwitch:%{public}d", switchTemp); } + std::lock_guard whiteListLock(whiteListMutex_); if (doNotDisturbSwitch_ == DONOTDISTURB_SWITCH_ON) { std::vector whiteListTemp; int32_t whiteListRet = GetWhiteListValue(DO_NOT_DISTURB_WHITE_LIST, whiteListTemp); @@ -443,6 +444,7 @@ bool VibrationPriorityManager::IgnoreAppVibrations(const VibrateInfo &vibrateInf MISC_HILOGD("DoNotDisturbSwitch is off"); return false; } + std::lock_guard whiteListLock(whiteListMutex_); for (const WhiteListAppInfo &whiteListAppInfo : doNotDisturbWhiteList_) { if (vibrateInfo.packageName == whiteListAppInfo.bundle) { MISC_HILOGD("Not ignore app vibration, the app is on the whitelist, bundleName::%{public}s", diff --git a/utils/common/src/file_utils.cpp b/utils/common/src/file_utils.cpp index 78419ef..fff2eac 100755 --- a/utils/common/src/file_utils.cpp +++ b/utils/common/src/file_utils.cpp @@ -187,16 +187,23 @@ std::string ReadFd(const RawFileDescriptor &rawFd) int64_t fdSize = GetFileSize(rawFd.fd); if ((rawFd.offset < 0) || (rawFd.offset > fdSize)) { MISC_HILOGE("offset is invalid, offset:%{public}" PRId64, rawFd.offset); - close(rawFd.fd); return {}; } if ((rawFd.length <= 0) || (rawFd.length > fdSize - rawFd.offset)) { MISC_HILOGE("length is invalid, length:%{public}" PRId64, rawFd.length); - close(rawFd.fd); return {}; } - FILE *fp = fdopen(rawFd.fd, "r"); - CHKPS(fp); + int dupFd = dup(rawFd.fd); + if (dupFd < 0) { + MISC_HILOGE("dup fd failed, fd:%{public}d, errno:%{public}d", rawFd.fd, errno); + return {}; + } + FILE *fp = fdopen(dupFd, "r"); + if (fp == nullptr) { + MISC_HILOGE("fdopen failed, fd:%{public}d, errno:%{public}d", dupFd, errno); + close(dupFd); + return {}; + } if (fseek(fp, rawFd.offset, SEEK_SET) != 0) { MISC_HILOGE("fseek failed, errno:%{public}d", errno); if (fclose(fp) != 0) { -- Gitee From 9fe49345000ecea52f69cd63fefe82a1ecf5eedb Mon Sep 17 00:00:00 2001 From: shenpeixing Date: Fri, 22 Aug 2025 09:17:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9IsSupportEffect=E7=9A=84j?= =?UTF-8?q?s=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=A0=81=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shenpeixing --- frameworks/js/napi/vibrator/src/vibrator_js.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frameworks/js/napi/vibrator/src/vibrator_js.cpp b/frameworks/js/napi/vibrator/src/vibrator_js.cpp index 9b5b707..82efe49 100644 --- a/frameworks/js/napi/vibrator/src/vibrator_js.cpp +++ b/frameworks/js/napi/vibrator/src/vibrator_js.cpp @@ -675,7 +675,12 @@ static napi_value IsSupportEffect(napi_env env, napi_callback_info info) sptr asyncCallbackInfo = new (std::nothrow) AsyncCallbackInfo(env); CHKPP(asyncCallbackInfo); asyncCallbackInfo->callbackType = IS_SUPPORT_EFFECT_CALLBACK; - asyncCallbackInfo->error.code = IsSupportEffect(effectId.c_str(), &asyncCallbackInfo->isSupportEffect); + bool isSupportEffect = false; + int32_t ret = IsSupportEffect(effectId.c_str(), &isSupportEffect); + if (ret == PERMISSION_DENIED || ret == PARAMETER_ERROR) { + asyncCallbackInfo->error.code = ret; + } + asyncCallbackInfo->isSupportEffect = isSupportEffect; if ((argc > 1) && (IsMatchType(env, args[1], napi_function))) { return EmitAsyncWork(args[1], asyncCallbackInfo); } -- Gitee