Skip to content

Commit

Permalink
Merge tag 'LA.UM.9.12.r1-08600-SMxx50.0' of gps into lineage-18.1
Browse files Browse the repository at this point in the history
"LA.UM.9.12.r1-08600-SMxx50.0"

Change-Id: I0ab813fe8ed2c840474ec45f4445e1a9454d41f7
  • Loading branch information
erfanoabdi committed Apr 8, 2021
2 parents e1cd9c0 + d410b96 commit 15f1f8a
Show file tree
Hide file tree
Showing 173 changed files with 12,028 additions and 2,152 deletions.
45 changes: 45 additions & 0 deletions gps/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
GNSS_CFLAGS = [
"-Werror",
"-Wno-error=unused-parameter",
"-Wno-error=macro-redefined",
"-Wno-error=reorder",
"-Wno-error=missing-braces",
"-Wno-error=self-assign",
"-Wno-error=enum-conversion",
"-Wno-error=logical-op-parentheses",
"-Wno-error=null-arithmetic",
"-Wno-error=null-conversion",
"-Wno-error=parentheses-equality",
"-Wno-error=undefined-bool-conversion",
"-Wno-error=tautological-compare",
"-Wno-error=switch",
"-Wno-error=date-time",
]

/* Activate the following for regression testing */
GNSS_SANITIZE = {
/* address: true,*/
cfi: true,
misc_undefined: [
"bounds",
"null",
"unreachable",
"integer",
],
}

/* Activate the following for debug purposes only,
comment out for production */
GNSS_SANITIZE_DIAG = {
/*
diag: {
cfi: true,
misc_undefined: [
"bounds",
"null",
"unreachable",
"integer",
],
},
*/
}
43 changes: 41 additions & 2 deletions gps/Android.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)

# Set required flags
GNSS_CFLAGS := \
-Werror \
-Wno-error=unused-parameter \
-Wno-error=macro-redefined \
-Wno-error=reorder \
-Wno-error=missing-braces \
-Wno-error=self-assign \
-Wno-error=enum-conversion \
-Wno-error=logical-op-parentheses \
-Wno-error=null-arithmetic \
-Wno-error=null-conversion \
-Wno-error=parentheses-equality \
-Wno-error=undefined-bool-conversion \
-Wno-error=tautological-compare \
-Wno-error=switch \
-Wno-error=date-time

GNSS_HIDL_VERSION = 2.1

GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += msm8937
GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += msm8953
GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += msm8998
GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += apq8098_latv
GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += sdm710
GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += qcs605
GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += sdm845
GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += sdm660

ifneq (,$(filter $(GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST),$(TARGET_BOARD_PLATFORM)))
GNSS_HIDL_LEGACY_MEASURMENTS = true
endif

LOCAL_PATH := $(call my-dir)
include $(LOCAL_PATH)/build/target_specific_features.mk
include $(call all-makefiles-under,$(LOCAL_PATH))
endif

GNSS_SANITIZE := cfi bounds null unreachable integer
# Activate the following two lines for regression testing
#GNSS_SANITIZE += address
#GNSS_SANITIZE_DIAG := $(GNSS_SANITIZE)

endif # ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
4 changes: 0 additions & 4 deletions gps/android/1.0/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ LOCAL_HEADER_LIBRARIES := \
LOCAL_SHARED_LIBRARIES := \
liblog \
libhidlbase \
libhidltransport \
libhwbinder \
libcutils \
libutils \
[email protected] \
Expand Down Expand Up @@ -89,9 +87,7 @@ LOCAL_SHARED_LIBRARIES := \
libqti_vndfwk_detect \

LOCAL_SHARED_LIBRARIES += \
libhwbinder \
libhidlbase \
libhidltransport \
[email protected] \

