1 /* 2 * Copyright (C) 2023 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 #ifndef NFC_TIMER_H 16 #define NFC_TIMER_H 17 #include <functional> 18 #include "common_timer_errors.h" 19 #include "timer.h" 20 21 namespace OHOS { 22 namespace NFC { 23 using TimeOutCallback = std::function<void()>; 24 const uint32_t TIMEOUT_UNLOAD_NFC_SA = 5 * 60 * 1000; // ms 25 26 class NfcTimer { 27 public: 28 using TimerCallback = std::function<void()>; 29 static constexpr uint32_t DEFAULT_TIMEROUT = 10000; // ms 30 static NfcTimer *GetInstance(void); 31 32 NfcTimer(); 33 ~NfcTimer(); 34 35 void Register(const TimerCallback &callback, uint32_t &outTimerId, uint32_t interval = DEFAULT_TIMEROUT); 36 void UnRegister(uint32_t timerId); 37 38 private: 39 std::unique_ptr<Utils::Timer> timer_{nullptr}; 40 }; 41 } // namespace NFC 42 } // namespace OHOS 43 #endif // NFC_TIMER_H