Create measurement corrections 1.1 with eBearing

Test: matest VtsHalGnssV2_1TargetTesti and manually injected
dummy measurement corrections in GnssLocationProvider and
verified that cuttlefish implementation properly recieved
them below the HAL
Bug: 145963440
Change-Id: Ib5eb4f8c759c91b9fa2217ce6658319edd11bb27
This commit is contained in:
Sasha Kuznetsov 2020-01-03 13:06:38 -08:00
parent c9464216ec
commit 31eea85faf
20 changed files with 279 additions and 14 deletions

View file

@ -639,11 +639,13 @@ f18695dd36ee205640b8326a17453858a7b4596653aaa6ef0016b0aef1bd4dac android.hardwar
881aa8720fb1d69aa9843bfab69d810ab7654a61d2f5ab5e2626cbf240f24eaf android.hardware.dumpstate@1.1::types
13b33f623521ded51a6c0f7ea5b77e97066d0aa1e38a83c2873f08ad67294f89 android.hardware.dumpstate@1.1::IDumpstateDevice
769d346927a94fd40ee80a5a976d8d15cf022ef99c5900738f4a82f26c0ed229 android.hardware.gnss@2.1::types
3dacec7801968e1e4479724dc0180442d9e915466bff051f80996266b1a51c2c android.hardware.gnss@2.1::IGnss
88371e0edf69a1f72bfc45ecb2335e9b145e87339d3eecc92664a1fb200213ba android.hardware.gnss@2.1::IGnss
ba62e1e8993bfb9f27fa04816fa0f2241ae2d01edfa3d0c04182e2e5de80045c android.hardware.gnss@2.1::IGnssCallback
ccdf3c0fb2c02a6d4dc57afb276c3497ae8172b80b00ebc0bf8a0238dd38b01d android.hardware.gnss@2.1::IGnssConfiguration
5a125c49ca83629e22afc8c39e865509343bfa2c38f0baea9a186bbac103492d android.hardware.gnss@2.1::IGnssMeasurement
d7bf37660a0946de9599dcbae997b077ee3e604fc2044534d40d3da04297a5d3 android.hardware.gnss@2.1::IGnssMeasurementCallback
6670e7780803a8c696c6391fda5589a334b1b37dc7be9393792ed35035413633 android.hardware.gnss.measurement_corrections@1.1::IMeasurementCorrections
a3f439b782a6a92aaf3c0250f3526e94e8bf8844c3d578f0815e21b12c431346 android.hardware.gnss.measurement_corrections@1.1::types
ce8dbe76eb9ee94b46ef98f725be992e760a5751073d4f4912484026541371f3 android.hardware.health@2.1::IHealth
26f04510a0b57aba5167c5c0a7c2f077c2acbb98b81902a072517829fd9fd67f android.hardware.health@2.1::IHealthInfoCallback
db47f4ceceb1f06c656f39caa70c557b0f8471ef59fd58611bea667ffca20101 android.hardware.health@2.1::types

View file

@ -29,6 +29,10 @@ cc_test {
],
shared_libs: [
"android.hardware.gnss.measurement_corrections@1.0",
"android.hardware.gnss.measurement_corrections@1.1",
],
test_suites: [
"general-tests",
"vts-core",
],
test_suites: ["general-tests", "vts-core"],
}

View file

@ -296,6 +296,12 @@ TEST_P(GnssHalTest, TestGnssVisibilityControlExtension) {
* capability flag is set.
*/
TEST_P(GnssHalTest, TestGnssMeasurementCorrectionsCapabilities) {
if (!IsGnssHalVersion_2_0()) {
ALOGI("Test GnssMeasurementCorrectionsCapabilities skipped. GNSS HAL version is greater "
"than 2.0.");
return;
}
if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENT_CORRECTIONS)) {
return;
}

View file

