1518678f8Sopenharmony_ci/* 2518678f8Sopenharmony_ci * Copyright (C) 2021-2023 Huawei Device Co., Ltd. 3518678f8Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4518678f8Sopenharmony_ci * you may not use this file except in compliance with the License. 5518678f8Sopenharmony_ci * You may obtain a copy of the License at 6518678f8Sopenharmony_ci * 7518678f8Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8518678f8Sopenharmony_ci * 9518678f8Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10518678f8Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11518678f8Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12518678f8Sopenharmony_ci * See the License for the specific language governing permissions and 13518678f8Sopenharmony_ci * limitations under the License. 14518678f8Sopenharmony_ci */ 15518678f8Sopenharmony_ci#ifndef OHOS_ARCH_LITE 16518678f8Sopenharmony_ci#include "dhcp_system_timer.h" 17518678f8Sopenharmony_ci#include "dhcp_logger.h" 18518678f8Sopenharmony_ci#include "common_timer_errors.h" 19518678f8Sopenharmony_ci 20518678f8Sopenharmony_cinamespace OHOS { 21518678f8Sopenharmony_cinamespace DHCP { 22518678f8Sopenharmony_ciDEFINE_DHCPLOG_DHCP_LABEL("DhcpSystemTimer"); 23518678f8Sopenharmony_ciDhcpSysTimer::DhcpSysTimer() 24518678f8Sopenharmony_ci{ 25518678f8Sopenharmony_ci DHCP_LOGI("DhcpSysTimer"); 26518678f8Sopenharmony_ci} 27518678f8Sopenharmony_ci 28518678f8Sopenharmony_ciDhcpSysTimer::~DhcpSysTimer() 29518678f8Sopenharmony_ci{ 30518678f8Sopenharmony_ci DHCP_LOGI("~DhcpSysTime"); 31518678f8Sopenharmony_ci} 32518678f8Sopenharmony_ci 33518678f8Sopenharmony_ciDhcpSysTimer::DhcpSysTimer(bool repeat, uint64_t interval, bool isNoWakeUp, bool isIdle) 34518678f8Sopenharmony_ci{ 35518678f8Sopenharmony_ci this->repeat = repeat; 36518678f8Sopenharmony_ci this->interval = interval; 37518678f8Sopenharmony_ci this->type = TIMER_TYPE_REALTIME; 38518678f8Sopenharmony_ci if (!isNoWakeUp) { 39518678f8Sopenharmony_ci this->type = TIMER_TYPE_WAKEUP + TIMER_TYPE_REALTIME; 40518678f8Sopenharmony_ci } 41518678f8Sopenharmony_ci if (isIdle) { 42518678f8Sopenharmony_ci this->type = TIMER_TYPE_IDLE; 43518678f8Sopenharmony_ci } 44518678f8Sopenharmony_ci} 45518678f8Sopenharmony_ci 46518678f8Sopenharmony_civoid DhcpSysTimer::OnTrigger() 47518678f8Sopenharmony_ci{ 48518678f8Sopenharmony_ci if (callBack_ != nullptr) { 49518678f8Sopenharmony_ci callBack_(); 50518678f8Sopenharmony_ci } 51518678f8Sopenharmony_ci} 52518678f8Sopenharmony_ci 53518678f8Sopenharmony_civoid DhcpSysTimer::SetCallbackInfo(const std::function<void()> &callBack) 54518678f8Sopenharmony_ci{ 55518678f8Sopenharmony_ci this->callBack_ = callBack; 56518678f8Sopenharmony_ci} 57518678f8Sopenharmony_ci 58518678f8Sopenharmony_civoid DhcpSysTimer::SetType(const int &type) 59518678f8Sopenharmony_ci{ 60518678f8Sopenharmony_ci this->type = type; 61518678f8Sopenharmony_ci} 62518678f8Sopenharmony_ci 63518678f8Sopenharmony_civoid DhcpSysTimer::SetRepeat(bool repeat) 64518678f8Sopenharmony_ci{ 65518678f8Sopenharmony_ci this->repeat = repeat; 66518678f8Sopenharmony_ci} 67518678f8Sopenharmony_ci 68518678f8Sopenharmony_civoid DhcpSysTimer::SetInterval(const uint64_t &interval) 69518678f8Sopenharmony_ci{ 70518678f8Sopenharmony_ci this->interval = interval; 71518678f8Sopenharmony_ci} 72518678f8Sopenharmony_ci 73518678f8Sopenharmony_civoid DhcpSysTimer::SetWantAgent(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent) 74518678f8Sopenharmony_ci{ 75518678f8Sopenharmony_ci this->wantAgent = wantAgent; 76518678f8Sopenharmony_ci} 77518678f8Sopenharmony_ci} // namespace DHCP 78518678f8Sopenharmony_ci} // namespace OHOS 79518678f8Sopenharmony_ci#endif