1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "notification_timer_info.h" 17 #include "ans_log_wrapper.h" 18 namespace OHOS { 19 namespace Notification { SetType(const int & timerInfoType)20void NotificationTimerInfo::SetType(const int &timerInfoType) 21 { 22 type = timerInfoType; 23 } 24 SetRepeat(bool timerInfoRepeat)25void NotificationTimerInfo::SetRepeat(bool timerInfoRepeat) 26 { 27 repeat = timerInfoRepeat; 28 } 29 SetInterval(const uint64_t & timerInfoInterval)30void NotificationTimerInfo::SetInterval(const uint64_t &timerInfoInterval) 31 { 32 interval = timerInfoInterval; 33 } 34 SetWantAgent(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> timerInfoWantAgent)35void NotificationTimerInfo::SetWantAgent(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> timerInfoWantAgent) 36 { 37 wantAgent = timerInfoWantAgent; 38 } 39 OnTrigger()40void NotificationTimerInfo::OnTrigger() 41 { 42 ANSR_LOGI("Timing is arrived."); 43 std::shared_ptr<ffrt::queue> notificationSvrQueue_ = 44 OHOS::Notification::AdvancedNotificationService::GetInstance()->GetNotificationSvrQueue(); 45 ffrt::task_handle handler = notificationSvrQueue_->submit_h(std::bind([&]() { 46 ANS_LOGD("ffrt enter!"); 47 if (callBack_ != nullptr) { 48 callBack_(); 49 callBack_ = nullptr; 50 } 51 })); 52 notificationSvrQueue_->wait(handler); 53 } 54 SetCallbackInfo(const std::function<void ()> & callBack)55void NotificationTimerInfo::SetCallbackInfo(const std::function<void()> &callBack) 56 { 57 callBack_ = callBack; 58 } 59 GetCallBack()60std::function<void()> NotificationTimerInfo::GetCallBack() 61 { 62 return callBack_; 63 } 64 } 65 } 66