• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 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 REPORT_CALL_INFO_HANDLER_H
17 #define REPORT_CALL_INFO_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 
28 namespace OHOS {
29 namespace Telephony {
30 class ReportCallInfoHandler : public AppExecFwk::EventHandler {
31 public:
32     ReportCallInfoHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner);
33     virtual ~ReportCallInfoHandler();
34     void Init();
35     void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event);
36 
37 private:
38     using CallManagerServiceFunc = void (ReportCallInfoHandler::*)(const AppExecFwk::InnerEvent::Pointer &event);
39     void ReportCallInfo(const AppExecFwk::InnerEvent::Pointer &event);
40     void ReportCallsInfo(const AppExecFwk::InnerEvent::Pointer &event);
41     void ReportDisconnectedCause(const AppExecFwk::InnerEvent::Pointer &event);
42     void ReportEventInfo(const AppExecFwk::InnerEvent::Pointer &event);
43     void ReportOttEvent(const AppExecFwk::InnerEvent::Pointer &event);
44     void OnUpdateMediaModeResponse(const AppExecFwk::InnerEvent::Pointer &event);
45     std::map<uint32_t, CallManagerServiceFunc> memberFuncMap_;
46     std::unique_ptr<CallStatusManager> callStatusManagerPtr_;
47 };
48 
49 class ReportCallInfoHandlerService : public std::enable_shared_from_this<ReportCallInfoHandlerService> {
50     DECLARE_DELAYED_SINGLETON(ReportCallInfoHandlerService)
51 public:
52     void Start();
53     int32_t UpdateCallReportInfo(const CallDetailInfo &info);
54     int32_t UpdateCallsReportInfo(CallDetailsInfo &info);
55     int32_t UpdateDisconnectedCause(const DisconnectedDetails &details);
56     int32_t UpdateEventResultInfo(const CellularCallEventInfo &info);
57     int32_t UpdateOttEventInfo(const OttCallEventInfo &info);
58     int32_t UpdateMediaModeResponse(const CallMediaModeResponse &response);
59 
60     enum {
61         HANDLER_UPDATE_CELLULAR_CALL_INFO = 0,
62         HANDLER_UPDATE_CALL_INFO_LIST,
63         HANDLER_UPDATE_DISCONNECTED_CAUSE,
64         HANDLER_UPDATE_CELLULAR_EVENT_RESULT_INFO,
65         HANDLER_UPDATE_OTT_EVENT_RESULT_INFO,
66         HANDLE_UPDATE_MEDIA_MODE_RESPONSE,
67     };
68 
69 private:
70     std::shared_ptr<AppExecFwk::EventRunner> eventLoop_;
71     std::shared_ptr<ReportCallInfoHandler> handler_;
72 };
73 } // namespace Telephony
74 } // namespace OHOS
75 
76 #endif // REPORT_CALL_INFO_HANDLER_H
77