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