Merge pull request !982 from liuxinbing/master
This commit is contained in:
openharmony_ci 2024-11-13 01:39:25 +00:00 committed by Gitee
commit f6368195c9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 41 additions and 0 deletions

View File

@ -54,6 +54,10 @@ void SatelliteStatus::ReadFromParcel(Parcel& parcel)
bool SatelliteStatus::Marshalling(Parcel& parcel) const
{
bool isValid = IsValidityDatas();
if (!isValid) {
return false;
}
CHK_PARCEL_RETURN_VALUE(parcel.WriteInt64(satellitesNumber_));
for (int i = 0; i < satellitesNumber_; i++) {
CHK_PARCEL_RETURN_VALUE(parcel.WriteInt64(satelliteIds_[i]));
@ -67,6 +71,39 @@ bool SatelliteStatus::Marshalling(Parcel& parcel) const
return true;
}
bool SatelliteStatus::IsValidityDatas() const
{
if (satellitesNumber_ != satelliteIds_.size()) {
LBSLOGE(GNSS, "%{public}s: satelliteIds data length is incorrect.", __func__);
return false;
}
if (satellitesNumber_ != carrierToNoiseDensitys_.size()) {
LBSLOGE(GNSS, "%{public}s: carrierToNoiseDensitys data length is incorrect.", __func__);
return false;
}
if (satellitesNumber_ != altitudes_.size()) {
LBSLOGE(GNSS, "%{public}s: altitudes data length is incorrect.", __func__);
return false;
}
if (satellitesNumber_ != azimuths_.size()) {
LBSLOGE(GNSS, "%{public}s: azimuths data length is incorrect.", __func__);
return false;
}
if (satellitesNumber_ != carrierFrequencies_.size()) {
LBSLOGE(GNSS, "%{public}s: carrierFrequencies data length is incorrect.", __func__);
return false;
}
if (satellitesNumber_ != constellationTypes_.size()) {
LBSLOGE(GNSS, "%{public}s: constellationTypes data length is incorrect.", __func__);
return false;
}
if (satellitesNumber_ != additionalInfoList_.size()) {
LBSLOGE(GNSS, "%{public}s: additionalInfoList data length is incorrect.", __func__);
return false;
}
return true;
}
std::unique_ptr<SatelliteStatus> SatelliteStatus::Unmarshalling(Parcel& parcel)
{
std::unique_ptr<SatelliteStatus> status = std::make_unique<SatelliteStatus>();

View File

@ -177,6 +177,8 @@ public:
bool Marshalling(Parcel& parcel) const override;
static std::unique_ptr<SatelliteStatus> Unmarshalling(Parcel& parcel);
private:
bool IsValidityDatas() const;
int satellitesNumber_;
std::vector<int> satelliteIds_;
std::vector<double> carrierToNoiseDensitys_;

View File

@ -37,6 +37,7 @@ const int MAX_SV_COUNT = 64;
const int GPS_DUMMY_SV_COUNT = 5;
const int AZIMUTH_DEGREES = 60;
const int ELEVATION_DEGREES = 90;
const int SATELLITES_ADDITIONAL = 4;
bool g_hasLocation = false;
bool g_svIncrease = false;
std::unique_ptr<SatelliteStatus> g_svInfo = nullptr;
@ -244,6 +245,7 @@ void GnssEventCallback::AddDummySv(std::unique_ptr<SatelliteStatus> &sv, int svi
sv->SetAltitude(ELEVATION_DEGREES); // elevationDegrees
sv->SetAzimuth(AZIMUTH_DEGREES); // azimuthDegrees
sv->SetCarrierFrequencie(0); // carrierFrequencyHz
sv->SetSatelliteAdditionalInfo(SATELLITES_ADDITIONAL); // satellites_additional
}
int32_t GnssEventCallback::RequestGnssReferenceInfo(GnssRefInfoType type)