• 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_INFO_H
17 #define TIMER_INFO_H
18 
19 #include <cstdint>
20 #include <string>
21 
22 #include "timer_manager_interface.h"
23 
24 namespace OHOS {
25 namespace MiscServices {
26 class TimerInfo {
27 public:
28     const uint64_t id;
29     const int type;
30     const std::chrono::milliseconds origWhen;
31     const bool wakeup;
32     const std::function<void (const uint64_t)> callback;
33     const std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent;
34     const uint32_t flags;
35     const int uid;
36 
37     uint64_t count {};
38     std::chrono::milliseconds when;
39     std::chrono::milliseconds windowLength;
40     std::chrono::steady_clock::time_point whenElapsed;
41     std::chrono::steady_clock::time_point maxWhenElapsed;
42     std::chrono::steady_clock::time_point expectedWhenElapsed;
43     std::chrono::steady_clock::time_point expectedMaxWhenElapsed;
44     std::chrono::milliseconds repeatInterval;
45     std::chrono::milliseconds offset;
46     std::string bundleName;
47 
48     TimerInfo(uint64_t id, int type,
49         std::chrono::milliseconds when,
50         std::chrono::steady_clock::time_point whenElapsed,
51         std::chrono::milliseconds windowLength,
52         std::chrono::steady_clock::time_point maxWhen,
53         std::chrono::milliseconds interval,
54         std::function<void (const uint64_t)> callback,
55         std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent,
56         uint32_t flags,
57         int uid,
58         const std::string &bundleName);
59     virtual ~TimerInfo() = default;
60     bool operator==(const TimerInfo &other) const;
61     bool Matches(const std::string &packageName) const;
62     bool UpdateWhenElapsed(std::chrono::steady_clock::time_point policyElapsed, std::chrono::nanoseconds offset);
63 };
64 } // MiscService
65 } // OHOS
66 #endif