mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2024-11-27 09:12:20 +00:00
commit
265b6fc5f4
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
|
||||
ErrCode SetScanControlInfo(const ScanControlInfo &info) override;
|
||||
ErrCode Scan(bool compatible) override;
|
||||
ErrCode PermissionVerification();
|
||||
ErrCode AdvanceScan(const WifiScanParams ¶ms) override;
|
||||
ErrCode IsWifiClosedScan(bool &bOpen) override;
|
||||
ErrCode GetScanInfoList(std::vector<WifiScanInfo> &result, bool compatible) override;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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
|
Loading…
Reference in New Issue
Block a user