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 struct CallForwardingInfo { 61 int32_t slotId = 0; 62 bool enable = false; 63 char number[maxNumberLen + 1] = { 0 }; 64 }; 65 66 class CellularCallHiSysEvent : public TelephonyHiSysEvent { 67 public: 68 static void WriteFoundationRestartFaultEvent(const int32_t count); 69 static void WriteCallEndBehaviorEvent(const int32_t slotId, const int32_t cause); 70 static void WriteDialCallBehaviorEvent(const CallBehaviorParameterInfo &info, const CallResponseResult &result); 71 static void WriteHangUpCallBehaviorEvent(const CallBehaviorParameterInfo &info, const CallResponseResult &result); 72 static void WriteAnswerCallBehaviorEvent(const CallBehaviorParameterInfo &info, const CallResponseResult &result); 73 static void WriteDialCallFaultEvent(const int32_t slotId, const int32_t callType, const int32_t videoState, 74 const int32_t errorCode, const std::string &desc); 75 static void WriteAnswerCallFaultEvent(const int32_t slotId, const int32_t callId, const int32_t videoState, 76 const int32_t errorCode, const std::string &desc); 77 static void WriteHangUpFaultEvent( 78 const int32_t slotId, const int32_t callId, const int32_t errorCode, const std::string &desc); 79 static void WriteIncomingCallFaultEvent(const int32_t slotId, const int32_t callType, const int32_t videoState, 80 const int32_t errCode, const std::string &desc); 81 static void WriteVoNRSwitchChangeEvent(const int32_t enable); 82 void SetCallParameterInfo(const int32_t slotId, const int32_t callType, const int32_t videoState); 83 void SetIncomingCallParameterInfo(const int32_t incomingCallType, const int32_t incomingVideoState); 84 void GetCallParameterInfo(CallBehaviorParameterInfo &info); 85 void SetIncomingStartTime(); 86 void JudgingIncomingTimeOut(const int32_t slotId, const int32_t callType, const int32_t videoState); 87 void SetCallForwardingInfo(const int32_t slotId, const bool enable, const std::string &number); 88 void GetCallForwardingInfo(CallForwardingInfo &info); 89 90 private: 91 template<typename... Types> 92 static void CallWriteEvent(const std::string &eventName, Types... args); 93 static int32_t ErrorCodeConversion(const int32_t errCode, CallErrorCode &eventValue); 94 static int32_t CallDataErrorCodeConversion(const int32_t errCode, CallErrorCode &eventValue); 95 static int32_t CallInterfaceErrorCodeConversion(const int32_t errCode, CallErrorCode &eventValue); 96 static int32_t TelephonyErrorCodeConversion(const int32_t errCode, CallErrorCode &eventValue); 97 98 private: 99 bool callForwardingEnable_ = false; 100 int32_t callForwardingSlotId_; 101 int32_t dfxSlotId_; 102 int32_t dfxCallId_; 103 int32_t dfxCallType_; 104 int32_t dfxVideoState_; 105 int32_t dfxIncomingCallType_; 106 int32_t dfxIncomingVideoState_; 107 int64_t incomingStartTime_ = 0L; 108 std::string callForwardingNumber_ = ""; 109 }; 110 } // namespace Telephony 111 } // namespace OHOS 112 113 #endif // CELLULAR_CALL_HISYSEVENT_H 114