diff --git a/Android.mk b/Android.mk index ac3a321..17059a4 100755 --- a/Android.mk +++ b/Android.mk @@ -1,5 +1,5 @@ # -# Copyright (C) 2014 The CyanogenMod Project +# Copyright (C) 2012 The Android Open-Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +14,12 @@ # limitations under the License. # +# WARNING: Everything listed here will be built on ALL platforms, +# including x86, the emulator, and the SDK. Modules must be uniquely +# named (liblights.tuna), and must build everywhere, or limit themselves +# to only building on ARM if they include assembly. Individual makefiles +# are responsible for having their own logic, for fine-grained control. + LOCAL_PATH := $(call my-dir) ifeq ($(TARGET_DEVICE),mondrianwifi) @@ -21,266 +27,6 @@ include $(call all-subdir-makefiles,$(LOCAL_PATH)) include $(CLEAR_VARS) -ADSP_IMAGES := \ - adsp.b00 adsp.b01 adsp.b02 adsp.b03 adsp.b04 adsp.b05 adsp.b06 \ - adsp.b08 adsp.b09 adsp.b10 adsp.b11 adsp.b12 adsp.mdt - -ADSP_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(ADSP_IMAGES))) -$(ADSP_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "ADSP firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware-modem/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(ADSP_SYMLINKS) - -DTCPIP_IMAGES := \ - dtcpip.b00 dtcpip.b01 dtcpip.b02 dtcpip.b03 dtcpip.mdt - -DTCPIP_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(DTCPIP_IMAGES))) -$(DTCPIP_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "DTCPIP firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(DTCPIP_SYMLINKS) - -KM_IMAGES := \ - keymaste.b00 keymaste.b01 keymaste.b02 keymaste.b03 keymaste.mdt - -KM_SYMLINKS := $(addprefix $(TARGET_OUT_VENDOR)/firmware/keymaster/,$(notdir $(KM_IMAGES))) -$(KM_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "Keymaster firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/keymaste$(suffix $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(KM_SYMLINKS) - -MBA_IMAGES := \ - mba.b00 mba.mdt - -MBA_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(MBA_IMAGES))) -$(MBA_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "MBA firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware-modem/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(MBA_SYMLINKS) - -DXPRDY_IMAGES := \ - dxprdy.b00 dxprdy.b01 dxprdy.b02 dxprdy.b03 dxprdy.mdt - -DXPRDY_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(DXPRDY_IMAGES))) -$(DXPRDY_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "DXPRDY firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(DXPRDY_SYMLINKS) - -MLDAP_IMAGES := \ - mldap.b00 mldap.b01 mldap.b02 mldap.b03 mldap.mdt - -MLDAP_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(MLDAP_IMAGES))) -$(MLDAP_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "MLDAP firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(MLDAP_SYMLINKS) - -MC_IMAGES := \ - mc_v2.b00 mc_v2.b01 mc_v2.b02 mc_v2.b03 mc_v2.mdt - -MC_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(MC_IMAGES))) -$(MC_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "Mobicore firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(MC_SYMLINKS) - -MODEM_IMAGES := \ - modem.b00 modem.b01 modem.b02 modem.b03 modem.b05 \ - modem.b08 modem.b10 modem.b11 modem.b13 modem.b14 \ - modem.b15 modem.b16 modem.b17 modem.b18 modem.b19 modem.b20 modem.b21 \ - modem.b22 modem.b25 modem.b26 modem.b27 modem.mdt - -MODEM_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(MODEM_IMAGES))) -$(MODEM_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "Modem firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware-modem/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(MODEM_SYMLINKS) - -PROV_MODEM_IMAGES := \ - prov.b00 prov.b01 prov.b02 prov.b03 prov.mdt - -PROV_MODEM_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(PROV_MODEM_IMAGES))) -$(PROV_MODEM_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "Prov Firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(PROV_MODEM_SYMLINKS) - -ACTLOCK_IMAGES := \ - act_lock.b00 act_lock.b01 act_lock.b02 act_lock.b03 act_lock.mdt - -ACTLOCK_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(ACTLOCK_IMAGES))) -$(ACTLOCK_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "Actlock firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(ACTLOCK_SYMLINKS) - -TKM_IMAGES := \ - t2_ks_mi.b00 t2_ks_mi.b01 t2_ks_mi.b02 t2_ks_mi.b03 t2_ks_mi.mdt - -TKM_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(TKM_IMAGES))) -$(TKM_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "TKM firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(TKM_SYMLINKS) - -PLAYREADY_IMAGES := \ - playread.b00 playread.b01 playread.b02 playread.b03 playread.mdt - -PLAYREADY_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(PLAYREADY_IMAGES))) -$(PLAYREADY_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "Playready firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(PLAYREADY_SYMLINKS) - -SECSTOR_IMAGES := \ - sec_stor.b00 sec_stor.b01 sec_stor.b02 sec_stor.b03 sec_stor.mdt - -SECSTOR_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(SECSTOR_IMAGES))) -$(SECSTOR_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "Secstor firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(SECSTOR_SYMLINKS) - -SKM_IMAGES := \ - skm.b00 skm.b01 skm.b02 skm.b03 skm.mdt - -SKM_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(SKM_IMAGES))) -$(SKM_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "SKM firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(SKM_SYMLINKS) - -SKMM_TA_IMAGES := \ - skmm_ta.b00 skmm_ta.b01 skmm_ta.b02 skmm_ta.b03 skmm_ta.mdt - -SKMM_TA_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(SKMM_TA_IMAGES))) -$(SKMM_TA_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "SKMM firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(SKMM_TA_SYMLINKS) - -SSHDCPAP_IMAGES := \ - sshdcpap.b00 sshdcpap.b01 sshdcpap.b02 sshdcpap.b03 sshdcpap.mdt - -SSHDCPAP_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(SSHDCPAP_IMAGES))) -$(SSHDCPAP_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "SSHDCPAP firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(SSHDCPAP_SYMLINKS) - -TIMA_IMAGES := \ - tima_atn.b00 tima_atn.b01 tima_atn.b02 tima_atn.b03 tima_atn.mdt \ - tima_key.b00 tima_key.b01 tima_key.b02 tima_key.b03 tima_key.mdt \ - tima_lkm.b00 tima_lkm.b01 tima_lkm.b02 tima_lkm.b03 tima_lkm.mdt \ - tima_pkm.b00 tima_pkm.b01 tima_pkm.b02 tima_pkm.b03 tima_pkm.mdt - -TIMA_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(TIMA_IMAGES))) -$(TIMA_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "Tima firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(TIMA_SYMLINKS) - -TZPR_IMAGES := \ - tzpr25.b00 tzpr25.b01 tzpr25.b02 tzpr25.b03 tzpr25.mdt - -TZPR_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(TZPR_IMAGES))) -$(TZPR_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "TZPR firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(TZPR_SYMLINKS) - -TZ_CCM_IMAGES := \ - tz_ccm.b00 tz_ccm.b01 tz_ccm.b02 tz_ccm.b03 tz_ccm.mdt - -TZ_CCM_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(TZ_CCM_IMAGES))) -$(TZ_CCM_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "TZ_CCM firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(TZ_CCM_SYMLINKS) - -VENUS_IMAGES := \ - venus.b00 venus.b01 venus.b02 venus.b03 venus.b04 venus.mdt - -VENUS_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(VENUS_IMAGES))) -$(VENUS_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "Venus firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(VENUS_SYMLINKS) - -WV_IMAGES := \ - cmnlib.b00 cmnlib.b01 cmnlib.b02 cmnlib.b03 cmnlib.mdt \ - widevine.b00 widevine.b01 widevine.b02 widevine.b03 widevine.mdt - -WV_SYMLINKS := $(addprefix $(TARGET_OUT_VENDOR)/firmware/,$(notdir $(WV_IMAGES))) -$(WV_SYMLINKS): $(LOCAL_INSTALLED_MODULE) - @echo "Widevine firmware link: $@" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf /firmware/image/$(notdir $@) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(WV_SYMLINKS) - ISDBT_IMAGES := \ isdbtmm.b00 isdbtmm.b01 isdbtmm.b02 isdbtmm.b03 isdbtmm.mdt @@ -306,15 +52,6 @@ $(WCNSS_SYMLINKS): $(LOCAL_INSTALLED_MODULE) ALL_DEFAULT_INSTALLED_MODULES += $(WCNSS_SYMLINKS) -# Create links for audcal data files -$(shell mkdir -p $(TARGET_OUT)/etc/firmware/wcd9320; \ - ln -sf /data/misc/audio/wcd9320_anc.bin \ - $(TARGET_OUT)/etc/firmware/wcd9320/wcd9320_anc.bin;\ - ln -sf /data/misc/audio/mbhc.bin \ - $(TARGET_OUT)/etc/firmware/wcd9320/wcd9320_mbhc.bin; \ - ln -sf /data/misc/audio/wcd9320_mad_audio.bin \ - $(TARGET_OUT)/etc/firmware/wcd9320/wcd9320_mad_audio.bin) - # Create a link for the WCNSS config file, which ends up as a writable # version in /data/misc/wifi $(shell mkdir -p $(TARGET_OUT)/etc/firmware/wlan/prima; \ diff --git a/BoardConfig.mk b/BoardConfig.mk index 756fed3..189f4e3 100755 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -1,5 +1,5 @@ -# Copyright (C) 2014-2016 The CyanogenMod Project -# Copyright (C) 2017-2018 The LineageOS Project +# Copyright (C) 2012 The CyanogenMod Project +# Copyright (C) 2017-2019,2021 The LineageOS Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,173 +13,92 @@ # See the License for the specific language governing permissions and # limitations under the License. -LOCAL_PATH := device/samsung/mondrianwifi +# inherit from common msm8974 +include device/samsung/msm8974-common/BoardConfigCommon.mk -# temporary -BUILD_BROKEN_DUP_RULES := true +DEVICE_PATH := device/samsung/mondrianwifi -BOARD_VENDOR := samsung +TARGET_SPECIFIC_HEADER_PATH := $(DEVICE_PATH)/include -# Include path -TARGET_SPECIFIC_HEADER_PATH := $(LOCAL_PATH)/include +# Audio +USE_CUSTOM_AUDIO_POLICY := 1 + +# Bluetooth +BLUETOOTH_HCI_USE_MCT := true +BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := $(DEVICE_PATH)/bluetooth +BOARD_HAVE_BLUETOOTH_QCOM := true +QCOM_BT_USE_SMD_TTY := true # Bootloader TARGET_BOOTLOADER_BOARD_NAME := MSM8974 -TARGET_NO_BOOTLOADER := true TARGET_NO_RADIOIMAGE := true -# Platform -TARGET_BOARD_PLATFORM := msm8974 -TARGET_BOARD_PLATFORM_GPU := qcom-adreno330 +# Filesystem +TARGET_FS_CONFIG_GEN += $(DEVICE_PATH)/config.fs -# Architecture -TARGET_ARCH := arm -TARGET_ARCH_VARIANT := armv7-a-neon -TARGET_CPU_ABI := armeabi-v7a -TARGET_CPU_ABI2 := armeabi -TARGET_CPU_VARIANT := generic -TARGET_CPU_VARIANT_RUNTIME := krait - -# Binder API version -TARGET_USES_64_BIT_BINDER := true +# HIDL +DEVICE_MANIFEST_FILE := $(DEVICE_PATH)/manifest.xml # Kernel BOARD_KERNEL_BASE := 0x00000000 -#BOARD_KERNEL_CMDLINE := console=null androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 zcache.enabled=1 zcache.compressor=lz4 maxcpus=1 -BOARD_KERNEL_CMDLINE := console=null androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 androidboot.selinux=permissive +BOARD_KERNEL_CMDLINE := console=null androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 zcache.enabled=1 zcache.compressor=lz4 androidboot.selinux=permissive BOARD_KERNEL_IMAGE_NAME := zImage BOARD_KERNEL_PAGESIZE := 2048 BOARD_KERNEL_SEPARATED_DT := true BOARD_MKBOOTIMG_ARGS := --ramdisk_offset 0x02000000 --tags_offset 0x01E00000 BOARD_CUSTOM_BOOTIMG := true BOARD_CUSTOM_BOOTIMG_MK := hardware/samsung/mkbootimg.mk +BOARD_RAMDISK_USE_XZ := true TARGET_KERNEL_ARCH := arm TARGET_KERNEL_CONFIG := lineage_mondrian_defconfig TARGET_KERNEL_SOURCE := kernel/samsung/msm8974_tab -# Audio -AUDIO_FEATURE_ENABLED_COMPRESS_VOIP := true -AUDIO_FEATURE_ENABLED_EXTN_FORMATS := true -AUDIO_FEATURE_ENABLED_EXTN_POST_PROC := true -AUDIO_FEATURE_ENABLED_FLUENCE := true -AUDIO_FEATURE_ENABLED_HFP := true -AUDIO_FEATURE_ENABLED_PROXY_DEVICE := true -BOARD_USES_ALSA_AUDIO := true - -USE_CUSTOM_AUDIO_POLICY := 1 - -# Bluetooth -BLUETOOTH_HCI_USE_MCT := true -BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := $(LOCAL_PATH)/bluetooth -BOARD_HAVE_BLUETOOTH_QCOM := true -QCOM_BT_USE_SMD_TTY := true - -# Camera -TARGET_HAS_LEGACY_CAMERA_HAL1 := true -MALLOC_SVELTE_FOR_LIBC32 := true - -# Charger -BOARD_BATTERY_DEVICE_NAME := "battery" -BOARD_CHARGING_CMDLINE_NAME := "androidboot.bootchg" -BOARD_CHARGING_CMDLINE_VALUE := "true" -WITH_LINEAGE_CHARGER := false - -# Partitions -BOARD_FLASH_BLOCK_SIZE := 131072 -BOARD_BOOTIMAGE_PARTITION_SIZE := 10485760 -BOARD_RECOVERYIMAGE_PARTITION_SIZE := 13631488 -# Use a conservative size to make sure don't run out of space -# US variant is: 2569011200 -# EU variant is: 2411724800 -BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2000000000 -BOARD_USERDATAIMAGE_PARTITION_SIZE := 12661537792 -TARGET_USERIMAGES_USE_EXT4 := true -TARGET_USERIMAGES_USE_F2FS := true -BOARD_CACHEIMAGE_PARTITION_SIZE := 209715200 -BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4 - -# Extended Filesystem Support -TARGET_EXFAT_DRIVER := sdfat - -# Filesystem -TARGET_FS_CONFIG_GEN := $(LOCAL_PATH)/config.fs - -# Ramdisk -BOARD_ROOT_EXTRA_FOLDERS += firmware firmware-modem efs misc - -# Graphics -MAX_EGL_CACHE_KEY_SIZE := 12*1024 -MAX_EGL_CACHE_SIZE := 2048*1024 -NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3 -TARGET_ADDITIONAL_GRALLOC_10_USAGE_BITS := 0x02000000U -TARGET_DISABLE_POSTRENDER_CLEANUP := true -TARGET_BOOTANIMATION_MULTITHREAD_DECODE := true -TARGET_CONTINUOUS_SPLASH_ENABLED := true -TARGET_USES_ION := true -USE_OPENGL_RENDERER := true - -# HIDL -DEVICE_MANIFEST_FILE := $(LOCAL_PATH)/manifest.xml -DEVICE_MATRIX_FILE := $(LOCAL_PATH)/compatibility_matrix.xml -PRODUCT_ENFORCE_VINTF_MANIFEST_OVERRIDE := true - -# Legacy memfd -TARGET_HAS_MEMFD_BACKPORT := true - -# Netd -TARGET_NEEDS_NETD_DIRECT_CONNECT_RULE := true - -# Keymaster -TARGET_PROVIDES_KEYMASTER := true - -# Power -TARGET_USES_INTERACTION_BOOST := true - -# Time services -BOARD_USES_QC_TIME_SERVICES := true - -# Qualcomm support -BOARD_USES_QCOM_HARDWARE := true - -# SDClang -TARGET_USE_SDCLANG := true - -TARGET_LD_SHIM_LIBS = \ - /system/vendor/lib/hw/camera.vendor.msm8974.so|libshim_camera.so - +# Legacy BLOB Support TARGET_LD_SHIM_LIBS += \ + /system/vendor/lib/hw/camera.vendor.msm8974.so|libshim_camera.so \ /system/vendor/lib/libperipheral_client.so|libshim_binder.so - TARGET_PROCESS_SDK_VERSION_OVERRIDE += \ /system/bin/mediaserver=22 \ /system/vendor/bin/mm-qcamera-daemon=22 -# Lineage Hardware -JAVA_SOURCE_OVERLAYS := org.lineageos.hardware|$(LOCAL_PATH)/lineagehw|**/*.java +# Partitions +BOARD_BOOTIMAGE_PARTITION_SIZE := 10485760 +BOARD_CACHEIMAGE_PARTITION_SIZE := 209715200 +BOARD_RECOVERYIMAGE_PARTITION_SIZE := 13631488 +# Use a conservative size to make sure don't run out of space +# US variant is: 2569011200 +# EU variant is: 2411724800 +BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2411724800 +BOARD_USERDATAIMAGE_PARTITION_SIZE := 12661537792 +BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4 +BOARD_FLASH_BLOCK_SIZE := 131072 +BOARD_ROOT_EXTRA_FOLDERS := efs firmware firmware-modem misc +BOARD_ROOT_EXTRA_SYMLINKS := \ + /data/tombstones:/tombstones +TARGET_USERIMAGES_USE_EXT4 := true +TARGET_USERIMAGES_USE_F2FS := true -# Filesystem -TARGET_FS_CONFIG_GEN := $(LOCAL_PATH)/config.fs +# Properties +TARGET_SYSTEM_PROP += $(DEVICE_PATH)/system.prop + +# Keymaster +TARGET_PROVIDES_KEYMASTER := true # Security patch level - P905XXUABPE2 VENDOR_SECURITY_PATCH := 2016-05-01 # Recovery -BOARD_RAMDISK_USE_XZ := true -BOARD_HAS_DOWNLOAD_MODE := true - -BOARD_CUSTOM_RECOVERY_KEYMAPPING := ../../$(LOCAL_PATH)/recovery/recovery_keys.c -BOARD_USE_CUSTOM_RECOVERY_FONT := \"roboto_23x41.h\" +BOARD_CUSTOM_RECOVERY_KEYMAPPING := ../../$(DEVICE_PATH)/recovery/recovery_keys.c BOARD_USES_MMCUTILS := true BOARD_HAS_LARGE_FILESYSTEM := true BOARD_HAS_NO_MISC_PARTITION := true BOARD_HAS_NO_SELECT_BUTTON := true BOARD_RECOVERY_SWIPE := true -TARGET_RECOVERY_FSTAB := $(LOCAL_PATH)/rootdir/etc/fstab.qcom +TARGET_RECOVERY_DENSITY := xhdpi +TARGET_RECOVERY_FSTAB := $(DEVICE_PATH)/rootdir/etc/fstab.qcom # SELinux -include $(LOCAL_PATH)/sepolicy/sepolicy.mk - -SELINUX_IGNORE_NEVERALLOWS := true +include $(DEVICE_PATH)/sepolicy/sepolicy.mk # Sensors TARGET_NO_SENSOR_PERMISSION_CHECK := true diff --git a/compatibility_matrix.xml b/compatibility_matrix.xml deleted file mode 100755 index 3082485..0000000 --- a/compatibility_matrix.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - android.frameworks.schedulerservice - 1.0 - - ISchedulingPolicyService - default - - - - android.frameworks.sensorservice - 1.0 - - ISensorManager - default - - - - android.hidl.allocator - 1.0 - - IAllocator - ashmem - - - - android.hidl.manager - 1.0 - - IServiceManager - default - - - - android.hidl.memory - 1.0 - - IMapper - ashmem - - - - android.hidl.token - 1.0 - - ITokenManager - default - - - - android.system.wifi.keystore - 1.0 - - IKeystore - default - - - - diff --git a/config.fs b/config.fs index e873a39..3ff60aa 100755 --- a/config.fs +++ b/config.fs @@ -1,12 +1,3 @@ -[AID_VENDOR_QCOM_DIAG] -value:2950 - -[AID_VENDOR_RFS] -value:2951 - -[AID_VENDOR_RFS_SHARED] -value:2952 - [efs/] mode: 0771 user: AID_SYSTEM diff --git a/configs/ld.config.txt b/configs/ld.config.txt deleted file mode 100644 index 87a0456..0000000 --- a/configs/ld.config.txt +++ /dev/null @@ -1,147 +0,0 @@ -# Copyright (C) 2019 The Android Open Source Project -# -# Bionic loader config file for the media swcodec APEX. -# -# There are no versioned APEX paths here - this APEX module does not support -# having several versions mounted. - -dir.swcodec = /apex/com.android.media.swcodec/bin/ - -[swcodec] -additional.namespaces = platform,sphal - -############################################################################### -# "default" namespace -# -# This namespace is for the binaries and libraries on the swcodec APEX. -############################################################################### - -namespace.default.isolated = true -namespace.default.visible = true - -namespace.default.search.paths = /apex/com.android.media.swcodec/${LIB} -namespace.default.asan.search.paths = /apex/com.android.media.swcodec/${LIB} - -namespace.default.links = platform - -# TODO: replace the following when apex has a way to auto-generate this list -# namespace.default.link.platform.shared_libs = %LLNDK_LIBRARIES% -# namespace.default.link.platform.shared_libs += %SANITIZER_RUNTIME_LIBRARIES% -namespace.default.link.platform.shared_libs = libEGL.so:libGLESv1_CM.so:libGLESv2.so:libGLESv3.so:libRS.so:libandroid_net.so:libc.so:libcgrouprc.so:libclang_rt.asan-aarch64-android.so:libclang_rt.asan-arm-android.so:libclang_rt.hwasan-aarch64-android.so:libclang_rt.asan-i686-android.so:libclang_rt.asan-x86_64-android.so:libdl.so:libft2.so:liblog.so:libm.so:libmediandk.so:libnativewindow.so:libneuralnetworks.so:libsync.so:libvndksupport.so:libdl_android.so:libvulkan.so:libashmemd_client.so:libbinder_ndk.so - -############################################################################### -# "platform" namespace -# -# This namespace is for linking to LLNDK and ASAN libraries on the system. -############################################################################### - -namespace.platform.isolated = true - -namespace.platform.search.paths = /system/${LIB} -namespace.platform.asan.search.paths = /data/asan/system/${LIB} -namespace.platform.asan.search.paths += /system/${LIB} - -# TODO(b/140790209): These directories are wrong in R and later because they -# only contain Bionic internal libraries dependencies that should not be -# accessed from the outside. However, they may be necessary for APEX builds that -# are pushed to Q. Remove them as soon as Q compatibility is no longer required. -namespace.platform.search.paths += /apex/com.android.runtime/${LIB} -namespace.platform.asan.search.paths += /apex/com.android.runtime/${LIB} - -# /system/lib/libc.so, etc are symlinks to /apex/com.android.lib/lib/bionic/libc.so, etc. -# Add /apex/... path to the permitted paths because linker uses realpath(3) -# to check the accessibility of the lib. We could add this to search.paths -# instead but that makes the resolution of bionic libs be dependent on -# the order of /system/lib and /apex/... in search.paths. If /apex/... -# is after /system/lib, then /apex/... is never tried because libc.so -# is always found in /system/lib but fails to pass the accessibility test -# because of its realpath. It's better to not depend on the ordering if -# possible. -namespace.platform.permitted.paths = /apex/com.android.runtime/${LIB}/bionic -namespace.platform.asan.permitted.paths = /apex/com.android.runtime/${LIB}/bionic - -############################################################################### -# "sphal" namespace -# -############################################################################### -namespace.sphal.isolated = true -namespace.sphal.visible = true - -# Keep the below in sync with "sphal" namespace in system's /etc/ld.config.txt -# Codec2 has dependencies on some SP-hals (eg. android.hardware.graphics.mapper@2.0) -# These are dlopen'ed by libvndksupport.so. -namespace.sphal.search.paths = /odm/${LIB} -namespace.sphal.search.paths += /vendor/${LIB} - -namespace.sphal.permitted.paths = /odm/${LIB} -namespace.sphal.permitted.paths += /vendor/${LIB} -namespace.sphal.permitted.paths += /vendor/${LIB}/hw -namespace.sphal.permitted.paths += /system/vendor/${LIB} - -namespace.sphal.asan.search.paths = /data/asan/odm/${LIB} -namespace.sphal.asan.search.paths += /odm/${LIB} -namespace.sphal.asan.search.paths += /data/asan/vendor/${LIB} -namespace.sphal.asan.search.paths += /vendor/${LIB} - -namespace.sphal.asan.permitted.paths = /data/asan/odm/${LIB} -namespace.sphal.asan.permitted.paths += /odm/${LIB} -namespace.sphal.asan.permitted.paths += /data/asan/vendor/${LIB} -namespace.sphal.asan.permitted.paths += /vendor/${LIB} - -# Keep the below in sync with "vndk" namespace in system's /etc/ld.config.txt -# System's sphal namespace links to vndk namespace for %VNDK_SAMEPROCESS_LIBRARIES%, -# since we don't have a good way to auto-expand %VNDK_SAMEPROCESS_LIBRARIES%, -# we'll add the vndk paths below. - -namespace.sphal.search.paths += /odm/${LIB}/vndk-sp -namespace.sphal.search.paths += /vendor/${LIB}/vndk-sp -namespace.sphal.search.paths += /system/${LIB}/vndk-sp${VNDK_VER} - -# Legacy devices do not have vndk-sp, so add /system/${LIB} to search path instead -namespace.sphal.search.paths += /system/${LIB} - -namespace.sphal.permitted.paths += /odm/${LIB}/hw -namespace.sphal.permitted.paths += /odm/${LIB}/egl -namespace.sphal.permitted.paths += /vendor/${LIB}/hw -namespace.sphal.permitted.paths += /vendor/${LIB}/egl -namespace.sphal.permitted.paths += /system/vendor/${LIB}/hw -namespace.sphal.permitted.paths += /system/vendor/${LIB}/egl -# This is exceptionally required since android.hidl.memory@1.0-impl.so is here -namespace.sphal.permitted.paths += /system/${LIB}/vndk-sp${VNDK_VER}/hw - -namespace.sphal.asan.search.paths += /data/asan/odm/${LIB}/vndk-sp -namespace.sphal.asan.search.paths += /odm/${LIB}/vndk-sp -namespace.sphal.asan.search.paths += /data/asan/vendor/${LIB}/vndk-sp -namespace.sphal.asan.search.paths += /vendor/${LIB}/vndk-sp -namespace.sphal.asan.search.paths += /data/asan/system/${LIB}/vndk-sp${VNDK_VER} -namespace.sphal.asan.search.paths += /system/${LIB}/vndk-sp${VNDK_VER} - -namespace.sphal.asan.permitted.paths += /data/asan/odm/${LIB}/hw -namespace.sphal.asan.permitted.paths += /odm/${LIB}/hw -namespace.sphal.asan.permitted.paths += /data/asan/odm/${LIB}/egl -namespace.sphal.asan.permitted.paths += /odm/${LIB}/egl -namespace.sphal.asan.permitted.paths += /data/asan/vendor/${LIB}/hw -namespace.sphal.asan.permitted.paths += /vendor/${LIB}/hw -namespace.sphal.asan.permitted.paths += /data/asan/vendor/${LIB}/egl -namespace.sphal.asan.permitted.paths += /vendor/${LIB}/egl - -namespace.sphal.asan.permitted.paths += /data/asan/system/${LIB}/vndk-sp${VNDK_VER}/hw -namespace.sphal.asan.permitted.paths += /system/${LIB}/vndk-sp${VNDK_VER}/hw - -# Once in this namespace, access to libraries in /system/lib is restricted. Only -# libs listed here can be used. -namespace.sphal.links = platform - -# TODO: replace the following when apex has a way to auto-generate this list -# namespace.sphal.link.platform.shared_libs = %LLNDK_LIBRARIES% -# namespace.sphal.link.platform.shared_libs += %SANITIZER_RUNTIME_LIBRARIES% -namespace.sphal.link.platform.shared_libs = libEGL.so:libGLESv1_CM.so:libGLESv2.so:libGLESv3.so:libRS.so:libandroid_net.so:libc.so:libcgrouprc.so:libclang_rt.asan-aarch64-android.so:libclang_rt.asan-arm-android.so:libclang_rt.hwasan-aarch64-android.so:libclang_rt.asan-i686-android.so:libclang_rt.asan-x86_64-android.so:libdl.so:libft2.so:liblog.so:libm.so:libmediandk.so:libnativewindow.so:libneuralnetworks.so:libsync.so:libvndksupport.so:libvulkan.so:libbinder_ndk.so - -# Add a link for libz.so which is llndk on devices where VNDK is not enforced. -namespace.sphal.link.platform.shared_libs += libz.so - -# With VNDK APEX, /system/${LIB}/vndk-sp${VNDK_VER} is a symlink to the following. -# Add /apex/... path to the permitted paths because linker uses realpath(3) -# to check the accessibility of the lib. -namespace.sphal.permitted.paths += /apex/com.android.vndk.${VNDK_APEX_VER}/${LIB} -namespace.sphal.asan.permitted.paths += /apex/com.android.vndk.${VNDK_APEX_VER}/${LIB} diff --git a/configs/media_codecs.xml b/configs/media_codecs.xml deleted file mode 100755 index 798fa4f..0000000 --- a/configs/media_codecs.xml +++ /dev/null @@ -1,229 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/device.mk b/device.mk index 807cd33..9963ca3 100755 --- a/device.mk +++ b/device.mk @@ -1,6 +1,6 @@ # # Copyright (C) 2014-2016 The CyanogenMod Project -# Copyright (C) 2017-2018 The LineageOS Project +# Copyright (C) 2017-2018,2021 The LineageOS Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,9 +17,6 @@ $(call inherit-product, $(SRC_TARGET_DIR)/product/languages_full.mk) -# Get non-open-source specific aspects -$(call inherit-product, vendor/samsung/mondrianwifi/mondrianwifi-vendor.mk) - # We are a tablet, not a phone PRODUCT_CHARACTERISTICS := tablet @@ -28,151 +25,43 @@ DEVICE_PACKAGE_OVERLAYS += \ $(LOCAL_PATH)/overlay \ $(LOCAL_PATH)/overlay-lineage -# Device uses high-density artwork where available -PRODUCT_AAPT_CONFIG := normal -PRODUCT_AAPT_PREF_CONFIG := xhdpi # Boot animation TARGET_SCREEN_WIDTH := 2560 TARGET_SCREEN_HEIGHT := 1600 -TARGET_BOOTANIMATION_HALF_RES := true - -# Permissions -PRODUCT_COPY_FILES += \ - frameworks/native/data/etc/android.hardware.bluetooth_le.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth_le.xml \ - frameworks/native/data/etc/android.hardware.consumerir.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.consumerir.xml \ - frameworks/native/data/etc/android.hardware.camera.flash-autofocus.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.flash-autofocus.xml \ - frameworks/native/data/etc/android.hardware.camera.front.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.front.xml \ - frameworks/native/data/etc/android.hardware.ethernet.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.ethernet.xml \ - frameworks/native/data/etc/android.hardware.location.gps.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.location.gps.xml \ - frameworks/native/data/etc/android.hardware.sensor.barometer.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.barometer.xml \ - frameworks/native/data/etc/android.hardware.sensor.gyroscope.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.gyroscope.xml \ - frameworks/native/data/etc/android.hardware.sensor.light.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.light.xml \ - frameworks/native/data/etc/android.hardware.sensor.proximity.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.proximity.xml \ - frameworks/native/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \ - frameworks/native/data/etc/android.hardware.usb.accessory.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.accessory.xml \ - frameworks/native/data/etc/android.hardware.usb.host.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.host.xml \ - frameworks/native/data/etc/android.hardware.wifi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.xml \ - frameworks/native/data/etc/android.hardware.wifi.direct.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.direct.xml \ - frameworks/native/data/etc/android.software.freeform_window_management.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.freeform_window_management.xml \ - frameworks/native/data/etc/android.software.picture_in_picture.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.picture_in_picture.xml \ - frameworks/native/data/etc/android.software.sip.voip.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.sip.voip.xml - -PRODUCT_COPY_FILES += \ - frameworks/native/data/etc/android.hardware.audio.low_latency.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.low_latency.xml \ - frameworks/native/data/etc/android.hardware.sensor.stepcounter.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.stepcounter.xml \ - frameworks/native/data/etc/android.hardware.sensor.stepdetector.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.stepdetector.xml \ - frameworks/native/data/etc/android.hardware.telephony.cdma.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.telephony.cdma.xml \ - frameworks/native/data/etc/android.hardware.telephony.gsm.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.telephony.gsm.xml \ - frameworks/native/data/etc/handheld_core_hardware.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/handheld_core_hardware.xml - -# Advanced Display -PRODUCT_PACKAGES += \ - AdvancedDisplay - -# APEX -PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/configs/ld.config.txt:$(TARGET_COPY_OUT_SYSTEM)/etc/swcodec/ld.config.txt # Audio -PRODUCT_PACKAGES += \ - android.hardware.audio@2.0-impl \ - android.hardware.audio.effect@2.0-impl \ - audio_policy.msm8974 \ - audio.a2dp.default \ - audio.primary.msm8974 \ - audio.r_submix.default \ - audio.usb.default \ - libaudio-resampler \ - libqcomvisualizer \ - libqcompostprocbundle \ - libqcomvoiceprocessing \ - tinymix - PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/audio/audio_effects.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_effects.xml \ $(LOCAL_PATH)/audio/audio_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_platform_info.xml \ $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \ - $(LOCAL_PATH)/audio/mixer_paths.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths.xml - -PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/audio/mixer_paths.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths.xml \ frameworks/av/services/audiopolicy/config/a2dp_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_audio_policy_configuration.xml \ frameworks/av/services/audiopolicy/config/audio_policy_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_volumes.xml \ frameworks/av/services/audiopolicy/config/default_volume_tables.xml:$(TARGET_COPY_OUT_VENDOR)/etc/default_volume_tables.xml \ frameworks/av/services/audiopolicy/config/r_submix_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/r_submix_audio_policy_configuration.xml \ frameworks/av/services/audiopolicy/config/usb_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/usb_audio_policy_configuration.xml -# Bluetooth -PRODUCT_PACKAGES += \ - android.hardware.bluetooth@1.0-impl \ - android.hardware.bluetooth@1.0-service \ - libbt-vendor - -# Display -PRODUCT_PACKAGES += \ - android.hardware.graphics.allocator@2.0-impl \ - android.hardware.graphics.allocator@2.0-service \ - android.hardware.graphics.composer@2.1-service \ - android.hardware.graphics.mapper@2.0-impl-2.1 \ - android.hardware.memtrack@1.0-impl \ - android.hardware.memtrack@1.0-service \ - copybit.msm8974 \ - gralloc.msm8974 \ - hwcomposer.msm8974 \ - memtrack.msm8974 - # Camera -PRODUCT_PACKAGES += \ - android.hardware.camera.provider@2.4-impl \ - camera.device@1.0-impl \ - camera.msm8974 \ - Snap - PRODUCT_PACKAGES += \ libshim_camera +# Device uses high-density artwork where available +PRODUCT_AAPT_CONFIG := normal +PRODUCT_AAPT_PREF_CONFIG := xxhdpi + # Doze PRODUCT_PACKAGES += \ SamsungDoze +# DRM +PRODUCT_PACKAGES += \ + android.hardware.drm@1.3-service.clearkey + # FlipFlap PRODUCT_PACKAGES += \ FlipFlap -# DRM -PRODUCT_PACKAGES += \ - android.hardware.drm@1.0-impl \ - android.hardware.drm@1.0-service \ - android.hardware.drm@1.3-service.clearkey - -# Gatekeeper -PRODUCT_PACKAGES += \ - android.hardware.gatekeeper@1.0-service.software - -# GPS -PRODUCT_PACKAGES += \ - android.hardware.gnss@1.0-impl.legacy \ - android.hardware.gnss@1.0-service.legacy \ - gps.msm8974 - -PRODUCT_PACKAGES += \ - libshim_binder - -PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/gps/etc/flp.conf:$(TARGET_COPY_OUT_SYSTEM)/etc/flp.conf \ - $(LOCAL_PATH)/gps/etc/gps.conf:$(TARGET_COPY_OUT_SYSTEM)/etc/gps.conf \ - $(LOCAL_PATH)/gps/etc/izat.conf:$(TARGET_COPY_OUT_SYSTEM)/etc/izat.conf \ - $(LOCAL_PATH)/gps/etc/sap.conf:$(TARGET_COPY_OUT_SYSTEM)/etc/sap.conf - -# Health -PRODUCT_PACKAGES += \ - android.hardware.health@2.1-impl \ - android.hardware.health@2.1-service - -# IR Blaster -PRODUCT_PACKAGES += \ - android.hardware.ir@1.0-service.samsung - # Input device PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/idc/sec_e-pen.idc:$(TARGET_COPY_OUT_SYSTEM)/usr/idc/sec_e-pen.idc @@ -187,77 +76,27 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/keylayout/sec_touchscreen.kl:$(TARGET_COPY_OUT_SYSTEM)/usr/keylayout/sec_touchscreen.kl \ $(LOCAL_PATH)/keylayout/ue_rf4ce_remote.kl:$(TARGET_COPY_OUT_SYSTEM)/usr/keylayout/ue_rf4ce_remote.kl -# Keymaster -PRODUCT_PACKAGES += \ - android.hardware.keymaster@3.0-impl \ - android.hardware.keymaster@3.0-service - -# Lights -PRODUCT_PACKAGES += \ - android.hardware.light@2.0-service.samsung - -# LiveDisplay -PRODUCT_PACKAGES += \ - vendor.lineage.livedisplay@2.0-service.samsung-qcom - # Media PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/configs/media_profiles_V1_0.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/media_profiles_V1_0.xml \ - $(LOCAL_PATH)/configs/media_codecs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs.xml \ - $(LOCAL_PATH)/configs/media_codecs_performance.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/media_codecs_performance.xml \ + $(LOCAL_PATH)/configs/media_profiles_V1_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_profiles_V1_0.xml \ + $(LOCAL_PATH)/configs/media_codecs_performance.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_performance.xml \ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_audio.xml \ frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_telephony.xml \ frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_video.xml \ -# OMX -PRODUCT_PACKAGES += \ - libc2dcolorconvert \ - libOmxAacEnc \ - libOmxAmrEnc \ - libOmxCore \ - libOmxEvrcEnc \ - libOmxQcelp13Enc \ - libOmxVdec \ - libOmxVenc \ - libstagefrighthw - -# Power HAL -PRODUCT_PACKAGES += \ - android.hardware.power-service-qti - -# RenderScript HAL -PRODUCT_PACKAGES += \ - android.hardware.renderscript@1.0-impl - -# Seccomp +# Permissions PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/seccomp/mediacodec.policy:$(TARGET_COPY_OUT_VENDOR)/etc/seccomp_policy/mediacodec.policy - -# Sensors -PRODUCT_PACKAGES += \ - android.hardware.sensors@1.0-impl.samsung8974 \ - android.hardware.sensors@1.0-service.samsung8974 \ - sensors.msm8974 - -PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/configs/sensors/_hals.conf:$(TARGET_COPY_OUT_VENDOR)/etc/sensors/_hals.conf - -# Touch features -PRODUCT_PACKAGES += \ - vendor.lineage.touch@1.0-service.samsung - -# Trust HAL -PRODUCT_PACKAGES += \ - vendor.lineage.trust@1.0-service + frameworks/native/data/etc/android.software.freeform_window_management.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.freeform_window_management.xml \ + frameworks/native/data/etc/android.software.picture_in_picture.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.picture_in_picture.xml \ + frameworks/native/data/etc/android.hardware.audio.low_latency.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.low_latency.xml \ + frameworks/native/data/etc/android.hardware.sensor.stepcounter.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.stepcounter.xml \ + frameworks/native/data/etc/android.hardware.sensor.stepdetector.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.stepdetector.xml \ + frameworks/native/data/etc/handheld_core_hardware.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/handheld_core_hardware.xml # HW crypto PRODUCT_PACKAGES += \ vendor.qti.hardware.cryptfshw@1.0-service-ioctl-qti -# USB -PRODUCT_PACKAGES += \ - android.hardware.usb@1.0-service.basic - # Misc dependency packages PRODUCT_PACKAGES += \ libbson \ @@ -266,10 +105,7 @@ PRODUCT_PACKAGES += \ # Radio PRODUCT_PACKAGES += \ - libsecnativefeature \ - libcnefeatureconfig \ - librmnetctl \ - libxml2 + libsecnativefeature # Ramdisk PRODUCT_PACKAGES += \ @@ -280,6 +116,17 @@ PRODUCT_PACKAGES += \ init.qcom.bt.sh \ init.input.sh +# Sensors +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/configs/sensors/_hals.conf:$(TARGET_COPY_OUT_VENDOR)/etc/sensors/_hals.conf + +# Shims +PRODUCT_PACKAGES += \ + libshim_binder + +# Shipping API level +$(call inherit-product, $(SRC_TARGET_DIR)/product/product_launched_with_k.mk) + # Thermal PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/configs/thermal-engine-8974.conf:$(TARGET_COPY_OUT_VENDOR)/etc/thermal-engine-8974.conf @@ -288,18 +135,7 @@ PRODUCT_COPY_FILES += \ PRODUCT_PACKAGES += \ android.hardware.vibrator@1.0-impl -# Vendor properties --include $(LOCAL_PATH)/system_prop.mk - # Wifi -PRODUCT_PACKAGES += \ - android.hardware.wifi@1.0-service.legacy \ - dhcpcd.conf \ - libwpa_client \ - hostapd \ - wpa_supplicant \ - wpa_supplicant.conf \ - PRODUCT_PACKAGES += \ libwcnss_qmi \ wcnss_service @@ -317,11 +153,15 @@ PRODUCT_COPY_FILES += \ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/configs/sensor_def_qcomdev.conf:$(TARGET_COPY_OUT_VENDOR)/etc/sensor_def_qcomdev.conf -# Shipping API level -$(call inherit-product, $(SRC_TARGET_DIR)/product/product_launched_with_k.mk) - # ADB PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \ persist.sys.usb.config=adb \ ro.adb.secure=0 \ ro.secure=0 + +# Get non-open-source specific aspects +$(call inherit-product, vendor/samsung/mondrianwifi/mondrianwifi-vendor.mk) + +# common msm8974 +$(call inherit-product, device/samsung/msm8974-common/msm8974.mk) + diff --git a/gps/Android.mk b/gps/Android.mk deleted file mode 100644 index 5dcfbb5..0000000 --- a/gps/Android.mk +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright (C) 2018 The LineageOS Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -include $(call first-makefiles-under,$(call my-dir)) diff --git a/gps/core/Android.mk b/gps/core/Android.mk deleted file mode 100755 index 292ad06..0000000 --- a/gps/core/Android.mk +++ /dev/null @@ -1,39 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := libloc_core -LOCAL_MODULE_OWNER := qcom -LOCAL_PROPRIETARY_MODULE := true - -LOCAL_SHARED_LIBRARIES := \ - liblog \ - libutils \ - libcutils \ - libgps.utils \ - libdl - -LOCAL_SRC_FILES += \ - LocApiBase.cpp \ - LocAdapterBase.cpp \ - ContextBase.cpp \ - LocDualContext.cpp \ - loc_core_log.cpp - -LOCAL_CFLAGS += \ - -fno-short-enums \ - -D_ANDROID_ - -LOCAL_C_INCLUDES:= \ - $(TARGET_OUT_HEADERS)/gps.utils \ - $(TARGET_OUT_HEADERS)/libflp - -LOCAL_HEADER_LIBRARIES := libgps.utils_headers - - -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libloc_core_headers -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) -include $(BUILD_HEADER_LIBRARY) diff --git a/gps/core/ContextBase.cpp b/gps/core/ContextBase.cpp deleted file mode 100644 index 9f6c4aa..0000000 --- a/gps/core/ContextBase.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_CtxBase" - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace loc_core { - -LBSProxyBase* ContextBase::getLBSProxy(const char* libName) -{ - LBSProxyBase* proxy = NULL; - LOC_LOGD("%s:%d]: getLBSProxy libname: %s\n", __func__, __LINE__, libName); - void* lib = dlopen(libName, RTLD_NOW); - - if ((void*)NULL != lib) { - getLBSProxy_t* getter = (getLBSProxy_t*)dlsym(lib, "getLBSProxy"); - if (NULL != getter) { - proxy = (*getter)(); - } - } - if (NULL == proxy) { - proxy = new LBSProxyBase(); - } - LOC_LOGD("%s:%d]: Exiting\n", __func__, __LINE__); - return proxy; -} - -LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask) -{ - LocApiBase* locApi = NULL; - - // first if can not be MPQ - if (TARGET_MPQ != loc_get_target()) { - if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask, this))) { - void *handle = NULL; - //try to see if LocApiV02 is present - if((handle = dlopen("libloc_api_v02.so", RTLD_NOW)) != NULL) { - LOC_LOGD("%s:%d]: libloc_api_v02.so is present", __func__, __LINE__); - getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi"); - if(getter != NULL) { - LOC_LOGD("%s:%d]: getter is not NULL for LocApiV02", __func__, __LINE__); - locApi = (*getter)(mMsgTask, exMask, this); - } - } - // only RPC is the option now - else { - LOC_LOGD("%s:%d]: libloc_api_v02.so is NOT present. Trying RPC", - __func__, __LINE__); - handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW); - if (NULL != handle) { - getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi"); - if (NULL != getter) { - LOC_LOGD("%s:%d]: getter is not NULL in RPC", __func__, __LINE__); - locApi = (*getter)(mMsgTask, exMask, this); - } - } - } - } - } - - // locApi could still be NULL at this time - // we would then create a dummy one - if (NULL == locApi) { - locApi = new LocApiBase(mMsgTask, exMask, this); - } - - return locApi; -} - -ContextBase::ContextBase(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T exMask, - const char* libName) : - mLBSProxy(getLBSProxy(libName)), - mMsgTask(msgTask), - mLocApi(createLocApi(exMask)), - mLocApiProxy(mLocApi->getLocApiProxy()) -{ -} - -} diff --git a/gps/core/ContextBase.h b/gps/core/ContextBase.h deleted file mode 100644 index fe0b860..0000000 --- a/gps/core/ContextBase.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (c) 2011-2015, 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_CONTEXT_BASE__ -#define __LOC_CONTEXT_BASE__ - -#include -#include -#include -#include -#include - -namespace loc_core { - -class LocAdapterBase; - -class ContextBase { - static LBSProxyBase* getLBSProxy(const char* libName); - LocApiBase* createLocApi(LOC_API_ADAPTER_EVENT_MASK_T excludedMask); -protected: - const LBSProxyBase* mLBSProxy; - const MsgTask* mMsgTask; - LocApiBase* mLocApi; - LocApiProxyBase *mLocApiProxy; -public: - ContextBase(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T exMask, - const char* libName); - inline virtual ~ContextBase() { delete mLocApi; delete mLBSProxy; } - - inline const MsgTask* getMsgTask() { return mMsgTask; } - inline LocApiBase* getLocApi() { return mLocApi; } - inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; } - inline bool hasAgpsExtendedCapabilities() { return mLBSProxy->hasAgpsExtendedCapabilities(); } - inline bool hasCPIExtendedCapabilities() { return mLBSProxy->hasCPIExtendedCapabilities(); } - inline void modemPowerVote(bool power) const { return mLBSProxy->modemPowerVote(power); } - inline void requestUlp(LocAdapterBase* adapter, - unsigned long capabilities) { - mLBSProxy->requestUlp(adapter, capabilities); - } - inline IzatDevId_t getIzatDevId() const { - return mLBSProxy->getIzatDevId(); - } - inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); } -}; - -} // namespace loc_core - -#endif //__LOC_CONTEXT_BASE__ diff --git a/gps/core/LBSProxyBase.h b/gps/core/LBSProxyBase.h deleted file mode 100644 index b3736c2..0000000 --- a/gps/core/LBSProxyBase.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (c) 2013-2015, 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 IZAT_PROXY_BASE_H -#define IZAT_PROXY_BASE_H -#include -#include - -namespace loc_core { - -class LocApiBase; -class LocAdapterBase; -class ContextBase; - -class LBSProxyBase { - friend class ContextBase; - inline virtual LocApiBase* - getLocApi(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T exMask, - ContextBase* context) const { - - (void)msgTask; - (void)exMask; - (void)context; - return NULL; - } -protected: - inline LBSProxyBase() {} -public: - inline virtual ~LBSProxyBase() {} - inline virtual void requestUlp(LocAdapterBase* adapter, - unsigned long capabilities) const { - - (void)adapter; - (void)capabilities; - } - inline virtual bool hasAgpsExtendedCapabilities() const { return false; } - inline virtual bool hasCPIExtendedCapabilities() const { return false; } - inline virtual void modemPowerVote(bool power) const { - - (void)power; - } - virtual void injectFeatureConfig(ContextBase* context) const { - - (void)context; - } - inline virtual IzatDevId_t getIzatDevId() const { return 0; } -}; - -typedef LBSProxyBase* (getLBSProxy_t)(); - -} // namespace loc_core - -#endif // IZAT_PROXY_BASE_H diff --git a/gps/core/LocAdapterBase.cpp b/gps/core/LocAdapterBase.cpp deleted file mode 100644 index 8348efa..0000000 --- a/gps/core/LocAdapterBase.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_LocAdapterBase" - -#include -#include -#include -#include -#include - -namespace loc_core { - -// This is the top level class, so the constructor will -// always gets called. Here we prepare for the default. -// But if getLocApi(targetEnumType target) is overriden, -// the right locApi should get created. -LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, - ContextBase* context, LocAdapterProxyBase *adapterProxyBase) : - mEvtMask(mask), mContext(context), - mLocApi(context->getLocApi()), mLocAdapterProxyBase(adapterProxyBase), - mMsgTask(context->getMsgTask()) -{ - mLocApi->addAdapter(this); -} - -void LocAdapterBase::handleEngineUpEvent() -{ - if (mLocAdapterProxyBase) { - mLocAdapterProxyBase->handleEngineUpEvent(); - } -} - -void LocAdapterBase::handleEngineDownEvent() -{ - if (mLocAdapterProxyBase) { - mLocAdapterProxyBase->handleEngineDownEvent(); - } -} - -void LocAdapterBase:: - reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, - enum loc_sess_status status, - LocPosTechMask loc_technology_mask) { - if (mLocAdapterProxyBase == NULL || - !mLocAdapterProxyBase->reportPosition(location, - locationExtended, - status, - loc_technology_mask)) { - DEFAULT_IMPL() - } -} - -void LocAdapterBase:: - reportSv(HaxxSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt) -DEFAULT_IMPL() - - -void LocAdapterBase:: - reportStatus(GpsStatusValue status) -DEFAULT_IMPL() - - -void LocAdapterBase:: - reportNmea(const char* nmea, int length) -DEFAULT_IMPL() - -bool LocAdapterBase:: - reportXtraServer(const char* url1, const char* url2, - const char* url3, const int maxlength) -DEFAULT_IMPL(false) - -bool LocAdapterBase:: - requestXtraData() -DEFAULT_IMPL(false) - -bool LocAdapterBase:: - requestTime() -DEFAULT_IMPL(false) - -bool LocAdapterBase:: - requestLocation() -DEFAULT_IMPL(false) - -bool LocAdapterBase:: - requestATL(int connHandle, AGpsType agps_type) -DEFAULT_IMPL(false) - -bool LocAdapterBase:: - releaseATL(int connHandle) -DEFAULT_IMPL(false) - -bool LocAdapterBase:: - requestSuplES(int connHandle) -DEFAULT_IMPL(false) - -bool LocAdapterBase:: - reportDataCallOpened() -DEFAULT_IMPL(false) - -bool LocAdapterBase:: - reportDataCallClosed() -DEFAULT_IMPL(false) - -bool LocAdapterBase:: - requestNiNotify(GpsNiNotification ¬ify, const void* data) -DEFAULT_IMPL(false) - -void LocAdapterBase:: - reportGpsMeasurementData(GpsData &gpsMeasurementData) -DEFAULT_IMPL() -} // namespace loc_core diff --git a/gps/core/LocAdapterBase.h b/gps/core/LocAdapterBase.h deleted file mode 100644 index 40783df..0000000 --- a/gps/core/LocAdapterBase.h +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (c) 2011-2014, 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_API_ADAPTER_BASE_H -#define LOC_API_ADAPTER_BASE_H - -#include -#include -#include - -namespace loc_core { - -class LocAdapterProxyBase; - -class LocAdapterBase { -protected: - LOC_API_ADAPTER_EVENT_MASK_T mEvtMask; - ContextBase* mContext; - LocApiBase* mLocApi; - LocAdapterProxyBase* mLocAdapterProxyBase; - const MsgTask* mMsgTask; - - inline LocAdapterBase(const MsgTask* msgTask) : - mEvtMask(0), mContext(NULL), mLocApi(NULL), - mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {} -public: - inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); } - LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, - ContextBase* context, LocAdapterProxyBase *adapterProxyBase = NULL); - inline LOC_API_ADAPTER_EVENT_MASK_T - checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const { - return mEvtMask & mask; - } - - inline LOC_API_ADAPTER_EVENT_MASK_T getEvtMask() const { - return mEvtMask; - } - - inline void sendMsg(const LocMsg* msg) const { - mMsgTask->sendMsg(msg); - } - - inline void sendMsg(const LocMsg* msg) { - mMsgTask->sendMsg(msg); - } - - inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event, - loc_registration_mask_status isEnabled) - { - mEvtMask = - isEnabled == LOC_REGISTRATION_MASK_ENABLED ? (mEvtMask|event):(mEvtMask&~event); - - mLocApi->updateEvtMask(); - } - - // This will be overridden by the individual adapters - // if necessary. - inline virtual void setUlpProxy(UlpProxyBase* ulp) { - - (void)ulp; - } - virtual void handleEngineUpEvent(); - virtual void handleEngineDownEvent(); - inline virtual void setPositionModeInt(LocPosMode& posMode) { - - (void)posMode; - } - virtual void startFixInt() {} - virtual void stopFixInt() {} - virtual void getZppInt() {} - virtual void reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, - enum loc_sess_status status, - LocPosTechMask loc_technology_mask); - virtual void reportSv(HaxxSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt); - virtual void reportStatus(GpsStatusValue status); - virtual void reportNmea(const char* nmea, int length); - virtual bool reportXtraServer(const char* url1, const char* url2, - const char* url3, const int maxlength); - virtual bool requestXtraData(); - virtual bool requestTime(); - virtual bool requestLocation(); - virtual bool requestATL(int connHandle, AGpsType agps_type); - virtual bool releaseATL(int connHandle); - virtual bool requestSuplES(int connHandle); - virtual bool reportDataCallOpened(); - virtual bool reportDataCallClosed(); - virtual bool requestNiNotify(GpsNiNotification ¬ify, - const void* data); - inline virtual bool isInSession() { return false; } - ContextBase* getContext() const { return mContext; } - virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData); -}; - -} // namespace loc_core - -#endif //LOC_API_ADAPTER_BASE_H diff --git a/gps/core/LocAdapterProxyBase.h b/gps/core/LocAdapterProxyBase.h deleted file mode 100644 index 11859de..0000000 --- a/gps/core/LocAdapterProxyBase.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (c) 2014 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_ADAPTER_PROXY_BASE_H -#define LOC_ADAPTER_PROXY_BASE_H - -#include -#include - -namespace loc_core { - -class LocAdapterProxyBase { -private: - LocAdapterBase *mLocAdapterBase; -protected: - inline LocAdapterProxyBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, - ContextBase* context): - mLocAdapterBase(new LocAdapterBase(mask, context, this)) { - } - inline virtual ~LocAdapterProxyBase() { - delete mLocAdapterBase; - } - ContextBase* getContext() const { - return mLocAdapterBase->getContext(); - } - inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event, - loc_registration_mask_status isEnabled) { - mLocAdapterBase->updateEvtMask(event,isEnabled); - } - -public: - inline virtual void handleEngineUpEvent() {}; - inline virtual void handleEngineDownEvent() {}; - inline virtual bool reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - enum loc_sess_status status, - LocPosTechMask loc_technology_mask) { - - (void)location; - (void)locationExtended; - (void)status; - (void)loc_technology_mask; - return false; - } -}; - -} // namespace loc_core - -#endif //LOC_ADAPTER_PROXY_BASE_H diff --git a/gps/core/LocApiBase.cpp b/gps/core/LocApiBase.cpp deleted file mode 100644 index 1278155..0000000 --- a/gps/core/LocApiBase.cpp +++ /dev/null @@ -1,553 +0,0 @@ -/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_LocApiBase" - -#include -#include -#include -#include -#include - -namespace loc_core { - -#define TO_ALL_LOCADAPTERS(call) TO_ALL_ADAPTERS(mLocAdapters, (call)) -#define TO_1ST_HANDLING_LOCADAPTERS(call) TO_1ST_HANDLING_ADAPTER(mLocAdapters, (call)) - -int hexcode(char *hexstring, int string_size, - const char *data, int data_size) -{ - int i; - for (i = 0; i < data_size; i++) - { - char ch = data[i]; - if (i*2 + 3 <= string_size) - { - snprintf(&hexstring[i*2], 3, "%02X", ch); - } - else { - break; - } - } - return i; -} - -int decodeAddress(char *addr_string, int string_size, - const char *data, int data_size) -{ - const char addr_prefix = 0x91; - int i, idxOutput = 0; - - if (!data || !addr_string) { return 0; } - - if (data[0] != addr_prefix) - { - LOC_LOGW("decodeAddress: address prefix is not 0x%x but 0x%x", addr_prefix, data[0]); - addr_string[0] = '\0'; - return 0; // prefix not correct - } - - for (i = 1; i < data_size; i++) - { - unsigned char ch = data[i], low = ch & 0x0F, hi = ch >> 4; - if (low <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = low + '0'; } - if (hi <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = hi + '0'; } - } - - addr_string[idxOutput] = '\0'; // Terminates the string - - return idxOutput; -} - -struct LocSsrMsg : public LocMsg { - LocApiBase* mLocApi; - inline LocSsrMsg(LocApiBase* locApi) : - LocMsg(), mLocApi(locApi) - { - locallog(); - } - inline virtual void proc() const { - mLocApi->close(); - mLocApi->open(mLocApi->getEvtMask()); - } - inline void locallog() { - LOC_LOGV("LocSsrMsg"); - } - inline virtual void log() { - locallog(); - } -}; - -struct LocOpenMsg : public LocMsg { - LocApiBase* mLocApi; - 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(mMask); - } - inline void locallog() { - LOC_LOGV("%s:%d]: LocOpen Mask: %x\n", - __func__, __LINE__, mMask); - } - inline virtual void log() { - locallog(); - } -}; - -LocApiBase::LocApiBase(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T excludedMask, - ContextBase* context) : - mExcludedMask(excludedMask), mMsgTask(msgTask), - mMask(0), mSupportedMsg(0), mContext(context) -{ - memset(mLocAdapters, 0, sizeof(mLocAdapters)); -} - -LOC_API_ADAPTER_EVENT_MASK_T LocApiBase::getEvtMask() -{ - LOC_API_ADAPTER_EVENT_MASK_T mask = 0; - - TO_ALL_LOCADAPTERS(mask |= mLocAdapters[i]->getEvtMask()); - - return mask & ~mExcludedMask; -} - -bool LocApiBase::isInSession() -{ - bool inSession = false; - - for (int i = 0; - !inSession && i < MAX_ADAPTERS && NULL != mLocAdapters[i]; - i++) { - inSession = mLocAdapters[i]->isInSession(); - } - - return inSession; -} - -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, - (adapter->getEvtMask()))); - break; - } - } -} - -void LocApiBase::removeAdapter(LocAdapterBase* adapter) -{ - for (int i = 0; - i < MAX_ADAPTERS && NULL != mLocAdapters[i]; - i++) { - if (mLocAdapters[i] == adapter) { - mLocAdapters[i] = NULL; - - // shift the rest of the adapters up so that the pointers - // in the array do not have holes. This should be more - // performant, because the array maintenance is much much - // less frequent than event handlings, which need to linear - // search all the adapters - int j = i; - while (++i < MAX_ADAPTERS && mLocAdapters[i] != NULL); - - // i would be MAX_ADAPTERS or point to a NULL - i--; - // i now should point to a none NULL adapter within valid - // range although i could be equal to j, but it won't hurt. - // No need to check it, as it gains nothing. - mLocAdapters[j] = mLocAdapters[i]; - // this makes sure that we exit the for loop - mLocAdapters[i] = NULL; - - // if we have an empty list of adapters - if (0 == i) { - close(); - } else { - // else we need to remove the bit - mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask())); - } - } - } -} - -void LocApiBase::updateEvtMask() -{ - mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask())); -} - -void LocApiBase::handleEngineUpEvent() -{ - // This will take care of renegotiating the loc handle - mMsgTask->sendMsg(new LocSsrMsg(this)); - - LocDualContext::injectFeatureConfig(mContext); - - // loop through adapters, and deliver to all adapters. - TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent()); -} - -void LocApiBase::handleEngineDownEvent() -{ - // loop through adapters, and deliver to all adapters. - TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineDownEvent()); -} - -void LocApiBase::reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, - enum loc_sess_status status, - LocPosTechMask loc_technology_mask) -{ - // print the location info before delivering - LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n " - "altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n " - "timestamp: %lld\n rawDataSize: %d\n rawData: %p\n " - "Session status: %d\n Technology mask: %u", - location.gpsLocation.flags, location.position_source, - location.gpsLocation.latitude, location.gpsLocation.longitude, - location.gpsLocation.altitude, location.gpsLocation.speed, - location.gpsLocation.bearing, location.gpsLocation.accuracy, - location.gpsLocation.timestamp, location.rawDataSize, - location.rawData, status, loc_technology_mask); - // loop through adapters, and deliver to all adapters. - TO_ALL_LOCADAPTERS( - mLocAdapters[i]->reportPosition(location, - locationExtended, - locationExt, - status, - loc_technology_mask) - ); -} - -void LocApiBase::reportSv(HaxxSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt) -{ - // print the SV info before delivering - LOC_LOGV("num sv: %d\n ephemeris mask: %dxn almanac mask: %x\n gps/glo/bds in use" - " mask: %x/%x/%x\n sv: prn snr elevation azimuth", - svStatus.num_svs, svStatus.ephemeris_mask, - svStatus.almanac_mask, svStatus.gps_used_in_fix_mask, - svStatus.glo_used_in_fix_mask, svStatus.bds_used_in_fix_mask); - for (int i = 0; i < svStatus.num_svs && i < GPS_MAX_SVS; i++) { - LOC_LOGV(" %d: %d %f %f %f", - i, - svStatus.sv_list[i].prn, - svStatus.sv_list[i].snr, - svStatus.sv_list[i].elevation, - svStatus.sv_list[i].azimuth); - } - // loop through adapters, and deliver to all adapters. - TO_ALL_LOCADAPTERS( - mLocAdapters[i]->reportSv(svStatus, - locationExtended, - svExt) - ); -} - -void LocApiBase::reportStatus(GpsStatusValue status) -{ - // loop through adapters, and deliver to all adapters. - TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportStatus(status)); -} - -void LocApiBase::reportNmea(const char* nmea, int length) -{ - // loop through adapters, and deliver to all adapters. - TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmea(nmea, length)); -} - -void LocApiBase::reportXtraServer(const char* url1, const char* url2, - const char* url3, const int maxlength) -{ - // loop through adapters, and deliver to the first handling adapter. - TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportXtraServer(url1, url2, url3, maxlength)); - -} - -void LocApiBase::requestXtraData() -{ - // loop through adapters, and deliver to the first handling adapter. - TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestXtraData()); -} - -void LocApiBase::requestTime() -{ - // loop through adapters, and deliver to the first handling adapter. - TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestTime()); -} - -void LocApiBase::requestLocation() -{ - // loop through adapters, and deliver to the first handling adapter. - TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestLocation()); -} - -void LocApiBase::requestATL(int connHandle, AGpsType agps_type) -{ - // loop through adapters, and deliver to the first handling adapter. - TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestATL(connHandle, agps_type)); -} - -void LocApiBase::releaseATL(int connHandle) -{ - // loop through adapters, and deliver to the first handling adapter. - TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->releaseATL(connHandle)); -} - -void LocApiBase::requestSuplES(int connHandle) -{ - // loop through adapters, and deliver to the first handling adapter. - TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestSuplES(connHandle)); -} - -void LocApiBase::reportDataCallOpened() -{ - // loop through adapters, and deliver to the first handling adapter. - TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallOpened()); -} - -void LocApiBase::reportDataCallClosed() -{ - // loop through adapters, and deliver to the first handling adapter. - TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallClosed()); -} - -void LocApiBase::requestNiNotify(GpsNiNotification ¬ify, const void* data) -{ - // loop through adapters, and deliver to the first handling adapter. - TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotify(notify, data)); -} - -void LocApiBase::saveSupportedMsgList(uint64_t supportedMsgList) -{ - mSupportedMsg = supportedMsgList; -} - -void* LocApiBase :: getSibling() - DEFAULT_IMPL(NULL) - -LocApiProxyBase* LocApiBase :: getLocApiProxy() - DEFAULT_IMPL(NULL) - -void LocApiBase::reportGpsMeasurementData(GpsData &gpsMeasurementData) -{ - // loop through adapters, and deliver to all adapters. - TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGpsMeasurementData(gpsMeasurementData)); -} - -enum loc_api_adapter_err LocApiBase:: - open(LOC_API_ADAPTER_EVENT_MASK_T mask) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - close() -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - startFix(const LocPosMode& posMode) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - stopFix() -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - deleteAidingData(GpsAidingData f) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - enableData(int enable) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - setAPN(char* apn, int len) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -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:: - setTime(GpsUtcTime time, int64_t timeReference, int uncertainty) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - setXtraData(char* data, int length) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - requestXtraServer() -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - atlOpenStatus(int handle, int is_succ, char* apn, - AGpsBearerType bear, AGpsType agpsType) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - atlCloseStatus(int handle, int is_succ) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - setPositionMode(const LocPosMode& posMode) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - setServer(const char* url, int len) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - setServer(unsigned int ip, int port, - LocServerType type) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - informNiResponse(GpsUserResponseType userResponse, - const void* passThroughData) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - setSUPLVersion(uint32_t version) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - setLPPConfig(uint32_t profile) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - setSensorControlConfig(int sensorUsage, - int sensorProvider) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, - float gyroBiasVarianceRandomWalk, - bool accelBiasVarianceRandomWalk_valid, - float accelBiasVarianceRandomWalk, - bool angleBiasVarianceRandomWalk_valid, - float angleBiasVarianceRandomWalk, - bool rateBiasVarianceRandomWalk_valid, - float rateBiasVarianceRandomWalk, - bool velocityBiasVarianceRandomWalk_valid, - float velocityBiasVarianceRandomWalk) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - setSensorPerfControlConfig(int controlMode, - int accelSamplesPerBatch, - int accelBatchesPerSec, - int gyroSamplesPerBatch, - int gyroBatchesPerSec, - int accelSamplesPerBatchHigh, - int accelBatchesPerSecHigh, - int gyroSamplesPerBatchHigh, - int gyroBatchesPerSecHigh, - int algorithmConfig) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - setExtPowerConfig(int isBatteryCharging) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - setAGLONASSProtocol(unsigned long aGlonassProtocol) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - getWwanZppFix(GpsLocation& zppLoc) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -enum loc_api_adapter_err LocApiBase:: - getBestAvailableZppFix(GpsLocation& zppLoc) -{ - memset(&zppLoc, 0, sizeof(zppLoc)); - DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) -} - -enum loc_api_adapter_err LocApiBase:: - getBestAvailableZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask) -{ - memset(&zppLoc, 0, sizeof(zppLoc)); - memset(&tech_mask, 0, sizeof(tech_mask)); - DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) -} - -int LocApiBase:: - initDataServiceClient() -DEFAULT_IMPL(-1) - -int LocApiBase:: - openAndStartDataCall() -DEFAULT_IMPL(-1) - -void LocApiBase:: - stopDataCall() -DEFAULT_IMPL() - -void LocApiBase:: - closeDataCall() -DEFAULT_IMPL() - -int LocApiBase:: - setGpsLock(LOC_GPS_LOCK_MASK lock) -DEFAULT_IMPL(-1) - -void LocApiBase:: - installAGpsCert(const DerEncodedCertificate* pData, - size_t length, - uint32_t slotBitMask) -DEFAULT_IMPL() - -int LocApiBase:: - getGpsLock() -DEFAULT_IMPL(-1) - -enum loc_api_adapter_err LocApiBase:: - setXtraVersionCheck(enum xtra_version_check check) -DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) - -int LocApiBase:: - updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event, - loc_registration_mask_status isEnabled) -DEFAULT_IMPL(-1) - -bool LocApiBase:: - gnssConstellationConfig() -DEFAULT_IMPL(false) - -} // namespace loc_core diff --git a/gps/core/LocApiBase.h b/gps/core/LocApiBase.h deleted file mode 100644 index 64bb0f9..0000000 --- a/gps/core/LocApiBase.h +++ /dev/null @@ -1,267 +0,0 @@ -/* Copyright (c) 2011-2014, 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_API_BASE_H -#define LOC_API_BASE_H - -#include -#include -#include -#include -#include - -namespace loc_core { -class ContextBase; - -int hexcode(char *hexstring, int string_size, - const char *data, int data_size); -int decodeAddress(char *addr_string, int string_size, - const char *data, int data_size); - -#define MAX_ADAPTERS 10 - -#define TO_ALL_ADAPTERS(adapters, call) \ - for (int i = 0; i < MAX_ADAPTERS && NULL != (adapters)[i]; i++) { \ - call; \ - } - -#define TO_1ST_HANDLING_ADAPTER(adapters, call) \ - for (int i = 0; i sendMsg(msg); - } - - void addAdapter(LocAdapterBase* adapter); - void removeAdapter(LocAdapterBase* adapter); - - // upward calls - void handleEngineUpEvent(); - void handleEngineDownEvent(); - void reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, - enum loc_sess_status status, - LocPosTechMask loc_technology_mask = - LOC_POS_TECH_MASK_DEFAULT); - void reportSv(HaxxSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt); - void reportStatus(GpsStatusValue status); - void reportNmea(const char* nmea, int length); - void reportXtraServer(const char* url1, const char* url2, - const char* url3, const int maxlength); - void requestXtraData(); - void requestTime(); - void requestLocation(); - void requestATL(int connHandle, AGpsType agps_type); - void releaseATL(int connHandle); - void requestSuplES(int connHandle); - void reportDataCallOpened(); - void reportDataCallClosed(); - void requestNiNotify(GpsNiNotification ¬ify, const void* data); - void saveSupportedMsgList(uint64_t supportedMsgList); - void reportGpsMeasurementData(GpsData &gpsMeasurementData); - - // downward calls - // All below functions are to be defined by adapter specific modules: - // RPC, QMI, etc. The default implementation is empty. - - virtual void* getSibling(); - virtual LocApiProxyBase* getLocApiProxy(); - virtual enum loc_api_adapter_err - startFix(const LocPosMode& posMode); - virtual enum loc_api_adapter_err - stopFix(); - virtual enum loc_api_adapter_err - deleteAidingData(GpsAidingData f); - virtual enum loc_api_adapter_err - enableData(int enable); - virtual enum loc_api_adapter_err - setAPN(char* apn, int len); - virtual enum loc_api_adapter_err - injectPosition(double latitude, double longitude, float accuracy); - virtual enum loc_api_adapter_err - setTime(GpsUtcTime time, int64_t timeReference, int uncertainty); - virtual enum loc_api_adapter_err - setXtraData(char* data, int length); - virtual enum loc_api_adapter_err - requestXtraServer(); - virtual enum loc_api_adapter_err - atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType); - virtual enum loc_api_adapter_err - atlCloseStatus(int handle, int is_succ); - virtual enum loc_api_adapter_err - setPositionMode(const LocPosMode& posMode); - virtual enum loc_api_adapter_err - setServer(const char* url, int len); - virtual enum loc_api_adapter_err - setServer(unsigned int ip, int port, - LocServerType type); - virtual enum loc_api_adapter_err - informNiResponse(GpsUserResponseType userResponse, const void* passThroughData); - virtual enum loc_api_adapter_err - setSUPLVersion(uint32_t version); - virtual enum loc_api_adapter_err - setLPPConfig(uint32_t profile); - virtual enum loc_api_adapter_err - setSensorControlConfig(int sensorUsage, int sensorProvider); - virtual enum loc_api_adapter_err - setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, - float gyroBiasVarianceRandomWalk, - bool accelBiasVarianceRandomWalk_valid, - float accelBiasVarianceRandomWalk, - bool angleBiasVarianceRandomWalk_valid, - float angleBiasVarianceRandomWalk, - bool rateBiasVarianceRandomWalk_valid, - float rateBiasVarianceRandomWalk, - bool velocityBiasVarianceRandomWalk_valid, - float velocityBiasVarianceRandomWalk); - virtual enum loc_api_adapter_err - setSensorPerfControlConfig(int controlMode, - int accelSamplesPerBatch, - int accelBatchesPerSec, - int gyroSamplesPerBatch, - int gyroBatchesPerSec, - int accelSamplesPerBatchHigh, - int accelBatchesPerSecHigh, - int gyroSamplesPerBatchHigh, - int gyroBatchesPerSecHigh, - int algorithmConfig); - virtual enum loc_api_adapter_err - setExtPowerConfig(int isBatteryCharging); - virtual enum loc_api_adapter_err - setAGLONASSProtocol(unsigned long aGlonassProtocol); - virtual enum loc_api_adapter_err - getWwanZppFix(GpsLocation & zppLoc); - virtual enum loc_api_adapter_err - getBestAvailableZppFix(GpsLocation & zppLoc); - virtual enum loc_api_adapter_err - getBestAvailableZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask); - virtual int initDataServiceClient(); - virtual int openAndStartDataCall(); - virtual void stopDataCall(); - virtual void closeDataCall(); - virtual void installAGpsCert(const DerEncodedCertificate* pData, - size_t length, - uint32_t slotBitMask); - inline virtual void setInSession(bool inSession) { - - (void)inSession; - } - inline bool isMessageSupported (LocCheckingMessagesID msgID) const { - - // confirm if msgID is not larger than the number of bits in - // mSupportedMsg - if ((uint64_t)msgID > (sizeof(mSupportedMsg) << 3)) { - return false; - } else { - uint32_t messageChecker = 1 << msgID; - return (messageChecker & mSupportedMsg) == messageChecker; - } - } - void updateEvtMask(); - - /*Values for lock - 1 = Do not lock any position sessions - 2 = Lock MI position sessions - 3 = Lock MT position sessions - 4 = Lock all position sessions - */ - virtual int setGpsLock(LOC_GPS_LOCK_MASK lock); - /* - Returns - Current value of GPS Lock on success - -1 on failure - */ - virtual int getGpsLock(void); - - virtual enum loc_api_adapter_err setXtraVersionCheck(enum xtra_version_check check); - - /* - Update gps reporting events - */ - virtual int updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event, - loc_registration_mask_status isEnabled); - /* - Check if the modem support the service - */ - virtual bool gnssConstellationConfig(); -}; - -typedef LocApiBase* (getLocApi_t)(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T exMask, - ContextBase *context); - -} // namespace loc_core - -#endif //LOC_API_BASE_H diff --git a/gps/core/LocDualContext.cpp b/gps/core/LocDualContext.cpp deleted file mode 100644 index 578421c..0000000 --- a/gps/core/LocDualContext.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_DualCtx" - -#include -#include -#include -#include -#include -#include - -namespace loc_core { - -// nothing exclude for foreground -const LOC_API_ADAPTER_EVENT_MASK_T -LocDualContext::mFgExclMask = 0; -// excluded events for background clients -const LOC_API_ADAPTER_EVENT_MASK_T -LocDualContext::mBgExclMask = - (LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT | - LOC_API_ADAPTER_BIT_SATELLITE_REPORT | - LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT | - LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT | - LOC_API_ADAPTER_BIT_IOCTL_REPORT | - LOC_API_ADAPTER_BIT_STATUS_REPORT | - LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT | - LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT); - -const MsgTask* LocDualContext::mMsgTask = NULL; -ContextBase* LocDualContext::mFgContext = NULL; -ContextBase* LocDualContext::mBgContext = NULL; -ContextBase* LocDualContext::mInjectContext = NULL; -// the name must be shorter than 15 chars -const char* LocDualContext::mLocationHalName = "Loc_hal_worker"; -const char* LocDualContext::mLBSLibName = "liblbs_core.so"; - -pthread_mutex_t LocDualContext::mGetLocContextMutex = PTHREAD_MUTEX_INITIALIZER; - -const MsgTask* LocDualContext::getMsgTask(LocThread::tCreate tCreator, - const char* name, bool joinable) -{ - if (NULL == mMsgTask) { - mMsgTask = new MsgTask(tCreator, name, joinable); - } - return mMsgTask; -} - -inline -const MsgTask* LocDualContext::getMsgTask(const char* name, bool joinable) { - return getMsgTask((LocThread::tCreate)NULL, name, joinable); -} - -ContextBase* LocDualContext::getLocFgContext(LocThread::tCreate tCreator, - LocMsg* firstMsg, const char* name, bool joinable) -{ - pthread_mutex_lock(&LocDualContext::mGetLocContextMutex); - LOC_LOGD("%s:%d]: querying ContextBase with tCreator", __func__, __LINE__); - if (NULL == mFgContext) { - LOC_LOGD("%s:%d]: creating msgTask with tCreator", __func__, __LINE__); - const MsgTask* msgTask = getMsgTask(tCreator, name, joinable); - mFgContext = new LocDualContext(msgTask, - mFgExclMask); - } - if(NULL == mInjectContext) { - LOC_LOGD("%s:%d]: mInjectContext is FgContext", __func__, __LINE__); - mInjectContext = mFgContext; - injectFeatureConfig(mInjectContext); - } - pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex); - - if (firstMsg) { - mFgContext->sendMsg(firstMsg); - } - - return mFgContext; -} - -ContextBase* LocDualContext::getLocBgContext(LocThread::tCreate tCreator, - LocMsg* firstMsg, const char* name, bool joinable) -{ - pthread_mutex_lock(&LocDualContext::mGetLocContextMutex); - LOC_LOGD("%s:%d]: querying ContextBase with tCreator", __func__, __LINE__); - if (NULL == mBgContext) { - LOC_LOGD("%s:%d]: creating msgTask with tCreator", __func__, __LINE__); - const MsgTask* msgTask = getMsgTask(tCreator, name, joinable); - mBgContext = new LocDualContext(msgTask, - mBgExclMask); - } - if(NULL == mInjectContext) { - LOC_LOGD("%s:%d]: mInjectContext is BgContext", __func__, __LINE__); - mInjectContext = mBgContext; - injectFeatureConfig(mInjectContext); - } - pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex); - - if (firstMsg) { - mBgContext->sendMsg(firstMsg); - } - - return mBgContext; -} - -void LocDualContext :: injectFeatureConfig(ContextBase *curContext) -{ - LOC_LOGD("%s:%d]: Enter", __func__, __LINE__); - if(curContext == mInjectContext) { - LOC_LOGD("%s:%d]: Calling LBSProxy (%p) to inject feature config", - __func__, __LINE__, ((LocDualContext *)mInjectContext)->mLBSProxy); - ((LocDualContext *)mInjectContext)->mLBSProxy->injectFeatureConfig(curContext); - } - LOC_LOGD("%s:%d]: Exit", __func__, __LINE__); -} - -LocDualContext::LocDualContext(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T exMask) : - ContextBase(msgTask, exMask, mLBSLibName) -{ -} - -} diff --git a/gps/core/LocDualContext.h b/gps/core/LocDualContext.h deleted file mode 100644 index ce77a1a..0000000 --- a/gps/core/LocDualContext.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (c) 2011-2014, 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_ENG_CONTEXT__ -#define __LOC_ENG_CONTEXT__ - -#include -#include -#include -#include - -namespace loc_core { - -class LocDualContext : public ContextBase { - static const MsgTask* mMsgTask; - static ContextBase* mFgContext; - static ContextBase* mBgContext; - static ContextBase* mInjectContext; - static const MsgTask* getMsgTask(LocThread::tCreate tCreator, - const char* name, bool joinable = true); - static const MsgTask* getMsgTask(const char* name, bool joinable = true); - static pthread_mutex_t mGetLocContextMutex; - -protected: - LocDualContext(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T exMask); - inline virtual ~LocDualContext() {} - -public: - static const char* mLBSLibName; - static const LOC_API_ADAPTER_EVENT_MASK_T mFgExclMask; - static const LOC_API_ADAPTER_EVENT_MASK_T mBgExclMask; - static const char* mLocationHalName; - - static ContextBase* getLocFgContext(LocThread::tCreate tCreator, LocMsg* firstMsg, - const char* name, bool joinable = true); - inline static ContextBase* getLocFgContext(const char* name, bool joinable = true) { - return getLocFgContext(NULL, NULL, name, joinable); - } - static ContextBase* getLocBgContext(LocThread::tCreate tCreator, LocMsg* firstMsg, - const char* name, bool joinable = true); - inline static ContextBase* getLocBgContext(const char* name, bool joinable = true) { - return getLocBgContext(NULL, NULL, name, joinable); - } - - static void injectFeatureConfig(ContextBase *context); -}; - -} - -#endif //__LOC_ENG_CONTEXT__ diff --git a/gps/core/UlpProxyBase.h b/gps/core/UlpProxyBase.h deleted file mode 100644 index 79b5248..0000000 --- a/gps/core/UlpProxyBase.h +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright (c) 2013-2015, 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 ULP_PROXY_BASE_H -#define ULP_PROXY_BASE_H - -#include - -struct FlpExtLocation_s; -struct FlpExtBatchOptions; - -namespace loc_core { - -class LocAdapterBase; - -class UlpProxyBase { -public: - LocPosMode mPosMode; - bool mFixSet; - inline UlpProxyBase() { - mPosMode.mode = LOC_POSITION_MODE_INVALID; - mFixSet = false; - } - inline virtual ~UlpProxyBase() {} - inline virtual bool sendStartFix() { mFixSet = true; return false; } - inline virtual bool sendStopFix() { mFixSet = false; return false; } - inline virtual bool sendFixMode(LocPosMode ¶ms) { - mPosMode = params; - return false; - } - - inline virtual bool reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, - enum loc_sess_status status, - LocPosTechMask loc_technology_mask) { - (void)location; - (void)locationExtended; - (void)locationExt; - (void)status; - (void)loc_technology_mask; - return false; - } - inline virtual bool reportSv(HaxxSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt) { - (void)svStatus; - (void)locationExtended; - (void)svExt; - return false; - } - inline virtual bool reportStatus(GpsStatusValue status) { - - (void)status; - return false; - } - inline virtual void setAdapter(LocAdapterBase* adapter) { - - (void)adapter; - } - inline virtual void setCapabilities(unsigned long capabilities) { - - (void)capabilities; - } - inline virtual bool reportBatchingSession(FlpExtBatchOptions &options, - bool active) { - - (void)options; - (void)active; - return false; - } - inline virtual bool reportPositions(const struct FlpExtLocation_s* locations, - int32_t number_of_locations) { - (void)locations; - (void)number_of_locations; - return false; - } -}; - -} // namespace loc_core - -#endif // ULP_PROXY_BASE_H diff --git a/gps/core/gps_extended.h b/gps/core/gps_extended.h deleted file mode 100644 index 88b0415..0000000 --- a/gps/core/gps_extended.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (c) 2013, 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 GPS_EXTENDED_H -#define GPS_EXTENDED_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include - -struct LocPosMode -{ - LocPositionMode mode; - GpsPositionRecurrence recurrence; - uint32_t min_interval; - uint32_t preferred_accuracy; - uint32_t preferred_time; - char credentials[14]; - char provider[8]; - LocPosMode(LocPositionMode m, GpsPositionRecurrence recr, - uint32_t gap, uint32_t accu, uint32_t time, - const char* cred, const char* prov) : - mode(m), recurrence(recr), - min_interval(gap < MIN_POSSIBLE_FIX_INTERVAL ? MIN_POSSIBLE_FIX_INTERVAL : gap), - preferred_accuracy(accu), preferred_time(time) { - memset(credentials, 0, sizeof(credentials)); - memset(provider, 0, sizeof(provider)); - if (NULL != cred) { - memcpy(credentials, cred, sizeof(credentials)-1); - } - if (NULL != prov) { - memcpy(provider, prov, sizeof(provider)-1); - } - } - - inline LocPosMode() : - mode(LOC_POSITION_MODE_MS_BASED), - recurrence(GPS_POSITION_RECURRENCE_PERIODIC), - min_interval(MIN_POSSIBLE_FIX_INTERVAL), - preferred_accuracy(50), preferred_time(120000) { - memset(credentials, 0, sizeof(credentials)); - memset(provider, 0, sizeof(provider)); - } - - inline bool equals(const LocPosMode &anotherMode) const - { - return anotherMode.mode == mode && - anotherMode.recurrence == recurrence && - anotherMode.min_interval == min_interval && - anotherMode.preferred_accuracy == preferred_accuracy && - anotherMode.preferred_time == preferred_time && - !strncmp(anotherMode.credentials, credentials, sizeof(credentials)-1) && - !strncmp(anotherMode.provider, provider, sizeof(provider)-1); - } - - void logv() const; -}; - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* GPS_EXTENDED_H */ - diff --git a/gps/core/gps_extended_c.h b/gps/core/gps_extended_c.h deleted file mode 100644 index fb08364..0000000 --- a/gps/core/gps_extended_c.h +++ /dev/null @@ -1,438 +0,0 @@ -/* Copyright (c) 2013-2015, 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 GPS_EXTENDED_C_H -#define GPS_EXTENDED_C_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include -#include -#include -#include -#include - -/** Location has valid source information. */ -#define LOCATION_HAS_SOURCE_INFO 0x0020 -/** GpsLocation has valid "is indoor?" flag */ -#define GPS_LOCATION_HAS_IS_INDOOR 0x0040 -/** GpsLocation has valid floor number */ -#define GPS_LOCATION_HAS_FLOOR_NUMBER 0x0080 -/** GpsLocation has valid map URL*/ -#define GPS_LOCATION_HAS_MAP_URL 0x0100 -/** GpsLocation has valid map index */ -#define GPS_LOCATION_HAS_MAP_INDEX 0x0200 - -/** Sizes for indoor fields */ -#define GPS_LOCATION_MAP_URL_SIZE 400 -#define GPS_LOCATION_MAP_INDEX_SIZE 16 - -/** Position source is ULP */ -#define ULP_LOCATION_IS_FROM_HYBRID 0x0001 -/** Position source is GNSS only */ -#define ULP_LOCATION_IS_FROM_GNSS 0x0002 -/** Position source is ZPP only */ -#define ULP_LOCATION_IS_FROM_ZPP 0x0004 -/** Position is from a Geofence Breach Event */ -#define ULP_LOCATION_IS_FROM_GEOFENCE 0X0008 -/** Position is from Hardware FLP */ -#define ULP_LOCATION_IS_FROM_HW_FLP 0x0010 -/** Position is from NLP */ -#define ULP_LOCATION_IS_FROM_NLP 0x0020 -/** Position is from PIP */ -#define ULP_LOCATION_IS_FROM_PIP 0x0040 - -#define ULP_MIN_INTERVAL_INVALID 0xffffffff - -/*Emergency SUPL*/ -#define GPS_NI_TYPE_EMERGENCY_SUPL 4 - -#define AGPS_CERTIFICATE_MAX_LENGTH 2000 -#define AGPS_CERTIFICATE_MAX_SLOTS 10 - -enum loc_registration_mask_status { - LOC_REGISTRATION_MASK_ENABLED, - LOC_REGISTRATION_MASK_DISABLED -}; - -typedef struct { - /** set to sizeof(UlpLocation) */ - size_t size; - GpsLocation gpsLocation; - /* Provider indicator for HYBRID or GPS */ - uint16_t position_source; - /*allows HAL to pass additional information related to the location */ - int rawDataSize; /* in # of bytes */ - void * rawData; - bool is_indoor; - float floor_number; - char map_url[GPS_LOCATION_MAP_URL_SIZE]; - unsigned char map_index[GPS_LOCATION_MAP_INDEX_SIZE]; -} UlpLocation; - -/** AGPS type */ -typedef int16_t AGpsExtType; -#define AGPS_TYPE_INVALID -1 -#define AGPS_TYPE_ANY 0 -#define AGPS_TYPE_SUPL 1 -#define AGPS_TYPE_C2K 2 -#define AGPS_TYPE_WWAN_ANY 3 -#define AGPS_TYPE_WIFI 4 -#define AGPS_TYPE_SUPL_ES 5 - -/** SSID length */ -#define SSID_BUF_SIZE (32+1) - -typedef int16_t AGpsBearerType; -#define AGPS_APN_BEARER_INVALID -1 -#define AGPS_APN_BEARER_IPV4 0 -#define AGPS_APN_BEARER_IPV6 1 -#define AGPS_APN_BEARER_IPV4V6 2 - -/** GPS extended callback structure. */ -typedef struct { - /** set to sizeof(GpsCallbacks) */ - size_t size; - gps_set_capabilities set_capabilities_cb; - gps_acquire_wakelock acquire_wakelock_cb; - gps_release_wakelock release_wakelock_cb; - gps_create_thread create_thread_cb; - gps_request_utc_time request_utc_time_cb; -} GpsExtCallbacks; - -/** Callback to report the xtra server url to the client. - * The client should use this url when downloading xtra unless overwritten - * in the gps.conf file - */ -typedef void (* report_xtra_server)(const char*, const char*, const char*); - -/** Callback structure for the XTRA interface. */ -typedef struct { - gps_xtra_download_request download_request_cb; - gps_create_thread create_thread_cb; - report_xtra_server report_xtra_server_cb; -} GpsXtraExtCallbacks; - -/** Represents the status of AGPS. */ -typedef struct { - /** set to sizeof(AGpsExtStatus) */ - size_t size; - - AGpsExtType type; - AGpsStatusValue status; - uint32_t ipv4_addr; - struct sockaddr_storage addr; - char ssid[SSID_BUF_SIZE]; - char password[SSID_BUF_SIZE]; -} AGpsExtStatus; - -/** Callback with AGPS status information. - * Can only be called from a thread created by create_thread_cb. - */ -typedef void (* agps_status_extended)(AGpsExtStatus* status); - -/** Callback structure for the AGPS interface. */ -typedef struct { - agps_status_extended status_cb; - gps_create_thread create_thread_cb; -} AGpsExtCallbacks; - - -/** GPS NI callback structure. */ -typedef struct -{ - /** - * Sends the notification request from HAL to GPSLocationProvider. - */ - gps_ni_notify_callback notify_cb; - gps_create_thread create_thread_cb; -} GpsNiExtCallbacks; - -typedef enum loc_server_type { - LOC_AGPS_CDMA_PDE_SERVER, - LOC_AGPS_CUSTOM_PDE_SERVER, - LOC_AGPS_MPC_SERVER, - LOC_AGPS_SUPL_SERVER -} LocServerType; - -typedef enum loc_position_mode_type { - LOC_POSITION_MODE_INVALID = -1, - LOC_POSITION_MODE_STANDALONE = 0, - LOC_POSITION_MODE_MS_BASED, - LOC_POSITION_MODE_MS_ASSISTED, - LOC_POSITION_MODE_RESERVED_1, - LOC_POSITION_MODE_RESERVED_2, - LOC_POSITION_MODE_RESERVED_3, - LOC_POSITION_MODE_RESERVED_4, - LOC_POSITION_MODE_RESERVED_5 - -} LocPositionMode; - -#define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */ - -/** Flags to indicate which values are valid in a GpsLocationExtended. */ -typedef uint16_t GpsLocationExtendedFlags; -/** GpsLocationExtended has valid pdop, hdop, vdop. */ -#define GPS_LOCATION_EXTENDED_HAS_DOP 0x0001 -/** GpsLocationExtended has valid altitude mean sea level. */ -#define GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL 0x0002 -/** UlpLocation has valid magnetic deviation. */ -#define GPS_LOCATION_EXTENDED_HAS_MAG_DEV 0x0004 -/** UlpLocation has valid mode indicator. */ -#define GPS_LOCATION_EXTENDED_HAS_MODE_IND 0x0008 -/** GpsLocationExtended has valid vertical uncertainty */ -#define GPS_LOCATION_EXTENDED_HAS_VERT_UNC 0x0010 -/** GpsLocationExtended has valid speed uncertainty */ -#define GPS_LOCATION_EXTENDED_HAS_SPEED_UNC 0x0020 -/** GpsLocationExtended has valid heading uncertainty */ -#define GPS_LOCATION_EXTENDED_HAS_BEARING_UNC 0x0040 -/** GpsLocationExtended has valid horizontal reliability */ -#define GPS_LOCATION_EXTENDED_HAS_HOR_RELIABILITY 0x0080 -/** GpsLocationExtended has valid vertical reliability */ -#define GPS_LOCATION_EXTENDED_HAS_VERT_RELIABILITY 0x0100 - -typedef enum { - LOC_RELIABILITY_NOT_SET = 0, - LOC_RELIABILITY_VERY_LOW = 1, - LOC_RELIABILITY_LOW = 2, - LOC_RELIABILITY_MEDIUM = 3, - LOC_RELIABILITY_HIGH = 4 -}LocReliability; - -/** Represents gps location extended. */ -typedef struct { - /** set to sizeof(GpsLocationExtended) */ - size_t size; - /** Contains GpsLocationExtendedFlags bits. */ - uint16_t flags; - /** Contains the Altitude wrt mean sea level */ - float altitudeMeanSeaLevel; - /** Contains Position Dilusion of Precision. */ - float pdop; - /** Contains Horizontal Dilusion of Precision. */ - float hdop; - /** Contains Vertical Dilusion of Precision. */ - float vdop; - /** Contains Magnetic Deviation. */ - float magneticDeviation; - /** vertical uncertainty in meters */ - float vert_unc; - /** speed uncertainty in m/s */ - float speed_unc; - /** heading uncertainty in degrees (0 to 359.999) */ - float bearing_unc; - /** horizontal reliability. */ - LocReliability horizontal_reliability; - /** vertical reliability. */ - LocReliability vertical_reliability; -} GpsLocationExtended; - -/** Represents SV status. */ -typedef struct { - /** set to sizeof(HaxxSvStatus) */ - size_t size; - - /** Number of SVs currently visible. */ - int num_svs; - - /** Contains an array of SV information. */ - GpsSvInfo sv_list[GPS_MAX_SVS]; - - /** Represents a bit mask indicating which SVs - * have ephemeris data. - */ - uint32_t ephemeris_mask; - - /** Represents a bit mask indicating which SVs - * have almanac data. - */ - uint32_t almanac_mask; - - /** - * Represents a bit mask indicating which GPS SVs - * were used for computing the most recent position fix. - */ - uint32_t gps_used_in_fix_mask; - - /** - * Represents a bit mask indicating which GLONASS SVs - * were used for computing the most recent position fix. - */ - uint32_t glo_used_in_fix_mask; - - /** - * Represents a bit mask indicating which BDS SVs - * were used for computing the most recent position fix. - */ - uint64_t bds_used_in_fix_mask; - -} HaxxSvStatus; - -enum loc_sess_status { - LOC_SESS_SUCCESS, - LOC_SESS_INTERMEDIATE, - LOC_SESS_FAILURE -}; - -typedef uint32_t LocPosTechMask; -#define LOC_POS_TECH_MASK_DEFAULT ((LocPosTechMask)0x00000000) -#define LOC_POS_TECH_MASK_SATELLITE ((LocPosTechMask)0x00000001) -#define LOC_POS_TECH_MASK_CELLID ((LocPosTechMask)0x00000002) -#define LOC_POS_TECH_MASK_WIFI ((LocPosTechMask)0x00000004) -#define LOC_POS_TECH_MASK_SENSORS ((LocPosTechMask)0x00000008) -#define LOC_POS_TECH_MASK_REFERENCE_LOCATION ((LocPosTechMask)0x00000010) -#define LOC_POS_TECH_MASK_INJECTED_COARSE_POSITION ((LocPosTechMask)0x00000020) -#define LOC_POS_TECH_MASK_AFLT ((LocPosTechMask)0x00000040) -#define LOC_POS_TECH_MASK_HYBRID ((LocPosTechMask)0x00000080) - -typedef enum { - LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0, - LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM, - LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU, - LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, - LOC_ENG_IF_REQUEST_SENDER_ID_MODEM, - LOC_ENG_IF_REQUEST_SENDER_ID_UNKNOWN -} loc_if_req_sender_id_e_type; - - -#define smaller_of(a, b) (((a) > (b)) ? (b) : (a)) -#define MAX_APN_LEN 100 - -// This will be overridden by the individual adapters -// if necessary. -#define DEFAULT_IMPL(rtv) \ -{ \ - LOC_LOGD("%s: default implementation invoked", __func__); \ - return rtv; \ -} - -enum loc_api_adapter_err { - LOC_API_ADAPTER_ERR_SUCCESS = 0, - LOC_API_ADAPTER_ERR_GENERAL_FAILURE = 1, - LOC_API_ADAPTER_ERR_UNSUPPORTED = 2, - LOC_API_ADAPTER_ERR_INVALID_HANDLE = 4, - LOC_API_ADAPTER_ERR_INVALID_PARAMETER = 5, - LOC_API_ADAPTER_ERR_ENGINE_BUSY = 6, - LOC_API_ADAPTER_ERR_PHONE_OFFLINE = 7, - LOC_API_ADAPTER_ERR_TIMEOUT = 8, - LOC_API_ADAPTER_ERR_SERVICE_NOT_PRESENT = 9, - LOC_API_ADAPTER_ERR_INTERNAL = 10, - - /* equating engine down to phone offline, as they are the same errror */ - LOC_API_ADAPTER_ERR_ENGINE_DOWN = LOC_API_ADAPTER_ERR_PHONE_OFFLINE, - LOC_API_ADAPTER_ERR_FAILURE = 101, - LOC_API_ADAPTER_ERR_UNKNOWN -}; - -enum loc_api_adapter_event_index { - LOC_API_ADAPTER_REPORT_POSITION = 0, // Position report comes in loc_parsed_position_s_type - LOC_API_ADAPTER_REPORT_SATELLITE, // Satellite in view report - LOC_API_ADAPTER_REPORT_NMEA_1HZ, // NMEA report at 1HZ rate - LOC_API_ADAPTER_REPORT_NMEA_POSITION, // NMEA report at position report rate - LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY, // NI notification/verification request - LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA, // Assistance data, eg: time, predicted orbits request - LOC_API_ADAPTER_REQUEST_LOCATION_SERVER, // Request for location server - LOC_API_ADAPTER_REPORT_IOCTL, // Callback report for loc_ioctl - LOC_API_ADAPTER_REPORT_STATUS, // Misc status report: eg, engine state - LOC_API_ADAPTER_REQUEST_WIFI, // - LOC_API_ADAPTER_SENSOR_STATUS, // - LOC_API_ADAPTER_REQUEST_TIME_SYNC, // - LOC_API_ADAPTER_REPORT_SPI, // - LOC_API_ADAPTER_REPORT_NI_GEOFENCE, // - LOC_API_ADAPTER_GEOFENCE_GEN_ALERT, // - LOC_API_ADAPTER_REPORT_GENFENCE_BREACH, // - LOC_API_ADAPTER_PEDOMETER_CTRL, // - LOC_API_ADAPTER_MOTION_CTRL, // - LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA, // Wifi ap data - LOC_API_ADAPTER_BATCH_FULL, // Batching on full - LOC_API_ADAPTER_BATCHED_POSITION_REPORT, // Batching on fix - LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT, // - LOC_API_ADAPTER_GDT_UPLOAD_BEGIN_REQ, // GDT upload start request - LOC_API_ADAPTER_GDT_UPLOAD_END_REQ, // GDT upload end request - LOC_API_ADAPTER_GNSS_MEASUREMENT, // GNSS Measurement report - LOC_API_ADAPTER_REQUEST_TIMEZONE, // Timezone injection request - LOC_API_ADAPTER_REPORT_GENFENCE_DWELL_REPORT, // Geofence dwell report - LOC_API_ADAPTER_EVENT_MAX -}; - -#define LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT (1< -#include -#include - -void LocPosMode::logv() const -{ - LOC_LOGV ("Position mode: %s\n Position recurrence: %s\n " - "min interval: %d\n preferred accuracy: %d\n " - "preferred time: %d\n credentials: %s provider: %s", - loc_get_position_mode_name(mode), - loc_get_position_recurrence_name(recurrence), - min_interval, - preferred_accuracy, - preferred_time, - credentials, - provider); -} - -/* GPS status names */ -static const loc_name_val_s_type gps_status_name[] = -{ - NAME_VAL( GPS_STATUS_NONE ), - NAME_VAL( GPS_STATUS_SESSION_BEGIN ), - NAME_VAL( GPS_STATUS_SESSION_END ), - NAME_VAL( GPS_STATUS_ENGINE_ON ), - NAME_VAL( GPS_STATUS_ENGINE_OFF ), -}; -static const int gps_status_num = sizeof(gps_status_name) / sizeof(loc_name_val_s_type); - -/* Find Android GPS status name */ -const char* loc_get_gps_status_name(GpsStatusValue gps_status) -{ - return loc_get_name_from_val(gps_status_name, gps_status_num, - (long) gps_status); -} - - - -static const loc_name_val_s_type loc_eng_position_modes[] = -{ - NAME_VAL( LOC_POSITION_MODE_STANDALONE ), - NAME_VAL( LOC_POSITION_MODE_MS_BASED ), - NAME_VAL( LOC_POSITION_MODE_MS_ASSISTED ), - NAME_VAL( LOC_POSITION_MODE_RESERVED_1 ), - NAME_VAL( LOC_POSITION_MODE_RESERVED_2 ), - NAME_VAL( LOC_POSITION_MODE_RESERVED_3 ), - NAME_VAL( LOC_POSITION_MODE_RESERVED_4 ), - NAME_VAL( LOC_POSITION_MODE_RESERVED_5 ) -}; -static const int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type); - -const char* loc_get_position_mode_name(GpsPositionMode mode) -{ - return loc_get_name_from_val(loc_eng_position_modes, loc_eng_position_mode_num, (long) mode); -} - - - -static const loc_name_val_s_type loc_eng_position_recurrences[] = -{ - NAME_VAL( GPS_POSITION_RECURRENCE_PERIODIC ), - NAME_VAL( GPS_POSITION_RECURRENCE_SINGLE ) -}; -static const int loc_eng_position_recurrence_num = sizeof(loc_eng_position_recurrences) / sizeof(loc_name_val_s_type); - -const char* loc_get_position_recurrence_name(GpsPositionRecurrence 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( GPS_DELETE_EPHEMERIS ), - NAME_VAL( GPS_DELETE_ALMANAC ), - NAME_VAL( GPS_DELETE_POSITION ), - NAME_VAL( GPS_DELETE_TIME ), - NAME_VAL( GPS_DELETE_IONO ), - NAME_VAL( GPS_DELETE_UTC ), - NAME_VAL( GPS_DELETE_HEALTH ), - NAME_VAL( GPS_DELETE_SVDIR ), - NAME_VAL( GPS_DELETE_SVSTEER ), - NAME_VAL( GPS_DELETE_SADATA ), - NAME_VAL( GPS_DELETE_RTI ), - NAME_VAL( GPS_DELETE_CELLDB_INFO ), - NAME_VAL( 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(GpsAidingData data) -{ - return NULL; -} - - -static const loc_name_val_s_type loc_eng_agps_types[] = -{ - NAME_VAL( AGPS_TYPE_INVALID ), - NAME_VAL( AGPS_TYPE_ANY ), - NAME_VAL( AGPS_TYPE_SUPL ), - NAME_VAL( AGPS_TYPE_C2K ), - NAME_VAL( AGPS_TYPE_WWAN_ANY ) -}; -static const int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type); - -const char* loc_get_agps_type_name(AGpsType type) -{ - return loc_get_name_from_val(loc_eng_agps_types, loc_eng_agps_type_num, (long) type); -} - - -static const loc_name_val_s_type loc_eng_ni_types[] = -{ - NAME_VAL( GPS_NI_TYPE_VOICE ), - NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ), - NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE ), - NAME_VAL( GPS_NI_TYPE_EMERGENCY_SUPL ) -}; -static const int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type); - -const char* loc_get_ni_type_name(GpsNiType type) -{ - return loc_get_name_from_val(loc_eng_ni_types, loc_eng_ni_type_num, (long) type); -} - - -static const loc_name_val_s_type loc_eng_ni_responses[] = -{ - NAME_VAL( GPS_NI_RESPONSE_ACCEPT ), - NAME_VAL( GPS_NI_RESPONSE_DENY ), - NAME_VAL( GPS_NI_RESPONSE_DENY ) -}; -static const int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type); - -const char* loc_get_ni_response_name(GpsUserResponseType response) -{ - return loc_get_name_from_val(loc_eng_ni_responses, loc_eng_ni_reponse_num, (long) response); -} - - -static const loc_name_val_s_type loc_eng_ni_encodings[] = -{ - NAME_VAL( GPS_ENC_NONE ), - NAME_VAL( GPS_ENC_SUPL_GSM_DEFAULT ), - NAME_VAL( GPS_ENC_SUPL_UTF8 ), - NAME_VAL( GPS_ENC_SUPL_UCS2 ), - NAME_VAL( GPS_ENC_UNKNOWN ) -}; -static const int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type); - -const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding) -{ - return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding); -} - -static const loc_name_val_s_type loc_eng_agps_bears[] = -{ - NAME_VAL( AGPS_APN_BEARER_INVALID ), - NAME_VAL( AGPS_APN_BEARER_IPV4 ), - NAME_VAL( AGPS_APN_BEARER_IPV6 ), - NAME_VAL( AGPS_APN_BEARER_IPV4V6 ) -}; -static const int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type); - -const char* loc_get_agps_bear_name(AGpsBearerType bearer) -{ - return loc_get_name_from_val(loc_eng_agps_bears, loc_eng_agps_bears_num, (long) bearer); -} - -static const loc_name_val_s_type loc_eng_server_types[] = -{ - NAME_VAL( LOC_AGPS_CDMA_PDE_SERVER ), - NAME_VAL( LOC_AGPS_CUSTOM_PDE_SERVER ), - NAME_VAL( LOC_AGPS_MPC_SERVER ), - NAME_VAL( LOC_AGPS_SUPL_SERVER ) -}; -static const int loc_eng_server_types_num = sizeof(loc_eng_server_types) / sizeof(loc_name_val_s_type); - -const char* loc_get_server_type_name(LocServerType type) -{ - return loc_get_name_from_val(loc_eng_server_types, loc_eng_server_types_num, (long) type); -} - -static const loc_name_val_s_type loc_eng_position_sess_status_types[] = -{ - NAME_VAL( LOC_SESS_SUCCESS ), - NAME_VAL( LOC_SESS_INTERMEDIATE ), - NAME_VAL( LOC_SESS_FAILURE ) -}; -static const int loc_eng_position_sess_status_num = sizeof(loc_eng_position_sess_status_types) / sizeof(loc_name_val_s_type); - -const char* loc_get_position_sess_status_name(enum loc_sess_status status) -{ - return loc_get_name_from_val(loc_eng_position_sess_status_types, loc_eng_position_sess_status_num, (long) status); -} - -static const loc_name_val_s_type loc_eng_agps_status_names[] = -{ - NAME_VAL( GPS_REQUEST_AGPS_DATA_CONN ), - NAME_VAL( GPS_RELEASE_AGPS_DATA_CONN ), - NAME_VAL( GPS_AGPS_DATA_CONNECTED ), - NAME_VAL( GPS_AGPS_DATA_CONN_DONE ), - NAME_VAL( GPS_AGPS_DATA_CONN_FAILED ) -}; -static const int loc_eng_agps_status_num = sizeof(loc_eng_agps_status_names) / sizeof(loc_name_val_s_type); - -const char* loc_get_agps_status_name(AGpsStatusValue status) -{ - return loc_get_name_from_val(loc_eng_agps_status_names, loc_eng_agps_status_num, (long) status); -} diff --git a/gps/core/loc_core_log.h b/gps/core/loc_core_log.h deleted file mode 100644 index 8a1825a..0000000 --- a/gps/core/loc_core_log.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) 2011-2013, 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_CORE_LOG_H -#define LOC_CORE_LOG_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include - -const char* loc_get_gps_status_name(GpsStatusValue gps_status); -const char* loc_get_position_mode_name(GpsPositionMode mode); -const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur); -const char* loc_get_aiding_data_mask_names(GpsAidingData data); -const char* loc_get_agps_type_name(AGpsType type); -const char* loc_get_ni_type_name(GpsNiType type); -const char* loc_get_ni_response_name(GpsUserResponseType response); -const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding); -const char* loc_get_agps_bear_name(AGpsBearerType bear); -const char* loc_get_server_type_name(LocServerType type); -const char* loc_get_position_sess_status_name(enum loc_sess_status status); -const char* loc_get_agps_status_name(AGpsStatusValue status); - -#ifdef __cplusplus -} -#endif - -#endif /* LOC_CORE_LOG_H */ diff --git a/gps/etc/flp.conf b/gps/etc/flp.conf deleted file mode 100644 index a34f3d2..0000000 --- a/gps/etc/flp.conf +++ /dev/null @@ -1,60 +0,0 @@ -################################### -##### FLP settings ##### -################################### - -################################### -# FLP BATCHING SIZE -################################### -# The number of batched locations -# requested to modem. The desired number -# defined below may not be satisfied, as -# the modem can only return the number -# of batched locations that can be allocated, -# which is limited by memory. The default -# batch size defined as 20 as below. -BATCH_SIZE=20 - -################################### -# FLP BATCHING SESSION TIMEOUT -################################### -# Duration with which batch session timeout -# happens in milliseconds. If not specified -# or set to zero, batching session timeout -# defaults to 20 seconds by the modem. -# BATCH_SESSION_TIMEOUT=20000 - -################################### -# FLP CAPABILITIES BIT MASK -################################### -# GEOFENCE = 0x01 -# BATCHING = 0x02 -# default = GEOFENCE | BATCHING -CAPABILITIES=0x00 - -################################### -# FLP BATCHING ACCURACY -################################### -# Set to one of the defined values below -# to define the accuracy of batching. -# If not specified, accuracy defaults -# to LOW. -# FLP BATCHING ACCURACY values: -# Low accuracy = 0 -# Medium accuracy = 1 -# High accuracy = 2 -ACCURACY=0 - -################################### -# FLP GEOFENCE RESPONSIVENESS -################################### -# If set to one of the defined values below, -# it will override the responsiveness for -# FLP geofence, which implements the fused -# location API. If not set to a value defined -# below, which is default, it will not -# override the responsivness. -# FLP_GEOFENCE_RESPONSIVENESS_OVERRIDE Values: -# 1: LOW responsiveness -# 2: MEDIUM responsiveness -# 3: HIGH responsiveness -FLP_GEOFENCE_RESPONSIVENESS_OVERRIDE = 0 diff --git a/gps/etc/gps.conf b/gps/etc/gps.conf deleted file mode 100644 index e6646a8..0000000 --- a/gps/etc/gps.conf +++ /dev/null @@ -1,112 +0,0 @@ -#XTRA_SERVER_1=https://xtrapath1.izatcloud.net/xtra3grc.bin -#XTRA_SERVER_2=https://xtrapath2.izatcloud.net/xtra3grc.bin -#XTRA_SERVER_3=https://xtrapath3.izatcloud.net/xtra3grc.bin - -#Version check for XTRA -#DISABLE = 0 -#AUTO = 1 -#XTRA2 = 2 -#XTRA3 = 3 -XTRA_VERSION_CHECK=1 - -# Error Estimate -# _SET = 1 -# _CLEAR = 0 -ERR_ESTIMATE=0 - -# Worldwide -NTP_SERVER=1.android.pool.ntp.org - -# DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info -# 4 - Debug, 5 - Verbose -# If DEBUG_LEVEL is commented, Android's logging levels will be used -DEBUG_LEVEL = 2 - -# Intermediate position report, 1=enable, 0=disable -INTERMEDIATE_POS=0 - -# Below bit mask configures how GPS functionalities -# should be locked when user turns off GPS on Settings -# Set bit 0x1 if MO GPS functionalities are to be locked -# Set bit 0x2 if NI GPS functionalities are to be locked -# default - non is locked for backward compatibility -#GPS_LOCK = 0 - -# supl version 2.0 -SUPL_VER=0x20000 - -# Emergency SUPL, 1=enable, 0=disable -#SUPL_ES=0 -# Sensor R&D : Non-SUPL ES should be default - -#Choose PDN for Emergency SUPL -#1 - Use emergency PDN -#0 - Use regular SUPL PDN for Emergency SUPL -USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL=1 - -#SUPL_MODE is a bit mask set in config.xml per carrier by default. -#If it is uncommented here, this value will over write the value from -#config.xml. -#MSA=0X2 -#MSB=0X1 -#Sensor R&D : Change default bit mask -#SUPL_MODE=1 - -# GPS Capabilities bit mask -# SCHEDULING = 0x01 -# MSB = 0x02 -# MSA = 0x04 -# ON_DEMAND_TIME = 0x10 -# GEOFENCE = 0x20 -# default = ON_DEMAND_TIME | MSA | MSB | SCHEDULING | GEOFENCE -CAPABILITIES=0x31 - -# Accuracy threshold for intermediate positions -# less accurate positions are ignored, 0 for passing all positions -# ACCURACY_THRES=5000 - -################################ -##### AGPS server settings ##### -################################ - -# FOR SUPL SUPPORT, set the following -#SUPL_HOST=supl.google.com -#SUPL_PORT=7275 - -# FOR C2K PDE SUPPORT, set the following -# C2K_HOST=c2k.pde.com or IP -# C2K_PORT=1234 - -# Bitmask of slots that are available -# for write/install to, where 1s indicate writable, -# and the default value is 0 where no slots -# are writable. For example, AGPS_CERT_WRITABLE_MASK -# of b1000001010 makes 3 slots available -# and the remaining 7 slots unwritable. -#AGPS_CERT_WRITABLE_MASK=0 - -#################################### -# LTE Positioning Profile Settings -#################################### -# 0: Enable RRLP on LTE(Default) -# 1: Enable LPP_User_Plane on LTE -# 2: Enable LPP_Control_Plane -# 3: Enable both LPP_User_Plane and LPP_Control_Plane -#LPP_PROFILE = 0 # Sensor R&D : This will not be injected to MODEM - -################################ -# EXTRA SETTINGS -################################ -# NMEA provider (1=Modem Processor, 0=Application Processor) -NMEA_PROVIDER=1 -# Mark if it is a SGLTE target (1=SGLTE, 0=nonSGLTE) -SGLTE_TARGET=0 - -################################################## -# Select Positioning Protocol on A-GLONASS system -################################################## -# 0x1: RRC CPlane -# 0x2: RRLP UPlane -# 0x4: LLP Uplane -# Sensor R&D : This will not be injected to MODEM -A_GLONASS_POS_PROTOCOL_SELECT = 0 diff --git a/gps/etc/izat.conf b/gps/etc/izat.conf deleted file mode 100644 index 6f5d5b8..0000000 --- a/gps/etc/izat.conf +++ /dev/null @@ -1,196 +0,0 @@ -######################################### -# Log verbosity control for izat modules -######################################### -# OFF = 0, ERROR = 1, WARNING = 2, INFO = 3, DEBUG = 4, VERBOSE = 5 -IZAT_DEBUG_LEVEL = 2 - -################################################## -# Select WIFI Wait Timeout value in seconds for SUPL -################################################## -WIFI_WAIT_TIMEOUT_SELECT = 0 - -################################ -# NLP Settings -################################ -# NLP_MODE 1: GNP Only, 2: QNP Only, 3: Combo -# NLP_TOLERANCE_TIME_FIRST: Time in ms used in Combo mode -# to determine how much Tolerance for first position -# NLP_TOLERANCE_TIME_AFTER: Time in ms used in Combo mode -# to determine how much Tolerance for positions after first -# NLP_THRESHOLD: Sets how many failures needed before -# switching preferred NLP in Combo mode -# NLP_ACCURACY_MULTIPLE: Determines how far off the accuracy -# must be, in multiples, between two NLP location reports to -# be considered much worse accuracy. Used in switching logic -# NLP COMBO MODE USES QNP WITH NO EULA CONSENT: Determines -# whether or not to still send network location requests to -# QNP when the EULA is not consented to by the user. QNP can -# still return ZPP locations or injected locations even -# without EULA consent, but the uncertainty can be high. -NLP_MODE = 1 -NLP_TOLERANCE_TIME_FIRST = 5000 -NLP_TOLERANCE_TIME_AFTER = 20000 -NLP_THRESHOLD = 3 -NLP_ACCURACY_MULTIPLE = 2 -NLP_COMBO_MODE_USES_QNP_WITH_NO_EULA_CONSENT = 0 - -# Threshold period for ZPP triggers -ZPP_TRIGGER_THRESHOLD=60000 - -################################### -# GEOFENCE SERVICES -################################### -# If set to one of the defined values below, it will override -# the responsiveness for geofence services, which implements -# the Proximity Alert API. If not set to a value defined below, -# which is default, it will not override the responsivness. -# The geofence HAL API is unaffected by this value. -# GEOFENCE_SERVICES_RESPONSIVENESS_OVERRIDE Values: -# 1: LOW responsiveness -# 2: MEDIUM responsiveness -# 3: HIGH responsiveness -GEOFENCE_SERVICES_RESPONSIVENESS_OVERRIDE = 0 - -##################################### -# IZAT PREMIUM FEATURE SETTINGS -##################################### -#Possible states of a feature: -#DISABLED -#BASIC -#PREMIUM - -#GTP_CELL_PROC valid options: -# AP -# MODEM -GTP_CELL_PROC=MODEM - -#GTP_CELL valid modes: -# DISABLED -# BASIC -GTP_CELL=BASIC - -#GTP_WIFI valid modes: -# DISABLED -# BASIC -GTP_WIFI=BASIC - -#GTP_WAA valid modes: -# DISABLED -# BASIC -GTP_WAA=DISABLED - -#SAP valid modes: -# DISABLED -# BASIC -# PREMIUM -SAP=BASIC - -#ODCPI valid modes: -#DISABLED -#BASIC -ODCPI=DISABLED - -#FREE_WIFI_SCAN_INJECT valid modes: -#DISABLED -#BASIC -FREE_WIFI_SCAN_INJECT=BASIC - -#SUPL_WIFI valid modes: -#DISABLED -#BASIC -SUPL_WIFI=DISABLED - -#WIFI_SUPPLICANT_INFO valid modes: -#DISABLED -#BASIC -WIFI_SUPPLICANT_INFO=BASIC - -##################################### -# Location process launcher settings -##################################### - -#Values for PROCESS_STATE: -# ENABLED -# DISABLED - -#FEATURE MASKS: -# GTP-WIFI 0X03 -# GTP-AP-CELL 0X0c -# GTP-MP-CELL 0xc00 -# GTP-WAA 0X300 -# SAP 0Xc0 -# ODCPI 0x1000 -# FREE_WIFI_SCAN_INJECT 0x2000 -# SUPL_WIFI 0x4000 -# WIFI_SUPPLICANT_INFO 0x8000 - -#Values for PLATFORMS can be: -#1. Any valid values obtained from ro.board.platform separated by single space. For example: msm8960 msm8226 -#2. all -> for All platforms - -#Values for BASEBAND can be: -#1. Any valid values obtained from ro.baseband separated by single space. For example: sglte sglte2 -#2. all -> for all basebands - -#Valyes for LEAN_TARGETS can be: -#ENABLED -> if this process is supposed to run on lean and mean targets -#DISABLED -> if this process is to be disabled on lean and mean targets -PROCESS_NAME=/system/bin/garden_app -PROCESS_ARGUMENT=-u 0 -q 0 -j 0 -g 0 -l 0 -Z 0 -T 1 -PROCESS_STATE=ENABLED -PROCESS_GROUPS=gps net_raw -PREMIUM_FEATURE=0 -IZAT_FEATURE_MASK=0 -PLATFORMS=all -BASEBAND=auto -LEAN_TARGETS=DISABLED - -PROCESS_NAME=/system/bin/gpsone_daemon -PROCESS_ARGUMENT= -PROCESS_STATE=DISABLED -PROCESS_GROUPS=inet net_raw -PREMIUM_FEATURE=0 -IZAT_FEATURE_MASK=0 -PLATFORMS=msm7630_fusion -BASEBAND=svlte2a sglte sglte2 -LEAN_TARGETS=DISABLED - -PROCESS_NAME=/system/bin/lowi-server -PROCESS_ARGUMENT= -PROCESS_STATE=ENABLED -PROCESS_GROUPS=gps net_admin wifi inet oem_2950 net_raw -PREMIUM_FEATURE=0 -IZAT_FEATURE_MASK=0xf303 -PLATFORMS=all -BASEBAND=all -LEAN_TARGETS=DISABLED - -PROCESS_NAME=/system/bin/xtwifi-inet-agent -PROCESS_ARGUMENT= -PROCESS_STATE=ENABLED -PROCESS_GROUPS=inet gps -PREMIUM_FEATURE=1 -IZAT_FEATURE_MASK=0xc0f -PLATFORMS=all -BASEBAND=all -LEAN_TARGETS=DISABLED - -PROCESS_NAME=/system/bin/xtwifi-client -PROCESS_ARGUMENT= -PROCESS_STATE=ENABLED -PROCESS_GROUPS=net_admin wifi inet gps net_raw oem_2952 -PREMIUM_FEATURE=1 -IZAT_FEATURE_MASK=0xf0f -PLATFORMS=all -BASEBAND=all -LEAN_TARGETS=DISABLED - -PROCESS_NAME=/system/vendor/bin/slim_daemon -PROCESS_ARGUMENT= -PROCESS_STATE=ENABLED -PROCESS_GROUPS=gps net_raw oem_2950 -PREMIUM_FEATURE=1 -IZAT_FEATURE_MASK=0xf0 -PLATFORMS=all -BASEBAND=all -LEAN_TARGETS=DISABLED diff --git a/gps/etc/sap.conf b/gps/etc/sap.conf deleted file mode 100644 index 9ed2451..0000000 --- a/gps/etc/sap.conf +++ /dev/null @@ -1,53 +0,0 @@ -################################ -# Sensor Settings -################################ -#The following parameters are optional. -#Internal defaults support MEMS sensors -#native to most handset devices. -#Device specific sensor characterization -#for improved performance is possible as -#described in SAP application notes. -#GYRO_BIAS_RANDOM_WALK= -#ACCEL_RANDOM_WALK_SPECTRAL_DENSITY= -#ANGLE_RANDOM_WALK_SPECTRAL_DENSITY= -#RATE_RANDOM_WALK_SPECTRAL_DENSITY= -#VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY= - -# Sensor Sampling Rate Parameters for Low-Data Rate Filter (should be greater than 0) -# used in loc_eng_reinit -SENSOR_ACCEL_BATCHES_PER_SEC=2 -SENSOR_ACCEL_SAMPLES_PER_BATCH=5 -SENSOR_GYRO_BATCHES_PER_SEC=2 -SENSOR_GYRO_SAMPLES_PER_BATCH=5 -# Sensor Sampling Rate Parameters for High-Data Rate Filter (should be greater than 0) -SENSOR_ACCEL_BATCHES_PER_SEC_HIGH=4 -SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH=25 -SENSOR_GYRO_BATCHES_PER_SEC_HIGH=4 -SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH=25 - -# Sensor Control Mode (0=AUTO, 1=FORCE_ON) -# used in loc_eng_reinit -SENSOR_CONTROL_MODE=0 - -# Enable or Disable Sensors for GPS use (0=Enable, 1=Disable) -# used in loc_eng_reinit -SENSOR_USAGE=0 - -# Choose GSIFF sensor provider (1=Snapdragon Sensors Core, 2=Android NDK) -SENSOR_PROVIDER=2 - -# Bit mask used to define which sensor algorithms are used. -# Setting each bit has the following definition: -# 0x1 - DISABLE_INS_POSITIONING_FILTER -# 0x0 - ENABLE_INS_POSITIONING_FILTER -SENSOR_ALGORITHM_CONFIG_MASK=0x0 - -# Time source used by Sensor HAL -# Setting this value controls accuracy of location sensor services. -# 0 - Unknown -# 1 - CLOCK_BOOTTIME -# 2 - CLOCK_MONOTONIC -# 3 - CLOCK_REALTIME -# 4 - CLOCK_BOOTTIME using Alarm timer interface -NDK_PROVIDER_TIME_SOURCE=1 - diff --git a/gps/loc_api/Android.mk b/gps/loc_api/Android.mk deleted file mode 100644 index 5053e7d..0000000 --- a/gps/loc_api/Android.mk +++ /dev/null @@ -1 +0,0 @@ -include $(call all-subdir-makefiles) diff --git a/gps/loc_api/libloc_api_50001/Android.mk b/gps/loc_api/libloc_api_50001/Android.mk deleted file mode 100755 index 8b14d5f..0000000 --- a/gps/loc_api/libloc_api_50001/Android.mk +++ /dev/null @@ -1,88 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := libloc_eng -LOCAL_MODULE_OWNER := qcom -LOCAL_PROPRIETARY_MODULE := true - -LOCAL_SHARED_LIBRARIES := \ - libutils \ - libcutils \ - libdl \ - liblog \ - libloc_core \ - libgps.utils - -LOCAL_SRC_FILES += \ - loc_eng.cpp \ - loc_eng_agps.cpp \ - loc_eng_xtra.cpp \ - loc_eng_ni.cpp \ - loc_eng_log.cpp \ - loc_eng_nmea.cpp \ - LocEngAdapter.cpp - -LOCAL_SRC_FILES += \ - loc_eng_dmn_conn.cpp \ - loc_eng_dmn_conn_handler.cpp \ - loc_eng_dmn_conn_thread_helper.c \ - loc_eng_dmn_conn_glue_msg.c \ - loc_eng_dmn_conn_glue_pipe.c - -LOCAL_CFLAGS += \ - -fno-short-enums \ - -D_ANDROID_ - -LOCAL_C_INCLUDES:= \ - $(TARGET_OUT_HEADERS)/gps.utils \ - $(TARGET_OUT_HEADERS)/libloc_core \ - $(LOCAL_PATH) \ - $(TARGET_OUT_HEADERS)/libflp - -LOCAL_HEADER_LIBRARIES := libgps.utils_headers libloc_core_headers - -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libloc_eng_headers -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) -include $(BUILD_HEADER_LIBRARY) - -include $(CLEAR_VARS) - -LOCAL_MODULE := gps.$(TARGET_BOARD_PLATFORM) -LOCAL_MODULE_OWNER := qcom -LOCAL_PROPRIETARY_MODULE := true - -LOCAL_MODULE_TAGS := optional - -## Libs -LOCAL_SHARED_LIBRARIES := \ - libutils \ - libcutils \ - liblog \ - libloc_eng \ - libloc_core \ - libgps.utils \ - libdl - -LOCAL_SRC_FILES += \ - loc.cpp \ - gps.c - -LOCAL_CFLAGS += \ - -fno-short-enums \ - -D_ANDROID_ \ - -## Includes -LOCAL_C_INCLUDES:= \ - $(TARGET_OUT_HEADERS)/gps.utils \ - $(TARGET_OUT_HEADERS)/libloc_core \ - $(TARGET_OUT_HEADERS)/libflp - -LOCAL_MODULE_RELATIVE_PATH := hw - -LOCAL_HEADER_LIBRARIES := libgps.utils_headers libloc_core_headers - -include $(BUILD_SHARED_LIBRARY) diff --git a/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp b/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp deleted file mode 100644 index f8c103a..0000000 --- a/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp +++ /dev/null @@ -1,600 +0,0 @@ -/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_EngAdapter" - -#include -#include -#include -#include -#include -#include "loc_eng_msg.h" -#include "loc_log.h" - -#define CHIPSET_SERIAL_NUMBER_MAX_LEN 16 -#define USER_AGENT_MAX_LEN 512 - -using namespace loc_core; - -LocInternalAdapter::LocInternalAdapter(LocEngAdapter* adapter) : - LocAdapterBase(adapter->getMsgTask()), - mLocEngAdapter(adapter) -{ -} -void LocInternalAdapter::setPositionModeInt(LocPosMode& posMode) { - sendMsg(new LocEngPositionMode(mLocEngAdapter, posMode)); -} -void LocInternalAdapter::startFixInt() { - sendMsg(new LocEngStartFix(mLocEngAdapter)); -} -void LocInternalAdapter::stopFixInt() { - sendMsg(new LocEngStopFix(mLocEngAdapter)); -} -void LocInternalAdapter::getZppInt() { - sendMsg(new LocEngGetZpp(mLocEngAdapter)); -} - -LocEngAdapter::LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask, - void* owner, ContextBase* context, - LocThread::tCreate tCreator) : - LocAdapterBase(mask, - //Get the AFW context if VzW context has not already been intialized in - //loc_ext - context == NULL? - LocDualContext::getLocFgContext(tCreator, - NULL, - LocDualContext::mLocationHalName, - false) - :context), - mOwner(owner), mInternalAdapter(new LocInternalAdapter(this)), - mUlp(new UlpProxyBase()), mNavigating(false), - mSupportsAgpsRequests(false), - mSupportsPositionInjection(false), - mSupportsTimeInjection(false), - mPowerVote(0) -{ - memset(&mFixCriteria, 0, sizeof(mFixCriteria)); - mFixCriteria.mode = LOC_POSITION_MODE_INVALID; - LOC_LOGD("LocEngAdapter created"); -} - -inline -LocEngAdapter::~LocEngAdapter() -{ - delete mInternalAdapter; - LOC_LOGV("LocEngAdapter deleted"); -} - -void LocEngAdapter::setXtraUserAgent() { - struct LocSetXtraUserAgent : public LocMsg { - const ContextBase* const mContext; - inline LocSetXtraUserAgent(ContextBase* context) : - LocMsg(), mContext(context) { - } - virtual void proc() const { - char release[PROPERTY_VALUE_MAX]; - char manufacture[PROPERTY_VALUE_MAX]; - char model[PROPERTY_VALUE_MAX]; - char board[PROPERTY_VALUE_MAX]; - char brand[PROPERTY_VALUE_MAX]; - char chipsetsn[CHIPSET_SERIAL_NUMBER_MAX_LEN]; - char userAgent[USER_AGENT_MAX_LEN]; - const char defVal[] = "-"; - - property_get("ro.build.version.release", release, defVal); - property_get("ro.product.manufacturer", manufacture, defVal); - property_get("ro.product.model", model, defVal); - property_get("ro.product.board", board, defVal); - property_get("ro.product.brand", brand, defVal); - getChipsetSerialNo(chipsetsn, sizeof(chipsetsn), defVal); - - encodeInPlace(release, PROPERTY_VALUE_MAX); - encodeInPlace(manufacture, PROPERTY_VALUE_MAX); - encodeInPlace(model, PROPERTY_VALUE_MAX); - encodeInPlace(board, PROPERTY_VALUE_MAX); - encodeInPlace(brand, PROPERTY_VALUE_MAX); - - snprintf(userAgent, sizeof(userAgent), "A/%s/%s/%s/%s/-/QCX3/s%u/-/%s/-/%s/-/-/-", - release, manufacture, model, board, - mContext->getIzatDevId(), chipsetsn, brand); - - for (int i = 0; i < sizeof(userAgent) && userAgent[i]; i++) { - if (' ' == userAgent[i]) userAgent[i] = '#'; - } - - saveUserAgentString(userAgent, strlen(userAgent)); - LOC_LOGV("%s] UserAgent %s", __func__, userAgent); - } - - void saveUserAgentString(const char* data, const int len) const { - const char XTRA_FOLDER[] = "/data/misc/location/xtra"; - const char USER_AGENT_FILE[] = "/data/misc/location/xtra/useragent.txt"; - - if (data == NULL || len < 1) { - LOC_LOGE("%s:%d]: invalid input data = %p len = %d", __func__, __LINE__, data, len); - return; - } - - struct stat s; - int err = stat(XTRA_FOLDER, &s); - if (err < 0) { - if (ENOENT == errno) { - if (mkdir(XTRA_FOLDER, 0700) < 0) { - LOC_LOGE("%s:%d]: make XTRA_FOLDER failed", __func__, __LINE__); - return; - } - } else { - LOC_LOGE("%s:%d]: XTRA_FOLDER invalid", __func__, __LINE__); - return; - } - } - - FILE* file = fopen(USER_AGENT_FILE, "wt"); - if (file == NULL) { - LOC_LOGE("%s:%d]: open USER_AGENT_FILE failed", __func__, __LINE__); - return; - } - - size_t written = fwrite(data, 1, len, file); - fclose(file); - file = NULL; - - // set file permission - chmod(USER_AGENT_FILE, 0600); - - if (written != len) { - LOC_LOGE("%s:%d]: write USER_AGENT_FILE failed", __func__, __LINE__); - } - } - - void getChipsetSerialNo(char buf[], int buflen, const char def[]) const { - const char SOC_SERIAL_NUMBER[] = "/sys/devices/soc0/serial_number"; - - FILE* file = fopen(SOC_SERIAL_NUMBER, "rt"); - if (file == NULL) { - // use default upon unreadable file - strlcpy(buf, def, buflen); - - } else { - size_t size = fread(buf, 1, buflen - 1, file); - if (size == 0) { - // use default upon empty file - strlcpy(buf, def, buflen); - - } else { - buf[size] = '\0'; - } - - fclose(file); - - // remove trailing spaces - char *s; - s = buf + strlen(buf); - while (--s >= buf) { - if (!isspace(*s)) break; - *s = 0; - } - } - - return; - } - - /** - * encode the given string value such that all separator characters ('/','+','|','%') - * in the string are repaced by their corresponding encodings (%2F","%2B","%7C", "%25") - */ - static void encodeInPlace(char value[], const int size) { - char buffer[size]; - - struct ENCODE { - const char ch; - const char *code; - }; - - const ENCODE encodings[] = { {'/', "%2F"}, {'+', "%2B"}, {'|', "%7C",}, {'%', "%25"} }; - const int nencodings = (int)sizeof(encodings) / sizeof(encodings[0]); - - int inpos = 0, outpos = 0; - while(value[inpos] != '\0' && outpos < size - 1) { - // check if escaped character - int escchar = 0; - while(escchar < nencodings && encodings[escchar].ch != value[inpos]) { - escchar++; - } - - if (escchar == nencodings) { - // non escaped character - buffer[outpos++] = value[inpos++]; - continue; - } - - // escaped character - int codepos = 0; - #define NUM_CHARS_IN_CODE 3 - - if (outpos + NUM_CHARS_IN_CODE >= size) { - // skip last character if there is insufficient space - break; - } - - while(outpos < size - 1 && codepos < NUM_CHARS_IN_CODE) { - buffer[outpos++] = encodings[escchar].code[codepos++]; - } - inpos++; - } - - // copy to ouput - value[outpos] = '\0'; - while(--outpos >= 0) { - value[outpos] = buffer[outpos]; - } - } - }; - - sendMsg(new LocSetXtraUserAgent(mContext)); -} - -void LocInternalAdapter::setUlpProxy(UlpProxyBase* ulp) { - struct LocSetUlpProxy : public LocMsg { - LocAdapterBase* mAdapter; - UlpProxyBase* mUlp; - inline LocSetUlpProxy(LocAdapterBase* adapter, UlpProxyBase* ulp) : - LocMsg(), mAdapter(adapter), mUlp(ulp) { - } - virtual void proc() const { - LOC_LOGV("%s] ulp %p adapter %p", __func__, - mUlp, mAdapter); - mAdapter->setUlpProxy(mUlp); - } - }; - - sendMsg(new LocSetUlpProxy(mLocEngAdapter, ulp)); -} - -void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp) -{ - if (ulp == mUlp) { - //This takes care of the case when double initalization happens - //and we get the same object back for UlpProxyBase . Do nothing - return; - } - - LOC_LOGV("%s] %p", __func__, ulp); - if (NULL == ulp) { - LOC_LOGE("%s:%d]: ulp pointer is NULL", __func__, __LINE__); - ulp = new UlpProxyBase(); - } - - if (LOC_POSITION_MODE_INVALID != mUlp->mPosMode.mode) { - // need to send this mode and start msg to ULP - ulp->sendFixMode(mUlp->mPosMode); - } - - if(mUlp->mFixSet) { - ulp->sendStartFix(); - } - - delete mUlp; - mUlp = ulp; -} - -int LocEngAdapter::setGpsLockMsg(LOC_GPS_LOCK_MASK lockMask) -{ - struct LocEngAdapterGpsLock : public LocMsg { - LocEngAdapter* mAdapter; - LOC_GPS_LOCK_MASK mLockMask; - inline LocEngAdapterGpsLock(LocEngAdapter* adapter, LOC_GPS_LOCK_MASK lockMask) : - LocMsg(), mAdapter(adapter), mLockMask(lockMask) - { - locallog(); - } - inline virtual void proc() const { - mAdapter->setGpsLock(mLockMask); - } - inline void locallog() const { - LOC_LOGV("LocEngAdapterGpsLock - mLockMask: %x", mLockMask); - } - inline virtual void log() const { - locallog(); - } - }; - sendMsg(new LocEngAdapterGpsLock(this, lockMask)); - return 0; -} - -void LocEngAdapter::requestPowerVote() -{ - if (getPowerVoteRight()) { - /* Power voting without engine lock: - * 101: vote down, 102-104 - vote up - * These codes are used not to confuse with actual engine lock - * functionality, that can't be used in SSR scenario, as it - * conflicts with initialization sequence. - */ - bool powerUp = getPowerVote(); - LOC_LOGV("LocEngAdapterVotePower - Vote Power: %d", (int)powerUp); - setGpsLock(powerUp ? 103 : 101); - } -} - -void LocInternalAdapter::reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, - enum loc_sess_status status, - LocPosTechMask loc_technology_mask) -{ - sendMsg(new LocEngReportPosition(mLocEngAdapter, - location, - locationExtended, - locationExt, - status, - loc_technology_mask)); -} - - -void LocEngAdapter::reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, - enum loc_sess_status status, - LocPosTechMask loc_technology_mask) -{ - if (! mUlp->reportPosition(location, - locationExtended, - locationExt, - status, - loc_technology_mask )) { - mInternalAdapter->reportPosition(location, - locationExtended, - locationExt, - status, - loc_technology_mask); - } -} - -void LocInternalAdapter::reportSv(HaxxSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt){ - sendMsg(new LocEngReportSv(mLocEngAdapter, svStatus, - locationExtended, svExt)); -} - -void LocEngAdapter::reportSv(HaxxSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt) -{ - - // We want to send SV info to ULP to help it in determining GNSS - // signal strength ULP will forward the SV reports to HAL without - // any modifications - if (! mUlp->reportSv(svStatus, locationExtended, svExt)) { - mInternalAdapter->reportSv(svStatus, locationExtended, svExt); - } -} - -void LocEngAdapter::setInSession(bool inSession) -{ - mNavigating = inSession; - mLocApi->setInSession(inSession); - if (!mNavigating) { - mFixCriteria.mode = LOC_POSITION_MODE_INVALID; - } -} - -void LocInternalAdapter::reportStatus(GpsStatusValue status) -{ - sendMsg(new LocEngReportStatus(mLocEngAdapter, status)); -} - -void LocEngAdapter::reportStatus(GpsStatusValue status) -{ - if (!mUlp->reportStatus(status)) { - mInternalAdapter->reportStatus(status); - } -} - -inline -void LocEngAdapter::reportNmea(const char* nmea, int length) -{ - sendMsg(new LocEngReportNmea(mOwner, nmea, length)); -} - -inline -bool LocEngAdapter::reportXtraServer(const char* url1, - const char* url2, - const char* url3, - const int maxlength) -{ - if (mSupportsAgpsRequests) { - sendMsg(new LocEngReportXtraServer(mOwner, url1, - url2, url3, maxlength)); - } - return mSupportsAgpsRequests; -} - -inline -bool LocEngAdapter::requestATL(int connHandle, AGpsType agps_type) -{ - if (mSupportsAgpsRequests) { - sendMsg(new LocEngRequestATL(mOwner, - connHandle, agps_type)); - } - return mSupportsAgpsRequests; -} - -inline -bool LocEngAdapter::releaseATL(int connHandle) -{ - if (mSupportsAgpsRequests) { - sendMsg(new LocEngReleaseATL(mOwner, connHandle)); - } - return mSupportsAgpsRequests; -} - -inline -bool LocEngAdapter::requestXtraData() -{ - if (mSupportsAgpsRequests) { - sendMsg(new LocEngRequestXtra(mOwner)); - } - return mSupportsAgpsRequests; -} - -inline -bool LocEngAdapter::requestTime() -{ - if (mSupportsAgpsRequests) { - sendMsg(new LocEngRequestTime(mOwner)); - } - return mSupportsAgpsRequests; -} - -inline -bool LocEngAdapter::requestNiNotify(GpsNiNotification ¬if, const void* data) -{ - if (mSupportsAgpsRequests) { - notif.size = sizeof(notif); - notif.timeout = LOC_NI_NO_RESPONSE_TIME; - - sendMsg(new LocEngRequestNi(mOwner, notif, data)); - } - return mSupportsAgpsRequests; -} - -inline -bool LocEngAdapter::requestSuplES(int connHandle) -{ - if (mSupportsAgpsRequests) - sendMsg(new LocEngRequestSuplEs(mOwner, connHandle)); - return mSupportsAgpsRequests; -} - -inline -bool LocEngAdapter::reportDataCallOpened() -{ - if(mSupportsAgpsRequests) - sendMsg(new LocEngSuplEsOpened(mOwner)); - return mSupportsAgpsRequests; -} - -inline -bool LocEngAdapter::reportDataCallClosed() -{ - if(mSupportsAgpsRequests) - sendMsg(new LocEngSuplEsClosed(mOwner)); - return mSupportsAgpsRequests; -} - -inline -void LocEngAdapter::handleEngineDownEvent() -{ - sendMsg(new LocEngDown(mOwner)); -} - -inline -void LocEngAdapter::handleEngineUpEvent() -{ - sendMsg(new LocEngUp(mOwner)); -} - -enum loc_api_adapter_err LocEngAdapter::setTime(GpsUtcTime time, - int64_t timeReference, - int uncertainty) -{ - loc_api_adapter_err result = LOC_API_ADAPTER_ERR_SUCCESS; - - LOC_LOGD("%s:%d]: mSupportsTimeInjection is %d", - __func__, __LINE__, mSupportsTimeInjection); - - if (mSupportsTimeInjection) { - LOC_LOGD("%s:%d]: Injecting time", __func__, __LINE__); - result = mLocApi->setTime(time, timeReference, uncertainty); - } else { - mSupportsTimeInjection = true; - } - return result; -} - -enum loc_api_adapter_err LocEngAdapter::setXtraVersionCheck(int check) -{ - enum loc_api_adapter_err ret; - ENTRY_LOG(); - enum xtra_version_check eCheck; - switch (check) { - case 0: - eCheck = DISABLED; - break; - case 1: - eCheck = AUTO; - break; - case 2: - eCheck = XTRA2; - break; - case 3: - eCheck = XTRA3; - break; - default: - eCheck = DISABLED; - } - ret = mLocApi->setXtraVersionCheck(eCheck); - EXIT_LOG(%d, ret); - return ret; -} - -void LocEngAdapter::reportGpsMeasurementData(GpsData &gpsMeasurementData) -{ - sendMsg(new LocEngReportGpsMeasurement(mOwner, - gpsMeasurementData)); -} - -/* - Update Registration Mask - */ -void LocEngAdapter::updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event, - loc_registration_mask_status isEnabled) -{ - LOC_LOGD("entering %s", __func__); - int result = LOC_API_ADAPTER_ERR_FAILURE; - result = mLocApi->updateRegistrationMask(event, isEnabled); - if (result == LOC_API_ADAPTER_ERR_SUCCESS) { - LOC_LOGD("%s] update registration mask succeed.", __func__); - } else { - LOC_LOGE("%s] update registration mask failed.", __func__); - } -} - -/* - Set Gnss Constellation Config - */ -bool LocEngAdapter::gnssConstellationConfig() -{ - LOC_LOGD("entering %s", __func__); - bool result = false; - result = mLocApi->gnssConstellationConfig(); - return result; -} diff --git a/gps/loc_api/libloc_api_50001/LocEngAdapter.h b/gps/loc_api/libloc_api_50001/LocEngAdapter.h deleted file mode 100644 index b58c8e7..0000000 --- a/gps/loc_api/libloc_api_50001/LocEngAdapter.h +++ /dev/null @@ -1,351 +0,0 @@ -/* Copyright (c) 2011-2015, 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_API_ENG_ADAPTER_H -#define LOC_API_ENG_ADAPTER_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAX_URL_LEN 256 - -using namespace loc_core; - -class LocEngAdapter; - -class LocInternalAdapter : public LocAdapterBase { - LocEngAdapter* mLocEngAdapter; -public: - LocInternalAdapter(LocEngAdapter* adapter); - - virtual void reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, - enum loc_sess_status status, - LocPosTechMask loc_technology_mask); - virtual void reportSv(HaxxSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt); - virtual void reportStatus(GpsStatusValue status); - virtual void setPositionModeInt(LocPosMode& posMode); - virtual void startFixInt(); - virtual void stopFixInt(); - virtual void getZppInt(); - virtual void setUlpProxy(UlpProxyBase* ulp); -}; - -typedef void (*loc_msg_sender)(void* loc_eng_data_p, void* msgp); - -class LocEngAdapter : public LocAdapterBase { - void* mOwner; - LocInternalAdapter* mInternalAdapter; - UlpProxyBase* mUlp; - LocPosMode mFixCriteria; - bool mNavigating; - // mPowerVote is encoded as - // mPowerVote & 0x20 -- powerVoteRight - // mPowerVote & 0x10 -- power On / Off - unsigned int mPowerVote; - static const unsigned int POWER_VOTE_RIGHT = 0x20; - static const unsigned int POWER_VOTE_VALUE = 0x10; - -public: - bool mSupportsAgpsRequests; - bool mSupportsPositionInjection; - bool mSupportsTimeInjection; - - LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask, - void* owner, ContextBase* context, - LocThread::tCreate tCreator); - virtual ~LocEngAdapter(); - - virtual void setUlpProxy(UlpProxyBase* ulp); - void setXtraUserAgent(); - inline void requestUlp(unsigned long capabilities) { - mContext->requestUlp(mInternalAdapter, capabilities); - } - inline LocInternalAdapter* getInternalAdapter() { return mInternalAdapter; } - inline UlpProxyBase* getUlpProxy() { return mUlp; } - inline void* getOwner() { return mOwner; } - inline bool hasAgpsExtendedCapabilities() { - return mContext->hasAgpsExtendedCapabilities(); - } - inline bool hasCPIExtendedCapabilities() { - return mContext->hasCPIExtendedCapabilities(); - } - inline const MsgTask* getMsgTask() { return mMsgTask; } - - inline enum loc_api_adapter_err - startFix() - { - return mLocApi->startFix(mFixCriteria); - } - inline enum loc_api_adapter_err - stopFix() - { - return mLocApi->stopFix(); - } - inline enum loc_api_adapter_err - deleteAidingData(GpsAidingData f) - { - return mLocApi->deleteAidingData(f); - } - inline enum loc_api_adapter_err - enableData(int enable) - { - return mLocApi->enableData(enable); - } - inline enum loc_api_adapter_err - setAPN(char* apn, int len) - { - return mLocApi->setAPN(apn, len); - } - inline enum loc_api_adapter_err - injectPosition(double latitude, double longitude, float accuracy) - { - return mLocApi->injectPosition(latitude, longitude, accuracy); - } - inline enum loc_api_adapter_err - setXtraData(char* data, int length) - { - return mLocApi->setXtraData(data, length); - } - inline enum loc_api_adapter_err - requestXtraServer() - { - return mLocApi->requestXtraServer(); - } - inline enum loc_api_adapter_err - atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, AGpsType agpsType) - { - return mLocApi->atlOpenStatus(handle, is_succ, apn, bearer, agpsType); - } - inline enum loc_api_adapter_err - atlCloseStatus(int handle, int is_succ) - { - return mLocApi->atlCloseStatus(handle, is_succ); - } - inline enum loc_api_adapter_err - setPositionMode(const LocPosMode *posMode) - { - if (NULL != posMode) { - mFixCriteria = *posMode; - } - return mLocApi->setPositionMode(mFixCriteria); - } - inline enum loc_api_adapter_err - setServer(const char* url, int len) - { - return mLocApi->setServer(url, len); - } - inline enum loc_api_adapter_err - setServer(unsigned int ip, int port, - LocServerType type) - { - return mLocApi->setServer(ip, port, type); - } - inline enum loc_api_adapter_err - informNiResponse(GpsUserResponseType userResponse, const void* passThroughData) - { - return mLocApi->informNiResponse(userResponse, passThroughData); - } - inline enum loc_api_adapter_err - setSUPLVersion(uint32_t version) - { - return mLocApi->setSUPLVersion(version); - } - inline enum loc_api_adapter_err - setLPPConfig(uint32_t profile) - { - return mLocApi->setLPPConfig(profile); - } - inline enum loc_api_adapter_err - setSensorControlConfig(int sensorUsage, int sensorProvider) - { - return mLocApi->setSensorControlConfig(sensorUsage, sensorProvider); - } - inline enum loc_api_adapter_err - setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, float gyroBiasVarianceRandomWalk, - bool accelBiasVarianceRandomWalk_valid, float accelBiasVarianceRandomWalk, - bool angleBiasVarianceRandomWalk_valid, float angleBiasVarianceRandomWalk, - bool rateBiasVarianceRandomWalk_valid, float rateBiasVarianceRandomWalk, - bool velocityBiasVarianceRandomWalk_valid, float velocityBiasVarianceRandomWalk) - { - return mLocApi->setSensorProperties(gyroBiasVarianceRandomWalk_valid, gyroBiasVarianceRandomWalk, - accelBiasVarianceRandomWalk_valid, accelBiasVarianceRandomWalk, - angleBiasVarianceRandomWalk_valid, angleBiasVarianceRandomWalk, - rateBiasVarianceRandomWalk_valid, rateBiasVarianceRandomWalk, - velocityBiasVarianceRandomWalk_valid, velocityBiasVarianceRandomWalk); - } - inline virtual enum loc_api_adapter_err - setSensorPerfControlConfig(int controlMode, int accelSamplesPerBatch, int accelBatchesPerSec, - int gyroSamplesPerBatch, int gyroBatchesPerSec, - int accelSamplesPerBatchHigh, int accelBatchesPerSecHigh, - int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh, int algorithmConfig) - { - return mLocApi->setSensorPerfControlConfig(controlMode, accelSamplesPerBatch, accelBatchesPerSec, - gyroSamplesPerBatch, gyroBatchesPerSec, - accelSamplesPerBatchHigh, accelBatchesPerSecHigh, - gyroSamplesPerBatchHigh, gyroBatchesPerSecHigh, - algorithmConfig); - } - inline virtual enum loc_api_adapter_err - setExtPowerConfig(int isBatteryCharging) - { - return mLocApi->setExtPowerConfig(isBatteryCharging); - } - inline virtual enum loc_api_adapter_err - setAGLONASSProtocol(unsigned long aGlonassProtocol) - { - return mLocApi->setAGLONASSProtocol(aGlonassProtocol); - } - inline virtual int initDataServiceClient() - { - return mLocApi->initDataServiceClient(); - } - inline virtual int openAndStartDataCall() - { - return mLocApi->openAndStartDataCall(); - } - inline virtual void stopDataCall() - { - mLocApi->stopDataCall(); - } - inline virtual void closeDataCall() - { - mLocApi->closeDataCall(); - } - inline enum loc_api_adapter_err - getZpp(GpsLocation &zppLoc, LocPosTechMask &tech_mask) - { - return mLocApi->getBestAvailableZppFix(zppLoc, tech_mask); - } - enum loc_api_adapter_err setTime(GpsUtcTime time, - int64_t timeReference, - int uncertainty); - enum loc_api_adapter_err setXtraVersionCheck(int check); - inline virtual void installAGpsCert(const DerEncodedCertificate* pData, - size_t length, - uint32_t slotBitMask) - { - mLocApi->installAGpsCert(pData, length, slotBitMask); - } - virtual void handleEngineDownEvent(); - virtual void handleEngineUpEvent(); - virtual void reportPosition(UlpLocation &location, - GpsLocationExtended &locationExtended, - void* locationExt, - enum loc_sess_status status, - LocPosTechMask loc_technology_mask); - virtual void reportSv(HaxxSvStatus &svStatus, - GpsLocationExtended &locationExtended, - void* svExt); - virtual void reportStatus(GpsStatusValue status); - virtual void reportNmea(const char* nmea, int length); - virtual bool reportXtraServer(const char* url1, const char* url2, - const char* url3, const int maxlength); - virtual bool requestXtraData(); - virtual bool requestTime(); - virtual bool requestATL(int connHandle, AGpsType agps_type); - virtual bool releaseATL(int connHandle); - virtual bool requestNiNotify(GpsNiNotification ¬ify, const void* data); - virtual bool requestSuplES(int connHandle); - virtual bool reportDataCallOpened(); - virtual bool reportDataCallClosed(); - virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData); - - inline const LocPosMode& getPositionMode() const - {return mFixCriteria;} - inline virtual bool isInSession() - { return mNavigating; } - void setInSession(bool inSession); - - // Permit/prohibit power voting - inline void setPowerVoteRight(bool powerVoteRight) { - mPowerVote = powerVoteRight ? (mPowerVote | POWER_VOTE_RIGHT) : - (mPowerVote & ~POWER_VOTE_RIGHT); - } - inline bool getPowerVoteRight() const { - return (mPowerVote & POWER_VOTE_RIGHT) != 0 ; - } - // Set the power voting up/down and do actual operation if permitted - inline void setPowerVote(bool powerOn) { - mPowerVote = powerOn ? (mPowerVote | POWER_VOTE_VALUE) : - (mPowerVote & ~POWER_VOTE_VALUE); - requestPowerVote(); - mContext->modemPowerVote(powerOn); - } - inline bool getPowerVote() const { - return (mPowerVote & POWER_VOTE_VALUE) != 0 ; - } - // Do power voting according to last settings if permitted - void requestPowerVote(); - - /*Values for lock - 1 = Do not lock any position sessions - 2 = Lock MI position sessions - 3 = Lock MT position sessions - 4 = Lock all position sessions - */ - inline int setGpsLock(LOC_GPS_LOCK_MASK lock) - { - return mLocApi->setGpsLock(lock); - } - - int setGpsLockMsg(LOC_GPS_LOCK_MASK lock); - - /* - Returns - Current value of GPS lock on success - -1 on failure - */ - inline int getGpsLock() - { - return mLocApi->getGpsLock(); - } - - /* - Update Registration Mask - */ - void updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event, - loc_registration_mask_status isEnabled); - - /* - Set Gnss Constellation Config - */ - bool gnssConstellationConfig(); -}; - -#endif //LOC_API_ENG_ADAPTER_H diff --git a/gps/loc_api/libloc_api_50001/gps.c b/gps/loc_api/libloc_api_50001/gps.c deleted file mode 100644 index 29f20f4..0000000 --- a/gps/loc_api/libloc_api_50001/gps.c +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (c) 2011,2015 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 - -#include -#include - -extern const GpsInterface* get_gps_interface(); - -const GpsInterface* gps__get_gps_interface(struct gps_device_t* dev) -{ - return get_gps_interface(); -} - -static int open_gps(const struct hw_module_t* module, char const* name, - struct hw_device_t** device) -{ - struct gps_device_t *dev = (struct gps_device_t *) malloc(sizeof(struct gps_device_t)); - - if(dev == NULL) - return -1; - - memset(dev, 0, sizeof(*dev)); - - dev->common.tag = HARDWARE_DEVICE_TAG; - dev->common.version = 0; - dev->common.module = (struct hw_module_t*)module; - dev->get_gps_interface = gps__get_gps_interface; - - *device = (struct hw_device_t*)dev; - return 0; -} - -static struct hw_module_methods_t gps_module_methods = { - .open = open_gps -}; - -struct hw_module_t HAL_MODULE_INFO_SYM = { - .tag = HARDWARE_MODULE_TAG, - .module_api_version = 1, - .hal_api_version = 0, - .id = GPS_HARDWARE_MODULE_ID, - .name = "loc_api GPS Module", - .author = "Qualcomm USA, Inc.", - .methods = &gps_module_methods, -}; diff --git a/gps/loc_api/libloc_api_50001/loc.cpp b/gps/loc_api/libloc_api_50001/loc.cpp deleted file mode 100644 index 505fc94..0000000 --- a/gps/loc_api/libloc_api_50001/loc.cpp +++ /dev/null @@ -1,1077 +0,0 @@ -/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_afw" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace loc_core; - -#define LOC_PM_CLIENT_NAME "GPS" - -//Globals defns -static gps_location_callback gps_loc_cb = NULL; -static gps_sv_status_callback gps_sv_cb = NULL; - -static void local_loc_cb(UlpLocation* location, void* locExt); -static void local_sv_cb(GpsSvStatus* sv_status, void* svExt); - -static const GpsGeofencingInterface* get_geofence_interface(void); - -// Function declarations for sLocEngInterface -static int loc_init(GpsCallbacks* callbacks); -static int loc_start(); -static int loc_stop(); -static void loc_cleanup(); -static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty); -static int loc_inject_location(double latitude, double longitude, float accuracy); -static void loc_delete_aiding_data(GpsAidingData f); -static int loc_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence recurrence, - uint32_t min_interval, uint32_t preferred_accuracy, - uint32_t preferred_time); -static const void* loc_get_extension(const char* name); -// Defines the GpsInterface in gps.h -static const GpsInterface sLocEngInterface = -{ - sizeof(GpsInterface), - loc_init, - loc_start, - loc_stop, - loc_cleanup, - loc_inject_time, - loc_inject_location, - loc_delete_aiding_data, - loc_set_position_mode, - loc_get_extension -}; - -// Function declarations for sLocEngAGpsInterface -static void loc_agps_init(AGpsCallbacks* callbacks); -static int loc_agps_open(const char* apn); -static int loc_agps_closed(); -static int loc_agps_open_failed(); -static int loc_agps_set_server(AGpsType type, const char *hostname, int port); -static int loc_agps_open_with_apniptype( const char* apn, ApnIpType apnIpType); - -static const AGpsInterface sLocEngAGpsInterface = -{ - sizeof(AGpsInterface), - loc_agps_init, - loc_agps_open, - loc_agps_closed, - loc_agps_open_failed, - loc_agps_set_server, - loc_agps_open_with_apniptype -}; - -static int loc_xtra_init(GpsXtraCallbacks* callbacks); -static int loc_xtra_inject_data(char* data, int length); - -static const GpsXtraInterface sLocEngXTRAInterface = -{ - sizeof(GpsXtraInterface), - loc_xtra_init, - loc_xtra_inject_data -}; - -static void loc_ni_init(GpsNiCallbacks *callbacks); -static void loc_ni_respond(int notif_id, GpsUserResponseType user_response); - -static const GpsNiInterface sLocEngNiInterface = -{ - sizeof(GpsNiInterface), - loc_ni_init, - loc_ni_respond, -}; - -static int loc_gps_measurement_init(GpsMeasurementCallbacks* callbacks); -static void loc_gps_measurement_close(); - -static const GpsMeasurementInterface sLocEngGpsMeasurementInterface = -{ - sizeof(GpsMeasurementInterface), - loc_gps_measurement_init, - loc_gps_measurement_close -}; - -static void loc_agps_ril_init( AGpsRilCallbacks* callbacks ); -static void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct); -static void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid); -static void loc_agps_ril_ni_message(uint8_t *msg, size_t len); -static void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info); -static void loc_agps_ril_update_network_availability(int avaiable, const char* apn); - -static const AGpsRilInterface sLocEngAGpsRilInterface = -{ - sizeof(AGpsRilInterface), - loc_agps_ril_init, - loc_agps_ril_set_ref_location, - loc_agps_ril_set_set_id, - loc_agps_ril_ni_message, - loc_agps_ril_update_network_state, - loc_agps_ril_update_network_availability -}; - -static int loc_agps_install_certificates(const DerEncodedCertificate* certificates, - size_t length); -static int loc_agps_revoke_certificates(const Sha1CertificateFingerprint* fingerprints, - size_t length); - -static const SuplCertificateInterface sLocEngAGpsCertInterface = -{ - sizeof(SuplCertificateInterface), - loc_agps_install_certificates, - loc_agps_revoke_certificates -}; - -static void loc_configuration_update(const char* config_data, int32_t length); - -static const GnssConfigurationInterface sLocEngConfigInterface = -{ - sizeof(GnssConfigurationInterface), - loc_configuration_update -}; - -static loc_eng_data_s_type loc_afw_data; -static int gss_fd = -1; -static int sGnssType = GNSS_UNKNOWN; -/*=========================================================================== -FUNCTION gps_get_hardware_interface - -DESCRIPTION - Returns the GPS hardware interaface based on LOC API - if GPS is enabled. - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -const GpsInterface* gps_get_hardware_interface () -{ - ENTRY_LOG_CALLFLOW(); - const GpsInterface* ret_val; - - char propBuf[PROPERTY_VALUE_MAX]; - - loc_eng_read_config(); - - // check to see if GPS should be disabled - property_get("gps.disable", propBuf, ""); - if (propBuf[0] == '1') - { - LOC_LOGD("gps_get_interface returning NULL because gps.disable=1\n"); - ret_val = NULL; - } else { - ret_val = &sLocEngInterface; - } - - loc_eng_read_config(); - - EXIT_LOG(%p, ret_val); - return ret_val; -} - -// for gps.c -extern "C" const GpsInterface* get_gps_interface() -{ - unsigned int target = TARGET_DEFAULT; - loc_eng_read_config(); - - target = loc_get_target(); - LOC_LOGD("Target name check returned %s", loc_get_target_name(target)); - - sGnssType = getTargetGnssType(target); - switch (sGnssType) - { - case GNSS_GSS: - case GNSS_AUTO: - //APQ8064 - gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); - gss_fd = open("/dev/gss", O_RDONLY); - if (gss_fd < 0) { - LOC_LOGE("GSS open failed: %s\n", strerror(errno)); - } - else { - LOC_LOGD("GSS open success! CAPABILITIES %0lx\n", - gps_conf.CAPABILITIES); - } - break; - case GNSS_NONE: - //MPQ8064 - LOC_LOGE("No GPS HW on this target. Not returning interface."); - return NULL; - case GNSS_QCA1530: - // qca1530 chip is present - gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); - LOC_LOGD("qca1530 present: CAPABILITIES %0lx\n", gps_conf.CAPABILITIES); - break; - } - return &sLocEngInterface; -} - -/*=========================================================================== -FUNCTION loc_init - -DESCRIPTION - Initialize the location engine, this include setting up global datas - and registers location engien with loc api service. - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/Ax - -===========================================================================*/ -static int loc_init(GpsCallbacks* callbacks) -{ - int retVal = -1; - ENTRY_LOG(); - LOC_API_ADAPTER_EVENT_MASK_T event; - - if (NULL == callbacks) { - LOC_LOGE("loc_init failed. cb = NULL\n"); - EXIT_LOG(%d, retVal); - return retVal; - } - - event = LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT | - LOC_API_ADAPTER_BIT_SATELLITE_REPORT | - LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST | - LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST | - LOC_API_ADAPTER_BIT_IOCTL_REPORT | - LOC_API_ADAPTER_BIT_STATUS_REPORT | - LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT | - LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST; - - LocCallbacks clientCallbacks = {local_loc_cb, /* location_cb */ - callbacks->status_cb, /* status_cb */ - local_sv_cb, /* sv_status_cb */ - callbacks->nmea_cb, /* nmea_cb */ - callbacks->set_capabilities_cb, /* set_capabilities_cb */ - callbacks->acquire_wakelock_cb, /* acquire_wakelock_cb */ - callbacks->release_wakelock_cb, /* release_wakelock_cb */ - callbacks->create_thread_cb, /* create_thread_cb */ - NULL, /* location_ext_parser */ - NULL, /* sv_ext_parser */ - callbacks->request_utc_time_cb, /* request_utc_time_cb */ - }; - - gps_loc_cb = callbacks->location_cb; - gps_sv_cb = callbacks->sv_status_cb; - - retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event, NULL); - loc_afw_data.adapter->mSupportsAgpsRequests = !loc_afw_data.adapter->hasAgpsExtendedCapabilities(); - loc_afw_data.adapter->mSupportsPositionInjection = !loc_afw_data.adapter->hasCPIExtendedCapabilities(); - loc_afw_data.adapter->mSupportsTimeInjection = !loc_afw_data.adapter->hasCPIExtendedCapabilities(); - loc_afw_data.adapter->setGpsLockMsg(0); - loc_afw_data.adapter->requestUlp(getCarrierCapabilities()); - loc_afw_data.adapter->setXtraUserAgent(); - - if(retVal) { - LOC_LOGE("loc_eng_init() fail!"); - goto err; - } - - loc_afw_data.adapter->setPowerVoteRight(loc_get_target() == TARGET_QCA1530); - loc_afw_data.adapter->setPowerVote(true); - - LOC_LOGD("loc_eng_init() success!"); - -err: - EXIT_LOG(%d, retVal); - return retVal; -} - -/*=========================================================================== -FUNCTION loc_cleanup - -DESCRIPTION - Cleans location engine. The location client handle will be released. - -DEPENDENCIES - None - -RETURN VALUE - None - -SIDE EFFECTS - N/A - -===========================================================================*/ -static void loc_cleanup() -{ - ENTRY_LOG(); - - loc_afw_data.adapter->setPowerVote(false); - loc_afw_data.adapter->setGpsLockMsg(gps_conf.GPS_LOCK); - - loc_eng_cleanup(loc_afw_data); - gps_loc_cb = NULL; - gps_sv_cb = NULL; - - EXIT_LOG(%s, VOID_RET); -} - -/*=========================================================================== -FUNCTION loc_start - -DESCRIPTION - Starts the tracking session - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_start() -{ - ENTRY_LOG(); - int ret_val = loc_eng_start(loc_afw_data); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_stop - -DESCRIPTION - Stops the tracking session - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_stop() -{ - ENTRY_LOG(); - int ret_val = -1; - ret_val = loc_eng_stop(loc_afw_data); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_set_position_mode - -DESCRIPTION - Sets the mode and fix frequency for the tracking session. - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_set_position_mode(GpsPositionMode mode, - GpsPositionRecurrence recurrence, - uint32_t min_interval, - uint32_t preferred_accuracy, - uint32_t preferred_time) -{ - ENTRY_LOG(); - int ret_val = -1; - LocPositionMode locMode; - switch (mode) { - case GPS_POSITION_MODE_MS_BASED: - locMode = LOC_POSITION_MODE_MS_BASED; - break; - case GPS_POSITION_MODE_MS_ASSISTED: - locMode = LOC_POSITION_MODE_MS_ASSISTED; - break; - default: - locMode = LOC_POSITION_MODE_STANDALONE; - break; - } - - LocPosMode params(locMode, recurrence, min_interval, - preferred_accuracy, preferred_time, NULL, NULL); - ret_val = loc_eng_set_position_mode(loc_afw_data, params); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_inject_time - -DESCRIPTION - This is used by Java native function to do time injection. - -DEPENDENCIES - None - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty) -{ - ENTRY_LOG(); - int ret_val = 0; - - ret_val = loc_eng_inject_time(loc_afw_data, time, - timeReference, uncertainty); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - - -/*=========================================================================== -FUNCTION loc_inject_location - -DESCRIPTION - This is used by Java native function to do location injection. - -DEPENDENCIES - None - -RETURN VALUE - 0 : Successful - error code : Failure - -SIDE EFFECTS - N/A -===========================================================================*/ -static int loc_inject_location(double latitude, double longitude, float accuracy) -{ - ENTRY_LOG(); - - int ret_val = 0; - ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - - -/*=========================================================================== -FUNCTION loc_delete_aiding_data - -DESCRIPTION - This is used by Java native function to delete the aiding data. The function - updates the global variable for the aiding data to be deleted. If the GPS - engine is off, the aiding data will be deleted. Otherwise, the actual action - will happen when gps engine is turned off. - -DEPENDENCIES - Assumes the aiding data type specified in GpsAidingData matches with - LOC API specification. - -RETURN VALUE - None - -SIDE EFFECTS - N/A - -===========================================================================*/ -static void loc_delete_aiding_data(GpsAidingData f) -{ - ENTRY_LOG(); - loc_eng_delete_aiding_data(loc_afw_data, f); - - EXIT_LOG(%s, VOID_RET); -} - -const GpsGeofencingInterface* get_geofence_interface(void) -{ - ENTRY_LOG(); - void *handle; - const char *error; - typedef const GpsGeofencingInterface* (*get_gps_geofence_interface_function) (void); - get_gps_geofence_interface_function get_gps_geofence_interface; - static const GpsGeofencingInterface* geofence_interface = NULL; - - dlerror(); /* Clear any existing error */ - - handle = dlopen ("libgeofence.so", RTLD_NOW); - - if (!handle) - { - if ((error = dlerror()) != NULL) { - LOC_LOGE ("%s, dlopen for libgeofence.so failed, error = %s\n", __func__, error); - } - goto exit; - } - dlerror(); /* Clear any existing error */ - get_gps_geofence_interface = (get_gps_geofence_interface_function)dlsym(handle, "gps_geofence_get_interface"); - if ((error = dlerror()) != NULL || NULL == get_gps_geofence_interface) { - LOC_LOGE ("%s, dlsym for get_gps_geofence_interface failed, error = %s\n", __func__, error); - goto exit; - } - - geofence_interface = get_gps_geofence_interface(); - -exit: - EXIT_LOG(%d, geofence_interface == NULL); - return geofence_interface; -} -/*=========================================================================== -FUNCTION loc_get_extension - -DESCRIPTION - Get the gps extension to support XTRA. - -DEPENDENCIES - N/A - -RETURN VALUE - The GPS extension interface. - -SIDE EFFECTS - N/A - -===========================================================================*/ -const void* loc_get_extension(const char* name) -{ - ENTRY_LOG(); - const void* ret_val = NULL; - - LOC_LOGD("%s:%d] For Interface = %s\n",__func__, __LINE__, name); - if (strcmp(name, GPS_XTRA_INTERFACE) == 0) - { - ret_val = &sLocEngXTRAInterface; - } - else if (strcmp(name, AGPS_INTERFACE) == 0) - { - ret_val = &sLocEngAGpsInterface; - } - else if (strcmp(name, GPS_NI_INTERFACE) == 0) - { - ret_val = &sLocEngNiInterface; - } - else if (strcmp(name, AGPS_RIL_INTERFACE) == 0) - { - char baseband[PROPERTY_VALUE_MAX]; - property_get("ro.baseband", baseband, "msm"); - if (strcmp(baseband, "csfb") == 0) - { - ret_val = &sLocEngAGpsRilInterface; - } - } - else if (strcmp(name, GPS_GEOFENCING_INTERFACE) == 0) - { - if ((gps_conf.CAPABILITIES | GPS_CAPABILITY_GEOFENCING) == gps_conf.CAPABILITIES ){ - ret_val = get_geofence_interface(); - } - } - else if (strcmp(name, SUPL_CERTIFICATE_INTERFACE) == 0) - { - ret_val = &sLocEngAGpsCertInterface; - } - else if (strcmp(name, GNSS_CONFIGURATION_INTERFACE) == 0) - { - ret_val = &sLocEngConfigInterface; - } - else if (strcmp(name, GPS_MEASUREMENT_INTERFACE) == 0) - { - ret_val = &sLocEngGpsMeasurementInterface; - } - else - { - LOC_LOGE ("get_extension: Invalid interface passed in\n"); - } - EXIT_LOG(%p, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_agps_init - -DESCRIPTION - Initialize the AGps interface. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -static void loc_agps_init(AGpsCallbacks* callbacks) -{ - ENTRY_LOG(); - loc_eng_agps_init(loc_afw_data, (AGpsExtCallbacks*)callbacks); - EXIT_LOG(%s, VOID_RET); -} - -/*=========================================================================== -FUNCTION loc_agps_open - -DESCRIPTION - This function is called when on-demand data connection opening is successful. -It should inform ARM 9 about the data open result. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_agps_open(const char* apn) -{ - ENTRY_LOG(); - AGpsType agpsType = AGPS_TYPE_SUPL; - AGpsBearerType bearerType = AGPS_APN_BEARER_IPV4; - int ret_val = loc_eng_agps_open(loc_afw_data, agpsType, apn, bearerType); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_agps_open_with_apniptype - -DESCRIPTION - This function is called when on-demand data connection opening is successful. -It should inform ARM 9 about the data open result. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_agps_open_with_apniptype(const char* apn, ApnIpType apnIpType) -{ - ENTRY_LOG(); - AGpsType agpsType = AGPS_TYPE_SUPL; - AGpsBearerType bearerType; - - switch (apnIpType) { - case APN_IP_IPV4: - bearerType = AGPS_APN_BEARER_IPV4; - break; - case APN_IP_IPV6: - bearerType = AGPS_APN_BEARER_IPV6; - break; - case APN_IP_IPV4V6: - bearerType = AGPS_APN_BEARER_IPV4V6; - break; - default: - bearerType = AGPS_APN_BEARER_INVALID; - break; - } - - int ret_val = loc_eng_agps_open(loc_afw_data, agpsType, apn, bearerType); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_agps_closed - -DESCRIPTION - This function is called when on-demand data connection closing is done. -It should inform ARM 9 about the data close result. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_agps_closed() -{ - ENTRY_LOG(); - AGpsType agpsType = AGPS_TYPE_SUPL; - int ret_val = loc_eng_agps_closed(loc_afw_data, agpsType); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_agps_open_failed - -DESCRIPTION - This function is called when on-demand data connection opening has failed. -It should inform ARM 9 about the data open result. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_agps_open_failed() -{ - ENTRY_LOG(); - AGpsType agpsType = AGPS_TYPE_SUPL; - int ret_val = loc_eng_agps_open_failed(loc_afw_data, agpsType); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_agps_set_server - -DESCRIPTION - If loc_eng_set_server is called before loc_eng_init, it doesn't work. This - proxy buffers server settings and calls loc_eng_set_server when the client is - open. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_agps_set_server(AGpsType type, const char* hostname, int port) -{ - ENTRY_LOG(); - LocServerType serverType; - switch (type) { - case AGPS_TYPE_SUPL: - serverType = LOC_AGPS_SUPL_SERVER; - break; - case AGPS_TYPE_C2K: - serverType = LOC_AGPS_CDMA_PDE_SERVER; - break; - default: - serverType = LOC_AGPS_SUPL_SERVER; - } - int ret_val = loc_eng_set_server_proxy(loc_afw_data, serverType, hostname, port); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTIONf571 - loc_xtra_init - -DESCRIPTION - Initialize XTRA module. - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_xtra_init(GpsXtraCallbacks* callbacks) -{ - ENTRY_LOG(); - GpsXtraExtCallbacks extCallbacks; - memset(&extCallbacks, 0, sizeof(extCallbacks)); - extCallbacks.download_request_cb = callbacks->download_request_cb; - int ret_val = loc_eng_xtra_init(loc_afw_data, &extCallbacks); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - - -/*=========================================================================== -FUNCTION loc_xtra_inject_data - -DESCRIPTION - Initialize XTRA module. - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_xtra_inject_data(char* data, int length) -{ - ENTRY_LOG(); - int ret_val = -1; - if( (data != NULL) && ((unsigned int)length <= XTRA_DATA_MAX_SIZE)) - ret_val = loc_eng_xtra_inject_data(loc_afw_data, data, length); - else - LOC_LOGE("%s, Could not inject XTRA data. Buffer address: %p, length: %d", - __func__, data, length); - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_gps_measurement_init - -DESCRIPTION - This function initializes the gps measurement interface - -DEPENDENCIES - NONE - -RETURN VALUE - None - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_gps_measurement_init(GpsMeasurementCallbacks* callbacks) -{ - ENTRY_LOG(); - int ret_val = loc_eng_gps_measurement_init(loc_afw_data, - callbacks); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_gps_measurement_close - -DESCRIPTION - This function closes the gps measurement interface - -DEPENDENCIES - NONE - -RETURN VALUE - None - -SIDE EFFECTS - N/A - -===========================================================================*/ -static void loc_gps_measurement_close() -{ - ENTRY_LOG(); - loc_eng_gps_measurement_close(loc_afw_data); - - EXIT_LOG(%s, VOID_RET); -} - -/*=========================================================================== -FUNCTION loc_ni_init - -DESCRIPTION - This function initializes the NI interface - -DEPENDENCIES - NONE - -RETURN VALUE - None - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_ni_init(GpsNiCallbacks *callbacks) -{ - ENTRY_LOG(); - loc_eng_ni_init(loc_afw_data,(GpsNiExtCallbacks*) callbacks); - EXIT_LOG(%s, VOID_RET); -} - -/*=========================================================================== -FUNCTION loc_ni_respond - -DESCRIPTION - This function sends an NI respond to the modem processor - -DEPENDENCIES - NONE - -RETURN VALUE - None - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_ni_respond(int notif_id, GpsUserResponseType user_response) -{ - ENTRY_LOG(); - loc_eng_ni_respond(loc_afw_data, notif_id, user_response); - EXIT_LOG(%s, VOID_RET); -} - -// Below stub functions are members of sLocEngAGpsRilInterface -static void loc_agps_ril_init( AGpsRilCallbacks* callbacks ) {} -static void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct) {} -static void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid) {} -static void loc_agps_ril_ni_message(uint8_t *msg, size_t len) {} -static void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info) {} - -/*=========================================================================== -FUNCTION loc_agps_ril_update_network_availability - -DESCRIPTION - Sets data call allow vs disallow flag to modem - This is the only member of sLocEngAGpsRilInterface implemented. - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -static void loc_agps_ril_update_network_availability(int available, const char* apn) -{ - ENTRY_LOG(); - loc_eng_agps_ril_update_network_availability(loc_afw_data, available, apn); - EXIT_LOG(%s, VOID_RET); -} - -static int loc_agps_install_certificates(const DerEncodedCertificate* certificates, - size_t length) -{ - ENTRY_LOG(); - int ret_val = loc_eng_agps_install_certificates(loc_afw_data, certificates, length); - EXIT_LOG(%d, ret_val); - return ret_val; -} -static int loc_agps_revoke_certificates(const Sha1CertificateFingerprint* fingerprints, - size_t length) -{ - ENTRY_LOG(); - LOC_LOGE("%s:%d]: agps_revoke_certificates not supported"); - int ret_val = AGPS_CERTIFICATE_ERROR_GENERIC; - EXIT_LOG(%d, ret_val); - return ret_val; -} - -static void loc_configuration_update(const char* config_data, int32_t length) -{ - ENTRY_LOG(); - loc_eng_configuration_update(loc_afw_data, config_data, length); - switch (sGnssType) - { - case GNSS_GSS: - case GNSS_AUTO: - case GNSS_QCA1530: - //APQ - gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); - break; - } - EXIT_LOG(%s, VOID_RET); -} - -static void local_loc_cb(UlpLocation* location, void* locExt) -{ - ENTRY_LOG(); - if (NULL != location) { - CALLBACK_LOG_CALLFLOW("location_cb - from", %d, location->position_source); - - if (NULL != gps_loc_cb) { - gps_loc_cb(&location->gpsLocation); - } - } - EXIT_LOG(%s, VOID_RET); -} - -static void local_sv_cb(GpsSvStatus* sv_status, void* svExt) -{ - ENTRY_LOG(); - if (NULL != gps_sv_cb) { - CALLBACK_LOG_CALLFLOW("sv_status_cb -", %d, sv_status->num_svs); - gps_sv_cb(sv_status); - } - EXIT_LOG(%s, VOID_RET); -} - diff --git a/gps/loc_api/libloc_api_50001/loc.h b/gps/loc_api/libloc_api_50001/loc.h deleted file mode 100644 index e56fdcf..0000000 --- a/gps/loc_api/libloc_api_50001/loc.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (c) 2011,2014 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_H__ -#define __LOC_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include -#include -#include -#include - -#define XTRA_DATA_MAX_SIZE 100000 /*bytes*/ - -typedef void (*loc_location_cb_ext) (UlpLocation* location, void* locExt); -typedef void (*loc_sv_status_cb_ext) (GpsSvStatus* sv_status, void* svExt); -typedef void* (*loc_ext_parser)(void* data); - -typedef struct { - loc_location_cb_ext location_cb; - gps_status_callback status_cb; - loc_sv_status_cb_ext sv_status_cb; - gps_nmea_callback nmea_cb; - gps_set_capabilities set_capabilities_cb; - gps_acquire_wakelock acquire_wakelock_cb; - gps_release_wakelock release_wakelock_cb; - gps_create_thread create_thread_cb; - loc_ext_parser location_ext_parser; - loc_ext_parser sv_ext_parser; - gps_request_utc_time request_utc_time_cb; -} LocCallbacks; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif //__LOC_H__ diff --git a/gps/loc_api/libloc_api_50001/loc_eng.cpp b/gps/loc_api/libloc_api_50001/loc_eng.cpp deleted file mode 100644 index 0aa1c8b..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng.cpp +++ /dev/null @@ -1,3000 +0,0 @@ -/* Copyright (c) 2009-2015, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_eng" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* struct sockaddr_in */ -#include -#include -#include -#include -#include -#include - -#include -#ifndef USE_GLIB -#include -#include -#endif /* USE_GLIB */ - -#ifdef USE_GLIB -#include -#include -#endif /* USE_GLIB */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include "log_util.h" -#include "platform_lib_includes.h" -#include "loc_core_log.h" -#include "loc_eng_log.h" - -#define SUCCESS TRUE -#define FAILURE FALSE - -#ifndef GPS_CONF_FILE -#define GPS_CONF_FILE "/etc/gps.conf" //??? platform independent -#endif - -#ifndef SAP_CONF_FILE -#define SAP_CONF_FILE "/etc/sap.conf" -#endif - -#define XTRA1_GPSONEXTRA "xtra1.gpsonextra.net" - -using namespace loc_core; - -boolean configAlreadyRead = false; -unsigned int agpsStatus = 0; -loc_gps_cfg_s_type gps_conf; -loc_sap_cfg_s_type sap_conf; - -/* Parameter spec table */ -static const loc_param_s_type gps_conf_table[] = -{ - {"GPS_LOCK", &gps_conf.GPS_LOCK, NULL, 'n'}, - {"SUPL_VER", &gps_conf.SUPL_VER, NULL, 'n'}, - {"LPP_PROFILE", &gps_conf.LPP_PROFILE, NULL, 'n'}, - {"A_GLONASS_POS_PROTOCOL_SELECT", &gps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'}, - {"AGPS_CERT_WRITABLE_MASK", &gps_conf.AGPS_CERT_WRITABLE_MASK, NULL, 'n'}, - {"SUPL_MODE", &gps_conf.SUPL_MODE, NULL, 'n'}, - {"INTERMEDIATE_POS", &gps_conf.INTERMEDIATE_POS, NULL, 'n'}, - {"ACCURACY_THRES", &gps_conf.ACCURACY_THRES, NULL, 'n'}, - {"NMEA_PROVIDER", &gps_conf.NMEA_PROVIDER, NULL, 'n'}, - {"CAPABILITIES", &gps_conf.CAPABILITIES, NULL, 'n'}, - {"XTRA_VERSION_CHECK", &gps_conf.XTRA_VERSION_CHECK, NULL, 'n'}, - {"XTRA_SERVER_1", &gps_conf.XTRA_SERVER_1, NULL, 's'}, - {"XTRA_SERVER_2", &gps_conf.XTRA_SERVER_2, NULL, 's'}, - {"XTRA_SERVER_3", &gps_conf.XTRA_SERVER_3, NULL, 's'}, - {"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL", &gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'}, -}; - -static const loc_param_s_type sap_conf_table[] = -{ - {"GYRO_BIAS_RANDOM_WALK", &sap_conf.GYRO_BIAS_RANDOM_WALK, &sap_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'}, - {"ACCEL_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'}, - {"ANGLE_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'}, - {"RATE_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'}, - {"VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'}, - {"SENSOR_ACCEL_BATCHES_PER_SEC", &sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC, NULL, 'n'}, - {"SENSOR_ACCEL_SAMPLES_PER_BATCH", &sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, NULL, 'n'}, - {"SENSOR_GYRO_BATCHES_PER_SEC", &sap_conf.SENSOR_GYRO_BATCHES_PER_SEC, NULL, 'n'}, - {"SENSOR_GYRO_SAMPLES_PER_BATCH", &sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH, NULL, 'n'}, - {"SENSOR_ACCEL_BATCHES_PER_SEC_HIGH", &sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, NULL, 'n'}, - {"SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH", &sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, NULL, 'n'}, - {"SENSOR_GYRO_BATCHES_PER_SEC_HIGH", &sap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, NULL, 'n'}, - {"SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH", &sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, NULL, 'n'}, - {"SENSOR_CONTROL_MODE", &sap_conf.SENSOR_CONTROL_MODE, NULL, 'n'}, - {"SENSOR_USAGE", &sap_conf.SENSOR_USAGE, NULL, 'n'}, - {"SENSOR_ALGORITHM_CONFIG_MASK", &sap_conf.SENSOR_ALGORITHM_CONFIG_MASK, NULL, 'n'}, - {"SENSOR_PROVIDER", &sap_conf.SENSOR_PROVIDER, NULL, 'n'} -}; - -static void loc_default_parameters(void) -{ - /*Defaults for gps.conf*/ - gps_conf.INTERMEDIATE_POS = 0; - gps_conf.ACCURACY_THRES = 0; - gps_conf.NMEA_PROVIDER = 0; - gps_conf.GPS_LOCK = 0; - gps_conf.SUPL_VER = 0x10000; - gps_conf.SUPL_MODE = 0x3; - gps_conf.CAPABILITIES = 0x7; - /* LTE Positioning Profile configuration is disable by default*/ - gps_conf.LPP_PROFILE = 0; - /*By default no positioning protocol is selected on A-GLONASS system*/ - gps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0; - /*XTRA version check is disabled by default*/ - gps_conf.XTRA_VERSION_CHECK=0; - /*Use emergency PDN by default*/ - gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = 1; - - /*Defaults for sap.conf*/ - sap_conf.GYRO_BIAS_RANDOM_WALK = 0; - sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC = 2; - sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH = 5; - sap_conf.SENSOR_GYRO_BATCHES_PER_SEC = 2; - sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH = 5; - sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH = 4; - sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH = 25; - sap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH = 4; - sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH = 25; - sap_conf.SENSOR_CONTROL_MODE = 0; /* AUTO */ - sap_conf.SENSOR_USAGE = 0; /* Enabled */ - sap_conf.SENSOR_ALGORITHM_CONFIG_MASK = 0; /* INS Disabled = FALSE*/ - /* Values MUST be set by OEMs in configuration for sensor-assisted - navigation to work. There are NO default values */ - sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY = 0; - sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY = 0; - sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY = 0; - sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY = 0; - sap_conf.GYRO_BIAS_RANDOM_WALK_VALID = 0; - sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; - sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; - sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; - sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; - /* default provider is SSC */ - sap_conf.SENSOR_PROVIDER = 1; - - /* None of the 10 slots for agps certificates are writable by default */ - gps_conf.AGPS_CERT_WRITABLE_MASK = 0; -} - -// 2nd half of init(), singled out for -// modem restart to use. -static int loc_eng_reinit(loc_eng_data_s_type &loc_eng_data); -static void loc_eng_agps_reinit(loc_eng_data_s_type &loc_eng_data); - -static int loc_eng_set_server(loc_eng_data_s_type &loc_eng_data, - LocServerType type, const char *hostname, int port); -// Internal functions -static void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data, - GpsStatusValue status); -static void loc_eng_report_status(loc_eng_data_s_type &loc_eng_data, - GpsStatusValue status); -static void loc_eng_process_conn_request(loc_eng_data_s_type &loc_eng_data, - int connHandle, AGpsType agps_type); -static void loc_eng_agps_close_status(loc_eng_data_s_type &loc_eng_data, int is_succ); -static void loc_eng_handle_engine_down(loc_eng_data_s_type &loc_eng_data) ; -static void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data) ; - -static int loc_eng_start_handler(loc_eng_data_s_type &loc_eng_data); -static int loc_eng_stop_handler(loc_eng_data_s_type &loc_eng_data); -static int loc_eng_get_zpp_handler(loc_eng_data_s_type &loc_eng_data); -static void deleteAidingData(loc_eng_data_s_type &logEng); -static AgpsStateMachine* -getAgpsStateMachine(loc_eng_data_s_type& logEng, AGpsExtType agpsType); -static int dataCallCb(void *cb_data); -static void update_aiding_data_for_deletion(loc_eng_data_s_type& loc_eng_data) { - if (loc_eng_data.engine_status != GPS_STATUS_ENGINE_ON && - loc_eng_data.aiding_data_for_deletion != 0) - { - loc_eng_data.adapter->deleteAidingData(loc_eng_data.aiding_data_for_deletion); - loc_eng_data.aiding_data_for_deletion = 0; - } -} - -static void* noProc(void* data) -{ - return NULL; -} - -/********************************************************************* - * definitions of the static messages used in the file - *********************************************************************/ -// case LOC_ENG_MSG_REQUEST_NI: -LocEngRequestNi::LocEngRequestNi(void* locEng, - GpsNiNotification ¬if, - const void* data) : - LocMsg(), mLocEng(locEng), mNotify(notif), mPayload(data) { - locallog(); -} -void LocEngRequestNi::proc() const { - loc_eng_ni_request_handler(*((loc_eng_data_s_type*)mLocEng), - &mNotify, mPayload); -} -void LocEngRequestNi::locallog() const -{ - LOC_LOGV("id: %d\n type: %s\n flags: %d\n time out: %d\n " - "default response: %s\n requestor id encoding: %s\n" - " text encoding: %s\n passThroughData: %p", - mNotify.notification_id, - loc_get_ni_type_name(mNotify.ni_type), - mNotify.notify_flags, - mNotify.timeout, - loc_get_ni_response_name(mNotify.default_response), - loc_get_ni_encoding_name(mNotify.requestor_id_encoding), - loc_get_ni_encoding_name(mNotify.text_encoding), - mPayload); -} -inline void LocEngRequestNi::log() const { - locallog(); -} - -// case LOC_ENG_MSG_INFORM_NI_RESPONSE: -// in loc_eng_ni.cpp - -// case LOC_ENG_MSG_START_FIX: -LocEngStartFix::LocEngStartFix(LocEngAdapter* adapter) : - LocMsg(), mAdapter(adapter) -{ - locallog(); -} -inline void LocEngStartFix::proc() const -{ - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mAdapter->getOwner(); - loc_eng_start_handler(*locEng); -} -inline void LocEngStartFix::locallog() const -{ - LOC_LOGV("LocEngStartFix"); -} -inline void LocEngStartFix::log() const -{ - locallog(); -} -void LocEngStartFix::send() const { - mAdapter->sendMsg(this); -} - -// case LOC_ENG_MSG_STOP_FIX: -LocEngStopFix::LocEngStopFix(LocEngAdapter* adapter) : - LocMsg(), mAdapter(adapter) -{ - locallog(); -} -inline void LocEngStopFix::proc() const -{ - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mAdapter->getOwner(); - loc_eng_stop_handler(*locEng); -} -inline void LocEngStopFix::locallog() const -{ - LOC_LOGV("LocEngStopFix"); -} -inline void LocEngStopFix::log() const -{ - locallog(); -} -void LocEngStopFix::send() const { - mAdapter->sendMsg(this); -} - -// case LOC_ENG_MSG_SET_POSITION_MODE: -LocEngPositionMode::LocEngPositionMode(LocEngAdapter* adapter, - LocPosMode &mode) : - LocMsg(), mAdapter(adapter), mPosMode(mode) -{ - mPosMode.logv(); -} -inline void LocEngPositionMode::proc() const { - mAdapter->setPositionMode(&mPosMode); -} -inline void LocEngPositionMode::log() const { - mPosMode.logv(); -} -void LocEngPositionMode::send() const { - mAdapter->sendMsg(this); -} - -LocEngGetZpp::LocEngGetZpp(LocEngAdapter* adapter) : - LocMsg(), mAdapter(adapter) -{ - locallog(); -} -inline void LocEngGetZpp::proc() const -{ - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mAdapter->getOwner(); - loc_eng_get_zpp_handler(*locEng); -} -inline void LocEngGetZpp::locallog() const -{ - LOC_LOGV("LocEngGetZpp"); -} -inline void LocEngGetZpp::log() const -{ - locallog(); -} -void LocEngGetZpp::send() const { - mAdapter->sendMsg(this); -} - -struct LocEngSetTime : public LocMsg { - LocEngAdapter* mAdapter; - const GpsUtcTime mTime; - const int64_t mTimeReference; - const int mUncertainty; - inline LocEngSetTime(LocEngAdapter* adapter, - GpsUtcTime t, int64_t tf, int unc) : - LocMsg(), mAdapter(adapter), - mTime(t), mTimeReference(tf), mUncertainty(unc) - { - locallog(); - } - inline virtual void proc() const { - mAdapter->setTime(mTime, mTimeReference, mUncertainty); - } - inline void locallog() const { - LOC_LOGV("time: %lld\n timeReference: %lld\n uncertainty: %d", - mTime, mTimeReference, mUncertainty); - } - inline virtual void log() const { - locallog(); - } -}; - - // case LOC_ENG_MSG_INJECT_LOCATION: -struct LocEngInjectLocation : public LocMsg { - LocEngAdapter* mAdapter; - const double mLatitude; - const double mLongitude; - const float mAccuracy; - inline LocEngInjectLocation(LocEngAdapter* adapter, - double lat, double lon, float accur) : - LocMsg(), mAdapter(adapter), - mLatitude(lat), mLongitude(lon), mAccuracy(accur) - { - locallog(); - } - inline virtual void proc() const { - mAdapter->injectPosition(mLatitude, mLongitude, mAccuracy); - } - inline void locallog() const { - LOC_LOGV("latitude: %f\n longitude: %f\n accuracy: %f", - mLatitude, mLongitude, mAccuracy); - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_SET_SERVER_IPV4: -struct LocEngSetServerIpv4 : public LocMsg { - LocEngAdapter* mAdapter; - const unsigned int mNlAddr; - const int mPort; - const LocServerType mServerType; - inline LocEngSetServerIpv4(LocEngAdapter* adapter, - unsigned int ip, - int port, - LocServerType type) : - LocMsg(), mAdapter(adapter), - mNlAddr(ip), mPort(port), mServerType(type) - { - locallog(); - } - inline virtual void proc() const { - mAdapter->setServer(mNlAddr, mPort, mServerType); - } - inline void locallog() const { - LOC_LOGV("LocEngSetServerIpv4 - addr: %x, port: %d, type: %s", - mNlAddr, mPort, loc_get_server_type_name(mServerType)); - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_SET_SERVER_URL: -struct LocEngSetServerUrl : public LocMsg { - LocEngAdapter* mAdapter; - const int mLen; - char* mUrl; - inline LocEngSetServerUrl(LocEngAdapter* adapter, - char* urlString, - int url_len) : - LocMsg(), mAdapter(adapter), - mLen(url_len), mUrl(new char[mLen+1]) - { - memcpy((void*)mUrl, (void*)urlString, url_len); - mUrl[mLen] = 0; - locallog(); - } - inline ~LocEngSetServerUrl() - { - delete[] mUrl; - } - inline virtual void proc() const { - mAdapter->setServer(mUrl, mLen); - } - inline void locallog() const { - LOC_LOGV("LocEngSetServerUrl - url: %s", mUrl); - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_A_GLONASS_PROTOCOL: -struct LocEngAGlonassProtocol : public LocMsg { - LocEngAdapter* mAdapter; - const unsigned long mAGlonassProtocl; - inline LocEngAGlonassProtocol(LocEngAdapter* adapter, - unsigned long protocol) : - LocMsg(), mAdapter(adapter), mAGlonassProtocl(protocol) - { - locallog(); - } - inline virtual void proc() const { - mAdapter->setAGLONASSProtocol(mAGlonassProtocl); - } - inline void locallog() const { - LOC_LOGV("A-GLONASS protocol: 0x%lx", mAGlonassProtocl); - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_SUPL_VERSION: -struct LocEngSuplVer : public LocMsg { - LocEngAdapter* mAdapter; - const int mSuplVer; - inline LocEngSuplVer(LocEngAdapter* adapter, - int suplVer) : - LocMsg(), mAdapter(adapter), mSuplVer(suplVer) - { - locallog(); - } - inline virtual void proc() const { - mAdapter->setSUPLVersion(mSuplVer); - } - inline void locallog() const { - LOC_LOGV("SUPL Version: %d", mSuplVer); - } - inline virtual void log() const { - locallog(); - } -}; - -struct LocEngSuplMode : public LocMsg { - UlpProxyBase* mUlp; - - inline LocEngSuplMode(UlpProxyBase* ulp) : - LocMsg(), mUlp(ulp) - { - locallog(); - } - inline virtual void proc() const { - mUlp->setCapabilities(getCarrierCapabilities()); - } - inline void locallog() const { - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_LPP_CONFIG: -struct LocEngLppConfig : public LocMsg { - LocEngAdapter* mAdapter; - const int mLppConfig; - inline LocEngLppConfig(LocEngAdapter* adapter, - int lppConfig) : - LocMsg(), mAdapter(adapter), mLppConfig(lppConfig) - { - locallog(); - } - inline virtual void proc() const { - mAdapter->setLPPConfig(mLppConfig); - } - inline void locallog() const { - LOC_LOGV("LocEngLppConfig - profile: %d", mLppConfig); - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_SET_SENSOR_CONTROL_CONFIG: -struct LocEngSensorControlConfig : public LocMsg { - LocEngAdapter* mAdapter; - const int mSensorsDisabled; - const int mSensorProvider; - inline LocEngSensorControlConfig(LocEngAdapter* adapter, - int sensorsDisabled, int sensorProvider) : - LocMsg(), mAdapter(adapter), mSensorsDisabled(sensorsDisabled), - mSensorProvider(sensorProvider) - { - locallog(); - } - inline virtual void proc() const { - mAdapter->setSensorControlConfig(mSensorsDisabled, mSensorProvider); - } - inline void locallog() const { - LOC_LOGV("LocEngSensorControlConfig - Sensors Disabled: %d, Sensor Provider: %d", - mSensorsDisabled, mSensorProvider); - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_SET_SENSOR_PROPERTIES: -struct LocEngSensorProperties : public LocMsg { - LocEngAdapter* mAdapter; - const bool mGyroBiasVarianceRandomWalkValid; - const float mGyroBiasVarianceRandomWalk; - const bool mAccelRandomWalkValid; - const float mAccelRandomWalk; - const bool mAngleRandomWalkValid; - const float mAngleRandomWalk; - const bool mRateRandomWalkValid; - const float mRateRandomWalk; - const bool mVelocityRandomWalkValid; - const float mVelocityRandomWalk; - inline LocEngSensorProperties(LocEngAdapter* adapter, - bool gyroBiasRandomWalk_valid, - float gyroBiasRandomWalk, - bool accelRandomWalk_valid, - float accelRandomWalk, - bool angleRandomWalk_valid, - float angleRandomWalk, - bool rateRandomWalk_valid, - float rateRandomWalk, - bool velocityRandomWalk_valid, - float velocityRandomWalk) : - LocMsg(), mAdapter(adapter), - mGyroBiasVarianceRandomWalkValid(gyroBiasRandomWalk_valid), - mGyroBiasVarianceRandomWalk(gyroBiasRandomWalk), - mAccelRandomWalkValid(accelRandomWalk_valid), - mAccelRandomWalk(accelRandomWalk), - mAngleRandomWalkValid(angleRandomWalk_valid), - mAngleRandomWalk(angleRandomWalk), - mRateRandomWalkValid(rateRandomWalk_valid), - mRateRandomWalk(rateRandomWalk), - mVelocityRandomWalkValid(velocityRandomWalk_valid), - mVelocityRandomWalk(velocityRandomWalk) - { - locallog(); - } - inline virtual void proc() const { - mAdapter->setSensorProperties(mGyroBiasVarianceRandomWalkValid, - mGyroBiasVarianceRandomWalk, - mAccelRandomWalkValid, - mAccelRandomWalk, - mAngleRandomWalkValid, - mAngleRandomWalk, - mRateRandomWalkValid, - mRateRandomWalk, - mVelocityRandomWalkValid, - mVelocityRandomWalk); - } - inline void locallog() const { - LOC_LOGV("Sensor properties validity, Gyro Random walk: %d " - "Accel Random Walk: %d " - "Angle Random Walk: %d Rate Random Walk: %d " - "Velocity Random Walk: %d\n" - "Sensor properties, Gyro Random walk: %f " - "Accel Random Walk: %f " - "Angle Random Walk: %f Rate Random Walk: %f " - "Velocity Random Walk: %f", - mGyroBiasVarianceRandomWalkValid, - mAccelRandomWalkValid, - mAngleRandomWalkValid, - mRateRandomWalkValid, - mVelocityRandomWalkValid, - mGyroBiasVarianceRandomWalk, - mAccelRandomWalk, - mAngleRandomWalk, - mRateRandomWalk, - mVelocityRandomWalk - ); - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_SET_SENSOR_PERF_CONTROL_CONFIG: -struct LocEngSensorPerfControlConfig : public LocMsg { - LocEngAdapter* mAdapter; - const int mControlMode; - const int mAccelSamplesPerBatch; - const int mAccelBatchesPerSec; - const int mGyroSamplesPerBatch; - const int mGyroBatchesPerSec; - const int mAccelSamplesPerBatchHigh; - const int mAccelBatchesPerSecHigh; - const int mGyroSamplesPerBatchHigh; - const int mGyroBatchesPerSecHigh; - const int mAlgorithmConfig; - inline LocEngSensorPerfControlConfig(LocEngAdapter* adapter, - int controlMode, - int accelSamplesPerBatch, - int accelBatchesPerSec, - int gyroSamplesPerBatch, - int gyroBatchesPerSec, - int accelSamplesPerBatchHigh, - int accelBatchesPerSecHigh, - int gyroSamplesPerBatchHigh, - int gyroBatchesPerSecHigh, - int algorithmConfig) : - LocMsg(), mAdapter(adapter), - mControlMode(controlMode), - mAccelSamplesPerBatch(accelSamplesPerBatch), - mAccelBatchesPerSec(accelBatchesPerSec), - mGyroSamplesPerBatch(gyroSamplesPerBatch), - mGyroBatchesPerSec(gyroBatchesPerSec), - mAccelSamplesPerBatchHigh(accelSamplesPerBatchHigh), - mAccelBatchesPerSecHigh(accelBatchesPerSecHigh), - mGyroSamplesPerBatchHigh(gyroSamplesPerBatchHigh), - mGyroBatchesPerSecHigh(gyroBatchesPerSecHigh), - mAlgorithmConfig(algorithmConfig) - { - locallog(); - } - inline virtual void proc() const { - mAdapter->setSensorPerfControlConfig(mControlMode, - mAccelSamplesPerBatch, - mAccelBatchesPerSec, - mGyroSamplesPerBatch, - mGyroBatchesPerSec, - mAccelSamplesPerBatchHigh, - mAccelBatchesPerSecHigh, - mGyroSamplesPerBatchHigh, - mGyroBatchesPerSecHigh, - mAlgorithmConfig); - } - inline void locallog() const { - LOC_LOGV("Sensor Perf Control Config (performanceControlMode)(%u) " - "accel(#smp,#batches) (%u,%u) " - "gyro(#smp,#batches) (%u,%u), " - "accel_high(#smp,#batches) (%u,%u) " - "gyro_high(#smp,#batches) (%u,%u), " - "algorithmConfig(%u)\n", - mControlMode, - mAccelSamplesPerBatch, mAccelBatchesPerSec, - mGyroSamplesPerBatch, mGyroBatchesPerSec, - mAccelSamplesPerBatchHigh, mAccelBatchesPerSecHigh, - mGyroSamplesPerBatchHigh, mGyroBatchesPerSecHigh, - mAlgorithmConfig); - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_EXT_POWER_CONFIG: -struct LocEngExtPowerConfig : public LocMsg { - LocEngAdapter* mAdapter; - const int mIsBatteryCharging; - inline LocEngExtPowerConfig(LocEngAdapter* adapter, - int isBatteryCharging) : - LocMsg(), mAdapter(adapter), - mIsBatteryCharging(isBatteryCharging) - { - locallog(); - } - inline virtual void proc() const { - mAdapter->setExtPowerConfig(mIsBatteryCharging); - } - inline void locallog() const { - LOC_LOGV("LocEngExtPowerConfig - isBatteryCharging: %d", - mIsBatteryCharging); - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_REPORT_POSITION: -LocEngReportPosition::LocEngReportPosition(LocAdapterBase* adapter, - UlpLocation &loc, - GpsLocationExtended &locExtended, - void* locExt, - enum loc_sess_status st, - LocPosTechMask technology) : - LocMsg(), mAdapter(adapter), mLocation(loc), - mLocationExtended(locExtended), - mLocationExt(((loc_eng_data_s_type*) - ((LocEngAdapter*) - (mAdapter))->getOwner())->location_ext_parser(locExt)), - mStatus(st), mTechMask(technology) -{ - locallog(); -} -void LocEngReportPosition::proc() const { - LocEngAdapter* adapter = (LocEngAdapter*)mAdapter; - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)adapter->getOwner(); - - if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION) { - bool reported = false; - if (locEng->location_cb != NULL) { - if (LOC_SESS_FAILURE == mStatus) { - // in case we want to handle the failure case - locEng->location_cb(NULL, NULL); - reported = true; - } - // what's in the else 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 - else if ((LOC_SESS_SUCCESS == mStatus && - ((LOC_POS_TECH_MASK_SATELLITE | - LOC_POS_TECH_MASK_SENSORS | - LOC_POS_TECH_MASK_HYBRID) & - mTechMask)) || - (LOC_SESS_INTERMEDIATE == locEng->intermediateFix && - !((mLocation.gpsLocation.flags & - GPS_LOCATION_HAS_ACCURACY) && - (gps_conf.ACCURACY_THRES != 0) && - (mLocation.gpsLocation.accuracy > - gps_conf.ACCURACY_THRES)))) { - locEng->location_cb((UlpLocation*)&(mLocation), - (void*)mLocationExt); - reported = true; - } - } - - // if we have reported this fix - if (reported && - // and if this is a singleshot - GPS_POSITION_RECURRENCE_SINGLE == - locEng->adapter->getPositionMode().recurrence) { - if (LOC_SESS_INTERMEDIATE == mStatus) { - // modem could be still working for a final fix, - // although we no longer need it. So stopFix(). - locEng->adapter->stopFix(); - } - // turn off the session flag. - locEng->adapter->setInSession(false); - } - - LOC_LOGV("LocEngReportPosition::proc() - generateNmea: %d, position source: %d, " - "engine_status: %d, isInSession: %d", - locEng->generateNmea, mLocation.position_source, - locEng->engine_status, locEng->adapter->isInSession()); - - if (locEng->generateNmea && - locEng->adapter->isInSession()) - { - unsigned char generate_nmea = reported && - (mStatus != LOC_SESS_FAILURE); - loc_eng_nmea_generate_pos(locEng, mLocation, mLocationExtended, - generate_nmea); - } - - // Free the allocated memory for rawData - UlpLocation* gp = (UlpLocation*)&(mLocation); - if (gp != NULL && gp->rawData != NULL) - { - delete (char*)gp->rawData; - gp->rawData = NULL; - gp->rawDataSize = 0; - } - } -} -void LocEngReportPosition::locallog() const { - LOC_LOGV("LocEngReportPosition"); -} -void LocEngReportPosition::log() const { - locallog(); -} -void LocEngReportPosition::send() const { - mAdapter->sendMsg(this); -} - - -// case LOC_ENG_MSG_REPORT_SV: -LocEngReportSv::LocEngReportSv(LocAdapterBase* adapter, - HaxxSvStatus &sv, - GpsLocationExtended &locExtended, - void* svExt) : - LocMsg(), mAdapter(adapter), mSvStatus(sv), - mLocationExtended(locExtended), - mSvExt(((loc_eng_data_s_type*) - ((LocEngAdapter*) - (mAdapter))->getOwner())->sv_ext_parser(svExt)) -{ - locallog(); -} -void LocEngReportSv::proc() const { - LocEngAdapter* adapter = (LocEngAdapter*)mAdapter; - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)adapter->getOwner(); - - if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION) - { - if (locEng->sv_status_cb != NULL) { - locEng->sv_status_cb((GpsSvStatus*)&(mSvStatus), - (void*)mSvExt); - } - - if (locEng->generateNmea) - { - loc_eng_nmea_generate_sv(locEng, mSvStatus, mLocationExtended); - } - } -} -void LocEngReportSv::locallog() const { - LOC_LOGV("%s:%d] LocEngReportSv",__func__, __LINE__); -} -inline void LocEngReportSv::log() const { - locallog(); -} -void LocEngReportSv::send() const { - mAdapter->sendMsg(this); -} - -// case LOC_ENG_MSG_REPORT_STATUS: -LocEngReportStatus::LocEngReportStatus(LocAdapterBase* adapter, - GpsStatusValue engineStatus) : - LocMsg(), mAdapter(adapter), mStatus(engineStatus) -{ - locallog(); -} -inline void LocEngReportStatus::proc() const -{ - LocEngAdapter* adapter = (LocEngAdapter*)mAdapter; - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)adapter->getOwner(); - - loc_eng_report_status(*locEng, mStatus); - update_aiding_data_for_deletion(*locEng); -} -inline void LocEngReportStatus::locallog() const { - LOC_LOGV("LocEngReportStatus"); -} -inline void LocEngReportStatus::log() const { - locallog(); -} - -// case LOC_ENG_MSG_REPORT_NMEA: -LocEngReportNmea::LocEngReportNmea(void* locEng, - const char* data, int len) : - LocMsg(), mLocEng(locEng), mNmea(new char[len+1]), mLen(len) -{ - strlcpy(mNmea, data, len+1); - locallog(); -} -void LocEngReportNmea::proc() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*) mLocEng; - - struct timeval tv; - gettimeofday(&tv, (struct timezone *) NULL); - int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000; - CALLBACK_LOG_CALLFLOW("nmea_cb", %d, mLen); - - if (locEng->nmea_cb != NULL) - locEng->nmea_cb(now, mNmea, mLen); -} -inline void LocEngReportNmea::locallog() const { - LOC_LOGV("LocEngReportNmea"); -} -inline void LocEngReportNmea::log() const { - locallog(); -} - -// case LOC_ENG_MSG_REPORT_XTRA_SERVER: -LocEngReportXtraServer::LocEngReportXtraServer(void* locEng, - const char *url1, - const char *url2, - const char *url3, - const int maxlength) : - LocMsg(), mLocEng(locEng), mMaxLen(maxlength), - mServers(new char[3*(mMaxLen+1)]) -{ - char * cptr = mServers; - memset(mServers, 0, 3*(mMaxLen+1)); - - // Override modem URLs with uncommented gps.conf urls - if( gps_conf.XTRA_SERVER_1[0] != '\0' ) { - url1 = &gps_conf.XTRA_SERVER_1[0]; - } - if( gps_conf.XTRA_SERVER_2[0] != '\0' ) { - url2 = &gps_conf.XTRA_SERVER_2[0]; - } - if( gps_conf.XTRA_SERVER_3[0] != '\0' ) { - url3 = &gps_conf.XTRA_SERVER_3[0]; - } - // copy non xtra1.gpsonextra.net URLs into the forwarding buffer. - if( NULL == strcasestr(url1, XTRA1_GPSONEXTRA) ) { - strlcpy(cptr, url1, mMaxLen + 1); - cptr += mMaxLen + 1; - } - if( NULL == strcasestr(url2, XTRA1_GPSONEXTRA) ) { - strlcpy(cptr, url2, mMaxLen + 1); - cptr += mMaxLen + 1; - } - if( NULL == strcasestr(url3, XTRA1_GPSONEXTRA) ) { - strlcpy(cptr, url3, mMaxLen + 1); - } - locallog(); -} - -void LocEngReportXtraServer::proc() const { - loc_eng_xtra_data_s_type* locEngXtra = - &(((loc_eng_data_s_type*)mLocEng)->xtra_module_data); - - if (locEngXtra->report_xtra_server_cb != NULL) { - CALLBACK_LOG_CALLFLOW("report_xtra_server_cb", %s, mServers); - locEngXtra->report_xtra_server_cb(mServers, - &(mServers[mMaxLen+1]), - &(mServers[(mMaxLen+1)<<1])); - } else { - LOC_LOGE("Callback function for request xtra is NULL"); - } -} -inline void LocEngReportXtraServer::locallog() const { - LOC_LOGV("LocEngReportXtraServers: server1: %s\n server2: %s\n" - " server3: %s\n", - mServers, &mServers[mMaxLen+1], &mServers[(mMaxLen+1)<<1]); -} -inline void LocEngReportXtraServer::log() const { - locallog(); -} - -// case LOC_ENG_MSG_REQUEST_BIT: -// case LOC_ENG_MSG_RELEASE_BIT: -LocEngReqRelBIT::LocEngReqRelBIT(void* locEng, AGpsExtType type, - int ipv4, char* ipv6, bool isReq) : - LocMsg(), mLocEng(locEng), mType(type), mIPv4Addr(ipv4), - mIPv6Addr(ipv6 ? new char[16] : NULL), mIsReq(isReq) { - if (NULL != ipv6) - memcpy(mIPv6Addr, ipv6, 16); - locallog(); -} -inline LocEngReqRelBIT::~LocEngReqRelBIT() { - if (mIPv6Addr) { - delete[] mIPv6Addr; - } -} -void LocEngReqRelBIT::proc() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - BITSubscriber s(getAgpsStateMachine(*locEng, mType), - mIPv4Addr, mIPv6Addr); - AgpsStateMachine* sm = (AgpsStateMachine*)s.mStateMachine; - - if (mIsReq) { - sm->subscribeRsrc((Subscriber*)&s); - } else { - sm->unsubscribeRsrc((Subscriber*)&s); - } -} -inline void LocEngReqRelBIT::locallog() const { - LOC_LOGV("LocEngRequestBIT - ipv4: %d.%d.%d.%d, ipv6: %s", - (unsigned char)mIPv4Addr, - (unsigned char)(mIPv4Addr>>8), - (unsigned char)(mIPv4Addr>>16), - (unsigned char)(mIPv4Addr>>24), - NULL != mIPv6Addr ? mIPv6Addr : ""); -} -inline void LocEngReqRelBIT::log() const { - locallog(); -} -void LocEngReqRelBIT::send() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - locEng->adapter->sendMsg(this); -} - -// case LOC_ENG_MSG_RELEASE_BIT: -struct LocEngReleaseBIT : public LocMsg { - const BITSubscriber mSubscriber; - inline LocEngReleaseBIT(const AgpsStateMachine* stateMachine, - unsigned int ipv4, char* ipv6) : - LocMsg(), - mSubscriber(stateMachine, ipv4, ipv6) - { - locallog(); - } - inline virtual void proc() const - { - AgpsStateMachine* sm = (AgpsStateMachine*)mSubscriber.mStateMachine; - sm->unsubscribeRsrc((Subscriber*)&mSubscriber); - } - inline void locallog() const { - LOC_LOGV("LocEngReleaseBIT - ipv4: %d.%d.%d.%d, ipv6: %s", - (unsigned char)(mSubscriber.ID>>24), - (unsigned char)(mSubscriber.ID>>16), - (unsigned char)(mSubscriber.ID>>8), - (unsigned char)mSubscriber.ID, - NULL != mSubscriber.mIPv6Addr ? mSubscriber.mIPv6Addr : ""); - } - virtual void log() const { - locallog(); - } -}; - -// LocEngSuplEsOpened -LocEngSuplEsOpened::LocEngSuplEsOpened(void* locEng) : - LocMsg(), mLocEng(locEng) { - locallog(); -} -void LocEngSuplEsOpened::proc() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - if (locEng->ds_nif) { - AgpsStateMachine* sm = locEng->ds_nif; - sm->onRsrcEvent(RSRC_GRANTED); - } -} -void LocEngSuplEsOpened::locallog() const { - LOC_LOGV("LocEngSuplEsOpened"); -} -void LocEngSuplEsOpened::log() const { - locallog(); -} - -// LocEngSuplEsClosed -LocEngSuplEsClosed::LocEngSuplEsClosed(void* locEng) : - LocMsg(), mLocEng(locEng) { - locallog(); -} -void LocEngSuplEsClosed::proc() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - if (locEng->ds_nif) { - AgpsStateMachine* sm = locEng->ds_nif; - sm->onRsrcEvent(RSRC_RELEASED); - } -} -void LocEngSuplEsClosed::locallog() const { - LOC_LOGV("LocEngSuplEsClosed"); -} -void LocEngSuplEsClosed::log() const { - locallog(); -} - - -// case LOC_ENG_MSG_REQUEST_SUPL_ES: -LocEngRequestSuplEs::LocEngRequestSuplEs(void* locEng, int id) : - LocMsg(), mLocEng(locEng), mID(id) { - locallog(); -} -void LocEngRequestSuplEs::proc() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - if (locEng->ds_nif) { - AgpsStateMachine* sm = locEng->ds_nif; - DSSubscriber s(sm, mID); - sm->subscribeRsrc((Subscriber*)&s); - } - else if (locEng->agnss_nif) { - AgpsStateMachine *sm = locEng->agnss_nif; - ATLSubscriber s(mID, - sm, - locEng->adapter, - false); - sm->subscribeRsrc((Subscriber*)&s); - LOC_LOGD("%s:%d]: Using regular ATL for SUPL ES", __func__, __LINE__); - } - else { - locEng->adapter->atlOpenStatus(mID, 0, NULL, -1, -1); - } -} -inline void LocEngRequestSuplEs::locallog() const { - LOC_LOGV("LocEngRequestSuplEs"); -} -inline void LocEngRequestSuplEs::log() const { - locallog(); -} - -// case LOC_ENG_MSG_REQUEST_ATL: -LocEngRequestATL::LocEngRequestATL(void* locEng, int id, - AGpsExtType agps_type) : - LocMsg(), mLocEng(locEng), mID(id), mType(agps_type) { - locallog(); -} -void LocEngRequestATL::proc() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - AgpsStateMachine* sm = (AgpsStateMachine*) - getAgpsStateMachine(*locEng, mType); - if (sm) { - ATLSubscriber s(mID, - sm, - locEng->adapter, - AGPS_TYPE_INVALID == mType); - sm->subscribeRsrc((Subscriber*)&s); - } else { - locEng->adapter->atlOpenStatus(mID, 0, NULL, -1, mType); - } -} -inline void LocEngRequestATL::locallog() const { - LOC_LOGV("LocEngRequestATL"); -} -inline void LocEngRequestATL::log() const { - locallog(); -} - -// case LOC_ENG_MSG_RELEASE_ATL: -LocEngReleaseATL::LocEngReleaseATL(void* locEng, int id) : - LocMsg(), mLocEng(locEng), mID(id) { - locallog(); -} -void LocEngReleaseATL::proc() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - - if (locEng->agnss_nif) { - ATLSubscriber s1(mID, locEng->agnss_nif, locEng->adapter, false); - if (locEng->agnss_nif->unsubscribeRsrc((Subscriber*)&s1)) { - LOC_LOGD("%s:%d]: Unsubscribed from agnss_nif", - __func__, __LINE__); - return; - } - } - - if (locEng->internet_nif) { - ATLSubscriber s2(mID, locEng->internet_nif, locEng->adapter, false); - if (locEng->internet_nif->unsubscribeRsrc((Subscriber*)&s2)) { - LOC_LOGD("%s:%d]: Unsubscribed from internet_nif", - __func__, __LINE__); - return; - } - } - - if (locEng->ds_nif) { - DSSubscriber s3(locEng->ds_nif, mID); - if (locEng->ds_nif->unsubscribeRsrc((Subscriber*)&s3)) { - LOC_LOGD("%s:%d]: Unsubscribed from ds_nif", - __func__, __LINE__); - return; - } - } - - LOC_LOGW("%s:%d]: Could not release ATL. " - "No subscribers found\n", - __func__, __LINE__); - locEng->adapter->atlCloseStatus(mID, 0); -} -inline void LocEngReleaseATL::locallog() const { - LOC_LOGV("LocEngReleaseATL"); -} -inline void LocEngReleaseATL::log() const { - locallog(); -} - -// case LOC_ENG_MSG_REQUEST_WIFI: -// case LOC_ENG_MSG_RELEASE_WIFI: -LocEngReqRelWifi::LocEngReqRelWifi(void* locEng, AGpsExtType type, - loc_if_req_sender_id_e_type sender_id, - char* s, char* p, bool isReq) : - LocMsg(), mLocEng(locEng), mType(type), mSenderId(sender_id), - mSSID(NULL == s ? NULL : new char[SSID_BUF_SIZE]), - mPassword(NULL == p ? NULL : new char[SSID_BUF_SIZE]), - mIsReq(isReq) { - if (NULL != s) - strlcpy(mSSID, s, SSID_BUF_SIZE); - if (NULL != p) - strlcpy(mPassword, p, SSID_BUF_SIZE); - locallog(); -} -LocEngReqRelWifi::~LocEngReqRelWifi() { - if (NULL != mSSID) { - delete[] mSSID; - } - if (NULL != mPassword) { - delete[] mPassword; - } -} -void LocEngReqRelWifi::proc() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - if (locEng->wifi_nif) { - WIFISubscriber s(locEng->wifi_nif, mSSID, mPassword, mSenderId); - if (mIsReq) { - locEng->wifi_nif->subscribeRsrc((Subscriber*)&s); - } else { - locEng->wifi_nif->unsubscribeRsrc((Subscriber*)&s); - } - } else { - locEng->adapter->atlOpenStatus(mSenderId, 0, NULL, -1, mType); - } -} -inline void LocEngReqRelWifi::locallog() const { - LOC_LOGV("%s - senderId: %d, ssid: %s, password: %s", - mIsReq ? "LocEngRequestWifi" : "LocEngReleaseWifi", - mSenderId, - NULL != mSSID ? mSSID : "", - NULL != mPassword ? mPassword : ""); -} -inline void LocEngReqRelWifi::log() const { - locallog(); -} -void LocEngReqRelWifi::send() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - locEng->adapter->sendMsg(this); -} - -// case LOC_ENG_MSG_REQUEST_XTRA_DATA: -LocEngRequestXtra::LocEngRequestXtra(void* locEng) : - mLocEng(locEng) { - locallog(); -} -void LocEngRequestXtra::proc() const -{ - loc_eng_xtra_data_s_type* locEngXtra = - &(((loc_eng_data_s_type*)mLocEng)->xtra_module_data); - - if (locEngXtra->download_request_cb != NULL) { - CALLBACK_LOG_CALLFLOW("download_request_cb", %p, mLocEng); - locEngXtra->download_request_cb(); - } else { - LOC_LOGE("Callback function for request xtra is NULL"); - } -} -inline void LocEngRequestXtra::locallog() const { - LOC_LOGV("LocEngReqXtra"); -} -inline void LocEngRequestXtra::log() const { - locallog(); -} - -// case LOC_ENG_MSG_REQUEST_TIME: -LocEngRequestTime::LocEngRequestTime(void* locEng) : - LocMsg(), mLocEng(locEng) -{ - locallog(); -} -void LocEngRequestTime::proc() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - if (gps_conf.CAPABILITIES & GPS_CAPABILITY_ON_DEMAND_TIME) { - if (locEng->request_utc_time_cb != NULL) { - locEng->request_utc_time_cb(); - } else { - LOC_LOGE("Callback function for request time is NULL"); - } - } -} -inline void LocEngRequestTime::locallog() const { - LOC_LOGV("LocEngReqTime"); -} -inline void LocEngRequestTime::log() const { - locallog(); -} - -// case LOC_ENG_MSG_DELETE_AIDING_DATA: -struct LocEngDelAidData : public LocMsg { - loc_eng_data_s_type* mLocEng; - const GpsAidingData mType; - inline LocEngDelAidData(loc_eng_data_s_type* locEng, - GpsAidingData f) : - LocMsg(), mLocEng(locEng), mType(f) - { - locallog(); - } - inline virtual void proc() const { - mLocEng->aiding_data_for_deletion = mType; - update_aiding_data_for_deletion(*mLocEng); - } - inline void locallog() const { - LOC_LOGV("aiding data msak %d", mType); - } - virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_ENABLE_DATA: -struct LocEngEnableData : public LocMsg { - LocEngAdapter* mAdapter; - const int mEnable; - char* mAPN; - const int mLen; - inline LocEngEnableData(LocEngAdapter* adapter, - const char* name, int len, int enable) : - LocMsg(), mAdapter(adapter), - mEnable(enable), mAPN(NULL), mLen(len) - { - if (NULL != name) { - mAPN = new char[len+1]; - memcpy((void*)mAPN, (void*)name, len); - mAPN[len] = 0; - } - locallog(); - } - inline ~LocEngEnableData() { - if (NULL != mAPN) { - delete[] mAPN; - } - } - inline virtual void proc() const { - mAdapter->enableData(mEnable); - if (NULL != mAPN) { - mAdapter->setAPN(mAPN, mLen); - } - } - inline void locallog() const { - LOC_LOGV("apn: %s\n enable: %d", - (NULL == mAPN) ? "NULL" : mAPN, mEnable); - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_INJECT_XTRA_DATA: -// loc_eng_xtra.cpp - -// case LOC_ENG_MSG_SET_CAPABILITIES: -struct LocEngSetCapabilities : public LocMsg { - loc_eng_data_s_type* mLocEng; - inline LocEngSetCapabilities(loc_eng_data_s_type* locEng) : - LocMsg(), mLocEng(locEng) - { - locallog(); - } - inline virtual void proc() const { - if (NULL != mLocEng->set_capabilities_cb) { - LOC_LOGV("calling set_capabilities_cb 0x%x", - gps_conf.CAPABILITIES); - mLocEng->set_capabilities_cb(gps_conf.CAPABILITIES); - } else { - LOC_LOGV("set_capabilities_cb is NULL.\n"); - } - } - inline void locallog() const - { - LOC_LOGV("LocEngSetCapabilities"); - } - inline virtual void log() const - { - locallog(); - } -}; - -// case LOC_ENG_MSG_LOC_INIT: -struct LocEngInit : public LocMsg { - loc_eng_data_s_type* mLocEng; - inline LocEngInit(loc_eng_data_s_type* locEng) : - LocMsg(), mLocEng(locEng) - { - locallog(); - } - inline virtual void proc() const { - loc_eng_reinit(*mLocEng); - mLocEng->adapter->setGpsLock(1); - // set the capabilities - mLocEng->adapter->sendMsg(new LocEngSetCapabilities(mLocEng)); - } - inline void locallog() const - { - LOC_LOGV("LocEngInit"); - } - inline virtual void log() const - { - locallog(); - } -}; - -// case LOC_ENG_MSG_REQUEST_XTRA_SERVER: -// loc_eng_xtra.cpp - -// case LOC_ENG_MSG_ATL_OPEN_SUCCESS: -struct LocEngAtlOpenSuccess : public LocMsg { - AgpsStateMachine* mStateMachine; - const int mLen; - char* mAPN; - const AGpsBearerType mBearerType; - inline LocEngAtlOpenSuccess(AgpsStateMachine* statemachine, - const char* name, - int len, - AGpsBearerType btype) : - LocMsg(), - mStateMachine(statemachine), mLen(len), - mAPN(new char[len+1]), mBearerType(btype) - { - memcpy((void*)mAPN, (void*)name, len); - mAPN[len] = 0; - locallog(); - } - inline ~LocEngAtlOpenSuccess() - { - delete[] mAPN; - } - inline virtual void proc() const { - mStateMachine->setBearer(mBearerType); - mStateMachine->setAPN(mAPN, mLen); - mStateMachine->onRsrcEvent(RSRC_GRANTED); - } - inline void locallog() const { - LOC_LOGV("LocEngAtlOpenSuccess agps type: %s\n apn: %s\n" - " bearer type: %s", - loc_get_agps_type_name(mStateMachine->getType()), - mAPN, - loc_get_agps_bear_name(mBearerType)); - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_ATL_CLOSED: -struct LocEngAtlClosed : public LocMsg { - AgpsStateMachine* mStateMachine; - inline LocEngAtlClosed(AgpsStateMachine* statemachine) : - LocMsg(), mStateMachine(statemachine) { - locallog(); - } - inline virtual void proc() const { - mStateMachine->onRsrcEvent(RSRC_RELEASED); - } - inline void locallog() const { - LOC_LOGV("LocEngAtlClosed"); - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_ATL_OPEN_FAILED: -struct LocEngAtlOpenFailed : public LocMsg { - AgpsStateMachine* mStateMachine; - inline LocEngAtlOpenFailed(AgpsStateMachine* statemachine) : - LocMsg(), mStateMachine(statemachine) { - locallog(); - } - inline virtual void proc() const { - mStateMachine->onRsrcEvent(RSRC_DENIED); - } - inline void locallog() const { - LOC_LOGV("LocEngAtlOpenFailed"); - } - inline virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_ENGINE_DOWN: -LocEngDown::LocEngDown(void* locEng) : - LocMsg(), mLocEng(locEng) { - locallog(); -} -inline void LocEngDown::proc() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - loc_eng_handle_engine_down(*locEng); -} -inline void LocEngDown::locallog() const { - LOC_LOGV("LocEngDown"); -} -inline void LocEngDown::log() const { - locallog(); -} - -// case LOC_ENG_MSG_ENGINE_UP: -LocEngUp::LocEngUp(void* locEng) : - LocMsg(), mLocEng(locEng) { - locallog(); -} -inline void LocEngUp::proc() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - loc_eng_handle_engine_up(*locEng); -} -inline void LocEngUp::locallog() const { - LOC_LOGV("LocEngUp"); -} -inline void LocEngUp::log() const { - locallog(); -} - -struct LocEngDataClientInit : public LocMsg { - loc_eng_data_s_type* mLocEng; - inline LocEngDataClientInit(loc_eng_data_s_type* locEng) : - LocMsg(), mLocEng(locEng) { - locallog(); - } - virtual void proc() const { - loc_eng_data_s_type *locEng = (loc_eng_data_s_type *)mLocEng; - if(!locEng->adapter->initDataServiceClient()) { - locEng->ds_nif = new DSStateMachine(servicerTypeExt, - (void *)dataCallCb, - locEng->adapter); - } - } - void locallog() const { - LOC_LOGV("LocEngDataClientInit\n"); - } - virtual void log() const { - locallog(); - } -}; - -struct LocEngInstallAGpsCert : public LocMsg { - LocEngAdapter* mpAdapter; - const size_t mNumberOfCerts; - const uint32_t mSlotBitMask; - DerEncodedCertificate* mpData; - inline LocEngInstallAGpsCert(LocEngAdapter* adapter, - const DerEncodedCertificate* pData, - size_t numberOfCerts, - uint32_t slotBitMask) : - LocMsg(), mpAdapter(adapter), - mNumberOfCerts(numberOfCerts), mSlotBitMask(slotBitMask), - mpData(new DerEncodedCertificate[mNumberOfCerts]) - { - for (int i=0; i < mNumberOfCerts; i++) { - mpData[i].data = new u_char[pData[i].length]; - if (mpData[i].data) { - memcpy(mpData[i].data, (void*)pData[i].data, pData[i].length); - mpData[i].length = pData[i].length; - } else { - LOC_LOGE("malloc failed for cert#%d", i); - break; - } - } - locallog(); - } - inline ~LocEngInstallAGpsCert() - { - for (int i=0; i < mNumberOfCerts; i++) { - if (mpData[i].data) { - delete[] mpData[i].data; - } - } - delete[] mpData; - } - inline virtual void proc() const { - mpAdapter->installAGpsCert(mpData, mNumberOfCerts, mSlotBitMask); - } - inline void locallog() const { - LOC_LOGV("LocEngInstallAGpsCert - certs=%u mask=%u", - mNumberOfCerts, mSlotBitMask); - } - inline virtual void log() const { - locallog(); - } -}; - -struct LocEngUpdateRegistrationMask : public LocMsg { - loc_eng_data_s_type* mLocEng; - LOC_API_ADAPTER_EVENT_MASK_T mMask; - loc_registration_mask_status mIsEnabled; - inline LocEngUpdateRegistrationMask(loc_eng_data_s_type* locEng, - LOC_API_ADAPTER_EVENT_MASK_T mask, - loc_registration_mask_status isEnabled) : - LocMsg(), mLocEng(locEng), mMask(mask), mIsEnabled(isEnabled) { - locallog(); - } - inline virtual void proc() const { - loc_eng_data_s_type *locEng = (loc_eng_data_s_type *)mLocEng; - locEng->adapter->updateRegistrationMask(mMask, - mIsEnabled); - } - void locallog() const { - LOC_LOGV("LocEngUpdateRegistrationMask\n"); - } - virtual void log() const { - locallog(); - } -}; - -struct LocEngGnssConstellationConfig : public LocMsg { - LocEngAdapter* mAdapter; - inline LocEngGnssConstellationConfig(LocEngAdapter* adapter) : - LocMsg(), mAdapter(adapter) { - locallog(); - } - inline virtual void proc() const { - if (mAdapter->gnssConstellationConfig()) { - LOC_LOGV("Modem supports GNSS measurements\n"); - gps_conf.CAPABILITIES |= GPS_CAPABILITY_MEASUREMENTS; - } else { - LOC_LOGV("Modem does not support GNSS measurements\n"); - } - } - void locallog() const { - LOC_LOGV("LocEngGnssConstellationConfig\n"); - } - virtual void log() const { - locallog(); - } -}; - -// case LOC_ENG_MSG_REPORT_GNSS_MEASUREMENT: -LocEngReportGpsMeasurement::LocEngReportGpsMeasurement(void* locEng, - GpsData &gpsData) : - LocMsg(), mLocEng(locEng), mGpsData(gpsData) -{ - locallog(); -} -void LocEngReportGpsMeasurement::proc() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*) mLocEng; - if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION) - { - if (locEng->gps_measurement_cb != NULL) { - locEng->gps_measurement_cb((GpsData*)&(mGpsData)); - } - } -} -void LocEngReportGpsMeasurement::locallog() const { - IF_LOC_LOGV { - LOC_LOGV("%s:%d]: Received in GPS HAL." - "GNSS Measurements count: %d \n", - __func__, __LINE__, mGpsData.measurement_count); - for (int i =0; i< mGpsData.measurement_count && i < GPS_MAX_SVS; i++) { - LOC_LOGV(" GNSS measurement data in GPS HAL: \n" - " GPS_HAL => Measurement ID | prn | time_offset_ns | state |" - " received_gps_tow_ns| c_n0_dbhz | pseudorange_rate_mps |" - " pseudorange_rate_uncertainty_mps |" - " accumulated_delta_range_state | flags \n" - " GPS_HAL => %d | %d | %f | %d | %lld | %f | %f | %f | %d | %d \n", - i, - mGpsData.measurements[i].prn, - mGpsData.measurements[i].time_offset_ns, - mGpsData.measurements[i].state, - mGpsData.measurements[i].received_gps_tow_ns, - mGpsData.measurements[i].c_n0_dbhz, - mGpsData.measurements[i].pseudorange_rate_mps, - mGpsData.measurements[i].pseudorange_rate_uncertainty_mps, - mGpsData.measurements[i].accumulated_delta_range_state, - mGpsData.measurements[i].flags); - } - LOC_LOGV(" GPS_HAL => Clocks Info: type | time_ns \n" - " GPS_HAL => Clocks Info: %d | %lld", mGpsData.clock.type, - mGpsData.clock.time_ns); - } -} -inline void LocEngReportGpsMeasurement::log() const { - locallog(); -} - -/********************************************************************* - * Initialization checking macros - *********************************************************************/ -#define STATE_CHECK(ctx, x, ret) \ - if (!(ctx)) \ - { \ - /* Not intialized, abort */\ - LOC_LOGE("%s: log_eng state error: %s", __func__, x); \ - EXIT_LOG(%s, x); \ - ret; \ - } -#define INIT_CHECK(ctx, ret) STATE_CHECK(ctx, "instance not initialized", ret) - -uint32_t getCarrierCapabilities() { - #define carrierMSA (uint32_t)0x2 - #define carrierMSB (uint32_t)0x1 - #define gpsConfMSA (uint32_t)0x4 - #define gpsConfMSB (uint32_t)0x2 - uint32_t capabilities = gps_conf.CAPABILITIES; - if ((gps_conf.SUPL_MODE & carrierMSA) != carrierMSA) { - capabilities &= ~gpsConfMSA; - } - if ((gps_conf.SUPL_MODE & carrierMSB) != carrierMSB) { - capabilities &= ~gpsConfMSB; - } - - LOC_LOGV("getCarrierCapabilities: CAPABILITIES %x, SUPL_MODE %x, carrier capabilities %x", - gps_conf.CAPABILITIES, gps_conf.SUPL_MODE, capabilities); - return capabilities; -} - -/*=========================================================================== -FUNCTION loc_eng_init - -DESCRIPTION - Initialize the location engine, this include setting up global datas - and registers location engien with loc api service. - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks, - LOC_API_ADAPTER_EVENT_MASK_T event, ContextBase* context) - -{ - int ret_val = 0; - - ENTRY_LOG_CALLFLOW(); - if (NULL == callbacks || 0 == event) { - LOC_LOGE("loc_eng_init: bad parameters cb %p eMask %d", callbacks, event); - ret_val = -1; - EXIT_LOG(%d, ret_val); - return ret_val; - } - - STATE_CHECK((NULL == loc_eng_data.adapter), - "instance already initialized", return 0); - - memset(&loc_eng_data, 0, sizeof (loc_eng_data)); - - // Save callbacks - loc_eng_data.location_cb = callbacks->location_cb; - loc_eng_data.sv_status_cb = callbacks->sv_status_cb; - loc_eng_data.status_cb = callbacks->status_cb; - loc_eng_data.nmea_cb = callbacks->nmea_cb; - loc_eng_data.set_capabilities_cb = callbacks->set_capabilities_cb; - loc_eng_data.acquire_wakelock_cb = callbacks->acquire_wakelock_cb; - loc_eng_data.release_wakelock_cb = callbacks->release_wakelock_cb; - loc_eng_data.request_utc_time_cb = callbacks->request_utc_time_cb; - loc_eng_data.location_ext_parser = callbacks->location_ext_parser ? - callbacks->location_ext_parser : noProc; - loc_eng_data.sv_ext_parser = callbacks->sv_ext_parser ? - callbacks->sv_ext_parser : noProc; - loc_eng_data.intermediateFix = gps_conf.INTERMEDIATE_POS; - // initial states taken care of by the memset above - // loc_eng_data.engine_status -- GPS_STATUS_NONE; - // loc_eng_data.fix_session_status -- GPS_STATUS_NONE; - // loc_eng_data.mute_session_state -- LOC_MUTE_SESS_NONE; - - if ((event & LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT) && (gps_conf.NMEA_PROVIDER == NMEA_PROVIDER_AP)) - { - event = event ^ LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT; // unregister for modem NMEA report - loc_eng_data.generateNmea = true; - } - else - { - loc_eng_data.generateNmea = false; - } - - loc_eng_data.adapter = - new LocEngAdapter(event, &loc_eng_data, context, - (LocThread::tCreate)callbacks->create_thread_cb); - - LOC_LOGD("loc_eng_init created client, id = %p\n", - loc_eng_data.adapter); - loc_eng_data.adapter->sendMsg(new LocEngInit(&loc_eng_data)); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -static int loc_eng_reinit(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG(); - int ret_val = LOC_API_ADAPTER_ERR_SUCCESS; - LocEngAdapter* adapter = loc_eng_data.adapter; - - adapter->sendMsg(new LocEngGnssConstellationConfig(adapter)); - adapter->sendMsg(new LocEngSuplVer(adapter, gps_conf.SUPL_VER)); - adapter->sendMsg(new LocEngLppConfig(adapter, gps_conf.LPP_PROFILE)); - adapter->sendMsg(new LocEngSensorControlConfig(adapter, sap_conf.SENSOR_USAGE, - sap_conf.SENSOR_PROVIDER)); - adapter->sendMsg(new LocEngAGlonassProtocol(adapter, gps_conf.A_GLONASS_POS_PROTOCOL_SELECT)); - - /* Make sure at least one of the sensor property is specified by the user in the gps.conf file. */ - if( sap_conf.GYRO_BIAS_RANDOM_WALK_VALID || - sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID || - sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || - sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || - sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) { - adapter->sendMsg(new LocEngSensorProperties(adapter, - sap_conf.GYRO_BIAS_RANDOM_WALK_VALID, - sap_conf.GYRO_BIAS_RANDOM_WALK, - sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, - sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, - sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, - sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, - sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY)); - } - - adapter->sendMsg(new LocEngSensorPerfControlConfig(adapter, - sap_conf.SENSOR_CONTROL_MODE, - sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, - sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC, - sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH, - sap_conf.SENSOR_GYRO_BATCHES_PER_SEC, - sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, - sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, - sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, - sap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, - sap_conf.SENSOR_ALGORITHM_CONFIG_MASK)); - - adapter->sendMsg(new LocEngEnableData(adapter, NULL, 0, (agpsStatus ? 1:0))); - - loc_eng_xtra_version_check(loc_eng_data, gps_conf.XTRA_VERSION_CHECK); - - LOC_LOGD("loc_eng_reinit reinit() successful"); - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_eng_cleanup - -DESCRIPTION - Cleans location engine. The location client handle will be released. - -DEPENDENCIES - None - -RETURN VALUE - None - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG_CALLFLOW(); - INIT_CHECK(loc_eng_data.adapter, return); - - // XTRA has no state, so we are fine with it. - - // we need to check and clear NI -#if 0 - // we need to check and clear ATL - if (NULL != loc_eng_data.agnss_nif) { - delete loc_eng_data.agnss_nif; - loc_eng_data.agnss_nif = NULL; - } - if (NULL != loc_eng_data.internet_nif) { - delete loc_eng_data.internet_nif; - loc_eng_data.internet_nif = NULL; - } -#endif - if (loc_eng_data.adapter->isInSession()) - { - LOC_LOGD("loc_eng_cleanup: fix not stopped. stop it now."); - loc_eng_stop(loc_eng_data); - } - -#if 0 // can't afford to actually clean up, for many reason. - - LOC_LOGD("loc_eng_init: client opened. close it now."); - delete loc_eng_data.adapter; - loc_eng_data.adapter = NULL; - - loc_eng_dmn_conn_loc_api_server_unblock(); - loc_eng_dmn_conn_loc_api_server_join(); - -#endif - - EXIT_LOG(%s, VOID_RET); -} - - -/*=========================================================================== -FUNCTION loc_eng_start - -DESCRIPTION - Starts the tracking session - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_start(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG_CALLFLOW(); - INIT_CHECK(loc_eng_data.adapter, return -1); - - if(! loc_eng_data.adapter->getUlpProxy()->sendStartFix()) - { - loc_eng_data.adapter->sendMsg(new LocEngStartFix(loc_eng_data.adapter)); - } - - EXIT_LOG(%d, 0); - return 0; -} - -static int loc_eng_start_handler(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG(); - int ret_val = LOC_API_ADAPTER_ERR_SUCCESS; - - if (!loc_eng_data.adapter->isInSession()) { - ret_val = loc_eng_data.adapter->startFix(); - - if (ret_val == LOC_API_ADAPTER_ERR_SUCCESS || - ret_val == LOC_API_ADAPTER_ERR_ENGINE_DOWN || - ret_val == LOC_API_ADAPTER_ERR_PHONE_OFFLINE || - ret_val == LOC_API_ADAPTER_ERR_INTERNAL) - { - loc_eng_data.adapter->setInSession(TRUE); - } - } - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_eng_stop_wrapper - -DESCRIPTION - Stops the tracking session - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_stop(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG_CALLFLOW(); - INIT_CHECK(loc_eng_data.adapter, return -1); - - if(! loc_eng_data.adapter->getUlpProxy()->sendStopFix()) - { - loc_eng_data.adapter->sendMsg(new LocEngStopFix(loc_eng_data.adapter)); - } - - EXIT_LOG(%d, 0); - return 0; -} - -static int loc_eng_stop_handler(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG(); - int ret_val = LOC_API_ADAPTER_ERR_SUCCESS; - - if (loc_eng_data.adapter->isInSession()) { - - ret_val = loc_eng_data.adapter->stopFix(); - loc_eng_data.adapter->setInSession(FALSE); - } - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_eng_mute_one_session - -DESCRIPTION - Mutes one session - -DEPENDENCIES - None - -RETURN VALUE - 0: Success - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_eng_mute_one_session(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG(); - loc_eng_data.mute_session_state = LOC_MUTE_SESS_WAIT; - EXIT_LOG(%s, VOID_RET); -} - -/*=========================================================================== -FUNCTION loc_eng_set_position_mode - -DESCRIPTION - Sets the mode and fix frequency for the tracking session. - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data, - LocPosMode ¶ms) -{ - ENTRY_LOG_CALLFLOW(); - INIT_CHECK(loc_eng_data.adapter, return -1); - - // The position mode for AUTO/GSS/QCA1530 can only be standalone - if (!(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSB) && - !(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) && - (params.mode != LOC_POSITION_MODE_STANDALONE)) { - params.mode = LOC_POSITION_MODE_STANDALONE; - LOC_LOGD("Position mode changed to standalone for target with AUTO/GSS/qca1530."); - } - - if(! loc_eng_data.adapter->getUlpProxy()->sendFixMode(params)) - { - LocEngAdapter* adapter = loc_eng_data.adapter; - adapter->sendMsg(new LocEngPositionMode(adapter, params)); - } - - EXIT_LOG(%d, 0); - return 0; -} - -/*=========================================================================== -FUNCTION loc_eng_inject_time - -DESCRIPTION - This is used by Java native function to do time injection. - -DEPENDENCIES - None - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data, GpsUtcTime time, - int64_t timeReference, int uncertainty) -{ - ENTRY_LOG_CALLFLOW(); - INIT_CHECK(loc_eng_data.adapter, return -1); - LocEngAdapter* adapter = loc_eng_data.adapter; - - adapter->sendMsg(new LocEngSetTime(adapter, time, timeReference, - uncertainty)); - - EXIT_LOG(%d, 0); - return 0; -} - - -/*=========================================================================== -FUNCTION loc_eng_inject_location - -DESCRIPTION - This is used by Java native function to do location injection. - -DEPENDENCIES - None - -RETURN VALUE - 0 : Successful - error code : Failure - -SIDE EFFECTS - N/A -===========================================================================*/ -int loc_eng_inject_location(loc_eng_data_s_type &loc_eng_data, double latitude, - double longitude, float accuracy) -{ - ENTRY_LOG_CALLFLOW(); - INIT_CHECK(loc_eng_data.adapter, return -1); - LocEngAdapter* adapter = loc_eng_data.adapter; - if(adapter->mSupportsPositionInjection) - { - adapter->sendMsg(new LocEngInjectLocation(adapter, latitude, longitude, - accuracy)); - } - - EXIT_LOG(%d, 0); - return 0; -} - - -/*=========================================================================== -FUNCTION loc_eng_delete_aiding_data - -DESCRIPTION - This is used by Java native function to delete the aiding data. The function - updates the global variable for the aiding data to be deleted. If the GPS - engine is off, the aiding data will be deleted. Otherwise, the actual action - will happen when gps engine is turned off. - -DEPENDENCIES - Assumes the aiding data type specified in GpsAidingData matches with - LOC API specification. - -RETURN VALUE - None - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_eng_delete_aiding_data(loc_eng_data_s_type &loc_eng_data, GpsAidingData f) -{ - ENTRY_LOG_CALLFLOW(); - INIT_CHECK(loc_eng_data.adapter, return); - - loc_eng_data.adapter->sendMsg(new LocEngDelAidData(&loc_eng_data, f)); - - EXIT_LOG(%s, VOID_RET); -} - -/*=========================================================================== - -FUNCTION loc_inform_gps_state - -DESCRIPTION - Informs the GPS Provider about the GPS status - -DEPENDENCIES - None - -RETURN VALUE - None - -SIDE EFFECTS - N/A - -===========================================================================*/ -static void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data, GpsStatusValue status) -{ - ENTRY_LOG(); - - if (loc_eng_data.status_cb) - { - GpsStatus gs = { sizeof(gs),status }; - CALLBACK_LOG_CALLFLOW("status_cb", %s, - loc_get_gps_status_name(gs.status)); - loc_eng_data.status_cb(&gs); - } - - EXIT_LOG(%s, VOID_RET); -} - -static int loc_eng_get_zpp_handler(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG(); - int ret_val = LOC_API_ADAPTER_ERR_SUCCESS; - UlpLocation location; - LocPosTechMask tech_mask = LOC_POS_TECH_MASK_DEFAULT; - GpsLocationExtended locationExtended; - memset(&locationExtended, 0, sizeof (GpsLocationExtended)); - locationExtended.size = sizeof(locationExtended); - - ret_val = loc_eng_data.adapter->getZpp(location.gpsLocation, tech_mask); - //Mark the location source as from ZPP - location.gpsLocation.flags |= LOCATION_HAS_SOURCE_INFO; - location.position_source = ULP_LOCATION_IS_FROM_ZPP; - - loc_eng_data.adapter->getUlpProxy()->reportPosition(location, - locationExtended, - NULL, - LOC_SESS_SUCCESS, - tech_mask); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/* - Callback function passed to Data Services State Machine - This becomes part of the state machine's servicer and - is used to send requests to the data services client -*/ -static int dataCallCb(void *cb_data) -{ - LOC_LOGD("Enter dataCallCb\n"); - int ret=0; - if(cb_data != NULL) { - dsCbData *cbData = (dsCbData *)cb_data; - LocEngAdapter *locAdapter = (LocEngAdapter *)cbData->mAdapter; - if(cbData->action == GPS_REQUEST_AGPS_DATA_CONN) { - LOC_LOGD("dataCallCb GPS_REQUEST_AGPS_DATA_CONN\n"); - ret = locAdapter->openAndStartDataCall(); - } - else if(cbData->action == GPS_RELEASE_AGPS_DATA_CONN) { - LOC_LOGD("dataCallCb GPS_RELEASE_AGPS_DATA_CONN\n"); - locAdapter->stopDataCall(); - } - } - else { - LOC_LOGE("NULL argument received. Failing.\n"); - ret = -1; - goto err; - } - -err: - LOC_LOGD("Exit dataCallCb ret = %d\n", ret); - return ret; -} - -/*=========================================================================== -FUNCTION loc_eng_agps_reinit - -DESCRIPTION - 2nd half of loc_eng_agps_init(), singled out for modem restart to use. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -static void loc_eng_agps_reinit(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG(); - - // Set server addresses which came before init - if (loc_eng_data.supl_host_set) - { - loc_eng_set_server(loc_eng_data, LOC_AGPS_SUPL_SERVER, - loc_eng_data.supl_host_buf, - loc_eng_data.supl_port_buf); - } - - if (loc_eng_data.c2k_host_set) - { - loc_eng_set_server(loc_eng_data, LOC_AGPS_CDMA_PDE_SERVER, - loc_eng_data.c2k_host_buf, - loc_eng_data.c2k_port_buf); - } - EXIT_LOG(%s, VOID_RET); -} -/*=========================================================================== -FUNCTION loc_eng_agps_init - -DESCRIPTION - Initialize the AGps interface. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsExtCallbacks* callbacks) -{ - ENTRY_LOG_CALLFLOW(); - INIT_CHECK(loc_eng_data.adapter, return); - STATE_CHECK((NULL == loc_eng_data.agps_status_cb), - "agps instance already initialized", - return); - if (callbacks == NULL) { - LOC_LOGE("loc_eng_agps_init: bad parameters cb %p", callbacks); - EXIT_LOG(%s, VOID_RET); - return; - } - LocEngAdapter* adapter = loc_eng_data.adapter; - loc_eng_data.agps_status_cb = callbacks->status_cb; - - loc_eng_data.internet_nif = new AgpsStateMachine(servicerTypeAgps, - (void *)loc_eng_data.agps_status_cb, - AGPS_TYPE_WWAN_ANY, - false); - loc_eng_data.wifi_nif = new AgpsStateMachine(servicerTypeAgps, - (void *)loc_eng_data.agps_status_cb, - AGPS_TYPE_WIFI, - true); - - if ((gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) || - (gps_conf.CAPABILITIES & GPS_CAPABILITY_MSB)) { - loc_eng_data.agnss_nif = new AgpsStateMachine(servicerTypeAgps, - (void *)loc_eng_data.agps_status_cb, - AGPS_TYPE_SUPL, - false); - - if (adapter->mSupportsAgpsRequests) { - if(gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL) { - loc_eng_data.adapter->sendMsg(new LocEngDataClientInit(&loc_eng_data)); - } - loc_eng_dmn_conn_loc_api_server_launch(callbacks->create_thread_cb, - NULL, NULL, &loc_eng_data); - } - loc_eng_agps_reinit(loc_eng_data); - } - - EXIT_LOG(%s, VOID_RET); -} - -static void deleteAidingData(loc_eng_data_s_type &logEng) { - if (logEng.engine_status != GPS_STATUS_ENGINE_ON && - logEng.aiding_data_for_deletion != 0) { - logEng.adapter->deleteAidingData(logEng.aiding_data_for_deletion); - logEng.aiding_data_for_deletion = 0; - } -} - -static AgpsStateMachine* -getAgpsStateMachine(loc_eng_data_s_type &locEng, AGpsExtType agpsType) { - AgpsStateMachine* stateMachine; - switch (agpsType) { - case AGPS_TYPE_WIFI: { - stateMachine = locEng.wifi_nif; - break; - } - case AGPS_TYPE_INVALID: - case AGPS_TYPE_SUPL: { - stateMachine = locEng.agnss_nif; - break; - } - case AGPS_TYPE_SUPL_ES: { - locEng.ds_nif ? - stateMachine = locEng.ds_nif: - stateMachine = locEng.agnss_nif; - break; - } - default: - stateMachine = locEng.internet_nif; - } - return stateMachine; -} - -/*=========================================================================== -FUNCTION loc_eng_agps_open - -DESCRIPTION - This function is called when on-demand data connection opening is successful. -It should inform engine about the data open result. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType, - const char* apn, AGpsBearerType bearerType) -{ - ENTRY_LOG_CALLFLOW(); - INIT_CHECK(loc_eng_data.adapter && loc_eng_data.agps_status_cb, - return -1); - - if (apn == NULL) - { - LOC_LOGE("APN Name NULL\n"); - return 0; - } - - LOC_LOGD("loc_eng_agps_open APN name = [%s]", apn); - - int apn_len = smaller_of(strlen (apn), MAX_APN_LEN); - AgpsStateMachine* sm = getAgpsStateMachine(loc_eng_data, agpsType); - - loc_eng_data.adapter->sendMsg( - new LocEngAtlOpenSuccess(sm, apn, apn_len, bearerType)); - - EXIT_LOG(%d, 0); - return 0; -} - -/*=========================================================================== -FUNCTION loc_eng_agps_closed - -DESCRIPTION - This function is called when on-demand data connection closing is done. -It should inform engine about the data close result. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType) -{ - ENTRY_LOG_CALLFLOW(); - INIT_CHECK(loc_eng_data.adapter && loc_eng_data.agps_status_cb, - return -1); - - AgpsStateMachine* sm = getAgpsStateMachine(loc_eng_data, agpsType); - loc_eng_data.adapter->sendMsg(new LocEngAtlClosed(sm)); - - EXIT_LOG(%d, 0); - return 0; -} - -/*=========================================================================== -FUNCTION loc_eng_agps_open_failed - -DESCRIPTION - This function is called when on-demand data connection opening has failed. -It should inform engine about the data open result. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType) -{ - ENTRY_LOG_CALLFLOW(); - INIT_CHECK(loc_eng_data.adapter && loc_eng_data.agps_status_cb, - return -1); - - AgpsStateMachine* sm = getAgpsStateMachine(loc_eng_data, agpsType); - loc_eng_data.adapter->sendMsg(new LocEngAtlOpenFailed(sm)); - - EXIT_LOG(%d, 0); - return 0; -} - -/*=========================================================================== - -FUNCTION resolve_in_addr - -DESCRIPTION - Translates a hostname to in_addr struct - -DEPENDENCIES - n/a - -RETURN VALUE - TRUE if successful - -SIDE EFFECTS - n/a - -===========================================================================*/ -static boolean resolve_in_addr(const char *host_addr, struct in_addr *in_addr_ptr) -{ - ENTRY_LOG(); - boolean ret_val = TRUE; - - struct hostent *hp; - hp = gethostbyname(host_addr); - if (hp != NULL) /* DNS OK */ - { - memcpy(in_addr_ptr, hp->h_addr_list[0], hp->h_length); - } - else - { - /* Try IP representation */ - if (inet_aton(host_addr, in_addr_ptr) == 0) - { - /* IP not valid */ - LOC_LOGE("DNS query on '%s' failed\n", host_addr); - ret_val = FALSE; - } - } - - EXIT_LOG(%s, loc_logger_boolStr[ret_val!=0]); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_eng_set_server - -DESCRIPTION - This is used to set the default AGPS server. Server address is obtained - from gps.conf. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_eng_set_server(loc_eng_data_s_type &loc_eng_data, - LocServerType type, const char* hostname, int port) -{ - ENTRY_LOG(); - int ret = 0; - LocEngAdapter* adapter = loc_eng_data.adapter; - - if (LOC_AGPS_SUPL_SERVER == type) { - char url[MAX_URL_LEN]; - unsigned int len = 0; - const char nohost[] = "NONE"; - if (hostname == NULL || - strncasecmp(nohost, hostname, sizeof(nohost)) == 0) { - url[0] = NULL; - } else { - len = snprintf(url, sizeof(url), "%s:%u", hostname, (unsigned) port); - } - - if (sizeof(url) > len) { - adapter->sendMsg(new LocEngSetServerUrl(adapter, url, len)); - } - } else if (LOC_AGPS_CDMA_PDE_SERVER == type || - LOC_AGPS_CUSTOM_PDE_SERVER == type || - LOC_AGPS_MPC_SERVER == type) { - struct in_addr addr; - if (!resolve_in_addr(hostname, &addr)) - { - LOC_LOGE("loc_eng_set_server, hostname %s cannot be resolved.\n", hostname); - ret = -2; - } else { - unsigned int ip = htonl(addr.s_addr); - adapter->sendMsg(new LocEngSetServerIpv4(adapter, ip, port, type)); - } - } else { - LOC_LOGE("loc_eng_set_server, type %d cannot be resolved.\n", type); - } - - EXIT_LOG(%d, ret); - return ret; -} - -/*=========================================================================== -FUNCTION loc_eng_set_server_proxy - -DESCRIPTION - If loc_eng_set_server is called before loc_eng_init, it doesn't work. This - proxy buffers server settings and calls loc_eng_set_server when the client is - open. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_set_server_proxy(loc_eng_data_s_type &loc_eng_data, - LocServerType type, - const char* hostname, int port) -{ - ENTRY_LOG_CALLFLOW(); - int ret_val = 0; - - LOC_LOGV("save the address, type: %d, hostname: %s, port: %d", - (int) type, hostname, port); - switch (type) - { - case LOC_AGPS_SUPL_SERVER: - strlcpy(loc_eng_data.supl_host_buf, hostname, - sizeof(loc_eng_data.supl_host_buf)); - loc_eng_data.supl_port_buf = port; - loc_eng_data.supl_host_set = 1; - break; - case LOC_AGPS_CDMA_PDE_SERVER: - strlcpy(loc_eng_data.c2k_host_buf, hostname, - sizeof(loc_eng_data.c2k_host_buf)); - loc_eng_data.c2k_port_buf = port; - loc_eng_data.c2k_host_set = 1; - break; - default: - LOC_LOGE("loc_eng_set_server_proxy, unknown server type = %d", (int) type); - } - - if (NULL != loc_eng_data.adapter) - { - ret_val = loc_eng_set_server(loc_eng_data, type, hostname, port); - } - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_eng_agps_ril_update_network_availability - -DESCRIPTION - Sets data call allow vs disallow flag to modem - This is the only member of sLocEngAGpsRilInterface implemented. - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data, - int available, const char* apn) -{ - ENTRY_LOG_CALLFLOW(); - - //This is to store the status of data availability over the network. - //If GPS is not enabled, the INIT_CHECK will fail and the modem will - //not be updated with the network's availability. Since the data status - //can change before GPS is enabled the, storing the status will enable - //us to inform the modem after GPS is enabled - agpsStatus = available; - - INIT_CHECK(loc_eng_data.adapter, return); - if (apn != NULL) - { - LOC_LOGD("loc_eng_agps_ril_update_network_availability: APN Name = [%s]\n", apn); - int apn_len = smaller_of(strlen (apn), MAX_APN_LEN); - LocEngAdapter* adapter = loc_eng_data.adapter; - adapter->sendMsg(new LocEngEnableData(adapter, apn, apn_len, available)); - } - EXIT_LOG(%s, VOID_RET); -} - -int loc_eng_agps_install_certificates(loc_eng_data_s_type &loc_eng_data, - const DerEncodedCertificate* certificates, - size_t numberOfCerts) -{ - ENTRY_LOG_CALLFLOW(); - int ret_val = AGPS_CERTIFICATE_OPERATION_SUCCESS; - - uint32_t slotBitMask = gps_conf.AGPS_CERT_WRITABLE_MASK; - uint32_t slotCount = 0; - for (uint32_t slotBitMaskCounter=slotBitMask; slotBitMaskCounter; slotCount++) { - slotBitMaskCounter &= slotBitMaskCounter - 1; - } - LOC_LOGD("SlotBitMask=%u SlotCount=%u NumberOfCerts=%u", - slotBitMask, slotCount, numberOfCerts); - - LocEngAdapter* adapter = loc_eng_data.adapter; - - if (numberOfCerts == 0) { - LOC_LOGE("No certs to install, since numberOfCerts is zero"); - ret_val = AGPS_CERTIFICATE_OPERATION_SUCCESS; - } else if (!adapter) { - LOC_LOGE("adapter is null!"); - ret_val = AGPS_CERTIFICATE_ERROR_GENERIC; - } else if (slotCount < numberOfCerts) { - LOC_LOGE("Not enough cert slots (%u) to install %u certs!", - slotCount, numberOfCerts); - ret_val = AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES; - } else { - for (int i=0; i < numberOfCerts; ++i) - { - if (certificates[i].length > AGPS_CERTIFICATE_MAX_LENGTH) { - LOC_LOGE("cert#(%u) length of %u is too big! greater than %u", - certificates[i].length, AGPS_CERTIFICATE_MAX_LENGTH); - ret_val = AGPS_CERTIFICATE_ERROR_GENERIC; - break; - } - } - - if (ret_val == AGPS_CERTIFICATE_OPERATION_SUCCESS) { - adapter->sendMsg(new LocEngInstallAGpsCert(adapter, - certificates, - numberOfCerts, - slotBitMask)); - } - } - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -void loc_eng_configuration_update (loc_eng_data_s_type &loc_eng_data, - const char* config_data, int32_t length) -{ - ENTRY_LOG_CALLFLOW(); - - if (config_data && length > 0) { - loc_gps_cfg_s_type gps_conf_tmp = gps_conf; - UTIL_UPDATE_CONF(config_data, length, gps_conf_table); - LocEngAdapter* adapter = loc_eng_data.adapter; - - // it is possible that HAL is not init'ed at this time - if (adapter) { - if (gps_conf_tmp.SUPL_VER != gps_conf.SUPL_VER) { - adapter->sendMsg(new LocEngSuplVer(adapter, gps_conf.SUPL_VER)); - } - if (gps_conf_tmp.LPP_PROFILE != gps_conf.LPP_PROFILE) { - adapter->sendMsg(new LocEngLppConfig(adapter, gps_conf.LPP_PROFILE)); - } - if (gps_conf_tmp.A_GLONASS_POS_PROTOCOL_SELECT != gps_conf.A_GLONASS_POS_PROTOCOL_SELECT) { - adapter->sendMsg(new LocEngAGlonassProtocol(adapter, - gps_conf.A_GLONASS_POS_PROTOCOL_SELECT)); - } - if (gps_conf_tmp.SUPL_MODE != gps_conf.SUPL_MODE) { - adapter->sendMsg(new LocEngSuplMode(adapter->getUlpProxy())); - } - } - - gps_conf_tmp.SUPL_VER = gps_conf.SUPL_VER; - gps_conf_tmp.LPP_PROFILE = gps_conf.LPP_PROFILE; - gps_conf_tmp.A_GLONASS_POS_PROTOCOL_SELECT = gps_conf.A_GLONASS_POS_PROTOCOL_SELECT; - gps_conf_tmp.GPS_LOCK = gps_conf.GPS_LOCK; - gps_conf = gps_conf_tmp; - } - - EXIT_LOG(%s, VOID_RET); -} - -/*=========================================================================== -FUNCTION loc_eng_report_status - -DESCRIPTION - Reports GPS engine state to Java layer. - -DEPENDENCIES - N/A - -RETURN VALUE - N/A - -SIDE EFFECTS - N/A - -===========================================================================*/ -static void loc_eng_report_status (loc_eng_data_s_type &loc_eng_data, GpsStatusValue status) -{ - ENTRY_LOG(); - // Switch from WAIT to MUTE, for "engine on" or "session begin" event - if (status == GPS_STATUS_SESSION_BEGIN || status == GPS_STATUS_ENGINE_ON) - { - if (loc_eng_data.mute_session_state == LOC_MUTE_SESS_WAIT) - { - LOC_LOGD("loc_eng_report_status: mute_session_state changed from WAIT to IN SESSION"); - loc_eng_data.mute_session_state = LOC_MUTE_SESS_IN_SESSION; - } - } - - // Switch off MUTE session - if (loc_eng_data.mute_session_state == LOC_MUTE_SESS_IN_SESSION && - (status == GPS_STATUS_SESSION_END || status == GPS_STATUS_ENGINE_OFF)) - { - LOC_LOGD("loc_eng_report_status: mute_session_state changed from IN SESSION to NONE"); - loc_eng_data.mute_session_state = LOC_MUTE_SESS_NONE; - } - - // Session End is not reported during Android navigating state - boolean navigating = loc_eng_data.adapter->isInSession(); - if (status != GPS_STATUS_NONE && - !(status == GPS_STATUS_SESSION_END && navigating) && - !(status == GPS_STATUS_SESSION_BEGIN && !navigating)) - { - if (loc_eng_data.mute_session_state != LOC_MUTE_SESS_IN_SESSION) - { - // Inform GpsLocationProvider about mNavigating status - loc_inform_gps_status(loc_eng_data, status); - } - else { - LOC_LOGD("loc_eng_report_status: muting the status report."); - } - } - - // Only keeps ENGINE ON/OFF in engine_status - if (status == GPS_STATUS_ENGINE_ON || status == GPS_STATUS_ENGINE_OFF) - { - loc_eng_data.engine_status = status; - } - - // Only keeps SESSION BEGIN/END in fix_session_status - if (status == GPS_STATUS_SESSION_BEGIN || status == GPS_STATUS_SESSION_END) - { - loc_eng_data.fix_session_status = status; - } - EXIT_LOG(%s, VOID_RET); -} - -/*=========================================================================== -FUNCTION loc_eng_handle_engine_down - loc_eng_handle_engine_up - -DESCRIPTION - Calls this function when it is detected that modem restart is happening. - Either we detected the modem is down or received modem up event. - This must be called from the deferred thread to avoid race condition. - -DEPENDENCIES - None - -RETURN VALUE - None - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_eng_handle_engine_down(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG(); - loc_eng_ni_reset_on_engine_restart(loc_eng_data); - loc_eng_report_status(loc_eng_data, GPS_STATUS_ENGINE_OFF); - EXIT_LOG(%s, VOID_RET); -} - -void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG(); - loc_eng_reinit(loc_eng_data); - - loc_eng_data.adapter->requestPowerVote(); - - if (loc_eng_data.agps_status_cb != NULL) { - if (loc_eng_data.agnss_nif) - loc_eng_data.agnss_nif->dropAllSubscribers(); - if (loc_eng_data.internet_nif) - loc_eng_data.internet_nif->dropAllSubscribers(); - - loc_eng_agps_reinit(loc_eng_data); - } - - // modem is back up. If we crashed in the middle of navigating, we restart. - if (loc_eng_data.adapter->isInSession()) { - // This sets the copy in adapter to modem - loc_eng_data.adapter->setInSession(false); - loc_eng_data.adapter->sendMsg(new LocEngStartFix(loc_eng_data.adapter)); - } - EXIT_LOG(%s, VOID_RET); -} - -#ifdef USE_GLIB -/*=========================================================================== -FUNCTION set_sched_policy - -DESCRIPTION - Local copy of this function which bypasses android set_sched_policy - -DEPENDENCIES - None - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int set_sched_policy(int tid, SchedPolicy policy) -{ - return 0; -} -#endif /* USE_GLIB */ - -/*=========================================================================== -FUNCTION loc_eng_read_config - -DESCRIPTION - Initiates the reading of the gps config file stored in /etc dir - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_read_config(void) -{ - ENTRY_LOG_CALLFLOW(); - if(configAlreadyRead == false) - { - // Initialize our defaults before reading of configuration file overwrites them. - loc_default_parameters(); - // We only want to parse the conf file once. This is a good place to ensure that. - // In fact one day the conf file should go into context. - UTIL_READ_CONF(GPS_CONF_FILE, gps_conf_table); - UTIL_READ_CONF(SAP_CONF_FILE, sap_conf_table); - configAlreadyRead = true; - } else { - LOC_LOGV("GPS Config file has already been read\n"); - } - - EXIT_LOG(%d, 0); - return 0; -} - -/*=========================================================================== -FUNCTION loc_eng_gps_measurement_init - -DESCRIPTION - Initialize gps measurement module. - -DEPENDENCIES - N/A - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_gps_measurement_init(loc_eng_data_s_type &loc_eng_data, - GpsMeasurementCallbacks* callbacks) -{ - ENTRY_LOG_CALLFLOW(); - - STATE_CHECK((NULL == loc_eng_data.gps_measurement_cb), - "gps measurement already initialized", - return GPS_MEASUREMENT_ERROR_ALREADY_INIT); - STATE_CHECK((callbacks != NULL), - "callbacks can not be NULL", - return GPS_MEASUREMENT_ERROR_GENERIC); - STATE_CHECK(loc_eng_data.adapter, - "GpsInterface must be initialized first", - return GPS_MEASUREMENT_ERROR_GENERIC); - - // updated the mask - LOC_API_ADAPTER_EVENT_MASK_T event = LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT; - loc_eng_data.adapter->sendMsg(new LocEngUpdateRegistrationMask( - &loc_eng_data, - event, - LOC_REGISTRATION_MASK_ENABLED)); - // set up the callback - loc_eng_data.gps_measurement_cb = callbacks->measurement_callback; - LOC_LOGD ("%s, event masks updated successfully", __func__); - - return GPS_MEASUREMENT_OPERATION_SUCCESS; -} - -/*=========================================================================== -FUNCTION loc_eng_gps_measurement_close - -DESCRIPTION - Close gps measurement module. - -DEPENDENCIES - N/A - -RETURN VALUE - N/A - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_eng_gps_measurement_close(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG_CALLFLOW(); - - INIT_CHECK(loc_eng_data.adapter, return); - - // updated the mask - LOC_API_ADAPTER_EVENT_MASK_T event = LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT; - loc_eng_data.adapter->sendMsg(new LocEngUpdateRegistrationMask( - &loc_eng_data, - event, - LOC_REGISTRATION_MASK_DISABLED)); - // set up the callback - loc_eng_data.gps_measurement_cb = NULL; - EXIT_LOG(%d, 0); -} diff --git a/gps/loc_api/libloc_api_50001/loc_eng.h b/gps/loc_api/libloc_api_50001/loc_eng.h deleted file mode 100644 index a203e6b..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng.h +++ /dev/null @@ -1,270 +0,0 @@ -/* Copyright (c) 2009-2014, 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_ENG_H -#define LOC_ENG_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -// Uncomment to keep all LOG messages (LOGD, LOGI, LOGV, etc.) -#define MAX_NUM_ATL_CONNECTIONS 2 - -// Define boolean type to be used by libgps on loc api module -typedef unsigned char boolean; - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// The data connection minimal open time -#define DATA_OPEN_MIN_TIME 1 /* sec */ - -// The system sees GPS engine turns off after inactive for this period of time -#define GPS_AUTO_OFF_TIME 2 /* secs */ -#define SUCCESS TRUE -#define FAILURE FALSE -#define INVALID_ATL_CONNECTION_HANDLE -1 - -#define MAX_XTRA_SERVER_URL_LENGTH 256 - -enum loc_nmea_provider_e_type { - NMEA_PROVIDER_AP = 0, // Application Processor Provider of NMEA - NMEA_PROVIDER_MP // Modem Processor Provider of NMEA -}; - -enum loc_mute_session_e_type { - LOC_MUTE_SESS_NONE = 0, - LOC_MUTE_SESS_WAIT, - LOC_MUTE_SESS_IN_SESSION -}; - -// Module data -typedef struct loc_eng_data_s -{ - LocEngAdapter *adapter; - loc_location_cb_ext location_cb; - gps_status_callback status_cb; - loc_sv_status_cb_ext sv_status_cb; - agps_status_extended agps_status_cb; - gps_nmea_callback nmea_cb; - gps_ni_notify_callback ni_notify_cb; - gps_set_capabilities set_capabilities_cb; - gps_acquire_wakelock acquire_wakelock_cb; - gps_release_wakelock release_wakelock_cb; - gps_request_utc_time request_utc_time_cb; - gps_measurement_callback gps_measurement_cb; - boolean intermediateFix; - AGpsStatusValue agps_status; - loc_eng_xtra_data_s_type xtra_module_data; - loc_eng_ni_data_s_type loc_eng_ni_data; - - // AGPS state machines - AgpsStateMachine* agnss_nif; - AgpsStateMachine* internet_nif; - AgpsStateMachine* wifi_nif; - //State machine for Data Services - AgpsStateMachine* ds_nif; - - // GPS engine status - GpsStatusValue engine_status; - GpsStatusValue fix_session_status; - - // Aiding data information to be deleted, aiding data can only be deleted when GPS engine is off - GpsAidingData aiding_data_for_deletion; - - // For muting session broadcast - loc_mute_session_e_type mute_session_state; - - // For nmea generation - boolean generateNmea; - uint32_t sv_used_mask; - float hdop; - float pdop; - float vdop; - - // Address buffers, for addressing setting before init - int supl_host_set; - char supl_host_buf[101]; - int supl_port_buf; - int c2k_host_set; - char c2k_host_buf[101]; - int c2k_port_buf; - int mpc_host_set; - char mpc_host_buf[101]; - int mpc_port_buf; - - loc_ext_parser location_ext_parser; - loc_ext_parser sv_ext_parser; -} loc_eng_data_s_type; - -/* GPS.conf support */ -/* NOTE: the implementaiton of the parser casts number - fields to 32 bit. To ensure all 'n' fields working, - they must all be 32 bit fields. */ -typedef struct loc_gps_cfg_s -{ - uint32_t INTERMEDIATE_POS; - uint32_t ACCURACY_THRES; - uint32_t SUPL_VER; - uint32_t SUPL_MODE; - uint32_t CAPABILITIES; - uint32_t LPP_PROFILE; - uint32_t XTRA_VERSION_CHECK; - char XTRA_SERVER_1[MAX_XTRA_SERVER_URL_LENGTH]; - char XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH]; - char XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH]; - uint32_t USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL; - uint32_t NMEA_PROVIDER; - uint32_t GPS_LOCK; - uint32_t A_GLONASS_POS_PROTOCOL_SELECT; - uint32_t AGPS_CERT_WRITABLE_MASK; -} loc_gps_cfg_s_type; - -/* NOTE: the implementaiton of the parser casts number - fields to 32 bit. To ensure all 'n' fields working, - they must all be 32 bit fields. */ -/* Meanwhile, *_valid fields are 8 bit fields, and 'f' - fields are double. Rigid as they are, it is the - the status quo, until the parsing mechanism is - change, that is. */ -typedef struct -{ - uint8_t GYRO_BIAS_RANDOM_WALK_VALID; - double GYRO_BIAS_RANDOM_WALK; - uint32_t SENSOR_ACCEL_BATCHES_PER_SEC; - uint32_t SENSOR_ACCEL_SAMPLES_PER_BATCH; - uint32_t SENSOR_GYRO_BATCHES_PER_SEC; - uint32_t SENSOR_GYRO_SAMPLES_PER_BATCH; - uint32_t SENSOR_ACCEL_BATCHES_PER_SEC_HIGH; - uint32_t SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH; - uint32_t SENSOR_GYRO_BATCHES_PER_SEC_HIGH; - uint32_t SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH; - uint32_t SENSOR_CONTROL_MODE; - uint32_t SENSOR_USAGE; - uint32_t SENSOR_ALGORITHM_CONFIG_MASK; - uint8_t ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID; - double ACCEL_RANDOM_WALK_SPECTRAL_DENSITY; - uint8_t ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID; - double ANGLE_RANDOM_WALK_SPECTRAL_DENSITY; - uint8_t RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID; - double RATE_RANDOM_WALK_SPECTRAL_DENSITY; - uint8_t VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID; - double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY; - uint32_t SENSOR_PROVIDER; -} loc_sap_cfg_s_type; - -extern loc_gps_cfg_s_type gps_conf; -extern loc_sap_cfg_s_type sap_conf; - - -uint32_t getCarrierCapabilities(); - -//loc_eng functions -int loc_eng_init(loc_eng_data_s_type &loc_eng_data, - LocCallbacks* callbacks, - LOC_API_ADAPTER_EVENT_MASK_T event, - ContextBase* context); -int loc_eng_start(loc_eng_data_s_type &loc_eng_data); -int loc_eng_stop(loc_eng_data_s_type &loc_eng_data); -void loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data); -int loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data, - GpsUtcTime time, int64_t timeReference, - int uncertainty); -int loc_eng_inject_location(loc_eng_data_s_type &loc_eng_data, - double latitude, double longitude, - float accuracy); -void loc_eng_delete_aiding_data(loc_eng_data_s_type &loc_eng_data, - GpsAidingData f); -int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data, - LocPosMode ¶ms); -const void* loc_eng_get_extension(loc_eng_data_s_type &loc_eng_data, - const char* name); -int loc_eng_set_server_proxy(loc_eng_data_s_type &loc_eng_data, - LocServerType type, const char *hostname, int port); -void loc_eng_mute_one_session(loc_eng_data_s_type &loc_eng_data); -int loc_eng_read_config(void); - -//loc_eng_agps functions -void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, - AGpsExtCallbacks* callbacks); -int loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType, - const char* apn, AGpsBearerType bearerType); -int loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType); -int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType); -void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data, - int avaiable, const char* apn); -int loc_eng_agps_install_certificates(loc_eng_data_s_type &loc_eng_data, - const DerEncodedCertificate* certificates, - size_t length); - -//loc_eng_xtra functions -int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data, - GpsXtraExtCallbacks* callbacks); -int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data, - char* data, int length); -int loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data); -void loc_eng_xtra_version_check(loc_eng_data_s_type &loc_eng_data, int check); - -//loc_eng_ni functions -extern void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, - GpsNiExtCallbacks *callbacks); -extern void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data, - int notif_id, GpsUserResponseType user_response); -extern void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data, - const GpsNiNotification *notif, - const void* passThrough); -extern void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data); - -void loc_eng_configuration_update (loc_eng_data_s_type &loc_eng_data, - const char* config_data, int32_t length); -int loc_eng_gps_measurement_init(loc_eng_data_s_type &loc_eng_data, - GpsMeasurementCallbacks* callbacks); -void loc_eng_gps_measurement_close(loc_eng_data_s_type &loc_eng_data); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif // LOC_ENG_H diff --git a/gps/loc_api/libloc_api_50001/loc_eng_agps.cpp b/gps/loc_api/libloc_api_50001/loc_eng_agps.cpp deleted file mode 100644 index 5016b5c..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_agps.cpp +++ /dev/null @@ -1,970 +0,0 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_eng" - -#include -#include -#include -#include -#include -#include -#include - -//====================================================================== -// C callbacks -//====================================================================== - -// This is given to linked_list_add as the dealloc callback -// data -- an instance of Subscriber -static void deleteObj(void* data) -{ - delete (Subscriber*)data; -} - -// This is given to linked_list_search() as the comparison callback -// when the state manchine needs to process for particular subscriber -// fromCaller -- caller provides this obj -// fromList -- linked_list_search() function take this one from list -static bool hasSubscriber(void* fromCaller, void* fromList) -{ - Notification* notification = (Notification*)fromCaller; - Subscriber* s1 = (Subscriber*)fromList; - - return s1->forMe(*notification); -} - -// This is gvien to linked_list_search() to notify subscriber objs -// when the state machine needs to inform all subscribers of resource -// status changes, e.g. when resource is GRANTED. -// fromCaller -- caller provides this ptr to a Notification obj. -// fromList -- linked_list_search() function take this one from list -static bool notifySubscriber(void* fromCaller, void* fromList) -{ - Notification* notification = (Notification*)fromCaller; - Subscriber* s1 = (Subscriber*)fromList; - - // we notify every subscriber indiscriminatively - // each subscriber decides if this notification is interesting. - return s1->notifyRsrcStatus(*notification) && - // if we do not want to delete the subscriber from the - // the list, we must set this to false so this function - // returns false - notification->postNotifyDelete; -} - -//====================================================================== -// Notification -//====================================================================== -const int Notification::BROADCAST_ALL = 0x80000000; -const int Notification::BROADCAST_ACTIVE = 0x80000001; -const int Notification::BROADCAST_INACTIVE = 0x80000002; -const unsigned char DSStateMachine::MAX_START_DATA_CALL_RETRIES = 4; -const unsigned int DSStateMachine::DATA_CALL_RETRY_DELAY_MSEC = 500; -//====================================================================== -// Subscriber: BITSubscriber / ATLSubscriber / WIFISubscriber -//====================================================================== -bool Subscriber::forMe(Notification ¬ification) -{ - if (NULL != notification.rcver) { - return equals(notification.rcver); - } else { - return Notification::BROADCAST_ALL == notification.groupID || - (Notification::BROADCAST_ACTIVE == notification.groupID && - !isInactive()) || - (Notification::BROADCAST_INACTIVE == notification.groupID && - isInactive()); - } -} -bool BITSubscriber::equals(const Subscriber *s) const -{ - BITSubscriber* bitS = (BITSubscriber*)s; - - return (ID == bitS->ID && - (INADDR_NONE != (unsigned int)ID || - 0 == strncmp(mIPv6Addr, bitS->mIPv6Addr, sizeof(mIPv6Addr)))); -} - -bool BITSubscriber::notifyRsrcStatus(Notification ¬ification) -{ - bool notify = forMe(notification); - - if (notify) { - switch(notification.rsrcStatus) - { - case RSRC_UNSUBSCRIBE: - case RSRC_RELEASED: - loc_eng_dmn_conn_loc_api_server_data_conn( - LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, - GPSONE_LOC_API_IF_RELEASE_SUCCESS); - break; - case RSRC_DENIED: - loc_eng_dmn_conn_loc_api_server_data_conn( - LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, - GPSONE_LOC_API_IF_FAILURE); - break; - case RSRC_GRANTED: - loc_eng_dmn_conn_loc_api_server_data_conn( - LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, - GPSONE_LOC_API_IF_REQUEST_SUCCESS); - break; - default: - notify = false; - } - } - - return notify; -} - -bool ATLSubscriber::notifyRsrcStatus(Notification ¬ification) -{ - bool notify = forMe(notification); - - if (notify) { - switch(notification.rsrcStatus) - { - case RSRC_UNSUBSCRIBE: - case RSRC_RELEASED: - ((LocEngAdapter*)mLocAdapter)->atlCloseStatus(ID, 1); - break; - case RSRC_DENIED: - { - AGpsExtType type = mBackwardCompatibleMode ? - AGPS_TYPE_INVALID : mStateMachine->getType(); - ((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 0, - (char*)mStateMachine->getAPN(), - mStateMachine->getBearer(), - type); - } - break; - case RSRC_GRANTED: - { - AGpsExtType type = mBackwardCompatibleMode ? - AGPS_TYPE_INVALID : mStateMachine->getType(); - ((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 1, - (char*)mStateMachine->getAPN(), - mStateMachine->getBearer(), - type); - } - break; - default: - notify = false; - } - } - - return notify; -} - -bool WIFISubscriber::notifyRsrcStatus(Notification ¬ification) -{ - bool notify = forMe(notification); - - if (notify) { - switch(notification.rsrcStatus) - { - case RSRC_UNSUBSCRIBE: - break; - case RSRC_RELEASED: - loc_eng_dmn_conn_loc_api_server_data_conn( - senderId, - GPSONE_LOC_API_IF_RELEASE_SUCCESS); - break; - case RSRC_DENIED: - loc_eng_dmn_conn_loc_api_server_data_conn( - senderId, - GPSONE_LOC_API_IF_FAILURE); - break; - case RSRC_GRANTED: - loc_eng_dmn_conn_loc_api_server_data_conn( - senderId, - GPSONE_LOC_API_IF_REQUEST_SUCCESS); - break; - default: - notify = false; - } - } - - return notify; -} -bool DSSubscriber::notifyRsrcStatus(Notification ¬ification) -{ - bool notify = forMe(notification); - LOC_LOGD("DSSubscriber::notifyRsrcStatus. notify:%d \n",(int)(notify)); - if(notify) { - switch(notification.rsrcStatus) { - case RSRC_UNSUBSCRIBE: - case RSRC_RELEASED: - case RSRC_DENIED: - case RSRC_GRANTED: - ((DSStateMachine *)mStateMachine)->informStatus(notification.rsrcStatus, ID); - break; - default: - notify = false; - } - } - return notify; -} -void DSSubscriber :: setInactive() -{ - mIsInactive = true; - ((DSStateMachine *)mStateMachine)->informStatus(RSRC_UNSUBSCRIBE, ID); -} -//====================================================================== -// AgpsState: AgpsReleasedState / AgpsPendingState / AgpsAcquiredState -//====================================================================== - -// AgpsReleasedState -class AgpsReleasedState : public AgpsState -{ - friend class AgpsStateMachine; - - inline AgpsReleasedState(AgpsStateMachine* stateMachine) : - AgpsState(stateMachine) - { mReleasedState = this; } - - inline ~AgpsReleasedState() {} -public: - virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data); - inline virtual char* whoami() {return (char*)"AgpsReleasedState";} -}; - -AgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data) -{ - LOC_LOGD("AgpsReleasedState::onRsrcEvent; event:%d\n", (int)event); - if (mStateMachine->hasSubscribers()) { - LOC_LOGE("Error: %s subscriber list not empty!!!", whoami()); - // I don't know how to recover from it. I am adding this rather - // for debugging purpose. - } - - AgpsState* nextState = this; - switch (event) - { - case RSRC_SUBSCRIBE: - { - // no notification until we get RSRC_GRANTED - // but we need to add subscriber to the list - mStateMachine->addSubscriber((Subscriber*)data); - // request from connecivity service for NIF - //The if condition is added so that if the data call setup fails - //for DS State Machine, we want to retry in released state. - //for AGps State Machine, sendRsrcRequest() will always return success - if(!mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN)) { - // move the state to PENDING - nextState = mPendingState; - } - } - break; - - case RSRC_UNSUBSCRIBE: - { - // the list should really be empty, nothing to remove. - // but we might as well just tell the client it is - // unsubscribed. False tolerance, right? - Subscriber* subscriber = (Subscriber*) data; - Notification notification(subscriber, event, false); - subscriber->notifyRsrcStatus(notification); - } - // break; - case RSRC_GRANTED: - case RSRC_RELEASED: - case RSRC_DENIED: - default: - LOC_LOGW("%s: unrecognized event %d", whoami(), event); - // no state change. - break; - } - - LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d", - whoami(), nextState->whoami(), event); - return nextState; -} - -// AgpsPendingState -class AgpsPendingState : public AgpsState -{ - friend class AgpsStateMachine; - - inline AgpsPendingState(AgpsStateMachine* stateMachine) : - AgpsState(stateMachine) - { mPendingState = this; } - - inline ~AgpsPendingState() {} -public: - virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data); - inline virtual char* whoami() {return (char*)"AgpsPendingState";} -}; - -AgpsState* AgpsPendingState::onRsrcEvent(AgpsRsrcStatus event, void* data) -{ - AgpsState* nextState = this;; - LOC_LOGD("AgpsPendingState::onRsrcEvent; event:%d\n", (int)event); - switch (event) - { - case RSRC_SUBSCRIBE: - { - // already requested for NIF resource, - // do nothing until we get RSRC_GRANTED indication - // but we need to add subscriber to the list - mStateMachine->addSubscriber((Subscriber*)data); - // no state change. - } - break; - - case RSRC_UNSUBSCRIBE: - { - Subscriber* subscriber = (Subscriber*) data; - if (subscriber->waitForCloseComplete()) { - subscriber->setInactive(); - } else { - // auto notify this subscriber of the unsubscribe - Notification notification(subscriber, event, true); - mStateMachine->notifySubscribers(notification); - } - - // now check if there is any subscribers left - if (!mStateMachine->hasSubscribers()) { - // no more subscribers, move to RELEASED state - nextState = mReleasedState; - - // tell connecivity service we can release NIF - mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN); - } else if (!mStateMachine->hasActiveSubscribers()) { - // only inactive subscribers, move to RELEASING state - nextState = mReleasingState; - - // tell connecivity service we can release NIF - mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN); - } - } - break; - - case RSRC_GRANTED: - { - nextState = mAcquiredState; - Notification notification(Notification::BROADCAST_ACTIVE, event, false); - // notify all subscribers NIF resource GRANTED - // by setting false, we keep subscribers on the linked list - mStateMachine->notifySubscribers(notification); - } - break; - - case RSRC_RELEASED: - // no state change. - // we are expecting either GRANTED or DENIED. Handling RELEASED - // may like break our state machine in race conditions. - break; - - case RSRC_DENIED: - { - nextState = mReleasedState; - Notification notification(Notification::BROADCAST_ALL, event, true); - // notify all subscribers NIF resource RELEASED or DENIED - // by setting true, we remove subscribers from the linked list - mStateMachine->notifySubscribers(notification); - } - break; - - default: - LOC_LOGE("%s: unrecognized event %d", whoami(), event); - // no state change. - } - - LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d", - whoami(), nextState->whoami(), event); - return nextState; -} - - -class AgpsAcquiredState : public AgpsState -{ - friend class AgpsStateMachine; - - inline AgpsAcquiredState(AgpsStateMachine* stateMachine) : - AgpsState(stateMachine) - { mAcquiredState = this; } - - inline ~AgpsAcquiredState() {} -public: - virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data); - inline virtual char* whoami() { return (char*)"AgpsAcquiredState"; } -}; - - -AgpsState* AgpsAcquiredState::onRsrcEvent(AgpsRsrcStatus event, void* data) -{ - AgpsState* nextState = this; - LOC_LOGD("AgpsAcquiredState::onRsrcEvent; event:%d\n", (int)event); - switch (event) - { - case RSRC_SUBSCRIBE: - { - // we already have the NIF resource, simply notify subscriber - Subscriber* subscriber = (Subscriber*) data; - // we have rsrc in hand, so grant it right away - Notification notification(subscriber, RSRC_GRANTED, false); - subscriber->notifyRsrcStatus(notification); - // add subscriber to the list - mStateMachine->addSubscriber(subscriber); - // no state change. - } - break; - - case RSRC_UNSUBSCRIBE: - { - Subscriber* subscriber = (Subscriber*) data; - if (subscriber->waitForCloseComplete()) { - subscriber->setInactive(); - } else { - // auto notify this subscriber of the unsubscribe - Notification notification(subscriber, event, true); - mStateMachine->notifySubscribers(notification); - } - - // now check if there is any subscribers left - if (!mStateMachine->hasSubscribers()) { - // no more subscribers, move to RELEASED state - nextState = mReleasedState; - - // tell connecivity service we can release NIF - mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN); - } else if (!mStateMachine->hasActiveSubscribers()) { - // only inactive subscribers, move to RELEASING state - nextState = mReleasingState; - - // tell connecivity service we can release NIF - mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN); - } - } - break; - - case RSRC_GRANTED: - LOC_LOGW("%s: %d, RSRC_GRANTED already received", whoami(), event); - // no state change. - break; - - case RSRC_RELEASED: - { - LOC_LOGW("%s: %d, a force rsrc release", whoami(), event); - nextState = mReleasedState; - Notification notification(Notification::BROADCAST_ALL, event, true); - // by setting true, we remove subscribers from the linked list - mStateMachine->notifySubscribers(notification); - } - break; - - case RSRC_DENIED: - // no state change. - // we are expecting RELEASED. Handling DENIED - // may like break our state machine in race conditions. - break; - - default: - LOC_LOGE("%s: unrecognized event %d", whoami(), event); - // no state change. - } - - LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d", - whoami(), nextState->whoami(), event); - return nextState; -} - -// AgpsPendingState -class AgpsReleasingState : public AgpsState -{ - friend class AgpsStateMachine; - - inline AgpsReleasingState(AgpsStateMachine* stateMachine) : - AgpsState(stateMachine) - { mReleasingState = this; } - - inline ~AgpsReleasingState() {} -public: - virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data); - inline virtual char* whoami() {return (char*)"AgpsReleasingState";} -}; - -AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data) -{ - AgpsState* nextState = this;; - LOC_LOGD("AgpsReleasingState::onRsrcEvent; event:%d\n", (int)event); - - switch (event) - { - case RSRC_SUBSCRIBE: - { - // already requested for NIF resource, - // do nothing until we get RSRC_GRANTED indication - // but we need to add subscriber to the list - mStateMachine->addSubscriber((Subscriber*)data); - // no state change. - } - break; - - case RSRC_UNSUBSCRIBE: - { - Subscriber* subscriber = (Subscriber*) data; - if (subscriber->waitForCloseComplete()) { - subscriber->setInactive(); - } else { - // auto notify this subscriber of the unsubscribe - Notification notification(subscriber, event, true); - mStateMachine->notifySubscribers(notification); - } - - // now check if there is any subscribers left - if (!mStateMachine->hasSubscribers()) { - // no more subscribers, move to RELEASED state - nextState = mReleasedState; - } - } - break; - - case RSRC_DENIED: - // A race condition subscriber unsubscribes before AFW denies resource. - case RSRC_RELEASED: - { - nextState = mAcquiredState; - Notification notification(Notification::BROADCAST_INACTIVE, event, true); - // notify all subscribers that are active NIF resource RELEASE - // by setting false, we keep subscribers on the linked list - mStateMachine->notifySubscribers(notification); - - if (mStateMachine->hasActiveSubscribers()) { - nextState = mPendingState; - // request from connecivity service for NIF - mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN); - } else { - nextState = mReleasedState; - } - } - break; - - case RSRC_GRANTED: - default: - LOC_LOGE("%s: unrecognized event %d", whoami(), event); - // no state change. - } - - LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d", - whoami(), nextState->whoami(), event); - return nextState; -} -//====================================================================== -//Servicer -//====================================================================== -Servicer* Servicer :: getServicer(servicerType type, void *cb_func) -{ - LOC_LOGD(" Enter getServicer type:%d\n", (int)type); - switch(type) { - case servicerTypeNoCbParam: - return (new Servicer(cb_func)); - case servicerTypeExt: - return (new ExtServicer(cb_func)); - case servicerTypeAgps: - return (new AGpsServicer(cb_func)); - default: - return NULL; - } -} - -int Servicer :: requestRsrc(void *cb_data) -{ - callback(); - return 0; -} - -int ExtServicer :: requestRsrc(void *cb_data) -{ - int ret=-1; - LOC_LOGD("Enter ExtServicer :: requestRsrc\n"); - ret = callbackExt(cb_data); - LOC_LOGD("Exit ExtServicer :: requestRsrc\n"); - return(ret); -} - -int AGpsServicer :: requestRsrc(void *cb_data) -{ - callbackAGps((AGpsStatus *)cb_data); - return 0; -} - -//====================================================================== -// AgpsStateMachine -//====================================================================== - -AgpsStateMachine::AgpsStateMachine(servicerType servType, - void *cb_func, - AGpsExtType type, - bool enforceSingleSubscriber) : - mStatePtr(new AgpsReleasedState(this)),mType(type), - mAPN(NULL), - mAPNLen(0), - mBearer(AGPS_APN_BEARER_INVALID), - mEnforceSingleSubscriber(enforceSingleSubscriber), - mServicer(Servicer :: getServicer(servType, (void *)cb_func)) -{ - linked_list_init(&mSubscribers); - - // setting up mReleasedState - mStatePtr->mPendingState = new AgpsPendingState(this); - mStatePtr->mAcquiredState = new AgpsAcquiredState(this); - mStatePtr->mReleasingState = new AgpsReleasingState(this); - - // setting up mAcquiredState - mStatePtr->mAcquiredState->mReleasedState = mStatePtr; - mStatePtr->mAcquiredState->mPendingState = mStatePtr->mPendingState; - mStatePtr->mAcquiredState->mReleasingState = mStatePtr->mReleasingState; - - // setting up mPendingState - mStatePtr->mPendingState->mAcquiredState = mStatePtr->mAcquiredState; - mStatePtr->mPendingState->mReleasedState = mStatePtr; - mStatePtr->mPendingState->mReleasingState = mStatePtr->mReleasingState; - - // setting up mReleasingState - mStatePtr->mReleasingState->mReleasedState = mStatePtr; - mStatePtr->mReleasingState->mPendingState = mStatePtr->mPendingState; - mStatePtr->mReleasingState->mAcquiredState = mStatePtr->mAcquiredState; -} - -AgpsStateMachine::~AgpsStateMachine() -{ - dropAllSubscribers(); - - // free the 3 states. We must read out all 3 pointers first. - // Otherwise we run the risk of getting pointers from already - // freed memory. - AgpsState* acquiredState = mStatePtr->mAcquiredState; - AgpsState* releasedState = mStatePtr->mReleasedState; - AgpsState* pendindState = mStatePtr->mPendingState; - AgpsState* releasingState = mStatePtr->mReleasingState; - - delete acquiredState; - delete releasedState; - delete pendindState; - delete releasingState; - delete mServicer; - linked_list_destroy(&mSubscribers); - - if (NULL != mAPN) { - delete[] mAPN; - mAPN = NULL; - } -} - -void AgpsStateMachine::setAPN(const char* apn, unsigned int len) -{ - if (NULL != mAPN) { - delete mAPN; - } - - if (NULL != apn) { - mAPN = new char[len+1]; - memcpy(mAPN, apn, len); - mAPN[len] = NULL; - - mAPNLen = len; - } else { - mAPN = NULL; - mAPNLen = 0; - } -} - -void AgpsStateMachine::onRsrcEvent(AgpsRsrcStatus event) -{ - switch (event) - { - case RSRC_GRANTED: - case RSRC_RELEASED: - case RSRC_DENIED: - mStatePtr = mStatePtr->onRsrcEvent(event, NULL); - break; - default: - LOC_LOGW("AgpsStateMachine: unrecognized event %d", event); - break; - } -} - -void AgpsStateMachine::notifySubscribers(Notification& notification) const -{ - if (notification.postNotifyDelete) { - // just any non NULL value to get started - Subscriber* s = (Subscriber*)~0; - while (NULL != s) { - s = NULL; - // if the last param sets to true, _search will delete - // the node from the list for us. But the problem is - // once that is done, _search returns, leaving the - // rest of the list unprocessed. So we need a loop. - linked_list_search(mSubscribers, (void**)&s, notifySubscriber, - (void*)¬ification, true); - delete s; - } - } else { - // no loop needed if it the last param sets to false, which - // mean nothing gets deleted from the list. - linked_list_search(mSubscribers, NULL, notifySubscriber, - (void*)¬ification, false); - } -} - -void AgpsStateMachine::addSubscriber(Subscriber* subscriber) const -{ - Subscriber* s = NULL; - Notification notification((const Subscriber*)subscriber); - linked_list_search(mSubscribers, (void**)&s, - hasSubscriber, (void*)¬ification, false); - - if (NULL == s) { - linked_list_add(mSubscribers, subscriber->clone(), deleteObj); - } -} - -int AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const -{ - Subscriber* s = NULL; - Notification notification(Notification::BROADCAST_ACTIVE); - linked_list_search(mSubscribers, (void**)&s, hasSubscriber, - (void*)¬ification, false); - - if ((NULL == s) == (GPS_RELEASE_AGPS_DATA_CONN == action)) { - AGpsExtStatus nifRequest; - nifRequest.size = sizeof(nifRequest); - nifRequest.type = mType; - nifRequest.status = action; - - if (s == NULL) { - nifRequest.ipv4_addr = INADDR_NONE; - memset(&nifRequest.addr, 0, sizeof(nifRequest.addr)); - nifRequest.ssid[0] = '\0'; - nifRequest.password[0] = '\0'; - } else { - s->setIPAddresses(nifRequest.addr); - s->setWifiInfo(nifRequest.ssid, nifRequest.password); - } - - CALLBACK_LOG_CALLFLOW("agps_cb", %s, loc_get_agps_status_name(action)); - mServicer->requestRsrc((void *)&nifRequest); - } - return 0; -} - -void AgpsStateMachine::subscribeRsrc(Subscriber *subscriber) -{ - if (mEnforceSingleSubscriber && hasSubscribers()) { - Notification notification(Notification::BROADCAST_ALL, RSRC_DENIED, true); - notifySubscriber(¬ification, subscriber); - } else { - mStatePtr = mStatePtr->onRsrcEvent(RSRC_SUBSCRIBE, (void*)subscriber); - } -} - -bool AgpsStateMachine::unsubscribeRsrc(Subscriber *subscriber) -{ - Subscriber* s = NULL; - Notification notification((const Subscriber*)subscriber); - linked_list_search(mSubscribers, (void**)&s, - hasSubscriber, (void*)¬ification, false); - - if (NULL != s) { - mStatePtr = mStatePtr->onRsrcEvent(RSRC_UNSUBSCRIBE, (void*)s); - return true; - } - return false; -} - -bool AgpsStateMachine::hasActiveSubscribers() const -{ - Subscriber* s = NULL; - Notification notification(Notification::BROADCAST_ACTIVE); - linked_list_search(mSubscribers, (void**)&s, - hasSubscriber, (void*)¬ification, false); - return NULL != s; -} - -//====================================================================== -// DSStateMachine -//====================================================================== -void delay_callback(void *callbackData, int result) -{ - if(callbackData) { - DSStateMachine *DSSMInstance = (DSStateMachine *)callbackData; - DSSMInstance->retryCallback(); - } - else { - LOC_LOGE(" NULL argument received. Failing.\n"); - goto err; - } -err: - return; -} - -DSStateMachine :: DSStateMachine(servicerType type, void *cb_func, - LocEngAdapter* adapterHandle): - AgpsStateMachine(type, cb_func, AGPS_TYPE_INVALID,false), - mLocAdapter(adapterHandle) -{ - LOC_LOGD("%s:%d]: New DSStateMachine\n", __func__, __LINE__); - mRetries = 0; -} - -void DSStateMachine :: retryCallback(void) -{ - DSSubscriber *subscriber = NULL; - Notification notification(Notification::BROADCAST_ACTIVE); - linked_list_search(mSubscribers, (void**)&subscriber, hasSubscriber, - (void*)¬ification, false); - if(subscriber) - mLocAdapter->requestSuplES(subscriber->ID); - else - LOC_LOGE("DSStateMachine :: retryCallback: No subscriber found." \ - "Cannot retry data call\n"); - return; -} - -int DSStateMachine :: sendRsrcRequest(AGpsStatusValue action) const -{ - DSSubscriber* s = NULL; - dsCbData cbData; - int ret=-1; - int connHandle=-1; - LOC_LOGD("Enter DSStateMachine :: sendRsrcRequest\n"); - Notification notification(Notification::BROADCAST_ACTIVE); - linked_list_search(mSubscribers, (void**)&s, hasSubscriber, - (void*)¬ification, false); - if(s) { - connHandle = s->ID; - LOC_LOGD("DSStateMachine :: sendRsrcRequest - subscriber found\n"); - } - else - LOC_LOGD("DSStateMachine :: sendRsrcRequest - No subscriber found\n"); - - cbData.action = action; - cbData.mAdapter = mLocAdapter; - ret = mServicer->requestRsrc((void *)&cbData); - //Only the request to start data call returns a success/failure - //The request to stop data call will always succeed - //Hence, the below block will only be executed when the - //request to start the data call fails - switch(ret) { - case LOC_API_ADAPTER_ERR_ENGINE_BUSY: - LOC_LOGD("DSStateMachine :: sendRsrcRequest - Failure returned: %d\n",ret); - ((DSStateMachine *)this)->incRetries(); - if(mRetries > MAX_START_DATA_CALL_RETRIES) { - LOC_LOGE(" Failed to start Data call. Fallback to normal ATL SUPL\n"); - informStatus(RSRC_DENIED, connHandle); - } - else { - if(loc_timer_start(DATA_CALL_RETRY_DELAY_MSEC, delay_callback, (void *)this)) { - LOC_LOGE("Error: Could not start delay thread\n"); - ret = -1; - goto err; - } - } - break; - case LOC_API_ADAPTER_ERR_UNSUPPORTED: - LOC_LOGE("No profile found for emergency call. Fallback to normal SUPL ATL\n"); - informStatus(RSRC_DENIED, connHandle); - break; - case LOC_API_ADAPTER_ERR_SUCCESS: - LOC_LOGD("%s:%d]: Request to start data call sent\n", __func__, __LINE__); - break; - case -1: - //One of the ways this case can be encountered is if the callback function - //receives a null argument, it just exits with -1 error - LOC_LOGE("Error: Something went wrong somewhere. Falling back to normal SUPL ATL\n"); - informStatus(RSRC_DENIED, connHandle); - break; - default: - LOC_LOGE("%s:%d]: Unrecognized return value\n", __func__, __LINE__); - } -err: - LOC_LOGD("EXIT DSStateMachine :: sendRsrcRequest; ret = %d\n", ret); - return ret; -} - -void DSStateMachine :: onRsrcEvent(AgpsRsrcStatus event) -{ - void* currState = (void *)mStatePtr; - LOC_LOGD("Enter DSStateMachine :: onRsrcEvent. event = %d\n", (int)event); - switch (event) - { - case RSRC_GRANTED: - LOC_LOGD("DSStateMachine :: onRsrcEvent RSRC_GRANTED\n"); - mStatePtr = mStatePtr->onRsrcEvent(event, NULL); - break; - case RSRC_RELEASED: - LOC_LOGD("DSStateMachine :: onRsrcEvent RSRC_RELEASED\n"); - mStatePtr = mStatePtr->onRsrcEvent(event, NULL); - //To handle the case where we get a RSRC_RELEASED in - //pending state, we translate that to a RSRC_DENIED state - //since the callback from DSI is either RSRC_GRANTED or RSRC_RELEASED - //for when the call is connected or disconnected respectively. - if((void *)mStatePtr != currState) - break; - else { - event = RSRC_DENIED; - LOC_LOGE(" Switching event to RSRC_DENIED\n"); - } - case RSRC_DENIED: - mStatePtr = mStatePtr->onRsrcEvent(event, NULL); - break; - default: - LOC_LOGW("AgpsStateMachine: unrecognized event %d", event); - break; - } - LOC_LOGD("Exit DSStateMachine :: onRsrcEvent. event = %d\n", (int)event); -} - -void DSStateMachine :: informStatus(AgpsRsrcStatus status, int ID) const -{ - LOC_LOGD("DSStateMachine :: informStatus. Status=%d\n",(int)status); - switch(status) { - case RSRC_UNSUBSCRIBE: - mLocAdapter->atlCloseStatus(ID, 1); - break; - case RSRC_RELEASED: - mLocAdapter->closeDataCall(); - break; - case RSRC_DENIED: - ((DSStateMachine *)this)->mRetries = 0; - mLocAdapter->requestATL(ID, AGPS_TYPE_SUPL); - break; - case RSRC_GRANTED: - mLocAdapter->atlOpenStatus(ID, 1, - NULL, - AGPS_APN_BEARER_INVALID, - AGPS_TYPE_INVALID); - break; - default: - LOC_LOGW("DSStateMachine :: informStatus - unknown status"); - } - return; -} diff --git a/gps/loc_api/libloc_api_50001/loc_eng_agps.h b/gps/loc_api/libloc_api_50001/loc_eng_agps.h deleted file mode 100644 index 2d689ce..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_agps.h +++ /dev/null @@ -1,431 +0,0 @@ -/* Copyright (c) 2011-2013, 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_ENG_AGPS_H__ -#define __LOC_ENG_AGPS_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// forward declaration -class AgpsStateMachine; -class Subscriber; - -// NIF resource events -typedef enum { - RSRC_SUBSCRIBE, - RSRC_UNSUBSCRIBE, - RSRC_GRANTED, - RSRC_RELEASED, - RSRC_DENIED, - RSRC_STATUS_MAX -} AgpsRsrcStatus; - -typedef enum { - servicerTypeNoCbParam, - servicerTypeAgps, - servicerTypeExt -}servicerType; - -//DS Callback struct -typedef struct { - LocEngAdapter *mAdapter; - AGpsStatusValue action; -}dsCbData; - -// information bundle for subscribers -struct Notification { - // goes to every subscriber - static const int BROADCAST_ALL; - // goes to every ACTIVE subscriber - static const int BROADCAST_ACTIVE; - // goes to every INACTIVE subscriber - static const int BROADCAST_INACTIVE; - - // go to a specific subscriber - const Subscriber* rcver; - // broadcast - const int groupID; - // the new resource status event - const AgpsRsrcStatus rsrcStatus; - // should the subscriber be deleted after the notification - const bool postNotifyDelete; - - // convenient constructor - inline Notification(const int broadcast, - const AgpsRsrcStatus status, - const bool deleteAfterwards) : - rcver(NULL), groupID(broadcast), rsrcStatus(status), - postNotifyDelete(deleteAfterwards) {} - - // convenient constructor - inline Notification(const Subscriber* subscriber, - const AgpsRsrcStatus status, - const bool deleteAfterwards) : - rcver(subscriber), groupID(-1), rsrcStatus(status), - postNotifyDelete(deleteAfterwards) {} - - // convenient constructor - inline Notification(const int broadcast) : - rcver(NULL), groupID(broadcast), rsrcStatus(RSRC_STATUS_MAX), - postNotifyDelete(false) {} - - // convenient constructor - inline Notification(const Subscriber* subscriber) : - rcver(subscriber), groupID(-1), rsrcStatus(RSRC_STATUS_MAX), - postNotifyDelete(false) {} -}; - -class AgpsState { - // allows AgpsStateMachine to access private data - // no class members are public. We don't want - // anyone but state machine to use state. - friend class AgpsStateMachine; - friend class DSStateMachine; - // state transitions are done here. - // Each state implements its own transitions (of course). - inline virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data) = 0; - -protected: - // handle back to state machine - const AgpsStateMachine* mStateMachine; - // each state has pointers to all 3 states - // one of which is to itself. - AgpsState* mReleasedState; - AgpsState* mAcquiredState; - AgpsState* mPendingState; - AgpsState* mReleasingState; - - inline AgpsState(const AgpsStateMachine *stateMachine) : - mStateMachine(stateMachine), - mReleasedState(NULL), - mAcquiredState(NULL), - mPendingState(NULL), - mReleasingState(NULL) {} - virtual ~AgpsState() {} - -public: - // for logging purpose - inline virtual char* whoami() = 0; -}; - -class Servicer { - void (*callback)(void); -public: - static Servicer* getServicer(servicerType type, void *cb_func); - virtual int requestRsrc(void *cb_data); - Servicer() {} - Servicer(void *cb_func) - { callback = (void(*)(void))(cb_func); } - virtual ~Servicer(){} - inline virtual char *whoami() {return (char*)"Servicer";} -}; - -class ExtServicer : public Servicer { - int (*callbackExt)(void *cb_data); -public: - int requestRsrc(void *cb_data); - ExtServicer() {} - ExtServicer(void *cb_func) - { callbackExt = (int(*)(void *))(cb_func); } - virtual ~ExtServicer(){} - inline virtual char *whoami() {return (char*)"ExtServicer";} -}; - -class AGpsServicer : public Servicer { - void (*callbackAGps)(AGpsStatus* status); -public: - int requestRsrc(void *cb_data); - AGpsServicer() {} - AGpsServicer(void *cb_func) - { callbackAGps = (void(*)(AGpsStatus *))(cb_func); } - virtual ~AGpsServicer(){} - inline virtual char *whoami() {return (char*)"AGpsServicer";} -}; - -class AgpsStateMachine { -protected: - // a linked list of subscribers. - void* mSubscribers; - //handle to whoever provides the service - Servicer *mServicer; - // allows AgpsState to access private data - // each state is really internal data to the - // state machine, so it should be able to - // access anything within the state machine. - friend class AgpsState; - // pointer to the current state. - AgpsState* mStatePtr; -private: - // NIF type: AGNSS or INTERNET. - const AGpsExtType mType; - // apn to the NIF. Each state machine tracks - // resource state of a particular NIF. For each - // NIF, there is also an active APN. - char* mAPN; - // for convenience, we don't do strlen each time. - unsigned int mAPNLen; - // bear - AGpsBearerType mBearer; - // ipv4 address for routing - bool mEnforceSingleSubscriber; - -public: - AgpsStateMachine(servicerType servType, void *cb_func, - AGpsExtType type, bool enforceSingleSubscriber); - virtual ~AgpsStateMachine(); - - // self explanatory methods below - void setAPN(const char* apn, unsigned int len); - inline const char* getAPN() const { return (const char*)mAPN; } - inline void setBearer(AGpsBearerType bearer) { mBearer = bearer; } - inline AGpsBearerType getBearer() const { return mBearer; } - inline AGpsExtType getType() const { return (AGpsExtType)mType; } - - // someone, a ATL client or BIT, is asking for NIF - void subscribeRsrc(Subscriber *subscriber); - - // someone, a ATL client or BIT, is done with NIF - bool unsubscribeRsrc(Subscriber *subscriber); - - // add a subscriber in the linked list, if not already there. - void addSubscriber(Subscriber* subscriber) const; - - virtual void onRsrcEvent(AgpsRsrcStatus event); - - // put the data together and send the FW - virtual int sendRsrcRequest(AGpsStatusValue action) const; - - //if list is empty, linked_list_empty returns 1 - //else if list is not empty, returns 0 - //so hasSubscribers() returns 1 if list is not empty - //and returns 0 if list is empty - inline bool hasSubscribers() const - { return !linked_list_empty(mSubscribers); } - - bool hasActiveSubscribers() const; - - inline void dropAllSubscribers() const - { linked_list_flush(mSubscribers); } - - // private. Only a state gets to call this. - void notifySubscribers(Notification& notification) const; - -}; - -class DSStateMachine : public AgpsStateMachine { - static const unsigned char MAX_START_DATA_CALL_RETRIES; - static const unsigned int DATA_CALL_RETRY_DELAY_MSEC; - LocEngAdapter* mLocAdapter; - unsigned char mRetries; -public: - DSStateMachine(servicerType type, - void *cb_func, - LocEngAdapter* adapterHandle); - int sendRsrcRequest(AGpsStatusValue action) const; - void onRsrcEvent(AgpsRsrcStatus event); - void retryCallback(); - void informStatus(AgpsRsrcStatus status, int ID) const; - inline void incRetries() {mRetries++;} - inline virtual char *whoami() {return (char*)"DSStateMachine";} -}; - -// each subscriber is a AGPS client. In the case of ATL, there could be -// multiple clients from modem. In the case of BIT, there is only one -// cilent from BIT daemon. -struct Subscriber { - const uint32_t ID; - const AgpsStateMachine* mStateMachine; - inline Subscriber(const int id, - const AgpsStateMachine* stateMachine) : - ID(id), mStateMachine(stateMachine) {} - inline virtual ~Subscriber() {} - - virtual void setIPAddresses(uint32_t &v4, char* v6) = 0; - virtual void setIPAddresses(struct sockaddr_storage& addr) = 0; - inline virtual void setWifiInfo(char* ssid, char* password) - { ssid[0] = 0; password[0] = 0; } - - inline virtual bool equals(const Subscriber *s) const - { return ID == s->ID; } - - // notifies a subscriber a new NIF resource status, usually - // either GRANTE, DENIED, or RELEASED - virtual bool notifyRsrcStatus(Notification ¬ification) = 0; - - virtual bool waitForCloseComplete() { return false; } - virtual void setInactive() {} - virtual bool isInactive() { return false; } - - virtual Subscriber* clone() = 0; - // checks if this notification is for me, i.e. - // either has my id, or has a broadcast id. - bool forMe(Notification ¬ification); -}; - -// BITSubscriber, created with requests from BIT daemon -struct BITSubscriber : public Subscriber { - char mIPv6Addr[16]; - - inline BITSubscriber(const AgpsStateMachine* stateMachine, - unsigned int ipv4, char* ipv6) : - Subscriber(ipv4, stateMachine) - { - if (NULL == ipv6) { - mIPv6Addr[0] = 0; - } else { - memcpy(mIPv6Addr, ipv6, sizeof(mIPv6Addr)); - } - } - - virtual bool notifyRsrcStatus(Notification ¬ification); - - inline virtual void setIPAddresses(uint32_t &v4, char* v6) - { v4 = ID; memcpy(v6, mIPv6Addr, sizeof(mIPv6Addr)); } - - inline virtual void setIPAddresses(struct sockaddr_storage& addr) - { addr.ss_family = AF_INET6;/*todo: convert mIPv6Addr into addr */ } - - virtual Subscriber* clone() - { - return new BITSubscriber(mStateMachine, ID, mIPv6Addr); - } - - virtual bool equals(const Subscriber *s) const; - inline virtual ~BITSubscriber(){} -}; - -// ATLSubscriber, created with requests from ATL -struct ATLSubscriber : public Subscriber { - const LocEngAdapter* mLocAdapter; - const bool mBackwardCompatibleMode; - inline ATLSubscriber(const int id, - const AgpsStateMachine* stateMachine, - const LocEngAdapter* adapter, - const bool compatibleMode) : - Subscriber(id, stateMachine), mLocAdapter(adapter), - mBackwardCompatibleMode(compatibleMode){} - virtual bool notifyRsrcStatus(Notification ¬ification); - - inline virtual void setIPAddresses(uint32_t &v4, char* v6) - { v4 = INADDR_NONE; v6[0] = 0; } - - inline virtual void setIPAddresses(struct sockaddr_storage& addr) - { addr.ss_family = AF_INET6; } - - inline virtual Subscriber* clone() - { - return new ATLSubscriber(ID, mStateMachine, mLocAdapter, - mBackwardCompatibleMode); - } - inline virtual ~ATLSubscriber(){} -}; - -// WIFISubscriber, created with requests from MSAPM or QuIPC -struct WIFISubscriber : public Subscriber { - char * mSSID; - char * mPassword; - loc_if_req_sender_id_e_type senderId; - bool mIsInactive; - inline WIFISubscriber(const AgpsStateMachine* stateMachine, - char * ssid, char * password, loc_if_req_sender_id_e_type sender_id) : - Subscriber(sender_id, stateMachine), - mSSID(NULL == ssid ? NULL : new char[SSID_BUF_SIZE]), - mPassword(NULL == password ? NULL : new char[SSID_BUF_SIZE]), - senderId(sender_id) - { - if (NULL != mSSID) - strlcpy(mSSID, ssid, SSID_BUF_SIZE); - if (NULL != mPassword) - strlcpy(mPassword, password, SSID_BUF_SIZE); - mIsInactive = false; - } - - virtual bool notifyRsrcStatus(Notification ¬ification); - - inline virtual void setIPAddresses(uint32_t &v4, char* v6) {} - - inline virtual void setIPAddresses(struct sockaddr_storage& addr) - { addr.ss_family = AF_INET6; } - - inline virtual void setWifiInfo(char* ssid, char* password) - { - if (NULL != mSSID) - strlcpy(ssid, mSSID, SSID_BUF_SIZE); - else - ssid[0] = '\0'; - if (NULL != mPassword) - strlcpy(password, mPassword, SSID_BUF_SIZE); - else - password[0] = '\0'; - } - - inline virtual bool waitForCloseComplete() { return true; } - - inline virtual void setInactive() { mIsInactive = true; } - inline virtual bool isInactive() { return mIsInactive; } - - virtual Subscriber* clone() - { - return new WIFISubscriber(mStateMachine, mSSID, mPassword, senderId); - } - inline virtual ~WIFISubscriber(){} -}; - -struct DSSubscriber : public Subscriber { - bool mIsInactive; - inline DSSubscriber(const AgpsStateMachine *stateMachine, - const int id) : - Subscriber(id, stateMachine) - { - mIsInactive = false; - } - inline virtual void setIPAddresses(uint32_t &v4, char* v6) {} - inline virtual void setIPAddresses(struct sockaddr_storage& addr) - { addr.ss_family = AF_INET6; } - virtual Subscriber* clone() - {return new DSSubscriber(mStateMachine, ID);} - virtual bool notifyRsrcStatus(Notification ¬ification); - inline virtual bool waitForCloseComplete() { return true; } - virtual void setInactive(); - inline virtual bool isInactive() - { return mIsInactive; } - inline virtual ~DSSubscriber(){} - inline virtual char *whoami() {return (char*)"DSSubscriber";} -}; - -#endif //__LOC_ENG_AGPS_H__ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp deleted file mode 100644 index c257dff..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* Copyright (c) 2011-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include "log_util.h" -#include "platform_lib_includes.h" -#include "loc_eng_dmn_conn_glue_msg.h" -#include "loc_eng_dmn_conn_handler.h" -#include "loc_eng_dmn_conn.h" -#include "loc_eng_msg.h" - -static int loc_api_server_msgqid; -static int loc_api_resp_msgqid; -static int quipc_msgqid; -static int msapm_msgqid; -static int msapu_msgqid; - -static const char * global_loc_api_q_path = GPSONE_LOC_API_Q_PATH; -static const char * global_loc_api_resp_q_path = GPSONE_LOC_API_RESP_Q_PATH; -static const char * global_quipc_ctrl_q_path = QUIPC_CTRL_Q_PATH; -static const char * global_msapm_ctrl_q_path = MSAPM_CTRL_Q_PATH; -static const char * global_msapu_ctrl_q_path = MSAPU_CTRL_Q_PATH; - -static int loc_api_server_proc_init(void *context) -{ - loc_api_server_msgqid = loc_eng_dmn_conn_glue_msgget(global_loc_api_q_path, O_RDWR); - //change mode/group for the global_loc_api_q_path pipe - int result = chmod (global_loc_api_q_path, 0660); - if (result != 0) - { - LOC_LOGE("failed to change mode for %s, error = %s\n", global_loc_api_q_path, strerror(errno)); - } - - struct group * gps_group = getgrnam("gps"); - if (gps_group != NULL) - { - result = chown (global_loc_api_q_path, -1, gps_group->gr_gid); - if (result != 0) - { - LOC_LOGE("chown for pipe failed, pipe %s, gid = %d, result = %d, error = %s\n", - global_loc_api_q_path, gps_group->gr_gid, result, strerror(errno)); - } - } - else - { - LOC_LOGE("getgrnam for gps failed, error code = %d\n", errno); - } - - loc_api_resp_msgqid = loc_eng_dmn_conn_glue_msgget(global_loc_api_resp_q_path, O_RDWR); - - //change mode/group for the global_loc_api_resp_q_path pipe - result = chmod (global_loc_api_resp_q_path, 0660); - if (result != 0) - { - LOC_LOGE("failed to change mode for %s, error = %s\n", global_loc_api_resp_q_path, strerror(errno)); - } - - if (gps_group != NULL) - { - result = chown (global_loc_api_resp_q_path, -1, gps_group->gr_gid); - if (result != 0) - { - LOC_LOGE("chown for pipe failed, pipe %s, gid = %d, result = %d, error = %s\n", - global_loc_api_resp_q_path, - gps_group->gr_gid, result, strerror(errno)); - } - } - - quipc_msgqid = loc_eng_dmn_conn_glue_msgget(global_quipc_ctrl_q_path, O_RDWR); - msapm_msgqid = loc_eng_dmn_conn_glue_msgget(global_msapm_ctrl_q_path , O_RDWR); - msapu_msgqid = loc_eng_dmn_conn_glue_msgget(global_msapu_ctrl_q_path , O_RDWR); - - LOC_LOGD("%s:%d] loc_api_server_msgqid = %d\n", __func__, __LINE__, loc_api_server_msgqid); - return 0; -} - -static int loc_api_server_proc_pre(void *context) -{ - return 0; -} - -static int loc_api_server_proc(void *context) -{ - int length, sz; - int result = 0; - static int cnt = 0; - struct ctrl_msgbuf * p_cmsgbuf; - struct ctrl_msgbuf cmsg_resp; - - sz = sizeof(struct ctrl_msgbuf) + 256; - p_cmsgbuf = (struct ctrl_msgbuf *) malloc(sz); - - if (!p_cmsgbuf) { - LOC_LOGE("%s:%d] Out of memory\n", __func__, __LINE__); - return -1; - } - - cnt ++; - LOC_LOGD("%s:%d] %d listening on %s...\n", __func__, __LINE__, cnt, (char *) context); - length = loc_eng_dmn_conn_glue_msgrcv(loc_api_server_msgqid, p_cmsgbuf, sz); - if (length <= 0) { - free(p_cmsgbuf); - LOC_LOGE("%s:%d] fail receiving msg from gpsone_daemon, retry later\n", __func__, __LINE__); - usleep(1000); - return -1; - } - - LOC_LOGD("%s:%d] received ctrl_type = %d\n", __func__, __LINE__, p_cmsgbuf->ctrl_type); - switch(p_cmsgbuf->ctrl_type) { - case GPSONE_LOC_API_IF_REQUEST: - result = loc_eng_dmn_conn_loc_api_server_if_request_handler(p_cmsgbuf, length); - break; - - case GPSONE_LOC_API_IF_RELEASE: - result = loc_eng_dmn_conn_loc_api_server_if_release_handler(p_cmsgbuf, length); - break; - - case GPSONE_UNBLOCK: - LOC_LOGD("%s:%d] GPSONE_UNBLOCK\n", __func__, __LINE__); - break; - - default: - LOC_LOGE("%s:%d] unsupported ctrl_type = %d\n", - __func__, __LINE__, p_cmsgbuf->ctrl_type); - break; - } - - free(p_cmsgbuf); - return 0; -} - -static int loc_api_server_proc_post(void *context) -{ - LOC_LOGD("%s:%d]\n", __func__, __LINE__); - loc_eng_dmn_conn_glue_msgremove( global_loc_api_q_path, loc_api_server_msgqid); - loc_eng_dmn_conn_glue_msgremove( global_loc_api_resp_q_path, loc_api_resp_msgqid); - loc_eng_dmn_conn_glue_msgremove( global_quipc_ctrl_q_path, quipc_msgqid); - loc_eng_dmn_conn_glue_msgremove( global_msapm_ctrl_q_path, msapm_msgqid); - loc_eng_dmn_conn_glue_msgremove( global_msapu_ctrl_q_path, msapu_msgqid); - return 0; -} - -static int loc_eng_dmn_conn_unblock_proc(void) -{ - struct ctrl_msgbuf cmsgbuf; - cmsgbuf.ctrl_type = GPSONE_UNBLOCK; - LOC_LOGD("%s:%d]\n", __func__, __LINE__); - loc_eng_dmn_conn_glue_msgsnd(loc_api_server_msgqid, & cmsgbuf, sizeof(cmsgbuf)); - return 0; -} - -static struct loc_eng_dmn_conn_thelper thelper; - -int loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread create_thread_cb, - const char * loc_api_q_path, const char * resp_q_path, void *agps_handle) -{ - int result; - - loc_api_handle = agps_handle; - - if (loc_api_q_path) global_loc_api_q_path = loc_api_q_path; - if (resp_q_path) global_loc_api_resp_q_path = resp_q_path; - - result = loc_eng_dmn_conn_launch_thelper( &thelper, - loc_api_server_proc_init, - loc_api_server_proc_pre, - loc_api_server_proc, - loc_api_server_proc_post, - create_thread_cb, - (char *) global_loc_api_q_path); - if (result != 0) { - LOC_LOGE("%s:%d]\n", __func__, __LINE__); - return -1; - } - return 0; -} - -int loc_eng_dmn_conn_loc_api_server_unblock(void) -{ - loc_eng_dmn_conn_unblock_thelper(&thelper); - loc_eng_dmn_conn_unblock_proc(); - return 0; -} - -int loc_eng_dmn_conn_loc_api_server_join(void) -{ - loc_eng_dmn_conn_join_thelper(&thelper); - return 0; -} - -int loc_eng_dmn_conn_loc_api_server_data_conn(int sender_id, int status) { - struct ctrl_msgbuf cmsgbuf; - LOC_LOGD("%s:%d] quipc_msgqid = %d\n", __func__, __LINE__, quipc_msgqid); - cmsgbuf.ctrl_type = GPSONE_LOC_API_RESPONSE; - cmsgbuf.cmsg.cmsg_response.result = status; - switch (sender_id) { - case LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC: { - LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC", __func__, __LINE__); - if (loc_eng_dmn_conn_glue_msgsnd(quipc_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) { - LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__); - return -1; - } - break; - } - case LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM: { - LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM", __func__, __LINE__); - if (loc_eng_dmn_conn_glue_msgsnd(msapm_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) { - LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__); - return -1; - } - break; - } - case LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU: { - LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU", __func__, __LINE__); - if (loc_eng_dmn_conn_glue_msgsnd(msapu_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) { - LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__); - return -1; - } - break; - } - case LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON: { - LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON", __func__, __LINE__); - if (loc_eng_dmn_conn_glue_msgsnd(loc_api_resp_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) { - LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__); - return -1; - } - break; - } - default: { - LOC_LOGD("%s:%d] invalid sender ID!", __func__, __LINE__); - } - } - return 0; -} - diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h deleted file mode 100644 index 1d8c142..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (c) 2011-2012,2014 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_ENG_DATA_SERVER_H -#define LOC_ENG_DATA_SERVER_H - -#include "loc_eng_dmn_conn_thread_helper.h" - -#ifdef _ANDROID_ - -#define GPSONE_LOC_API_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_q" -#define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_resp_q" -#define QUIPC_CTRL_Q_PATH "/data/misc/location/gpsone_d/quipc_ctrl_q" -#define MSAPM_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapm_ctrl_q" -#define MSAPU_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapu_ctrl_q" - -#else - -#define GPSONE_LOC_API_Q_PATH "/tmp/gpsone_loc_api_q" -#define GPSONE_LOC_API_RESP_Q_PATH "/tmp/gpsone_loc_api_resp_q" -#define QUIPC_CTRL_Q_PATH "/tmp/quipc_ctrl_q" -#define MSAPM_CTRL_Q_PATH "/tmp/msapm_ctrl_q" -#define MSAPU_CTRL_Q_PATH "/tmp/msapu_ctrl_q" - -#endif - -int loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread create_thread_cb, - const char * loc_api_q_path, const char * ctrl_q_path, void *agps_handle); -int loc_eng_dmn_conn_loc_api_server_unblock(void); -int loc_eng_dmn_conn_loc_api_server_join(void); -int loc_eng_dmn_conn_loc_api_server_data_conn(int, int); - -#endif /* LOC_ENG_DATA_SERVER_H */ - diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c deleted file mode 100644 index a1076ff..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c +++ /dev/null @@ -1,223 +0,0 @@ -/* Copyright (c) 2011, 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 -#include - -#include - -#include "log_util.h" -#include "platform_lib_includes.h" -#include "loc_eng_dmn_conn_glue_msg.h" -#include "loc_eng_dmn_conn_handler.h" - -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_glue_msgget - -DESCRIPTION - This function get a message queue - - q_path - name path of the message queue - mode - - -DEPENDENCIES - None - -RETURN VALUE - message queue id - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_glue_msgget(const char * q_path, int mode) -{ - int msgqid; - msgqid = loc_eng_dmn_conn_glue_pipeget(q_path, mode); - return msgqid; -} - -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_glue_msgremove - -DESCRIPTION - remove a message queue - - q_path - name path of the message queue - msgqid - message queue id - -DEPENDENCIES - None - -RETURN VALUE - 0: success or negative value for failure - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_glue_msgremove(const char * q_path, int msgqid) -{ - int result; - result = loc_eng_dmn_conn_glue_piperemove(q_path, msgqid); - return result; -} - -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_glue_msgsnd - -DESCRIPTION - Send a message - - msgqid - message queue id - msgp - pointer to the message to be sent - msgsz - size of the message - -DEPENDENCIES - None - -RETURN VALUE - number of bytes sent out or negative value for failure - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_glue_msgsnd(int msgqid, const void * msgp, size_t msgsz) -{ - int result; - struct ctrl_msgbuf *pmsg = (struct ctrl_msgbuf *) msgp; - pmsg->msgsz = msgsz; - - result = loc_eng_dmn_conn_glue_pipewrite(msgqid, msgp, msgsz); - if (result != (int) msgsz) { - LOC_LOGE("%s:%d] pipe broken %d, msgsz = %d\n", __func__, __LINE__, result, (int) msgsz); - return -1; - } - - return result; -} - -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_glue_msgrcv - -DESCRIPTION - receive a message - - msgqid - message queue id - msgp - pointer to the buffer to hold the message - msgsz - size of the buffer - -DEPENDENCIES - None - -RETURN VALUE - number of bytes received or negative value for failure - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_glue_msgrcv(int msgqid, void *msgp, size_t msgbufsz) -{ - int result; - struct ctrl_msgbuf *pmsg = (struct ctrl_msgbuf *) msgp; - - result = loc_eng_dmn_conn_glue_piperead(msgqid, &(pmsg->msgsz), sizeof(pmsg->msgsz)); - if (result != sizeof(pmsg->msgsz)) { - LOC_LOGE("%s:%d] pipe broken %d\n", __func__, __LINE__, result); - return -1; - } - - if (msgbufsz < pmsg->msgsz) { - LOC_LOGE("%s:%d] msgbuf is too small %d < %d\n", __func__, __LINE__, (int) msgbufsz, (int) pmsg->msgsz); - return -1; - } - - result = loc_eng_dmn_conn_glue_piperead(msgqid, (uint8_t *) msgp + sizeof(pmsg->msgsz), pmsg->msgsz - sizeof(pmsg->msgsz)); - if (result != (int) (pmsg->msgsz - sizeof(pmsg->msgsz))) { - LOC_LOGE("%s:%d] pipe broken %d, msgsz = %d\n", __func__, __LINE__, result, (int) pmsg->msgsz); - return -1; - } - - return pmsg->msgsz; -} - -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_glue_msgunblock - -DESCRIPTION - unblock a message queue - - msgqid - message queue id - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_glue_msgunblock(int msgqid) -{ - return loc_eng_dmn_conn_glue_pipeunblock(msgqid); -} - -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_glue_msgflush - -DESCRIPTION - flush out the message in a queue - - msgqid - message queue id - -DEPENDENCIES - None - -RETURN VALUE - number of bytes that are flushed out. - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_glue_msgflush(int msgqid) -{ - int length; - char buf[128]; - - do { - length = loc_eng_dmn_conn_glue_piperead(msgqid, buf, 128); - LOC_LOGD("%s:%d] %s\n", __func__, __LINE__, buf); - } while(length); - return length; -} - diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h deleted file mode 100644 index d685c87..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (c) 2011, 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_ENG_DMN_CONN_GLUE_MSG_H -#define LOC_ENG_DMN_CONN_GLUE_MSG_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#include -#include "loc_eng_dmn_conn_glue_pipe.h" - -int loc_eng_dmn_conn_glue_msgget(const char * q_path, int mode); -int loc_eng_dmn_conn_glue_msgremove(const char * q_path, int msgqid); -int loc_eng_dmn_conn_glue_msgsnd(int msgqid, const void * msgp, size_t msgsz); -int loc_eng_dmn_conn_glue_msgrcv(int msgqid, void *msgp, size_t msgsz); -int loc_eng_dmn_conn_glue_msgflush(int msgqid); -int loc_eng_dmn_conn_glue_msgunblock(int msgqid); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* LOC_ENG_DMN_CONN_GLUE_MSG_H */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c deleted file mode 100644 index dffcad0..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c +++ /dev/null @@ -1,214 +0,0 @@ -/* Copyright (c) 2011-2012, 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 -#include -#include - -// #include -#include -// #include -#include -#include - -#include "loc_eng_dmn_conn_glue_pipe.h" -#include "log_util.h" -#include "platform_lib_includes.h" -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_glue_pipeget - -DESCRIPTION - create a named pipe. - - pipe_name - pipe name path - mode - mode - -DEPENDENCIES - None - -RETURN VALUE - 0: success or negative value for failure - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode) -{ - int fd; - int result; - - LOC_LOGD("%s, mode = %d\n", pipe_name, mode); - result = mkfifo(pipe_name, 0660); - - if ((result == -1) && (errno != EEXIST)) { - LOC_LOGE("failed: %s\n", strerror(errno)); - return result; - } - - // The mode in mkfifo is not honoured and does not provide the - // group permissions. Doing chmod to add group permissions. - result = chmod (pipe_name, 0660); - if (result != 0){ - LOC_LOGE ("%s failed to change mode for %s, error = %s\n", __func__, - pipe_name, strerror(errno)); - } - - fd = open(pipe_name, mode); - if (fd <= 0) - { - LOC_LOGE("failed: %s\n", strerror(errno)); - } - LOC_LOGD("fd = %d, %s\n", fd, pipe_name); - return fd; -} - -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_glue_piperemove - -DESCRIPTION - remove a pipe - - pipe_name - pipe name path - fd - fd for the pipe - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd) -{ - close(fd); - if (pipe_name) unlink(pipe_name); - LOC_LOGD("fd = %d, %s\n", fd, pipe_name); - return 0; -} - -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_glue_pipewrite - -DESCRIPTION - write to a pipe - - fd - fd of a pipe - buf - buffer for the data to write - sz - size of the data in buffer - -DEPENDENCIES - None - -RETURN VALUE - number of bytes written or negative value for failure - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_glue_pipewrite(int fd, const void * buf, size_t sz) -{ - int result; - - result = write(fd, buf, sz); - - /* @todo check for non EINTR & EAGAIN, shall not do select again, select_tut Law 7) */ - - /* LOC_LOGD("fd = %d, buf = 0x%lx, size = %d, result = %d\n", fd, (long) buf, (int) sz, (int) result); */ - return result; -} - -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_glue_piperead - -DESCRIPTION - read from a pipe - - fd - fd for the pipe - buf - buffer to hold the data read from pipe - sz - size of the buffer - -DEPENDENCIES - None - -RETURN VALUE - number of bytes read from pipe or negative value for failure - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_glue_piperead(int fd, void * buf, size_t sz) -{ - int len; - - len = read(fd, buf, sz); - - /* @todo check for non EINTR & EAGAIN, shall not do select again, select_tut Law 7) */ - - /* LOC_LOGD("fd = %d, buf = 0x%lx, size = %d, len = %d\n", fd, (long) buf, (int) sz, len); */ - return len; -} - -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_glue_pipeunblock - -DESCRIPTION - unblock a pipe - - fd - fd for the pipe - -DEPENDENCIES - None - -RETURN VALUE - 0 for success or negative value for failure - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_glue_pipeunblock(int fd) -{ - int result; - struct flock flock_v; - LOC_LOGD("\n"); -// result = fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NDELAY); - flock_v.l_type = F_UNLCK; - flock_v.l_len = 32; - result = fcntl(fd, F_SETLK, &flock_v); - if (result < 0) { - LOC_LOGE("fcntl failure, %s\n", strerror(errno)); - } - - return result; -} diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h deleted file mode 100644 index b2fa3a0..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2011, 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_ENG_DMN_CONN_GLUE_PIPE_H -#define LOC_ENG_DMN_CONN_GLUE_PIPE_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include - -int loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode); -int loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd); -int loc_eng_dmn_conn_glue_pipewrite(int fd, const void * buf, size_t sz); -int loc_eng_dmn_conn_glue_piperead(int fd, void * buf, size_t sz); - -int loc_eng_dmn_conn_glue_pipeflush(int fd); -int loc_eng_dmn_conn_glue_pipeunblock(int fd); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* LOC_ENG_DMN_CONN_GLUE_PIPE_H */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp deleted file mode 100644 index edd53f2..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* Copyright (c) 2011-2012, 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 -#include -#include -#include - -#include "log_util.h" -#include "platform_lib_includes.h" -#include "loc_eng_msg.h" -#include "loc_eng_dmn_conn.h" -#include "loc_eng_dmn_conn_handler.h" - -void* loc_api_handle = NULL; - -int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg, int len) -{ - LOC_LOGD("%s:%d]\n", __func__, __LINE__); -#ifndef DEBUG_DMN_LOC_API - if (NULL == loc_api_handle) { - LOC_LOGE("%s:%d] NO agps data handle\n", __func__, __LINE__); - return 1; - } - - if (NULL != loc_api_handle) { - AGpsExtType type; - switch (pmsg->cmsg.cmsg_if_request.type) { - case IF_REQUEST_TYPE_SUPL: - { - LOC_LOGD("IF_REQUEST_TYPE_SUPL"); - type = AGPS_TYPE_SUPL; - break; - } - case IF_REQUEST_TYPE_WIFI: - { - LOC_LOGD("IF_REQUEST_TYPE_WIFI"); - type = AGPS_TYPE_WIFI; - break; - } - case IF_REQUEST_TYPE_ANY: - { - LOC_LOGD("IF_REQUEST_TYPE_ANY"); - type = AGPS_TYPE_ANY; - break; - } - default: - { - LOC_LOGD("invalid IF_REQUEST_TYPE!"); - return -1; - } - } - switch (pmsg->cmsg.cmsg_if_request.sender_id) { - case IF_REQUEST_SENDER_ID_QUIPC: - { - LOC_LOGD("IF_REQUEST_SENDER_ID_QUIPC"); - LocEngReqRelWifi* msg = - new LocEngReqRelWifi(loc_api_handle, - type, - LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC, - (char*)pmsg->cmsg.cmsg_if_request.ssid, - (char*)pmsg->cmsg.cmsg_if_request.password, - true); - msg->send(); - break; - } - case IF_REQUEST_SENDER_ID_MSAPM: - { - LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPM"); - LocEngReqRelWifi* msg = - new LocEngReqRelWifi(loc_api_handle, - type, - LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM, - (char*)pmsg->cmsg.cmsg_if_request.ssid, - (char*)pmsg->cmsg.cmsg_if_request.password, - true); - msg->send(); - break; - } - case IF_REQUEST_SENDER_ID_MSAPU: - { - LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPU"); - LocEngReqRelWifi* msg = - new LocEngReqRelWifi(loc_api_handle, - type, - LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU, - (char*)pmsg->cmsg.cmsg_if_request.ssid, - (char*)pmsg->cmsg.cmsg_if_request.password, - true); - msg->send(); - break; - } - case IF_REQUEST_SENDER_ID_GPSONE_DAEMON: - { - LOC_LOGD("IF_REQUEST_SENDER_ID_GPSONE_DAEMON"); - LocEngReqRelBIT* msg = - new LocEngReqRelBIT(loc_api_handle, - type, - pmsg->cmsg.cmsg_if_request.ipv4_addr, - (char*)pmsg->cmsg.cmsg_if_request.ipv6_addr, - true); - msg->send(); - break; - } - default: - { - LOC_LOGD("invalid IF_REQUEST_SENDER_ID!"); - return -1; - } - } - } - -#else - loc_eng_dmn_conn_loc_api_server_data_conn(LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, GPSONE_LOC_API_IF_REQUEST_SUCCESS); -#endif - return 0; -} - -int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg, int len) -{ - LOC_LOGD("%s:%d]\n", __func__, __LINE__); -#ifndef DEBUG_DMN_LOC_API - AGpsExtType type; - switch (pmsg->cmsg.cmsg_if_request.type) { - case IF_REQUEST_TYPE_SUPL: - { - LOC_LOGD("IF_REQUEST_TYPE_SUPL"); - type = AGPS_TYPE_SUPL; - break; - } - case IF_REQUEST_TYPE_WIFI: - { - LOC_LOGD("IF_REQUEST_TYPE_WIFI"); - type = AGPS_TYPE_WIFI; - break; - } - case IF_REQUEST_TYPE_ANY: - { - LOC_LOGD("IF_REQUEST_TYPE_ANY"); - type = AGPS_TYPE_ANY; - break; - } - default: - { - LOC_LOGD("invalid IF_REQUEST_TYPE!"); - return -1; - } - } - switch (pmsg->cmsg.cmsg_if_request.sender_id) { - case IF_REQUEST_SENDER_ID_QUIPC: - { - LOC_LOGD("IF_REQUEST_SENDER_ID_QUIPC"); - LocEngReqRelWifi* msg = - new LocEngReqRelWifi(loc_api_handle, - type, - LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC, - (char*)pmsg->cmsg.cmsg_if_request.ssid, - (char*)pmsg->cmsg.cmsg_if_request.password, - false); - msg->send(); - break; - } - case IF_REQUEST_SENDER_ID_MSAPM: - { - LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPM"); - LocEngReqRelWifi* msg = - new LocEngReqRelWifi(loc_api_handle, - type, - LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM, - (char*)pmsg->cmsg.cmsg_if_request.ssid, - (char*)pmsg->cmsg.cmsg_if_request.password, - false); - msg->send(); - break; - } - case IF_REQUEST_SENDER_ID_MSAPU: - { - LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPU"); - LocEngReqRelWifi* msg = - new LocEngReqRelWifi(loc_api_handle, - type, - LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU, - (char*)pmsg->cmsg.cmsg_if_request.ssid, - (char*)pmsg->cmsg.cmsg_if_request.password, - false); - msg->send(); - break; - } - case IF_REQUEST_SENDER_ID_GPSONE_DAEMON: - { - LOC_LOGD("IF_REQUEST_SENDER_ID_GPSONE_DAEMON"); - LocEngReqRelBIT* msg = - new LocEngReqRelBIT(loc_api_handle, - type, - pmsg->cmsg.cmsg_if_request.ipv4_addr, - (char*)pmsg->cmsg.cmsg_if_request.ipv6_addr, - false); - msg->send(); - break; - } - default: - { - LOC_LOGD("invalid IF_REQUEST_SENDER_ID!"); - return -1; - } - } -#else - loc_eng_dmn_conn_loc_api_server_data_conn(LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, GPSONE_LOC_API_IF_RELEASE_SUCCESS); -#endif - return 0; -} - diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h deleted file mode 100644 index 1c0edd5..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright (c) 2011-2012, 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_ENG_DATA_SERVER_HANDLER -#define LOC_ENG_DATA_SERVER_HANDLER - -#include -#include - -//for SSID_BUF_SIZE -#include - -#ifndef SSID_BUF_SIZE - #define SSID_BUF_SIZE (32+1) -#endif - -enum { - /* 0x0 - 0xEF is reserved for daemon internal */ - GPSONE_LOC_API_IF_REQUEST = 0xF0, - GPSONE_LOC_API_IF_RELEASE, - GPSONE_LOC_API_RESPONSE, - GPSONE_UNBLOCK, -}; - -enum { - GPSONE_LOC_API_IF_REQUEST_SUCCESS = 0xF0, - GPSONE_LOC_API_IF_RELEASE_SUCCESS, - GPSONE_LOC_API_IF_FAILURE, -}; - - -struct ctrl_msg_response { - int result; -}; - -struct ctrl_msg_unblock { - int reserved; -}; - -typedef enum { - IF_REQUEST_TYPE_SUPL = 0, - IF_REQUEST_TYPE_WIFI, - IF_REQUEST_TYPE_ANY -} ctrl_if_req_type_e_type; - -typedef enum { - IF_REQUEST_SENDER_ID_QUIPC = 0, - IF_REQUEST_SENDER_ID_MSAPM, - IF_REQUEST_SENDER_ID_MSAPU, - IF_REQUEST_SENDER_ID_GPSONE_DAEMON, - IF_REQUEST_SENDER_ID_MODEM -} ctrl_if_req_sender_id_e_type; - -struct ctrl_msg_if_request { - ctrl_if_req_type_e_type type; - ctrl_if_req_sender_id_e_type sender_id; - unsigned long ipv4_addr; - unsigned char ipv6_addr[16]; - char ssid[SSID_BUF_SIZE]; - char password[SSID_BUF_SIZE]; -}; - -/* do not change this structure */ -struct ctrl_msgbuf { - size_t msgsz; - uint16_t reserved1; - uint32_t reserved2; - uint8_t ctrl_type; - union { - struct ctrl_msg_response cmsg_response; - struct ctrl_msg_unblock cmsg_unblock; - struct ctrl_msg_if_request cmsg_if_request; - } cmsg; -}; - -extern void* loc_api_handle; - -int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg, int len); -int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg, int len); - -#endif /* LOC_ENG_DATA_SERVER_HANDLER */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c deleted file mode 100644 index 9fed9d4..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c +++ /dev/null @@ -1,399 +0,0 @@ -/* Copyright (c) 2011, 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 - -#include "log_util.h" -#include "platform_lib_includes.h" -#include "loc_eng_dmn_conn_thread_helper.h" - -/*=========================================================================== -FUNCTION thelper_signal_init - -DESCRIPTION - This function will initialize the conditional variable resources. - - thelper - thelper instance - -DEPENDENCIES - None - -RETURN VALUE - 0: success or negative value for failure - -SIDE EFFECTS - N/A - -===========================================================================*/ -int thelper_signal_init(struct loc_eng_dmn_conn_thelper * thelper) -{ - int result; - thelper->thread_exit = 0; - thelper->thread_ready = 0; - result = pthread_cond_init( &thelper->thread_cond, NULL); - if (result) { - return result; - } - - result = pthread_mutex_init(&thelper->thread_mutex, NULL); - if (result) { - pthread_cond_destroy(&thelper->thread_cond); - } - return result; -} - -/*=========================================================================== -FUNCTION - -DESCRIPTION - This function will destroy the conditional variable resources - - thelper - pointer to thelper instance - -DEPENDENCIES - None - -RETURN VALUE - 0: success or negative value for failure - -SIDE EFFECTS - N/A - -===========================================================================*/ -int thelper_signal_destroy(struct loc_eng_dmn_conn_thelper * thelper) -{ - int result, ret_result = 0; - result = pthread_cond_destroy( &thelper->thread_cond); - if (result) { - ret_result = result; - } - - result = pthread_mutex_destroy(&thelper->thread_mutex); - if (result) { - ret_result = result; - } - - return ret_result; -} - -/*=========================================================================== -FUNCTION thelper_signal_wait - -DESCRIPTION - This function will be blocked on the conditional variable until thelper_signal_ready - is called - - thelper - pointer to thelper instance - -DEPENDENCIES - None - -RETURN VALUE - 0: success or negative value for failure - -SIDE EFFECTS - N/A - -===========================================================================*/ -int thelper_signal_wait(struct loc_eng_dmn_conn_thelper * thelper) -{ - int result = 0; - - pthread_mutex_lock(&thelper->thread_mutex); - if (!thelper->thread_ready && !thelper->thread_exit) { - result = pthread_cond_wait(&thelper->thread_cond, &thelper->thread_mutex); - } - - if (thelper->thread_exit) { - result = -1; - } - pthread_mutex_unlock(&thelper->thread_mutex); - - return result; -} - -/*=========================================================================== -FUNCTION thelper_signal_ready - -DESCRIPTION - This function will wake up the conditional variable - - thelper - pointer to thelper instance - -DEPENDENCIES - None - -RETURN VALUE - 0: success or negative value for failure - -SIDE EFFECTS - N/A - -===========================================================================*/ -int thelper_signal_ready(struct loc_eng_dmn_conn_thelper * thelper) -{ - int result; - - LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); - - pthread_mutex_lock(&thelper->thread_mutex); - thelper->thread_ready = 1; - result = pthread_cond_signal(&thelper->thread_cond); - pthread_mutex_unlock(&thelper->thread_mutex); - - return result; -} - -/*=========================================================================== -FUNCTION thelper_signal_block - -DESCRIPTION - This function will set the thread ready to 0 to block the thelper_signal_wait - - thelper - pointer to thelper instance - -DEPENDENCIES - None - -RETURN VALUE - if thread_ready is set - -SIDE EFFECTS - N/A - -===========================================================================*/ -int thelper_signal_block(struct loc_eng_dmn_conn_thelper * thelper) -{ - int result = thelper->thread_ready; - - LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); - - pthread_mutex_lock(&thelper->thread_mutex); - thelper->thread_ready = 0; - pthread_mutex_unlock(&thelper->thread_mutex); - - return result; -} - -/*=========================================================================== -FUNCTION thelper_main - -DESCRIPTION - This function is the main thread. It will be launched as a child thread - - data - pointer to the instance - -DEPENDENCIES - None - -RETURN VALUE - NULL - -SIDE EFFECTS - N/A - -===========================================================================*/ -static void * thelper_main(void *data) -{ - int result = 0; - struct loc_eng_dmn_conn_thelper * thelper = (struct loc_eng_dmn_conn_thelper *) data; - - if (thelper->thread_proc_init) { - result = thelper->thread_proc_init(thelper->thread_context); - if (result < 0) { - thelper->thread_exit = 1; - thelper_signal_ready(thelper); - LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper); - return NULL; - } - } - - thelper_signal_ready(thelper); - - if (thelper->thread_proc_pre) { - result = thelper->thread_proc_pre(thelper->thread_context); - if (result < 0) { - thelper->thread_exit = 1; - LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper); - return NULL; - } - } - - do { - if (thelper->thread_proc) { - result = thelper->thread_proc(thelper->thread_context); - if (result < 0) { - thelper->thread_exit = 1; - LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper); - } - } - } while (thelper->thread_exit == 0); - - if (thelper->thread_proc_post) { - result = thelper->thread_proc_post(thelper->thread_context); - } - - if (result != 0) { - LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper); - } - return NULL; -} - -static void thelper_main_2(void *data) -{ - thelper_main(data); - return; -} - - -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_launch_thelper - -DESCRIPTION - This function will initialize the thread context and launch the thelper_main - - thelper - pointer to thelper instance - thread_proc_init - The initialization function pointer - thread_proc_pre - The function to call before task loop and after initialization - thread_proc - The task loop - thread_proc_post - The function to call after the task loop - context - the context for the above four functions - -DEPENDENCIES - None - -RETURN VALUE - 0: success or negative value for failure - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_launch_thelper(struct loc_eng_dmn_conn_thelper * thelper, - int (*thread_proc_init) (void * context), - int (*thread_proc_pre) (void * context), - int (*thread_proc) (void * context), - int (*thread_proc_post) (void * context), - thelper_create_thread create_thread_cb, - void * context) -{ - int result; - - thelper_signal_init(thelper); - - if (context) { - thelper->thread_context = context; - } - - thelper->thread_proc_init = thread_proc_init; - thelper->thread_proc_pre = thread_proc_pre; - thelper->thread_proc = thread_proc; - thelper->thread_proc_post = thread_proc_post; - - LOC_LOGD("%s:%d] 0x%lx call pthread_create\n", __func__, __LINE__, (long) thelper); - if (create_thread_cb) { - result = 0; - thelper->thread_id = create_thread_cb("loc_eng_dmn_conn", - thelper_main_2, (void *)thelper); - } else { - result = pthread_create(&thelper->thread_id, NULL, - thelper_main, (void *)thelper); - } - - if (result != 0) { - LOC_LOGE("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); - return -1; - } - - LOC_LOGD("%s:%d] 0x%lx pthread_create done\n", __func__, __LINE__, (long) thelper); - - thelper_signal_wait(thelper); - - LOC_LOGD("%s:%d] 0x%lx pthread ready\n", __func__, __LINE__, (long) thelper); - return thelper->thread_exit; -} - -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_unblock_thelper - -DESCRIPTION - This function unblocks thelper_main to release the thread - - thelper - pointer to thelper instance - -DEPENDENCIES - None - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_unblock_thelper(struct loc_eng_dmn_conn_thelper * thelper) -{ - LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); - thelper->thread_exit = 1; - return 0; -} - -/*=========================================================================== -FUNCTION loc_eng_dmn_conn_join_thelper - - thelper - pointer to thelper instance - -DESCRIPTION - This function will wait for the thread of thelper_main to finish - -DEPENDENCIES - None - -RETURN VALUE - 0: success or negative value for failure - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_dmn_conn_join_thelper(struct loc_eng_dmn_conn_thelper * thelper) -{ - int result; - - LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); - result = pthread_join(thelper->thread_id, NULL); - if (result != 0) { - LOC_LOGE("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); - } - LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); - - thelper_signal_destroy(thelper); - - return result; -} - diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h deleted file mode 100644 index 89e598b..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (c) 2011, 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_ENG_DMN_CONN_THREAD_HELPER_H__ -#define __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include - -struct loc_eng_dmn_conn_thelper { - unsigned char thread_exit; - unsigned char thread_ready; - pthread_cond_t thread_cond; - pthread_mutex_t thread_mutex; - pthread_t thread_id; - void * thread_context; - int (*thread_proc_init) (void * context); - int (*thread_proc_pre) (void * context); - int (*thread_proc) (void * context); - int (*thread_proc_post) (void * context); -}; - -typedef pthread_t (* thelper_create_thread)(const char* name, void (*start)(void *), void* arg); -int loc_eng_dmn_conn_launch_thelper(struct loc_eng_dmn_conn_thelper * thelper, - int (*thread_proc_init) (void * context), - int (*thread_proc_pre) (void * context), - int (*thread_proc) (void * context), - int (*thread_proc_post) (void * context), - thelper_create_thread create_thread_cb, - void * context); - -int loc_eng_dmn_conn_unblock_thelper(struct loc_eng_dmn_conn_thelper * thelper); -int loc_eng_dmn_conn_join_thelper(struct loc_eng_dmn_conn_thelper * thelper); - -/* if only need to use signal */ -int thelper_signal_init(struct loc_eng_dmn_conn_thelper * thelper); -int thelper_signal_destroy(struct loc_eng_dmn_conn_thelper * thelper); -int thelper_signal_wait(struct loc_eng_dmn_conn_thelper * thelper); -int thelper_signal_ready(struct loc_eng_dmn_conn_thelper * thelper); -int thelper_signal_block(struct loc_eng_dmn_conn_thelper * thelper); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_log.cpp b/gps/loc_api/libloc_api_50001/loc_eng_log.cpp deleted file mode 100644 index 3a34167..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_log.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_eng" - -#include "loc_log.h" -#include "loc_eng_log.h" - diff --git a/gps/loc_api/libloc_api_50001/loc_eng_log.h b/gps/loc_api/libloc_api_50001/loc_eng_log.h deleted file mode 100644 index a68bd84..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_log.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2011-2013, 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_ENG_LOG_H -#define LOC_ENG_LOG_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include - -#ifdef __cplusplus -} -#endif - -#endif /* LOC_ENG_LOG_H */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_msg.h b/gps/loc_api/libloc_api_50001/loc_eng_msg.h deleted file mode 100644 index 3bff162..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_msg.h +++ /dev/null @@ -1,306 +0,0 @@ -/* Copyright (c) 2011-2013, 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_ENG_MSG_H -#define LOC_ENG_MSG_H - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef SSID_BUF_SIZE - #define SSID_BUF_SIZE (32+1) -#endif -#ifdef USE_GLIB - -#include - -#endif /* USE_GLIB */ -#include "platform_lib_includes.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -using namespace loc_core; - -struct LocEngPositionMode : public LocMsg { - LocEngAdapter* mAdapter; - const LocPosMode mPosMode; - LocEngPositionMode(LocEngAdapter* adapter, LocPosMode &mode); - virtual void proc() const; - virtual void log() const; - void send() const; -}; - - -struct LocEngStartFix : public LocMsg { - LocEngAdapter* mAdapter; - LocEngStartFix(LocEngAdapter* adapter); - virtual void proc() const; - void locallog() const; - virtual void log() const; - void send() const; -}; - -struct LocEngStopFix : public LocMsg { - LocEngAdapter* mAdapter; - LocEngStopFix(LocEngAdapter* adapter); - virtual void proc() const; - void locallog() const; - virtual void log() const; - void send() const; -}; - -struct LocEngReportPosition : public LocMsg { - LocAdapterBase* mAdapter; - const UlpLocation mLocation; - const GpsLocationExtended mLocationExtended; - const void* mLocationExt; - const enum loc_sess_status mStatus; - const LocPosTechMask mTechMask; - LocEngReportPosition(LocAdapterBase* adapter, - UlpLocation &loc, - GpsLocationExtended &locExtended, - void* locExt, - enum loc_sess_status st, - LocPosTechMask technology); - virtual void proc() const; - void locallog() const; - virtual void log() const; - void send() const; -}; - -struct LocEngReportSv : public LocMsg { - LocAdapterBase* mAdapter; - const HaxxSvStatus mSvStatus; - const GpsLocationExtended mLocationExtended; - const void* mSvExt; - LocEngReportSv(LocAdapterBase* adapter, - HaxxSvStatus &sv, - GpsLocationExtended &locExtended, - void* svExtended); - virtual void proc() const; - void locallog() const; - virtual void log() const; - void send() const; -}; - -struct LocEngReportStatus : public LocMsg { - LocAdapterBase* mAdapter; - const GpsStatusValue mStatus; - LocEngReportStatus(LocAdapterBase* adapter, - GpsStatusValue engineStatus); - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -struct LocEngReportNmea : public LocMsg { - void* mLocEng; - char* const mNmea; - const int mLen; - LocEngReportNmea(void* locEng, - const char* data, int len); - inline virtual ~LocEngReportNmea() - { - delete[] mNmea; - } - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -struct LocEngReportXtraServer : public LocMsg { - void* mLocEng; - int mMaxLen; - char *mServers; - LocEngReportXtraServer(void* locEng, - const char *url1, const char *url2, - const char *url3, const int maxlength); - inline virtual ~LocEngReportXtraServer() - { - delete[] mServers; - } - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -struct LocEngSuplEsOpened : public LocMsg { - void* mLocEng; - LocEngSuplEsOpened(void* locEng); - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -struct LocEngSuplEsClosed : public LocMsg { - void* mLocEng; - LocEngSuplEsClosed(void* locEng); - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -struct LocEngRequestSuplEs : public LocMsg { - void* mLocEng; - const int mID; - LocEngRequestSuplEs(void* locEng, int id); - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -struct LocEngRequestATL : public LocMsg { - void* mLocEng; - const int mID; - const AGpsExtType mType; - LocEngRequestATL(void* locEng, int id, - AGpsExtType agps_type); - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -struct LocEngReleaseATL : public LocMsg { - void* mLocEng; - const int mID; - LocEngReleaseATL(void* locEng, int id); - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -struct LocEngReqRelBIT : public LocMsg { - void* mLocEng; - const AGpsExtType mType; - const int mIPv4Addr; - char* const mIPv6Addr; - const bool mIsReq; - LocEngReqRelBIT(void* instance, AGpsExtType type, - int ipv4, char* ipv6, bool isReq); - virtual ~LocEngReqRelBIT(); - virtual void proc() const; - void locallog() const; - virtual void log() const; - void send() const; -}; - -struct LocEngReqRelWifi : public LocMsg { - void* mLocEng; - const AGpsExtType mType; - const loc_if_req_sender_id_e_type mSenderId; - char* const mSSID; - char* const mPassword; - const bool mIsReq; - LocEngReqRelWifi(void* locEng, AGpsExtType type, - loc_if_req_sender_id_e_type sender_id, - char* s, char* p, bool isReq); - virtual ~LocEngReqRelWifi(); - virtual void proc() const; - void locallog() const; - virtual void log() const; - void send() const; -}; - -struct LocEngRequestXtra : public LocMsg { - void* mLocEng; - LocEngRequestXtra(void* locEng); - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -struct LocEngRequestTime : public LocMsg { - void* mLocEng; - LocEngRequestTime(void* locEng); - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -struct LocEngRequestNi : public LocMsg { - void* mLocEng; - const GpsNiNotification mNotify; - const void *mPayload; - LocEngRequestNi(void* locEng, - GpsNiNotification ¬if, - const void* data); - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -struct LocEngDown : public LocMsg { - void* mLocEng; - LocEngDown(void* locEng); - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -struct LocEngUp : public LocMsg { - void* mLocEng; - LocEngUp(void* locEng); - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -struct LocEngGetZpp : public LocMsg { - LocEngAdapter* mAdapter; - LocEngGetZpp(LocEngAdapter* adapter); - virtual void proc() const; - void locallog() const; - virtual void log() const; - void send() const; -}; - -struct LocEngReportGpsMeasurement : public LocMsg { - void* mLocEng; - const GpsData mGpsData; - LocEngReportGpsMeasurement(void* locEng, - GpsData &gpsData); - virtual void proc() const; - void locallog() const; - virtual void log() const; -}; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* LOC_ENG_MSG_H */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp b/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp deleted file mode 100644 index 4597b98..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp +++ /dev/null @@ -1,414 +0,0 @@ -/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_eng" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "log_util.h" -#include "platform_lib_includes.h" - -using namespace loc_core; - -/*============================================================================= - * - * DATA DECLARATION - * - *============================================================================*/ - -/*============================================================================= - * - * FUNCTION DECLARATIONS - * - *============================================================================*/ -static void* ni_thread_proc(void *args); - -struct LocEngInformNiResponse : public LocMsg { - LocEngAdapter* mAdapter; - const GpsUserResponseType mResponse; - const void *mPayload; - inline LocEngInformNiResponse(LocEngAdapter* adapter, - GpsUserResponseType resp, - const void* data) : - LocMsg(), mAdapter(adapter), - mResponse(resp), mPayload(data) - { - locallog(); - } - inline ~LocEngInformNiResponse() - { - // this is a bit weird since mPayload is not - // allocated by this class. But there is no better way. - // mPayload actually won't be NULL here. - free((void*)mPayload); - } - inline virtual void proc() const - { - mAdapter->informNiResponse(mResponse, mPayload); - } - inline void locallog() const - { - LOC_LOGV("LocEngInformNiResponse - " - "response: %s\n mPayload: %p", - loc_get_ni_response_name(mResponse), - mPayload); - } - inline virtual void log() const - { - locallog(); - } -}; - -/*=========================================================================== - -FUNCTION loc_eng_ni_request_handler - -DESCRIPTION - Displays the NI request and awaits user input. If a previous request is - in session, it is ignored. - -RETURN VALUE - none - -===========================================================================*/ -void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data, - const GpsNiNotification *notif, - const void* passThrough) -{ - ENTRY_LOG(); - char lcs_addr[32]; // Decoded LCS address for UMTS CP NI - loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data; - loc_eng_ni_session_s_type* pSession = NULL; - - if (NULL == loc_eng_data.ni_notify_cb) { - EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet."); - return; - } - - if (notif->ni_type == GPS_NI_TYPE_EMERGENCY_SUPL) { - if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) { - LOC_LOGW("loc_eng_ni_request_handler, supl es NI in progress, new supl es NI ignored, type: %d", - notif->ni_type); - if (NULL != passThrough) { - free((void*)passThrough); - } - } else { - pSession = &loc_eng_ni_data_p->sessionEs; - } - } else { - if (NULL != loc_eng_ni_data_p->session.rawRequest || - NULL != loc_eng_ni_data_p->sessionEs.rawRequest) { - LOC_LOGW("loc_eng_ni_request_handler, supl NI in progress, new supl NI ignored, type: %d", - notif->ni_type); - if (NULL != passThrough) { - free((void*)passThrough); - } - } else { - pSession = &loc_eng_ni_data_p->session; - } - } - - - if (pSession) { - /* Save request */ - pSession->rawRequest = (void*)passThrough; - pSession->reqID = ++loc_eng_ni_data_p->reqIDCounter; - pSession->adapter = loc_eng_data.adapter; - - /* Fill in notification */ - ((GpsNiNotification*)notif)->notification_id = pSession->reqID; - - if (notif->notify_flags == GPS_NI_PRIVACY_OVERRIDE) - { - loc_eng_mute_one_session(loc_eng_data); - } - - /* Log requestor ID and text for debugging */ - LOC_LOGI("Notification: notif_type: %d, timeout: %d, default_resp: %d", notif->ni_type, notif->timeout, notif->default_response); - LOC_LOGI(" requestor_id: %s (encoding: %d)", notif->requestor_id, notif->requestor_id_encoding); - LOC_LOGI(" text: %s text (encoding: %d)", notif->text, notif->text_encoding); - if (notif->extras[0]) - { - LOC_LOGI(" extras: %s", notif->extras); - } - - /* For robustness, spawn a thread at this point to timeout to clear up the notification status, even though - * the OEM layer in java does not do so. - **/ - pSession->respTimeLeft = 5 + (notif->timeout != 0 ? notif->timeout : LOC_NI_NO_RESPONSE_TIME); - LOC_LOGI("Automatically sends 'no response' in %d seconds (to clear status)\n", pSession->respTimeLeft); - - int rc = 0; - rc = pthread_create(&pSession->thread, NULL, ni_thread_proc, pSession); - if (rc) - { - LOC_LOGE("Loc NI thread is not created.\n"); - } - rc = pthread_detach(pSession->thread); - if (rc) - { - LOC_LOGE("Loc NI thread is not detached.\n"); - } - - CALLBACK_LOG_CALLFLOW("ni_notify_cb - id", %d, notif->notification_id); - loc_eng_data.ni_notify_cb((GpsNiNotification*)notif); - } - EXIT_LOG(%s, VOID_RET); -} - -/*=========================================================================== - -FUNCTION ni_thread_proc - -===========================================================================*/ -static void* ni_thread_proc(void *args) -{ - ENTRY_LOG(); - - loc_eng_ni_session_s_type* pSession = (loc_eng_ni_session_s_type*)args; - int rc = 0; /* return code from pthread calls */ - - struct timeval present_time; - struct timespec expire_time; - - LOC_LOGD("Starting Loc NI thread...\n"); - pthread_mutex_lock(&pSession->tLock); - /* Calculate absolute expire time */ - gettimeofday(&present_time, NULL); - expire_time.tv_sec = present_time.tv_sec + pSession->respTimeLeft; - expire_time.tv_nsec = present_time.tv_usec * 1000; - LOC_LOGD("ni_thread_proc-Time out set for abs time %ld with delay %d sec\n", - (long) expire_time.tv_sec, pSession->respTimeLeft ); - - while (!pSession->respRecvd) - { - rc = pthread_cond_timedwait(&pSession->tCond, - &pSession->tLock, - &expire_time); - if (rc == ETIMEDOUT) - { - pSession->resp = GPS_NI_RESPONSE_NORESP; - LOC_LOGD("ni_thread_proc-Thread time out after valting for specified time. Ret Val %d\n",rc ); - break; - } - } - LOC_LOGD("ni_thread_proc-Java layer has sent us a user response and return value from " - "pthread_cond_timedwait = %d\n",rc ); - pSession->respRecvd = FALSE; /* Reset the user response flag for the next session*/ - - LOC_LOGD("pSession->resp is %d\n",pSession->resp); - - // adding this check to support modem restart, in which case, we need the thread - // to exit without calling sending data. We made sure that rawRequest is NULL in - // loc_eng_ni_reset_on_engine_restart() - LocEngAdapter* adapter = pSession->adapter; - LocEngInformNiResponse *msg = NULL; - - if (NULL != pSession->rawRequest) { - if (pSession->resp != GPS_NI_RESPONSE_IGNORE) { - LOC_LOGD("pSession->resp != GPS_NI_RESPONSE_IGNORE \n"); - msg = new LocEngInformNiResponse(adapter, - pSession->resp, - pSession->rawRequest); - } else { - LOC_LOGD("this is the ignore reply for SUPL ES\n"); - free(pSession->rawRequest); - } - pSession->rawRequest = NULL; - } - pthread_mutex_unlock(&pSession->tLock); - - pSession->respTimeLeft = 0; - pSession->reqID = 0; - - if (NULL != msg) { - LOC_LOGD("ni_thread_proc: adapter->sendMsg(msg)\n"); - adapter->sendMsg(msg); - } - - EXIT_LOG(%s, VOID_RET); - return NULL; -} - -void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG(); - loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data; - - if (NULL == loc_eng_data.ni_notify_cb) { - EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet."); - return; - } - - // only if modem has requested but then died. - if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) { - free(loc_eng_ni_data_p->sessionEs.rawRequest); - loc_eng_ni_data_p->sessionEs.rawRequest = NULL; - - pthread_mutex_lock(&loc_eng_ni_data_p->sessionEs.tLock); - // the goal is to wake up ni_thread_proc - // and let it exit. - loc_eng_ni_data_p->sessionEs.respRecvd = TRUE; - pthread_cond_signal(&loc_eng_ni_data_p->sessionEs.tCond); - pthread_mutex_unlock(&loc_eng_ni_data_p->sessionEs.tLock); - } - - if (NULL != loc_eng_ni_data_p->session.rawRequest) { - free(loc_eng_ni_data_p->session.rawRequest); - loc_eng_ni_data_p->session.rawRequest = NULL; - - pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock); - // the goal is to wake up ni_thread_proc - // and let it exit. - loc_eng_ni_data_p->session.respRecvd = TRUE; - pthread_cond_signal(&loc_eng_ni_data_p->session.tCond); - pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock); - } - - EXIT_LOG(%s, VOID_RET); -} - -/*=========================================================================== -FUNCTION loc_eng_ni_init - -DESCRIPTION - This function initializes the NI interface - -DEPENDENCIES - NONE - -RETURN VALUE - None - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, GpsNiExtCallbacks *callbacks) -{ - ENTRY_LOG_CALLFLOW(); - - if(callbacks == NULL) - EXIT_LOG(%s, "loc_eng_ni_init: failed, cb is NULL"); - else if (NULL == callbacks->notify_cb) { - EXIT_LOG(%s, "loc_eng_ni_init: failed, no cb."); - } else if (NULL != loc_eng_data.ni_notify_cb) { - EXIT_LOG(%s, "loc_eng_ni_init: already inited."); - } else { - loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data; - loc_eng_ni_data_p->sessionEs.respTimeLeft = 0; - loc_eng_ni_data_p->sessionEs.respRecvd = FALSE; - loc_eng_ni_data_p->sessionEs.rawRequest = NULL; - loc_eng_ni_data_p->sessionEs.reqID = 0; - pthread_cond_init(&loc_eng_ni_data_p->sessionEs.tCond, NULL); - pthread_mutex_init(&loc_eng_ni_data_p->sessionEs.tLock, NULL); - - loc_eng_ni_data_p->session.respTimeLeft = 0; - loc_eng_ni_data_p->session.respRecvd = FALSE; - loc_eng_ni_data_p->session.rawRequest = NULL; - loc_eng_ni_data_p->session.reqID = 0; - pthread_cond_init(&loc_eng_ni_data_p->session.tCond, NULL); - pthread_mutex_init(&loc_eng_ni_data_p->session.tLock, NULL); - - loc_eng_data.ni_notify_cb = callbacks->notify_cb; - EXIT_LOG(%s, VOID_RET); - } -} - -/*=========================================================================== -FUNCTION loc_eng_ni_respond - -DESCRIPTION - This function receives user response from upper layer framework - -DEPENDENCIES - NONE - -RETURN VALUE - None - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data, - int notif_id, GpsUserResponseType user_response) -{ - ENTRY_LOG_CALLFLOW(); - loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data; - loc_eng_ni_session_s_type* pSession = NULL; - - if (NULL == loc_eng_data.ni_notify_cb) { - EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet."); - return; - } - - if (notif_id == loc_eng_ni_data_p->sessionEs.reqID && - NULL != loc_eng_ni_data_p->sessionEs.rawRequest) { - pSession = &loc_eng_ni_data_p->sessionEs; - // ignore any SUPL NI non-Es session if a SUPL NI ES is accepted - if (user_response == GPS_NI_RESPONSE_ACCEPT && - NULL != loc_eng_ni_data_p->session.rawRequest) { - pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock); - loc_eng_ni_data_p->session.resp = GPS_NI_RESPONSE_IGNORE; - loc_eng_ni_data_p->session.respRecvd = TRUE; - pthread_cond_signal(&loc_eng_ni_data_p->session.tCond); - pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock); - } - } else if (notif_id == loc_eng_ni_data_p->session.reqID && - NULL != loc_eng_ni_data_p->session.rawRequest) { - pSession = &loc_eng_ni_data_p->session; - } - - if (pSession) { - LOC_LOGI("loc_eng_ni_respond: send user response %d for notif %d", user_response, notif_id); - pthread_mutex_lock(&pSession->tLock); - pSession->resp = user_response; - pSession->respRecvd = TRUE; - pthread_cond_signal(&pSession->tCond); - pthread_mutex_unlock(&pSession->tLock); - } - else { - LOC_LOGE("loc_eng_ni_respond: notif_id %d not an active session", notif_id); - } - - EXIT_LOG(%s, VOID_RET); -} diff --git a/gps/loc_api/libloc_api_50001/loc_eng_ni.h b/gps/loc_api/libloc_api_50001/loc_eng_ni.h deleted file mode 100644 index 068f5cd..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_ni.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (c) 2009,2011,2014 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_ENG_NI_H -#define LOC_ENG_NI_H - -#include -#include - -#define LOC_NI_NO_RESPONSE_TIME 20 /* secs */ -#define LOC_NI_NOTIF_KEY_ADDRESS "Address" -#define GPS_NI_RESPONSE_IGNORE 4 - -typedef struct { - pthread_t thread; /* NI thread */ - int respTimeLeft; /* examine time for NI response */ - bool respRecvd; /* NI User reponse received or not from Java layer*/ - void* rawRequest; - int reqID; /* ID to check against response */ - GpsUserResponseType resp; - pthread_cond_t tCond; - pthread_mutex_t tLock; - LocEngAdapter* adapter; -} loc_eng_ni_session_s_type; - -typedef struct { - loc_eng_ni_session_s_type session; /* SUPL NI Session */ - loc_eng_ni_session_s_type sessionEs; /* Emergency SUPL NI Session */ - int reqIDCounter; -} loc_eng_ni_data_s_type; - - -#endif /* LOC_ENG_NI_H */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp b/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp deleted file mode 100644 index e6fbec8..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp +++ /dev/null @@ -1,814 +0,0 @@ -/* Copyright (c) 2012, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_eng_nmea" -#define GPS_PRN_START 1 -#define GPS_PRN_END 32 -#define GLONASS_PRN_START 65 -#define GLONASS_PRN_END 96 -#include -#include -#include -#include "log_util.h" - -/*=========================================================================== -FUNCTION loc_eng_nmea_send - -DESCRIPTION - send out NMEA sentence - -DEPENDENCIES - NONE - -RETURN VALUE - Total length of the nmea sentence - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p) -{ - struct timeval tv; - gettimeofday(&tv, (struct timezone *) NULL); - int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000; - CALLBACK_LOG_CALLFLOW("nmea_cb", %p, pNmea); - if (loc_eng_data_p->nmea_cb != NULL) - loc_eng_data_p->nmea_cb(now, pNmea, length); - LOC_LOGD("NMEA <%s", pNmea); -} - -/*=========================================================================== -FUNCTION loc_eng_nmea_put_checksum - -DESCRIPTION - Generate NMEA sentences generated based on position report - -DEPENDENCIES - NONE - -RETURN VALUE - Total length of the nmea sentence - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_nmea_put_checksum(char *pNmea, int maxSize) -{ - uint8_t checksum = 0; - int length = 0; - - pNmea++; //skip the $ - while (*pNmea != '\0') - { - checksum ^= *pNmea++; - length++; - } - - int checksumLength = snprintf(pNmea,(maxSize-length-1),"*%02X\r\n", checksum); - return (length + checksumLength); -} - -/*=========================================================================== -FUNCTION loc_eng_nmea_generate_pos - -DESCRIPTION - Generate NMEA sentences generated based on position report - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, - const UlpLocation &location, - const GpsLocationExtended &locationExtended, - unsigned char generate_nmea) -{ - ENTRY_LOG(); - time_t utcTime(location.gpsLocation.timestamp/1000); - tm * pTm = gmtime(&utcTime); - if (NULL == pTm) { - LOC_LOGE("gmtime failed"); - return; - } - - char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0}; - char* pMarker = sentence; - int lengthRemaining = sizeof(sentence); - int length = 0; - int utcYear = pTm->tm_year % 100; // 2 digit year - int utcMonth = pTm->tm_mon + 1; // tm_mon starts at zero - int utcDay = pTm->tm_mday; - int utcHours = pTm->tm_hour; - int utcMinutes = pTm->tm_min; - int utcSeconds = pTm->tm_sec; - - if (generate_nmea) { - // ------------------ - // ------$GPGSA------ - // ------------------ - - uint32_t svUsedCount = 0; - uint32_t svUsedList[32] = {0}; - uint32_t mask = loc_eng_data_p->sv_used_mask; - for (uint8_t i = 1; mask > 0 && svUsedCount < 32; i++) - { - if (mask & 1) - svUsedList[svUsedCount++] = i; - mask = mask >> 1; - } - // clear the cache so they can't be used again - loc_eng_data_p->sv_used_mask = 0; - - char fixType; - if (svUsedCount == 0) - fixType = '1'; // no fix - else if (svUsedCount <= 3) - fixType = '2'; // 2D fix - else - fixType = '3'; // 3D fix - - length = snprintf(pMarker, lengthRemaining, "$GPGSA,A,%c,", fixType); - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - for (uint8_t i = 0; i < 12; i++) // only the first 12 sv go in sentence - { - if (i < svUsedCount) - length = snprintf(pMarker, lengthRemaining, "%02d,", svUsedList[i]); - else - length = snprintf(pMarker, lengthRemaining, ","); - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - } - - if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP) - { // dop is in locationExtended, (QMI) - length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f", - locationExtended.pdop, - locationExtended.hdop, - locationExtended.vdop); - } - else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0) - { // dop was cached from sv report (RPC) - length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f", - loc_eng_data_p->pdop, - loc_eng_data_p->hdop, - loc_eng_data_p->vdop); - } - else - { // no dop - length = snprintf(pMarker, lengthRemaining, ",,"); - } - - length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); - loc_eng_nmea_send(sentence, length, loc_eng_data_p); - - // ------------------ - // ------$GPVTG------ - // ------------------ - - pMarker = sentence; - lengthRemaining = sizeof(sentence); - - if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING) - { - float magTrack = location.gpsLocation.bearing; - if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV) - { - float magTrack = location.gpsLocation.bearing - locationExtended.magneticDeviation; - if (magTrack < 0.0) - magTrack += 360.0; - else if (magTrack > 360.0) - magTrack -= 360.0; - } - - length = snprintf(pMarker, lengthRemaining, "$GPVTG,%.1lf,T,%.1lf,M,", location.gpsLocation.bearing, magTrack); - } - else - { - length = snprintf(pMarker, lengthRemaining, "$GPVTG,,T,,M,"); - } - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED) - { - float speedKnots = location.gpsLocation.speed * (3600.0/1852.0); - float speedKmPerHour = location.gpsLocation.speed * 3.6; - - length = snprintf(pMarker, lengthRemaining, "%.1lf,N,%.1lf,K,", speedKnots, speedKmPerHour); - } - else - { - length = snprintf(pMarker, lengthRemaining, ",N,,K,"); - } - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)) - length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix - else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode) - length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous - else - length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential - - length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); - loc_eng_nmea_send(sentence, length, loc_eng_data_p); - - // ------------------ - // ------$GPRMC------ - // ------------------ - - pMarker = sentence; - lengthRemaining = sizeof(sentence); - - length = snprintf(pMarker, lengthRemaining, "$GPRMC,%02d%02d%02d,A," , - utcHours, utcMinutes, utcSeconds); - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG) - { - double latitude = location.gpsLocation.latitude; - double longitude = location.gpsLocation.longitude; - char latHemisphere; - char lonHemisphere; - double latMinutes; - double lonMinutes; - - if (latitude > 0) - { - latHemisphere = 'N'; - } - else - { - latHemisphere = 'S'; - latitude *= -1.0; - } - - if (longitude < 0) - { - lonHemisphere = 'W'; - longitude *= -1.0; - } - else - { - lonHemisphere = 'E'; - } - - latMinutes = fmod(latitude * 60.0 , 60.0); - lonMinutes = fmod(longitude * 60.0 , 60.0); - - length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,", - (uint8_t)floor(latitude), latMinutes, latHemisphere, - (uint8_t)floor(longitude),lonMinutes, lonHemisphere); - } - else - { - length = snprintf(pMarker, lengthRemaining,",,,,"); - } - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED) - { - float speedKnots = location.gpsLocation.speed * (3600.0/1852.0); - length = snprintf(pMarker, lengthRemaining, "%.1lf,", speedKnots); - } - else - { - length = snprintf(pMarker, lengthRemaining, ","); - } - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING) - { - length = snprintf(pMarker, lengthRemaining, "%.1lf,", location.gpsLocation.bearing); - } - else - { - length = snprintf(pMarker, lengthRemaining, ","); - } - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - length = snprintf(pMarker, lengthRemaining, "%2.2d%2.2d%2.2d,", - utcDay, utcMonth, utcYear); - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV) - { - float magneticVariation = locationExtended.magneticDeviation; - char direction; - if (magneticVariation < 0.0) - { - direction = 'W'; - magneticVariation *= -1.0; - } - else - { - direction = 'E'; - } - - length = snprintf(pMarker, lengthRemaining, "%.1lf,%c,", - magneticVariation, direction); - } - else - { - length = snprintf(pMarker, lengthRemaining, ",,"); - } - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)) - length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix - else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode) - length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous - else - length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential - - length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); - loc_eng_nmea_send(sentence, length, loc_eng_data_p); - - // ------------------ - // ------$GPGGA------ - // ------------------ - - pMarker = sentence; - lengthRemaining = sizeof(sentence); - - length = snprintf(pMarker, lengthRemaining, "$GPGGA,%02d%02d%02d," , - utcHours, utcMinutes, utcSeconds); - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG) - { - double latitude = location.gpsLocation.latitude; - double longitude = location.gpsLocation.longitude; - char latHemisphere; - char lonHemisphere; - double latMinutes; - double lonMinutes; - - if (latitude > 0) - { - latHemisphere = 'N'; - } - else - { - latHemisphere = 'S'; - latitude *= -1.0; - } - - if (longitude < 0) - { - lonHemisphere = 'W'; - longitude *= -1.0; - } - else - { - lonHemisphere = 'E'; - } - - latMinutes = fmod(latitude * 60.0 , 60.0); - lonMinutes = fmod(longitude * 60.0 , 60.0); - - length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,", - (uint8_t)floor(latitude), latMinutes, latHemisphere, - (uint8_t)floor(longitude),lonMinutes, lonHemisphere); - } - else - { - length = snprintf(pMarker, lengthRemaining,",,,,"); - } - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - char gpsQuality; - if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)) - gpsQuality = '0'; // 0 means no fix - else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode) - gpsQuality = '1'; // 1 means GPS fix - else - gpsQuality = '2'; // 2 means DGPS fix - - if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP) - { // dop is in locationExtended, (QMI) - length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,", - gpsQuality, svUsedCount, locationExtended.hdop); - } - else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0) - { // dop was cached from sv report (RPC) - length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,", - gpsQuality, svUsedCount, loc_eng_data_p->hdop); - } - else - { // no hdop - length = snprintf(pMarker, lengthRemaining, "%c,%02d,,", - gpsQuality, svUsedCount); - } - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL) - { - length = snprintf(pMarker, lengthRemaining, "%.1lf,M,", - locationExtended.altitudeMeanSeaLevel); - } - else - { - length = snprintf(pMarker, lengthRemaining,",,"); - } - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - if ((location.gpsLocation.flags & GPS_LOCATION_HAS_ALTITUDE) && - (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL)) - { - length = snprintf(pMarker, lengthRemaining, "%.1lf,M,,", - location.gpsLocation.altitude - locationExtended.altitudeMeanSeaLevel); - } - else - { - length = snprintf(pMarker, lengthRemaining,",,,"); - } - - length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); - loc_eng_nmea_send(sentence, length, loc_eng_data_p); - - } - //Send blank NMEA reports for non-final fixes - else { - strlcpy(sentence, "$GPGSA,A,1,,,,,,,,,,,,,,,", sizeof(sentence)); - length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); - loc_eng_nmea_send(sentence, length, loc_eng_data_p); - - strlcpy(sentence, "$GPVTG,,T,,M,,N,,K,N", sizeof(sentence)); - length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); - loc_eng_nmea_send(sentence, length, loc_eng_data_p); - - strlcpy(sentence, "$GPRMC,,V,,,,,,,,,,N", sizeof(sentence)); - length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); - loc_eng_nmea_send(sentence, length, loc_eng_data_p); - - strlcpy(sentence, "$GPGGA,,,,,,0,,,,,,,,", sizeof(sentence)); - length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); - loc_eng_nmea_send(sentence, length, loc_eng_data_p); - } - // clear the dop cache so they can't be used again - loc_eng_data_p->pdop = 0; - loc_eng_data_p->hdop = 0; - loc_eng_data_p->vdop = 0; - - EXIT_LOG(%d, 0); -} - - - -/*=========================================================================== -FUNCTION loc_eng_nmea_generate_sv - -DESCRIPTION - Generate NMEA sentences generated based on sv report - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, - const HaxxSvStatus &svStatus, const GpsLocationExtended &locationExtended) -{ - ENTRY_LOG(); - - char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0}; - char* pMarker = sentence; - int lengthRemaining = sizeof(sentence); - int length = 0; - int svCount = svStatus.num_svs; - int sentenceCount = 0; - int sentenceNumber = 1; - int svNumber = 1; - int gpsCount = 0; - int glnCount = 0; - - //Count GPS SVs for saparating GPS from GLONASS and throw others - - for(svNumber=1; svNumber <= svCount; svNumber++) { - if( (svStatus.sv_list[svNumber-1].prn >= GPS_PRN_START)&& - (svStatus.sv_list[svNumber-1].prn <= GPS_PRN_END) ) - { - gpsCount++; - } - else if( (svStatus.sv_list[svNumber-1].prn >= GLONASS_PRN_START) && - (svStatus.sv_list[svNumber-1].prn <= GLONASS_PRN_END) ) - { - glnCount++; - } - } - - // ------------------ - // ------$GPGSV------ - // ------------------ - - if (gpsCount <= 0) - { - // no svs in view, so just send a blank $GPGSV sentence - strlcpy(sentence, "$GPGSV,1,1,0,", sizeof(sentence)); - length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); - loc_eng_nmea_send(sentence, length, loc_eng_data_p); - } - else - { - svNumber = 1; - sentenceNumber = 1; - sentenceCount = gpsCount/4 + (gpsCount % 4 != 0); - - while (sentenceNumber <= sentenceCount) - { - pMarker = sentence; - lengthRemaining = sizeof(sentence); - - length = snprintf(pMarker, lengthRemaining, "$GPGSV,%d,%d,%02d", - sentenceCount, sentenceNumber, gpsCount); - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - for (int i=0; (svNumber <= svCount) && (i < 4); svNumber++) - { - if( (svStatus.sv_list[svNumber-1].prn >= GPS_PRN_START) && - (svStatus.sv_list[svNumber-1].prn <= GPS_PRN_END) ) - { - length = snprintf(pMarker, lengthRemaining,",%02d,%02d,%03d,", - svStatus.sv_list[svNumber-1].prn, - (int)(0.5 + svStatus.sv_list[svNumber-1].elevation), //float to int - (int)(0.5 + svStatus.sv_list[svNumber-1].azimuth)); //float to int - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - if (svStatus.sv_list[svNumber-1].snr > 0) - { - length = snprintf(pMarker, lengthRemaining,"%02d", - (int)(0.5 + svStatus.sv_list[svNumber-1].snr)); //float to int - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - } - - i++; - } - - } - - length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); - loc_eng_nmea_send(sentence, length, loc_eng_data_p); - sentenceNumber++; - - } //while - - } //if - - // ------------------ - // ------$GLGSV------ - // ------------------ - - if (glnCount <= 0) - { - // no svs in view, so just send a blank $GLGSV sentence - strlcpy(sentence, "$GLGSV,1,1,0,", sizeof(sentence)); - length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); - loc_eng_nmea_send(sentence, length, loc_eng_data_p); - } - else - { - svNumber = 1; - sentenceNumber = 1; - sentenceCount = glnCount/4 + (glnCount % 4 != 0); - - while (sentenceNumber <= sentenceCount) - { - pMarker = sentence; - lengthRemaining = sizeof(sentence); - - length = snprintf(pMarker, lengthRemaining, "$GLGSV,%d,%d,%02d", - sentenceCount, sentenceNumber, glnCount); - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - for (int i=0; (svNumber <= svCount) && (i < 4); svNumber++) - { - if( (svStatus.sv_list[svNumber-1].prn >= GLONASS_PRN_START) && - (svStatus.sv_list[svNumber-1].prn <= GLONASS_PRN_END) ) { - - length = snprintf(pMarker, lengthRemaining,",%02d,%02d,%03d,", - svStatus.sv_list[svNumber-1].prn, - (int)(0.5 + svStatus.sv_list[svNumber-1].elevation), //float to int - (int)(0.5 + svStatus.sv_list[svNumber-1].azimuth)); //float to int - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - - if (svStatus.sv_list[svNumber-1].snr > 0) - { - length = snprintf(pMarker, lengthRemaining,"%02d", - (int)(0.5 + svStatus.sv_list[svNumber-1].snr)); //float to int - - if (length < 0 || length >= lengthRemaining) - { - LOC_LOGE("NMEA Error in string formatting"); - return; - } - pMarker += length; - lengthRemaining -= length; - } - - i++; - } - - } - - length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); - loc_eng_nmea_send(sentence, length, loc_eng_data_p); - sentenceNumber++; - - } //while - - }//if - - // cache the used in fix mask, as it will be needed to send $GPGSA - // during the position report - loc_eng_data_p->sv_used_mask = svStatus.gps_used_in_fix_mask; - - // For RPC, the DOP are sent during sv report, so cache them - // now to be sent during position report. - // For QMI, the DOP will be in position report. - if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP) - { - loc_eng_data_p->pdop = locationExtended.pdop; - loc_eng_data_p->hdop = locationExtended.hdop; - loc_eng_data_p->vdop = locationExtended.vdop; - } - else - { - loc_eng_data_p->pdop = 0; - loc_eng_data_p->hdop = 0; - loc_eng_data_p->vdop = 0; - } - - EXIT_LOG(%d, 0); -} diff --git a/gps/loc_api/libloc_api_50001/loc_eng_nmea.h b/gps/loc_api/libloc_api_50001/loc_eng_nmea.h deleted file mode 100644 index 7b0c524..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_nmea.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (c) 2012, 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_ENG_NMEA_H -#define LOC_ENG_NMEA_H - -#include -#include - -#define NMEA_SENTENCE_MAX_LENGTH 200 - -void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p); -int loc_eng_nmea_put_checksum(char *pNmea, int maxSize); -void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, const HaxxSvStatus &svStatus, const GpsLocationExtended &locationExtended); -void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, const UlpLocation &location, const GpsLocationExtended &locationExtended, unsigned char generate_nmea); - -#endif // LOC_ENG_NMEA_H diff --git a/gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp b/gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp deleted file mode 100644 index 7bb8083..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_eng" - -#include -#include -#include "log_util.h" -#include "platform_lib_includes.h" - -using namespace loc_core; - -struct LocEngRequestXtraServer : public LocMsg { - LocEngAdapter* mAdapter; - inline LocEngRequestXtraServer(LocEngAdapter* adapter) : - LocMsg(), mAdapter(adapter) - { - locallog(); - } - inline virtual void proc() const { - mAdapter->requestXtraServer(); - } - inline void locallog() const { - LOC_LOGV("LocEngRequestXtraServer"); - } - inline virtual void log() const { - locallog(); - } -}; - -struct LocEngInjectXtraData : public LocMsg { - LocEngAdapter* mAdapter; - char* mData; - const int mLen; - inline LocEngInjectXtraData(LocEngAdapter* adapter, - char* data, int len): - LocMsg(), mAdapter(adapter), - mData(new char[len]), mLen(len) - { - memcpy((void*)mData, (void*)data, len); - locallog(); - } - inline ~LocEngInjectXtraData() - { - delete[] mData; - } - inline virtual void proc() const { - mAdapter->setXtraData(mData, mLen); - } - inline void locallog() const { - LOC_LOGV("length: %d\n data: %p", mLen, mData); - } - inline virtual void log() const { - locallog(); - } -}; - -struct LocEngSetXtraVersionCheck : public LocMsg { - LocEngAdapter *mAdapter; - int mCheck; - inline LocEngSetXtraVersionCheck(LocEngAdapter* adapter, - int check): - mAdapter(adapter), mCheck(check) {} - inline virtual void proc() const { - locallog(); - mAdapter->setXtraVersionCheck(mCheck); - } - inline void locallog() const { - LOC_LOGD("%s:%d]: mCheck: %d", - __func__, __LINE__, mCheck); - } - inline virtual void log() const { - locallog(); - } -}; - -/*=========================================================================== -FUNCTION loc_eng_xtra_init - -DESCRIPTION - Initialize XTRA module. - -DEPENDENCIES - N/A - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data, - GpsXtraExtCallbacks* callbacks) -{ - int ret_val = -1; - loc_eng_xtra_data_s_type *xtra_module_data_ptr; - ENTRY_LOG(); - - if(callbacks == NULL) { - LOC_LOGE("loc_eng_xtra_init: failed, cb is NULL"); - } else { - xtra_module_data_ptr = &loc_eng_data.xtra_module_data; - xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb; - xtra_module_data_ptr->report_xtra_server_cb = callbacks->report_xtra_server_cb; - - ret_val = 0; - } - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_eng_xtra_inject_data - -DESCRIPTION - Injects XTRA file into the engine but buffers the data if engine is busy. - -DEPENDENCIES - N/A - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data, - char* data, int length) -{ - ENTRY_LOG(); - LocEngAdapter* adapter = loc_eng_data.adapter; - adapter->sendMsg(new LocEngInjectXtraData(adapter, data, length)); - EXIT_LOG(%d, 0); - return 0; -} -/*=========================================================================== -FUNCTION loc_eng_xtra_request_server - -DESCRIPTION - Request the Xtra server url from the modem - -DEPENDENCIES - N/A - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data) -{ - ENTRY_LOG(); - LocEngAdapter* adapter = loc_eng_data.adapter; - adapter->sendMsg(new LocEngRequestXtraServer(adapter)); - EXIT_LOG(%d, 0); - return 0; -} -/*=========================================================================== -FUNCTION loc_eng_xtra_version_check - -DESCRIPTION - Injects the enable/disable value for checking XTRA version - that is specified in gps.conf - -DEPENDENCIES - N/A - -RETURN VALUE - none - -SIDE EFFECTS - N/A - -===========================================================================*/ -void loc_eng_xtra_version_check(loc_eng_data_s_type &loc_eng_data, - int check) -{ - ENTRY_LOG(); - LocEngAdapter *adapter = loc_eng_data.adapter; - adapter->sendMsg(new LocEngSetXtraVersionCheck(adapter, check)); - EXIT_LOG(%d, 0); -} diff --git a/gps/loc_api/libloc_api_50001/loc_eng_xtra.h b/gps/loc_api/libloc_api_50001/loc_eng_xtra.h deleted file mode 100644 index 175f497..0000000 --- a/gps/loc_api/libloc_api_50001/loc_eng_xtra.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (c) 2009,2011 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_ENG_XTRA_H -#define LOC_ENG_XTRA_H - -#include - -// Module data -typedef struct -{ - // loc_eng_ioctl_cb_data_s_type ioctl_cb_data; - gps_xtra_download_request download_request_cb; - report_xtra_server report_xtra_server_cb; - - // XTRA data buffer - char *xtra_data_for_injection; // NULL if no pending data - int xtra_data_len; -} loc_eng_xtra_data_s_type; - -#endif // LOC_ENG_XTRA_H diff --git a/gps/utils/Android.mk b/gps/utils/Android.mk deleted file mode 100755 index 2968370..0000000 --- a/gps/utils/Android.mk +++ /dev/null @@ -1,48 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -## Libs -LOCAL_SHARED_LIBRARIES := \ - libutils \ - libcutils \ - liblog - -LOCAL_SRC_FILES += \ - loc_log.cpp \ - loc_cfg.cpp \ - 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 - -# Flag -std=c++11 is not accepted by compiler when LOCAL_CLANG is set to true -LOCAL_CFLAGS += \ - -fno-short-enums \ - -D_ANDROID_ - -ifeq ($(TARGET_BUILD_VARIANT),user) - LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER -endif - -LOCAL_LDFLAGS += -Wl,--export-dynamic - -## Includes -LOCAL_C_INCLUDES:= \ - $(LOCAL_PATH)/platform_lib_abstractions - -LOCAL_MODULE := libgps.utils -LOCAL_MODULE_OWNER := qcom -LOCAL_PROPRIETARY_MODULE := true - -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libgps.utils_headers -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) $(LOCAL_PATH)/platform_lib_abstractions -include $(BUILD_HEADER_LIBRARY) diff --git a/gps/utils/LocHeap.cpp b/gps/utils/LocHeap.cpp deleted file mode 100644 index d667f14..0000000 --- a/gps/utils/LocHeap.cpp +++ /dev/null @@ -1,354 +0,0 @@ -/* Copyright (c) 2015, 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 - -class LocHeapNode { - friend class LocHeap; - - // size of of the subtree, excluding self, 1 if no subtree - int mSize; - LocHeapNode* mLeft; - LocHeapNode* mRight; - LocRankable* mData; -public: - inline LocHeapNode(LocRankable& data) : - mSize(1), mLeft(NULL), mRight(NULL), mData(&data) {} - ~LocHeapNode(); - - // this only swaps the data of the two nodes, so no - // detach / re-attached is necessary - void swap(LocHeapNode& node); - - LocRankable* detachData(); - - // push a node into the tree stucture, keeping sorted by rank - void push(LocHeapNode& node); - - // pop the head node out of the tree stucture. keeping sorted by rank - static LocHeapNode* pop(LocHeapNode*& top); - - // remove a specific node from the tree - // returns the pointer to the node removed, which would be either the - // same as input (if successfully removed); or NULL (if failed). - static LocHeapNode* remove(LocHeapNode*& top, LocRankable& data); - - // convenience method to compare data ranking - inline bool outRanks(LocHeapNode& node) { return mData->outRanks(*node.mData); } - inline bool outRanks(LocRankable& data) { return mData->outRanks(data); } - - // checks if mSize is correct, AND this node is the highest ranking - // of the entire subtree - bool checkNodes(); - - inline int getSize() { return mSize; } -}; - -inline -LocHeapNode::~LocHeapNode() { - if (mLeft) { - delete mLeft; - mLeft = NULL; - } - if (mRight) { - delete mRight; - mRight = NULL; - } - if (mData) { - mData = NULL; - } -} - -inline -void LocHeapNode::swap(LocHeapNode& node) { - LocRankable* tmpData = node.mData; - node.mData = mData; - mData = tmpData; -} - -inline -LocRankable* LocHeapNode::detachData() { - LocRankable* data = mData; - mData = NULL; - return data; -} - -// push keeps the tree sorted by rank, it also tries to balance the -// tree by adding the new node to the smaller of the subtrees. -// The pointer to the tree and internal links never change. If the -// mData of tree top ranks lower than that of the incoming node, -// mData will be swapped with that of the incoming node to ensure -// ranking, no restructuring the container nodes. -void LocHeapNode::push(LocHeapNode& node) { - // ensure the current node ranks higher than in the incoming one - if (node.outRanks(*this)) { - swap(node); - } - - // now drop the new node (ensured lower than *this) into a subtree - if (NULL == mLeft) { - mLeft = &node; - } else if (NULL == mRight) { - mRight = &node; - } else if (mLeft->mSize <= mRight->mSize) { - mLeft->push(node); - } else { - mRight->push(node); - } - mSize++; -} - -// pop keeps the tree sorted by rank, but it does not try to balance -// the tree. It recursively swaps with the higher ranked top of the -// subtrees. -// The return is a popped out node from leaf level, that has the data -// swapped all the way down from the top. The pinter to the tree and -// internal links will not be changed or restructured, except for the -// node that is popped out. -// If the return pointer == this, this the last node in the tree. -LocHeapNode* LocHeapNode::pop(LocHeapNode*& top) { - // we know the top has the highest ranking at this point, else - // the tree is broken. This top will be popped out. But we need - // a node from the left or right child, whichever ranks higher, - // to replace the current top. This then will need to be done - // recursively to the leaf level. So we swap the mData of the - // current top node all the way down to the leaf level. - LocHeapNode* poppedNode = top; - // top is losing a node in its subtree - top->mSize--; - if (top->mLeft || top->mRight) { - // if mLeft is NULL, mRight for sure is NOT NULL, take that; - // else if mRight is NULL, mLeft for sure is NOT, take that; - // else we take the address of whatever has higher ranking mData - LocHeapNode*& subTop = (NULL == top->mLeft) ? top->mRight : - ((NULL == top->mRight) ? top->mLeft : - (top->mLeft->outRanks(*(top->mRight)) ? top->mLeft : top->mRight)); - // swap mData, the tree top gets updated with the new data. - top->swap(*subTop); - // pop out from the subtree - poppedNode = pop(subTop); - } else { - // if the top has only single node - // detach the poppedNode from the tree - // subTop is the reference of ether mLeft or mRight - // NOT a local stack pointer. so it MUST be NULL'ed here. - top = NULL; - } - - return poppedNode; -} - -// navigating through the tree and find the node that hass the input -// data. Since this is a heap, we do recursive linear search. -// returns the pointer to the node removed, which would be either the -// same as input (if successfully removed); or NULL (if failed). -LocHeapNode* LocHeapNode::remove(LocHeapNode*& top, LocRankable& data) { - LocHeapNode* removedNode = NULL; - // this is the node, by address - if (&data == (LocRankable*)(top->mData)) { - // pop this node out - removedNode = pop(top); - } else if (!data.outRanks(*top->mData)) { - // subtrees might have this node - if (top->mLeft) { - removedNode = remove(top->mLeft, data); - } - // if we did not find in mLeft, and mRight is not empty - if (!removedNode && top->mRight) { - removedNode = remove(top->mRight, data); - } - - // top lost a node in its subtree - if (removedNode) { - top->mSize--; - } - } - - return removedNode; -} - -// checks if mSize is correct, AND this node is the highest ranking -// of the entire subtree -bool LocHeapNode::checkNodes() { - // size of the current subtree - int totalSize = mSize; - if (mLeft) { - // check the consistency of left subtree - if (mLeft->outRanks(*this) || !mLeft->checkNodes()) { - return false; - } - // subtract the size of left subtree (with subtree head) - totalSize -= mLeft->mSize; - } - - if (mRight) { - // check the consistency of right subtree - if (mRight->outRanks(*this) || !mRight->checkNodes()) { - return false; - } - // subtract the size of right subtree (with subtree head) - totalSize -= mRight->mSize; - } - - // for the tree nodes to consistent, totalSize must be 1 now - return totalSize == 1; -} - -LocHeap::~LocHeap() { - if (mTree) { - delete mTree; - } -} - -void LocHeap::push(LocRankable& node) { - LocHeapNode* heapNode = new LocHeapNode(node); - if (!mTree) { - mTree = heapNode; - } else { - mTree->push(*heapNode); - } -} - -LocRankable* LocHeap::peek() { - LocRankable* top = NULL; - if (mTree) { - top = mTree->mData; - } - return top; -} - -LocRankable* LocHeap::pop() { - LocRankable* locNode = NULL; - if (mTree) { - // mTree may become NULL after this call - LocHeapNode* heapNode = LocHeapNode::pop(mTree); - locNode = heapNode->detachData(); - delete heapNode; - } - return locNode; -} - -LocRankable* LocHeap::remove(LocRankable& rankable) { - LocRankable* locNode = NULL; - if (mTree) { - // mTree may become NULL after this call - LocHeapNode* heapNode = LocHeapNode::remove(mTree, rankable); - if (heapNode) { - locNode = heapNode->detachData(); - delete heapNode; - } - } - return locNode; -} - -#ifdef __LOC_UNIT_TEST__ -bool LocHeap::checkTree() { - return ((NULL == mTree) || mTree->checkNodes()); -} -uint32_t LocHeap::getTreeSize() { - return (NULL == mTree) ? 0 : mTree->getSize(); -} -#endif - -#ifdef __LOC_DEBUG__ - -#include -#include -#include - -class LocHeapDebug : public LocHeap { -public: - bool checkTree() { - return ((NULL == mTree) || mTree->checkNodes()); - } - - uint32_t getTreeSize() { - return (NULL == mTree) ? 0 : (mTree->getSize()); - } -}; - -class LocHeapDebugData : public LocRankable { - const int mID; -public: - LocHeapDebugData(int id) : mID(id) {} - inline virtual int ranks(LocRankable& rankable) { - LocHeapDebugData* testData = dynamic_cast(&rankable); - return testData->mID - mID; - } -}; - -// For Linux command line testing: -// compilation: g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -I. -I../../../../vendor/qcom/proprietary/gps-internal/unit-tests/fakes_for_host -I../../../../system/core/include LocHeap.cpp -// test: valgrind --leak-check=full ./a.out 100 -int main(int argc, char** argv) { - srand(time(NULL)); - int tries = atoi(argv[1]); - int checks = tries >> 3; - LocHeapDebug heap; - int treeSize = 0; - - for (int i = 0; i < tries; i++) { - if (i % checks == 0 && !heap.checkTree()) { - printf("tree check failed before %dth op\n", i); - } - int r = rand(); - - if (r & 1) { - LocHeapDebugData* data = new LocHeapDebugData(r >> 1); - heap.push(dynamic_cast(*data)); - treeSize++; - } else { - LocRankable* rankable = heap.pop(); - if (rankable) { - delete rankable; - } - treeSize ? treeSize-- : 0; - } - - printf("%s: %d == %d\n", (r&1)?"push":"pop", treeSize, heap.getTreeSize()); - if (treeSize != heap.getTreeSize()) { - printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - tries = i+1; - break; - } - } - - if (!heap.checkTree()) { - printf("!!!!!!!!!!tree check failed at the end after %d ops!!!!!!!\n", tries); - } else { - printf("success!\n"); - } - - for (LocRankable* data = heap.pop(); NULL != data; data = heap.pop()) { - delete data; - } - - return 0; -} - -#endif diff --git a/gps/utils/LocHeap.h b/gps/utils/LocHeap.h deleted file mode 100644 index b491948..0000000 --- a/gps/utils/LocHeap.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (c) 2015, 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_HEAP__ -#define __LOC_HEAP__ - -#include -#include - -// abstract class to be implemented by client to provide a rankable class -class LocRankable { -public: - virtual inline ~LocRankable() {} - - // method to rank objects of such type for sorting purposes. - // The pointer of the input node would be stored in the heap. - // >0 if ranks higher than the input; - // ==0 if equally ranks with the input; - // <0 if ranks lower than the input - virtual int ranks(LocRankable& rankable) = 0; - - // convenient method to rank objects of such type for sorting purposes. - inline bool outRanks(LocRankable& rankable) { return ranks(rankable) > 0; } -}; - -// opaque class to provide service implementation. -class LocHeapNode; - -// a heap whose left and right children are not sorted. It is sorted only vertically, -// i.e. parent always ranks higher than children, if they exist. Ranking algorithm is -// implemented in Rankable. The reason that there is no sort between children is to -// help beter balance the tree with lower cost. When a node is pushed to the tree, -// it is guaranteed that the subtree that is smaller gets to have the new node. -class LocHeap { -protected: - LocHeapNode* mTree; -public: - inline LocHeap() : mTree(NULL) {} - ~LocHeap(); - - // push keeps the tree sorted by rank, it also tries to balance the - // tree by adding the new node to the smaller of the subtrees. - // node is reference to an obj that is managed by client, that client - // creates and destroyes. The destroy should happen after the - // node is popped out from the heap. - void push(LocRankable& node); - - // Peeks the node data on tree top, which has currently the highest ranking - // There is no change the tree structure with this operation - // Returns NULL if the tree is empty, otherwise pointer to the node data of - // the tree top. - LocRankable* peek(); - - // pop keeps the tree sorted by rank, but it does not try to balance - // the tree. - // Return - pointer to the node popped out, or NULL if heap is already empty - LocRankable* pop(); - - // navigating through the tree and find the node that ranks the same - // as the input data, then remove it from the tree. Rank is implemented - // by rankable obj. - // returns the pointer to the node removed; or NULL (if failed). - LocRankable* remove(LocRankable& rankable); - -#ifdef __LOC_UNIT_TEST__ - bool checkTree(); - uint32_t getTreeSize(); -#endif -}; - -#endif //__LOC_HEAP__ diff --git a/gps/utils/LocSharedLock.h b/gps/utils/LocSharedLock.h deleted file mode 100644 index 7fe6237..0000000 --- a/gps/utils/LocSharedLock.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (c) 2015, 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_SHARED_LOCK__ -#define __LOC_SHARED_LOCK__ - -#include -#include -#include - -// This is a utility created for use cases such that there are more than -// one client who need to share the same lock, but it is not predictable -// which of these clients is to last to go away. This shared lock deletes -// itself when the last client calls its drop() method. To add a cient, -// this share lock's share() method has to be called, so that the obj -// can maintain an accurate client count. -class LocSharedLock { - volatile int32_t mRef; - pthread_mutex_t mMutex; - inline ~LocSharedLock() { pthread_mutex_destroy(&mMutex); } -public: - // first client to create this LockSharedLock - inline LocSharedLock() : mRef(1) { pthread_mutex_init(&mMutex, NULL); } - // following client(s) are to *share()* this lock created by the first client - inline LocSharedLock* share() { android_atomic_inc(&mRef); return this; } - // whe a client no longer needs this shared lock, drop() shall be called. - inline void drop() { if (1 == android_atomic_dec(&mRef)) delete this; } - // locking the lock to enter critical section - inline void lock() { pthread_mutex_lock(&mMutex); } - // unlocking the lock to leave the critical section - inline void unlock() { pthread_mutex_unlock(&mMutex); } -}; - -#endif //__LOC_SHARED_LOCK__ diff --git a/gps/utils/LocThread.cpp b/gps/utils/LocThread.cpp deleted file mode 100644 index 19bf101..0000000 --- a/gps/utils/LocThread.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* Copyright (c) 2015, 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 -#include -#include - -class LocThreadDelegate { - LocRunnable* mRunnable; - bool mJoinable; - pthread_t mThandle; - pthread_mutex_t mMutex; - int mRefCount; - ~LocThreadDelegate(); - LocThreadDelegate(LocThread::tCreate creator, const char* threadName, - LocRunnable* runnable, bool joinable); - void destroy(); -public: - static LocThreadDelegate* create(LocThread::tCreate creator, - const char* threadName, LocRunnable* runnable, bool joinable); - void stop(); - // bye() is for the parent thread to go away. if joinable, - // parent must stop the spawned thread, join, and then - // destroy(); if detached, the parent can go straight - // ahead to destroy() - inline void bye() { mJoinable ? stop() : destroy(); } - inline bool isRunning() { return (NULL != mRunnable); } - static void* threadMain(void* arg); -}; - -// it is important to note that internal members must be -// initialized to values as if pthread_create succeeds. -// This is to avoid the race condition between the threads, -// once the thread is created, some of these values will -// be check in the spawned thread, and must set correctly -// then and there. -// However, upon pthread_create failure, the data members -// must be set to indicate failure, e.g. mRunnable, and -// threashold approprietly for destroy(), e.g. mRefCount. -LocThreadDelegate::LocThreadDelegate(LocThread::tCreate creator, - const char* threadName, LocRunnable* runnable, bool joinable) : - mRunnable(runnable), mJoinable(joinable), mThandle(NULL), - mMutex(PTHREAD_MUTEX_INITIALIZER), mRefCount(2) { - - // set up thread name, if nothing is passed in - if (!threadName) { - threadName = "LocThread"; - } - - // create the thread here, then if successful - // and a name is given, we set the thread name - if (creator) { - mThandle = creator(threadName, threadMain, this); - } else if (pthread_create(&mThandle, NULL, threadMain, this)) { - // pthread_create() failed - mThandle = NULL; - } - - if (mThandle) { - // set thread name - char lname[16]; - int len = sizeof(lname) - 1; - memcpy(lname, threadName, len); - lname[len] = 0; - // set the thread name here - pthread_setname_np(mThandle, lname); - - // detach, if not joinable - if (!joinable) { - pthread_detach(mThandle); - } - } else { - // must set these values upon failure - mRunnable = NULL; - mJoinable = false; - mRefCount = 1; - } -} - -inline -LocThreadDelegate::~LocThreadDelegate() { - // at this point nothing should need done any more -} - -// factory method so that we could return NULL upon failure -LocThreadDelegate* LocThreadDelegate::create(LocThread::tCreate creator, - const char* threadName, LocRunnable* runnable, bool joinable) { - LocThreadDelegate* thread = NULL; - if (runnable) { - thread = new LocThreadDelegate(creator, threadName, runnable, joinable); - if (thread && !thread->isRunning()) { - thread->destroy(); - thread = NULL; - } - } - - return thread; -} - -// The order is importang -// NULLing mRunnalbe stops the while loop in threadMain() -// join() if mJoinble must come before destroy() call, as -// the obj must remain alive at this time so that mThandle -// remains valud. -void LocThreadDelegate::stop() { - // mRunnable and mJoinable are reset on different triggers. - // mRunnable may get nulled on the spawned thread's way out; - // or here. - // mJouinable (if ever been true) gets falsed when client - // thread triggers stop, with either a stop() - // call or the client releases thread obj handle. - if (mRunnable) { - mRunnable = NULL; - } - if (mJoinable) { - mJoinable = false; - pthread_join(mThandle, NULL); - } - // call destroy() to possibly delete the obj - destroy(); -} - -// method for clients to call to release the obj -// when it is a detached thread, the client thread -// and the spawned thread can both try to destroy() -// asynchronously. And we delete this obj when -// mRefCount becomes 0. -void LocThreadDelegate::destroy() { - // else case shouldn't happen, unless there is a - // leaking obj. But only our code here has such - // obj, so if we test our code well, else case - // will never happen - if (mRefCount > 0) { - // we need a flag on the stack - bool callDelete = false; - - // critical section between threads - pthread_mutex_lock(&mMutex); - // last destroy() call - callDelete = (1 == mRefCount--); - pthread_mutex_unlock(&mMutex); - - // upon last destroy() call we delete this obj - if (callDelete) { - delete this; - } - } -} - -void* LocThreadDelegate::threadMain(void* arg) { - LocThreadDelegate* locThread = (LocThreadDelegate*)(arg); - - if (locThread) { - LocRunnable* runnable = locThread->mRunnable; - - if (runnable) { - if (locThread->isRunning()) { - runnable->prerun(); - } - - while (locThread->isRunning() && runnable->run()); - - if (locThread->isRunning()) { - runnable->postrun(); - } - - // at this time, locThread->mRunnable may or may not be NULL - // NULL it just to be safe and clean, as we want the field - // in the released memory slot to be NULL. - locThread->mRunnable = NULL; - delete runnable; - } - locThread->destroy(); - } - - return NULL; -} - -LocThread::~LocThread() { - if (mThread) { - mThread->bye(); - mThread = NULL; - } -} - -bool LocThread::start(tCreate creator, const char* threadName, LocRunnable* runnable, bool joinable) { - bool success = false; - if (!mThread) { - mThread = LocThreadDelegate::create(creator, threadName, runnable, joinable); - // true only if thread is created successfully - success = (NULL != mThread); - } - return success; -} - -void LocThread::stop() { - if (mThread) { - mThread->stop(); - mThread = NULL; - } -} - -#ifdef __LOC_DEBUG__ - -#include -#include -#include - -class LocRunnableTest1 : public LocRunnable { - int mID; -public: - LocRunnableTest1(int id) : LocRunnable(), mID(id) {} - virtual bool run() { - printf("LocRunnableTest1: %d\n", mID++); - sleep(1); - return true; - } -}; - -// on linux command line: -// compile: g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -std=c++0x -I. -I../../../../vendor/qcom/proprietary/gps-internal/unit-tests/fakes_for_host -I../../../../system/core/include -lpthread LocThread.cpp -// test detached thread: valgrind ./a.out 0 -// test joinable thread: valgrind ./a.out 1 -int main(int argc, char** argv) { - LocRunnableTest1 test(10); - - LocThread thread; - thread.start("LocThreadTest", test, atoi(argv[1])); - - sleep(10); - - thread.stop(); - - sleep(5); - - return 0; -} - -#endif diff --git a/gps/utils/LocThread.h b/gps/utils/LocThread.h deleted file mode 100644 index 2a65d8f..0000000 --- a/gps/utils/LocThread.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (c) 2015, 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_THREAD__ -#define __LOC_THREAD__ - -#include -#include - -// abstract class to be implemented by client to provide a runnable class -// which gets scheduled by LocThread -class LocRunnable { -public: - inline LocRunnable() {} - inline virtual ~LocRunnable() {} - - // The method to be implemented by thread clients - // and be scheduled by LocThread - // This method will be repeated called until it returns false; or - // until thread is stopped. - virtual bool run() = 0; - - // The method to be run before thread loop (conditionally repeatedly) - // calls run() - inline virtual void prerun() {} - - // The method to be run after thread loop (conditionally repeatedly) - // calls run() - inline virtual void postrun() {} -}; - -// opaque class to provide service implementation. -class LocThreadDelegate; - -// A utility class to create a thread and run LocRunnable -// caller passes in. -class LocThread { - LocThreadDelegate* mThread; -public: - inline LocThread() : mThread(NULL) {} - virtual ~LocThread(); - - typedef pthread_t (*tCreate)(const char* name, void* (*start)(void*), void* arg); - // client starts thread with a runnable, which implements - // the logics to fun in the created thread context. - // The thread could be either joinable or detached. - // runnable is an obj managed by client. Client creates and - // frees it (but must be after stop() is called, or - // this LocThread obj is deleted). - // The obj will be deleted by LocThread if start() - // returns true. Else it is client's responsibility - // to delete the object - // Returns 0 if success; false if failure. - bool start(tCreate creator, const char* threadName, LocRunnable* runnable, bool joinable = true); - inline bool start(const char* threadName, LocRunnable* runnable, bool joinable = true) { - return start(NULL, threadName, runnable, joinable); - } - - // NOTE: if this is a joinable thread, this stop may block - // for a while until the thread is joined. - void stop(); - - // thread status check - inline bool isRunning() { return NULL != mThread; } -}; - -#endif //__LOC_THREAD__ diff --git a/gps/utils/LocTimer.cpp b/gps/utils/LocTimer.cpp deleted file mode 100644 index 70904b2..0000000 --- a/gps/utils/LocTimer.cpp +++ /dev/null @@ -1,737 +0,0 @@ -/* Copyright (c) 2015, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __HOST_UNIT_TEST__ -#define EPOLLWAKEUP 0 -#define CLOCK_BOOTTIME CLOCK_MONOTONIC -#define CLOCK_BOOTTIME_ALARM CLOCK_MONOTONIC -#endif - -/* -There are implementations of 5 classes in this file: -LocTimer, LocTimerDelegate, LocTimerContainer, LocTimerPollTask, LocTimerWrapper - -LocTimer - client front end, interface for client to start / stop timers, also - to provide a callback. -LocTimerDelegate - an internal timer entity, which also is a LocRankable obj. - Its life cycle is different than that of LocTimer. It gets - created when LocTimer::start() is called, and gets deleted - when it expires or clients calls the hosting LocTimer obj's - stop() method. When a LocTimerDelegate obj is ticking, it - stays in the corresponding LocTimerContainer. When expired - or stopped, the obj is removed from the container. Since it - is also a LocRankable obj, and LocTimerContainer also is a - heap, its ranks() implementation decides where it is placed - in the heap. -LocTimerContainer - core of the timer service. It is a container (derived from - LocHeap) for LocTimerDelegate (implements LocRankable) objs. - There are 2 of such containers, one for sw timers (or Linux - timers) one for hw timers (or Linux alarms). It adds one of - each (those that expire the soonest) to kernel via services - provided by LocTimerPollTask. All the heap management on the - LocTimerDelegate objs are done in the MsgTask context, such - that synchronization is ensured. -LocTimerPollTask - is a class that wraps timerfd and epoll POXIS APIs. It also - both implements LocRunnalbe with epoll_wait() in the run() - method. It is also a LocThread client, so as to loop the run - method. -LocTimerWrapper - a LocTimer client itself, to implement the existing C API with - APIs, loc_timer_start() and loc_timer_stop(). - -*/ - -class LocTimerPollTask; - -// This is a multi-functaional class that: -// * extends the LocHeap class for the detection of head update upon add / remove -// events. When that happens, soonest time out changes, so timerfd needs update. -// * contains the timers, and add / remove them into the heap -// * provides and maps 2 of such containers, one for timers (or mSwTimers), one -// for alarms (or mHwTimers); -// * provides a polling thread; -// * provides a MsgTask thread for synchronized add / remove / timer client callback. -class LocTimerContainer : public LocHeap { - // mutex to synchronize getters of static members - static pthread_mutex_t mMutex; - // Container of timers - static LocTimerContainer* mSwTimers; - // Container of alarms - static LocTimerContainer* mHwTimers; - // Msg task to provider msg Q, sender and reader. - static MsgTask* mMsgTask; - // Poll task to provide epoll call and threading to poll. - static LocTimerPollTask* mPollTask; - // timer / alarm fd - int mDevFd; - // ctor - LocTimerContainer(bool wakeOnExpire); - // dtor - ~LocTimerContainer(); - static MsgTask* getMsgTaskLocked(); - static LocTimerPollTask* getPollTaskLocked(); - // extend LocHeap and pop if the top outRanks input - LocTimerDelegate* popIfOutRanks(LocTimerDelegate& timer); - // update the timer POSIX calls with updated soonest timer spec - void updateSoonestTime(LocTimerDelegate* priorTop); - -public: - // factory method to control the creation of mSwTimers / mHwTimers - static LocTimerContainer* get(bool wakeOnExpire); - - LocTimerDelegate* getSoonestTimer(); - int getTimerFd(); - // add a timer / alarm obj into the container - void add(LocTimerDelegate& timer); - // remove a timer / alarm obj from the container - void remove(LocTimerDelegate& timer); - // handling of timer / alarm expiration - void expire(); -}; - -// This class implements the polling thread that epolls imer / alarm fds. -// The LocRunnable::run() contains the actual polling. The other methods -// will be run in the caller's thread context to add / remove timer / alarm -// fds the kernel, while the polling is blocked on epoll_wait() call. -// Since the design is that we have maximally 2 polls, one for all the -// timers; one for all the alarms, we will poll at most on 2 fds. But it -// is possile that all we have are only timers or alarms at one time, so we -// allow dynamically add / remove fds we poll on. The design decision of -// having 1 fd per container of timer / alarm is such that, we may not need -// to make a system call each time a timer / alarm is added / removed, unless -// that changes the "soonest" time out of that of all the timers / alarms. -class LocTimerPollTask : public LocRunnable { - // the epoll fd - const int mFd; - // the thread that calls run() method - LocThread* mThread; - friend class LocThreadDelegate; - // dtor - ~LocTimerPollTask(); -public: - // ctor - LocTimerPollTask(); - // this obj will be deleted once thread is deleted - void destroy(); - // add a container of timers. Each contain has a unique device fd, i.e. - // either timer or alarm fd, and a heap of timers / alarms. It is expected - // that container would have written to the device fd with the soonest - // time out value in the heap at the time of calling this method. So all - // this method does is to add the fd of the input container to the poll - // and also add the pointer of the container to the event data ptr, such - // when poll_wait wakes up on events, we know who is the owner of the fd. - void addPoll(LocTimerContainer& timerContainer); - // remove a fd that is assciated with a container. The expectation is that - // the atual timer would have been removed from the container. - void removePoll(LocTimerContainer& timerContainer); - // The polling thread context will call this method. This is where - // epoll_wait() is blocking and waiting for events.. - virtual bool run(); -}; - -// Internal class of timer obj. It gets born when client calls LocTimer::start(); -// and gets deleted when client calls LocTimer::stop() or when the it expire()'s. -// This class implements LocRankable::ranks() so that when an obj is added into -// the container (of LocHeap), it gets placed in sorted order. -class LocTimerDelegate : public LocRankable { - friend class LocTimerContainer; - friend class LocTimer; - LocTimer* mClient; - LocSharedLock* mLock; - struct timespec mFutureTime; - LocTimerContainer* mContainer; - // not a complete obj, just ctor for LocRankable comparisons - inline LocTimerDelegate(struct timespec& delay) - : mClient(NULL), mLock(NULL), mFutureTime(delay), mContainer(NULL) {} - inline ~LocTimerDelegate() { if (mLock) { mLock->drop(); mLock = NULL; } } -public: - LocTimerDelegate(LocTimer& client, struct timespec& futureTime, bool wakeOnExpire); - void destroyLocked(); - // LocRankable virtual method - virtual int ranks(LocRankable& rankable); - void expire(); - inline struct timespec getFutureTime() { return mFutureTime; } -}; - -/***************************LocTimerContainer methods***************************/ - -// Most of these static recources are created on demand. They however are never -// destoyed. The theory is that there are processes that link to this util lib -// but never use timer, then these resources would never need to be created. -// For those processes that do use timer, it will likely also need to every -// once in a while. It might be cheaper keeping them around. -pthread_mutex_t LocTimerContainer::mMutex = PTHREAD_MUTEX_INITIALIZER; -LocTimerContainer* LocTimerContainer::mSwTimers = NULL; -LocTimerContainer* LocTimerContainer::mHwTimers = NULL; -MsgTask* LocTimerContainer::mMsgTask = NULL; -LocTimerPollTask* LocTimerContainer::mPollTask = NULL; - -// ctor - initialize timer heaps -// A container for swTimer (timer) is created, when wakeOnExpire is true; or -// HwTimer (alarm), when wakeOnExpire is false. -LocTimerContainer::LocTimerContainer(bool wakeOnExpire) : - mDevFd(timerfd_create(wakeOnExpire ? CLOCK_BOOTTIME_ALARM : CLOCK_BOOTTIME, 0)) { - - if ((-1 == mDevFd) && (errno == EINVAL)) { - LOC_LOGW("%s: timerfd_create failure, fallback to CLOCK_MONOTONIC - %s", - __FUNCTION__, strerror(errno)); - mDevFd = timerfd_create(CLOCK_MONOTONIC, 0); - } - - if (-1 != mDevFd) { - // ensure we have the necessary resources created - LocTimerContainer::getPollTaskLocked(); - LocTimerContainer::getMsgTaskLocked(); - } else { - LOC_LOGE("%s: timerfd_create failure - %s", __FUNCTION__, strerror(errno)); - } -} - -// dtor -// we do not ever destroy the static resources. -inline -LocTimerContainer::~LocTimerContainer() { - close(mDevFd); -} - -LocTimerContainer* LocTimerContainer::get(bool wakeOnExpire) { - // get the reference of either mHwTimer or mSwTimers per wakeOnExpire - LocTimerContainer*& container = wakeOnExpire ? mHwTimers : mSwTimers; - // it is cheap to check pointer first than locking mutext unconditionally - if (!container) { - pthread_mutex_lock(&mMutex); - // let's check one more time to be safe - if (!container) { - container = new LocTimerContainer(wakeOnExpire); - // timerfd_create failure - if (-1 == container->getTimerFd()) { - delete container; - container = NULL; - } - } - pthread_mutex_unlock(&mMutex); - } - return container; -} - -MsgTask* LocTimerContainer::getMsgTaskLocked() { - // it is cheap to check pointer first than locking mutext unconditionally - if (!mMsgTask) { - mMsgTask = new MsgTask("LocTimerMsgTask", false); - } - return mMsgTask; -} - -LocTimerPollTask* LocTimerContainer::getPollTaskLocked() { - // it is cheap to check pointer first than locking mutext unconditionally - if (!mPollTask) { - mPollTask = new LocTimerPollTask(); - } - return mPollTask; -} - -inline -LocTimerDelegate* LocTimerContainer::getSoonestTimer() { - return (LocTimerDelegate*)(peek()); -} - -inline -int LocTimerContainer::getTimerFd() { - return mDevFd; -} - -void LocTimerContainer::updateSoonestTime(LocTimerDelegate* priorTop) { - LocTimerDelegate* curTop = getSoonestTimer(); - - // check if top has changed - if (curTop != priorTop) { - struct itimerspec delay = {0}; - bool toSetTime = false; - // if tree is empty now, we remove poll and disarm timer - if (!curTop) { - mPollTask->removePoll(*this); - // setting the values to disarm timer - delay.it_value.tv_sec = 0; - delay.it_value.tv_nsec = 0; - toSetTime = true; - } else if (!priorTop || curTop->outRanks(*priorTop)) { - // do this first to avoid race condition, in case settime is called - // with too small an interval - mPollTask->addPoll(*this); - delay.it_value = curTop->getFutureTime(); - toSetTime = true; - } - if (toSetTime) { - timerfd_settime(getTimerFd(), TFD_TIMER_ABSTIME, &delay, NULL); - } - } -} - -// all the heap management is done in the MsgTask context. -inline -void LocTimerContainer::add(LocTimerDelegate& timer) { - struct MsgTimerPush : public LocMsg { - LocTimerContainer* mTimerContainer; - LocHeapNode* mTree; - LocTimerDelegate* mTimer; - inline MsgTimerPush(LocTimerContainer& container, LocTimerDelegate& timer) : - LocMsg(), mTimerContainer(&container), mTimer(&timer) {} - inline virtual void proc() const { - LocTimerDelegate* priorTop = mTimerContainer->getSoonestTimer(); - mTimerContainer->push((LocRankable&)(*mTimer)); - mTimerContainer->updateSoonestTime(priorTop); - } - }; - - mMsgTask->sendMsg(new MsgTimerPush(*this, timer)); -} - -// all the heap management is done in the MsgTask context. -void LocTimerContainer::remove(LocTimerDelegate& timer) { - struct MsgTimerRemove : public LocMsg { - LocTimerContainer* mTimerContainer; - LocTimerDelegate* mTimer; - inline MsgTimerRemove(LocTimerContainer& container, LocTimerDelegate& timer) : - LocMsg(), mTimerContainer(&container), mTimer(&timer) {} - inline virtual void proc() const { - LocTimerDelegate* priorTop = mTimerContainer->getSoonestTimer(); - - // update soonest timer only if mTimer is actually removed from - // mTimerContainer AND mTimer is not priorTop. - if (priorTop == ((LocHeap*)mTimerContainer)->remove((LocRankable&)*mTimer)) { - // if passing in NULL, we tell updateSoonestTime to update - // kernel with the current top timer interval. - mTimerContainer->updateSoonestTime(NULL); - } - // all timers are deleted here, and only here. - delete mTimer; - } - }; - - mMsgTask->sendMsg(new MsgTimerRemove(*this, timer)); -} - -// all the heap management is done in the MsgTask context. -// Upon expire, we check and continuously pop the heap until -// the top node's timeout is in the future. -void LocTimerContainer::expire() { - struct MsgTimerExpire : public LocMsg { - LocTimerContainer* mTimerContainer; - inline MsgTimerExpire(LocTimerContainer& container) : - LocMsg(), mTimerContainer(&container) {} - inline virtual void proc() const { - struct timespec now; - // get time spec of now - clock_gettime(CLOCK_BOOTTIME, &now); - LocTimerDelegate timerOfNow(now); - // pop everything in the heap that outRanks now, i.e. has time older than now - // and then call expire() on that timer. - for (LocTimerDelegate* timer = (LocTimerDelegate*)mTimerContainer->pop(); - NULL != timer; - timer = mTimerContainer->popIfOutRanks(timerOfNow)) { - // the timer delegate obj will be deleted before the return of this call - timer->expire(); - } - mTimerContainer->updateSoonestTime(NULL); - } - }; - - struct itimerspec delay = {0}; - timerfd_settime(getTimerFd(), TFD_TIMER_ABSTIME, &delay, NULL); - mPollTask->removePoll(*this); - mMsgTask->sendMsg(new MsgTimerExpire(*this)); -} - -LocTimerDelegate* LocTimerContainer::popIfOutRanks(LocTimerDelegate& timer) { - LocTimerDelegate* poppedNode = NULL; - if (mTree && !timer.outRanks(*peek())) { - poppedNode = (LocTimerDelegate*)(pop()); - } - - return poppedNode; -} - - -/***************************LocTimerPollTask methods***************************/ - -inline -LocTimerPollTask::LocTimerPollTask() - : mFd(epoll_create(2)), mThread(new LocThread()) { - // before a next call returens, a thread will be created. The run() method - // could already be running in parallel. Also, since each of the objs - // creates a thread, the container will make sure that there will be only - // one of such obj for our timer implementation. - if (!mThread->start("LocTimerPollTask", this)) { - delete mThread; - mThread = NULL; - } -} - -inline -LocTimerPollTask::~LocTimerPollTask() { - // when fs is closed, epoll_wait() should fail run() should return false - // and the spawned thread should exit. - close(mFd); -} - -void LocTimerPollTask::destroy() { - if (mThread) { - LocThread* thread = mThread; - mThread = NULL; - delete thread; - } else { - delete this; - } -} - -void LocTimerPollTask::addPoll(LocTimerContainer& timerContainer) { - struct epoll_event ev; - memset(&ev, 0, sizeof(ev)); - - ev.events = EPOLLIN | EPOLLWAKEUP; - ev.data.fd = timerContainer.getTimerFd(); - // it is important that we set this context pointer with the input - // timer container this is how we know which container should handle - // which expiration. - ev.data.ptr = &timerContainer; - - epoll_ctl(mFd, EPOLL_CTL_ADD, timerContainer.getTimerFd(), &ev); -} - -inline -void LocTimerPollTask::removePoll(LocTimerContainer& timerContainer) { - epoll_ctl(mFd, EPOLL_CTL_DEL, timerContainer.getTimerFd(), NULL); -} - -// The polling thread context will call this method. If run() method needs to -// be repetitvely called, it must return true from the previous call. -bool LocTimerPollTask::run() { - struct epoll_event ev[2]; - - // we have max 2 descriptors to poll from - int fds = epoll_wait(mFd, ev, 2, -1); - - // we pretty much want to continually poll until the fd is closed - bool rerun = (fds > 0) || (errno == EINTR); - - if (fds > 0) { - // we may have 2 events - for (int i = 0; i < fds; i++) { - // each fd has a context pointer associated with the right timer container - LocTimerContainer* container = (LocTimerContainer*)(ev[i].data.ptr); - if (container) { - container->expire(); - } else { - epoll_ctl(mFd, EPOLL_CTL_DEL, ev[i].data.fd, NULL); - } - } - } - - // if rerun is true, we are requesting to be scheduled again - return rerun; -} - -/***************************LocTimerDelegate methods***************************/ - -inline -LocTimerDelegate::LocTimerDelegate(LocTimer& client, struct timespec& futureTime, bool wakeOnExpire) - : mClient(&client), - mLock(mClient->mLock->share()), - mFutureTime(futureTime), - mContainer(LocTimerContainer::get(wakeOnExpire)) { - // adding the timer into the container - mContainer->add(*this); -} - -inline -void LocTimerDelegate::destroyLocked() { - // client handle will likely be deleted soon after this - // method returns. Nulling this handle so that expire() - // won't call the callback on the dead handle any more. - mClient = NULL; - - if (mContainer) { - LocTimerContainer* container = mContainer; - mContainer = NULL; - if (container) { - container->remove(*this); - } - } // else we do not do anything. No such *this* can be - // created and reached here with mContainer ever been - // a non NULL. So *this* must have reached the if clause - // once, and we want it reach there only once. -} - -int LocTimerDelegate::ranks(LocRankable& rankable) { - int rank = -1; - LocTimerDelegate* timer = (LocTimerDelegate*)(&rankable); - if (timer) { - // larger time ranks lower!!! - // IOW, if input obj has bigger tv_sec, this obj outRanks higher - rank = timer->mFutureTime.tv_sec - mFutureTime.tv_sec; - } - return rank; -} - -inline -void LocTimerDelegate::expire() { - // keeping a copy of client pointer to be safe - // when timeOutCallback() is called at the end of this - // method, *this* obj may be already deleted. - LocTimer* client = mClient; - // force a stop, which will lead to delete of this obj - if (client && client->stop()) { - // calling client callback with a pointer save on the stack - // only if stop() returns true, i.e. it hasn't been stopped - // already. - client->timeOutCallback(); - } -} - - -/***************************LocTimer methods***************************/ -LocTimer::LocTimer() : mTimer(NULL), mLock(new LocSharedLock()) { -} - -LocTimer::~LocTimer() { - stop(); - if (mLock) { - mLock->drop(); - mLock = NULL; - } -} - -bool LocTimer::start(unsigned int timeOutInMs, bool wakeOnExpire) { - bool success = false; - mLock->lock(); - if (!mTimer) { - struct timespec futureTime; - clock_gettime(CLOCK_BOOTTIME, &futureTime); - futureTime.tv_sec += timeOutInMs / 1000; - futureTime.tv_nsec += (timeOutInMs % 1000) * 1000000; - if (futureTime.tv_nsec >= 1000000000) { - futureTime.tv_sec += futureTime.tv_nsec / 1000000000; - futureTime.tv_nsec %= 1000000000; - } - mTimer = new LocTimerDelegate(*this, futureTime, wakeOnExpire); - // if mTimer is non 0, success should be 0; or vice versa - success = (NULL != mTimer); - } - mLock->unlock(); - return success; -} - -bool LocTimer::stop() { - bool success = false; - mLock->lock(); - if (mTimer) { - LocTimerDelegate* timer = mTimer; - mTimer = NULL; - if (timer) { - timer->destroyLocked(); - success = true; - } - } - mLock->unlock(); - return success; -} - -/***************************LocTimerWrapper methods***************************/ -////////////////////////////////////////////////////////////////////////// -// This section below wraps for the C style APIs -////////////////////////////////////////////////////////////////////////// -class LocTimerWrapper : public LocTimer { - loc_timer_callback mCb; - void* mCallerData; - LocTimerWrapper* mMe; - static pthread_mutex_t mMutex; - inline ~LocTimerWrapper() { mCb = NULL; mMe = NULL; } -public: - inline LocTimerWrapper(loc_timer_callback cb, void* callerData) : - mCb(cb), mCallerData(callerData), mMe(this) { - } - void destroy() { - pthread_mutex_lock(&mMutex); - if (NULL != mCb && this == mMe) { - delete this; - } - pthread_mutex_unlock(&mMutex); - } - virtual void timeOutCallback() { - loc_timer_callback cb = mCb; - void* callerData = mCallerData; - if (cb) { - cb(callerData, 0); - } - destroy(); - } -}; - -pthread_mutex_t LocTimerWrapper::mMutex = PTHREAD_MUTEX_INITIALIZER; - -void* loc_timer_start(uint64_t msec, loc_timer_callback cb_func, - void *caller_data, bool wake_on_expire) -{ - LocTimerWrapper* locTimerWrapper = NULL; - - if (cb_func) { - locTimerWrapper = new LocTimerWrapper(cb_func, caller_data); - - if (locTimerWrapper) { - locTimerWrapper->start(msec, wake_on_expire); - } - } - - return locTimerWrapper; -} - -void loc_timer_stop(void*& handle) -{ - if (handle) { - LocTimerWrapper* locTimerWrapper = (LocTimerWrapper*)(handle); - locTimerWrapper->destroy(); - handle = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -// This section above wraps for the C style APIs -////////////////////////////////////////////////////////////////////////// - -#ifdef __LOC_DEBUG__ - -double getDeltaSeconds(struct timespec from, struct timespec to) { - return (double)to.tv_sec + (double)to.tv_nsec / 1000000000 - - from.tv_sec - (double)from.tv_nsec / 1000000000; -} - -struct timespec getNow() { - struct timespec now; - clock_gettime(CLOCK_BOOTTIME, &now); - return now; -} - -class LocTimerTest : public LocTimer, public LocRankable { - int mTimeOut; - const struct timespec mTimeOfBirth; - inline struct timespec getTimerWrapper(int timeout) { - struct timespec now; - clock_gettime(CLOCK_BOOTTIME, &now); - now.tv_sec += timeout; - return now; - } -public: - inline LocTimerTest(int timeout) : LocTimer(), LocRankable(), - mTimeOut(timeout), mTimeOfBirth(getTimerWrapper(0)) {} - inline virtual int ranks(LocRankable& rankable) { - LocTimerTest* timer = dynamic_cast(&rankable); - return timer->mTimeOut - mTimeOut; - } - inline virtual void timeOutCallback() { - printf("timeOutCallback() - "); - deviation(); - } - double deviation() { - struct timespec now = getTimerWrapper(0); - double delta = getDeltaSeconds(mTimeOfBirth, now); - printf("%lf: %lf\n", delta, delta * 100 / mTimeOut); - return delta / mTimeOut; - } -}; - -// For Linux command line testing: -// compilation: -// g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -I. -I../../../../system/core/include -o LocHeap.o LocHeap.cpp -// g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -std=c++0x -I. -I../../../../system/core/include -lpthread -o LocThread.o LocThread.cpp -// g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -I. -I../../../../system/core/include -o LocTimer.o LocTimer.cpp -int main(int argc, char** argv) { - struct timespec timeOfStart=getNow(); - srand(time(NULL)); - int tries = atoi(argv[1]); - int checks = tries >> 3; - LocTimerTest** timerArray = new LocTimerTest*[tries]; - memset(timerArray, NULL, tries); - - for (int i = 0; i < tries; i++) { - int r = rand() % tries; - LocTimerTest* timer = new LocTimerTest(r); - if (timerArray[r]) { - if (!timer->stop()) { - printf("%lf:\n", getDeltaSeconds(timeOfStart, getNow())); - printf("ERRER: %dth timer, id %d, not running when it should be\n", i, r); - exit(0); - } else { - printf("stop() - %d\n", r); - delete timer; - timerArray[r] = NULL; - } - } else { - if (!timer->start(r, false)) { - printf("%lf:\n", getDeltaSeconds(timeOfStart, getNow())); - printf("ERRER: %dth timer, id %d, running when it should not be\n", i, r); - exit(0); - } else { - printf("stop() - %d\n", r); - timerArray[r] = timer; - } - } - } - - for (int i = 0; i < tries; i++) { - if (timerArray[i]) { - if (!timerArray[i]->stop()) { - printf("%lf:\n", getDeltaSeconds(timeOfStart, getNow())); - printf("ERRER: %dth timer, not running when it should be\n", i); - exit(0); - } else { - printf("stop() - %d\n", i); - delete timerArray[i]; - timerArray[i] = NULL; - } - } - } - - delete[] timerArray; - - return 0; -} - -#endif diff --git a/gps/utils/LocTimer.h b/gps/utils/LocTimer.h deleted file mode 100644 index c146852..0000000 --- a/gps/utils/LocTimer.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (c) 2015, 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_TIMER_CPP_H__ -#define __LOC_TIMER_CPP_H__ - -#include -#include - -// opaque class to provide service implementation. -class LocTimerDelegate; -class LocSharedLock; - -// LocTimer client must extend this class and implementthe callback. -// start() / stop() methods are to arm / disarm timer. -class LocTimer -{ - LocTimerDelegate* mTimer; - LocSharedLock* mLock; - // don't really want mLock to be manipulated by clients, yet LocTimer - // has to have a reference to the lock so that the delete of LocTimer - // and LocTimerDelegate can work together on their share resources. - friend class LocTimerDelegate; - -public: - LocTimer(); - virtual ~LocTimer(); - - // timeOutInMs: timeout delay in ms - // wakeOnExpire: true if to wake up CPU (if sleeping) upon timer - // expiration and notify the client. - // false if to wait until next time CPU wakes up (if - // sleeping) and then notify the client. - // return: true on success; - // false on failure, e.g. timer is already running. - bool start(uint32_t timeOutInMs, bool wakeOnExpire); - - // return: true on success; - // false on failure, e.g. timer is not running. - bool stop(); - - // LocTimer client Should implement this method. - // This method is used for timeout calling back to client. This method - // should be short enough (eg: send a message to your own thread). - virtual void timeOutCallback() = 0; -}; - -#endif //__LOC_DELAY_H__ diff --git a/gps/utils/MsgTask.cpp b/gps/utils/MsgTask.cpp deleted file mode 100755 index 86fcdce..0000000 --- a/gps/utils/MsgTask.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (c) 2011-2013,2015 The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_MsgTask" - -#include -#include -#include -#include -#include -#include - -static void LocMsgDestroy(void* msg) { - delete (LocMsg*)msg; -} - -MsgTask::MsgTask(LocThread::tCreate tCreator, - const char* threadName, bool joinable) : - mQ(msg_q_init2()), mThread(new LocThread()) { - if (!mThread->start(tCreator, threadName, this, joinable)) { - delete mThread; - mThread = NULL; - } -} - -MsgTask::MsgTask(const char* threadName, bool joinable) : - mQ(msg_q_init2()), mThread(new LocThread()) { - if (!mThread->start(threadName, this, joinable)) { - delete mThread; - mThread = NULL; - } -} - -MsgTask::~MsgTask() { - msg_q_flush((void*)mQ); - msg_q_destroy((void**)&mQ); -} - -void MsgTask::destroy() { - msg_q_unblock((void*)mQ); - if (mThread) { - LocThread* thread = mThread; - mThread = NULL; - delete thread; - } else { - delete this; - } -} - -void MsgTask::sendMsg(const LocMsg* msg) const { - msg_q_snd((void*)mQ, (void*)msg, LocMsgDestroy); -} - -void MsgTask::prerun() { - // make sure we do not run in background scheduling group -// set_sched_policy(gettid(), SP_FOREGROUND); -} - -bool MsgTask::run() { - LOC_LOGV("MsgTask::loop() listening ...\n"); - LocMsg* msg; - msq_q_err_type result = msg_q_rcv((void*)mQ, (void **)&msg); - if (eMSG_Q_SUCCESS != result) { - LOC_LOGE("%s:%d] fail receiving msg: %s\n", __func__, __LINE__, - loc_get_msg_q_status(result)); - return false; - } - - msg->log(); - // there is where each individual msg handling is invoked - msg->proc(); - - delete msg; - - return true; -} diff --git a/gps/utils/MsgTask.h b/gps/utils/MsgTask.h deleted file mode 100644 index 9eb1f56..0000000 --- a/gps/utils/MsgTask.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (c) 2011-2013,2015 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 __MSG_TASK__ -#define __MSG_TASK__ - -#include - -struct LocMsg { - inline LocMsg() {} - inline virtual ~LocMsg() {} - virtual void proc() const = 0; - inline virtual void log() const {} -}; - -class MsgTask : public LocRunnable { - const void* mQ; - LocThread* mThread; - friend class LocThreadDelegate; -protected: - virtual ~MsgTask(); -public: - MsgTask(LocThread::tCreate tCreator, const char* threadName = NULL, bool joinable = true); - MsgTask(const char* threadName = NULL, bool joinable = true); - // this obj will be deleted once thread is deleted - void destroy(); - void sendMsg(const LocMsg* msg) const; - // Overrides of LocRunnable methods - // This method will be repeated called until it returns false; or - // until thread is stopped. - virtual bool run(); - - // The method to be run before thread loop (conditionally repeatedly) - // calls run() - virtual void prerun(); - - // The method to be run after thread loop (conditionally repeatedly) - // calls run() - inline virtual void postrun() {} -}; - -#endif //__MSG_TASK__ diff --git a/gps/utils/linked_list.c b/gps/utils/linked_list.c deleted file mode 100644 index 2c91714..0000000 --- a/gps/utils/linked_list.c +++ /dev/null @@ -1,328 +0,0 @@ -/* Copyright (c) 2011, 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 "linked_list.h" -#include -#include - -#define LOG_TAG "LocSvc_utils_ll" -#include "log_util.h" -#include "platform_lib_includes.h" -#include -#include - -typedef struct list_element { - struct list_element* next; - struct list_element* prev; - void* data_ptr; - void (*dealloc_func)(void*); -}list_element; - -typedef struct list_state { - list_element* p_head; - list_element* p_tail; -} list_state; - -/* ----------------------- END INTERNAL FUNCTIONS ---------------------------------------- */ - -/*=========================================================================== - - FUNCTION: linked_list_init - - ===========================================================================*/ -linked_list_err_type linked_list_init(void** list_data) -{ - if( list_data == NULL ) - { - LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); - return eLINKED_LIST_INVALID_PARAMETER; - } - - list_state* tmp_list; - tmp_list = (list_state*)calloc(1, sizeof(list_state)); - if( tmp_list == NULL ) - { - LOC_LOGE("%s: Unable to allocate space for list!\n", __FUNCTION__); - return eLINKED_LIST_FAILURE_GENERAL; - } - - tmp_list->p_head = NULL; - tmp_list->p_tail = NULL; - - *list_data = tmp_list; - - return eLINKED_LIST_SUCCESS; -} - -/*=========================================================================== - - FUNCTION: linked_list_destroy - - ===========================================================================*/ -linked_list_err_type linked_list_destroy(void** list_data) -{ - if( list_data == NULL ) - { - LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); - return eLINKED_LIST_INVALID_HANDLE; - } - - list_state* p_list = (list_state*)*list_data; - - linked_list_flush(p_list); - - free(*list_data); - *list_data = NULL; - - return eLINKED_LIST_SUCCESS; -} - -/*=========================================================================== - - FUNCTION: linked_list_add - - ===========================================================================*/ -linked_list_err_type linked_list_add(void* list_data, void *data_obj, void (*dealloc)(void*)) -{ - LOC_LOGV("%s: Adding to list data_obj = 0x%08X\n", __FUNCTION__, data_obj); - if( list_data == NULL ) - { - LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); - return eLINKED_LIST_INVALID_HANDLE; - } - - if( data_obj == NULL ) - { - LOC_LOGE("%s: Invalid input parameter!\n", __FUNCTION__); - return eLINKED_LIST_INVALID_PARAMETER; - } - - list_state* p_list = (list_state*)list_data; - list_element* elem = (list_element*)malloc(sizeof(list_element)); - if( elem == NULL ) - { - LOC_LOGE("%s: Memory allocation failed\n", __FUNCTION__); - return eLINKED_LIST_FAILURE_GENERAL; - } - - /* Copy data to newly created element */ - elem->data_ptr = data_obj; - elem->next = NULL; - elem->prev = NULL; - elem->dealloc_func = dealloc; - - /* Replace head element */ - list_element* tmp = p_list->p_head; - p_list->p_head = elem; - /* Point next to the previous head element */ - p_list->p_head->next = tmp; - - if( tmp != NULL ) - { - tmp->prev = p_list->p_head; - } - else - { - p_list->p_tail = p_list->p_head; - } - - return eLINKED_LIST_SUCCESS; -} - -/*=========================================================================== - - FUNCTION: linked_list_remove - - ===========================================================================*/ -linked_list_err_type linked_list_remove(void* list_data, void **data_obj) -{ - LOC_LOGV("%s: Removing from list\n", __FUNCTION__); - if( list_data == NULL ) - { - LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); - return eLINKED_LIST_INVALID_HANDLE; - } - - if( data_obj == NULL ) - { - LOC_LOGE("%s: Invalid input parameter!\n", __FUNCTION__); - return eLINKED_LIST_INVALID_PARAMETER; - } - - list_state* p_list = (list_state*)list_data; - if( p_list->p_tail == NULL ) - { - return eLINKED_LIST_UNAVAILABLE_RESOURCE; - } - - list_element* tmp = p_list->p_tail; - - /* Replace tail element */ - p_list->p_tail = tmp->prev; - - if( p_list->p_tail != NULL ) - { - p_list->p_tail->next = NULL; - } - else - { - p_list->p_head = p_list->p_tail; - } - - /* Copy data to output param */ - *data_obj = tmp->data_ptr; - - /* Free allocated list element */ - free(tmp); - - return eLINKED_LIST_SUCCESS; -} - -/*=========================================================================== - - FUNCTION: linked_list_empty - - ===========================================================================*/ -int linked_list_empty(void* list_data) -{ - if( list_data == NULL ) - { - LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); - return (int)eLINKED_LIST_INVALID_HANDLE; - } - else - { - list_state* p_list = (list_state*)list_data; - return p_list->p_head == NULL ? 1 : 0; - } -} - -/*=========================================================================== - - FUNCTION: linked_list_flush - - ===========================================================================*/ -linked_list_err_type linked_list_flush(void* list_data) -{ - if( list_data == NULL ) - { - LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); - return eLINKED_LIST_INVALID_HANDLE; - } - - list_state* p_list = (list_state*)list_data; - - /* Remove all dynamically allocated elements */ - while( p_list->p_head != NULL ) - { - list_element* tmp = p_list->p_head->next; - - /* Free data pointer if told to do so. */ - if( p_list->p_head->dealloc_func != NULL ) - { - p_list->p_head->dealloc_func(p_list->p_head->data_ptr); - } - - /* Free list element */ - free(p_list->p_head); - - p_list->p_head = tmp; - } - - p_list->p_tail = NULL; - - return eLINKED_LIST_SUCCESS; -} - -/*=========================================================================== - - FUNCTION: linked_list_search - - ===========================================================================*/ -linked_list_err_type linked_list_search(void* list_data, void **data_p, - bool (*equal)(void* data_0, void* data), - void* data_0, bool rm_if_found) -{ - LOC_LOGV("%s: Search the list\n", __FUNCTION__); - if( list_data == NULL || NULL == equal ) - { - LOC_LOGE("%s: Invalid list parameter! list_data %p equal %p\n", - __FUNCTION__, list_data, equal); - return eLINKED_LIST_INVALID_HANDLE; - } - - list_state* p_list = (list_state*)list_data; - if( p_list->p_tail == NULL ) - { - return eLINKED_LIST_UNAVAILABLE_RESOURCE; - } - - list_element* tmp = p_list->p_head; - - if (NULL != data_p) { - *data_p = NULL; - } - - while (NULL != tmp) { - if ((*equal)(data_0, tmp->data_ptr)) { - if (NULL != data_p) { - *data_p = tmp->data_ptr; - } - - if (rm_if_found) { - if (NULL == tmp->prev) { - p_list->p_head = tmp->next; - } else { - tmp->prev->next = tmp->next; - } - - if (NULL == tmp->next) { - p_list->p_tail = tmp->prev; - } else { - tmp->next->prev = tmp->prev; - } - - tmp->prev = tmp->next = NULL; - - // dealloc data if it is not copied out && caller - // has given us a dealloc function pointer. - if (NULL == data_p && NULL != tmp->dealloc_func) { - tmp->dealloc_func(tmp->data_ptr); - } - free(tmp); - } - - tmp = NULL; - } else { - tmp = tmp->next; - } - } - - return eLINKED_LIST_SUCCESS; -} - diff --git a/gps/utils/linked_list.h b/gps/utils/linked_list.h deleted file mode 100644 index a85f09a..0000000 --- a/gps/utils/linked_list.h +++ /dev/null @@ -1,217 +0,0 @@ -/* Copyright (c) 2011, 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 __LINKED_LIST_H__ -#define __LINKED_LIST_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include -#include - -/** Linked List Return Codes */ -typedef enum -{ - eLINKED_LIST_SUCCESS = 0, - /**< Request was successful. */ - eLINKED_LIST_FAILURE_GENERAL = -1, - /**< Failed because of a general failure. */ - eLINKED_LIST_INVALID_PARAMETER = -2, - /**< Failed because the request contained invalid parameters. */ - eLINKED_LIST_INVALID_HANDLE = -3, - /**< Failed because an invalid handle was specified. */ - eLINKED_LIST_UNAVAILABLE_RESOURCE = -4, - /**< Failed because an there were not enough resources. */ - eLINKED_LIST_INSUFFICIENT_BUFFER = -5, - /**< Failed because an the supplied buffer was too small. */ -}linked_list_err_type; - -/*=========================================================================== -FUNCTION linked_list_init - -DESCRIPTION - Initializes internal structures for linked list. - - list_data: State of list to be initialized. - -DEPENDENCIES - N/A - -RETURN VALUE - Look at error codes above. - -SIDE EFFECTS - N/A - -===========================================================================*/ -linked_list_err_type linked_list_init(void** list_data); - -/*=========================================================================== -FUNCTION linked_list_destroy - -DESCRIPTION - Destroys internal structures for linked list. - - p_list_data: State of list to be destroyed. - -DEPENDENCIES - N/A - -RETURN VALUE - Look at error codes above. - -SIDE EFFECTS - N/A - -===========================================================================*/ -linked_list_err_type linked_list_destroy(void** list_data); - -/*=========================================================================== -FUNCTION linked_list_add - -DESCRIPTION - Adds an element to the head of the linked list. The passed in data pointer - is not modified or freed. Passed in data_obj is expected to live throughout - the use of the linked_list (i.e. data is not allocated internally) - - p_list_data: List to add data to the head of. - data_obj: Pointer to data to add into list - dealloc: Function used to deallocate memory for this element. Pass NULL - if you do not want data deallocated during a flush operation - -DEPENDENCIES - N/A - -RETURN VALUE - Look at error codes above. - -SIDE EFFECTS - N/A - -===========================================================================*/ -linked_list_err_type linked_list_add(void* list_data, void *data_obj, void (*dealloc)(void*)); - -/*=========================================================================== -FUNCTION linked_list_remove - -DESCRIPTION - Retrieves data from the list tail. data_obj is the tail element from the list - passed in by linked_list_add. - - p_list_data: List to remove the tail from. - data_obj: Pointer to data removed from list - -DEPENDENCIES - N/A - -RETURN VALUE - Look at error codes above. - -SIDE EFFECTS - N/A - -===========================================================================*/ -linked_list_err_type linked_list_remove(void* list_data, void **data_obj); - -/*=========================================================================== -FUNCTION linked_list_empty - -DESCRIPTION - Tells whether the list currently contains any elements - - p_list_data: List to check if empty. - -DEPENDENCIES - N/A - -RETURN VALUE - 0/FALSE : List contains elements - 1/TRUE : List is Empty - Otherwise look at error codes above. - -SIDE EFFECTS - N/A - -===========================================================================*/ -int linked_list_empty(void* list_data); - -/*=========================================================================== -FUNCTION linked_list_flush - -DESCRIPTION - Removes all elements from the list and deallocates them using the provided - dealloc function while adding elements. - - p_list_data: List to remove all elements from. - -DEPENDENCIES - N/A - -RETURN VALUE - Look at error codes above. - -SIDE EFFECTS - N/A - -===========================================================================*/ -linked_list_err_type linked_list_flush(void* list_data); - -/*=========================================================================== -FUNCTION linked_list_search - -DESCRIPTION - Searches for an element in the linked list. - - p_list_data: List handle. - data_p: to be stored with the data found; NUll if no match. - if data_p passed in as NULL, then no write to it. - equal: Function ptr takes in a list element, and returns - indication if this the one looking for. - data_0: The data being compared against. - rm_if_found: Should data be removed if found? - -DEPENDENCIES - N/A - -RETURN VALUE - Look at error codes above. - -SIDE EFFECTS - N/A - -===========================================================================*/ -linked_list_err_type linked_list_search(void* list_data, void **data_p, - bool (*equal)(void* data_0, void* data), - void* data_0, bool rm_if_found); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __LINKED_LIST_H__ */ diff --git a/gps/utils/loc_cfg.cpp b/gps/utils/loc_cfg.cpp deleted file mode 100644 index 967d2f3..0000000 --- a/gps/utils/loc_cfg.cpp +++ /dev/null @@ -1,400 +0,0 @@ -/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_utils_cfg" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef USE_GLIB -#include -#endif -#include "platform_lib_includes.h" - -/*============================================================================= - * - * GLOBAL DATA DECLARATION - * - *============================================================================*/ - -/* Parameter data */ -static uint32_t DEBUG_LEVEL = 0xff; -static uint32_t TIMESTAMP = 0; - -/* Parameter spec table */ -static const loc_param_s_type loc_param_table[] = -{ - {"DEBUG_LEVEL", &DEBUG_LEVEL, NULL, 'n'}, - {"TIMESTAMP", &TIMESTAMP, NULL, 'n'}, -}; -static const int loc_param_num = sizeof(loc_param_table) / sizeof(loc_param_s_type); - -typedef struct loc_param_v_type -{ - char* param_name; - char* param_str_value; - int param_int_value; - double param_double_value; -}loc_param_v_type; - -/*=========================================================================== -FUNCTION loc_set_config_entry - -DESCRIPTION - Potentially sets a given configuration table entry based on the passed in - configuration value. This is done by using a string comparison of the - parameter names and those found in the configuration file. - -PARAMETERS: - config_entry: configuration entry in the table to possibly set - config_value: value to store in the entry if the parameter names match - -DEPENDENCIES - N/A - -RETURN VALUE - None - -SIDE EFFECTS - N/A -===========================================================================*/ -int loc_set_config_entry(const loc_param_s_type* config_entry, loc_param_v_type* config_value) -{ - int ret=-1; - if(NULL == config_entry || NULL == config_value) - { - LOC_LOGE("%s: INVALID config entry or parameter", __FUNCTION__); - return ret; - } - - if (strcmp(config_entry->param_name, config_value->param_name) == 0 && - config_entry->param_ptr) - { - switch (config_entry->param_type) - { - case 's': - if (strcmp(config_value->param_str_value, "NULL") == 0) - { - *((char*)config_entry->param_ptr) = '\0'; - } - else { - strlcpy((char*) config_entry->param_ptr, - config_value->param_str_value, - LOC_MAX_PARAM_STRING + 1); - } - /* Log INI values */ - LOC_LOGD("%s: PARAM %s = %s", __FUNCTION__, - config_entry->param_name, (char*)config_entry->param_ptr); - - if(NULL != config_entry->param_set) - { - *(config_entry->param_set) = 1; - } - ret = 0; - break; - case 'n': - *((int *)config_entry->param_ptr) = config_value->param_int_value; - /* Log INI values */ - LOC_LOGD("%s: PARAM %s = %d", __FUNCTION__, - config_entry->param_name, config_value->param_int_value); - - if(NULL != config_entry->param_set) - { - *(config_entry->param_set) = 1; - } - ret = 0; - break; - case 'f': - *((double *)config_entry->param_ptr) = config_value->param_double_value; - /* Log INI values */ - LOC_LOGD("%s: PARAM %s = %f", __FUNCTION__, - config_entry->param_name, config_value->param_double_value); - - if(NULL != config_entry->param_set) - { - *(config_entry->param_set) = 1; - } - ret = 0; - break; - default: - LOC_LOGE("%s: PARAM %s parameter type must be n, f, or s", - __FUNCTION__, config_entry->param_name); - } - } - return ret; -} - -/*=========================================================================== -FUNCTION loc_fill_conf_item - -DESCRIPTION - Takes a line of configuration item and sets defined values based on - the passed in configuration table. This table maps strings to values to - set along with the type of each of these values. - -PARAMETERS: - input_buf : buffer contanis config item - config_table: table definition of strings to places to store information - table_length: length of the configuration table - -DEPENDENCIES - N/A - -RETURN VALUE - 0: Number of records in the config_table filled with input_buf - -SIDE EFFECTS - N/A -===========================================================================*/ -int loc_fill_conf_item(char* input_buf, - const loc_param_s_type* config_table, uint32_t table_length) -{ - int ret = 0; - - if (input_buf && config_table) { - char *lasts; - loc_param_v_type config_value; - memset(&config_value, 0, sizeof(config_value)); - - /* Separate variable and value */ - config_value.param_name = strtok_r(input_buf, "=", &lasts); - /* skip lines that do not contain "=" */ - if (config_value.param_name) { - config_value.param_str_value = strtok_r(NULL, "=", &lasts); - - /* skip lines that do not contain two operands */ - if (config_value.param_str_value) { - /* Trim leading and trailing spaces */ - loc_util_trim_space(config_value.param_name); - loc_util_trim_space(config_value.param_str_value); - - /* Parse numerical value */ - if ((strlen(config_value.param_str_value) >=3) && - (config_value.param_str_value[0] == '0') && - (tolower(config_value.param_str_value[1]) == 'x')) - { - /* hex */ - config_value.param_int_value = (int) strtol(&config_value.param_str_value[2], - (char**) NULL, 16); - } - else { - config_value.param_double_value = (double) atof(config_value.param_str_value); /* float */ - config_value.param_int_value = atoi(config_value.param_str_value); /* dec */ - } - - for(uint32_t i = 0; NULL != config_table && i < table_length; i++) - { - if(!loc_set_config_entry(&config_table[i], &config_value)) { - ret += 1; - } - } - } - } - } - - return ret; -} - -/*=========================================================================== -FUNCTION loc_read_conf_r (repetitive) - -DESCRIPTION - Reads the specified configuration file and sets defined values based on - the passed in configuration table. This table maps strings to values to - set along with the type of each of these values. - The difference between this and loc_read_conf is that this function returns - the file pointer position at the end of filling a config table. Also, it - reads a fixed number of parameters at a time which is equal to the length - of the configuration table. This functionality enables the caller to - repeatedly call the function to read data from the same file. - -PARAMETERS: - conf_fp : file pointer - config_table: table definition of strings to places to store information - table_length: length of the configuration table - -DEPENDENCIES - N/A - -RETURN VALUE - 0: Table filled successfully - 1: No more parameters to read - -1: Error filling table - -SIDE EFFECTS - N/A -===========================================================================*/ -int loc_read_conf_r(FILE *conf_fp, const loc_param_s_type* config_table, uint32_t table_length) -{ - int ret=0; - - unsigned int num_params=table_length; - if(conf_fp == NULL) { - LOC_LOGE("%s:%d]: ERROR: File pointer is NULL\n", __func__, __LINE__); - ret = -1; - goto err; - } - - /* Clear all validity bits */ - for(uint32_t i = 0; NULL != config_table && i < table_length; i++) - { - if(NULL != config_table[i].param_set) - { - *(config_table[i].param_set) = 0; - } - } - - char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */ - - LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params); - while(num_params) - { - if(!fgets(input_buf, LOC_MAX_PARAM_LINE, conf_fp)) { - LOC_LOGD("%s:%d]: fgets returned NULL\n", __func__, __LINE__); - break; - } - - num_params -= loc_fill_conf_item(input_buf, config_table, table_length); - } - -err: - return ret; -} - -/*=========================================================================== -FUNCTION loc_udpate_conf - -DESCRIPTION - Parses the passed in buffer for configuration items, and update the table - that is also passed in. - -Reads the specified configuration file and sets defined values based on - the passed in configuration table. This table maps strings to values to - set along with the type of each of these values. - -PARAMETERS: - conf_data: configuration items in bufferas a string - length: strlen(conf_data) - config_table: table definition of strings to places to store information - table_length: length of the configuration table - -DEPENDENCIES - N/A - -RETURN VALUE - number of the records in the table that is updated at time of return. - -SIDE EFFECTS - N/A -===========================================================================*/ -int loc_update_conf(const char* conf_data, int32_t length, - const loc_param_s_type* config_table, uint32_t table_length) -{ - int ret = -1; - - if (conf_data && length && config_table && table_length) { - // make a copy, so we do not tokenize the original data - char* conf_copy = (char*)malloc(length+1); - - if (conf_copy != NULL) - { - memcpy(conf_copy, conf_data, length); - // we hard NULL the end of string to be safe - conf_copy[length] = 0; - - // start with one record off - uint32_t num_params = table_length - 1; - char* saveptr = NULL; - char* input_buf = strtok_r(conf_copy, "\n", &saveptr); - ret = 0; - - LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params); - while(num_params && input_buf) { - ret++; - num_params -= loc_fill_conf_item(input_buf, config_table, table_length); - input_buf = strtok_r(NULL, "\n", &saveptr); - } - free(conf_copy); - } - } - - return ret; -} - -/*=========================================================================== -FUNCTION loc_read_conf - -DESCRIPTION - Reads the specified configuration file and sets defined values based on - the passed in configuration table. This table maps strings to values to - set along with the type of each of these values. - -PARAMETERS: - conf_file_name: configuration file to read - config_table: table definition of strings to places to store information - table_length: length of the configuration table - -DEPENDENCIES - N/A - -RETURN VALUE - None - -SIDE EFFECTS - N/A -===========================================================================*/ -void loc_read_conf(const char* conf_file_name, const loc_param_s_type* config_table, - uint32_t table_length) -{ - FILE *conf_fp = NULL; - char *lasts; - loc_param_v_type config_value; - uint32_t i; - - if((conf_fp = fopen(conf_file_name, "r")) != NULL) - { - LOC_LOGD("%s: using %s", __FUNCTION__, conf_file_name); - if(table_length && config_table) { - loc_read_conf_r(conf_fp, config_table, table_length); - rewind(conf_fp); - } - loc_read_conf_r(conf_fp, loc_param_table, loc_param_num); - fclose(conf_fp); - } - /* Initialize logging mechanism with parsed data */ - loc_logger_init(DEBUG_LEVEL, TIMESTAMP); -} diff --git a/gps/utils/loc_cfg.h b/gps/utils/loc_cfg.h deleted file mode 100644 index 9045e1d..0000000 --- a/gps/utils/loc_cfg.h +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (c) 2011-2015, 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_CFG_H -#define LOC_CFG_H - -#include -#include - -#define LOC_MAX_PARAM_NAME 80 -#define LOC_MAX_PARAM_STRING 80 -#define LOC_MAX_PARAM_LINE (LOC_MAX_PARAM_NAME + LOC_MAX_PARAM_STRING) - -#define UTIL_UPDATE_CONF(conf_data, len, config_table) \ - loc_update_conf((conf_data), (len), (config_table), \ - sizeof(config_table) / sizeof(config_table[0])) - -#define UTIL_READ_CONF_DEFAULT(filename) \ - loc_read_conf((filename), NULL, 0); - -#define UTIL_READ_CONF(filename, config_table) \ - loc_read_conf((filename), (config_table), sizeof(config_table) / sizeof(config_table[0])) - -/*============================================================================= - * - * MODULE TYPE DECLARATION - * - *============================================================================*/ -typedef struct -{ - const char *param_name; - void *param_ptr; - uint8_t *param_set; /* was this value set by config file? */ - char param_type; /* 'n' for number, - 's' for string, - 'f' for float */ -} loc_param_s_type; - -/*============================================================================= - * - * MODULE EXTERNAL DATA - * - *============================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/*============================================================================= - * - * MODULE EXPORTED FUNCTIONS - * - *============================================================================*/ -void loc_read_conf(const char* conf_file_name, - const loc_param_s_type* config_table, - uint32_t table_length); -int loc_read_conf_r(FILE *conf_fp, const loc_param_s_type* config_table, - uint32_t table_length); -int loc_update_conf(const char* conf_data, int32_t length, - const loc_param_s_type* config_table, uint32_t table_length); -#ifdef __cplusplus -} -#endif - -#endif /* LOC_CFG_H */ diff --git a/gps/utils/loc_log.cpp b/gps/utils/loc_log.cpp deleted file mode 100644 index 76f0c53..0000000 --- a/gps/utils/loc_log.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/* Copyright (c) 2011-2012, 2015, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation, nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define LOG_NDDEBUG 0 - -#include -#include -#include -#include "loc_log.h" -#include "msg_q.h" -#ifdef USE_GLIB -#include -#endif /* USE_GLIB */ -#include "log_util.h" -#include "platform_lib_includes.h" - -#define BUFFER_SIZE 120 - -// Logging Improvements -const char *loc_logger_boolStr[]={"False","True"}; -const char VOID_RET[] = "None"; -const char FROM_AFW[] = "===>"; -const char TO_MODEM[] = "--->"; -const char FROM_MODEM[] = "<---"; -const char TO_AFW[] = "<==="; -const char EXIT_TAG[] = "Exiting"; -const char ENTRY_TAG[] = "Entering"; -const char EXIT_ERROR_TAG[] = "Exiting with error"; - -/* Logging Mechanism */ -loc_logger_s_type loc_logger; - -/* Get names from value */ -const char* loc_get_name_from_mask(const loc_name_val_s_type table[], size_t table_size, long mask) -{ - size_t i; - for (i = 0; i < table_size; i++) - { - if (table[i].val & (long) mask) - { - return table[i].name; - } - } - return UNKNOWN_STR; -} - -/* Get names from value */ -const char* loc_get_name_from_val(const loc_name_val_s_type table[], size_t table_size, long value) -{ - size_t i; - for (i = 0; i < table_size; i++) - { - if (table[i].val == (long) value) - { - return table[i].name; - } - } - return UNKNOWN_STR; -} - -static const loc_name_val_s_type loc_msg_q_status[] = -{ - NAME_VAL( eMSG_Q_SUCCESS ), - NAME_VAL( eMSG_Q_FAILURE_GENERAL ), - NAME_VAL( eMSG_Q_INVALID_PARAMETER ), - NAME_VAL( eMSG_Q_INVALID_HANDLE ), - NAME_VAL( eMSG_Q_UNAVAILABLE_RESOURCE ), - NAME_VAL( eMSG_Q_INSUFFICIENT_BUFFER ) -}; -static const size_t loc_msg_q_status_num = LOC_TABLE_SIZE(loc_msg_q_status); - -/* Find msg_q status name */ -const char* loc_get_msg_q_status(int status) -{ - return loc_get_name_from_val(loc_msg_q_status, loc_msg_q_status_num, (long) status); -} - -const char* log_succ_fail_string(int is_succ) -{ - return is_succ? "successful" : "failed"; -} - -//Target names -static const loc_name_val_s_type target_name[] = -{ - NAME_VAL(GNSS_NONE), - NAME_VAL(GNSS_MSM), - NAME_VAL(GNSS_GSS), - NAME_VAL(GNSS_MDM), - NAME_VAL(GNSS_QCA1530), - NAME_VAL(GNSS_AUTO), - NAME_VAL(GNSS_UNKNOWN) -}; - -static const size_t target_name_num = LOC_TABLE_SIZE(target_name); - -/*=========================================================================== - -FUNCTION loc_get_target_name - -DESCRIPTION - Returns pointer to a string that contains name of the target - - XX:XX:XX.000\0 - -RETURN VALUE - The target name string - -===========================================================================*/ -const char *loc_get_target_name(unsigned int target) -{ - int index = 0; - static char ret[BUFFER_SIZE]; - - index = getTargetGnssType(target); - if( index < 0 || (unsigned)index >= target_name_num ) - index = target_name_num - 1; - - if( (target & HAS_SSC) == HAS_SSC ) { - snprintf(ret, sizeof(ret), " %s with SSC", - loc_get_name_from_val(target_name, target_name_num, (long)index) ); - } - else { - snprintf(ret, sizeof(ret), " %s without SSC", - loc_get_name_from_val(target_name, target_name_num, (long)index) ); - } - return ret; -} - - -/*=========================================================================== - -FUNCTION loc_get_time - -DESCRIPTION - Logs a callback event header. - The pointer time_string should point to a buffer of at least 13 bytes: - - XX:XX:XX.000\0 - -RETURN VALUE - The time string - -===========================================================================*/ -char *loc_get_time(char *time_string, size_t buf_size) -{ - struct timeval now; /* sec and usec */ - struct tm now_tm; /* broken-down time */ - char hms_string[80]; /* HH:MM:SS */ - - gettimeofday(&now, NULL); - localtime_r(&now.tv_sec, &now_tm); - - strftime(hms_string, sizeof hms_string, "%H:%M:%S", &now_tm); - snprintf(time_string, buf_size, "%s.%03d", hms_string, (int) (now.tv_usec / 1000)); - - return time_string; -} - - -/*=========================================================================== -FUNCTION loc_logger_init - -DESCRIPTION - Initializes the state of DEBUG_LEVEL and TIMESTAMP - -DEPENDENCIES - N/A - -RETURN VALUE - None - -SIDE EFFECTS - N/A -===========================================================================*/ -void loc_logger_init(unsigned long debug, unsigned long timestamp) -{ - loc_logger.DEBUG_LEVEL = debug; -#ifdef TARGET_BUILD_VARIANT_USER - // force user builds to 2 or less - if (loc_logger.DEBUG_LEVEL > 2) { - loc_logger.DEBUG_LEVEL = 2; - } -#endif - loc_logger.TIMESTAMP = timestamp; -} - - -/*=========================================================================== -FUNCTION get_timestamp - -DESCRIPTION - Generates a timestamp using the current system time - -DEPENDENCIES - N/A - -RETURN VALUE - Char pointer to the parameter str - -SIDE EFFECTS - N/A -===========================================================================*/ -char * get_timestamp(char *str, unsigned long buf_size) -{ - struct timeval tv; - struct timezone tz; - int hh, mm, ss; - gettimeofday(&tv, &tz); - hh = tv.tv_sec/3600%24; - mm = (tv.tv_sec%3600)/60; - ss = tv.tv_sec%60; - snprintf(str, buf_size, "%02d:%02d:%02d.%06ld", hh, mm, ss, tv.tv_usec); - return str; -} - diff --git a/gps/utils/loc_log.h b/gps/utils/loc_log.h deleted file mode 100644 index be492b1..0000000 --- a/gps/utils/loc_log.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) 2011-2012, 2015 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_LOG_H -#define LOC_LOG_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include "loc_target.h" - -typedef struct -{ - const char *name; - long val; -} loc_name_val_s_type; - -#define NAME_VAL(x) {"" #x "", x } - -#define UNKNOWN_STR "UNKNOWN" - -#define CHECK_MASK(type, value, mask_var, mask) \ - (((mask_var) & (mask)) ? (type) (value) : (type) (-1)) - -#define LOC_TABLE_SIZE(table) (sizeof(table)/sizeof((table)[0])) - -/* Get names from value */ -const char* loc_get_name_from_mask(const loc_name_val_s_type table[], size_t table_size, long mask); -const char* loc_get_name_from_val(const loc_name_val_s_type table[], size_t table_size, long value); -const char* loc_get_msg_q_status(int status); -const char* loc_get_target_name(unsigned int target); - -extern const char* log_succ_fail_string(int is_succ); - -extern char *loc_get_time(char *time_string, size_t buf_size); - -#ifdef __cplusplus -} -#endif - -#endif /* LOC_LOG_H */ diff --git a/gps/utils/loc_misc_utils.cpp b/gps/utils/loc_misc_utils.cpp deleted file mode 100644 index 7e96313..0000000 --- a/gps/utils/loc_misc_utils.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright (c) 2014, 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 -#include -#include -#include -#include - -#define LOG_NDDEBUG 0 -#define LOG_TAG "LocSvc_misc_utils" - -int loc_util_split_string(char *raw_string, char **split_strings_ptr, - int max_num_substrings, char delimiter) -{ - int raw_string_index=0; - int num_split_strings=0; - unsigned char end_string=0; - int raw_string_length=0; - - if(!raw_string || !split_strings_ptr) { - LOC_LOGE("%s:%d]: NULL parameters", __func__, __LINE__); - num_split_strings = -1; - goto err; - } - LOC_LOGD("%s:%d]: raw string: %s\n", __func__, __LINE__, raw_string); - raw_string_length = strlen(raw_string) + 1; - split_strings_ptr[num_split_strings] = &raw_string[raw_string_index]; - for(raw_string_index=0; raw_string_index < raw_string_length; raw_string_index++) { - if(raw_string[raw_string_index] == '\0') - end_string=1; - if((raw_string[raw_string_index] == delimiter) || end_string) { - raw_string[raw_string_index] = '\0'; - LOC_LOGD("%s:%d]: split string: %s\n", - __func__, __LINE__, split_strings_ptr[num_split_strings]); - num_split_strings++; - if(((raw_string_index + 1) < raw_string_length) && - (num_split_strings < max_num_substrings)) { - split_strings_ptr[num_split_strings] = &raw_string[raw_string_index+1]; - } - else { - break; - } - } - if(end_string) - break; - } -err: - LOC_LOGD("%s:%d]: num_split_strings: %d\n", __func__, __LINE__, num_split_strings); - return num_split_strings; -} - -void loc_util_trim_space(char *org_string) -{ - char *scan_ptr, *write_ptr; - char *first_nonspace = NULL, *last_nonspace = NULL; - - if(org_string == NULL) { - LOC_LOGE("%s:%d]: NULL parameter", __func__, __LINE__); - goto err; - } - - scan_ptr = write_ptr = org_string; - - while (*scan_ptr) { - //Find the first non-space character - if ( !isspace(*scan_ptr) && first_nonspace == NULL) { - first_nonspace = scan_ptr; - } - //Once the first non-space character is found in the - //above check, keep shifting the characters to the left - //to replace the spaces - if (first_nonspace != NULL) { - *(write_ptr++) = *scan_ptr; - //Keep track of which was the last non-space character - //encountered - //last_nonspace will not be updated in the case where - //the string ends with spaces - if ( !isspace(*scan_ptr)) { - last_nonspace = write_ptr; - } - } - scan_ptr++; - } - //Add NULL terminator after the last non-space character - if (last_nonspace) { *last_nonspace = '\0'; } -err: - return; -} diff --git a/gps/utils/loc_misc_utils.h b/gps/utils/loc_misc_utils.h deleted file mode 100644 index 7d66d84..0000000 --- a/gps/utils/loc_misc_utils.h +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright (c) 2014, 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_MISC_UTILS_H_ -#define _LOC_MISC_UTILS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/*=========================================================================== -FUNCTION loc_split_string - -DESCRIPTION: - This function is used to split a delimiter separated string into - sub-strings. This function does not allocate new memory to store the split - strings. Instead, it places '\0' in places of delimiters and assings the - starting address of the substring within the raw string as the string address - The input raw_string no longer remains to be a collection of sub-strings - after this function is executed. - Please make a copy of the input string before calling this function if - necessary - -PARAMETERS: - char *raw_string: is the original string with delimiter separated substrings - char **split_strings_ptr: is the arraw of pointers which will hold the addresses - of individual substrings - int max_num_substrings: is the maximum number of substrings that are expected - by the caller. The array of pointers in the above parameter - is usually this long - char delimiter: is the delimiter that separates the substrings. Examples: ' ', ';' - -DEPENDENCIES - N/A - -RETURN VALUE - int Number of split strings - -SIDE EFFECTS - The input raw_string no longer remains a delimiter separated single string. - -EXAMPLE - delimiter = ' ' //space - raw_string = "hello new user" //delimiter is space ' ' - addresses = 0123456789abcd - split_strings_ptr[0] = &raw_string[0]; //split_strings_ptr[0] contains "hello" - split_strings_ptr[1] = &raw_string[6]; //split_strings_ptr[1] contains "new" - split_strings_ptr[2] = &raw_string[a]; //split_strings_ptr[2] contains "user" - -===========================================================================*/ -int loc_util_split_string(char *raw_string, char **split_strings_ptr, int max_num_substrings, - char delimiter); - -/*=========================================================================== -FUNCTION trim_space - -DESCRIPTION - Removes leading and trailing spaces of the string - -DEPENDENCIES - N/A - -RETURN VALUE - None - -SIDE EFFECTS - N/A -===========================================================================*/ -void loc_util_trim_space(char *org_string); -#ifdef __cplusplus -} -#endif - -#endif //_LOC_MISC_UTILS_H_ diff --git a/gps/utils/loc_target.cpp b/gps/utils/loc_target.cpp deleted file mode 100644 index faaedf6..0000000 --- a/gps/utils/loc_target.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* Copyright (c) 2012-2015, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include "loc_target.h" -#include "loc_log.h" -#include "log_util.h" - -#define APQ8064_ID_1 "109" -#define APQ8064_ID_2 "153" -#define MPQ8064_ID_1 "130" -#define MSM8930_ID_1 "142" -#define MSM8930_ID_2 "116" -#define APQ8030_ID_1 "157" -#define APQ8074_ID_1 "184" - -#define LINE_LEN 100 -#define STR_LIQUID "Liquid" -#define STR_SURF "Surf" -#define STR_MTP "MTP" -#define STR_APQ "apq" -#define STR_AUTO "auto" -#define IS_STR_END(c) ((c) == '\0' || (c) == '\n' || (c) == '\r') -#define LENGTH(s) (sizeof(s) - 1) -#define GPS_CHECK_NO_ERROR 0 -#define GPS_CHECK_NO_GPS_HW 1 -/* When system server is started, it uses 20 seconds as ActivityManager - * timeout. After that it sends SIGSTOP signal to process. - */ -#define QCA1530_DETECT_TIMEOUT 15 -#define QCA1530_DETECT_PRESENT "yes" -#define QCA1530_DETECT_PROGRESS "detect" - -static unsigned int gTarget = (unsigned int)-1; - -static int read_a_line(const char * file_path, char * line, int line_size) -{ - FILE *fp; - int result = 0; - - * line = '\0'; - fp = fopen(file_path, "r" ); - if( fp == NULL ) { - LOC_LOGE("open failed: %s: %s\n", file_path, strerror(errno)); - result = -1; - } else { - int len; - fgets(line, line_size, fp); - len = strlen(line); - len = len < line_size - 1? len : line_size - 1; - line[len] = '\0'; - LOC_LOGD("cat %s: %s", file_path, line); - fclose(fp); - } - return result; -} - -/*! - * \brief Checks if QCA1530 is avalable. - * - * Function verifies if qca1530 SoC is configured on the device. The test is - * based on property value. For 1530 scenario, the value shall be one of the - * following: "yes", "no", "detect". All other values are treated equally to - * "no". When the value is "detect" the system waits for SoC detection to - * finish before returning result. - * - * \retval true - QCA1530 is available. - * \retval false - QCA1530 is not available. - */ -static bool is_qca1530(void) -{ - static const char qca1530_property_name[] = "sys.qca1530"; - bool res = false; - int ret, i; - char buf[PROPERTY_VALUE_MAX]; - - memset(buf, 0, sizeof(buf)); - - for (i = 0; i < QCA1530_DETECT_TIMEOUT; ++i) - { - ret = property_get(qca1530_property_name, buf, NULL); - if (ret < 0) - { - LOC_LOGV( "qca1530: property %s is not accessible, ret=%d", - qca1530_property_name, - ret); - - break; - } - - LOC_LOGV( "qca1530: property %s is set to %s", - qca1530_property_name, - buf); - - if (!memcmp(buf, QCA1530_DETECT_PRESENT, - sizeof(QCA1530_DETECT_PRESENT))) - { - res = true; - break; - } - if (!memcmp(buf, QCA1530_DETECT_PROGRESS, - sizeof(QCA1530_DETECT_PROGRESS))) - { - LOC_LOGV("qca1530: SoC detection is in progress."); - sleep(1); - continue; - } - break; - } - - LOC_LOGD("qca1530: detected=%s", res ? "true" : "false"); - return res; -} - -/*The character array passed to this function should have length - of atleast PROPERTY_VALUE_MAX*/ -void loc_get_target_baseband(char *baseband, int array_length) -{ - if(baseband && (array_length >= PROPERTY_VALUE_MAX)) { - property_get("ro.baseband", baseband, ""); - LOC_LOGD("%s:%d]: Baseband: %s\n", __func__, __LINE__, baseband); - } - else { - LOC_LOGE("%s:%d]: NULL parameter or array length less than PROPERTY_VALUE_MAX\n", - __func__, __LINE__); - } -} - -/*The character array passed to this function should have length - of atleast PROPERTY_VALUE_MAX*/ -void loc_get_platform_name(char *platform_name, int array_length) -{ - if(platform_name && (array_length >= PROPERTY_VALUE_MAX)) { - property_get("ro.board.platform", platform_name, ""); - LOC_LOGD("%s:%d]: Target name: %s\n", __func__, __LINE__, platform_name); - } - else { - LOC_LOGE("%s:%d]: Null parameter or array length less than PROPERTY_VALUE_MAX\n", - __func__, __LINE__); - } -} - -unsigned int loc_get_target(void) -{ - if (gTarget != (unsigned int)-1) - return gTarget; - - static const char hw_platform[] = "/sys/devices/soc0/hw_platform"; - static const char id[] = "/sys/devices/soc0/soc_id"; - static const char hw_platform_dep[] = - "/sys/devices/system/soc/soc0/hw_platform"; - static const char id_dep[] = "/sys/devices/system/soc/soc0/id"; - static const char mdm[] = "/dev/mdm"; // No such file or directory - - char rd_hw_platform[LINE_LEN]; - char rd_id[LINE_LEN]; - char rd_mdm[LINE_LEN]; - char baseband[LINE_LEN]; - - if (is_qca1530()) { - gTarget = TARGET_QCA1530; - goto detected; - } - - loc_get_target_baseband(baseband, sizeof(baseband)); - - if (!access(hw_platform, F_OK)) { - read_a_line(hw_platform, rd_hw_platform, LINE_LEN); - } else { - read_a_line(hw_platform_dep, rd_hw_platform, LINE_LEN); - } - if (!access(id, F_OK)) { - read_a_line(id, rd_id, LINE_LEN); - } else { - read_a_line(id_dep, rd_id, LINE_LEN); - } - if( !memcmp(baseband, STR_AUTO, LENGTH(STR_AUTO)) ) - { - gTarget = TARGET_AUTO; - goto detected; - } - if( !memcmp(baseband, STR_APQ, LENGTH(STR_APQ)) ){ - - if( !memcmp(rd_id, MPQ8064_ID_1, LENGTH(MPQ8064_ID_1)) - && IS_STR_END(rd_id[LENGTH(MPQ8064_ID_1)]) ) - gTarget = TARGET_MPQ; - else - gTarget = TARGET_APQ_SA; - } - else { - if( (!memcmp(rd_hw_platform, STR_LIQUID, LENGTH(STR_LIQUID)) - && IS_STR_END(rd_hw_platform[LENGTH(STR_LIQUID)])) || - (!memcmp(rd_hw_platform, STR_SURF, LENGTH(STR_SURF)) - && IS_STR_END(rd_hw_platform[LENGTH(STR_SURF)])) || - (!memcmp(rd_hw_platform, STR_MTP, LENGTH(STR_MTP)) - && IS_STR_END(rd_hw_platform[LENGTH(STR_MTP)]))) { - - if (!read_a_line( mdm, rd_mdm, LINE_LEN)) - gTarget = TARGET_MDM; - } - else if( (!memcmp(rd_id, MSM8930_ID_1, LENGTH(MSM8930_ID_1)) - && IS_STR_END(rd_id[LENGTH(MSM8930_ID_1)])) || - (!memcmp(rd_id, MSM8930_ID_2, LENGTH(MSM8930_ID_2)) - && IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) ) - gTarget = TARGET_MSM_NO_SSC; - else - gTarget = TARGET_UNKNOWN; - } - -detected: - LOC_LOGD("HAL: %s returned %d", __FUNCTION__, gTarget); - return gTarget; -} - -/*Reads the property ro.lean to identify if this is a lean target - Returns: - 0 if not a lean and mean target - 1 if this is a lean and mean target -*/ -int loc_identify_lean_target() -{ - int ret = 0; - char lean_target[PROPERTY_VALUE_MAX]; - property_get("ro.lean", lean_target, ""); - LOC_LOGD("%s:%d]: lean target: %s\n", __func__, __LINE__, lean_target); - return !(strncmp(lean_target, "true", PROPERTY_VALUE_MAX)); -} diff --git a/gps/utils/loc_target.h b/gps/utils/loc_target.h deleted file mode 100644 index 3bb3b5e..0000000 --- a/gps/utils/loc_target.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (c) 2012-2014, 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_TARGET_H -#define LOC_TARGET_H -#define TARGET_SET(gnss,ssc) ( (gnss<<1)|ssc ) -#define TARGET_DEFAULT TARGET_SET(GNSS_MSM, HAS_SSC) -#define TARGET_MDM TARGET_SET(GNSS_MDM, HAS_SSC) -#define TARGET_APQ_SA TARGET_SET(GNSS_GSS, NO_SSC) -#define TARGET_MPQ TARGET_SET(GNSS_NONE,NO_SSC) -#define TARGET_MSM_NO_SSC TARGET_SET(GNSS_MSM, NO_SSC) -#define TARGET_QCA1530 TARGET_SET(GNSS_QCA1530, NO_SSC) -#define TARGET_AUTO TARGET_SET(GNSS_AUTO, NO_SSC) -#define TARGET_UNKNOWN TARGET_SET(GNSS_UNKNOWN, NO_SSC) -#define getTargetGnssType(target) (target>>1) - -#ifdef __cplusplus -extern "C" -{ -#endif - -unsigned int loc_get_target(void); - -/*The character array passed to this function should have length - of atleast PROPERTY_VALUE_MAX*/ -void loc_get_target_baseband(char *baseband, int array_length); -/*The character array passed to this function should have length - of atleast PROPERTY_VALUE_MAX*/ -void loc_get_platform_name(char *platform_name, int array_length); -/*Reads the property ro.lean to identify if this is a lean target - Returns: - 0 if not a lean and mean target - 1 if this is a lean and mean target*/ -int loc_identify_lean_target(); - -/* Please remember to update 'target_name' in loc_log.cpp, - if do any changes to this enum. */ -typedef enum { - GNSS_NONE = 0, - GNSS_MSM, - GNSS_GSS, - GNSS_MDM, - GNSS_QCA1530, - GNSS_AUTO, - GNSS_UNKNOWN -}GNSS_TARGET; - -typedef enum { - NO_SSC = 0, - HAS_SSC -}SSC_TYPE; - -#ifdef __cplusplus -} -#endif - -#endif /*LOC_TARGET_H*/ diff --git a/gps/utils/loc_timer.h b/gps/utils/loc_timer.h deleted file mode 100644 index 2967858..0000000 --- a/gps/utils/loc_timer.h +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (c) 2013,2015 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_DELAY_H__ -#define __LOC_DELAY_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ -#include - -/* - user_data: client context pointer, passthrough. Originally received - from calling client when loc_timer_start() is called. - result: 0 if timer successfully timed out; else timer failed. -*/ -typedef void (*loc_timer_callback)(void *user_data, int32_t result); - - -/* - delay_msec: timeout value for the timer. - cb_func: callback function pointer, implemented by client. - Can not be NULL. - user_data: client context pointer, passthrough. Will be - returned when loc_timer_callback() is called. - wakeOnExpire: true if to wake up CPU (if sleeping) upon timer - expiration and notify the client. - false if to wait until next time CPU wakes up (if - sleeping) and then notify the client. - Returns the handle, which can be used to stop the timer - NULL, if timer start fails (e.g. if cb_func is NULL). -*/ -void* loc_timer_start(uint64_t delay_msec, - loc_timer_callback cb_func, - void *user_data, - bool wake_on_expire=false); - -/* - handle becomes invalid upon the return of the callback -*/ -void loc_timer_stop(void*& handle); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif //__LOC_DELAY_H__ diff --git a/gps/utils/log_util.h b/gps/utils/log_util.h deleted file mode 100644 index 0d59f01..0000000 --- a/gps/utils/log_util.h +++ /dev/null @@ -1,167 +0,0 @@ -/* Copyright (c) 2011-2014 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 __LOG_UTIL_H__ -#define __LOG_UTIL_H__ - -#ifndef USE_GLIB -#include -#endif /* USE_GLIB */ - -#ifdef USE_GLIB - -#include -#include -#include - -#ifndef LOG_TAG -#define LOG_TAG "GPS_UTILS" - -#endif // LOG_TAG - -#endif /* USE_GLIB */ - -#ifdef __cplusplus -extern "C" -{ -#endif -/*============================================================================= - * - * LOC LOGGER TYPE DECLARATION - * - *============================================================================*/ -/* LOC LOGGER */ -typedef struct loc_logger_s -{ - unsigned long DEBUG_LEVEL; - unsigned long TIMESTAMP; -} loc_logger_s_type; - -/*============================================================================= - * - * EXTERNAL DATA - * - *============================================================================*/ -extern loc_logger_s_type loc_logger; - -// Logging Improvements -extern const char *loc_logger_boolStr[]; - -extern const char *boolStr[]; -extern const char VOID_RET[]; -extern const char FROM_AFW[]; -extern const char TO_MODEM[]; -extern const char FROM_MODEM[]; -extern const char TO_AFW[]; -extern const char EXIT_TAG[]; -extern const char ENTRY_TAG[]; -extern const char EXIT_ERROR_TAG[]; - -/*============================================================================= - * - * MODULE EXPORTED FUNCTIONS - * - *============================================================================*/ -extern void loc_logger_init(unsigned long debug, unsigned long timestamp); -extern char* get_timestamp(char* str, unsigned long buf_size); - -#ifndef DEBUG_DMN_LOC_API - -/* LOGGING MACROS */ -/*loc_logger.DEBUG_LEVEL is initialized to 0xff in loc_cfg.cpp - if that value remains unchanged, it means gps.conf did not - provide a value and we default to the initial value to use - Android's logging levels*/ -#define IF_LOC_LOGE if((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5)) -#define IF_LOC_LOGW if((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5)) -#define IF_LOC_LOGI if((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5)) -#define IF_LOC_LOGD if((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5)) -#define IF_LOC_LOGV if((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5)) - -#define LOC_LOGE(...) IF_LOC_LOGE { ALOGE(__VA_ARGS__); } -#define LOC_LOGW(...) IF_LOC_LOGW { ALOGW(__VA_ARGS__); } -#define LOC_LOGI(...) IF_LOC_LOGI { ALOGI(__VA_ARGS__); } -#define LOC_LOGD(...) IF_LOC_LOGD { ALOGD(__VA_ARGS__); } -#define LOC_LOGV(...) IF_LOC_LOGV { ALOGV(__VA_ARGS__); } - -#else /* DEBUG_DMN_LOC_API */ - -#define LOC_LOGE(...) ALOGE(__VA_ARGS__) -#define LOC_LOGW(...) ALOGW(__VA_ARGS__) -#define LOC_LOGI(...) ALOGI(__VA_ARGS__) -#define LOC_LOGD(...) ALOGD(__VA_ARGS__) -#define LOC_LOGV(...) ALOGV(__VA_ARGS__) - -#endif /* DEBUG_DMN_LOC_API */ - -/*============================================================================= - * - * LOGGING IMPROVEMENT MACROS - * - *============================================================================*/ -#define LOG_(LOC_LOG, ID, WHAT, SPEC, VAL) \ - do { \ - if (loc_logger.TIMESTAMP) { \ - char ts[32]; \ - LOC_LOG("[%s] %s %s line %d " #SPEC, \ - get_timestamp(ts, sizeof(ts)), ID, WHAT, __LINE__, VAL); \ - } else { \ - LOC_LOG("%s %s line %d " #SPEC, \ - ID, WHAT, __LINE__, VAL); \ - } \ - } while(0) - -#define LOG_I(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGI, ID, WHAT, SPEC, VAL) -#define LOG_V(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGV, ID, WHAT, SPEC, VAL) -#define LOG_E(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGE, ID, WHAT, SPEC, VAL) - -#define ENTRY_LOG() LOG_V(ENTRY_TAG, __FUNCTION__, %s, "") -#define EXIT_LOG(SPEC, VAL) LOG_V(EXIT_TAG, __FUNCTION__, SPEC, VAL) -#define EXIT_LOG_WITH_ERROR(SPEC, VAL) \ - if (VAL != 0) { \ - LOG_E(EXIT_ERROR_TAG, __FUNCTION__, SPEC, VAL); \ - } else { \ - LOG_V(EXIT_TAG, __FUNCTION__, SPEC, VAL); \ - } - - -// Used for logging callflow from Android Framework -#define ENTRY_LOG_CALLFLOW() LOG_I(FROM_AFW, __FUNCTION__, %s, "") -// Used for logging callflow to Modem -#define EXIT_LOG_CALLFLOW(SPEC, VAL) LOG_I(TO_MODEM, __FUNCTION__, SPEC, VAL) -// Used for logging callflow from Modem(TO_MODEM, __FUNCTION__, %s, "") -#define MODEM_LOG_CALLFLOW(SPEC, VAL) LOG_I(FROM_MODEM, __FUNCTION__, SPEC, VAL) -// Used for logging callflow to Android Framework -#define CALLBACK_LOG_CALLFLOW(CB, SPEC, VAL) LOG_I(TO_AFW, CB, SPEC, VAL) - -#ifdef __cplusplus -} -#endif - -#endif // __LOG_UTIL_H__ diff --git a/gps/utils/msg_q.c b/gps/utils/msg_q.c deleted file mode 100644 index 5be8547..0000000 --- a/gps/utils/msg_q.c +++ /dev/null @@ -1,336 +0,0 @@ -/* Copyright (c) 2011-2012, 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 "msg_q.h" - -#define LOG_TAG "LocSvc_utils_q" -#include "log_util.h" -#include "platform_lib_includes.h" -#include "linked_list.h" -#include -#include -#include - -typedef struct msg_q { - void* msg_list; /* Linked list to store information */ - pthread_cond_t list_cond; /* Condition variable for waiting on msg queue */ - pthread_mutex_t list_mutex; /* Mutex for exclusive access to message queue */ - int unblocked; /* Has this message queue been unblocked? */ -} msg_q; - -/*=========================================================================== -FUNCTION convert_linked_list_err_type - -DESCRIPTION - Converts from one set of enum values to another. - - linked_list_val: Value to convert to msg_q_enum_type - -DEPENDENCIES - N/A - -RETURN VALUE - Corresponding linked_list_enum_type in msg_q_enum_type - -SIDE EFFECTS - N/A - -===========================================================================*/ -static msq_q_err_type convert_linked_list_err_type(linked_list_err_type linked_list_val) -{ - switch( linked_list_val ) - { - case eLINKED_LIST_SUCCESS: - return eMSG_Q_SUCCESS; - case eLINKED_LIST_INVALID_PARAMETER: - return eMSG_Q_INVALID_PARAMETER; - case eLINKED_LIST_INVALID_HANDLE: - return eMSG_Q_INVALID_HANDLE; - case eLINKED_LIST_UNAVAILABLE_RESOURCE: - return eMSG_Q_UNAVAILABLE_RESOURCE; - case eLINKED_LIST_INSUFFICIENT_BUFFER: - return eMSG_Q_INSUFFICIENT_BUFFER; - - case eLINKED_LIST_FAILURE_GENERAL: - default: - return eMSG_Q_FAILURE_GENERAL; - } -} - -/* ----------------------- END INTERNAL FUNCTIONS ---------------------------------------- */ - -/*=========================================================================== - - FUNCTION: msg_q_init - - ===========================================================================*/ -msq_q_err_type msg_q_init(void** msg_q_data) -{ - if( msg_q_data == NULL ) - { - LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__); - return eMSG_Q_INVALID_PARAMETER; - } - - msg_q* tmp_msg_q; - tmp_msg_q = (msg_q*)calloc(1, sizeof(msg_q)); - if( tmp_msg_q == NULL ) - { - LOC_LOGE("%s: Unable to allocate space for message queue!\n", __FUNCTION__); - return eMSG_Q_FAILURE_GENERAL; - } - - if( linked_list_init(&tmp_msg_q->msg_list) != 0 ) - { - LOC_LOGE("%s: Unable to initialize storage list!\n", __FUNCTION__); - free(tmp_msg_q); - return eMSG_Q_FAILURE_GENERAL; - } - - if( pthread_mutex_init(&tmp_msg_q->list_mutex, NULL) != 0 ) - { - LOC_LOGE("%s: Unable to initialize list mutex!\n", __FUNCTION__); - linked_list_destroy(&tmp_msg_q->msg_list); - free(tmp_msg_q); - return eMSG_Q_FAILURE_GENERAL; - } - - if( pthread_cond_init(&tmp_msg_q->list_cond, NULL) != 0 ) - { - LOC_LOGE("%s: Unable to initialize msg q cond var!\n", __FUNCTION__); - linked_list_destroy(&tmp_msg_q->msg_list); - pthread_mutex_destroy(&tmp_msg_q->list_mutex); - free(tmp_msg_q); - return eMSG_Q_FAILURE_GENERAL; - } - - tmp_msg_q->unblocked = 0; - - *msg_q_data = tmp_msg_q; - - return eMSG_Q_SUCCESS; -} - -/*=========================================================================== - - FUNCTION: msg_q_init2 - - ===========================================================================*/ -const void* msg_q_init2() -{ - void* q = NULL; - if (eMSG_Q_SUCCESS != msg_q_init(&q)) { - q = NULL; - } - return q; -} - -/*=========================================================================== - - FUNCTION: msg_q_destroy - - ===========================================================================*/ -msq_q_err_type msg_q_destroy(void** msg_q_data) -{ - if( msg_q_data == NULL ) - { - LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__); - return eMSG_Q_INVALID_HANDLE; - } - - msg_q* p_msg_q = (msg_q*)*msg_q_data; - - linked_list_destroy(&p_msg_q->msg_list); - pthread_mutex_destroy(&p_msg_q->list_mutex); - pthread_cond_destroy(&p_msg_q->list_cond); - - p_msg_q->unblocked = 0; - - free(*msg_q_data); - *msg_q_data = NULL; - - return eMSG_Q_SUCCESS; -} - -/*=========================================================================== - - FUNCTION: msg_q_snd - - ===========================================================================*/ -msq_q_err_type msg_q_snd(void* msg_q_data, void* msg_obj, void (*dealloc)(void*)) -{ - msq_q_err_type rv; - if( msg_q_data == NULL ) - { - LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__); - return eMSG_Q_INVALID_HANDLE; - } - if( msg_obj == NULL ) - { - LOC_LOGE("%s: Invalid msg_obj parameter!\n", __FUNCTION__); - return eMSG_Q_INVALID_PARAMETER; - } - - msg_q* p_msg_q = (msg_q*)msg_q_data; - - pthread_mutex_lock(&p_msg_q->list_mutex); - LOC_LOGV("%s: Sending message with handle = 0x%08X\n", __FUNCTION__, msg_obj); - - if( p_msg_q->unblocked ) - { - LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__); - pthread_mutex_unlock(&p_msg_q->list_mutex); - return eMSG_Q_UNAVAILABLE_RESOURCE; - } - - rv = convert_linked_list_err_type(linked_list_add(p_msg_q->msg_list, msg_obj, dealloc)); - - /* Show data is in the message queue. */ - pthread_cond_signal(&p_msg_q->list_cond); - - pthread_mutex_unlock(&p_msg_q->list_mutex); - - LOC_LOGV("%s: Finished Sending message with handle = 0x%08X\n", __FUNCTION__, msg_obj); - - return rv; -} - -/*=========================================================================== - - FUNCTION: msg_q_rcv - - ===========================================================================*/ -msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj) -{ - msq_q_err_type rv; - if( msg_q_data == NULL ) - { - LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__); - return eMSG_Q_INVALID_HANDLE; - } - - if( msg_obj == NULL ) - { - LOC_LOGE("%s: Invalid msg_obj parameter!\n", __FUNCTION__); - return eMSG_Q_INVALID_PARAMETER; - } - - msg_q* p_msg_q = (msg_q*)msg_q_data; - - LOC_LOGV("%s: Waiting on message\n", __FUNCTION__); - - pthread_mutex_lock(&p_msg_q->list_mutex); - - if( p_msg_q->unblocked ) - { - LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__); - pthread_mutex_unlock(&p_msg_q->list_mutex); - return eMSG_Q_UNAVAILABLE_RESOURCE; - } - - /* Wait for data in the message queue */ - while( linked_list_empty(p_msg_q->msg_list) && !p_msg_q->unblocked ) - { - pthread_cond_wait(&p_msg_q->list_cond, &p_msg_q->list_mutex); - } - - rv = convert_linked_list_err_type(linked_list_remove(p_msg_q->msg_list, msg_obj)); - - pthread_mutex_unlock(&p_msg_q->list_mutex); - - LOC_LOGV("%s: Received message 0x%08X rv = %d\n", __FUNCTION__, *msg_obj, rv); - - return rv; -} - -/*=========================================================================== - - FUNCTION: msg_q_flush - - ===========================================================================*/ -msq_q_err_type msg_q_flush(void* msg_q_data) -{ - msq_q_err_type rv; - if ( msg_q_data == NULL ) - { - LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__); - return eMSG_Q_INVALID_HANDLE; - } - - msg_q* p_msg_q = (msg_q*)msg_q_data; - - LOC_LOGD("%s: Flushing Message Queue\n", __FUNCTION__); - - pthread_mutex_lock(&p_msg_q->list_mutex); - - /* Remove all elements from the list */ - rv = convert_linked_list_err_type(linked_list_flush(p_msg_q->msg_list)); - - pthread_mutex_unlock(&p_msg_q->list_mutex); - - LOC_LOGD("%s: Message Queue flushed\n", __FUNCTION__); - - return rv; -} - -/*=========================================================================== - - FUNCTION: msg_q_unblock - - ===========================================================================*/ -msq_q_err_type msg_q_unblock(void* msg_q_data) -{ - if ( msg_q_data == NULL ) - { - LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__); - return eMSG_Q_INVALID_HANDLE; - } - - msg_q* p_msg_q = (msg_q*)msg_q_data; - pthread_mutex_lock(&p_msg_q->list_mutex); - - if( p_msg_q->unblocked ) - { - LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__); - pthread_mutex_unlock(&p_msg_q->list_mutex); - return eMSG_Q_UNAVAILABLE_RESOURCE; - } - - LOC_LOGD("%s: Unblocking Message Queue\n", __FUNCTION__); - /* Unblocking message queue */ - p_msg_q->unblocked = 1; - - /* Allow all the waiters to wake up */ - pthread_cond_broadcast(&p_msg_q->list_cond); - - pthread_mutex_unlock(&p_msg_q->list_mutex); - - LOC_LOGD("%s: Message Queue unblocked\n", __FUNCTION__); - - return eMSG_Q_SUCCESS; -} diff --git a/gps/utils/msg_q.h b/gps/utils/msg_q.h deleted file mode 100644 index 453b8ce..0000000 --- a/gps/utils/msg_q.h +++ /dev/null @@ -1,207 +0,0 @@ -/* Copyright (c) 2011, 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 __MSG_Q_H__ -#define __MSG_Q_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include - -/** Linked List Return Codes */ -typedef enum -{ - eMSG_Q_SUCCESS = 0, - /**< Request was successful. */ - eMSG_Q_FAILURE_GENERAL = -1, - /**< Failed because of a general failure. */ - eMSG_Q_INVALID_PARAMETER = -2, - /**< Failed because the request contained invalid parameters. */ - eMSG_Q_INVALID_HANDLE = -3, - /**< Failed because an invalid handle was specified. */ - eMSG_Q_UNAVAILABLE_RESOURCE = -4, - /**< Failed because an there were not enough resources. */ - eMSG_Q_INSUFFICIENT_BUFFER = -5, - /**< Failed because an the supplied buffer was too small. */ -}msq_q_err_type; - -/*=========================================================================== -FUNCTION msg_q_init - -DESCRIPTION - Initializes internal structures for message queue. - - msg_q_data: pointer to an opaque Q handle to be returned; NULL if fails - -DEPENDENCIES - N/A - -RETURN VALUE - Look at error codes above. - -SIDE EFFECTS - N/A - -===========================================================================*/ -msq_q_err_type msg_q_init(void** msg_q_data); - -/*=========================================================================== -FUNCTION msg_q_init2 - -DESCRIPTION - Initializes internal structures for message queue. - -DEPENDENCIES - N/A - -RETURN VALUE - opaque handle to the Q created; NULL if create fails - -SIDE EFFECTS - N/A - -===========================================================================*/ -const void* msg_q_init2(); - -/*=========================================================================== -FUNCTION msg_q_destroy - -DESCRIPTION - Releases internal structures for message queue. - - msg_q_data: State of message queue to be released. - -DEPENDENCIES - N/A - -RETURN VALUE - Look at error codes above. - -SIDE EFFECTS - N/A - -===========================================================================*/ -msq_q_err_type msg_q_destroy(void** msg_q_data); - -/*=========================================================================== -FUNCTION msg_q_snd - -DESCRIPTION - Sends data to the message queue. The passed in data pointer - is not modified or freed. Passed in msg_obj is expected to live throughout - the use of the msg_q (i.e. data is not allocated internally) - - msg_q_data: Message Queue to add the element to. - msgp: Pointer to data to add into message queue. - dealloc: Function used to deallocate memory for this element. Pass NULL - if you do not want data deallocated during a flush operation - -DEPENDENCIES - N/A - -RETURN VALUE - Look at error codes above. - -SIDE EFFECTS - N/A - -===========================================================================*/ -msq_q_err_type msg_q_snd(void* msg_q_data, void* msg_obj, void (*dealloc)(void*)); - -/*=========================================================================== -FUNCTION msg_q_rcv - -DESCRIPTION - Retrieves data from the message queue. msg_obj is the oldest message received - and pointer is simply removed from message queue. - - msg_q_data: Message Queue to copy data from into msgp. - msg_obj: Pointer to space to copy msg_q contents to. - -DEPENDENCIES - N/A - -RETURN VALUE - Look at error codes above. - -SIDE EFFECTS - N/A - -===========================================================================*/ -msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj); - -/*=========================================================================== -FUNCTION msg_q_flush - -DESCRIPTION - Function removes all elements from the message queue. - - msg_q_data: Message Queue to remove elements from. - -DEPENDENCIES - N/A - -RETURN VALUE - Look at error codes above. - -SIDE EFFECTS - N/A - -===========================================================================*/ -msq_q_err_type msg_q_flush(void* msg_q_data); - -/*=========================================================================== -FUNCTION msg_q_unblock - -DESCRIPTION - This function will stop use of the message queue. All waiters will wake up - and likely receive nothing from the queue resulting in a negative return - value. The message queue can no longer be used until it is destroyed - and initialized again after calling this function. - - msg_q_data: Message queue to unblock. - -DEPENDENCIES - N/A - -RETURN VALUE - Look at error codes above. - -SIDE EFFECTS - N/A - -===========================================================================*/ -msq_q_err_type msg_q_unblock(void* msg_q_data); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __MSG_Q_H__ */ diff --git a/gps/utils/platform_lib_abstractions/elapsed_millis_since_boot.cpp b/gps/utils/platform_lib_abstractions/elapsed_millis_since_boot.cpp deleted file mode 100644 index e8cb93a..0000000 --- a/gps/utils/platform_lib_abstractions/elapsed_millis_since_boot.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) 2013, 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 -#include -#include "platform_lib_time.h" - -int64_t systemTime(int clock) -{ - struct timeval t; - t.tv_sec = t.tv_usec = 0; - gettimeofday(&t, NULL); - return t.tv_sec*1000000LL + t.tv_usec; -} - - -int64_t elapsedMillisSinceBoot() -{ - int64_t t_us = systemTime(0); - return (int64_t) t_us / 1000LL; -} diff --git a/gps/utils/platform_lib_abstractions/platform_lib_includes.h b/gps/utils/platform_lib_abstractions/platform_lib_includes.h deleted file mode 100644 index 5858674..0000000 --- a/gps/utils/platform_lib_abstractions/platform_lib_includes.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2013, 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 _PLATFORM_LIB_INCLUDES_H_ -#define _PLATFORM_LIB_INCLUDES_H_ - -#include "platform_lib_time.h" -#include "platform_lib_macros.h" - -#endif diff --git a/gps/utils/platform_lib_abstractions/platform_lib_macros.h b/gps/utils/platform_lib_abstractions/platform_lib_macros.h deleted file mode 100644 index bc48dd9..0000000 --- a/gps/utils/platform_lib_abstractions/platform_lib_macros.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright (c) 2013, 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 __PLATFORM_LIB_MACROS_H__ -#define __PLATFORM_LIB_MACROS_H__ - -#include - -#define TS_PRINTF(format, x...) \ -{ \ - struct timeval tv; \ - struct timezone tz; \ - int hh, mm, ss; \ - gettimeofday(&tv, &tz); \ - hh = tv.tv_sec/3600%24; \ - mm = (tv.tv_sec%3600)/60; \ - ss = tv.tv_sec%60; \ - fprintf(stdout,"%02d:%02d:%02d.%06ld]" format "\n", hh, mm, ss, tv.tv_usec,##x); \ -} - - -#ifdef USE_GLIB - -#define strlcat g_strlcat -#define strlcpy g_strlcpy - -#define ALOGE(format, x...) TS_PRINTF("E/%s (%d): " format , LOG_TAG, getpid(), ##x) -#define ALOGW(format, x...) TS_PRINTF("W/%s (%d): " format , LOG_TAG, getpid(), ##x) -#define ALOGI(format, x...) TS_PRINTF("I/%s (%d): " format , LOG_TAG, getpid(), ##x) -#define ALOGD(format, x...) TS_PRINTF("D/%s (%d): " format , LOG_TAG, getpid(), ##x) -#define ALOGV(format, x...) TS_PRINTF("V/%s (%d): " format , LOG_TAG, getpid(), ##x) - -#define GETTID_PLATFORM_LIB_ABSTRACTION (syscall(SYS_gettid)) - -#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION createPthread -#define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (elapsedMillisSinceBoot()) - - -#else - -#ifdef __cplusplus -extern "C" { -#endif -pid_t gettid(void); - -#ifdef __cplusplus -} -#endif - -#define GETTID_PLATFORM_LIB_ABSTRACTION (gettid()) -#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION android::AndroidRuntime::createJavaThread -#define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (android::elapsedRealtime()) - -#endif - -#endif diff --git a/gps/utils/platform_lib_abstractions/platform_lib_time.h b/gps/utils/platform_lib_abstractions/platform_lib_time.h deleted file mode 100644 index ce013af..0000000 --- a/gps/utils/platform_lib_abstractions/platform_lib_time.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2013, 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 _PLATFORM_LIB_TIME_H_ -#define _PLATFORM_LIB_TIME_H_ - -int64_t systemTime(int clock); -int64_t elapsedMillisSinceBoot(); - -#endif diff --git a/keylayout/Vendor_04e8_Product_7021.kl b/keylayout/Vendor_04e8_Product_7021.kl deleted file mode 100755 index 4eddce0..0000000 --- a/keylayout/Vendor_04e8_Product_7021.kl +++ /dev/null @@ -1,393 +0,0 @@ -# Copyright (C) 2010 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Generic key layout file for full alphabetic US English PC style external keyboards. -# -# This file is intentionally very generic and is intended to support a broad rang of keyboards. -# Do not edit the generic key layout to support a specific keyboard; instead, create -# a new key layout file with the required keyboard configuration. -# - -key 1 BACK -key 2 1 -key 3 2 -key 4 3 -key 5 4 -key 6 5 -key 7 6 -key 8 7 -key 9 8 -key 10 9 -key 11 0 -key 12 MINUS -key 13 EQUALS -key 14 DEL -key 15 TAB -key 16 Q -key 17 W -key 18 E -key 19 R -key 20 T -key 21 Y -key 22 U -key 23 I -key 24 O -key 25 P -key 26 LEFT_BRACKET -key 27 RIGHT_BRACKET -key 28 ENTER -key 29 CTRL_LEFT -key 30 A -key 31 S -key 32 D -key 33 F -key 34 G -key 35 H -key 36 J -key 37 K -key 38 L -key 39 SEMICOLON -key 40 APOSTROPHE -key 41 GRAVE -key 42 SHIFT_LEFT -key 43 BACKSLASH -key 44 Z -key 45 X -key 46 C -key 47 V -key 48 B -key 49 N -key 50 M -key 51 COMMA -key 52 PERIOD -key 53 SLASH -key 54 SHIFT_RIGHT -key 55 NUMPAD_MULTIPLY -key 56 ALT_LEFT -key 57 SPACE -key 58 CAPS_LOCK -key 59 F1 -key 60 F2 -key 61 F3 -key 62 F4 -key 63 F5 -key 64 F6 -key 65 F7 -key 66 F8 -key 67 F9 -key 68 F10 -key 69 NUM_LOCK -key 70 SCROLL_LOCK -key 71 NUMPAD_7 -key 72 NUMPAD_8 -key 73 NUMPAD_9 -key 74 NUMPAD_SUBTRACT -key 75 NUMPAD_4 -key 76 NUMPAD_5 -key 77 NUMPAD_6 -key 78 NUMPAD_ADD -key 79 NUMPAD_1 -key 80 NUMPAD_2 -key 81 NUMPAD_3 -key 82 NUMPAD_0 -key 83 NUMPAD_DOT -# key 84 (undefined) -# key 85 "KEY_ZENKAKUHANKAKU" -key 86 BACKSLASH -key 87 F11 -key 88 F12 -# key 89 "KEY_RO" -# key 90 "KEY_KATAKANA" -# key 91 "KEY_HIRAGANA" -# key 92 "KEY_HENKAN" -# key 93 "KEY_KATAKANAHIRAGANA" -# key 94 "KEY_MUHENKAN" -key 95 NUMPAD_COMMA -key 96 NUMPAD_ENTER -key 97 CTRL_RIGHT -key 98 NUMPAD_DIVIDE -key 99 SYSRQ -key 100 ALT_GR -# key 101 "KEY_LINEFEED" -key 102 MOVE_HOME -key 103 DPAD_UP -key 104 PAGE_UP -key 105 DPAD_LEFT -key 106 DPAD_RIGHT -key 107 MOVE_END -key 108 DPAD_DOWN -key 109 PAGE_DOWN -key 110 INSERT -key 111 FORWARD_DEL -# key 112 "KEY_MACRO" -key 113 MUTE -key 114 VOLUME_DOWN -key 115 VOLUME_UP -key 116 POWER WAKE -key 117 NUMPAD_EQUALS -# key 118 "KEY_KPPLUSMINUS" -key 119 BREAK -# key 120 (undefined) -key 121 NUMPAD_COMMA -# key 122 "KEY_HANGEUL" -# key 123 "KEY_HANJA" -# key 124 "KEY_YEN" -key 125 META_LEFT -key 126 META_RIGHT -key 127 MENU WAKE_DROPPED -key 128 MEDIA_STOP -# key 129 "KEY_AGAIN" -# key 130 "KEY_PROPS" -# key 131 "KEY_UNDO" -# key 132 "KEY_FRONT" -# key 133 "KEY_COPY" -# key 134 "KEY_OPEN" -# key 135 "KEY_PASTE" -# key 136 "KEY_FIND" -# key 137 "KEY_CUT" -# key 138 "KEY_HELP" -key 139 MENU WAKE_DROPPED -# key 140 "KEY_CALC" -# key 141 "KEY_SETUP" -# key 142 "KEY_SLEEP" -# key 143 "KEY_WAKEUP" -# key 144 "KEY_FILE" -# key 145 "KEY_SENDFILE" -# key 146 "KEY_DELETEFILE" -# key 147 "KEY_XFER" -# key 148 "KEY_PROG1" -# key 149 "KEY_PROG2" -key 150 EXPLORER -# key 151 "KEY_MSDOS" -# key 152 "KEY_COFFEE" -key 152 POWER WAKE -# key 153 "KEY_DIRECTION" -# key 154 "KEY_CYCLEWINDOWS" -key 155 EMAIL -key 156 BOOKMARK -# key 157 "KEY_COMPUTER" -key 158 BACK WAKE_DROPPED -key 159 FORWARD -key 160 MEDIA_CLOSE -key 161 MEDIA_EJECT -key 162 MEDIA_EJECT -key 163 MEDIA_NEXT -key 164 MEDIA_PLAY_PAUSE -key 165 MEDIA_PREVIOUS -key 166 MEDIA_STOP -key 167 MEDIA_RECORD -key 168 MEDIA_REWIND -key 169 CALL -# key 170 "KEY_ISO" -# key 171 "KEY_CONFIG" -key 172 HOME -# key 173 "KEY_REFRESH" -# key 174 "KEY_EXIT" -# key 175 "KEY_MOVE" -# key 176 "KEY_EDIT" -key 177 PAGE_UP -key 178 PAGE_DOWN -key 179 NUMPAD_LEFT_PAREN -key 180 NUMPAD_RIGHT_PAREN -# key 181 "KEY_NEW" -# key 182 "KEY_REDO" -# key 183 F13 -# key 184 F14 -# key 185 F15 -# key 186 F16 -# key 187 F17 -# key 188 F18 -# key 189 F19 -# key 190 F20 -# key 191 F21 -# key 192 F22 -# key 193 F23 -# key 194 F24 -# key 195 (undefined) -# key 196 (undefined) -# key 197 (undefined) -# key 198 (undefined) -# key 199 (undefined) -key 200 MEDIA_PLAY -key 201 MEDIA_PAUSE -# key 202 "KEY_PROG3" -# key 203 "KEY_PROG4" -# key 204 (undefined) -# key 205 "KEY_SUSPEND" -# key 206 "KEY_CLOSE" -key 207 MEDIA_PLAY -key 208 MEDIA_FAST_FORWARD -# key 209 "KEY_BASSBOOST" -# key 210 "KEY_PRINT" -# key 211 "KEY_HP" -key 212 CAMERA -# key 213 "KEY_SOUND" -# key 214 "KEY_QUESTION" -key 215 ENVELOPE -# key 216 "KEY_CHAT" -key 217 SEARCH -# key 218 "KEY_CONNECT" -# key 219 "KEY_FINANCE" -# key 220 "KEY_SPORT" -# key 221 "KEY_SHOP" -# key 222 "KEY_ALTERASE" -# key 223 "KEY_CANCEL" -key 224 BRIGHTNESS_DOWN -key 225 BRIGHTNESS_UP -key 226 HEADSETHOOK -key 227 STAR -key 228 POUND -key 229 SOFT_LEFT -key 230 SOFT_RIGHT -key 231 CALL -key 232 DPAD_CENTER -key 233 HEADSETHOOK -# key 234 "KEY_0_5" or "KEY_SAVE" -# key 235 "KEY_2_5" or "KEY_DOCUMENTS" -# key 236 "KEY_SWITCHVIDEOMODE" or "KEY_BATTERY" -# key 237 "KEY_KBDILLUMTOGGLE" -# key 238 "KEY_KBDILLUMDOWN" -# key 239 "KEY_KBDILLUMUP" -# key 240 "KEY_UNKNOWN" - - -key 304 BUTTON_A -key 305 BUTTON_B -key 306 BUTTON_C -key 307 BUTTON_X -key 308 BUTTON_Y -key 309 BUTTON_Z -key 310 BUTTON_L1 -key 311 BUTTON_R1 -key 312 BUTTON_L2 -key 313 BUTTON_R2 -key 314 BUTTON_SELECT -key 315 BUTTON_START -key 316 BUTTON_MODE -key 317 BUTTON_THUMBL -key 318 BUTTON_THUMBR - - -# key 352 "KEY_OK" -# key 353 "KEY_SELECT" -# key 354 "KEY_GOTO" -# key 355 "KEY_CLEAR" -# key 356 "KEY_POWER2" -# key 357 "KEY_OPTION" -# key 358 "KEY_INFO" -# key 359 "KEY_TIME" -# key 360 "KEY_VENDOR" -# key 361 "KEY_ARCHIVE" -key 362 GUIDE -# key 363 "KEY_CHANNEL" -# key 364 "KEY_FAVORITES" -# key 365 "KEY_EPG" -key 366 DVR -# key 367 "KEY_MHP" -# key 368 "KEY_LANGUAGE" -key 368 LANG -# key 369 "KEY_TITLE" -# key 370 "KEY_SUBTITLE" -# key 371 "KEY_ANGLE" -# key 372 "KEY_ZOOM" -# key 373 "KEY_MODE" -# key 374 "KEY_KEYBOARD" -# key 375 "KEY_SCREEN" -# key 376 "KEY_PC" -key 377 TV -# key 378 "KEY_TV2" -# key 379 "KEY_VCR" -# key 380 "KEY_VCR2" -# key 381 "KEY_SAT" -# key 382 "KEY_SAT2" -# key 383 "KEY_CD" -# key 384 "KEY_TAPE" -# key 385 "KEY_RADIO" -# key 386 "KEY_TUNER" -# key 387 "KEY_PLAYER" -# key 388 "KEY_TEXT" -# key 389 "KEY_DVD" -# key 390 "KEY_AUX" -# key 391 "KEY_MP3" -# key 392 "KEY_AUDIO" -# key 393 "KEY_VIDEO" -# key 394 "KEY_DIRECTORY" -# key 395 "KEY_LIST" -# key 396 "KEY_MEMO" -# key 397 "KEY_CALENDAR" -# key 398 "KEY_RED" -# key 399 "KEY_GREEN" -# key 400 "KEY_YELLOW" -# key 401 "KEY_BLUE" -key 402 CHANNEL_UP -key 403 CHANNEL_DOWN -# key 404 "KEY_FIRST" -# key 405 "KEY_LAST" -# key 406 "KEY_AB" -# key 407 "KEY_NEXT" -# key 408 "KEY_RESTART" -# key 409 "KEY_SLOW" -# key 410 "KEY_SHUFFLE" -# key 411 "KEY_BREAK" -# key 412 "KEY_PREVIOUS" -# key 413 "KEY_DIGITS" -# key 414 "KEY_TEEN" -# key 415 "KEY_TWEN" - - -# key 448 "KEY_DEL_EOL" -# key 449 "KEY_DEL_EOS" -# key 450 "KEY_INS_LINE" -# key 451 "KEY_DEL_LINE" - - -key 464 FUNCTION -key 465 ESCAPE FUNCTION -key 466 F1 FUNCTION -key 467 F2 FUNCTION -key 468 F3 FUNCTION -key 469 F4 FUNCTION -key 470 F5 FUNCTION -key 471 F6 FUNCTION -key 472 F7 FUNCTION -key 473 F8 FUNCTION -key 474 F9 FUNCTION -key 475 F10 FUNCTION -key 476 F11 FUNCTION -key 477 F12 FUNCTION -key 478 1 FUNCTION -key 479 2 FUNCTION -key 480 D FUNCTION -key 481 E FUNCTION -key 482 F FUNCTION -key 483 S FUNCTION -key 484 B FUNCTION - - -# key 497 KEY_BRL_DOT1 -# key 498 KEY_BRL_DOT2 -# key 499 KEY_BRL_DOT3 -# key 500 KEY_BRL_DOT4 -# key 501 KEY_BRL_DOT5 -# key 502 KEY_BRL_DOT6 -# key 503 KEY_BRL_DOT7 -# key 504 KEY_BRL_DOT8 - - -key 704 RECENTAPPS -key 705 APPLICATION -key 706 SIP_ON_OFF -key 707 VOICESEARCH -key 708 QPANEL_ON_OFF \ No newline at end of file diff --git a/libsecnativefeature/Android.mk b/libsecnativefeature/Android.mk deleted file mode 100644 index 7b78946..0000000 --- a/libsecnativefeature/Android.mk +++ /dev/null @@ -1,21 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := \ - SecNativeFeatureCIf.cpp \ - SecNativeFeatureCppIf.cpp - -LOCAL_C_INCLUDES += \ - external/expat/lib - -LOCAL_SHARED_LIBRARIES := \ - libexpat - -LOCAL_CFLAGS := -Wall -Werror - -LOCAL_MODULE := libsecnativefeature -LOCAL_PROPRIETARY_MODULE := true - -include $(BUILD_SHARED_LIBRARY) diff --git a/libsecnativefeature/SecNativeFeature.h b/libsecnativefeature/SecNativeFeature.h deleted file mode 100644 index 4de0283..0000000 --- a/libsecnativefeature/SecNativeFeature.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef SEC_NATIVE_FEATURE_H -#define SEC_NATIVE_FEATURE_H - -#include "SecNativeFeatureTagAll.h" - -// define TAG for default value -/* -#define Str_NoTag "" -#define Bool_NoTag false -#define Int_NoTag (0) - -#define TAG_BOOLEAN_TEST_TRUE "CscFeature_BooleanTestTrue" -#define TAG_BOOLEAN_TEST_FALSE "CscFeature_BooleanTestFalse" -#define TAG_BOOLEAN_TEST_NULL "CscFeature_BooleanTestNull" -#define TAG_STRING_TEST "CscFeature_StringTest" -#define TAG_STRING_TEST_NULL "CscFeature_StringTestNull" -#define TAG_INTEGER_TEST "CscFeature_IntegerTest" -#define TAG_INTEGER_TEST_NULL "CscFeature_IntegerTestNull" - -#define TAG_FMRADIO_RTPLUS "CscFeature_FMRadioRTPlus" -#define TAG_FMRADIO_SEASETTING "CscFeature_FMRadioSEASetting" -*/ - -#ifdef __cplusplus -#include "SecNativeFeatureCppIf.h" -#else -#include "SecNativeFeatureCIf.h" -#endif - -#endif // SEC_NATIVE_FEATURE_H - diff --git a/libsecnativefeature/SecNativeFeatureCIf.cpp b/libsecnativefeature/SecNativeFeatureCIf.cpp deleted file mode 100644 index 88a5405..0000000 --- a/libsecnativefeature/SecNativeFeatureCIf.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include -#include -#include "SecNativeFeatureCppIf.h" -#include "SecNativeFeatureCIf.h" -#include -#include - - -int -SecNativeFeature_getEnableStatus(const char* tag) -{ - SecNativeFeature* instance = SecNativeFeature::getInstance(); - - if (instance) - { - return instance->getEnableStatus(tag); - } - - return 0; -} - -int -SecNativeFeature_getEnableStatusWithDefault(const char* tag, int defaultValue) -{ - SecNativeFeature* instance = SecNativeFeature::getInstance(); - - if (instance) - { - return instance->getEnableStatus(tag, defaultValue); - } - - return defaultValue; -} - -int -SecNativeFeature_getInteger(const char* tag) -{ - SecNativeFeature* instance = SecNativeFeature::getInstance(); - - if (instance) - { - return instance->getInteger(tag); - } - - return -1; -} - -int -SecNativeFeature_getIntegerWithDefault(const char* tag, int defaultValue) -{ - SecNativeFeature* instance = SecNativeFeature::getInstance(); - - if (instance) - { - return instance->getInteger(tag, defaultValue); - } - - return defaultValue; -} - -const char* -SecNativeFeature_getString(const char* tag) -{ - SecNativeFeature* instance = SecNativeFeature::getInstance(); - - if (instance) - { - return instance->getString(tag); - } - - return NULL; -} - -const char* -SecNativeFeature_getStringWithDefault(const char* tag, char* defaultValue) -{ - SecNativeFeature* instance = SecNativeFeature::getInstance(); - - if (instance) - { - return instance->getString(tag, defaultValue); - } - - return defaultValue; -} diff --git a/libsecnativefeature/SecNativeFeatureCIf.h b/libsecnativefeature/SecNativeFeatureCIf.h deleted file mode 100644 index 3d26168..0000000 --- a/libsecnativefeature/SecNativeFeatureCIf.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef SEC_NATIVE_FEATURE_CIF_H -#define SEC_NATIVE_FEATURE_CIF_H - -#ifdef __cplusplus -#define DECLARE_BEGIN_C extern "C" { -#define DECLARE_END_C } -#else -#define DECLARE_BEGIN_C -#define DECLARE_END_C -#endif - -DECLARE_BEGIN_C - -int SecNativeFeature_getEnableStatus(const char* tag); -int SecNativeFeature_getEnableStatusWithDefault(const char* tag, int defaultValue); -int SecNativeFeature_getInteger(const char* tag); -int SecNativeFeature_getIntegerWithDefault(const char* tag, int defaultValue); -const char* SecNativeFeature_getString(const char* tag); -const char* SecNativeFeature_getStringWithDefault(const char* tag, char* defaultValue); - -DECLARE_END_C - -#endif // SEC_NATIVE_FEATURE_CIF_H - diff --git a/libsecnativefeature/SecNativeFeatureCppIf.cpp b/libsecnativefeature/SecNativeFeatureCppIf.cpp deleted file mode 100644 index d70ebe7..0000000 --- a/libsecnativefeature/SecNativeFeatureCppIf.cpp +++ /dev/null @@ -1,187 +0,0 @@ -#include -#include -#include "SecNativeFeatureCppIf.h" -#include -#include - -// feature file location (which should be "/system/csc/feature.xml") -#define FEATURE_FILE "/system/csc/feature.xml" -// feature file location (which should be "/system/csc/others.xml") -#define MPS_FEATURE_FILE "/system/csc/others.xml" - -// XML parsing using expat lib - handlers -typedef struct{ - std::string curr_name; - std::map *pFeatures; - int depth; -} ParserUserData; - -static void XMLCALL -charDataHandler(void *userData, const char *s, int len){ - ParserUserData* pData = (ParserUserData*)userData; - std::string value(s, len); - std::string curr_name = pData->curr_name; - - if(!curr_name.empty()){ - std::map::iterator result = (*pData->pFeatures).find(curr_name); - - if (result != (*pData->pFeatures).end()) { - value = result->second + value; - (*pData->pFeatures).erase(curr_name); - } - - std::map::iterator begin; - begin = (*pData->pFeatures).begin(); - std::pair feature(curr_name,value); - (*pData->pFeatures).insert(begin, feature); - } - // else{ - // // printf("no name\n"); - // } -} - -static void XMLCALL -startElement(void *userData, const char *name, const char **atts __unused) -{ - ParserUserData* pData = (ParserUserData*)userData; - pData->curr_name.assign(name); - pData->depth += 1; -} - -static void XMLCALL -endElement(void *userData, const char *name __unused) -{ - ParserUserData* pData = (ParserUserData*)userData; - pData->curr_name.clear(); - pData->depth -= 1; -} - -// SecNativeFeture class implementation -SecNativeFeature* SecNativeFeature::_instance = NULL; -SecNativeFeature::SecNativeFeature() { - int load_result = 0; - _features.clear(); - load_result = _loadFeature(); - if (load_result == -1){ - // todo : handle _loadFeature errors here. - } -} - -SecNativeFeature::~SecNativeFeature() { - delete _instance; -} -SecNativeFeature* SecNativeFeature::getInstance() { - if(_instance == NULL) { - _instance = new SecNativeFeature(); - } - return _instance; -} - -bool SecNativeFeature::getEnableStatus(const char* tag) { - std::map::iterator found; - found = _features.find(tag); - - if(found == _features.end()) { - return false; - } - - if(found->second.compare("true") == 0 || found->second.compare("TRUE") == 0) { - return true; - } - return false; -} - -bool SecNativeFeature::getEnableStatus(const char* tag, bool defaultValue) { - std::map::iterator found; - found = _features.find(tag); - - if(found == _features.end()) { - return defaultValue; - } - - if(found->second.compare("true") == 0 || found->second.compare("TRUE") == 0) { - return true; - } - return defaultValue; -} - -const char* SecNativeFeature::getString(const char* tag) { - std::map::iterator found; - found = _features.find(tag); - - if(found == _features.end()) { - return ""; - } - return found->second.c_str(); -} - -const char* SecNativeFeature::getString(const char* tag, char* defaultValue) { - std::map::iterator found; - found = _features.find(tag); - - if(found == _features.end()) { - return defaultValue; - } - return found->second.c_str(); -} - -int SecNativeFeature::getInteger(const char* tag) { - std::map::iterator found; - found = _features.find(tag); - - if(found == _features.end()) { - return -1; - } - std::string raw_value = _features.find(tag)->second; - return atoi(raw_value.c_str()); -} - -int SecNativeFeature::getInteger(const char* tag, int defaultValue) { - std::map::iterator found; - found = _features.find(tag); - - if(found == _features.end()) { - return defaultValue; - } - std::string raw_value = _features.find(tag)->second; - return atoi(raw_value.c_str()); -} - -int SecNativeFeature::_loadFeature(){ - char buf[BUFSIZ]; - XML_Parser parser = XML_ParserCreate(NULL); - int done; - FILE * pFeatureFile = NULL; - ParserUserData userData; - userData.curr_name = std::string (); - userData.pFeatures = &_features; - userData.depth = 0; - - pFeatureFile = fopen(FEATURE_FILE, "r"); - if (pFeatureFile == NULL) { - pFeatureFile = fopen(MPS_FEATURE_FILE, "r"); - if (pFeatureFile == NULL) { - return -1; - } - } - XML_SetUserData(parser, &userData); - XML_SetElementHandler(parser, startElement, endElement); - XML_SetCharacterDataHandler(parser, charDataHandler); - do { - size_t len = fread(buf, 1, sizeof(buf), pFeatureFile); - if ((len != sizeof(buf)) && (ferror(pFeatureFile))){ - fclose(pFeatureFile); - return -1; - } - done = len < sizeof(buf); - if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) { - if(pFeatureFile) { - fclose(pFeatureFile); - } - return -1; - } - } while (!done); - XML_ParserFree(parser); - fclose(pFeatureFile); - return 0; -} diff --git a/libsecnativefeature/SecNativeFeatureCppIf.h b/libsecnativefeature/SecNativeFeatureCppIf.h deleted file mode 100644 index 37cb085..0000000 --- a/libsecnativefeature/SecNativeFeatureCppIf.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef SEC_NATIVE_FEATURE_CPPIF_H -#define SEC_NATIVE_FEATURE_CPPIF_H - -#include -#include - -class SecNativeFeature { -public: - bool getEnableStatus(const char* tag); - bool getEnableStatus(const char* tag, bool defaultValue); - const char* getString(const char* tag); - const char* getString(const char* tag, char* defaultValue); - int getInteger(const char* tag); - int getInteger(const char* tag, int defaultValue); - - static SecNativeFeature* getInstance(); -private: - static SecNativeFeature* _instance; - SecNativeFeature(); - ~SecNativeFeature(); - int _loadFeature(); - int _loadDefault(); - std::map _features; -}; - -#endif // SEC_NATIVE_FEATURE_CPPIF_H - diff --git a/libsecnativefeature/SecNativeFeatureTagAll.h b/libsecnativefeature/SecNativeFeatureTagAll.h deleted file mode 100644 index 1bbc23f..0000000 --- a/libsecnativefeature/SecNativeFeatureTagAll.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * CSC Features - * Auto generated by gen_cscfeaturetag_ih.pl - * DO NOT EDIT THIS FILE - */ - -/* -#include "SecNativeFeatureTagGMS.h" -#include "SecNativeFeatureTagIMS.h" -#include "SecNativeFeatureTagMediaProvider.h" -#include "SecNativeFeatureTagNFC.h" -#include "SecNativeFeatureTagRIL.h" -#include "SecNativeFeatureTagStreaming.h" -#include "SecNativeFeatureTagWiFi.h" -#include "SecNativeFeatureTagBT.h" -*/ - -#include "SecNativeFeatureTagFramework.h" -#include "SecNativeFeatureTagCommon.h" -#include "SecNativeFeatureTagWeb.h" diff --git a/libsecnativefeature/SecNativeFeatureTagCommon.h b/libsecnativefeature/SecNativeFeatureTagCommon.h deleted file mode 100644 index 7439806..0000000 --- a/libsecnativefeature/SecNativeFeatureTagCommon.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef SEC_NATIVE_FEATURE_TAG_COMMON_H -#define SEC_NATIVE_FEATURE_TAG_COMMON_H - -// Note -// The string must be same as the string in CSCFeatureTagCommon.java -// Because one feature coulde be implemented both in java layer and in native layer -#define TAG_CSCFEATURE_COMMON_USECHAMELEON "CscFeature_Common_UseChameleon" - -#endif // SEC_NATIVE_FEATURE_TAG_COMMON_H diff --git a/libsecnativefeature/SecNativeFeatureTagFramework.h b/libsecnativefeature/SecNativeFeatureTagFramework.h deleted file mode 100644 index a29d67c..0000000 --- a/libsecnativefeature/SecNativeFeatureTagFramework.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef SEC_NATIVE_FEATURE_TAG_FRAMEWORK_H -#define SEC_NATIVE_FEATURE_TAG_FRAMEWORK_H - - -// Note -// The string must be same as the string in CSCFeatureTagFramework.java -// Because one feature coulde be implemented both in java layer and in native layer - - -#define TAG_CSCFEATURE_FRAMEWORK_ENABLEBIDIRECTION "CscFeature_Framework_EnableBidirection" - -#define TAG_CSCFEATURE_FRAMEWORK_ENABLEHARFBUZZ "CscFeature_Framework_EnableHarfbuzz" - -#define TAG_CSCFEATURE_FRAMEWORK_ENABLETHAIVIETRESHAPING "CscFeature_Framework_EnableThaiVietReshaping" - -#endif // SEC_NATIVE_FEATURE_TAG_FRAMEWORK_H diff --git a/libsecnativefeature/SecNativeFeatureTagWeb.h b/libsecnativefeature/SecNativeFeatureTagWeb.h deleted file mode 100644 index 100448a..0000000 --- a/libsecnativefeature/SecNativeFeatureTagWeb.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef SEC_NATIVE_FEATURE_TAG_WEB_H -#define SEC_NATIVE_FEATURE_TAG_WEB_H - - -// Note -// The string must be same as the string in CSCFeatureTagWeb.java -// Because one feature coulde be implemented both in java layer and in native layer - -// The default values for each types -// This means the specified TAG is not defined -#define CSCFeatureTagWeb_Str_NoTag "" -#define CSCFeatureTagWeb_Bool_NoTag false -#define CSCFeatureTagWeb_Int_NoTag 0 - -// To define custom UserAgent string -// If this value is not defined, the default Android UserAgent will be sent to server -#define CSCFeatureTagWeb_SetUserAgent "CscFeature_Web_SetUserAgent" - - -// To define UAProfile string -// If this value is not defined, UAProfile will not be sent to server -#define CSCFeatureTagWeb_SetUAProfile "CscFeature_Web_SetUAProfile" - -// Change homepage_base regardless language and APN -#define CscFeatureTagWeb_SetHomepageURL "CscFeature_Web_SetHomepageURL" -// Disable RSS button on the url bar -#define CscFeatureTagWeb_DisableRSS "CscFeature_Web_DisableRSS" -// Remove voicesearch button on the url bar -#define CscFeatureTagWeb_DisableVoiceSearch "CscFeature_Web_DisableVoiceSearch" -// Disable showing activity chooser on redirecting in case when 3rd party browser also installed -#define CscFeatureTagWeb_DisableRedirectionChooser "CscFeature_Web_DisableRedirectionChooser" - -// Enable UAProfile in Header -#define CscFeatureTagWeb_Bool_EnableUAProfile "CscFeature_Web_Bool_EnableUAProfile" - -// To Enable the GateConfig Logs(USA STA requirement for stability test) -#define CscFeatureTagWeb_Bool_EnableGateConfig "CscFeature_Web_EnableLogStabililtyTest" - -//add for Handling Operator UA -#define CscFeature_Web_OverrideUserAgent "CscFeature_Web_OverrideUserAgent" - -// add menu clear today history -#define CscFeatureTagWeb_EnableDeletingTodayHistory "CscFeature_Web_EnableDeletingTodayHistory" - - // To enable bookmark overwrite -#define CscFeatureTagWeb_EnableOverwritingBookmark "CscFeature_Web_EnableOverwritingBookmark" - -// To enable downloaded folder notification -#define CscFeatureTagWeb_EnableDownloadedFolderInNotificationBar "CscFeature_Web_EnableDownloadedFolderInNotificationBar" - - //Enable DeviceID at Header(USA ATT Requirement) -#define CscFeatureTag_Web_Bool_DeviceID "CscFeature_Web_UseDeviceIdInHeader" - -// support uploading contacts in VCard format (China-Telecom requirement) -#define CscFeatureTagWeb_SupportVcfUpload "CscFeature_Web_SupportVcfUpload" -//Parse XHTML document as HTML (ignore parse error. China-Telecom requirement) -#define CscFeatureTagWeb_ParseXHtmlToHtml "CscFeature_Web_ParseXHtmlToHtml" - - //Block SD & CD download ( NAGSM common requirement) -#define CscFeatureTag_Web_Bool_BlockSDCDDownload "CscFeature_Web_BlockSDCDDownload" - -// display download progress on notification bar (China-Telecom requirement) -#define CscFeatureTagWeb_ShowDownloadProgressOnNotification "CscFeature_Web_ShowDownloadProgressOnNotification" - -// show browser version in browser settings (China-Telecom requirement) -#define CscFeatureTagWeb_ShowVersionInSetting "CscFeature_Web_ShowVersionInSetting" - -// support "exit browser" option (China-Telecom requirement) -#define CscFeatureTagWeb_AddOptionToTerminate "CscFeature_Web_AddOptionToTerminate" -// Add "Delete-all" function at Download list (China-Telecom requirement) -#define CscFeatureTagWeb_EnableDeleteAllOnDownloadList "CscFeature_Web_EnableDeleteAllOnDownloadList" -// Support save-as function and default folder by mime-type (China-Telecom requirement) -#define CscFeatureTagWeb_SupportDownloadSaveAs "CscFeature_Web_SupportDownloadSaveAs" -// support delete-all option in bookmarks page (China-Telecom requirement) -#define CscFeatureTagWeb_EnableDeleteAllBookmarks "CscFeature_Web_EnableDeleteAllBookmarks" -// Add "FullHandwriting IME issue "(China-Common requirement) -#define CscFeatureTagWeb_EnableOptionEditTextDuringFullHwr "CscFeature_Web_EnableOptionEditTextDuringFullHwr" -// support offline-startup page includes bookmarks, history, search dialog (China-Telecom requirement) -#define CscFeatureTagWeb_SupportOfflineStartupPage "CscFeature_Web_SupportOfflineStartupPage" - -// support not to set factory-reset-homepage to PREF_HOMEPAGE -#define CscFeatureTagWeb_Bool_DisableSetFactoryResetHomeToPrefHome "CscFeature_Web_Bool_DisableSetFactoryResetHomeToPrefHome" - -// Show roaming dialog (ATT Requirement) -#define CscFeatureTagWeb_Bool_ShowRoamingDialog "CscFeature_Web_EnableRoamingDialog" - -// set download folder by mime-type for China-Telecom requirement -#define CscFeatureTagWeb_SetDownloadFolderNameByMimeType "CscFeature_Web_SetDownloadFolderNameByMimeType" - -// Disable showing activity chooser for defined string -#define CscFeature_Web_DisableChooser4 "CscFeature_Web_DisableChooser4" - -// Enable download hebrew filename -#define CscFeature_Web_SupportHebrewFileName "CscFeature_Web_SupportHebrewFileName" - -// remove google in search engine list -#define CscFeatureTagWeb_DisableGoogleInBrowserSearchEngine "CscFeature_Web_DisableGoogleInBrowserSearchEngine" - -// set off overview mode as default (CTC Requirement) -#define CscFeatureTagWeb_SetOffOverviewModeAsDefault "CscFeature_Web_SetOffOverviewModeAsDefault" - -// Disable setting homepage as it is set in APN when SIM changed -#define CscFeature_Web_EnableAutoSimHomeUrlInProfile "CscFeature_Web_EnableAutoSimHomeUrlInProfile" - -// Add download file name decode feature for China region -#define CscFeatureTagWeb_SupportDownloadedFileNameInChineseChar "CscFeature_Web_SupportDownloadedFileNameInChineseChar" - -// support multiAPN (CMCC Requirement) -#define CscFeatureTagWeb_EnableMultipleApn4 "CscFeature_Web_EnableMultipleApn4" - -// Enable Ask to exit on back (CMCC Requirement) -#define CscFeatureTagWeb_EnablePromptToExit "CscFeature_Web_EnablePromptToExit" - - -// Enable EMOJI for JPN -#define CscFeatureTagWeb_EnableEmoji "CscFeature_Web_Bool_EnableEmoji" - -// Show Wifi AP List when WIFI switch is on (CMCC Requirement) -#define CscFeatureTagWeb_ShowWifiAPList "CscFeature_Web_ShowWifiAPList" - - // Enable Operator's toolbar (ATT Requirement) -#define CscFeatureTagWeb_EnableOperatorToolbar "CscFeature_Web_EnableOperatorToolbar" - -// Set TCP Connection timout (China Requirement) -#define CscFeatureTagWeb_SetTcpConnTimeoutAs "CscFeature_Web_SetTcpConnTimeoutAs" - -// Add WML mime type to Accept Header (CMCC Requirement) -#define CscFeatureTagWeb_AddWmlToHttpAcceptHeader4 "CscFeature_Web_AddWmlToHttpAcceptHeader4" - -// change block zoom method to position based touch block zoom (Australia Requirement) -#define CscFeature_Web_BlockZoomBaseOnTouchPosition "CscFeature_Web_BlockZoomBaseOnTouchPosition" - -// Remove Partial View During Horizontal Scroll in Nav Screen (Australia Requirement) -#define CscFeature_Web_RemovePartialViewDuringHorizontalScroll "CscFeature_Web_RemovePartialViewDuringHorizontalScroll" - -// Show Popup for MaxLength reached during Url input (CMCC Requirement) -#define CscFeatureTagWeb_EnablePopup4MaxLengthReachedDuringUrlInput "CscFeature_Web_EnablePopup4MaxLengthReachedDuringUrlInput" - -// Support Tel Number in the page to go to dialing app (KOR Requirement) -#define CscFeature_Web_RecognizeTelNumber "CscFeature_Web_RecognizeTelNumber" - -// Large file transfer in Internet download (VZW Requirement) -#define CscFeature_Web_EnableWifiOption4LargeFileDownload "CscFeature_Web_EnableWifiOption4LargeFileDownload" - -// Add additional accept charset to Accept Header (CTC Requirement) -#define CscFeature_Web_AddCharSetToHttpHeader "CscFeature_Web_AddCharSetToHttpHeader" - -// max connection per host for performance -#define CscFeature_Web_MaxConnectionPerHost "CscFeature_Web_MaxConnectionPerHost" -#endif // SEC_NATIVE_FEATURE_TAG_WEB_H diff --git a/libshims/libshim_binder/Android.mk b/libshims/libshim_binder/Android.mk deleted file mode 100644 index ac5575a..0000000 --- a/libshims/libshim_binder/Android.mk +++ /dev/null @@ -1,11 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := libbinder_interface.cpp -LOCAL_MODULE := libshim_binder -LOCAL_MODULE_CLASS := SHARED_LIBRARIES -LOCAL_PROPRIETARY_MODULE := true -LOCAL_SHARED_LIBRARIES := libbinder libutils - -include $(BUILD_SHARED_LIBRARY) diff --git a/libshims/libshim_binder/libbinder_interface.cpp b/libshims/libshim_binder/libbinder_interface.cpp deleted file mode 100644 index 53848b3..0000000 --- a/libshims/libshim_binder/libbinder_interface.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -extern "C" { - -void _ZN7android10IInterface8asBinderEv(void *retval, void* self) { - android::sp *ret = new(retval) android::sp; - *ret = android::IInterface::asBinder((android::IInterface*)self); -} - -void _ZNK7android10IInterface8asBinderEv(void *retval, void *self) { - android::sp *ret = new(retval) android::sp; - *ret = android::IInterface::asBinder((android::IInterface*)self); -} - -} // extern "C" diff --git a/lineage.dependencies b/lineage.dependencies index 18cb444..b0b7bb3 100755 --- a/lineage.dependencies +++ b/lineage.dependencies @@ -1,10 +1,10 @@ [ { - "repository": "android_hardware_samsung", - "target_path": "hardware/samsung" + "repository": "android_device_samsung_msm8974-common", + "target_path": "device/samsung/msm8974-common" }, { - "repository": "android_packages_resources_devicesettings", - "target_path": "packages/resources/devicesettings" + "repository": "android_kernel_samsung_msm8974", + "target_path": "kernel/samsung/msm8974_tab" } ] diff --git a/overlay-lineage/frameworks/base/core/res/res/values/config.xml b/overlay-lineage/frameworks/base/core/res/res/values/config.xml index 185002c..f1e15b5 100755 --- a/overlay-lineage/frameworks/base/core/res/res/values/config.xml +++ b/overlay-lineage/frameworks/base/core/res/res/values/config.xml @@ -19,9 +19,6 @@ --> - - true - diff --git a/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml b/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml index c01bc1e..38607c1 100755 --- a/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml +++ b/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml @@ -16,10 +16,6 @@ --> - - true - - - "rndis0" - "usb0" - - - - - "wlan0" - - - - - "bt-pan" - - false @@ -193,7 +171,7 @@ 10 - + 0 1 @@ -218,36 +196,20 @@ false - - - - - - - + true + true @@ -272,11 +234,6 @@ ehrpd:4094,87380,1048576,4096,16384,262144 - - - 2 - - - XTRA_SERVER_1=https://xtrapath1.izatcloud.net/xtra3grc.bin @@ -304,19 +258,6 @@ A_GLONASS_POS_PROTOCOL_SELECT=0 - - true - - - true - - - true - - - false - - - - Network Extender - diff --git a/overlay/frameworks/opt/net/wifi/service/res/values/config.xml b/overlay/frameworks/opt/net/wifi/service/res/values/config.xml index 23a86e6..e3cd7ce 100644 --- a/overlay/frameworks/opt/net/wifi/service/res/values/config.xml +++ b/overlay/frameworks/opt/net/wifi/service/res/values/config.xml @@ -12,22 +12,7 @@ --> - - true - - - true - 524288,1048576,2097152,262144,524288,1048576 - - - false diff --git a/overlay/hardware/samsung/AdvancedDisplay/res/values/arrays.xml b/overlay/hardware/samsung/AdvancedDisplay/res/values/arrays.xml deleted file mode 100644 index 4f1ad05..0000000 --- a/overlay/hardware/samsung/AdvancedDisplay/res/values/arrays.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - @string/mdnie_scenario_ui - @string/mdnie_scenario_video - @string/mdnie_scenario_video_warm - @string/mdnie_scenario_video_cold - @string/mdnie_scenario_camera - @string/mdnie_scenario_navigation - @string/mdnie_scenario_gallery - @string/mdnie_scenario_vt - @string/mdnie_scenario_browser - @string/mdnie_scenario_ebook - @string/mdnie_scenario_email - - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - @string/mdnie_accessibility_normal - @string/mdnie_accessibility_inverse - @string/mdnie_accessibility_color_blind - @string/mdnie_accessibility_screen_curtain - @string/mdnie_accessibility_grayscale - @string/mdnie_accessibility_gray_negative - - - - 0 - 1 - 2 - 3 - 4 - 5 - - diff --git a/overlay/hardware/samsung/AdvancedDisplay/res/values/config.xml b/overlay/hardware/samsung/AdvancedDisplay/res/values/config.xml deleted file mode 100644 index 7f7e582..0000000 --- a/overlay/hardware/samsung/AdvancedDisplay/res/values/config.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - "/sys/class/mdnie/mdnie/scenario" - "/sys/class/mdnie/mdnie/accessibility" - diff --git a/proprietary-files.txt b/proprietary-files.txt index ea8d4c8..b9506b7 100755 --- a/proprietary-files.txt +++ b/proprietary-files.txt @@ -47,13 +47,6 @@ etc/wifi/nvram_net.txt_4354_a1 vendor/firmware/bcm4335_V0031.0146.hcd vendor/firmware/bcm4350_V0301.0599.hcd -# GPS -lib/libloc_api_v02.so -vendor/lib/libgeofence.so -vendor/lib/libizat_core.so -vendor/lib/liblbs_core.so -vendor/lib/liblocationservice.so - # Audio vendor/lib/libacdbloader.so # Stock would be: vendor/lib/libacdbloader.so:lib/libacdbloader.so @@ -89,26 +82,6 @@ vendor/lib/libOmxQcelp13Dec.so vendor/lib/libOmxWmaDec.so vendor/lib/libSHIMDivxDrm.so -# Adreno GPU -vendor/lib/egl/eglsubAndroid.so -vendor/lib/egl/libEGL_adreno.so -vendor/lib/egl/libGLESv1_CM_adreno.so -vendor/lib/egl/libGLESv2_adreno.so -vendor/lib/egl/libq3dtools_adreno.so -vendor/lib/libadreno_utils.so -vendor/lib/libbccQTI.so -vendor/lib/libC2D2.so -vendor/lib/libc2d30-a3xx.so -vendor/lib/libc2d30.so -vendor/lib/libCB.so -vendor/lib/libgsl.so -vendor/lib/libllvm-qcom.so -vendor/lib/libOpenCL.so -vendor/lib/libsc-a3xx.so -vendor/lib/libscale.so -etc/firmware/a330_pfp.fw -etc/firmware/a330_pm4.fw - # Graphics vendor/lib/libmm-color-convertor.so @@ -150,7 +123,6 @@ lib/libsecril-client.so # Time services bin/time_daemon --vendor/lib/libtime_genoff.so # Camera bin/mm-qcamera-daemon @@ -216,7 +188,6 @@ lib/libmmcamera2_stats_algorithm.so lib/libmmcamera_cac2_lib.so lib/libmmcamera_fidelix_eeprom.so lib/libmmqjpeg_codec.so -lib/libmmjpeg.so lib/libmmjpeg_interface.so lib/libsecnativefeature.so lib/libvdis.so @@ -253,19 +224,12 @@ vendor/lib/libqc-opt.so # DRM bin/qseecomd -framework/com.google.widevine.software.drm.jar -lib/libdrmdecrypt.so -vendor/lib/drm/libdrmwvmplugin.so vendor/lib/libdrmdiag.so vendor/lib/libdrmfs.so vendor/lib/libdrmtime.so vendor/lib/libQSEEComAPI.so vendor/lib/librpmb.so vendor/lib/libssd.so -vendor/lib/libwvdrm_L3.so -vendor/lib/libwvm.so -vendor/lib/libWVStreamControlAPI_L3.so -vendor/lib/mediadrm/libwvdrmengine.so # IPC router security etc/sec_config @@ -293,3 +257,4 @@ lib/hw/sensors.msm8974.so lib/librilutils.so lib/libqservice.so lib/libtinyxml.so + diff --git a/rootdir/etc/init.qcom.rc b/rootdir/etc/init.qcom.rc index f721422..6dd2aaa 100755 --- a/rootdir/etc/init.qcom.rc +++ b/rootdir/etc/init.qcom.rc @@ -877,11 +877,6 @@ service thermal-engine /vendor/bin/thermal-engine socket thermal-recv-passive-client stream 0666 system system group root -service time_daemon /vendor/bin/time_daemon - class late_start - user root - group root - service audiod /system/bin/audiod class late_start user system @@ -994,8 +989,11 @@ on property:sys.boot_completed=1 restorecon /data/data/com.android.providers.telephony/databases restorecon /data/data/com.android.providers.telephony/shared_prefs -service charger /charger +service charger /system/bin/charger class charger + user system + group system graphics input + capabilities SYS_BOOT seclabel u:r:charger:s0 on property:persist.sys.ssr.restart_level=1 diff --git a/seccomp/mediacodec.policy b/seccomp/mediacodec.policy deleted file mode 100644 index f04ecba..0000000 --- a/seccomp/mediacodec.policy +++ /dev/null @@ -1,7 +0,0 @@ -# device specific syscalls -# extension of services/mediacodec/minijail/seccomp_policy/mediacodec-seccomp-arm.policy -pselect6: 1 -eventfd2: 1 -sendto: 1 -recvfrom: 1 -_llseek: 1 diff --git a/sensors/Android.bp b/sensors/Android.bp deleted file mode 100755 index 35b1476..0000000 --- a/sensors/Android.bp +++ /dev/null @@ -1,68 +0,0 @@ -cc_library_static { - name: "multihal-samsung8974", - vendor: true, - srcs: [ - "multihal.cpp", - "SensorEventQueue.cpp", - ], - header_libs: [ - "libhardware_headers", - ], - shared_libs: [ - "liblog", - "libcutils", - "libutils", - "libdl", - ], - export_include_dirs: ["."], - cflags: [ - "-Wall", - "-Werror", - ], -} - -cc_library_shared { - name: "android.hardware.sensors@1.0-impl.samsung8974", - defaults: ["hidl_defaults"], - proprietary: true, - relative_install_path: "hw", - srcs: ["Sensors.cpp"], - shared_libs: [ - "liblog", - "libcutils", - "libhardware", - "libbase", - "libutils", - "libhidlbase", - "android.hardware.sensors@1.0", - ], - static_libs: [ - "android.hardware.sensors@1.0-convert", - "multihal-samsung8974", - ], - local_include_dirs: ["include/sensors"], -} - -cc_binary { - name: "android.hardware.sensors@1.0-service.samsung8974", - defaults: ["hidl_defaults"], - relative_install_path: "hw", - vendor: true, - init_rc: ["android.hardware.sensors@1.0-service.samsung8974.rc"], - srcs: ["service.cpp"], - - shared_libs: [ - "liblog", - "libcutils", - "libdl", - "libbase", - "libutils", - "libhidlbase", - "android.hardware.sensors@1.0", - ], - arch: { - arm: { - cflags: ["-DARCH_ARM_32"], - }, - }, -} diff --git a/sensors/Android.mk b/sensors/Android.mk deleted file mode 100644 index 6889f5b..0000000 --- a/sensors/Android.mk +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (C) 2013 The Android Open-Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := sensors.$(TARGET_BOARD_PLATFORM) - -LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_PROPRIETARY_MODULE := true - -LOCAL_CFLAGS := -Wall -Werror -DLOG_TAG=\"MultiHal\" - -LOCAL_SRC_FILES := \ - multihal.cpp \ - SensorEventQueue.cpp \ - -LOCAL_HEADER_LIBRARIES := \ - libhardware_headers \ - -LOCAL_SHARED_LIBRARIES := \ - libcutils \ - libdl \ - liblog \ - libutils \ - -LOCAL_STRIP_MODULE := false - -include $(BUILD_SHARED_LIBRARY) - -include $(call all-makefiles-under, $(LOCAL_PATH)) diff --git a/sensors/SensorEventQueue.cpp b/sensors/SensorEventQueue.cpp deleted file mode 100644 index 0d4d64a..0000000 --- a/sensors/SensorEventQueue.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include - -#include - -#include -#include "SensorEventQueue.h" - -SensorEventQueue::SensorEventQueue(int capacity) { - mCapacity = capacity; - - mStart = 0; - mSize = 0; - mData = new sensors_event_t[mCapacity]; - pthread_cond_init(&mSpaceAvailableCondition, NULL); -} - -SensorEventQueue::~SensorEventQueue() { - delete[] mData; - mData = NULL; - pthread_cond_destroy(&mSpaceAvailableCondition); -} - -int SensorEventQueue::getWritableRegion(int requestedLength, sensors_event_t** out) { - if (mSize == mCapacity || requestedLength <= 0) { - *out = NULL; - return 0; - } - // Start writing after the last readable record. - int firstWritable = (mStart + mSize) % mCapacity; - - int lastWritable = firstWritable + requestedLength - 1; - - // Don't go past the end of the data array. - if (lastWritable > mCapacity - 1) { - lastWritable = mCapacity - 1; - } - // Don't go into the readable region. - if (firstWritable < mStart && lastWritable >= mStart) { - lastWritable = mStart - 1; - } - *out = &mData[firstWritable]; - return lastWritable - firstWritable + 1; -} - -void SensorEventQueue::markAsWritten(int count) { - mSize += count; -} - -int SensorEventQueue::getSize() { - return mSize; -} - -sensors_event_t* SensorEventQueue::peek() { - if (mSize == 0) return NULL; - return &mData[mStart]; -} - -void SensorEventQueue::dequeue() { - if (mSize == 0) return; - if (mSize == mCapacity) { - pthread_cond_broadcast(&mSpaceAvailableCondition); - } - mSize--; - mStart = (mStart + 1) % mCapacity; -} - -// returns true if it waited, or false if it was a no-op. -bool SensorEventQueue::waitForSpace(pthread_mutex_t* mutex) { - bool waited = false; - while (mSize == mCapacity) { - waited = true; - pthread_cond_wait(&mSpaceAvailableCondition, mutex); - } - return waited; -} diff --git a/sensors/SensorEventQueue.h b/sensors/SensorEventQueue.h deleted file mode 100644 index 9778e93..0000000 --- a/sensors/SensorEventQueue.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SENSOREVENTQUEUE_H_ -#define SENSOREVENTQUEUE_H_ - -#include -#include - -/* - * Fixed-size circular queue, with an API developed around the sensor HAL poll() method. - * Poll() takes a pointer to a buffer, which is written by poll() before it returns. - * This class can provide a pointer to a spot in its internal buffer for poll() to - * write to, instead of using an intermediate buffer and a memcpy. - * - * Thread safety: - * Reading can be done safely after grabbing the mutex lock, while poll() writing in a separate - * thread without a mutex lock. But there can only be one writer at a time. - */ -class SensorEventQueue { - int mCapacity; - int mStart; // start of readable region - int mSize; // number of readable items - sensors_event_t* mData; - pthread_cond_t mSpaceAvailableCondition; - -public: - explicit SensorEventQueue(int capacity); - ~SensorEventQueue(); - - // Returns length of region, between zero and min(capacity, requestedLength). If there is any - // writable space, it will return a region of at least one. Because it must return - // a pointer to a contiguous region, it may return smaller regions as we approach the end of - // the data array. - // Only call while holding the lock. - // The region is not marked internally in any way. Subsequent calls may return overlapping - // regions. This class expects there to be exactly one writer at a time. - int getWritableRegion(int requestedLength, sensors_event_t** out); - - // After writing to the region returned by getWritableRegion(), call this to indicate how - // many records were actually written. - // This increases size() by count. - // Only call while holding the lock. - void markAsWritten(int count); - - // Gets the number of readable records. - // Only call while holding the lock. - int getSize(); - - // Returns pointer to the first readable record, or NULL if size() is zero. - // Only call this while holding the lock. - sensors_event_t* peek(); - - // This will decrease the size by one, freeing up the oldest readable event's slot for writing. - // Only call while holding the lock. - void dequeue(); - - // Blocks until space is available. No-op if there is already space. - // Returns true if it had to wait. - bool waitForSpace(pthread_mutex_t* mutex); -}; - -#endif // SENSOREVENTQUEUE_H_ diff --git a/sensors/Sensors.cpp b/sensors/Sensors.cpp deleted file mode 100644 index 1100dd6..0000000 --- a/sensors/Sensors.cpp +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Sensors.h" -#include "convert.h" -#include "multihal.h" - -#include - -#include - -namespace android { -namespace hardware { -namespace sensors { -namespace V1_0 { -namespace implementation { - -/* - * If a multi-hal configuration file exists in the proper location, - * return true indicating we need to use multi-hal functionality. - */ -static bool UseMultiHal() { - const std::string& name = MULTI_HAL_CONFIG_FILE_PATH; - struct stat buffer; - return (stat (name.c_str(), &buffer) == 0); -} - -static Result ResultFromStatus(status_t err) { - switch (err) { - case OK: - return Result::OK; - case PERMISSION_DENIED: - return Result::PERMISSION_DENIED; - case NO_MEMORY: - return Result::NO_MEMORY; - case BAD_VALUE: - return Result::BAD_VALUE; - default: - return Result::INVALID_OPERATION; - } -} - -Sensors::Sensors() - : mInitCheck(NO_INIT), - mSensorModule(nullptr), - mSensorDevice(nullptr) { - status_t err = OK; - if (UseMultiHal()) { - mSensorModule = ::get_multi_hal_module_info(); - } else { - err = hw_get_module( - SENSORS_HARDWARE_MODULE_ID, - (hw_module_t const **)&mSensorModule); - } - if (mSensorModule == NULL) { - err = UNKNOWN_ERROR; - } - - if (err != OK) { - LOG(ERROR) << "Couldn't load " - << SENSORS_HARDWARE_MODULE_ID - << " module (" - << strerror(-err) - << ")"; - - mInitCheck = err; - return; - } - - err = sensors_open_1(&mSensorModule->common, &mSensorDevice); - - if (err != OK) { - LOG(ERROR) << "Couldn't open device for module " - << SENSORS_HARDWARE_MODULE_ID - << " (" - << strerror(-err) - << ")"; - - mInitCheck = err; - return; - } - - // Require all the old HAL APIs to be present except for injection, which - // is considered optional. - CHECK_GE(getHalDeviceVersion(), SENSORS_DEVICE_API_VERSION_1_3); - - if (getHalDeviceVersion() == SENSORS_DEVICE_API_VERSION_1_4) { - if (mSensorDevice->inject_sensor_data == nullptr) { - LOG(ERROR) << "HAL specifies version 1.4, but does not implement inject_sensor_data()"; - } - if (mSensorModule->set_operation_mode == nullptr) { - LOG(ERROR) << "HAL specifies version 1.4, but does not implement set_operation_mode()"; - } - } - - mInitCheck = OK; -} - -status_t Sensors::initCheck() const { - return mInitCheck; -} - -Return Sensors::getSensorsList(getSensorsList_cb _hidl_cb) { - sensor_t const *list; - size_t count = mSensorModule->get_sensors_list(mSensorModule, &list); - - hidl_vec out; - out.resize(count); - - for (size_t i = 0; i < count; ++i) { - const sensor_t *src = &list[i]; - SensorInfo *dst = &out[i]; - - convertFromSensor(*src, dst); - } - - _hidl_cb(out); - - return Void(); -} - -int Sensors::getHalDeviceVersion() const { - if (!mSensorDevice) { - return -1; - } - - return mSensorDevice->common.version; -} - -Return Sensors::setOperationMode(OperationMode mode) { - if (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_4 - || mSensorModule->set_operation_mode == nullptr) { - return Result::INVALID_OPERATION; - } - return ResultFromStatus(mSensorModule->set_operation_mode((uint32_t)mode)); -} - -Return Sensors::activate( - int32_t sensor_handle, bool enabled) { - return ResultFromStatus( - mSensorDevice->activate( - reinterpret_cast(mSensorDevice), - sensor_handle, - enabled)); -} - -Return Sensors::poll(int32_t maxCount, poll_cb _hidl_cb) { - - hidl_vec out; - hidl_vec dynamicSensorsAdded; - - std::unique_ptr data; - int err = android::NO_ERROR; - - { // scope of reentry lock - - // This enforces a single client, meaning that a maximum of one client can call poll(). - // If this function is re-entred, it means that we are stuck in a state that may prevent - // the system from proceeding normally. - // - // Exit and let the system restart the sensor-hal-implementation hidl service. - // - // This function must not call _hidl_cb(...) or return until there is no risk of blocking. - std::unique_lock lock(mPollLock, std::try_to_lock); - if(!lock.owns_lock()){ - // cannot get the lock, hidl service will go into deadlock if it is not restarted. - // This is guaranteed to not trigger in passthrough mode. - LOG(ERROR) << - "ISensors::poll() re-entry. I do not know what to do except killing myself."; - ::exit(-1); - } - - if (maxCount <= 0) { - err = android::BAD_VALUE; - } else { - int bufferSize = maxCount <= kPollMaxBufferSize ? maxCount : kPollMaxBufferSize; - data.reset(new sensors_event_t[bufferSize]); - err = mSensorDevice->poll( - reinterpret_cast(mSensorDevice), - data.get(), bufferSize); - } - } - - if (err < 0) { - _hidl_cb(ResultFromStatus(err), out, dynamicSensorsAdded); - return Void(); - } - - const size_t count = (size_t)err; - - for (size_t i = 0; i < count; ++i) { - if (data[i].type != SENSOR_TYPE_DYNAMIC_SENSOR_META) { - continue; - } - - const dynamic_sensor_meta_event_t *dyn = &data[i].dynamic_sensor_meta; - - if (!dyn->connected) { - continue; - } - - CHECK(dyn->sensor != nullptr); - CHECK_EQ(dyn->sensor->handle, dyn->handle); - - SensorInfo info; - convertFromSensor(*dyn->sensor, &info); - - size_t numDynamicSensors = dynamicSensorsAdded.size(); - dynamicSensorsAdded.resize(numDynamicSensors + 1); - dynamicSensorsAdded[numDynamicSensors] = info; - } - - out.resize(count); - convertFromSensorEvents(err, data.get(), &out); - - _hidl_cb(Result::OK, out, dynamicSensorsAdded); - - return Void(); -} - -Return Sensors::batch( - int32_t sensor_handle, - int64_t sampling_period_ns, - int64_t max_report_latency_ns) { - return ResultFromStatus( - mSensorDevice->batch( - mSensorDevice, - sensor_handle, - 0, /*flags*/ - sampling_period_ns, - max_report_latency_ns)); -} - -Return Sensors::flush(int32_t sensor_handle) { - return ResultFromStatus(mSensorDevice->flush(mSensorDevice, sensor_handle)); -} - -Return Sensors::injectSensorData(const Event& event) { - if (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_4 - || mSensorDevice->inject_sensor_data == nullptr) { - return Result::INVALID_OPERATION; - } - - sensors_event_t out; - convertToSensorEvent(event, &out); - - return ResultFromStatus( - mSensorDevice->inject_sensor_data(mSensorDevice, &out)); -} - -Return Sensors::registerDirectChannel( - const SharedMemInfo& mem, registerDirectChannel_cb _hidl_cb) { - if (mSensorDevice->register_direct_channel == nullptr - || mSensorDevice->config_direct_report == nullptr) { - // HAL does not support - _hidl_cb(Result::INVALID_OPERATION, -1); - return Void(); - } - - sensors_direct_mem_t m; - if (!convertFromSharedMemInfo(mem, &m)) { - _hidl_cb(Result::BAD_VALUE, -1); - return Void(); - } - - int err = mSensorDevice->register_direct_channel(mSensorDevice, &m, -1); - - if (err < 0) { - _hidl_cb(ResultFromStatus(err), -1); - } else { - int32_t channelHandle = static_cast(err); - _hidl_cb(Result::OK, channelHandle); - } - return Void(); -} - -Return Sensors::unregisterDirectChannel(int32_t channelHandle) { - if (mSensorDevice->register_direct_channel == nullptr - || mSensorDevice->config_direct_report == nullptr) { - // HAL does not support - return Result::INVALID_OPERATION; - } - - mSensorDevice->register_direct_channel(mSensorDevice, nullptr, channelHandle); - - return Result::OK; -} - -Return Sensors::configDirectReport( - int32_t sensorHandle, int32_t channelHandle, RateLevel rate, - configDirectReport_cb _hidl_cb) { - if (mSensorDevice->register_direct_channel == nullptr - || mSensorDevice->config_direct_report == nullptr) { - // HAL does not support - _hidl_cb(Result::INVALID_OPERATION, -1); - return Void(); - } - - sensors_direct_cfg_t cfg = { - .rate_level = convertFromRateLevel(rate) - }; - if (cfg.rate_level < 0) { - _hidl_cb(Result::BAD_VALUE, -1); - return Void(); - } - - int err = mSensorDevice->config_direct_report(mSensorDevice, - sensorHandle, channelHandle, &cfg); - - if (rate == RateLevel::STOP) { - _hidl_cb(ResultFromStatus(err), -1); - } else { - _hidl_cb(err > 0 ? Result::OK : ResultFromStatus(err), err); - } - return Void(); -} - -// static -void Sensors::convertFromSensorEvents( - size_t count, - const sensors_event_t *srcArray, - hidl_vec *dstVec) { - for (size_t i = 0; i < count; ++i) { - const sensors_event_t &src = srcArray[i]; - Event *dst = &(*dstVec)[i]; - - convertFromSensorEvent(src, dst); - } -} - -ISensors *HIDL_FETCH_ISensors(const char * /* hal */) { - Sensors *sensors = new Sensors; - if (sensors->initCheck() != OK) { - delete sensors; - sensors = nullptr; - - return nullptr; - } - - return sensors; -} - -} // namespace implementation -} // namespace V1_0 -} // namespace sensors -} // namespace hardware -} // namespace android diff --git a/sensors/Sensors.h b/sensors/Sensors.h deleted file mode 100644 index be00a96..0000000 --- a/sensors/Sensors.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_SENSORS_H_ - -#define HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_SENSORS_H_ - -#include -#include -#include -#include - -namespace android { -namespace hardware { -namespace sensors { -namespace V1_0 { -namespace implementation { - - -struct Sensors : public ::android::hardware::sensors::V1_0::ISensors { - Sensors(); - - status_t initCheck() const; - - Return getSensorsList(getSensorsList_cb _hidl_cb) override; - - Return setOperationMode(OperationMode mode) override; - - Return activate( - int32_t sensor_handle, bool enabled) override; - - Return poll(int32_t maxCount, poll_cb _hidl_cb) override; - - Return batch( - int32_t sensor_handle, - int64_t sampling_period_ns, - int64_t max_report_latency_ns) override; - - Return flush(int32_t sensor_handle) override; - - Return injectSensorData(const Event& event) override; - - Return registerDirectChannel( - const SharedMemInfo& mem, registerDirectChannel_cb _hidl_cb) override; - - Return unregisterDirectChannel(int32_t channelHandle) override; - - Return configDirectReport( - int32_t sensorHandle, int32_t channelHandle, RateLevel rate, - configDirectReport_cb _hidl_cb) override; - -private: - static constexpr int32_t kPollMaxBufferSize = 128; - status_t mInitCheck; - sensors_module_t *mSensorModule; - sensors_poll_device_1_t *mSensorDevice; - std::mutex mPollLock; - - int getHalDeviceVersion() const; - - static void convertFromSensorEvents( - size_t count, const sensors_event_t *src, hidl_vec *dst); - - DISALLOW_COPY_AND_ASSIGN(Sensors); -}; - -extern "C" ISensors *HIDL_FETCH_ISensors(const char *name); - -} // namespace implementation -} // namespace V1_0 -} // namespace sensors -} // namespace hardware -} // namespace android - -#endif // HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_SENSORS_H_ diff --git a/sensors/android.hardware.sensors@1.0-service.samsung8974.rc b/sensors/android.hardware.sensors@1.0-service.samsung8974.rc deleted file mode 100644 index d17a02c..0000000 --- a/sensors/android.hardware.sensors@1.0-service.samsung8974.rc +++ /dev/null @@ -1,6 +0,0 @@ -service vendor.sensors-hal-1-0 /vendor/bin/hw/android.hardware.sensors@1.0-service.samsung8974 - class hal - user system - group system input wakelock - capabilities BLOCK_SUSPEND - rlimit rtprio 10 10 diff --git a/sensors/include/sensors/convert.h b/sensors/include/sensors/convert.h deleted file mode 100644 index c3a0125..0000000 --- a/sensors/include/sensors/convert.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_INCLUDE_CONVERT_H_ - -#define HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_INCLUDE_CONVERT_H_ - -#include -#include - -namespace android { -namespace hardware { -namespace sensors { -namespace V1_0 { -namespace implementation { - -void convertFromSensor(const sensor_t &src, SensorInfo *dst); -void convertToSensor(const SensorInfo &src, sensor_t *dst); - -void convertFromSensorEvent(const sensors_event_t &src, Event *dst); -void convertToSensorEvent(const Event &src, sensors_event_t *dst); - -bool convertFromSharedMemInfo(const SharedMemInfo& memIn, sensors_direct_mem_t *memOut); -int convertFromRateLevel(RateLevel rate); - -} // namespace implementation -} // namespace V1_0 -} // namespace sensors -} // namespace hardware -} // namespace android - -#endif // HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_INCLUDE_CONVERT_H_ diff --git a/sensors/multihal.cpp b/sensors/multihal.cpp deleted file mode 100755 index 0143321..0000000 --- a/sensors/multihal.cpp +++ /dev/null @@ -1,853 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "SensorEventQueue.h" -#include "multihal.h" - -#define LOG_NDEBUG 1 -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -static pthread_mutex_t init_modules_mutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t init_sensors_mutex = PTHREAD_MUTEX_INITIALIZER; - -// This mutex is shared by all queues -static pthread_mutex_t queue_mutex = PTHREAD_MUTEX_INITIALIZER; - -// Used to pause the multihal poll(). Broadcasted by sub-polling tasks if waiting_for_data. -static pthread_cond_t data_available_cond = PTHREAD_COND_INITIALIZER; -bool waiting_for_data = false; - -// Vector of sub modules, whose indexes are referred to in this file as module_index. -static std::vector *sub_hw_modules = nullptr; - -// Vector of sub modules shared object handles -static std::vector *so_handles = nullptr; - -/* - * Comparable class that globally identifies a sensor, by module index and local handle. - * A module index is the module's index in sub_hw_modules. - * A local handle is the handle the sub-module assigns to a sensor. - */ -struct FullHandle { - int moduleIndex; - int localHandle; - - bool operator<(const FullHandle &that) const { - if (moduleIndex < that.moduleIndex) { - return true; - } - if (moduleIndex > that.moduleIndex) { - return false; - } - return localHandle < that.localHandle; - } - - bool operator==(const FullHandle &that) const { - return moduleIndex == that.moduleIndex && localHandle == that.localHandle; - } -}; - -std::map global_to_full; -std::map full_to_global; -int next_global_handle = 1; - -static int assign_global_handle(int module_index, int local_handle) { - int global_handle = next_global_handle++; - FullHandle full_handle; - full_handle.moduleIndex = module_index; - full_handle.localHandle = local_handle; - full_to_global[full_handle] = global_handle; - global_to_full[global_handle] = full_handle; - return global_handle; -} - -// Returns the local handle, or -1 if it does not exist. -static int get_local_handle(int global_handle) { - if (global_to_full.count(global_handle) == 0) { - ALOGW("Unknown global_handle %d", global_handle); - return -1; - } - return global_to_full[global_handle].localHandle; -} - -// Returns the sub_hw_modules index of the module that contains the sensor associates with this -// global_handle, or -1 if that global_handle does not exist. -static int get_module_index(int global_handle) { - if (global_to_full.count(global_handle) == 0) { - ALOGW("Unknown global_handle %d", global_handle); - return -1; - } - FullHandle f = global_to_full[global_handle]; - ALOGV("FullHandle for global_handle %d: moduleIndex %d, localHandle %d", - global_handle, f.moduleIndex, f.localHandle); - return f.moduleIndex; -} - -// Returns the global handle for this full_handle, or -1 if the full_handle is unknown. -static int get_global_handle(FullHandle* full_handle) { - int global_handle = -1; - if (full_to_global.count(*full_handle)) { - global_handle = full_to_global[*full_handle]; - } else { - ALOGW("Unknown FullHandle: moduleIndex %d, localHandle %d", - full_handle->moduleIndex, full_handle->localHandle); - } - return global_handle; -} - -static const int SENSOR_EVENT_QUEUE_CAPACITY = 36; - -struct TaskContext { - sensors_poll_device_t* device; - SensorEventQueue* queue; -}; - -void *writerTask(void* ptr) { - ALOGV("writerTask STARTS"); - TaskContext* ctx = (TaskContext*)ptr; - sensors_poll_device_t* device = ctx->device; - SensorEventQueue* queue = ctx->queue; - sensors_event_t* buffer; - int eventsPolled; - while (1) { - pthread_mutex_lock(&queue_mutex); - if (queue->waitForSpace(&queue_mutex)) { - ALOGV("writerTask waited for space"); - } - int bufferSize = queue->getWritableRegion(SENSOR_EVENT_QUEUE_CAPACITY, &buffer); - // Do blocking poll outside of lock - pthread_mutex_unlock(&queue_mutex); - - ALOGV("writerTask before poll() - bufferSize = %d", bufferSize); - eventsPolled = device->poll(device, buffer, bufferSize); - ALOGV("writerTask poll() got %d events.", eventsPolled); - if (eventsPolled <= 0) { - if (eventsPolled < 0) { - ALOGV("writerTask ignored error %d from %s", eventsPolled, device->common.module->name); - ALOGE("ERROR: Fix %s so it does not return error from poll()", device->common.module->name); - } - continue; - } - pthread_mutex_lock(&queue_mutex); - queue->markAsWritten(eventsPolled); - ALOGV("writerTask wrote %d events", eventsPolled); - if (waiting_for_data) { - ALOGV("writerTask - broadcast data_available_cond"); - pthread_cond_broadcast(&data_available_cond); - } - pthread_mutex_unlock(&queue_mutex); - } - // never actually returns - return NULL; -} - -/* - * Cache of all sensors, with original handles replaced by global handles. - * This will be handled to get_sensors_list() callers. - */ -static struct sensor_t const* global_sensors_list = NULL; -static int global_sensors_count = -1; - -/* - * Extends a sensors_poll_device_1 by including all the sub-module's devices. - */ -struct sensors_poll_context_t { - /* - * This is the device that SensorDevice.cpp uses to make API calls - * to the multihal, which fans them out to sub-HALs. - */ - sensors_poll_device_1 proxy_device; // must be first - - void addSubHwDevice(struct hw_device_t*); - - int activate(int handle, int enabled); - int setDelay(int handle, int64_t ns); - int poll(sensors_event_t* data, int count); - int batch(int handle, int flags, int64_t period_ns, int64_t timeout); - int flush(int handle); - int inject_sensor_data(const sensors_event_t *data); - int register_direct_channel(const struct sensors_direct_mem_t* mem, - int channel_handle); - int config_direct_report(int sensor_handle, - int channel_handle, - const struct sensors_direct_cfg_t *config); - int close(); - - std::vector sub_hw_devices; - std::vector queues; - std::vector threads; - int nextReadIndex; - - sensors_poll_device_t* get_v0_device_by_handle(int global_handle); - sensors_poll_device_1_t* get_v1_device_by_handle(int global_handle); - sensors_poll_device_1_t* get_primary_v1_device(); - int get_device_version_by_handle(int global_handle); - - void copy_event_remap_handle(sensors_event_t* src, sensors_event_t* dest, int sub_index); -}; - -void sensors_poll_context_t::addSubHwDevice(struct hw_device_t* sub_hw_device) { - ALOGV("addSubHwDevice"); - this->sub_hw_devices.push_back(sub_hw_device); - - SensorEventQueue *queue = new SensorEventQueue(SENSOR_EVENT_QUEUE_CAPACITY); - this->queues.push_back(queue); - - TaskContext* taskContext = new TaskContext(); - taskContext->device = (sensors_poll_device_t*) sub_hw_device; - taskContext->queue = queue; - - pthread_t writerThread; - pthread_create(&writerThread, NULL, writerTask, taskContext); - this->threads.push_back(writerThread); -} - -// Returns the device pointer, or NULL if the global handle is invalid. -sensors_poll_device_t* sensors_poll_context_t::get_v0_device_by_handle(int global_handle) { - int sub_index = get_module_index(global_handle); - if (sub_index < 0 || sub_index >= (int) this->sub_hw_devices.size()) { - return NULL; - } - return (sensors_poll_device_t*) this->sub_hw_devices[sub_index]; -} - -// Returns the device pointer, or NULL if the global handle is invalid. -sensors_poll_device_1_t* sensors_poll_context_t::get_v1_device_by_handle(int global_handle) { - int sub_index = get_module_index(global_handle); - if (sub_index < 0 || sub_index >= (int) this->sub_hw_devices.size()) { - return NULL; - } - return (sensors_poll_device_1_t*) this->sub_hw_devices[sub_index]; -} - -// Returns the device pointer, or NULL if primary hal does not exist -sensors_poll_device_1_t* sensors_poll_context_t::get_primary_v1_device() { - if (sub_hw_devices.size() < 1) { - return nullptr; - } - return (sensors_poll_device_1_t*) this->sub_hw_devices[0]; -} - -// Returns the device version, or -1 if the handle is invalid. -int sensors_poll_context_t::get_device_version_by_handle(int handle) { - sensors_poll_device_t* v0 = this->get_v0_device_by_handle(handle); - if (v0) { - return v0->common.version; - } else { - return -1; - } -} - -// Android N and hire require sensor HALs to be at least 1_3 compliant -#define HAL_VERSION_IS_COMPLIANT(version) \ - (version >= SENSORS_DEVICE_API_VERSION_1_3) - -// Returns true if HAL is compliant, false if HAL is not compliant or if handle is invalid -static bool halIsCompliant(sensors_poll_context_t *ctx, int handle) { - int version = ctx->get_device_version_by_handle(handle); - return version != -1 && HAL_VERSION_IS_COMPLIANT(version); -} - -static bool halIsAPILevelCompliant(sensors_poll_context_t *ctx, int handle, int level) { - int version = ctx->get_device_version_by_handle(handle); - return version != -1 && (version >= level); -} - -static bool halSupportDirectSensorReport(sensors_poll_device_1_t* v1) { - return v1 != nullptr && HAL_VERSION_IS_COMPLIANT(v1->common.version) && - v1->register_direct_channel != nullptr && v1->config_direct_report != nullptr; -} - -const char *apiNumToStr(int version) { - switch(version) { - case SENSORS_DEVICE_API_VERSION_1_0: - return "SENSORS_DEVICE_API_VERSION_1_0"; - case SENSORS_DEVICE_API_VERSION_1_1: - return "SENSORS_DEVICE_API_VERSION_1_1"; - case SENSORS_DEVICE_API_VERSION_1_2: - return "SENSORS_DEVICE_API_VERSION_1_2"; - case SENSORS_DEVICE_API_VERSION_1_3: - return "SENSORS_DEVICE_API_VERSION_1_3"; - case SENSORS_DEVICE_API_VERSION_1_4: - return "SENSORS_DEVICE_API_VERSION_1_4"; - default: - return "UNKNOWN"; - } -} - -int sensors_poll_context_t::activate(int handle, int enabled) { - int retval = -EINVAL; - ALOGV("activate"); - int local_handle = get_local_handle(handle); - sensors_poll_device_t* v0 = this->get_v0_device_by_handle(handle); - if (halIsCompliant(this, handle) && local_handle >= 0 && v0) { - retval = v0->activate(v0, local_handle, enabled); - } else { - ALOGE("IGNORING activate(enable %d) call to non-API-compliant sensor handle=%d !", - enabled, handle); - } - ALOGV("retval %d", retval); - return retval; -} - -int sensors_poll_context_t::setDelay(int handle, int64_t ns) { - int retval = -EINVAL; - ALOGV("setDelay"); - int local_handle = get_local_handle(handle); - sensors_poll_device_t* v0 = this->get_v0_device_by_handle(handle); - if (halIsCompliant(this, handle) && local_handle >= 0 && v0) { - retval = v0->setDelay(v0, local_handle, ns); - } else { - ALOGE("IGNORING setDelay() call for non-API-compliant sensor handle=%d !", handle); - } - ALOGV("retval %d", retval); - return retval; -} - -void sensors_poll_context_t::copy_event_remap_handle(sensors_event_t* dest, sensors_event_t* src, - int sub_index) { - memcpy(dest, src, sizeof(struct sensors_event_t)); - // A normal event's "sensor" field is a local handle. Convert it to a global handle. - // A meta-data event must have its sensor set to 0, but it has a nested event - // with a local handle that needs to be converted to a global handle. - FullHandle full_handle; - full_handle.moduleIndex = sub_index; - - // If it's a metadata event, rewrite the inner payload, not the sensor field. - // If the event's sensor field is unregistered for any reason, rewrite the sensor field - // with a -1, instead of writing an incorrect but plausible sensor number, because - // get_global_handle() returns -1 for unknown FullHandles. - if (dest->type == SENSOR_TYPE_META_DATA) { - full_handle.localHandle = dest->meta_data.sensor; - dest->meta_data.sensor = get_global_handle(&full_handle); - } else { - full_handle.localHandle = dest->sensor; - dest->sensor = get_global_handle(&full_handle); - } -} - -int sensors_poll_context_t::poll(sensors_event_t *data, int maxReads) { - ALOGV("poll"); - int empties = 0; - int queueCount = 0; - int eventsRead = 0; - - pthread_mutex_lock(&queue_mutex); - queueCount = (int)this->queues.size(); - while (eventsRead == 0) { - while (empties < queueCount && eventsRead < maxReads) { - SensorEventQueue* queue = this->queues.at(this->nextReadIndex); - sensors_event_t* event = queue->peek(); - if (event == NULL) { - empties++; - } else { - empties = 0; - this->copy_event_remap_handle(&data[eventsRead], event, nextReadIndex); - if (data[eventsRead].sensor == SENSORS_HANDLE_BASE - 1) { - // Bad handle, do not pass corrupted event upstream ! - ALOGW("Dropping bad local handle event packet on the floor"); - } else { - eventsRead++; - } - queue->dequeue(); - } - this->nextReadIndex = (this->nextReadIndex + 1) % queueCount; - } - if (eventsRead == 0) { - // The queues have been scanned and none contain data, so wait. - ALOGV("poll stopping to wait for data"); - waiting_for_data = true; - pthread_cond_wait(&data_available_cond, &queue_mutex); - waiting_for_data = false; - empties = 0; - } - } - pthread_mutex_unlock(&queue_mutex); - ALOGV("poll returning %d events.", eventsRead); - - return eventsRead; -} - -int sensors_poll_context_t::batch(int handle, int flags, int64_t period_ns, int64_t timeout) { - ALOGV("batch"); - int retval = -EINVAL; - int local_handle = get_local_handle(handle); - sensors_poll_device_1_t* v1 = this->get_v1_device_by_handle(handle); - if (halIsCompliant(this, handle) && local_handle >= 0 && v1) { - retval = v1->batch(v1, local_handle, flags, period_ns, timeout); - } else { - ALOGE("IGNORING batch() call to non-API-compliant sensor handle=%d !", handle); - } - ALOGV("retval %d", retval); - return retval; -} - -int sensors_poll_context_t::flush(int handle) { - ALOGV("flush"); - int retval = -EINVAL; - int local_handle = get_local_handle(handle); - sensors_poll_device_1_t* v1 = this->get_v1_device_by_handle(handle); - if (halIsCompliant(this, handle) && local_handle >= 0 && v1) { - retval = v1->flush(v1, local_handle); - } else { - ALOGE("IGNORING flush() call to non-API-compliant sensor handle=%d !", handle); - } - ALOGV("retval %d", retval); - return retval; -} - -int sensors_poll_context_t::inject_sensor_data(const sensors_event_t *data) { - int retval = -EINVAL; - ALOGV("inject_sensor_data"); - if (data->sensor == -1) { - // operational parameter - sensors_poll_device_1_t* v1 = get_primary_v1_device(); - if (v1 && v1->common.version >= SENSORS_DEVICE_API_VERSION_1_4) { - retval = v1->inject_sensor_data(v1, data); - } else { - ALOGE("IGNORED inject_sensor_data(operational param) call to non-API-compliant sensor"); - return -ENOSYS; - } - } else { - // Get handle for the sensor owning the event being injected - int local_handle = get_local_handle(data->sensor); - sensors_poll_device_1_t* v1 = this->get_v1_device_by_handle(data->sensor); - if (halIsAPILevelCompliant(this, data->sensor, SENSORS_DEVICE_API_VERSION_1_4) && - local_handle >= 0 && v1) { - // if specific sensor is used, we have to replace global sensor handle - // with local one, before passing to concrete HAL - sensors_event_t data_copy = *data; - data_copy.sensor = local_handle; - retval = v1->inject_sensor_data(v1, &data_copy); - } else { - ALOGE("IGNORED inject_sensor_data(type=%d, handle=%d) call to non-API-compliant sensor", - data->type, data->sensor); - retval = -ENOSYS; - } - } - ALOGV("retval %d", retval); - return retval; -} - -int sensors_poll_context_t::register_direct_channel(const struct sensors_direct_mem_t* mem, - int channel_handle) { - int retval = -EINVAL; - ALOGV("register_direct_channel"); - sensors_poll_device_1_t* v1 = get_primary_v1_device(); - if (v1 && halSupportDirectSensorReport(v1)) { - retval = v1->register_direct_channel(v1, mem, channel_handle); - } else { - ALOGE("IGNORED register_direct_channel(mem=%p, handle=%d) call to non-API-compliant sensor", - mem, channel_handle); - retval = -ENOSYS; - } - ALOGV("retval %d", retval); - return retval; -} - -int sensors_poll_context_t::config_direct_report(int sensor_handle, - int channel_handle, - const struct sensors_direct_cfg_t *config) { - int retval = -EINVAL; - ALOGV("config_direct_report"); - - if (config != nullptr) { - int local_handle = get_local_handle(sensor_handle); - sensors_poll_device_1_t* v1 = get_primary_v1_device(); - if (v1 && halSupportDirectSensorReport(v1)) { - retval = v1->config_direct_report(v1, local_handle, channel_handle, config); - } else { - ALOGE("IGNORED config_direct_report(sensor=%d, channel=%d, rate_level=%d) call to " - "non-API-compliant sensor", sensor_handle, channel_handle, config->rate_level); - retval = -ENOSYS; - } - } - ALOGV("retval %d", retval); - return retval; -} -int sensors_poll_context_t::close() { - ALOGV("close"); - for (std::vector::iterator it = this->sub_hw_devices.begin(); - it != this->sub_hw_devices.end(); it++) { - hw_device_t* dev = *it; - int retval = dev->close(dev); - ALOGV("retval %d", retval); - } - return 0; -} - - -static int device__close(struct hw_device_t *dev) { - pthread_mutex_lock(&init_modules_mutex); - sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev; - if (ctx != NULL) { - int retval = ctx->close(); - delete ctx; - pthread_mutex_unlock(&init_modules_mutex); - return retval; - } - - if (sub_hw_modules != nullptr) { - delete sub_hw_modules; - sub_hw_modules = nullptr; - } - - if (so_handles != nullptr) { - for (auto handle : *so_handles) { - dlclose(handle); - } - delete so_handles; - so_handles = nullptr; - } - pthread_mutex_unlock(&init_modules_mutex); - return 0; -} - -static int device__activate(struct sensors_poll_device_t *dev, int handle, - int enabled) { - sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev; - return ctx->activate(handle, enabled); -} - -static int device__setDelay(struct sensors_poll_device_t *dev, int handle, - int64_t ns) { - sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev; - return ctx->setDelay(handle, ns); -} - -static int device__poll(struct sensors_poll_device_t *dev, sensors_event_t* data, - int count) { - sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev; - return ctx->poll(data, count); -} - -static int device__batch(struct sensors_poll_device_1 *dev, int handle, - int flags, int64_t period_ns, int64_t timeout) { - (void)flags; - (void)timeout; - - sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev; - ctx->setDelay(handle, period_ns); - return 0; -} - -static int device__flush(struct sensors_poll_device_1 *dev, int handle) { - (void)dev; - (void)handle; - - return -EINVAL; -} - -static int device__inject_sensor_data(struct sensors_poll_device_1 *dev, - const sensors_event_t *data) { - sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev; - return ctx->inject_sensor_data(data); -} - -static int device__register_direct_channel(struct sensors_poll_device_1 *dev, - const struct sensors_direct_mem_t* mem, - int channel_handle) { - sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev; - return ctx->register_direct_channel(mem, channel_handle); -} - -static int device__config_direct_report(struct sensors_poll_device_1 *dev, - int sensor_handle, - int channel_handle, - const struct sensors_direct_cfg_t *config) { - sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev; - return ctx->config_direct_report(sensor_handle, channel_handle, config); -} - -static int open_sensors(const struct hw_module_t* module, const char* name, - struct hw_device_t** device); - -/* - * Adds valid paths from the config file to the vector passed in. - * The vector must not be null. - */ -static std::vector get_so_paths() { - std::vector so_paths; - - const std::vector config_path_list( - { MULTI_HAL_CONFIG_FILE_PATH, DEPRECATED_MULTI_HAL_CONFIG_FILE_PATH }); - - std::ifstream stream; - const char *path = nullptr; - for (auto i : config_path_list) { - std::ifstream f(i); - if (f) { - stream = std::move(f); - path = i; - break; - } - } - if(!stream) { - ALOGW("No multihal config file found"); - return so_paths; - } - - ALOGE_IF(strcmp(path, DEPRECATED_MULTI_HAL_CONFIG_FILE_PATH) == 0, - "Multihal configuration file path %s is not compatible with Treble " - "requirements. Please move it to %s.", - path, MULTI_HAL_CONFIG_FILE_PATH); - - ALOGV("Multihal config file found at %s", path); - std::string line; - while (std::getline(stream, line)) { - ALOGV("config file line: '%s'", line.c_str()); - so_paths.push_back(line); - } - return so_paths; -} - -/* - * Ensures that the sub-module array is initialized. - * This can be first called from get_sensors_list or from open_sensors. - */ -static void lazy_init_modules() { - pthread_mutex_lock(&init_modules_mutex); - if (sub_hw_modules != NULL) { - pthread_mutex_unlock(&init_modules_mutex); - return; - } - std::vector so_paths(get_so_paths()); - - // dlopen the module files and cache their module symbols in sub_hw_modules - sub_hw_modules = new std::vector(); - so_handles = new std::vector(); - dlerror(); // clear any old errors - const char* sym = HAL_MODULE_INFO_SYM_AS_STR; - for (const auto &s : so_paths) { - const char* path = s.c_str(); - void* lib_handle = dlopen(path, RTLD_LAZY); - if (lib_handle == NULL) { - ALOGW("dlerror(): %s", dlerror()); - } else { - ALOGI("Loaded library from %s", path); - ALOGV("Opening symbol \"%s\"", sym); - // clear old errors - dlerror(); - struct hw_module_t* module = (hw_module_t*) dlsym(lib_handle, sym); - const char* error; - if ((error = dlerror()) != NULL) { - ALOGW("Error calling dlsym: %s", error); - } else if (module == NULL) { - ALOGW("module == NULL"); - } else { - ALOGV("Loaded symbols from \"%s\"", sym); - sub_hw_modules->push_back(module); - so_handles->push_back(lib_handle); - lib_handle = nullptr; - } - } - if (lib_handle != nullptr) { - dlclose(lib_handle); - } - } - pthread_mutex_unlock(&init_modules_mutex); -} - -/* - * Fix the fields of the sensor to be compliant with the API version - * reported by the wrapper. - */ -static void fix_sensor_fields(sensor_t& sensor) { - /* - * Because batching and flushing don't work modify the - * sensor fields to not report any fifo counts. - */ - sensor.fifoReservedEventCount = 0; - sensor.fifoMaxEventCount = 0; -} - -/* - * Lazy-initializes global_sensors_count, global_sensors_list, and module_sensor_handles. - */ -static void lazy_init_sensors_list() { - ALOGV("lazy_init_sensors_list"); - pthread_mutex_lock(&init_sensors_mutex); - if (global_sensors_list != NULL) { - // already initialized - pthread_mutex_unlock(&init_sensors_mutex); - ALOGV("lazy_init_sensors_list - early return"); - return; - } - - ALOGV("lazy_init_sensors_list needs to do work"); - lazy_init_modules(); - - // Count all the sensors, then allocate an array of blanks. - global_sensors_count = 0; - const struct sensor_t *subhal_sensors_list; - for (std::vector::iterator it = sub_hw_modules->begin(); - it != sub_hw_modules->end(); it++) { - struct sensors_module_t *module = (struct sensors_module_t*) *it; - global_sensors_count += module->get_sensors_list(module, &subhal_sensors_list); - ALOGV("increased global_sensors_count to %d", global_sensors_count); - } - - // The global_sensors_list is full of consts. - // Manipulate this non-const list, and point the const one to it when we're done. - sensor_t* mutable_sensor_list = new sensor_t[global_sensors_count]; - - // index of the next sensor to set in mutable_sensor_list - int mutable_sensor_index = 0; - int module_index = 0; - - for (std::vector::iterator it = sub_hw_modules->begin(); - it != sub_hw_modules->end(); it++) { - hw_module_t *hw_module = *it; - ALOGV("examine one module"); - // Read the sub-module's sensor list. - struct sensors_module_t *module = (struct sensors_module_t*) hw_module; - int module_sensor_count = module->get_sensors_list(module, &subhal_sensors_list); - ALOGV("the module has %d sensors", module_sensor_count); - - // Copy the HAL's sensor list into global_sensors_list, - // with the handle changed to be a global handle. - for (int i = 0; i < module_sensor_count; i++) { - ALOGV("examining one sensor"); - const struct sensor_t *local_sensor = &subhal_sensors_list[i]; - int local_handle = local_sensor->handle; - memcpy(&mutable_sensor_list[mutable_sensor_index], local_sensor, - sizeof(struct sensor_t)); - - // sensor direct report is only for primary module - if (module_index != 0) { - mutable_sensor_list[mutable_sensor_index].flags &= - ~(SENSOR_FLAG_MASK_DIRECT_REPORT | SENSOR_FLAG_MASK_DIRECT_CHANNEL); - } - - // Overwrite the global version's handle with a global handle. - int global_handle = assign_global_handle(module_index, local_handle); - - mutable_sensor_list[mutable_sensor_index].handle = global_handle; - ALOGV("module_index %d, local_handle %d, global_handle %d", - module_index, local_handle, global_handle); - - fix_sensor_fields(mutable_sensor_list[mutable_sensor_index]); - mutable_sensor_index++; - } - module_index++; - } - // Set the const static global_sensors_list to the mutable one allocated by this function. - global_sensors_list = mutable_sensor_list; - - pthread_mutex_unlock(&init_sensors_mutex); - ALOGV("end lazy_init_sensors_list"); -} - -static int module__get_sensors_list(__unused struct sensors_module_t* module, - struct sensor_t const** list) { - ALOGV("module__get_sensors_list start"); - lazy_init_sensors_list(); - *list = global_sensors_list; - ALOGV("global_sensors_count: %d", global_sensors_count); - for (int i = 0; i < global_sensors_count; i++) { - ALOGV("sensor type: %d", global_sensors_list[i].type); - } - return global_sensors_count; -} - -static struct hw_module_methods_t sensors_module_methods = { - .open = open_sensors -}; - -struct sensors_module_t HAL_MODULE_INFO_SYM = { - .common = { - .tag = HARDWARE_MODULE_TAG, - .version_major = 1, - .version_minor = 1, - .id = SENSORS_HARDWARE_MODULE_ID, - .name = "MultiHal Sensor Module", - .author = "Google, Inc", - .methods = &sensors_module_methods, - .dso = NULL, - .reserved = {0}, - }, - .get_sensors_list = module__get_sensors_list -}; - -struct sensors_module_t *get_multi_hal_module_info() { - return (&HAL_MODULE_INFO_SYM); -} - -static int open_sensors(const struct hw_module_t* hw_module, const char* name, - struct hw_device_t** hw_device_out) { - ALOGV("open_sensors begin..."); - - lazy_init_modules(); - - // Create proxy device, to return later. - sensors_poll_context_t *dev = new sensors_poll_context_t(); - memset(dev, 0, sizeof(sensors_poll_device_1_t)); - dev->proxy_device.common.tag = HARDWARE_DEVICE_TAG; - dev->proxy_device.common.version = SENSORS_DEVICE_API_VERSION_1_4; - dev->proxy_device.common.module = const_cast(hw_module); - dev->proxy_device.common.close = device__close; - dev->proxy_device.activate = device__activate; - dev->proxy_device.setDelay = device__setDelay; - dev->proxy_device.poll = device__poll; - dev->proxy_device.batch = device__batch; - dev->proxy_device.flush = device__flush; - dev->proxy_device.inject_sensor_data = device__inject_sensor_data; - dev->proxy_device.register_direct_channel = device__register_direct_channel; - dev->proxy_device.config_direct_report = device__config_direct_report; - - dev->nextReadIndex = 0; - - // Open() the subhal modules. Remember their devices in a vector parallel to sub_hw_modules. - for (std::vector::iterator it = sub_hw_modules->begin(); - it != sub_hw_modules->end(); it++) { - sensors_module_t *sensors_module = (sensors_module_t*) *it; - struct hw_device_t* sub_hw_device; - int sub_open_result = sensors_module->common.methods->open(*it, name, &sub_hw_device); - if (!sub_open_result) { - if (!HAL_VERSION_IS_COMPLIANT(sub_hw_device->version)) { - ALOGE("SENSORS_DEVICE_API_VERSION_1_3 or newer is required for all sensor HALs"); - ALOGE("This HAL reports non-compliant API level : %s", - apiNumToStr(sub_hw_device->version)); - ALOGE("Sensors belonging to this HAL will get ignored !"); - } - dev->addSubHwDevice(sub_hw_device); - } - } - - // Prepare the output param and return - *hw_device_out = &dev->proxy_device.common; - ALOGV("...open_sensors end"); - return 0; -} diff --git a/sensors/multihal.h b/sensors/multihal.h deleted file mode 100644 index e4fbe7e..0000000 --- a/sensors/multihal.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef HARDWARE_LIBHARDWARE_MODULES_SENSORS_MULTIHAL_H_ -#define HARDWARE_LIBHARDWARE_MODULES_SENSORS_MULTIHAL_H_ - -#include -#include - -static const char* MULTI_HAL_CONFIG_FILE_PATH = "/vendor/etc/sensors/_hals.conf"; - -// Depracated because system partition HAL config file does not satisfy treble requirements. -static const char* DEPRECATED_MULTI_HAL_CONFIG_FILE_PATH = "/system/etc/sensors/_hals.conf"; - -struct sensors_module_t *get_multi_hal_module_info(void); - -#endif // HARDWARE_LIBHARDWARE_MODULES_SENSORS_MULTIHAL_H_ diff --git a/sensors/service.cpp b/sensors/service.cpp deleted file mode 100644 index 72f32fd..0000000 --- a/sensors/service.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "android.hardware.sensors@1.0-service" - -#include -#include -#ifdef ARCH_ARM_32 -#include -#endif - -using android::hardware::sensors::V1_0::ISensors; -using android::hardware::defaultPassthroughServiceImplementation; - -int main() { -#ifdef ARCH_ARM_32 - android::hardware::ProcessState::initWithMmapSize((size_t)8192); -#endif - /* Sensors framework service needs at least two threads. - * One thread blocks on a "poll" - * The second thread is needed for all other HAL methods. - */ - return defaultPassthroughServiceImplementation(2); -} diff --git a/sepolicy/common/add.te b/sepolicy/common/add.te deleted file mode 100755 index 3456502..0000000 --- a/sepolicy/common/add.te +++ /dev/null @@ -1,27 +0,0 @@ -#============= fsck ============== -allow fsck self:capability dac_override; - -#============= init ============== -allow init shell_exec:file execute_no_trans; -allow init sysfs:file setattr; - -#============= shell ============== -allow shell kernel:system syslog_read; - -#============= system_app ============== -allow system_app proc_pagetypeinfo:file { getattr open read }; - -#============= webview_zygote ============== -allow webview_zygote zygote:unix_dgram_socket write; - -#============= zygote ============== -allow zygote proc_cmdline:file { open read getattr }; - -#============= hal_sensors_default ============== -allow hal_sensors_default sysfs:file { open read write getattr }; - -#============= mediaserver ============== -allow mediaserver hal_lineage_camera_motor_hwservice:hwservice_manager find; - -#============= wcnss_service ============== -allow wcnss_service wifi_efs_file:file { open read getattr }; diff --git a/sepolicy/common/add1.te b/sepolicy/common/add1.te deleted file mode 100755 index f981d08..0000000 --- a/sepolicy/common/add1.te +++ /dev/null @@ -1,10 +0,0 @@ -#============= priv_app ============== -allow priv_app sysfs:file { open read }; - -#============= qti_init_shell ============== -allow qti_init_shell bluetooth_efs_file:dir search; -allow qti_init_shell bluetooth_efs_file:file { open read }; -allow qti_init_shell toolbox_exec:file getattr; - -#============= system_server ============== -allow system_server dalvikcache_data_file:file execute; diff --git a/sepolicy/common/device.te b/sepolicy/common/device.te deleted file mode 100755 index d358529..0000000 --- a/sepolicy/common/device.te +++ /dev/null @@ -1 +0,0 @@ -type rfkill_device, dev_type; diff --git a/sepolicy/common/file.te b/sepolicy/common/file.te new file mode 100644 index 0000000..3afd706 --- /dev/null +++ b/sepolicy/common/file.te @@ -0,0 +1 @@ +type mediadrm_vendor_data_file, file_type, data_file_type; diff --git a/sepolicy/common/file_contexts b/sepolicy/common/file_contexts old mode 100755 new mode 100644 index c8ef21f..92197da --- a/sepolicy/common/file_contexts +++ b/sepolicy/common/file_contexts @@ -1,4 +1,6 @@ -# sysfs -/sys/devices(/.*)?/input/input[1-2]/enabled u:object_r:sysfs_hal_pwr:s0 +# rootfs +/misc u:object_r:misc_block_device:s0 -/sys/class/rfkill/rfkill0(/.*)? u:object_r:sysfs_bluetooth_writable:s0 +# DRM +/(vendor|system/vendor)/bin/hw/android\.hardware\.drm@1\.3-service\.clearkey u:object_r:hal_drm_clearkey_exec:s0 +/data/vendor/mediadrm(/.*)? u:object_r:mediadrm_vendor_data_file:s0 diff --git a/sepolicy/common/hal_bluetooth_default.te b/sepolicy/common/hal_bluetooth_default.te deleted file mode 100755 index f53cdfd..0000000 --- a/sepolicy/common/hal_bluetooth_default.te +++ /dev/null @@ -1,7 +0,0 @@ -allow hal_bluetooth_default bluetooth_data_file:file r_file_perms; -allow hal_bluetooth_default bluetooth_data_file:dir { search }; -r_dir_file(hal_bluetooth_default, firmware_file) - -# Write to /sys/class/rfkill/rfkill0/state -allow hal_bluetooth_default sysfs:file rw_file_perms; -allow bluetooth sysfs:file rw_file_perms; diff --git a/sepolicy/common/hal_drm_clearkey.te b/sepolicy/common/hal_drm_clearkey.te new file mode 100644 index 0000000..106ebb9 --- /dev/null +++ b/sepolicy/common/hal_drm_clearkey.te @@ -0,0 +1,13 @@ +type hal_drm_clearkey, domain; +type hal_drm_clearkey_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(hal_drm_clearkey) + +vndbinder_use(hal_drm_clearkey); + +hal_server_domain(hal_drm_clearkey, hal_drm) + +allow hal_drm_clearkey mediadrm_vendor_data_file:dir create_dir_perms; +allow hal_drm_clearkey mediadrm_vendor_data_file:file create_file_perms; + +allow hal_drm_clearkey { appdomain -isolated_app }:fd use; diff --git a/sepolicy/common/hal_power_default.te b/sepolicy/common/hal_power_default.te deleted file mode 100755 index b7ed43c..0000000 --- a/sepolicy/common/hal_power_default.te +++ /dev/null @@ -1,3 +0,0 @@ -allow hal_power_default sysfs:file write; -allow hal_power_default sysfs_input:dir search; -allow hal_power_default sysfs_input:file { write open }; diff --git a/sepolicy/common/hal_sensors_default.te b/sepolicy/common/hal_sensors_default.te deleted file mode 100755 index 2fbe2bb..0000000 --- a/sepolicy/common/hal_sensors_default.te +++ /dev/null @@ -1,2 +0,0 @@ -allow hal_sensors_default system_data_file:dir { write add_name }; -allow hal_sensors_default system_data_file:file { create open write getattr }; diff --git a/sepolicy/common/hal_wifi_default.te b/sepolicy/common/hal_wifi_default.te deleted file mode 100755 index c0382ed..0000000 --- a/sepolicy/common/hal_wifi_default.te +++ /dev/null @@ -1,2 +0,0 @@ -r_dir_file(hal_wifi_default, firmware_file) -r_dir_file(hal_wifi_default, wifi_data_file) \ No newline at end of file diff --git a/sepolicy/common/hal_wifi_hostapd_default.te b/sepolicy/common/hal_wifi_hostapd_default.te deleted file mode 100755 index 37fa24b..0000000 --- a/sepolicy/common/hal_wifi_hostapd_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_wifi_hostapd_default rfkill_device:chr_file {r_file_perms}; diff --git a/sepolicy/common/hal_wifi_supplicant_default.te b/sepolicy/common/hal_wifi_supplicant_default.te deleted file mode 100755 index c679ba5..0000000 --- a/sepolicy/common/hal_wifi_supplicant_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_wifi_supplicant_default rfkill_device:chr_file r_file_perms; diff --git a/sepolicy/common/hostapd.te b/sepolicy/common/hostapd.te deleted file mode 100755 index 463eb2e..0000000 --- a/sepolicy/common/hostapd.te +++ /dev/null @@ -1 +0,0 @@ -allow hostapd rfkill_device:chr_file r_file_perms; diff --git a/sepolicy/common/init.te b/sepolicy/common/init.te deleted file mode 100755 index 89d78e8..0000000 --- a/sepolicy/common/init.te +++ /dev/null @@ -1 +0,0 @@ -allow init system_file:dir relabelfrom; diff --git a/sepolicy/common/kernel.te b/sepolicy/common/kernel.te deleted file mode 100755 index 8bef3be..0000000 --- a/sepolicy/common/kernel.te +++ /dev/null @@ -1 +0,0 @@ -allow kernel sensors_persist_file:dir search; diff --git a/sepolicy/common/priv_app.te b/sepolicy/common/priv_app.te deleted file mode 100755 index d4f095a..0000000 --- a/sepolicy/common/priv_app.te +++ /dev/null @@ -1 +0,0 @@ -allow priv_app su_exec:file { read open }; diff --git a/sepolicy/common/qti_init_shell.te b/sepolicy/common/qti_init_shell.te deleted file mode 100755 index 49b3ce4..0000000 --- a/sepolicy/common/qti_init_shell.te +++ /dev/null @@ -1,12 +0,0 @@ -allow qti_init_shell bluetooth_data_file:dir search; -allow qti_init_shell bluetooth_data_file:file r_file_perms; -allow qti_init_shell bluetooth_loader_exec:file rx_file_perms; -allow qti_init_shell hci_attach_dev:chr_file rw_file_perms; -allow qti_init_shell modem_block_device:blk_file r_file_perms; -allow qti_init_shell proc_net:dir { read open }; -allow qti_init_shell qmuxd:unix_stream_socket connectto; -allow qti_init_shell qmuxd_socket:dir w_dir_perms; -allow qti_init_shell qmuxd_socket:sock_file create_file_perms; -allow qti_init_shell qmuxd_socket:unix_stream_socket connectto; -allow qti_init_shell radio_prop:property_service set; -allow qti_init_shell diag_device:chr_file rw_file_perms; diff --git a/sepolicy/common_tmp/file.te b/sepolicy/common_tmp/file.te deleted file mode 100755 index 342fe3f..0000000 --- a/sepolicy/common_tmp/file.te +++ /dev/null @@ -1,2 +0,0 @@ -type firmware_file, file_type; -type persist_file, file_type; diff --git a/sepolicy/common_tmp/file_contexts b/sepolicy/common_tmp/file_contexts deleted file mode 100755 index 71f649f..0000000 --- a/sepolicy/common_tmp/file_contexts +++ /dev/null @@ -1,3 +0,0 @@ -/firmware(/.*)? u:object_r:firmware_file:s0 -/firmware-modem(/.*)? u:object_r:firmware_file:s0 -/misc(/.*)? u:object_r:persist_file:s0 diff --git a/sepolicy/sepolicy.mk b/sepolicy/sepolicy.mk index 2f3ca5e..406f636 100755 --- a/sepolicy/sepolicy.mk +++ b/sepolicy/sepolicy.mk @@ -21,4 +21,4 @@ # device/samsung/mondrianwifi/sepolicy/common BOARD_SEPOLICY_DIRS += \ - device/samsung/mondrianwifi/sepolicy/common_tmp \ No newline at end of file + device/samsung/mondrianwifi/sepolicy/common diff --git a/system.prop b/system.prop new file mode 100755 index 0000000..ba066e0 --- /dev/null +++ b/system.prop @@ -0,0 +1,66 @@ +# Art +dalvik.vm.dex2oat-swap=false + +# Audio +af.fast_track_multiplier=1 +audio.deep_buffer.media=true +audio.offload.buffer.size.kb=32 +audio.offload.pcm.16bit.enable=true +audio.offload.pcm.24bit.enable=true +audio.offload.video=true +persist.vendor.audio.fluence.speaker=true +persist.vendor.audio.fluence.voicecall=true +persist.vendor.audio.fluence.voicerec=false +ro.vendor.audio.sdk.fluencetype=fluence +vendor.audio.offload.multiple.enabled=false +vendor.audio_hal.period_size=192 +vendor.dedicated.device.for.voip=true +vendor.voice.path.for.pcm.voip=false + +# Bluetooth +vendor.qcom.bluetooth.soc=smd +ro.bt.bdaddr_path=/efs/bluetooth/bt_addr + +# Camera +camera2.portability.force_api=1 + +# Dalvik heap +dalvik.vm.heapstartsize=16m +dalvik.vm.heapgrowthlimit=192m +dalvik.vm.heapsize=512m +dalvik.vm.heaptargetutilization=0.75 +dalvik.vm.heapminfree=2m +dalvik.vm.heapmaxfree=8m + +# Display +debug.mdpcomp.logs=0 +persist.hwc.mdpcomp.enable=true +ro.sf.lcd_density=320 +lockscreen.rot_override=true + +# GPS +persist.gps.qc_nlp_in_use=0 +ro.gps.agps_provider=1 +ro.qc.sdk.izat.premium_enabled=0 +ro.qc.sdk.izat.service_mask=0x0 + +# Memory optimizations +ro.vendor.qti.am.reschedule_service=true + +# Perf +ro.vendor.extension_library=/vendor/lib/libqti-perfd-client.so + +# Radio +ro.radio.noril=yes + +# Sensors +debug.sensors=1 + +# Tethering +net.tethering.noprovisioning=true + +# Vendor security patch level +ro.lineage.build.vendor_security_patch=2016-05-01 + +# WiFi +wifi.interface=wlan0 diff --git a/system_prop.mk b/system_prop.mk deleted file mode 100755 index 6fc5fcc..0000000 --- a/system_prop.mk +++ /dev/null @@ -1,111 +0,0 @@ -# Memory optimizations -PRODUCT_PROPERTY_OVERRIDES += \ - ro.vendor.qti.am.reschedule_service=true \ - ro.vendor.qti.sys.fw.bservice_enable=true - -# Art -PRODUCT_PROPERTY_OVERRIDES += \ - dalvik.vm.dex2oat-swap=false - -# Low memory -#PRODUCT_PROPERTY_OVERRIDES += \ -# ro.config.low_ram=true - -# Audio -PRODUCT_PROPERTY_OVERRIDES += \ - af.fast_track_multiplier=1 \ - audio.deep_buffer.media=true \ - audio.offload.buffer.size.kb=32 \ - audio.offload.pcm.16bit.enable=true \ - audio.offload.pcm.24bit.enable=true \ - audio.offload.video=true \ - persist.vendor.audio.fluence.speaker=true \ - persist.vendor.audio.fluence.voicecall=true \ - persist.vendor.audio.fluence.voicerec=false \ - ro.vendor.audio.sdk.fluencetype=fluence \ - vendor.audio.offload.multiple.enabled=false \ - vendor.audio_hal.period_size=192 \ - vendor.dedicated.device.for.voip=true \ - vendor.voice.path.for.pcm.voip=false - -PRODUCT_PROPERTY_OVERRIDES += \ - audio.offload.gapless.enabled=false \ - av.offload.enable=true - -# Camera -PRODUCT_PROPERTY_OVERRIDES += \ - camera2.portability.force_api=1 - -# Dalvik heap -PRODUCT_PROPERTY_OVERRIDES += \ - dalvik.vm.heapstartsize=16m \ - dalvik.vm.heapgrowthlimit=192m \ - dalvik.vm.heapsize=512m \ - dalvik.vm.heaptargetutilization=0.75 \ - dalvik.vm.heapminfree=2m \ - dalvik.vm.heapmaxfree=8m - -# Limit dex2oat threads to improve thermals -PRODUCT_PROPERTY_OVERRIDES += \ - dalvik.vm.dex2oat-threads=2 \ - dalvik.vm.image-dex2oat-threads=2 - -# Bluetooth -PRODUCT_PROPERTY_OVERRIDES += \ - vendor.qcom.bluetooth.soc=smd \ - ro.bt.bdaddr_path=/efs/bluetooth/bt_addr - -# Display -PRODUCT_PROPERTY_OVERRIDES += \ - debug.sf.hw=1 \ - debug.mdpcomp.logs=0 \ - persist.hwc.mdpcomp.enable=true \ - ro.hdcp2.rx=tz \ - ro.qualcomm.cabl=1 \ - ro.secwvk=144 \ - ro.sf.lcd_density=320 \ - debug.hwui.use_buffer_age=false \ - ro.opengles.version=196608 \ - debug.sf.enable_gl_backpressure=1 \ - debug.sf.latch_unsignaled=1 - -PRODUCT_PROPERTY_OVERRIDES += \ - lockscreen.rot_override=true - -# GPS -PRODUCT_PROPERTY_OVERRIDES += \ - persist.gps.qc_nlp_in_use=0 \ - ro.gps.agps_provider=1 \ - ro.qc.sdk.izat.premium_enabled=0 \ - ro.qc.sdk.izat.service_mask=0x0 - -# Media -PRODUCT_PROPERTY_OVERRIDES += \ - persist.media.treble_omx=false - -# Disable more Codec2.0 components -PRODUCT_PROPERTY_OVERRIDES += \ - debug.stagefright.ccodec=0 - -# Perf -PRODUCT_PROPERTY_OVERRIDES += \ - ro.vendor.extension_library=/vendor/lib/libqti-perfd-client.so - -# Radio -PRODUCT_PROPERTY_OVERRIDES += \ - ro.radio.noril=yes - -# Sensors -PRODUCT_PROPERTY_OVERRIDES += \ - debug.sensors=1 - -# Tethering -PRODUCT_PROPERTY_OVERRIDES += \ - net.tethering.noprovisioning=true - -# WiFi -PRODUCT_PROPERTY_OVERRIDES += \ - wifi.interface=wlan0 - -PRODUCT_PROPERTY_OVERRIDES += \ - persist.timed.enable=true