Report mock locations in 2.0 default implementation
- Create android.hardware.gnss@common-default-lib for sharing common
default implementation code.
- Create android.hardware.gnss@common-vts-lib for sharing common VTS
code.
Bug: 121217686
Change-Id: I35c127c23d97ab9a5c6ee13b36fbfe9c3708e3f3
Fixes: 121217686
Test: tested on cuttlefish
diff --git a/gnss/1.1/default/Android.bp b/gnss/1.1/default/Android.bp
index 44aed2b..8c3aac4 100644
--- a/gnss/1.1/default/Android.bp
+++ b/gnss/1.1/default/Android.bp
@@ -18,4 +18,7 @@
"android.hardware.gnss@1.1",
"android.hardware.gnss@1.0",
],
+ static_libs: [
+ "android.hardware.gnss@common-default-lib",
+ ],
}
diff --git a/gnss/1.1/default/Gnss.cpp b/gnss/1.1/default/Gnss.cpp
index bbf1cd3..4abe707 100644
--- a/gnss/1.1/default/Gnss.cpp
+++ b/gnss/1.1/default/Gnss.cpp
@@ -4,9 +4,9 @@
#include <log/log.h>
#include "Gnss.h"
-#include "GnssConstants.h"
#include "GnssDebug.h"
#include "GnssMeasurement.h"
+#include "Utils.h"
namespace android {
namespace hardware {
@@ -14,6 +14,7 @@
namespace V1_1 {
namespace implementation {
+using ::android::hardware::gnss::common::Utils;
using GnssSvFlags = IGnssCallback::GnssSvFlags;
const uint32_t MIN_INTERVAL_MILLIS = 100;
@@ -43,7 +44,7 @@
auto svStatus = this->getMockSvStatus();
this->reportSvStatus(svStatus);
- auto location = this->getMockLocation();
+ auto location = Utils::getMockLocation();
this->reportLocation(location);
std::this_thread::sleep_for(std::chrono::milliseconds(mMinIntervalMs));
@@ -193,44 +194,17 @@
return true;
}
-Return<GnssLocation> Gnss::getMockLocation() const {
- GnssLocation location = {.gnssLocationFlags = 0xFF,
- .latitudeDegrees = kMockLatitudeDegrees,
- .longitudeDegrees = kMockLongitudeDegrees,
- .altitudeMeters = kMockAltitudeMeters,
- .speedMetersPerSec = kMockSpeedMetersPerSec,
- .bearingDegrees = kMockBearingDegrees,
- .horizontalAccuracyMeters = kMockHorizontalAccuracyMeters,
- .verticalAccuracyMeters = kMockVerticalAccuracyMeters,
- .speedAccuracyMetersPerSecond = kMockSpeedAccuracyMetersPerSecond,
- .bearingAccuracyDegrees = kMockBearingAccuracyDegrees,
- .timestamp = kMockTimestamp};
- return location;
-}
-
-Return<GnssSvInfo> Gnss::getSvInfo(int16_t svid, GnssConstellationType type, float cN0DbHz,
- float elevationDegrees, float azimuthDegrees) const {
- GnssSvInfo svInfo = {.svid = svid,
- .constellation = type,
- .cN0Dbhz = cN0DbHz,
- .elevationDegrees = elevationDegrees,
- .azimuthDegrees = azimuthDegrees,
- .svFlag = GnssSvFlags::USED_IN_FIX | GnssSvFlags::HAS_EPHEMERIS_DATA |
- GnssSvFlags::HAS_ALMANAC_DATA};
- return svInfo;
-}
-
Return<GnssSvStatus> Gnss::getMockSvStatus() const {
std::unique_lock<std::recursive_mutex> lock(mGnssConfiguration->getMutex());
GnssSvInfo mockGnssSvInfoList[] = {
- getSvInfo(3, GnssConstellationType::GPS, 32.5, 59.1, 166.5),
- getSvInfo(5, GnssConstellationType::GPS, 27.0, 29.0, 56.5),
- getSvInfo(17, GnssConstellationType::GPS, 30.5, 71.0, 77.0),
- getSvInfo(26, GnssConstellationType::GPS, 24.1, 28.0, 253.0),
- getSvInfo(5, GnssConstellationType::GLONASS, 20.5, 11.5, 116.0),
- getSvInfo(17, GnssConstellationType::GLONASS, 21.5, 28.5, 186.0),
- getSvInfo(18, GnssConstellationType::GLONASS, 28.3, 38.8, 69.0),
- getSvInfo(10, GnssConstellationType::GLONASS, 25.0, 66.0, 247.0)};
+ Utils::getSvInfo(3, GnssConstellationType::GPS, 32.5, 59.1, 166.5),
+ Utils::getSvInfo(5, GnssConstellationType::GPS, 27.0, 29.0, 56.5),
+ Utils::getSvInfo(17, GnssConstellationType::GPS, 30.5, 71.0, 77.0),
+ Utils::getSvInfo(26, GnssConstellationType::GPS, 24.1, 28.0, 253.0),
+ Utils::getSvInfo(5, GnssConstellationType::GLONASS, 20.5, 11.5, 116.0),
+ Utils::getSvInfo(17, GnssConstellationType::GLONASS, 21.5, 28.5, 186.0),
+ Utils::getSvInfo(18, GnssConstellationType::GLONASS, 28.3, 38.8, 69.0),
+ Utils::getSvInfo(10, GnssConstellationType::GLONASS, 25.0, 66.0, 247.0)};
GnssSvStatus svStatus = {.numSvs = sizeof(mockGnssSvInfoList) / sizeof(GnssSvInfo)};
for (uint32_t i = 0; i < svStatus.numSvs; i++) {
diff --git a/gnss/1.1/default/Gnss.h b/gnss/1.1/default/Gnss.h
index 99af34c..21b66a2 100644
--- a/gnss/1.1/default/Gnss.h
+++ b/gnss/1.1/default/Gnss.h
@@ -84,10 +84,7 @@
// Methods from ::android::hidl::base::V1_0::IBase follow.
private:
- Return<GnssLocation> getMockLocation() const;
Return<GnssSvStatus> getMockSvStatus() const;
- Return<GnssSvInfo> getSvInfo(int16_t svid, GnssConstellationType type, float cN0DbHz,
- float elevationDegress, float azimuthDegress) const;
Return<void> reportLocation(const GnssLocation&) const;
Return<void> reportSvStatus(const GnssSvStatus&) const;
diff --git a/gnss/1.1/default/GnssConstants.h b/gnss/1.1/default/GnssConstants.h
deleted file mode 100644
index 9ce1a12..0000000
--- a/gnss/1.1/default/GnssConstants.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-#ifndef android_hardware_gnss_V1_1_GnssConstants_H_
-#define android_hardware_gnss_V1_1_GnssConstants_H_
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-const float kMockLatitudeDegrees = 37.4219999;
-const float kMockLongitudeDegrees = -122.0840575;
-const float kMockAltitudeMeters = 1.60062531;
-const float kMockSpeedMetersPerSec = 0;
-const float kMockBearingDegrees = 0;
-const float kMockHorizontalAccuracyMeters = 5;
-const float kMockVerticalAccuracyMeters = 5;
-const float kMockSpeedAccuracyMetersPerSecond = 1;
-const float kMockBearingAccuracyDegrees = 90;
-const int64_t kMockTimestamp = 1519930775453L;
-
-} // namespace implementation
-} // namespace V1_1
-} // namespace gnss
-} // namespace hardware
-} // namespace android
-
-#endif // android_hardware_gnss_V1_1_GnssConstants_H_
diff --git a/gnss/1.1/default/GnssDebug.cpp b/gnss/1.1/default/GnssDebug.cpp
index 62870e4..471ed24 100644
--- a/gnss/1.1/default/GnssDebug.cpp
+++ b/gnss/1.1/default/GnssDebug.cpp
@@ -18,9 +18,11 @@
#include <log/log.h>
-#include "GnssConstants.h"
+#include "Constants.h"
#include "GnssDebug.h"
+using namespace ::android::hardware::gnss::common;
+
namespace android {
namespace hardware {
namespace gnss {