Replace GPS settings from Xiaomi/msm8996-common
Signed-off-by: Deokgyu Yang <secugyu@gmail.com> Change-Id: Ib3ab311d789ac286e7c7bd6725e478202b608bec
This commit is contained in:
parent
779f97c5a0
commit
98d049a586
153 changed files with 3266 additions and 3252 deletions
|
@ -198,8 +198,7 @@ PRODUCT_PACKAGES += \
|
|||
libcurl \
|
||||
libgnss \
|
||||
libgnsspps \
|
||||
libsensorndkbridge \
|
||||
libwifi-hal-ctrl
|
||||
libsensorndkbridge
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(LOCAL_PATH)/gps/etc/flp.conf:$(TARGET_COPY_OUT_VENDOR)/etc/flp.conf \
|
||||
|
|
5
gps/Android.mk
Executable file → Normal file
5
gps/Android.mk
Executable file → Normal file
|
@ -15,7 +15,4 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
include $(LOCAL_PATH)/build/target_specific_features.mk
|
||||
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
||||
include $(call first-makefiles-under,$(call my-dir))
|
||||
|
|
2
gps/android/AGnss.cpp
Executable file → Normal file
2
gps/android/AGnss.cpp
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
|
8
gps/android/AGnss.h
Executable file → Normal file
8
gps/android/AGnss.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
@ -18,8 +18,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_0_AGNSS_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_0_AGNSS_H
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_1_AGNSS_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_1_AGNSS_H
|
||||
|
||||
#include <android/hardware/gnss/1.0/IAGnss.h>
|
||||
#include <hidl/Status.h>
|
||||
|
@ -76,4 +76,4 @@ struct AGnss : public IAGnss {
|
|||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_0_AGNSS_H
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_1_AGNSS_H
|
||||
|
|
2
gps/android/AGnssRil.cpp
Executable file → Normal file
2
gps/android/AGnssRil.cpp
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
|
2
gps/android/AGnssRil.h
Executable file → Normal file
2
gps/android/AGnssRil.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
|
15
gps/android/Android.mk
Executable file → Normal file
15
gps/android/Android.mk
Executable file → Normal file
|
@ -2,7 +2,8 @@ LOCAL_PATH := $(call my-dir)
|
|||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.gnss@1.0-impl-qti
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
|
||||
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
LOCAL_SRC_FILES := \
|
||||
AGnss.cpp \
|
||||
|
@ -33,9 +34,6 @@ LOCAL_HEADER_LIBRARIES := \
|
|||
LOCAL_SHARED_LIBRARIES := \
|
||||
liblog \
|
||||
libhidlbase \
|
||||
libhidltransport \
|
||||
libhwbinder \
|
||||
libcutils \
|
||||
libutils \
|
||||
android.hardware.gnss@1.0 \
|
||||
|
||||
|
@ -43,6 +41,7 @@ LOCAL_SHARED_LIBRARIES += \
|
|||
libloc_core \
|
||||
libgps.utils \
|
||||
libdl \
|
||||
libloc_pla \
|
||||
liblocation_api \
|
||||
|
||||
LOCAL_CFLAGS += $(GNSS_CFLAGS)
|
||||
|
@ -51,15 +50,19 @@ include $(BUILD_SHARED_LIBRARY)
|
|||
BUILD_GNSS_HIDL_SERVICE := true
|
||||
ifneq ($(BOARD_VENDOR_QCOM_LOC_PDK_FEATURE_SET), true)
|
||||
ifneq ($(LW_FEATURE_SET),true)
|
||||
ifneq ($(TARGET_HAS_LOW_RAM),true)
|
||||
BUILD_GNSS_HIDL_SERVICE := false
|
||||
endif # TARGET_HAS_LOW_RAM
|
||||
endif # LW_FEATURE_SET
|
||||
endif # BOARD_VENDOR_QCOM_LOC_PDK_FEATURE_SET
|
||||
|
||||
ifeq ($(BUILD_GNSS_HIDL_SERVICE), true)
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.gnss@1.0-service-qti
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES)
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
LOCAL_MODULE_OWNER := qti
|
||||
LOCAL_INIT_RC := android.hardware.gnss@1.0-service-qti.rc
|
||||
LOCAL_SRC_FILES := \
|
||||
service.cpp \
|
||||
|
@ -81,9 +84,7 @@ LOCAL_SHARED_LIBRARIES := \
|
|||
libutils \
|
||||
|
||||
LOCAL_SHARED_LIBRARIES += \
|
||||
libhwbinder \
|
||||
libhidlbase \
|
||||
libhidltransport \
|
||||
android.hardware.gnss@1.0 \
|
||||
|
||||
LOCAL_CFLAGS += $(GNSS_CFLAGS)
|
||||
|
|
33
gps/android/Gnss.cpp
Executable file → Normal file
33
gps/android/Gnss.cpp
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
@ -20,13 +20,9 @@
|
|||
|
||||
#define LOG_TAG "LocSvc_GnssInterface"
|
||||
|
||||
#include <fstream>
|
||||
#include <log_util.h>
|
||||
#include <dlfcn.h>
|
||||
#include <cutils/properties.h>
|
||||
#include "Gnss.h"
|
||||
#include <LocationUtil.h>
|
||||
|
||||
typedef void* (getLocationInterface)();
|
||||
|
||||
namespace android {
|
||||
|
@ -111,7 +107,7 @@ GnssInterface* Gnss::getGnssInterface() {
|
|||
return mGnssInterface;
|
||||
}
|
||||
|
||||
Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>& callback) {
|
||||
Return<bool> Gnss::setCallback(const sp<IGnssCallback>& callback) {
|
||||
ENTRY_LOG_CALLFLOW();
|
||||
if (mGnssCbIface != nullptr) {
|
||||
mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
|
||||
|
@ -255,7 +251,7 @@ Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
|
|||
}
|
||||
}
|
||||
|
||||
Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) {
|
||||
Return<void> Gnss::deleteAidingData(IGnss::GnssAidingData aidingDataFlags) {
|
||||
ENTRY_LOG_CALLFLOW();
|
||||
GnssAPIClient* api = getApi();
|
||||
if (api) {
|
||||
|
@ -264,8 +260,8 @@ Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags)
|
|||
return Void();
|
||||
}
|
||||
|
||||
Return<bool> Gnss::setPositionMode(V1_0::IGnss::GnssPositionMode mode,
|
||||
V1_0::IGnss::GnssPositionRecurrence recurrence,
|
||||
Return<bool> Gnss::setPositionMode(IGnss::GnssPositionMode mode,
|
||||
IGnss::GnssPositionRecurrence recurrence,
|
||||
uint32_t minIntervalMs,
|
||||
uint32_t preferredAccuracyMeters,
|
||||
uint32_t preferredTimeMs) {
|
||||
|
@ -279,49 +275,48 @@ Return<bool> Gnss::setPositionMode(V1_0::IGnss::GnssPositionMode mode,
|
|||
return retVal;
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IAGnss>> Gnss::getExtensionAGnss() {
|
||||
Return<sp<IAGnss>> Gnss::getExtensionAGnss() {
|
||||
ENTRY_LOG_CALLFLOW();
|
||||
mAGnssIface = new AGnss(this);
|
||||
return mAGnssIface;
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssNi>> Gnss::getExtensionGnssNi() {
|
||||
Return<sp<IGnssNi>> Gnss::getExtensionGnssNi() {
|
||||
ENTRY_LOG_CALLFLOW();
|
||||
mGnssNi = new GnssNi(this);
|
||||
return mGnssNi;
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() {
|
||||
Return<sp<IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() {
|
||||
ENTRY_LOG_CALLFLOW();
|
||||
if (mGnssMeasurement == nullptr)
|
||||
mGnssMeasurement = new GnssMeasurement();
|
||||
mGnssMeasurement = new GnssMeasurement();
|
||||
return mGnssMeasurement;
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration() {
|
||||
Return<sp<IGnssConfiguration>> Gnss::getExtensionGnssConfiguration() {
|
||||
ENTRY_LOG_CALLFLOW();
|
||||
mGnssConfig = new GnssConfiguration(this);
|
||||
return mGnssConfig;
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssGeofencing>> Gnss::getExtensionGnssGeofencing() {
|
||||
Return<sp<IGnssGeofencing>> Gnss::getExtensionGnssGeofencing() {
|
||||
ENTRY_LOG_CALLFLOW();
|
||||
mGnssGeofencingIface = new GnssGeofencing();
|
||||
return mGnssGeofencingIface;
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssBatching>> Gnss::getExtensionGnssBatching() {
|
||||
Return<sp<IGnssBatching>> Gnss::getExtensionGnssBatching() {
|
||||
mGnssBatching = new GnssBatching();
|
||||
return mGnssBatching;
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssDebug>> Gnss::getExtensionGnssDebug() {
|
||||
Return<sp<IGnssDebug>> Gnss::getExtensionGnssDebug() {
|
||||
ENTRY_LOG_CALLFLOW();
|
||||
mGnssDebug = new GnssDebug(this);
|
||||
return mGnssDebug;
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() {
|
||||
Return<sp<IAGnssRil>> Gnss::getExtensionAGnssRil() {
|
||||
mGnssRil = new AGnssRil(this);
|
||||
return mGnssRil;
|
||||
}
|
||||
|
|
64
gps/android/Gnss.h
Executable file → Normal file
64
gps/android/Gnss.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018-2018-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
@ -18,8 +18,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSS_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_0_GNSS_H
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSS_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_1_GNSS_H
|
||||
|
||||
#include <AGnss.h>
|
||||
#include <AGnssRil.h>
|
||||
|
@ -31,7 +31,6 @@
|
|||
#include <GnssDebug.h>
|
||||
|
||||
#include <android/hardware/gnss/1.0/IGnss.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
#include <GnssAPIClient.h>
|
||||
|
@ -43,24 +42,34 @@ 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::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::sp;
|
||||
using ::android::hardware::gnss::V1_0::GnssLocation;
|
||||
|
||||
struct Gnss : public IGnss {
|
||||
Gnss();
|
||||
~Gnss();
|
||||
|
||||
// registerAsService will call interfaceChain to determine the version of service
|
||||
/* comment this out until we know really how to manipulate hidl version
|
||||
using interfaceChain_cb = std::function<
|
||||
void(const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& descriptors)>;
|
||||
virtual ::android::hardware::Return<void> interfaceChain(interfaceChain_cb _hidl_cb) override {
|
||||
_hidl_cb({
|
||||
"android.hardware.gnss@1.1::IGnss",
|
||||
::android::hidl::base::V1_0::IBase::descriptor,
|
||||
});
|
||||
return ::android::hardware::Void();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Methods from ::android::hardware::gnss::V1_0::IGnss follow.
|
||||
* These declarations were generated from Gnss.hal.
|
||||
*/
|
||||
Return<bool> setCallback(const sp<V1_0::IGnssCallback>& callback) override;
|
||||
Return<bool> setCallback(const sp<IGnssCallback>& callback) override;
|
||||
Return<bool> start() override;
|
||||
Return<bool> stop() override;
|
||||
Return<void> cleanup() override;
|
||||
|
@ -70,30 +79,30 @@ struct Gnss : public IGnss {
|
|||
Return<bool> injectTime(int64_t timeMs,
|
||||
int64_t timeReferenceMs,
|
||||
int32_t uncertaintyMs) override;
|
||||
Return<void> deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) override;
|
||||
Return<bool> setPositionMode(V1_0::IGnss::GnssPositionMode mode,
|
||||
V1_0::IGnss::GnssPositionRecurrence recurrence,
|
||||
Return<void> deleteAidingData(IGnss::GnssAidingData aidingDataFlags) override;
|
||||
Return<bool> setPositionMode(IGnss::GnssPositionMode mode,
|
||||
IGnss::GnssPositionRecurrence recurrence,
|
||||
uint32_t minIntervalMs,
|
||||
uint32_t preferredAccuracyMeters,
|
||||
uint32_t preferredTimeMs) override;
|
||||
Return<sp<V1_0::IAGnss>> getExtensionAGnss() override;
|
||||
Return<sp<V1_0::IGnssNi>> getExtensionGnssNi() override;
|
||||
Return<sp<V1_0::IGnssMeasurement>> getExtensionGnssMeasurement() override;
|
||||
Return<sp<V1_0::IGnssConfiguration>> getExtensionGnssConfiguration() override;
|
||||
Return<sp<V1_0::IGnssGeofencing>> getExtensionGnssGeofencing() override;
|
||||
Return<sp<V1_0::IGnssBatching>> getExtensionGnssBatching() override;
|
||||
Return<sp<IAGnss>> getExtensionAGnss() override;
|
||||
Return<sp<IGnssNi>> getExtensionGnssNi() override;
|
||||
Return<sp<IGnssMeasurement>> getExtensionGnssMeasurement() override;
|
||||
Return<sp<IGnssConfiguration>> getExtensionGnssConfiguration() override;
|
||||
Return<sp<IGnssGeofencing>> getExtensionGnssGeofencing() override;
|
||||
Return<sp<IGnssBatching>> getExtensionGnssBatching() override;
|
||||
|
||||
Return<sp<V1_0::IAGnssRil>> getExtensionAGnssRil() override;
|
||||
Return<sp<IAGnssRil>> getExtensionAGnssRil() override;
|
||||
|
||||
inline Return<sp<V1_0::IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override {
|
||||
inline Return<sp<IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline Return<sp<V1_0::IGnssXtra>> getExtensionXtra() override {
|
||||
inline Return<sp<IGnssXtra>> getExtensionXtra() override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Return<sp<V1_0::IGnssDebug>> getExtensionGnssDebug() override;
|
||||
Return<sp<IGnssDebug>> getExtensionGnssDebug() override;
|
||||
|
||||
// These methods are not part of the IGnss base class.
|
||||
GnssAPIClient* getApi();
|
||||
|
@ -101,9 +110,6 @@ struct Gnss : public IGnss {
|
|||
Return<bool> updateConfiguration(GnssConfig& gnssConfig);
|
||||
GnssInterface* getGnssInterface();
|
||||
|
||||
// Callback for ODCPI request
|
||||
void odcpiRequestCb(const OdcpiRequestInfo& request);
|
||||
|
||||
private:
|
||||
struct GnssDeathRecipient : hidl_death_recipient {
|
||||
GnssDeathRecipient(sp<Gnss> gnss) : mGnss(gnss) {
|
||||
|
@ -126,8 +132,8 @@ struct Gnss : public IGnss {
|
|||
sp<AGnssRil> mGnssRil = nullptr;
|
||||
|
||||
GnssAPIClient* mApi = nullptr;
|
||||
sp<V1_0::IGnssCallback> mGnssCbIface = nullptr;
|
||||
sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr;
|
||||
sp<IGnssCallback> mGnssCbIface = nullptr;
|
||||
sp<IGnssNiCallback> mGnssNiCbIface = nullptr;
|
||||
GnssConfig mPendingConfig;
|
||||
GnssInterface* mGnssInterface = nullptr;
|
||||
};
|
||||
|
@ -140,4 +146,4 @@ extern "C" IGnss* HIDL_FETCH_IGnss(const char* name);
|
|||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSS_H
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSS_H
|
||||
|
|
2
gps/android/GnssBatching.cpp
Executable file → Normal file
2
gps/android/GnssBatching.cpp
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
|
8
gps/android/GnssBatching.h
Executable file → Normal file
8
gps/android/GnssBatching.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
@ -18,8 +18,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSSBATCHING_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_0_GNSSBATCHING_H
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSBATCHING_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_1_GNSSBATCHING_H
|
||||
|
||||
#include <android/hardware/gnss/1.0/IGnssBatching.h>
|
||||
#include <hidl/Status.h>
|
||||
|
@ -77,4 +77,4 @@ struct GnssBatching : public IGnssBatching {
|
|||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSSBATCHING_H
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSBATCHING_H
|
||||
|
|
2
gps/android/GnssConfiguration.cpp
Executable file → Normal file
2
gps/android/GnssConfiguration.cpp
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
|
8
gps/android/GnssConfiguration.h
Executable file → Normal file
8
gps/android/GnssConfiguration.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
|||
*/
|
||||
|
||||
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSSCONFIGURATION_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_0_GNSSCONFIGURATION_H
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H
|
||||
|
||||
#include <android/hardware/gnss/1.0/IGnssConfiguration.h>
|
||||
#include <hidl/Status.h>
|
||||
|
@ -68,4 +68,4 @@ struct GnssConfiguration : public IGnssConfiguration {
|
|||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSSCONFIGURATION_H
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H
|
||||
|
|
57
gps/android/GnssDebug.cpp
Executable file → Normal file
57
gps/android/GnssDebug.cpp
Executable file → Normal file
|
@ -30,14 +30,8 @@ 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
|
||||
#define GNSS_DEBUG_UNKNOWN_UTC_TIME (1483228800000ULL) // 1/1/2017 00:00 GMT
|
||||
#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC (1.57783680E17) // 5 years in ns
|
||||
|
||||
GnssDebug::GnssDebug(Gnss* gnss) : mGnss(gnss)
|
||||
{
|
||||
|
@ -97,40 +91,6 @@ Return<void> GnssDebug::getDebugData(getDebugData_cb _hidl_cb)
|
|||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -138,17 +98,10 @@ Return<void> GnssDebug::getDebugData(getDebugData_cb _hidl_cb)
|
|||
data.time.frequencyUncertaintyNsPerSec =
|
||||
reports.mTime.frequencyUncertaintyNsPerSec;
|
||||
}
|
||||
|
||||
if (data.time.timeEstimate < GNSS_DEBUG_UNKNOWN_UTC_TIME) {
|
||||
else {
|
||||
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;
|
||||
data.time.timeUncertaintyNs = (float)(GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC);
|
||||
data.time.frequencyUncertaintyNsPerSec = 0;
|
||||
}
|
||||
|
||||
// satellite data block
|
||||
|
|
6
gps/android/GnssDebug.h
Executable file → Normal file
6
gps/android/GnssDebug.h
Executable file → Normal file
|
@ -14,8 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSSDEBUG_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_0_GNSSDEBUG_H
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSDEBUG_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_1_GNSSDEBUG_H
|
||||
|
||||
|
||||
#include <android/hardware/gnss/1.0/IGnssDebug.h>
|
||||
|
@ -56,4 +56,4 @@ private:
|
|||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSSDEBUG_H
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSDEBUG_H
|
||||
|
|
2
gps/android/GnssGeofencing.cpp
Executable file → Normal file
2
gps/android/GnssGeofencing.cpp
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
|
8
gps/android/GnssGeofencing.h
Executable file → Normal file
8
gps/android/GnssGeofencing.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
@ -18,8 +18,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSSGEOFENCING_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_0_GNSSGEOFENCING_H
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSGEOFENCING_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_1_GNSSGEOFENCING_H
|
||||
|
||||
#include <android/hardware/gnss/1.0/IGnssGeofencing.h>
|
||||
#include <hidl/Status.h>
|
||||
|
@ -88,4 +88,4 @@ struct GnssGeofencing : public IGnssGeofencing {
|
|||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSSGEOFENCING_H
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSGEOFENCING_H
|
||||
|
|
8
gps/android/GnssMeasurement.cpp
Executable file → Normal file
8
gps/android/GnssMeasurement.cpp
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
@ -52,9 +52,8 @@ GnssMeasurement::~GnssMeasurement() {
|
|||
}
|
||||
|
||||
// Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
|
||||
|
||||
Return<IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
|
||||
const sp<V1_0::IGnssMeasurementCallback>& callback) {
|
||||
const sp<IGnssMeasurementCallback>& callback) {
|
||||
|
||||
Return<IGnssMeasurement::GnssMeasurementStatus> ret =
|
||||
IGnssMeasurement::GnssMeasurementStatus::ERROR_GENERIC;
|
||||
|
@ -73,10 +72,9 @@ Return<IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
|
|||
}
|
||||
|
||||
mGnssMeasurementCbIface = callback;
|
||||
mGnssMeasurementCbIface->linkToDeath(mGnssMeasurementDeathRecipient, 0);
|
||||
mGnssMeasurementCbIface->linkToDeath(mGnssMeasurementDeathRecipient, 0 /*cookie*/);
|
||||
|
||||
return mApi->measurementSetCallback(callback);
|
||||
|
||||
}
|
||||
|
||||
Return<void> GnssMeasurement::close() {
|
||||
|
|
15
gps/android/GnssMeasurement.h
Executable file → Normal file
15
gps/android/GnssMeasurement.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
@ -18,11 +18,10 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSSMEASUREMENT_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_0_GNSSMEASUREMENT_H
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSMEASUREMENT_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_1_GNSSMEASUREMENT_H
|
||||
|
||||
#include <android/hardware/gnss/1.0/IGnssMeasurement.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
namespace android {
|
||||
|
@ -48,8 +47,8 @@ struct GnssMeasurement : public IGnssMeasurement {
|
|||
* Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
|
||||
* These declarations were generated from IGnssMeasurement.hal.
|
||||
*/
|
||||
Return<GnssMeasurement::GnssMeasurementStatus> setCallback(
|
||||
const sp<V1_0::IGnssMeasurementCallback>& callback) override;
|
||||
Return<GnssMeasurementStatus> setCallback(
|
||||
const sp<IGnssMeasurementCallback>& callback) override;
|
||||
Return<void> close() override;
|
||||
|
||||
private:
|
||||
|
@ -64,7 +63,7 @@ struct GnssMeasurement : public IGnssMeasurement {
|
|||
|
||||
private:
|
||||
sp<GnssMeasurementDeathRecipient> mGnssMeasurementDeathRecipient = nullptr;
|
||||
sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface = nullptr;
|
||||
sp<IGnssMeasurementCallback> mGnssMeasurementCbIface = nullptr;
|
||||
MeasurementAPIClient* mApi;
|
||||
};
|
||||
|
||||
|
@ -74,4 +73,4 @@ struct GnssMeasurement : public IGnssMeasurement {
|
|||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSSMEASUREMENT_H
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSMEASUREMENT_H
|
||||
|
|
2
gps/android/GnssNi.cpp
Executable file → Normal file
2
gps/android/GnssNi.cpp
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
|
8
gps/android/GnssNi.h
Executable file → Normal file
8
gps/android/GnssNi.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
@ -18,8 +18,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSSNI_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_0_GNSSNI_H
|
||||
#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSNI_H
|
||||
#define ANDROID_HARDWARE_GNSS_V1_1_GNSSNI_H
|
||||
|
||||
#include <android/hardware/gnss/1.0/IGnssNi.h>
|
||||
#include <hidl/Status.h>
|
||||
|
@ -72,4 +72,4 @@ struct GnssNi : public IGnssNi {
|
|||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_0_GNSSNI_H
|
||||
#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSNI_H
|
||||
|
|
2
gps/android/android.hardware.gnss@1.1-service-qti.rc → gps/android/android.hardware.gnss@1.0-service-qti.rc
Executable file → Normal file
2
gps/android/android.hardware.gnss@1.1-service-qti.rc → gps/android/android.hardware.gnss@1.0-service-qti.rc
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
service gnss_service /vendor/bin/hw/android.hardware.gnss@1.0-service-qti
|
||||
class hal
|
||||
class main
|
||||
user gps
|
||||
group system gps radio
|
9
gps/android/location_api/BatchingAPIClient.cpp
Executable file → Normal file
9
gps/android/location_api/BatchingAPIClient.cpp
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2017, 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
|
||||
|
@ -45,10 +45,6 @@ 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);
|
||||
|
||||
|
@ -157,8 +153,7 @@ void BatchingAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMa
|
|||
mLocationCapabilitiesMask = capabilitiesMask;
|
||||
}
|
||||
|
||||
void BatchingAPIClient::onBatchingCb(size_t count, Location* location,
|
||||
BatchingOptions /*batchOptions*/)
|
||||
void BatchingAPIClient::onBatchingCb(size_t count, Location* location, BatchingOptions batchOptions)
|
||||
{
|
||||
LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, count);
|
||||
if (mGnssBatchingCbIface != nullptr && count > 0) {
|
||||
|
|
11
gps/android/location_api/BatchingAPIClient.h
Executable file → Normal file
11
gps/android/location_api/BatchingAPIClient.h
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2017, 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
|
||||
|
@ -45,11 +45,11 @@ namespace implementation {
|
|||
class BatchingAPIClient : public LocationAPIClientBase
|
||||
{
|
||||
public:
|
||||
BatchingAPIClient(const sp<V1_0::IGnssBatchingCallback>& callback);
|
||||
BatchingAPIClient(const sp<IGnssBatchingCallback>& callback);
|
||||
~BatchingAPIClient();
|
||||
int getBatchSize();
|
||||
int startSession(const V1_0::IGnssBatching::Options& options);
|
||||
int updateSessionOptions(const V1_0::IGnssBatching::Options& options);
|
||||
int startSession(const IGnssBatching::Options& options);
|
||||
int updateSessionOptions(const IGnssBatching::Options& options);
|
||||
int stopSession();
|
||||
void getBatchedLocation(int last_n_locations);
|
||||
void flushBatchedLocations();
|
||||
|
@ -61,8 +61,9 @@ public:
|
|||
void onBatchingCb(size_t count, Location* location, BatchingOptions batchOptions) final;
|
||||
|
||||
private:
|
||||
sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface;
|
||||
sp<IGnssBatchingCallback> mGnssBatchingCbIface;
|
||||
uint32_t mDefaultId;
|
||||
int mBatchSize;
|
||||
LocationCapabilitiesMask mLocationCapabilitiesMask;
|
||||
};
|
||||
|
||||
|
|
6
gps/android/location_api/GeofenceAPIClient.cpp
Executable file → Normal file
6
gps/android/location_api/GeofenceAPIClient.cpp
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2017, 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
|
||||
|
@ -42,8 +42,6 @@ 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<IGnssGeofenceCallback>& callback) :
|
||||
LocationAPIClientBase(),
|
||||
|
@ -160,7 +158,7 @@ void GeofenceAPIClient::onGeofenceBreachCb(GeofenceBreachNotification geofenceBr
|
|||
|
||||
auto r = mGnssGeofencingCbIface->gnssGeofenceTransitionCb(
|
||||
geofenceBreachNotification.ids[i], gnssLocation, transition,
|
||||
static_cast<V1_0::GnssUtcTime>(geofenceBreachNotification.timestamp));
|
||||
static_cast<GnssUtcTime>(geofenceBreachNotification.timestamp));
|
||||
if (!r.isOk()) {
|
||||
LOC_LOGE("%s] Error from gnssGeofenceTransitionCb description=%s",
|
||||
__func__, r.description().c_str());
|
||||
|
|
6
gps/android/location_api/GeofenceAPIClient.h
Executable file → Normal file
6
gps/android/location_api/GeofenceAPIClient.h
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2017, 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
|
||||
|
@ -45,7 +45,7 @@ using ::android::sp;
|
|||
class GeofenceAPIClient : public LocationAPIClientBase
|
||||
{
|
||||
public:
|
||||
GeofenceAPIClient(const sp<V1_0::IGnssGeofenceCallback>& callback);
|
||||
GeofenceAPIClient(const sp<IGnssGeofenceCallback>& callback);
|
||||
virtual ~GeofenceAPIClient() = default;
|
||||
|
||||
void geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
void onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
|
||||
|
||||
private:
|
||||
sp<V1_0::IGnssGeofenceCallback> mGnssGeofencingCbIface;
|
||||
sp<IGnssGeofenceCallback> mGnssGeofencingCbIface;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
|
21
gps/android/location_api/GnssAPIClient.cpp
Executable file → Normal file
21
gps/android/location_api/GnssAPIClient.cpp
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2017, 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
|
||||
|
@ -43,11 +43,6 @@ 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<IGnssCallback>& gpsCb,
|
||||
|
@ -165,10 +160,6 @@ bool GnssAPIClient::gnssSetPositionMode(IGnss::GnssPositionMode mode,
|
|||
mLocationOptions.size = sizeof(LocationOptions);
|
||||
mLocationOptions.minInterval = minIntervalMs;
|
||||
mLocationOptions.minDistance = preferredAccuracyMeters;
|
||||
if (IGnss::GnssPositionRecurrence::RECURRENCE_SINGLE == recurrence) {
|
||||
mLocationOptions.minInterval =
|
||||
std::numeric_limits<decltype(mLocationOptions.minInterval)>::max();
|
||||
}
|
||||
if (mode == IGnss::GnssPositionMode::STANDALONE)
|
||||
mLocationOptions.mode = GNSS_SUPL_MODE_STANDALONE;
|
||||
else if (mode == IGnss::GnssPositionMode::MS_BASED)
|
||||
|
@ -454,7 +445,7 @@ void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
|
|||
android::hardware::hidl_string nmeaString;
|
||||
nmeaString.setToExternal(gnssNmeaNotification.nmea, gnssNmeaNotification.length);
|
||||
auto r = gnssCbIface->gnssNmeaCb(
|
||||
static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString);
|
||||
static_cast<GnssUtcTime>(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());
|
||||
|
@ -508,10 +499,10 @@ static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvSta
|
|||
{
|
||||
memset(&out, 0, sizeof(IGnssCallback::GnssSvStatus));
|
||||
out.numSvs = in.count;
|
||||
if (out.numSvs > static_cast<uint32_t>(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<uint32_t>(V1_0::GnssMax::SVS_COUNT);
|
||||
if (out.numSvs > static_cast<uint32_t>(GnssMax::SVS_COUNT)) {
|
||||
LOC_LOGW("%s]: Too many satellites %zd. Clamps to %d.",
|
||||
__FUNCTION__, out.numSvs, GnssMax::SVS_COUNT);
|
||||
out.numSvs = static_cast<uint32_t>(GnssMax::SVS_COUNT);
|
||||
}
|
||||
for (size_t i = 0; i < out.numSvs; i++) {
|
||||
IGnssCallback::GnssSvInfo& info = out.gnssSvList[i];
|
||||
|
|
24
gps/android/location_api/GnssAPIClient.h
Executable file → Normal file
24
gps/android/location_api/GnssAPIClient.h
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2017, 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
|
||||
|
@ -30,7 +30,6 @@
|
|||
#ifndef GNSS_API_CLINET_H
|
||||
#define GNSS_API_CLINET_H
|
||||
|
||||
|
||||
#include <mutex>
|
||||
#include <android/hardware/gnss/1.0/IGnss.h>
|
||||
#include <android/hardware/gnss/1.0/IGnssCallback.h>
|
||||
|
@ -48,28 +47,28 @@ using ::android::sp;
|
|||
class GnssAPIClient : public LocationAPIClientBase
|
||||
{
|
||||
public:
|
||||
GnssAPIClient(const sp<V1_0::IGnssCallback>& gpsCb,
|
||||
const sp<V1_0::IGnssNiCallback>& niCb);
|
||||
GnssAPIClient(const sp<IGnssCallback>& gpsCb,
|
||||
const sp<IGnssNiCallback>& niCb);
|
||||
virtual ~GnssAPIClient();
|
||||
GnssAPIClient(const GnssAPIClient&) = delete;
|
||||
GnssAPIClient& operator=(const GnssAPIClient&) = delete;
|
||||
|
||||
// for GpsInterface
|
||||
void gnssUpdateCallbacks(const sp<V1_0::IGnssCallback>& gpsCb,
|
||||
const sp<V1_0::IGnssNiCallback>& niCb);
|
||||
void gnssUpdateCallbacks(const sp<IGnssCallback>& gpsCb,
|
||||
const sp<IGnssNiCallback>& niCb);
|
||||
bool gnssStart();
|
||||
bool gnssStop();
|
||||
bool gnssSetPositionMode(V1_0::IGnss::GnssPositionMode mode,
|
||||
V1_0::IGnss::GnssPositionRecurrence recurrence,
|
||||
bool gnssSetPositionMode(IGnss::GnssPositionMode mode,
|
||||
IGnss::GnssPositionRecurrence recurrence,
|
||||
uint32_t minIntervalMs,
|
||||
uint32_t preferredAccuracyMeters,
|
||||
uint32_t preferredTimeMs);
|
||||
|
||||
// for GpsNiInterface
|
||||
void gnssNiRespond(int32_t notifId, V1_0::IGnssNiCallback::GnssUserResponseType userResponse);
|
||||
void gnssNiRespond(int32_t notifId, IGnssNiCallback::GnssUserResponseType userResponse);
|
||||
|
||||
// these apis using LocationAPIControlClient
|
||||
void gnssDeleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags);
|
||||
void gnssDeleteAidingData(IGnss::GnssAidingData aidingDataFlags);
|
||||
void gnssEnable(LocationTechnologyType techType);
|
||||
void gnssDisable();
|
||||
void gnssConfigurationUpdate(const GnssConfig& gnssConfig);
|
||||
|
@ -90,13 +89,12 @@ public:
|
|||
void onStopTrackingCb(LocationError error) final;
|
||||
|
||||
private:
|
||||
sp<V1_0::IGnssCallback> mGnssCbIface;
|
||||
sp<V1_0::IGnssNiCallback> mGnssNiCbIface;
|
||||
sp<IGnssCallback> mGnssCbIface;
|
||||
sp<IGnssNiCallback> mGnssNiCbIface;
|
||||
std::mutex mMutex;
|
||||
LocationAPIControlClient* mControlClient;
|
||||
LocationCapabilitiesMask mLocationCapabilitiesMask;
|
||||
bool mLocationCapabilitiesCached;
|
||||
|
||||
LocationOptions mLocationOptions;
|
||||
};
|
||||
|
||||
|
|
39
gps/android/location_api/LocationUtil.cpp
Executable file → Normal file
39
gps/android/location_api/LocationUtil.cpp
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2017, 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
|
||||
|
@ -35,10 +35,6 @@ 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));
|
||||
|
@ -67,38 +63,7 @@ void convertGnssLocation(Location& in, GnssLocation& out)
|
|||
out.verticalAccuracyMeters = in.verticalAccuracy;
|
||||
out.speedAccuracyMetersPerSecond = in.speedAccuracy;
|
||||
out.bearingAccuracyDegrees = in.bearingAccuracy;
|
||||
out.timestamp = static_cast<V1_0::GnssUtcTime>(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;
|
||||
if (in.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE)
|
||||
out.flags |= LOCATION_HAS_ALTITUDE_BIT;
|
||||
if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED)
|
||||
out.flags |= LOCATION_HAS_SPEED_BIT;
|
||||
if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING)
|
||||
out.flags |= LOCATION_HAS_BEARING_BIT;
|
||||
if (in.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY)
|
||||
out.flags |= LOCATION_HAS_ACCURACY_BIT;
|
||||
if (in.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY)
|
||||
out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT;
|
||||
if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY)
|
||||
out.flags |= LOCATION_HAS_SPEED_ACCURACY_BIT;
|
||||
if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY)
|
||||
out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT;
|
||||
out.latitude = in.latitudeDegrees;
|
||||
out.longitude = in.longitudeDegrees;
|
||||
out.altitude = in.altitudeMeters;
|
||||
out.speed = in.speedMetersPerSec;
|
||||
out.bearing = in.bearingDegrees;
|
||||
out.accuracy = in.horizontalAccuracyMeters;
|
||||
out.verticalAccuracy = in.verticalAccuracyMeters;
|
||||
out.speedAccuracy = in.speedAccuracyMetersPerSecond;
|
||||
out.bearingAccuracy = in.bearingAccuracyDegrees;
|
||||
out.timestamp = static_cast<uint64_t>(in.timestamp);
|
||||
out.timestamp = static_cast<GnssUtcTime>(in.timestamp);
|
||||
}
|
||||
|
||||
void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out)
|
||||
|
|
7
gps/android/location_api/LocationUtil.h
Executable file → Normal file
7
gps/android/location_api/LocationUtil.h
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2017, 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
|
||||
|
@ -40,9 +40,8 @@ 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 convertGnssLocation(Location& in, GnssLocation& out);
|
||||
void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out);
|
||||
void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out);
|
||||
void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out);
|
||||
void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out);
|
||||
|
|
38
gps/android/location_api/MeasurementAPIClient.cpp
Executable file → Normal file
38
gps/android/location_api/MeasurementAPIClient.cpp
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2017, 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
|
||||
|
@ -42,13 +42,10 @@ 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);
|
||||
IGnssMeasurementCallback::GnssData& out);
|
||||
static void convertGnssMeasurement(GnssMeasurementsData& in,
|
||||
V1_0::IGnssMeasurementCallback::GnssMeasurement& out);
|
||||
IGnssMeasurementCallback::GnssMeasurement& out);
|
||||
static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out);
|
||||
|
||||
MeasurementAPIClient::MeasurementAPIClient() :
|
||||
|
@ -65,7 +62,7 @@ MeasurementAPIClient::~MeasurementAPIClient()
|
|||
|
||||
// for GpsInterface
|
||||
Return<IGnssMeasurement::GnssMeasurementStatus>
|
||||
MeasurementAPIClient::measurementSetCallback(const sp<V1_0::IGnssMeasurementCallback>& callback)
|
||||
MeasurementAPIClient::measurementSetCallback(const sp<IGnssMeasurementCallback>& callback)
|
||||
{
|
||||
LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
|
||||
|
||||
|
@ -73,12 +70,6 @@ MeasurementAPIClient::measurementSetCallback(const sp<V1_0::IGnssMeasurementCall
|
|||
mGnssMeasurementCbIface = callback;
|
||||
mMutex.unlock();
|
||||
|
||||
return startTracking();
|
||||
}
|
||||
|
||||
Return<IGnssMeasurement::GnssMeasurementStatus>
|
||||
MeasurementAPIClient::startTracking()
|
||||
{
|
||||
LocationCallbacks locationCallbacks;
|
||||
memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
|
||||
locationCallbacks.size = sizeof(LocationCallbacks);
|
||||
|
@ -124,18 +115,15 @@ void MeasurementAPIClient::measurementClose() {
|
|||
void MeasurementAPIClient::onGnssMeasurementsCb(
|
||||
GnssMeasurementsNotification gnssMeasurementsNotification)
|
||||
{
|
||||
LOC_LOGD("%s]: (count: %zu active: %d)",
|
||||
LOC_LOGD("%s]: (count: %zu active: %zu)",
|
||||
__FUNCTION__, gnssMeasurementsNotification.count, mTracking);
|
||||
if (mTracking) {
|
||||
mMutex.lock();
|
||||
sp<V1_0::IGnssMeasurementCallback> gnssMeasurementCbIface = nullptr;
|
||||
if (mGnssMeasurementCbIface != nullptr) {
|
||||
gnssMeasurementCbIface = mGnssMeasurementCbIface;
|
||||
}
|
||||
auto gnssMeasurementCbIface(mGnssMeasurementCbIface);
|
||||
mMutex.unlock();
|
||||
|
||||
if (gnssMeasurementCbIface != nullptr) {
|
||||
V1_0::IGnssMeasurementCallback::GnssData gnssData;
|
||||
IGnssMeasurementCallback::GnssData gnssData;
|
||||
convertGnssData(gnssMeasurementsNotification, gnssData);
|
||||
auto r = gnssMeasurementCbIface->GnssMeasurementCb(gnssData);
|
||||
if (!r.isOk()) {
|
||||
|
@ -147,7 +135,7 @@ void MeasurementAPIClient::onGnssMeasurementsCb(
|
|||
}
|
||||
|
||||
static void convertGnssMeasurement(GnssMeasurementsData& in,
|
||||
V1_0::IGnssMeasurementCallback::GnssMeasurement& out)
|
||||
IGnssMeasurementCallback::GnssMeasurement& out)
|
||||
{
|
||||
memset(&out, 0, sizeof(IGnssMeasurementCallback::GnssMeasurement));
|
||||
if (in.flags & GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT)
|
||||
|
@ -254,13 +242,13 @@ static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback
|
|||
}
|
||||
|
||||
static void convertGnssData(GnssMeasurementsNotification& in,
|
||||
V1_0::IGnssMeasurementCallback::GnssData& out)
|
||||
IGnssMeasurementCallback::GnssData& out)
|
||||
{
|
||||
out.measurementCount = in.count;
|
||||
if (out.measurementCount > static_cast<uint32_t>(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<uint32_t>(V1_0::GnssMax::SVS_COUNT);
|
||||
if (out.measurementCount > static_cast<uint32_t>(GnssMax::SVS_COUNT)) {
|
||||
LOC_LOGW("%s]: Too many measurement %zd. Clamps to %d.",
|
||||
__FUNCTION__, out.measurementCount, GnssMax::SVS_COUNT);
|
||||
out.measurementCount = static_cast<uint32_t>(GnssMax::SVS_COUNT);
|
||||
}
|
||||
for (size_t i = 0; i < out.measurementCount; i++) {
|
||||
convertGnssMeasurement(in.measurements[i], out.measurements[i]);
|
||||
|
|
11
gps/android/location_api/MeasurementAPIClient.h
Executable file → Normal file
11
gps/android/location_api/MeasurementAPIClient.h
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2017, 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
|
||||
|
@ -42,6 +42,7 @@ namespace gnss {
|
|||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::gnss::V1_0::IGnssMeasurement;
|
||||
using ::android::sp;
|
||||
|
||||
class MeasurementAPIClient : public LocationAPIClientBase
|
||||
|
@ -53,18 +54,16 @@ public:
|
|||
MeasurementAPIClient& operator=(const MeasurementAPIClient&) = delete;
|
||||
|
||||
// for GpsMeasurementInterface
|
||||
Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> measurementSetCallback(
|
||||
const sp<V1_0::IGnssMeasurementCallback>& callback);
|
||||
Return<IGnssMeasurement::GnssMeasurementStatus> measurementSetCallback(
|
||||
const sp<IGnssMeasurementCallback>& callback);
|
||||
void measurementClose();
|
||||
Return<IGnssMeasurement::GnssMeasurementStatus> startTracking();
|
||||
|
||||
// callbacks we are interested in
|
||||
void onGnssMeasurementsCb(GnssMeasurementsNotification gnssMeasurementsNotification) final;
|
||||
|
||||
private:
|
||||
sp<IGnssMeasurementCallback> mGnssMeasurementCbIface;
|
||||
std::mutex mMutex;
|
||||
sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface;
|
||||
|
||||
bool mTracking;
|
||||
};
|
||||
|
||||
|
|
6
gps/android/service.cpp
Executable file → Normal file
6
gps/android/service.cpp
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution
|
||||
*/
|
||||
/*
|
||||
|
@ -18,9 +18,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.gnss@1.1-service-qti"
|
||||
#define LOG_TAG "android.hardware.gnss@1.0-service-qti"
|
||||
|
||||
#include <android/hardware/gnss/1.1/IGnss.h>
|
||||
#include <android/hardware/gnss/1.0/IGnss.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
|
||||
using android::hardware::gnss::V1_0::IGnss;
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
GNSS_CFLAGS := \
|
||||
-Werror \
|
||||
-Wno-error=unused-parameter \
|
||||
-Wno-error=format \
|
||||
-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
|
11
gps/core/Android.mk
Executable file → Normal file
11
gps/core/Android.mk
Executable file → Normal file
|
@ -3,7 +3,9 @@ LOCAL_PATH := $(call my-dir)
|
|||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libloc_core
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
|
||||
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
ifeq ($(BOARD_VENDOR_QCOM_LOC_PDK_FEATURE_SET),true)
|
||||
LOCAL_CFLAGS += -DPDK_FEATURE_SET
|
||||
|
@ -15,7 +17,8 @@ LOCAL_SHARED_LIBRARIES := \
|
|||
libcutils \
|
||||
libgps.utils \
|
||||
libdl \
|
||||
liblog
|
||||
liblog \
|
||||
libloc_pla
|
||||
|
||||
LOCAL_SRC_FILES += \
|
||||
LocApiBase.cpp \
|
||||
|
@ -24,6 +27,9 @@ LOCAL_SRC_FILES += \
|
|||
LocDualContext.cpp \
|
||||
loc_core_log.cpp \
|
||||
data-items/DataItemsFactoryProxy.cpp \
|
||||
data-items/common/ClientIndex.cpp \
|
||||
data-items/common/DataItemIndex.cpp \
|
||||
data-items/common/IndexFactory.cpp \
|
||||
SystemStatusOsObserver.cpp \
|
||||
SystemStatus.cpp
|
||||
|
||||
|
@ -37,7 +43,6 @@ LOCAL_C_INCLUDES:= \
|
|||
$(LOCAL_PATH)/observer \
|
||||
|
||||
LOCAL_HEADER_LIBRARIES := \
|
||||
libutils_headers \
|
||||
libgps.utils_headers \
|
||||
libloc_pla_headers \
|
||||
liblocation_api_headers
|
||||
|
|
6
gps/core/ContextBase.cpp
Executable file → Normal file
6
gps/core/ContextBase.cpp
Executable file → Normal file
|
@ -35,7 +35,7 @@
|
|||
#include <ContextBase.h>
|
||||
#include <msg_q.h>
|
||||
#include <loc_target.h>
|
||||
#include <loc_pla.h>
|
||||
#include <platform_lib_includes.h>
|
||||
#include <loc_log.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
@ -65,8 +65,6 @@ const loc_param_s_type ContextBase::mGps_conf_table[] =
|
|||
{"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL", &mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'},
|
||||
{"AGPS_CONFIG_INJECT", &mGps_conf.AGPS_CONFIG_INJECT, NULL, 'n'},
|
||||
{"EXTERNAL_DR_ENABLED", &mGps_conf.EXTERNAL_DR_ENABLED, NULL, 'n'},
|
||||
{"SUPL_HOST", &mGps_conf.SUPL_HOST, NULL, 's'},
|
||||
{"SUPL_PORT", &mGps_conf.SUPL_PORT, NULL, 'n'},
|
||||
};
|
||||
|
||||
const loc_param_s_type ContextBase::mSap_conf_table[] =
|
||||
|
@ -100,8 +98,6 @@ void ContextBase::readConfig()
|
|||
mGps_conf.SUPL_VER = 0x10000;
|
||||
mGps_conf.SUPL_MODE = 0x1;
|
||||
mGps_conf.SUPL_ES = 0;
|
||||
mGps_conf.SUPL_HOST[0] = 0;
|
||||
mGps_conf.SUPL_PORT = 0;
|
||||
mGps_conf.CAPABILITIES = 0x7;
|
||||
/* LTE Positioning Profile configuration is disable by default*/
|
||||
mGps_conf.LPP_PROFILE = 0;
|
||||
|
|
5
gps/core/ContextBase.h
Executable file → Normal file
5
gps/core/ContextBase.h
Executable file → Normal file
|
@ -36,8 +36,7 @@
|
|||
#include <LBSProxyBase.h>
|
||||
#include <loc_cfg.h>
|
||||
|
||||
#define MAX_XTRA_SERVER_URL_LENGTH (256)
|
||||
#define MAX_SUPL_SERVER_URL_LENGTH (256)
|
||||
#define MAX_XTRA_SERVER_URL_LENGTH 256
|
||||
|
||||
/* GPS.conf support */
|
||||
/* NOTE: the implementaiton of the parser casts number
|
||||
|
@ -65,8 +64,6 @@ typedef struct loc_gps_cfg_s
|
|||
uint32_t LPPE_CP_TECHNOLOGY;
|
||||
uint32_t LPPE_UP_TECHNOLOGY;
|
||||
uint32_t EXTERNAL_DR_ENABLED;
|
||||
char SUPL_HOST[MAX_SUPL_SERVER_URL_LENGTH];
|
||||
uint32_t SUPL_PORT;
|
||||
} loc_gps_cfg_s_type;
|
||||
|
||||
/* NOTE: the implementaiton of the parser casts number
|
||||
|
|
0
gps/core/LBSProxyBase.h
Executable file → Normal file
0
gps/core/LBSProxyBase.h
Executable file → Normal file
6
gps/core/LocAdapterBase.cpp
Executable file → Normal file
6
gps/core/LocAdapterBase.cpp
Executable file → Normal file
|
@ -32,7 +32,7 @@
|
|||
#include <dlfcn.h>
|
||||
#include <LocAdapterBase.h>
|
||||
#include <loc_target.h>
|
||||
#include <log_util.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <LocAdapterProxyBase.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
@ -161,8 +161,4 @@ bool LocAdapterBase::
|
|||
reportWwanZppFix(LocGpsLocation &/*zppLoc*/)
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
reportOdcpiRequestEvent(OdcpiRequestInfo& /*request*/)
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
} // namespace loc_core
|
||||
|
|
1
gps/core/LocAdapterBase.h
Executable file → Normal file
1
gps/core/LocAdapterBase.h
Executable file → Normal file
|
@ -153,7 +153,6 @@ public:
|
|||
virtual void reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurements,
|
||||
int msInWeek);
|
||||
virtual bool reportWwanZppFix(LocGpsLocation &zppLoc);
|
||||
virtual bool reportOdcpiRequestEvent(OdcpiRequestInfo& request);
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
|
0
gps/core/LocAdapterProxyBase.h
Executable file → Normal file
0
gps/core/LocAdapterProxyBase.h
Executable file → Normal file
30
gps/core/LocApiBase.cpp
Executable file → Normal file
30
gps/core/LocApiBase.cpp
Executable file → Normal file
|
@ -33,7 +33,7 @@
|
|||
#include <inttypes.h>
|
||||
#include <LocApiBase.h>
|
||||
#include <LocAdapterBase.h>
|
||||
#include <log_util.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <LocDualContext.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
@ -107,16 +107,19 @@ struct LocSsrMsg : public LocMsg {
|
|||
|
||||
struct LocOpenMsg : public LocMsg {
|
||||
LocApiBase* mLocApi;
|
||||
inline LocOpenMsg(LocApiBase* locApi) :
|
||||
LocMsg(), mLocApi(locApi)
|
||||
LOC_API_ADAPTER_EVENT_MASK_T mMask;
|
||||
inline LocOpenMsg(LocApiBase* locApi,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T mask) :
|
||||
LocMsg(), mLocApi(locApi), mMask(mask)
|
||||
{
|
||||
locallog();
|
||||
}
|
||||
inline virtual void proc() const {
|
||||
mLocApi->open(mLocApi->getEvtMask());
|
||||
mLocApi->open(mMask);
|
||||
}
|
||||
inline void locallog() const {
|
||||
LOC_LOGv("LocOpen Mask: %" PRIx64 "\n", mLocApi->getEvtMask());
|
||||
LOC_LOGV("%s:%d]: LocOpen Mask: %x\n",
|
||||
__func__, __LINE__, mMask);
|
||||
}
|
||||
inline virtual void log() const {
|
||||
locallog();
|
||||
|
@ -160,7 +163,8 @@ void LocApiBase::addAdapter(LocAdapterBase* adapter)
|
|||
for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) {
|
||||
if (mLocAdapters[i] == NULL) {
|
||||
mLocAdapters[i] = adapter;
|
||||
mMsgTask->sendMsg(new LocOpenMsg(this));
|
||||
mMsgTask->sendMsg(new LocOpenMsg(this,
|
||||
(adapter->getEvtMask())));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +200,7 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter)
|
|||
close();
|
||||
} else {
|
||||
// else we need to remove the bit
|
||||
mMsgTask->sendMsg(new LocOpenMsg(this));
|
||||
mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +208,7 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter)
|
|||
|
||||
void LocApiBase::updateEvtMask()
|
||||
{
|
||||
open(getEvtMask());
|
||||
mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask()));
|
||||
}
|
||||
|
||||
void LocApiBase::handleEngineUpEvent()
|
||||
|
@ -260,12 +264,6 @@ void LocApiBase::reportWwanZppFix(LocGpsLocation &zppLoc)
|
|||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportWwanZppFix(zppLoc));
|
||||
}
|
||||
|
||||
void LocApiBase::reportOdcpiRequest(OdcpiRequestInfo& request)
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportOdcpiRequestEvent(request));
|
||||
}
|
||||
|
||||
void LocApiBase::reportSv(GnssSvNotification& svNotify)
|
||||
{
|
||||
const char* constellationString[] = { "Unknown", "GPS", "SBAS", "GLONASS",
|
||||
|
@ -442,10 +440,6 @@ enum loc_api_adapter_err LocApiBase::
|
|||
injectPosition(double /*latitude*/, double /*longitude*/, float /*accuracy*/)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
injectPosition(const Location& /*location*/)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setTime(LocGpsUtcTime /*time*/, int64_t /*timeReference*/, int /*uncertainty*/)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
|
5
gps/core/LocApiBase.h
Executable file → Normal file
5
gps/core/LocApiBase.h
Executable file → Normal file
|
@ -34,7 +34,7 @@
|
|||
#include <gps_extended.h>
|
||||
#include <LocationAPI.h>
|
||||
#include <MsgTask.h>
|
||||
#include <log_util.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
|
||||
namespace loc_core {
|
||||
class ContextBase;
|
||||
|
@ -134,7 +134,6 @@ public:
|
|||
void reportGnssMeasurementData(GnssMeasurementsNotification& measurements, int msInWeek);
|
||||
void saveSupportedFeatureList(uint8_t *featureList);
|
||||
void reportWwanZppFix(LocGpsLocation &zppLoc);
|
||||
void reportOdcpiRequest(OdcpiRequestInfo& request);
|
||||
|
||||
// downward calls
|
||||
// All below functions are to be defined by adapter specific modules:
|
||||
|
@ -154,8 +153,6 @@ public:
|
|||
setAPN(char* apn, int len);
|
||||
virtual enum loc_api_adapter_err
|
||||
injectPosition(double latitude, double longitude, float accuracy);
|
||||
virtual enum loc_api_adapter_err
|
||||
injectPosition(const Location& location);
|
||||
virtual enum loc_api_adapter_err
|
||||
setTime(LocGpsUtcTime time, int64_t timeReference, int uncertainty);
|
||||
virtual enum loc_api_adapter_err
|
||||
|
|
2
gps/core/LocDualContext.cpp
Executable file → Normal file
2
gps/core/LocDualContext.cpp
Executable file → Normal file
|
@ -33,7 +33,7 @@
|
|||
#include <unistd.h>
|
||||
#include <LocDualContext.h>
|
||||
#include <msg_q.h>
|
||||
#include <log_util.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <loc_log.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
|
0
gps/core/LocDualContext.h
Executable file → Normal file
0
gps/core/LocDualContext.h
Executable file → Normal file
221
gps/core/SystemStatus.cpp
Executable file → Normal file
221
gps/core/SystemStatus.cpp
Executable file → Normal file
|
@ -34,8 +34,8 @@
|
|||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <pthread.h>
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <MsgTask.h>
|
||||
#include <loc_nmea.h>
|
||||
#include <DataItemsFactoryProxy.h>
|
||||
#include <SystemStatus.h>
|
||||
|
@ -120,12 +120,6 @@ public:
|
|||
double mAgcGal; // x16
|
||||
int32_t mLeapSeconds;// x17
|
||||
int32_t mLeapSecUnc; // x18
|
||||
uint32_t mGloBpAmpI; // x19
|
||||
uint32_t mGloBpAmpQ; // x1A
|
||||
uint32_t mBdsBpAmpI; // x1B
|
||||
uint32_t mBdsBpAmpQ; // x1C
|
||||
uint32_t mGalBpAmpI; // x1D
|
||||
uint32_t mGalBpAmpQ; // x1E
|
||||
};
|
||||
|
||||
// parser
|
||||
|
@ -160,12 +154,6 @@ private:
|
|||
eMax0 = eAgcGal,
|
||||
eLeapSeconds = 23,
|
||||
eLeapSecUnc = 24,
|
||||
eGloBpAmpI = 25,
|
||||
eGloBpAmpQ = 26,
|
||||
eBdsBpAmpI = 27,
|
||||
eBdsBpAmpQ = 28,
|
||||
eGalBpAmpI = 29,
|
||||
eGalBpAmpQ = 30,
|
||||
eMax
|
||||
};
|
||||
SystemStatusPQWM1 mM1;
|
||||
|
@ -195,12 +183,6 @@ public:
|
|||
inline uint32_t getRecErrorRecovery() { return mM1.mRecErrorRecovery; }
|
||||
inline int32_t getLeapSeconds(){ return mM1.mLeapSeconds; }
|
||||
inline int32_t getLeapSecUnc() { return mM1.mLeapSecUnc; }
|
||||
inline uint32_t getGloBpAmpI() { return mM1.mGloBpAmpI; }
|
||||
inline uint32_t getGloBpAmpQ() { return mM1.mGloBpAmpQ; }
|
||||
inline uint32_t getBdsBpAmpI() { return mM1.mBdsBpAmpI; }
|
||||
inline uint32_t getBdsBpAmpQ() { return mM1.mBdsBpAmpQ; }
|
||||
inline uint32_t getGalBpAmpI() { return mM1.mGalBpAmpI; }
|
||||
inline uint32_t getGalBpAmpQ() { return mM1.mGalBpAmpQ; }
|
||||
|
||||
SystemStatusPQWM1parser(const char *str_in, uint32_t len_in)
|
||||
: SystemStatusNmeaBase(str_in, len_in)
|
||||
|
@ -237,14 +219,6 @@ public:
|
|||
mM1.mLeapSeconds = atoi(mField[eLeapSeconds].c_str());
|
||||
mM1.mLeapSecUnc = atoi(mField[eLeapSecUnc].c_str());
|
||||
}
|
||||
if (mField.size() > eGalBpAmpQ) {
|
||||
mM1.mGloBpAmpI = atoi(mField[eGloBpAmpI].c_str());
|
||||
mM1.mGloBpAmpQ = atoi(mField[eGloBpAmpQ].c_str());
|
||||
mM1.mBdsBpAmpI = atoi(mField[eBdsBpAmpI].c_str());
|
||||
mM1.mBdsBpAmpQ = atoi(mField[eBdsBpAmpQ].c_str());
|
||||
mM1.mGalBpAmpI = atoi(mField[eGalBpAmpI].c_str());
|
||||
mM1.mGalBpAmpQ = atoi(mField[eGalBpAmpQ].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
inline SystemStatusPQWM1& get() { return mM1;} //getparser
|
||||
|
@ -791,13 +765,7 @@ SystemStatusRfAndParams::SystemStatusRfAndParams(const SystemStatusPQWM1& nmea)
|
|||
mAgcGps(nmea.mAgcGps),
|
||||
mAgcGlo(nmea.mAgcGlo),
|
||||
mAgcBds(nmea.mAgcBds),
|
||||
mAgcGal(nmea.mAgcGal),
|
||||
mGloBpAmpI(nmea.mGloBpAmpI),
|
||||
mGloBpAmpQ(nmea.mGloBpAmpQ),
|
||||
mBdsBpAmpI(nmea.mBdsBpAmpI),
|
||||
mBdsBpAmpQ(nmea.mBdsBpAmpQ),
|
||||
mGalBpAmpI(nmea.mGalBpAmpI),
|
||||
mGalBpAmpQ(nmea.mGalBpAmpQ)
|
||||
mAgcGal(nmea.mAgcGal)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -815,13 +783,7 @@ bool SystemStatusRfAndParams::equals(const SystemStatusRfAndParams& peer)
|
|||
(mAgcGps != peer.mAgcGps) ||
|
||||
(mAgcGlo != peer.mAgcGlo) ||
|
||||
(mAgcBds != peer.mAgcBds) ||
|
||||
(mAgcGal != peer.mAgcGal) ||
|
||||
(mGloBpAmpI != peer.mGloBpAmpI) ||
|
||||
(mGloBpAmpQ != peer.mGloBpAmpQ) ||
|
||||
(mBdsBpAmpI != peer.mBdsBpAmpI) ||
|
||||
(mBdsBpAmpQ != peer.mBdsBpAmpQ) ||
|
||||
(mGalBpAmpI != peer.mGalBpAmpI) ||
|
||||
(mGalBpAmpQ != peer.mGalBpAmpQ)) {
|
||||
(mAgcGal != peer.mAgcGal)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -1255,7 +1217,8 @@ IOsObserver* SystemStatus::getOsObserver()
|
|||
}
|
||||
|
||||
SystemStatus::SystemStatus(const MsgTask* msgTask) :
|
||||
mSysStatusObsvr(this, msgTask)
|
||||
mSysStatusObsvr(this, msgTask),
|
||||
mConnected(false)
|
||||
{
|
||||
int result = 0;
|
||||
ENTRY_LOG ();
|
||||
|
@ -1305,10 +1268,17 @@ SystemStatus::SystemStatus(const MsgTask* msgTask) :
|
|||
/******************************************************************************
|
||||
SystemStatus - storing dataitems
|
||||
******************************************************************************/
|
||||
template <typename TYPE_REPORT, typename TYPE_ITEM>
|
||||
bool SystemStatus::setIteminReport(TYPE_REPORT& report, TYPE_ITEM&& s)
|
||||
template <typename TYPE_SYSTEMSTATUS_ITEM, typename TYPE_REPORT, typename TYPE_ITEMBASE>
|
||||
bool SystemStatus::setItemBaseinReport(TYPE_REPORT& report, const TYPE_ITEMBASE& s)
|
||||
{
|
||||
if (!report.empty() && report.back().equals(static_cast<TYPE_ITEM&>(s.collate(report.back())))) {
|
||||
TYPE_SYSTEMSTATUS_ITEM sout(s);
|
||||
return setIteminReport(report, sout);
|
||||
}
|
||||
|
||||
template <typename TYPE_REPORT, typename TYPE_ITEM>
|
||||
bool SystemStatus::setIteminReport(TYPE_REPORT& report, const TYPE_ITEM& s)
|
||||
{
|
||||
if (!report.empty() && report.back().equals(s)) {
|
||||
// there is no change - just update reported timestamp
|
||||
report.back().mUtcReported = s.mUtcReported;
|
||||
return false;
|
||||
|
@ -1347,10 +1317,11 @@ void SystemStatus::getIteminReport(TYPE_REPORT& reportout, const TYPE_ITEM& c) c
|
|||
@param[In] data pointer to the NMEA string
|
||||
@param[In] len length of the NMEA string
|
||||
|
||||
@return true when the NMEA is consumed by the method.
|
||||
@return true when successfully done
|
||||
******************************************************************************/
|
||||
bool SystemStatus::setNmeaString(const char *data, uint32_t len)
|
||||
{
|
||||
bool ret = false;
|
||||
if (!loc_nmea_is_debug(data, len)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1361,43 +1332,43 @@ bool SystemStatus::setNmeaString(const char *data, uint32_t len)
|
|||
pthread_mutex_lock(&mMutexSystemStatus);
|
||||
|
||||
// parse the received nmea strings here
|
||||
if (0 == strncmp(data, "$PQWM1", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
if (0 == strncmp(data, "$PQWM1", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
SystemStatusPQWM1 s = SystemStatusPQWM1parser(buf, len).get();
|
||||
setIteminReport(mCache.mTimeAndClock, SystemStatusTimeAndClock(s));
|
||||
setIteminReport(mCache.mXoState, SystemStatusXoState(s));
|
||||
setIteminReport(mCache.mRfAndParams, SystemStatusRfAndParams(s));
|
||||
setIteminReport(mCache.mErrRecovery, SystemStatusErrRecovery(s));
|
||||
ret |= setIteminReport(mCache.mTimeAndClock, SystemStatusTimeAndClock(s));
|
||||
ret |= setIteminReport(mCache.mXoState, SystemStatusXoState(s));
|
||||
ret |= setIteminReport(mCache.mRfAndParams, SystemStatusRfAndParams(s));
|
||||
ret |= setIteminReport(mCache.mErrRecovery, SystemStatusErrRecovery(s));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP1", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
setIteminReport(mCache.mInjectedPosition,
|
||||
ret = setIteminReport(mCache.mInjectedPosition,
|
||||
SystemStatusInjectedPosition(SystemStatusPQWP1parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP2", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
setIteminReport(mCache.mBestPosition,
|
||||
ret = setIteminReport(mCache.mBestPosition,
|
||||
SystemStatusBestPosition(SystemStatusPQWP2parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP3", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
setIteminReport(mCache.mXtra,
|
||||
ret = setIteminReport(mCache.mXtra,
|
||||
SystemStatusXtra(SystemStatusPQWP3parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP4", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
setIteminReport(mCache.mEphemeris,
|
||||
ret = setIteminReport(mCache.mEphemeris,
|
||||
SystemStatusEphemeris(SystemStatusPQWP4parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP5", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
setIteminReport(mCache.mSvHealth,
|
||||
ret = setIteminReport(mCache.mSvHealth,
|
||||
SystemStatusSvHealth(SystemStatusPQWP5parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP6", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
setIteminReport(mCache.mPdr,
|
||||
ret = setIteminReport(mCache.mPdr,
|
||||
SystemStatusPdr(SystemStatusPQWP6parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWP7", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
setIteminReport(mCache.mNavData,
|
||||
ret = setIteminReport(mCache.mNavData,
|
||||
SystemStatusNavData(SystemStatusPQWP7parser(buf, len).get()));
|
||||
}
|
||||
else if (0 == strncmp(data, "$PQWS1", SystemStatusNmeaBase::NMEA_MINSIZE)) {
|
||||
setIteminReport(mCache.mPositionFailure,
|
||||
ret = setIteminReport(mCache.mPositionFailure,
|
||||
SystemStatusPositionFailure(SystemStatusPQWS1parser(buf, len).get()));
|
||||
}
|
||||
else {
|
||||
|
@ -1405,7 +1376,7 @@ bool SystemStatus::setNmeaString(const char *data, uint32_t len)
|
|||
}
|
||||
|
||||
pthread_mutex_unlock(&mMutexSystemStatus);
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -1446,92 +1417,94 @@ bool SystemStatus::eventDataItemNotify(IDataItemCore* dataitem)
|
|||
switch(dataitem->getId())
|
||||
{
|
||||
case AIRPLANEMODE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mAirplaneMode,
|
||||
SystemStatusAirplaneMode(*(static_cast<AirplaneModeDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusAirplaneMode>(mCache.mAirplaneMode,
|
||||
*(static_cast<AirplaneModeDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case ENH_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mENH,
|
||||
SystemStatusENH(*(static_cast<ENHDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusENH>(mCache.mENH,
|
||||
*(static_cast<ENHDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case GPSSTATE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mGPSState,
|
||||
SystemStatusGpsState(*(static_cast<GPSStateDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusGpsState>(mCache.mGPSState,
|
||||
*(static_cast<GPSStateDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case NLPSTATUS_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mNLPStatus,
|
||||
SystemStatusNLPStatus(*(static_cast<NLPStatusDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusNLPStatus>(mCache.mNLPStatus,
|
||||
*(static_cast<NLPStatusDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case WIFIHARDWARESTATE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mWifiHardwareState,
|
||||
SystemStatusWifiHardwareState(*(static_cast<WifiHardwareStateDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusWifiHardwareState>(mCache.mWifiHardwareState,
|
||||
*(static_cast<WifiHardwareStateDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case NETWORKINFO_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mNetworkInfo,
|
||||
SystemStatusNetworkInfo(*(static_cast<NetworkInfoDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusNetworkInfo>(mCache.mNetworkInfo,
|
||||
*(static_cast<NetworkInfoDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case RILSERVICEINFO_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mRilServiceInfo,
|
||||
SystemStatusServiceInfo(*(static_cast<RilServiceInfoDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusServiceInfo>(mCache.mRilServiceInfo,
|
||||
*(static_cast<RilServiceInfoDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case RILCELLINFO_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mRilCellInfo,
|
||||
SystemStatusRilCellInfo(*(static_cast<RilCellInfoDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusRilCellInfo>(mCache.mRilCellInfo,
|
||||
*(static_cast<RilCellInfoDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case SERVICESTATUS_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mServiceStatus,
|
||||
SystemStatusServiceStatus(*(static_cast<ServiceStatusDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusServiceStatus>(mCache.mServiceStatus,
|
||||
*(static_cast<ServiceStatusDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case MODEL_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mModel,
|
||||
SystemStatusModel(*(static_cast<ModelDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusModel>(mCache.mModel,
|
||||
*(static_cast<ModelDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case MANUFACTURER_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mManufacturer,
|
||||
SystemStatusManufacturer(*(static_cast<ManufacturerDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusManufacturer>(mCache.mManufacturer,
|
||||
*(static_cast<ManufacturerDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case ASSISTED_GPS_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mAssistedGps,
|
||||
SystemStatusAssistedGps(*(static_cast<AssistedGpsDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusAssistedGps>(mCache.mAssistedGps,
|
||||
*(static_cast<AssistedGpsDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case SCREEN_STATE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mScreenState,
|
||||
SystemStatusScreenState(*(static_cast<ScreenStateDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusScreenState>(mCache.mScreenState,
|
||||
*(static_cast<ScreenStateDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case POWER_CONNECTED_STATE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mPowerConnectState,
|
||||
SystemStatusPowerConnectState(*(static_cast<PowerConnectStateDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusPowerConnectState>(mCache.mPowerConnectState,
|
||||
*(static_cast<PowerConnectStateDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case TIMEZONE_CHANGE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mTimeZoneChange,
|
||||
SystemStatusTimeZoneChange(*(static_cast<TimeZoneChangeDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusTimeZoneChange>(mCache.mTimeZoneChange,
|
||||
*(static_cast<TimeZoneChangeDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case TIME_CHANGE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mTimeChange,
|
||||
SystemStatusTimeChange(*(static_cast<TimeChangeDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusTimeChange>(mCache.mTimeChange,
|
||||
*(static_cast<TimeChangeDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case WIFI_SUPPLICANT_STATUS_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mWifiSupplicantStatus,
|
||||
SystemStatusWifiSupplicantStatus(*(static_cast<WifiSupplicantStatusDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusWifiSupplicantStatus>(
|
||||
mCache.mWifiSupplicantStatus,
|
||||
*(static_cast<WifiSupplicantStatusDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case SHUTDOWN_STATE_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mShutdownState,
|
||||
SystemStatusShutdownState(*(static_cast<ShutdownStateDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusShutdownState>(mCache.mShutdownState,
|
||||
*(static_cast<ShutdownStateDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case TAC_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mTac,
|
||||
SystemStatusTac(*(static_cast<TacDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusTac>(mCache.mTac,
|
||||
*(static_cast<TacDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case MCCMNC_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mMccMnc,
|
||||
SystemStatusMccMnc(*(static_cast<MccmncDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusMccMnc>(mCache.mMccMnc,
|
||||
*(static_cast<MccmncDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case BTLE_SCAN_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mBtDeviceScanDetail,
|
||||
SystemStatusBtDeviceScanDetail(*(static_cast<BtDeviceScanDetailsDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusBtDeviceScanDetail>(mCache.mBtDeviceScanDetail,
|
||||
*(static_cast<BtDeviceScanDetailsDataItemBase*>(dataitem)));
|
||||
break;
|
||||
case BT_SCAN_DATA_ITEM_ID:
|
||||
ret = setIteminReport(mCache.mBtLeDeviceScanDetail,
|
||||
SystemStatusBtleDeviceScanDetail(*(static_cast<BtLeDeviceScanDetailsDataItemBase*>(dataitem))));
|
||||
ret = setItemBaseinReport<SystemStatusBtleDeviceScanDetail>(
|
||||
mCache.mBtLeDeviceScanDetail,
|
||||
*(static_cast<BtLeDeviceScanDetailsDataItemBase*>(dataitem)));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1650,7 +1623,7 @@ bool SystemStatus::getReport(SystemStatusReports& report, bool isLatestOnly) con
|
|||
|
||||
@return true when successfully done
|
||||
******************************************************************************/
|
||||
bool SystemStatus::setDefaultGnssEngineStates(void)
|
||||
bool SystemStatus::setDefaultReport(void)
|
||||
{
|
||||
pthread_mutex_lock(&mMutexSystemStatus);
|
||||
|
||||
|
@ -1671,6 +1644,29 @@ bool SystemStatus::setDefaultGnssEngineStates(void)
|
|||
|
||||
setDefaultIteminReport(mCache.mPositionFailure, SystemStatusPositionFailure());
|
||||
|
||||
setDefaultIteminReport(mCache.mAirplaneMode, SystemStatusAirplaneMode());
|
||||
setDefaultIteminReport(mCache.mENH, SystemStatusENH());
|
||||
setDefaultIteminReport(mCache.mGPSState, SystemStatusGpsState());
|
||||
setDefaultIteminReport(mCache.mNLPStatus, SystemStatusNLPStatus());
|
||||
setDefaultIteminReport(mCache.mWifiHardwareState, SystemStatusWifiHardwareState());
|
||||
setDefaultIteminReport(mCache.mNetworkInfo, SystemStatusNetworkInfo());
|
||||
setDefaultIteminReport(mCache.mRilServiceInfo, SystemStatusServiceInfo());
|
||||
setDefaultIteminReport(mCache.mRilCellInfo, SystemStatusRilCellInfo());
|
||||
setDefaultIteminReport(mCache.mServiceStatus, SystemStatusServiceStatus());
|
||||
setDefaultIteminReport(mCache.mModel, SystemStatusModel());
|
||||
setDefaultIteminReport(mCache.mManufacturer, SystemStatusManufacturer());
|
||||
setDefaultIteminReport(mCache.mAssistedGps, SystemStatusAssistedGps());
|
||||
setDefaultIteminReport(mCache.mScreenState, SystemStatusScreenState());
|
||||
setDefaultIteminReport(mCache.mPowerConnectState, SystemStatusPowerConnectState());
|
||||
setDefaultIteminReport(mCache.mTimeZoneChange, SystemStatusTimeZoneChange());
|
||||
setDefaultIteminReport(mCache.mTimeChange, SystemStatusTimeChange());
|
||||
setDefaultIteminReport(mCache.mWifiSupplicantStatus, SystemStatusWifiSupplicantStatus());
|
||||
setDefaultIteminReport(mCache.mShutdownState, SystemStatusShutdownState());
|
||||
setDefaultIteminReport(mCache.mTac, SystemStatusTac());
|
||||
setDefaultIteminReport(mCache.mMccMnc, SystemStatusMccMnc());
|
||||
setDefaultIteminReport(mCache.mBtDeviceScanDetail, SystemStatusBtDeviceScanDetail());
|
||||
setDefaultIteminReport(mCache.mBtLeDeviceScanDetail, SystemStatusBtleDeviceScanDetail());
|
||||
|
||||
pthread_mutex_unlock(&mMutexSystemStatus);
|
||||
return true;
|
||||
}
|
||||
|
@ -1682,12 +1678,17 @@ bool SystemStatus::setDefaultGnssEngineStates(void)
|
|||
|
||||
@return true when successfully done
|
||||
******************************************************************************/
|
||||
bool SystemStatus::eventConnectionStatus(bool connected, int8_t type)
|
||||
bool SystemStatus::eventConnectionStatus(bool connected, uint8_t type)
|
||||
{
|
||||
// send networkinof dataitem to systemstatus observer clients
|
||||
SystemStatusNetworkInfo s(type, "", "", connected);
|
||||
mSysStatusObsvr.notify({&s});
|
||||
if (connected != mConnected) {
|
||||
mConnected = connected;
|
||||
|
||||
// send networkinof dataitem to systemstatus observer clients
|
||||
SystemStatusNetworkInfo s(type, "", "", false, connected, false);
|
||||
list<IDataItemCore*> dl(0);
|
||||
dl.push_back(&s);
|
||||
mSysStatusObsvr.notify(dl);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
91
gps/core/SystemStatus.h
Executable file → Normal file
91
gps/core/SystemStatus.h
Executable file → Normal file
|
@ -30,10 +30,9 @@
|
|||
#define __SYSTEM_STATUS__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <MsgTask.h>
|
||||
#include <IDataItemCore.h>
|
||||
#include <IOsObserver.h>
|
||||
|
@ -71,17 +70,14 @@ public:
|
|||
static const uint32_t maxItem = 5;
|
||||
|
||||
SystemStatusItemBase() {
|
||||
struct timespec tv;
|
||||
clock_gettime(CLOCK_MONOTONIC, &tv);
|
||||
timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
mUtcTime.tv_sec = tv.tv_sec;
|
||||
mUtcTime.tv_nsec = tv.tv_nsec;
|
||||
mUtcTime.tv_nsec = tv.tv_usec *1000ULL;
|
||||
mUtcReported = mUtcTime;
|
||||
};
|
||||
virtual ~SystemStatusItemBase() {};
|
||||
inline virtual SystemStatusItemBase& collate(SystemStatusItemBase&) {
|
||||
return *this;
|
||||
}
|
||||
virtual void dump(void) {};
|
||||
virtual ~SystemStatusItemBase() { };
|
||||
virtual void dump(void) { };
|
||||
};
|
||||
|
||||
class SystemStatusLocation : public SystemStatusItemBase
|
||||
|
@ -96,7 +92,7 @@ public:
|
|||
const GpsLocationExtended& locationEx) :
|
||||
mValid(true),
|
||||
mLocation(location),
|
||||
mLocationEx(locationEx) {}
|
||||
mLocationEx(locationEx) { }
|
||||
bool equals(const SystemStatusLocation& peer);
|
||||
void dump(void);
|
||||
};
|
||||
|
@ -156,12 +152,6 @@ public:
|
|||
double mAgcGlo;
|
||||
double mAgcBds;
|
||||
double mAgcGal;
|
||||
uint32_t mGloBpAmpI;
|
||||
uint32_t mGloBpAmpQ;
|
||||
uint32_t mBdsBpAmpI;
|
||||
uint32_t mBdsBpAmpQ;
|
||||
uint32_t mGalBpAmpI;
|
||||
uint32_t mGalBpAmpQ;
|
||||
inline SystemStatusRfAndParams() :
|
||||
mPgaGain(0),
|
||||
mGpsBpAmpI(0),
|
||||
|
@ -175,13 +165,7 @@ public:
|
|||
mAgcGps(0),
|
||||
mAgcGlo(0),
|
||||
mAgcBds(0),
|
||||
mAgcGal(0),
|
||||
mGloBpAmpI(0),
|
||||
mGloBpAmpQ(0),
|
||||
mBdsBpAmpI(0),
|
||||
mBdsBpAmpQ(0),
|
||||
mGalBpAmpI(0),
|
||||
mGalBpAmpQ(0) {}
|
||||
mAgcGal(0) {}
|
||||
inline SystemStatusRfAndParams(const SystemStatusPQWM1& nmea);
|
||||
bool equals(const SystemStatusRfAndParams& peer);
|
||||
void dump(void);
|
||||
|
@ -460,49 +444,38 @@ public:
|
|||
class SystemStatusNetworkInfo : public SystemStatusItemBase,
|
||||
public NetworkInfoDataItemBase
|
||||
{
|
||||
NetworkInfoDataItemBase* mSrcObjPtr;
|
||||
public:
|
||||
inline SystemStatusNetworkInfo(
|
||||
int32_t type=0,
|
||||
std::string typeName="",
|
||||
string subTypeName="",
|
||||
bool available=false,
|
||||
bool connected=false,
|
||||
bool roaming=false) :
|
||||
NetworkInfoDataItemBase(
|
||||
(NetworkType)type,
|
||||
type,
|
||||
typeName,
|
||||
subTypeName,
|
||||
connected && (!roaming),
|
||||
available,
|
||||
connected,
|
||||
roaming),
|
||||
mSrcObjPtr(nullptr) {}
|
||||
roaming) {}
|
||||
inline SystemStatusNetworkInfo(const NetworkInfoDataItemBase& itemBase) :
|
||||
NetworkInfoDataItemBase(itemBase),
|
||||
mSrcObjPtr((NetworkInfoDataItemBase*)&itemBase) {
|
||||
NetworkInfoDataItemBase(itemBase) {
|
||||
mType = itemBase.getType();
|
||||
}
|
||||
inline bool equals(const SystemStatusNetworkInfo& peer) {
|
||||
return (mAllTypes == peer.mAllTypes);
|
||||
}
|
||||
inline virtual SystemStatusItemBase& collate(SystemStatusItemBase& curInfo) {
|
||||
uint64_t allTypes = (static_cast<SystemStatusNetworkInfo&>(curInfo)).mAllTypes;
|
||||
if (mConnected) {
|
||||
mAllTypes |= allTypes;
|
||||
} else if (0 != mAllTypes) {
|
||||
mAllTypes = (allTypes & (~mAllTypes));
|
||||
} // else (mConnected == false && mAllTypes == 0)
|
||||
// we keep mAllTypes as 0, which means no more connections.
|
||||
|
||||
if (nullptr != mSrcObjPtr) {
|
||||
// this is critical, changing mAllTypes of the original obj
|
||||
mSrcObjPtr->mAllTypes = mAllTypes;
|
||||
if ((mType == peer.mType) &&
|
||||
(mTypeName == peer.mTypeName) &&
|
||||
(mSubTypeName == peer.mSubTypeName) &&
|
||||
(mAvailable == peer.mAvailable) &&
|
||||
(mConnected == peer.mConnected) &&
|
||||
(mRoaming == peer.mRoaming)) {
|
||||
return true;
|
||||
}
|
||||
return *this;
|
||||
return false;
|
||||
}
|
||||
inline void dump(void) override {
|
||||
LOC_LOGD("NetworkInfo: mAllTypes=%" PRIx64 " connected=%u mType=%x",
|
||||
mAllTypes, mConnected, mType);
|
||||
LOC_LOGD("NetworkInfo: type=%u connected=%u", mType, mConnected);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -514,9 +487,8 @@ public:
|
|||
RilServiceInfoDataItemBase() {}
|
||||
inline SystemStatusServiceInfo(const RilServiceInfoDataItemBase& itemBase) :
|
||||
RilServiceInfoDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusServiceInfo& peer) {
|
||||
return static_cast<const RilServiceInfoDataItemBase&>(peer) ==
|
||||
static_cast<const RilServiceInfoDataItemBase&>(*this);
|
||||
inline bool equals(const SystemStatusServiceInfo& /*peer*/) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -528,9 +500,8 @@ public:
|
|||
RilCellInfoDataItemBase() {}
|
||||
inline SystemStatusRilCellInfo(const RilCellInfoDataItemBase& itemBase) :
|
||||
RilCellInfoDataItemBase(itemBase) {}
|
||||
inline bool equals(const SystemStatusRilCellInfo& peer) {
|
||||
return static_cast<const RilCellInfoDataItemBase&>(peer) ==
|
||||
static_cast<const RilCellInfoDataItemBase&>(*this);
|
||||
inline bool equals(const SystemStatusRilCellInfo& /*peer*/) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -799,9 +770,13 @@ private:
|
|||
// Data members
|
||||
static pthread_mutex_t mMutexSystemStatus;
|
||||
SystemStatusReports mCache;
|
||||
bool mConnected;
|
||||
|
||||
template <typename TYPE_SYSTEMSTATUS_ITEM, typename TYPE_REPORT, typename TYPE_ITEMBASE>
|
||||
bool setItemBaseinReport(TYPE_REPORT& report, const TYPE_ITEMBASE& s);
|
||||
|
||||
template <typename TYPE_REPORT, typename TYPE_ITEM>
|
||||
bool setIteminReport(TYPE_REPORT& report, TYPE_ITEM&& s);
|
||||
bool setIteminReport(TYPE_REPORT& report, const TYPE_ITEM& s);
|
||||
|
||||
// set default dataitem derived item in report cache
|
||||
template <typename TYPE_REPORT, typename TYPE_ITEM>
|
||||
|
@ -821,8 +796,8 @@ public:
|
|||
bool eventDataItemNotify(IDataItemCore* dataitem);
|
||||
bool setNmeaString(const char *data, uint32_t len);
|
||||
bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const;
|
||||
bool setDefaultGnssEngineStates(void);
|
||||
bool eventConnectionStatus(bool connected, int8_t type);
|
||||
bool setDefaultReport(void);
|
||||
bool eventConnectionStatus(bool connected, uint8_t type);
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
|
676
gps/core/SystemStatusOsObserver.cpp
Executable file → Normal file
676
gps/core/SystemStatusOsObserver.cpp
Executable file → Normal file
|
@ -32,20 +32,25 @@
|
|||
#include <SystemStatus.h>
|
||||
#include <SystemStatusOsObserver.h>
|
||||
#include <IDataItemCore.h>
|
||||
#include <IClientIndex.h>
|
||||
#include <IDataItemIndex.h>
|
||||
#include <IndexFactory.h>
|
||||
#include <DataItemsFactoryProxy.h>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
template <typename CINT, typename COUT>
|
||||
COUT SystemStatusOsObserver::containerTransfer(CINT& inContainer) {
|
||||
COUT outContainer(0);
|
||||
for (auto item : inContainer) {
|
||||
outContainer.insert(outContainer.begin(), item);
|
||||
}
|
||||
return outContainer;
|
||||
SystemStatusOsObserver::SystemStatusOsObserver(
|
||||
SystemStatus* systemstatus, const MsgTask* msgTask) :
|
||||
mSystemStatus(systemstatus),
|
||||
mAddress("SystemStatusOsObserver"),
|
||||
mClientIndex(IndexFactory<IDataItemObserver*, DataItemId> :: createClientIndex()),
|
||||
mDataItemIndex(IndexFactory<IDataItemObserver*, DataItemId> :: createDataItemIndex())
|
||||
{
|
||||
mContext.mMsgTask = msgTask;
|
||||
}
|
||||
|
||||
SystemStatusOsObserver::~SystemStatusOsObserver() {
|
||||
SystemStatusOsObserver::~SystemStatusOsObserver()
|
||||
{
|
||||
// Close data-item library handle
|
||||
DataItemsFactoryProxy::closeDataItemLibraryHandle();
|
||||
|
||||
|
@ -57,238 +62,290 @@ SystemStatusOsObserver::~SystemStatusOsObserver() {
|
|||
}
|
||||
|
||||
mDataItemCache.clear();
|
||||
delete mClientIndex;
|
||||
delete mDataItemIndex;
|
||||
}
|
||||
|
||||
void SystemStatusOsObserver::setSubscriptionObj(IDataItemSubscription* subscriptionObj)
|
||||
{
|
||||
struct SetSubsObj : public LocMsg {
|
||||
ObserverContext& mContext;
|
||||
IDataItemSubscription* mSubsObj;
|
||||
inline SetSubsObj(ObserverContext& context, IDataItemSubscription* subscriptionObj) :
|
||||
mContext(context), mSubsObj(subscriptionObj) {}
|
||||
void proc() const {
|
||||
mContext.mSubscriptionObj = mSubsObj;
|
||||
mContext.mSubscriptionObj = subscriptionObj;
|
||||
|
||||
if (!mContext.mSSObserver->mDataItemToClients.empty()) {
|
||||
list<DataItemId> dis(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
mContext.mSSObserver->mDataItemToClients.getKeys()));
|
||||
mContext.mSubscriptionObj->subscribe(dis, mContext.mSSObserver);
|
||||
mContext.mSubscriptionObj->requestData(dis, mContext.mSSObserver);
|
||||
}
|
||||
LOC_LOGD("Request cache size - Subscribe:%zu RequestData:%zu",
|
||||
mSubscribeReqCache.size(), mReqDataCache.size());
|
||||
|
||||
// we have received the subscription object. process cached requests
|
||||
// process - subscribe request cache
|
||||
for (auto each : mSubscribeReqCache) {
|
||||
subscribe(each.second, each.first);
|
||||
}
|
||||
// process - requestData request cache
|
||||
for (auto each : mReqDataCache) {
|
||||
requestData(each.second, each.first);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to cache requests subscribe and requestData till subscription obj is obtained
|
||||
void SystemStatusOsObserver::cacheObserverRequest(ObserverReqCache& reqCache,
|
||||
const list<DataItemId>& l, IDataItemObserver* client)
|
||||
{
|
||||
ObserverReqCache::iterator dicIter = reqCache.find(client);
|
||||
if (dicIter != reqCache.end()) {
|
||||
// found
|
||||
list<DataItemId> difference(0);
|
||||
set_difference(l.begin(), l.end(),
|
||||
dicIter->second.begin(), dicIter->second.end(),
|
||||
inserter(difference, difference.begin()));
|
||||
if (!difference.empty()) {
|
||||
difference.sort();
|
||||
dicIter->second.merge(difference);
|
||||
dicIter->second.unique();
|
||||
}
|
||||
};
|
||||
|
||||
if (nullptr == subscriptionObj) {
|
||||
LOC_LOGw("subscriptionObj is NULL");
|
||||
} else {
|
||||
mContext.mMsgTask->sendMsg(new SetSubsObj(mContext, subscriptionObj));
|
||||
}
|
||||
else {
|
||||
// not found
|
||||
reqCache[client] = l;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
IDataItemSubscription Overrides
|
||||
******************************************************************************/
|
||||
void SystemStatusOsObserver::subscribe(const list<DataItemId>& l, IDataItemObserver* client,
|
||||
bool toRequestData)
|
||||
void SystemStatusOsObserver::subscribe(
|
||||
const list<DataItemId>& l, IDataItemObserver* client)
|
||||
{
|
||||
if (nullptr == mContext.mSubscriptionObj) {
|
||||
LOC_LOGD("%s]: Subscription object is NULL. Caching requests", __func__);
|
||||
cacheObserverRequest(mSubscribeReqCache, l, client);
|
||||
return;
|
||||
}
|
||||
|
||||
struct HandleSubscribeReq : public LocMsg {
|
||||
inline HandleSubscribeReq(SystemStatusOsObserver* parent,
|
||||
list<DataItemId>& l, IDataItemObserver* client, bool requestData) :
|
||||
mParent(parent), mClient(client),
|
||||
mDataItemSet(containerTransfer<list<DataItemId>, unordered_set<DataItemId>>(l)),
|
||||
mToRequestData(requestData) {}
|
||||
|
||||
HandleSubscribeReq(SystemStatusOsObserver* parent,
|
||||
const list<DataItemId>& l, IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client), mDataItemList(l) {}
|
||||
virtual ~HandleSubscribeReq() {}
|
||||
void proc() const {
|
||||
unordered_set<DataItemId> dataItemsToSubscribe(0);
|
||||
mParent->mDataItemToClients.add(mDataItemSet, {mClient}, &dataItemsToSubscribe);
|
||||
mParent->mClientToDataItems.add(mClient, mDataItemSet);
|
||||
|
||||
mParent->sendCachedDataItems(mDataItemSet, mClient);
|
||||
if (mDataItemList.empty()) {
|
||||
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
// Send subscription set to framework
|
||||
if (nullptr != mParent->mContext.mSubscriptionObj && !dataItemsToSubscribe.empty()) {
|
||||
// Handle First Response
|
||||
list<DataItemId> pendingFirstResponseList(0);
|
||||
mParent->mClientIndex->add(mClient, mDataItemList, pendingFirstResponseList);
|
||||
|
||||
// Do not send first response for only pendingFirstResponseList,
|
||||
// instead send for all the data items (present in the cache) that
|
||||
// have been subscribed for each time.
|
||||
mParent->sendFirstResponse(mDataItemList, mClient);
|
||||
|
||||
list<DataItemId> yetToSubscribeDataItemsList(0);
|
||||
mParent->mDataItemIndex->add(mClient, mDataItemList, yetToSubscribeDataItemsList);
|
||||
|
||||
// Send subscription list to framework
|
||||
if (!yetToSubscribeDataItemsList.empty()) {
|
||||
mParent->mContext.mSubscriptionObj->subscribe(yetToSubscribeDataItemsList, mParent);
|
||||
LOC_LOGD("Subscribe Request sent to framework for the following");
|
||||
mParent->logMe(dataItemsToSubscribe);
|
||||
|
||||
if (mToRequestData) {
|
||||
mParent->mContext.mSubscriptionObj->requestData(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
std::move(dataItemsToSubscribe)),
|
||||
mParent);
|
||||
} else {
|
||||
mParent->mContext.mSubscriptionObj->subscribe(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
std::move(dataItemsToSubscribe)),
|
||||
mParent);
|
||||
}
|
||||
mParent->logMe(yetToSubscribeDataItemsList);
|
||||
}
|
||||
}
|
||||
mutable SystemStatusOsObserver* mParent;
|
||||
SystemStatusOsObserver* mParent;
|
||||
IDataItemObserver* mClient;
|
||||
const unordered_set<DataItemId> mDataItemSet;
|
||||
bool mToRequestData;
|
||||
const list<DataItemId> mDataItemList;
|
||||
};
|
||||
|
||||
if (l.empty() || nullptr == client) {
|
||||
LOC_LOGw("Data item set is empty or client is nullptr");
|
||||
} else {
|
||||
mContext.mMsgTask->sendMsg(
|
||||
new HandleSubscribeReq(this, (list<DataItemId>&)l, client, toRequestData));
|
||||
}
|
||||
mContext.mMsgTask->sendMsg(new (nothrow) HandleSubscribeReq(this, l, client));
|
||||
}
|
||||
|
||||
void SystemStatusOsObserver::updateSubscription(
|
||||
const list<DataItemId>& l, IDataItemObserver* client)
|
||||
{
|
||||
if (nullptr == mContext.mSubscriptionObj) {
|
||||
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
struct HandleUpdateSubscriptionReq : public LocMsg {
|
||||
HandleUpdateSubscriptionReq(SystemStatusOsObserver* parent,
|
||||
list<DataItemId>& l, IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client),
|
||||
mDataItemSet(containerTransfer<list<DataItemId>, unordered_set<DataItemId>>(l)) {}
|
||||
|
||||
const list<DataItemId>& l, IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client), mDataItemList(l) {}
|
||||
virtual ~HandleUpdateSubscriptionReq() {}
|
||||
void proc() const {
|
||||
unordered_set<DataItemId> dataItemsToSubscribe(0);
|
||||
unordered_set<DataItemId> dataItemsToUnsubscribe(0);
|
||||
unordered_set<IDataItemObserver*> clients({mClient});
|
||||
// below removes clients from all entries keyed with the return of the
|
||||
// mClientToDataItems.update() call. If leaving an empty set of clients as the
|
||||
// result, the entire entry will be removed. dataItemsToUnsubscribe will be
|
||||
// populated to keep the keys of the removed entries.
|
||||
mParent->mDataItemToClients.trimOrRemove(
|
||||
// this call updates <IDataItemObserver*, DataItemId> map; removes
|
||||
// the DataItemId's that are not new to the clietn from mDataItemSet;
|
||||
// and returns a set of mDataItemSet's that are no longer used by client.
|
||||
// This unused set of mDataItemSet's is passed to trimOrRemove method of
|
||||
// <DataItemId, IDataItemObserver*> map to remove the client from the
|
||||
// corresponding entries, and gets a set of the entries that are
|
||||
// removed from the <DataItemId, IDataItemObserver*> map as a result.
|
||||
mParent->mClientToDataItems.update(mClient,
|
||||
(unordered_set<DataItemId>&)mDataItemSet),
|
||||
clients, &dataItemsToUnsubscribe, nullptr);
|
||||
// below adds mClient to <DataItemId, IDataItemObserver*> map, and populates
|
||||
// new keys added to that map, which are DataItemIds to be subscribed.
|
||||
mParent->mDataItemToClients.add(mDataItemSet, clients, &dataItemsToSubscribe);
|
||||
if (mDataItemList.empty()) {
|
||||
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
list<DataItemId> currentlySubscribedList(0);
|
||||
mParent->mClientIndex->getSubscribedList(mClient, currentlySubscribedList);
|
||||
|
||||
list<DataItemId> removeDataItemList(0);
|
||||
set_difference(currentlySubscribedList.begin(), currentlySubscribedList.end(),
|
||||
mDataItemList.begin(), mDataItemList.end(),
|
||||
inserter(removeDataItemList,removeDataItemList.begin()));
|
||||
|
||||
// Handle First Response
|
||||
list<DataItemId> pendingFirstResponseList(0);
|
||||
mParent->mClientIndex->add(mClient, mDataItemList, pendingFirstResponseList);
|
||||
|
||||
// Send First Response
|
||||
mParent->sendCachedDataItems(mDataItemSet, mClient);
|
||||
mParent->sendFirstResponse(pendingFirstResponseList, mClient);
|
||||
|
||||
if (nullptr != mParent->mContext.mSubscriptionObj) {
|
||||
// Send subscription set to framework
|
||||
if (!dataItemsToSubscribe.empty()) {
|
||||
LOC_LOGD("Subscribe Request sent to framework for the following");
|
||||
mParent->logMe(dataItemsToSubscribe);
|
||||
list<DataItemId> yetToSubscribeDataItemsList(0);
|
||||
mParent->mDataItemIndex->add(
|
||||
mClient, mDataItemList, yetToSubscribeDataItemsList);
|
||||
|
||||
mParent->mContext.mSubscriptionObj->subscribe(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
std::move(dataItemsToSubscribe)),
|
||||
mParent);
|
||||
}
|
||||
// Send subscription list to framework
|
||||
if (!yetToSubscribeDataItemsList.empty()) {
|
||||
mParent->mContext.mSubscriptionObj->subscribe(
|
||||
yetToSubscribeDataItemsList, mParent);
|
||||
LOC_LOGD("Subscribe Request sent to framework for the following");
|
||||
mParent->logMe(yetToSubscribeDataItemsList);
|
||||
}
|
||||
|
||||
list<DataItemId> unsubscribeList(0);
|
||||
list<DataItemId> unused(0);
|
||||
mParent->mClientIndex->remove(mClient, removeDataItemList, unused);
|
||||
|
||||
if (!mParent->mClientIndex->isSubscribedClient(mClient)) {
|
||||
mParent->mDataItemIndex->remove(
|
||||
list<IDataItemObserver*> (1,mClient), unsubscribeList);
|
||||
}
|
||||
if (!unsubscribeList.empty()) {
|
||||
// Send unsubscribe to framework
|
||||
if (!dataItemsToUnsubscribe.empty()) {
|
||||
LOC_LOGD("Unsubscribe Request sent to framework for the following");
|
||||
mParent->logMe(dataItemsToUnsubscribe);
|
||||
|
||||
mParent->mContext.mSubscriptionObj->unsubscribe(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
std::move(dataItemsToUnsubscribe)),
|
||||
mParent);
|
||||
}
|
||||
mParent->mContext.mSubscriptionObj->unsubscribe(unsubscribeList, mParent);
|
||||
LOC_LOGD("Unsubscribe Request sent to framework for the following");
|
||||
mParent->logMe(unsubscribeList);
|
||||
}
|
||||
}
|
||||
SystemStatusOsObserver* mParent;
|
||||
IDataItemObserver* mClient;
|
||||
unordered_set<DataItemId> mDataItemSet;
|
||||
const list<DataItemId> mDataItemList;
|
||||
};
|
||||
mContext.mMsgTask->sendMsg(new (nothrow) HandleUpdateSubscriptionReq(this, l, client));
|
||||
}
|
||||
|
||||
if (l.empty() || nullptr == client) {
|
||||
LOC_LOGw("Data item set is empty or client is nullptr");
|
||||
} else {
|
||||
mContext.mMsgTask->sendMsg(
|
||||
new HandleUpdateSubscriptionReq(this, (list<DataItemId>&)l, client));
|
||||
void SystemStatusOsObserver::requestData(
|
||||
const list<DataItemId>& l, IDataItemObserver* client)
|
||||
{
|
||||
if (nullptr == mContext.mSubscriptionObj) {
|
||||
LOC_LOGD("%s]: Subscription object is NULL. Caching requests", __func__);
|
||||
cacheObserverRequest(mReqDataCache, l, client);
|
||||
return;
|
||||
}
|
||||
|
||||
struct HandleRequestData : public LocMsg {
|
||||
HandleRequestData(SystemStatusOsObserver* parent,
|
||||
const list<DataItemId>& l, IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client), mDataItemList(l) {}
|
||||
virtual ~HandleRequestData() {}
|
||||
void proc() const {
|
||||
if (mDataItemList.empty()) {
|
||||
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
list<DataItemId> yetToSubscribeDataItemsList(0);
|
||||
mParent->mClientIndex->add(
|
||||
mClient, mDataItemList, yetToSubscribeDataItemsList);
|
||||
mParent->mDataItemIndex->add(
|
||||
mClient, mDataItemList, yetToSubscribeDataItemsList);
|
||||
|
||||
// Send subscription list to framework
|
||||
if (!mDataItemList.empty()) {
|
||||
mParent->mContext.mSubscriptionObj->requestData(mDataItemList, mParent);
|
||||
LOC_LOGD("Subscribe Request sent to framework for the following");
|
||||
mParent->logMe(yetToSubscribeDataItemsList);
|
||||
}
|
||||
}
|
||||
SystemStatusOsObserver* mParent;
|
||||
IDataItemObserver* mClient;
|
||||
const list<DataItemId> mDataItemList;
|
||||
};
|
||||
mContext.mMsgTask->sendMsg(new (nothrow) HandleRequestData(this, l, client));
|
||||
}
|
||||
|
||||
void SystemStatusOsObserver::unsubscribe(
|
||||
const list<DataItemId>& l, IDataItemObserver* client)
|
||||
{
|
||||
if (nullptr == mContext.mSubscriptionObj) {
|
||||
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
|
||||
return;
|
||||
}
|
||||
struct HandleUnsubscribeReq : public LocMsg {
|
||||
HandleUnsubscribeReq(SystemStatusOsObserver* parent,
|
||||
list<DataItemId>& l, IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client),
|
||||
mDataItemSet(containerTransfer<list<DataItemId>, unordered_set<DataItemId>>(l)) {}
|
||||
|
||||
const list<DataItemId>& l, IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client), mDataItemList(l) {}
|
||||
virtual ~HandleUnsubscribeReq() {}
|
||||
void proc() const {
|
||||
unordered_set<DataItemId> dataItemsUnusedByClient(0);
|
||||
unordered_set<IDataItemObserver*> clientToRemove(0);
|
||||
mParent->mClientToDataItems.trimOrRemove({mClient}, mDataItemSet, &clientToRemove,
|
||||
&dataItemsUnusedByClient);
|
||||
unordered_set<DataItemId> dataItemsToUnsubscribe(0);
|
||||
mParent->mDataItemToClients.trimOrRemove(dataItemsUnusedByClient, {mClient},
|
||||
&dataItemsToUnsubscribe, nullptr);
|
||||
if (mDataItemList.empty()) {
|
||||
LOC_LOGV("mDataItemList is empty. Nothing to do. Exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nullptr != mParent->mContext.mSubscriptionObj && !dataItemsToUnsubscribe.empty()) {
|
||||
LOC_LOGD("Unsubscribe Request sent to framework for the following data items");
|
||||
mParent->logMe(dataItemsToUnsubscribe);
|
||||
list<DataItemId> unsubscribeList(0);
|
||||
list<DataItemId> unused(0);
|
||||
mParent->mClientIndex->remove(mClient, mDataItemList, unused);
|
||||
|
||||
for (auto each : mDataItemList) {
|
||||
list<IDataItemObserver*> clientListSubs(0);
|
||||
list<IDataItemObserver*> clientListOut(0);
|
||||
mParent->mDataItemIndex->remove(
|
||||
each, list<IDataItemObserver*> (1,mClient), clientListOut);
|
||||
// check if there are any other subscribed client for this data item id
|
||||
mParent->mDataItemIndex->getListOfSubscribedClients(each, clientListSubs);
|
||||
if (clientListSubs.empty())
|
||||
{
|
||||
LOC_LOGD("Client list subscribed is empty for dataitem - %d", each);
|
||||
unsubscribeList.push_back(each);
|
||||
}
|
||||
}
|
||||
|
||||
if (!unsubscribeList.empty()) {
|
||||
// Send unsubscribe to framework
|
||||
mParent->mContext.mSubscriptionObj->unsubscribe(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
std::move(dataItemsToUnsubscribe)),
|
||||
mParent);
|
||||
mParent->mContext.mSubscriptionObj->unsubscribe(unsubscribeList, mParent);
|
||||
LOC_LOGD("Unsubscribe Request sent to framework for the following data items");
|
||||
mParent->logMe(unsubscribeList);
|
||||
}
|
||||
}
|
||||
SystemStatusOsObserver* mParent;
|
||||
IDataItemObserver* mClient;
|
||||
unordered_set<DataItemId> mDataItemSet;
|
||||
const list<DataItemId> mDataItemList;
|
||||
};
|
||||
|
||||
if (l.empty() || nullptr == client) {
|
||||
LOC_LOGw("Data item set is empty or client is nullptr");
|
||||
} else {
|
||||
mContext.mMsgTask->sendMsg(new HandleUnsubscribeReq(this, (list<DataItemId>&)l, client));
|
||||
}
|
||||
mContext.mMsgTask->sendMsg(new (nothrow) HandleUnsubscribeReq(this, l, client));
|
||||
}
|
||||
|
||||
void SystemStatusOsObserver::unsubscribeAll(IDataItemObserver* client)
|
||||
{
|
||||
if (nullptr == mContext.mSubscriptionObj) {
|
||||
LOC_LOGE("%s:%d]: Subscription object is NULL", __func__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
struct HandleUnsubscribeAllReq : public LocMsg {
|
||||
HandleUnsubscribeAllReq(SystemStatusOsObserver* parent,
|
||||
IDataItemObserver* client) :
|
||||
mParent(parent), mClient(client) {}
|
||||
|
||||
virtual ~HandleUnsubscribeAllReq() {}
|
||||
void proc() const {
|
||||
unordered_set<DataItemId> diByClient = mParent->mClientToDataItems.getValSet(mClient);
|
||||
if (!diByClient.empty()) {
|
||||
unordered_set<DataItemId> dataItemsToUnsubscribe;
|
||||
mParent->mClientToDataItems.remove(mClient);
|
||||
mParent->mDataItemToClients.trimOrRemove(diByClient, {mClient},
|
||||
&dataItemsToUnsubscribe, nullptr);
|
||||
list<IDataItemObserver*> clients(1, mClient);
|
||||
list<DataItemId> unsubscribeList(0);
|
||||
if(0 == mParent->mClientIndex->remove(mClient)) {
|
||||
return;
|
||||
}
|
||||
mParent->mDataItemIndex->remove(clients, unsubscribeList);
|
||||
|
||||
if (!dataItemsToUnsubscribe.empty() &&
|
||||
nullptr != mParent->mContext.mSubscriptionObj) {
|
||||
|
||||
LOC_LOGD("Unsubscribe Request sent to framework for the following data items");
|
||||
mParent->logMe(dataItemsToUnsubscribe);
|
||||
|
||||
// Send unsubscribe to framework
|
||||
mParent->mContext.mSubscriptionObj->unsubscribe(
|
||||
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
|
||||
std::move(dataItemsToUnsubscribe)),
|
||||
mParent);
|
||||
}
|
||||
if (!unsubscribeList.empty()) {
|
||||
// Send unsubscribe to framework
|
||||
mParent->mContext.mSubscriptionObj->unsubscribe(unsubscribeList, mParent);
|
||||
LOC_LOGD("Unsubscribe Request sent to framework for the following data items");
|
||||
mParent->logMe(unsubscribeList);
|
||||
}
|
||||
}
|
||||
SystemStatusOsObserver* mParent;
|
||||
IDataItemObserver* mClient;
|
||||
};
|
||||
|
||||
if (nullptr == client) {
|
||||
LOC_LOGw("Data item set is empty or client is nullptr");
|
||||
} else {
|
||||
mContext.mMsgTask->sendMsg(new HandleUnsubscribeAllReq(this, client));
|
||||
}
|
||||
mContext.mMsgTask->sendMsg(new (nothrow) HandleUnsubscribeAllReq(this, client));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -296,81 +353,84 @@ void SystemStatusOsObserver::unsubscribeAll(IDataItemObserver* client)
|
|||
******************************************************************************/
|
||||
void SystemStatusOsObserver::notify(const list<IDataItemCore*>& dlist)
|
||||
{
|
||||
struct HandleNotify : public LocMsg {
|
||||
HandleNotify(SystemStatusOsObserver* parent, vector<IDataItemCore*>& v) :
|
||||
mParent(parent), mDiVec(std::move(v)) {}
|
||||
list<IDataItemCore*> dataItemList(0);
|
||||
|
||||
inline virtual ~HandleNotify() {
|
||||
for (auto item : mDiVec) {
|
||||
delete item;
|
||||
}
|
||||
for (auto each : dlist) {
|
||||
string dv;
|
||||
each->stringify(dv);
|
||||
LOC_LOGD("notify: DataItem In Value:%s", dv.c_str());
|
||||
|
||||
IDataItemCore* di = DataItemsFactoryProxy::createNewDataItem(each->getId());
|
||||
if (nullptr == di) {
|
||||
LOC_LOGE("Unable to create dataitem:%d", each->getId());
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy contents into the newly created data item
|
||||
di->copy(each);
|
||||
|
||||
// Request systemstatus to record this dataitem in its cache
|
||||
if (mSystemStatus->eventDataItemNotify(di)) {
|
||||
// add this dataitem if updated from last one
|
||||
dataItemList.push_back(di);
|
||||
}
|
||||
}
|
||||
|
||||
struct HandleNotify : public LocMsg {
|
||||
HandleNotify(SystemStatusOsObserver* parent, const list<IDataItemCore*>& l) :
|
||||
mParent(parent), mDList(l) {}
|
||||
virtual ~HandleNotify() {
|
||||
for (auto each : mDList) {
|
||||
delete each;
|
||||
}
|
||||
}
|
||||
void proc() const {
|
||||
// Update Cache with received data items and prepare
|
||||
// list of data items to be sent.
|
||||
unordered_set<DataItemId> dataItemIdsToBeSent(0);
|
||||
for (auto item : mDiVec) {
|
||||
if (mParent->updateCache(item)) {
|
||||
dataItemIdsToBeSent.insert(item->getId());
|
||||
list<DataItemId> dataItemIdsToBeSent(0);
|
||||
for (auto item : mDList) {
|
||||
bool dataItemUpdated = false;
|
||||
mParent->updateCache(item, dataItemUpdated);
|
||||
if (dataItemUpdated) {
|
||||
dataItemIdsToBeSent.push_back(item->getId());
|
||||
}
|
||||
}
|
||||
|
||||
// Send data item to all subscribed clients
|
||||
unordered_set<IDataItemObserver*> clientSet(0);
|
||||
list<IDataItemObserver*> clientList(0);
|
||||
for (auto each : dataItemIdsToBeSent) {
|
||||
auto clients = mParent->mDataItemToClients.getValSetPtr(each);
|
||||
if (nullptr != clients) {
|
||||
clientSet.insert(clients->begin(), clients->end());
|
||||
list<IDataItemObserver*> clients(0);
|
||||
mParent->mDataItemIndex->getListOfSubscribedClients(each, clients);
|
||||
for (auto each_cient: clients) {
|
||||
clientList.push_back(each_cient);
|
||||
}
|
||||
}
|
||||
clientList.unique();
|
||||
|
||||
for (auto client : clientSet) {
|
||||
unordered_set<DataItemId> dataItemIdsForThisClient(
|
||||
mParent->mClientToDataItems.getValSet(client));
|
||||
for (auto itr = dataItemIdsForThisClient.begin();
|
||||
itr != dataItemIdsForThisClient.end(); ) {
|
||||
if (dataItemIdsToBeSent.find(*itr) == dataItemIdsToBeSent.end()) {
|
||||
itr = dataItemIdsForThisClient.erase(itr);
|
||||
} else {
|
||||
itr++;
|
||||
}
|
||||
}
|
||||
for (auto client : clientList) {
|
||||
list<DataItemId> dataItemIdsSubscribedByThisClient(0);
|
||||
list<DataItemId> dataItemIdsToBeSentForThisClient(0);
|
||||
mParent->mClientIndex->getSubscribedList(
|
||||
client, dataItemIdsSubscribedByThisClient);
|
||||
dataItemIdsSubscribedByThisClient.sort();
|
||||
dataItemIdsToBeSent.sort();
|
||||
|
||||
mParent->sendCachedDataItems(dataItemIdsForThisClient, client);
|
||||
set_intersection(dataItemIdsToBeSent.begin(),
|
||||
dataItemIdsToBeSent.end(),
|
||||
dataItemIdsSubscribedByThisClient.begin(),
|
||||
dataItemIdsSubscribedByThisClient.end(),
|
||||
inserter(dataItemIdsToBeSentForThisClient,
|
||||
dataItemIdsToBeSentForThisClient.begin()));
|
||||
|
||||
mParent->sendCachedDataItems(dataItemIdsToBeSentForThisClient, client);
|
||||
dataItemIdsSubscribedByThisClient.clear();
|
||||
dataItemIdsToBeSentForThisClient.clear();
|
||||
}
|
||||
}
|
||||
SystemStatusOsObserver* mParent;
|
||||
const vector<IDataItemCore*> mDiVec;
|
||||
const list<IDataItemCore*> mDList;
|
||||
};
|
||||
|
||||
if (!dlist.empty()) {
|
||||
vector<IDataItemCore*> dataItemVec(dlist.size());
|
||||
|
||||
for (auto each : dlist) {
|
||||
IF_LOC_LOGD {
|
||||
string dv;
|
||||
each->stringify(dv);
|
||||
LOC_LOGD("notify: DataItem In Value:%s", dv.c_str());
|
||||
}
|
||||
|
||||
IDataItemCore* di = DataItemsFactoryProxy::createNewDataItem(each->getId());
|
||||
if (nullptr == di) {
|
||||
LOC_LOGw("Unable to create dataitem:%d", each->getId());
|
||||
continue;
|
||||
}
|
||||
|
||||
// Copy contents into the newly created data item
|
||||
di->copy(each);
|
||||
|
||||
// add this dataitem if updated from last one
|
||||
dataItemVec.push_back(di);
|
||||
}
|
||||
|
||||
if (!dataItemVec.empty()) {
|
||||
mContext.mMsgTask->sendMsg(new HandleNotify(this, dataItemVec));
|
||||
}
|
||||
}
|
||||
mContext.mMsgTask->sendMsg(new (nothrow) HandleNotify(this, dataItemList));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -384,7 +444,7 @@ void SystemStatusOsObserver::turnOn(DataItemId dit, int timeOut)
|
|||
}
|
||||
|
||||
// Check if data item exists in mActiveRequestCount
|
||||
DataItemIdToInt::iterator citer = mActiveRequestCount.find(dit);
|
||||
map<DataItemId, int>::iterator citer = mActiveRequestCount.find(dit);
|
||||
if (citer == mActiveRequestCount.end()) {
|
||||
// Data item not found in map
|
||||
// Add reference count as 1 and add dataitem to map
|
||||
|
@ -422,7 +482,7 @@ void SystemStatusOsObserver::turnOff(DataItemId dit)
|
|||
}
|
||||
|
||||
// Check if data item exists in mActiveRequestCount
|
||||
DataItemIdToInt::iterator citer = mActiveRequestCount.find(dit);
|
||||
map<DataItemId, int>::iterator citer = mActiveRequestCount.find(dit);
|
||||
if (citer != mActiveRequestCount.end()) {
|
||||
// found
|
||||
citer->second--;
|
||||
|
@ -448,127 +508,87 @@ void SystemStatusOsObserver::turnOff(DataItemId dit)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef USE_GLIB
|
||||
bool SystemStatusOsObserver::connectBackhaul()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (mContext.mFrameworkActionReqObj != NULL) {
|
||||
struct HandleConnectBackhaul : public LocMsg {
|
||||
HandleConnectBackhaul(IFrameworkActionReq* fwkActReq) :
|
||||
mFwkActionReqObj(fwkActReq) {}
|
||||
virtual ~HandleConnectBackhaul() {}
|
||||
void proc() const {
|
||||
LOC_LOGD("HandleConnectBackhaul");
|
||||
mFwkActionReqObj->connectBackhaul();
|
||||
}
|
||||
IFrameworkActionReq* mFwkActionReqObj;
|
||||
};
|
||||
mContext.mMsgTask->sendMsg(
|
||||
new (nothrow) HandleConnectBackhaul(mContext.mFrameworkActionReqObj));
|
||||
result = true;
|
||||
}
|
||||
else {
|
||||
++mBackHaulConnectReqCount;
|
||||
LOC_LOGE("Framework action request object is NULL.Caching connect request: %d",
|
||||
mBackHaulConnectReqCount);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
bool SystemStatusOsObserver::disconnectBackhaul()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (mContext.mFrameworkActionReqObj != NULL) {
|
||||
struct HandleDisconnectBackhaul : public LocMsg {
|
||||
HandleDisconnectBackhaul(IFrameworkActionReq* fwkActReq) :
|
||||
mFwkActionReqObj(fwkActReq) {}
|
||||
virtual ~HandleDisconnectBackhaul() {}
|
||||
void proc() const {
|
||||
LOC_LOGD("HandleDisconnectBackhaul");
|
||||
mFwkActionReqObj->disconnectBackhaul();
|
||||
}
|
||||
IFrameworkActionReq* mFwkActionReqObj;
|
||||
};
|
||||
mContext.mMsgTask->sendMsg(
|
||||
new (nothrow) HandleDisconnectBackhaul(mContext.mFrameworkActionReqObj));
|
||||
}
|
||||
else {
|
||||
if (mBackHaulConnectReqCount > 0) {
|
||||
--mBackHaulConnectReqCount;
|
||||
}
|
||||
LOC_LOGE("Framework action request object is NULL.Caching disconnect request: %d",
|
||||
mBackHaulConnectReqCount);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
/******************************************************************************
|
||||
Helpers
|
||||
******************************************************************************/
|
||||
void SystemStatusOsObserver::sendCachedDataItems(
|
||||
const unordered_set<DataItemId>& s, IDataItemObserver* to)
|
||||
void SystemStatusOsObserver::sendFirstResponse(
|
||||
const list<DataItemId>& l, IDataItemObserver* to)
|
||||
{
|
||||
if (nullptr == to) {
|
||||
LOC_LOGv("client pointer is NULL.");
|
||||
} else {
|
||||
string clientName;
|
||||
to->getName(clientName);
|
||||
list<IDataItemCore*> dataItems(0);
|
||||
if (l.empty()) {
|
||||
LOC_LOGV("list is empty. Nothing to do. Exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto each : s) {
|
||||
auto citer = mDataItemCache.find(each);
|
||||
if (citer != mDataItemCache.end()) {
|
||||
string dv;
|
||||
citer->second->stringify(dv);
|
||||
LOC_LOGI("DataItem: %s >> %s", dv.c_str(), clientName.c_str());
|
||||
dataItems.push_front(citer->second);
|
||||
}
|
||||
}
|
||||
string clientName;
|
||||
to->getName(clientName);
|
||||
list<IDataItemCore*> dataItems(0);
|
||||
|
||||
if (dataItems.empty()) {
|
||||
LOC_LOGv("No items to notify.");
|
||||
} else {
|
||||
to->notify(dataItems);
|
||||
for (auto each : l) {
|
||||
map<DataItemId, IDataItemCore*>::const_iterator citer = mDataItemCache.find(each);
|
||||
if (citer != mDataItemCache.end()) {
|
||||
string dv;
|
||||
citer->second->stringify(dv);
|
||||
LOC_LOGI("DataItem: %s >> %s", dv.c_str(), clientName.c_str());
|
||||
dataItems.push_back(citer->second);
|
||||
}
|
||||
}
|
||||
if (dataItems.empty()) {
|
||||
LOC_LOGV("No items to notify. Nothing to do. Exiting");
|
||||
return;
|
||||
}
|
||||
to->notify(dataItems);
|
||||
}
|
||||
|
||||
bool SystemStatusOsObserver::updateCache(IDataItemCore* d)
|
||||
void SystemStatusOsObserver::sendCachedDataItems(
|
||||
const list<DataItemId>& l, IDataItemObserver* to)
|
||||
{
|
||||
bool dataItemUpdated = false;
|
||||
string clientName;
|
||||
to->getName(clientName);
|
||||
list<IDataItemCore*> dataItems(0);
|
||||
|
||||
// Request systemstatus to record this dataitem in its cache
|
||||
// if the return is false, it means that SystemStatus is not
|
||||
// handling it, so SystemStatusOsObserver also doesn't.
|
||||
// So it has to be true to proceed.
|
||||
if (nullptr != d && mSystemStatus->eventDataItemNotify(d)) {
|
||||
auto citer = mDataItemCache.find(d->getId());
|
||||
if (citer == mDataItemCache.end()) {
|
||||
// New data item; not found in cache
|
||||
IDataItemCore* dataitem = DataItemsFactoryProxy::createNewDataItem(d->getId());
|
||||
if (nullptr != dataitem) {
|
||||
// Copy the contents of the data item
|
||||
dataitem->copy(d);
|
||||
// Insert in mDataItemCache
|
||||
mDataItemCache.insert(std::make_pair(d->getId(), dataitem));
|
||||
dataItemUpdated = true;
|
||||
}
|
||||
} else {
|
||||
// Found in cache; Update cache if necessary
|
||||
citer->second->copy(d, &dataItemUpdated);
|
||||
for (auto each : l) {
|
||||
string dv;
|
||||
IDataItemCore* di = mDataItemCache[each];
|
||||
di->stringify(dv);
|
||||
LOC_LOGI("DataItem: %s >> %s", dv.c_str(), clientName.c_str());
|
||||
dataItems.push_back(di);
|
||||
}
|
||||
to->notify(dataItems);
|
||||
}
|
||||
|
||||
void SystemStatusOsObserver::updateCache(IDataItemCore* d, bool& dataItemUpdated)
|
||||
{
|
||||
if (nullptr == d) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if data item exists in cache
|
||||
map<DataItemId, IDataItemCore*>::iterator citer =
|
||||
mDataItemCache.find(d->getId());
|
||||
if (citer == mDataItemCache.end()) {
|
||||
// New data item; not found in cache
|
||||
IDataItemCore* dataitem = DataItemsFactoryProxy::createNewDataItem(d->getId());
|
||||
if (nullptr == dataitem) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dataItemUpdated) {
|
||||
LOC_LOGV("DataItem:%d updated:%d", d->getId(), dataItemUpdated);
|
||||
// Copy the contents of the data item
|
||||
dataitem->copy(d);
|
||||
pair<DataItemId, IDataItemCore*> cpair(d->getId(), dataitem);
|
||||
// Insert in mDataItemCache
|
||||
mDataItemCache.insert(cpair);
|
||||
dataItemUpdated = true;
|
||||
}
|
||||
else {
|
||||
// Found in cache; Update cache if necessary
|
||||
if(0 == citer->second->copy(d, &dataItemUpdated)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return dataItemUpdated;
|
||||
if (dataItemUpdated) {
|
||||
LOC_LOGV("DataItem:%d updated:%d", d->getId(), dataItemUpdated);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace loc_core
|
||||
|
|
109
gps/core/SystemStatusOsObserver.h
Executable file → Normal file
109
gps/core/SystemStatusOsObserver.h
Executable file → Normal file
|
@ -39,9 +39,7 @@
|
|||
#include <MsgTask.h>
|
||||
#include <DataItemId.h>
|
||||
#include <IOsObserver.h>
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
#include <LocUnorderedSetMap.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
|
@ -49,123 +47,86 @@ namespace loc_core
|
|||
SystemStatusOsObserver
|
||||
******************************************************************************/
|
||||
using namespace std;
|
||||
using namespace loc_util;
|
||||
|
||||
// Forward Declarations
|
||||
class IDataItemCore;
|
||||
class SystemStatus;
|
||||
class SystemStatusOsObserver;
|
||||
typedef map<IDataItemObserver*, list<DataItemId>> ObserverReqCache;
|
||||
typedef LocUnorderedSetMap<IDataItemObserver*, DataItemId> ClientToDataItems;
|
||||
typedef LocUnorderedSetMap<DataItemId, IDataItemObserver*> DataItemToClients;
|
||||
typedef unordered_map<DataItemId, IDataItemCore*> DataItemIdToCore;
|
||||
typedef unordered_map<DataItemId, int> DataItemIdToInt;
|
||||
template<typename CT, typename DIT> class IClientIndex;
|
||||
template<typename CT, typename DIT> class IDataItemIndex;
|
||||
|
||||
struct ObserverContext {
|
||||
struct SystemContext {
|
||||
IDataItemSubscription* mSubscriptionObj;
|
||||
IFrameworkActionReq* mFrameworkActionReqObj;
|
||||
const MsgTask* mMsgTask;
|
||||
SystemStatusOsObserver* mSSObserver;
|
||||
|
||||
inline ObserverContext(const MsgTask* msgTask, SystemStatusOsObserver* observer) :
|
||||
mSubscriptionObj(NULL), mFrameworkActionReqObj(NULL),
|
||||
mMsgTask(msgTask), mSSObserver(observer) {}
|
||||
inline SystemContext() :
|
||||
mSubscriptionObj(NULL),
|
||||
mFrameworkActionReqObj(NULL),
|
||||
mMsgTask(NULL) {}
|
||||
};
|
||||
|
||||
typedef map<IDataItemObserver*, list<DataItemId>> ObserverReqCache;
|
||||
|
||||
// Clients wanting to get data from OS/Framework would need to
|
||||
// subscribe with OSObserver using IDataItemSubscription interface.
|
||||
// Such clients would need to implement IDataItemObserver interface
|
||||
// to receive data when it becomes available.
|
||||
class SystemStatus;
|
||||
class SystemStatusOsObserver : public IOsObserver {
|
||||
|
||||
public:
|
||||
// ctor
|
||||
inline SystemStatusOsObserver(SystemStatus* systemstatus, const MsgTask* msgTask) :
|
||||
mSystemStatus(systemstatus), mContext(msgTask, this),
|
||||
mAddress("SystemStatusOsObserver"),
|
||||
mClientToDataItems(MAX_DATA_ITEM_ID), mDataItemToClients(MAX_DATA_ITEM_ID)
|
||||
#ifdef USE_GLIB
|
||||
, mBackHaulConnectReqCount(0)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
SystemStatusOsObserver(
|
||||
SystemStatus* systemstatus, const MsgTask* msgTask);
|
||||
// dtor
|
||||
~SystemStatusOsObserver();
|
||||
|
||||
template <typename CINT, typename COUT>
|
||||
static COUT containerTransfer(CINT& s);
|
||||
template <typename CINT, typename COUT>
|
||||
inline static COUT containerTransfer(CINT&& s) {
|
||||
return containerTransfer<CINT, COUT>(s);
|
||||
}
|
||||
|
||||
// To set the subscription object
|
||||
virtual void setSubscriptionObj(IDataItemSubscription* subscriptionObj);
|
||||
|
||||
// To set the framework action request object
|
||||
inline void setFrameworkActionReqObj(IFrameworkActionReq* frameworkActionReqObj) {
|
||||
mContext.mFrameworkActionReqObj = frameworkActionReqObj;
|
||||
#ifdef USE_GLIB
|
||||
if (mBackHaulConnectReqCount > 0) {
|
||||
connectBackhaul();
|
||||
mBackHaulConnectReqCount = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// IDataItemSubscription Overrides
|
||||
inline virtual void subscribe(const list<DataItemId>& l, IDataItemObserver* client) override {
|
||||
subscribe(l, client, false);
|
||||
}
|
||||
virtual void updateSubscription(const list<DataItemId>& l, IDataItemObserver* client) override;
|
||||
inline virtual void requestData(const list<DataItemId>& l, IDataItemObserver* client) override {
|
||||
subscribe(l, client, true);
|
||||
}
|
||||
virtual void unsubscribe(const list<DataItemId>& l, IDataItemObserver* client) override;
|
||||
virtual void unsubscribeAll(IDataItemObserver* client) override;
|
||||
virtual void subscribe(const list<DataItemId>& l, IDataItemObserver* client);
|
||||
virtual void updateSubscription(const list<DataItemId>& l, IDataItemObserver* client);
|
||||
virtual void requestData(const list<DataItemId>& l, IDataItemObserver* client);
|
||||
virtual void unsubscribe(const list<DataItemId>& l, IDataItemObserver* client);
|
||||
virtual void unsubscribeAll(IDataItemObserver* client);
|
||||
|
||||
// IDataItemObserver Overrides
|
||||
virtual void notify(const list<IDataItemCore*>& dlist) override;
|
||||
inline virtual void getName(string& name) override {
|
||||
virtual void notify(const list<IDataItemCore*>& dlist);
|
||||
inline virtual void getName(string& name) {
|
||||
name = mAddress;
|
||||
}
|
||||
|
||||
// IFrameworkActionReq Overrides
|
||||
virtual void turnOn(DataItemId dit, int timeOut = 0) override;
|
||||
virtual void turnOff(DataItemId dit) override;
|
||||
#ifdef USE_GLIB
|
||||
virtual bool connectBackhaul() override;
|
||||
virtual bool disconnectBackhaul();
|
||||
#endif
|
||||
virtual void turnOn(DataItemId dit, int timeOut = 0);
|
||||
virtual void turnOff(DataItemId dit);
|
||||
|
||||
private:
|
||||
SystemStatus* mSystemStatus;
|
||||
ObserverContext mContext;
|
||||
SystemContext mContext;
|
||||
const string mAddress;
|
||||
ClientToDataItems mClientToDataItems;
|
||||
DataItemToClients mDataItemToClients;
|
||||
DataItemIdToCore mDataItemCache;
|
||||
DataItemIdToInt mActiveRequestCount;
|
||||
IClientIndex<IDataItemObserver*, DataItemId>* mClientIndex;
|
||||
IDataItemIndex<IDataItemObserver*, DataItemId>* mDataItemIndex;
|
||||
map<DataItemId, IDataItemCore*> mDataItemCache;
|
||||
map<DataItemId, int> mActiveRequestCount;
|
||||
|
||||
// Cache the subscribe and requestData till subscription obj is obtained
|
||||
ObserverReqCache mSubscribeReqCache;
|
||||
ObserverReqCache mReqDataCache;
|
||||
void cacheObserverRequest(ObserverReqCache& reqCache,
|
||||
const list<DataItemId>& l, IDataItemObserver* client);
|
||||
#ifdef USE_GLIB
|
||||
// Cache the framework action request for connect/disconnect
|
||||
int mBackHaulConnectReqCount;
|
||||
#endif
|
||||
|
||||
void subscribe(const list<DataItemId>& l, IDataItemObserver* client, bool toRequestData);
|
||||
|
||||
// Helpers
|
||||
void sendCachedDataItems(const unordered_set<DataItemId>& s, IDataItemObserver* to);
|
||||
bool updateCache(IDataItemCore* d);
|
||||
inline void logMe(const unordered_set<DataItemId>& l) {
|
||||
IF_LOC_LOGD {
|
||||
for (auto id : l) {
|
||||
LOC_LOGD("DataItem %d", id);
|
||||
}
|
||||
void sendFirstResponse(const list<DataItemId>& l, IDataItemObserver* to);
|
||||
void sendCachedDataItems(const list<DataItemId>& l, IDataItemObserver* to);
|
||||
void updateCache(IDataItemCore* d, bool& dataItemUpdated);
|
||||
inline void logMe(const list<DataItemId>& l) {
|
||||
for (auto id : l) {
|
||||
LOC_LOGD("DataItem %d", id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
0
gps/core/UlpProxyBase.h
Executable file → Normal file
0
gps/core/UlpProxyBase.h
Executable file → Normal file
83
gps/core/data-items/DataItemConcreteTypesBase.h
Executable file → Normal file
83
gps/core/data-items/DataItemConcreteTypesBase.h
Executable file → Normal file
|
@ -221,22 +221,9 @@ protected:
|
|||
|
||||
class NetworkInfoDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
enum NetworkType {
|
||||
TYPE_MOBILE,
|
||||
TYPE_WIFI,
|
||||
TYPE_ETHERNET,
|
||||
TYPE_BLUETOOTH,
|
||||
TYPE_MMS,
|
||||
TYPE_SUPL,
|
||||
TYPE_DUN,
|
||||
TYPE_HIPRI,
|
||||
TYPE_WIMAX,
|
||||
TYPE_UNKNOWN,
|
||||
};
|
||||
NetworkInfoDataItemBase(
|
||||
NetworkType initialType, int32_t type, string typeName, string subTypeName,
|
||||
int32_t type, string typeName, string subTypeName,
|
||||
bool available, bool connected, bool roaming ):
|
||||
mAllTypes(typeToAllTypes(initialType)),
|
||||
mType(type),
|
||||
mTypeName(typeName),
|
||||
mSubTypeName(subTypeName),
|
||||
|
@ -248,12 +235,22 @@ public:
|
|||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
enum NetworkType {
|
||||
TYPE_UNKNOWN,
|
||||
TYPE_MOBILE,
|
||||
TYPE_WIFI,
|
||||
TYPE_ETHERNET,
|
||||
TYPE_BLUETOOTH,
|
||||
TYPE_MMS,
|
||||
TYPE_SUPL,
|
||||
TYPE_DUN,
|
||||
TYPE_HIPRI,
|
||||
TYPE_WIMAX
|
||||
};
|
||||
inline virtual NetworkType getType(void) const {
|
||||
return (NetworkType)mType;
|
||||
}
|
||||
inline uint64_t getAllTypes() { return mAllTypes; }
|
||||
// Data members
|
||||
uint64_t mAllTypes;
|
||||
// Data members
|
||||
int32_t mType;
|
||||
string mTypeName;
|
||||
string mSubTypeName;
|
||||
|
@ -262,9 +259,7 @@ public:
|
|||
bool mRoaming;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
inline uint64_t typeToAllTypes(NetworkType type) {
|
||||
return (type >= TYPE_UNKNOWN || type < TYPE_MOBILE) ? 0 : (1<<type);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class ServiceStatusDataItemBase : public IDataItemCore {
|
||||
|
@ -314,42 +309,24 @@ protected:
|
|||
|
||||
class RilServiceInfoDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
inline RilServiceInfoDataItemBase() :
|
||||
mData(nullptr), mId(RILSERVICEINFO_DATA_ITEM_ID) {}
|
||||
inline virtual ~RilServiceInfoDataItemBase() { if (nullptr != mData) free(mData); }
|
||||
RilServiceInfoDataItemBase() :
|
||||
mId(RILSERVICEINFO_DATA_ITEM_ID) {}
|
||||
virtual ~RilServiceInfoDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
inline RilServiceInfoDataItemBase(const RilServiceInfoDataItemBase& peer) :
|
||||
RilServiceInfoDataItemBase() {
|
||||
peer.setPeerData(*this);
|
||||
}
|
||||
inline virtual bool operator==(const RilServiceInfoDataItemBase& other) const {
|
||||
return other.mData == mData;
|
||||
}
|
||||
inline virtual void setPeerData(RilServiceInfoDataItemBase& /*peer*/) const {}
|
||||
void* mData;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class RilCellInfoDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
inline RilCellInfoDataItemBase() :
|
||||
mData(nullptr), mId(RILCELLINFO_DATA_ITEM_ID) {}
|
||||
inline virtual ~RilCellInfoDataItemBase() { if (nullptr != mData) free(mData); }
|
||||
RilCellInfoDataItemBase() :
|
||||
mId(RILCELLINFO_DATA_ITEM_ID) {}
|
||||
virtual ~RilCellInfoDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
inline RilCellInfoDataItemBase(const RilCellInfoDataItemBase& peer) :
|
||||
RilCellInfoDataItemBase() {
|
||||
peer.setPeerData(*this);
|
||||
}
|
||||
inline virtual bool operator==(const RilCellInfoDataItemBase& other) const {
|
||||
return other.mData == mData;
|
||||
}
|
||||
inline virtual void setPeerData(RilCellInfoDataItemBase& /*peer*/) const {}
|
||||
void* mData;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
@ -416,7 +393,7 @@ protected:
|
|||
class MccmncDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
MccmncDataItemBase(const string & name) :
|
||||
mValue(name),
|
||||
mValue (name),
|
||||
mId(MCCMNC_DATA_ITEM_ID) {}
|
||||
virtual ~MccmncDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
|
@ -430,7 +407,7 @@ protected:
|
|||
|
||||
class SrnDeviceScanDetailsDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
SrnDeviceScanDetailsDataItemBase(DataItemId Id) :
|
||||
SrnDeviceScanDetailsDataItemBase (DataItemId Id) :
|
||||
mValidSrnData(false),
|
||||
mApSrnRssi(-1),
|
||||
mApSrnTimestamp(0),
|
||||
|
@ -438,7 +415,7 @@ public:
|
|||
mReceiveTimestamp(0),
|
||||
mErrorCause(-1),
|
||||
mId(Id) {}
|
||||
virtual ~SrnDeviceScanDetailsDataItemBase() {}
|
||||
virtual ~SrnDeviceScanDetailsDataItemBase () {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
// Data members common to all SRN tech types
|
||||
/* Represents info on whether SRN data is valid (no error)*/
|
||||
|
@ -479,18 +456,6 @@ public:
|
|||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
};
|
||||
|
||||
class BatteryLevelDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
inline BatteryLevelDataItemBase(uint8_t batteryPct) :
|
||||
mBatteryPct(batteryPct), mId(BATTERY_LEVEL_DATA_ITEM_ID) {}
|
||||
inline ~BatteryLevelDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
// Data members
|
||||
uint8_t mBatteryPct;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif //__DATAITEMCONCRETEBASETYPES__
|
||||
|
|
8
gps/core/data-items/DataItemId.h
Executable file → Normal file
8
gps/core/data-items/DataItemId.h
Executable file → Normal file
|
@ -67,13 +67,7 @@ typedef enum e_DataItemId {
|
|||
BTLE_SCAN_DATA_ITEM_ID,
|
||||
BT_SCAN_DATA_ITEM_ID,
|
||||
OEM_GTP_UPLOAD_TRIGGER_READY_ITEM_ID,
|
||||
|
||||
MAX_DATA_ITEM_ID,
|
||||
|
||||
// 26 -
|
||||
BATTERY_LEVEL_DATA_ITEM_ID,
|
||||
|
||||
MAX_DATA_ITEM_ID_1_1,
|
||||
MAX_DATA_ITEM_ID
|
||||
} DataItemId;
|
||||
|
||||
#endif // #ifndef __DATAITEMID_H__
|
||||
|
|
5
gps/core/data-items/DataItemsFactoryProxy.cpp
Executable file → Normal file
5
gps/core/data-items/DataItemsFactoryProxy.cpp
Executable file → Normal file
|
@ -32,8 +32,7 @@
|
|||
#include <DataItemId.h>
|
||||
#include <IDataItemCore.h>
|
||||
#include <DataItemsFactoryProxy.h>
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
|
@ -69,7 +68,7 @@ IDataItemCore* DataItemsFactoryProxy::createNewDataItem(DataItemId id)
|
|||
getConcreteDIFunc = (get_concrete_data_item_fn * )
|
||||
dlsym(dataItemLibHandle, DATA_ITEMS_GET_CONCRETE_DI);
|
||||
if (NULL != getConcreteDIFunc) {
|
||||
LOC_LOGD("Loaded function %s : %p",DATA_ITEMS_GET_CONCRETE_DI,getConcreteDIFunc);
|
||||
LOC_LOGD("Loaded function %s : %x",DATA_ITEMS_GET_CONCRETE_DI,getConcreteDIFunc);
|
||||
mydi = (*getConcreteDIFunc)(id);
|
||||
}
|
||||
else {
|
||||
|
|
0
gps/core/data-items/DataItemsFactoryProxy.h
Executable file → Normal file
0
gps/core/data-items/DataItemsFactoryProxy.h
Executable file → Normal file
0
gps/core/data-items/IDataItemCore.h
Executable file → Normal file
0
gps/core/data-items/IDataItemCore.h
Executable file → Normal file
171
gps/core/data-items/common/ClientIndex.cpp
Normal file
171
gps/core/data-items/common/ClientIndex.cpp
Normal file
|
@ -0,0 +1,171 @@
|
|||
/* Copyright (c) 2015, 2017 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 <algorithm>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <ClientIndex.h>
|
||||
#include <IDataItemObserver.h>
|
||||
#include <DataItemId.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace loc_core;
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
inline ClientIndex <CT,DIT> :: ClientIndex () {}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
inline ClientIndex <CT,DIT> :: ~ClientIndex () {}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
bool ClientIndex <CT,DIT> :: isSubscribedClient (CT client) {
|
||||
bool result = false;
|
||||
ENTRY_LOG ();
|
||||
typename map < CT, list <DIT> > :: iterator it =
|
||||
mDataItemsPerClientMap.find (client);
|
||||
if (it != mDataItemsPerClientMap.end ()) {
|
||||
result = true;
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",result);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void ClientIndex <CT,DIT> :: getSubscribedList (CT client, list <DIT> & out) {
|
||||
ENTRY_LOG ();
|
||||
typename map < CT, list <DIT> > :: iterator it =
|
||||
mDataItemsPerClientMap.find (client);
|
||||
if (it != mDataItemsPerClientMap.end ()) {
|
||||
out = it->second;
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
int ClientIndex <CT,DIT> :: remove (CT client) {
|
||||
int result = 0;
|
||||
ENTRY_LOG ();
|
||||
mDataItemsPerClientMap.erase (client);
|
||||
EXIT_LOG_WITH_ERROR ("%d",result);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void ClientIndex <CT,DIT> :: remove (const list <DIT> & r, list <CT> & out) {
|
||||
ENTRY_LOG ();
|
||||
typename map < CT, list <DIT> > :: iterator dicIter =
|
||||
mDataItemsPerClientMap.begin ();
|
||||
while (dicIter != mDataItemsPerClientMap.end()) {
|
||||
typename list <DIT> :: const_iterator it = r.begin ();
|
||||
for (; it != r.end (); ++it) {
|
||||
typename list <DIT> :: iterator iter =
|
||||
find (dicIter->second.begin (), dicIter->second.end (), *it);
|
||||
if (iter != dicIter->second.end ()) {
|
||||
dicIter->second.erase (iter);
|
||||
}
|
||||
}
|
||||
if (dicIter->second.empty ()) {
|
||||
out.push_back (dicIter->first);
|
||||
// Post-increment operator increases the iterator but returns the
|
||||
// prevous one that will be invalidated by erase()
|
||||
mDataItemsPerClientMap.erase (dicIter++);
|
||||
} else {
|
||||
++dicIter;
|
||||
}
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void ClientIndex <CT,DIT> :: remove
|
||||
(
|
||||
CT client,
|
||||
const list <DIT> & r,
|
||||
list <DIT> & out
|
||||
)
|
||||
{
|
||||
ENTRY_LOG ();
|
||||
typename map < CT, list <DIT> > :: iterator dicIter =
|
||||
mDataItemsPerClientMap.find (client);
|
||||
if (dicIter != mDataItemsPerClientMap.end ()) {
|
||||
set_intersection (dicIter->second.begin (), dicIter->second.end (),
|
||||
r.begin (), r.end (),
|
||||
inserter (out,out.begin ()));
|
||||
if (!out.empty ()) {
|
||||
typename list <DIT> :: iterator it = out.begin ();
|
||||
for (; it != out.end (); ++it) {
|
||||
dicIter->second.erase (find (dicIter->second.begin (),
|
||||
dicIter->second.end (),
|
||||
*it));
|
||||
}
|
||||
}
|
||||
if (dicIter->second.empty ()) {
|
||||
mDataItemsPerClientMap.erase (dicIter);
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void ClientIndex <CT,DIT> :: add
|
||||
(
|
||||
CT client,
|
||||
const list <DIT> & l,
|
||||
list <DIT> & out
|
||||
)
|
||||
{
|
||||
ENTRY_LOG ();
|
||||
list <DIT> difference;
|
||||
typename map < CT, list <DIT> > :: iterator dicIter =
|
||||
mDataItemsPerClientMap.find (client);
|
||||
if (dicIter != mDataItemsPerClientMap.end ()) {
|
||||
set_difference (l.begin (), l.end (),
|
||||
dicIter->second.begin (), dicIter->second.end (),
|
||||
inserter (difference,difference.begin ()));
|
||||
if (!difference.empty ()) {
|
||||
difference.sort ();
|
||||
out = difference;
|
||||
dicIter->second.merge (difference);
|
||||
dicIter->second.unique ();
|
||||
}
|
||||
} else {
|
||||
out = l;
|
||||
pair < CT, list <DIT> > dicnpair (client, out);
|
||||
mDataItemsPerClientMap.insert (dicnpair);
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
// Explicit instantiation must occur in same namespace where class is defined
|
||||
namespace loc_core
|
||||
{
|
||||
template class ClientIndex <IDataItemObserver *, DataItemId>;
|
||||
template class ClientIndex <string, DataItemId>;
|
||||
}
|
70
gps/core/data-items/common/ClientIndex.h
Normal file
70
gps/core/data-items/common/ClientIndex.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* Copyright (c) 2015, 2017 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 __CLIENTINDEX_H__
|
||||
#define __CLIENTINDEX_H__
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <IClientIndex.h>
|
||||
|
||||
using loc_core::IClientIndex;
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
|
||||
class ClientIndex : public IClientIndex <CT, DIT> {
|
||||
|
||||
public:
|
||||
|
||||
ClientIndex ();
|
||||
|
||||
~ClientIndex ();
|
||||
|
||||
bool isSubscribedClient (CT client);
|
||||
|
||||
void getSubscribedList (CT client, std :: list <DIT> & out);
|
||||
|
||||
int remove (CT client);
|
||||
|
||||
void remove (const std :: list <DIT> & r, std :: list <CT> & out);
|
||||
|
||||
void remove (CT client, const std :: list <DIT> & r, std :: list <DIT> & out);
|
||||
|
||||
void add (CT client, const std :: list <DIT> & l, std :: list <DIT> & out);
|
||||
|
||||
private:
|
||||
//Data members
|
||||
std :: map < CT , std :: list <DIT> > mDataItemsPerClientMap;
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif // #ifndef __CLIENTINDEX_H__
|
202
gps/core/data-items/common/DataItemIndex.cpp
Normal file
202
gps/core/data-items/common/DataItemIndex.cpp
Normal file
|
@ -0,0 +1,202 @@
|
|||
/* Copyright (c) 2015, 2017 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 <string>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <DataItemIndex.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <IDataItemObserver.h>
|
||||
#include <DataItemId.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace loc_core;
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
inline DataItemIndex <CT,DIT> :: DataItemIndex () {}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
inline DataItemIndex <CT,DIT> :: ~DataItemIndex () {}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void DataItemIndex <CT,DIT> :: getListOfSubscribedClients
|
||||
(
|
||||
DIT id,
|
||||
list <CT> & out
|
||||
)
|
||||
{
|
||||
typename map < DIT, list <CT> > :: iterator cdiIter =
|
||||
mClientsPerDataItemMap.find (id);
|
||||
if (cdiIter != mClientsPerDataItemMap.end ()) {
|
||||
out = cdiIter->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
int DataItemIndex <CT,DIT> :: remove (DIT id) {
|
||||
int result = 0;
|
||||
ENTRY_LOG ();
|
||||
mClientsPerDataItemMap.erase (id);
|
||||
EXIT_LOG_WITH_ERROR ("%d",result);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void DataItemIndex <CT,DIT> :: remove (const list <CT> & r, list <DIT> & out) {
|
||||
ENTRY_LOG ();
|
||||
typename map < DIT, list <CT> > :: iterator cdiIter =
|
||||
mClientsPerDataItemMap.begin ();
|
||||
while (cdiIter != mClientsPerDataItemMap.end()) {
|
||||
typename list <CT> :: const_iterator it = r.begin ();
|
||||
for (; it != r.end (); ++it) {
|
||||
typename list <CT> :: iterator iter =
|
||||
find
|
||||
(
|
||||
cdiIter->second.begin (),
|
||||
cdiIter->second.end (),
|
||||
*it
|
||||
);
|
||||
if (iter != cdiIter->second.end ()) {
|
||||
cdiIter->second.erase (iter);
|
||||
}
|
||||
}
|
||||
|
||||
if (cdiIter->second.empty ()) {
|
||||
out.push_back (cdiIter->first);
|
||||
// Post-increment operator increases the iterator but returns the
|
||||
// prevous one that will be invalidated by erase()
|
||||
mClientsPerDataItemMap.erase (cdiIter++);
|
||||
} else {
|
||||
++cdiIter;
|
||||
}
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void DataItemIndex <CT,DIT> :: remove
|
||||
(
|
||||
DIT id,
|
||||
const list <CT> & r,
|
||||
list <CT> & out
|
||||
)
|
||||
{
|
||||
ENTRY_LOG ();
|
||||
|
||||
typename map < DIT, list <CT> > :: iterator cdiIter =
|
||||
mClientsPerDataItemMap.find (id);
|
||||
if (cdiIter != mClientsPerDataItemMap.end ()) {
|
||||
set_intersection (cdiIter->second.begin (), cdiIter->second.end (),
|
||||
r.begin (), r.end (),
|
||||
inserter (out, out.begin ()));
|
||||
if (!out.empty ()) {
|
||||
typename list <CT> :: iterator it = out.begin ();
|
||||
for (; it != out.end (); ++it) {
|
||||
cdiIter->second.erase (find (cdiIter->second.begin (),
|
||||
cdiIter->second.end (),
|
||||
*it));
|
||||
}
|
||||
}
|
||||
if (cdiIter->second.empty ()) {
|
||||
mClientsPerDataItemMap.erase (cdiIter);
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void DataItemIndex <CT,DIT> :: add
|
||||
(
|
||||
DIT id,
|
||||
const list <CT> & l,
|
||||
list <CT> & out
|
||||
)
|
||||
{
|
||||
ENTRY_LOG ();
|
||||
list <CT> difference;
|
||||
typename map < DIT, list <CT> > :: iterator cdiIter =
|
||||
mClientsPerDataItemMap.find (id);
|
||||
if (cdiIter != mClientsPerDataItemMap.end ()) {
|
||||
set_difference (l.begin (), l.end (),
|
||||
cdiIter->second.begin (), cdiIter->second.end (),
|
||||
inserter (difference, difference.begin ()));
|
||||
if (!difference.empty ()) {
|
||||
difference.sort ();
|
||||
out = difference;
|
||||
cdiIter->second.merge (difference);
|
||||
}
|
||||
} else {
|
||||
out = l;
|
||||
pair < DIT, list <CT> > cndipair (id, out);
|
||||
mClientsPerDataItemMap.insert (cndipair);
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void DataItemIndex <CT,DIT> :: add
|
||||
(
|
||||
CT client,
|
||||
const list <DIT> & l,
|
||||
list <DIT> & out
|
||||
)
|
||||
{
|
||||
ENTRY_LOG ();
|
||||
typename map < DIT, list <CT> > :: iterator cdiIter;
|
||||
typename list <DIT> :: const_iterator it = l.begin ();
|
||||
for (; it != l.end (); ++it) {
|
||||
cdiIter = mClientsPerDataItemMap.find (*it);
|
||||
if (cdiIter == mClientsPerDataItemMap.end ()) {
|
||||
out.push_back (*it);
|
||||
pair < DIT, list <CT> > cndiPair (*it, list <CT> (1, client));
|
||||
mClientsPerDataItemMap.insert (cndiPair);
|
||||
} else {
|
||||
typename list<CT> :: iterator clientIter =
|
||||
find
|
||||
(
|
||||
cdiIter->second.begin (),
|
||||
cdiIter->second.end (),
|
||||
client
|
||||
);
|
||||
if (clientIter == cdiIter->second.end()) {
|
||||
cdiIter->second.push_back (client);
|
||||
}
|
||||
}
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
// Explicit instantiation must occur in same namespace where class is defined
|
||||
namespace loc_core
|
||||
{
|
||||
template class DataItemIndex <IDataItemObserver *, DataItemId>;
|
||||
template class DataItemIndex <string, DataItemId>;
|
||||
}
|
70
gps/core/data-items/common/DataItemIndex.h
Normal file
70
gps/core/data-items/common/DataItemIndex.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* Copyright (c) 2015, 2017 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 __DATAITEMINDEX_H__
|
||||
#define __DATAITEMINDEX_H__
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <IDataItemIndex.h>
|
||||
|
||||
using loc_core::IDataItemIndex;
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
|
||||
class DataItemIndex : public IDataItemIndex <CT, DIT> {
|
||||
|
||||
public:
|
||||
|
||||
DataItemIndex ();
|
||||
|
||||
~DataItemIndex ();
|
||||
|
||||
void getListOfSubscribedClients (DIT id, std :: list <CT> & out);
|
||||
|
||||
int remove (DIT id);
|
||||
|
||||
void remove (const std :: list <CT> & r, std :: list <DIT> & out);
|
||||
|
||||
void remove (DIT id, const std :: list <CT> & r, std :: list <CT> & out);
|
||||
|
||||
void add (DIT id, const std :: list <CT> & l, std :: list <CT> & out);
|
||||
|
||||
void add (CT client, const std :: list <DIT> & l, std :: list <DIT> & out);
|
||||
|
||||
private:
|
||||
std :: map < DIT, std :: list <CT> > mClientsPerDataItemMap;
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif // #ifndef __DATAITEMINDEX_H__
|
83
gps/core/data-items/common/IClientIndex.h
Normal file
83
gps/core/data-items/common/IClientIndex.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/* Copyright (c) 2015, 2017 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 __ICLIENTINDEX_H__
|
||||
#define __ICLIENTINDEX_H__
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
|
||||
class IClientIndex {
|
||||
public:
|
||||
|
||||
// Checks if client is subscribed
|
||||
virtual bool isSubscribedClient (CT client) = 0;
|
||||
|
||||
// gets subscription list
|
||||
virtual void getSubscribedList (CT client, std :: list <DIT> & out) = 0;
|
||||
|
||||
// removes an entry
|
||||
virtual int remove (CT client) = 0;
|
||||
|
||||
// removes std :: list of data items and returns a list of clients
|
||||
// removed if any.
|
||||
virtual void remove
|
||||
(
|
||||
const std :: list <DIT> & r,
|
||||
std :: list <CT> & out
|
||||
) = 0;
|
||||
|
||||
// removes list of data items indexed by client and returns list
|
||||
// of data items removed if any.
|
||||
virtual void remove
|
||||
(
|
||||
CT client,
|
||||
const std :: list <DIT> & r,
|
||||
std :: list <DIT> & out
|
||||
) = 0;
|
||||
|
||||
// adds/modifies entry in map and returns new data items added.
|
||||
virtual void add
|
||||
(
|
||||
CT client,
|
||||
const std :: list <DIT> & l,
|
||||
std :: list <DIT> & out
|
||||
) = 0;
|
||||
|
||||
// dtor
|
||||
virtual ~IClientIndex () {}
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif // #ifndef __ICLIENTINDEX_H__
|
94
gps/core/data-items/common/IDataItemIndex.h
Normal file
94
gps/core/data-items/common/IDataItemIndex.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
/* Copyright (c) 2015, 2017 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 __IDATAITEMINDEX_H__
|
||||
#define __IDATAITEMINDEX_H__
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
|
||||
class IDataItemIndex {
|
||||
|
||||
public:
|
||||
|
||||
// gets std :: list of subscribed clients
|
||||
virtual void getListOfSubscribedClients
|
||||
(
|
||||
DIT id,
|
||||
std :: list <CT> & out
|
||||
) = 0;
|
||||
|
||||
// removes an entry from
|
||||
virtual int remove (DIT id) = 0;
|
||||
|
||||
// removes list of clients and returns a list of data items
|
||||
// removed if any.
|
||||
virtual void remove
|
||||
(
|
||||
const std :: list <CT> & r,
|
||||
std :: list <DIT> & out
|
||||
) = 0;
|
||||
|
||||
// removes list of clients indexed by data item and returns list of
|
||||
// clients removed if any.
|
||||
virtual void remove
|
||||
(
|
||||
DIT id,
|
||||
const std :: list <CT> & r,
|
||||
std :: list <CT> & out
|
||||
) = 0;
|
||||
|
||||
// adds/modifies entry and returns new clients added
|
||||
virtual void add
|
||||
(
|
||||
DIT id,
|
||||
const std :: list <CT> & l,
|
||||
std :: list <CT> & out
|
||||
) = 0;
|
||||
|
||||
// adds/modifies entry and returns yet to subscribe list of data items
|
||||
virtual void add
|
||||
(
|
||||
CT client,
|
||||
const std :: list <DIT> & l,
|
||||
std :: list <DIT> & out
|
||||
) = 0;
|
||||
|
||||
// dtor
|
||||
virtual ~IDataItemIndex () {}
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif // #ifndef __IDATAITEMINDEX_H__
|
||||
|
64
gps/core/data-items/common/IndexFactory.cpp
Normal file
64
gps/core/data-items/common/IndexFactory.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* Copyright (c) 2015, 2017 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 <string>
|
||||
#include <IndexFactory.h>
|
||||
#include <IClientIndex.h>
|
||||
#include <ClientIndex.h>
|
||||
#include <IDataItemIndex.h>
|
||||
#include <DataItemIndex.h>
|
||||
#include <IDataItemObserver.h>
|
||||
#include <DataItemId.h>
|
||||
|
||||
using namespace std;
|
||||
using loc_core::IClientIndex;
|
||||
using loc_core::IDataItemIndex;
|
||||
using loc_core::IDataItemObserver;
|
||||
using namespace loc_core;
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
inline IClientIndex <CT, DIT> * IndexFactory <CT, DIT> :: createClientIndex
|
||||
()
|
||||
{
|
||||
return new (nothrow) ClientIndex <CT, DIT> ();
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
inline IDataItemIndex <CT, DIT> * IndexFactory <CT, DIT> :: createDataItemIndex
|
||||
()
|
||||
{
|
||||
return new (nothrow) DataItemIndex <CT, DIT> ();
|
||||
}
|
||||
|
||||
// Explicit instantiation must occur in same namespace where class is defined
|
||||
namespace loc_core
|
||||
{
|
||||
template class IndexFactory <IDataItemObserver *, DataItemId>;
|
||||
template class IndexFactory <string, DataItemId>;
|
||||
}
|
48
gps/core/data-items/common/IndexFactory.h
Normal file
48
gps/core/data-items/common/IndexFactory.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* Copyright (c) 2015, 2017 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 __INDEXFACTORY_H__
|
||||
#define __INDEXFACTORY_H__
|
||||
|
||||
#include <IClientIndex.h>
|
||||
#include <IDataItemIndex.h>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
template <typename CT, typename DIT>
|
||||
class IndexFactory {
|
||||
|
||||
public:
|
||||
static IClientIndex <CT, DIT> * createClientIndex ();
|
||||
static IDataItemIndex <CT, DIT> * createDataItemIndex ();
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif // #ifndef __INDEXFACTORY_H__
|
23
gps/core/loc_core_log.cpp
Executable file → Normal file
23
gps/core/loc_core_log.cpp
Executable file → Normal file
|
@ -30,10 +30,9 @@
|
|||
#define LOG_NDEBUG 0
|
||||
#define LOG_TAG "LocSvc_core_log"
|
||||
|
||||
#include <log_util.h>
|
||||
#include <loc_log.h>
|
||||
#include <loc_core_log.h>
|
||||
#include <loc_pla.h>
|
||||
#include <platform_lib_includes.h>
|
||||
|
||||
void LocPosMode::logv() const
|
||||
{
|
||||
|
@ -101,6 +100,26 @@ const char* loc_get_position_recurrence_name(LocGpsPositionRecurrence recur)
|
|||
return loc_get_name_from_val(loc_eng_position_recurrences, loc_eng_position_recurrence_num, (long) recur);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const loc_name_val_s_type loc_eng_aiding_data_bits[] =
|
||||
{
|
||||
NAME_VAL( LOC_GPS_DELETE_EPHEMERIS ),
|
||||
NAME_VAL( LOC_GPS_DELETE_ALMANAC ),
|
||||
NAME_VAL( LOC_GPS_DELETE_POSITION ),
|
||||
NAME_VAL( LOC_GPS_DELETE_TIME ),
|
||||
NAME_VAL( LOC_GPS_DELETE_IONO ),
|
||||
NAME_VAL( LOC_GPS_DELETE_UTC ),
|
||||
NAME_VAL( LOC_GPS_DELETE_HEALTH ),
|
||||
NAME_VAL( LOC_GPS_DELETE_SVDIR ),
|
||||
NAME_VAL( LOC_GPS_DELETE_SVSTEER ),
|
||||
NAME_VAL( LOC_GPS_DELETE_SADATA ),
|
||||
NAME_VAL( LOC_GPS_DELETE_RTI ),
|
||||
NAME_VAL( LOC_GPS_DELETE_CELLDB_INFO ),
|
||||
NAME_VAL( LOC_GPS_DELETE_ALL)
|
||||
};
|
||||
static const int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_aiding_data_mask_names(LocGpsAidingData /*data*/)
|
||||
{
|
||||
return NULL;
|
||||
|
|
0
gps/core/loc_core_log.h
Executable file → Normal file
0
gps/core/loc_core_log.h
Executable file → Normal file
0
gps/core/observer/IDataItemObserver.h
Executable file → Normal file
0
gps/core/observer/IDataItemObserver.h
Executable file → Normal file
0
gps/core/observer/IDataItemSubscription.h
Executable file → Normal file
0
gps/core/observer/IDataItemSubscription.h
Executable file → Normal file
18
gps/core/observer/IFrameworkActionReq.h
Executable file → Normal file
18
gps/core/observer/IFrameworkActionReq.h
Executable file → Normal file
|
@ -70,24 +70,6 @@ public:
|
|||
*/
|
||||
virtual void turnOff (DataItemId dit) = 0;
|
||||
|
||||
#ifdef USE_GLIB
|
||||
/**
|
||||
* @brief Setup WWAN backhaul
|
||||
* @details Setup WWAN backhaul
|
||||
*
|
||||
* @param None
|
||||
*/
|
||||
virtual bool connectBackhaul() = 0;
|
||||
|
||||
/**
|
||||
* @brief Disconnects the WWANbackhaul
|
||||
* @details Disconnects the WWANbackhaul, only if it was setup by us
|
||||
*
|
||||
* @param None
|
||||
*/
|
||||
virtual bool disconnectBackhaul() = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
* @details Destructor
|
||||
|
|
4
gps/core/observer/IOsObserver.h
Executable file → Normal file
4
gps/core/observer/IOsObserver.h
Executable file → Normal file
|
@ -90,10 +90,6 @@ public:
|
|||
// IFrameworkActionReq Overrides
|
||||
inline virtual void turnOn (DataItemId /*dit*/, int /*timeOut*/){}
|
||||
inline virtual void turnOff (DataItemId /*dit*/) {}
|
||||
#ifdef USE_GLIB
|
||||
inline virtual bool connectBackhaul() {}
|
||||
inline virtual bool disconnectBackhaul() {}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
|
|
0
gps/etc/flp.conf
Executable file → Normal file
0
gps/etc/flp.conf
Executable file → Normal file
19
gps/etc/gps.conf
Executable file → Normal file
19
gps/etc/gps.conf
Executable file → Normal file
|
@ -208,17 +208,10 @@ MISSING_PULSE_TIME_DELTA = 900
|
|||
# This settings enables time uncertainty propagation
|
||||
# logic incase of missing PPS pulse
|
||||
PROPAGATION_TIME_UNCERTAINTY = 1
|
||||
XTRA_TEST_ENABLED = 1
|
||||
XTRA_THROTTLE_ENABLED = 0
|
||||
|
||||
#######################################
|
||||
# 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
|
||||
####################################
|
||||
#system time injection
|
||||
####################################
|
||||
XTRA_SYSTEM_TIME_INJECT = 1
|
||||
|
|
0
gps/etc/lowi.conf
Executable file → Normal file
0
gps/etc/lowi.conf
Executable file → Normal file
0
gps/etc/sap.conf
Executable file → Normal file
0
gps/etc/sap.conf
Executable file → Normal file
0
gps/etc/xtwifi.conf
Executable file → Normal file
0
gps/etc/xtwifi.conf
Executable file → Normal file
2
gps/gnss/Agps.cpp
Executable file → Normal file
2
gps/gnss/Agps.cpp
Executable file → Normal file
|
@ -30,7 +30,7 @@
|
|||
#define LOG_TAG "LocSvc_Agps"
|
||||
|
||||
#include <Agps.h>
|
||||
#include <loc_pla.h>
|
||||
#include <platform_lib_includes.h>
|
||||
#include <ContextBase.h>
|
||||
#include <loc_timer.h>
|
||||
|
||||
|
|
20
gps/gnss/Agps.h
Executable file → Normal file
20
gps/gnss/Agps.h
Executable file → Normal file
|
@ -34,8 +34,7 @@
|
|||
#include <list>
|
||||
#include <MsgTask.h>
|
||||
#include <gps_extended_c.h>
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
|
||||
/* ATL callback function pointers
|
||||
* Passed in by Adapter to AgpsManager */
|
||||
|
@ -278,27 +277,32 @@ public:
|
|||
mAgnssNif(NULL), mInternetNif(NULL), mDsNif(NULL) {}
|
||||
|
||||
/* Register callbacks */
|
||||
inline void registerATLCallbacks(AgpsAtlOpenStatusCb atlOpenStatusCb,
|
||||
void registerCallbacks(
|
||||
AgnssStatusIpV4Cb frameworkStatusV4Cb,
|
||||
|
||||
AgpsAtlOpenStatusCb atlOpenStatusCb,
|
||||
AgpsAtlCloseStatusCb atlCloseStatusCb,
|
||||
|
||||
AgpsDSClientInitFn dsClientInitFn,
|
||||
AgpsDSClientOpenAndStartDataCallFn dsClientOpenAndStartDataCallFn,
|
||||
AgpsDSClientStopDataCallFn dsClientStopDataCallFn,
|
||||
AgpsDSClientCloseDataCallFn dsClientCloseDataCallFn,
|
||||
AgpsDSClientReleaseFn dsClientReleaseFn,
|
||||
SendMsgToAdapterMsgQueueFn sendMsgToAdapterQueueFn) {
|
||||
|
||||
SendMsgToAdapterMsgQueueFn sendMsgToAdapterQueueFn ){
|
||||
|
||||
mFrameworkStatusV4Cb = frameworkStatusV4Cb;
|
||||
|
||||
mAtlOpenStatusCb = atlOpenStatusCb;
|
||||
mAtlCloseStatusCb = atlCloseStatusCb;
|
||||
|
||||
mDSClientInitFn = dsClientInitFn;
|
||||
mDSClientOpenAndStartDataCallFn = dsClientOpenAndStartDataCallFn;
|
||||
mDSClientStopDataCallFn = dsClientStopDataCallFn;
|
||||
mDSClientCloseDataCallFn = dsClientCloseDataCallFn;
|
||||
mDSClientReleaseFn = dsClientReleaseFn;
|
||||
mSendMsgToAdapterQueueFn = sendMsgToAdapterQueueFn;
|
||||
}
|
||||
|
||||
inline void registerFrameworkStatusCallback(AgnssStatusIpV4Cb frameworkStatusV4Cb) {
|
||||
mFrameworkStatusV4Cb = frameworkStatusV4Cb;
|
||||
mSendMsgToAdapterQueueFn = sendMsgToAdapterQueueFn;
|
||||
}
|
||||
|
||||
/* Create all AGPS state machines */
|
||||
|
|
4
gps/gnss/Android.mk
Executable file → Normal file
4
gps/gnss/Android.mk
Executable file → Normal file
|
@ -3,7 +3,9 @@ LOCAL_PATH := $(call my-dir)
|
|||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libgnss
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
|
||||
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libutils \
|
||||
|
|
556
gps/gnss/GnssAdapter.cpp
Executable file → Normal file
556
gps/gnss/GnssAdapter.cpp
Executable file → Normal file
|
@ -74,79 +74,12 @@ GnssAdapter::GnssAdapter() :
|
|||
mNiData(),
|
||||
mAgpsManager(),
|
||||
mAgpsCbInfo(),
|
||||
mOdcpiRequestCb(nullptr),
|
||||
mOdcpiRequestActive(false),
|
||||
mOdcpiTimer(this),
|
||||
mOdcpiRequest(),
|
||||
mSystemStatus(SystemStatus::getInstance(mMsgTask)),
|
||||
mServerUrl(":"),
|
||||
mServerUrl(""),
|
||||
mXtraObserver(mSystemStatus->getOsObserver(), mMsgTask)
|
||||
{
|
||||
LOC_LOGD("%s]: Constructor %p", __func__, this);
|
||||
mUlpPositionMode.mode = LOC_POSITION_MODE_INVALID;
|
||||
|
||||
pthread_condattr_t condAttr;
|
||||
pthread_condattr_init(&condAttr);
|
||||
pthread_condattr_setclock(&condAttr, CLOCK_MONOTONIC);
|
||||
pthread_cond_init(&mNiData.session.tCond, &condAttr);
|
||||
pthread_cond_init(&mNiData.sessionEs.tCond, &condAttr);
|
||||
pthread_condattr_destroy(&condAttr);
|
||||
|
||||
/* Set ATL open/close callbacks */
|
||||
AgpsAtlOpenStatusCb atlOpenStatusCb =
|
||||
[this](int handle, int isSuccess, char* apn,
|
||||
AGpsBearerType bearerType, AGpsExtType agpsType) {
|
||||
|
||||
mLocApi->atlOpenStatus(
|
||||
handle, isSuccess, apn, bearerType, agpsType);
|
||||
};
|
||||
AgpsAtlCloseStatusCb atlCloseStatusCb =
|
||||
[this](int handle, int isSuccess) {
|
||||
|
||||
mLocApi->atlCloseStatus(handle, isSuccess);
|
||||
};
|
||||
|
||||
/* Register DS Client APIs */
|
||||
AgpsDSClientInitFn dsClientInitFn =
|
||||
[this](bool isDueToSSR) {
|
||||
|
||||
return mLocApi->initDataServiceClient(isDueToSSR);
|
||||
};
|
||||
|
||||
AgpsDSClientOpenAndStartDataCallFn dsClientOpenAndStartDataCallFn =
|
||||
[this] {
|
||||
|
||||
return mLocApi->openAndStartDataCall();
|
||||
};
|
||||
|
||||
AgpsDSClientStopDataCallFn dsClientStopDataCallFn =
|
||||
[this] {
|
||||
|
||||
mLocApi->stopDataCall();
|
||||
};
|
||||
|
||||
AgpsDSClientCloseDataCallFn dsClientCloseDataCallFn =
|
||||
[this] {
|
||||
|
||||
mLocApi->closeDataCall();
|
||||
};
|
||||
|
||||
AgpsDSClientReleaseFn dsClientReleaseFn =
|
||||
[this] {
|
||||
|
||||
mLocApi->releaseDataServiceClient();
|
||||
};
|
||||
|
||||
/* Send Msg function */
|
||||
SendMsgToAdapterMsgQueueFn sendMsgFn =
|
||||
[this](LocMsg* msg) {
|
||||
|
||||
sendMsg(msg);
|
||||
};
|
||||
mAgpsManager.registerATLCallbacks(atlOpenStatusCb, atlCloseStatusCb,
|
||||
dsClientInitFn, dsClientOpenAndStartDataCallFn, dsClientStopDataCallFn,
|
||||
dsClientCloseDataCallFn, dsClientReleaseFn, sendMsgFn);
|
||||
|
||||
readConfigCommand();
|
||||
setConfigCommand();
|
||||
initDefaultAgpsCommand();
|
||||
|
@ -589,38 +522,6 @@ GnssAdapter::readConfigCommand()
|
|||
}
|
||||
}
|
||||
|
||||
LocationError
|
||||
GnssAdapter::setSuplHostServer(const char* server, int port)
|
||||
{
|
||||
LocationError locErr = LOCATION_ERROR_SUCCESS;
|
||||
if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
|
||||
char serverUrl[MAX_URL_LEN] = {};
|
||||
int32_t length = -1;
|
||||
const char noHost[] = "NONE";
|
||||
|
||||
locErr = LOCATION_ERROR_INVALID_PARAMETER;
|
||||
|
||||
if ((NULL == server) || (server[0] == 0) ||
|
||||
(strncasecmp(noHost, server, sizeof(noHost)) == 0)) {
|
||||
serverUrl[0] = '\0';
|
||||
length = 0;
|
||||
} else if (port > 0) {
|
||||
length = snprintf(serverUrl, sizeof(serverUrl), "%s:%u", server, port);
|
||||
}
|
||||
|
||||
if (length >= 0 && strncasecmp(getServerUrl().c_str(),
|
||||
serverUrl, sizeof(serverUrl)) != 0) {
|
||||
setServerUrl(serverUrl);
|
||||
locErr = mLocApi->setServer(serverUrl, length);
|
||||
if (locErr != LOCATION_ERROR_SUCCESS) {
|
||||
LOC_LOGE("%s]:Error while setting SUPL_HOST server:%s",
|
||||
__func__, serverUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
return locErr;
|
||||
}
|
||||
|
||||
void
|
||||
GnssAdapter::setConfigCommand()
|
||||
{
|
||||
|
@ -640,8 +541,6 @@ GnssAdapter::setConfigCommand()
|
|||
mApi.setLPPConfig(mAdapter.convertLppProfile(ContextBase::mGps_conf.LPP_PROFILE));
|
||||
mApi.setAGLONASSProtocol(ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT);
|
||||
}
|
||||
mAdapter.setSuplHostServer(ContextBase::mGps_conf.SUPL_HOST,
|
||||
ContextBase::mGps_conf.SUPL_PORT);
|
||||
mApi.setSensorControlConfig(ContextBase::mSap_conf.SENSOR_USAGE,
|
||||
ContextBase::mSap_conf.SENSOR_PROVIDER);
|
||||
mApi.setLPPeProtocolCp(
|
||||
|
@ -784,8 +683,30 @@ GnssAdapter::gnssUpdateConfigCommand(GnssConfig config)
|
|||
}
|
||||
if (mConfig.flags & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
|
||||
if (GNSS_ASSISTANCE_TYPE_SUPL == mConfig.assistanceServer.type) {
|
||||
err = mAdapter.setSuplHostServer(mConfig.assistanceServer.hostName,
|
||||
mConfig.assistanceServer.port);
|
||||
if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
|
||||
char serverUrl[MAX_URL_LEN] = {};
|
||||
int32_t length = 0;
|
||||
const char noHost[] = "NONE";
|
||||
if (NULL == mConfig.assistanceServer.hostName ||
|
||||
strncasecmp(noHost,
|
||||
mConfig.assistanceServer.hostName,
|
||||
sizeof(noHost)) == 0) {
|
||||
err = LOCATION_ERROR_INVALID_PARAMETER;
|
||||
} else {
|
||||
length = snprintf(serverUrl, sizeof(serverUrl), "%s:%u",
|
||||
mConfig.assistanceServer.hostName,
|
||||
mConfig.assistanceServer.port);
|
||||
}
|
||||
|
||||
if (length > 0 && strncasecmp(mAdapter.getServerUrl().c_str(),
|
||||
serverUrl, sizeof(serverUrl)) != 0) {
|
||||
mAdapter.setServerUrl(serverUrl);
|
||||
err = mApi.setServer(serverUrl, length);
|
||||
}
|
||||
|
||||
} else {
|
||||
err = LOCATION_ERROR_SUCCESS;
|
||||
}
|
||||
} else if (GNSS_ASSISTANCE_TYPE_C2K == mConfig.assistanceServer.type) {
|
||||
if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
|
||||
struct in_addr addr;
|
||||
|
@ -938,7 +859,7 @@ GnssAdapter::gnssDeleteAidingDataCommand(GnssAidingData& data)
|
|||
mAdapter.reportResponse(err, mSessionId);
|
||||
SystemStatus* s = mAdapter.getSystemStatus();
|
||||
if ((nullptr != s) && (mData.deleteAll)) {
|
||||
s->setDefaultGnssEngineStates();
|
||||
s->setDefaultReport();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -947,26 +868,6 @@ GnssAdapter::gnssDeleteAidingDataCommand(GnssAidingData& data)
|
|||
return sessionId;
|
||||
}
|
||||
|
||||
void
|
||||
GnssAdapter::gnssUpdateXtraThrottleCommand(const bool enabled)
|
||||
{
|
||||
LOC_LOGD("%s] enabled:%d", __func__, enabled);
|
||||
|
||||
struct UpdateXtraThrottleMsg : public LocMsg {
|
||||
GnssAdapter& mAdapter;
|
||||
const bool mEnabled;
|
||||
inline UpdateXtraThrottleMsg(GnssAdapter& adapter, const bool enabled) :
|
||||
LocMsg(),
|
||||
mAdapter(adapter),
|
||||
mEnabled(enabled) {}
|
||||
inline virtual void proc() const {
|
||||
mAdapter.mXtraObserver.updateXtraThrottle(mEnabled);
|
||||
}
|
||||
};
|
||||
|
||||
sendMsg(new UpdateXtraThrottleMsg(*this, enabled));
|
||||
}
|
||||
|
||||
void
|
||||
GnssAdapter::injectLocationCommand(double latitude, double longitude, float accuracy)
|
||||
{
|
||||
|
@ -1176,16 +1077,7 @@ GnssAdapter::updateClientsEventMask()
|
|||
mask |= LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT;
|
||||
mask |= LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT;
|
||||
|
||||
LOC_LOGD("%s]: Auto usecase, Enable MEAS/POLY - mask 0x%" PRIu64 "", __func__, mask);
|
||||
}
|
||||
|
||||
if (mAgpsCbInfo.statusV4Cb != NULL) {
|
||||
mask |= LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST;
|
||||
}
|
||||
|
||||
// Add ODCPI handling
|
||||
if (nullptr != mOdcpiRequestCb) {
|
||||
mask |= LOC_API_ADAPTER_BIT_REQUEST_WIFI;
|
||||
LOC_LOGD("%s]: Auto usecase, Enable MEAS/POLY - mask 0x%x", __func__, mask);
|
||||
}
|
||||
|
||||
updateEvtMask(mask, LOC_REGISTRATION_MASK_SET);
|
||||
|
@ -1213,9 +1105,6 @@ GnssAdapter::restartSessions()
|
|||
{
|
||||
LOC_LOGD("%s]: ", __func__);
|
||||
|
||||
// odcpi session is no longer active after restart
|
||||
mOdcpiRequestActive = false;
|
||||
|
||||
if (mTrackingSessions.empty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -2054,8 +1943,7 @@ GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation,
|
|||
inline virtual void proc() const {
|
||||
// extract bug report info - this returns true if consumed by systemstatus
|
||||
SystemStatus* s = mAdapter.getSystemStatus();
|
||||
if ((nullptr != s) &&
|
||||
((LOC_SESS_SUCCESS == mStatus) || (LOC_SESS_INTERMEDIATE == mStatus))){
|
||||
if ((nullptr != s) && (LOC_SESS_SUCCESS == mStatus)){
|
||||
s->eventPosition(mUlpLocation, mLocationExtended);
|
||||
}
|
||||
mAdapter.reportPosition(mUlpLocation, mLocationExtended, mStatus, mTechMask);
|
||||
|
@ -2065,41 +1953,34 @@ GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation,
|
|||
sendMsg(new MsgReportPosition(*this, ulpLocation, locationExtended, status, techMask));
|
||||
}
|
||||
|
||||
bool
|
||||
GnssAdapter::needReport(const UlpLocation& ulpLocation,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask techMask) {
|
||||
bool reported = false;
|
||||
if (LOC_SESS_SUCCESS == status) {
|
||||
// this is a final fix
|
||||
LocPosTechMask mask =
|
||||
LOC_POS_TECH_MASK_SATELLITE | LOC_POS_TECH_MASK_SENSORS | LOC_POS_TECH_MASK_HYBRID;
|
||||
// it is a Satellite fix or a sensor fix
|
||||
reported = (mask & techMask);
|
||||
} else if (LOC_SESS_INTERMEDIATE == status &&
|
||||
LOC_SESS_INTERMEDIATE == ContextBase::mGps_conf.INTERMEDIATE_POS) {
|
||||
// this is a intermediate fix and we accepte intermediate
|
||||
|
||||
// it is NOT the case that
|
||||
// there is inaccuracy; and
|
||||
// we care about inaccuracy; and
|
||||
// the inaccuracy exceeds our tolerance
|
||||
reported = !((ulpLocation.gpsLocation.flags & LOC_GPS_LOCATION_HAS_ACCURACY) &&
|
||||
(ContextBase::mGps_conf.ACCURACY_THRES != 0) &&
|
||||
(ulpLocation.gpsLocation.accuracy > ContextBase::mGps_conf.ACCURACY_THRES));
|
||||
}
|
||||
|
||||
return reported;
|
||||
}
|
||||
|
||||
void
|
||||
GnssAdapter::reportPosition(const UlpLocation& ulpLocation,
|
||||
const GpsLocationExtended& locationExtended,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask techMask)
|
||||
{
|
||||
bool reported = needReport(ulpLocation, status, techMask);
|
||||
if (reported) {
|
||||
bool reported = false;
|
||||
// what's in the if is... (line by line)
|
||||
// 1. this is a final fix; and
|
||||
// 1.1 it is a Satellite fix; or
|
||||
// 1.2 it is a sensor fix
|
||||
// 2. (must be intermediate fix... implicit)
|
||||
// 2.1 we accepte intermediate; and
|
||||
// 2.2 it is NOT the case that
|
||||
// 2.2.1 there is inaccuracy; and
|
||||
// 2.2.2 we care about inaccuracy; and
|
||||
// 2.2.3 the inaccuracy exceeds our tolerance
|
||||
if ((LOC_SESS_SUCCESS == status &&
|
||||
((LOC_POS_TECH_MASK_SATELLITE |
|
||||
LOC_POS_TECH_MASK_SENSORS |
|
||||
LOC_POS_TECH_MASK_HYBRID) &
|
||||
techMask)) ||
|
||||
(LOC_SESS_INTERMEDIATE == ContextBase::mGps_conf.INTERMEDIATE_POS &&
|
||||
!((ulpLocation.gpsLocation.flags &
|
||||
LOC_GPS_LOCATION_HAS_ACCURACY) &&
|
||||
(ContextBase::mGps_conf.ACCURACY_THRES != 0) &&
|
||||
(ulpLocation.gpsLocation.accuracy >
|
||||
ContextBase::mGps_conf.ACCURACY_THRES)))) {
|
||||
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_GNSS_SV_USED_DATA) {
|
||||
mGnssSvIdUsedInPosAvail = true;
|
||||
mGnssSvIdUsedInPosition = locationExtended.gnss_sv_used_ids;
|
||||
|
@ -2116,6 +1997,7 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation,
|
|||
it->second.gnssLocationInfoCb(locationInfo);
|
||||
}
|
||||
}
|
||||
reported = true;
|
||||
}
|
||||
|
||||
if (NMEA_PROVIDER_AP == ContextBase::mGps_conf.NMEA_PROVIDER && !mTrackingSessions.empty()) {
|
||||
|
@ -2342,14 +2224,14 @@ static void* niThreadProc(void *args)
|
|||
NiSession* pSession = (NiSession*)args;
|
||||
int rc = 0; /* return code from pthread calls */
|
||||
|
||||
struct timespec present_time;
|
||||
struct timeval present_time;
|
||||
struct timespec expire_time;
|
||||
|
||||
pthread_mutex_lock(&pSession->tLock);
|
||||
/* Calculate absolute expire time */
|
||||
clock_gettime(CLOCK_MONOTONIC, &present_time);
|
||||
gettimeofday(&present_time, NULL);
|
||||
expire_time.tv_sec = present_time.tv_sec + pSession->respTimeLeft;
|
||||
expire_time.tv_nsec = present_time.tv_nsec;
|
||||
expire_time.tv_nsec = present_time.tv_usec * 1000;
|
||||
LOC_LOGD("%s]: time out set for abs time %ld with delay %d sec",
|
||||
__func__, (long)expire_time.tv_sec, pSession->respTimeLeft);
|
||||
|
||||
|
@ -2474,7 +2356,7 @@ void
|
|||
GnssAdapter::reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurements,
|
||||
int msInWeek)
|
||||
{
|
||||
LOC_LOGD("%s]: msInWeek=%d", __func__, msInWeek);
|
||||
LOC_LOGD("%s]: ", __func__);
|
||||
|
||||
struct MsgReportGnssMeasurementData : public LocMsg {
|
||||
GnssAdapter& mAdapter;
|
||||
|
@ -2525,170 +2407,19 @@ GnssAdapter::reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial)
|
|||
mUlpProxy->reportSvPolynomial(svPolynomial);
|
||||
}
|
||||
|
||||
bool
|
||||
GnssAdapter::reportOdcpiRequestEvent(OdcpiRequestInfo& request)
|
||||
{
|
||||
struct MsgReportOdcpiRequest : public LocMsg {
|
||||
GnssAdapter& mAdapter;
|
||||
OdcpiRequestInfo mOdcpiRequest;
|
||||
inline MsgReportOdcpiRequest(GnssAdapter& adapter, OdcpiRequestInfo& request) :
|
||||
LocMsg(),
|
||||
mAdapter(adapter),
|
||||
mOdcpiRequest(request) {}
|
||||
inline virtual void proc() const {
|
||||
mAdapter.reportOdcpiRequest(mOdcpiRequest);
|
||||
}
|
||||
};
|
||||
|
||||
sendMsg(new MsgReportOdcpiRequest(*this, request));
|
||||
return true;
|
||||
}
|
||||
|
||||
void GnssAdapter::reportOdcpiRequest(const OdcpiRequestInfo& request)
|
||||
{
|
||||
if (nullptr != mOdcpiRequestCb) {
|
||||
LOC_LOGd("request: type %d, tbf %d, isEmergency %d"
|
||||
" requestActive: %d timerActive: %d",
|
||||
request.type, request.tbfMillis, request.isEmergencyMode,
|
||||
mOdcpiRequestActive, mOdcpiTimer.isActive());
|
||||
// ODCPI START and ODCPI STOP from modem can come in quick succession
|
||||
// so the mOdcpiTimer helps avoid spamming the framework as well as
|
||||
// extending the odcpi session past 30 seconds if needed
|
||||
if (ODCPI_REQUEST_TYPE_START == request.type) {
|
||||
if (false == mOdcpiRequestActive && false == mOdcpiTimer.isActive()) {
|
||||
mOdcpiRequestCb(request);
|
||||
mOdcpiRequestActive = true;
|
||||
mOdcpiTimer.start();
|
||||
// if the current active odcpi session is non-emergency, and the new
|
||||
// odcpi request is emergency, replace the odcpi request with new request
|
||||
// and restart the timer
|
||||
} else if (false == mOdcpiRequest.isEmergencyMode &&
|
||||
true == request.isEmergencyMode) {
|
||||
mOdcpiRequestCb(request);
|
||||
mOdcpiRequestActive = true;
|
||||
if (true == mOdcpiTimer.isActive()) {
|
||||
mOdcpiTimer.restart();
|
||||
} else {
|
||||
mOdcpiTimer.start();
|
||||
}
|
||||
// if ODCPI request is not active but the timer is active, then
|
||||
// just update the active state and wait for timer to expire
|
||||
// before requesting new ODCPI to avoid spamming ODCPI requests
|
||||
} else if (false == mOdcpiRequestActive && true == mOdcpiTimer.isActive()) {
|
||||
mOdcpiRequestActive = true;
|
||||
}
|
||||
mOdcpiRequest = request;
|
||||
// the request is being stopped, but allow timer to expire first
|
||||
// before stopping the timer just in case more ODCPI requests come
|
||||
// to avoid spamming more odcpi requests to the framework
|
||||
} else {
|
||||
mOdcpiRequestActive = false;
|
||||
}
|
||||
} else {
|
||||
LOC_LOGw("ODCPI request not supported");
|
||||
}
|
||||
}
|
||||
|
||||
void GnssAdapter::initOdcpiCommand(const OdcpiRequestCallback& callback)
|
||||
{
|
||||
struct MsgInitOdcpi : public LocMsg {
|
||||
GnssAdapter& mAdapter;
|
||||
OdcpiRequestCallback mOdcpiCb;
|
||||
inline MsgInitOdcpi(GnssAdapter& adapter,
|
||||
const OdcpiRequestCallback& callback) :
|
||||
LocMsg(),
|
||||
mAdapter(adapter),
|
||||
mOdcpiCb(callback) {}
|
||||
inline virtual void proc() const {
|
||||
mAdapter.initOdcpi(mOdcpiCb);
|
||||
}
|
||||
};
|
||||
|
||||
sendMsg(new MsgInitOdcpi(*this, callback));
|
||||
}
|
||||
|
||||
void GnssAdapter::initOdcpi(const OdcpiRequestCallback& callback)
|
||||
{
|
||||
mOdcpiRequestCb = callback;
|
||||
|
||||
/* Register for WIFI request */
|
||||
updateEvtMask(LOC_API_ADAPTER_BIT_REQUEST_WIFI,
|
||||
LOC_REGISTRATION_MASK_ENABLED);
|
||||
}
|
||||
|
||||
void GnssAdapter::injectOdcpiCommand(const Location& location)
|
||||
{
|
||||
struct MsgInjectOdcpi : public LocMsg {
|
||||
GnssAdapter& mAdapter;
|
||||
Location mLocation;
|
||||
inline MsgInjectOdcpi(GnssAdapter& adapter, const Location& location) :
|
||||
LocMsg(),
|
||||
mAdapter(adapter),
|
||||
mLocation(location) {}
|
||||
inline virtual void proc() const {
|
||||
mAdapter.injectOdcpi(mLocation);
|
||||
}
|
||||
};
|
||||
|
||||
sendMsg(new MsgInjectOdcpi(*this, location));
|
||||
}
|
||||
|
||||
void GnssAdapter::injectOdcpi(const Location& location)
|
||||
{
|
||||
LOC_LOGd("ODCPI Injection: requestActive: %d timerActive: %d"
|
||||
"lat %.7f long %.7f",
|
||||
mOdcpiRequestActive, mOdcpiTimer.isActive(),
|
||||
location.latitude, location.longitude);
|
||||
|
||||
loc_api_adapter_err err = mLocApi->injectPosition(location);
|
||||
if (LOC_API_ADAPTER_ERR_SUCCESS != err) {
|
||||
LOC_LOGe("Inject Position API error %d", err);
|
||||
}
|
||||
}
|
||||
|
||||
// Called in the context of LocTimer thread
|
||||
void OdcpiTimer::timeOutCallback()
|
||||
{
|
||||
if (nullptr != mAdapter) {
|
||||
mAdapter->odcpiTimerExpireEvent();
|
||||
}
|
||||
}
|
||||
|
||||
// Called in the context of LocTimer thread
|
||||
void GnssAdapter::odcpiTimerExpireEvent()
|
||||
{
|
||||
struct MsgOdcpiTimerExpire : public LocMsg {
|
||||
GnssAdapter& mAdapter;
|
||||
inline MsgOdcpiTimerExpire(GnssAdapter& adapter) :
|
||||
LocMsg(),
|
||||
mAdapter(adapter) {}
|
||||
inline virtual void proc() const {
|
||||
mAdapter.odcpiTimerExpire();
|
||||
}
|
||||
};
|
||||
sendMsg(new MsgOdcpiTimerExpire(*this));
|
||||
}
|
||||
void GnssAdapter::odcpiTimerExpire()
|
||||
{
|
||||
LOC_LOGd("requestActive: %d timerActive: %d",
|
||||
mOdcpiRequestActive, mOdcpiTimer.isActive());
|
||||
|
||||
// if ODCPI request is still active after timer
|
||||
// expires, request again and restart timer
|
||||
if (mOdcpiRequestActive) {
|
||||
mOdcpiRequestCb(mOdcpiRequest);
|
||||
mOdcpiTimer.restart();
|
||||
} else {
|
||||
mOdcpiTimer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
void GnssAdapter::initDefaultAgps() {
|
||||
LOC_LOGD("%s]: ", __func__);
|
||||
|
||||
LocationCapabilitiesMask mask = getCapabilities();
|
||||
if (!(mask & LOCATION_CAPABILITIES_GNSS_MSB_BIT) &&
|
||||
!(mask & LOCATION_CAPABILITIES_GNSS_MSA_BIT)) {
|
||||
LOC_LOGI("%s]: Target does not support MSB and MSA.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
void *handle = nullptr;
|
||||
if ((handle = dlopen("libloc_net_iface.so", RTLD_NOW)) == nullptr) {
|
||||
LOC_LOGD("%s]: libloc_net_iface.so not found !", __func__);
|
||||
LOC_LOGE("%s]: libloc_net_iface.so not found !", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2706,7 +2437,7 @@ void GnssAdapter::initDefaultAgps() {
|
|||
return;
|
||||
}
|
||||
|
||||
initAgps(cbInfo);
|
||||
initAgpsCommand(cbInfo);
|
||||
}
|
||||
|
||||
void GnssAdapter::initDefaultAgpsCommand() {
|
||||
|
@ -2717,6 +2448,7 @@ void GnssAdapter::initDefaultAgpsCommand() {
|
|||
inline MsgInitDefaultAgps(GnssAdapter& adapter) :
|
||||
LocMsg(),
|
||||
mAdapter(adapter) {
|
||||
LOC_LOGV("MsgInitDefaultAgps");
|
||||
}
|
||||
inline virtual void proc() const {
|
||||
mAdapter.initDefaultAgps();
|
||||
|
@ -2727,53 +2459,141 @@ void GnssAdapter::initDefaultAgpsCommand() {
|
|||
}
|
||||
|
||||
/* INIT LOC AGPS MANAGER */
|
||||
|
||||
void GnssAdapter::initAgps(const AgpsCbInfo& cbInfo) {
|
||||
LOC_LOGD("%s]: mAgpsCbInfo.cbPriority - %d; cbInfo.cbPriority - %d",
|
||||
__func__, mAgpsCbInfo.cbPriority, cbInfo.cbPriority)
|
||||
|
||||
if (!((ContextBase::mGps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSB) ||
|
||||
(ContextBase::mGps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSA))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAgpsCbInfo.cbPriority > cbInfo.cbPriority) {
|
||||
return;
|
||||
} else {
|
||||
mAgpsCbInfo = cbInfo;
|
||||
|
||||
mAgpsManager.registerFrameworkStatusCallback((AgnssStatusIpV4Cb)cbInfo.statusV4Cb);
|
||||
|
||||
mAgpsManager.createAgpsStateMachines();
|
||||
|
||||
/* Register for AGPS event mask */
|
||||
updateEvtMask(LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST,
|
||||
LOC_REGISTRATION_MASK_ENABLED);
|
||||
}
|
||||
}
|
||||
|
||||
void GnssAdapter::initAgpsCommand(const AgpsCbInfo& cbInfo){
|
||||
|
||||
LOC_LOGI("GnssAdapter::initAgpsCommand");
|
||||
|
||||
/* Set ATL open/close callbacks */
|
||||
AgpsAtlOpenStatusCb atlOpenStatusCb =
|
||||
[this](int handle, int isSuccess, char* apn,
|
||||
AGpsBearerType bearerType, AGpsExtType agpsType) {
|
||||
|
||||
mLocApi->atlOpenStatus(
|
||||
handle, isSuccess, apn, bearerType, agpsType);
|
||||
};
|
||||
AgpsAtlCloseStatusCb atlCloseStatusCb =
|
||||
[this](int handle, int isSuccess) {
|
||||
|
||||
mLocApi->atlCloseStatus(handle, isSuccess);
|
||||
};
|
||||
|
||||
/* Register DS Client APIs */
|
||||
AgpsDSClientInitFn dsClientInitFn =
|
||||
[this](bool isDueToSSR) {
|
||||
|
||||
return mLocApi->initDataServiceClient(isDueToSSR);
|
||||
};
|
||||
|
||||
AgpsDSClientOpenAndStartDataCallFn dsClientOpenAndStartDataCallFn =
|
||||
[this] {
|
||||
|
||||
return mLocApi->openAndStartDataCall();
|
||||
};
|
||||
|
||||
AgpsDSClientStopDataCallFn dsClientStopDataCallFn =
|
||||
[this] {
|
||||
|
||||
mLocApi->stopDataCall();
|
||||
};
|
||||
|
||||
AgpsDSClientCloseDataCallFn dsClientCloseDataCallFn =
|
||||
[this] {
|
||||
|
||||
mLocApi->closeDataCall();
|
||||
};
|
||||
|
||||
AgpsDSClientReleaseFn dsClientReleaseFn =
|
||||
[this] {
|
||||
|
||||
mLocApi->releaseDataServiceClient();
|
||||
};
|
||||
|
||||
/* Send Msg function */
|
||||
SendMsgToAdapterMsgQueueFn sendMsgFn =
|
||||
[this](LocMsg* msg) {
|
||||
|
||||
sendMsg(msg);
|
||||
};
|
||||
|
||||
/* Message to initialize AGPS module */
|
||||
struct AgpsMsgInit: public LocMsg {
|
||||
const AgpsCbInfo mCbInfo;
|
||||
|
||||
AgpsManager* mAgpsManager;
|
||||
|
||||
AgnssStatusIpV4Cb mFrameworkStatusV4Cb;
|
||||
|
||||
AgpsAtlOpenStatusCb mAtlOpenStatusCb;
|
||||
AgpsAtlCloseStatusCb mAtlCloseStatusCb;
|
||||
|
||||
AgpsDSClientInitFn mDSClientInitFn;
|
||||
AgpsDSClientOpenAndStartDataCallFn mDSClientOpenAndStartDataCallFn;
|
||||
AgpsDSClientStopDataCallFn mDSClientStopDataCallFn;
|
||||
AgpsDSClientCloseDataCallFn mDSClientCloseDataCallFn;
|
||||
AgpsDSClientReleaseFn mDSClientReleaseFn;
|
||||
|
||||
SendMsgToAdapterMsgQueueFn mSendMsgFn;
|
||||
GnssAdapter& mAdapter;
|
||||
|
||||
inline AgpsMsgInit(const AgpsCbInfo& cbInfo,
|
||||
inline AgpsMsgInit(AgpsManager* agpsManager,
|
||||
AgnssStatusIpV4Cb frameworkStatusV4Cb,
|
||||
AgpsAtlOpenStatusCb atlOpenStatusCb,
|
||||
AgpsAtlCloseStatusCb atlCloseStatusCb,
|
||||
AgpsDSClientInitFn dsClientInitFn,
|
||||
AgpsDSClientOpenAndStartDataCallFn dsClientOpenAndStartDataCallFn,
|
||||
AgpsDSClientStopDataCallFn dsClientStopDataCallFn,
|
||||
AgpsDSClientCloseDataCallFn dsClientCloseDataCallFn,
|
||||
AgpsDSClientReleaseFn dsClientReleaseFn,
|
||||
SendMsgToAdapterMsgQueueFn sendMsgFn,
|
||||
GnssAdapter& adapter) :
|
||||
LocMsg(), mCbInfo(cbInfo), mAdapter(adapter) {
|
||||
LocMsg(), mAgpsManager(agpsManager), mFrameworkStatusV4Cb(
|
||||
frameworkStatusV4Cb), mAtlOpenStatusCb(atlOpenStatusCb), mAtlCloseStatusCb(
|
||||
atlCloseStatusCb), mDSClientInitFn(dsClientInitFn), mDSClientOpenAndStartDataCallFn(
|
||||
dsClientOpenAndStartDataCallFn), mDSClientStopDataCallFn(
|
||||
dsClientStopDataCallFn), mDSClientCloseDataCallFn(
|
||||
dsClientCloseDataCallFn), mDSClientReleaseFn(
|
||||
dsClientReleaseFn), mSendMsgFn(sendMsgFn),
|
||||
mAdapter(adapter) {
|
||||
|
||||
LOC_LOGV("AgpsMsgInit");
|
||||
}
|
||||
|
||||
inline virtual void proc() const {
|
||||
|
||||
LOC_LOGV("AgpsMsgInit::proc()");
|
||||
mAdapter.initAgps(mCbInfo);
|
||||
|
||||
mAgpsManager->registerCallbacks(mFrameworkStatusV4Cb, mAtlOpenStatusCb,
|
||||
mAtlCloseStatusCb, mDSClientInitFn,
|
||||
mDSClientOpenAndStartDataCallFn, mDSClientStopDataCallFn,
|
||||
mDSClientCloseDataCallFn, mDSClientReleaseFn, mSendMsgFn);
|
||||
|
||||
mAgpsManager->createAgpsStateMachines();
|
||||
|
||||
/* Register for AGPS event mask */
|
||||
mAdapter.updateEvtMask(LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST,
|
||||
LOC_REGISTRATION_MASK_ENABLED);
|
||||
}
|
||||
};
|
||||
|
||||
if (mAgpsCbInfo.cbPriority > cbInfo.cbPriority) {
|
||||
LOC_LOGI("Higher priority AGPS CB already registered (%d > %d) !",
|
||||
mAgpsCbInfo.cbPriority, cbInfo.cbPriority);
|
||||
return;
|
||||
} else {
|
||||
mAgpsCbInfo = cbInfo;
|
||||
LOC_LOGI("Registering AGPS CB %p with priority %d",
|
||||
mAgpsCbInfo.statusV4Cb, mAgpsCbInfo.cbPriority);
|
||||
}
|
||||
|
||||
/* Send message to initialize AGPS Manager */
|
||||
sendMsg(new AgpsMsgInit(cbInfo, *this));
|
||||
sendMsg(new AgpsMsgInit(
|
||||
&mAgpsManager,
|
||||
(AgnssStatusIpV4Cb)cbInfo.statusV4Cb,
|
||||
atlOpenStatusCb, atlCloseStatusCb,
|
||||
dsClientInitFn, dsClientOpenAndStartDataCallFn,
|
||||
dsClientStopDataCallFn, dsClientCloseDataCallFn,
|
||||
dsClientReleaseFn,
|
||||
sendMsgFn,
|
||||
*this));
|
||||
}
|
||||
|
||||
/* GnssAdapter::requestATL
|
||||
|
@ -3173,9 +2993,6 @@ bool GnssAdapter::getDebugReport(GnssDebugReport& r)
|
|||
r.mLocation.mLocation.longitude =
|
||||
(double)(reports.mBestPosition.back().mBestLon) * RAD2DEG;
|
||||
r.mLocation.mLocation.altitude = reports.mBestPosition.back().mBestAlt;
|
||||
r.mLocation.mLocation.accuracy =
|
||||
(double)(reports.mBestPosition.back().mBestHepe);
|
||||
|
||||
r.mLocation.mUtcReported = reports.mBestPosition.back().mUtcReported;
|
||||
}
|
||||
else {
|
||||
|
@ -3201,8 +3018,8 @@ bool GnssAdapter::getDebugReport(GnssDebugReport& r)
|
|||
(int64_t)(reports.mTimeAndClock.back().mGpsTowMs);
|
||||
|
||||
r.mTime.timeUncertaintyNs =
|
||||
((float)(reports.mTimeAndClock.back().mTimeUnc) +
|
||||
(float)(reports.mTimeAndClock.back().mLeapSecUnc))*1000.0f;
|
||||
(float)((reports.mTimeAndClock.back().mTimeUnc +
|
||||
reports.mTimeAndClock.back().mLeapSecUnc)*1000);
|
||||
r.mTime.frequencyUncertaintyNsPerSec =
|
||||
(float)(reports.mTimeAndClock.back().mClockFreqBiasUnc);
|
||||
LOC_LOGV("getDebugReport - timeestimate=%" PRIu64 " unc=%f frequnc=%f",
|
||||
|
@ -3235,12 +3052,12 @@ GnssAdapter::getAgcInformation(GnssMeasurementsNotification& measurements, int m
|
|||
systemstatus->getReport(reports, true);
|
||||
|
||||
if ((!reports.mRfAndParams.empty()) && (!reports.mTimeAndClock.empty()) &&
|
||||
reports.mTimeAndClock.back().mTimeValid &&
|
||||
(abs(msInWeek - (int)reports.mTimeAndClock.back().mGpsTowMs) < 2000)) {
|
||||
|
||||
for (size_t i = 0; i < measurements.count; i++) {
|
||||
switch (measurements.measurements[i].svType) {
|
||||
case GNSS_SV_TYPE_GPS:
|
||||
case GNSS_SV_TYPE_QZSS:
|
||||
measurements.measurements[i].agcLevelDb =
|
||||
reports.mRfAndParams.back().mAgcGps;
|
||||
measurements.measurements[i].flags |=
|
||||
|
@ -3268,6 +3085,7 @@ GnssAdapter::getAgcInformation(GnssMeasurementsNotification& measurements, int m
|
|||
GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT;
|
||||
break;
|
||||
|
||||
case GNSS_SV_TYPE_QZSS:
|
||||
case GNSS_SV_TYPE_SBAS:
|
||||
case GNSS_SV_TYPE_UNKNOWN:
|
||||
default:
|
||||
|
|
56
gps/gnss/GnssAdapter.h
Executable file → Normal file
56
gps/gnss/GnssAdapter.h
Executable file → Normal file
|
@ -43,39 +43,9 @@
|
|||
#define MAX_SATELLITES_IN_USE 12
|
||||
#define LOC_NI_NO_RESPONSE_TIME 20
|
||||
#define LOC_GPS_NI_RESPONSE_IGNORE 4
|
||||
#define ODCPI_EXPECTED_INJECTION_TIME_MS 10000
|
||||
|
||||
class GnssAdapter;
|
||||
|
||||
class OdcpiTimer : public LocTimer {
|
||||
public:
|
||||
OdcpiTimer(GnssAdapter* adapter) :
|
||||
LocTimer(), mAdapter(adapter), mActive(false) {}
|
||||
|
||||
inline void start() {
|
||||
mActive = true;
|
||||
LocTimer::start(ODCPI_EXPECTED_INJECTION_TIME_MS, false);
|
||||
}
|
||||
inline void stop() {
|
||||
mActive = false;
|
||||
LocTimer::stop();
|
||||
}
|
||||
inline void restart() {
|
||||
stop();
|
||||
start();
|
||||
}
|
||||
inline bool isActive() {
|
||||
return mActive;
|
||||
}
|
||||
|
||||
private:
|
||||
// Override
|
||||
virtual void timeOutCallback() override;
|
||||
|
||||
GnssAdapter* mAdapter;
|
||||
bool mActive;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
pthread_t thread; /* NI thread */
|
||||
uint32_t respTimeLeft; /* examine time for NI response */
|
||||
|
@ -111,7 +81,6 @@ namespace loc_core {
|
|||
}
|
||||
|
||||
class GnssAdapter : public LocAdapterBase {
|
||||
|
||||
/* ==== ULP ============================================================================ */
|
||||
UlpProxyBase* mUlpProxy;
|
||||
|
||||
|
@ -133,18 +102,10 @@ class GnssAdapter : public LocAdapterBase {
|
|||
/* ==== NI ============================================================================= */
|
||||
NiData mNiData;
|
||||
|
||||
/* ==== AGPS =========================================================================== */
|
||||
/* ==== AGPS ========================================================*/
|
||||
// This must be initialized via initAgps()
|
||||
AgpsManager mAgpsManager;
|
||||
AgpsCbInfo mAgpsCbInfo;
|
||||
void initAgps(const AgpsCbInfo& cbInfo);
|
||||
|
||||
/* ==== ODCPI ========================================================================== */
|
||||
OdcpiRequestCallback mOdcpiRequestCb;
|
||||
bool mOdcpiRequestActive;
|
||||
OdcpiTimer mOdcpiTimer;
|
||||
OdcpiRequestInfo mOdcpiRequest;
|
||||
void odcpiTimerExpire();
|
||||
|
||||
/* === SystemStatus ===================================================================== */
|
||||
SystemStatus* mSystemStatus;
|
||||
|
@ -190,7 +151,6 @@ public:
|
|||
LocationCallbacks getClientCallbacks(LocationAPI* client);
|
||||
LocationCapabilitiesMask getCapabilities();
|
||||
void broadcastCapabilities(LocationCapabilitiesMask);
|
||||
LocationError setSuplHostServer(const char* server, int port);
|
||||
|
||||
/* ==== TRACKING ======================================================================= */
|
||||
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
|
||||
|
@ -238,7 +198,6 @@ public:
|
|||
void setConfigCommand();
|
||||
uint32_t* gnssUpdateConfigCommand(GnssConfig config);
|
||||
uint32_t gnssDeleteAidingDataCommand(GnssAidingData& data);
|
||||
void gnssUpdateXtraThrottleCommand(const bool enabled);
|
||||
|
||||
void initDefaultAgpsCommand();
|
||||
void initAgpsCommand(const AgpsCbInfo& cbInfo);
|
||||
|
@ -247,15 +206,6 @@ public:
|
|||
void dataConnClosedCommand(AGpsExtType agpsType);
|
||||
void dataConnFailedCommand(AGpsExtType agpsType);
|
||||
|
||||
/* ========= ODCPI ===================================================================== */
|
||||
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
|
||||
void initOdcpiCommand(const OdcpiRequestCallback& callback);
|
||||
void injectOdcpiCommand(const Location& location);
|
||||
/* ======== UTILITIES ================================================================== */
|
||||
void initOdcpi(const OdcpiRequestCallback& callback);
|
||||
void injectOdcpi(const Location& location);
|
||||
void odcpiTimerExpireEvent();
|
||||
|
||||
/* ======== RESPONSES ================================================================== */
|
||||
void reportResponse(LocationError err, uint32_t sessionId);
|
||||
void reportResponse(size_t count, LocationError* errs, uint32_t* ids);
|
||||
|
@ -289,11 +239,8 @@ public:
|
|||
virtual bool requestSuplES(int connHandle);
|
||||
virtual bool reportDataCallOpened();
|
||||
virtual bool reportDataCallClosed();
|
||||
virtual bool reportOdcpiRequestEvent(OdcpiRequestInfo& request);
|
||||
|
||||
/* ======== UTILITIES ================================================================= */
|
||||
bool needReport(const UlpLocation& ulpLocation,
|
||||
enum loc_sess_status status, LocPosTechMask techMask);
|
||||
void reportPosition(const UlpLocation &ulpLocation,
|
||||
const GpsLocationExtended &locationExtended,
|
||||
enum loc_sess_status status,
|
||||
|
@ -302,7 +249,6 @@ public:
|
|||
void reportNmea(const char* nmea, size_t length);
|
||||
bool requestNiNotify(const GnssNiNotification& notify, const void* data);
|
||||
void reportGnssMeasurementData(const GnssMeasurementsNotification& measurements);
|
||||
void reportOdcpiRequest(const OdcpiRequestInfo& request);
|
||||
|
||||
/*======== GNSSDEBUG ================================================================*/
|
||||
bool getDebugReport(GnssDebugReport& report);
|
||||
|
|
147
gps/gnss/XtraSystemStatusObserver.cpp
Executable file → Normal file
147
gps/gnss/XtraSystemStatusObserver.cpp
Executable file → Normal file
|
@ -43,6 +43,7 @@
|
|||
#include <SystemStatus.h>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
#include <XtraSystemStatusObserver.h>
|
||||
#include <LocAdapterBase.h>
|
||||
#include <DataItemId.h>
|
||||
|
@ -51,121 +52,94 @@
|
|||
|
||||
using namespace loc_core;
|
||||
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "LocSvc_XSSO"
|
||||
#define XTRA_HAL_SOCKET_NAME "/data/vendor/location/xtra/socket_hal_xtra"
|
||||
|
||||
bool XtraSystemStatusObserver::updateLockStatus(uint32_t lock) {
|
||||
mGpsLock = lock;
|
||||
|
||||
if (!mReqStatusReceived) {
|
||||
return true;
|
||||
}
|
||||
|
||||
stringstream ss;
|
||||
ss << "gpslock";
|
||||
ss << " " << lock;
|
||||
return ( send(LOC_IPC_XTRA, ss.str()) );
|
||||
ss << "\n"; // append seperator
|
||||
return ( sendEvent(ss) );
|
||||
}
|
||||
|
||||
bool XtraSystemStatusObserver::updateConnections(uint64_t allConnections) {
|
||||
mIsConnectivityStatusKnown = true;
|
||||
mConnections = allConnections;
|
||||
|
||||
if (!mReqStatusReceived) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool XtraSystemStatusObserver::updateConnectionStatus(bool connected, uint32_t type) {
|
||||
stringstream ss;
|
||||
ss << "connection";
|
||||
ss << " " << mConnections;
|
||||
return ( send(LOC_IPC_XTRA, ss.str()) );
|
||||
ss << " " << (connected ? "1" : "0");
|
||||
ss << " " << (int)type;
|
||||
ss << "\n"; // append seperator
|
||||
return ( sendEvent(ss) );
|
||||
}
|
||||
|
||||
bool XtraSystemStatusObserver::updateTac(const string& tac) {
|
||||
mTac = tac;
|
||||
|
||||
if (!mReqStatusReceived) {
|
||||
return true;
|
||||
}
|
||||
|
||||
stringstream ss;
|
||||
ss << "tac";
|
||||
ss << " " << tac.c_str();
|
||||
return ( send(LOC_IPC_XTRA, ss.str()) );
|
||||
ss << "\n"; // append seperator
|
||||
return ( sendEvent(ss) );
|
||||
}
|
||||
|
||||
bool XtraSystemStatusObserver::updateMccMnc(const string& mccmnc) {
|
||||
mMccmnc = mccmnc;
|
||||
|
||||
if (!mReqStatusReceived) {
|
||||
return true;
|
||||
}
|
||||
|
||||
stringstream ss;
|
||||
ss << "mncmcc";
|
||||
ss << " " << mccmnc.c_str();
|
||||
return ( send(LOC_IPC_XTRA, ss.str()) );
|
||||
ss << "\n"; // append seperator
|
||||
return ( sendEvent(ss) );
|
||||
}
|
||||
|
||||
bool XtraSystemStatusObserver::updateXtraThrottle(const bool enabled) {
|
||||
mXtraThrottle = enabled;
|
||||
|
||||
if (!mReqStatusReceived) {
|
||||
return true;
|
||||
bool XtraSystemStatusObserver::sendEvent(const stringstream& event) {
|
||||
int socketFd = createSocket();
|
||||
if (socketFd < 0) {
|
||||
LOC_LOGe("XTRA unreachable. sending failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream ss;
|
||||
ss << "xtrathrottle";
|
||||
ss << " " << (enabled ? 1 : 0);
|
||||
return ( send(LOC_IPC_XTRA, ss.str()) );
|
||||
}
|
||||
|
||||
inline bool XtraSystemStatusObserver::onStatusRequested(int32_t xtraStatusUpdated) {
|
||||
mReqStatusReceived = true;
|
||||
|
||||
if (xtraStatusUpdated) {
|
||||
return true;
|
||||
const string& data = event.str();
|
||||
int remain = data.length();
|
||||
ssize_t sent = 0;
|
||||
while (remain > 0 &&
|
||||
(sent = ::send(socketFd, data.c_str() + (data.length() - remain),
|
||||
remain, MSG_NOSIGNAL)) > 0) {
|
||||
remain -= sent;
|
||||
}
|
||||
|
||||
stringstream ss;
|
||||
if (sent < 0) {
|
||||
LOC_LOGe("sending error. reason:%s", strerror(errno));
|
||||
}
|
||||
|
||||
ss << "respondStatus" << endl;
|
||||
(mGpsLock == -1 ? ss : ss << mGpsLock) << endl << mConnections << endl
|
||||
<< mTac << endl << mMccmnc << endl << mIsConnectivityStatusKnown;
|
||||
closeSocket(socketFd);
|
||||
|
||||
return ( send(LOC_IPC_XTRA, ss.str()) );
|
||||
return (remain == 0);
|
||||
}
|
||||
|
||||
void XtraSystemStatusObserver::onReceive(const std::string& data) {
|
||||
if (!strncmp(data.c_str(), "ping", sizeof("ping") - 1)) {
|
||||
LOC_LOGd("ping received");
|
||||
|
||||
#ifdef USE_GLIB
|
||||
} else if (!strncmp(data.c_str(), "connectBackhaul", sizeof("connectBackhaul") - 1)) {
|
||||
mSystemStatusObsrvr->connectBackhaul();
|
||||
int XtraSystemStatusObserver::createSocket() {
|
||||
int socketFd = -1;
|
||||
|
||||
} else if (!strncmp(data.c_str(), "disconnectBackhaul", sizeof("disconnectBackhaul") - 1)) {
|
||||
mSystemStatusObsrvr->disconnectBackhaul();
|
||||
#endif
|
||||
if ((socketFd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
||||
LOC_LOGe("create socket error. reason:%s", strerror(errno));
|
||||
|
||||
} else if (!strncmp(data.c_str(), "requestStatus", sizeof("requestStatus") - 1)) {
|
||||
int32_t xtraStatusUpdated = 0;
|
||||
sscanf(data.c_str(), "%*s %d", &xtraStatusUpdated);
|
||||
} else {
|
||||
const char* socketPath = XTRA_HAL_SOCKET_NAME ;
|
||||
struct sockaddr_un addr = { .sun_family = AF_UNIX };
|
||||
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socketPath);
|
||||
|
||||
struct HandleStatusRequestMsg : public LocMsg {
|
||||
XtraSystemStatusObserver& mXSSO;
|
||||
int32_t mXtraStatusUpdated;
|
||||
inline HandleStatusRequestMsg(XtraSystemStatusObserver& xsso,
|
||||
int32_t xtraStatusUpdated) :
|
||||
mXSSO(xsso), mXtraStatusUpdated(xtraStatusUpdated) {}
|
||||
inline void proc() const override { mXSSO.onStatusRequested(mXtraStatusUpdated); }
|
||||
};
|
||||
mMsgTask->sendMsg(new (nothrow) HandleStatusRequestMsg(*this, xtraStatusUpdated));
|
||||
if (::connect(socketFd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
|
||||
LOC_LOGe("cannot connect to XTRA. reason:%s", strerror(errno));
|
||||
if (::close(socketFd)) {
|
||||
LOC_LOGe("close socket error. reason:%s", strerror(errno));
|
||||
}
|
||||
socketFd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
LOC_LOGw("unknown event: %s", data.c_str());
|
||||
return socketFd;
|
||||
}
|
||||
|
||||
void XtraSystemStatusObserver::closeSocket(const int socketFd) {
|
||||
if (socketFd >= 0) {
|
||||
if(::close(socketFd)) {
|
||||
LOC_LOGe("close socket error. reason:%s", strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,11 +171,11 @@ void XtraSystemStatusObserver::getName(string& name)
|
|||
|
||||
void XtraSystemStatusObserver::notify(const list<IDataItemCore*>& dlist)
|
||||
{
|
||||
struct HandleOsObserverUpdateMsg : public LocMsg {
|
||||
struct handleOsObserverUpdateMsg : public LocMsg {
|
||||
XtraSystemStatusObserver* mXtraSysStatObj;
|
||||
list <IDataItemCore*> mDataItemList;
|
||||
|
||||
inline HandleOsObserverUpdateMsg(XtraSystemStatusObserver* xtraSysStatObs,
|
||||
inline handleOsObserverUpdateMsg(XtraSystemStatusObserver* xtraSysStatObs,
|
||||
const list<IDataItemCore*>& dataItemList) :
|
||||
mXtraSysStatObj(xtraSysStatObs) {
|
||||
for (auto eachItem : dataItemList) {
|
||||
|
@ -217,7 +191,7 @@ void XtraSystemStatusObserver::notify(const list<IDataItemCore*>& dlist)
|
|||
}
|
||||
}
|
||||
|
||||
inline ~HandleOsObserverUpdateMsg() {
|
||||
inline ~handleOsObserverUpdateMsg() {
|
||||
for (auto each : mDataItemList) {
|
||||
delete each;
|
||||
}
|
||||
|
@ -231,7 +205,8 @@ void XtraSystemStatusObserver::notify(const list<IDataItemCore*>& dlist)
|
|||
{
|
||||
NetworkInfoDataItemBase* networkInfo =
|
||||
static_cast<NetworkInfoDataItemBase*>(each);
|
||||
mXtraSysStatObj->updateConnections(networkInfo->getAllTypes());
|
||||
mXtraSysStatObj->updateConnectionStatus(networkInfo->mConnected,
|
||||
networkInfo->mType);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -257,5 +232,7 @@ void XtraSystemStatusObserver::notify(const list<IDataItemCore*>& dlist)
|
|||
}
|
||||
}
|
||||
};
|
||||
mMsgTask->sendMsg(new (nothrow) HandleOsObserverUpdateMsg(this, dlist));
|
||||
mMsgTask->sendMsg(new (nothrow) handleOsObserverUpdateMsg(this, dlist));
|
||||
}
|
||||
|
||||
|
||||
|
|
44
gps/gnss/XtraSystemStatusObserver.h
Executable file → Normal file
44
gps/gnss/XtraSystemStatusObserver.h
Executable file → Normal file
|
@ -31,67 +31,41 @@
|
|||
|
||||
#include <cinttypes>
|
||||
#include <MsgTask.h>
|
||||
#include <LocIpc.h>
|
||||
#include <LocTimer.h>
|
||||
|
||||
using namespace std;
|
||||
using loc_core::IOsObserver;
|
||||
using loc_core::IDataItemObserver;
|
||||
using loc_core::IDataItemCore;
|
||||
using loc_util::LocIpc;
|
||||
|
||||
class XtraSystemStatusObserver : public IDataItemObserver, public LocIpc{
|
||||
|
||||
class XtraSystemStatusObserver : public IDataItemObserver {
|
||||
public :
|
||||
// constructor & destructor
|
||||
inline XtraSystemStatusObserver(IOsObserver* sysStatObs, const MsgTask* msgTask):
|
||||
mSystemStatusObsrvr(sysStatObs), mMsgTask(msgTask),
|
||||
mGpsLock(-1), mConnections(0), mXtraThrottle(true), mReqStatusReceived(false),
|
||||
mDelayLocTimer(*this), mIsConnectivityStatusKnown (false) {
|
||||
mSystemStatusObsrvr(sysStatObs), mMsgTask(msgTask) {
|
||||
subscribe(true);
|
||||
startListeningNonBlocking(LOC_IPC_HAL);
|
||||
mDelayLocTimer.start(100 /*.1 sec*/, false);
|
||||
}
|
||||
inline virtual ~XtraSystemStatusObserver() {
|
||||
subscribe(false);
|
||||
stopListening();
|
||||
}
|
||||
inline XtraSystemStatusObserver() {};
|
||||
inline virtual ~XtraSystemStatusObserver() { subscribe(false); }
|
||||
|
||||
// IDataItemObserver overrides
|
||||
inline virtual void getName(string& name);
|
||||
virtual void notify(const list<IDataItemCore*>& dlist);
|
||||
|
||||
bool updateLockStatus(uint32_t lock);
|
||||
bool updateConnections(uint64_t allConnections);
|
||||
bool updateConnectionStatus(bool connected, uint32_t type);
|
||||
bool updateTac(const string& tac);
|
||||
bool updateMccMnc(const string& mccmnc);
|
||||
bool updateXtraThrottle(const bool enabled);
|
||||
inline const MsgTask* getMsgTask() { return mMsgTask; }
|
||||
void subscribe(bool yes);
|
||||
|
||||
protected:
|
||||
void onReceive(const std::string& data) override;
|
||||
|
||||
private:
|
||||
int createSocket();
|
||||
void closeSocket(const int32_t socketFd);
|
||||
bool sendEvent(const stringstream& event);
|
||||
IOsObserver* mSystemStatusObsrvr;
|
||||
const MsgTask* mMsgTask;
|
||||
int32_t mGpsLock;
|
||||
uint64_t mConnections;
|
||||
string mTac;
|
||||
string mMccmnc;
|
||||
bool mXtraThrottle;
|
||||
bool mReqStatusReceived;
|
||||
bool mIsConnectivityStatusKnown;
|
||||
|
||||
class DelayLocTimer : public LocTimer {
|
||||
XtraSystemStatusObserver& mXSSO;
|
||||
public:
|
||||
DelayLocTimer(XtraSystemStatusObserver& xsso) : mXSSO(xsso) {}
|
||||
void timeOutCallback() override {
|
||||
mXSSO.send(LOC_IPC_XTRA, "halinit");
|
||||
}
|
||||
} mDelayLocTimer;
|
||||
|
||||
bool onStatusRequested(int32_t xtraStatusUpdated);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
33
gps/gnss/location_gnss.cpp
Executable file → Normal file
33
gps/gnss/location_gnss.cpp
Executable file → Normal file
|
@ -45,7 +45,6 @@ static void stopTracking(LocationAPI* client, uint32_t id);
|
|||
|
||||
static void gnssNiResponse(LocationAPI* client, uint32_t id, GnssNiResponse response);
|
||||
static uint32_t gnssDeleteAidingData(GnssAidingData& data);
|
||||
static void gnssUpdateXtraThrottle(const bool enabled);
|
||||
|
||||
static void setControlCallbacks(LocationControlCallbacks& controlCallbacks);
|
||||
static uint32_t enable(LocationTechnologyType techType);
|
||||
|
@ -60,10 +59,7 @@ static void agpsDataConnOpen(AGpsExtType agpsType, const char* apnName, int apnL
|
|||
static void agpsDataConnClosed(AGpsExtType agpsType);
|
||||
static void agpsDataConnFailed(AGpsExtType agpsType);
|
||||
static void getDebugReport(GnssDebugReport& report);
|
||||
static void updateConnectionStatus(bool connected, int8_t type);
|
||||
|
||||
static void odcpiInit(const OdcpiRequestCallback& callback);
|
||||
static void odcpiInject(const Location& location);
|
||||
static void updateConnectionStatus(bool connected, uint8_t type);
|
||||
|
||||
static const GnssInterface gGnssInterface = {
|
||||
sizeof(GnssInterface),
|
||||
|
@ -81,7 +77,6 @@ static const GnssInterface gGnssInterface = {
|
|||
disable,
|
||||
gnssUpdateConfig,
|
||||
gnssDeleteAidingData,
|
||||
gnssUpdateXtraThrottle,
|
||||
injectLocation,
|
||||
injectTime,
|
||||
agpsInit,
|
||||
|
@ -90,8 +85,6 @@ static const GnssInterface gGnssInterface = {
|
|||
agpsDataConnFailed,
|
||||
getDebugReport,
|
||||
updateConnectionStatus,
|
||||
odcpiInit,
|
||||
odcpiInject,
|
||||
};
|
||||
|
||||
#ifndef DEBUG_X86
|
||||
|
@ -210,13 +203,6 @@ static uint32_t gnssDeleteAidingData(GnssAidingData& data)
|
|||
}
|
||||
}
|
||||
|
||||
static void gnssUpdateXtraThrottle(const bool enabled)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->gnssUpdateXtraThrottleCommand(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
static void injectLocation(double latitude, double longitude, float accuracy)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
|
@ -265,23 +251,8 @@ static void getDebugReport(GnssDebugReport& report) {
|
|||
}
|
||||
}
|
||||
|
||||
static void updateConnectionStatus(bool connected, int8_t type) {
|
||||
static void updateConnectionStatus(bool connected, uint8_t type) {
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->getSystemStatus()->eventConnectionStatus(connected, type);
|
||||
}
|
||||
}
|
||||
|
||||
static void odcpiInit(const OdcpiRequestCallback& callback)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->initOdcpiCommand(callback);
|
||||
}
|
||||
}
|
||||
|
||||
static void odcpiInject(const Location& location)
|
||||
{
|
||||
if (NULL != gGnssAdapter) {
|
||||
gGnssAdapter->injectOdcpiCommand(location);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
1
gps/gnsspps/Android.mk
Executable file → Normal file
1
gps/gnsspps/Android.mk
Executable file → Normal file
|
@ -5,6 +5,7 @@ include $(CLEAR_VARS)
|
|||
LOCAL_MODULE := libgnsspps
|
||||
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
|
||||
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libutils \
|
||||
|
|
2
gps/gnsspps/gnsspps.c
Executable file → Normal file
2
gps/gnsspps/gnsspps.c
Executable file → Normal file
|
@ -25,7 +25,7 @@
|
|||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <log_util.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
|
0
gps/gnsspps/gnsspps.h
Executable file → Normal file
0
gps/gnsspps/gnsspps.h
Executable file → Normal file
0
gps/gnsspps/timepps.h
Executable file → Normal file
0
gps/gnsspps/timepps.h
Executable file → Normal file
4
gps/location/Android.mk
Executable file → Normal file
4
gps/location/Android.mk
Executable file → Normal file
|
@ -3,7 +3,9 @@ LOCAL_PATH := $(call my-dir)
|
|||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := liblocation_api
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
|
||||
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libutils \
|
||||
|
|
3
gps/location/LocationAPI.cpp
Executable file → Normal file
3
gps/location/LocationAPI.cpp
Executable file → Normal file
|
@ -29,8 +29,7 @@
|
|||
|
||||
#include <location_interface.h>
|
||||
#include <dlfcn.h>
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <pthread.h>
|
||||
#include <map>
|
||||
|
||||
|
|
0
gps/location/LocationAPI.h
Executable file → Normal file
0
gps/location/LocationAPI.h
Executable file → Normal file
39
gps/location/LocationAPIClientBase.cpp
Executable file → Normal file
39
gps/location/LocationAPIClientBase.cpp
Executable file → Normal file
|
@ -29,12 +29,12 @@
|
|||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_APIClientBase"
|
||||
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <inttypes.h>
|
||||
#include <loc_cfg.h>
|
||||
#include "LocationAPIClientBase.h"
|
||||
|
||||
#define FLP_CONF_FILE "/etc/flp.conf"
|
||||
#define GEOFENCE_SESSION_ID 0xFFFFFFFF
|
||||
#define CONFIG_SESSION_ID 0xFFFFFFFF
|
||||
|
||||
|
@ -153,6 +153,7 @@ uint32_t LocationAPIControlClient::locAPIGnssUpdateConfig(GnssConfig config)
|
|||
|
||||
memcpy(&mConfig, &config, sizeof(GnssConfig));
|
||||
|
||||
uint32_t session = 0;
|
||||
uint32_t* idArray = mLocationControlAPI->gnssUpdateConfig(config);
|
||||
LOC_LOGV("%s:%d] gnssUpdateConfig return array: %p", __FUNCTION__, __LINE__, idArray);
|
||||
if (idArray != nullptr) {
|
||||
|
@ -364,7 +365,7 @@ int32_t LocationAPIClientBase::locAPIGetBatchSize()
|
|||
{
|
||||
{"BATCH_SIZE", &mBatchSize, nullptr, 'n'},
|
||||
};
|
||||
UTIL_READ_CONF(LOC_PATH_FLP_CONF, flp_conf_param_table);
|
||||
UTIL_READ_CONF(FLP_CONF_FILE, flp_conf_param_table);
|
||||
if (mBatchSize < 0) {
|
||||
// set mBatchSize to 0 if we got an illegal value from config file
|
||||
mBatchSize = 0;
|
||||
|
@ -561,16 +562,10 @@ uint32_t LocationAPIClientBase::locAPIGetBatchedLocations(uint32_t id, size_t co
|
|||
if (mLocationAPI) {
|
||||
if (mSessionBiDict.hasId(id)) {
|
||||
SessionEntity entity = mSessionBiDict.getExtById(id);
|
||||
if (entity.sessionMode != SESSION_MODE_ON_FIX) {
|
||||
uint32_t batchingSession = entity.batchingSession;
|
||||
mRequestQueues[REQUEST_SESSION].push(new GetBatchedLocationsRequest(*this));
|
||||
mLocationAPI->getBatchedLocations(batchingSession, count);
|
||||
retVal = LOCATION_ERROR_SUCCESS;
|
||||
} else {
|
||||
LOC_LOGE("%s:%d] Unsupported for session id: %d, mode is SESSION_MODE_ON_FIX",
|
||||
__FUNCTION__, __LINE__, id);
|
||||
retVal = LOCATION_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
uint32_t batchingSession = entity.batchingSession;
|
||||
mRequestQueues[REQUEST_SESSION].push(new GetBatchedLocationsRequest(*this));
|
||||
mLocationAPI->getBatchedLocations(batchingSession, count);
|
||||
retVal = LOCATION_ERROR_SUCCESS;
|
||||
} else {
|
||||
retVal = LOCATION_ERROR_ID_UNKNOWN;
|
||||
LOC_LOGE("%s:%d] invalid session: %d.", __FUNCTION__, __LINE__, id);
|
||||
|
@ -619,24 +614,26 @@ void LocationAPIClientBase::locAPIRemoveGeofences(size_t count, uint32_t* ids)
|
|||
}
|
||||
|
||||
if (mRequestQueues[REQUEST_GEOFENCE].getSession() == GEOFENCE_SESSION_ID) {
|
||||
BiDict<GeofenceBreachTypeMask>* removedGeofenceBiDict =
|
||||
new BiDict<GeofenceBreachTypeMask>();
|
||||
size_t j = 0;
|
||||
uint32_t id_cb;
|
||||
LocationError err;
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
sessions[j] = mGeofenceBiDict.getSession(ids[i]);
|
||||
id_cb = ids[i];
|
||||
if (sessions[j] > 0) {
|
||||
GeofenceBreachTypeMask type = mGeofenceBiDict.getExtBySession(sessions[j]);
|
||||
mGeofenceBiDict.rmBySession(sessions[j]);
|
||||
removedGeofenceBiDict->set(ids[i], sessions[j], type);
|
||||
err = LOCATION_ERROR_SUCCESS;
|
||||
onRemoveGeofencesCb(1, &err, &id_cb);
|
||||
j++;
|
||||
} else {
|
||||
err = LOCATION_ERROR_ID_UNKNOWN;
|
||||
onRemoveGeofencesCb(1, &err, &id_cb);
|
||||
}
|
||||
}
|
||||
|
||||
if (j > 0) {
|
||||
mRequestQueues[REQUEST_GEOFENCE].push(new RemoveGeofencesRequest(*this,
|
||||
removedGeofenceBiDict));
|
||||
mRequestQueues[REQUEST_GEOFENCE].push(new RemoveGeofencesRequest(*this));
|
||||
mLocationAPI->removeGeofences(j, sessions);
|
||||
} else {
|
||||
delete(removedGeofenceBiDict);
|
||||
}
|
||||
} else {
|
||||
LOC_LOGE("%s:%d] invalid session: %d.", __FUNCTION__, __LINE__,
|
||||
|
|
19
gps/location/LocationAPIClientBase.h
Executable file → Normal file
19
gps/location/LocationAPIClientBase.h
Executable file → Normal file
|
@ -36,8 +36,6 @@
|
|||
#include <map>
|
||||
|
||||
#include "LocationAPI.h"
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
|
||||
enum SESSION_MODE {
|
||||
SESSION_MODE_NONE = 0,
|
||||
|
@ -471,24 +469,11 @@ private:
|
|||
|
||||
class RemoveGeofencesRequest : public LocationAPIRequest {
|
||||
public:
|
||||
RemoveGeofencesRequest(LocationAPIClientBase& API,
|
||||
BiDict<GeofenceBreachTypeMask>* removedGeofenceBiDict) :
|
||||
mAPI(API), mRemovedGeofenceBiDict(removedGeofenceBiDict) {}
|
||||
RemoveGeofencesRequest(LocationAPIClientBase& API) : mAPI(API) {}
|
||||
inline void onCollectiveResponse(size_t count, LocationError* errors, uint32_t* sessions) {
|
||||
if (nullptr != mRemovedGeofenceBiDict) {
|
||||
uint32_t *ids = (uint32_t*)malloc(sizeof(uint32_t) * count);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
ids[i] = mRemovedGeofenceBiDict->getId(sessions[i]);
|
||||
}
|
||||
mAPI.onRemoveGeofencesCb(count, errors, ids);
|
||||
free(ids);
|
||||
delete(mRemovedGeofenceBiDict);
|
||||
} else {
|
||||
LOC_LOGE("%s:%d] Unable to access removed geofences data.", __FUNCTION__, __LINE__);
|
||||
}
|
||||
// No need to handle collectiveResponse, cbs already notified
|
||||
}
|
||||
LocationAPIClientBase& mAPI;
|
||||
BiDict<GeofenceBreachTypeMask>* mRemovedGeofenceBiDict;
|
||||
};
|
||||
|
||||
class ModifyGeofencesRequest : public LocationAPIRequest {
|
||||
|
|
5
gps/location/location_interface.h
Executable file → Normal file
5
gps/location/location_interface.h
Executable file → Normal file
|
@ -48,7 +48,6 @@ struct GnssInterface {
|
|||
void (*disable)(uint32_t id);
|
||||
uint32_t* (*gnssUpdateConfig)(GnssConfig config);
|
||||
uint32_t (*gnssDeleteAidingData)(GnssAidingData& data);
|
||||
void (*gnssUpdateXtraThrottle)(const bool enabled);
|
||||
void (*injectLocation)(double latitude, double longitude, float accuracy);
|
||||
void (*injectTime)(int64_t time, int64_t timeReference, int32_t uncertainty);
|
||||
void (*agpsInit)(const AgpsCbInfo& cbInfo);
|
||||
|
@ -56,9 +55,7 @@ struct GnssInterface {
|
|||
void (*agpsDataConnClosed)(AGpsExtType agpsType);
|
||||
void (*agpsDataConnFailed)(AGpsExtType agpsType);
|
||||
void (*getDebugReport)(GnssDebugReport& report);
|
||||
void (*updateConnectionStatus)(bool connected, int8_t type);
|
||||
void (*odcpiInit)(const OdcpiRequestCallback& callback);
|
||||
void (*odcpiInject)(const Location& location);
|
||||
void (*updateConnectionStatus)(bool connected, uint8_t type);
|
||||
};
|
||||
|
||||
struct FlpInterface {
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
GNSS_CFLAGS := \
|
||||
-Werror \
|
||||
-Wno-error=unused-parameter \
|
||||
-Wno-error=format \
|
||||
-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_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libloc_pla_headers
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/android
|
||||
include $(BUILD_HEADER_LIBRARY)
|
15
gps/utils/Android.mk
Executable file → Normal file
15
gps/utils/Android.mk
Executable file → Normal file
|
@ -2,12 +2,12 @@ LOCAL_PATH := $(call my-dir)
|
|||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
|
||||
## Libs
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libutils \
|
||||
libcutils \
|
||||
liblog \
|
||||
libloc_pla \
|
||||
libprocessgroup
|
||||
|
||||
LOCAL_SRC_FILES += \
|
||||
|
@ -16,13 +16,13 @@ LOCAL_SRC_FILES += \
|
|||
msg_q.c \
|
||||
linked_list.c \
|
||||
loc_target.cpp \
|
||||
platform_lib_abstractions/elapsed_millis_since_boot.cpp \
|
||||
LocHeap.cpp \
|
||||
LocTimer.cpp \
|
||||
LocThread.cpp \
|
||||
MsgTask.cpp \
|
||||
loc_misc_utils.cpp \
|
||||
loc_nmea.cpp \
|
||||
LocIpc.cpp
|
||||
loc_nmea.cpp
|
||||
|
||||
# Flag -std=c++11 is not accepted by compiler when LOCAL_CLANG is set to true
|
||||
LOCAL_CFLAGS += \
|
||||
|
@ -37,14 +37,13 @@ LOCAL_LDFLAGS += -Wl,--export-dynamic
|
|||
|
||||
## Includes
|
||||
LOCAL_HEADER_LIBRARIES := \
|
||||
libutils_headers \
|
||||
libloc_pla_headers \
|
||||
liblocation_api_headers
|
||||
|
||||
LOCAL_MODULE := libgps.utils
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
|
||||
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_CFLAGS += $(GNSS_CFLAGS)
|
||||
|
||||
|
@ -54,3 +53,5 @@ include $(CLEAR_VARS)
|
|||
LOCAL_MODULE := libgps.utils_headers
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
|
||||
include $(BUILD_HEADER_LIBRARY)
|
||||
|
||||
include $(addsuffix /Android.mk, $(addprefix $(LOCAL_PATH)/, platform_lib_abstractions))
|
||||
|
|
0
gps/utils/LocHeap.cpp
Executable file → Normal file
0
gps/utils/LocHeap.cpp
Executable file → Normal file
0
gps/utils/LocHeap.h
Executable file → Normal file
0
gps/utils/LocHeap.h
Executable file → Normal file
|
@ -1,237 +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 <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <log_util.h>
|
||||
#include "LocIpc.h"
|
||||
|
||||
namespace loc_util {
|
||||
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "LocSvc_LocIpc"
|
||||
|
||||
#define LOC_MSG_BUF_LEN 8192
|
||||
#define LOC_MSG_HEAD "$MSGLEN$"
|
||||
#define LOC_MSG_ABORT "LocIpcMsg::ABORT"
|
||||
|
||||
class LocIpcRunnable : public LocRunnable {
|
||||
friend LocIpc;
|
||||
public:
|
||||
LocIpcRunnable(LocIpc& locIpc, const std::string& ipcName)
|
||||
: mLocIpc(locIpc), mIpcName(ipcName) {}
|
||||
bool run() override {
|
||||
if (!mLocIpc.startListeningBlocking(mIpcName)) {
|
||||
LOC_LOGe("listen to socket failed");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
LocIpc& mLocIpc;
|
||||
const std::string mIpcName;
|
||||
};
|
||||
|
||||
bool LocIpc::startListeningNonBlocking(const std::string& name) {
|
||||
mRunnable = new LocIpcRunnable(*this, name);
|
||||
std::string threadName("LocIpc-");
|
||||
threadName.append(name);
|
||||
return mThread.start(threadName.c_str(), mRunnable);
|
||||
}
|
||||
|
||||
bool LocIpc::startListeningBlocking(const std::string& name) {
|
||||
|
||||
int fd = socket(AF_UNIX, SOCK_DGRAM, 0);
|
||||
if (fd < 0) {
|
||||
LOC_LOGe("create socket error. reason:%s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((unlink(name.c_str()) < 0) && (errno != ENOENT)) {
|
||||
LOC_LOGw("unlink socket error. reason:%s", strerror(errno));
|
||||
}
|
||||
|
||||
struct sockaddr_un addr = { .sun_family = AF_UNIX };
|
||||
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", name.c_str());
|
||||
|
||||
umask(0157);
|
||||
|
||||
if (::bind(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
|
||||
LOC_LOGe("bind socket error. reason:%s", strerror(errno));
|
||||
::close(fd);
|
||||
fd = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
mIpcFd = fd;
|
||||
|
||||
// inform that the socket is ready to receive message
|
||||
onListenerReady();
|
||||
|
||||
ssize_t nBytes = 0;
|
||||
std::string msg = "";
|
||||
std::string abort = LOC_MSG_ABORT;
|
||||
while (1) {
|
||||
msg.resize(LOC_MSG_BUF_LEN);
|
||||
nBytes = ::recvfrom(mIpcFd, (void*)(msg.data()), msg.size(), 0, NULL, NULL);
|
||||
if (nBytes < 0) {
|
||||
break;
|
||||
} else if (nBytes == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(msg.data(), abort.c_str(), abort.length()) == 0) {
|
||||
LOC_LOGi("recvd abort msg.data %s", msg.data());
|
||||
break;
|
||||
}
|
||||
|
||||
if (strncmp(msg.data(), LOC_MSG_HEAD, sizeof(LOC_MSG_HEAD) - 1)) {
|
||||
// short message
|
||||
msg.resize(nBytes);
|
||||
onReceive(msg);
|
||||
} else {
|
||||
// long message
|
||||
size_t msgLen = 0;
|
||||
sscanf(msg.data(), LOC_MSG_HEAD"%zu", &msgLen);
|
||||
msg.resize(msgLen);
|
||||
size_t msgLenReceived = 0;
|
||||
while ((msgLenReceived < msgLen) && (nBytes > 0)) {
|
||||
nBytes = recvfrom(mIpcFd, (void*)&(msg[msgLenReceived]),
|
||||
msg.size() - msgLenReceived, 0, NULL, NULL);
|
||||
msgLenReceived += nBytes;
|
||||
}
|
||||
if (nBytes > 0) {
|
||||
onReceive(msg);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mStopRequested) {
|
||||
mStopRequested = false;
|
||||
return true;
|
||||
} else {
|
||||
LOC_LOGe("cannot read socket. reason:%s", strerror(errno));
|
||||
(void)::close(mIpcFd);
|
||||
mIpcFd = -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void LocIpc::stopListening() {
|
||||
|
||||
const char *socketName = nullptr;
|
||||
mStopRequested = true;
|
||||
|
||||
if (mRunnable) {
|
||||
std::string abort = LOC_MSG_ABORT;
|
||||
socketName = (reinterpret_cast<LocIpcRunnable *>(mRunnable))->mIpcName.c_str();
|
||||
send(socketName, abort);
|
||||
mRunnable = nullptr;
|
||||
}
|
||||
|
||||
if (mIpcFd >= 0) {
|
||||
if (::close(mIpcFd)) {
|
||||
LOC_LOGe("cannot close socket:%s", strerror(errno));
|
||||
}
|
||||
mIpcFd = -1;
|
||||
}
|
||||
|
||||
//delete from the file system at the end
|
||||
if (socketName) {
|
||||
unlink(socketName);
|
||||
}
|
||||
}
|
||||
|
||||
bool LocIpc::send(const char name[], const std::string& data) {
|
||||
return send(name, (const uint8_t*)data.c_str(), data.length());
|
||||
}
|
||||
|
||||
bool LocIpc::send(const char name[], const uint8_t data[], uint32_t length) {
|
||||
|
||||
bool result = true;
|
||||
int fd = ::socket(AF_UNIX, SOCK_DGRAM, 0);
|
||||
if (fd < 0) {
|
||||
LOC_LOGe("create socket error. reason:%s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
struct sockaddr_un addr = { .sun_family = AF_UNIX };
|
||||
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", name);
|
||||
|
||||
result = sendData(fd, addr, data, length);
|
||||
|
||||
(void)::close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool LocIpc::sendData(int fd, const sockaddr_un &addr, const uint8_t data[], uint32_t length) {
|
||||
|
||||
bool result = true;
|
||||
|
||||
if (length <= LOC_MSG_BUF_LEN) {
|
||||
if (::sendto(fd, data, length, 0,
|
||||
(struct sockaddr*)&addr, sizeof(addr)) < 0) {
|
||||
LOC_LOGe("cannot send to socket. reason:%s", strerror(errno));
|
||||
result = false;
|
||||
}
|
||||
} else {
|
||||
std::string head = LOC_MSG_HEAD;
|
||||
head.append(std::to_string(length));
|
||||
if (::sendto(fd, head.c_str(), head.length(), 0,
|
||||
(struct sockaddr*)&addr, sizeof(addr)) < 0) {
|
||||
LOC_LOGe("cannot send to socket. reason:%s", strerror(errno));
|
||||
result = false;
|
||||
} else {
|
||||
size_t sentBytes = 0;
|
||||
while(sentBytes < length) {
|
||||
size_t partLen = length - sentBytes;
|
||||
if (partLen > LOC_MSG_BUF_LEN) {
|
||||
partLen = LOC_MSG_BUF_LEN;
|
||||
}
|
||||
ssize_t rv = ::sendto(fd, data + sentBytes, partLen, 0,
|
||||
(struct sockaddr*)&addr, sizeof(addr));
|
||||
if (rv < 0) {
|
||||
LOC_LOGe("cannot send to socket. reason:%s", strerror(errno));
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
sentBytes += rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,153 +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 __LOC_SOCKET__
|
||||
#define __LOC_SOCKET__
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <LocThread.h>
|
||||
|
||||
namespace loc_util {
|
||||
|
||||
class LocIpcSender;
|
||||
|
||||
class LocIpc {
|
||||
friend LocIpcSender;
|
||||
public:
|
||||
inline LocIpc() : mIpcFd(-1), mStopRequested(false), mRunnable(nullptr) {}
|
||||
inline virtual ~LocIpc() { stopListening(); }
|
||||
|
||||
// Listen for new messages in current thread. Calling this funciton will
|
||||
// block current thread. The listening can be stopped by calling stopListening().
|
||||
//
|
||||
// Argument name is the path of the unix local socket to be listened.
|
||||
// The function will return true on success, and false on failure.
|
||||
bool startListeningBlocking(const std::string& name);
|
||||
|
||||
// Create a new LocThread and listen for new messages in it.
|
||||
// Calling this function will return immediately and won't block current thread.
|
||||
// The listening can be stopped by calling stopListening().
|
||||
//
|
||||
// Argument name is the path of the unix local socket to be be listened.
|
||||
// The function will return true on success, and false on failure.
|
||||
bool startListeningNonBlocking(const std::string& name);
|
||||
|
||||
// Stop listening to new messages.
|
||||
void stopListening();
|
||||
|
||||
// Send out a message.
|
||||
// Call this function to send a message in argument data to socket in argument name.
|
||||
//
|
||||
// Argument name contains the name of the target unix socket. data contains the
|
||||
// message to be sent out. Convert your message to a string before calling this function.
|
||||
// The function will return true on success, and false on failure.
|
||||
static bool send(const char name[], const std::string& data);
|
||||
static bool send(const char name[], const uint8_t data[], uint32_t length);
|
||||
|
||||
protected:
|
||||
// Callback function for receiving incoming messages.
|
||||
// Override this function in your derived class to process incoming messages.
|
||||
// For each received message, this callback function will be called once.
|
||||
// This callback function will be called in the calling thread of startListeningBlocking
|
||||
// or in the new LocThread created by startListeningNonBlocking.
|
||||
//
|
||||
// Argument data contains the received message. You need to parse it.
|
||||
inline virtual void onReceive(const std::string& /*data*/) {}
|
||||
|
||||
// LocIpc client can overwrite this function to get notification
|
||||
// when the socket for LocIpc is ready to receive messages.
|
||||
inline virtual void onListenerReady() {}
|
||||
|
||||
private:
|
||||
static bool sendData(int fd, const sockaddr_un& addr,
|
||||
const uint8_t data[], uint32_t length);
|
||||
|
||||
int mIpcFd;
|
||||
bool mStopRequested;
|
||||
LocThread mThread;
|
||||
LocRunnable *mRunnable;
|
||||
};
|
||||
|
||||
class LocIpcSender {
|
||||
public:
|
||||
// Constructor of LocIpcSender class
|
||||
//
|
||||
// Argument destSocket contains the full path name of destination socket.
|
||||
// This class hides generated fd and destination address object from user.
|
||||
inline LocIpcSender(const char* destSocket):
|
||||
LocIpcSender(std::make_shared<int>(::socket(AF_UNIX, SOCK_DGRAM, 0)), destSocket) {
|
||||
if (-1 == *mSocket) {
|
||||
mSocket = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// Replicate a new LocIpcSender object with new destination socket.
|
||||
inline LocIpcSender* replicate(const char* destSocket) {
|
||||
return (nullptr == mSocket) ? nullptr : new LocIpcSender(mSocket, destSocket);
|
||||
}
|
||||
|
||||
inline ~LocIpcSender() {
|
||||
if (nullptr != mSocket && mSocket.unique()) {
|
||||
::close(*mSocket);
|
||||
}
|
||||
}
|
||||
|
||||
// Send out a message.
|
||||
// Call this function to send a message
|
||||
//
|
||||
// Argument data and length contains the message to be sent out.
|
||||
// Return true when succeeded
|
||||
inline bool send(const uint8_t data[], uint32_t length) {
|
||||
bool rtv = false;
|
||||
if (nullptr != mSocket && nullptr != data) {
|
||||
rtv = LocIpc::sendData(*mSocket, mDestAddr, data, length);
|
||||
}
|
||||
return rtv;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<int> mSocket;
|
||||
struct sockaddr_un mDestAddr;
|
||||
|
||||
inline LocIpcSender(
|
||||
const std::shared_ptr<int>& mySocket, const char* destSocket) : mSocket(mySocket) {
|
||||
if ((nullptr != mSocket) && (-1 != *mSocket) && (nullptr != destSocket)) {
|
||||
mDestAddr.sun_family = AF_UNIX;
|
||||
snprintf(mDestAddr.sun_path, sizeof(mDestAddr.sun_path), "%s", destSocket);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //__LOC_SOCKET__
|
0
gps/utils/LocSharedLock.h
Executable file → Normal file
0
gps/utils/LocSharedLock.h
Executable file → Normal file
2
gps/utils/LocThread.cpp
Executable file → Normal file
2
gps/utils/LocThread.cpp
Executable file → Normal file
|
@ -29,7 +29,7 @@
|
|||
#include <LocThread.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <loc_pla.h>
|
||||
#include <platform_lib_macros.h>
|
||||
|
||||
class LocThreadDelegate {
|
||||
LocRunnable* mRunnable;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue