• 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 CALL_STATUS_MANAGER_H
17 #define CALL_STATUS_MANAGER_H
18 
19 #include <map>
20 
21 #include "refbase.h"
22 
23 #include "common_type.h"
24 #include "call_status_policy.h"
25 #include "call_incoming_filter_manager.h"
26 
27 /**
28  * Singleton
29  * @ClassName:CallStatusManager
30  * @Description:CallStatusManager is designed for watching call state changes,
31  * when call state changes, cellularcall will notify callstatusmanager to handle it.
32  * call state: idle,disconnected, disconnecting,dialing,alerting,active,holding,waiting
33  * incoming
34  */
35 namespace OHOS {
36 namespace Telephony {
37 class CallStatusManager : public CallStatusPolicy {
38 public:
39     CallStatusManager();
40     ~CallStatusManager();
41     int32_t Init();
42     int32_t UnInit();
43     int32_t HandleCallReportInfo(const CallDetailInfo &info);
44     int32_t HandleCallsReportInfo(const CallDetailsInfo &info);
45     int32_t HandleDisconnectedCause(const DisconnectedDetails &details);
46     int32_t HandleEventResultReportInfo(const CellularCallEventInfo &info);
47     int32_t HandleOttEventReportInfo(const OttCallEventInfo &info);
48     void CallFilterCompleteResult(const CallDetailInfo &info);
49 
50 private:
51     void InitCallBaseEvent();
52     int32_t IncomingHandle(const CallDetailInfo &info);
53     int32_t DialingHandle(const CallDetailInfo &info);
54     int32_t ActiveHandle(const CallDetailInfo &info);
55     int32_t HoldingHandle(const CallDetailInfo &info);
56     int32_t WaitingHandle(const CallDetailInfo &info);
57     int32_t AlertHandle(const CallDetailInfo &info);
58     int32_t DisconnectingHandle(const CallDetailInfo &info);
59     int32_t DisconnectedHandle(const CallDetailInfo &info);
60     sptr<CallBase> CreateNewCall(const CallDetailInfo &info, CallDirection dir);
61     sptr<CallBase> RefreshCallIfNecessary(const sptr<CallBase> &call, const CallDetailInfo &info);
62     void PackParaInfo(
63         DialParaInfo &paraInfo, const CallDetailInfo &info, CallDirection dir, AppExecFwk::PacMap &extras);
64     int32_t UpdateCallState(sptr<CallBase> &call, TelCallState nextState);
65     int32_t ToSpeakerPhone(sptr<CallBase> &call);
66     int32_t TurnOffMute(sptr<CallBase> &call);
67     int32_t IncomingFilterPolicy(const CallDetailInfo &info);
68     void QueryCallerInfo(ContactInfo &contactInfo, std::string phoneNum);
69     int32_t UpdateDialingCallInfo(const CallDetailInfo &info);
70 
71 private:
72     CallDetailInfo callReportInfo_;
73     CallDetailsInfo callDetailsInfo_;
74     sptr<CallIncomingFilterManager> CallIncomingFilterManagerPtr_;
75     std::map<RequestResultEventId, CallAbilityEventId> mEventIdTransferMap_;
76     std::map<OttCallEventId, CallAbilityEventId> mOttEventIdTransferMap_;
77     const std::string DETAIL_INFO = "detail_info";
78     const std::string CONTENT_TYPE = "content_type";
79     const std::string PHONE = "phone";
80 };
81 } // namespace Telephony
82 } // namespace OHOS
83 
84 #endif // CALL_STATUS_MANAGER_H
85