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
20 namespace OHOS {
21 namespace DHCP {
22 DEFINE_DHCPLOG_DHCP_LABEL("DhcpSystemTimer");
DhcpSysTimer()23 DhcpSysTimer::DhcpSysTimer()
24 {
25 DHCP_LOGI("DhcpSysTimer");
26 }
27
~DhcpSysTimer()28 DhcpSysTimer::~DhcpSysTimer()
29 {
30 DHCP_LOGI("~DhcpSysTime");
31 }
32
DhcpSysTimer(bool repeat,uint64_t interval,bool isNoWakeUp,bool isIdle)33 DhcpSysTimer::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
OnTrigger()46 void DhcpSysTimer::OnTrigger()
47 {
48 if (callBack_ != nullptr) {
49 callBack_();
50 }
51 }
52
SetCallbackInfo(const std::function<void ()> & callBack)53 void DhcpSysTimer::SetCallbackInfo(const std::function<void()> &callBack)
54 {
55 this->callBack_ = callBack;
56 }
57
SetType(const int & type)58 void DhcpSysTimer::SetType(const int &type)
59 {
60 this->type = type;
61 }
62
SetRepeat(bool repeat)63 void DhcpSysTimer::SetRepeat(bool repeat)
64 {
65 this->repeat = repeat;
66 }
67
SetInterval(const uint64_t & interval)68 void DhcpSysTimer::SetInterval(const uint64_t &interval)
69 {
70 this->interval = interval;
71 }
72
SetWantAgent(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent)73 void DhcpSysTimer::SetWantAgent(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent)
74 {
75 this->wantAgent = wantAgent;
76 }
77 } // namespace DHCP
78 } // namespace OHOS
79 #endif