• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 CELLULAR_CALL_HISYSEVENT_H
17 #define CELLULAR_CALL_HISYSEVENT_H
18 
19 #include <string>
20 
21 #include "telephony_hisysevent.h"
22 
23 namespace OHOS {
24 namespace Telephony {
25 static const int64_t NORMAL_INCOMING_TIME = 500; // incoming time (ms)
26 static const int16_t maxNumberLen = 100;
27 
28 enum class AnswerCallType {
29     IMS_VOICE_ANSWER = 0,
30     IMS_VIDEO_TO_VOICE_ANSWER,
31     IMS_VIDEO_TO_VIDEO_ANSWER,
32     CS_VOICE_ANSWER,
33 };
34 
35 enum class DialCallType {
36     IMS_VOICE_DIAL = 0,
37     IMS_VIDEO_DIAL,
38     CS_VOICE_DIAL,
39 };
40 
41 enum class HangUpCallType {
42     IMS_VOICE_CALL = 0,
43     IMS_VIDEO_CALL,
44     CS_VOICE_CALL,
45 };
46 
47 enum class CallResponseResult {
48     COMMAND_FAILURE = 0,
49     COMMAND_SUCCESS,
50 };
51 
52 struct CallBehaviorParameterInfo {
53     int32_t slotId = 0;
54     int32_t callType = 0;
55     int32_t videoState = 0;
56     int32_t incomingCallType = 0;
57     int32_t incomingVideoState = 0;
58 };
59 
60 enum class CallModeBehaviorType {
61     SEND_REQUEST_EVENT = 0,
62     SEND_RESPONSE_EVENT,
63     RECEIVE_REQUEST_EVENT,
64     RECEIVE_RESPONSE_EVENT,
65 };
66 
67 struct CallForwardingInfo {
68     int32_t slotId = 0;
69     bool enable = false;
70     char number[maxNumberLen + 1] = { 0 };
71 };
72 
73 class CellularCallHiSysEvent : public TelephonyHiSysEvent {
74 public:
75     static void WriteFoundationRestartFaultEvent(const int32_t count);
76     static void WriteCallEndBehaviorEvent(const int32_t slotId, const int32_t cause);
77     static void WriteDialCallBehaviorEvent(const CallBehaviorParameterInfo &info, const CallResponseResult &result);
78     static void WriteHangUpCallBehaviorEvent(const CallBehaviorParameterInfo &info, const CallResponseResult &result);
79     static void WriteAnswerCallBehaviorEvent(const CallBehaviorParameterInfo &info, const CallResponseResult &result);
80     static void WriteDialCallFaultEvent(const int32_t slotId, const int32_t callType, const int32_t videoState,
81         const int32_t errorCode, const std::string &desc);
82     static void WriteAnswerCallFaultEvent(const int32_t slotId, const int32_t callId, const int32_t videoState,
83         const int32_t errorCode, const std::string &desc);
84     static void WriteHangUpFaultEvent(
85         const int32_t slotId, const int32_t callId, const int32_t errorCode, const std::string &desc);
86     static void WriteIncomingCallFaultEvent(const int32_t slotId, const int32_t callType, const int32_t videoState,
87         const int32_t errCode, const std::string &desc);
88     static void WriteVoNRSwitchChangeEvent(const int32_t enable);
89     static void WriteImsCallModeBehaviorEvent(
90         const CallModeBehaviorType type, const CallBehaviorParameterInfo &info, const int32_t requestResult);
91 #ifdef SECURITY_GUARDE_ENABLE
92     static void WriteCallTansferEvent(uint8_t state);
93 #endif
94     void SetCallParameterInfo(const int32_t slotId, const int32_t callType, const int32_t videoState);
95     void SetIncomingCallParameterInfo(const int32_t incomingCallType, const int32_t incomingVideoState);
96     void GetCallParameterInfo(CallBehaviorParameterInfo &info);
97     void SetIncomingStartTime();
98     void JudgingIncomingTimeOut(const int32_t slotId, const int32_t callType, const int32_t videoState);
99     void SetCallForwardingInfo(const int32_t slotId, const bool enable, const std::string &number);
100     void GetCallForwardingInfo(CallForwardingInfo &info);
101 
102 private:
103     template<typename... Types>
104     static void CallWriteEvent(const std::string &eventName, Types... args);
105     static int32_t ErrorCodeConversion(const int32_t errCode, CallErrorCode &eventValue);
106     static int32_t CallDataErrorCodeConversion(const int32_t errCode, CallErrorCode &eventValue);
107     static int32_t CallInterfaceErrorCodeConversion(const int32_t errCode, CallErrorCode &eventValue);
108     static int32_t TelephonyErrorCodeConversion(const int32_t errCode, CallErrorCode &eventValue);
109 
110 private:
111     bool callForwardingEnable_ = false;
112     int32_t callForwardingSlotId_;
113     int32_t dfxSlotId_;
114     int32_t dfxCallId_;
115     int32_t dfxCallType_;
116     int32_t dfxVideoState_;
117     int32_t dfxIncomingCallType_;
118     int32_t dfxIncomingVideoState_;
119     int64_t incomingStartTime_ = 0L;
120     std::string callForwardingNumber_ = "";
121 };
122 } // namespace Telephony
123 } // namespace OHOS
124 
125 #endif // CELLULAR_CALL_HISYSEVENT_H
126