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