!940 增加异常维测

Merge pull request !940 from liuxinbing/master
This commit is contained in:
openharmony_ci 2024-09-30 08:33:00 +00:00 committed by Gitee
commit 7e3d5d0c4f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 28 additions and 6 deletions

View File

@ -178,7 +178,7 @@ public:
LocationErrCode UnregisterBleScanInfoCallback(const sptr<IRemoteObject>& callback);
LocationErrCode RegisterLocationError(sptr<ILocatorCallback>& callback, AppIdentity &identity);
LocationErrCode UnregisterLocationError(sptr<ILocatorCallback>& callback, AppIdentity &identity);
void ReportLocationError(std::string uuid, int32_t errCode);
void ReportLocationError(std::string uuid, int32_t errCode, int32_t netErrCode);
std::shared_ptr<std::map<std::string, std::list<std::shared_ptr<Request>>>> GetRequests();
std::shared_ptr<std::map<sptr<IRemoteObject>, std::list<std::shared_ptr<Request>>>> GetReceivers();
@ -283,9 +283,12 @@ public:
std::string GetUuid();
void SetErrCode(int32_t errCode);
int32_t GetErrCode();
void SetNetErrCode(int32_t netErrCode);
int32_t GetNetErrCode();
private:
std::string uuid_;
int32_t errCode_;
int32_t netErrCode_;
};
class LocatorSwitchMessage {

View File

@ -1534,11 +1534,12 @@ LocationErrCode LocatorAbility::UnregisterLocationError(sptr<ILocatorCallback>&
return ERRCODE_SUCCESS;
}
void LocatorAbility::ReportLocationError(std::string uuid, int32_t errCode)
void LocatorAbility::ReportLocationError(std::string uuid, int32_t errCode, int32_t netErrCode)
{
std::unique_ptr<LocatorErrorMessage> locatorErrorMessage = std::make_unique<LocatorErrorMessage>();
locatorErrorMessage->SetUuid(uuid);
locatorErrorMessage->SetErrCode(errCode);
locatorErrorMessage->SetNetErrCode(netErrCode);
AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::
Get(EVENT_REPORT_LOCATION_ERROR, locatorErrorMessage);
if (locatorHandler_ != nullptr) {
@ -1732,6 +1733,16 @@ int32_t LocatorErrorMessage::GetErrCode()
return errCode_;
}
void LocatorErrorMessage::SetNetErrCode(int32_t netErrCode)
{
netErrCode_ = netErrCode;
}
int32_t LocatorErrorMessage::GetNetErrCode()
{
return netErrCode_;
}
void LocatorSwitchMessage::SetUserId(int32_t userId)
{
userId_ = userId;
@ -2023,6 +2034,7 @@ void LocatorHandler::ReportNetworkLocatingErrorEvent(const AppExecFwk::InnerEven
}
auto uuid = locatorErrorMessage->GetUuid();
auto errCode = locatorErrorMessage->GetErrCode();
auto netErrCode = locatorErrorMessage->GetNetErrCode();
auto requestMap = LocatorAbility::GetInstance()->GetRequests();
if (requestMap == nullptr || requestMap->empty()) {
LBSLOGE(REQUEST_MANAGER, "requests map is empty");
@ -2036,6 +2048,12 @@ void LocatorHandler::ReportNetworkLocatingErrorEvent(const AppExecFwk::InnerEven
for (auto iter = requestList.begin(); iter != requestList.end(); iter++) {
auto request = *iter;
if (uuid.compare(request->GetUuid()) == 0) {
std::string requestInfo = "";
if (request->GetRequestConfig() != nullptr) {
requestInfo = request->GetRequestConfig()->ToString();
}
WriteLocationInnerEvent(LOCATION_REQUEST_DENY, {"errorCode", std::to_string(netErrCode),
"requestAppName", request->GetPackageName(), "requestInfo", requestInfo});
RequestManager::GetInstance()->ReportLocationError(errCode, request);
break;
}

View File

@ -1150,7 +1150,8 @@ int LocatorAbilityStub::PreReportLocationError(MessageParcel &data, MessageParce
int32_t errCode = data.ReadInt32();
std::string errMsg = data.ReadString();
std::string uuid = data.ReadString();
locatorAbility->ReportLocationError(uuid, errCode);
int32_t netErrCode = data.ReadInt32();
locatorAbility->ReportLocationError(uuid, errCode, netErrCode);
return ERRCODE_SUCCESS;
}

View File

@ -524,7 +524,6 @@ void NetworkAbility::UnregisterNlpServiceDeathRecipient()
}
}
bool NetworkAbility::IsConnect()
{
std::unique_lock<ffrt::mutex> uniqueLock(nlpServiceMutex_);
@ -550,6 +549,7 @@ void NetworkAbility::ReportLocationError(int32_t errCode, std::string errMsg, st
data.WriteInt32(LOCATING_FAILED_INTERNET_ACCESS_FAILURE);
data.WriteString(errMsg);
data.WriteString(uuid);
data.WriteInt32(errCode);
sptr<IRemoteObject> objectLocator =
CommonUtils::GetRemoteObject(LOCATION_LOCATOR_SA_ID, CommonUtils::InitDeviceId());
if (objectLocator == nullptr) {

View File

@ -579,8 +579,8 @@ HWTEST_F(LocatorAbilityTest, LocatorAbilityReportLocationError001, TestSize.Leve
sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
std::string uuid;
int32_t errCode = 10;
locatorAbility->ReportLocationError(uuid, errCode);
locatorAbility->ReportLocationError(uuid, errCode);
locatorAbility->ReportLocationError(uuid, errCode, errCode);
locatorAbility->ReportLocationError(uuid, errCode, errCode);
locatorAbility->locatorHandler_->TaskCancelAndWait();
LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUnRegisterLocationError001 end");
}