1 /* 2 * Copyright (C) 2021 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 I_TIMER_INFO_H 16 #define I_TIMER_INFO_H 17 18 #include <mutex> 19 20 #include "visibility.h" 21 #include "want_agent_helper.h" 22 23 namespace OHOS { 24 namespace MiscServices { 25 class ITimerInfo { 26 public: 27 TIME_API ITimerInfo(); 28 TIME_API virtual ~ITimerInfo(); 29 30 int type; 31 bool repeat; 32 uint64_t interval; 33 std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent; 34 35 /** 36 * Indicates the timing policy the timer use, which can be REALTIME or UTC. 37 */ 38 const int TIMER_TYPE_REALTIME = 1 << 0; 39 40 /** 41 * Describes whether a timer will wake the device up. 42 */ 43 const int TIMER_TYPE_WAKEUP = 1 << 1; 44 45 /** 46 * Describes whether a timer will be delivered precisely at a scheduled time. 47 */ 48 const int TIMER_TYPE_EXACT = 1 << 2; 49 50 /** 51 * Indicates whether the timer waking up the system is supported in low-power mode. 52 */ 53 const int TIMER_TYPE_IDLE = 1 << 3; 54 55 /** 56 * Indicates whether the timer is from inexact reminder agent. 57 */ 58 const int TIMER_TYPE_INEXACT_REMINDER = 1 << 4; 59 /** 60 * SetType set timer type 61 * @para: type: TIMER_TYPE_REALTIME | TIMER_TYPE_WAKEUP 62 * 63 */ 64 virtual void SetType(const int &type) = 0; 65 66 /** 67 * SetRepeat set timer repeat or not 68 * @para: repeat: bool 69 * 70 */ 71 virtual void SetRepeat(bool repeat) = 0; 72 73 /** 74 * SetInterval set timer repeat interval 75 * @para: repeat: uint64_t >= 5000ms 76 * 77 */ 78 virtual void SetInterval(const uint64_t &interval) = 0; 79 virtual void SetWantAgent(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent) = 0; 80 virtual void OnTrigger() = 0; 81 }; 82 } // MiscServices 83 } // OHOS 84 85 #endif // I_TIMER_INFO_H