1cf69771bSopenharmony_ci/*
2cf69771bSopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd.
3cf69771bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4cf69771bSopenharmony_ci * you may not use this file except in compliance with the License.
5cf69771bSopenharmony_ci * You may obtain a copy of the License at
6cf69771bSopenharmony_ci *
7cf69771bSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8cf69771bSopenharmony_ci *
9cf69771bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10cf69771bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11cf69771bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12cf69771bSopenharmony_ci * See the License for the specific language governing permissions and
13cf69771bSopenharmony_ci * limitations under the License.
14cf69771bSopenharmony_ci */
15cf69771bSopenharmony_ci#ifndef I_TIMER_INFO_H
16cf69771bSopenharmony_ci#define I_TIMER_INFO_H
17cf69771bSopenharmony_ci
18cf69771bSopenharmony_ci#include <mutex>
19cf69771bSopenharmony_ci
20cf69771bSopenharmony_ci#include "visibility.h"
21cf69771bSopenharmony_ci#include "want_agent_helper.h"
22cf69771bSopenharmony_ci
23cf69771bSopenharmony_cinamespace OHOS {
24cf69771bSopenharmony_cinamespace MiscServices {
25cf69771bSopenharmony_ciclass ITimerInfo {
26cf69771bSopenharmony_cipublic:
27cf69771bSopenharmony_ci    TIME_API ITimerInfo();
28cf69771bSopenharmony_ci    TIME_API virtual ~ITimerInfo();
29cf69771bSopenharmony_ci
30cf69771bSopenharmony_ci    int type;
31cf69771bSopenharmony_ci    bool repeat;
32cf69771bSopenharmony_ci    bool disposable = false;
33cf69771bSopenharmony_ci    uint64_t interval;
34cf69771bSopenharmony_ci    std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent;
35cf69771bSopenharmony_ci
36cf69771bSopenharmony_ci    /**
37cf69771bSopenharmony_ci    * Indicates the timing policy the timer use, which can be REALTIME or UTC.
38cf69771bSopenharmony_ci    */
39cf69771bSopenharmony_ci    const int TIMER_TYPE_REALTIME = 1 << 0;
40cf69771bSopenharmony_ci
41cf69771bSopenharmony_ci    /**
42cf69771bSopenharmony_ci    * Describes whether a timer will wake the device up.
43cf69771bSopenharmony_ci    */
44cf69771bSopenharmony_ci    const int TIMER_TYPE_WAKEUP = 1 << 1;
45cf69771bSopenharmony_ci
46cf69771bSopenharmony_ci    /**
47cf69771bSopenharmony_ci    * Describes whether a timer will be delivered precisely at a scheduled time.
48cf69771bSopenharmony_ci    */
49cf69771bSopenharmony_ci    const int TIMER_TYPE_EXACT = 1 << 2;
50cf69771bSopenharmony_ci
51cf69771bSopenharmony_ci    /**
52cf69771bSopenharmony_ci    * Indicates whether the timer waking up the system is supported in low-power mode.
53cf69771bSopenharmony_ci    */
54cf69771bSopenharmony_ci    const int TIMER_TYPE_IDLE = 1 << 3;
55cf69771bSopenharmony_ci
56cf69771bSopenharmony_ci    /**
57cf69771bSopenharmony_ci    * Indicates whether the timer is from inexact reminder agent.
58cf69771bSopenharmony_ci    */
59cf69771bSopenharmony_ci    const int TIMER_TYPE_INEXACT_REMINDER = 1 << 4;
60cf69771bSopenharmony_ci    /**
61cf69771bSopenharmony_ci     * SetType set timer type
62cf69771bSopenharmony_ci     * @para: type: TIMER_TYPE_REALTIME | TIMER_TYPE_WAKEUP
63cf69771bSopenharmony_ci     *
64cf69771bSopenharmony_ci     */
65cf69771bSopenharmony_ci    virtual void SetType(const int &type) = 0;
66cf69771bSopenharmony_ci
67cf69771bSopenharmony_ci    /**
68cf69771bSopenharmony_ci     * SetRepeat set timer repeat or not
69cf69771bSopenharmony_ci     * @para: repeat: bool
70cf69771bSopenharmony_ci     *
71cf69771bSopenharmony_ci     */
72cf69771bSopenharmony_ci    virtual void SetRepeat(bool repeat) = 0;
73cf69771bSopenharmony_ci
74cf69771bSopenharmony_ci    /**
75cf69771bSopenharmony_ci     * SetInterval set timer repeat interval
76cf69771bSopenharmony_ci     * @para: repeat: uint64_t  >= 5000ms
77cf69771bSopenharmony_ci     *
78cf69771bSopenharmony_ci     */
79cf69771bSopenharmony_ci    virtual void SetInterval(const uint64_t &interval) = 0;
80cf69771bSopenharmony_ci
81cf69771bSopenharmony_ci    /**
82cf69771bSopenharmony_ci     * SetDisposable set timer disposable or not
83cf69771bSopenharmony_ci     * @para: _disposable bool
84cf69771bSopenharmony_ci     *        true: the timer will be destoryed automaticly when it is triggered.
85cf69771bSopenharmony_ci     *              But do not take effect for repeat timer.
86cf69771bSopenharmony_ci     *        fasle: the timer need to be destroyed by client
87cf69771bSopenharmony_ci     */
88cf69771bSopenharmony_ci    void SetDisposable(const bool &_disposable)
89cf69771bSopenharmony_ci    {
90cf69771bSopenharmony_ci        disposable = _disposable;
91cf69771bSopenharmony_ci    }
92cf69771bSopenharmony_ci    virtual void SetWantAgent(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent) = 0;
93cf69771bSopenharmony_ci    virtual void OnTrigger() = 0;
94cf69771bSopenharmony_ci};
95cf69771bSopenharmony_ci} // MiscServices
96cf69771bSopenharmony_ci} // OHOS
97cf69771bSopenharmony_ci
98cf69771bSopenharmony_ci#endif // I_TIMER_INFO_H