From 348e409c6d97f01074f2e13af046d285f33aa570 Mon Sep 17 00:00:00 2001 From: fangJinliang1 Date: Sat, 7 May 2022 17:20:23 +0800 Subject: [PATCH] interface support subsystem Signed-off-by: fangJinliang1 Change-Id: Iddc9fd4b425df1f97b1264c010d82303f98b947c Signed-off-by: fangJinliang1 --- .../notification_conversational_content.cpp | 2 +- .../ans/native/src/notification_request.cpp | 2 +- .../native/src/notification_user_input.cpp | 2 +- .../ans/src/advanced_notification_service.cpp | 27 ++++++++++--------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/frameworks/ans/native/src/notification_conversational_content.cpp b/frameworks/ans/native/src/notification_conversational_content.cpp index 08f3599b7..46f741aba 100644 --- a/frameworks/ans/native/src/notification_conversational_content.cpp +++ b/frameworks/ans/native/src/notification_conversational_content.cpp @@ -255,7 +255,7 @@ bool NotificationConversationalContent::ReadFromParcel(Parcel &parcel) messageUser_ = *pUser; auto vsize = parcel.ReadInt32(); - for (auto it = 0; it < vsize; ++it) { + for (uint64_t it = 0; it < vsize; ++it) { auto valid = parcel.ReadBool(); if (!valid) { ANS_LOGE("Invalid message, read from parcel failed"); diff --git a/frameworks/ans/native/src/notification_request.cpp b/frameworks/ans/native/src/notification_request.cpp index fea842eca..43e22f2c5 100644 --- a/frameworks/ans/native/src/notification_request.cpp +++ b/frameworks/ans/native/src/notification_request.cpp @@ -1349,7 +1349,7 @@ bool NotificationRequest::ReadFromParcel(Parcel &parcel) } vsize = parcel.ReadInt32(); - for (auto it = 0; it < vsize; ++it) { + for (uint64_t it = 0; it < vsize; ++it) { auto member = parcel.ReadParcelable(); if (member == nullptr) { ANS_LOGE("Failed to read messageUser"); diff --git a/frameworks/ans/native/src/notification_user_input.cpp b/frameworks/ans/native/src/notification_user_input.cpp index dfd11abb9..e09545934 100644 --- a/frameworks/ans/native/src/notification_user_input.cpp +++ b/frameworks/ans/native/src/notification_user_input.cpp @@ -393,7 +393,7 @@ bool NotificationUserInput::ReadFromParcel(Parcel &parcel) } auto ssize = parcel.ReadInt32(); - for (auto it = 0; it < ssize; ++it) { + for (uint64_t it = 0; it < ssize; ++it) { std::string member {}; if (!parcel.ReadString(member)) { ANS_LOGE("Failed to read permitMimeTypes"); diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 8010b6616..c700afee6 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -1231,8 +1231,9 @@ ErrCode AdvancedNotificationService::Subscribe( { ANS_LOGD("%{public}s", __FUNCTION__); - if (!IsSystemApp()) { - ANS_LOGE("Client is not a system app"); + bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); + if (!IsSystemApp() && !isSubsystem) { + ANS_LOGE("Client is not a system app or subsystem"); return ERR_ANS_NON_SYSTEM_APP; } @@ -1252,8 +1253,9 @@ ErrCode AdvancedNotificationService::Unsubscribe( { ANS_LOGD("%{public}s", __FUNCTION__); - if (!IsSystemApp()) { - ANS_LOGE("Client is not a system app"); + bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); + if (!IsSystemApp() && !isSubsystem) { + ANS_LOGE("Client is not a system app or subsystem"); return ERR_ANS_NON_SYSTEM_APP; } @@ -1311,7 +1313,8 @@ ErrCode AdvancedNotificationService::GetAllActiveNotifications(std::vector targetBundle = nullptr; - auto callerToken = IPCSkeleton::GetCallingTokenID(); - bool isSubsystem = AccessTokenHelper::VerifyNativeToken(callerToken); + bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); if (isSubsystem) { if (bundleOption != nullptr) { targetBundle = GenerateValidBundleOption(bundleOption); @@ -1672,8 +1674,7 @@ ErrCode AdvancedNotificationService::PublishContinuousTaskNotification(const spt { ANS_LOGD("%{public}s", __FUNCTION__); - auto callerToken = IPCSkeleton::GetCallingTokenID(); - bool isSubsystem = AccessTokenHelper::VerifyNativeToken(callerToken); + bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); if (!isSubsystem) { return ERR_ANS_NOT_SYSTEM_SERVICE; } @@ -1734,8 +1735,8 @@ ErrCode AdvancedNotificationService::PublishContinuousTaskNotification(const spt ErrCode AdvancedNotificationService::CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) { ANS_LOGD("%{public}s", __FUNCTION__); - auto callerToken = IPCSkeleton::GetCallingTokenID(); - bool isSubsystem = AccessTokenHelper::VerifyNativeToken(callerToken); + + bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); if (!isSubsystem) { return ERR_ANS_NOT_SYSTEM_SERVICE; } @@ -2518,8 +2519,8 @@ ErrCode AdvancedNotificationService::DoesSupportDoNotDisturbMode(bool &doesSuppo bool AdvancedNotificationService::CheckPermission() { ANS_LOGD("%{public}s", __FUNCTION__); - auto callerToken = IPCSkeleton::GetCallingTokenID(); - bool isSubsystem = AccessTokenHelper::VerifyNativeToken(callerToken); + + bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); if (isSubsystem) { return true; } -- Gitee