• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 "sys_timer.h"
17 #include "common_timer_errors.h"
18 
19 namespace OHOS {
20 namespace NetManagerStandard {
21 
SysTimer()22 SysTimer::SysTimer()
23 {}
24 
~SysTimer()25 SysTimer::~SysTimer()
26 {}
27 
SysTimer(bool repeat,uint64_t interval,bool isNoWakeUp,bool isIdle)28 SysTimer::SysTimer(bool repeat, uint64_t interval, bool isNoWakeUp, bool isIdle)
29 {
30     this->repeat = repeat;
31     this->interval = interval;
32     this->type = TIMER_TYPE_REALTIME;
33     if (!isNoWakeUp) {
34         this->type = TIMER_TYPE_WAKEUP + TIMER_TYPE_REALTIME;
35     }
36     if (isIdle) {
37         this->type = TIMER_TYPE_IDLE;
38     }
39 }
40 
OnTrigger()41 void SysTimer::OnTrigger()
42 {
43     if (callBack_ != nullptr) {
44         callBack_();
45     }
46 }
47 
SetCallbackInfo(const std::function<void ()> & callBack)48 void SysTimer::SetCallbackInfo(const std::function<void()> &callBack)
49 {
50     this->callBack_ = callBack;
51 }
52 
SetType(const int & type)53 void SysTimer::SetType(const int &type)
54 {
55     this->type = type;
56 }
57 
SetRepeat(bool repeat)58 void SysTimer::SetRepeat(bool repeat)
59 {
60     this->repeat = repeat;
61 }
62 
SetInterval(const uint64_t & interval)63 void SysTimer::SetInterval(const uint64_t &interval)
64 {
65     this->interval = interval;
66 }
67 
SetWantAgent(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent)68 void SysTimer::SetWantAgent(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent)
69 {
70     this->wantAgent = wantAgent;
71 }
72 } // namespace NetManagerStandard
73 } // namespace OHOS