• 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 #include "core_service_hisysevent.h"
17 
18 #include "telephony_log_wrapper.h"
19 
20 namespace OHOS {
21 namespace Telephony {
22 // EVENT
23 static constexpr const char *SIGNAL_LEVEL_EVENT = "SIGNAL_LEVEL";
24 static constexpr const char *NETWORK_REGISTER_EVENT = "NETWORK_REGISTER";
25 static constexpr const char *SET_DEFAULT_CELLULAR_DATA_EVENT = "SET_DEFAULT_CELLULAR_DATA";
26 static constexpr const char *SIM_STATE_CHANGE_EVENT = "SIM_STATE_CHANGE";
27 static constexpr const char *CALL_DIAL_FAILED_EVENT = "CALL_DIAL_FAILED";
28 static constexpr const char *CALL_ANSWER_FAILED_EVENT = "CALL_ANSWER_FAILED";
29 static constexpr const char *CALL_HANGUP_FAILED_EVENT = "CALL_HANGUP_FAILED";
30 static constexpr const char *SMS_SEND_FAILED_EVENT = "SMS_SEND_FAILED";
31 static constexpr const char *SMS_RECEIVE_FAILED_EVENT = "SMS_RECEIVE_FAILED";
32 static constexpr const char *DATA_ACTIVATE_FAILED_EVENT = "DATA_ACTIVATE_FAILED";
33 
34 // KEY
35 static constexpr const char *SLOT_ID_KEY = "SLOT_ID";
36 static constexpr const char *SIGANL_LEVEL_KEY = "LEVEL";
37 static constexpr const char *NETWORK_DOMAIN_KEY = "REGISTRATION_DOMAIN";
38 static constexpr const char *NETWORK_TECH_KEY = "RADIO_TECH";
39 static constexpr const char *NETWORK_STATE_KEY = "REGISTRATION_STATE";
40 static constexpr const char *STATE_KEY = "STATE";
41 static constexpr const char *MODULE_NAME_KEY = "MODULE";
42 static constexpr const char *CALL_ID_KEY = "CALL_ID";
43 static constexpr const char *CALL_TYPE_KEY = "CALL_TYPE";
44 static constexpr const char *VIDEO_STATE_KEY = "VIDEO_STATE";
45 static constexpr const char *ERROR_TYPE_KEY = "ERROR_TYPE";
46 static constexpr const char *ERROR_MSG_KEY = "ERROR_MSG";
47 static constexpr const char *MSG_TYPE_KEY = "MSG_TYPE";
48 static constexpr const char *DATA_SWITCH_KEY = "DATA_SWITCH";
49 static constexpr const char *UPLINK_DATA_KEY = "UPLINK_DATA";
50 static constexpr const char *DOWNLINK_DATA_KEY = "DOWNLINK_DATA";
51 static constexpr const char *DATASTATE_KEY = "DATASTATE";
52 
53 // VALUE
54 static constexpr const char *CORE_SERVICE_MODULE = "CORE_SERVICE";
55 
WriteSignalLevelBehaviorEvent(int32_t slotId,int32_t level)56 void CoreServiceHiSysEvent::WriteSignalLevelBehaviorEvent(int32_t slotId, int32_t level)
57 {
58     HiWriteBehaviorEvent(SIGNAL_LEVEL_EVENT, SLOT_ID_KEY, slotId, SIGANL_LEVEL_KEY, level);
59 }
60 
WriteNetworkStateBehaviorEvent(int32_t slotId,int32_t domain,int32_t tech,int32_t state)61 void CoreServiceHiSysEvent::WriteNetworkStateBehaviorEvent(int32_t slotId, int32_t domain, int32_t tech, int32_t state)
62 {
63     HiWriteBehaviorEvent(NETWORK_REGISTER_EVENT, SLOT_ID_KEY, slotId, NETWORK_DOMAIN_KEY, domain, NETWORK_TECH_KEY,
64         tech, NETWORK_STATE_KEY, state);
65 }
66 
WriteDefaultDataSlotIdBehaviorEvent(int32_t slotId)67 void CoreServiceHiSysEvent::WriteDefaultDataSlotIdBehaviorEvent(int32_t slotId)
68 {
69     HiWriteBehaviorEvent(SET_DEFAULT_CELLULAR_DATA_EVENT, SLOT_ID_KEY, slotId);
70 }
71 
WriteSimStateBehaviorEvent(int32_t slotId,int32_t state)72 void CoreServiceHiSysEvent::WriteSimStateBehaviorEvent(int32_t slotId, int32_t state)
73 {
74     HiWriteBehaviorEvent(SIM_STATE_CHANGE_EVENT, SLOT_ID_KEY, slotId, STATE_KEY, state);
75 }
76 
WriteDialCallFaultEvent(int32_t slotId,int32_t errCode,const std::string & desc)77 void CoreServiceHiSysEvent::WriteDialCallFaultEvent(int32_t slotId, int32_t errCode, const std::string &desc)
78 {
79     HiWriteFaultEvent(CALL_DIAL_FAILED_EVENT, MODULE_NAME_KEY, CORE_SERVICE_MODULE, SLOT_ID_KEY, slotId, CALL_TYPE_KEY,
80         INVALID_PARAMETER, VIDEO_STATE_KEY, INVALID_PARAMETER, ERROR_TYPE_KEY, errCode, ERROR_MSG_KEY, desc);
81 }
82 
WriteAnswerCallFaultEvent(int32_t slotId,int32_t errCode,const std::string & desc)83 void CoreServiceHiSysEvent::WriteAnswerCallFaultEvent(int32_t slotId, int32_t errCode, const std::string &desc)
84 {
85     HiWriteFaultEvent(CALL_ANSWER_FAILED_EVENT, MODULE_NAME_KEY, CORE_SERVICE_MODULE, SLOT_ID_KEY, slotId, CALL_ID_KEY,
86         INVALID_PARAMETER, VIDEO_STATE_KEY, INVALID_PARAMETER, ERROR_TYPE_KEY, errCode, ERROR_MSG_KEY, desc);
87 }
88 
WriteHangUpFaultEvent(int32_t slotId,int32_t errCode,const std::string & desc)89 void CoreServiceHiSysEvent::WriteHangUpFaultEvent(int32_t slotId, int32_t errCode, const std::string &desc)
90 {
91     HiWriteFaultEvent(CALL_HANGUP_FAILED_EVENT, MODULE_NAME_KEY, CORE_SERVICE_MODULE, SLOT_ID_KEY, slotId, CALL_ID_KEY,
92         INVALID_PARAMETER, ERROR_TYPE_KEY, errCode, ERROR_MSG_KEY, desc);
93 }
94 
WriteSmsSendFaultEvent(int32_t slotId,SmsMmsMessageType type,SmsMmsErrorCode errorCode,const std::string & desc)95 void CoreServiceHiSysEvent::WriteSmsSendFaultEvent(
96     int32_t slotId, SmsMmsMessageType type, SmsMmsErrorCode errorCode, const std::string &desc)
97 {
98     HiWriteFaultEvent(SMS_SEND_FAILED_EVENT, MODULE_NAME_KEY, CORE_SERVICE_MODULE, SLOT_ID_KEY, slotId, MSG_TYPE_KEY,
99         static_cast<int32_t>(type), ERROR_TYPE_KEY, static_cast<int32_t>(errorCode), ERROR_MSG_KEY, desc);
100 }
101 
WriteSmsReceiveFaultEvent(int32_t slotId,SmsMmsMessageType type,SmsMmsErrorCode errorCode,const std::string & desc)102 void CoreServiceHiSysEvent::WriteSmsReceiveFaultEvent(
103     int32_t slotId, SmsMmsMessageType type, SmsMmsErrorCode errorCode, const std::string &desc)
104 {
105     HiWriteFaultEvent(SMS_RECEIVE_FAILED_EVENT, MODULE_NAME_KEY, CORE_SERVICE_MODULE, SLOT_ID_KEY, slotId, MSG_TYPE_KEY,
106         static_cast<int32_t>(type), ERROR_TYPE_KEY, static_cast<int32_t>(errorCode), ERROR_MSG_KEY, desc);
107 }
108 
WriteDataActivateFaultEvent(int32_t slotId,int32_t switchState,CellularDataErrorCode errorType,const std::string & errorMsg)109 void CoreServiceHiSysEvent::WriteDataActivateFaultEvent(
110     int32_t slotId, int32_t switchState, CellularDataErrorCode errorType, const std::string &errorMsg)
111 {
112     HiWriteFaultEvent(DATA_ACTIVATE_FAILED_EVENT, MODULE_NAME_KEY, CORE_SERVICE_MODULE, SLOT_ID_KEY, slotId,
113         DATA_SWITCH_KEY, switchState, UPLINK_DATA_KEY, INVALID_PARAMETER, DOWNLINK_DATA_KEY, INVALID_PARAMETER,
114         DATASTATE_KEY, INVALID_PARAMETER, ERROR_TYPE_KEY, static_cast<int32_t>(errorType), ERROR_MSG_KEY, errorMsg);
115 }
116 } // namespace Telephony
117 } // namespace OHOS
118