LOCAL_CFLAGS += $(GNSS_CFLAGS)
Expand Down
7 changes: 4 additions & 3 deletions gps/android/1.0/Gnss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who
LOC_LOGE("%s] service died. cookie: %llu, who: %p",
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
if (mGnss != nullptr) {
mGnss->getGnssInterface()->resetNetworkInfo();
mGnss->stop();
mGnss->cleanup();
}
Expand Down Expand Up @@ -70,7 +71,7 @@ Gnss::Gnss() {
Gnss::~Gnss() {
ENTRY_LOG_CALLFLOW();
if (mApi != nullptr) {
delete mApi;
mApi->destroy();
mApi = nullptr;
}
sGnss = nullptr;
Expand Down Expand Up @@ -110,7 +111,7 @@ const GnssInterface* Gnss::getGnssInterface() {
if (nullptr == getter) {
getGnssInterfaceFailed = true;
} else {
mGnssInterface = (GnssInterface*)(*getter)();
mGnssInterface = (const GnssInterface*)(*getter)();
}
}
return mGnssInterface;
Expand Down Expand Up @@ -175,7 +176,7 @@ Return<bool> Gnss::updateConfiguration(GnssConfig& gnssConfig) {
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
mPendingConfig.lppProfile = gnssConfig.lppProfile;
mPendingConfig.lppProfileMask = gnssConfig.lppProfileMask;
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT;
Expand Down
4 changes: 2 additions & 2 deletions gps/android/1.0/GnssBatching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ GnssBatching::GnssBatching() : mApi(nullptr) {

GnssBatching::~GnssBatching() {
if (mApi != nullptr) {
delete mApi;
mApi->destroy();
mApi = nullptr;
}
}
Expand All @@ -56,7 +56,7 @@ GnssBatching::~GnssBatching() {
Return<bool> GnssBatching::init(const sp<IGnssBatchingCallback>& callback) {
if (mApi != nullptr) {
LOC_LOGD("%s]: mApi is NOT nullptr, delete it first", __FUNCTION__);
delete mApi;
mApi->destroy();
mApi = nullptr;
}

Expand Down
38 changes: 15 additions & 23 deletions gps/android/1.0/GnssConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ Return<bool> GnssConfiguration::setSuplVersion(uint32_t version) {
default:
LOC_LOGE("%s]: invalid version: 0x%x.", __FUNCTION__, version);
return false;
break;
}

return mGnss->updateConfiguration(config);
Expand Down Expand Up @@ -112,39 +111,33 @@ Return<bool> GnssConfiguration::setSuplMode(uint8_t mode) {
default:
LOC_LOGE("%s]: invalid mode: %d.", __FUNCTION__, mode);
return false;
break;
}

return mGnss->updateConfiguration(config);
}

Return<bool> GnssConfiguration::setLppProfile(uint8_t lppProfile) {
Return<bool> GnssConfiguration::setLppProfile(uint8_t lppProfileMask) {
if (mGnss == nullptr) {
LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
return false;
}

GnssConfig config;
memset(&config, 0, sizeof(GnssConfig));
GnssConfig config = {};
config.size = sizeof(GnssConfig);
config.flags = GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
switch (lppProfile) {
case 0:
config.lppProfile = GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE;
break;
case 1:
config.lppProfile = GNSS_CONFIG_LPP_PROFILE_USER_PLANE;
break;
case 2:
config.lppProfile = GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE;
break;
case 3:
config.lppProfile = GNSS_CONFIG_LPP_PROFILE_USER_PLANE_AND_CONTROL_PLANE;
break;
default:
LOC_LOGE("%s]: invalid lppProfile: %d.", __FUNCTION__, lppProfile);
return false;
break;
config.lppProfileMask = GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE; //default

if (lppProfileMask & (1<<0)) {
config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_USER_PLANE_BIT;
}
if (lppProfileMask & (1<<1)) {
config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE_BIT;
}
if (lppProfileMask & (1<<2)) {
config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_USER_PLANE_OVER_NR5G_SA_BIT;
}
if (lppProfileMask & (1<<3)) {
config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE_OVER_NR5G_SA_BIT;
}

return mGnss->updateConfiguration(config);
Expand Down Expand Up @@ -203,7 +196,6 @@ Return<bool> GnssConfiguration::setGpsLock(uint8_t lock) {
default:
LOC_LOGE("%s]: invalid lock: %d.", __FUNCTION__, lock);
return false;
break;
}

return mGnss->updateConfiguration(config);
Expand Down
2 changes: 1 addition & 1 deletion gps/android/1.0/GnssConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct GnssConfiguration : public IGnssConfiguration {
Return<bool> setSuplVersion(uint32_t version) override;
Return<bool> setSuplMode(uint8_t mode) override;
Return<bool> setSuplEs(bool enabled) override;
Return<bool> setLppProfile(uint8_t lppProfile) override;
Return<bool> setLppProfile(uint8_t lppProfileMask) override;
Return<bool> setGlonassPositioningProtocol(uint8_t protocol) override;
Return<bool> setEmergencySuplPdn(bool enable) override;
Return<bool> setGpsLock(uint8_t lock) override;
Expand Down
2 changes: 1 addition & 1 deletion gps/android/1.0/GnssGeofencing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ GnssGeofencing::GnssGeofencing() : mApi(nullptr) {

GnssGeofencing::~GnssGeofencing() {
if (mApi != nullptr) {
delete mApi;
mApi->destroy();
mApi = nullptr;
}
}
Expand Down
2 changes: 1 addition & 1 deletion gps/android/1.0/GnssMeasurement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ GnssMeasurement::GnssMeasurement() {

GnssMeasurement::~GnssMeasurement() {
if (mApi) {
delete mApi;
mApi->destroy();
mApi = nullptr;
}
}
Expand Down
3 changes: 2 additions & 1 deletion gps/android/1.0/location_api/BatchingAPIClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class BatchingAPIClient : public LocationAPIClientBase
{
public:
BatchingAPIClient(const sp<V1_0::IGnssBatchingCallback>& callback);
~BatchingAPIClient();
int getBatchSize();
int startSession(const V1_0::IGnssBatching::Options& options);
int updateSessionOptions(const V1_0::IGnssBatching::Options& options);
Expand All @@ -61,6 +60,8 @@ class BatchingAPIClient : public LocationAPIClientBase
void onBatchingCb(size_t count, Location* location, BatchingOptions batchOptions) final;

private:
~BatchingAPIClient();

sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface;
uint32_t mDefaultId;
LocationCapabilitiesMask mLocationCapabilitiesMask;
Expand Down
3 changes: 2 additions & 1 deletion gps/android/1.0/location_api/GeofenceAPIClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class GeofenceAPIClient : public LocationAPIClientBase
{
public:
GeofenceAPIClient(const sp<V1_0::IGnssGeofenceCallback>& callback);
virtual ~GeofenceAPIClient() = default;

void geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
double radius_meters, int32_t last_transition, int32_t monitor_transitions,
Expand All @@ -65,6 +64,8 @@ class GeofenceAPIClient : public LocationAPIClientBase
void onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;

private:
virtual ~GeofenceAPIClient() = default;

sp<V1_0::IGnssGeofenceCallback> mGnssGeofencingCbIface;
};

Expand Down
27 changes: 13 additions & 14 deletions gps/android/1.0/location_api/GnssAPIClient.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -110,9 +110,7 @@ void GnssAPIClient::gnssUpdateCallbacks(const sp<IGnssCallback>& gpsCb,

locationCallbacks.gnssNiCb = nullptr;
loc_core::ContextBase* context =
loc_core::LocContext::getLocContext(
NULL, NULL,
loc_core::LocContext::mLocationHalName, false);
loc_core::LocContext::getLocContext(loc_core::LocContext::mLocationHalName);
if (mGnssNiCbIface != nullptr && !context->hasAgpsExtendedCapabilities()) {
LOC_LOGD("Registering NI CB");
locationCallbacks.gnssNiCb = [this](uint32_t id, GnssNiNotification gnssNiNotification) {
Expand Down Expand Up @@ -331,16 +329,17 @@ void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
}
}
if (gnssCbIface != nullptr) {
IGnssCallback::GnssSystemInfo gnssInfo;
if (capabilitiesMask & LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT ||
capabilitiesMask & LOCATION_CAPABILITIES_AGPM_BIT) {
gnssInfo.yearOfHw = 2018;
} else if (capabilitiesMask & LOCATION_CAPABILITIES_DEBUG_NMEA_BIT) {
gnssInfo.yearOfHw = 2017;
} else if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT) {
gnssInfo.yearOfHw = 2016;
} else {
gnssInfo.yearOfHw = 2015;
IGnssCallback::GnssSystemInfo gnssInfo = { .yearOfHw = 2015 };

if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT) {
gnssInfo.yearOfHw++; // 2016
if (capabilitiesMask & LOCATION_CAPABILITIES_DEBUG_NMEA_BIT) {
gnssInfo.yearOfHw++; // 2017
if (capabilitiesMask & LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT ||
capabilitiesMask & LOCATION_CAPABILITIES_AGPM_BIT) {
gnssInfo.yearOfHw++; // 2018
}
}
}
LOC_LOGV("%s:%d] set_system_info_cb (%d)", __FUNCTION__, __LINE__, gnssInfo.yearOfHw);
auto r = gnssCbIface->gnssSetSystemInfoCb(gnssInfo);
Expand Down
3 changes: 2 additions & 1 deletion gps/android/1.0/location_api/GnssAPIClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class GnssAPIClient : public LocationAPIClientBase
public:
GnssAPIClient(const sp<V1_0::IGnssCallback>& gpsCb,
const sp<V1_0::IGnssNiCallback>& niCb);
virtual ~GnssAPIClient();
GnssAPIClient(const GnssAPIClient&) = delete;
GnssAPIClient& operator=(const GnssAPIClient&) = delete;

Expand Down Expand Up @@ -92,6 +91,8 @@ class GnssAPIClient : public LocationAPIClientBase
void onStopTrackingCb(LocationError error) final;

private:
virtual ~GnssAPIClient();

sp<V1_0::IGnssCallback> mGnssCbIface;
sp<V1_0::IGnssNiCallback> mGnssNiCbIface;
std::mutex mMutex;
Expand Down
10 changes: 10 additions & 0 deletions gps/android/1.0/location_api/LocationUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ void convertGnssSvid(GnssSv& in, int16_t& out)
case GNSS_SV_TYPE_GALILEO:
out = in.svId - GAL_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_NAVIC:
/*Android doesn't define Navic svid range yet, use Naviv svid [1, 14] now
will update this once Android give Navic svid definiitons */
out = in.svId - NAVIC_SV_PRN_MIN + 1;
break;
default:
out = in.svId;
break;
Expand Down Expand Up @@ -199,6 +204,11 @@ void convertGnssSvid(GnssMeasurementsData& in, int16_t& out)
case GNSS_SV_TYPE_GALILEO:
out = in.svId - GAL_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_NAVIC:
/*Android doesn't define Navic svid range yet, use Naviv svid [1, 14] now
will update this once Android give Navic svid definiitons */
out = in.svId - NAVIC_SV_PRN_MIN + 1;
break;
default:
out = in.svId;
break;
Expand Down
3 changes: 2 additions & 1 deletion gps/android/1.0/location_api/MeasurementAPIClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class MeasurementAPIClient : public LocationAPIClientBase
{
public:
MeasurementAPIClient();
virtual ~MeasurementAPIClient();
MeasurementAPIClient(const MeasurementAPIClient&) = delete;
MeasurementAPIClient& operator=(const MeasurementAPIClient&) = delete;

Expand All @@ -63,6 +62,8 @@ class MeasurementAPIClient : public LocationAPIClientBase
void onGnssMeasurementsCb(GnssMeasurementsNotification gnssMeasurementsNotification) final;

private:
virtual ~MeasurementAPIClient();

std::mutex mMutex;
sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface;

Expand Down
Loading

0 comments on commit 15f1f8a

Please sign in to comment.