@ -15,6 +15,7 @@ hidl_interface {
"IGnssConfiguration.hal",
],
interfaces: [
"android.hardware.gnss.measurement_corrections@1.1",
"android.hardware.gnss.measurement_corrections@1.0",
"android.hardware.gnss.visibility_control@1.0",
"android.hardware.gnss@1.0",

View file

@ -16,6 +16,7 @@
package android.hardware.gnss@2.1;
import android.hardware.gnss.measurement_corrections@1.1::IMeasurementCorrections;
import @2.0::IGnss;
import IGnssCallback;
@ -62,4 +63,14 @@ interface IGnss extends @2.0::IGnss {
* @return gnssConfigurationIface Handle to the IGnssConfiguration interface.
*/
getExtensionGnssConfiguration_2_1() generates (IGnssConfiguration gnssConfigurationIface);
/**
* This method returns the IMeasurementCorrections interface.
*
* Both getExtensionMeasurementCorrections and getExtensionMeasurementCorrections_1_1 must
* return non-null. Both methods can return the same V1.1 IMeasurementCorrections object.
*
* @return measurementCorrectionsIface Handle to the IMeasurementCorrections interface.
*/
getExtensionMeasurementCorrections_1_1() generates (IMeasurementCorrections measurementCorrectionsIface);
};

View file

@ -32,6 +32,7 @@ cc_binary {
"libhidlbase",
"libutils",
"liblog",
"android.hardware.gnss.measurement_corrections@1.1",
"android.hardware.gnss.measurement_corrections@1.0",
"android.hardware.gnss.visibility_control@1.0",
"android.hardware.gnss@2.1",

View file

@ -25,7 +25,7 @@
#include <log/log.h>
using ::android::hardware::gnss::common::Utils;
using ::android::hardware::gnss::measurement_corrections::V1_0::implementation::
using ::android::hardware::gnss::measurement_corrections::V1_1::implementation::
GnssMeasurementCorrections;
namespace android {
@ -368,6 +368,12 @@ Return<sp<V2_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_2_1() {
return mGnssConfiguration;
}
Return<sp<measurement_corrections::V1_1::IMeasurementCorrections>>
Gnss::getExtensionMeasurementCorrections_1_1() {
ALOGD("Gnss::getExtensionMeasurementCorrections_1_1()");
return new GnssMeasurementCorrections();
}
void Gnss::reportSvStatus(const hidl_vec<GnssSvInfo>& svInfoList) const {
std::unique_lock<std::mutex> lock(mMutex);
// TODO(skz): update this to call 2_0 callback if non-null

View file

@ -89,6 +89,8 @@ struct Gnss : public IGnss {
Return<bool> setCallback_2_1(const sp<V2_1::IGnssCallback>& callback) override;
Return<sp<V2_1::IGnssMeasurement>> getExtensionGnssMeasurement_2_1() override;
Return<sp<V2_1::IGnssConfiguration>> getExtensionGnssConfiguration_2_1() override;
Return<sp<measurement_corrections::V1_1::IMeasurementCorrections>>
getExtensionMeasurementCorrections_1_1() override;
private:
void reportLocation(const V2_0::GnssLocation&) const;

View file

@ -23,11 +23,12 @@ namespace android {
namespace hardware {
namespace gnss {
namespace measurement_corrections {
namespace V1_0 {
namespace V1_1 {
namespace implementation {
// Methods from V1_0::IMeasurementCorrections follow.
Return<bool> GnssMeasurementCorrections::setCorrections(const MeasurementCorrections& corrections) {
Return<bool> GnssMeasurementCorrections::setCorrections(
const V1_0::MeasurementCorrections& corrections) {
ALOGD("setCorrections");
ALOGD("corrections = lat: %f, lng: %f, alt: %f, hUnc: %f, vUnc: %f, toa: %llu, "
"satCorrections.size: %d",
@ -67,8 +68,40 @@ Return<bool> GnssMeasurementCorrections::setCallback(
return true;
}
// Methods from V1_1::IMeasurementCorrections follow.
Return<bool> GnssMeasurementCorrections::setCorrections_1_1(
const V1_1::MeasurementCorrections& corrections) {
ALOGD("setCorrections_1_1");
ALOGD("corrections = lat: %f, lng: %f, alt: %f, hUnc: %f, vUnc: %f, toa: %llu,"
"satCorrections.size: %d, hasEnvironmentBearing: %d, environmentBearingDeg: %f,"
"environmentBearingUncDeg: %f",
corrections.v1_0.latitudeDegrees, corrections.v1_0.longitudeDegrees,
corrections.v1_0.altitudeMeters, corrections.v1_0.horizontalPositionUncertaintyMeters,
corrections.v1_0.verticalPositionUncertaintyMeters,
static_cast<unsigned long long>(corrections.v1_0.toaGpsNanosecondsOfWeek),
static_cast<int>(corrections.v1_0.satCorrections.size()),
corrections.hasEnvironmentBearing, corrections.environmentBearingDegrees,
corrections.environmentBearingUncertaintyDegrees);
for (auto singleSatCorrection : corrections.v1_0.satCorrections) {
ALOGD("singleSatCorrection = flags: %d, constellation: %d, svid: %d, cfHz: %f, probLos: %f,"
" epl: %f, eplUnc: %f",
static_cast<int>(singleSatCorrection.singleSatCorrectionFlags),
static_cast<int>(singleSatCorrection.constellation),
static_cast<int>(singleSatCorrection.svid), singleSatCorrection.carrierFrequencyHz,
singleSatCorrection.probSatIsLos, singleSatCorrection.excessPathLengthMeters,
singleSatCorrection.excessPathLengthUncertaintyMeters);
ALOGD("reflecting plane = lat: %f, lng: %f, alt: %f, azm: %f",
singleSatCorrection.reflectingPlane.latitudeDegrees,
singleSatCorrection.reflectingPlane.longitudeDegrees,
singleSatCorrection.reflectingPlane.altitudeMeters,
singleSatCorrection.reflectingPlane.azimuthDegrees);
}
return true;
}
} // namespace implementation
} // namespace V1_0
} // namespace V1_1
} // namespace measurement_corrections
} // namespace gnss
} // namespace hardware

View file

@ -16,7 +16,7 @@
#pragma once
#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrections.h>
#include <android/hardware/gnss/measurement_corrections/1.1/IMeasurementCorrections.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
@ -24,7 +24,7 @@ namespace android {
namespace hardware {
namespace gnss {
namespace measurement_corrections {
namespace V1_0 {
namespace V1_1 {
namespace implementation {
using ::android::sp;
@ -37,12 +37,15 @@ using ::android::hardware::Void;
struct GnssMeasurementCorrections : public IMeasurementCorrections {
// Methods from V1_0::IMeasurementCorrections follow.
Return<bool> setCorrections(const MeasurementCorrections& corrections) override;
Return<bool> setCorrections(const V1_0::MeasurementCorrections& corrections) override;
Return<bool> setCallback(const sp<V1_0::IMeasurementCorrectionsCallback>& callback) override;
// Methods from V1_1::IMeasurementCorrections follow.
Return<bool> setCorrections_1_1(const V1_1::MeasurementCorrections& corrections) override;
};
} // namespace implementation
} // namespace V1_0
} // namespace V1_1
} // namespace measurement_corrections
} // namespace gnss
} // namespace hardware

View file

@ -24,6 +24,7 @@ cc_test {
],
static_libs: [
"android.hardware.gnss.measurement_corrections@1.0",
"android.hardware.gnss.measurement_corrections@1.1",
"android.hardware.gnss.visibility_control@1.0",
"android.hardware.gnss@1.0",
"android.hardware.gnss@1.1",
@ -31,5 +32,8 @@ cc_test {
"android.hardware.gnss@2.1",
"android.hardware.gnss@common-vts-lib",
],
test_suites: ["general-tests", "vts-core"],
test_suites: [
"general-tests",
"vts-core",
],
}

View file

@ -256,3 +256,10 @@ Return<void> GnssHalTest::GnssMeasurementCallback::gnssMeasurementCb_2_1(
measurement_cbq_.store(data);
return Void();
}
Return<void> GnssHalTest::GnssMeasurementCorrectionsCallback::setCapabilitiesCb(
uint32_t capabilities) {
ALOGI("GnssMeasurementCorrectionsCallback capabilities received %d", capabilities);
capabilities_cbq_.store(capabilities);
return Void();
}

View file

@ -27,6 +27,7 @@ using android::hardware::Return;
using android::hardware::Void;
using android::hardware::gnss::common::GnssCallbackEventQueue;
using android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrectionsCallback;
using android::hardware::gnss::V1_0::GnssLocationFlags;
using android::hardware::gnss::V2_0::GnssConstellationType;
using android::hardware::gnss::V2_1::IGnss;
@ -138,6 +139,19 @@ class GnssHalTest : public testing::TestWithParam<std::string> {
Return<void> gnssMeasurementCb_2_1(const IGnssMeasurementCallback_2_1::GnssData&) override;
};
/* Callback class for GnssMeasurementCorrections. */
class GnssMeasurementCorrectionsCallback : public IMeasurementCorrectionsCallback {
public:
uint32_t last_capabilities_;
GnssCallbackEventQueue<uint32_t> capabilities_cbq_;
GnssMeasurementCorrectionsCallback() : capabilities_cbq_("capabilities"){};
virtual ~GnssMeasurementCorrectionsCallback() = default;
// Methods from V1_0::IMeasurementCorrectionsCallback follow.
Return<void> setCapabilitiesCb(uint32_t capabilities) override;
};
/*
* SetUpGnssCallback:
* Set GnssCallback and verify the result.

View file

@ -41,6 +41,8 @@ using android::hardware::gnss::V2_0::GnssConstellationType;
using android::hardware::gnss::V2_1::IGnssConfiguration;
using GnssMeasurementFlags = IGnssMeasurementCallback_2_1::GnssMeasurementFlags;
using IMeasurementCorrections_1_1 =
android::hardware::gnss::measurement_corrections::V1_1::IMeasurementCorrections;
/*
* SetupTeardownCreateCleanup:
@ -562,3 +564,35 @@ TEST_P(GnssHalTest, BlacklistConstellationLocationOn) {
ASSERT_TRUE(result.isOk());
EXPECT_TRUE(result);
}
/*
* TestGnssMeasurementCorrections:
* If measurement corrections capability is supported, verifies that it supports the
* gnss.measurement_corrections@1.1::IMeasurementCorrections interface by invoking a method.
*/
TEST_P(GnssHalTest, TestGnssMeasurementCorrections) {
if (!(gnss_cb_->last_capabilities_ &
IGnssCallback_2_1::Capabilities::MEASUREMENT_CORRECTIONS)) {
return;
}
// Verify IMeasurementCorrections is supported.
auto measurementCorrections = gnss_hal_->getExtensionMeasurementCorrections_1_1();
ASSERT_TRUE(measurementCorrections.isOk());
sp<IMeasurementCorrections_1_1> iMeasurementCorrections = measurementCorrections;
ASSERT_NE(iMeasurementCorrections, nullptr);
sp<GnssMeasurementCorrectionsCallback> callback = new GnssMeasurementCorrectionsCallback();
iMeasurementCorrections->setCallback(callback);
const int kMeasurementCorrectionsCapabilitiesTimeoutSeconds = 5;
callback->capabilities_cbq_.retrieve(callback->last_capabilities_,
kMeasurementCorrectionsCapabilitiesTimeoutSeconds);
ASSERT_TRUE(callback->capabilities_cbq_.calledCount() > 0);
// Set a mock MeasurementCorrections.
auto result =
iMeasurementCorrections->setCorrections_1_1(Utils::getMockMeasurementCorrections_1_1());
ASSERT_TRUE(result.isOk());
EXPECT_TRUE(result);
}

View file

@ -30,6 +30,7 @@ cc_library_static {
shared_libs: [
"android.hardware.gnss@1.0",
"android.hardware.gnss.measurement_corrections@1.0",
"android.hardware.gnss.measurement_corrections@1.1",
],
static_libs: [
"libgtest",

View file

@ -92,7 +92,7 @@ void Utils::checkLocation(const GnssLocation& location, bool check_speed,
EXPECT_GT(location.timestamp, 1.48e12);
}
const MeasurementCorrections Utils::getMockMeasurementCorrections() {
const MeasurementCorrections_1_0 Utils::getMockMeasurementCorrections() {
ReflectingPlane reflectingPlane = {
.latitudeDegrees = 37.4220039,
.longitudeDegrees = -122.0840991,
@ -127,7 +127,7 @@ const MeasurementCorrections Utils::getMockMeasurementCorrections() {
hidl_vec<SingleSatCorrection> singleSatCorrections = {singleSatCorrection1,
singleSatCorrection2};
MeasurementCorrections mockCorrections = {
MeasurementCorrections_1_0 mockCorrections = {
.latitudeDegrees = 37.4219999,
.longitudeDegrees = -122.0840575,
.altitudeMeters = 30.60062531,
@ -139,6 +139,18 @@ const MeasurementCorrections Utils::getMockMeasurementCorrections() {
return mockCorrections;
}
const MeasurementCorrections_1_1 Utils::getMockMeasurementCorrections_1_1() {
MeasurementCorrections_1_0 mockCorrections_1_0 = getMockMeasurementCorrections();
MeasurementCorrections_1_1 mockCorrections_1_1 = {
.v1_0 = mockCorrections_1_0,
.hasEnvironmentBearing = true,
.environmentBearingDegrees = 45.0,
.environmentBearingUncertaintyDegrees = 4.0,
};
return mockCorrections_1_1;
}
} // namespace common
} // namespace gnss
} // namespace hardware

View file

@ -19,10 +19,16 @@
#include <android/hardware/gnss/1.0/IGnss.h>
#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrections.h>
#include <android/hardware/gnss/measurement_corrections/1.1/IMeasurementCorrections.h>
using GnssLocation = ::android::hardware::gnss::V1_0::GnssLocation;
using namespace android::hardware::gnss::measurement_corrections::V1_0;
using MeasurementCorrections_1_0 =
android::hardware::gnss::measurement_corrections::V1_0::MeasurementCorrections;
using MeasurementCorrections_1_1 =
android::hardware::gnss::measurement_corrections::V1_1::MeasurementCorrections;
namespace android {
namespace hardware {
namespace gnss {
@ -31,7 +37,8 @@ namespace common {
struct Utils {
static void checkLocation(const GnssLocation& location, bool check_speed,
bool check_more_accuracies);
static const MeasurementCorrections getMockMeasurementCorrections();
static const MeasurementCorrections_1_0 getMockMeasurementCorrections();
static const MeasurementCorrections_1_1 getMockMeasurementCorrections_1_1();
};
} // namespace common

View file

@ -0,0 +1,19 @@
// This file is autogenerated by hidl-gen -Landroidbp.
hidl_interface {
name: "android.hardware.gnss.measurement_corrections@1.1",
root: "android.hardware",
vndk: {
enabled: true,
},
srcs: [
"types.hal",
"IMeasurementCorrections.hal",
],
interfaces: [
"android.hardware.gnss.measurement_corrections@1.0",
"android.hardware.gnss@1.0",
"android.hidl.base@1.0",
],
gen_java: true,
}

View file

@ -0,0 +1,40 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.gnss.measurement_corrections@1.1;
import @1.0::IMeasurementCorrections;
/**
* Interface for measurement corrections support.
*/
interface IMeasurementCorrections extends @1.0::IMeasurementCorrections {
/**
* Injects measurement corrections to be used by the HAL to improve the GNSS location output.
*
* These are NOT to be used to adjust the IGnssMeasurementCallback output values -
* those remain raw, uncorrected measurements.
*
* In general, these are injected when conditions defined by the platform are met, such as when
* GNSS Location is being requested at a sufficiently high accuracy, based on the capabilities
* of the GNSS chipset as reported in the IGnssCallback.
*
* @param corrections The computed corrections to be used by the HAL.
*
* @return success Whether the HAL can accept & use these corrections.
*/
setCorrections_1_1(MeasurementCorrections corrections) generates (bool success);
};

View file

@ -0,0 +1,58 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.gnss.measurement_corrections@1.1;
import @1.0::MeasurementCorrections;
/**
* A struct containing a set of measurement corrections for all used GNSS satellites at the location
* specified by latitudeDegrees, longitudeDegrees, altitudeMeters and at the time of week specified
* toaGpsNanosecondsOfWeek
*/
struct MeasurementCorrections {
@1.0::MeasurementCorrections v1_0;
/**
* Boolean indicating if environment bearing is available.
*/
bool hasEnvironmentBearing;
/**
* Environment bearing in degrees clockwise from true North (0.0 to 360.0], in direction of
* user motion. Environment bearing is provided when it is known with high probability that
* velocity is aligned with an environment feature, such as a building or road.
*
* If user speed is zero, environmentBearingDegrees represents bearing of most recent speed
* that was > 0.
*
* As position approaches another road, environmentBearingUncertaintyDegrees will grow, and at
* some stage hasEnvironmentBearing = false.
*
* As position moves towards an open area, environmentBearingUncertaintyDegrees will grow, and
* at some stage hasEnvironmentBearing = false.
*
* If the road is curved in the vicinity of the user location, then
* environmentBearingUncertaintyDegrees will include the amount by which the road direction
* changes in the area of position uncertainty.
*/
float environmentBearingDegrees;
/**
* Bearing uncertainty [0 to 180].
*/
float environmentBearingUncertaintyDegrees;
};