1/*
2 * Copyright (C) 2021-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#ifndef OHOS_ARCH_LITE
16#include "dhcp_system_timer.h"
17#include "dhcp_logger.h"
18#include "common_timer_errors.h"
19
20namespace OHOS {
21namespace DHCP {
22DEFINE_DHCPLOG_DHCP_LABEL("DhcpSystemTimer");
23DhcpSysTimer::DhcpSysTimer()
24{
25    DHCP_LOGI("DhcpSysTimer");
26}
27
28DhcpSysTimer::~DhcpSysTimer()
29{
30    DHCP_LOGI("~DhcpSysTime");
31}
32
33DhcpSysTimer::DhcpSysTimer(bool repeat, uint64_t interval, bool isNoWakeUp, bool isIdle)
34{
35    this->repeat = repeat;
36    this->interval = interval;
37    this->type = TIMER_TYPE_REALTIME;
38    if (!isNoWakeUp) {
39        this->type = TIMER_TYPE_WAKEUP + TIMER_TYPE_REALTIME;
40    }
41    if (isIdle) {
42        this->type = TIMER_TYPE_IDLE;
43    }
44}
45
46void DhcpSysTimer::OnTrigger()
47{
48    if (callBack_ != nullptr) {
49        callBack_();
50    }
51}
52
53void DhcpSysTimer::SetCallbackInfo(const std::function<void()> &callBack)
54{
55    this->callBack_ = callBack;
56}
57
58void DhcpSysTimer::SetType(const int &type)
59{
60    this->type = type;
61}
62
63void DhcpSysTimer::SetRepeat(bool repeat)
64{
65    this->repeat = repeat;
66}
67
68void DhcpSysTimer::SetInterval(const uint64_t &interval)
69{
70    this->interval = interval;
71}
72
73void DhcpSysTimer::SetWantAgent(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent)
74{
75    this->wantAgent = wantAgent;
76}
77} // namespace DHCP
78} // namespace OHOS
79#endif