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 std::string bundleName; 35 }; 36 37 class ITimerManager { 38 public: 39 enum TimerFlag { 40 STANDALONE = 1 << 0, 41 WAKE_FROM_IDLE = 1 << 1, 42 ALLOW_WHILE_IDLE = 1 << 2, 43 ALLOW_WHILE_IDLE_UNRESTRICTED = 1 << 3, 44 IDLE_UNTIL = 1 << 4, 45 INEXACT_REMINDER = 1 << 5, 46 }; 47 48 enum TimerType { 49 RTC_WAKEUP = 0, 50 RTC = 1, 51 ELAPSED_REALTIME_WAKEUP = 2, 52 ELAPSED_REALTIME = 3 53 }; 54 55 virtual int32_t CreateTimer(TimerPara ¶s, 56 std::function<void (const uint64_t)> callback, 57 std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent, 58 int uid, uint64_t &timerId) = 0; 59 60 virtual int32_t StartTimer(uint64_t timerId, uint64_t triggerTime) = 0; 61 virtual int32_t StopTimer(uint64_t timerId) = 0; 62 virtual int32_t DestroyTimer(uint64_t timerId) = 0; 63 virtual ~ITimerManager() = default; 64 virtual bool ProxyTimer(int32_t uid, bool isProxy, bool needRetrigger) = 0; 65 virtual bool ResetAllProxy() = 0; 66 }; // ITimerManager 67 } // MiscService 68 } // OHOS 69 70 #endif