Merge "Report GnssStatusValue when GNSS start/stop" into sc-dev am: 63133733c1
am: a8eac41967
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/15342527 Change-Id: I57cafeddd72b41bb3b298de4d1bc3f228f2340b4
This commit is contained in:
commit
d695c465cd
5 changed files with 58 additions and 26 deletions
|
@ -1,9 +1,9 @@
|
|||
#define LOG_TAG "Gnss"
|
||||
|
||||
#include "Gnss.h"
|
||||
#include <android/hardware/gnss/1.0/types.h>
|
||||
#include <log/log.h>
|
||||
|
||||
#include "Gnss.h"
|
||||
#include "Constants.h"
|
||||
#include "GnssDebug.h"
|
||||
#include "GnssMeasurement.h"
|
||||
#include "Utils.h"
|
||||
|
@ -16,6 +16,7 @@ namespace implementation {
|
|||
|
||||
using ::android::hardware::gnss::common::Utils;
|
||||
using GnssSvFlags = IGnssCallback::GnssSvFlags;
|
||||
using namespace ::android::hardware::gnss::common;
|
||||
|
||||
const uint32_t MIN_INTERVAL_MILLIS = 100;
|
||||
sp<::android::hardware::gnss::V1_1::IGnssCallback> Gnss::sGnssCallback = nullptr;
|
||||
|
@ -197,14 +198,21 @@ Return<bool> Gnss::injectBestLocation(const GnssLocation&) {
|
|||
Return<GnssSvStatus> Gnss::getMockSvStatus() const {
|
||||
std::unique_lock<std::recursive_mutex> lock(mGnssConfiguration->getMutex());
|
||||
GnssSvInfo mockGnssSvInfoList[] = {
|
||||
Utils::getMockSvInfoV1_0(3, GnssConstellationType::GPS, 32.5, 59.1, 166.5),
|
||||
Utils::getMockSvInfoV1_0(5, GnssConstellationType::GPS, 27.0, 29.0, 56.5),
|
||||
Utils::getMockSvInfoV1_0(17, GnssConstellationType::GPS, 30.5, 71.0, 77.0),
|
||||
Utils::getMockSvInfoV1_0(26, GnssConstellationType::GPS, 24.1, 28.0, 253.0),
|
||||
Utils::getMockSvInfoV1_0(5, GnssConstellationType::GLONASS, 20.5, 11.5, 116.0),
|
||||
Utils::getMockSvInfoV1_0(17, GnssConstellationType::GLONASS, 21.5, 28.5, 186.0),
|
||||
Utils::getMockSvInfoV1_0(18, GnssConstellationType::GLONASS, 28.3, 38.8, 69.0),
|
||||
Utils::getMockSvInfoV1_0(10, GnssConstellationType::GLONASS, 25.0, 66.0, 247.0)};
|
||||
Utils::getMockSvInfoV1_0(3, GnssConstellationType::GPS, 32.5, 59.1, 166.5,
|
||||
kGpsL1FreqHz),
|
||||
Utils::getMockSvInfoV1_0(5, GnssConstellationType::GPS, 27.0, 29.0, 56.5, kGpsL1FreqHz),
|
||||
Utils::getMockSvInfoV1_0(17, GnssConstellationType::GPS, 30.5, 71.0, 77.0,
|
||||
kGpsL5FreqHz),
|
||||
Utils::getMockSvInfoV1_0(26, GnssConstellationType::GPS, 24.1, 28.0, 253.0,
|
||||
kGpsL5FreqHz),
|
||||
Utils::getMockSvInfoV1_0(5, GnssConstellationType::GLONASS, 20.5, 11.5, 116.0,
|
||||
kGloG1FreqHz),
|
||||
Utils::getMockSvInfoV1_0(17, GnssConstellationType::GLONASS, 21.5, 28.5, 186.0,
|
||||
kGloG1FreqHz),
|
||||
Utils::getMockSvInfoV1_0(18, GnssConstellationType::GLONASS, 28.3, 38.8, 69.0,
|
||||
kGloG1FreqHz),
|
||||
Utils::getMockSvInfoV1_0(10, GnssConstellationType::GLONASS, 25.0, 66.0, 247.0,
|
||||
kGloG1FreqHz)};
|
||||
|
||||
GnssSvStatus svStatus = {.numSvs = sizeof(mockGnssSvInfoList) / sizeof(GnssSvInfo)};
|
||||
for (uint32_t i = 0; i < svStatus.numSvs; i++) {
|
||||
|
|
|
@ -265,50 +265,50 @@ V1_0::GnssLocation Utils::getMockLocationV1_0() {
|
|||
}
|
||||
|
||||
hidl_vec<GnssSvInfoV2_1> Utils::getMockSvInfoListV2_1() {
|
||||
GnssSvInfoV1_0 gnssSvInfoV1_0 =
|
||||
Utils::getMockSvInfoV1_0(3, V1_0::GnssConstellationType::GPS, 32.5, 59.1, 166.5);
|
||||
GnssSvInfoV1_0 gnssSvInfoV1_0 = Utils::getMockSvInfoV1_0(3, V1_0::GnssConstellationType::GPS,
|
||||
32.5, 59.1, 166.5, kGpsL1FreqHz);
|
||||
GnssSvInfoV2_0 gnssSvInfoV2_0 =
|
||||
Utils::getMockSvInfoV2_0(gnssSvInfoV1_0, V2_0::GnssConstellationType::GPS);
|
||||
hidl_vec<GnssSvInfoV2_1> gnssSvInfoList = {
|
||||
Utils::getMockSvInfoV2_1(gnssSvInfoV2_0, 27.5),
|
||||
getMockSvInfoV2_1(
|
||||
getMockSvInfoV2_0(getMockSvInfoV1_0(5, V1_0::GnssConstellationType::GPS, 27.0,
|
||||
29.0, 56.5),
|
||||
29.0, 56.5, kGpsL1FreqHz),
|
||||
V2_0::GnssConstellationType::GPS),
|
||||
22.0),
|
||||
getMockSvInfoV2_1(
|
||||
getMockSvInfoV2_0(getMockSvInfoV1_0(17, V1_0::GnssConstellationType::GPS, 30.5,
|
||||
71.0, 77.0),
|
||||
71.0, 77.0, kGpsL5FreqHz),
|
||||
V2_0::GnssConstellationType::GPS),
|
||||
25.5),
|
||||
getMockSvInfoV2_1(
|
||||
getMockSvInfoV2_0(getMockSvInfoV1_0(26, V1_0::GnssConstellationType::GPS, 24.1,
|
||||
28.0, 253.0),
|
||||
28.0, 253.0, kGpsL5FreqHz),
|
||||
V2_0::GnssConstellationType::GPS),
|
||||
19.1),
|
||||
getMockSvInfoV2_1(
|
||||
getMockSvInfoV2_0(getMockSvInfoV1_0(5, V1_0::GnssConstellationType::GLONASS,
|
||||
20.5, 11.5, 116.0),
|
||||
20.5, 11.5, 116.0, kGloG1FreqHz),
|
||||
V2_0::GnssConstellationType::GLONASS),
|
||||
15.5),
|
||||
getMockSvInfoV2_1(
|
||||
getMockSvInfoV2_0(getMockSvInfoV1_0(17, V1_0::GnssConstellationType::GLONASS,
|
||||
21.5, 28.5, 186.0),
|
||||
21.5, 28.5, 186.0, kGloG1FreqHz),
|
||||
V2_0::GnssConstellationType::GLONASS),
|
||||
16.5),
|
||||
getMockSvInfoV2_1(
|
||||
getMockSvInfoV2_0(getMockSvInfoV1_0(18, V1_0::GnssConstellationType::GLONASS,
|
||||
28.3, 38.8, 69.0),
|
||||
28.3, 38.8, 69.0, kGloG1FreqHz),
|
||||
V2_0::GnssConstellationType::GLONASS),
|
||||
25.3),
|
||||
getMockSvInfoV2_1(
|
||||
getMockSvInfoV2_0(getMockSvInfoV1_0(10, V1_0::GnssConstellationType::GLONASS,
|
||||
25.0, 66.0, 247.0),
|
||||
25.0, 66.0, 247.0, kGloG1FreqHz),
|
||||
V2_0::GnssConstellationType::GLONASS),
|
||||
20.0),
|
||||
getMockSvInfoV2_1(
|
||||
getMockSvInfoV2_0(getMockSvInfoV1_0(3, V1_0::GnssConstellationType::UNKNOWN,
|
||||
22.0, 35.0, 112.0),
|
||||
22.0, 35.0, 112.0, kIrnssL5FreqHz),
|
||||
V2_0::GnssConstellationType::IRNSS),
|
||||
19.7),
|
||||
};
|
||||
|
@ -333,21 +333,23 @@ GnssSvInfoV2_0 Utils::getMockSvInfoV2_0(GnssSvInfoV1_0 gnssSvInfoV1_0,
|
|||
}
|
||||
|
||||
GnssSvInfoV1_0 Utils::getMockSvInfoV1_0(int16_t svid, V1_0::GnssConstellationType type,
|
||||
float cN0DbHz, float elevationDegrees,
|
||||
float azimuthDegrees) {
|
||||
float cN0DbHz, float elevationDegrees, float azimuthDegrees,
|
||||
float carrierFrequencyHz) {
|
||||
GnssSvInfoV1_0 svInfo = {.svid = svid,
|
||||
.constellation = type,
|
||||
.cN0Dbhz = cN0DbHz,
|
||||
.elevationDegrees = elevationDegrees,
|
||||
.azimuthDegrees = azimuthDegrees,
|
||||
.carrierFrequencyHz = carrierFrequencyHz,
|
||||
.svFlag = GnssSvFlags::USED_IN_FIX | GnssSvFlags::HAS_EPHEMERIS_DATA |
|
||||
GnssSvFlags::HAS_ALMANAC_DATA};
|
||||
GnssSvFlags::HAS_ALMANAC_DATA |
|
||||
GnssSvFlags::HAS_CARRIER_FREQUENCY};
|
||||
return svInfo;
|
||||
}
|
||||
|
||||
hidl_vec<GnssAntennaInfo> Utils::getMockAntennaInfos() {
|
||||
GnssAntennaInfo mockAntennaInfo_1 = {
|
||||
.carrierFrequencyMHz = 123412.12,
|
||||
.carrierFrequencyMHz = kGpsL1FreqHz * 1e-6,
|
||||
.phaseCenterOffsetCoordinateMillimeters = Coord{.x = 1,
|
||||
.xUncertainty = 0.1,
|
||||
.y = 2,
|
||||
|
@ -381,7 +383,7 @@ hidl_vec<GnssAntennaInfo> Utils::getMockAntennaInfos() {
|
|||
};
|
||||
|
||||
GnssAntennaInfo mockAntennaInfo_2 = {
|
||||
.carrierFrequencyMHz = 532324.23,
|
||||
.carrierFrequencyMHz = kGpsL5FreqHz * 1e-6,
|
||||
.phaseCenterOffsetCoordinateMillimeters = Coord{.x = 5,
|
||||
.xUncertainty = 0.1,
|
||||
.y = 6,
|
||||
|
|
|
@ -29,6 +29,10 @@ const float kMockVerticalAccuracyMeters = 5;
|
|||
const float kMockSpeedAccuracyMetersPerSecond = 1;
|
||||
const float kMockBearingAccuracyDegrees = 90;
|
||||
const int64_t kMockTimestamp = 1519930775453L;
|
||||
const float kGpsL1FreqHz = 1575.42 * 1e6;
|
||||
const float kGpsL5FreqHz = 1176.45 * 1e6;
|
||||
const float kGloG1FreqHz = 1602.0 * 1e6;
|
||||
const float kIrnssL5FreqHz = 1176.45 * 1e6;
|
||||
|
||||
} // namespace common
|
||||
} // namespace gnss
|
||||
|
|
|
@ -44,7 +44,8 @@ struct Utils {
|
|||
static V1_0::IGnssCallback::GnssSvInfo getMockSvInfoV1_0(int16_t svid,
|
||||
V1_0::GnssConstellationType type,
|
||||
float cN0DbHz, float elevationDegrees,
|
||||
float azimuthDegrees);
|
||||
float azimuthDegrees,
|
||||
float carrierFrequencyHz);
|
||||
static hidl_vec<V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo> getMockAntennaInfos();
|
||||
};
|
||||
|
||||
|
|
|
@ -113,6 +113,7 @@ struct GnssTemplate : public T_IGnss {
|
|||
void reportLocation(const V2_0::GnssLocation&) const;
|
||||
void reportLocation(const V1_0::GnssLocation&) const;
|
||||
void reportSvStatus(const hidl_vec<V2_1::IGnssCallback::GnssSvInfo>&) const;
|
||||
void reportGnssStatusValue(const V1_0::IGnssCallback::GnssStatusValue) const;
|
||||
|
||||
Return<void> help(const hidl_handle& fd);
|
||||
Return<void> setLocation(const hidl_handle& fd, const hidl_vec<hidl_string>& options);
|
||||
|
@ -215,6 +216,7 @@ Return<bool> GnssTemplate<T_IGnss>::start() {
|
|||
}
|
||||
|
||||
mIsActive = true;
|
||||
this->reportGnssStatusValue(V1_0::IGnssCallback::GnssStatusValue::SESSION_BEGIN);
|
||||
mThread = std::thread([this]() {
|
||||
while (mIsActive == true) {
|
||||
auto svStatus = filterBlocklistedSatellitesV2_1(Utils::getMockSvInfoListV2_1());
|
||||
|
@ -266,6 +268,7 @@ template <class T_IGnss>
|
|||
Return<bool> GnssTemplate<T_IGnss>::stop() {
|
||||
ALOGD("stop");
|
||||
mIsActive = false;
|
||||
this->reportGnssStatusValue(V1_0::IGnssCallback::GnssStatusValue::SESSION_END);
|
||||
if (mThread.joinable()) {
|
||||
mThread.join();
|
||||
}
|
||||
|
@ -605,6 +608,20 @@ Return<sp<V2_1::IGnssAntennaInfo>> GnssTemplate<T_IGnss>::getExtensionGnssAntenn
|
|||
return new V2_1::implementation::GnssAntennaInfo();
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
void GnssTemplate<T_IGnss>::reportGnssStatusValue(
|
||||
const V1_0::IGnssCallback::GnssStatusValue gnssStatusValue) const {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
if (sGnssCallback_2_1 == nullptr) {
|
||||
ALOGE("%s: sGnssCallback v2.1 is null.", __func__);
|
||||
return;
|
||||
}
|
||||
auto ret = sGnssCallback_2_1->gnssStatusCb(gnssStatusValue);
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("%s: Unable to invoke callback", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
void GnssTemplate<T_IGnss>::reportSvStatus(
|
||||
const hidl_vec<V2_1::IGnssCallback::GnssSvInfo>& svInfoList) const {
|
||||
|
|
Loading…
Reference in a new issue