summaryrefslogtreecommitdiff
path: root/gnss/aidl/default
diff options
context:
space:
mode:
Diffstat (limited to 'gnss/aidl/default')
-rw-r--r--gnss/aidl/default/Android.bp3
-rw-r--r--gnss/aidl/default/Gnss.cpp39
-rw-r--r--gnss/aidl/default/Gnss.h9
-rw-r--r--gnss/aidl/default/GnssAntennaInfo.cpp149
-rw-r--r--gnss/aidl/default/GnssAntennaInfo.h51
-rw-r--r--gnss/aidl/default/MeasurementCorrectionsInterface.cpp68
-rw-r--r--gnss/aidl/default/MeasurementCorrectionsInterface.h36
7 files changed, 352 insertions, 3 deletions
diff --git a/gnss/aidl/default/Android.bp b/gnss/aidl/default/Android.bp
index 29c26d16ec..3be7fb929e 100644
--- a/gnss/aidl/default/Android.bp
+++ b/gnss/aidl/default/Android.bp
@@ -52,12 +52,12 @@ cc_binary {
"android.hardware.gnss.measurement_corrections@1.1",
"android.hardware.gnss.measurement_corrections@1.0",
"android.hardware.gnss.visibility_control@1.0",
- "android.hardware.gnss.visibility_control-V1-ndk",
"android.hardware.gnss-V2-ndk",
],
srcs: [
"AGnss.cpp",
"Gnss.cpp",
+ "GnssAntennaInfo.cpp",
"GnssBatching.cpp",
"GnssDebug.cpp",
"GnssGeofence.cpp",
@@ -68,6 +68,7 @@ cc_binary {
"GnssConfiguration.cpp",
"GnssMeasurementInterface.cpp",
"GnssVisibilityControl.cpp",
+ "MeasurementCorrectionsInterface.cpp",
"service.cpp",
],
static_libs: [
diff --git a/gnss/aidl/default/Gnss.cpp b/gnss/aidl/default/Gnss.cpp
index e296351d95..c11a99ae9b 100644
--- a/gnss/aidl/default/Gnss.cpp
+++ b/gnss/aidl/default/Gnss.cpp
@@ -20,6 +20,8 @@
#include <inttypes.h>
#include <log/log.h>
#include "AGnss.h"
+#include "DeviceFileReader.h"
+#include "GnssAntennaInfo.h"
#include "GnssBatching.h"
#include "GnssConfiguration.h"
#include "GnssDebug.h"
@@ -28,10 +30,14 @@
#include "GnssNavigationMessageInterface.h"
#include "GnssPsds.h"
#include "GnssVisibilityControl.h"
+#include "MeasurementCorrectionsInterface.h"
+#include "NmeaFixInfo.h"
#include "Utils.h"
namespace aidl::android::hardware::gnss {
+using ::android::hardware::gnss::common::NmeaFixInfo;
using ::android::hardware::gnss::common::Utils;
+
using ndk::ScopedAStatus;
using GnssSvInfo = IGnssCallback::GnssSvInfo;
@@ -62,6 +68,12 @@ ScopedAStatus Gnss::setCallback(const std::shared_ptr<IGnssCallback>& callback)
return ScopedAStatus::ok();
}
+std::unique_ptr<GnssLocation> Gnss::getLocationFromHW() {
+ std::string inputStr =
+ ::android::hardware::gnss::common::DeviceFileReader::Instance().getLocationData();
+ return ::android::hardware::gnss::common::NmeaFixInfo::getAidlLocationFromInputStr(inputStr);
+}
+
ScopedAStatus Gnss::start() {
ALOGD("start()");
if (mIsActive) {
@@ -82,9 +94,14 @@ ScopedAStatus Gnss::start() {
auto svStatus = filterBlocklistedSatellites(Utils::getMockSvInfoList());
this->reportSvStatus(svStatus);
+ auto currentLocation = getLocationFromHW();
mGnssPowerIndication->notePowerConsumption();
- const auto location = Utils::getMockLocation();
- this->reportLocation(location);
+ if (currentLocation != nullptr) {
+ this->reportLocation(*currentLocation);
+ } else {
+ const auto location = Utils::getMockLocation();
+ this->reportLocation(location);
+ }
std::this_thread::sleep_for(std::chrono::milliseconds(mMinIntervalMs));
}
});
@@ -264,4 +281,22 @@ ndk::ScopedAStatus Gnss::getExtensionGnssVisibilityControl(
return ndk::ScopedAStatus::ok();
}
+ndk::ScopedAStatus Gnss::getExtensionGnssAntennaInfo(
+ std::shared_ptr<IGnssAntennaInfo>* iGnssAntennaInfo) {
+ ALOGD("Gnss::getExtensionGnssAntennaInfo");
+
+ *iGnssAntennaInfo = SharedRefBase::make<GnssAntennaInfo>();
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus Gnss::getExtensionMeasurementCorrections(
+ std::shared_ptr<measurement_corrections::IMeasurementCorrectionsInterface>*
+ iMeasurementCorrections) {
+ ALOGD("Gnss::getExtensionMeasurementCorrections");
+
+ *iMeasurementCorrections =
+ SharedRefBase::make<measurement_corrections::MeasurementCorrectionsInterface>();
+ return ndk::ScopedAStatus::ok();
+}
+
} // namespace aidl::android::hardware::gnss
diff --git a/gnss/aidl/default/Gnss.h b/gnss/aidl/default/Gnss.h
index 384c8629a2..478dc94e4d 100644
--- a/gnss/aidl/default/Gnss.h
+++ b/gnss/aidl/default/Gnss.h
@@ -18,12 +18,14 @@
#include <aidl/android/hardware/gnss/BnAGnss.h>
#include <aidl/android/hardware/gnss/BnGnss.h>
+#include <aidl/android/hardware/gnss/BnGnssAntennaInfo.h>
#include <aidl/android/hardware/gnss/BnGnssBatching.h>
#include <aidl/android/hardware/gnss/BnGnssConfiguration.h>
#include <aidl/android/hardware/gnss/BnGnssDebug.h>
#include <aidl/android/hardware/gnss/BnGnssMeasurementInterface.h>
#include <aidl/android/hardware/gnss/BnGnssPowerIndication.h>
#include <aidl/android/hardware/gnss/BnGnssPsds.h>
+#include <aidl/android/hardware/gnss/measurement_corrections/BnMeasurementCorrectionsInterface.h>
#include <aidl/android/hardware/gnss/visibility_control/BnGnssVisibilityControl.h>
#include <atomic>
#include <mutex>
@@ -69,6 +71,12 @@ class Gnss : public BnGnss {
ndk::ScopedAStatus getExtensionGnssVisibilityControl(
std::shared_ptr<android::hardware::gnss::visibility_control::IGnssVisibilityControl>*
iGnssVisibilityControl) override;
+ ndk::ScopedAStatus getExtensionGnssAntennaInfo(
+ std::shared_ptr<IGnssAntennaInfo>* iGnssAntennaInfo) override;
+ ndk::ScopedAStatus getExtensionMeasurementCorrections(
+ std::shared_ptr<android::hardware::gnss::measurement_corrections::
+ IMeasurementCorrectionsInterface>* iMeasurementCorrections)
+ override;
std::shared_ptr<GnssConfiguration> mGnssConfiguration;
std::shared_ptr<GnssPowerIndication> mGnssPowerIndication;
@@ -79,6 +87,7 @@ class Gnss : public BnGnss {
std::vector<IGnssCallback::GnssSvInfo> filterBlocklistedSatellites(
std::vector<IGnssCallback::GnssSvInfo> gnssSvInfoList);
void reportGnssStatusValue(const IGnssCallback::GnssStatusValue gnssStatusValue) const;
+ std::unique_ptr<GnssLocation> getLocationFromHW();
static std::shared_ptr<IGnssCallback> sGnssCallback;
diff --git a/gnss/aidl/default/GnssAntennaInfo.cpp b/gnss/aidl/default/GnssAntennaInfo.cpp
new file mode 100644
index 0000000000..72def716de
--- /dev/null
+++ b/gnss/aidl/default/GnssAntennaInfo.cpp
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2021 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 "GnssAntennaInfoAidl"
+
+#include "GnssAntennaInfo.h"
+#include <aidl/android/hardware/gnss/BnGnss.h>
+#include <log/log.h>
+#include "Utils.h"
+
+namespace aidl::android::hardware::gnss {
+
+using namespace ::android::hardware::gnss;
+using Row = IGnssAntennaInfoCallback::Row;
+using Coord = IGnssAntennaInfoCallback::Coord;
+
+std::shared_ptr<IGnssAntennaInfoCallback> GnssAntennaInfo::sCallback = nullptr;
+
+GnssAntennaInfo::GnssAntennaInfo() : mMinIntervalMs(1000) {}
+
+GnssAntennaInfo::~GnssAntennaInfo() {
+ stop();
+}
+
+// Methods from ::android::hardware::gnss::V2_1::IGnssAntennaInfo follow.
+ndk::ScopedAStatus GnssAntennaInfo::setCallback(
+ const std::shared_ptr<IGnssAntennaInfoCallback>& callback) {
+ ALOGD("setCallback");
+ std::unique_lock<std::mutex> lock(mMutex);
+ sCallback = callback;
+
+ if (mIsActive) {
+ ALOGW("GnssAntennaInfo callback already set. Resetting the callback...");
+ stop();
+ }
+ start();
+
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus GnssAntennaInfo::close() {
+ ALOGD("close");
+ stop();
+ std::unique_lock<std::mutex> lock(mMutex);
+ sCallback = nullptr;
+ return ndk::ScopedAStatus::ok();
+}
+
+void GnssAntennaInfo::start() {
+ ALOGD("start");
+ mIsActive = true;
+ mThread = std::thread([this]() {
+ while (mIsActive == true) {
+ if (sCallback != nullptr) {
+ IGnssAntennaInfoCallback::GnssAntennaInfo mockAntennaInfo_1 = {
+ .carrierFrequencyHz = 1575420000,
+ .phaseCenterOffsetCoordinateMillimeters = Coord{.x = 1,
+ .xUncertainty = 0.1,
+ .y = 2,
+ .yUncertainty = 0.1,
+ .z = 3,
+ .zUncertainty = 0.1},
+ .phaseCenterVariationCorrectionMillimeters =
+ {
+ Row{std::vector<double>{1, -1, 5, -2, 3, -1}},
+ Row{std::vector<double>{-2, 3, 2, 0, 1, 2}},
+ Row{std::vector<double>{1, 3, 2, -1, -3, 5}},
+ },
+ .phaseCenterVariationCorrectionUncertaintyMillimeters =
+ {
+ Row{std::vector<double>{0.1, 0.2, 0.4, 0.1, 0.2, 0.3}},
+ Row{std::vector<double>{0.3, 0.2, 0.3, 0.6, 0.1, 0.1}},
+ Row{std::vector<double>{0.1, 0.1, 0.4, 0.2, 0.5, 0.3}},
+ },
+ .signalGainCorrectionDbi =
+ {
+ Row{std::vector<double>{2, -3, 1, -3, 0, -4}},
+ Row{std::vector<double>{1, 0, -4, 1, 3, -2}},
+ Row{std::vector<double>{3, -2, 0, -2, 3, 0}},
+ },
+ .signalGainCorrectionUncertaintyDbi =
+ {
+ Row{std::vector<double>{0.3, 0.1, 0.2, 0.6, 0.1, 0.3}},
+ Row{std::vector<double>{0.1, 0.1, 0.5, 0.2, 0.3, 0.1}},
+ Row{std::vector<double>{0.2, 0.4, 0.2, 0.1, 0.1, 0.2}},
+ },
+ };
+
+ IGnssAntennaInfoCallback::GnssAntennaInfo mockAntennaInfo_2 = {
+ .carrierFrequencyHz = 1176450000,
+ .phaseCenterOffsetCoordinateMillimeters = Coord{.x = 5,
+ .xUncertainty = 0.1,
+ .y = 6,
+ .yUncertainty = 0.1,
+ .z = 7,
+ .zUncertainty = 0.1},
+ };
+
+ std::vector<IGnssAntennaInfoCallback::GnssAntennaInfo> mockAntennaInfos = {
+ mockAntennaInfo_1,
+ mockAntennaInfo_2,
+ };
+ this->reportAntennaInfo(mockAntennaInfos);
+ }
+
+ /** For mock implementation this is good. On real device, we should only report
+ antennaInfo at start and when there is a configuration change. **/
+ std::this_thread::sleep_for(std::chrono::milliseconds(mMinIntervalMs));
+ }
+ });
+}
+
+void GnssAntennaInfo::stop() {
+ ALOGD("stop");
+ mIsActive = false;
+ if (mThread.joinable()) {
+ mThread.join();
+ }
+}
+
+void GnssAntennaInfo::reportAntennaInfo(
+ const std::vector<IGnssAntennaInfoCallback::GnssAntennaInfo>& antennaInfo) const {
+ std::unique_lock<std::mutex> lock(mMutex);
+
+ if (sCallback == nullptr) {
+ ALOGE("%s: No non-null callback", __func__);
+ return;
+ }
+
+ auto ret = sCallback->gnssAntennaInfoCb(antennaInfo);
+ if (!ret.isOk()) {
+ ALOGE("%s: Unable to invoke callback", __func__);
+ }
+}
+
+} // namespace aidl::android::hardware::gnss
diff --git a/gnss/aidl/default/GnssAntennaInfo.h b/gnss/aidl/default/GnssAntennaInfo.h
new file mode 100644
index 0000000000..2cf7b1366b
--- /dev/null
+++ b/gnss/aidl/default/GnssAntennaInfo.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2021 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 <aidl/android/hardware/gnss/BnGnssAntennaInfo.h>
+#include <atomic>
+#include <mutex>
+#include <thread>
+
+namespace aidl::android::hardware::gnss {
+
+struct GnssAntennaInfo : public BnGnssAntennaInfo {
+ public:
+ GnssAntennaInfo();
+ ~GnssAntennaInfo();
+ ndk::ScopedAStatus setCallback(
+ const std::shared_ptr<IGnssAntennaInfoCallback>& callback) override;
+ ndk::ScopedAStatus close() override;
+
+ private:
+ void start();
+ void stop();
+ void reportAntennaInfo(
+ const std::vector<IGnssAntennaInfoCallback::GnssAntennaInfo>& antennaInfo) const;
+
+ // Guarded by mMutex
+ static std::shared_ptr<IGnssAntennaInfoCallback> sCallback;
+
+ std::atomic<bool> mIsActive;
+ std::atomic<long> mMinIntervalMs;
+ std::thread mThread;
+
+ // Synchronization lock for sCallback
+ mutable std::mutex mMutex;
+};
+
+} // namespace aidl::android::hardware::gnss
diff --git a/gnss/aidl/default/MeasurementCorrectionsInterface.cpp b/gnss/aidl/default/MeasurementCorrectionsInterface.cpp
new file mode 100644
index 0000000000..0f1851cafe
--- /dev/null
+++ b/gnss/aidl/default/MeasurementCorrectionsInterface.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2021 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 "MeasurementCorrectionsInterface"
+
+#include "MeasurementCorrectionsInterface.h"
+#include <inttypes.h>
+#include <log/log.h>
+
+namespace aidl::android::hardware::gnss::measurement_corrections {
+
+std::shared_ptr<IMeasurementCorrectionsCallback> MeasurementCorrectionsInterface::sCallback =
+ nullptr;
+
+ndk::ScopedAStatus MeasurementCorrectionsInterface::setCorrections(
+ const MeasurementCorrections& corrections) {
+ ALOGD("setCorrections");
+ ALOGD("corrections = lat: %f, lng: %f, alt: %f, hUnc: %f, vUnc: %f, toa: %llu, "
+ "satCorrections.size: %d",
+ corrections.latitudeDegrees, corrections.longitudeDegrees, corrections.altitudeMeters,
+ corrections.horizontalPositionUncertaintyMeters,
+ corrections.verticalPositionUncertaintyMeters,
+ static_cast<unsigned long long>(corrections.toaGpsNanosecondsOfWeek),
+ static_cast<int>(corrections.satCorrections.size()));
+ for (auto singleSatCorrection : corrections.satCorrections) {
+ ALOGD("singleSatCorrection = flags: %d, constellation: %d, svid: %d"
+ ", cfHz: %" PRId64 ", probLos: %f, epl: %f, eplUnc: %f",
+ singleSatCorrection.singleSatCorrectionFlags, singleSatCorrection.constellation,
+ singleSatCorrection.svid, singleSatCorrection.carrierFrequencyHz,
+ singleSatCorrection.probSatIsLos, singleSatCorrection.excessPathLengthMeters,
+ singleSatCorrection.excessPathLengthUncertaintyMeters);
+ ALOGD("reflecting plane = lat: %f, lng: %f, alt: %f, azm: %f",
+ singleSatCorrection.reflectingPlane.latitudeDegrees,
+ singleSatCorrection.reflectingPlane.longitudeDegrees,
+ singleSatCorrection.reflectingPlane.altitudeMeters,
+ singleSatCorrection.reflectingPlane.azimuthDegrees);
+ }
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus MeasurementCorrectionsInterface::setCallback(
+ const std::shared_ptr<IMeasurementCorrectionsCallback>& callback) {
+ ALOGD("MeasurementCorrections::setCallback");
+ std::unique_lock<std::mutex> lock(mMutex);
+ sCallback = callback;
+ auto ret = sCallback->setCapabilitiesCb(
+ IMeasurementCorrectionsCallback::CAPABILITY_LOS_SATS |
+ IMeasurementCorrectionsCallback::CAPABILITY_EXCESS_PATH_LENGTH |
+ IMeasurementCorrectionsCallback::CAPABILITY_REFLECTING_PLANE);
+ if (!ret.isOk()) {
+ ALOGE("%s: Unable to invoke callback", __func__);
+ }
+ return ndk::ScopedAStatus::ok();
+}
+} // namespace aidl::android::hardware::gnss::measurement_corrections
diff --git a/gnss/aidl/default/MeasurementCorrectionsInterface.h b/gnss/aidl/default/MeasurementCorrectionsInterface.h
new file mode 100644
index 0000000000..af58725050
--- /dev/null
+++ b/gnss/aidl/default/MeasurementCorrectionsInterface.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 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 <aidl/android/hardware/gnss/measurement_corrections/BnMeasurementCorrectionsInterface.h>
+
+namespace aidl::android::hardware::gnss::measurement_corrections {
+
+struct MeasurementCorrectionsInterface : public BnMeasurementCorrectionsInterface {
+ public:
+ ndk::ScopedAStatus setCorrections(const MeasurementCorrections& corrections) override;
+ ndk::ScopedAStatus setCallback(
+ const std::shared_ptr<IMeasurementCorrectionsCallback>& callback) override;
+
+ private:
+ // Synchronization lock for sCallback
+ mutable std::mutex mMutex;
+ // Guarded by mMutex
+ static std::shared_ptr<IMeasurementCorrectionsCallback> sCallback;
+};
+
+} // namespace aidl::android::hardware::gnss::measurement_corrections