!1675 chr打点 Wifi扫描接口异常

Merge pull request !1675 from 武宏博/master
This commit is contained in:
openharmony_ci 2024-01-02 03:29:17 +00:00 committed by Gitee
commit 265b6fc5f4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 51 additions and 9 deletions

View File

@ -22,6 +22,8 @@
#include "wifi_logger.h"
#include "wifi_scan_proxy.h"
#include "wifi_scan_mgr_proxy.h"
#include "wifi_hisysevent.h"
#include "wifi_common_util.h"
DEFINE_WIFILOG_SCAN_LABEL("WifiScanImpl");
@ -80,12 +82,14 @@ bool WifiScanImpl::GetWifiScanProxy()
sptr<ISystemAbilityManager> sa_mgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (sa_mgr == nullptr) {
WIFI_LOGE("failed to get SystemAbilityManager");
WriteWifiScanApiFailHiSysEvent(GetBundleName(), -1);
return false;
}
sptr<IRemoteObject> object = sa_mgr->GetSystemAbility(systemAbilityId_);
if (object == nullptr) {
WIFI_LOGE("failed to get SCAN_SERVICE");
WriteWifiScanApiFailHiSysEvent(GetBundleName(), -1);
return false;
}
@ -95,12 +99,14 @@ bool WifiScanImpl::GetWifiScanProxy()
}
if (scanMgr == nullptr) {
WIFI_LOGE("wifi scan init failed, %{public}d", systemAbilityId_);
WriteWifiScanApiFailHiSysEvent(GetBundleName(), -1);
return false;
}
sptr<IRemoteObject> service = scanMgr->GetWifiRemote(instId_);
if (service == nullptr) {
WIFI_LOGE("wifi scan remote obj is null, %{public}d", instId_);
WriteWifiScanApiFailHiSysEvent(GetBundleName(), -1);
return false;
}
@ -110,6 +116,7 @@ bool WifiScanImpl::GetWifiScanProxy()
}
if (client_ == nullptr) {
WIFI_LOGE("wifi scan instId_ %{public}d init failed. %{public}d", instId_, systemAbilityId_);
WriteWifiScanApiFailHiSysEvent(GetBundleName(), -1);
return false;
}
return true;

View File

@ -32,6 +32,7 @@
#include "wifi_service_manager.h"
#include "wifi_sta_hal_interface.h"
#include "wifi_common_util.h"
#include "wifi_hisysevent.h"
DEFINE_WIFILOG_SCAN_LABEL("WifiScanServiceImpl");
namespace OHOS {
@ -111,38 +112,59 @@ ErrCode WifiScanServiceImpl::Scan(bool compatible)
WIFI_LOGI("Scan, compatible:%{public}d", compatible);
if (WifiPermissionUtils::VerifyGetWifiInfoInternalPermission() == PERMISSION_DENIED) {
WIFI_LOGE("Scan:VerifyGetWifiInfoInternalPermission PERMISSION_DENIED!");
if (WifiPermissionUtils::VerifySetWifiInfoPermission() == PERMISSION_DENIED) {
WIFI_LOGE("Scan:VerifySetWifiInfoPermission PERMISSION_DENIED!");
#ifndef OHOS_ARCH_LITE
WriteWifiScanApiFailHiSysEvent(GetBundleName(), -1);
#endif
return WIFI_OPT_PERMISSION_DENIED;
}
if (compatible) {
if (WifiPermissionUtils::VerifyGetScanInfosPermission() == PERMISSION_DENIED) {
WIFI_LOGE("Scan:VerifyGetScanInfosPermission PERMISSION_DENIED!");
#ifndef OHOS_ARCH_LITE
WriteWifiScanApiFailHiSysEvent(GetBundleName(), -1);
#endif
return WIFI_OPT_PERMISSION_DENIED;
}
} else {
if (!WifiAuthCenter::IsSystemAppByToken()) {
WIFI_LOGE("Scan:NOT System APP, PERMISSION_DENIED!");
#ifndef OHOS_ARCH_LITE
WriteWifiScanApiFailHiSysEvent(GetBundleName(), -1);
#endif
return WIFI_OPT_NON_SYSTEMAPP;
}
if (WifiPermissionUtils::VerifyWifiConnectionPermission() == PERMISSION_DENIED) {
WIFI_LOGE("Scan:VerifyGetScanInfosPermission PERMISSION_DENIED!");
#ifndef OHOS_ARCH_LITE
WriteWifiScanApiFailHiSysEvent(GetBundleName(), -1);
#endif
return WIFI_OPT_PERMISSION_DENIED;
}
}
}
if (!IsScanServiceRunning()) {
#ifndef OHOS_ARCH_LITE
WriteWifiScanApiFailHiSysEvent(GetBundleName(), -1);
#endif
return WIFI_OPT_SCAN_NOT_OPENED;
}
#ifndef OHOS_ARCH_LITE
UpdateScanMode();
#endif
return PermissionVerification();
}
ErrCode WifiScanServiceImpl::PermissionVerification()
{
IScanService *pService = WifiServiceManager::GetInstance().GetScanServiceInst(m_instId);
if (pService == nullptr) {
#ifndef OHOS_ARCH_LITE
WriteWifiScanApiFailHiSysEvent(GetBundleName(), -1);
#endif
return WIFI_OPT_SCAN_NOT_OPENED;
}
@ -156,6 +178,9 @@ ErrCode WifiScanServiceImpl::Scan(bool compatible)
ErrCode ret = pService->Scan(externFlag);
if (ret != WIFI_OPT_SUCCESS) {
WIFI_LOGE("Scan failed: %{public}d!", static_cast<int>(ret));
#ifndef OHOS_ARCH_LITE
WriteWifiScanApiFailHiSysEvent(GetBundleName(), -1);
#endif
}
return ret;
}

