From 02035166d46b03075f80bdb4796da820ab812e1a Mon Sep 17 00:00:00 2001 From: XKK Date: Tue, 5 Sep 2023 09:59:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=9D=83=E9=99=90=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: XKK --- frameworks/core/common/include/ans_permission_def.h | 1 + services/ans/src/advanced_notification_service.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/frameworks/core/common/include/ans_permission_def.h b/frameworks/core/common/include/ans_permission_def.h index 427900b87..4df5515c6 100644 --- a/frameworks/core/common/include/ans_permission_def.h +++ b/frameworks/core/common/include/ans_permission_def.h @@ -22,6 +22,7 @@ namespace OHOS { namespace Notification { // Permission constexpr char OHOS_PERMISSION_NOTIFICATION_CONTROLLER[] = "ohos.permission.NOTIFICATION_CONTROLLER"; +constexpr char OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION[] = "ohos.permission.SET_UNREMOVABLE_NOTIFICATION"; constexpr char OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER[] = "ohos.permission.NOTIFICATION_AGENT_CONTROLLER"; } // namespace Notification } // namespace OHOS diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 7e9924100..c1082b7c3 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -577,7 +577,7 @@ ErrCode AdvancedNotificationService::Publish(const std::string &label, const spt } if (!request->IsRemoveAllowed()) { - if (!AccessTokenHelper::IsSystemApp() || !CheckPermission(OHOS_PERMISSION_NOTIFICATION_CONTROLLER)) { + if (!CheckPermission(OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION)) { request->SetRemoveAllowed(true); } } -- Gitee From d281340cea02c8b5e67671fb1a9b5d902a66a77c Mon Sep 17 00:00:00 2001 From: XKK Date: Tue, 5 Sep 2023 15:28:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8A=A0=E9=94=81=E4=BF=9D=E6=8A=A4wantAge?= =?UTF-8?q?nt=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: XKK --- frameworks/js/napi/include/common.h | 1 + frameworks/js/napi/src/common.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/frameworks/js/napi/include/common.h b/frameworks/js/napi/include/common.h index 1c8f831e8..d7bb8acf9 100644 --- a/frameworks/js/napi/include/common.h +++ b/frameworks/js/napi/include/common.h @@ -1576,6 +1576,7 @@ private: static const int32_t ONLY_CALLBACK_MAX_PARA = 1; static const int32_t ONLY_CALLBACK_MIN_PARA = 0; static std::set> wantAgent_; + static std::mutex mutex_; }; } // namespace NotificationNapi } // namespace OHOS diff --git a/frameworks/js/napi/src/common.cpp b/frameworks/js/napi/src/common.cpp index c14aae32e..25a8d0bae 100644 --- a/frameworks/js/napi/src/common.cpp +++ b/frameworks/js/napi/src/common.cpp @@ -4598,6 +4598,7 @@ napi_value Common::CreateWantAgentByJS(const napi_env &env, return nullptr; } + std::lock_guard lock(mutex_); wantAgent_.insert(agent); napi_value wantAgent = nullptr; napi_value wantAgentClass = nullptr; -- Gitee