diff --git a/wifi/hisysevent.yaml b/wifi/hisysevent.yaml index 0493fd072..170e57aa2 100644 --- a/wifi/hisysevent.yaml +++ b/wifi/hisysevent.yaml @@ -123,6 +123,28 @@ WIFI_KPI_SSID: DISCONNECT_COUNT: {type: INT32, desc: sum of disconnection} IP_DHCP_COUNT: {type: INT32, desc: sum of dhcp} +P2P_CHR_EVENT: + __BASE: {type: STATISTIC, level: MINOR, desc: P2P chr event} + EVENT_NAME: {type: STRING, desc: event name} + EVENT_VALUE: {type: STRING, desc: event value} + +P2P_KPI: + __BASE: {type: STATISTIC, level: MINOR, desc: P2P KPI} + CONN_CNT: {type: INT32, desc: P2P connect count} + MAGICLINK_CONNECTED_COUNT: {type: INT32, desc: magiclink connect success count} + P2P_SUC_2G4_CNT: {type: INT32, desc: channl is on 2.4GHz channl after P2P connection} + P2P_SUC_5G_CNT: {type: INT32, desc: channl is on 5GHz channl after P2P connection} + +P2P_CONNECT_FAIL: + __BASE: {type: FAULT, level: MINOR, desc: P2P conect fail} + ERR_CODE: {type: INT32, desc: fail error code} + SUB_ERR_CODE: {type: INT32, desc: fail reason} + +P2P_AB_DISCONNECT: + __BASE: {type: FAULT, level: MINOR, desc: P2P abnormal disconect} + ERR_CODE: {type: INT32, desc: fail error code} + SUB_ERR_CODE: {type: INT32, desc: fail reason} + CHIP_CALIBRATION_FAIL: __BASE: {type: FAULT, level: MINOR, desc: calibration Fail Err event} ERROR_CODE: {type: INT32, desc: ERROR_CODE} diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/group_negotiation_state.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/group_negotiation_state.cpp index ba96e5707..5661c0d2b 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/group_negotiation_state.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/group_negotiation_state.cpp @@ -17,6 +17,8 @@ #include "wifi_p2p_hal_interface.h" #include "p2p_state_machine.h" #include "wifi_logger.h" +#include "p2p_define.h" +#include "wifi_hisysevent.h" DEFINE_WIFILOG_P2P_LABEL("GroupNegotiationState"); @@ -153,6 +155,7 @@ bool GroupNegotiationState::ProcessNegotFailEvt(InternalMessage &msg) const { int status = msg.GetParam1(); WIFI_LOGE("Negotiation failure. Error code: %{public}d", status); + WriteP2pConnectFailedHiSysEvent(status, static_cast(P2P_ERROR_RES::NEGO_FAILURE)); WifiErrorNo ret = WifiP2PHalInterface::GetInstance().P2pFlush(); if (ret != WifiErrorNo::WIFI_IDL_OPT_OK) { WIFI_LOGE("call P2pFlush() failed, ErrCode: %{public}d", static_cast(ret)); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_define.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_define.h index 0ecdcba31..6cadaab31 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_define.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_define.h @@ -161,6 +161,39 @@ enum class DHCPTYPE { DHCP_LEGACEGO, }; +enum class P2P_ERROR_RES { + NEGO_FAILURE = 0, // p2p go negotiation failure + FORMATION_FAILURE, // p2p group formation failure + PROV_SCAN_FAILURE, // prov scan failur + P2P_GROUP_REMOVE_FAILURE, + P2P_DISCOVERY_FAILURE +}; + +enum class P2P_ERROR_CODE { + NEGO_FAILURE_ERROR = 1001, + PROV_SCAN_ERROR, + FORMATION_ERROR, + P2P_GROUP_REMOVE_ERROR, + P2P_DISCOVER_FAILURE_ERROR +}; + +enum class P2P_CHR_EVENT { + CONN_CNT = 0, + MAGICLINK_CNT, + P2P_SUC_2G4_CNT, + P2P_SUC_5G_CNT +}; + +enum class P2P_CONNECT_FAIL { + ERR_CODE = 0, + FAIL_REASON +}; + +enum class P2P_AB_DISCONNECT { + ERR_CODE = 0, + FAIL_REASON +}; + using HandlerMethod = void(P2P_STATE_MACHINE_CMD, int, int, const std::any &); } // namespace Wifi } // namespace OHOS diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_monitor.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_monitor.cpp index 4a4d0008a..13998d68e 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_monitor.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_monitor.cpp @@ -18,6 +18,8 @@ #include "dhcpd_interface.h" #include "wifi_logger.h" #include "wifi_common_util.h" +#include "p2p_define.h" +#include "wifi_hisysevent.h" DEFINE_WIFILOG_P2P_LABEL("P2pMonitor"); @@ -395,6 +397,8 @@ void P2pMonitor::WpaEventGoNegFailure(int status) const void P2pMonitor::WpaEventInvitationReceived(const IdlP2pInvitationInfo &recvInfo) const { WIFI_LOGI("onInvitationReceived callback"); + WriteP2pAbDisConnectHiSysEvent(static_cast(P2P_ERROR_CODE::NEGO_FAILURE_ERROR), + static_cast(P2P_ERROR_RES::NEGO_FAILURE)); WifiP2pGroupInfo group; group.SetNetworkId(recvInfo.persistentNetworkId); @@ -451,6 +455,8 @@ void P2pMonitor::WpaEventGroupFormationFailure(const std::string &failureReason) void P2pMonitor::WpaEventGroupStarted(const IdlP2pGroupInfo &groupInfo) const { WIFI_LOGD("onGroupStarted callback"); + WriteP2pConnectFailedHiSysEvent(static_cast(P2P_ERROR_CODE::FORMATION_ERROR), + static_cast(P2P_ERROR_RES::FORMATION_FAILURE)); if (groupInfo.groupName.empty()) { WIFI_LOGE("Missing group interface name."); return; @@ -479,6 +485,8 @@ void P2pMonitor::WpaEventGroupRemoved(const std::string &groupIfName, bool isGo) { WIFI_LOGD("onGroupRemoved callback, groupIfName:%{private}s, isGo:%{public}s", groupIfName.c_str(), (isGo) ? "true" : "false"); + WriteP2pAbDisConnectHiSysEvent(static_cast(P2P_ERROR_CODE::P2P_GROUP_REMOVE_ERROR), + static_cast(P2P_ERROR_RES::P2P_GROUP_REMOVE_FAILURE)); if (groupIfName.empty()) { WIFI_LOGE("ERROR! No group name!"); return; @@ -539,6 +547,8 @@ void P2pMonitor::WpaEventProvDiscShowPin(const std::string &p2pDeviceAddress, co void P2pMonitor::WpaEventProvDiscFailure(void) const { WIFI_LOGD("onProvisionDiscoveryFailure callback"); + WriteP2pConnectFailedHiSysEvent(static_cast(P2P_ERROR_CODE::P2P_DISCOVER_FAILURE_ERROR), + static_cast(P2P_ERROR_RES::P2P_DISCOVERY_FAILURE)); Broadcast2SmProvDiscFailure(selectIfacName); } diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/provision_discovery_state.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/provision_discovery_state.cpp index 8672a2625..4d3bb7b88 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/provision_discovery_state.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/provision_discovery_state.cpp @@ -17,6 +17,7 @@ #include "wifi_p2p_temp_disc_event.h" #include "wifi_p2p_hal_interface.h" #include "wifi_logger.h" +#include "wifi_hisysevent.h" DEFINE_WIFILOG_P2P_LABEL("ProvisionDiscoveryState"); @@ -89,7 +90,8 @@ bool ProvisionDiscoveryState::ProcessCmdStartListen(InternalMessage &msg) const bool ProvisionDiscoveryState::ProcessProvDiscPbcRspEvt(InternalMessage &msg) const { WifiP2pTempDiscEvent provDisc; - + WriteP2pConnectFailedHiSysEvent(static_cast(P2P_ERROR_CODE::PROV_SCAN_ERROR), + static_cast(P2P_ERROR_RES::PROV_SCAN_FAILURE)); if (!msg.GetMessageObj(provDisc)) { WIFI_LOGD("Invalid argument provDisc"); return EXECUTED; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_service_impl.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_service_impl.cpp index 55c4ea93c..213c568af 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_service_impl.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_service_impl.cpp @@ -31,6 +31,8 @@ #include "wifi_service_manager.h" #include "wifi_global_func.h" #include "mac_address.h" +#include "p2p_define.h" +#include "wifi_hisysevent.h" DEFINE_WIFILOG_P2P_LABEL("WifiP2pServiceImpl"); @@ -493,8 +495,10 @@ ErrCode WifiP2pServiceImpl::DeleteGroup(const WifiP2pGroupInfo &group) ErrCode WifiP2pServiceImpl::P2pConnect(const WifiP2pConfig &config) { - WIFI_LOGI("P2pConnect device address [%{private}s], addressType: %{public}d], pid:%{public}d, uid:%{public}d", - config.GetDeviceAddress().c_str(), config.GetDeviceAddressType(), GetCallingPid(), GetCallingUid()); + WIFI_LOGI("P2pConnect device address [%{private}s], addressType: %{public}d], " + "pid:%{public}d, uid:%{public}d ,BundleName:%{public}s", + config.GetDeviceAddress().c_str(), config.GetDeviceAddressType(), + GetCallingPid(), GetCallingUid(), GetBundleName().c_str()); if (WifiPermissionUtils::VerifyGetWifiInfoInternalPermission() == PERMISSION_DENIED) { WIFI_LOGE("P2pConnect:VerifyGetWifiInfoInternalPermission PERMISSION_DENIED!"); @@ -561,6 +565,7 @@ ErrCode WifiP2pServiceImpl::P2pConnect(const WifiP2pConfig &config) WIFI_LOGE("Get P2P service failed!"); return WIFI_OPT_P2P_NOT_OPENED; } + WriteP2pKpiCountHiSysEvent(static_cast(P2P_CHR_EVENT::CONN_CNT)); return pService->P2pConnect(updateConfig); } @@ -1116,6 +1121,7 @@ ErrCode WifiP2pServiceImpl::Hid2dConnect(const Hid2dConnectConfig& config) return WIFI_OPT_P2P_NOT_OPENED; } WifiSettings::GetInstance().SetP2pBusinessType(P2pBusinessType::P2P_TYPE_HID2D); + WriteP2pKpiCountHiSysEvent(static_cast(P2P_CHR_EVENT::MAGICLINK_CNT)); return pService->Hid2dConnect(config); } @@ -1162,6 +1168,11 @@ ErrCode WifiP2pServiceImpl::Hid2dGetRecommendChannel(const RecommendChannelReque int channel = pService->GetP2pRecommendChannel(); int freq = ChannelToFrequency(channel); WIFI_LOGI("Get recommended channel: %{public}d, freq: %{public}d", channel, freq); + if (channel == 0) { + WriteP2pKpiCountHiSysEvent(static_cast(P2P_CHR_EVENT::P2P_SUC_2G4_CNT)); + } else { + WriteP2pKpiCountHiSysEvent(static_cast(P2P_CHR_EVENT::P2P_SUC_5G_CNT)); + } response.centerFreq = freq; response.status = RecommendStatus::RS_SUCCESS; return WIFI_OPT_SUCCESS; diff --git a/wifi/utils/inc/wifi_hisysevent.h b/wifi/utils/inc/wifi_hisysevent.h index 85bcb3482..427f98a97 100644 --- a/wifi/utils/inc/wifi_hisysevent.h +++ b/wifi/utils/inc/wifi_hisysevent.h @@ -79,6 +79,12 @@ void WriteWifiPnoScanHiSysEvent(int isStartScan, int suspendReason); void WriteBrowserFailedForPortalHiSysEvent(int respCode, std::string &Server); void WriteWifiConnectFailedEventHiSysEvent(int operateType); + +void WriteP2pKpiCountHiSysEvent(int eventType); + +void WriteP2pConnectFailedHiSysEvent(int errCode, int failRes); + +void WriteP2pAbDisConnectHiSysEvent(int errCode, int failRes); } // namespace Wifi } // namespace OHOS #endif \ No newline at end of file diff --git a/wifi/utils/src/wifi_hisysevent.cpp b/wifi/utils/src/wifi_hisysevent.cpp index cc29c31cf..727c7ffa6 100644 --- a/wifi/utils/src/wifi_hisysevent.cpp +++ b/wifi/utils/src/wifi_hisysevent.cpp @@ -141,5 +141,31 @@ void WriteWifiConnectFailedEventHiSysEvent(int operateType) root["OPERATE_TYPE"] = operateType; WriteEvent("WIFI_CHR_EVENT", "EVENT_NAME", "WIFI_CONNECT_FAILED_EVENT", "EVENT_VALUE", writer.write(root)); } + +void WriteP2pKpiCountHiSysEvent(int eventType) +{ + Json::Value root; + Json::FastWriter writer; + root["EVENT_TYPE"] = eventType; + WriteEvent("WIFI_CHR_EVENT", "EVENT_NAME", "P2P_KPI", "EVENT_VALUE", writer.write(root)); +} + +void WriteP2pConnectFailedHiSysEvent(int errCode, int failRes) +{ + Json::Value root; + Json::FastWriter writer; + root["EVENT_TYPE"] = errCode; + root["FAIL_RES"] = failRes; + WriteEvent("WIFI_CHR_EVENT", "EVENT_NAME", "P2P_CONNECT_FAIL", "EVENT_VALUE", writer.write(root)); +} + +void WriteP2pAbDisConnectHiSysEvent(int errCode, int failRes) +{ + Json::Value root; + Json::FastWriter writer; + root["EVENT_TYPE"] = errCode; + root["FAIL_RES"] = failRes; + WriteEvent("WIFI_CHR_EVENT", "EVENT_NAME", "P2P_AB_DISCONNECT", "EVENT_VALUE", writer.write(root)); +} } // namespace Wifi } // namespace OHOS \ No newline at end of file