View File

@ -44,6 +44,7 @@ public:
ErrCode SetScanControlInfo(const ScanControlInfo &info) override;
ErrCode Scan(bool compatible) override;
ErrCode PermissionVerification();
ErrCode AdvanceScan(const WifiScanParams &params) override;
ErrCode IsWifiClosedScan(bool &bOpen) override;
ErrCode GetScanInfoList(std::vector<WifiScanInfo> &result, bool compatible) override;

View File

@ -142,6 +142,7 @@ void StaNetworkCheck::ArpDetection()
if (!arpChecker.DoArpCheck(MAX_ARP_DNS_CHECK_TIME, true)) {
LOGI("RunNetCheckThreadFunc arp check failed.");
arpStateHandler(StaArpState::ARP_STATE_UNREACHABLE);
WriteWifiAccessIntFailedHiSysEvent(ARP_OPT, StaArpState::ARP_STATE_UNREACHABLE);
}
});
}
@ -174,6 +175,7 @@ StaNetState StaNetworkCheck::CheckResponseCode(std::string url, int codeNum, int
(lastNetState.load() != NETWORK_CHECK_PORTAL)) {
WIFI_LOGE("http detect network not working!");
lastNetState = NETWORK_STATE_NOINTERNET;
WriteWifiAccessIntFailedHiSysEvent(DETECT_NOT_NETWORK, NETWORK_STATE_NOINTERNET);
} else {
WIFI_LOGE("http detect unknow network!");
}
@ -320,10 +322,7 @@ void StaNetworkCheck::RunNetCheckThreadFunc()
ArpDetection();
StopHttpProbeTimer();
isStopNetCheck = true;
httpDetectCnt++;
if (httpDetectCnt == HTTP_OPT) {
WriteWifiAccessIntFailedHiSysEvent(HTTP_OPT, NETWORK_STATE_NOINTERNET);
}
WriteWifiAccessIntFailedHiSysEvent(HTTP_OPT, NETWORK_STATE_NOINTERNET);
continue;
}
@ -371,7 +370,6 @@ void StaNetworkCheck::SignalNetCheckThread()
WIFI_LOGI("detection is now running or screen %{public}d!\n", m_screenState);
return;
}
httpDetectCnt = 0;
// get mac address
std::string macAddress;
WifiSettings::GetInstance().GetMacAddress(macAddress, m_instId);

View File

@ -40,6 +40,7 @@
#define ARP_OPT 0
#define HTTP_OPT 1
#define DETECT_NOT_NETWORK 2
namespace OHOS {
namespace Wifi {
@ -144,7 +145,6 @@ private:
#ifndef OHOS_ARCH_LITE
std::unique_ptr<WifiEventHandler> mDetectionEventHandler = nullptr;
#endif
int httpDetectCnt;
};
} // namespace Wifi
} // namespace OHOS

View File

@ -97,6 +97,8 @@ void WriteSoftApAbDisconnectHiSysEvent(int errorCode);
void WriteIsInternetHiSysEvent(bool isInternet);
void WriteSoftApConnectFailHiSysEvent(int errorCnt);
void WriteWifiScanApiFailHiSysEvent(const std::string& pkgName, int failReason);
} // namespace Wifi
} // namespace OHOS
#endif

View File

@ -212,5 +212,14 @@ void WriteSoftApConnectFailHiSysEvent(int errorCnt)
root["ERROR_CODE"] = errorCnt;
WriteEvent("WIFI_CHR_EVENT", "EVENT_NAME", "SOFT_AP_CONNECT_FAILD", "EVENT_VALUE", writer.write(root));
}
void WriteWifiScanApiFailHiSysEvent(const std::string& pkgName, int failReason)
{
Json::Value root;
Json::FastWriter writer;
root["PACKAGE_NAME"] = pkgName;
root["FAIL_REASON"] = failReason;
WriteEvent("WIFI_SCAN", "EVENT_NAME", "WIFI_SCAN_API_FAIL", "EVENT_VALUE", writer.write(root));
}
} // namespace Wifi
} // namespace OHOS