mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 05:49:27 +00:00
Add GNSS HAL v3.0 (hardware/interfaces)
Bug: 158518085
Test: atest VtsHalGnssV3_0TargetTest
atest VtsHalGnssV2_1TargetTest
atest VtsHalGnssV2_0TargetTest
atest VtsHalGnssV1_1TargetTest
atest VtsHalGnssV1_0TargetTest
Change-Id: Id4ac1e31207da7cfff3f1885c84748785bec19ba
This commit is contained in:
@@ -203,6 +203,7 @@
|
||||
<hal format="hidl" optional="true">
|
||||
<name>android.hardware.gnss</name>
|
||||
<version>2.0-1</version>
|
||||
<version>3.0</version>
|
||||
<interface>
|
||||
<name>IGnss</name>
|
||||
<instance>default</instance>
|
||||
|
||||
@@ -12,13 +12,13 @@ hidl_interface {
|
||||
"IGnssAntennaInfo.hal",
|
||||
"IGnssAntennaInfoCallback.hal",
|
||||
"IGnssCallback.hal",
|
||||
"IGnssConfiguration.hal",
|
||||
"IGnssMeasurement.hal",
|
||||
"IGnssMeasurementCallback.hal",
|
||||
"IGnssConfiguration.hal",
|
||||
],
|
||||
interfaces: [
|
||||
"android.hardware.gnss.measurement_corrections@1.1",
|
||||
"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",
|
||||
@@ -26,4 +26,5 @@ hidl_interface {
|
||||
"android.hidl.base@1.0",
|
||||
],
|
||||
gen_java: true,
|
||||
gen_java_constants: true,
|
||||
}
|
||||
|
||||
@@ -21,12 +21,6 @@ cc_binary {
|
||||
vendor: true,
|
||||
vintf_fragments: ["android.hardware.gnss@2.1-service.xml"],
|
||||
srcs: [
|
||||
"Gnss.cpp",
|
||||
"GnssAntennaInfo.cpp",
|
||||
"GnssDebug.cpp",
|
||||
"GnssMeasurement.cpp",
|
||||
"GnssMeasurementCorrections.cpp",
|
||||
"GnssConfiguration.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <android/hardware/gnss/2.1/IGnss.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include "GnssAntennaInfo.h"
|
||||
#include "GnssConfiguration.h"
|
||||
#include "NmeaFixInfo.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace gnss {
|
||||
namespace V2_1 {
|
||||
|
||||
using GnssSvInfo = IGnssCallback::GnssSvInfo;
|
||||
using ::android::hardware::gnss::common::NmeaFixInfo;
|
||||
|
||||
namespace implementation {
|
||||
|
||||
constexpr int INPUT_BUFFER_SIZE = 128;
|
||||
constexpr char CMD_GET_LOCATION[] = "CMD_GET_LOCATION";
|
||||
constexpr char GNSS_PATH[] = "/dev/gnss0";
|
||||
|
||||
struct Gnss : public IGnss {
|
||||
Gnss();
|
||||
~Gnss();
|
||||
// Methods from V1_0::IGnss follow.
|
||||
Return<bool> setCallback(const sp<V1_0::IGnssCallback>& callback) override;
|
||||
Return<bool> start() override;
|
||||
Return<bool> stop() override;
|
||||
Return<void> cleanup() override;
|
||||
Return<bool> injectTime(int64_t timeMs, int64_t timeReferenceMs,
|
||||
int32_t uncertaintyMs) override;
|
||||
Return<bool> injectLocation(double latitudeDegrees, double longitudeDegrees,
|
||||
float accuracyMeters) override;
|
||||
Return<void> deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) override;
|
||||
Return<bool> setPositionMode(V1_0::IGnss::GnssPositionMode mode,
|
||||
V1_0::IGnss::GnssPositionRecurrence recurrence,
|
||||
uint32_t minIntervalMs, uint32_t preferredAccuracyMeters,
|
||||
uint32_t preferredTimeMs) override;
|
||||
Return<sp<V1_0::IAGnssRil>> getExtensionAGnssRil() override;
|
||||
Return<sp<V1_0::IGnssGeofencing>> getExtensionGnssGeofencing() override;
|
||||
Return<sp<V1_0::IAGnss>> getExtensionAGnss() override;
|
||||
Return<sp<V1_0::IGnssNi>> getExtensionGnssNi() override;
|
||||
Return<sp<V1_0::IGnssMeasurement>> getExtensionGnssMeasurement() override;
|
||||
Return<sp<V1_0::IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override;
|
||||
Return<sp<V1_0::IGnssXtra>> getExtensionXtra() override;
|
||||
Return<sp<V1_0::IGnssConfiguration>> getExtensionGnssConfiguration() override;
|
||||
Return<sp<V1_0::IGnssDebug>> getExtensionGnssDebug() override;
|
||||
Return<sp<V1_0::IGnssBatching>> getExtensionGnssBatching() override;
|
||||
|
||||
// Methods from V1_1::IGnss follow.
|
||||
Return<bool> setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) override;
|
||||
Return<bool> setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode,
|
||||
V1_0::IGnss::GnssPositionRecurrence recurrence,
|
||||
uint32_t minIntervalMs, uint32_t preferredAccuracyMeters,
|
||||
uint32_t preferredTimeMs, bool lowPowerMode) override;
|
||||
Return<sp<V1_1::IGnssConfiguration>> getExtensionGnssConfiguration_1_1() override;
|
||||
Return<sp<V1_1::IGnssMeasurement>> getExtensionGnssMeasurement_1_1() override;
|
||||
Return<bool> injectBestLocation(const V1_0::GnssLocation& location) override;
|
||||
|
||||
// Methods from V2_0::IGnss follow.
|
||||
Return<bool> setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) override;
|
||||
Return<sp<V2_0::IGnssConfiguration>> getExtensionGnssConfiguration_2_0() override;
|
||||
Return<sp<V2_0::IGnssDebug>> getExtensionGnssDebug_2_0() override;
|
||||
Return<sp<V2_0::IAGnss>> getExtensionAGnss_2_0() override;
|
||||
Return<sp<V2_0::IAGnssRil>> getExtensionAGnssRil_2_0() override;
|
||||
Return<sp<V2_0::IGnssMeasurement>> getExtensionGnssMeasurement_2_0() override;
|
||||
Return<sp<measurement_corrections::V1_0::IMeasurementCorrections>>
|
||||
getExtensionMeasurementCorrections() override;
|
||||
Return<sp<visibility_control::V1_0::IGnssVisibilityControl>> getExtensionVisibilityControl()
|
||||
override;
|
||||
Return<sp<V2_0::IGnssBatching>> getExtensionGnssBatching_2_0() override;
|
||||
Return<bool> injectBestLocation_2_0(const V2_0::GnssLocation& location) override;
|
||||
|
||||
// Methods from V2_1::IGnss follow.
|
||||
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;
|
||||
Return<sp<V2_1::IGnssAntennaInfo>> getExtensionGnssAntennaInfo() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<V2_0::GnssLocation> getLocationFromHW();
|
||||
void reportLocation(const V2_0::GnssLocation&) const;
|
||||
void reportLocation(const V1_0::GnssLocation&) const;
|
||||
void reportSvStatus(const hidl_vec<GnssSvInfo>&) const;
|
||||
|
||||
static sp<V2_1::IGnssCallback> sGnssCallback_2_1;
|
||||
static sp<V2_0::IGnssCallback> sGnssCallback_2_0;
|
||||
static sp<V1_1::IGnssCallback> sGnssCallback_1_1;
|
||||
static sp<V1_0::IGnssCallback> sGnssCallback_1_0;
|
||||
std::atomic<long> mMinIntervalMs;
|
||||
sp<GnssConfiguration> mGnssConfiguration;
|
||||
std::atomic<bool> mIsActive;
|
||||
std::atomic<bool> mHardwareModeOn;
|
||||
std::atomic<int> mGnssFd;
|
||||
std::thread mThread;
|
||||
|
||||
mutable std::mutex mMutex;
|
||||
hidl_vec<GnssSvInfo> filterBlacklistedSatellitesV2_1(hidl_vec<GnssSvInfo> gnssSvInfoList);
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_1
|
||||
} // namespace gnss
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -18,17 +18,17 @@
|
||||
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include "Gnss.h"
|
||||
#include "v2_1/GnssTemplate.h"
|
||||
|
||||
using ::android::OK;
|
||||
using ::android::sp;
|
||||
using ::android::hardware::configureRpcThreadpool;
|
||||
using ::android::hardware::joinRpcThreadpool;
|
||||
using ::android::hardware::gnss::common::implementation::GnssTemplate;
|
||||
using ::android::hardware::gnss::V2_1::IGnss;
|
||||
using ::android::hardware::gnss::V2_1::implementation::Gnss;
|
||||
|
||||
int main(int /* argc */, char* /* argv */[]) {
|
||||
sp<IGnss> gnss = new Gnss();
|
||||
sp<IGnss> gnss = new GnssTemplate<IGnss>();
|
||||
configureRpcThreadpool(1, true /* will join */);
|
||||
if (gnss->registerAsService() != OK) {
|
||||
ALOGE("Could not register gnss 2.1 service.");
|
||||
|
||||
@@ -18,7 +18,6 @@ cc_test {
|
||||
name: "VtsHalGnssV2_1TargetTest",
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: [
|
||||
"gnss_hal_test.cpp",
|
||||
"gnss_hal_test_cases.cpp",
|
||||
"VtsHalGnssV2_1TargetTest.cpp",
|
||||
],
|
||||
|
||||
@@ -1,278 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "GnssHalTest"
|
||||
|
||||
#include <gnss_hal_test.h>
|
||||
#include <chrono>
|
||||
#include "Utils.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using ::android::hardware::gnss::common::Utils;
|
||||
|
||||
// Implementations for the main test class for GNSS HAL
|
||||
void GnssHalTest::SetUp() {
|
||||
gnss_hal_ = IGnss::getService(GetParam());
|
||||
ASSERT_NE(gnss_hal_, nullptr);
|
||||
|
||||
SetUpGnssCallback();
|
||||
}
|
||||
|
||||
void GnssHalTest::TearDown() {
|
||||
if (gnss_hal_ != nullptr) {
|
||||
gnss_hal_->cleanup();
|
||||
gnss_hal_ = nullptr;
|
||||
}
|
||||
|
||||
// Set to nullptr to destruct the callback event queues and warn of any unprocessed events.
|
||||
gnss_cb_ = nullptr;
|
||||
}
|
||||
|
||||
void GnssHalTest::SetUpGnssCallback() {
|
||||
gnss_cb_ = new GnssCallback();
|
||||
ASSERT_NE(gnss_cb_, nullptr);
|
||||
|
||||
auto result = gnss_hal_->setCallback_2_1(gnss_cb_);
|
||||
if (!result.isOk()) {
|
||||
ALOGE("result of failed setCallback %s", result.description().c_str());
|
||||
}
|
||||
|
||||
ASSERT_TRUE(result.isOk());
|
||||
ASSERT_TRUE(result);
|
||||
|
||||
/*
|
||||
* All capabilities, name and systemInfo callbacks should trigger
|
||||
*/
|
||||
EXPECT_TRUE(gnss_cb_->capabilities_cbq_.retrieve(gnss_cb_->last_capabilities_, TIMEOUT_SEC));
|
||||
EXPECT_TRUE(gnss_cb_->info_cbq_.retrieve(gnss_cb_->last_info_, TIMEOUT_SEC));
|
||||
EXPECT_TRUE(gnss_cb_->name_cbq_.retrieve(gnss_cb_->last_name_, TIMEOUT_SEC));
|
||||
|
||||
EXPECT_EQ(gnss_cb_->capabilities_cbq_.calledCount(), 1);
|
||||
EXPECT_EQ(gnss_cb_->info_cbq_.calledCount(), 1);
|
||||
EXPECT_EQ(gnss_cb_->name_cbq_.calledCount(), 1);
|
||||
}
|
||||
|
||||
void GnssHalTest::StopAndClearLocations() {
|
||||
const auto result = gnss_hal_->stop();
|
||||
|
||||
EXPECT_TRUE(result.isOk());
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
/*
|
||||
* Clear notify/waiting counter, allowing up till the timeout after
|
||||
* the last reply for final startup messages to arrive (esp. system
|
||||
* info.)
|
||||
*/
|
||||
while (gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_, TIMEOUT_SEC)) {
|
||||
}
|
||||
gnss_cb_->location_cbq_.reset();
|
||||
}
|
||||
|
||||
void GnssHalTest::SetPositionMode(const int min_interval_msec, const bool low_power_mode) {
|
||||
const int kPreferredAccuracy = 0; // Ideally perfect (matches GnssLocationProvider)
|
||||
const int kPreferredTimeMsec = 0; // Ideally immediate
|
||||
|
||||
const auto result = gnss_hal_->setPositionMode_1_1(
|
||||
IGnss::GnssPositionMode::MS_BASED, IGnss::GnssPositionRecurrence::RECURRENCE_PERIODIC,
|
||||
min_interval_msec, kPreferredAccuracy, kPreferredTimeMsec, low_power_mode);
|
||||
|
||||
ASSERT_TRUE(result.isOk());
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
|
||||
bool GnssHalTest::StartAndCheckFirstLocation() {
|
||||
const auto result = gnss_hal_->start();
|
||||
|
||||
EXPECT_TRUE(result.isOk());
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
/*
|
||||
* GnssLocationProvider support of AGPS SUPL & XtraDownloader is not available in VTS,
|
||||
* so allow time to demodulate ephemeris over the air.
|
||||
*/
|
||||
const int kFirstGnssLocationTimeoutSeconds = 75;
|
||||
|
||||
EXPECT_TRUE(gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_,
|
||||
kFirstGnssLocationTimeoutSeconds));
|
||||
int locationCalledCount = gnss_cb_->location_cbq_.calledCount();
|
||||
EXPECT_EQ(locationCalledCount, 1);
|
||||
|
||||
if (locationCalledCount > 0) {
|
||||
// don't require speed on first fix
|
||||
CheckLocation(gnss_cb_->last_location_, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GnssHalTest::CheckLocation(const GnssLocation_2_0& location, bool check_speed) {
|
||||
const bool check_more_accuracies =
|
||||
(gnss_cb_->info_cbq_.calledCount() > 0 && gnss_cb_->last_info_.yearOfHw >= 2017);
|
||||
|
||||
Utils::checkLocation(location.v1_0, check_speed, check_more_accuracies);
|
||||
}
|
||||
|
||||
void GnssHalTest::StartAndCheckLocations(int count) {
|
||||
const int kMinIntervalMsec = 500;
|
||||
const int kLocationTimeoutSubsequentSec = 2;
|
||||
const bool kLowPowerMode = false;
|
||||
|
||||
SetPositionMode(kMinIntervalMsec, kLowPowerMode);
|
||||
|
||||
EXPECT_TRUE(StartAndCheckFirstLocation());
|
||||
|
||||
for (int i = 1; i < count; i++) {
|
||||
EXPECT_TRUE(gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_,
|
||||
kLocationTimeoutSubsequentSec));
|
||||
int locationCalledCount = gnss_cb_->location_cbq_.calledCount();
|
||||
EXPECT_EQ(locationCalledCount, i + 1);
|
||||
// Don't cause confusion by checking details if no location yet
|
||||
if (locationCalledCount > 0) {
|
||||
// Should be more than 1 location by now, but if not, still don't check first fix speed
|
||||
CheckLocation(gnss_cb_->last_location_, locationCalledCount > 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GnssConstellationType GnssHalTest::startLocationAndGetNonGpsConstellation(
|
||||
const int locations_to_await, const int gnss_sv_info_list_timeout) {
|
||||
gnss_cb_->location_cbq_.reset();
|
||||
StartAndCheckLocations(locations_to_await);
|
||||
const int location_called_count = gnss_cb_->location_cbq_.calledCount();
|
||||
|
||||
// Tolerate 1 less sv status to handle edge cases in reporting.
|
||||
int sv_info_list_cbq_size = gnss_cb_->sv_info_list_cbq_.size();
|
||||
EXPECT_GE(sv_info_list_cbq_size + 1, locations_to_await);
|
||||
ALOGD("Observed %d GnssSvInfo, while awaiting %d Locations (%d received)",
|
||||
sv_info_list_cbq_size, locations_to_await, location_called_count);
|
||||
|
||||
// Find first non-GPS constellation to blacklist
|
||||
GnssConstellationType constellation_to_blacklist = GnssConstellationType::UNKNOWN;
|
||||
for (int i = 0; i < sv_info_list_cbq_size; ++i) {
|
||||
hidl_vec<IGnssCallback_2_1::GnssSvInfo> sv_info_vec;
|
||||
gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_vec, gnss_sv_info_list_timeout);
|
||||
for (uint32_t iSv = 0; iSv < sv_info_vec.size(); iSv++) {
|
||||
const auto& gnss_sv = sv_info_vec[iSv];
|
||||
if ((gnss_sv.v2_0.v1_0.svFlag & IGnssCallback_1_0::GnssSvFlags::USED_IN_FIX) &&
|
||||
(gnss_sv.v2_0.constellation != GnssConstellationType::UNKNOWN) &&
|
||||
(gnss_sv.v2_0.constellation != GnssConstellationType::GPS)) {
|
||||
// found a non-GPS constellation
|
||||
constellation_to_blacklist = gnss_sv.v2_0.constellation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (constellation_to_blacklist != GnssConstellationType::UNKNOWN) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (constellation_to_blacklist == GnssConstellationType::UNKNOWN) {
|
||||
ALOGI("No non-GPS constellations found, constellation blacklist test less effective.");
|
||||
// Proceed functionally to blacklist something.
|
||||
constellation_to_blacklist = GnssConstellationType::GLONASS;
|
||||
}
|
||||
|
||||
return constellation_to_blacklist;
|
||||
}
|
||||
|
||||
GnssHalTest::GnssCallback::GnssCallback()
|
||||
: info_cbq_("system_info"),
|
||||
name_cbq_("name"),
|
||||
capabilities_cbq_("capabilities"),
|
||||
location_cbq_("location"),
|
||||
sv_info_list_cbq_("sv_info") {}
|
||||
|
||||
Return<void> GnssHalTest::GnssCallback::gnssSetSystemInfoCb(
|
||||
const IGnssCallback_1_0::GnssSystemInfo& info) {
|
||||
ALOGI("Info received, year %d", info.yearOfHw);
|
||||
info_cbq_.store(info);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssHalTest::GnssCallback::gnssSetCapabilitesCb(uint32_t capabilities) {
|
||||
ALOGI("Capabilities received %d", capabilities);
|
||||
capabilities_cbq_.store(capabilities);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssHalTest::GnssCallback::gnssSetCapabilitiesCb_2_0(uint32_t capabilities) {
|
||||
ALOGI("Capabilities (v2.0) received %d", capabilities);
|
||||
capabilities_cbq_.store(capabilities);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssHalTest::GnssCallback::gnssSetCapabilitiesCb_2_1(uint32_t capabilities) {
|
||||
ALOGI("Capabilities (v2.1) received %d", capabilities);
|
||||
capabilities_cbq_.store(capabilities);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssHalTest::GnssCallback::gnssNameCb(const android::hardware::hidl_string& name) {
|
||||
ALOGI("Name received: %s", name.c_str());
|
||||
name_cbq_.store(name);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssHalTest::GnssCallback::gnssLocationCb(const GnssLocation_1_0& location) {
|
||||
ALOGI("Location received");
|
||||
GnssLocation_2_0 location_v2_0;
|
||||
location_v2_0.v1_0 = location;
|
||||
return gnssLocationCbImpl(location_v2_0);
|
||||
}
|
||||
|
||||
Return<void> GnssHalTest::GnssCallback::gnssLocationCb_2_0(const GnssLocation_2_0& location) {
|
||||
ALOGI("Location (v2.0) received");
|
||||
return gnssLocationCbImpl(location);
|
||||
}
|
||||
|
||||
Return<void> GnssHalTest::GnssCallback::gnssLocationCbImpl(const GnssLocation_2_0& location) {
|
||||
location_cbq_.store(location);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssHalTest::GnssCallback::gnssSvStatusCb(const IGnssCallback_1_0::GnssSvStatus&) {
|
||||
ALOGI("gnssSvStatusCb");
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssHalTest::GnssCallback::gnssSvStatusCb_2_1(
|
||||
const hidl_vec<IGnssCallback_2_1::GnssSvInfo>& svInfoList) {
|
||||
ALOGI("gnssSvStatusCb_2_1. Size = %d", (int)svInfoList.size());
|
||||
sv_info_list_cbq_.store(svInfoList);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssHalTest::GnssMeasurementCallback::gnssMeasurementCb_2_1(
|
||||
const IGnssMeasurementCallback_2_1::GnssData& data) {
|
||||
ALOGD("GnssMeasurement v2.1 received. Size = %d", (int)data.measurements.size());
|
||||
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();
|
||||
}
|
||||
|
||||
Return<void> GnssHalTest::GnssAntennaInfoCallback::gnssAntennaInfoCb(
|
||||
const hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& gnssAntennaInfos) {
|
||||
ALOGD("GnssAntennaInfo v2.1 received. Size = %d", (int)gnssAntennaInfos.size());
|
||||
antenna_info_cbq_.store(gnssAntennaInfos);
|
||||
return Void();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
* 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.
|
||||
@@ -14,221 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef GNSS_HAL_TEST_H_
|
||||
#define GNSS_HAL_TEST_H_
|
||||
#pragma once
|
||||
|
||||
#include <android/hardware/gnss/2.1/IGnss.h>
|
||||
#include "GnssCallbackEventQueue.h"
|
||||
#include "v2_1/gnss_hal_test_template.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using android::hardware::hidl_vec;
|
||||
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;
|
||||
using android::hardware::gnss::V2_1::IGnssAntennaInfo;
|
||||
using android::hardware::gnss::V2_1::IGnssAntennaInfoCallback;
|
||||
|
||||
using GnssLocation_1_0 = android::hardware::gnss::V1_0::GnssLocation;
|
||||
using GnssLocation_2_0 = android::hardware::gnss::V2_0::GnssLocation;
|
||||
|
||||
using IGnssCallback_1_0 = android::hardware::gnss::V1_0::IGnssCallback;
|
||||
using IGnssCallback_2_0 = android::hardware::gnss::V2_0::IGnssCallback;
|
||||
using IGnssCallback_2_1 = android::hardware::gnss::V2_1::IGnssCallback;
|
||||
|
||||
using IGnssMeasurementCallback_1_0 = android::hardware::gnss::V1_0::IGnssMeasurementCallback;
|
||||
using IGnssMeasurementCallback_1_1 = android::hardware::gnss::V1_1::IGnssMeasurementCallback;
|
||||
using IGnssMeasurementCallback_2_0 = android::hardware::gnss::V2_0::IGnssMeasurementCallback;
|
||||
using IGnssMeasurementCallback_2_1 = android::hardware::gnss::V2_1::IGnssMeasurementCallback;
|
||||
|
||||
using android::sp;
|
||||
|
||||
#define TIMEOUT_SEC 2 // for basic commands/responses
|
||||
|
||||
// The main test class for GNSS HAL.
|
||||
class GnssHalTest : public testing::TestWithParam<std::string> {
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
|
||||
virtual void TearDown() override;
|
||||
|
||||
/* Callback class for data & Event. */
|
||||
class GnssCallback : public IGnssCallback_2_1 {
|
||||
public:
|
||||
IGnssCallback_1_0::GnssSystemInfo last_info_;
|
||||
android::hardware::hidl_string last_name_;
|
||||
uint32_t last_capabilities_;
|
||||
GnssLocation_2_0 last_location_;
|
||||
|
||||
GnssCallbackEventQueue<IGnssCallback_1_0::GnssSystemInfo> info_cbq_;
|
||||
GnssCallbackEventQueue<android::hardware::hidl_string> name_cbq_;
|
||||
GnssCallbackEventQueue<uint32_t> capabilities_cbq_;
|
||||
GnssCallbackEventQueue<GnssLocation_2_0> location_cbq_;
|
||||
GnssCallbackEventQueue<hidl_vec<IGnssCallback_2_1::GnssSvInfo>> sv_info_list_cbq_;
|
||||
|
||||
GnssCallback();
|
||||
virtual ~GnssCallback() = default;
|
||||
|
||||
// Dummy callback handlers
|
||||
Return<void> gnssStatusCb(const IGnssCallback_1_0::GnssStatusValue /* status */) override {
|
||||
return Void();
|
||||
}
|
||||
Return<void> gnssNmeaCb(int64_t /* timestamp */,
|
||||
const android::hardware::hidl_string& /* nmea */) override {
|
||||
return Void();
|
||||
}
|
||||
Return<void> gnssAcquireWakelockCb() override { return Void(); }
|
||||
Return<void> gnssReleaseWakelockCb() override { return Void(); }
|
||||
Return<void> gnssRequestLocationCb(bool /* independentFromGnss */) override {
|
||||
return Void();
|
||||
}
|
||||
Return<void> gnssRequestTimeCb() override { return Void(); }
|
||||
// Actual (test) callback handlers
|
||||
Return<void> gnssNameCb(const android::hardware::hidl_string& name) override;
|
||||
Return<void> gnssLocationCb(const GnssLocation_1_0& location) override;
|
||||
Return<void> gnssSetCapabilitesCb(uint32_t capabilities) override;
|
||||
Return<void> gnssSetSystemInfoCb(const IGnssCallback_1_0::GnssSystemInfo& info) override;
|
||||
Return<void> gnssSvStatusCb(const IGnssCallback_1_0::GnssSvStatus& svStatus) override;
|
||||
|
||||
// New in v2.0
|
||||
Return<void> gnssLocationCb_2_0(const GnssLocation_2_0& location) override;
|
||||
Return<void> gnssRequestLocationCb_2_0(bool /* independentFromGnss */,
|
||||
bool /* isUserEmergency */) override {
|
||||
return Void();
|
||||
}
|
||||
Return<void> gnssSetCapabilitiesCb_2_0(uint32_t capabilities) override;
|
||||
Return<void> gnssSvStatusCb_2_0(const hidl_vec<IGnssCallback_2_0::GnssSvInfo>&) override {
|
||||
return Void();
|
||||
}
|
||||
|
||||
// New in v2.1
|
||||
Return<void> gnssSvStatusCb_2_1(
|
||||
const hidl_vec<IGnssCallback_2_1::GnssSvInfo>& svInfoList) override;
|
||||
Return<void> gnssSetCapabilitiesCb_2_1(uint32_t capabilities) override;
|
||||
|
||||
private:
|
||||
Return<void> gnssLocationCbImpl(const GnssLocation_2_0& location);
|
||||
};
|
||||
|
||||
/* Callback class for GnssMeasurement. */
|
||||
class GnssMeasurementCallback : public IGnssMeasurementCallback_2_1 {
|
||||
public:
|
||||
GnssCallbackEventQueue<IGnssMeasurementCallback_2_1::GnssData> measurement_cbq_;
|
||||
|
||||
GnssMeasurementCallback() : measurement_cbq_("measurement"){};
|
||||
virtual ~GnssMeasurementCallback() = default;
|
||||
|
||||
// Methods from V1_0::IGnssMeasurementCallback follow.
|
||||
Return<void> GnssMeasurementCb(const IGnssMeasurementCallback_1_0::GnssData&) override {
|
||||
return Void();
|
||||
}
|
||||
|
||||
// Methods from V1_1::IGnssMeasurementCallback follow.
|
||||
Return<void> gnssMeasurementCb(const IGnssMeasurementCallback_1_1::GnssData&) override {
|
||||
return Void();
|
||||
}
|
||||
|
||||
// Methods from V2_0::IGnssMeasurementCallback follow.
|
||||
Return<void> gnssMeasurementCb_2_0(const IGnssMeasurementCallback_2_0::GnssData&) override {
|
||||
return Void();
|
||||
}
|
||||
|
||||
// Methods from V2_1::IGnssMeasurementCallback follow.
|
||||
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;
|
||||
};
|
||||
|
||||
/* Callback class for GnssAntennaInfo. */
|
||||
class GnssAntennaInfoCallback : public IGnssAntennaInfoCallback {
|
||||
public:
|
||||
GnssCallbackEventQueue<hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>>
|
||||
antenna_info_cbq_;
|
||||
|
||||
GnssAntennaInfoCallback() : antenna_info_cbq_("info"){};
|
||||
virtual ~GnssAntennaInfoCallback() = default;
|
||||
|
||||
// Methods from V2_1::GnssAntennaInfoCallback follow.
|
||||
Return<void> gnssAntennaInfoCb(
|
||||
const hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& gnssAntennaInfos);
|
||||
};
|
||||
|
||||
/*
|
||||
* SetUpGnssCallback:
|
||||
* Set GnssCallback and verify the result.
|
||||
*/
|
||||
void SetUpGnssCallback();
|
||||
|
||||
/*
|
||||
* StartAndCheckFirstLocation:
|
||||
* Helper function to start location, and check the first one.
|
||||
*
|
||||
* <p> Note this leaves the Location request active, to enable Stop call vs. other call
|
||||
* reordering tests.
|
||||
*
|
||||
* returns true if a location was successfully generated
|
||||
*/
|
||||
bool StartAndCheckFirstLocation();
|
||||
|
||||
/*
|
||||
* CheckLocation:
|
||||
* Helper function to vet Location fields
|
||||
*
|
||||
* check_speed: true if speed related fields are also verified.
|
||||
*/
|
||||
void CheckLocation(const GnssLocation_2_0& location, const bool check_speed);
|
||||
|
||||
/*
|
||||
* StartAndCheckLocations:
|
||||
* Helper function to collect, and check a number of
|
||||
* normal ~1Hz locations.
|
||||
*
|
||||
* Note this leaves the Location request active, to enable Stop call vs. other call
|
||||
* reordering tests.
|
||||
*/
|
||||
void StartAndCheckLocations(int count);
|
||||
|
||||
/*
|
||||
* StopAndClearLocations:
|
||||
* Helper function to stop locations, and clear any remaining notifications
|
||||
*/
|
||||
void StopAndClearLocations();
|
||||
|
||||
/*
|
||||
* SetPositionMode:
|
||||
* Helper function to set positioning mode and verify output
|
||||
*/
|
||||
void SetPositionMode(const int min_interval_msec, const bool low_power_mode);
|
||||
|
||||
/*
|
||||
* startLocationAndGetNonGpsConstellation:
|
||||
* 1. Start location
|
||||
* 2. Find and return first non-GPS constellation
|
||||
*
|
||||
* Note that location is not stopped in this method. The client should call
|
||||
* StopAndClearLocations() after the call.
|
||||
*/
|
||||
GnssConstellationType startLocationAndGetNonGpsConstellation(
|
||||
const int locations_to_await, const int gnss_sv_info_list_timeout);
|
||||
|
||||
sp<IGnss> gnss_hal_; // GNSS HAL to call into
|
||||
sp<GnssCallback> gnss_cb_; // Primary callback interface
|
||||
};
|
||||
|
||||
#endif // GNSS_HAL_TEST_H_
|
||||
class GnssHalTest : public GnssHalTestTemplate<IGnss> {};
|
||||
|
||||
25
gnss/3.0/Android.bp
Normal file
25
gnss/3.0/Android.bp
Normal file
@@ -0,0 +1,25 @@
|
||||
// This file is autogenerated by hidl-gen -Landroidbp.
|
||||
|
||||
hidl_interface {
|
||||
name: "android.hardware.gnss@3.0",
|
||||
root: "android.hardware",
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
srcs: [
|
||||
"IGnss.hal",
|
||||
"IGnssPsds.hal",
|
||||
"IGnssPsdsCallback.hal",
|
||||
],
|
||||
interfaces: [
|
||||
"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",
|
||||
"android.hardware.gnss@2.0",
|
||||
"android.hardware.gnss@2.1",
|
||||
"android.hidl.base@1.0",
|
||||
],
|
||||
gen_java: true,
|
||||
}
|
||||
32
gnss/3.0/IGnss.hal
Normal file
32
gnss/3.0/IGnss.hal
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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@3.0;
|
||||
|
||||
import @2.1::IGnss;
|
||||
import IGnssPsds;
|
||||
|
||||
/**
|
||||
* Represents the standard GNSS (Global Navigation Satellite System) interface.
|
||||
*/
|
||||
interface IGnss extends @2.1::IGnss {
|
||||
/**
|
||||
* This method returns the IGnssPsds interface.
|
||||
*
|
||||
* @return psdsIface Handle to the IGnssPsds interface.
|
||||
*/
|
||||
getExtensionPsds() generates (IGnssPsds psdsIface);
|
||||
};
|
||||
48
gnss/3.0/IGnssPsds.hal
Normal file
48
gnss/3.0/IGnssPsds.hal
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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@3.0;
|
||||
|
||||
import @1.0::IGnssXtra;
|
||||
import IGnssPsdsCallback;
|
||||
|
||||
/**
|
||||
* This interface is used by the GNSS HAL to request the framework to download Predicted Satellite
|
||||
* Data Service data.
|
||||
*/
|
||||
interface IGnssPsds extends @1.0::IGnssXtra {
|
||||
/**
|
||||
* Opens the PSDS interface and provides the callback routines to the implementation of this
|
||||
* interface.
|
||||
*
|
||||
* @param callback Handle to the IGnssPsdsCallback interface.
|
||||
*
|
||||
* @return success True if the operation is successful.
|
||||
*/
|
||||
setCallback_3_0(IGnssPsdsCallback callback) generates (bool success);
|
||||
|
||||
/**
|
||||
* Inject the downloaded PSDS data into the GNSS receiver.
|
||||
*
|
||||
* @param psdsType Type of PSDS as defined in IGnssPsdsCallback.hal
|
||||
* @param psdsData GNSS PSDS data. Framework must not parse the data since the data format is
|
||||
* opaque to framework.
|
||||
*
|
||||
* @return success True if the operation is successful.
|
||||
*/
|
||||
injectPsdsData_3_0(int32_t psdsType, string psdsData) generates (bool success);
|
||||
};
|
||||
|
||||
41
gnss/3.0/IGnssPsdsCallback.hal
Normal file
41
gnss/3.0/IGnssPsdsCallback.hal
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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@3.0;
|
||||
|
||||
import @1.0::IGnssXtraCallback;
|
||||
|
||||
/**
|
||||
* This interface is used by the GNSS HAL to request download data from Predicted Satellite Data
|
||||
* Service (PSDS).
|
||||
*/
|
||||
interface IGnssPsdsCallback extends @1.0::IGnssXtraCallback {
|
||||
/**
|
||||
* Callback to request the client to download PSDS data. The client should
|
||||
* download PSDS data and inject it by calling injectPsdsData().
|
||||
*
|
||||
* psdsType represents the type of PSDS data requested.
|
||||
* - Value 1 represents the Long-Term type PSDS data, which lasts for many hours to several days
|
||||
* and often provides satellite orbit and clock accuracy of 2 - 20 meters.
|
||||
* - Value 2 represents the Normal type PSDS data, which is similar to broadcast ephemeris in
|
||||
* longevity - lasting for hours and providings satellite orbit and clock accuracy of 1 - 2
|
||||
* meters.
|
||||
* - Value 3 represents the Real-Time type PSDS data, which lasts for minutes and provides brief
|
||||
* satellite status information such as temporary malfunction, but does not include satellite
|
||||
* orbit or clock information.
|
||||
*/
|
||||
downloadRequestCb_3_0(int32_t psdsType);
|
||||
};
|
||||
43
gnss/3.0/default/Android.bp
Normal file
43
gnss/3.0/default/Android.bp
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.gnss@3.0-service",
|
||||
init_rc: ["android.hardware.gnss@3.0-service.rc"],
|
||||
relative_install_path: "hw",
|
||||
vendor: true,
|
||||
vintf_fragments: ["android.hardware.gnss@3.0-service.xml"],
|
||||
srcs: [
|
||||
"Gnss.cpp",
|
||||
"GnssPsds.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libutils",
|
||||
"liblog",
|
||||
"android.hardware.gnss@1.0",
|
||||
"android.hardware.gnss@1.1",
|
||||
"android.hardware.gnss@2.0",
|
||||
"android.hardware.gnss@2.1",
|
||||
"android.hardware.gnss@3.0",
|
||||
"android.hardware.gnss.measurement_corrections@1.1",
|
||||
"android.hardware.gnss.measurement_corrections@1.0",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.gnss@common-default-lib",
|
||||
],
|
||||
}
|
||||
32
gnss/3.0/default/Gnss.cpp
Normal file
32
gnss/3.0/default/Gnss.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "Gnss"
|
||||
|
||||
#include "Gnss.h"
|
||||
#include <log/log.h>
|
||||
#include "GnssPsds.h"
|
||||
#include "Utils.h"
|
||||
|
||||
namespace android::hardware::gnss::V3_0::implementation {
|
||||
|
||||
// Methods from V3_0::IGnss follow.
|
||||
Return<sp<V3_0::IGnssPsds>> Gnss::getExtensionPsds() {
|
||||
ALOGD("Gnss::getExtensionPsds");
|
||||
return new GnssPsds();
|
||||
}
|
||||
|
||||
} // namespace android::hardware::gnss::V3_0::implementation
|
||||
42
gnss/3.0/default/Gnss.h
Normal file
42
gnss/3.0/default/Gnss.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <android/hardware/gnss/3.0/IGnss.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include "v2_1/GnssTemplate.h"
|
||||
|
||||
namespace android::hardware::gnss::V3_0::implementation {
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::gnss::common::implementation::GnssTemplate;
|
||||
|
||||
struct Gnss : public GnssTemplate<IGnss> {
|
||||
Gnss(){};
|
||||
~Gnss(){};
|
||||
|
||||
// Methods from V3_0::IGnss follow.
|
||||
Return<sp<V3_0::IGnssPsds>> getExtensionPsds() override;
|
||||
};
|
||||
|
||||
} // namespace android::hardware::gnss::V3_0::implementation
|
||||
50
gnss/3.0/default/GnssPsds.cpp
Normal file
50
gnss/3.0/default/GnssPsds.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "GnssPsds"
|
||||
|
||||
#include "GnssPsds.h"
|
||||
|
||||
#include <log/log.h>
|
||||
|
||||
namespace android::hardware::gnss::V3_0::implementation {
|
||||
|
||||
sp<V3_0::IGnssPsdsCallback> GnssPsds::sCallback_3_0 = nullptr;
|
||||
|
||||
// Methods from V1_0::IGnssXtra follow.
|
||||
Return<bool> GnssPsds::setCallback(const sp<V1_0::IGnssXtraCallback>&) {
|
||||
// TODO implement
|
||||
return bool{};
|
||||
}
|
||||
|
||||
Return<bool> GnssPsds::injectXtraData(const hidl_string&) {
|
||||
// TODO implement
|
||||
return bool{};
|
||||
}
|
||||
|
||||
// Methods from V3_0::IGnssPsds follow.
|
||||
Return<bool> GnssPsds::setCallback_3_0(const sp<V3_0::IGnssPsdsCallback>& callback) {
|
||||
ALOGD("setCallback_3_0");
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
sCallback_3_0 = callback;
|
||||
return true;
|
||||
}
|
||||
|
||||
Return<bool> GnssPsds::injectPsdsData_3_0(int32_t psdsType, const hidl_string& psdsData) {
|
||||
ALOGD("injectPsdsData_3_0. psdsType: %d, psdsData: %s", psdsType, psdsData.c_str());
|
||||
return true;
|
||||
}
|
||||
} // namespace android::hardware::gnss::V3_0::implementation
|
||||
50
gnss/3.0/default/GnssPsds.h
Normal file
50
gnss/3.0/default/GnssPsds.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <android/hardware/gnss/3.0/IGnssPsds.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
namespace android::hardware::gnss::V3_0::implementation {
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_array;
|
||||
using ::android::hardware::hidl_memory;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
struct GnssPsds : public V3_0::IGnssPsds {
|
||||
// Methods from V1_0::IGnssXtra follow.
|
||||
Return<bool> setCallback(const sp<V1_0::IGnssXtraCallback>& callback) override;
|
||||
Return<bool> injectXtraData(const hidl_string& xtraData) override;
|
||||
|
||||
// Methods from V3_0::IGnssPsds follow.
|
||||
Return<bool> setCallback_3_0(const sp<V3_0::IGnssPsdsCallback>& callback) override;
|
||||
Return<bool> injectPsdsData_3_0(int32_t psdsType, const hidl_string& psdsData) override;
|
||||
|
||||
private:
|
||||
// Guarded by mMutex
|
||||
static sp<V3_0::IGnssPsdsCallback> sCallback_3_0;
|
||||
|
||||
// Synchronization lock for sCallback_3_0
|
||||
mutable std::mutex mMutex;
|
||||
};
|
||||
|
||||
} // namespace android::hardware::gnss::V3_0::implementation
|
||||
4
gnss/3.0/default/OWNERS
Normal file
4
gnss/3.0/default/OWNERS
Normal file
@@ -0,0 +1,4 @@
|
||||
gomo@google.com
|
||||
smalkos@google.com
|
||||
wyattriley@google.com
|
||||
yuhany@google.com
|
||||
4
gnss/3.0/default/android.hardware.gnss@3.0-service.rc
Normal file
4
gnss/3.0/default/android.hardware.gnss@3.0-service.rc
Normal file
@@ -0,0 +1,4 @@
|
||||
service vendor.gnss-3-0 /vendor/bin/hw/android.hardware.gnss@3.0-service
|
||||
class hal
|
||||
user system
|
||||
group system
|
||||
13
gnss/3.0/default/android.hardware.gnss@3.0-service.xml
Normal file
13
gnss/3.0/default/android.hardware.gnss@3.0-service.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.gnss</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>3.0</version>
|
||||
<version>2.1</version>
|
||||
<version>1.1</version>
|
||||
<interface>
|
||||
<name>IGnss</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
||||
41
gnss/3.0/default/service.cpp
Normal file
41
gnss/3.0/default/service.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.gnss@3.0-service"
|
||||
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include "Gnss.h"
|
||||
|
||||
using ::android::OK;
|
||||
using ::android::sp;
|
||||
using ::android::hardware::configureRpcThreadpool;
|
||||
using ::android::hardware::joinRpcThreadpool;
|
||||
using ::android::hardware::gnss::V3_0::IGnss;
|
||||
using ::android::hardware::gnss::V3_0::implementation::Gnss;
|
||||
|
||||
int main(int /* argc */, char* /* argv */[]) {
|
||||
sp<IGnss> gnss = new Gnss();
|
||||
configureRpcThreadpool(1, true /* will join */);
|
||||
if (gnss->registerAsService() != OK) {
|
||||
ALOGE("Could not register gnss 3.0 service.");
|
||||
return 1;
|
||||
}
|
||||
joinRpcThreadpool();
|
||||
|
||||
ALOGE("Service exited!");
|
||||
return 1;
|
||||
}
|
||||
4
gnss/3.0/vts/OWNERS
Normal file
4
gnss/3.0/vts/OWNERS
Normal file
@@ -0,0 +1,4 @@
|
||||
gomo@google.com
|
||||
smalkos@google.com
|
||||
wyattriley@google.com
|
||||
yuhany@google.com
|
||||
39
gnss/3.0/vts/functional/Android.bp
Normal file
39
gnss/3.0/vts/functional/Android.bp
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
cc_test {
|
||||
name: "VtsHalGnssV3_0TargetTest",
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: [
|
||||
"gnss_hal_test_cases.cpp",
|
||||
"VtsHalGnssV3_0TargetTest.cpp",
|
||||
],
|
||||
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",
|
||||
"android.hardware.gnss@2.0",
|
||||
"android.hardware.gnss@2.1",
|
||||
"android.hardware.gnss@3.0",
|
||||
"android.hardware.gnss@common-vts-lib",
|
||||
],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
"vts",
|
||||
],
|
||||
}
|
||||
29
gnss/3.0/vts/functional/VtsHalGnssV3_0TargetTest.cpp
Normal file
29
gnss/3.0/vts/functional/VtsHalGnssV3_0TargetTest.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#define LOG_TAG "VtsHalGnssV3_0TargetTest"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
|
||||
#include "gnss_hal_test.h"
|
||||
|
||||
using android::hardware::gnss::V3_0::IGnss;
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PerInstance, GnssHalTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IGnss::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
25
gnss/3.0/vts/functional/gnss_hal_test.h
Normal file
25
gnss/3.0/vts/functional/gnss_hal_test.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <android/hardware/gnss/3.0/IGnss.h>
|
||||
#include "v2_1/gnss_hal_test_template.h"
|
||||
|
||||
using android::hardware::gnss::V3_0::IGnss;
|
||||
|
||||
// The main test class for GNSS HAL.
|
||||
class GnssHalTest : public GnssHalTestTemplate<IGnss> {};
|
||||
49
gnss/3.0/vts/functional/gnss_hal_test_cases.cpp
Normal file
49
gnss/3.0/vts/functional/gnss_hal_test_cases.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "GnssHalTestCases"
|
||||
|
||||
#include <gnss_hal_test.h>
|
||||
#include <cmath>
|
||||
#include "Utils.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using android::hardware::hidl_string;
|
||||
using android::hardware::hidl_vec;
|
||||
|
||||
using android::hardware::gnss::common::Utils;
|
||||
|
||||
using android::hardware::gnss::V3_0::IGnssPsds;
|
||||
|
||||
/*
|
||||
* SetupTeardownCreateCleanup:
|
||||
* Requests the gnss HAL then calls cleanup
|
||||
*
|
||||
* Empty test fixture to verify basic Setup & Teardown
|
||||
*/
|
||||
TEST_P(GnssHalTest, SetupTeardownCreateCleanup) {}
|
||||
|
||||
/*
|
||||
* TestPsdsExtension:
|
||||
* Gets the PsdsExtension and verifies that it returns a non-null extension.
|
||||
*/
|
||||
TEST_P(GnssHalTest, TestPsdsExtension) {
|
||||
auto psds = gnss_hal_->getExtensionPsds();
|
||||
ASSERT_TRUE(psds.isOk());
|
||||
sp<IGnssPsds> iPsds = psds;
|
||||
ASSERT_TRUE(iPsds != nullptr);
|
||||
}
|
||||
@@ -24,6 +24,11 @@ cc_library_static {
|
||||
"-Werror",
|
||||
],
|
||||
srcs: [
|
||||
"v2_1/GnssAntennaInfo.cpp",
|
||||
"v2_1/GnssConfiguration.cpp",
|
||||
"v2_1/GnssDebug.cpp",
|
||||
"v2_1/GnssMeasurement.cpp",
|
||||
"v2_1/GnssMeasurementCorrections.cpp",
|
||||
"Utils.cpp",
|
||||
"NmeaFixInfo.cpp",
|
||||
],
|
||||
@@ -34,5 +39,7 @@ cc_library_static {
|
||||
"android.hardware.gnss@1.0",
|
||||
"android.hardware.gnss@2.0",
|
||||
"android.hardware.gnss@2.1",
|
||||
"android.hardware.gnss.measurement_corrections@1.1",
|
||||
"android.hardware.gnss.measurement_corrections@1.0",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -14,23 +14,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V2_1_GNSSANTENNAINFO_H
|
||||
#define ANDROID_HARDWARE_GNSS_V2_1_GNSSANTENNAINFO_H
|
||||
#pragma once
|
||||
|
||||
#include <android/hardware/gnss/2.1/IGnssAntennaInfo.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace gnss {
|
||||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
namespace android::hardware::gnss::V2_1::implementation {
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using IGnssAntennaInfo = ::android::hardware::gnss::V2_1::IGnssAntennaInfo;
|
||||
using IGnssAntennaInfoCallback = ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback;
|
||||
|
||||
struct GnssAntennaInfo : public IGnssAntennaInfo {
|
||||
GnssAntennaInfo();
|
||||
@@ -58,10 +55,4 @@ struct GnssAntennaInfo : public IGnssAntennaInfo {
|
||||
mutable std::mutex mMutex;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_1
|
||||
} // namespace gnss
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_GNSS_V2_1_GNSSCONFIGURATION_H
|
||||
} // namespace android::hardware::gnss::V2_1::implementation
|
||||
@@ -14,8 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V2_1_GNSSCONFIGURATION_H
|
||||
#define ANDROID_HARDWARE_GNSS_V2_1_GNSSCONFIGURATION_H
|
||||
#pragma once
|
||||
|
||||
#include <android/hardware/gnss/2.1/IGnssCallback.h>
|
||||
#include <android/hardware/gnss/2.1/IGnssConfiguration.h>
|
||||
@@ -24,11 +23,7 @@
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace gnss {
|
||||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
namespace android::hardware::gnss::V2_1::implementation {
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_array;
|
||||
@@ -92,10 +87,4 @@ struct GnssConfiguration : public IGnssConfiguration {
|
||||
BlacklistedConstellationSetV2_1 mBlacklistedConstellationSet;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_1
|
||||
} // namespace gnss
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_GNSS_V2_1_GNSSCONFIGURATION_H
|
||||
} // namespace android::hardware::gnss::V2_1::implementation
|
||||
@@ -14,17 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef android_hardware_gnss_V1_1_GnssDebug_H_
|
||||
#define android_hardware_gnss_V1_1_GnssDebug_H_
|
||||
#pragma once
|
||||
|
||||
#include <android/hardware/gnss/1.0/IGnssDebug.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace gnss {
|
||||
namespace V1_1 {
|
||||
namespace implementation {
|
||||
namespace android::hardware::gnss::V1_1::implementation {
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_string;
|
||||
@@ -42,10 +37,4 @@ struct GnssDebug : public IGnssDebug {
|
||||
Return<void> getDebugData(V1_0::IGnssDebug::getDebugData_cb _hidl_cb) override;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_1
|
||||
} // namespace gnss
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // android_hardware_gnss_V1_1_GnssDebug_H_
|
||||
} // namespace android::hardware::gnss::V1_1::implementation
|
||||
@@ -23,11 +23,7 @@
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace gnss {
|
||||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
namespace android::hardware::gnss::V2_1::implementation {
|
||||
|
||||
using GnssDataV2_1 = V2_1::IGnssMeasurementCallback::GnssData;
|
||||
using GnssDataV2_0 = V2_0::IGnssMeasurementCallback::GnssData;
|
||||
@@ -80,8 +76,4 @@ struct GnssMeasurement : public IGnssMeasurement {
|
||||
mutable std::mutex mMutex;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_1
|
||||
} // namespace gnss
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace android::hardware::gnss::V2_1::implementation
|
||||
@@ -20,22 +20,15 @@
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace gnss {
|
||||
namespace measurement_corrections {
|
||||
namespace V1_1 {
|
||||
namespace implementation {
|
||||
namespace android::hardware::gnss::measurement_corrections::V1_1::implementation {
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_array;
|
||||
using ::android::hardware::hidl_memory;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
struct GnssMeasurementCorrections : public IMeasurementCorrections {
|
||||
GnssMeasurementCorrections();
|
||||
~GnssMeasurementCorrections();
|
||||
|
||||
// Methods from V1_0::IMeasurementCorrections follow.
|
||||
Return<bool> setCorrections(const V1_0::MeasurementCorrections& corrections) override;
|
||||
Return<bool> setCallback(const sp<V1_0::IMeasurementCorrectionsCallback>& callback) override;
|
||||
@@ -44,9 +37,4 @@ struct GnssMeasurementCorrections : public IMeasurementCorrections {
|
||||
Return<bool> setCorrections_1_1(const V1_1::MeasurementCorrections& corrections) override;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_1
|
||||
} // namespace measurement_corrections
|
||||
} // namespace gnss
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace android::hardware::gnss::measurement_corrections::V1_1::implementation
|
||||
@@ -14,44 +14,149 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "Gnss"
|
||||
#pragma once
|
||||
|
||||
#include "Gnss.h"
|
||||
#include <android/hardware/gnss/2.1/IGnss.h>
|
||||
#include <fcntl.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <log/log.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#include "GnssAntennaInfo.h"
|
||||
#include "GnssConfiguration.h"
|
||||
#include "GnssDebug.h"
|
||||
#include "GnssMeasurement.h"
|
||||
#include "GnssMeasurementCorrections.h"
|
||||
#include "NmeaFixInfo.h"
|
||||
#include "Utils.h"
|
||||
|
||||
using ::android::hardware::gnss::common::Utils;
|
||||
using ::android::hardware::gnss::measurement_corrections::V1_1::implementation::
|
||||
GnssMeasurementCorrections;
|
||||
namespace android::hardware::gnss::common::implementation {
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace gnss {
|
||||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
using GnssSvInfo = V2_1::IGnssCallback::GnssSvInfo;
|
||||
|
||||
sp<V2_1::IGnssCallback> Gnss::sGnssCallback_2_1 = nullptr;
|
||||
sp<V2_0::IGnssCallback> Gnss::sGnssCallback_2_0 = nullptr;
|
||||
sp<V1_1::IGnssCallback> Gnss::sGnssCallback_1_1 = nullptr;
|
||||
sp<V1_0::IGnssCallback> Gnss::sGnssCallback_1_0 = nullptr;
|
||||
using common::NmeaFixInfo;
|
||||
using common::Utils;
|
||||
using measurement_corrections::V1_1::implementation::GnssMeasurementCorrections;
|
||||
|
||||
Gnss::Gnss()
|
||||
using V2_1::implementation::GnssAntennaInfo;
|
||||
using V2_1::implementation::GnssConfiguration;
|
||||
using V2_1::implementation::GnssMeasurement;
|
||||
|
||||
constexpr int INPUT_BUFFER_SIZE = 128;
|
||||
constexpr char CMD_GET_LOCATION[] = "CMD_GET_LOCATION";
|
||||
constexpr char GNSS_PATH[] = "/dev/gnss0";
|
||||
|
||||
template <class T_IGnss>
|
||||
struct GnssTemplate : public T_IGnss {
|
||||
GnssTemplate();
|
||||
~GnssTemplate();
|
||||
// Methods from V1_0::IGnss follow.
|
||||
Return<bool> setCallback(const sp<V1_0::IGnssCallback>& callback) override;
|
||||
Return<bool> start() override;
|
||||
Return<bool> stop() override;
|
||||
Return<void> cleanup() override;
|
||||
Return<bool> injectTime(int64_t timeMs, int64_t timeReferenceMs,
|
||||
int32_t uncertaintyMs) override;
|
||||
Return<bool> injectLocation(double latitudeDegrees, double longitudeDegrees,
|
||||
float accuracyMeters) override;
|
||||
Return<void> deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) override;
|
||||
Return<bool> setPositionMode(V1_0::IGnss::GnssPositionMode mode,
|
||||
V1_0::IGnss::GnssPositionRecurrence recurrence,
|
||||
uint32_t minIntervalMs, uint32_t preferredAccuracyMeters,
|
||||
uint32_t preferredTimeMs) override;
|
||||
Return<sp<V1_0::IAGnssRil>> getExtensionAGnssRil() override;
|
||||
Return<sp<V1_0::IGnssGeofencing>> getExtensionGnssGeofencing() override;
|
||||
Return<sp<V1_0::IAGnss>> getExtensionAGnss() override;
|
||||
Return<sp<V1_0::IGnssNi>> getExtensionGnssNi() override;
|
||||
Return<sp<V1_0::IGnssMeasurement>> getExtensionGnssMeasurement() override;
|
||||
Return<sp<V1_0::IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override;
|
||||
Return<sp<V1_0::IGnssXtra>> getExtensionXtra() override;
|
||||
Return<sp<V1_0::IGnssConfiguration>> getExtensionGnssConfiguration() override;
|
||||
Return<sp<V1_0::IGnssDebug>> getExtensionGnssDebug() override;
|
||||
Return<sp<V1_0::IGnssBatching>> getExtensionGnssBatching() override;
|
||||
|
||||
// Methods from V1_1::IGnss follow.
|
||||
Return<bool> setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) override;
|
||||
Return<bool> setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode,
|
||||
V1_0::IGnss::GnssPositionRecurrence recurrence,
|
||||
uint32_t minIntervalMs, uint32_t preferredAccuracyMeters,
|
||||
uint32_t preferredTimeMs, bool lowPowerMode) override;
|
||||
Return<sp<V1_1::IGnssConfiguration>> getExtensionGnssConfiguration_1_1() override;
|
||||
Return<sp<V1_1::IGnssMeasurement>> getExtensionGnssMeasurement_1_1() override;
|
||||
Return<bool> injectBestLocation(const V1_0::GnssLocation& location) override;
|
||||
|
||||
// Methods from V2_0::IGnss follow.
|
||||
Return<bool> setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) override;
|
||||
Return<sp<V2_0::IGnssConfiguration>> getExtensionGnssConfiguration_2_0() override;
|
||||
Return<sp<V2_0::IGnssDebug>> getExtensionGnssDebug_2_0() override;
|
||||
Return<sp<V2_0::IAGnss>> getExtensionAGnss_2_0() override;
|
||||
Return<sp<V2_0::IAGnssRil>> getExtensionAGnssRil_2_0() override;
|
||||
Return<sp<V2_0::IGnssMeasurement>> getExtensionGnssMeasurement_2_0() override;
|
||||
Return<sp<measurement_corrections::V1_0::IMeasurementCorrections>>
|
||||
getExtensionMeasurementCorrections() override;
|
||||
Return<sp<visibility_control::V1_0::IGnssVisibilityControl>> getExtensionVisibilityControl()
|
||||
override;
|
||||
Return<sp<V2_0::IGnssBatching>> getExtensionGnssBatching_2_0() override;
|
||||
Return<bool> injectBestLocation_2_0(const V2_0::GnssLocation& location) override;
|
||||
|
||||
// Methods from V2_1::IGnss follow.
|
||||
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;
|
||||
Return<sp<V2_1::IGnssAntennaInfo>> getExtensionGnssAntennaInfo() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<V2_0::GnssLocation> getLocationFromHW();
|
||||
void reportLocation(const V2_0::GnssLocation&) const;
|
||||
void reportLocation(const V1_0::GnssLocation&) const;
|
||||
void reportSvStatus(const hidl_vec<GnssSvInfo>&) const;
|
||||
|
||||
static sp<V2_1::IGnssCallback> sGnssCallback_2_1;
|
||||
static sp<V2_0::IGnssCallback> sGnssCallback_2_0;
|
||||
static sp<V1_1::IGnssCallback> sGnssCallback_1_1;
|
||||
static sp<V1_0::IGnssCallback> sGnssCallback_1_0;
|
||||
|
||||
std::atomic<long> mMinIntervalMs;
|
||||
sp<GnssConfiguration> mGnssConfiguration;
|
||||
std::atomic<bool> mIsActive;
|
||||
std::atomic<bool> mHardwareModeOn;
|
||||
std::atomic<int> mGnssFd;
|
||||
std::thread mThread;
|
||||
|
||||
mutable std::mutex mMutex;
|
||||
hidl_vec<GnssSvInfo> filterBlacklistedSatellitesV2_1(hidl_vec<GnssSvInfo> gnssSvInfoList);
|
||||
};
|
||||
|
||||
template <class T_IGnss>
|
||||
sp<V2_1::IGnssCallback> GnssTemplate<T_IGnss>::sGnssCallback_2_1 = nullptr;
|
||||
template <class T_IGnss>
|
||||
sp<V2_0::IGnssCallback> GnssTemplate<T_IGnss>::sGnssCallback_2_0 = nullptr;
|
||||
template <class T_IGnss>
|
||||
sp<V1_1::IGnssCallback> GnssTemplate<T_IGnss>::sGnssCallback_1_1 = nullptr;
|
||||
template <class T_IGnss>
|
||||
sp<V1_0::IGnssCallback> GnssTemplate<T_IGnss>::sGnssCallback_1_0 = nullptr;
|
||||
|
||||
template <class T_IGnss>
|
||||
GnssTemplate<T_IGnss>::GnssTemplate()
|
||||
: mMinIntervalMs(1000),
|
||||
mGnssConfiguration{new GnssConfiguration()},
|
||||
mHardwareModeOn(false),
|
||||
mGnssFd(-1) {}
|
||||
|
||||
Gnss::~Gnss() {
|
||||
template <class T_IGnss>
|
||||
GnssTemplate<T_IGnss>::~GnssTemplate() {
|
||||
stop();
|
||||
}
|
||||
|
||||
std::unique_ptr<V2_0::GnssLocation> Gnss::getLocationFromHW() {
|
||||
template <class T_IGnss>
|
||||
std::unique_ptr<V2_0::GnssLocation> GnssTemplate<T_IGnss>::getLocationFromHW() {
|
||||
char inputBuffer[INPUT_BUFFER_SIZE];
|
||||
mHardwareModeOn = false;
|
||||
if (mGnssFd == -1) {
|
||||
@@ -89,7 +194,8 @@ std::unique_ptr<V2_0::GnssLocation> Gnss::getLocationFromHW() {
|
||||
return NmeaFixInfo::getLocationFromInputStr(inputStr);
|
||||
}
|
||||
|
||||
Return<bool> Gnss::start() {
|
||||
template <class T_IGnss>
|
||||
Return<bool> GnssTemplate<T_IGnss>::start() {
|
||||
if (mIsActive) {
|
||||
ALOGW("Gnss has started. Restarting...");
|
||||
stop();
|
||||
@@ -124,7 +230,9 @@ Return<bool> Gnss::start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
hidl_vec<GnssSvInfo> Gnss::filterBlacklistedSatellitesV2_1(hidl_vec<GnssSvInfo> gnssSvInfoList) {
|
||||
template <class T_IGnss>
|
||||
hidl_vec<GnssSvInfo> GnssTemplate<T_IGnss>::filterBlacklistedSatellitesV2_1(
|
||||
hidl_vec<GnssSvInfo> gnssSvInfoList) {
|
||||
for (uint32_t i = 0; i < gnssSvInfoList.size(); i++) {
|
||||
if (mGnssConfiguration->isBlacklistedV2_1(gnssSvInfoList[i])) {
|
||||
gnssSvInfoList[i].v2_0.v1_0.svFlag &=
|
||||
@@ -134,7 +242,8 @@ hidl_vec<GnssSvInfo> Gnss::filterBlacklistedSatellitesV2_1(hidl_vec<GnssSvInfo>
|
||||
return gnssSvInfoList;
|
||||
}
|
||||
|
||||
Return<bool> Gnss::stop() {
|
||||
template <class T_IGnss>
|
||||
Return<bool> GnssTemplate<T_IGnss>::stop() {
|
||||
ALOGD("stop");
|
||||
mIsActive = false;
|
||||
if (mThread.joinable()) {
|
||||
@@ -148,7 +257,8 @@ Return<bool> Gnss::stop() {
|
||||
}
|
||||
|
||||
// Methods from V1_0::IGnss follow.
|
||||
Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>& callback) {
|
||||
template <class T_IGnss>
|
||||
Return<bool> GnssTemplate<T_IGnss>::setCallback(const sp<V1_0::IGnssCallback>& callback) {
|
||||
if (callback == nullptr) {
|
||||
ALOGE("%s: Null callback ignored", __func__);
|
||||
return false;
|
||||
@@ -163,7 +273,7 @@ Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>& callback) {
|
||||
ALOGE("%s: Unable to invoke callback", __func__);
|
||||
}
|
||||
|
||||
IGnssCallback::GnssSystemInfo gnssInfo = {.yearOfHw = 2018};
|
||||
V2_1::IGnssCallback::GnssSystemInfo gnssInfo = {.yearOfHw = 2018};
|
||||
|
||||
ret = sGnssCallback_1_0->gnssSetSystemInfoCb(gnssInfo);
|
||||
if (!ret.isOk()) {
|
||||
@@ -173,83 +283,100 @@ Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>& callback) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Return<void> Gnss::cleanup() {
|
||||
template <class T_IGnss>
|
||||
Return<void> GnssTemplate<T_IGnss>::cleanup() {
|
||||
sGnssCallback_2_1 = nullptr;
|
||||
sGnssCallback_2_0 = nullptr;
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<bool> Gnss::injectTime(int64_t, int64_t, int32_t) {
|
||||
template <class T_IGnss>
|
||||
Return<bool> GnssTemplate<T_IGnss>::injectTime(int64_t, int64_t, int32_t) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Return<bool> Gnss::injectLocation(double, double, float) {
|
||||
template <class T_IGnss>
|
||||
Return<bool> GnssTemplate<T_IGnss>::injectLocation(double, double, float) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData) {
|
||||
template <class T_IGnss>
|
||||
Return<void> GnssTemplate<T_IGnss>::deleteAidingData(V1_0::IGnss::GnssAidingData) {
|
||||
// TODO implement
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<bool> Gnss::setPositionMode(V1_0::IGnss::GnssPositionMode,
|
||||
V1_0::IGnss::GnssPositionRecurrence, uint32_t minIntervalMs,
|
||||
uint32_t, uint32_t) {
|
||||
template <class T_IGnss>
|
||||
Return<bool> GnssTemplate<T_IGnss>::setPositionMode(V1_0::IGnss::GnssPositionMode,
|
||||
V1_0::IGnss::GnssPositionRecurrence,
|
||||
uint32_t minIntervalMs, uint32_t, uint32_t) {
|
||||
mMinIntervalMs = minIntervalMs;
|
||||
return true;
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V1_0::IAGnssRil>> GnssTemplate<T_IGnss>::getExtensionAGnssRil() {
|
||||
// TODO implement
|
||||
return ::android::sp<V1_0::IAGnssRil>{};
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssGeofencing>> Gnss::getExtensionGnssGeofencing() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V1_0::IGnssGeofencing>> GnssTemplate<T_IGnss>::getExtensionGnssGeofencing() {
|
||||
// TODO implement
|
||||
return ::android::sp<V1_0::IGnssGeofencing>{};
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IAGnss>> Gnss::getExtensionAGnss() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V1_0::IAGnss>> GnssTemplate<T_IGnss>::getExtensionAGnss() {
|
||||
// TODO implement
|
||||
return ::android::sp<V1_0::IAGnss>{};
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssNi>> Gnss::getExtensionGnssNi() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V1_0::IGnssNi>> GnssTemplate<T_IGnss>::getExtensionGnssNi() {
|
||||
// TODO implement
|
||||
return ::android::sp<V1_0::IGnssNi>{};
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V1_0::IGnssMeasurement>> GnssTemplate<T_IGnss>::getExtensionGnssMeasurement() {
|
||||
ALOGD("Gnss::getExtensionGnssMeasurement");
|
||||
return new GnssMeasurement();
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssNavigationMessage>> Gnss::getExtensionGnssNavigationMessage() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V1_0::IGnssNavigationMessage>>
|
||||
GnssTemplate<T_IGnss>::getExtensionGnssNavigationMessage() {
|
||||
// TODO implement
|
||||
return ::android::sp<V1_0::IGnssNavigationMessage>{};
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssXtra>> Gnss::getExtensionXtra() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V1_0::IGnssXtra>> GnssTemplate<T_IGnss>::getExtensionXtra() {
|
||||
// TODO implement
|
||||
return ::android::sp<V1_0::IGnssXtra>{};
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V1_0::IGnssConfiguration>> GnssTemplate<T_IGnss>::getExtensionGnssConfiguration() {
|
||||
// TODO implement
|
||||
return ::android::sp<V1_0::IGnssConfiguration>{};
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssDebug>> Gnss::getExtensionGnssDebug() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V1_0::IGnssDebug>> GnssTemplate<T_IGnss>::getExtensionGnssDebug() {
|
||||
return new V1_1::implementation::GnssDebug();
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssBatching>> Gnss::getExtensionGnssBatching() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V1_0::IGnssBatching>> GnssTemplate<T_IGnss>::getExtensionGnssBatching() {
|
||||
// TODO implement
|
||||
return ::android::sp<V1_0::IGnssBatching>{};
|
||||
}
|
||||
|
||||
// Methods from V1_1::IGnss follow.
|
||||
Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
|
||||
template <class T_IGnss>
|
||||
Return<bool> GnssTemplate<T_IGnss>::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
|
||||
if (callback == nullptr) {
|
||||
ALOGE("%s: Null callback ignored", __func__);
|
||||
return false;
|
||||
@@ -263,7 +390,7 @@ Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
|
||||
ALOGE("%s: Unable to invoke callback", __func__);
|
||||
}
|
||||
|
||||
IGnssCallback::GnssSystemInfo gnssInfo = {.yearOfHw = 2018};
|
||||
V2_1::IGnssCallback::GnssSystemInfo gnssInfo = {.yearOfHw = 2018};
|
||||
|
||||
ret = sGnssCallback_1_1->gnssSetSystemInfoCb(gnssInfo);
|
||||
if (!ret.isOk()) {
|
||||
@@ -279,29 +406,35 @@ Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Return<bool> Gnss::setPositionMode_1_1(V1_0::IGnss::GnssPositionMode,
|
||||
V1_0::IGnss::GnssPositionRecurrence, uint32_t minIntervalMs,
|
||||
uint32_t, uint32_t, bool) {
|
||||
template <class T_IGnss>
|
||||
Return<bool> GnssTemplate<T_IGnss>::setPositionMode_1_1(V1_0::IGnss::GnssPositionMode,
|
||||
V1_0::IGnss::GnssPositionRecurrence,
|
||||
uint32_t minIntervalMs, uint32_t, uint32_t,
|
||||
bool) {
|
||||
mMinIntervalMs = minIntervalMs;
|
||||
return true;
|
||||
}
|
||||
|
||||
Return<sp<V1_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_1_1() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V1_1::IGnssConfiguration>> GnssTemplate<T_IGnss>::getExtensionGnssConfiguration_1_1() {
|
||||
// TODO implement
|
||||
return ::android::sp<V1_1::IGnssConfiguration>{};
|
||||
}
|
||||
|
||||
Return<sp<V1_1::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_1_1() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V1_1::IGnssMeasurement>> GnssTemplate<T_IGnss>::getExtensionGnssMeasurement_1_1() {
|
||||
// TODO implement
|
||||
return ::android::sp<V1_1::IGnssMeasurement>{};
|
||||
}
|
||||
|
||||
Return<bool> Gnss::injectBestLocation(const V1_0::GnssLocation&) {
|
||||
template <class T_IGnss>
|
||||
Return<bool> GnssTemplate<T_IGnss>::injectBestLocation(const V1_0::GnssLocation&) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Methods from V2_0::IGnss follow.
|
||||
Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
|
||||
template <class T_IGnss>
|
||||
Return<bool> GnssTemplate<T_IGnss>::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
|
||||
ALOGD("Gnss::setCallback_2_0");
|
||||
if (callback == nullptr) {
|
||||
ALOGE("%s: Null callback ignored", __func__);
|
||||
@@ -334,54 +467,65 @@ Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Return<sp<V2_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_2_0() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V2_0::IGnssConfiguration>> GnssTemplate<T_IGnss>::getExtensionGnssConfiguration_2_0() {
|
||||
ALOGD("Gnss::getExtensionGnssConfiguration_2_0");
|
||||
return mGnssConfiguration;
|
||||
}
|
||||
|
||||
Return<sp<V2_0::IGnssDebug>> Gnss::getExtensionGnssDebug_2_0() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V2_0::IGnssDebug>> GnssTemplate<T_IGnss>::getExtensionGnssDebug_2_0() {
|
||||
// TODO implement
|
||||
return ::android::sp<V2_0::IGnssDebug>{};
|
||||
}
|
||||
|
||||
Return<sp<V2_0::IAGnss>> Gnss::getExtensionAGnss_2_0() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V2_0::IAGnss>> GnssTemplate<T_IGnss>::getExtensionAGnss_2_0() {
|
||||
// TODO implement
|
||||
return ::android::sp<V2_0::IAGnss>{};
|
||||
}
|
||||
|
||||
Return<sp<V2_0::IAGnssRil>> Gnss::getExtensionAGnssRil_2_0() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V2_0::IAGnssRil>> GnssTemplate<T_IGnss>::getExtensionAGnssRil_2_0() {
|
||||
// TODO implement
|
||||
return ::android::sp<V2_0::IAGnssRil>{};
|
||||
}
|
||||
|
||||
Return<sp<V2_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_0() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V2_0::IGnssMeasurement>> GnssTemplate<T_IGnss>::getExtensionGnssMeasurement_2_0() {
|
||||
ALOGD("Gnss::getExtensionGnssMeasurement_2_0");
|
||||
return new GnssMeasurement();
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
Return<sp<measurement_corrections::V1_0::IMeasurementCorrections>>
|
||||
Gnss::getExtensionMeasurementCorrections() {
|
||||
GnssTemplate<T_IGnss>::getExtensionMeasurementCorrections() {
|
||||
ALOGD("Gnss::getExtensionMeasurementCorrections()");
|
||||
return new GnssMeasurementCorrections();
|
||||
}
|
||||
|
||||
Return<sp<visibility_control::V1_0::IGnssVisibilityControl>> Gnss::getExtensionVisibilityControl() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<visibility_control::V1_0::IGnssVisibilityControl>>
|
||||
GnssTemplate<T_IGnss>::getExtensionVisibilityControl() {
|
||||
// TODO implement
|
||||
return ::android::sp<visibility_control::V1_0::IGnssVisibilityControl>{};
|
||||
}
|
||||
|
||||
Return<sp<V2_0::IGnssBatching>> Gnss::getExtensionGnssBatching_2_0() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V2_0::IGnssBatching>> GnssTemplate<T_IGnss>::getExtensionGnssBatching_2_0() {
|
||||
// TODO implement
|
||||
return ::android::sp<V2_0::IGnssBatching>{};
|
||||
}
|
||||
|
||||
Return<bool> Gnss::injectBestLocation_2_0(const V2_0::GnssLocation&) {
|
||||
template <class T_IGnss>
|
||||
Return<bool> GnssTemplate<T_IGnss>::injectBestLocation_2_0(const V2_0::GnssLocation&) {
|
||||
// TODO(b/124012850): Implement function.
|
||||
return bool{};
|
||||
}
|
||||
|
||||
// Methods from V2_1::IGnss follow.
|
||||
Return<bool> Gnss::setCallback_2_1(const sp<V2_1::IGnssCallback>& callback) {
|
||||
template <class T_IGnss>
|
||||
Return<bool> GnssTemplate<T_IGnss>::setCallback_2_1(const sp<V2_1::IGnssCallback>& callback) {
|
||||
ALOGD("Gnss::setCallback_2_1");
|
||||
if (callback == nullptr) {
|
||||
ALOGE("%s: Null callback ignored", __func__);
|
||||
@@ -415,28 +559,33 @@ Return<bool> Gnss::setCallback_2_1(const sp<V2_1::IGnssCallback>& callback) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Return<sp<V2_1::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_1() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V2_1::IGnssMeasurement>> GnssTemplate<T_IGnss>::getExtensionGnssMeasurement_2_1() {
|
||||
ALOGD("Gnss::getExtensionGnssMeasurement_2_1");
|
||||
return new GnssMeasurement();
|
||||
}
|
||||
|
||||
Return<sp<V2_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_2_1() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V2_1::IGnssConfiguration>> GnssTemplate<T_IGnss>::getExtensionGnssConfiguration_2_1() {
|
||||
ALOGD("Gnss::getExtensionGnssConfiguration_2_1");
|
||||
return mGnssConfiguration;
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
Return<sp<measurement_corrections::V1_1::IMeasurementCorrections>>
|
||||
Gnss::getExtensionMeasurementCorrections_1_1() {
|
||||
GnssTemplate<T_IGnss>::getExtensionMeasurementCorrections_1_1() {
|
||||
ALOGD("Gnss::getExtensionMeasurementCorrections_1_1()");
|
||||
return new GnssMeasurementCorrections();
|
||||
}
|
||||
|
||||
Return<sp<V2_1::IGnssAntennaInfo>> Gnss::getExtensionGnssAntennaInfo() {
|
||||
template <class T_IGnss>
|
||||
Return<sp<V2_1::IGnssAntennaInfo>> GnssTemplate<T_IGnss>::getExtensionGnssAntennaInfo() {
|
||||
ALOGD("Gnss::getExtensionGnssAntennaInfo");
|
||||
return new GnssAntennaInfo();
|
||||
}
|
||||
|
||||
void Gnss::reportSvStatus(const hidl_vec<GnssSvInfo>& svInfoList) const {
|
||||
template <class T_IGnss>
|
||||
void GnssTemplate<T_IGnss>::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
|
||||
if (sGnssCallback_2_1 == nullptr) {
|
||||
@@ -449,7 +598,8 @@ void Gnss::reportSvStatus(const hidl_vec<GnssSvInfo>& svInfoList) const {
|
||||
}
|
||||
}
|
||||
|
||||
void Gnss::reportLocation(const V1_0::GnssLocation& location) const {
|
||||
template <class T_IGnss>
|
||||
void GnssTemplate<T_IGnss>::reportLocation(const V1_0::GnssLocation& location) const {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
if (sGnssCallback_1_1 != nullptr) {
|
||||
auto ret = sGnssCallback_1_1->gnssLocationCb(location);
|
||||
@@ -468,7 +618,8 @@ void Gnss::reportLocation(const V1_0::GnssLocation& location) const {
|
||||
}
|
||||
}
|
||||
|
||||
void Gnss::reportLocation(const V2_0::GnssLocation& location) const {
|
||||
template <class T_IGnss>
|
||||
void GnssTemplate<T_IGnss>::reportLocation(const V2_0::GnssLocation& location) const {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
if (sGnssCallback_2_1 != nullptr) {
|
||||
auto ret = sGnssCallback_2_1->gnssLocationCb_2_0(location);
|
||||
@@ -487,8 +638,4 @@ void Gnss::reportLocation(const V2_0::GnssLocation& location) const {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_1
|
||||
} // namespace gnss
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace android::hardware::gnss::common::implementation
|
||||
@@ -16,18 +16,14 @@
|
||||
|
||||
#define LOG_TAG "GnssAntennaInfo"
|
||||
|
||||
#include "GnssAntennaInfo.h"
|
||||
#include "v2_1/GnssAntennaInfo.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#include <log/log.h>
|
||||
|
||||
using ::android::hardware::gnss::common::Utils;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace gnss {
|
||||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
namespace android::hardware::gnss::V2_1::implementation {
|
||||
|
||||
sp<IGnssAntennaInfoCallback> GnssAntennaInfo::sCallback = nullptr;
|
||||
|
||||
@@ -102,8 +98,4 @@ void GnssAntennaInfo::reportAntennaInfo(
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_1
|
||||
} // namespace gnss
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace android::hardware::gnss::V2_1::implementation
|
||||
@@ -16,14 +16,10 @@
|
||||
|
||||
#define LOG_TAG "GnssConfiguration"
|
||||
|
||||
#include "GnssConfiguration.h"
|
||||
#include "v2_1/GnssConfiguration.h"
|
||||
#include <log/log.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace gnss {
|
||||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
namespace android::hardware::gnss::V2_1::implementation {
|
||||
|
||||
// Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow.
|
||||
Return<bool> GnssConfiguration::setSuplEs(bool enable) {
|
||||
@@ -99,8 +95,4 @@ Return<bool> GnssConfiguration::isBlacklistedV2_1(const GnssSvInfoV2_1& gnssSvIn
|
||||
return (mBlacklistedSourceSet.find(source) != mBlacklistedSourceSet.end());
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_1
|
||||
} // namespace gnss
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace android::hardware::gnss::V2_1::implementation
|
||||
@@ -19,15 +19,11 @@
|
||||
#include <log/log.h>
|
||||
|
||||
#include "Constants.h"
|
||||
#include "GnssDebug.h"
|
||||
#include "v2_1/GnssDebug.h"
|
||||
|
||||
using namespace ::android::hardware::gnss::common;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace gnss {
|
||||
namespace V1_1 {
|
||||
namespace implementation {
|
||||
namespace android::hardware::gnss::V1_1::implementation {
|
||||
|
||||
// Methods from ::android::hardware::gnss::V1_0::IGnssDebug follow.
|
||||
Return<void> GnssDebug::getDebugData(V1_0::IGnssDebug::getDebugData_cb _hidl_cb) {
|
||||
@@ -55,8 +51,4 @@ Return<void> GnssDebug::getDebugData(V1_0::IGnssDebug::getDebugData_cb _hidl_cb)
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_1
|
||||
} // namespace gnss
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace android::hardware::gnss::V1_1::implementation
|
||||
@@ -16,19 +16,14 @@
|
||||
|
||||
#define LOG_TAG "GnssMeasurement"
|
||||
|
||||
#include "GnssMeasurement.h"
|
||||
#include "v2_1/GnssMeasurement.h"
|
||||
#include <log/log.h>
|
||||
#include "Utils.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace gnss {
|
||||
namespace android::hardware::gnss::V2_1::implementation {
|
||||
|
||||
using common::Utils;
|
||||
|
||||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
|
||||
sp<V2_1::IGnssMeasurementCallback> GnssMeasurement::sCallback_2_1 = nullptr;
|
||||
sp<V2_0::IGnssMeasurementCallback> GnssMeasurement::sCallback_2_0 = nullptr;
|
||||
|
||||
@@ -145,8 +140,4 @@ void GnssMeasurement::reportMeasurement(const GnssDataV2_1& data) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_1
|
||||
} // namespace gnss
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace android::hardware::gnss::V2_1::implementation
|
||||
@@ -16,15 +16,14 @@
|
||||
|
||||
#define LOG_TAG "GnssMeasurementCorrections"
|
||||
|
||||
#include "GnssMeasurementCorrections.h"
|
||||
#include "v2_1/GnssMeasurementCorrections.h"
|
||||
#include <log/log.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace gnss {
|
||||
namespace measurement_corrections {
|
||||
namespace V1_1 {
|
||||
namespace implementation {
|
||||
namespace android::hardware::gnss::measurement_corrections::V1_1::implementation {
|
||||
|
||||
GnssMeasurementCorrections::GnssMeasurementCorrections() {}
|
||||
|
||||
GnssMeasurementCorrections::~GnssMeasurementCorrections() {}
|
||||
|
||||
// Methods from V1_0::IMeasurementCorrections follow.
|
||||
Return<bool> GnssMeasurementCorrections::setCorrections(
|
||||
@@ -101,9 +100,4 @@ Return<bool> GnssMeasurementCorrections::setCorrections_1_1(
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_1
|
||||
} // namespace measurement_corrections
|
||||
} // namespace gnss
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace android::hardware::gnss::measurement_corrections::V1_1::implementation
|
||||
@@ -25,11 +25,14 @@ cc_library_static {
|
||||
],
|
||||
srcs: [
|
||||
"Utils.cpp",
|
||||
"v2_1/GnssCallback.cpp",
|
||||
],
|
||||
export_include_dirs: ["include"],
|
||||
shared_libs: [
|
||||
"android.hardware.gnss@1.0",
|
||||
"android.hardware.gnss@1.1",
|
||||
"android.hardware.gnss@2.0",
|
||||
"android.hardware.gnss@2.1",
|
||||
"android.hardware.gnss.measurement_corrections@1.0",
|
||||
"android.hardware.gnss.measurement_corrections@1.1",
|
||||
],
|
||||
|
||||
107
gnss/common/utils/vts/include/v2_1/GnssCallback.h
Normal file
107
gnss/common/utils/vts/include/v2_1/GnssCallback.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <android/hardware/gnss/2.1/IGnss.h>
|
||||
#include "GnssCallbackEventQueue.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using android::hardware::hidl_vec;
|
||||
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 GnssLocation_1_0 = android::hardware::gnss::V1_0::GnssLocation;
|
||||
using GnssLocation_2_0 = android::hardware::gnss::V2_0::GnssLocation;
|
||||
|
||||
using IGnssCallback_1_0 = android::hardware::gnss::V1_0::IGnssCallback;
|
||||
using IGnssCallback_2_0 = android::hardware::gnss::V2_0::IGnssCallback;
|
||||
using IGnssCallback_2_1 = android::hardware::gnss::V2_1::IGnssCallback;
|
||||
|
||||
using IGnssMeasurementCallback_1_0 = android::hardware::gnss::V1_0::IGnssMeasurementCallback;
|
||||
using IGnssMeasurementCallback_1_1 = android::hardware::gnss::V1_1::IGnssMeasurementCallback;
|
||||
using IGnssMeasurementCallback_2_0 = android::hardware::gnss::V2_0::IGnssMeasurementCallback;
|
||||
using IGnssMeasurementCallback_2_1 = android::hardware::gnss::V2_1::IGnssMeasurementCallback;
|
||||
|
||||
using android::sp;
|
||||
|
||||
#define TIMEOUT_SEC 2 // for basic commands/responses
|
||||
|
||||
namespace android::hardware::gnss::common {
|
||||
|
||||
/* Callback class for data & Event. */
|
||||
class GnssCallback : public IGnssCallback_2_1 {
|
||||
public:
|
||||
IGnssCallback_1_0::GnssSystemInfo last_info_;
|
||||
android::hardware::hidl_string last_name_;
|
||||
uint32_t last_capabilities_;
|
||||
GnssLocation_2_0 last_location_;
|
||||
|
||||
GnssCallbackEventQueue<IGnssCallback_1_0::GnssSystemInfo> info_cbq_;
|
||||
GnssCallbackEventQueue<android::hardware::hidl_string> name_cbq_;
|
||||
GnssCallbackEventQueue<uint32_t> capabilities_cbq_;
|
||||
GnssCallbackEventQueue<GnssLocation_2_0> location_cbq_;
|
||||
GnssCallbackEventQueue<hidl_vec<IGnssCallback_2_1::GnssSvInfo>> sv_info_list_cbq_;
|
||||
|
||||
GnssCallback();
|
||||
virtual ~GnssCallback() = default;
|
||||
|
||||
// Dummy callback handlers
|
||||
Return<void> gnssStatusCb(const IGnssCallback_1_0::GnssStatusValue /* status */) override {
|
||||
return Void();
|
||||
}
|
||||
Return<void> gnssNmeaCb(int64_t /* timestamp */,
|
||||
const android::hardware::hidl_string& /* nmea */) override {
|
||||
return Void();
|
||||
}
|
||||
Return<void> gnssAcquireWakelockCb() override { return Void(); }
|
||||
Return<void> gnssReleaseWakelockCb() override { return Void(); }
|
||||
Return<void> gnssRequestLocationCb(bool /* independentFromGnss */) override { return Void(); }
|
||||
Return<void> gnssRequestTimeCb() override { return Void(); }
|
||||
// Actual (test) callback handlers
|
||||
Return<void> gnssNameCb(const android::hardware::hidl_string& name) override;
|
||||
Return<void> gnssLocationCb(const GnssLocation_1_0& location) override;
|
||||
Return<void> gnssSetCapabilitesCb(uint32_t capabilities) override;
|
||||
Return<void> gnssSetSystemInfoCb(const IGnssCallback_1_0::GnssSystemInfo& info) override;
|
||||
Return<void> gnssSvStatusCb(const IGnssCallback_1_0::GnssSvStatus& svStatus) override;
|
||||
|
||||
// New in v2.0
|
||||
Return<void> gnssLocationCb_2_0(const GnssLocation_2_0& location) override;
|
||||
Return<void> gnssRequestLocationCb_2_0(bool /* independentFromGnss */,
|
||||
bool /* isUserEmergency */) override {
|
||||
return Void();
|
||||
}
|
||||
Return<void> gnssSetCapabilitiesCb_2_0(uint32_t capabilities) override;
|
||||
Return<void> gnssSvStatusCb_2_0(const hidl_vec<IGnssCallback_2_0::GnssSvInfo>&) override {
|
||||
return Void();
|
||||
}
|
||||
|
||||
// New in v2.1
|
||||
Return<void> gnssSvStatusCb_2_1(
|
||||
const hidl_vec<IGnssCallback_2_1::GnssSvInfo>& svInfoList) override;
|
||||
Return<void> gnssSetCapabilitiesCb_2_1(uint32_t capabilities) override;
|
||||
|
||||
private:
|
||||
Return<void> gnssLocationCbImpl(const GnssLocation_2_0& location);
|
||||
};
|
||||
|
||||
} // namespace android::hardware::gnss::common
|
||||
381
gnss/common/utils/vts/include/v2_1/gnss_hal_test_template.h
Normal file
381
gnss/common/utils/vts/include/v2_1/gnss_hal_test_template.h
Normal file
@@ -0,0 +1,381 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GnssCallbackEventQueue.h"
|
||||
#include "Utils.h"
|
||||
#include "v2_1/GnssCallback.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <chrono>
|
||||
|
||||
using ::android::hardware::gnss::common::Utils;
|
||||
|
||||
using android::hardware::hidl_vec;
|
||||
using android::hardware::Return;
|
||||
using android::hardware::Void;
|
||||
|
||||
using android::hardware::gnss::common::GnssCallback;
|
||||
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::IGnssAntennaInfo;
|
||||
using android::hardware::gnss::V2_1::IGnssAntennaInfoCallback;
|
||||
|
||||
using GnssLocation_1_0 = android::hardware::gnss::V1_0::GnssLocation;
|
||||
using GnssLocation_2_0 = android::hardware::gnss::V2_0::GnssLocation;
|
||||
|
||||
using IGnssCallback_1_0 = android::hardware::gnss::V1_0::IGnssCallback;
|
||||
using IGnssCallback_2_0 = android::hardware::gnss::V2_0::IGnssCallback;
|
||||
using IGnssCallback_2_1 = android::hardware::gnss::V2_1::IGnssCallback;
|
||||
|
||||
using IGnssMeasurementCallback_1_0 = android::hardware::gnss::V1_0::IGnssMeasurementCallback;
|
||||
using IGnssMeasurementCallback_1_1 = android::hardware::gnss::V1_1::IGnssMeasurementCallback;
|
||||
using IGnssMeasurementCallback_2_0 = android::hardware::gnss::V2_0::IGnssMeasurementCallback;
|
||||
using IGnssMeasurementCallback_2_1 = android::hardware::gnss::V2_1::IGnssMeasurementCallback;
|
||||
|
||||
using android::sp;
|
||||
|
||||
#define TIMEOUT_SEC 2 // for basic commands/responses
|
||||
|
||||
// The main test class for GNSS HAL.
|
||||
template <class T_IGnss>
|
||||
class GnssHalTestTemplate : public testing::TestWithParam<std::string> {
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
|
||||
virtual void TearDown() override;
|
||||
|
||||
/* Callback class for GnssMeasurement. */
|
||||
class GnssMeasurementCallback : public IGnssMeasurementCallback_2_1 {
|
||||
public:
|
||||
GnssCallbackEventQueue<IGnssMeasurementCallback_2_1::GnssData> measurement_cbq_;
|
||||
|
||||
GnssMeasurementCallback() : measurement_cbq_("measurement"){};
|
||||
virtual ~GnssMeasurementCallback() = default;
|
||||
|
||||
// Methods from V1_0::IGnssMeasurementCallback follow.
|
||||
Return<void> GnssMeasurementCb(const IGnssMeasurementCallback_1_0::GnssData&) override {
|
||||
return Void();
|
||||
}
|
||||
|
||||
// Methods from V1_1::IGnssMeasurementCallback follow.
|
||||
Return<void> gnssMeasurementCb(const IGnssMeasurementCallback_1_1::GnssData&) override {
|
||||
return Void();
|
||||
}
|
||||
|
||||
// Methods from V2_0::IGnssMeasurementCallback follow.
|
||||
Return<void> gnssMeasurementCb_2_0(const IGnssMeasurementCallback_2_0::GnssData&) override {
|
||||
return Void();
|
||||
}
|
||||
|
||||
// Methods from V2_1::IGnssMeasurementCallback follow.
|
||||
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;
|
||||
};
|
||||
|
||||
/* Callback class for GnssAntennaInfo. */
|
||||
class GnssAntennaInfoCallback : public IGnssAntennaInfoCallback {
|
||||
public:
|
||||
GnssCallbackEventQueue<hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>>
|
||||
antenna_info_cbq_;
|
||||
|
||||
GnssAntennaInfoCallback() : antenna_info_cbq_("info"){};
|
||||
virtual ~GnssAntennaInfoCallback() = default;
|
||||
|
||||
// Methods from V2_1::GnssAntennaInfoCallback follow.
|
||||
Return<void> gnssAntennaInfoCb(
|
||||
const hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& gnssAntennaInfos);
|
||||
};
|
||||
|
||||
/*
|
||||
* SetUpGnssCallback:
|
||||
* Set GnssCallback and verify the result.
|
||||
*/
|
||||
void SetUpGnssCallback();
|
||||
|
||||
/*
|
||||
* StartAndCheckFirstLocation:
|
||||
* Helper function to start location, and check the first one.
|
||||
*
|
||||
* <p> Note this leaves the Location request active, to enable Stop call vs. other call
|
||||
* reordering tests.
|
||||
*
|
||||
* returns true if a location was successfully generated
|
||||
*/
|
||||
bool StartAndCheckFirstLocation();
|
||||
|
||||
/*
|
||||
* CheckLocation:
|
||||
* Helper function to vet Location fields
|
||||
*
|
||||
* check_speed: true if speed related fields are also verified.
|
||||
*/
|
||||
void CheckLocation(const GnssLocation_2_0& location, const bool check_speed);
|
||||
|
||||
/*
|
||||
* StartAndCheckLocations:
|
||||
* Helper function to collect, and check a number of
|
||||
* normal ~1Hz locations.
|
||||
*
|
||||
* Note this leaves the Location request active, to enable Stop call vs. other call
|
||||
* reordering tests.
|
||||
*/
|
||||
void StartAndCheckLocations(int count);
|
||||
|
||||
/*
|
||||
* StopAndClearLocations:
|
||||
* Helper function to stop locations, and clear any remaining notifications
|
||||
*/
|
||||
void StopAndClearLocations();
|
||||
|
||||
/*
|
||||
* SetPositionMode:
|
||||
* Helper function to set positioning mode and verify output
|
||||
*/
|
||||
void SetPositionMode(const int min_interval_msec, const bool low_power_mode);
|
||||
|
||||
/*
|
||||
* startLocationAndGetNonGpsConstellation:
|
||||
* 1. Start location
|
||||
* 2. Find and return first non-GPS constellation
|
||||
*
|
||||
* Note that location is not stopped in this method. The client should call
|
||||
* StopAndClearLocations() after the call.
|
||||
*/
|
||||
GnssConstellationType startLocationAndGetNonGpsConstellation(
|
||||
const int locations_to_await, const int gnss_sv_info_list_timeout);
|
||||
|
||||
sp<T_IGnss> gnss_hal_; // GNSS HAL to call into
|
||||
sp<GnssCallback> gnss_cb_; // Primary callback interface
|
||||
};
|
||||
|
||||
using ::android::hardware::gnss::common::Utils;
|
||||
|
||||
// Implementations for the main test class for GNSS HAL
|
||||
template <class T_IGnss>
|
||||
void GnssHalTestTemplate<T_IGnss>::SetUp() {
|
||||
gnss_hal_ = T_IGnss::getService(GetParam());
|
||||
ASSERT_NE(gnss_hal_, nullptr);
|
||||
|
||||
SetUpGnssCallback();
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
void GnssHalTestTemplate<T_IGnss>::TearDown() {
|
||||
if (gnss_hal_ != nullptr) {
|
||||
gnss_hal_->cleanup();
|
||||
gnss_hal_ = nullptr;
|
||||
}
|
||||
|
||||
// Set to nullptr to destruct the callback event queues and warn of any unprocessed events.
|
||||
gnss_cb_ = nullptr;
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
void GnssHalTestTemplate<T_IGnss>::SetUpGnssCallback() {
|
||||
gnss_cb_ = new GnssCallback();
|
||||
ASSERT_NE(gnss_cb_, nullptr);
|
||||
|
||||
auto result = gnss_hal_->setCallback_2_1(gnss_cb_);
|
||||
if (!result.isOk()) {
|
||||
ALOGE("result of failed setCallback %s", result.description().c_str());
|
||||
}
|
||||
|
||||
ASSERT_TRUE(result.isOk());
|
||||
ASSERT_TRUE(result);
|
||||
|
||||
/*
|
||||
* All capabilities, name and systemInfo callbacks should trigger
|
||||
*/
|
||||
EXPECT_TRUE(gnss_cb_->capabilities_cbq_.retrieve(gnss_cb_->last_capabilities_, TIMEOUT_SEC));
|
||||
EXPECT_TRUE(gnss_cb_->info_cbq_.retrieve(gnss_cb_->last_info_, TIMEOUT_SEC));
|
||||
EXPECT_TRUE(gnss_cb_->name_cbq_.retrieve(gnss_cb_->last_name_, TIMEOUT_SEC));
|
||||
|
||||
EXPECT_EQ(gnss_cb_->capabilities_cbq_.calledCount(), 1);
|
||||
EXPECT_EQ(gnss_cb_->info_cbq_.calledCount(), 1);
|
||||
EXPECT_EQ(gnss_cb_->name_cbq_.calledCount(), 1);
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
void GnssHalTestTemplate<T_IGnss>::StopAndClearLocations() {
|
||||
const auto result = gnss_hal_->stop();
|
||||
|
||||
EXPECT_TRUE(result.isOk());
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
/*
|
||||
* Clear notify/waiting counter, allowing up till the timeout after
|
||||
* the last reply for final startup messages to arrive (esp. system
|
||||
* info.)
|
||||
*/
|
||||
while (gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_, TIMEOUT_SEC)) {
|
||||
}
|
||||
gnss_cb_->location_cbq_.reset();
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
void GnssHalTestTemplate<T_IGnss>::SetPositionMode(const int min_interval_msec,
|
||||
const bool low_power_mode) {
|
||||
const int kPreferredAccuracy = 0; // Ideally perfect (matches GnssLocationProvider)
|
||||
const int kPreferredTimeMsec = 0; // Ideally immediate
|
||||
|
||||
const auto result = gnss_hal_->setPositionMode_1_1(
|
||||
T_IGnss::GnssPositionMode::MS_BASED,
|
||||
T_IGnss::GnssPositionRecurrence::RECURRENCE_PERIODIC, min_interval_msec,
|
||||
kPreferredAccuracy, kPreferredTimeMsec, low_power_mode);
|
||||
|
||||
ASSERT_TRUE(result.isOk());
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
bool GnssHalTestTemplate<T_IGnss>::StartAndCheckFirstLocation() {
|
||||
const auto result = gnss_hal_->start();
|
||||
|
||||
EXPECT_TRUE(result.isOk());
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
/*
|
||||
* GnssLocationProvider support of AGPS SUPL & XtraDownloader is not available in VTS,
|
||||
* so allow time to demodulate ephemeris over the air.
|
||||
*/
|
||||
const int kFirstGnssLocationTimeoutSeconds = 75;
|
||||
|
||||
EXPECT_TRUE(gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_,
|
||||
kFirstGnssLocationTimeoutSeconds));
|
||||
int locationCalledCount = gnss_cb_->location_cbq_.calledCount();
|
||||
EXPECT_EQ(locationCalledCount, 1);
|
||||
|
||||
if (locationCalledCount > 0) {
|
||||
// don't require speed on first fix
|
||||
CheckLocation(gnss_cb_->last_location_, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
void GnssHalTestTemplate<T_IGnss>::CheckLocation(const GnssLocation_2_0& location,
|
||||
bool check_speed) {
|
||||
const bool check_more_accuracies =
|
||||
(gnss_cb_->info_cbq_.calledCount() > 0 && gnss_cb_->last_info_.yearOfHw >= 2017);
|
||||
|
||||
Utils::checkLocation(location.v1_0, check_speed, check_more_accuracies);
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
void GnssHalTestTemplate<T_IGnss>::StartAndCheckLocations(int count) {
|
||||
const int kMinIntervalMsec = 500;
|
||||
const int kLocationTimeoutSubsequentSec = 2;
|
||||
const bool kLowPowerMode = false;
|
||||
|
||||
SetPositionMode(kMinIntervalMsec, kLowPowerMode);
|
||||
|
||||
EXPECT_TRUE(StartAndCheckFirstLocation());
|
||||
|
||||
for (int i = 1; i < count; i++) {
|
||||
EXPECT_TRUE(gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_,
|
||||
kLocationTimeoutSubsequentSec));
|
||||
int locationCalledCount = gnss_cb_->location_cbq_.calledCount();
|
||||
EXPECT_EQ(locationCalledCount, i + 1);
|
||||
// Don't cause confusion by checking details if no location yet
|
||||
if (locationCalledCount > 0) {
|
||||
// Should be more than 1 location by now, but if not, still don't check first fix speed
|
||||
CheckLocation(gnss_cb_->last_location_, locationCalledCount > 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
GnssConstellationType GnssHalTestTemplate<T_IGnss>::startLocationAndGetNonGpsConstellation(
|
||||
const int locations_to_await, const int gnss_sv_info_list_timeout) {
|
||||
gnss_cb_->location_cbq_.reset();
|
||||
StartAndCheckLocations(locations_to_await);
|
||||
const int location_called_count = gnss_cb_->location_cbq_.calledCount();
|
||||
|
||||
// Tolerate 1 less sv status to handle edge cases in reporting.
|
||||
int sv_info_list_cbq_size = gnss_cb_->sv_info_list_cbq_.size();
|
||||
EXPECT_GE(sv_info_list_cbq_size + 1, locations_to_await);
|
||||
ALOGD("Observed %d GnssSvInfo, while awaiting %d Locations (%d received)",
|
||||
sv_info_list_cbq_size, locations_to_await, location_called_count);
|
||||
|
||||
// Find first non-GPS constellation to blacklist
|
||||
GnssConstellationType constellation_to_blacklist = GnssConstellationType::UNKNOWN;
|
||||
for (int i = 0; i < sv_info_list_cbq_size; ++i) {
|
||||
hidl_vec<IGnssCallback_2_1::GnssSvInfo> sv_info_vec;
|
||||
gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_vec, gnss_sv_info_list_timeout);
|
||||
for (uint32_t iSv = 0; iSv < sv_info_vec.size(); iSv++) {
|
||||
const auto& gnss_sv = sv_info_vec[iSv];
|
||||
if ((gnss_sv.v2_0.v1_0.svFlag & IGnssCallback_1_0::GnssSvFlags::USED_IN_FIX) &&
|
||||
(gnss_sv.v2_0.constellation != GnssConstellationType::UNKNOWN) &&
|
||||
(gnss_sv.v2_0.constellation != GnssConstellationType::GPS)) {
|
||||
// found a non-GPS constellation
|
||||
constellation_to_blacklist = gnss_sv.v2_0.constellation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (constellation_to_blacklist != GnssConstellationType::UNKNOWN) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (constellation_to_blacklist == GnssConstellationType::UNKNOWN) {
|
||||
ALOGI("No non-GPS constellations found, constellation blacklist test less effective.");
|
||||
// Proceed functionally to blacklist something.
|
||||
constellation_to_blacklist = GnssConstellationType::GLONASS;
|
||||
}
|
||||
|
||||
return constellation_to_blacklist;
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
Return<void> GnssHalTestTemplate<T_IGnss>::GnssMeasurementCallback::gnssMeasurementCb_2_1(
|
||||
const IGnssMeasurementCallback_2_1::GnssData& data) {
|
||||
ALOGD("GnssMeasurement v2.1 received. Size = %d", (int)data.measurements.size());
|
||||
measurement_cbq_.store(data);
|
||||
return Void();
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
Return<void> GnssHalTestTemplate<T_IGnss>::GnssMeasurementCorrectionsCallback::setCapabilitiesCb(
|
||||
uint32_t capabilities) {
|
||||
ALOGI("GnssMeasurementCorrectionsCallback capabilities received %d", capabilities);
|
||||
capabilities_cbq_.store(capabilities);
|
||||
return Void();
|
||||
}
|
||||
|
||||
template <class T_IGnss>
|
||||
Return<void> GnssHalTestTemplate<T_IGnss>::GnssAntennaInfoCallback::gnssAntennaInfoCb(
|
||||
const hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& gnssAntennaInfos) {
|
||||
ALOGD("GnssAntennaInfo v2.1 received. Size = %d", (int)gnssAntennaInfos.size());
|
||||
antenna_info_cbq_.store(gnssAntennaInfos);
|
||||
return Void();
|
||||
}
|
||||
95
gnss/common/utils/vts/v2_1/GnssCallback.cpp
Normal file
95
gnss/common/utils/vts/v2_1/GnssCallback.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "GnssCallback"
|
||||
|
||||
#include "v2_1/GnssCallback.h"
|
||||
#include <chrono>
|
||||
#include "Utils.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using ::android::hardware::gnss::common::Utils;
|
||||
|
||||
namespace android::hardware::gnss::common {
|
||||
|
||||
GnssCallback::GnssCallback()
|
||||
: info_cbq_("system_info"),
|
||||
name_cbq_("name"),
|
||||
capabilities_cbq_("capabilities"),
|
||||
location_cbq_("location"),
|
||||
sv_info_list_cbq_("sv_info") {}
|
||||
|
||||
Return<void> GnssCallback::gnssSetSystemInfoCb(const IGnssCallback_1_0::GnssSystemInfo& info) {
|
||||
ALOGI("Info received, year %d", info.yearOfHw);
|
||||
info_cbq_.store(info);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssCallback::gnssSetCapabilitesCb(uint32_t capabilities) {
|
||||
ALOGI("Capabilities received %d", capabilities);
|
||||
capabilities_cbq_.store(capabilities);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssCallback::gnssSetCapabilitiesCb_2_0(uint32_t capabilities) {
|
||||
ALOGI("Capabilities (v2.0) received %d", capabilities);
|
||||
capabilities_cbq_.store(capabilities);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssCallback::gnssSetCapabilitiesCb_2_1(uint32_t capabilities) {
|
||||
ALOGI("Capabilities (v2.1) received %d", capabilities);
|
||||
capabilities_cbq_.store(capabilities);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssCallback::gnssNameCb(const android::hardware::hidl_string& name) {
|
||||
ALOGI("Name received: %s", name.c_str());
|
||||
name_cbq_.store(name);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssCallback::gnssLocationCb(const GnssLocation_1_0& location) {
|
||||
ALOGI("Location received");
|
||||
GnssLocation_2_0 location_v2_0;
|
||||
location_v2_0.v1_0 = location;
|
||||
return gnssLocationCbImpl(location_v2_0);
|
||||
}
|
||||
|
||||
Return<void> GnssCallback::gnssLocationCb_2_0(const GnssLocation_2_0& location) {
|
||||
ALOGI("Location (v2.0) received");
|
||||
return gnssLocationCbImpl(location);
|
||||
}
|
||||
|
||||
Return<void> GnssCallback::gnssLocationCbImpl(const GnssLocation_2_0& location) {
|
||||
location_cbq_.store(location);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssCallback::gnssSvStatusCb(const IGnssCallback_1_0::GnssSvStatus&) {
|
||||
ALOGI("gnssSvStatusCb");
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> GnssCallback::gnssSvStatusCb_2_1(
|
||||
const hidl_vec<IGnssCallback::GnssSvInfo>& svInfoList) {
|
||||
ALOGI("gnssSvStatusCb_2_1. Size = %d", (int)svInfoList.size());
|
||||
sv_info_list_cbq_.store(svInfoList);
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace android::hardware::gnss::common
|
||||
@@ -12,8 +12,8 @@ hidl_interface {
|
||||
],
|
||||
interfaces: [
|
||||
"android.hardware.gnss.measurement_corrections@1.0",
|
||||
"android.hardware.gnss@2.0",
|
||||
"android.hardware.gnss@1.0",
|
||||
"android.hardware.gnss@2.0",
|
||||
"android.hidl.base@1.0",
|
||||
],
|
||||
gen_java: true,
|
||||
|
||||
Reference in New Issue
Block a user