Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a509861a authored by Yu-Han Yang's avatar Yu-Han Yang
Browse files

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
parent e50086a2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -18,4 +18,7 @@ cc_binary {
        "android.hardware.gnss@1.1",
        "android.hardware.gnss@1.0",
    ],
    static_libs: [
        "android.hardware.gnss@common-default-lib",
    ],
}
+11 −37
Original line number Diff line number Diff line
@@ -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 gnss {
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 @@ Return<bool> Gnss::start() {
            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<bool> Gnss::injectBestLocation(const GnssLocation&) {
    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++) {
+0 −3
Original line number Diff line number Diff line
@@ -84,10 +84,7 @@ struct Gnss : public IGnss {

    // 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;

+3 −1
Original line number Diff line number Diff line
@@ -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 {
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ cc_test {
    static_libs: [
        "android.hardware.gnss@1.0",
        "android.hardware.gnss@1.1",
        "android.hardware.gnss@common-vts-lib",
    ],
    test_suites: ["general-tests"],
}
Loading