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