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 TELEPHONY_CALL_RECORDS_HANDLER_H 17 #define TELEPHONY_CALL_RECORDS_HANDLER_H 18 19 #include <memory> 20 #include <mutex> 21 22 #include "event_handler.h" 23 #include "event_runner.h" 24 #include "singleton.h" 25 26 #include "call_status_manager.h" 27 #include "call_data_base_helper.h" 28 29 namespace OHOS { 30 namespace Telephony { 31 class CallRecordsHandler : public AppExecFwk::EventHandler { 32 public: 33 CallRecordsHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner); 34 virtual ~CallRecordsHandler() = default; 35 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event); 36 37 private: 38 std::shared_ptr<CallDataBaseHelper> callDataPtr_; 39 }; 40 41 class CallRecordsHandlerService : public std::enable_shared_from_this<CallRecordsHandlerService> { 42 DECLARE_DELAYED_SINGLETON(CallRecordsHandlerService) 43 public: 44 void Start(); 45 int32_t StoreCallRecord(const CallRecordInfo &info); 46 enum { 47 HANDLER_ADD_CALL_RECORD_INFO = 0, 48 }; 49 50 private: 51 std::shared_ptr<AppExecFwk::EventRunner> eventLoop_; 52 std::shared_ptr<CallRecordsHandler> handler_; 53 }; 54 } // namespace Telephony 55 } // namespace OHOS 56 #endif // TELEPHONY_CALL_RECORDS_HANDLER_H