• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "missed_call_notification.h"
27 #include "singleton.h"
28 
29 namespace OHOS {
30 namespace Telephony {
31 class CallRecordsHandler {
32 public:
33     CallRecordsHandler();
34     virtual ~CallRecordsHandler() = default;
35     int32_t QueryAndNotifyUnReadMissedCall();
36     int32_t AddCallLogInfo(const CallRecordInfo &info);
37 
38 private:
39     std::string CheckNumberLocationInfo(const CallRecordInfo &info);
40     void MakeCallLogInsertBucket(DataShare::DataShareValuesBucket &bucket,
41         const CallRecordInfo &info, std::string displayName, std::string numberLocation);
42     void DeleteCallLogForLimit(const CallRecordInfo &info);
43 
44 private:
45     std::shared_ptr<CallDataBaseHelper> callDataPtr_;
46     std::shared_ptr<MissedCallNotification> missedCallNotification_;
47 };
48 
49 class CallRecordsHandlerService : public std::enable_shared_from_this<CallRecordsHandlerService> {
50     DECLARE_DELAYED_SINGLETON(CallRecordsHandlerService)
51 public:
52     void Start();
53     int32_t StoreCallRecord(const CallRecordInfo &info);
54     int32_t RemoveMissedIncomingCallNotification();
55     int32_t QueryUnReadMissedCallLog();
56 
57 private:
58     std::shared_ptr<CallRecordsHandler> handler_;
59 };
60 } // namespace Telephony
61 } // namespace OHOS
62 #endif // TELEPHONY_CALL_RECORDS_HANDLER_H