• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef TIMER_MANAGER_INTERFACE_H
17 #define TIMER_MANAGER_INTERFACE_H
18 
19 #include <memory>
20 #include "want_agent_helper.h"
21 #include "time_common.h"
22 
23 namespace OHOS {
24 namespace MiscServices {
25 struct TimerEntry {
26     uint64_t id;
27     int type;
28     uint64_t windowLength;
29     uint64_t interval;
30     int flag;
31     std::function<void (const uint64_t)> callback;
32     std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent;
33     int uid;
34 };
35 
36 class ITimerManager {
37 public:
38     enum TimerFlag {
39         STANDALONE = 1 << 0,
40         WAKE_FROM_IDLE = 1 << 1,
41         ALLOW_WHILE_IDLE = 1 << 2,
42         ALLOW_WHILE_IDLE_UNRESTRICTED = 1 << 3,
43         IDLE_UNTIL = 1 << 4,
44         INEXACT_REMINDER = 1 << 5,
45     };
46 
47     enum TimerType {
48         RTC_WAKEUP = 0,
49         RTC = 1,
50         ELAPSED_REALTIME_WAKEUP = 2,
51         ELAPSED_REALTIME = 3
52     };
53 
54     virtual int32_t CreateTimer(TimerPara &paras,
55                                 std::function<void (const uint64_t)> callback,
56                                 std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent,
57                                 int uid, uint64_t &timerId) = 0;
58 
59     virtual int32_t StartTimer(uint64_t timerId, uint64_t triggerTime) = 0;
60     virtual int32_t StopTimer(uint64_t timerId) = 0;
61     virtual int32_t DestroyTimer(uint64_t timerId) = 0;
62     virtual ~ITimerManager() = default;
63     virtual bool ProxyTimer(int32_t uid, bool isProxy, bool needRetrigger) = 0;
64     virtual bool ResetAllProxy() = 0;
65 }; // ITimerManager
66 } // MiscService
67 } // OHOS
68 
69 #endif