• 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 
27 enum class AnswerCallType {
28     IMS_VOICE_ANSWER = 0,
29     IMS_VIDEO_TO_VOICE_ANSWER,
30     IMS_VIDEO_TO_VIDEO_ANSWER,
31     CS_VOICE_ANSWER,
32 };
33 
34 enum class DialCallType {
35     IMS_VOICE_DIAL = 0,
36     IMS_VIDEO_DIAL,
37     CS_VOICE_DIAL,
38 };
39 
40 enum class HangUpCallType {
41     IMS_VOICE_CALL = 0,
42     IMS_VIDEO_CALL,
43     CS_VOICE_CALL,
44 };
45 
46 enum class CallResponseResult {
47     COMMAND_FAILURE = 0,
48     COMMAND_SUCCESS,
49 };
50 
51 struct CallBehaviorParameterInfo {
52     int32_t slotId;
53     int32_t callType;
54     int32_t videoState;
55     int32_t incomingCallType;
56     int32_t incomingVideoState;
57 };
58 
59 class CellularCallHiSysEvent : public TelephonyHiSysEvent {
60 public:
61     static void WriteFoundationRestartFaultEvent(const int32_t count);
62     static void WriteCallEndBehaviorEvent(const int32_t slotId, const int32_t cause);
63     static void WriteDialCallBehaviorEvent(const CallBehaviorParameterInfo &info, const CallResponseResult &result);
64     static void WriteHangUpCallBehaviorEvent(const CallBehaviorParameterInfo &info, const CallResponseResult &result);
65     static void WriteAnswerCallBehaviorEvent(const CallBehaviorParameterInfo &info, const CallResponseResult &result);
66     static void WriteDialCallFaultEvent(const int32_t slotId, const int32_t callType, const int32_t videoState,
67         const int32_t errorCode, const std::string &desc);
68     static void WriteAnswerCallFaultEvent(const int32_t slotId, const int32_t callId, const int32_t videoState,
69         const int32_t errorCode, const std::string &desc);
70     static void WriteHangUpFaultEvent(
71         const int32_t slotId, const int32_t callId, const int32_t errorCode, const std::string &desc);
72     static void WriteIncomingCallFaultEvent(const int32_t slotId, const int32_t callType, const int32_t videoState,
73         const int32_t errCode, const std::string &desc);
74     void SetCallParameterInfo(const int32_t slotId, const int32_t callType, const int32_t videoState);
75     void SetIncomingCallParameterInfo(const int32_t incomingCallType, const int32_t incomingVideoState);
76     void GetCallParameterInfo(CallBehaviorParameterInfo &info);
77     void SetIncomingStartTime();
78     void JudgingIncomingTimeOut(const int32_t slotId, const int32_t callType, const int32_t videoState);
79 
80 private:
81     template<typename... Types>
82     static void CallWriteEvent(const std::string &eventName, Types... args);
83     static int32_t ErrorCodeConversion(const int32_t errCode, CallErrorCode &eventValue);
84     static int32_t CallDataErrorCodeConversion(const int32_t errCode, CallErrorCode &eventValue);
85     static int32_t CallInterfaceErrorCodeConversion(const int32_t errCode, CallErrorCode &eventValue);
86     static int32_t TelephonyErrorCodeConversion(const int32_t errCode, CallErrorCode &eventValue);
87 
88 private:
89     int32_t dfxSlotId_;
90     int32_t dfxCallId_;
91     int32_t dfxCallType_;
92     int32_t dfxVideoState_;
93     int32_t dfxIncomingCallType_;
94     int32_t dfxIncomingVideoState_;
95     int64_t incomingStartTime_ = 0L;
96 };
97 } // namespace Telephony
98 } // namespace OHOS
99 
100 #endif // CELLULAR_CALL_HISYSEVENT_H
101