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

Commit f001b128 authored by bohu's avatar bohu Committed by Bo Hu
Browse files

gnss: allows custom gnss device name

This is a temporary workaround the missing kernel
support of reclaiming virtio-console as gnss0 device.

When kernel can support converting virtio-console to
gnss0 device, this cl can be reverted

Bug: 180435101

Change-Id: I6e48b6c446dd945f066fbd8f5471b77226eba68b
parent 812a33cb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ cc_binary {
        "service.cpp",
    ],
    shared_libs: [
        "libcutils",
        "libhidlbase",
        "libutils",
        "liblog",
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ cc_binary {
    ],
    shared_libs: [
        "libbase",
        "libcutils",
        "libbinder_ndk",
        "libhidlbase",
        "libutils",
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ cc_library_static {
    ],
    export_include_dirs: ["include"],
    shared_libs: [
        "libcutils",
        "libhidlbase",
        "libutils",
        "android.hardware.gnss@1.0",
+12 −2
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@
#include <string>
#include <thread>

#include <cutils/properties.h>

#include "GnssAntennaInfo.h"
#include "GnssConfiguration.h"
#include "GnssDebug.h"
@@ -157,9 +159,17 @@ template <class T_IGnss>
std::unique_ptr<V2_0::GnssLocation> GnssTemplate<T_IGnss>::getLocationFromHW() {
    char inputBuffer[INPUT_BUFFER_SIZE];
    if (!mHardwareModeChecked) {
        mGnssFd = open(GNSS_PATH, O_RDWR | O_NONBLOCK);
        // default using gnss0
        const char * gnss_dev_path = GNSS_PATH;
        char devname_value[PROPERTY_VALUE_MAX] = "";
        if (property_get("debug.location.gnss.devname", devname_value, NULL) > 0) {
            gnss_dev_path = devname_value;
            ALOGD("using %s instead of the default %s", gnss_dev_path, GNSS_PATH);
        }

        mGnssFd = open(gnss_dev_path, O_RDWR | O_NONBLOCK);
        if (mGnssFd == -1) {
            ALOGW("Failed to open /dev/gnss0 errno: %d", errno);
            ALOGW("Failed to open %s errno: %d", gnss_dev_path, errno);
        }
        mHardwareModeChecked = true;
    }