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