diff --git a/frameworks/ans/src/reminder_request_alarm.cpp b/frameworks/ans/src/reminder_request_alarm.cpp index 70e43634c8c4af0bf84c681bf04463e97ae2e317..1357fc683847961b5c61cfbfad59d3b1a84c0d92 100644 --- a/frameworks/ans/src/reminder_request_alarm.cpp +++ b/frameworks/ans/src/reminder_request_alarm.cpp @@ -140,19 +140,35 @@ uint64_t ReminderRequestAlarm::GetNextTriggerTime(bool forceToGetNext) const } else { nextTriggerTime = target + nextDayInterval * HOURS_PER_DAY * SECONDS_PER_HOUR; } + time_t triggerTime = GetTriggerTimeWithDST(now, nextTriggerTime); struct tm test; - (void)localtime_r(&nextTriggerTime, &test); + (void)localtime_r(&triggerTime, &test); ANSR_LOGI("NextTriggerTime: year=%{public}d, mon=%{public}d, day=%{public}d, hour=%{public}d, " "min=%{public}d, sec=%{public}d, week=%{public}d, nextTriggerTime=%{public}lld", GetActualTime(TimeTransferType::YEAR, test.tm_year), GetActualTime(TimeTransferType::MONTH, test.tm_mon), test.tm_mday, test.tm_hour, test.tm_min, test.tm_sec, - GetActualTime(TimeTransferType::WEEK, test.tm_wday), (long long)nextTriggerTime); + GetActualTime(TimeTransferType::WEEK, test.tm_wday), (long long)triggerTime); - if (static_cast(nextTriggerTime) <= 0) { + if (static_cast(triggerTime) <= 0) { return 0; } - return ReminderRequest::GetDurationSinceEpochInMilli(nextTriggerTime); + return ReminderRequest::GetDurationSinceEpochInMilli(triggerTime); +} + +time_t ReminderRequestAlarm::GetTriggerTimeWithDST(const time_t now, const time_t nextTriggerTime) const +{ + time_t triggerTime = nextTriggerTime; + struct tm nowLocal; + struct tm nextLocal; + (void)localtime_r(&now, &nowLocal); + (void)localtime_r(&nextTriggerTime, &nextLocal); + if (nowLocal.tm_isdst == 0 && nextLocal.tm_isdst > 0) { + triggerTime -= SECONDS_PER_HOUR; + } else if (nowLocal.tm_isdst > 0 && nextLocal.tm_isdst == 0) { + triggerTime += SECONDS_PER_HOUR; + } + return triggerTime; } int8_t ReminderRequestAlarm::GetNextAlarm(const time_t now, const time_t target) const diff --git a/interfaces/inner_api/reminder_request_alarm.h b/interfaces/inner_api/reminder_request_alarm.h index 837fdcbb40459ef4f87c93e37efacc9a79bab51d..e95a5ec2aae55821fca63d418e1273f8493a72b2 100644 --- a/interfaces/inner_api/reminder_request_alarm.h +++ b/interfaces/inner_api/reminder_request_alarm.h @@ -150,6 +150,8 @@ private: */ int8_t GetNextAlarm(const time_t now, const time_t target) const; + time_t GetTriggerTimeWithDST(const time_t now, const time_t nextTriggerTime) const; + static const uint8_t DAYS_PER_WEEK; static const uint8_t MONDAY; static const uint8_t SUNDAY; diff --git a/notification.gni b/notification.gni index 543d27490d185e3a9137df64404e842baf40cb6c..97f92da332bf67c3b6c27c25e5f8fa5b2cb79f1c 100644 --- a/notification.gni +++ b/notification.gni @@ -50,6 +50,7 @@ declare_args() { device_usage = true hisysevent_usage = true standby_enable = true + player_framework = true if (defined(global_parts_info) && !defined(global_parts_info.resourceschedule_device_usage_statistics)) { @@ -66,5 +67,10 @@ declare_args() { standby_enable = false } + if (defined(global_parts_info) && + !defined(global_parts_info.multimedia_player_framework)) { + player_framework = false + } + print("hisysevent_usage = " + "$hisysevent_usage") } diff --git a/services/ans/BUILD.gn b/services/ans/BUILD.gn index ade0cd52f6e18f3ac239aec57824c2ad46e672ad..b7fc200949fd9ca6c1346cd880a1e89b9d08bf62 100644 --- a/services/ans/BUILD.gn +++ b/services/ans/BUILD.gn @@ -83,7 +83,6 @@ ohos_shared_library("libans") { "image_framework:image_native", "kv_store:distributeddata_inner", "os_account:os_account_innerkits", - "player_framework:media_client", "relational_store:native_rdb", "time_service:time_client", ] @@ -104,6 +103,11 @@ ohos_shared_library("libans") { defines += [ "DEVICE_STANDBY_ENABLE" ] } + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + subsystem_name = "${subsystem_name}" part_name = "${component_name}" } diff --git a/services/ans/include/reminder_data_manager.h b/services/ans/include/reminder_data_manager.h index 6e079ddde692d8e49afcc6cffbdb1043308ea6a0..9a5cf9aee5e29648e35a9091ad612c4f79fbc82a 100644 --- a/services/ans/include/reminder_data_manager.h +++ b/services/ans/include/reminder_data_manager.h @@ -21,7 +21,9 @@ #include "advanced_notification_service.h" #include "ans_inner_errors.h" +#ifdef PLAYER_FRAMEWORK_ENABLE #include "player.h" +#endif #include "reminder_request.h" #include "reminder_store.h" #include "reminder_timer_info.h" @@ -504,9 +506,9 @@ private: */ int32_t alertingReminderId_ = -1; sptr alertingReminder_ = nullptr; - +#ifdef PLAYER_FRAMEWORK_ENABLE std::shared_ptr soundPlayer_ = nullptr; - +#endif /** * Indicates the total count of reminders in system. */ diff --git a/services/ans/src/reminder_data_manager.cpp b/services/ans/src/reminder_data_manager.cpp index 5a0b410a02f92f2a106123d4f07516b67c724544..3ebfc47842ee530b3b09df520c02795ac47699d6 100644 --- a/services/ans/src/reminder_data_manager.cpp +++ b/services/ans/src/reminder_data_manager.cpp @@ -1166,6 +1166,7 @@ void ReminderDataManager::PlaySoundAndVibration(const sptr &rem TerminateAlerting(alertingReminder_, "PlaySoundAndVibration"); } ANSR_LOGD("Play sound and vibration, reminderId=%{public}d", reminder->GetReminderId()); +#ifdef PLAYER_FRAMEWORK_ENABLE if (soundPlayer_ == nullptr) { soundPlayer_ = Media::PlayerFactory::CreatePlayer(); if (soundPlayer_ == nullptr) { @@ -1180,6 +1181,7 @@ void ReminderDataManager::PlaySoundAndVibration(const sptr &rem soundPlayer_->SetLooping(true); soundPlayer_->PrepareAsync(); soundPlayer_->Play(); +#endif SetAlertingReminder(reminder); } @@ -1224,6 +1226,7 @@ void ReminderDataManager::StopSoundAndVibration(const sptr &rem return; } ANSR_LOGD("Stop sound and vibration, reminderId=%{public}d", reminder->GetReminderId()); +#ifdef PLAYER_FRAMEWORK_ENABLE if (soundPlayer_ == nullptr) { ANSR_LOGW("Sound player is null"); } else { @@ -1231,6 +1234,7 @@ void ReminderDataManager::StopSoundAndVibration(const sptr &rem soundPlayer_->Release(); soundPlayer_ = nullptr; } +#endif sptr nullReminder = nullptr; SetAlertingReminder(nullReminder); }