diff --git a/frameworks/ans/native/src/reminder_request.cpp b/frameworks/ans/native/src/reminder_request.cpp index 2984b3143b4d01f4d7b4a22c9844bbad7ffa2cc9..d523b9a31f337d1f9ca61ffba7696cab9669ffcc 100644 --- a/frameworks/ans/native/src/reminder_request.cpp +++ b/frameworks/ans/native/src/reminder_request.cpp @@ -1101,6 +1101,9 @@ bool ReminderRequest::UpdateNextReminder(const bool &force) void ReminderRequest::UpdateNotificationCommon() { + time_t now; + (void)time(&now); // unit is seconds. + notificationRequest_->SetDeliveryTime(static_cast(now) * MILLI_SECONDS); notificationRequest_->SetLabel(NOTIFICATION_LABEL); notificationRequest_->SetShowDeliveryTime(true); notificationRequest_->SetTapDismissed(true); @@ -1114,9 +1117,10 @@ void ReminderRequest::UpdateNotificationCommon() || reminderType_ == ReminderRequest::ReminderType::ALARM) { notificationRequest_->SetUnremovable(true); } - time_t now; - (void)time(&now); // unit is seconds. - notificationRequest_->SetDeliveryTime(static_cast(now) * MILLI_SECONDS); + auto flags = std::make_shared(); + flags->SetSoundEnabled(NotificationConstant::FlagStatus::CLOSE); + flags->SetVibrationEnabled(NotificationConstant::FlagStatus::CLOSE); + notificationRequest_->SetFlags(flags); } void ReminderRequest::UpdateNotificationContent(const bool &setSnooze) diff --git a/frameworks/ans/native/src/reminder_request_calendar.cpp b/frameworks/ans/native/src/reminder_request_calendar.cpp index df2a62a70b916060e68cc49a9bbcb46432b8e747..87751491934383e7148ec654cc3738010f53243d 100644 --- a/frameworks/ans/native/src/reminder_request_calendar.cpp +++ b/frameworks/ans/native/src/reminder_request_calendar.cpp @@ -152,11 +152,11 @@ uint64_t ReminderRequestCalendar::GetNextTriggerTime() const tarTime.tm_min = minute_; tarTime.tm_sec = 0; + ANSR_LOGD("Now time is: %{public}s", GetDateTimeInfo(now).c_str()); if (!(repeatMonth_ > 0 && repeatDay_ > 0)) { const time_t target = mktime(&tarTime); if (now <= target) { triggerTimeInMilli = static_cast(target) * MILLI_SECONDS; - ANSR_LOGD("Now time is: %{public}s", GetDateTimeInfo(now).c_str()); ANSR_LOGD("Next calendar time:%{public}s", GetDateTimeInfo(target).c_str()); } return triggerTimeInMilli; @@ -207,11 +207,18 @@ uint64_t ReminderRequestCalendar::GetTimeInstantMilli( tar.tm_min = minute; tar.tm_sec = second; const time_t target = mktime(&tar); - if (target < 0) { - ANSR_LOGW("GetTImeInstantMilli less than 0."); + if (target == -1) { + ANSR_LOGW("mktime return error."); return INVALID_LONG_LONG_VALUE; } - return static_cast(target) * MILLI_SECONDS; + auto tarEndTimePoint = std::chrono::system_clock::from_time_t(target); + auto tarDuration = std::chrono::duration_cast(tarEndTimePoint.time_since_epoch()); + int64_t tarDate = tarDuration.count(); + if (tarDate < 0) { + ANSR_LOGW("tarDuration is less than 0."); + return INVALID_LONG_LONG_VALUE; + } + return static_cast(tarDate); } void ReminderRequestCalendar::InitDateTime() diff --git a/services/ans/src/reminder_event_manager.cpp b/services/ans/src/reminder_event_manager.cpp index f4f75ad54477296cbb38a21b0301079da73f71d2..b864de2080181f15a6a93af6ba57338f2544bf87 100644 --- a/services/ans/src/reminder_event_manager.cpp +++ b/services/ans/src/reminder_event_manager.cpp @@ -15,10 +15,11 @@ #include "ans_log_wrapper.h" #include "appmgr/app_mgr_constants.h" +#include "bundle_constants.h" #include "bundle_mgr_interface.h" #include "common_event_manager.h" #include "common_event_support.h" -#include "bundle_constants.h" +#include "ipc_skeleton.h" #include "reminder_event_manager.h" @@ -44,11 +45,14 @@ void ReminderEventManager::init(std::shared_ptr &reminderDa matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_TIME_CHANGED); CommonEventSubscribeInfo subscriberInfo(matchingSkills); auto subscriber = std::make_shared(subscriberInfo, reminderDataManager); + + std::string identity = IPCSkeleton::ResetCallingIdentity(); if (CommonEventManager::SubscribeCommonEvent(subscriber)) { ANSR_LOGD("SubscribeCommonEvent ok"); } else { ANSR_LOGD("SubscribeCommonEvent fail"); } + IPCSkeleton::SetCallingIdentity(identity); } ReminderEventManager::ReminderEventSubscriber::ReminderEventSubscriber(