diff --git a/gps/Android.mk b/gps/Android.mk index f1088a4..0f8c039 100644 --- a/gps/Android.mk +++ b/gps/Android.mk @@ -1,5 +1,22 @@ +# +# Copyright (C) 2020 The LineageOS 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. +# + ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),) + LOCAL_PATH := $(call my-dir) -include $(LOCAL_PATH)/build/target_specific_features.mk -include $(call all-makefiles-under,$(LOCAL_PATH)) -endif +include $(call first-makefiles-under,$(LOCAL_PATH)) + +endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE diff --git a/gps/Makefile.am b/gps/Makefile.am deleted file mode 100644 index cd4a731..0000000 --- a/gps/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -# Makefile.am - Automake script for gps loc_api -# - -ACLOCAL_AMFLAGS = -I m4 - -SUBDIRS = gnss - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = loc-hal.pc -EXTRA_DIST = $(pkgconfig_DATA) diff --git a/gps/android/1.0/AGnss.cpp b/gps/android/1.0/AGnss.cpp deleted file mode 100644 index faaf75e..0000000 --- a/gps/android/1.0/AGnss.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc_AGnssInterface" - -#include -#include "Gnss.h" -#include "AGnss.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -static AGnss* spAGnss = nullptr; - -AGnss::AGnss(Gnss* gnss) : mGnss(gnss) { - spAGnss = this; -} - -AGnss::~AGnss() { - spAGnss = nullptr; -} - -void AGnss::agnssStatusIpV4Cb(AGnssExtStatusIpV4 status){ - if (nullptr != spAGnss) { - spAGnss->statusIpV4Cb(status); - } -} - -void AGnss::statusIpV4Cb(AGnssExtStatusIpV4 status) { - IAGnssCallback::AGnssStatusIpV4 st = {}; - - switch (status.type) { - case LOC_AGPS_TYPE_SUPL: - st.type = IAGnssCallback::AGnssType::TYPE_SUPL; - break; - case LOC_AGPS_TYPE_C2K: - st.type = IAGnssCallback::AGnssType::TYPE_C2K; - break; - default: - LOC_LOGE("invalid type: %d", status.type); - return; - } - - switch (status.status) { - case LOC_GPS_REQUEST_AGPS_DATA_CONN: - st.status = IAGnssCallback::AGnssStatusValue::REQUEST_AGNSS_DATA_CONN; - break; - case LOC_GPS_RELEASE_AGPS_DATA_CONN: - st.status = IAGnssCallback::AGnssStatusValue::RELEASE_AGNSS_DATA_CONN; - break; - case LOC_GPS_AGPS_DATA_CONNECTED: - st.status = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONNECTED; - break; - case LOC_GPS_AGPS_DATA_CONN_DONE: - st.status = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONN_DONE; - break; - case LOC_GPS_AGPS_DATA_CONN_FAILED: - st.status = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONN_FAILED; - break; - default: - LOC_LOGE("invalid status: %d", status.status); - return; - } - st.ipV4Addr = status.ipV4Addr; - - if (mAGnssCbIface != nullptr) { - auto r = mAGnssCbIface->agnssStatusIpV4Cb(st); - if (!r.isOk()) { - LOC_LOGw("Error invoking AGNSS status cb %s", r.description().c_str()); - } - } else { - LOC_LOGw("setCallback has not been called yet"); - } -} - -Return AGnss::setCallback(const sp& callback) { - - if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){ - LOC_LOGE("Null GNSS interface"); - return Void(); - } - - // Save the interface - mAGnssCbIface = callback; - - AgpsCbInfo cbInfo = {}; - cbInfo.statusV4Cb = (void*)agnssStatusIpV4Cb; - cbInfo.cbPriority = AGPS_CB_PRIORITY_LOW; - - mGnss->getGnssInterface()->agpsInit(cbInfo); - return Void(); -} - -Return AGnss::dataConnClosed() { - - if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){ - LOC_LOGE("Null GNSS interface"); - return false; - } - - mGnss->getGnssInterface()->agpsDataConnClosed(LOC_AGPS_TYPE_SUPL); - return true; -} - -Return AGnss::dataConnFailed() { - - if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){ - LOC_LOGE("Null GNSS interface"); - return false; - } - - mGnss->getGnssInterface()->agpsDataConnFailed(LOC_AGPS_TYPE_SUPL); - return true; -} - -Return AGnss::dataConnOpen(const hidl_string& apn, - IAGnss::ApnIpType apnIpType) { - - if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){ - LOC_LOGE("Null GNSS interface"); - return false; - } - - /* Validate */ - if(apn.empty()){ - LOC_LOGE("Invalid APN"); - return false; - } - - LOC_LOGD("dataConnOpen APN name = [%s]", apn.c_str()); - - AGpsBearerType bearerType; - switch (apnIpType) { - case IAGnss::ApnIpType::IPV4: - bearerType = AGPS_APN_BEARER_IPV4; - break; - case IAGnss::ApnIpType::IPV6: - bearerType = AGPS_APN_BEARER_IPV6; - break; - case IAGnss::ApnIpType::IPV4V6: - bearerType = AGPS_APN_BEARER_IPV4V6; - break; - default: - bearerType = AGPS_APN_BEARER_IPV4; - break; - } - - mGnss->getGnssInterface()->agpsDataConnOpen( - LOC_AGPS_TYPE_SUPL, apn.c_str(), apn.size(), (int)bearerType); - return true; -} - -Return AGnss::setServer(IAGnssCallback::AGnssType type, - const hidl_string& hostname, - int32_t port) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT; - config.assistanceServer.size = sizeof(GnssConfigSetAssistanceServer); - if (type == IAGnssCallback::AGnssType::TYPE_SUPL) { - config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_SUPL; - } else if (type == IAGnssCallback::AGnssType::TYPE_C2K) { - config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_C2K; - } else { - LOC_LOGE("%s]: invalid AGnssType: %d", __FUNCTION__, static_cast(type)); - return false; - } - config.assistanceServer.hostName = strdup(hostname.c_str()); - config.assistanceServer.port = port; - return mGnss->updateConfiguration(config); -} - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.0/AGnss.h b/gps/android/1.0/AGnss.h deleted file mode 100644 index cdd5931..0000000 --- a/gps/android/1.0/AGnss.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_0_AGNSS_H -#define ANDROID_HARDWARE_GNSS_V1_0_AGNSS_H - -#include -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IAGnss; -using ::android::hardware::gnss::V1_0::IAGnssCallback; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -struct Gnss; -struct AGnss : public IAGnss { - - AGnss(Gnss* gnss); - ~AGnss(); - /* - * Methods from ::android::hardware::gnss::V1_0::IAGnss interface follow. - * These declarations were generated from IAGnss.hal. - */ - Return setCallback(const sp& callback) override; - - Return dataConnClosed() override; - - Return dataConnFailed() override; - - Return dataConnOpen(const hidl_string& apn, - IAGnss::ApnIpType apnIpType) override; - - Return setServer(IAGnssCallback::AGnssType type, - const hidl_string& hostname, int32_t port) override; - - void statusIpV4Cb(AGnssExtStatusIpV4 status); - - /* Data call setup callback passed down to GNSS HAL implementation */ - static void agnssStatusIpV4Cb(AGnssExtStatusIpV4 status); - - private: - Gnss* mGnss = nullptr; - sp mAGnssCbIface = nullptr; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_0_AGNSS_H diff --git a/gps/android/1.0/AGnssRil.cpp b/gps/android/1.0/AGnssRil.cpp deleted file mode 100644 index 0437cf1..0000000 --- a/gps/android/1.0/AGnssRil.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc__AGnssRilInterface" - -#include -#include -#include -#include -#include -#include -#include -#include "Gnss.h" -#include "AGnssRil.h" -#include - -typedef void* (getLocationInterface)(); - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - - -AGnssRil::AGnssRil(Gnss* gnss) : mGnss(gnss) { - ENTRY_LOG_CALLFLOW(); -} - -AGnssRil::~AGnssRil() { - ENTRY_LOG_CALLFLOW(); -} - -Return AGnssRil::updateNetworkState(bool connected, NetworkType type, bool /*roaming*/) { - ENTRY_LOG_CALLFLOW(); - // Extra NetworkTypes not available in IAgnssRil enums - const int NetworkType_BLUETOOTH = 7; - const int NetworkType_ETHERNET = 9; - const int NetworkType_PROXY = 16; - - // for XTRA - if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) { - int8_t typeout = loc_core::NetworkInfoDataItemBase::TYPE_UNKNOWN; - switch(type) - { - case IAGnssRil::NetworkType::MOBILE: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_MOBILE; - break; - case IAGnssRil::NetworkType::WIFI: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_WIFI; - break; - case IAGnssRil::NetworkType::MMS: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_MMS; - break; - case IAGnssRil::NetworkType::SUPL: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_SUPL; - break; - case IAGnssRil::NetworkType::DUN: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_DUN; - break; - case IAGnssRil::NetworkType::HIPRI: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_HIPRI; - break; - case IAGnssRil::NetworkType::WIMAX: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_WIMAX; - break; - default: - { - int networkType = (int) type; - // Handling network types not available in IAgnssRil - switch(networkType) - { - case NetworkType_BLUETOOTH: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_BLUETOOTH; - break; - case NetworkType_ETHERNET: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_ETHERNET; - break; - case NetworkType_PROXY: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_PROXY; - break; - default: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_UNKNOWN; - } - } - break; - } - mGnss->getGnssInterface()->updateConnectionStatus(connected, false, typeout, 0); - } - return true; -} - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.0/AGnssRil.h b/gps/android/1.0/AGnssRil.h deleted file mode 100644 index 7f18c57..0000000 --- a/gps/android/1.0/AGnssRil.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_0_AGNSSRIL_H_ -#define ANDROID_HARDWARE_GNSS_V1_0_AGNSSRIL_H_ - -#include -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IAGnssRil; -using ::android::hardware::gnss::V1_0::IAGnssRilCallback; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -struct Gnss; -/* - * Extended interface for AGNSS RIL support. An Assisted GNSS Radio Interface Layer interface - * allows the GNSS chipset to request radio interface layer information from Android platform. - * Examples of such information are reference location, unique subscriber ID, phone number string - * and network availability changes. Also contains wrapper methods to allow methods from - * IAGnssiRilCallback interface to be passed into the conventional implementation of the GNSS HAL. - */ -struct AGnssRil : public IAGnssRil { - AGnssRil(Gnss* gnss); - ~AGnssRil(); - - /* - * Methods from ::android::hardware::gnss::V1_0::IAGnssRil follow. - * These declarations were generated from IAGnssRil.hal. - */ - Return setCallback(const sp& /*callback*/) override { - return Void(); - } - Return setRefLocation(const IAGnssRil::AGnssRefLocation& /*agnssReflocation*/) override { - return Void(); - } - Return setSetId(IAGnssRil::SetIDType /*type*/, const hidl_string& /*setid*/) override { - return false; - } - Return updateNetworkAvailability(bool /*available*/, - const hidl_string& /*apn*/) override { - return false; - } - Return updateNetworkState(bool connected, NetworkType type, bool roaming) override; - - private: - Gnss* mGnss = nullptr; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_0_AGNSSRIL_H_ diff --git a/gps/android/1.0/Android.mk b/gps/android/1.0/Android.mk deleted file mode 100644 index 9337325..0000000 --- a/gps/android/1.0/Android.mk +++ /dev/null @@ -1,97 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := android.hardware.gnss@1.0-impl-qti -LOCAL_VENDOR_MODULE := true -LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_SRC_FILES := \ - AGnss.cpp \ - Gnss.cpp \ - GnssBatching.cpp \ - GnssGeofencing.cpp \ - GnssMeasurement.cpp \ - GnssNi.cpp \ - GnssConfiguration.cpp \ - GnssDebug.cpp \ - AGnssRil.cpp - -LOCAL_SRC_FILES += \ - location_api/LocationUtil.cpp \ - location_api/GnssAPIClient.cpp \ - location_api/GeofenceAPIClient.cpp \ - location_api/BatchingAPIClient.cpp \ - location_api/MeasurementAPIClient.cpp \ - -LOCAL_C_INCLUDES:= \ - $(LOCAL_PATH)/location_api -LOCAL_HEADER_LIBRARIES := \ - libgps.utils_headers \ - libloc_core_headers \ - libloc_pla_headers \ - liblocation_api_headers \ - liblocbatterylistener_headers - -LOCAL_SHARED_LIBRARIES := \ - liblog \ - libhidlbase \ - libhidltransport \ - libhwbinder \ - libcutils \ - libutils \ - android.hardware.gnss@1.0 \ - android.hardware.health@1.0 \ - android.hardware.health@2.0 \ - android.hardware.power@1.2 \ - libbase - -LOCAL_SHARED_LIBRARIES += \ - libloc_core \ - libgps.utils \ - libdl \ - liblocation_api \ - -LOCAL_CFLAGS += $(GNSS_CFLAGS) -LOCAL_STATIC_LIBRARIES := liblocbatterylistener -LOCAL_STATIC_LIBRARIES += libhealthhalutils -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := android.hardware.gnss@1.0-service-qti -LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@1.0-service-qti.xml -LOCAL_VENDOR_MODULE := true -LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_INIT_RC := android.hardware.gnss@1.0-service-qti.rc -LOCAL_SRC_FILES := \ - service.cpp \ - -LOCAL_C_INCLUDES:= \ - $(LOCAL_PATH)/location_api -LOCAL_HEADER_LIBRARIES := \ - libgps.utils_headers \ - libloc_core_headers \ - libloc_pla_headers \ - liblocation_api_headers - - -LOCAL_SHARED_LIBRARIES := \ - liblog \ - libcutils \ - libdl \ - libbase \ - libutils \ - libgps.utils \ - libqti_vndfwk_detect \ - -LOCAL_SHARED_LIBRARIES += \ - libhwbinder \ - libhidlbase \ - libhidltransport \ - android.hardware.gnss@1.0 \ - -LOCAL_CFLAGS += $(GNSS_CFLAGS) - -ifneq ($(LOC_HIDL_VERSION),) -LOCAL_CFLAGS += -DLOC_HIDL_VERSION='"$(LOC_HIDL_VERSION)"' -endif - -include $(BUILD_EXECUTABLE) diff --git a/gps/android/1.0/Gnss.cpp b/gps/android/1.0/Gnss.cpp deleted file mode 100644 index d85e0a4..0000000 --- a/gps/android/1.0/Gnss.cpp +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc_GnssInterface" -#define LOG_NDEBUG 0 - -#include -#include -#include -#include -#include "Gnss.h" -#include -#include "battery_listener.h" - -typedef const GnssInterface* (getLocationInterface)(); - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -static sp sGnss; -void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp& who) { - LOC_LOGE("%s] service died. cookie: %llu, who: %p", - __FUNCTION__, static_cast(cookie), &who); - if (mGnss != nullptr) { - mGnss->stop(); - mGnss->cleanup(); - } -} - -void location_on_battery_status_changed(bool charging) { - LOC_LOGd("battery status changed to %s charging", charging ? "" : "not "); - if (sGnss != nullptr) { - sGnss->getGnssInterface()->updateBatteryStatus(charging); - } -} -Gnss::Gnss() { - ENTRY_LOG_CALLFLOW(); - sGnss = this; - // register health client to listen on battery change - loc_extn_battery_properties_listener_init(location_on_battery_status_changed); - // clear pending GnssConfig - memset(&mPendingConfig, 0, sizeof(GnssConfig)); - - mGnssDeathRecipient = new GnssDeathRecipient(this); -} - -Gnss::~Gnss() { - ENTRY_LOG_CALLFLOW(); - if (mApi != nullptr) { - delete mApi; - mApi = nullptr; - } - sGnss = nullptr; -} - -GnssAPIClient* Gnss::getApi() { - if (mApi == nullptr && (mGnssCbIface != nullptr || mGnssNiCbIface != nullptr)) { - mApi = new GnssAPIClient(mGnssCbIface, mGnssNiCbIface); - if (mApi == nullptr) { - LOC_LOGE("%s] faild to create GnssAPIClient", __FUNCTION__); - return mApi; - } - - if (mPendingConfig.size == sizeof(GnssConfig)) { - // we have pending GnssConfig - mApi->gnssConfigurationUpdate(mPendingConfig); - // clear size to invalid mPendingConfig - mPendingConfig.size = 0; - if (mPendingConfig.assistanceServer.hostName != nullptr) { - free((void*)mPendingConfig.assistanceServer.hostName); - } - } - } - if (mApi == nullptr) { - LOC_LOGW("%s] GnssAPIClient is not ready", __FUNCTION__); - } - return mApi; -} - -const GnssInterface* Gnss::getGnssInterface() { - static bool getGnssInterfaceFailed = false; - if (nullptr == mGnssInterface && !getGnssInterfaceFailed) { - LOC_LOGD("%s]: loading libgnss.so::getGnssInterface ...", __func__); - getLocationInterface* getter = NULL; - const char *error = NULL; - dlerror(); - void *handle = dlopen("libgnss.so", RTLD_NOW); - if (NULL == handle || (error = dlerror()) != NULL) { - LOC_LOGW("dlopen for libgnss.so failed, error = %s", error); - } else { - getter = (getLocationInterface*)dlsym(handle, "getGnssInterface"); - if ((error = dlerror()) != NULL) { - LOC_LOGW("dlsym for libgnss.so::getGnssInterface failed, error = %s", error); - getter = NULL; - } - } - - if (NULL == getter) { - getGnssInterfaceFailed = true; - } else { - mGnssInterface = (const GnssInterface*)(*getter)(); - } - } - return mGnssInterface; -} - -Return Gnss::setCallback(const sp& callback) { - ENTRY_LOG_CALLFLOW(); - if (mGnssCbIface != nullptr) { - mGnssCbIface->unlinkToDeath(mGnssDeathRecipient); - } - mGnssCbIface = callback; - if (mGnssCbIface != nullptr) { - mGnssCbIface->linkToDeath(mGnssDeathRecipient, 0 /*cookie*/); - } - - GnssAPIClient* api = getApi(); - if (api != nullptr) { - api->gnssUpdateCallbacks(mGnssCbIface, mGnssNiCbIface); - api->gnssEnable(LOCATION_TECHNOLOGY_TYPE_GNSS); - api->requestCapabilities(); - } - return true; -} - -Return Gnss::setGnssNiCb(const sp& callback) { - ENTRY_LOG_CALLFLOW(); - mGnssNiCbIface = callback; - GnssAPIClient* api = getApi(); - if (api != nullptr) { - api->gnssUpdateCallbacks(mGnssCbIface, mGnssNiCbIface); - } - return true; -} - -Return Gnss::updateConfiguration(GnssConfig& gnssConfig) { - ENTRY_LOG_CALLFLOW(); - GnssAPIClient* api = getApi(); - if (api) { - api->gnssConfigurationUpdate(gnssConfig); - } else if (gnssConfig.flags != 0) { - // api is not ready yet, update mPendingConfig with gnssConfig - mPendingConfig.size = sizeof(GnssConfig); - - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT; - mPendingConfig.gpsLock = gnssConfig.gpsLock; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT; - mPendingConfig.suplVersion = gnssConfig.suplVersion; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT; - mPendingConfig.assistanceServer.size = sizeof(GnssConfigSetAssistanceServer); - mPendingConfig.assistanceServer.type = gnssConfig.assistanceServer.type; - if (mPendingConfig.assistanceServer.hostName != nullptr) { - free((void*)mPendingConfig.assistanceServer.hostName); - mPendingConfig.assistanceServer.hostName = - strdup(gnssConfig.assistanceServer.hostName); - } - mPendingConfig.assistanceServer.port = gnssConfig.assistanceServer.port; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT; - mPendingConfig.lppProfile = gnssConfig.lppProfile; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT; - mPendingConfig.lppeControlPlaneMask = gnssConfig.lppeControlPlaneMask; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT; - mPendingConfig.lppeUserPlaneMask = gnssConfig.lppeUserPlaneMask; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT; - mPendingConfig.aGlonassPositionProtocolMask = gnssConfig.aGlonassPositionProtocolMask; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT; - mPendingConfig.emergencyPdnForEmergencySupl = gnssConfig.emergencyPdnForEmergencySupl; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT; - mPendingConfig.suplEmergencyServices = gnssConfig.suplEmergencyServices; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_MODE_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_MODE_BIT; - mPendingConfig.suplModeMask = gnssConfig.suplModeMask; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT; - mPendingConfig.blacklistedSvIds = gnssConfig.blacklistedSvIds; - } - } - return true; -} - -Return Gnss::start() { - ENTRY_LOG_CALLFLOW(); - bool retVal = false; - GnssAPIClient* api = getApi(); - if (api) { - retVal = api->gnssStart(); - } - return retVal; -} - -Return Gnss::stop() { - ENTRY_LOG_CALLFLOW(); - bool retVal = false; - GnssAPIClient* api = getApi(); - if (api) { - retVal = api->gnssStop(); - } - return retVal; -} - -Return Gnss::cleanup() { - ENTRY_LOG_CALLFLOW(); - - if (mApi != nullptr) { - mApi->gnssDisable(); - } - - return Void(); -} - -Return Gnss::injectLocation(double latitudeDegrees, - double longitudeDegrees, - float accuracyMeters) { - ENTRY_LOG_CALLFLOW(); - const GnssInterface* gnssInterface = getGnssInterface(); - if (nullptr != gnssInterface) { - gnssInterface->injectLocation(latitudeDegrees, longitudeDegrees, accuracyMeters); - return true; - } else { - return false; - } -} - -Return Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs, - int32_t uncertaintyMs) { - ENTRY_LOG_CALLFLOW(); - const GnssInterface* gnssInterface = getGnssInterface(); - if (nullptr != gnssInterface) { - gnssInterface->injectTime(timeMs, timeReferenceMs, uncertaintyMs); - return true; - } else { - return false; - } -} - -Return Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) { - ENTRY_LOG_CALLFLOW(); - GnssAPIClient* api = getApi(); - if (api) { - api->gnssDeleteAidingData(aidingDataFlags); - } - return Void(); -} - -Return Gnss::setPositionMode(V1_0::IGnss::GnssPositionMode mode, - V1_0::IGnss::GnssPositionRecurrence recurrence, - uint32_t minIntervalMs, - uint32_t preferredAccuracyMeters, - uint32_t preferredTimeMs) { - ENTRY_LOG_CALLFLOW(); - bool retVal = false; - GnssAPIClient* api = getApi(); - if (api) { - retVal = api->gnssSetPositionMode(mode, recurrence, minIntervalMs, - preferredAccuracyMeters, preferredTimeMs); - } - return retVal; -} - -Return> Gnss::getExtensionAGnss() { - ENTRY_LOG_CALLFLOW(); - mAGnssIface = new AGnss(this); - return mAGnssIface; -} - -Return> Gnss::getExtensionGnssNi() { - ENTRY_LOG_CALLFLOW(); - mGnssNi = new GnssNi(this); - return mGnssNi; -} - -Return> Gnss::getExtensionGnssMeasurement() { - ENTRY_LOG_CALLFLOW(); - if (mGnssMeasurement == nullptr) - mGnssMeasurement = new GnssMeasurement(); - return mGnssMeasurement; -} - -Return> Gnss::getExtensionGnssConfiguration() { - ENTRY_LOG_CALLFLOW(); - mGnssConfig = new GnssConfiguration(this); - return mGnssConfig; -} - -Return> Gnss::getExtensionGnssGeofencing() { - ENTRY_LOG_CALLFLOW(); - mGnssGeofencingIface = new GnssGeofencing(); - return mGnssGeofencingIface; -} - -Return> Gnss::getExtensionGnssBatching() { - mGnssBatching = new GnssBatching(); - return mGnssBatching; -} - -Return> Gnss::getExtensionGnssDebug() { - ENTRY_LOG_CALLFLOW(); - mGnssDebug = new GnssDebug(this); - return mGnssDebug; -} - -Return> Gnss::getExtensionAGnssRil() { - mGnssRil = new AGnssRil(this); - return mGnssRil; -} - -IGnss* HIDL_FETCH_IGnss(const char* hal) { - ENTRY_LOG_CALLFLOW(); - IGnss* iface = nullptr; - iface = new Gnss(); - if (iface == nullptr) { - LOC_LOGE("%s]: failed to get %s", __FUNCTION__, hal); - } - return iface; -} - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.0/Gnss.h b/gps/android/1.0/Gnss.h deleted file mode 100644 index 900a510..0000000 --- a/gps/android/1.0/Gnss.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_0_GNSS_H -#define ANDROID_HARDWARE_GNSS_V1_0_GNSS_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; -using ::android::hardware::gnss::V1_0::GnssLocation; - -struct Gnss : public IGnss { - Gnss(); - ~Gnss(); - - /* - * Methods from ::android::hardware::gnss::V1_0::IGnss follow. - * These declarations were generated from Gnss.hal. - */ - Return setCallback(const sp& callback) override; - Return start() override; - Return stop() override; - Return cleanup() override; - Return injectLocation(double latitudeDegrees, - double longitudeDegrees, - float accuracyMeters) override; - Return injectTime(int64_t timeMs, - int64_t timeReferenceMs, - int32_t uncertaintyMs) override; - Return deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) override; - Return setPositionMode(V1_0::IGnss::GnssPositionMode mode, - V1_0::IGnss::GnssPositionRecurrence recurrence, - uint32_t minIntervalMs, - uint32_t preferredAccuracyMeters, - uint32_t preferredTimeMs) override; - Return> getExtensionAGnss() override; - Return> getExtensionGnssNi() override; - Return> getExtensionGnssMeasurement() override; - Return> getExtensionGnssConfiguration() override; - Return> getExtensionGnssGeofencing() override; - Return> getExtensionGnssBatching() override; - - Return> getExtensionAGnssRil() override; - - inline Return> getExtensionGnssNavigationMessage() override { - return nullptr; - } - - inline Return> getExtensionXtra() override { - return nullptr; - } - - Return> getExtensionGnssDebug() override; - - // These methods are not part of the IGnss base class. - GnssAPIClient* getApi(); - Return setGnssNiCb(const sp& niCb); - Return updateConfiguration(GnssConfig& gnssConfig); - const GnssInterface* getGnssInterface(); - - // Callback for ODCPI request - void odcpiRequestCb(const OdcpiRequestInfo& request); - - private: - struct GnssDeathRecipient : hidl_death_recipient { - GnssDeathRecipient(sp gnss) : mGnss(gnss) { - } - ~GnssDeathRecipient() = default; - virtual void serviceDied(uint64_t cookie, const wp& who) override; - sp mGnss; - }; - - private: - sp mGnssDeathRecipient = nullptr; - - sp mAGnssIface = nullptr; - sp mGnssNi = nullptr; - sp mGnssMeasurement = nullptr; - sp mGnssConfig = nullptr; - sp mGnssGeofencingIface = nullptr; - sp mGnssBatching = nullptr; - sp mGnssDebug = nullptr; - sp mGnssRil = nullptr; - - GnssAPIClient* mApi = nullptr; - sp mGnssCbIface = nullptr; - sp mGnssNiCbIface = nullptr; - GnssConfig mPendingConfig; - const GnssInterface* mGnssInterface = nullptr; -}; - -extern "C" IGnss* HIDL_FETCH_IGnss(const char* name); - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSS_H diff --git a/gps/android/1.0/GnssBatching.cpp b/gps/android/1.0/GnssBatching.cpp deleted file mode 100644 index 3e5a9f4..0000000 --- a/gps/android/1.0/GnssBatching.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc_GnssBatchingInterface" - -#include -#include -#include "GnssBatching.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -void GnssBatching::GnssBatchingDeathRecipient::serviceDied( - uint64_t cookie, const wp& who) { - LOC_LOGE("%s] service died. cookie: %llu, who: %p", - __FUNCTION__, static_cast(cookie), &who); - if (mGnssBatching != nullptr) { - mGnssBatching->stop(); - mGnssBatching->cleanup(); - } -} - -GnssBatching::GnssBatching() : mApi(nullptr) { - mGnssBatchingDeathRecipient = new GnssBatchingDeathRecipient(this); -} - -GnssBatching::~GnssBatching() { - if (mApi != nullptr) { - delete mApi; - mApi = nullptr; - } -} - - -// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow. -Return GnssBatching::init(const sp& callback) { - if (mApi != nullptr) { - LOC_LOGD("%s]: mApi is NOT nullptr, delete it first", __FUNCTION__); - delete mApi; - mApi = nullptr; - } - - mApi = new BatchingAPIClient(callback); - if (mApi == nullptr) { - LOC_LOGE("%s]: failed to create mApi", __FUNCTION__); - return false; - } - - if (mGnssBatchingCbIface != nullptr) { - mGnssBatchingCbIface->unlinkToDeath(mGnssBatchingDeathRecipient); - } - mGnssBatchingCbIface = callback; - if (mGnssBatchingCbIface != nullptr) { - mGnssBatchingCbIface->linkToDeath(mGnssBatchingDeathRecipient, 0 /*cookie*/); - } - - return true; -} - -Return GnssBatching::getBatchSize() { - uint16_t ret = 0; - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - ret = mApi->getBatchSize(); - } - return ret; -} - -Return GnssBatching::start(const IGnssBatching::Options& options) { - bool ret = false; - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - ret = mApi->startSession(options); - } - return ret; -} - -Return GnssBatching::flush() { - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - mApi->flushBatchedLocations(); - } - return Void(); -} - -Return GnssBatching::stop() { - bool ret = false; - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - ret = mApi->stopSession(); - } - return ret; -} - -Return GnssBatching::cleanup() { - if (mGnssBatchingCbIface != nullptr) { - mGnssBatchingCbIface->unlinkToDeath(mGnssBatchingDeathRecipient); - } - return Void(); -} - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.0/GnssBatching.h b/gps/android/1.0/GnssBatching.h deleted file mode 100644 index 8fab857..0000000 --- a/gps/android/1.0/GnssBatching.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_0_GNSSBATCHING_H -#define ANDROID_HARDWARE_GNSS_V1_0_GNSSBATCHING_H - -#include -#include - - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssBatching; -using ::android::hardware::gnss::V1_0::IGnssBatchingCallback; -using ::android::hidl::base::V1_0::IBase; -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; - -class BatchingAPIClient; -struct GnssBatching : public IGnssBatching { - GnssBatching(); - ~GnssBatching(); - - // Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow. - Return init(const sp& callback) override; - Return getBatchSize() override; - Return start(const IGnssBatching::Options& options ) override; - Return flush() override; - Return stop() override; - Return cleanup() override; - - private: - struct GnssBatchingDeathRecipient : hidl_death_recipient { - GnssBatchingDeathRecipient(sp gnssBatching) : - mGnssBatching(gnssBatching) { - } - ~GnssBatchingDeathRecipient() = default; - virtual void serviceDied(uint64_t cookie, const wp& who) override; - sp mGnssBatching; - }; - - private: - sp mGnssBatchingDeathRecipient = nullptr; - sp mGnssBatchingCbIface = nullptr; - BatchingAPIClient* mApi = nullptr; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSSBATCHING_H diff --git a/gps/android/1.0/GnssConfiguration.cpp b/gps/android/1.0/GnssConfiguration.cpp deleted file mode 100644 index 0b62249..0000000 --- a/gps/android/1.0/GnssConfiguration.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc_GnssConfigurationInterface" - -#include -#include "Gnss.h" -#include "GnssConfiguration.h" -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::GnssConstellationType; - -GnssConfiguration::GnssConfiguration(Gnss* gnss) : mGnss(gnss) { -} - -// Methods from ::android::hardware::gps::V1_0::IGnssConfiguration follow. -Return GnssConfiguration::setSuplEs(bool enabled) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT; - config.suplEmergencyServices = (enabled ? - GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_YES : - GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO); - - return mGnss->updateConfiguration(config); -} - -Return GnssConfiguration::setSuplVersion(uint32_t version) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT; - switch (version) { - case 0x00020002: - config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_2; - break; - case 0x00020000: - config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_0; - break; - case 0x00010000: - config.suplVersion = GNSS_CONFIG_SUPL_VERSION_1_0_0; - break; - default: - LOC_LOGE("%s]: invalid version: 0x%x.", __FUNCTION__, version); - return false; - break; - } - - return mGnss->updateConfiguration(config); -} - -Return GnssConfiguration::setSuplMode(uint8_t mode) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_SUPL_MODE_BIT; - switch (mode) { - case 0: - config.suplModeMask = 0; // STANDALONE ONLY - break; - case 1: - config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSB_BIT; - break; - case 2: - config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSA_BIT; - break; - case 3: - config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSB_BIT | GNSS_CONFIG_SUPL_MODE_MSA_BIT; - break; - default: - LOC_LOGE("%s]: invalid mode: %d.", __FUNCTION__, mode); - return false; - break; - } - - return mGnss->updateConfiguration(config); -} - -Return GnssConfiguration::setLppProfile(uint8_t lppProfile) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - 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; - } - - return mGnss->updateConfiguration(config); -} - -Return GnssConfiguration::setGlonassPositioningProtocol(uint8_t protocol) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - - config.flags = GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT; - if (protocol & (1<<0)) { - config.aGlonassPositionProtocolMask |= GNSS_CONFIG_RRC_CONTROL_PLANE_BIT; - } - if (protocol & (1<<1)) { - config.aGlonassPositionProtocolMask |= GNSS_CONFIG_RRLP_USER_PLANE_BIT; - } - if (protocol & (1<<2)) { - config.aGlonassPositionProtocolMask |= GNSS_CONFIG_LLP_USER_PLANE_BIT; - } - if (protocol & (1<<3)) { - config.aGlonassPositionProtocolMask |= GNSS_CONFIG_LLP_CONTROL_PLANE_BIT; - } - - return mGnss->updateConfiguration(config); -} - -Return GnssConfiguration::setGpsLock(uint8_t lock) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT; - switch (lock) { - case 0: - config.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE; - break; - case 1: - config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO; - break; - case 2: - config.gpsLock = GNSS_CONFIG_GPS_LOCK_NI; - break; - case 3: - config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO_AND_NI; - break; - default: - LOC_LOGE("%s]: invalid lock: %d.", __FUNCTION__, lock); - return false; - break; - } - - return mGnss->updateConfiguration(config); -} - -Return GnssConfiguration::setEmergencySuplPdn(bool enabled) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT; - config.emergencyPdnForEmergencySupl = (enabled ? - GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_YES : - GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_NO); - - return mGnss->updateConfiguration(config); -} - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.0/GnssConfiguration.h b/gps/android/1.0/GnssConfiguration.h deleted file mode 100644 index 1629e06..0000000 --- a/gps/android/1.0/GnssConfiguration.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ - - /* Copyright (C) 2016 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_0_GNSSCONFIGURATION_H -#define ANDROID_HARDWARE_GNSS_V1_0_GNSSCONFIGURATION_H - -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssConfiguration; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -/* - * Interface for passing GNSS configuration info from platform to HAL. - */ -struct Gnss; -struct GnssConfiguration : public IGnssConfiguration { - GnssConfiguration(Gnss* gnss); - ~GnssConfiguration() = default; - - /* - * Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow. - * These declarations were generated from IGnssConfiguration.hal. - */ - Return setSuplVersion(uint32_t version) override; - Return setSuplMode(uint8_t mode) override; - Return setSuplEs(bool enabled) override; - Return setLppProfile(uint8_t lppProfile) override; - Return setGlonassPositioningProtocol(uint8_t protocol) override; - Return setEmergencySuplPdn(bool enable) override; - Return setGpsLock(uint8_t lock) override; - - private: - Gnss* mGnss = nullptr; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSSCONFIGURATION_H diff --git a/gps/android/1.0/GnssDebug.cpp b/gps/android/1.0/GnssDebug.cpp deleted file mode 100644 index ead72e1..0000000 --- a/gps/android/1.0/GnssDebug.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2016 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 "LocSvc_GnssDebugInterface" - -#include -#include -#include "Gnss.h" -#include "GnssDebug.h" -#include "LocationUtil.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::hidl_vec; - -#define GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS (20000000) -#define GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS (20000) -#define GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC (500) -#define GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG (180) - -#define GNSS_DEBUG_UNKNOWN_UTC_TIME (1483228800000LL) // 1/1/2017 00:00 GMT -#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC (1.57783680E17) // 5 years in ns -#define GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC (2.0e5) // ppm - -GnssDebug::GnssDebug(Gnss* gnss) : mGnss(gnss) -{ -} - -/* - * This methods requests position, time and satellite ephemeris debug information - * from the HAL. - * - * @return void -*/ -Return GnssDebug::getDebugData(getDebugData_cb _hidl_cb) -{ - LOC_LOGD("%s]: ", __func__); - - DebugData data = { }; - - if((nullptr == mGnss) || (nullptr == mGnss->getGnssInterface())){ - LOC_LOGE("GnssDebug - Null GNSS interface"); - _hidl_cb(data); - return Void(); - } - - // get debug report snapshot via hal interface - GnssDebugReport reports = { }; - mGnss->getGnssInterface()->getDebugReport(reports); - - // location block - if (reports.mLocation.mValid) { - data.position.valid = true; - data.position.latitudeDegrees = reports.mLocation.mLocation.latitude; - data.position.longitudeDegrees = reports.mLocation.mLocation.longitude; - data.position.altitudeMeters = reports.mLocation.mLocation.altitude; - - data.position.speedMetersPerSec = - (double)(reports.mLocation.mLocation.speed); - data.position.bearingDegrees = - (double)(reports.mLocation.mLocation.bearing); - data.position.horizontalAccuracyMeters = - (double)(reports.mLocation.mLocation.accuracy); - data.position.verticalAccuracyMeters = - reports.mLocation.verticalAccuracyMeters; - data.position.speedAccuracyMetersPerSecond = - reports.mLocation.speedAccuracyMetersPerSecond; - data.position.bearingAccuracyDegrees = - reports.mLocation.bearingAccuracyDegrees; - - timeval tv_now, tv_report; - tv_report.tv_sec = reports.mLocation.mUtcReported.tv_sec; - tv_report.tv_usec = reports.mLocation.mUtcReported.tv_nsec / 1000ULL; - gettimeofday(&tv_now, NULL); - data.position.ageSeconds = - (tv_now.tv_sec - tv_report.tv_sec) + - (float)((tv_now.tv_usec - tv_report.tv_usec)) / 1000000; - } - else { - data.position.valid = false; - } - - if (data.position.horizontalAccuracyMeters <= 0 || - data.position.horizontalAccuracyMeters > GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS) { - data.position.horizontalAccuracyMeters = GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS; - } - if (data.position.verticalAccuracyMeters <= 0 || - data.position.verticalAccuracyMeters > GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS) { - data.position.verticalAccuracyMeters = GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS; - } - if (data.position.speedAccuracyMetersPerSecond <= 0 || - data.position.speedAccuracyMetersPerSecond > GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC) { - data.position.speedAccuracyMetersPerSecond = GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC; - } - if (data.position.bearingAccuracyDegrees <= 0 || - data.position.bearingAccuracyDegrees > GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG) { - data.position.bearingAccuracyDegrees = GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG; - } - - // time block - if (reports.mTime.mValid) { - data.time.timeEstimate = reports.mTime.timeEstimate; - data.time.timeUncertaintyNs = reports.mTime.timeUncertaintyNs; - data.time.frequencyUncertaintyNsPerSec = - reports.mTime.frequencyUncertaintyNsPerSec; - } - - if (data.time.timeEstimate < GNSS_DEBUG_UNKNOWN_UTC_TIME) { - data.time.timeEstimate = GNSS_DEBUG_UNKNOWN_UTC_TIME; - } - if (data.time.timeUncertaintyNs <= 0 || - data.time.timeUncertaintyNs > (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC) { - data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC; - } - if (data.time.frequencyUncertaintyNsPerSec <= 0 || - data.time.frequencyUncertaintyNsPerSec > (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC) { - data.time.frequencyUncertaintyNsPerSec = (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC; - } - - // satellite data block - SatelliteData s = { }; - std::vector s_array = { }; - - for (uint32_t i=0; i -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssDebug; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -/* Interface for GNSS Debug support. */ -struct Gnss; -struct GnssDebug : public IGnssDebug { - GnssDebug(Gnss* gnss); - ~GnssDebug() {}; - - /* - * Methods from ::android::hardware::gnss::V1_0::IGnssDebug follow. - * These declarations were generated from IGnssDebug.hal. - */ - Return getDebugData(getDebugData_cb _hidl_cb) override; - -private: - Gnss* mGnss = nullptr; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSSDEBUG_H diff --git a/gps/android/1.0/GnssGeofencing.cpp b/gps/android/1.0/GnssGeofencing.cpp deleted file mode 100644 index 2a8ff88..0000000 --- a/gps/android/1.0/GnssGeofencing.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "GnssHal_GnssGeofencing" - -#include -#include -#include "GnssGeofencing.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -void GnssGeofencing::GnssGeofencingDeathRecipient::serviceDied( - uint64_t cookie, const wp& who) { - LOC_LOGE("%s] service died. cookie: %llu, who: %p", - __FUNCTION__, static_cast(cookie), &who); - if (mGnssGeofencing != nullptr) { - mGnssGeofencing->removeAllGeofences(); - } -} - -GnssGeofencing::GnssGeofencing() : mApi(nullptr) { - mGnssGeofencingDeathRecipient = new GnssGeofencingDeathRecipient(this); -} - -GnssGeofencing::~GnssGeofencing() { - if (mApi != nullptr) { - delete mApi; - mApi = nullptr; - } -} - -// Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow. -Return GnssGeofencing::setCallback(const sp& callback) { - if (mApi != nullptr) { - LOC_LOGE("%s]: mApi is NOT nullptr", __FUNCTION__); - return Void(); - } - - mApi = new GeofenceAPIClient(callback); - if (mApi == nullptr) { - LOC_LOGE("%s]: failed to create mApi", __FUNCTION__); - } - - if (mGnssGeofencingCbIface != nullptr) { - mGnssGeofencingCbIface->unlinkToDeath(mGnssGeofencingDeathRecipient); - } - mGnssGeofencingCbIface = callback; - if (mGnssGeofencingCbIface != nullptr) { - mGnssGeofencingCbIface->linkToDeath(mGnssGeofencingDeathRecipient, 0 /*cookie*/); - } - - return Void(); -} - -Return GnssGeofencing::addGeofence( - int32_t geofenceId, - double latitudeDegrees, - double longitudeDegrees, - double radiusMeters, - IGnssGeofenceCallback::GeofenceTransition lastTransition, - int32_t monitorTransitions, - uint32_t notificationResponsivenessMs, - uint32_t unknownTimerMs) { - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - mApi->geofenceAdd( - geofenceId, - latitudeDegrees, - longitudeDegrees, - radiusMeters, - static_cast(lastTransition), - monitorTransitions, - notificationResponsivenessMs, - unknownTimerMs); - } - return Void(); -} - -Return GnssGeofencing::pauseGeofence(int32_t geofenceId) { - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - mApi->geofencePause(geofenceId); - } - return Void(); -} - -Return GnssGeofencing::resumeGeofence(int32_t geofenceId, int32_t monitorTransitions) { - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - mApi->geofenceResume(geofenceId, monitorTransitions); - } - return Void(); -} - -Return GnssGeofencing::removeGeofence(int32_t geofenceId) { - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - mApi->geofenceRemove(geofenceId); - } - return Void(); -} - -Return GnssGeofencing::removeAllGeofences() { - if (mApi == nullptr) { - LOC_LOGD("%s]: mApi is nullptr, do nothing", __FUNCTION__); - } else { - mApi->geofenceRemoveAll(); - } - return Void(); -} - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.0/GnssGeofencing.h b/gps/android/1.0/GnssGeofencing.h deleted file mode 100644 index db5f9d2..0000000 --- a/gps/android/1.0/GnssGeofencing.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_0_GNSSGEOFENCING_H -#define ANDROID_HARDWARE_GNSS_V1_0_GNSSGEOFENCING_H - -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback; -using ::android::hardware::gnss::V1_0::IGnssGeofencing; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -class GeofenceAPIClient; -struct GnssGeofencing : public IGnssGeofencing { - GnssGeofencing(); - ~GnssGeofencing(); - - /* - * Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow. - * These declarations were generated from IGnssGeofencing.hal. - */ - Return setCallback(const sp& callback) override; - Return addGeofence(int32_t geofenceId, - double latitudeDegrees, - double longitudeDegrees, - double radiusMeters, - IGnssGeofenceCallback::GeofenceTransition lastTransition, - int32_t monitorTransitions, - uint32_t notificationResponsivenessMs, - uint32_t unknownTimerMs) override; - - Return pauseGeofence(int32_t geofenceId) override; - Return resumeGeofence(int32_t geofenceId, int32_t monitorTransitions) override; - Return removeGeofence(int32_t geofenceId) override; - - private: - // This method is not part of the IGnss base class. - // It is called by GnssGeofencingDeathRecipient to remove all geofences added so far. - Return removeAllGeofences(); - - private: - struct GnssGeofencingDeathRecipient : hidl_death_recipient { - GnssGeofencingDeathRecipient(sp gnssGeofencing) : - mGnssGeofencing(gnssGeofencing) { - } - ~GnssGeofencingDeathRecipient() = default; - virtual void serviceDied(uint64_t cookie, const wp& who) override; - sp mGnssGeofencing; - }; - - private: - sp mGnssGeofencingDeathRecipient = nullptr; - sp mGnssGeofencingCbIface = nullptr; - GeofenceAPIClient* mApi = nullptr; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSSGEOFENCING_H diff --git a/gps/android/1.0/GnssMeasurement.cpp b/gps/android/1.0/GnssMeasurement.cpp deleted file mode 100644 index 1c65bd6..0000000 --- a/gps/android/1.0/GnssMeasurement.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc_GnssMeasurementInterface" - -#include -#include -#include "GnssMeasurement.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -void GnssMeasurement::GnssMeasurementDeathRecipient::serviceDied( - uint64_t cookie, const wp& who) { - LOC_LOGE("%s] service died. cookie: %llu, who: %p", - __FUNCTION__, static_cast(cookie), &who); - if (mGnssMeasurement != nullptr) { - mGnssMeasurement->close(); - } -} - -GnssMeasurement::GnssMeasurement() { - mGnssMeasurementDeathRecipient = new GnssMeasurementDeathRecipient(this); - mApi = new MeasurementAPIClient(); -} - -GnssMeasurement::~GnssMeasurement() { - if (mApi) { - delete mApi; - mApi = nullptr; - } -} - -// Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow. - -Return GnssMeasurement::setCallback( - const sp& callback) { - - Return ret = - IGnssMeasurement::GnssMeasurementStatus::ERROR_GENERIC; - if (mGnssMeasurementCbIface != nullptr) { - LOC_LOGE("%s]: GnssMeasurementCallback is already set", __FUNCTION__); - return IGnssMeasurement::GnssMeasurementStatus::ERROR_ALREADY_INIT; - } - - if (callback == nullptr) { - LOC_LOGE("%s]: callback is nullptr", __FUNCTION__); - return ret; - } - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - return ret; - } - - mGnssMeasurementCbIface = callback; - mGnssMeasurementCbIface->linkToDeath(mGnssMeasurementDeathRecipient, 0); - - return mApi->measurementSetCallback(callback); - -} - -Return GnssMeasurement::close() { - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - return Void(); - } - - if (mGnssMeasurementCbIface != nullptr) { - mGnssMeasurementCbIface->unlinkToDeath(mGnssMeasurementDeathRecipient); - mGnssMeasurementCbIface = nullptr; - } - mApi->measurementClose(); - - return Void(); -} - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.0/GnssMeasurement.h b/gps/android/1.0/GnssMeasurement.h deleted file mode 100644 index 4247dbf..0000000 --- a/gps/android/1.0/GnssMeasurement.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_0_GNSSMEASUREMENT_H -#define ANDROID_HARDWARE_GNSS_V1_0_GNSSMEASUREMENT_H - -#include -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssMeasurement; -using ::android::hardware::gnss::V1_0::IGnssMeasurementCallback; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -class MeasurementAPIClient; -struct GnssMeasurement : public IGnssMeasurement { - GnssMeasurement(); - ~GnssMeasurement(); - - /* - * Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow. - * These declarations were generated from IGnssMeasurement.hal. - */ - Return setCallback( - const sp& callback) override; - Return close() override; - - private: - struct GnssMeasurementDeathRecipient : hidl_death_recipient { - GnssMeasurementDeathRecipient(sp gnssMeasurement) : - mGnssMeasurement(gnssMeasurement) { - } - ~GnssMeasurementDeathRecipient() = default; - virtual void serviceDied(uint64_t cookie, const wp& who) override; - sp mGnssMeasurement; - }; - - private: - sp mGnssMeasurementDeathRecipient = nullptr; - sp mGnssMeasurementCbIface = nullptr; - MeasurementAPIClient* mApi; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSSMEASUREMENT_H diff --git a/gps/android/1.0/GnssNi.cpp b/gps/android/1.0/GnssNi.cpp deleted file mode 100644 index d06cc20..0000000 --- a/gps/android/1.0/GnssNi.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc_GnssNiInterface" - -#include -#include "Gnss.h" -#include "GnssNi.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -void GnssNi::GnssNiDeathRecipient::serviceDied(uint64_t cookie, const wp& who) { - LOC_LOGE("%s] service died. cookie: %llu, who: %p", - __FUNCTION__, static_cast(cookie), &who); - // we do nothing here - // Gnss::GnssDeathRecipient will stop the session -} - -GnssNi::GnssNi(Gnss* gnss) : mGnss(gnss) { - mGnssNiDeathRecipient = new GnssNiDeathRecipient(this); -} - -// Methods from ::android::hardware::gnss::V1_0::IGnssNi follow. -Return GnssNi::setCallback(const sp& callback) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return Void(); - } - - mGnss->setGnssNiCb(callback); - - if (mGnssNiCbIface != nullptr) { - mGnssNiCbIface->unlinkToDeath(mGnssNiDeathRecipient); - } - mGnssNiCbIface = callback; - if (mGnssNiCbIface != nullptr) { - mGnssNiCbIface->linkToDeath(mGnssNiDeathRecipient, 0 /*cookie*/); - } - - return Void(); -} - -Return GnssNi::respond(int32_t notifId, IGnssNiCallback::GnssUserResponseType userResponse) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return Void(); - } - - GnssAPIClient* api = mGnss->getApi(); - if (api == nullptr) { - LOC_LOGE("%s]: api is nullptr", __FUNCTION__); - return Void(); - } - - api->gnssNiRespond(notifId, userResponse); - - return Void(); -} - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.0/GnssNi.h b/gps/android/1.0/GnssNi.h deleted file mode 100644 index 90f62d5..0000000 --- a/gps/android/1.0/GnssNi.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_0_GNSSNI_H -#define ANDROID_HARDWARE_GNSS_V1_0_GNSSNI_H - -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssNi; -using ::android::hardware::gnss::V1_0::IGnssNiCallback; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -struct Gnss; -struct GnssNi : public IGnssNi { - GnssNi(Gnss* gnss); - ~GnssNi() = default; - - /* - * Methods from ::android::hardware::gnss::V1_0::IGnssNi follow. - * These declarations were generated from IGnssNi.hal. - */ - Return setCallback(const sp& callback) override; - Return respond(int32_t notifId, - IGnssNiCallback::GnssUserResponseType userResponse) override; - - private: - struct GnssNiDeathRecipient : hidl_death_recipient { - GnssNiDeathRecipient(sp gnssNi) : mGnssNi(gnssNi) { - } - ~GnssNiDeathRecipient() = default; - virtual void serviceDied(uint64_t cookie, const wp& who) override; - sp mGnssNi; - }; - - private: - sp mGnssNiDeathRecipient = nullptr; - sp mGnssNiCbIface = nullptr; - Gnss* mGnss = nullptr; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSSNI_H diff --git a/gps/android/1.0/android.hardware.gnss@1.0-service-qti.rc b/gps/android/1.0/android.hardware.gnss@1.0-service-qti.rc deleted file mode 100644 index b5da6f9..0000000 --- a/gps/android/1.0/android.hardware.gnss@1.0-service-qti.rc +++ /dev/null @@ -1,4 +0,0 @@ -service gnss_service /vendor/bin/hw/android.hardware.gnss@1.0-service-qti - class hal - user gps - group system gps radio diff --git a/gps/android/1.0/android.hardware.gnss@1.0-service-qti.xml b/gps/android/1.0/android.hardware.gnss@1.0-service-qti.xml deleted file mode 100644 index 46bcffb..0000000 --- a/gps/android/1.0/android.hardware.gnss@1.0-service-qti.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - android.hardware.gnss - hwbinder - @1.0::IGnss/default - - - diff --git a/gps/android/1.0/location_api/BatchingAPIClient.cpp b/gps/android/1.0/location_api/BatchingAPIClient.cpp deleted file mode 100644 index 264ab83..0000000 --- a/gps/android/1.0/location_api/BatchingAPIClient.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDEBUG 0 -#define LOG_TAG "LocSvc_BatchingAPIClient" - -#include -#include - -#include "LocationUtil.h" -#include "BatchingAPIClient.h" - -#include "limits.h" - - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssBatching; -using ::android::hardware::gnss::V1_0::IGnssBatchingCallback; -using ::android::hardware::gnss::V1_0::GnssLocation; - -static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions& out, - LocationCapabilitiesMask mask); - -BatchingAPIClient::BatchingAPIClient(const sp& callback) : - LocationAPIClientBase(), - mGnssBatchingCbIface(callback), - mDefaultId(UINT_MAX), - mLocationCapabilitiesMask(0) -{ - LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback); - - LocationCallbacks locationCallbacks; - memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); - locationCallbacks.size = sizeof(LocationCallbacks); - - locationCallbacks.trackingCb = nullptr; - locationCallbacks.batchingCb = nullptr; - if (mGnssBatchingCbIface != nullptr) { - locationCallbacks.batchingCb = [this](size_t count, Location* location, - BatchingOptions batchOptions) { - onBatchingCb(count, location, batchOptions); - }; - } - locationCallbacks.geofenceBreachCb = nullptr; - locationCallbacks.geofenceStatusCb = nullptr; - locationCallbacks.gnssLocationInfoCb = nullptr; - locationCallbacks.gnssNiCb = nullptr; - locationCallbacks.gnssSvCb = nullptr; - locationCallbacks.gnssNmeaCb = nullptr; - locationCallbacks.gnssMeasurementsCb = nullptr; - - locAPISetCallbacks(locationCallbacks); -} - -BatchingAPIClient::~BatchingAPIClient() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); -} - -int BatchingAPIClient::getBatchSize() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); - return locAPIGetBatchSize(); -} - -int BatchingAPIClient::startSession(const IGnssBatching::Options& opts) -{ - LOC_LOGD("%s]: (%lld %d)", __FUNCTION__, - static_cast(opts.periodNanos), static_cast(opts.flags)); - int retVal = -1; - LocationOptions options; - convertBatchOption(opts, options, mLocationCapabilitiesMask); - uint32_t mode = 0; - if (opts.flags == static_cast(IGnssBatching::Flag::WAKEUP_ON_FIFO_FULL)) { - mode = SESSION_MODE_ON_FULL; - } - if (locAPIStartSession(mDefaultId, mode, options) == LOCATION_ERROR_SUCCESS) { - retVal = 1; - } - return retVal; -} - -int BatchingAPIClient::updateSessionOptions(const IGnssBatching::Options& opts) -{ - LOC_LOGD("%s]: (%lld %d)", __FUNCTION__, - static_cast(opts.periodNanos), static_cast(opts.flags)); - int retVal = -1; - LocationOptions options; - convertBatchOption(opts, options, mLocationCapabilitiesMask); - - uint32_t mode = 0; - if (opts.flags == static_cast(IGnssBatching::Flag::WAKEUP_ON_FIFO_FULL)) { - mode = SESSION_MODE_ON_FULL; - } - if (locAPIUpdateSessionOptions(mDefaultId, mode, options) == LOCATION_ERROR_SUCCESS) { - retVal = 1; - } - return retVal; -} - -int BatchingAPIClient::stopSession() -{ - LOC_LOGD("%s]: ", __FUNCTION__); - int retVal = -1; - if (locAPIStopSession(mDefaultId) == LOCATION_ERROR_SUCCESS) { - retVal = 1; - } - return retVal; -} - -void BatchingAPIClient::getBatchedLocation(int last_n_locations) -{ - LOC_LOGD("%s]: (%d)", __FUNCTION__, last_n_locations); - locAPIGetBatchedLocations(mDefaultId, last_n_locations); -} - -void BatchingAPIClient::flushBatchedLocations() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); - locAPIGetBatchedLocations(mDefaultId, SIZE_MAX); -} - -void BatchingAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) -{ - LOC_LOGD("%s]: (%02x)", __FUNCTION__, capabilitiesMask); - mLocationCapabilitiesMask = capabilitiesMask; -} - -void BatchingAPIClient::onBatchingCb(size_t count, Location* location, - BatchingOptions /*batchOptions*/) -{ - LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, count); - if (mGnssBatchingCbIface != nullptr && count > 0) { - hidl_vec locationVec; - locationVec.resize(count); - for (size_t i = 0; i < count; i++) { - convertGnssLocation(location[i], locationVec[i]); - } - auto r = mGnssBatchingCbIface->gnssLocationBatchCb(locationVec); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssLocationBatchCb description=%s", - __func__, r.description().c_str()); - } - } -} - -static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions& out, - LocationCapabilitiesMask mask) -{ - memset(&out, 0, sizeof(LocationOptions)); - out.size = sizeof(LocationOptions); - out.minInterval = (uint32_t)(in.periodNanos / 1000000L); - out.minDistance = 0; - out.mode = GNSS_SUPL_MODE_STANDALONE; - if (mask & LOCATION_CAPABILITIES_GNSS_MSA_BIT) - out.mode = GNSS_SUPL_MODE_MSA; - if (mask & LOCATION_CAPABILITIES_GNSS_MSB_BIT) - out.mode = GNSS_SUPL_MODE_MSB; -} - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.0/location_api/BatchingAPIClient.h b/gps/android/1.0/location_api/BatchingAPIClient.h deleted file mode 100644 index 5d64df3..0000000 --- a/gps/android/1.0/location_api/BatchingAPIClient.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef BATCHING_API_CLINET_H -#define BATCHING_API_CLINET_H - -#include -#include -#include - -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -class BatchingAPIClient : public LocationAPIClientBase -{ -public: - BatchingAPIClient(const sp& callback); - ~BatchingAPIClient(); - int getBatchSize(); - int startSession(const V1_0::IGnssBatching::Options& options); - int updateSessionOptions(const V1_0::IGnssBatching::Options& options); - int stopSession(); - void getBatchedLocation(int last_n_locations); - void flushBatchedLocations(); - - inline LocationCapabilitiesMask getCapabilities() { return mLocationCapabilitiesMask; } - - // callbacks - void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final; - void onBatchingCb(size_t count, Location* location, BatchingOptions batchOptions) final; - -private: - sp mGnssBatchingCbIface; - uint32_t mDefaultId; - LocationCapabilitiesMask mLocationCapabilitiesMask; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android -#endif // BATCHING_API_CLINET_H diff --git a/gps/android/1.0/location_api/GeofenceAPIClient.cpp b/gps/android/1.0/location_api/GeofenceAPIClient.cpp deleted file mode 100644 index 774a049..0000000 --- a/gps/android/1.0/location_api/GeofenceAPIClient.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDEBUG 0 -#define LOG_TAG "LocSvc_GeofenceApiClient" - -#include -#include - -#include "LocationUtil.h" -#include "GeofenceAPIClient.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback; -using ::android::hardware::gnss::V1_0::GnssLocation; - -GeofenceAPIClient::GeofenceAPIClient(const sp& callback) : - LocationAPIClientBase(), - mGnssGeofencingCbIface(callback) -{ - LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback); - - LocationCallbacks locationCallbacks; - memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); - locationCallbacks.size = sizeof(LocationCallbacks); - - locationCallbacks.trackingCb = nullptr; - locationCallbacks.batchingCb = nullptr; - - locationCallbacks.geofenceBreachCb = nullptr; - if (mGnssGeofencingCbIface != nullptr) { - locationCallbacks.geofenceBreachCb = - [this](GeofenceBreachNotification geofenceBreachNotification) { - onGeofenceBreachCb(geofenceBreachNotification); - }; - - locationCallbacks.geofenceStatusCb = - [this](GeofenceStatusNotification geofenceStatusNotification) { - onGeofenceStatusCb(geofenceStatusNotification); - }; - } - - locationCallbacks.gnssLocationInfoCb = nullptr; - locationCallbacks.gnssNiCb = nullptr; - locationCallbacks.gnssSvCb = nullptr; - locationCallbacks.gnssNmeaCb = nullptr; - locationCallbacks.gnssMeasurementsCb = nullptr; - - locAPISetCallbacks(locationCallbacks); -} - -void GeofenceAPIClient::geofenceAdd(uint32_t geofence_id, double latitude, double longitude, - double radius_meters, int32_t last_transition, int32_t monitor_transitions, - uint32_t notification_responsiveness_ms, uint32_t unknown_timer_ms) -{ - LOC_LOGD("%s]: (%d %f %f %f %d %d %d %d)", __FUNCTION__, - geofence_id, latitude, longitude, radius_meters, - last_transition, monitor_transitions, notification_responsiveness_ms, unknown_timer_ms); - - GeofenceOption options; - memset(&options, 0, sizeof(GeofenceOption)); - options.size = sizeof(GeofenceOption); - if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::ENTERED) - options.breachTypeMask |= GEOFENCE_BREACH_ENTER_BIT; - if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::EXITED) - options.breachTypeMask |= GEOFENCE_BREACH_EXIT_BIT; - options.responsiveness = notification_responsiveness_ms; - - GeofenceInfo data; - data.size = sizeof(GeofenceInfo); - data.latitude = latitude; - data.longitude = longitude; - data.radius = radius_meters; - - LocationError err = (LocationError)locAPIAddGeofences(1, &geofence_id, &options, &data); - if (LOCATION_ERROR_SUCCESS != err) { - onAddGeofencesCb(1, &err, &geofence_id); - } -} - -void GeofenceAPIClient::geofencePause(uint32_t geofence_id) -{ - LOC_LOGD("%s]: (%d)", __FUNCTION__, geofence_id); - locAPIPauseGeofences(1, &geofence_id); -} - -void GeofenceAPIClient::geofenceResume(uint32_t geofence_id, int32_t monitor_transitions) -{ - LOC_LOGD("%s]: (%d %d)", __FUNCTION__, geofence_id, monitor_transitions); - GeofenceBreachTypeMask mask = 0; - if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::ENTERED) - mask |= GEOFENCE_BREACH_ENTER_BIT; - if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::EXITED) - mask |= GEOFENCE_BREACH_EXIT_BIT; - locAPIResumeGeofences(1, &geofence_id, &mask); -} - -void GeofenceAPIClient::geofenceRemove(uint32_t geofence_id) -{ - LOC_LOGD("%s]: (%d)", __FUNCTION__, geofence_id); - locAPIRemoveGeofences(1, &geofence_id); -} - -void GeofenceAPIClient::geofenceRemoveAll() -{ - LOC_LOGD("%s]", __FUNCTION__); - // TODO locAPIRemoveAllGeofences(); -} - -// callbacks -void GeofenceAPIClient::onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification) -{ - LOC_LOGD("%s]: (%zu)", __FUNCTION__, geofenceBreachNotification.count); - if (mGnssGeofencingCbIface != nullptr) { - for (size_t i = 0; i < geofenceBreachNotification.count; i++) { - GnssLocation gnssLocation; - convertGnssLocation(geofenceBreachNotification.location, gnssLocation); - - IGnssGeofenceCallback::GeofenceTransition transition; - if (geofenceBreachNotification.type == GEOFENCE_BREACH_ENTER) - transition = IGnssGeofenceCallback::GeofenceTransition::ENTERED; - else if (geofenceBreachNotification.type == GEOFENCE_BREACH_EXIT) - transition = IGnssGeofenceCallback::GeofenceTransition::EXITED; - else { - // continue with other breach if transition is - // nether GPS_GEOFENCE_ENTERED nor GPS_GEOFENCE_EXITED - continue; - } - - auto r = mGnssGeofencingCbIface->gnssGeofenceTransitionCb( - geofenceBreachNotification.ids[i], gnssLocation, transition, - static_cast(geofenceBreachNotification.timestamp)); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssGeofenceTransitionCb description=%s", - __func__, r.description().c_str()); - } - } - } -} - -void GeofenceAPIClient::onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification) -{ - LOC_LOGD("%s]: (%d)", __FUNCTION__, geofenceStatusNotification.available); - if (mGnssGeofencingCbIface != nullptr) { - IGnssGeofenceCallback::GeofenceAvailability status = - IGnssGeofenceCallback::GeofenceAvailability::UNAVAILABLE; - if (geofenceStatusNotification.available == GEOFENCE_STATUS_AVAILABILE_YES) { - status = IGnssGeofenceCallback::GeofenceAvailability::AVAILABLE; - } - GnssLocation gnssLocation; - memset(&gnssLocation, 0, sizeof(GnssLocation)); - auto r = mGnssGeofencingCbIface->gnssGeofenceStatusCb(status, gnssLocation); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssGeofenceStatusCb description=%s", - __func__, r.description().c_str()); - } - } -} - -void GeofenceAPIClient::onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) -{ - LOC_LOGD("%s]: (%zu)", __FUNCTION__, count); - if (mGnssGeofencingCbIface != nullptr) { - for (size_t i = 0; i < count; i++) { - IGnssGeofenceCallback::GeofenceStatus status = - IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC; - if (errors[i] == LOCATION_ERROR_SUCCESS) - status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS; - else if (errors[i] == LOCATION_ERROR_ID_EXISTS) - status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_EXISTS; - auto r = mGnssGeofencingCbIface->gnssGeofenceAddCb(ids[i], status); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssGeofenceAddCb description=%s", - __func__, r.description().c_str()); - } - } - } -} - -void GeofenceAPIClient::onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) -{ - LOC_LOGD("%s]: (%zu)", __FUNCTION__, count); - if (mGnssGeofencingCbIface != nullptr) { - for (size_t i = 0; i < count; i++) { - IGnssGeofenceCallback::GeofenceStatus status = - IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC; - if (errors[i] == LOCATION_ERROR_SUCCESS) - status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS; - else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN) - status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN; - auto r = mGnssGeofencingCbIface->gnssGeofenceRemoveCb(ids[i], status); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssGeofenceRemoveCb description=%s", - __func__, r.description().c_str()); - } - } - } -} - -void GeofenceAPIClient::onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) -{ - LOC_LOGD("%s]: (%zu)", __FUNCTION__, count); - if (mGnssGeofencingCbIface != nullptr) { - for (size_t i = 0; i < count; i++) { - IGnssGeofenceCallback::GeofenceStatus status = - IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC; - if (errors[i] == LOCATION_ERROR_SUCCESS) - status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS; - else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN) - status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN; - auto r = mGnssGeofencingCbIface->gnssGeofencePauseCb(ids[i], status); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssGeofencePauseCb description=%s", - __func__, r.description().c_str()); - } - } - } -} - -void GeofenceAPIClient::onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) -{ - LOC_LOGD("%s]: (%zu)", __FUNCTION__, count); - if (mGnssGeofencingCbIface != nullptr) { - for (size_t i = 0; i < count; i++) { - IGnssGeofenceCallback::GeofenceStatus status = - IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC; - if (errors[i] == LOCATION_ERROR_SUCCESS) - status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS; - else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN) - status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN; - auto r = mGnssGeofencingCbIface->gnssGeofenceResumeCb(ids[i], status); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssGeofenceResumeCb description=%s", - __func__, r.description().c_str()); - } - } - } -} - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.0/location_api/GeofenceAPIClient.h b/gps/android/1.0/location_api/GeofenceAPIClient.h deleted file mode 100644 index dc99ddd..0000000 --- a/gps/android/1.0/location_api/GeofenceAPIClient.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GEOFENCE_API_CLINET_H -#define GEOFENCE_API_CLINET_H - - -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::sp; - -class GeofenceAPIClient : public LocationAPIClientBase -{ -public: - GeofenceAPIClient(const sp& 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, - uint32_t notification_responsiveness_ms, uint32_t unknown_timer_ms); - void geofencePause(uint32_t geofence_id); - void geofenceResume(uint32_t geofence_id, int32_t monitor_transitions); - void geofenceRemove(uint32_t geofence_id); - void geofenceRemoveAll(); - - // callbacks - void onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification) final; - void onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification) final; - void onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final; - void onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final; - void onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final; - void onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final; - -private: - sp mGnssGeofencingCbIface; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android -#endif // GEOFENCE_API_CLINET_H diff --git a/gps/android/1.0/location_api/GnssAPIClient.cpp b/gps/android/1.0/location_api/GnssAPIClient.cpp deleted file mode 100644 index a36d2b4..0000000 --- a/gps/android/1.0/location_api/GnssAPIClient.cpp +++ /dev/null @@ -1,565 +0,0 @@ -/* Copyright (c) 2017-2019, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDEBUG 0 -#define LOG_TAG "LocSvc_GnssAPIClient" -#define SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC (590 * 60 * 60 * 1000) // 590 hours - -#include -#include - -#include "LocationUtil.h" -#include "GnssAPIClient.h" -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnss; -using ::android::hardware::gnss::V1_0::IGnssCallback; -using ::android::hardware::gnss::V1_0::IGnssNiCallback; -using ::android::hardware::gnss::V1_0::GnssLocation; - -static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvStatus& out); - -GnssAPIClient::GnssAPIClient(const sp& gpsCb, - const sp& niCb) : - LocationAPIClientBase(), - mGnssCbIface(nullptr), - mGnssNiCbIface(nullptr), - mControlClient(new LocationAPIControlClient()), - mLocationCapabilitiesMask(0), - mLocationCapabilitiesCached(false) -{ - LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb); - - // set default LocationOptions. - memset(&mTrackingOptions, 0, sizeof(TrackingOptions)); - mTrackingOptions.size = sizeof(TrackingOptions); - mTrackingOptions.minInterval = 1000; - mTrackingOptions.minDistance = 0; - mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE; - - gnssUpdateCallbacks(gpsCb, niCb); -} - -GnssAPIClient::~GnssAPIClient() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); - if (mControlClient) { - delete mControlClient; - mControlClient = nullptr; - } -} - -// for GpsInterface -void GnssAPIClient::gnssUpdateCallbacks(const sp& gpsCb, - const sp& niCb) -{ - LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb); - - mMutex.lock(); - mGnssCbIface = gpsCb; - mGnssNiCbIface = niCb; - mMutex.unlock(); - - LocationCallbacks locationCallbacks; - memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); - locationCallbacks.size = sizeof(LocationCallbacks); - - locationCallbacks.trackingCb = nullptr; - if (mGnssCbIface != nullptr) { - locationCallbacks.trackingCb = [this](Location location) { - onTrackingCb(location); - }; - } - - locationCallbacks.batchingCb = nullptr; - locationCallbacks.geofenceBreachCb = nullptr; - locationCallbacks.geofenceStatusCb = nullptr; - locationCallbacks.gnssLocationInfoCb = nullptr; - - locationCallbacks.gnssNiCb = nullptr; - loc_core::ContextBase* context = - loc_core::LocContext::getLocContext( - NULL, NULL, - loc_core::LocContext::mLocationHalName, false); - if (mGnssNiCbIface != nullptr && !context->hasAgpsExtendedCapabilities()) { - LOC_LOGD("Registering NI CB"); - locationCallbacks.gnssNiCb = [this](uint32_t id, GnssNiNotification gnssNiNotification) { - onGnssNiCb(id, gnssNiNotification); - }; - } - - locationCallbacks.gnssSvCb = nullptr; - if (mGnssCbIface != nullptr) { - locationCallbacks.gnssSvCb = [this](GnssSvNotification gnssSvNotification) { - onGnssSvCb(gnssSvNotification); - }; - } - - locationCallbacks.gnssNmeaCb = nullptr; - if (mGnssCbIface != nullptr) { - locationCallbacks.gnssNmeaCb = [this](GnssNmeaNotification gnssNmeaNotification) { - onGnssNmeaCb(gnssNmeaNotification); - }; - } - - locationCallbacks.gnssMeasurementsCb = nullptr; - - locAPISetCallbacks(locationCallbacks); -} - -bool GnssAPIClient::gnssStart() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); - bool retVal = true; - locAPIStartTracking(mTrackingOptions); - return retVal; -} - -bool GnssAPIClient::gnssStop() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); - bool retVal = true; - locAPIStopTracking(); - return retVal; -} - -bool GnssAPIClient::gnssSetPositionMode(IGnss::GnssPositionMode mode, - IGnss::GnssPositionRecurrence recurrence, uint32_t minIntervalMs, - uint32_t preferredAccuracyMeters, uint32_t preferredTimeMs, - GnssPowerMode powerMode, uint32_t timeBetweenMeasurement) -{ - LOC_LOGD("%s]: (%d %d %d %d %d %d %d)", __FUNCTION__, - (int)mode, recurrence, minIntervalMs, preferredAccuracyMeters, - preferredTimeMs, (int)powerMode, timeBetweenMeasurement); - bool retVal = true; - memset(&mTrackingOptions, 0, sizeof(TrackingOptions)); - mTrackingOptions.size = sizeof(TrackingOptions); - mTrackingOptions.minInterval = minIntervalMs; - if (IGnss::GnssPositionMode::MS_ASSISTED == mode || - IGnss::GnssPositionRecurrence::RECURRENCE_SINGLE == recurrence) { - // We set a very large interval to simulate SINGLE mode. Once we report a fix, - // the caller should take the responsibility to stop the session. - // For MSA, we always treat it as SINGLE mode. - mTrackingOptions.minInterval = SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC; - } - mTrackingOptions.minDistance = preferredAccuracyMeters; - if (mode == IGnss::GnssPositionMode::STANDALONE) - mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE; - else if (mode == IGnss::GnssPositionMode::MS_BASED) - mTrackingOptions.mode = GNSS_SUPL_MODE_MSB; - else if (mode == IGnss::GnssPositionMode::MS_ASSISTED) - mTrackingOptions.mode = GNSS_SUPL_MODE_MSA; - else { - LOC_LOGD("%s]: invalid GnssPositionMode: %d", __FUNCTION__, (int)mode); - retVal = false; - } - if (GNSS_POWER_MODE_INVALID != powerMode) { - mTrackingOptions.powerMode = powerMode; - mTrackingOptions.tbm = timeBetweenMeasurement; - } - locAPIUpdateTrackingOptions(mTrackingOptions); - return retVal; -} - -// for GpsNiInterface -void GnssAPIClient::gnssNiRespond(int32_t notifId, - IGnssNiCallback::GnssUserResponseType userResponse) -{ - LOC_LOGD("%s]: (%d %d)", __FUNCTION__, notifId, static_cast(userResponse)); - GnssNiResponse data; - switch (userResponse) { - case IGnssNiCallback::GnssUserResponseType::RESPONSE_ACCEPT: - data = GNSS_NI_RESPONSE_ACCEPT; - break; - case IGnssNiCallback::GnssUserResponseType::RESPONSE_DENY: - data = GNSS_NI_RESPONSE_DENY; - break; - case IGnssNiCallback::GnssUserResponseType::RESPONSE_NORESP: - data = GNSS_NI_RESPONSE_NO_RESPONSE; - break; - default: - data = GNSS_NI_RESPONSE_IGNORE; - break; - } - - locAPIGnssNiResponse(notifId, data); -} - -// these apis using LocationAPIControlClient -void GnssAPIClient::gnssDeleteAidingData(IGnss::GnssAidingData aidingDataFlags) -{ - LOC_LOGD("%s]: (%02hx)", __FUNCTION__, aidingDataFlags); - if (mControlClient == nullptr) { - return; - } - GnssAidingData data; - memset(&data, 0, sizeof (GnssAidingData)); - data.sv.svTypeMask = GNSS_AIDING_DATA_SV_TYPE_GPS_BIT | - GNSS_AIDING_DATA_SV_TYPE_GLONASS_BIT | - GNSS_AIDING_DATA_SV_TYPE_QZSS_BIT | - GNSS_AIDING_DATA_SV_TYPE_BEIDOU_BIT | - GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT; - - if (aidingDataFlags == IGnss::GnssAidingData::DELETE_ALL) - data.deleteAll = true; - else { - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_EPHEMERIS) - data.sv.svMask |= GNSS_AIDING_DATA_SV_EPHEMERIS_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_ALMANAC) - data.sv.svMask |= GNSS_AIDING_DATA_SV_ALMANAC_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_POSITION) - data.common.mask |= GNSS_AIDING_DATA_COMMON_POSITION_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_TIME) - data.common.mask |= GNSS_AIDING_DATA_COMMON_TIME_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_IONO) - data.sv.svMask |= GNSS_AIDING_DATA_SV_IONOSPHERE_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_UTC) - data.common.mask |= GNSS_AIDING_DATA_COMMON_UTC_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_HEALTH) - data.sv.svMask |= GNSS_AIDING_DATA_SV_HEALTH_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SVDIR) - data.sv.svMask |= GNSS_AIDING_DATA_SV_DIRECTION_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SVSTEER) - data.sv.svMask |= GNSS_AIDING_DATA_SV_STEER_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SADATA) - data.sv.svMask |= GNSS_AIDING_DATA_SV_SA_DATA_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_RTI) - data.common.mask |= GNSS_AIDING_DATA_COMMON_RTI_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_CELLDB_INFO) - data.common.mask |= GNSS_AIDING_DATA_COMMON_CELLDB_BIT; - } - mControlClient->locAPIGnssDeleteAidingData(data); -} - -void GnssAPIClient::gnssEnable(LocationTechnologyType techType) -{ - LOC_LOGD("%s]: (%0d)", __FUNCTION__, techType); - if (mControlClient == nullptr) { - return; - } - mControlClient->locAPIEnable(techType); -} - -void GnssAPIClient::gnssDisable() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); - if (mControlClient == nullptr) { - return; - } - mControlClient->locAPIDisable(); -} - -void GnssAPIClient::gnssConfigurationUpdate(const GnssConfig& gnssConfig) -{ - LOC_LOGD("%s]: (%02x)", __FUNCTION__, gnssConfig.flags); - if (mControlClient == nullptr) { - return; - } - mControlClient->locAPIGnssUpdateConfig(gnssConfig); -} - -void GnssAPIClient::requestCapabilities() { - // only send capablities if it's already cached, otherwise the first time LocationAPI - // is initialized, capabilities will be sent by LocationAPI - if (mLocationCapabilitiesCached) { - onCapabilitiesCb(mLocationCapabilitiesMask); - } -} - -// callbacks -void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) -{ - LOC_LOGD("%s]: (%02x)", __FUNCTION__, capabilitiesMask); - mLocationCapabilitiesMask = capabilitiesMask; - mLocationCapabilitiesCached = true; - - mMutex.lock(); - auto gnssCbIface(mGnssCbIface); - mMutex.unlock(); - - if (gnssCbIface != nullptr) { - uint32_t data = 0; - if ((capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT) || - (capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT) || - (capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT) || - (capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT)) - data |= IGnssCallback::Capabilities::SCHEDULING; - if (capabilitiesMask & LOCATION_CAPABILITIES_GEOFENCE_BIT) - data |= IGnssCallback::Capabilities::GEOFENCING; - if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT) - data |= IGnssCallback::Capabilities::MEASUREMENTS; - if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSB_BIT) - data |= IGnssCallback::Capabilities::MSB; - if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSA_BIT) - data |= IGnssCallback::Capabilities::MSA; - auto r = gnssCbIface->gnssSetCapabilitesCb(data); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssSetCapabilitesCb description=%s", - __func__, r.description().c_str()); - } - } - 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; - } - LOC_LOGV("%s:%d] set_system_info_cb (%d)", __FUNCTION__, __LINE__, gnssInfo.yearOfHw); - auto r = gnssCbIface->gnssSetSystemInfoCb(gnssInfo); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssSetSystemInfoCb description=%s", - __func__, r.description().c_str()); - } - } -} - -void GnssAPIClient::onTrackingCb(Location location) -{ - LOC_LOGD("%s]: (flags: %02x)", __FUNCTION__, location.flags); - mMutex.lock(); - auto gnssCbIface(mGnssCbIface); - mMutex.unlock(); - - if (gnssCbIface != nullptr) { - GnssLocation gnssLocation; - convertGnssLocation(location, gnssLocation); - auto r = gnssCbIface->gnssLocationCb(gnssLocation); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssLocationCb description=%s", - __func__, r.description().c_str()); - } - } -} - -void GnssAPIClient::onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification) -{ - LOC_LOGD("%s]: (id: %d)", __FUNCTION__, id); - mMutex.lock(); - auto gnssNiCbIface(mGnssNiCbIface); - mMutex.unlock(); - - if (gnssNiCbIface == nullptr) { - LOC_LOGE("%s]: mGnssNiCbIface is nullptr", __FUNCTION__); - return; - } - - IGnssNiCallback::GnssNiNotification notificationGnss = {}; - - notificationGnss.notificationId = id; - - if (gnssNiNotification.type == GNSS_NI_TYPE_VOICE) - notificationGnss.niType = IGnssNiCallback::GnssNiType::VOICE; - else if (gnssNiNotification.type == GNSS_NI_TYPE_SUPL) - notificationGnss.niType = IGnssNiCallback::GnssNiType::UMTS_SUPL; - else if (gnssNiNotification.type == GNSS_NI_TYPE_CONTROL_PLANE) - notificationGnss.niType = IGnssNiCallback::GnssNiType::UMTS_CTRL_PLANE; - else if (gnssNiNotification.type == GNSS_NI_TYPE_EMERGENCY_SUPL) - notificationGnss.niType = IGnssNiCallback::GnssNiType::EMERGENCY_SUPL; - - if (gnssNiNotification.options & GNSS_NI_OPTIONS_NOTIFICATION_BIT) - notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::NEED_NOTIFY; - if (gnssNiNotification.options & GNSS_NI_OPTIONS_VERIFICATION_BIT) - notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::NEED_VERIFY; - if (gnssNiNotification.options & GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT) - notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::PRIVACY_OVERRIDE; - - notificationGnss.timeoutSec = gnssNiNotification.timeout; - - if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_ACCEPT) - notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_ACCEPT; - else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_DENY) - notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_DENY; - else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_NO_RESPONSE || - gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_IGNORE) - notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_NORESP; - - notificationGnss.requestorId = gnssNiNotification.requestor; - - notificationGnss.notificationMessage = gnssNiNotification.message; - - if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_NONE) - notificationGnss.requestorIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_NONE; - else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT) - notificationGnss.requestorIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_GSM_DEFAULT; - else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UTF8) - notificationGnss.requestorIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UTF8; - else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UCS2) - notificationGnss.requestorIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UCS2; - - if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_NONE) - notificationGnss.notificationIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_NONE; - else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT) - notificationGnss.notificationIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_GSM_DEFAULT; - else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UTF8) - notificationGnss.notificationIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UTF8; - else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UCS2) - notificationGnss.notificationIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UCS2; - - gnssNiCbIface->niNotifyCb(notificationGnss); -} - -void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification) -{ - LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, gnssSvNotification.count); - mMutex.lock(); - auto gnssCbIface(mGnssCbIface); - mMutex.unlock(); - - if (gnssCbIface != nullptr) { - IGnssCallback::GnssSvStatus svStatus; - convertGnssSvStatus(gnssSvNotification, svStatus); - auto r = gnssCbIface->gnssSvStatusCb(svStatus); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssSvStatusCb description=%s", - __func__, r.description().c_str()); - } - } -} - -void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification) -{ - mMutex.lock(); - auto gnssCbIface(mGnssCbIface); - mMutex.unlock(); - - if (gnssCbIface != nullptr) { - const std::string s(gnssNmeaNotification.nmea); - std::stringstream ss(s); - std::string each; - while(std::getline(ss, each, '\n')) { - each += '\n'; - android::hardware::hidl_string nmeaString; - nmeaString.setToExternal(each.c_str(), each.length()); - auto r = gnssCbIface->gnssNmeaCb( - static_cast(gnssNmeaNotification.timestamp), nmeaString); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssNmeaCb nmea=%s length=%zu description=%s", __func__, - gnssNmeaNotification.nmea, gnssNmeaNotification.length, - r.description().c_str()); - } - } - } -} - -void GnssAPIClient::onStartTrackingCb(LocationError error) -{ - LOC_LOGD("%s]: (%d)", __FUNCTION__, error); - mMutex.lock(); - auto gnssCbIface(mGnssCbIface); - mMutex.unlock(); - - if (error == LOCATION_ERROR_SUCCESS && gnssCbIface != nullptr) { - auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_ON); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssStatusCb ENGINE_ON description=%s", - __func__, r.description().c_str()); - } - r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_BEGIN); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssStatusCb SESSION_BEGIN description=%s", - __func__, r.description().c_str()); - } - } -} - -void GnssAPIClient::onStopTrackingCb(LocationError error) -{ - LOC_LOGD("%s]: (%d)", __FUNCTION__, error); - mMutex.lock(); - auto gnssCbIface(mGnssCbIface); - mMutex.unlock(); - - if (error == LOCATION_ERROR_SUCCESS && gnssCbIface != nullptr) { - auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_END); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssStatusCb SESSION_END description=%s", - __func__, r.description().c_str()); - } - r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_OFF); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssStatusCb ENGINE_OFF description=%s", - __func__, r.description().c_str()); - } - } -} - -static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvStatus& out) -{ - memset(&out, 0, sizeof(IGnssCallback::GnssSvStatus)); - out.numSvs = in.count; - if (out.numSvs > static_cast(V1_0::GnssMax::SVS_COUNT)) { - LOC_LOGW("%s]: Too many satellites %u. Clamps to %d.", - __FUNCTION__, out.numSvs, V1_0::GnssMax::SVS_COUNT); - out.numSvs = static_cast(V1_0::GnssMax::SVS_COUNT); - } - for (size_t i = 0; i < out.numSvs; i++) { - IGnssCallback::GnssSvInfo& info = out.gnssSvList[i]; - info.svid = in.gnssSvs[i].svId; - convertGnssConstellationType(in.gnssSvs[i].type, info.constellation); - info.cN0Dbhz = in.gnssSvs[i].cN0Dbhz; - info.elevationDegrees = in.gnssSvs[i].elevation; - info.azimuthDegrees = in.gnssSvs[i].azimuth; - info.carrierFrequencyHz = in.gnssSvs[i].carrierFrequencyHz; - info.svFlag = static_cast(IGnssCallback::GnssSvFlags::NONE); - if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_EPHEMER_BIT) - info.svFlag |= IGnssCallback::GnssSvFlags::HAS_EPHEMERIS_DATA; - if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_ALMANAC_BIT) - info.svFlag |= IGnssCallback::GnssSvFlags::HAS_ALMANAC_DATA; - if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT) - info.svFlag |= IGnssCallback::GnssSvFlags::USED_IN_FIX; - if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_CARRIER_FREQUENCY_BIT) - info.svFlag |= IGnssCallback::GnssSvFlags::HAS_CARRIER_FREQUENCY; - } -} - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.0/location_api/GnssAPIClient.h b/gps/android/1.0/location_api/GnssAPIClient.h deleted file mode 100644 index 4e4b4a9..0000000 --- a/gps/android/1.0/location_api/GnssAPIClient.h +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GNSS_API_CLINET_H -#define GNSS_API_CLINET_H - - -#include -#include -#include -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::sp; - -class GnssAPIClient : public LocationAPIClientBase -{ -public: - GnssAPIClient(const sp& gpsCb, - const sp& niCb); - virtual ~GnssAPIClient(); - GnssAPIClient(const GnssAPIClient&) = delete; - GnssAPIClient& operator=(const GnssAPIClient&) = delete; - - // for GpsInterface - void gnssUpdateCallbacks(const sp& gpsCb, - const sp& niCb); - bool gnssStart(); - bool gnssStop(); - bool gnssSetPositionMode(V1_0::IGnss::GnssPositionMode mode, - V1_0::IGnss::GnssPositionRecurrence recurrence, - uint32_t minIntervalMs, - uint32_t preferredAccuracyMeters, - uint32_t preferredTimeMs, - GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID, - uint32_t timeBetweenMeasurement = 0); - - // for GpsNiInterface - void gnssNiRespond(int32_t notifId, V1_0::IGnssNiCallback::GnssUserResponseType userResponse); - - // these apis using LocationAPIControlClient - void gnssDeleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags); - void gnssEnable(LocationTechnologyType techType); - void gnssDisable(); - void gnssConfigurationUpdate(const GnssConfig& gnssConfig); - - inline LocationCapabilitiesMask gnssGetCapabilities() const { - return mLocationCapabilitiesMask; - } - void requestCapabilities(); - - // callbacks we are interested in - void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final; - void onTrackingCb(Location location) final; - void onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification) final; - void onGnssSvCb(GnssSvNotification gnssSvNotification) final; - void onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification) final; - - void onStartTrackingCb(LocationError error) final; - void onStopTrackingCb(LocationError error) final; - -private: - sp mGnssCbIface; - sp mGnssNiCbIface; - std::mutex mMutex; - LocationAPIControlClient* mControlClient; - LocationCapabilitiesMask mLocationCapabilitiesMask; - bool mLocationCapabilitiesCached; - TrackingOptions mTrackingOptions; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android -#endif // GNSS_API_CLINET_H diff --git a/gps/android/1.0/location_api/LocationUtil.cpp b/gps/android/1.0/location_api/LocationUtil.cpp deleted file mode 100644 index 102593b..0000000 --- a/gps/android/1.0/location_api/LocationUtil.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::GnssLocation; -using ::android::hardware::gnss::V1_0::GnssConstellationType; -using ::android::hardware::gnss::V1_0::GnssLocationFlags; - -void convertGnssLocation(Location& in, GnssLocation& out) -{ - memset(&out, 0, sizeof(GnssLocation)); - if (in.flags & LOCATION_HAS_LAT_LONG_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_LAT_LONG; - out.latitudeDegrees = in.latitude; - out.longitudeDegrees = in.longitude; - } - if (in.flags & LOCATION_HAS_ALTITUDE_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_ALTITUDE; - out.altitudeMeters = in.altitude; - } - if (in.flags & LOCATION_HAS_SPEED_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED; - out.speedMetersPerSec = in.speed; - } - if (in.flags & LOCATION_HAS_BEARING_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING; - out.bearingDegrees = in.bearing; - } - if (in.flags & LOCATION_HAS_ACCURACY_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_HORIZONTAL_ACCURACY; - out.horizontalAccuracyMeters = in.accuracy; - } - if (in.flags & LOCATION_HAS_VERTICAL_ACCURACY_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_VERTICAL_ACCURACY; - out.verticalAccuracyMeters = in.verticalAccuracy; - } - if (in.flags & LOCATION_HAS_SPEED_ACCURACY_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED_ACCURACY; - out.speedAccuracyMetersPerSecond = in.speedAccuracy; - } - if (in.flags & LOCATION_HAS_BEARING_ACCURACY_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING_ACCURACY; - out.bearingAccuracyDegrees = in.bearingAccuracy; - } - - out.timestamp = static_cast(in.timestamp); -} - -void convertGnssLocation(const GnssLocation& in, Location& out) -{ - memset(&out, 0, sizeof(out)); - if (in.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG) { - out.flags |= LOCATION_HAS_LAT_LONG_BIT; - out.latitude = in.latitudeDegrees; - out.longitude = in.longitudeDegrees; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE) { - out.flags |= LOCATION_HAS_ALTITUDE_BIT; - out.altitude = in.altitudeMeters; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED) { - out.flags |= LOCATION_HAS_SPEED_BIT; - out.speed = in.speedMetersPerSec; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) { - out.flags |= LOCATION_HAS_BEARING_BIT; - out.bearing = in.bearingDegrees; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY) { - out.flags |= LOCATION_HAS_ACCURACY_BIT; - out.accuracy = in.horizontalAccuracyMeters; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) { - out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT; - out.verticalAccuracy = in.verticalAccuracyMeters; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) { - out.flags |= LOCATION_HAS_SPEED_ACCURACY_BIT; - out.speedAccuracy = in.speedAccuracyMetersPerSecond; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) { - out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT; - out.bearingAccuracy = in.bearingAccuracyDegrees; - } - - out.timestamp = static_cast(in.timestamp); -} - -void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out) -{ - switch(in) { - case GNSS_SV_TYPE_GPS: - out = GnssConstellationType::GPS; - break; - case GNSS_SV_TYPE_SBAS: - out = GnssConstellationType::SBAS; - break; - case GNSS_SV_TYPE_GLONASS: - out = GnssConstellationType::GLONASS; - break; - case GNSS_SV_TYPE_QZSS: - out = GnssConstellationType::QZSS; - break; - case GNSS_SV_TYPE_BEIDOU: - out = GnssConstellationType::BEIDOU; - break; - case GNSS_SV_TYPE_GALILEO: - out = GnssConstellationType::GALILEO; - break; - case GNSS_SV_TYPE_UNKNOWN: - default: - out = GnssConstellationType::UNKNOWN; - break; - } -} - -void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out) -{ - switch(in) { - case GNSS_EPH_TYPE_EPHEMERIS: - out = GnssDebug::SatelliteEphemerisType::EPHEMERIS; - break; - case GNSS_EPH_TYPE_ALMANAC: - out = GnssDebug::SatelliteEphemerisType::ALMANAC_ONLY; - break; - case GNSS_EPH_TYPE_UNKNOWN: - default: - out = GnssDebug::SatelliteEphemerisType::NOT_AVAILABLE; - break; - } -} - -void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out) -{ - switch(in) { - case GNSS_EPH_SOURCE_DEMODULATED: - out = GnssDebug::SatelliteEphemerisSource::DEMODULATED; - break; - case GNSS_EPH_SOURCE_SUPL_PROVIDED: - out = GnssDebug::SatelliteEphemerisSource::SUPL_PROVIDED; - break; - case GNSS_EPH_SOURCE_OTHER_SERVER_PROVIDED: - out = GnssDebug::SatelliteEphemerisSource::OTHER_SERVER_PROVIDED; - break; - case GNSS_EPH_SOURCE_LOCAL: - case GNSS_EPH_SOURCE_UNKNOWN: - default: - out = GnssDebug::SatelliteEphemerisSource::OTHER; - break; - } -} - -void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out) -{ - switch(in) { - case GNSS_EPH_HEALTH_GOOD: - out = GnssDebug::SatelliteEphemerisHealth::GOOD; - break; - case GNSS_EPH_HEALTH_BAD: - out = GnssDebug::SatelliteEphemerisHealth::BAD; - break; - case GNSS_EPH_HEALTH_UNKNOWN: - default: - out = GnssDebug::SatelliteEphemerisHealth::UNKNOWN; - break; - } -} - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.0/location_api/LocationUtil.h b/gps/android/1.0/location_api/LocationUtil.h deleted file mode 100644 index 9e0cd36..0000000 --- a/gps/android/1.0/location_api/LocationUtil.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef LOCATION_UTIL_H -#define LOCATION_UTIL_H - -#include -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -void convertGnssLocation(Location& in, V1_0::GnssLocation& out); -void convertGnssLocation(const V1_0::GnssLocation& in, Location& out); -void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out); -void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out); -void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out); -void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out); - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android -#endif // LOCATION_UTIL_H diff --git a/gps/android/1.0/location_api/MeasurementAPIClient.cpp b/gps/android/1.0/location_api/MeasurementAPIClient.cpp deleted file mode 100644 index 73709e3..0000000 --- a/gps/android/1.0/location_api/MeasurementAPIClient.cpp +++ /dev/null @@ -1,276 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDEBUG 0 -#define LOG_TAG "LocSvc_MeasurementAPIClient" - -#include -#include - -#include "LocationUtil.h" -#include "MeasurementAPIClient.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssMeasurement; -using ::android::hardware::gnss::V1_0::IGnssMeasurementCallback; - -static void convertGnssData(GnssMeasurementsNotification& in, - V1_0::IGnssMeasurementCallback::GnssData& out); -static void convertGnssMeasurement(GnssMeasurementsData& in, - V1_0::IGnssMeasurementCallback::GnssMeasurement& out); -static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out); - -MeasurementAPIClient::MeasurementAPIClient() : - mGnssMeasurementCbIface(nullptr), - mTracking(false) -{ - LOC_LOGD("%s]: ()", __FUNCTION__); -} - -MeasurementAPIClient::~MeasurementAPIClient() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); -} - -// for GpsInterface -Return -MeasurementAPIClient::measurementSetCallback(const sp& callback) -{ - LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback); - - mMutex.lock(); - mGnssMeasurementCbIface = callback; - mMutex.unlock(); - - return startTracking(); -} - -Return -MeasurementAPIClient::startTracking() -{ - LocationCallbacks locationCallbacks; - memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); - locationCallbacks.size = sizeof(LocationCallbacks); - - locationCallbacks.trackingCb = nullptr; - locationCallbacks.batchingCb = nullptr; - locationCallbacks.geofenceBreachCb = nullptr; - locationCallbacks.geofenceStatusCb = nullptr; - locationCallbacks.gnssLocationInfoCb = nullptr; - locationCallbacks.gnssNiCb = nullptr; - locationCallbacks.gnssSvCb = nullptr; - locationCallbacks.gnssNmeaCb = nullptr; - - locationCallbacks.gnssMeasurementsCb = nullptr; - if (mGnssMeasurementCbIface != nullptr) { - locationCallbacks.gnssMeasurementsCb = - [this](GnssMeasurementsNotification gnssMeasurementsNotification) { - onGnssMeasurementsCb(gnssMeasurementsNotification); - }; - } - - locAPISetCallbacks(locationCallbacks); - - TrackingOptions options = {}; - memset(&options, 0, sizeof(TrackingOptions)); - options.size = sizeof(TrackingOptions); - options.minInterval = 1000; - options.mode = GNSS_SUPL_MODE_STANDALONE; - - mTracking = true; - LOC_LOGD("%s]: start tracking session", __FUNCTION__); - locAPIStartTracking(options); - return IGnssMeasurement::GnssMeasurementStatus::SUCCESS; -} - -// for GpsMeasurementInterface -void MeasurementAPIClient::measurementClose() { - LOC_LOGD("%s]: ()", __FUNCTION__); - mTracking = false; - locAPIStopTracking(); -} - -// callbacks -void MeasurementAPIClient::onGnssMeasurementsCb( - GnssMeasurementsNotification gnssMeasurementsNotification) -{ - LOC_LOGD("%s]: (count: %zu active: %d)", - __FUNCTION__, gnssMeasurementsNotification.count, mTracking); - if (mTracking) { - mMutex.lock(); - sp gnssMeasurementCbIface = nullptr; - if (mGnssMeasurementCbIface != nullptr) { - gnssMeasurementCbIface = mGnssMeasurementCbIface; - } - mMutex.unlock(); - - if (gnssMeasurementCbIface != nullptr) { - V1_0::IGnssMeasurementCallback::GnssData gnssData; - convertGnssData(gnssMeasurementsNotification, gnssData); - auto r = gnssMeasurementCbIface->GnssMeasurementCb(gnssData); - if (!r.isOk()) { - LOC_LOGE("%s] Error from GnssMeasurementCb description=%s", - __func__, r.description().c_str()); - } - } - } -} - -static void convertGnssMeasurement(GnssMeasurementsData& in, - V1_0::IGnssMeasurementCallback::GnssMeasurement& out) -{ - memset(&out, 0, sizeof(IGnssMeasurementCallback::GnssMeasurement)); - if (in.flags & GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT) - out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_SNR; - if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT) - out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_FREQUENCY; - if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT) - out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_CYCLES; - if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT) - out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE; - if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT) - out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE_UNCERTAINTY; - if (in.flags & GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT) - out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_AUTOMATIC_GAIN_CONTROL; - out.svid = in.svId; - convertGnssConstellationType(in.svType, out.constellation); - out.timeOffsetNs = in.timeOffsetNs; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_CODE_LOCK; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BIT_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SUBFRAME_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_DECODED; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_MSEC_AMBIGUOUS; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SYMBOL_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_STRING_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_DECODED; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_BIT_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_SUBFRAME_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1BC_CODE_LOCK; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1C_2ND_CODE_LOCK; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1B_PAGE_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SBAS_SYNC; - out.receivedSvTimeInNs = in.receivedSvTimeNs; - out.receivedSvTimeUncertaintyInNs = in.receivedSvTimeUncertaintyNs; - out.cN0DbHz = in.carrierToNoiseDbHz; - out.pseudorangeRateMps = in.pseudorangeRateMps; - out.pseudorangeRateUncertaintyMps = in.pseudorangeRateUncertaintyMps; - if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT) - out.accumulatedDeltaRangeState |= - IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID; - if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT) - out.accumulatedDeltaRangeState |= - IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET; - if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT) - out.accumulatedDeltaRangeState |= - IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP; - out.accumulatedDeltaRangeM = in.adrMeters; - out.accumulatedDeltaRangeUncertaintyM = in.adrUncertaintyMeters; - out.carrierFrequencyHz = in.carrierFrequencyHz; - out.carrierCycles = in.carrierCycles; - out.carrierPhase = in.carrierPhase; - out.carrierPhaseUncertainty = in.carrierPhaseUncertainty; - uint8_t indicator = - static_cast(IGnssMeasurementCallback::GnssMultipathIndicator::INDICATOR_UNKNOWN); - if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_PRESENT) - indicator |= IGnssMeasurementCallback::GnssMultipathIndicator::INDICATOR_PRESENT; - if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_NOT_PRESENT) - indicator |= IGnssMeasurementCallback::GnssMultipathIndicator::INDICATIOR_NOT_PRESENT; - out.multipathIndicator = - static_cast(indicator); - out.snrDb = in.signalToNoiseRatioDb; - out.agcLevelDb = in.agcLevelDb; -} - -static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out) -{ - memset(&out, 0, sizeof(IGnssMeasurementCallback::GnssClock)); - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_LEAP_SECOND; - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_TIME_UNCERTAINTY; - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_FULL_BIAS; - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_BIAS; - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_BIAS_UNCERTAINTY; - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_DRIFT; - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_UNCERTAINTY_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_DRIFT_UNCERTAINTY; - out.leapSecond = in.leapSecond; - out.timeNs = in.timeNs; - out.timeUncertaintyNs = in.timeUncertaintyNs; - out.fullBiasNs = in.fullBiasNs; - out.biasNs = in.biasNs; - out.biasUncertaintyNs = in.biasUncertaintyNs; - out.driftNsps = in.driftNsps; - out.driftUncertaintyNsps = in.driftUncertaintyNsps; - out.hwClockDiscontinuityCount = in.hwClockDiscontinuityCount; -} - -static void convertGnssData(GnssMeasurementsNotification& in, - V1_0::IGnssMeasurementCallback::GnssData& out) -{ - out.measurementCount = in.count; - if (out.measurementCount > static_cast(V1_0::GnssMax::SVS_COUNT)) { - LOC_LOGW("%s]: Too many measurement %u. Clamps to %d.", - __FUNCTION__, out.measurementCount, V1_0::GnssMax::SVS_COUNT); - out.measurementCount = static_cast(V1_0::GnssMax::SVS_COUNT); - } - for (size_t i = 0; i < out.measurementCount; i++) { - convertGnssMeasurement(in.measurements[i], out.measurements[i]); - } - convertGnssClock(in.clock, out.clock); -} - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.0/location_api/MeasurementAPIClient.h b/gps/android/1.0/location_api/MeasurementAPIClient.h deleted file mode 100644 index c357313..0000000 --- a/gps/android/1.0/location_api/MeasurementAPIClient.h +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef MEASUREMENT_API_CLINET_H -#define MEASUREMENT_API_CLINET_H - -#include -#include -#include -#include -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_0 { -namespace implementation { - -using ::android::sp; - -class MeasurementAPIClient : public LocationAPIClientBase -{ -public: - MeasurementAPIClient(); - virtual ~MeasurementAPIClient(); - MeasurementAPIClient(const MeasurementAPIClient&) = delete; - MeasurementAPIClient& operator=(const MeasurementAPIClient&) = delete; - - // for GpsMeasurementInterface - Return measurementSetCallback( - const sp& callback); - void measurementClose(); - Return startTracking(); - - // callbacks we are interested in - void onGnssMeasurementsCb(GnssMeasurementsNotification gnssMeasurementsNotification) final; - -private: - std::mutex mMutex; - sp mGnssMeasurementCbIface; - - bool mTracking; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace gnss -} // namespace hardware -} // namespace android -#endif // MEASUREMENT_API_CLINET_H diff --git a/gps/android/1.0/service.cpp b/gps/android/1.0/service.cpp deleted file mode 100644 index 2a6f60f..0000000 --- a/gps/android/1.0/service.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "android.hardware.gnss@1.0-service-qti" - -#include -#include -#include "loc_cfg.h" -#include "loc_misc_utils.h" - -extern "C" { -#include "vndfwk-detect.h" -} - -#ifdef ARCH_ARM_32 -#define DEFAULT_HW_BINDER_MEM_SIZE 65536 -#endif - -using android::hardware::gnss::V1_0::IGnss; - -using android::hardware::configureRpcThreadpool; -using android::hardware::registerPassthroughServiceImplementation; -using android::hardware::joinRpcThreadpool; - -using android::status_t; -using android::OK; - -typedef int vendorEnhancedServiceMain(int /* argc */, char* /* argv */ []); - -int main() { - - ALOGI("%s", __FUNCTION__); - - int vendorInfo = getVendorEnhancedInfo(); - bool vendorEnhanced = ( 1 == vendorInfo || 3 == vendorInfo ); - setVendorEnhanced(vendorEnhanced); - -#ifdef ARCH_ARM_32 - android::hardware::ProcessState::initWithMmapSize((size_t)(DEFAULT_HW_BINDER_MEM_SIZE)); -#endif - configureRpcThreadpool(1, true); - status_t status; - - status = registerPassthroughServiceImplementation(); - if (status == OK) { - if (vendorEnhanced) { - #ifdef LOC_HIDL_VERSION - #define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so" - - void* libHandle = NULL; - vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*) - dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main"); - if (NULL != vendorEnhancedMainMethod) { - (*vendorEnhancedMainMethod)(0, NULL); - } - #else - ALOGE("LOC_HIDL_VERSION not defined."); - #endif - } - - joinRpcThreadpool(); - - } else { - ALOGE("Error while registering IGnss 1.0 service: %d", status); - } - - return 0; -} diff --git a/gps/android/1.1/AGnss.cpp b/gps/android/1.1/AGnss.cpp deleted file mode 100644 index fe50c9a..0000000 --- a/gps/android/1.1/AGnss.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc_AGnssInterface" - -#include -#include "Gnss.h" -#include "AGnss.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -static AGnss* spAGnss = nullptr; - -AGnss::AGnss(Gnss* gnss) : mGnss(gnss) { - spAGnss = this; -} - -AGnss::~AGnss() { - spAGnss = nullptr; -} - -void AGnss::agnssStatusIpV4Cb(AGnssExtStatusIpV4 status){ - if (nullptr != spAGnss) { - spAGnss->statusIpV4Cb(status); - } -} - -void AGnss::statusIpV4Cb(AGnssExtStatusIpV4 status) { - IAGnssCallback::AGnssStatusIpV4 st = {}; - - switch (status.type) { - case LOC_AGPS_TYPE_SUPL: - st.type = IAGnssCallback::AGnssType::TYPE_SUPL; - break; - case LOC_AGPS_TYPE_C2K: - st.type = IAGnssCallback::AGnssType::TYPE_C2K; - break; - default: - LOC_LOGE("invalid type: %d", status.type); - return; - } - - switch (status.status) { - case LOC_GPS_REQUEST_AGPS_DATA_CONN: - st.status = IAGnssCallback::AGnssStatusValue::REQUEST_AGNSS_DATA_CONN; - break; - case LOC_GPS_RELEASE_AGPS_DATA_CONN: - st.status = IAGnssCallback::AGnssStatusValue::RELEASE_AGNSS_DATA_CONN; - break; - case LOC_GPS_AGPS_DATA_CONNECTED: - st.status = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONNECTED; - break; - case LOC_GPS_AGPS_DATA_CONN_DONE: - st.status = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONN_DONE; - break; - case LOC_GPS_AGPS_DATA_CONN_FAILED: - st.status = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONN_FAILED; - break; - default: - LOC_LOGE("invalid status: %d", status.status); - return; - } - st.ipV4Addr = status.ipV4Addr; - - if (mAGnssCbIface != nullptr) { - auto r = mAGnssCbIface->agnssStatusIpV4Cb(st); - if (!r.isOk()) { - LOC_LOGw("Error invoking AGNSS status cb %s", r.description().c_str()); - } - } else { - LOC_LOGw("setCallback has not been called yet"); - } -} - -Return AGnss::setCallback(const sp& callback) { - - if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){ - LOC_LOGE("Null GNSS interface"); - return Void(); - } - - // Save the interface - mAGnssCbIface = callback; - - AgpsCbInfo cbInfo = {}; - cbInfo.statusV4Cb = (void*)agnssStatusIpV4Cb; - cbInfo.cbPriority = AGPS_CB_PRIORITY_LOW; - - mGnss->getGnssInterface()->agpsInit(cbInfo); - return Void(); -} - -Return AGnss::dataConnClosed() { - - if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){ - LOC_LOGE("Null GNSS interface"); - return false; - } - - mGnss->getGnssInterface()->agpsDataConnClosed(LOC_AGPS_TYPE_SUPL); - return true; -} - -Return AGnss::dataConnFailed() { - - if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){ - LOC_LOGE("Null GNSS interface"); - return false; - } - - mGnss->getGnssInterface()->agpsDataConnFailed(LOC_AGPS_TYPE_SUPL); - return true; -} - -Return AGnss::dataConnOpen(const hidl_string& apn, - IAGnss::ApnIpType apnIpType) { - - if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){ - LOC_LOGE("Null GNSS interface"); - return false; - } - - /* Validate */ - if(apn.empty()){ - LOC_LOGE("Invalid APN"); - return false; - } - - LOC_LOGD("dataConnOpen APN name = [%s]", apn.c_str()); - - AGpsBearerType bearerType; - switch (apnIpType) { - case IAGnss::ApnIpType::IPV4: - bearerType = AGPS_APN_BEARER_IPV4; - break; - case IAGnss::ApnIpType::IPV6: - bearerType = AGPS_APN_BEARER_IPV6; - break; - case IAGnss::ApnIpType::IPV4V6: - bearerType = AGPS_APN_BEARER_IPV4V6; - break; - default: - bearerType = AGPS_APN_BEARER_IPV4; - break; - } - - mGnss->getGnssInterface()->agpsDataConnOpen( - LOC_AGPS_TYPE_SUPL, apn.c_str(), apn.size(), (int)bearerType); - return true; -} - -Return AGnss::setServer(IAGnssCallback::AGnssType type, - const hidl_string& hostname, - int32_t port) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT; - config.assistanceServer.size = sizeof(GnssConfigSetAssistanceServer); - if (type == IAGnssCallback::AGnssType::TYPE_SUPL) { - config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_SUPL; - } else if (type == IAGnssCallback::AGnssType::TYPE_C2K) { - config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_C2K; - } else { - LOC_LOGE("%s]: invalid AGnssType: %d", __FUNCTION__, static_cast(type)); - return false; - } - config.assistanceServer.hostName = strdup(hostname.c_str()); - config.assistanceServer.port = port; - return mGnss->updateConfiguration(config); -} - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.1/AGnss.h b/gps/android/1.1/AGnss.h deleted file mode 100644 index 4b599b9..0000000 --- a/gps/android/1.1/AGnss.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_AGNSS_H -#define ANDROID_HARDWARE_GNSS_V1_1_AGNSS_H - -#include -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IAGnss; -using ::android::hardware::gnss::V1_0::IAGnssCallback; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -struct Gnss; -struct AGnss : public IAGnss { - - AGnss(Gnss* gnss); - ~AGnss(); - /* - * Methods from ::android::hardware::gnss::V1_0::IAGnss interface follow. - * These declarations were generated from IAGnss.hal. - */ - Return setCallback(const sp& callback) override; - - Return dataConnClosed() override; - - Return dataConnFailed() override; - - Return dataConnOpen(const hidl_string& apn, - IAGnss::ApnIpType apnIpType) override; - - Return setServer(IAGnssCallback::AGnssType type, - const hidl_string& hostname, int32_t port) override; - - void statusIpV4Cb(AGnssExtStatusIpV4 status); - - /* Data call setup callback passed down to GNSS HAL implementation */ - static void agnssStatusIpV4Cb(AGnssExtStatusIpV4 status); - - private: - Gnss* mGnss = nullptr; - sp mAGnssCbIface = nullptr; -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_1_AGNSS_H diff --git a/gps/android/1.1/AGnssRil.cpp b/gps/android/1.1/AGnssRil.cpp deleted file mode 100644 index 1e774f1..0000000 --- a/gps/android/1.1/AGnssRil.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc__AGnssRilInterface" - -#include -#include -#include -#include -#include -#include -#include -#include "Gnss.h" -#include "AGnssRil.h" -#include - -typedef void* (getLocationInterface)(); - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - - -AGnssRil::AGnssRil(Gnss* gnss) : mGnss(gnss) { - ENTRY_LOG_CALLFLOW(); -} - -AGnssRil::~AGnssRil() { - ENTRY_LOG_CALLFLOW(); -} - -Return AGnssRil::updateNetworkState(bool connected, NetworkType type, bool /*roaming*/) { - ENTRY_LOG_CALLFLOW(); - // Extra NetworkTypes not available in IAgnssRil enums - const int NetworkType_BLUETOOTH = 7; - const int NetworkType_ETHERNET = 9; - const int NetworkType_PROXY = 16; - - // for XTRA - if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) { - int8_t typeout = loc_core::NetworkInfoDataItemBase::TYPE_UNKNOWN; - switch(type) - { - case IAGnssRil::NetworkType::MOBILE: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_MOBILE; - break; - case IAGnssRil::NetworkType::WIFI: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_WIFI; - break; - case IAGnssRil::NetworkType::MMS: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_MMS; - break; - case IAGnssRil::NetworkType::SUPL: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_SUPL; - break; - case IAGnssRil::NetworkType::DUN: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_DUN; - break; - case IAGnssRil::NetworkType::HIPRI: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_HIPRI; - break; - case IAGnssRil::NetworkType::WIMAX: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_WIMAX; - break; - default: - { - int networkType = (int) type; - // Handling network types not available in IAgnssRil - switch(networkType) - { - case NetworkType_BLUETOOTH: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_BLUETOOTH; - break; - case NetworkType_ETHERNET: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_ETHERNET; - break; - case NetworkType_PROXY: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_PROXY; - break; - default: - typeout = loc_core::NetworkInfoDataItemBase::TYPE_UNKNOWN; - } - } - break; - } - mGnss->getGnssInterface()->updateConnectionStatus(connected, false, typeout, 0); - } - return true; -} - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.1/AGnssRil.h b/gps/android/1.1/AGnssRil.h deleted file mode 100644 index 5c9298a..0000000 --- a/gps/android/1.1/AGnssRil.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_0_AGNSSRIL_H_ -#define ANDROID_HARDWARE_GNSS_V1_0_AGNSSRIL_H_ - -#include -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IAGnssRil; -using ::android::hardware::gnss::V1_0::IAGnssRilCallback; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -struct Gnss; -/* - * Extended interface for AGNSS RIL support. An Assisted GNSS Radio Interface Layer interface - * allows the GNSS chipset to request radio interface layer information from Android platform. - * Examples of such information are reference location, unique subscriber ID, phone number string - * and network availability changes. Also contains wrapper methods to allow methods from - * IAGnssiRilCallback interface to be passed into the conventional implementation of the GNSS HAL. - */ -struct AGnssRil : public IAGnssRil { - AGnssRil(Gnss* gnss); - ~AGnssRil(); - - /* - * Methods from ::android::hardware::gnss::V1_0::IAGnssRil follow. - * These declarations were generated from IAGnssRil.hal. - */ - Return setCallback(const sp& /*callback*/) override { - return Void(); - } - Return setRefLocation(const IAGnssRil::AGnssRefLocation& /*agnssReflocation*/) override { - return Void(); - } - Return setSetId(IAGnssRil::SetIDType /*type*/, const hidl_string& /*setid*/) override { - return false; - } - Return updateNetworkAvailability(bool /*available*/, - const hidl_string& /*apn*/) override { - return false; - } - Return updateNetworkState(bool connected, NetworkType type, bool roaming) override; - - private: - Gnss* mGnss = nullptr; -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_0_AGNSSRIL_H_ diff --git a/gps/android/1.1/Android.mk b/gps/android/1.1/Android.mk deleted file mode 100644 index fb72de1..0000000 --- a/gps/android/1.1/Android.mk +++ /dev/null @@ -1,99 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := android.hardware.gnss@1.1-impl-qti -LOCAL_VENDOR_MODULE := true -LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_SRC_FILES := \ - AGnss.cpp \ - Gnss.cpp \ - GnssBatching.cpp \ - GnssGeofencing.cpp \ - GnssMeasurement.cpp \ - GnssNi.cpp \ - GnssConfiguration.cpp \ - GnssDebug.cpp \ - AGnssRil.cpp - -LOCAL_SRC_FILES += \ - location_api/LocationUtil.cpp \ - location_api/GnssAPIClient.cpp \ - location_api/GeofenceAPIClient.cpp \ - location_api/BatchingAPIClient.cpp \ - location_api/MeasurementAPIClient.cpp \ - -LOCAL_C_INCLUDES:= \ - $(LOCAL_PATH)/location_api -LOCAL_HEADER_LIBRARIES := \ - libgps.utils_headers \ - libloc_core_headers \ - libloc_pla_headers \ - liblocation_api_headers \ - liblocbatterylistener_headers - -LOCAL_SHARED_LIBRARIES := \ - liblog \ - libhidlbase \ - libhidltransport \ - libhwbinder \ - libcutils \ - libutils \ - android.hardware.gnss@1.0 \ - android.hardware.gnss@1.1 \ - android.hardware.health@1.0 \ - android.hardware.health@2.0 \ - android.hardware.power@1.2 \ - libbase - -LOCAL_SHARED_LIBRARIES += \ - libloc_core \ - libgps.utils \ - libdl \ - liblocation_api \ - -LOCAL_CFLAGS += $(GNSS_CFLAGS) -LOCAL_STATIC_LIBRARIES := liblocbatterylistener -LOCAL_STATIC_LIBRARIES += libhealthhalutils -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := android.hardware.gnss@1.1-service-qti -LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@1.1-service-qti.xml -LOCAL_VENDOR_MODULE := true -LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_INIT_RC := android.hardware.gnss@1.1-service-qti.rc -LOCAL_SRC_FILES := \ - service.cpp \ - -LOCAL_C_INCLUDES:= \ - $(LOCAL_PATH)/location_api -LOCAL_HEADER_LIBRARIES := \ - libgps.utils_headers \ - libloc_core_headers \ - libloc_pla_headers \ - liblocation_api_headers - - -LOCAL_SHARED_LIBRARIES := \ - liblog \ - libcutils \ - libdl \ - libbase \ - libutils \ - libgps.utils \ - libqti_vndfwk_detect \ - -LOCAL_SHARED_LIBRARIES += \ - libhwbinder \ - libhidlbase \ - libhidltransport \ - android.hardware.gnss@1.0 \ - android.hardware.gnss@1.1 \ - -LOCAL_CFLAGS += $(GNSS_CFLAGS) - -ifneq ($(LOC_HIDL_VERSION),) -LOCAL_CFLAGS += -DLOC_HIDL_VERSION='"$(LOC_HIDL_VERSION)"' -endif - -include $(BUILD_EXECUTABLE) diff --git a/gps/android/1.1/Gnss.cpp b/gps/android/1.1/Gnss.cpp deleted file mode 100644 index bea556f..0000000 --- a/gps/android/1.1/Gnss.cpp +++ /dev/null @@ -1,477 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc_GnssInterface" -#define LOG_NDEBUG 0 - -#include -#include -#include -#include -#include "Gnss.h" -#include - -#include "battery_listener.h" - -typedef const GnssInterface* (getLocationInterface)(); - -#define IMAGES_INFO_FILE "/sys/devices/soc0/images" -#define DELIMITER ";" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -static sp sGnss; -static std::string getVersionString() { - static std::string version; - if (!version.empty()) - return version; - - char value[PROPERTY_VALUE_MAX] = {0}; - property_get("ro.hardware", value, "unknown"); - version.append(value).append(DELIMITER); - - std::ifstream in(IMAGES_INFO_FILE); - std::string s; - while(getline(in, s)) { - std::size_t found = s.find("CRM:"); - if (std::string::npos == found) { - continue; - } - - // skip over space characters after "CRM:" - const char* substr = s.c_str(); - found += 4; - while (0 != substr[found] && isspace(substr[found])) { - found++; - } - if (s.find("11:") != found) { - continue; - } - s.erase(0, found + 3); - - found = s.find_first_of("\r\n"); - if (std::string::npos != found) { - s.erase(s.begin() + found, s.end()); - } - version.append(s).append(DELIMITER); - } - return version; -} - -void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp& who) { - LOC_LOGE("%s] service died. cookie: %llu, who: %p", - __FUNCTION__, static_cast(cookie), &who); - if (mGnss != nullptr) { - mGnss->stop(); - mGnss->cleanup(); - } -} - -void location_on_battery_status_changed(bool charging) { - LOC_LOGd("battery status changed to %s charging", charging ? "" : "not"); - if (sGnss != nullptr) { - sGnss->getGnssInterface()->updateBatteryStatus(charging); - } -} -Gnss::Gnss() { - ENTRY_LOG_CALLFLOW(); - sGnss = this; - // register health client to listen on battery change - loc_extn_battery_properties_listener_init(location_on_battery_status_changed); - // clear pending GnssConfig - memset(&mPendingConfig, 0, sizeof(GnssConfig)); - - mGnssDeathRecipient = new GnssDeathRecipient(this); -} - -Gnss::~Gnss() { - ENTRY_LOG_CALLFLOW(); - if (mApi != nullptr) { - delete mApi; - mApi = nullptr; - } - sGnss = nullptr; -} - -GnssAPIClient* Gnss::getApi() { - if (mApi == nullptr && (mGnssCbIface != nullptr || mGnssNiCbIface != nullptr)) { - mApi = new GnssAPIClient(mGnssCbIface, mGnssNiCbIface); - if (mApi == nullptr) { - LOC_LOGE("%s] faild to create GnssAPIClient", __FUNCTION__); - return mApi; - } - - if (mPendingConfig.size == sizeof(GnssConfig)) { - // we have pending GnssConfig - mApi->gnssConfigurationUpdate(mPendingConfig); - // clear size to invalid mPendingConfig - mPendingConfig.size = 0; - if (mPendingConfig.assistanceServer.hostName != nullptr) { - free((void*)mPendingConfig.assistanceServer.hostName); - } - } - } - if (mApi == nullptr) { - LOC_LOGW("%s] GnssAPIClient is not ready", __FUNCTION__); - } - return mApi; -} - -const GnssInterface* Gnss::getGnssInterface() { - static bool getGnssInterfaceFailed = false; - if (nullptr == mGnssInterface && !getGnssInterfaceFailed) { - LOC_LOGD("%s]: loading libgnss.so::getGnssInterface ...", __func__); - getLocationInterface* getter = NULL; - const char *error = NULL; - dlerror(); - void *handle = dlopen("libgnss.so", RTLD_NOW); - if (NULL == handle || (error = dlerror()) != NULL) { - LOC_LOGW("dlopen for libgnss.so failed, error = %s", error); - } else { - getter = (getLocationInterface*)dlsym(handle, "getGnssInterface"); - if ((error = dlerror()) != NULL) { - LOC_LOGW("dlsym for libgnss.so::getGnssInterface failed, error = %s", error); - getter = NULL; - } - } - - if (NULL == getter) { - getGnssInterfaceFailed = true; - } else { - mGnssInterface = (const GnssInterface*)(*getter)(); - } - } - return mGnssInterface; -} - -Return Gnss::setCallback(const sp& callback) { - ENTRY_LOG_CALLFLOW(); - if (mGnssCbIface != nullptr) { - mGnssCbIface->unlinkToDeath(mGnssDeathRecipient); - } - mGnssCbIface = callback; - if (mGnssCbIface != nullptr) { - mGnssCbIface->linkToDeath(mGnssDeathRecipient, 0 /*cookie*/); - } - - GnssAPIClient* api = getApi(); - if (api != nullptr) { - api->gnssUpdateCallbacks(mGnssCbIface, mGnssNiCbIface); - api->gnssEnable(LOCATION_TECHNOLOGY_TYPE_GNSS); - api->requestCapabilities(); - } - return true; -} - -Return Gnss::setGnssNiCb(const sp& callback) { - ENTRY_LOG_CALLFLOW(); - mGnssNiCbIface = callback; - GnssAPIClient* api = getApi(); - if (api != nullptr) { - api->gnssUpdateCallbacks(mGnssCbIface, mGnssNiCbIface); - } - return true; -} - -Return Gnss::updateConfiguration(GnssConfig& gnssConfig) { - ENTRY_LOG_CALLFLOW(); - GnssAPIClient* api = getApi(); - if (api) { - api->gnssConfigurationUpdate(gnssConfig); - } else if (gnssConfig.flags != 0) { - // api is not ready yet, update mPendingConfig with gnssConfig - mPendingConfig.size = sizeof(GnssConfig); - - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT; - mPendingConfig.gpsLock = gnssConfig.gpsLock; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT; - mPendingConfig.suplVersion = gnssConfig.suplVersion; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT; - mPendingConfig.assistanceServer.size = sizeof(GnssConfigSetAssistanceServer); - mPendingConfig.assistanceServer.type = gnssConfig.assistanceServer.type; - if (mPendingConfig.assistanceServer.hostName != nullptr) { - free((void*)mPendingConfig.assistanceServer.hostName); - mPendingConfig.assistanceServer.hostName = - strdup(gnssConfig.assistanceServer.hostName); - } - mPendingConfig.assistanceServer.port = gnssConfig.assistanceServer.port; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT; - mPendingConfig.lppProfile = gnssConfig.lppProfile; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT; - mPendingConfig.lppeControlPlaneMask = gnssConfig.lppeControlPlaneMask; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT; - mPendingConfig.lppeUserPlaneMask = gnssConfig.lppeUserPlaneMask; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT; - mPendingConfig.aGlonassPositionProtocolMask = gnssConfig.aGlonassPositionProtocolMask; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT; - mPendingConfig.emergencyPdnForEmergencySupl = gnssConfig.emergencyPdnForEmergencySupl; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT; - mPendingConfig.suplEmergencyServices = gnssConfig.suplEmergencyServices; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_MODE_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_MODE_BIT; - mPendingConfig.suplModeMask = gnssConfig.suplModeMask; - } - if (gnssConfig.flags & GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT) { - mPendingConfig.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT; - mPendingConfig.blacklistedSvIds = gnssConfig.blacklistedSvIds; - } - } - return true; -} - -Return Gnss::start() { - ENTRY_LOG_CALLFLOW(); - bool retVal = false; - GnssAPIClient* api = getApi(); - if (api) { - retVal = api->gnssStart(); - } - return retVal; -} - -Return Gnss::stop() { - ENTRY_LOG_CALLFLOW(); - bool retVal = false; - GnssAPIClient* api = getApi(); - if (api) { - retVal = api->gnssStop(); - } - return retVal; -} - -Return Gnss::cleanup() { - ENTRY_LOG_CALLFLOW(); - - if (mApi != nullptr) { - mApi->gnssDisable(); - } - - return Void(); -} - -Return Gnss::injectLocation(double latitudeDegrees, - double longitudeDegrees, - float accuracyMeters) { - ENTRY_LOG_CALLFLOW(); - const GnssInterface* gnssInterface = getGnssInterface(); - if (nullptr != gnssInterface) { - gnssInterface->injectLocation(latitudeDegrees, longitudeDegrees, accuracyMeters); - return true; - } else { - return false; - } -} - -Return Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs, - int32_t uncertaintyMs) { - ENTRY_LOG_CALLFLOW(); - const GnssInterface* gnssInterface = getGnssInterface(); - if (nullptr != gnssInterface) { - gnssInterface->injectTime(timeMs, timeReferenceMs, uncertaintyMs); - return true; - } else { - return false; - } -} - -Return Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) { - ENTRY_LOG_CALLFLOW(); - GnssAPIClient* api = getApi(); - if (api) { - api->gnssDeleteAidingData(aidingDataFlags); - } - return Void(); -} - -Return Gnss::setPositionMode(V1_0::IGnss::GnssPositionMode mode, - V1_0::IGnss::GnssPositionRecurrence recurrence, - uint32_t minIntervalMs, - uint32_t preferredAccuracyMeters, - uint32_t preferredTimeMs) { - ENTRY_LOG_CALLFLOW(); - bool retVal = false; - GnssAPIClient* api = getApi(); - if (api) { - retVal = api->gnssSetPositionMode(mode, recurrence, minIntervalMs, - preferredAccuracyMeters, preferredTimeMs); - } - return retVal; -} - -Return> Gnss::getExtensionAGnss() { - ENTRY_LOG_CALLFLOW(); - mAGnssIface = new AGnss(this); - return mAGnssIface; -} - -Return> Gnss::getExtensionGnssNi() { - ENTRY_LOG_CALLFLOW(); - mGnssNi = new GnssNi(this); - return mGnssNi; -} - -Return> Gnss::getExtensionGnssMeasurement() { - ENTRY_LOG_CALLFLOW(); - if (mGnssMeasurement == nullptr) - mGnssMeasurement = new GnssMeasurement(); - return mGnssMeasurement; -} - -Return> Gnss::getExtensionGnssConfiguration() { - ENTRY_LOG_CALLFLOW(); - mGnssConfig = new GnssConfiguration(this); - return mGnssConfig; -} - -Return> Gnss::getExtensionGnssGeofencing() { - ENTRY_LOG_CALLFLOW(); - mGnssGeofencingIface = new GnssGeofencing(); - return mGnssGeofencingIface; -} - -Return> Gnss::getExtensionGnssBatching() { - mGnssBatching = new GnssBatching(); - return mGnssBatching; -} - -Return> Gnss::getExtensionGnssDebug() { - ENTRY_LOG_CALLFLOW(); - mGnssDebug = new GnssDebug(this); - return mGnssDebug; -} - -Return> Gnss::getExtensionAGnssRil() { - mGnssRil = new AGnssRil(this); - return mGnssRil; -} - -// Methods from ::android::hardware::gnss::V1_1::IGnss follow. -Return Gnss::setCallback_1_1(const sp& callback) { - ENTRY_LOG_CALLFLOW(); - callback->gnssNameCb(getVersionString()); - mGnssCbIface_1_1 = callback; - const GnssInterface* gnssInterface = getGnssInterface(); - if (nullptr != gnssInterface) { - OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) { - odcpiRequestCb(odcpiRequest); - }; - gnssInterface->odcpiInit(cb); - } - return setCallback(callback); -} - -Return Gnss::setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode, - V1_0::IGnss::GnssPositionRecurrence recurrence, - uint32_t minIntervalMs, - uint32_t preferredAccuracyMeters, - uint32_t preferredTimeMs, - bool lowPowerMode) { - ENTRY_LOG_CALLFLOW(); - bool retVal = false; - GnssAPIClient* api = getApi(); - if (api) { - GnssPowerMode powerMode = lowPowerMode? - GNSS_POWER_MODE_M4 : GNSS_POWER_MODE_M2; - retVal = api->gnssSetPositionMode(mode, recurrence, minIntervalMs, - preferredAccuracyMeters, preferredTimeMs, powerMode, minIntervalMs); - } - return retVal; -} - -Return> Gnss::getExtensionGnssMeasurement_1_1() { - ENTRY_LOG_CALLFLOW(); - if (mGnssMeasurement == nullptr) - mGnssMeasurement = new GnssMeasurement(); - return mGnssMeasurement; -} - -Return> Gnss::getExtensionGnssConfiguration_1_1() { - ENTRY_LOG_CALLFLOW(); - if (mGnssConfig == nullptr) - mGnssConfig = new GnssConfiguration(this); - return mGnssConfig; -} - -Return Gnss::injectBestLocation(const GnssLocation& gnssLocation) { - ENTRY_LOG_CALLFLOW(); - const GnssInterface* gnssInterface = getGnssInterface(); - if (nullptr != gnssInterface) { - Location location = {}; - convertGnssLocation(gnssLocation, location); - gnssInterface->odcpiInject(location); - } - return true; -} - -void Gnss::odcpiRequestCb(const OdcpiRequestInfo& request) { - ENTRY_LOG_CALLFLOW(); - if (mGnssCbIface_1_1 != nullptr) { - // For emergency mode, request DBH (Device based hybrid) location - // Mark Independent from GNSS flag to false. - if (ODCPI_REQUEST_TYPE_START == request.type) { - auto r = mGnssCbIface_1_1->gnssRequestLocationCb(!request.isEmergencyMode); - if (!r.isOk()) { - LOC_LOGe("Error invoking gnssRequestLocationCb %s", r.description().c_str()); - } - } else { - LOC_LOGv("Unsupported ODCPI request type: %d", request.type); - } - } else { - LOC_LOGe("ODCPI request not supported."); - } -} - -V1_0::IGnss* HIDL_FETCH_IGnss(const char* hal) { - ENTRY_LOG_CALLFLOW(); - V1_0::IGnss* iface = nullptr; - iface = new Gnss(); - if (iface == nullptr) { - LOC_LOGE("%s]: failed to get %s", __FUNCTION__, hal); - } - return iface; -} - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.1/Gnss.h b/gps/android/1.1/Gnss.h deleted file mode 100644 index 15645eb..0000000 --- a/gps/android/1.1/Gnss.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2017-2018-2018-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_GNSS_H -#define ANDROID_HARDWARE_GNSS_V1_1_GNSS_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; -using ::android::hardware::gnss::V1_0::GnssLocation; - -struct Gnss : public IGnss { - Gnss(); - ~Gnss(); - - /* - * Methods from ::android::hardware::gnss::V1_0::IGnss follow. - * These declarations were generated from Gnss.hal. - */ - Return setCallback(const sp& callback) override; - Return start() override; - Return stop() override; - Return cleanup() override; - Return injectLocation(double latitudeDegrees, - double longitudeDegrees, - float accuracyMeters) override; - Return injectTime(int64_t timeMs, - int64_t timeReferenceMs, - int32_t uncertaintyMs) override; - Return deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) override; - Return setPositionMode(V1_0::IGnss::GnssPositionMode mode, - V1_0::IGnss::GnssPositionRecurrence recurrence, - uint32_t minIntervalMs, - uint32_t preferredAccuracyMeters, - uint32_t preferredTimeMs) override; - Return> getExtensionAGnss() override; - Return> getExtensionGnssNi() override; - Return> getExtensionGnssMeasurement() override; - Return> getExtensionGnssConfiguration() override; - Return> getExtensionGnssGeofencing() override; - Return> getExtensionGnssBatching() override; - - Return> getExtensionAGnssRil() override; - - inline Return> getExtensionGnssNavigationMessage() override { - return nullptr; - } - - inline Return> getExtensionXtra() override { - return nullptr; - } - - Return> getExtensionGnssDebug() override; - - // Methods from ::android::hardware::gnss::V1_1::IGnss follow. - Return setCallback_1_1(const sp& callback) override; - Return setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode, - V1_0::IGnss::GnssPositionRecurrence recurrence, - uint32_t minIntervalMs, uint32_t preferredAccuracyMeters, - uint32_t preferredTimeMs, bool lowPowerMode) override; - Return> getExtensionGnssMeasurement_1_1() override; - Return> getExtensionGnssConfiguration_1_1() override; - Return injectBestLocation(const GnssLocation& location) override; - - // These methods are not part of the IGnss base class. - GnssAPIClient* getApi(); - Return setGnssNiCb(const sp& niCb); - Return updateConfiguration(GnssConfig& gnssConfig); - const GnssInterface* getGnssInterface(); - - // Callback for ODCPI request - void odcpiRequestCb(const OdcpiRequestInfo& request); - - private: - struct GnssDeathRecipient : hidl_death_recipient { - GnssDeathRecipient(sp gnss) : mGnss(gnss) { - } - ~GnssDeathRecipient() = default; - virtual void serviceDied(uint64_t cookie, const wp& who) override; - sp mGnss; - }; - - private: - sp mGnssDeathRecipient = nullptr; - - sp mAGnssIface = nullptr; - sp mGnssNi = nullptr; - sp mGnssMeasurement = nullptr; - sp mGnssConfig = nullptr; - sp mGnssGeofencingIface = nullptr; - sp mGnssBatching = nullptr; - sp mGnssDebug = nullptr; - sp mGnssRil = nullptr; - - GnssAPIClient* mApi = nullptr; - sp mGnssCbIface = nullptr; - sp mGnssCbIface_1_1 = nullptr; - sp mGnssNiCbIface = nullptr; - GnssConfig mPendingConfig; - const GnssInterface* mGnssInterface = nullptr; -}; - -extern "C" V1_0::IGnss* HIDL_FETCH_IGnss(const char* name); - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSS_H diff --git a/gps/android/1.1/GnssBatching.cpp b/gps/android/1.1/GnssBatching.cpp deleted file mode 100644 index 9701aff..0000000 --- a/gps/android/1.1/GnssBatching.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc_GnssBatchingInterface" - -#include -#include -#include "GnssBatching.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -void GnssBatching::GnssBatchingDeathRecipient::serviceDied( - uint64_t cookie, const wp& who) { - LOC_LOGE("%s] service died. cookie: %llu, who: %p", - __FUNCTION__, static_cast(cookie), &who); - if (mGnssBatching != nullptr) { - mGnssBatching->stop(); - mGnssBatching->cleanup(); - } -} - -GnssBatching::GnssBatching() : mApi(nullptr) { - mGnssBatchingDeathRecipient = new GnssBatchingDeathRecipient(this); -} - -GnssBatching::~GnssBatching() { - if (mApi != nullptr) { - delete mApi; - mApi = nullptr; - } -} - - -// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow. -Return GnssBatching::init(const sp& callback) { - if (mApi != nullptr) { - LOC_LOGD("%s]: mApi is NOT nullptr, delete it first", __FUNCTION__); - delete mApi; - mApi = nullptr; - } - - mApi = new BatchingAPIClient(callback); - if (mApi == nullptr) { - LOC_LOGE("%s]: failed to create mApi", __FUNCTION__); - return false; - } - - if (mGnssBatchingCbIface != nullptr) { - mGnssBatchingCbIface->unlinkToDeath(mGnssBatchingDeathRecipient); - } - mGnssBatchingCbIface = callback; - if (mGnssBatchingCbIface != nullptr) { - mGnssBatchingCbIface->linkToDeath(mGnssBatchingDeathRecipient, 0 /*cookie*/); - } - - return true; -} - -Return GnssBatching::getBatchSize() { - uint16_t ret = 0; - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - ret = mApi->getBatchSize(); - } - return ret; -} - -Return GnssBatching::start(const IGnssBatching::Options& options) { - bool ret = false; - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - ret = mApi->startSession(options); - } - return ret; -} - -Return GnssBatching::flush() { - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - mApi->flushBatchedLocations(); - } - return Void(); -} - -Return GnssBatching::stop() { - bool ret = false; - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - ret = mApi->stopSession(); - } - return ret; -} - -Return GnssBatching::cleanup() { - if (mGnssBatchingCbIface != nullptr) { - mGnssBatchingCbIface->unlinkToDeath(mGnssBatchingDeathRecipient); - } - return Void(); -} - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.1/GnssBatching.h b/gps/android/1.1/GnssBatching.h deleted file mode 100644 index 8e235d8..0000000 --- a/gps/android/1.1/GnssBatching.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_GNSSBATCHING_H -#define ANDROID_HARDWARE_GNSS_V1_1_GNSSBATCHING_H - -#include -#include - - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssBatching; -using ::android::hardware::gnss::V1_0::IGnssBatchingCallback; -using ::android::hidl::base::V1_0::IBase; -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; - -class BatchingAPIClient; -struct GnssBatching : public IGnssBatching { - GnssBatching(); - ~GnssBatching(); - - // Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow. - Return init(const sp& callback) override; - Return getBatchSize() override; - Return start(const IGnssBatching::Options& options ) override; - Return flush() override; - Return stop() override; - Return cleanup() override; - - private: - struct GnssBatchingDeathRecipient : hidl_death_recipient { - GnssBatchingDeathRecipient(sp gnssBatching) : - mGnssBatching(gnssBatching) { - } - ~GnssBatchingDeathRecipient() = default; - virtual void serviceDied(uint64_t cookie, const wp& who) override; - sp mGnssBatching; - }; - - private: - sp mGnssBatchingDeathRecipient = nullptr; - sp mGnssBatchingCbIface = nullptr; - BatchingAPIClient* mApi = nullptr; -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSBATCHING_H diff --git a/gps/android/1.1/GnssConfiguration.cpp b/gps/android/1.1/GnssConfiguration.cpp deleted file mode 100644 index 93f9645..0000000 --- a/gps/android/1.1/GnssConfiguration.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc_GnssConfigurationInterface" - -#include -#include "Gnss.h" -#include "GnssConfiguration.h" -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::GnssConstellationType; - -GnssConfiguration::GnssConfiguration(Gnss* gnss) : mGnss(gnss) { -} - -// Methods from ::android::hardware::gps::V1_0::IGnssConfiguration follow. -Return GnssConfiguration::setSuplEs(bool enabled) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT; - config.suplEmergencyServices = (enabled ? - GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_YES : - GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO); - - return mGnss->updateConfiguration(config); -} - -Return GnssConfiguration::setSuplVersion(uint32_t version) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT; - switch (version) { - case 0x00020002: - config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_2; - break; - case 0x00020000: - config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_0; - break; - case 0x00010000: - config.suplVersion = GNSS_CONFIG_SUPL_VERSION_1_0_0; - break; - default: - LOC_LOGE("%s]: invalid version: 0x%x.", __FUNCTION__, version); - return false; - break; - } - - return mGnss->updateConfiguration(config); -} - -Return GnssConfiguration::setSuplMode(uint8_t mode) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_SUPL_MODE_BIT; - switch (mode) { - case 0: - config.suplModeMask = 0; // STANDALONE ONLY - break; - case 1: - config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSB_BIT; - break; - case 2: - config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSA_BIT; - break; - case 3: - config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSB_BIT | GNSS_CONFIG_SUPL_MODE_MSA_BIT; - break; - default: - LOC_LOGE("%s]: invalid mode: %d.", __FUNCTION__, mode); - return false; - break; - } - - return mGnss->updateConfiguration(config); -} - -Return GnssConfiguration::setLppProfile(uint8_t lppProfile) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - 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; - } - - return mGnss->updateConfiguration(config); -} - -Return GnssConfiguration::setGlonassPositioningProtocol(uint8_t protocol) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - - config.flags = GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT; - if (protocol & (1<<0)) { - config.aGlonassPositionProtocolMask |= GNSS_CONFIG_RRC_CONTROL_PLANE_BIT; - } - if (protocol & (1<<1)) { - config.aGlonassPositionProtocolMask |= GNSS_CONFIG_RRLP_USER_PLANE_BIT; - } - if (protocol & (1<<2)) { - config.aGlonassPositionProtocolMask |= GNSS_CONFIG_LLP_USER_PLANE_BIT; - } - if (protocol & (1<<3)) { - config.aGlonassPositionProtocolMask |= GNSS_CONFIG_LLP_CONTROL_PLANE_BIT; - } - - return mGnss->updateConfiguration(config); -} - -Return GnssConfiguration::setGpsLock(uint8_t lock) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT; - switch (lock) { - case 0: - config.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE; - break; - case 1: - config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO; - break; - case 2: - config.gpsLock = GNSS_CONFIG_GPS_LOCK_NI; - break; - case 3: - config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO_AND_NI; - break; - default: - LOC_LOGE("%s]: invalid lock: %d.", __FUNCTION__, lock); - return false; - break; - } - - return mGnss->updateConfiguration(config); -} - -Return GnssConfiguration::setEmergencySuplPdn(bool enabled) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT; - config.emergencyPdnForEmergencySupl = (enabled ? - GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_YES : - GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_NO); - - return mGnss->updateConfiguration(config); -} - -// Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow. -Return GnssConfiguration::setBlacklist( - const hidl_vec& blacklist) { - - ENTRY_LOG_CALLFLOW(); - if (nullptr == mGnss) { - LOC_LOGe("mGnss is null"); - return false; - } - - // blValid is true if blacklist is empty, i.e. clearing the BL; - // if blacklist is not empty, blValid is initialied to false, and later - // updated in the for loop to become true only if there is at least - // one {constellation, svid} in the list that is valid. - bool blValid = (0 == blacklist.size()); - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT; - config.blacklistedSvIds.clear(); - - GnssSvIdSource source = {}; - for (int idx = 0; idx < (int)blacklist.size(); idx++) { - // Set blValid true if any one source is valid - blValid = setBlacklistedSource(source, blacklist[idx]) || blValid; - config.blacklistedSvIds.push_back(source); - } - - // Update configuration only if blValid is true - // i.e. only if atleast one source is valid for blacklisting - return (blValid && mGnss->updateConfiguration(config)); -} - -bool GnssConfiguration::setBlacklistedSource( - GnssSvIdSource& copyToSource, - const GnssConfiguration::BlacklistedSource& copyFromSource) { - - bool retVal = true; - uint16_t svIdOffset = 0; - copyToSource.size = sizeof(GnssSvIdSource); - copyToSource.svId = copyFromSource.svid; - - switch(copyFromSource.constellation) { - case GnssConstellationType::GPS: - copyToSource.constellation = GNSS_SV_TYPE_GPS; - LOC_LOGe("GPS SVs can't be blacklisted."); - retVal = false; - break; - case GnssConstellationType::SBAS: - copyToSource.constellation = GNSS_SV_TYPE_SBAS; - LOC_LOGe("SBAS SVs can't be blacklisted."); - retVal = false; - break; - case GnssConstellationType::GLONASS: - copyToSource.constellation = GNSS_SV_TYPE_GLONASS; - svIdOffset = GNSS_SV_CONFIG_GLO_INITIAL_SV_ID - 1; - break; - case GnssConstellationType::QZSS: - copyToSource.constellation = GNSS_SV_TYPE_QZSS; - svIdOffset = 0; - break; - case GnssConstellationType::BEIDOU: - copyToSource.constellation = GNSS_SV_TYPE_BEIDOU; - svIdOffset = GNSS_SV_CONFIG_BDS_INITIAL_SV_ID - 1; - break; - case GnssConstellationType::GALILEO: - copyToSource.constellation = GNSS_SV_TYPE_GALILEO; - svIdOffset = GNSS_SV_CONFIG_GAL_INITIAL_SV_ID - 1; - break; - default: - copyToSource.constellation = GNSS_SV_TYPE_UNKNOWN; - LOC_LOGe("Invalid constellation %d", copyFromSource.constellation); - retVal = false; - break; - } - - if (copyToSource.svId > 0 && svIdOffset > 0) { - copyToSource.svId += svIdOffset; - } - - return retVal; -} - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.1/GnssConfiguration.h b/gps/android/1.1/GnssConfiguration.h deleted file mode 100644 index 96681b6..0000000 --- a/gps/android/1.1/GnssConfiguration.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ - - /* Copyright (C) 2016 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_GNSSCONFIGURATION_H -#define ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H - -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_1::IGnssConfiguration; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -/* - * Interface for passing GNSS configuration info from platform to HAL. - */ -struct Gnss; -struct GnssConfiguration : public IGnssConfiguration { - GnssConfiguration(Gnss* gnss); - ~GnssConfiguration() = default; - - /* - * Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow. - * These declarations were generated from IGnssConfiguration.hal. - */ - Return setSuplVersion(uint32_t version) override; - Return setSuplMode(uint8_t mode) override; - Return setSuplEs(bool enabled) override; - Return setLppProfile(uint8_t lppProfile) override; - Return setGlonassPositioningProtocol(uint8_t protocol) override; - Return setEmergencySuplPdn(bool enable) override; - Return setGpsLock(uint8_t lock) override; - - // Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow. - Return setBlacklist( - const hidl_vec& blacklist) override; - - private: - Gnss* mGnss = nullptr; - bool setBlacklistedSource( - GnssSvIdSource& copyToSource, - const GnssConfiguration::BlacklistedSource& copyFromSource); -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H diff --git a/gps/android/1.1/GnssDebug.cpp b/gps/android/1.1/GnssDebug.cpp deleted file mode 100644 index f164c54..0000000 --- a/gps/android/1.1/GnssDebug.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2016 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 "LocSvc_GnssDebugInterface" - -#include -#include -#include "Gnss.h" -#include "GnssDebug.h" -#include "LocationUtil.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::hidl_vec; - -#define GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS (20000000) -#define GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS (20000) -#define GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC (500) -#define GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG (180) - -#define GNSS_DEBUG_UNKNOWN_UTC_TIME (1483228800000LL) // 1/1/2017 00:00 GMT -#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN (999) // 999 ns -#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX (1.57783680E17) // 5 years in ns -#define GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC (2.0e5) // ppm - -GnssDebug::GnssDebug(Gnss* gnss) : mGnss(gnss) -{ -} - -/* - * This methods requests position, time and satellite ephemeris debug information - * from the HAL. - * - * @return void -*/ -Return GnssDebug::getDebugData(getDebugData_cb _hidl_cb) -{ - LOC_LOGD("%s]: ", __func__); - - DebugData data = { }; - - if((nullptr == mGnss) || (nullptr == mGnss->getGnssInterface())){ - LOC_LOGE("GnssDebug - Null GNSS interface"); - _hidl_cb(data); - return Void(); - } - - // get debug report snapshot via hal interface - GnssDebugReport reports = { }; - mGnss->getGnssInterface()->getDebugReport(reports); - - // location block - if (reports.mLocation.mValid) { - data.position.valid = true; - data.position.latitudeDegrees = reports.mLocation.mLocation.latitude; - data.position.longitudeDegrees = reports.mLocation.mLocation.longitude; - data.position.altitudeMeters = reports.mLocation.mLocation.altitude; - - data.position.speedMetersPerSec = - (double)(reports.mLocation.mLocation.speed); - data.position.bearingDegrees = - (double)(reports.mLocation.mLocation.bearing); - data.position.horizontalAccuracyMeters = - (double)(reports.mLocation.mLocation.accuracy); - data.position.verticalAccuracyMeters = - reports.mLocation.verticalAccuracyMeters; - data.position.speedAccuracyMetersPerSecond = - reports.mLocation.speedAccuracyMetersPerSecond; - data.position.bearingAccuracyDegrees = - reports.mLocation.bearingAccuracyDegrees; - - timeval tv_now, tv_report; - tv_report.tv_sec = reports.mLocation.mUtcReported.tv_sec; - tv_report.tv_usec = reports.mLocation.mUtcReported.tv_nsec / 1000ULL; - gettimeofday(&tv_now, NULL); - data.position.ageSeconds = - (tv_now.tv_sec - tv_report.tv_sec) + - (float)((tv_now.tv_usec - tv_report.tv_usec)) / 1000000; - } - else { - data.position.valid = false; - } - - if (data.position.horizontalAccuracyMeters <= 0 || - data.position.horizontalAccuracyMeters > GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS) { - data.position.horizontalAccuracyMeters = GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS; - } - if (data.position.verticalAccuracyMeters <= 0 || - data.position.verticalAccuracyMeters > GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS) { - data.position.verticalAccuracyMeters = GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS; - } - if (data.position.speedAccuracyMetersPerSecond <= 0 || - data.position.speedAccuracyMetersPerSecond > GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC) { - data.position.speedAccuracyMetersPerSecond = GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC; - } - if (data.position.bearingAccuracyDegrees <= 0 || - data.position.bearingAccuracyDegrees > GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG) { - data.position.bearingAccuracyDegrees = GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG; - } - - // time block - if (reports.mTime.mValid) { - data.time.timeEstimate = reports.mTime.timeEstimate; - data.time.timeUncertaintyNs = reports.mTime.timeUncertaintyNs; - data.time.frequencyUncertaintyNsPerSec = - reports.mTime.frequencyUncertaintyNsPerSec; - } - - if (data.time.timeEstimate < GNSS_DEBUG_UNKNOWN_UTC_TIME) { - data.time.timeEstimate = GNSS_DEBUG_UNKNOWN_UTC_TIME; - } - if (data.time.timeUncertaintyNs <= 0) { - data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN; - } else if (data.time.timeUncertaintyNs > GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX) { - data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX; - } - if (data.time.frequencyUncertaintyNsPerSec <= 0 || - data.time.frequencyUncertaintyNsPerSec > (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC) { - data.time.frequencyUncertaintyNsPerSec = (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC; - } - - // satellite data block - SatelliteData s = { }; - std::vector s_array = { }; - - for (uint32_t i=0; i -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssDebug; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -/* Interface for GNSS Debug support. */ -struct Gnss; -struct GnssDebug : public IGnssDebug { - GnssDebug(Gnss* gnss); - ~GnssDebug() {}; - - /* - * Methods from ::android::hardware::gnss::V1_0::IGnssDebug follow. - * These declarations were generated from IGnssDebug.hal. - */ - Return getDebugData(getDebugData_cb _hidl_cb) override; - -private: - Gnss* mGnss = nullptr; -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSDEBUG_H diff --git a/gps/android/1.1/GnssGeofencing.cpp b/gps/android/1.1/GnssGeofencing.cpp deleted file mode 100644 index d57a666..0000000 --- a/gps/android/1.1/GnssGeofencing.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "GnssHal_GnssGeofencing" - -#include -#include -#include "GnssGeofencing.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -void GnssGeofencing::GnssGeofencingDeathRecipient::serviceDied( - uint64_t cookie, const wp& who) { - LOC_LOGE("%s] service died. cookie: %llu, who: %p", - __FUNCTION__, static_cast(cookie), &who); - if (mGnssGeofencing != nullptr) { - mGnssGeofencing->removeAllGeofences(); - } -} - -GnssGeofencing::GnssGeofencing() : mApi(nullptr) { - mGnssGeofencingDeathRecipient = new GnssGeofencingDeathRecipient(this); -} - -GnssGeofencing::~GnssGeofencing() { - if (mApi != nullptr) { - delete mApi; - mApi = nullptr; - } -} - -// Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow. -Return GnssGeofencing::setCallback(const sp& callback) { - if (mApi != nullptr) { - LOC_LOGd("mApi is NOT nullptr"); - return Void(); - } - - mApi = new GeofenceAPIClient(callback); - if (mApi == nullptr) { - LOC_LOGE("%s]: failed to create mApi", __FUNCTION__); - } - - if (mGnssGeofencingCbIface != nullptr) { - mGnssGeofencingCbIface->unlinkToDeath(mGnssGeofencingDeathRecipient); - } - mGnssGeofencingCbIface = callback; - if (mGnssGeofencingCbIface != nullptr) { - mGnssGeofencingCbIface->linkToDeath(mGnssGeofencingDeathRecipient, 0 /*cookie*/); - } - - return Void(); -} - -Return GnssGeofencing::addGeofence( - int32_t geofenceId, - double latitudeDegrees, - double longitudeDegrees, - double radiusMeters, - IGnssGeofenceCallback::GeofenceTransition lastTransition, - int32_t monitorTransitions, - uint32_t notificationResponsivenessMs, - uint32_t unknownTimerMs) { - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - mApi->geofenceAdd( - geofenceId, - latitudeDegrees, - longitudeDegrees, - radiusMeters, - static_cast(lastTransition), - monitorTransitions, - notificationResponsivenessMs, - unknownTimerMs); - } - return Void(); -} - -Return GnssGeofencing::pauseGeofence(int32_t geofenceId) { - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - mApi->geofencePause(geofenceId); - } - return Void(); -} - -Return GnssGeofencing::resumeGeofence(int32_t geofenceId, int32_t monitorTransitions) { - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - mApi->geofenceResume(geofenceId, monitorTransitions); - } - return Void(); -} - -Return GnssGeofencing::removeGeofence(int32_t geofenceId) { - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - } else { - mApi->geofenceRemove(geofenceId); - } - return Void(); -} - -Return GnssGeofencing::removeAllGeofences() { - if (mApi == nullptr) { - LOC_LOGD("%s]: mApi is nullptr, do nothing", __FUNCTION__); - } else { - mApi->geofenceRemoveAll(); - } - return Void(); -} - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.1/GnssGeofencing.h b/gps/android/1.1/GnssGeofencing.h deleted file mode 100644 index 94a73de..0000000 --- a/gps/android/1.1/GnssGeofencing.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_GNSSGEOFENCING_H -#define ANDROID_HARDWARE_GNSS_V1_1_GNSSGEOFENCING_H - -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback; -using ::android::hardware::gnss::V1_0::IGnssGeofencing; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -class GeofenceAPIClient; -struct GnssGeofencing : public IGnssGeofencing { - GnssGeofencing(); - ~GnssGeofencing(); - - /* - * Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow. - * These declarations were generated from IGnssGeofencing.hal. - */ - Return setCallback(const sp& callback) override; - Return addGeofence(int32_t geofenceId, - double latitudeDegrees, - double longitudeDegrees, - double radiusMeters, - IGnssGeofenceCallback::GeofenceTransition lastTransition, - int32_t monitorTransitions, - uint32_t notificationResponsivenessMs, - uint32_t unknownTimerMs) override; - - Return pauseGeofence(int32_t geofenceId) override; - Return resumeGeofence(int32_t geofenceId, int32_t monitorTransitions) override; - Return removeGeofence(int32_t geofenceId) override; - - private: - // This method is not part of the IGnss base class. - // It is called by GnssGeofencingDeathRecipient to remove all geofences added so far. - Return removeAllGeofences(); - - private: - struct GnssGeofencingDeathRecipient : hidl_death_recipient { - GnssGeofencingDeathRecipient(sp gnssGeofencing) : - mGnssGeofencing(gnssGeofencing) { - } - ~GnssGeofencingDeathRecipient() = default; - virtual void serviceDied(uint64_t cookie, const wp& who) override; - sp mGnssGeofencing; - }; - - private: - sp mGnssGeofencingDeathRecipient = nullptr; - sp mGnssGeofencingCbIface = nullptr; - GeofenceAPIClient* mApi = nullptr; -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSGEOFENCING_H diff --git a/gps/android/1.1/GnssMeasurement.cpp b/gps/android/1.1/GnssMeasurement.cpp deleted file mode 100644 index ffe5c52..0000000 --- a/gps/android/1.1/GnssMeasurement.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc_GnssMeasurementInterface" - -#include -#include -#include "GnssMeasurement.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -void GnssMeasurement::GnssMeasurementDeathRecipient::serviceDied( - uint64_t cookie, const wp& who) { - LOC_LOGE("%s] service died. cookie: %llu, who: %p", - __FUNCTION__, static_cast(cookie), &who); - if (mGnssMeasurement != nullptr) { - mGnssMeasurement->close(); - } -} - -GnssMeasurement::GnssMeasurement() { - mGnssMeasurementDeathRecipient = new GnssMeasurementDeathRecipient(this); - mApi = new MeasurementAPIClient(); -} - -GnssMeasurement::~GnssMeasurement() { - if (mApi) { - delete mApi; - mApi = nullptr; - } -} - -// Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow. - -Return GnssMeasurement::setCallback( - const sp& callback) { - - Return ret = - IGnssMeasurement::GnssMeasurementStatus::ERROR_GENERIC; - if (mGnssMeasurementCbIface != nullptr) { - LOC_LOGE("%s]: GnssMeasurementCallback is already set", __FUNCTION__); - return IGnssMeasurement::GnssMeasurementStatus::ERROR_ALREADY_INIT; - } - - if (callback == nullptr) { - LOC_LOGE("%s]: callback is nullptr", __FUNCTION__); - return ret; - } - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - return ret; - } - - mGnssMeasurementCbIface = callback; - mGnssMeasurementCbIface->linkToDeath(mGnssMeasurementDeathRecipient, 0); - - return mApi->measurementSetCallback(callback); - -} - -Return GnssMeasurement::close() { - if (mApi == nullptr) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - return Void(); - } - - if (mGnssMeasurementCbIface != nullptr) { - mGnssMeasurementCbIface->unlinkToDeath(mGnssMeasurementDeathRecipient); - mGnssMeasurementCbIface = nullptr; - } - if (mGnssMeasurementCbIface_1_1 != nullptr) { - mGnssMeasurementCbIface_1_1->unlinkToDeath(mGnssMeasurementDeathRecipient); - mGnssMeasurementCbIface_1_1 = nullptr; - } - mApi->measurementClose(); - - return Void(); -} - -// Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow. -Return GnssMeasurement::setCallback_1_1( - const sp& callback, bool enableFullTracking) { - - Return ret = - IGnssMeasurement::GnssMeasurementStatus::ERROR_GENERIC; - if (mGnssMeasurementCbIface_1_1 != nullptr) { - LOC_LOGE("%s]: GnssMeasurementCallback is already set", __FUNCTION__); - return IGnssMeasurement::GnssMeasurementStatus::ERROR_ALREADY_INIT; - } - - if (callback == nullptr) { - LOC_LOGE("%s]: callback is nullptr", __FUNCTION__); - return ret; - } - if (nullptr == mApi) { - LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__); - return ret; - } - - mGnssMeasurementCbIface_1_1 = callback; - mGnssMeasurementCbIface_1_1->linkToDeath(mGnssMeasurementDeathRecipient, 0); - - GnssPowerMode powerMode = enableFullTracking? - GNSS_POWER_MODE_M1 : GNSS_POWER_MODE_M2; - - return mApi->measurementSetCallback_1_1(callback, powerMode); -} - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.1/GnssMeasurement.h b/gps/android/1.1/GnssMeasurement.h deleted file mode 100644 index 373f0d0..0000000 --- a/gps/android/1.1/GnssMeasurement.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_GNSSMEASUREMENT_H -#define ANDROID_HARDWARE_GNSS_V1_1_GNSSMEASUREMENT_H - -#include -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_1::IGnssMeasurement; -using ::android::hardware::gnss::V1_1::IGnssMeasurementCallback; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -class MeasurementAPIClient; -struct GnssMeasurement : public IGnssMeasurement { - GnssMeasurement(); - ~GnssMeasurement(); - - /* - * Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow. - * These declarations were generated from IGnssMeasurement.hal. - */ - Return setCallback( - const sp& callback) override; - Return close() override; - - // Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow. - Return setCallback_1_1( - const sp& callback, - bool enableFullTracking) override; - - private: - struct GnssMeasurementDeathRecipient : hidl_death_recipient { - GnssMeasurementDeathRecipient(sp gnssMeasurement) : - mGnssMeasurement(gnssMeasurement) { - } - ~GnssMeasurementDeathRecipient() = default; - virtual void serviceDied(uint64_t cookie, const wp& who) override; - sp mGnssMeasurement; - }; - - private: - sp mGnssMeasurementDeathRecipient = nullptr; - sp mGnssMeasurementCbIface = nullptr; - sp mGnssMeasurementCbIface_1_1 = nullptr; - MeasurementAPIClient* mApi; -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSMEASUREMENT_H diff --git a/gps/android/1.1/GnssNi.cpp b/gps/android/1.1/GnssNi.cpp deleted file mode 100644 index 5ce9569..0000000 --- a/gps/android/1.1/GnssNi.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "LocSvc_GnssNiInterface" - -#include -#include "Gnss.h" -#include "GnssNi.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -void GnssNi::GnssNiDeathRecipient::serviceDied(uint64_t cookie, const wp& who) { - LOC_LOGE("%s] service died. cookie: %llu, who: %p", - __FUNCTION__, static_cast(cookie), &who); - // we do nothing here - // Gnss::GnssDeathRecipient will stop the session -} - -GnssNi::GnssNi(Gnss* gnss) : mGnss(gnss) { - mGnssNiDeathRecipient = new GnssNiDeathRecipient(this); -} - -// Methods from ::android::hardware::gnss::V1_0::IGnssNi follow. -Return GnssNi::setCallback(const sp& callback) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return Void(); - } - - mGnss->setGnssNiCb(callback); - - if (mGnssNiCbIface != nullptr) { - mGnssNiCbIface->unlinkToDeath(mGnssNiDeathRecipient); - } - mGnssNiCbIface = callback; - if (mGnssNiCbIface != nullptr) { - mGnssNiCbIface->linkToDeath(mGnssNiDeathRecipient, 0 /*cookie*/); - } - - return Void(); -} - -Return GnssNi::respond(int32_t notifId, IGnssNiCallback::GnssUserResponseType userResponse) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return Void(); - } - - GnssAPIClient* api = mGnss->getApi(); - if (api == nullptr) { - LOC_LOGE("%s]: api is nullptr", __FUNCTION__); - return Void(); - } - - api->gnssNiRespond(notifId, userResponse); - - return Void(); -} - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.1/GnssNi.h b/gps/android/1.1/GnssNi.h deleted file mode 100644 index 6733e5b..0000000 --- a/gps/android/1.1/GnssNi.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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_GNSSNI_H -#define ANDROID_HARDWARE_GNSS_V1_1_GNSSNI_H - -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssNi; -using ::android::hardware::gnss::V1_0::IGnssNiCallback; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -struct Gnss; -struct GnssNi : public IGnssNi { - GnssNi(Gnss* gnss); - ~GnssNi() = default; - - /* - * Methods from ::android::hardware::gnss::V1_0::IGnssNi follow. - * These declarations were generated from IGnssNi.hal. - */ - Return setCallback(const sp& callback) override; - Return respond(int32_t notifId, - IGnssNiCallback::GnssUserResponseType userResponse) override; - - private: - struct GnssNiDeathRecipient : hidl_death_recipient { - GnssNiDeathRecipient(sp gnssNi) : mGnssNi(gnssNi) { - } - ~GnssNiDeathRecipient() = default; - virtual void serviceDied(uint64_t cookie, const wp& who) override; - sp mGnssNi; - }; - - private: - sp mGnssNiDeathRecipient = nullptr; - sp mGnssNiCbIface = nullptr; - Gnss* mGnss = nullptr; -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSNI_H diff --git a/gps/android/1.1/android.hardware.gnss@1.1-service-qti.rc b/gps/android/1.1/android.hardware.gnss@1.1-service-qti.rc deleted file mode 100644 index 41b105b..0000000 --- a/gps/android/1.1/android.hardware.gnss@1.1-service-qti.rc +++ /dev/null @@ -1,4 +0,0 @@ -service gnss_service /vendor/bin/hw/android.hardware.gnss@1.1-service-qti - class hal - user gps - group system gps radio diff --git a/gps/android/1.1/android.hardware.gnss@1.1-service-qti.xml b/gps/android/1.1/android.hardware.gnss@1.1-service-qti.xml deleted file mode 100644 index c9c83fb..0000000 --- a/gps/android/1.1/android.hardware.gnss@1.1-service-qti.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - android.hardware.gnss - hwbinder - @1.1::IGnss/default - - - diff --git a/gps/android/1.1/location_api/BatchingAPIClient.cpp b/gps/android/1.1/location_api/BatchingAPIClient.cpp deleted file mode 100644 index 82a803f..0000000 --- a/gps/android/1.1/location_api/BatchingAPIClient.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDEBUG 0 -#define LOG_TAG "LocSvc_BatchingAPIClient" - -#include -#include - -#include "LocationUtil.h" -#include "BatchingAPIClient.h" - -#include "limits.h" - - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssBatching; -using ::android::hardware::gnss::V1_0::IGnssBatchingCallback; -using ::android::hardware::gnss::V1_0::GnssLocation; - -static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions& out, - LocationCapabilitiesMask mask); - -BatchingAPIClient::BatchingAPIClient(const sp& callback) : - LocationAPIClientBase(), - mGnssBatchingCbIface(callback), - mDefaultId(UINT_MAX), - mLocationCapabilitiesMask(0) -{ - LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback); - - LocationCallbacks locationCallbacks; - memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); - locationCallbacks.size = sizeof(LocationCallbacks); - - locationCallbacks.trackingCb = nullptr; - locationCallbacks.batchingCb = nullptr; - if (mGnssBatchingCbIface != nullptr) { - locationCallbacks.batchingCb = [this](size_t count, Location* location, - BatchingOptions batchOptions) { - onBatchingCb(count, location, batchOptions); - }; - } - locationCallbacks.geofenceBreachCb = nullptr; - locationCallbacks.geofenceStatusCb = nullptr; - locationCallbacks.gnssLocationInfoCb = nullptr; - locationCallbacks.gnssNiCb = nullptr; - locationCallbacks.gnssSvCb = nullptr; - locationCallbacks.gnssNmeaCb = nullptr; - locationCallbacks.gnssMeasurementsCb = nullptr; - - locAPISetCallbacks(locationCallbacks); -} - -BatchingAPIClient::~BatchingAPIClient() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); -} - -int BatchingAPIClient::getBatchSize() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); - return locAPIGetBatchSize(); -} - -int BatchingAPIClient::startSession(const IGnssBatching::Options& opts) -{ - LOC_LOGD("%s]: (%lld %d)", __FUNCTION__, - static_cast(opts.periodNanos), static_cast(opts.flags)); - int retVal = -1; - LocationOptions options; - convertBatchOption(opts, options, mLocationCapabilitiesMask); - uint32_t mode = 0; - if (opts.flags == static_cast(IGnssBatching::Flag::WAKEUP_ON_FIFO_FULL)) { - mode = SESSION_MODE_ON_FULL; - } - if (locAPIStartSession(mDefaultId, mode, options) == LOCATION_ERROR_SUCCESS) { - retVal = 1; - } - return retVal; -} - -int BatchingAPIClient::updateSessionOptions(const IGnssBatching::Options& opts) -{ - LOC_LOGD("%s]: (%lld %d)", __FUNCTION__, - static_cast(opts.periodNanos), static_cast(opts.flags)); - int retVal = -1; - LocationOptions options; - convertBatchOption(opts, options, mLocationCapabilitiesMask); - - uint32_t mode = 0; - if (opts.flags == static_cast(IGnssBatching::Flag::WAKEUP_ON_FIFO_FULL)) { - mode = SESSION_MODE_ON_FULL; - } - if (locAPIUpdateSessionOptions(mDefaultId, mode, options) == LOCATION_ERROR_SUCCESS) { - retVal = 1; - } - return retVal; -} - -int BatchingAPIClient::stopSession() -{ - LOC_LOGD("%s]: ", __FUNCTION__); - int retVal = -1; - if (locAPIStopSession(mDefaultId) == LOCATION_ERROR_SUCCESS) { - retVal = 1; - } - return retVal; -} - -void BatchingAPIClient::getBatchedLocation(int last_n_locations) -{ - LOC_LOGD("%s]: (%d)", __FUNCTION__, last_n_locations); - locAPIGetBatchedLocations(mDefaultId, last_n_locations); -} - -void BatchingAPIClient::flushBatchedLocations() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); - locAPIGetBatchedLocations(mDefaultId, SIZE_MAX); -} - -void BatchingAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) -{ - LOC_LOGD("%s]: (%02x)", __FUNCTION__, capabilitiesMask); - mLocationCapabilitiesMask = capabilitiesMask; -} - -void BatchingAPIClient::onBatchingCb(size_t count, Location* location, - BatchingOptions /*batchOptions*/) -{ - LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, count); - if (mGnssBatchingCbIface != nullptr && count > 0) { - hidl_vec locationVec; - locationVec.resize(count); - for (size_t i = 0; i < count; i++) { - convertGnssLocation(location[i], locationVec[i]); - } - auto r = mGnssBatchingCbIface->gnssLocationBatchCb(locationVec); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssLocationBatchCb description=%s", - __func__, r.description().c_str()); - } - } -} - -static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions& out, - LocationCapabilitiesMask mask) -{ - memset(&out, 0, sizeof(LocationOptions)); - out.size = sizeof(LocationOptions); - out.minInterval = (uint32_t)(in.periodNanos / 1000000L); - out.minDistance = 0; - out.mode = GNSS_SUPL_MODE_STANDALONE; - if (mask & LOCATION_CAPABILITIES_GNSS_MSA_BIT) - out.mode = GNSS_SUPL_MODE_MSA; - if (mask & LOCATION_CAPABILITIES_GNSS_MSB_BIT) - out.mode = GNSS_SUPL_MODE_MSB; -} - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.1/location_api/BatchingAPIClient.h b/gps/android/1.1/location_api/BatchingAPIClient.h deleted file mode 100644 index 64d47a0..0000000 --- a/gps/android/1.1/location_api/BatchingAPIClient.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef BATCHING_API_CLINET_H -#define BATCHING_API_CLINET_H - -#include -#include -#include - -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -class BatchingAPIClient : public LocationAPIClientBase -{ -public: - BatchingAPIClient(const sp& callback); - ~BatchingAPIClient(); - int getBatchSize(); - int startSession(const V1_0::IGnssBatching::Options& options); - int updateSessionOptions(const V1_0::IGnssBatching::Options& options); - int stopSession(); - void getBatchedLocation(int last_n_locations); - void flushBatchedLocations(); - - inline LocationCapabilitiesMask getCapabilities() { return mLocationCapabilitiesMask; } - - // callbacks - void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final; - void onBatchingCb(size_t count, Location* location, BatchingOptions batchOptions) final; - -private: - sp mGnssBatchingCbIface; - uint32_t mDefaultId; - LocationCapabilitiesMask mLocationCapabilitiesMask; -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android -#endif // BATCHING_API_CLINET_H diff --git a/gps/android/1.1/location_api/GeofenceAPIClient.cpp b/gps/android/1.1/location_api/GeofenceAPIClient.cpp deleted file mode 100644 index 93d175e..0000000 --- a/gps/android/1.1/location_api/GeofenceAPIClient.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDEBUG 0 -#define LOG_TAG "LocSvc_GeofenceApiClient" - -#include -#include - -#include "LocationUtil.h" -#include "GeofenceAPIClient.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback; -using ::android::hardware::gnss::V1_0::GnssLocation; - -GeofenceAPIClient::GeofenceAPIClient(const sp& callback) : - LocationAPIClientBase(), - mGnssGeofencingCbIface(callback) -{ - LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback); - - LocationCallbacks locationCallbacks; - memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); - locationCallbacks.size = sizeof(LocationCallbacks); - - locationCallbacks.trackingCb = nullptr; - locationCallbacks.batchingCb = nullptr; - - locationCallbacks.geofenceBreachCb = nullptr; - if (mGnssGeofencingCbIface != nullptr) { - locationCallbacks.geofenceBreachCb = - [this](GeofenceBreachNotification geofenceBreachNotification) { - onGeofenceBreachCb(geofenceBreachNotification); - }; - - locationCallbacks.geofenceStatusCb = - [this](GeofenceStatusNotification geofenceStatusNotification) { - onGeofenceStatusCb(geofenceStatusNotification); - }; - } - - locationCallbacks.gnssLocationInfoCb = nullptr; - locationCallbacks.gnssNiCb = nullptr; - locationCallbacks.gnssSvCb = nullptr; - locationCallbacks.gnssNmeaCb = nullptr; - locationCallbacks.gnssMeasurementsCb = nullptr; - - locAPISetCallbacks(locationCallbacks); -} - -void GeofenceAPIClient::geofenceAdd(uint32_t geofence_id, double latitude, double longitude, - double radius_meters, int32_t last_transition, int32_t monitor_transitions, - uint32_t notification_responsiveness_ms, uint32_t unknown_timer_ms) -{ - LOC_LOGD("%s]: (%d %f %f %f %d %d %d %d)", __FUNCTION__, - geofence_id, latitude, longitude, radius_meters, - last_transition, monitor_transitions, notification_responsiveness_ms, unknown_timer_ms); - - GeofenceOption options; - memset(&options, 0, sizeof(GeofenceOption)); - options.size = sizeof(GeofenceOption); - if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::ENTERED) - options.breachTypeMask |= GEOFENCE_BREACH_ENTER_BIT; - if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::EXITED) - options.breachTypeMask |= GEOFENCE_BREACH_EXIT_BIT; - options.responsiveness = notification_responsiveness_ms; - - GeofenceInfo data; - data.size = sizeof(GeofenceInfo); - data.latitude = latitude; - data.longitude = longitude; - data.radius = radius_meters; - - LocationError err = (LocationError)locAPIAddGeofences(1, &geofence_id, &options, &data); - if (LOCATION_ERROR_SUCCESS != err) { - onAddGeofencesCb(1, &err, &geofence_id); - } -} - -void GeofenceAPIClient::geofencePause(uint32_t geofence_id) -{ - LOC_LOGD("%s]: (%d)", __FUNCTION__, geofence_id); - locAPIPauseGeofences(1, &geofence_id); -} - -void GeofenceAPIClient::geofenceResume(uint32_t geofence_id, int32_t monitor_transitions) -{ - LOC_LOGD("%s]: (%d %d)", __FUNCTION__, geofence_id, monitor_transitions); - GeofenceBreachTypeMask mask = 0; - if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::ENTERED) - mask |= GEOFENCE_BREACH_ENTER_BIT; - if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::EXITED) - mask |= GEOFENCE_BREACH_EXIT_BIT; - locAPIResumeGeofences(1, &geofence_id, &mask); -} - -void GeofenceAPIClient::geofenceRemove(uint32_t geofence_id) -{ - LOC_LOGD("%s]: (%d)", __FUNCTION__, geofence_id); - locAPIRemoveGeofences(1, &geofence_id); -} - -void GeofenceAPIClient::geofenceRemoveAll() -{ - LOC_LOGD("%s]", __FUNCTION__); - // TODO locAPIRemoveAllGeofences(); -} - -// callbacks -void GeofenceAPIClient::onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification) -{ - LOC_LOGD("%s]: (%zu)", __FUNCTION__, geofenceBreachNotification.count); - if (mGnssGeofencingCbIface != nullptr) { - for (size_t i = 0; i < geofenceBreachNotification.count; i++) { - GnssLocation gnssLocation; - convertGnssLocation(geofenceBreachNotification.location, gnssLocation); - - IGnssGeofenceCallback::GeofenceTransition transition; - if (geofenceBreachNotification.type == GEOFENCE_BREACH_ENTER) - transition = IGnssGeofenceCallback::GeofenceTransition::ENTERED; - else if (geofenceBreachNotification.type == GEOFENCE_BREACH_EXIT) - transition = IGnssGeofenceCallback::GeofenceTransition::EXITED; - else { - // continue with other breach if transition is - // nether GPS_GEOFENCE_ENTERED nor GPS_GEOFENCE_EXITED - continue; - } - - auto r = mGnssGeofencingCbIface->gnssGeofenceTransitionCb( - geofenceBreachNotification.ids[i], gnssLocation, transition, - static_cast(geofenceBreachNotification.timestamp)); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssGeofenceTransitionCb description=%s", - __func__, r.description().c_str()); - } - } - } -} - -void GeofenceAPIClient::onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification) -{ - LOC_LOGD("%s]: (%d)", __FUNCTION__, geofenceStatusNotification.available); - if (mGnssGeofencingCbIface != nullptr) { - IGnssGeofenceCallback::GeofenceAvailability status = - IGnssGeofenceCallback::GeofenceAvailability::UNAVAILABLE; - if (geofenceStatusNotification.available == GEOFENCE_STATUS_AVAILABILE_YES) { - status = IGnssGeofenceCallback::GeofenceAvailability::AVAILABLE; - } - GnssLocation gnssLocation; - memset(&gnssLocation, 0, sizeof(GnssLocation)); - auto r = mGnssGeofencingCbIface->gnssGeofenceStatusCb(status, gnssLocation); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssGeofenceStatusCb description=%s", - __func__, r.description().c_str()); - } - } -} - -void GeofenceAPIClient::onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) -{ - LOC_LOGD("%s]: (%zu)", __FUNCTION__, count); - if (mGnssGeofencingCbIface != nullptr) { - for (size_t i = 0; i < count; i++) { - IGnssGeofenceCallback::GeofenceStatus status = - IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC; - if (errors[i] == LOCATION_ERROR_SUCCESS) - status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS; - else if (errors[i] == LOCATION_ERROR_ID_EXISTS) - status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_EXISTS; - auto r = mGnssGeofencingCbIface->gnssGeofenceAddCb(ids[i], status); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssGeofenceAddCb description=%s", - __func__, r.description().c_str()); - } - } - } -} - -void GeofenceAPIClient::onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) -{ - LOC_LOGD("%s]: (%zu)", __FUNCTION__, count); - if (mGnssGeofencingCbIface != nullptr) { - for (size_t i = 0; i < count; i++) { - IGnssGeofenceCallback::GeofenceStatus status = - IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC; - if (errors[i] == LOCATION_ERROR_SUCCESS) - status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS; - else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN) - status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN; - auto r = mGnssGeofencingCbIface->gnssGeofenceRemoveCb(ids[i], status); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssGeofenceRemoveCb description=%s", - __func__, r.description().c_str()); - } - } - } -} - -void GeofenceAPIClient::onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) -{ - LOC_LOGD("%s]: (%zu)", __FUNCTION__, count); - if (mGnssGeofencingCbIface != nullptr) { - for (size_t i = 0; i < count; i++) { - IGnssGeofenceCallback::GeofenceStatus status = - IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC; - if (errors[i] == LOCATION_ERROR_SUCCESS) - status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS; - else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN) - status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN; - auto r = mGnssGeofencingCbIface->gnssGeofencePauseCb(ids[i], status); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssGeofencePauseCb description=%s", - __func__, r.description().c_str()); - } - } - } -} - -void GeofenceAPIClient::onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) -{ - LOC_LOGD("%s]: (%zu)", __FUNCTION__, count); - if (mGnssGeofencingCbIface != nullptr) { - for (size_t i = 0; i < count; i++) { - IGnssGeofenceCallback::GeofenceStatus status = - IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC; - if (errors[i] == LOCATION_ERROR_SUCCESS) - status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS; - else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN) - status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN; - auto r = mGnssGeofencingCbIface->gnssGeofenceResumeCb(ids[i], status); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssGeofenceResumeCb description=%s", - __func__, r.description().c_str()); - } - } - } -} - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.1/location_api/GeofenceAPIClient.h b/gps/android/1.1/location_api/GeofenceAPIClient.h deleted file mode 100644 index c74a59a..0000000 --- a/gps/android/1.1/location_api/GeofenceAPIClient.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GEOFENCE_API_CLINET_H -#define GEOFENCE_API_CLINET_H - - -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::sp; - -class GeofenceAPIClient : public LocationAPIClientBase -{ -public: - GeofenceAPIClient(const sp& 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, - uint32_t notification_responsiveness_ms, uint32_t unknown_timer_ms); - void geofencePause(uint32_t geofence_id); - void geofenceResume(uint32_t geofence_id, int32_t monitor_transitions); - void geofenceRemove(uint32_t geofence_id); - void geofenceRemoveAll(); - - // callbacks - void onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification) final; - void onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification) final; - void onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final; - void onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final; - void onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final; - void onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final; - -private: - sp mGnssGeofencingCbIface; -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android -#endif // GEOFENCE_API_CLINET_H diff --git a/gps/android/1.1/location_api/GnssAPIClient.cpp b/gps/android/1.1/location_api/GnssAPIClient.cpp deleted file mode 100644 index 89877e5..0000000 --- a/gps/android/1.1/location_api/GnssAPIClient.cpp +++ /dev/null @@ -1,565 +0,0 @@ -/* Copyright (c) 2017-2019, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDEBUG 0 -#define LOG_TAG "LocSvc_GnssAPIClient" -#define SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC (590 * 60 * 60 * 1000) // 590 hours - -#include -#include - -#include "LocationUtil.h" -#include "GnssAPIClient.h" -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnss; -using ::android::hardware::gnss::V1_0::IGnssCallback; -using ::android::hardware::gnss::V1_0::IGnssNiCallback; -using ::android::hardware::gnss::V1_0::GnssLocation; - -static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvStatus& out); - -GnssAPIClient::GnssAPIClient(const sp& gpsCb, - const sp& niCb) : - LocationAPIClientBase(), - mGnssCbIface(nullptr), - mGnssNiCbIface(nullptr), - mControlClient(new LocationAPIControlClient()), - mLocationCapabilitiesMask(0), - mLocationCapabilitiesCached(false) -{ - LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb); - - // set default LocationOptions. - memset(&mTrackingOptions, 0, sizeof(TrackingOptions)); - mTrackingOptions.size = sizeof(TrackingOptions); - mTrackingOptions.minInterval = 1000; - mTrackingOptions.minDistance = 0; - mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE; - - gnssUpdateCallbacks(gpsCb, niCb); -} - -GnssAPIClient::~GnssAPIClient() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); - if (mControlClient) { - delete mControlClient; - mControlClient = nullptr; - } -} - -// for GpsInterface -void GnssAPIClient::gnssUpdateCallbacks(const sp& gpsCb, - const sp& niCb) -{ - LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb); - - mMutex.lock(); - mGnssCbIface = gpsCb; - mGnssNiCbIface = niCb; - mMutex.unlock(); - - LocationCallbacks locationCallbacks; - memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); - locationCallbacks.size = sizeof(LocationCallbacks); - - locationCallbacks.trackingCb = nullptr; - if (mGnssCbIface != nullptr) { - locationCallbacks.trackingCb = [this](Location location) { - onTrackingCb(location); - }; - } - - locationCallbacks.batchingCb = nullptr; - locationCallbacks.geofenceBreachCb = nullptr; - locationCallbacks.geofenceStatusCb = nullptr; - locationCallbacks.gnssLocationInfoCb = nullptr; - - locationCallbacks.gnssNiCb = nullptr; - loc_core::ContextBase* context = - loc_core::LocContext::getLocContext( - NULL, NULL, - loc_core::LocContext::mLocationHalName, false); - if (mGnssNiCbIface != nullptr && !context->hasAgpsExtendedCapabilities()) { - LOC_LOGD("Registering NI CB"); - locationCallbacks.gnssNiCb = [this](uint32_t id, GnssNiNotification gnssNiNotification) { - onGnssNiCb(id, gnssNiNotification); - }; - } - - locationCallbacks.gnssSvCb = nullptr; - if (mGnssCbIface != nullptr) { - locationCallbacks.gnssSvCb = [this](GnssSvNotification gnssSvNotification) { - onGnssSvCb(gnssSvNotification); - }; - } - - locationCallbacks.gnssNmeaCb = nullptr; - if (mGnssCbIface != nullptr) { - locationCallbacks.gnssNmeaCb = [this](GnssNmeaNotification gnssNmeaNotification) { - onGnssNmeaCb(gnssNmeaNotification); - }; - } - - locationCallbacks.gnssMeasurementsCb = nullptr; - - locAPISetCallbacks(locationCallbacks); -} - -bool GnssAPIClient::gnssStart() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); - bool retVal = true; - locAPIStartTracking(mTrackingOptions); - return retVal; -} - -bool GnssAPIClient::gnssStop() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); - bool retVal = true; - locAPIStopTracking(); - return retVal; -} - -bool GnssAPIClient::gnssSetPositionMode(IGnss::GnssPositionMode mode, - IGnss::GnssPositionRecurrence recurrence, uint32_t minIntervalMs, - uint32_t preferredAccuracyMeters, uint32_t preferredTimeMs, - GnssPowerMode powerMode, uint32_t timeBetweenMeasurement) -{ - LOC_LOGD("%s]: (%d %d %d %d %d %d %d)", __FUNCTION__, - (int)mode, recurrence, minIntervalMs, preferredAccuracyMeters, - preferredTimeMs, (int)powerMode, timeBetweenMeasurement); - bool retVal = true; - memset(&mTrackingOptions, 0, sizeof(TrackingOptions)); - mTrackingOptions.size = sizeof(TrackingOptions); - mTrackingOptions.minInterval = minIntervalMs; - if (IGnss::GnssPositionMode::MS_ASSISTED == mode || - IGnss::GnssPositionRecurrence::RECURRENCE_SINGLE == recurrence) { - // We set a very large interval to simulate SINGLE mode. Once we report a fix, - // the caller should take the responsibility to stop the session. - // For MSA, we always treat it as SINGLE mode. - mTrackingOptions.minInterval = SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC; - } - mTrackingOptions.minDistance = preferredAccuracyMeters; - if (mode == IGnss::GnssPositionMode::STANDALONE) - mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE; - else if (mode == IGnss::GnssPositionMode::MS_BASED) - mTrackingOptions.mode = GNSS_SUPL_MODE_MSB; - else if (mode == IGnss::GnssPositionMode::MS_ASSISTED) - mTrackingOptions.mode = GNSS_SUPL_MODE_MSA; - else { - LOC_LOGD("%s]: invalid GnssPositionMode: %d", __FUNCTION__, (int)mode); - retVal = false; - } - if (GNSS_POWER_MODE_INVALID != powerMode) { - mTrackingOptions.powerMode = powerMode; - mTrackingOptions.tbm = timeBetweenMeasurement; - } - locAPIUpdateTrackingOptions(mTrackingOptions); - return retVal; -} - -// for GpsNiInterface -void GnssAPIClient::gnssNiRespond(int32_t notifId, - IGnssNiCallback::GnssUserResponseType userResponse) -{ - LOC_LOGD("%s]: (%d %d)", __FUNCTION__, notifId, static_cast(userResponse)); - GnssNiResponse data; - switch (userResponse) { - case IGnssNiCallback::GnssUserResponseType::RESPONSE_ACCEPT: - data = GNSS_NI_RESPONSE_ACCEPT; - break; - case IGnssNiCallback::GnssUserResponseType::RESPONSE_DENY: - data = GNSS_NI_RESPONSE_DENY; - break; - case IGnssNiCallback::GnssUserResponseType::RESPONSE_NORESP: - data = GNSS_NI_RESPONSE_NO_RESPONSE; - break; - default: - data = GNSS_NI_RESPONSE_IGNORE; - break; - } - - locAPIGnssNiResponse(notifId, data); -} - -// these apis using LocationAPIControlClient -void GnssAPIClient::gnssDeleteAidingData(IGnss::GnssAidingData aidingDataFlags) -{ - LOC_LOGD("%s]: (%02hx)", __FUNCTION__, aidingDataFlags); - if (mControlClient == nullptr) { - return; - } - GnssAidingData data; - memset(&data, 0, sizeof (GnssAidingData)); - data.sv.svTypeMask = GNSS_AIDING_DATA_SV_TYPE_GPS_BIT | - GNSS_AIDING_DATA_SV_TYPE_GLONASS_BIT | - GNSS_AIDING_DATA_SV_TYPE_QZSS_BIT | - GNSS_AIDING_DATA_SV_TYPE_BEIDOU_BIT | - GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT; - - if (aidingDataFlags == IGnss::GnssAidingData::DELETE_ALL) - data.deleteAll = true; - else { - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_EPHEMERIS) - data.sv.svMask |= GNSS_AIDING_DATA_SV_EPHEMERIS_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_ALMANAC) - data.sv.svMask |= GNSS_AIDING_DATA_SV_ALMANAC_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_POSITION) - data.common.mask |= GNSS_AIDING_DATA_COMMON_POSITION_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_TIME) - data.common.mask |= GNSS_AIDING_DATA_COMMON_TIME_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_IONO) - data.sv.svMask |= GNSS_AIDING_DATA_SV_IONOSPHERE_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_UTC) - data.common.mask |= GNSS_AIDING_DATA_COMMON_UTC_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_HEALTH) - data.sv.svMask |= GNSS_AIDING_DATA_SV_HEALTH_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SVDIR) - data.sv.svMask |= GNSS_AIDING_DATA_SV_DIRECTION_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SVSTEER) - data.sv.svMask |= GNSS_AIDING_DATA_SV_STEER_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SADATA) - data.sv.svMask |= GNSS_AIDING_DATA_SV_SA_DATA_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_RTI) - data.common.mask |= GNSS_AIDING_DATA_COMMON_RTI_BIT; - if (aidingDataFlags & IGnss::GnssAidingData::DELETE_CELLDB_INFO) - data.common.mask |= GNSS_AIDING_DATA_COMMON_CELLDB_BIT; - } - mControlClient->locAPIGnssDeleteAidingData(data); -} - -void GnssAPIClient::gnssEnable(LocationTechnologyType techType) -{ - LOC_LOGD("%s]: (%0d)", __FUNCTION__, techType); - if (mControlClient == nullptr) { - return; - } - mControlClient->locAPIEnable(techType); -} - -void GnssAPIClient::gnssDisable() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); - if (mControlClient == nullptr) { - return; - } - mControlClient->locAPIDisable(); -} - -void GnssAPIClient::gnssConfigurationUpdate(const GnssConfig& gnssConfig) -{ - LOC_LOGD("%s]: (%02x)", __FUNCTION__, gnssConfig.flags); - if (mControlClient == nullptr) { - return; - } - mControlClient->locAPIGnssUpdateConfig(gnssConfig); -} - -void GnssAPIClient::requestCapabilities() { - // only send capablities if it's already cached, otherwise the first time LocationAPI - // is initialized, capabilities will be sent by LocationAPI - if (mLocationCapabilitiesCached) { - onCapabilitiesCb(mLocationCapabilitiesMask); - } -} - -// callbacks -void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) -{ - LOC_LOGD("%s]: (%02x)", __FUNCTION__, capabilitiesMask); - mLocationCapabilitiesMask = capabilitiesMask; - mLocationCapabilitiesCached = true; - - mMutex.lock(); - auto gnssCbIface(mGnssCbIface); - mMutex.unlock(); - - if (gnssCbIface != nullptr) { - uint32_t data = 0; - if ((capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT) || - (capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT) || - (capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT) || - (capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT)) - data |= IGnssCallback::Capabilities::SCHEDULING; - if (capabilitiesMask & LOCATION_CAPABILITIES_GEOFENCE_BIT) - data |= IGnssCallback::Capabilities::GEOFENCING; - if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT) - data |= IGnssCallback::Capabilities::MEASUREMENTS; - if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSB_BIT) - data |= IGnssCallback::Capabilities::MSB; - if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSA_BIT) - data |= IGnssCallback::Capabilities::MSA; - auto r = gnssCbIface->gnssSetCapabilitesCb(data); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssSetCapabilitesCb description=%s", - __func__, r.description().c_str()); - } - } - 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; - } - LOC_LOGV("%s:%d] set_system_info_cb (%d)", __FUNCTION__, __LINE__, gnssInfo.yearOfHw); - auto r = gnssCbIface->gnssSetSystemInfoCb(gnssInfo); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssSetSystemInfoCb description=%s", - __func__, r.description().c_str()); - } - } -} - -void GnssAPIClient::onTrackingCb(Location location) -{ - LOC_LOGD("%s]: (flags: %02x)", __FUNCTION__, location.flags); - mMutex.lock(); - auto gnssCbIface(mGnssCbIface); - mMutex.unlock(); - - if (gnssCbIface != nullptr) { - GnssLocation gnssLocation; - convertGnssLocation(location, gnssLocation); - auto r = gnssCbIface->gnssLocationCb(gnssLocation); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssLocationCb description=%s", - __func__, r.description().c_str()); - } - } -} - -void GnssAPIClient::onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification) -{ - LOC_LOGD("%s]: (id: %d)", __FUNCTION__, id); - mMutex.lock(); - auto gnssNiCbIface(mGnssNiCbIface); - mMutex.unlock(); - - if (gnssNiCbIface == nullptr) { - LOC_LOGE("%s]: mGnssNiCbIface is nullptr", __FUNCTION__); - return; - } - - IGnssNiCallback::GnssNiNotification notificationGnss = {}; - - notificationGnss.notificationId = id; - - if (gnssNiNotification.type == GNSS_NI_TYPE_VOICE) - notificationGnss.niType = IGnssNiCallback::GnssNiType::VOICE; - else if (gnssNiNotification.type == GNSS_NI_TYPE_SUPL) - notificationGnss.niType = IGnssNiCallback::GnssNiType::UMTS_SUPL; - else if (gnssNiNotification.type == GNSS_NI_TYPE_CONTROL_PLANE) - notificationGnss.niType = IGnssNiCallback::GnssNiType::UMTS_CTRL_PLANE; - else if (gnssNiNotification.type == GNSS_NI_TYPE_EMERGENCY_SUPL) - notificationGnss.niType = IGnssNiCallback::GnssNiType::EMERGENCY_SUPL; - - if (gnssNiNotification.options & GNSS_NI_OPTIONS_NOTIFICATION_BIT) - notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::NEED_NOTIFY; - if (gnssNiNotification.options & GNSS_NI_OPTIONS_VERIFICATION_BIT) - notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::NEED_VERIFY; - if (gnssNiNotification.options & GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT) - notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::PRIVACY_OVERRIDE; - - notificationGnss.timeoutSec = gnssNiNotification.timeout; - - if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_ACCEPT) - notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_ACCEPT; - else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_DENY) - notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_DENY; - else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_NO_RESPONSE || - gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_IGNORE) - notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_NORESP; - - notificationGnss.requestorId = gnssNiNotification.requestor; - - notificationGnss.notificationMessage = gnssNiNotification.message; - - if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_NONE) - notificationGnss.requestorIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_NONE; - else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT) - notificationGnss.requestorIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_GSM_DEFAULT; - else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UTF8) - notificationGnss.requestorIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UTF8; - else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UCS2) - notificationGnss.requestorIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UCS2; - - if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_NONE) - notificationGnss.notificationIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_NONE; - else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT) - notificationGnss.notificationIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_GSM_DEFAULT; - else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UTF8) - notificationGnss.notificationIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UTF8; - else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UCS2) - notificationGnss.notificationIdEncoding = - IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UCS2; - - gnssNiCbIface->niNotifyCb(notificationGnss); -} - -void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification) -{ - LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, gnssSvNotification.count); - mMutex.lock(); - auto gnssCbIface(mGnssCbIface); - mMutex.unlock(); - - if (gnssCbIface != nullptr) { - IGnssCallback::GnssSvStatus svStatus; - convertGnssSvStatus(gnssSvNotification, svStatus); - auto r = gnssCbIface->gnssSvStatusCb(svStatus); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssSvStatusCb description=%s", - __func__, r.description().c_str()); - } - } -} - -void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification) -{ - mMutex.lock(); - auto gnssCbIface(mGnssCbIface); - mMutex.unlock(); - - if (gnssCbIface != nullptr) { - const std::string s(gnssNmeaNotification.nmea); - std::stringstream ss(s); - std::string each; - while(std::getline(ss, each, '\n')) { - each += '\n'; - android::hardware::hidl_string nmeaString; - nmeaString.setToExternal(each.c_str(), each.length()); - auto r = gnssCbIface->gnssNmeaCb( - static_cast(gnssNmeaNotification.timestamp), nmeaString); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssNmeaCb nmea=%s length=%zu description=%s", __func__, - gnssNmeaNotification.nmea, gnssNmeaNotification.length, - r.description().c_str()); - } - } - } -} - -void GnssAPIClient::onStartTrackingCb(LocationError error) -{ - LOC_LOGD("%s]: (%d)", __FUNCTION__, error); - mMutex.lock(); - auto gnssCbIface(mGnssCbIface); - mMutex.unlock(); - - if (error == LOCATION_ERROR_SUCCESS && gnssCbIface != nullptr) { - auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_ON); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssStatusCb ENGINE_ON description=%s", - __func__, r.description().c_str()); - } - r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_BEGIN); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssStatusCb SESSION_BEGIN description=%s", - __func__, r.description().c_str()); - } - } -} - -void GnssAPIClient::onStopTrackingCb(LocationError error) -{ - LOC_LOGD("%s]: (%d)", __FUNCTION__, error); - mMutex.lock(); - auto gnssCbIface(mGnssCbIface); - mMutex.unlock(); - - if (error == LOCATION_ERROR_SUCCESS && gnssCbIface != nullptr) { - auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_END); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssStatusCb SESSION_END description=%s", - __func__, r.description().c_str()); - } - r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_OFF); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssStatusCb ENGINE_OFF description=%s", - __func__, r.description().c_str()); - } - } -} - -static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvStatus& out) -{ - memset(&out, 0, sizeof(IGnssCallback::GnssSvStatus)); - out.numSvs = in.count; - if (out.numSvs > static_cast(V1_0::GnssMax::SVS_COUNT)) { - LOC_LOGW("%s]: Too many satellites %u. Clamps to %d.", - __FUNCTION__, out.numSvs, V1_0::GnssMax::SVS_COUNT); - out.numSvs = static_cast(V1_0::GnssMax::SVS_COUNT); - } - for (size_t i = 0; i < out.numSvs; i++) { - IGnssCallback::GnssSvInfo& info = out.gnssSvList[i]; - info.svid = in.gnssSvs[i].svId; - convertGnssConstellationType(in.gnssSvs[i].type, info.constellation); - info.cN0Dbhz = in.gnssSvs[i].cN0Dbhz; - info.elevationDegrees = in.gnssSvs[i].elevation; - info.azimuthDegrees = in.gnssSvs[i].azimuth; - info.carrierFrequencyHz = in.gnssSvs[i].carrierFrequencyHz; - info.svFlag = static_cast(IGnssCallback::GnssSvFlags::NONE); - if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_EPHEMER_BIT) - info.svFlag |= IGnssCallback::GnssSvFlags::HAS_EPHEMERIS_DATA; - if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_ALMANAC_BIT) - info.svFlag |= IGnssCallback::GnssSvFlags::HAS_ALMANAC_DATA; - if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT) - info.svFlag |= IGnssCallback::GnssSvFlags::USED_IN_FIX; - if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_CARRIER_FREQUENCY_BIT) - info.svFlag |= IGnssCallback::GnssSvFlags::HAS_CARRIER_FREQUENCY; - } -} - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.1/location_api/GnssAPIClient.h b/gps/android/1.1/location_api/GnssAPIClient.h deleted file mode 100644 index 82f8fbf..0000000 --- a/gps/android/1.1/location_api/GnssAPIClient.h +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GNSS_API_CLINET_H -#define GNSS_API_CLINET_H - - -#include -#include -#include -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::sp; - -class GnssAPIClient : public LocationAPIClientBase -{ -public: - GnssAPIClient(const sp& gpsCb, - const sp& niCb); - virtual ~GnssAPIClient(); - GnssAPIClient(const GnssAPIClient&) = delete; - GnssAPIClient& operator=(const GnssAPIClient&) = delete; - - // for GpsInterface - void gnssUpdateCallbacks(const sp& gpsCb, - const sp& niCb); - bool gnssStart(); - bool gnssStop(); - bool gnssSetPositionMode(V1_0::IGnss::GnssPositionMode mode, - V1_0::IGnss::GnssPositionRecurrence recurrence, - uint32_t minIntervalMs, - uint32_t preferredAccuracyMeters, - uint32_t preferredTimeMs, - GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID, - uint32_t timeBetweenMeasurement = 0); - - // for GpsNiInterface - void gnssNiRespond(int32_t notifId, V1_0::IGnssNiCallback::GnssUserResponseType userResponse); - - // these apis using LocationAPIControlClient - void gnssDeleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags); - void gnssEnable(LocationTechnologyType techType); - void gnssDisable(); - void gnssConfigurationUpdate(const GnssConfig& gnssConfig); - - inline LocationCapabilitiesMask gnssGetCapabilities() const { - return mLocationCapabilitiesMask; - } - void requestCapabilities(); - - // callbacks we are interested in - void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final; - void onTrackingCb(Location location) final; - void onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification) final; - void onGnssSvCb(GnssSvNotification gnssSvNotification) final; - void onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification) final; - - void onStartTrackingCb(LocationError error) final; - void onStopTrackingCb(LocationError error) final; - -private: - sp mGnssCbIface; - sp mGnssNiCbIface; - std::mutex mMutex; - LocationAPIControlClient* mControlClient; - LocationCapabilitiesMask mLocationCapabilitiesMask; - bool mLocationCapabilitiesCached; - TrackingOptions mTrackingOptions; -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android -#endif // GNSS_API_CLINET_H diff --git a/gps/android/1.1/location_api/LocationUtil.cpp b/gps/android/1.1/location_api/LocationUtil.cpp deleted file mode 100644 index f1d051c..0000000 --- a/gps/android/1.1/location_api/LocationUtil.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::GnssLocation; -using ::android::hardware::gnss::V1_0::GnssConstellationType; -using ::android::hardware::gnss::V1_0::GnssLocationFlags; - -void convertGnssLocation(Location& in, GnssLocation& out) -{ - memset(&out, 0, sizeof(GnssLocation)); - if (in.flags & LOCATION_HAS_LAT_LONG_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_LAT_LONG; - out.latitudeDegrees = in.latitude; - out.longitudeDegrees = in.longitude; - } - if (in.flags & LOCATION_HAS_ALTITUDE_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_ALTITUDE; - out.altitudeMeters = in.altitude; - } - if (in.flags & LOCATION_HAS_SPEED_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED; - out.speedMetersPerSec = in.speed; - } - if (in.flags & LOCATION_HAS_BEARING_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING; - out.bearingDegrees = in.bearing; - } - if (in.flags & LOCATION_HAS_ACCURACY_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_HORIZONTAL_ACCURACY; - out.horizontalAccuracyMeters = in.accuracy; - } - if (in.flags & LOCATION_HAS_VERTICAL_ACCURACY_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_VERTICAL_ACCURACY; - out.verticalAccuracyMeters = in.verticalAccuracy; - } - if (in.flags & LOCATION_HAS_SPEED_ACCURACY_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED_ACCURACY; - out.speedAccuracyMetersPerSecond = in.speedAccuracy; - } - if (in.flags & LOCATION_HAS_BEARING_ACCURACY_BIT) { - out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING_ACCURACY; - out.bearingAccuracyDegrees = in.bearingAccuracy; - } - - out.timestamp = static_cast(in.timestamp); -} - -void convertGnssLocation(const GnssLocation& in, Location& out) -{ - memset(&out, 0, sizeof(out)); - if (in.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG) { - out.flags |= LOCATION_HAS_LAT_LONG_BIT; - out.latitude = in.latitudeDegrees; - out.longitude = in.longitudeDegrees; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE) { - out.flags |= LOCATION_HAS_ALTITUDE_BIT; - out.altitude = in.altitudeMeters; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED) { - out.flags |= LOCATION_HAS_SPEED_BIT; - out.speed = in.speedMetersPerSec; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) { - out.flags |= LOCATION_HAS_BEARING_BIT; - out.bearing = in.bearingDegrees; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY) { - out.flags |= LOCATION_HAS_ACCURACY_BIT; - out.accuracy = in.horizontalAccuracyMeters; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) { - out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT; - out.verticalAccuracy = in.verticalAccuracyMeters; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) { - out.flags |= LOCATION_HAS_SPEED_ACCURACY_BIT; - out.speedAccuracy = in.speedAccuracyMetersPerSecond; - } - if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) { - out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT; - out.bearingAccuracy = in.bearingAccuracyDegrees; - } - - out.timestamp = static_cast(in.timestamp); -} - -void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out) -{ - switch(in) { - case GNSS_SV_TYPE_GPS: - out = GnssConstellationType::GPS; - break; - case GNSS_SV_TYPE_SBAS: - out = GnssConstellationType::SBAS; - break; - case GNSS_SV_TYPE_GLONASS: - out = GnssConstellationType::GLONASS; - break; - case GNSS_SV_TYPE_QZSS: - out = GnssConstellationType::QZSS; - break; - case GNSS_SV_TYPE_BEIDOU: - out = GnssConstellationType::BEIDOU; - break; - case GNSS_SV_TYPE_GALILEO: - out = GnssConstellationType::GALILEO; - break; - case GNSS_SV_TYPE_UNKNOWN: - default: - out = GnssConstellationType::UNKNOWN; - break; - } -} - -void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out) -{ - switch(in) { - case GNSS_EPH_TYPE_EPHEMERIS: - out = GnssDebug::SatelliteEphemerisType::EPHEMERIS; - break; - case GNSS_EPH_TYPE_ALMANAC: - out = GnssDebug::SatelliteEphemerisType::ALMANAC_ONLY; - break; - case GNSS_EPH_TYPE_UNKNOWN: - default: - out = GnssDebug::SatelliteEphemerisType::NOT_AVAILABLE; - break; - } -} - -void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out) -{ - switch(in) { - case GNSS_EPH_SOURCE_DEMODULATED: - out = GnssDebug::SatelliteEphemerisSource::DEMODULATED; - break; - case GNSS_EPH_SOURCE_SUPL_PROVIDED: - out = GnssDebug::SatelliteEphemerisSource::SUPL_PROVIDED; - break; - case GNSS_EPH_SOURCE_OTHER_SERVER_PROVIDED: - out = GnssDebug::SatelliteEphemerisSource::OTHER_SERVER_PROVIDED; - break; - case GNSS_EPH_SOURCE_LOCAL: - case GNSS_EPH_SOURCE_UNKNOWN: - default: - out = GnssDebug::SatelliteEphemerisSource::OTHER; - break; - } -} - -void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out) -{ - switch(in) { - case GNSS_EPH_HEALTH_GOOD: - out = GnssDebug::SatelliteEphemerisHealth::GOOD; - break; - case GNSS_EPH_HEALTH_BAD: - out = GnssDebug::SatelliteEphemerisHealth::BAD; - break; - case GNSS_EPH_HEALTH_UNKNOWN: - default: - out = GnssDebug::SatelliteEphemerisHealth::UNKNOWN; - break; - } -} - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.1/location_api/LocationUtil.h b/gps/android/1.1/location_api/LocationUtil.h deleted file mode 100644 index 63f4f6f..0000000 --- a/gps/android/1.1/location_api/LocationUtil.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef LOCATION_UTIL_H -#define LOCATION_UTIL_H - -#include -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -void convertGnssLocation(Location& in, V1_0::GnssLocation& out); -void convertGnssLocation(const V1_0::GnssLocation& in, Location& out); -void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out); -void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out); -void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out); -void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out); - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android -#endif // LOCATION_UTIL_H diff --git a/gps/android/1.1/location_api/MeasurementAPIClient.cpp b/gps/android/1.1/location_api/MeasurementAPIClient.cpp deleted file mode 100644 index 6f25067..0000000 --- a/gps/android/1.1/location_api/MeasurementAPIClient.cpp +++ /dev/null @@ -1,332 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDEBUG 0 -#define LOG_TAG "LocSvc_MeasurementAPIClient" - -#include -#include - -#include "LocationUtil.h" -#include "MeasurementAPIClient.h" - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::hardware::gnss::V1_0::IGnssMeasurement; -using ::android::hardware::gnss::V1_1::IGnssMeasurementCallback; - -static void convertGnssData(GnssMeasurementsNotification& in, - V1_0::IGnssMeasurementCallback::GnssData& out); -static void convertGnssData_1_1(GnssMeasurementsNotification& in, - IGnssMeasurementCallback::GnssData& out); -static void convertGnssMeasurement(GnssMeasurementsData& in, - V1_0::IGnssMeasurementCallback::GnssMeasurement& out); -static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out); - -MeasurementAPIClient::MeasurementAPIClient() : - mGnssMeasurementCbIface(nullptr), - mGnssMeasurementCbIface_1_1(nullptr), - mTracking(false) -{ - LOC_LOGD("%s]: ()", __FUNCTION__); -} - -MeasurementAPIClient::~MeasurementAPIClient() -{ - LOC_LOGD("%s]: ()", __FUNCTION__); -} - -// for GpsInterface -Return -MeasurementAPIClient::measurementSetCallback(const sp& callback) -{ - LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback); - - mMutex.lock(); - mGnssMeasurementCbIface = callback; - mMutex.unlock(); - - return startTracking(); -} - -Return -MeasurementAPIClient::measurementSetCallback_1_1( - const sp& callback, - GnssPowerMode powerMode, uint32_t timeBetweenMeasurement) -{ - LOC_LOGD("%s]: (%p) (powermode: %d) (tbm: %d)", - __FUNCTION__, &callback, (int)powerMode, timeBetweenMeasurement); - - mMutex.lock(); - mGnssMeasurementCbIface_1_1 = callback; - mMutex.unlock(); - - return startTracking(powerMode, timeBetweenMeasurement); -} - -Return -MeasurementAPIClient::startTracking( - GnssPowerMode powerMode, uint32_t timeBetweenMeasurement) -{ - LocationCallbacks locationCallbacks; - memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); - locationCallbacks.size = sizeof(LocationCallbacks); - - locationCallbacks.trackingCb = nullptr; - locationCallbacks.batchingCb = nullptr; - locationCallbacks.geofenceBreachCb = nullptr; - locationCallbacks.geofenceStatusCb = nullptr; - locationCallbacks.gnssLocationInfoCb = nullptr; - locationCallbacks.gnssNiCb = nullptr; - locationCallbacks.gnssSvCb = nullptr; - locationCallbacks.gnssNmeaCb = nullptr; - - locationCallbacks.gnssMeasurementsCb = nullptr; - if (mGnssMeasurementCbIface_1_1 != nullptr || mGnssMeasurementCbIface != nullptr) { - locationCallbacks.gnssMeasurementsCb = - [this](GnssMeasurementsNotification gnssMeasurementsNotification) { - onGnssMeasurementsCb(gnssMeasurementsNotification); - }; - } - - locAPISetCallbacks(locationCallbacks); - - TrackingOptions options = {}; - memset(&options, 0, sizeof(TrackingOptions)); - options.size = sizeof(TrackingOptions); - options.minInterval = 1000; - options.mode = GNSS_SUPL_MODE_STANDALONE; - if (GNSS_POWER_MODE_INVALID != powerMode) { - options.powerMode = powerMode; - options.tbm = timeBetweenMeasurement; - } - - mTracking = true; - LOC_LOGD("%s]: start tracking session", __FUNCTION__); - locAPIStartTracking(options); - return IGnssMeasurement::GnssMeasurementStatus::SUCCESS; -} - -// for GpsMeasurementInterface -void MeasurementAPIClient::measurementClose() { - LOC_LOGD("%s]: ()", __FUNCTION__); - mTracking = false; - locAPIStopTracking(); -} - -// callbacks -void MeasurementAPIClient::onGnssMeasurementsCb( - GnssMeasurementsNotification gnssMeasurementsNotification) -{ - LOC_LOGD("%s]: (count: %zu active: %d)", - __FUNCTION__, gnssMeasurementsNotification.count, mTracking); - if (mTracking) { - mMutex.lock(); - sp gnssMeasurementCbIface = nullptr; - sp gnssMeasurementCbIface_1_1 = nullptr; - if (mGnssMeasurementCbIface_1_1 != nullptr) { - gnssMeasurementCbIface_1_1 = mGnssMeasurementCbIface_1_1; - } else if (mGnssMeasurementCbIface != nullptr) { - gnssMeasurementCbIface = mGnssMeasurementCbIface; - } - mMutex.unlock(); - - if (gnssMeasurementCbIface_1_1 != nullptr) { - IGnssMeasurementCallback::GnssData gnssData; - convertGnssData_1_1(gnssMeasurementsNotification, gnssData); - auto r = gnssMeasurementCbIface_1_1->gnssMeasurementCb(gnssData); - if (!r.isOk()) { - LOC_LOGE("%s] Error from gnssMeasurementCb description=%s", - __func__, r.description().c_str()); - } - } else if (gnssMeasurementCbIface != nullptr) { - V1_0::IGnssMeasurementCallback::GnssData gnssData; - convertGnssData(gnssMeasurementsNotification, gnssData); - auto r = gnssMeasurementCbIface->GnssMeasurementCb(gnssData); - if (!r.isOk()) { - LOC_LOGE("%s] Error from GnssMeasurementCb description=%s", - __func__, r.description().c_str()); - } - } - } -} - -static void convertGnssMeasurement(GnssMeasurementsData& in, - V1_0::IGnssMeasurementCallback::GnssMeasurement& out) -{ - memset(&out, 0, sizeof(IGnssMeasurementCallback::GnssMeasurement)); - if (in.flags & GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT) - out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_SNR; - if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT) - out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_FREQUENCY; - if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT) - out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_CYCLES; - if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT) - out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE; - if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT) - out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE_UNCERTAINTY; - if (in.flags & GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT) - out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_AUTOMATIC_GAIN_CONTROL; - out.svid = in.svId; - convertGnssConstellationType(in.svType, out.constellation); - out.timeOffsetNs = in.timeOffsetNs; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_CODE_LOCK; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BIT_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SUBFRAME_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_DECODED; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_MSEC_AMBIGUOUS; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SYMBOL_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_STRING_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_DECODED; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_BIT_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_SUBFRAME_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1BC_CODE_LOCK; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1C_2ND_CODE_LOCK; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1B_PAGE_SYNC; - if (in.stateMask & GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT) - out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SBAS_SYNC; - out.receivedSvTimeInNs = in.receivedSvTimeNs; - out.receivedSvTimeUncertaintyInNs = in.receivedSvTimeUncertaintyNs; - out.cN0DbHz = in.carrierToNoiseDbHz; - out.pseudorangeRateMps = in.pseudorangeRateMps; - out.pseudorangeRateUncertaintyMps = in.pseudorangeRateUncertaintyMps; - if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT) - out.accumulatedDeltaRangeState |= - IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID; - if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT) - out.accumulatedDeltaRangeState |= - IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET; - if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT) - out.accumulatedDeltaRangeState |= - IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP; - out.accumulatedDeltaRangeM = in.adrMeters; - out.accumulatedDeltaRangeUncertaintyM = in.adrUncertaintyMeters; - out.carrierFrequencyHz = in.carrierFrequencyHz; - out.carrierCycles = in.carrierCycles; - out.carrierPhase = in.carrierPhase; - out.carrierPhaseUncertainty = in.carrierPhaseUncertainty; - uint8_t indicator = - static_cast(IGnssMeasurementCallback::GnssMultipathIndicator::INDICATOR_UNKNOWN); - if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_PRESENT) - indicator |= IGnssMeasurementCallback::GnssMultipathIndicator::INDICATOR_PRESENT; - if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_NOT_PRESENT) - indicator |= IGnssMeasurementCallback::GnssMultipathIndicator::INDICATIOR_NOT_PRESENT; - out.multipathIndicator = - static_cast(indicator); - out.snrDb = in.signalToNoiseRatioDb; - out.agcLevelDb = in.agcLevelDb; -} - -static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out) -{ - memset(&out, 0, sizeof(IGnssMeasurementCallback::GnssClock)); - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_LEAP_SECOND; - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_TIME_UNCERTAINTY; - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_FULL_BIAS; - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_BIAS; - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_BIAS_UNCERTAINTY; - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_DRIFT; - if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_UNCERTAINTY_BIT) - out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_DRIFT_UNCERTAINTY; - out.leapSecond = in.leapSecond; - out.timeNs = in.timeNs; - out.timeUncertaintyNs = in.timeUncertaintyNs; - out.fullBiasNs = in.fullBiasNs; - out.biasNs = in.biasNs; - out.biasUncertaintyNs = in.biasUncertaintyNs; - out.driftNsps = in.driftNsps; - out.driftUncertaintyNsps = in.driftUncertaintyNsps; - out.hwClockDiscontinuityCount = in.hwClockDiscontinuityCount; -} - -static void convertGnssData(GnssMeasurementsNotification& in, - V1_0::IGnssMeasurementCallback::GnssData& out) -{ - out.measurementCount = in.count; - if (out.measurementCount > static_cast(V1_0::GnssMax::SVS_COUNT)) { - LOC_LOGW("%s]: Too many measurement %u. Clamps to %d.", - __FUNCTION__, out.measurementCount, V1_0::GnssMax::SVS_COUNT); - out.measurementCount = static_cast(V1_0::GnssMax::SVS_COUNT); - } - for (size_t i = 0; i < out.measurementCount; i++) { - convertGnssMeasurement(in.measurements[i], out.measurements[i]); - } - convertGnssClock(in.clock, out.clock); -} - -static void convertGnssData_1_1(GnssMeasurementsNotification& in, - IGnssMeasurementCallback::GnssData& out) -{ - out.measurements.resize(in.count); - for (size_t i = 0; i < in.count; i++) { - convertGnssMeasurement(in.measurements[i], out.measurements[i].v1_0); - if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT) - out.measurements[i].accumulatedDeltaRangeState |= - IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID; - if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT) - out.measurements[i].accumulatedDeltaRangeState |= - IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET; - if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT) - out.measurements[i].accumulatedDeltaRangeState |= - IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP; - if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_HALF_CYCLE_RESOLVED_BIT) - out.measurements[i].accumulatedDeltaRangeState |= - IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_HALF_CYCLE_RESOLVED; - } - convertGnssClock(in.clock, out.clock); -} - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android diff --git a/gps/android/1.1/location_api/MeasurementAPIClient.h b/gps/android/1.1/location_api/MeasurementAPIClient.h deleted file mode 100644 index 38811c5..0000000 --- a/gps/android/1.1/location_api/MeasurementAPIClient.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) 2017-2018, 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 - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef MEASUREMENT_API_CLINET_H -#define MEASUREMENT_API_CLINET_H - -#include -#include -#include -#include -#include -#include - -namespace android { -namespace hardware { -namespace gnss { -namespace V1_1 { -namespace implementation { - -using ::android::sp; - -class MeasurementAPIClient : public LocationAPIClientBase -{ -public: - MeasurementAPIClient(); - virtual ~MeasurementAPIClient(); - MeasurementAPIClient(const MeasurementAPIClient&) = delete; - MeasurementAPIClient& operator=(const MeasurementAPIClient&) = delete; - - // for GpsMeasurementInterface - Return measurementSetCallback( - const sp& callback); - Return measurementSetCallback_1_1( - const sp& callback, - GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID, - uint32_t timeBetweenMeasurement = GPS_DEFAULT_FIX_INTERVAL_MS); - void measurementClose(); - Return startTracking( - GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID, - uint32_t timeBetweenMeasurement = GPS_DEFAULT_FIX_INTERVAL_MS); - - // callbacks we are interested in - void onGnssMeasurementsCb(GnssMeasurementsNotification gnssMeasurementsNotification) final; - -private: - std::mutex mMutex; - sp mGnssMeasurementCbIface; - sp mGnssMeasurementCbIface_1_1; - - bool mTracking; -}; - -} // namespace implementation -} // namespace V1_1 -} // namespace gnss -} // namespace hardware -} // namespace android -#endif // MEASUREMENT_API_CLINET_H diff --git a/gps/android/1.1/service.cpp b/gps/android/1.1/service.cpp deleted file mode 100644 index 0cb91f7..0000000 --- a/gps/android/1.1/service.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Not a Contribution - */ -/* - * Copyright (C) 2016 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 "android.hardware.gnss@1.1-service-qti" - -#include -#include -#include "loc_cfg.h" -#include "loc_misc_utils.h" - -extern "C" { -#include "vndfwk-detect.h" -} - -#ifdef ARCH_ARM_32 -#define DEFAULT_HW_BINDER_MEM_SIZE 65536 -#endif - -using android::hardware::gnss::V1_1::IGnss; - -using android::hardware::configureRpcThreadpool; -using android::hardware::registerPassthroughServiceImplementation; -using android::hardware::joinRpcThreadpool; - -using android::status_t; -using android::OK; - -typedef int vendorEnhancedServiceMain(int /* argc */, char* /* argv */ []); - -int main() { - - ALOGI("%s", __FUNCTION__); - - int vendorInfo = getVendorEnhancedInfo(); - bool vendorEnhanced = ( 1 == vendorInfo || 3 == vendorInfo ); - setVendorEnhanced(vendorEnhanced); - -#ifdef ARCH_ARM_32 - android::hardware::ProcessState::initWithMmapSize((size_t)(DEFAULT_HW_BINDER_MEM_SIZE)); -#endif - configureRpcThreadpool(1, true); - status_t status; - - status = registerPassthroughServiceImplementation(); - if (status == OK) { - if (vendorEnhanced) { - #ifdef LOC_HIDL_VERSION - #define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so" - - void* libHandle = NULL; - vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*) - dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main"); - if (NULL != vendorEnhancedMainMethod) { - (*vendorEnhancedMainMethod)(0, NULL); - } - #else - ALOGE("LOC_HIDL_VERSION not defined."); - #endif - } - - joinRpcThreadpool(); - - } else { - ALOGE("Error while registering IGnss 1.1 service: %d", status); - } - - return 0; -} diff --git a/gps/android/Android.mk b/gps/android/Android.mk index 3b5c01f..314f9d9 100644 --- a/gps/android/Android.mk +++ b/gps/android/Android.mk @@ -3,13 +3,5 @@ ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),) include $(CLEAR_VARS) DIR_LIST := $(LOCAL_PATH) include $(DIR_LIST)/utils/Android.mk -ifeq ($(GNSS_HIDL_VERSION),2.0) include $(DIR_LIST)/2.0/Android.mk -else -ifeq ($(GNSS_HIDL_VERSION),1.1) -include $(DIR_LIST)/1.1/Android.mk -else -include $(DIR_LIST)/1.0/Android.mk -endif #GNSS HIDL 1.1 -endif #GNSS HIDL 2.0 endif #BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE diff --git a/gps/build/target_specific_features.mk b/gps/build/target_specific_features.mk deleted file mode 100644 index 766402a..0000000 --- a/gps/build/target_specific_features.mk +++ /dev/null @@ -1,69 +0,0 @@ -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 - -LOCAL_SANITIZE := signed-integer-overflow, unsigned-integer-overflow - -# GPS-HIDL -GNSS_HIDL_1_0_TARGET_LIST := msm8960 -GNSS_HIDL_1_0_TARGET_LIST += msm8974 -GNSS_HIDL_1_0_TARGET_LIST += msm8226 -GNSS_HIDL_1_0_TARGET_LIST += msm8610 -GNSS_HIDL_1_0_TARGET_LIST += apq8084 -GNSS_HIDL_1_0_TARGET_LIST += msm8916 -GNSS_HIDL_1_0_TARGET_LIST += msm8994 -GNSS_HIDL_1_0_TARGET_LIST += msm8909 -GNSS_HIDL_1_0_TARGET_LIST += msm8952 -GNSS_HIDL_1_0_TARGET_LIST += msm8992 -GNSS_HIDL_1_0_TARGET_LIST += msm8996 -GNSS_HIDL_2_0_TARGET_LIST := msm8937 -GNSS_HIDL_2_0_TARGET_LIST += msm8953 -GNSS_HIDL_2_0_TARGET_LIST += msm8998 -GNSS_HIDL_2_0_TARGET_LIST += apq8098_latv -GNSS_HIDL_2_0_TARGET_LIST += sdm710 -GNSS_HIDL_2_0_TARGET_LIST += qcs605 -GNSS_HIDL_2_0_TARGET_LIST += sdm845 -GNSS_HIDL_2_0_TARGET_LIST += sdm660 -GNSS_HIDL_2_0_TARGET_LIST += msmnile -GNSS_HIDL_2_0_TARGET_LIST += $(MSMSTEPPE) -GNSS_HIDL_2_0_TARGET_LIST += $(TRINKET) -GNSS_HIDL_2_0_TARGET_LIST += kona -GNSS_HIDL_2_0_TARGET_LIST += atoll -GNSS_HIDL_2_0_TARGET_LIST += lito -GNSS_HIDL_2_0_TARGET_LIST += bengal - -ifneq (,$(filter $(GNSS_HIDL_2_0_TARGET_LIST),$(TARGET_BOARD_PLATFORM))) -GNSS_HIDL_VERSION = 2.0 -endif -ifneq (,$(filter $(GNSS_HIDL_1_0_TARGET_LIST),$(TARGET_BOARD_PLATFORM))) -GNSS_HIDL_VERSION = 1.0 -endif -ifneq (,$(filter $(GNSS_HIDL_1_1_TARGET_LIST),$(TARGET_BOARD_PLATFORM))) -GNSS_HIDL_VERSION = 1.1 -endif - -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 diff --git a/gps/configure.ac b/gps/configure.ac deleted file mode 100644 index 0ab8e68..0000000 --- a/gps/configure.ac +++ /dev/null @@ -1,87 +0,0 @@ -# configure.ac -- Autoconf script for gps loc_hal -# -# Process this file with autoconf to produce a configure script - -# Requires autoconf tool later than 2.61 -AC_PREREQ(2.61) -# Initialize the gps loc-hal package version 1.0.0 -AC_INIT([loc-hal],1.0.0) -# Does not strictly follow GNU Coding standards -AM_INIT_AUTOMAKE([foreign]) -# Disables auto rebuilding of configure, Makefile.ins -AM_MAINTAINER_MODE -# Verifies the --srcdir is correct by checking for the path -AC_CONFIG_SRCDIR([Makefile.am]) -# defines some macros variable to be included by source -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_MACRO_DIR([m4]) - -# Checks for programs. -AC_PROG_LIBTOOL -AC_PROG_CXX -AC_PROG_CC -AM_PROG_CC_C_O -AC_PROG_AWK -AC_PROG_CPP -AC_PROG_INSTALL -AC_PROG_LN_S -AC_PROG_MAKE_SET -PKG_PROG_PKG_CONFIG - -# Checks for libraries. -PKG_CHECK_MODULES([GPSUTILS], [gps-utils]) -AC_SUBST([GPSUTILS_CFLAGS]) -AC_SUBST([GPSUTILS_LIBS]) - -PKG_CHECK_MODULES([LOCCORE], [loc-core]) -AC_SUBST([LOCCORE_CFLAGS]) -AC_SUBST([LOCCORE_LIBS]) - -AC_ARG_WITH([core_includes], - AC_HELP_STRING([--with-core-includes=@<:@dir@:>@], - [Specify the location of the core headers]), - [core_incdir=$withval], - with_core_includes=no) - -if test "x$with_core_includes" != "xno"; then - CPPFLAGS="${CPPFLAGS} -I${core_incdir}" -fi - -AC_ARG_WITH([locpla_includes], - AC_HELP_STRING([--with-locpla-includes=@<:@dir@:>@], - [specify the path to locpla-includes in loc-pla_git.bb]), - [locpla_incdir=$withval], - with_locpla_includes=no) - -if test "x$with_locpla_includes" != "xno"; then - AC_SUBST(LOCPLA_CFLAGS, "-I${locpla_incdir}") -fi - -AC_SUBST([CPPFLAGS]) - -AC_ARG_WITH([glib], - AC_HELP_STRING([--with-glib], - [enable glib, building HLOS systems which use glib])) - -if (test "x${with_glib}" = "xyes"); then - AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib]) - PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes, - AC_MSG_ERROR(GThread >= 2.16 is required)) - PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes, - AC_MSG_ERROR(GLib >= 2.16 is required)) - GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS" - GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS" - - AC_SUBST(GLIB_CFLAGS) - AC_SUBST(GLIB_LIBS) -fi - -AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes") - -AC_CONFIG_FILES([ \ - Makefile \ - gnss/Makefile \ - loc-hal.pc \ - ]) - -AC_OUTPUT diff --git a/gps/etc/Android.mk b/gps/etc/Android.mk deleted file mode 100644 index 22ca2f7..0000000 --- a/gps/etc/Android.mk +++ /dev/null @@ -1,21 +0,0 @@ - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := gps.conf -LOCAL_VENDOR_MODULE := true -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_CLASS := ETC -LOCAL_SRC_FILES := gps.conf -LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC) -include $(BUILD_PREBUILT) - -include $(CLEAR_VARS) -LOCAL_MODULE := flp.conf -LOCAL_VENDOR_MODULE := true -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_CLASS := ETC -LOCAL_SRC_FILES := flp.conf -LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC) -include $(BUILD_PREBUILT) - diff --git a/gps/etc/flp.conf b/gps/etc/flp.conf deleted file mode 100644 index 65d54d3..0000000 --- a/gps/etc/flp.conf +++ /dev/null @@ -1,60 +0,0 @@ -################################### -##### FLP settings ##### -################################### - -################################### -# FLP BATCH SIZE -################################### -# The number of batched locations -# requested to modem. The desired number -# defined below may not be satisfied, as -# the modem can only return the number -# of batched locations that can be allocated, -# which is limited by memory. The default -# batch size defined as 20 as below. -BATCH_SIZE=20 - -################################### -# FLP OUTDOOR TRIP BATCH SIZE -################################### -# The number of batched locations -# requested to modem for outdoor -# trip batching. The desired number -# defined below may not be satisfied, as -# the modem can only return the number -# of batched locations that can be allocated, -# which is limited by memory. The default -# trip batch size defined as 600 as below. -OUTDOOR_TRIP_BATCH_SIZE=600 - -################################### -# FLP BATCHING SESSION TIMEOUT -################################### -# Duration with which batch session timeout -# happens in milliseconds. If not specified -# or set to zero, batching session timeout -# defaults to 20 seconds by the modem. -# BATCH_SESSION_TIMEOUT=20000 - -################################### -# FLP BATCHING ACCURACY -################################### -# Set to one of the defined values below -# to define the accuracy of batching. -# If not specified, accuracy defaults -# to LOW. -# FLP BATCHING ACCURACY values: -# Low accuracy = 0 -# Medium accuracy = 1 -# High accuracy = 2 -ACCURACY=1 - -#################################### -# By default if network fixes are not sensor assisted -# these fixes must be dropped. This parameter adds an exception -# for targets where there is no PDR and we still want to -# report out network fixes -# 0: MUST NOT ALLOW NETWORK FIXES -# 1: ALLOW NETWORK FIXES -#################################### -ALLOW_NETWORK_FIXES = 0 diff --git a/gps/etc/gps.conf b/gps/etc/gps.conf deleted file mode 100644 index 37b67d9..0000000 --- a/gps/etc/gps.conf +++ /dev/null @@ -1,289 +0,0 @@ -#Version check for XTRA -#DISABLE = 0 -#AUTO = 1 -#XTRA2 = 2 -#XTRA3 = 3 -XTRA_VERSION_CHECK=0 - -# Error Estimate -# _SET = 1 -# _CLEAR = 0 -ERR_ESTIMATE=0 - -#NTP server -NTP_SERVER=time.izatcloud.net - -#XTRA CA path -XTRA_CA_PATH=/usr/lib/ssl/certs - -# DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info -# 4 - Debug, 5 - Verbose -# If DEBUG_LEVEL is commented, Android's logging levels will be used -DEBUG_LEVEL = 3 - -# Intermediate position report, 1=enable, 0=disable -INTERMEDIATE_POS=0 - -# supl version 1.0 -SUPL_VER=0x10000 - -# Emergency SUPL, 1=enable, 0=disable -#SUPL_ES=1 - -#Choose PDN for Emergency SUPL -#1 - Use emergency PDN -#0 - Use regular SUPL PDN for Emergency SUPL -#USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL=0 - -#SUPL_MODE is a bit mask set in config.xml per carrier by default. -#If it is uncommented here, this value will overwrite the value from -#config.xml. -#MSA=0X2 -#MSB=0X1 -#SUPL_MODE= - -# GPS Capabilities bit mask -# SCHEDULING = 0x01 -# MSB = 0x02 -# MSA = 0x04 -# ON_DEMAND_TIME = 0x10 -# default = ON_DEMAND_TIME | MSA | MSB | SCHEDULING -CAPABILITIES=0x17 - -# Accuracy threshold for intermediate positions -# less accurate positions are ignored, 0 for passing all positions -# ACCURACY_THRES=5000 - -################################ -##### AGPS server settings ##### -################################ - -# FOR SUPL SUPPORT, set the following -# SUPL_HOST=supl.host.com or IP -# SUPL_PORT=1234 - -# FOR MO SUPL SUPPORT, set the following -# MO_SUPL_HOST=supl.host.com or IP -# MO_SUPL_PORT=1234 - -# FOR C2K PDE SUPPORT, set the following -# C2K_HOST=c2k.pde.com or IP -# C2K_PORT=1234 - -# Bitmask of slots that are available -# for write/install to, where 1s indicate writable, -# and the default value is 0 where no slots -# are writable. For example, AGPS_CERT_WRITABLE_MASK -# of b1000001010 makes 3 slots available -# and the remaining 7 slots unwritable. -#AGPS_CERT_WRITABLE_MASK=0 - -#################################### -# LTE Positioning Profile Settings -#################################### -# 0: Enable RRLP on LTE(Default) -# 1: Enable LPP_User_Plane on LTE -# 2: Enable LPP_Control_Plane -# 3: Enable both LPP_User_Plane and LPP_Control_Plane -LPP_PROFILE = 2 - -#################################### -#Datum Type -#################################### -# 0: WGS-84 -# 1: PZ-90 -DATUM_TYPE = 0 - -################################ -# EXTRA SETTINGS -################################ -# NMEA provider (1=Modem Processor, 0=Application Processor) -NMEA_PROVIDER=0 -# Mark if it is a SGLTE target (1=SGLTE, 0=nonSGLTE) -SGLTE_TARGET=0 - -################################################## -# Select Positioning Protocol on A-GLONASS system -################################################## -# 0x1: RRC CPlane -# 0x2: RRLP UPlane -# 0x4: LLP Uplane -A_GLONASS_POS_PROTOCOL_SELECT = 0 - -################################################## -# Select technology for LPPe Control Plane -################################################## -# 0x1: DBH for LPPe CP -# 0x2: WLAN AP Measurements for LPPe CP -# 0x4: SRN AP measurement for CP -# 0x8: Sensor Barometer Measurement LPPe CP -LPPE_CP_TECHNOLOGY = 0 - -################################################## -# Select technology for LPPe User Plane -################################################## -# 0x1: DBH for LPPe UP -# 0x2: WLAN AP Measurements for LPPe UP -# 0x4: SRN AP measurement for UP -# 0x8: Sensor Barometer Measurement LPPe UP -LPPE_UP_TECHNOLOGY = 0 - -################################################## -# AGPS_CONFIG_INJECT -################################################## -# enable/disable injection of AGPS configurations: -# SUPL_VER -# SUPL_HOST -# SUPL_PORT -# MO_SUPL_HOST -# MO_SUPL_PORT -# C2K_HOST -# C2K_PORT -# LPP_PROFILE -# A_GLONASS_POS_PROTOCOL_SELECT -# 0: disable -# 1: enable -AGPS_CONFIG_INJECT = 1 - -################################################## -# GNSS settings for automotive use cases -# Configurations in following section are -# specific to automotive use cases, others -# please do not change, keep the default values -################################################## - -# AP Coarse Timestamp Uncertainty -################################################## -# default : 10 -# AP time stamp uncertainty, until GNSS receiver -# is able to acquire better timing information -AP_TIMESTAMP_UNCERTAINTY = 10 - -################################################## -# QDR engine availability status -################################################## -# 0 : NO QDR (default) -# 1 : QDR enabled -# This settings enables QDR Configuration for -# automotive use case, if enabled then -# DR_AP_Service needs to be enabled in izat.conf -#EXTERNAL_DR_ENABLED = 0 - -##################################### -# DR_SYNC Pulse Availability -##################################### -# 0 : DR_SYNC pulse not available (default) -# 1 : DR_SYNC pulse available -# This configuration enables the driver to make use -# of PPS events generated by DR_SYNC pulse -# Standard Linux PPS driver needs to be enabled -DR_SYNC_ENABLED = 0 - -##################################### -# PPS Device name -##################################### -PPS_DEVICENAME = /dev/pps0 - -##################################### -# Ignore PPS at Startup and after long outage -##################################### -IGNORE_PPS_PULSE_COUNT = 1 - -##################################### -# Long GNSS RF outage in seconds -##################################### -GNSS_OUTAGE_DURATION = 10 - -##################################### -# AP Clock Accuracy -##################################### -# Quality of APPS processor clock (in PPM). -# Value specified is used for calculation of -# APPS time stamp uncertainty -AP_CLOCK_PPM = 100 - -##################################### -# MAX ms difference to detect missing pulse -##################################### -# Specifies time threshold in ms to validate any missing PPS pulses -MISSING_PULSE_TIME_DELTA = 900 - -##################################### -# Propagation time uncertainty -##################################### -# This settings enables time uncertainty propagation -# logic incase of missing PPS pulse -PROPAGATION_TIME_UNCERTAINTY = 1 - -####################################### -# APN / IP Type Configuration -# APN and IP Type to use for setting -# up WWAN call. -# Use below values for IP Type: -# v4 = 4 -# v6 = 6 -# v4v6 = 10 -####################################### -# INTERNET_APN = abc.xyz -# INTERNET_IP_TYPE = 4 -# SUPL_APN = abc.xyz -# SUPL_IP_TYPE = 4 - -##################################### -# Modem type -##################################### -# This setting configures modem type -# (external=0 or internal=1) -# comment out the next line to vote -# for the first modem in the list -MODEM_TYPE = 1 - -################################################## -# CONSTRAINED TIME UNCERTAINTY MODE -################################################## -# 0 : disabled (default) -# 1 : enabled -# This setting enables GPS engine to keep its time -# uncertainty below the specified constraint -#CONSTRAINED_TIME_UNCERTAINTY_ENABLED = 0 - -# If constrained time uncertainty mode is enabled, -# this setting specifies the time uncertainty -# threshold that gps engine need to maintain. -# In unit of milli-seconds. -# Default is 0.0 meaning that modem default value -# of time uncertainty threshold will be used. -#CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD = 0.0 - -# If constrained time uncertainty mode is enabled, -# this setting specifies the power budget that -# gps engine is allowed to spend to maintain the time -# uncertainty. -# Default is 0 meaning that GPS engine is not constained -# by power budget and can spend as much power as needed. -# In unit of 0.1 milli watt second. -#CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET = 0 - -################################################## -# POSITION ASSISTED CLOCK ESTIMATOR -################################################## -# 0 : disabled (default) -# 1 : enabled -# This setting enables GPS engine to estimate clock -# bias and drift when the signal from at least 1 -# SV is available and the UE’s position is known by -# other position engines. -#POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED = 0 - -##################################### -# proxyAppPackageName -##################################### -# This is a string that is sent to the framework -# in nfwNotifyCb callback -PROXY_APP_PACKAGE_NAME = com.google.android.carrierlocation - -##################################### -# CP_MTLR_ES -##################################### -# CP MTLR ES, 1=enable, 0=disable -CP_MTLR_ES=0 diff --git a/gps/gps_vendor_board.mk b/gps/gps_vendor_board.mk deleted file mode 100644 index e1915ea..0000000 --- a/gps/gps_vendor_board.mk +++ /dev/null @@ -1,7 +0,0 @@ -# Flags from BoardConfigVendor.mk -ifneq ($(TARGET_USES_QMAA),true) -BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE := default -else ifneq ($(TARGET_USES_QMAA_OVERRIDE_GPS),false) -BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE := default -endif - diff --git a/gps/gps_vendor_product.mk b/gps/gps_vendor_product.mk deleted file mode 100644 index 6e938b3..0000000 --- a/gps/gps_vendor_product.mk +++ /dev/null @@ -1,14 +0,0 @@ -# HAL packages -PRODUCT_PACKAGES += android.hardware.gnss@1.0-impl-qti -PRODUCT_PACKAGES += android.hardware.gnss@1.0-service-qti -PRODUCT_PACKAGES += android.hardware.gnss@1.1-impl-qti -PRODUCT_PACKAGES += android.hardware.gnss@1.1-service-qti -PRODUCT_PACKAGES += android.hardware.gnss@2.0-impl-qti -PRODUCT_PACKAGES += android.hardware.gnss@2.0-service-qti -PRODUCT_PACKAGES += gps.conf -PRODUCT_PACKAGES += libloc_core -PRODUCT_PACKAGES += libgnss -PRODUCT_PACKAGES += liblocation_api -PRODUCT_PACKAGES += libgps.utils -PRODUCT_PACKAGES += libbatching -PRODUCT_PACKAGES += libgeofencing diff --git a/gps/loc-hal.pc.in b/gps/loc-hal.pc.in deleted file mode 100644 index 22d174b..0000000 --- a/gps/loc-hal.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: loc-hal -Description: QTI GPS Loc HAL -Version: @VERSION -Libs: -L${libdir} -lgnss -Cflags: -I${includedir} -I${includedir}/utils -I${includedir}/core -I${includedir}/loc-hal