mirror of
https://github.com/openharmony/base_location.git
synced 2026-08-24 22:31:51 -04:00
@@ -352,19 +352,20 @@ bool LocatingRequiredDataToJsObj(const napi_env& env,
|
||||
CellularInfoToJsObj(env, replyList[i]->GetCampedCellInfo(), compedCellInfoObj);
|
||||
|
||||
napi_value neighboringCellInfoObj = nullptr;
|
||||
NAPI_CALL_BASE(env,
|
||||
napi_create_array_with_length(env, replyList[i]->GetNeighboringCellInfo().size(), &neighboringCellInfoObj), false);
|
||||
NAPI_CALL_BASE(env, napi_create_array_with_length(env, replyList[i]->GetNeighboringCellInfo().size(),
|
||||
&neighboringCellInfoObj), false);
|
||||
for (size_t j = 0; j < replyList[i]->GetNeighboringCellInfo().size(); j++) {
|
||||
napi_value cellularInfoObj;
|
||||
NAPI_CALL_BASE(env, napi_create_object(env, &cellularInfoObj), false);
|
||||
std::shared_ptr<CellularInfo> cellularInfo = replyList[i]->GetNeighboringCellInfo()[i];
|
||||
std::shared_ptr<CellularInfo> cellularInfo = replyList[i]->GetNeighboringCellInfo()[j];
|
||||
CellularInfoToJsObj(env, cellularInfo, cellularInfoObj);
|
||||
napi_set_element(env, neighboringCellInfoObj, j, cellularInfoObj);
|
||||
NAPI_CALL_BASE(env, napi_set_element(env, neighboringCellInfoObj, j, cellularInfoObj), false);
|
||||
}
|
||||
NAPI_CALL_BASE(env, napi_set_named_property(env, eachObj, "wifiData", wifiObj), false);
|
||||
NAPI_CALL_BASE(env, napi_set_named_property(env, eachObj, "bluetoothData", blueToothObj), false);
|
||||
NAPI_CALL_BASE(env, napi_set_named_property(env, eachObj, "campedCellInfo", compedCellInfoObj), false);
|
||||
NAPI_CALL_BASE(env, napi_set_named_property(env, eachObj, "neighboringCellInfo", neighboringCellInfoObj), false);
|
||||
NAPI_CALL_BASE(env,
|
||||
napi_set_named_property(env, eachObj, "neighboringCellInfo", neighboringCellInfoObj), false);
|
||||
napi_status status = napi_set_element(env, arrayResult, idx++, eachObj);
|
||||
if (status != napi_ok) {
|
||||
LBSLOGE(LOCATING_DATA_CALLBACK, "set element error: %{public}d, idx: %{public}d", status, idx - 1);
|
||||
@@ -469,7 +470,7 @@ void JsObjToLocatingRequiredDataConfig(const napi_env& env, const napi_value& ob
|
||||
if (arfcnInfoValue != nullptr) {
|
||||
std::shared_ptr<ArfcnInfo> arfcnInfo = std::make_shared<ArfcnInfo>();
|
||||
if (JsObjectToInt(env, arfcnInfoValue, "arfcnCount", valueInt) == SUCCESS) {
|
||||
arfcnInfo->SetArfcnCount(valueInt);;
|
||||
arfcnInfo->SetArfcnCount(valueInt);
|
||||
}
|
||||
if (GetIntArrayFromJsObj(env, arfcnInfoValue, "arfcnArray", vector)) {
|
||||
arfcnInfo->SetArfcnArray(vector);
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
mcc_ = 0;
|
||||
mnc_ = 0;
|
||||
rat_ = 0;
|
||||
singalIntensity_ = 0;
|
||||
signalIntensity_ = 0;
|
||||
arfcn_ = 0;
|
||||
pci_ = 0;
|
||||
additionsMap_ = std::make_shared<std::map<std::string, std::string>>();
|
||||
@@ -43,11 +43,11 @@ public:
|
||||
SetSlotId(cellularInfo.GetSlotId());
|
||||
SetTimeSinceBoot(cellularInfo.GetTimeSinceBoot());
|
||||
SetCellId(cellularInfo.GetCellId());
|
||||
SetLat(cellularInfo.GetLat());
|
||||
SetLac(cellularInfo.GetLac());
|
||||
SetMcc(cellularInfo.GetMcc());
|
||||
SetMnc(cellularInfo.GetMnc());
|
||||
SetRat(cellularInfo.GetRat());
|
||||
SetSingnalIntensity(cellularInfo.GetSingnalIntensity());
|
||||
SetSignalIntensity(cellularInfo.GetSignalIntensity());
|
||||
SetArfcn(cellularInfo.GetArfcn());
|
||||
SetPci(cellularInfo.GetPci());
|
||||
SetAdditionsMap(cellularInfo.GetAdditionsMap());
|
||||
@@ -85,12 +85,12 @@ public:
|
||||
return cellId_;
|
||||
}
|
||||
|
||||
inline void SetLat(int32_t lac)
|
||||
inline void SetLac(int32_t lac)
|
||||
{
|
||||
lac_ = lac;
|
||||
}
|
||||
|
||||
inline int32_t GetLat()
|
||||
inline int32_t GetLac()
|
||||
{
|
||||
return lac_;
|
||||
}
|
||||
@@ -125,14 +125,14 @@ public:
|
||||
return rat_;
|
||||
}
|
||||
|
||||
inline void SetSingnalIntensity(int32_t singalIntensity)
|
||||
inline void SetSignalIntensity(int32_t signalIntensity)
|
||||
{
|
||||
singalIntensity_ = singalIntensity;
|
||||
signalIntensity_ = signalIntensity;
|
||||
}
|
||||
|
||||
inline int32_t GetSingnalIntensity()
|
||||
inline int32_t GetSignalIntensity()
|
||||
{
|
||||
return singalIntensity_;
|
||||
return signalIntensity_;
|
||||
}
|
||||
|
||||
inline void SetArfcn(int32_t arfcn)
|
||||
@@ -174,14 +174,19 @@ public:
|
||||
mcc_ = parcel.ReadInt32();
|
||||
mnc_ = parcel.ReadInt32();
|
||||
rat_ = parcel.ReadInt32();
|
||||
singalIntensity_ = parcel.ReadInt32();
|
||||
signalIntensity_ = parcel.ReadInt32();
|
||||
arfcn_ = parcel.ReadInt32();
|
||||
pci_ = parcel.ReadInt32();
|
||||
size_t size = parcel.ReadUint32();
|
||||
size = size > MAXIMUM_LOCATING_REQUIRED_DATAS ? : MAXIMUM_LOCATING_REQUIRED_DATAS : size;
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
std::string key, value;
|
||||
std::string key;
|
||||
std::string value;
|
||||
key = parcel.ReadString();
|
||||
value = parcel.ReadString();
|
||||
if (additionsMap_ == nullptr) {
|
||||
additionsMap_ = std::make_shared<std::map<std::string, std::string>>();
|
||||
}
|
||||
(*additionsMap_)[key] = value;
|
||||
}
|
||||
}
|
||||
@@ -195,13 +200,14 @@ public:
|
||||
parcel.WriteInt32(mcc_);
|
||||
parcel.WriteInt32(mnc_);
|
||||
parcel.WriteInt32(rat_);
|
||||
parcel.WriteInt32(singalIntensity_);
|
||||
parcel.WriteInt32(signalIntensity_);
|
||||
parcel.WriteInt32(arfcn_);
|
||||
parcel.WriteInt32(pci_);
|
||||
if (additionsMap_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
size_t size = additionsMap_->size();
|
||||
size = size > MAXIMUM_LOCATING_REQUIRED_DATAS ? : MAXIMUM_LOCATING_REQUIRED_DATAS : size;
|
||||
if (!parcel.WriteUint32(size)) {
|
||||
return false;
|
||||
}
|
||||
@@ -227,7 +233,7 @@ private:
|
||||
int32_t mcc_;
|
||||
int32_t mnc_;
|
||||
int32_t rat_;
|
||||
int32_t singalIntensity_;
|
||||
int32_t signalIntensity_;
|
||||
int32_t arfcn_;
|
||||
int32_t pci_;
|
||||
std::shared_ptr<std::map<std::string, std::string>> additionsMap_;
|
||||
|
||||
@@ -30,13 +30,6 @@ public:
|
||||
plmnParamArray_ = {};
|
||||
}
|
||||
|
||||
explicit ArfcnInfo(ArfcnInfo& arfcnInfo)
|
||||
{
|
||||
SetArfcnCount(arfcnInfo.GetArfcnCount());
|
||||
SetArfcnArray(arfcnInfo.GetArfcnArray());
|
||||
SetPlmnParamArray(arfcnInfo.GetPlmnParamArray());
|
||||
}
|
||||
|
||||
~ArfcnInfo() override = default;
|
||||
|
||||
inline void SetArfcnCount(int32_t arfcnCount)
|
||||
@@ -196,7 +189,7 @@ public:
|
||||
return slotIdArray_;
|
||||
}
|
||||
|
||||
inline void SetSlotIdArray(std::vector<int32_t> slotIdArray)
|
||||
inline void SetSlotIdArray(const std::vector<int32_t>& slotIdArray)
|
||||
{
|
||||
slotIdArray_ = slotIdArray;
|
||||
}
|
||||
|
||||
@@ -192,8 +192,8 @@ __attribute__((no_sanitize("cfi"))) LocationErrCode LocatorRequiredDataManager::
|
||||
} else if (config->GetType() == LocatingRequiredDataType::BLUE_TOOTH) {
|
||||
return LOCATION_ERRCODE_NOT_SUPPORTED;
|
||||
} else if (config->GetType() == LocatingRequiredDataType::CELLULAR) {
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
LocatorRequiredInfo locatorRequiredInfo;
|
||||
locatorRequiredInfo.appIdentity_ = identity;
|
||||
locatorRequiredInfo.config_ = *config;
|
||||
|
||||
Reference in New Issue
Block a user