mirror of
https://gitee.com/openharmony/base_location
synced 2024-11-27 09:00:27 +00:00
commit
7e3d5d0c4f
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user