111fccf17Sopenharmony_ci/* 211fccf17Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd. 311fccf17Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 411fccf17Sopenharmony_ci * you may not use this file except in compliance with the License. 511fccf17Sopenharmony_ci * You may obtain a copy of the License at 611fccf17Sopenharmony_ci * 711fccf17Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 811fccf17Sopenharmony_ci * 911fccf17Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1011fccf17Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1111fccf17Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1211fccf17Sopenharmony_ci * See the License for the specific language governing permissions and 1311fccf17Sopenharmony_ci * limitations under the License. 1411fccf17Sopenharmony_ci */ 1511fccf17Sopenharmony_ci 1611fccf17Sopenharmony_ci#ifndef OHOS_HRIL_TIMER_CALLBACK_H 1711fccf17Sopenharmony_ci#define OHOS_HRIL_TIMER_CALLBACK_H 1811fccf17Sopenharmony_ci 1911fccf17Sopenharmony_ci#include <thread> 2011fccf17Sopenharmony_ci 2111fccf17Sopenharmony_ci#include "hril_event.h" 2211fccf17Sopenharmony_ci 2311fccf17Sopenharmony_cinamespace OHOS { 2411fccf17Sopenharmony_cinamespace Telephony { 2511fccf17Sopenharmony_citypedef void (*HRilCallbackFun)(uint8_t *param); 2611fccf17Sopenharmony_ci 2711fccf17Sopenharmony_cistruct HRilTimerCallbackMessage { 2811fccf17Sopenharmony_ci uint8_t *param; 2911fccf17Sopenharmony_ci HRilCallbackFun func; 3011fccf17Sopenharmony_ci}; 3111fccf17Sopenharmony_ci 3211fccf17Sopenharmony_ciclass HRilTimerCallback { 3311fccf17Sopenharmony_cipublic: 3411fccf17Sopenharmony_ci HRilTimerCallback() {}; 3511fccf17Sopenharmony_ci virtual ~HRilTimerCallback() = default; 3611fccf17Sopenharmony_ci std::unique_ptr<HRilEvent> event_ = nullptr; 3711fccf17Sopenharmony_ci 3811fccf17Sopenharmony_ci void EventLoop(); 3911fccf17Sopenharmony_ci std::shared_ptr<HRilTimerCallbackMessage> HRilSetTimerCallbackInfo( 4011fccf17Sopenharmony_ci HRilCallbackFun func, uint8_t *param, const struct timeval *tv); 4111fccf17Sopenharmony_ci void OnTriggerEvent(); 4211fccf17Sopenharmony_ci 4311fccf17Sopenharmony_ciprivate: 4411fccf17Sopenharmony_ci void FdTriggerCallback(int32_t fd, int16_t events, std::shared_ptr<void> param); 4511fccf17Sopenharmony_ci void TimerCallback(int32_t fd, int16_t events, std::shared_ptr<void> param); 4611fccf17Sopenharmony_ci 4711fccf17Sopenharmony_ciprivate: 4811fccf17Sopenharmony_ci HRilEventMessage fdTriggerEvent_; 4911fccf17Sopenharmony_ci int32_t triggerReadFd_; 5011fccf17Sopenharmony_ci int32_t triggerWriteFd_; 5111fccf17Sopenharmony_ci const int32_t PIPE_SIZE_MAX = 2; 5211fccf17Sopenharmony_ci const int32_t READ_FD_BUFF_SIZE = 16; 5311fccf17Sopenharmony_ci std::thread::id eventLoopTid_; 5411fccf17Sopenharmony_ci}; 5511fccf17Sopenharmony_ci} // namespace Telephony 5611fccf17Sopenharmony_ci} // namespace OHOS 5711fccf17Sopenharmony_ci#endif // OHOS_HRIL_TIMER_CALLBACK_H