diff --git a/frameworks/ans/native/src/notification_conversational_content.cpp b/frameworks/ans/native/src/notification_conversational_content.cpp index fb8cf668584eb66f3e62b8f0c47b9fca391751aa..78d0494b0c1d463d089b886a6fa103a3303e3fbb 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.ReadUint64(); - 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 88a2beb7f4bc9a788dd25f470edaf1eb512da9a4..a3a609bb39ddef429253f0a91979b3f69fb3a121 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.ReadUint64(); - 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 a0e992bab8b2e85b8b5764cef2e7df921b761479..17767323db4a13c65cde8ab3f1b73384fc55db04 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.ReadUint64(); - 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 cedff58c52f1e0812c1c0aa91bd7b58f30890164..4fc430d88661fb84b027920811aa0c3805c929bf 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -1237,8 +1237,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; } @@ -1258,8 +1259,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; } @@ -1317,7 +1319,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); @@ -1678,8 +1680,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; } @@ -1740,8 +1741,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; } @@ -2526,8 +2527,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; }