From 0734affb94b6e621ebbbd567e1aa1cfe173c14e5 Mon Sep 17 00:00:00 2001 From: derek Date: Tue, 22 Feb 2022 11:14:57 +0800 Subject: [PATCH 1/2] set flag to make systemUI not play sound and vibrate Signed-off-by: derek Change-Id: Icabf6a3cc1e847c045f663890799ad82443b16e3 --- frameworks/ans/native/src/reminder_request.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frameworks/ans/native/src/reminder_request.cpp b/frameworks/ans/native/src/reminder_request.cpp index 2984b3143..d523b9a31 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) -- Gitee From 7bd3e6afb8d467802c74c1d4d2151d35d8423048 Mon Sep 17 00:00:00 2001 From: derek Date: Tue, 22 Feb 2022 20:37:31 +0800 Subject: [PATCH 2/2] 1.fix app can not recieve event on wgr 2.fix calendar can not set on wgr Signed-off-by: derek Change-Id: I05b39a8d422f0cbc60e2d7476f78332bbe50d310 --- .../ans/native/src/reminder_request_calendar.cpp | 15 +++++++++++---- services/ans/src/reminder_event_manager.cpp | 6 +++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/frameworks/ans/native/src/reminder_request_calendar.cpp b/frameworks/ans/native/src/reminder_request_calendar.cpp index df2a62a70..877514919 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 f4f75ad54..b864de208 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( -- Gitee