summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.mk13
-rw-r--r--BoardConfigCommon.mk162
-rw-r--r--CleanSpec.mk63
-rw-r--r--README.md5
-rw-r--r--cm.dependencies26
-rw-r--r--cmhw/org/cyanogenmod/hardware/VibratorHW.java47
-rw-r--r--combinedroot/init.sh75
-rw-r--r--custombootimg.mk64
-rw-r--r--dumpstate/Android.mk26
-rw-r--r--dumpstate/NOTICE190
-rw-r--r--dumpstate/dumpstate.c28
-rwxr-xr-xextract-files.sh8
-rw-r--r--gps/Android.mk23
-rw-r--r--gps/CleanSpec.mk50
-rw-r--r--gps/core/Android.mk50
-rw-r--r--gps/core/ContextBase.cpp99
-rw-r--r--gps/core/ContextBase.h69
-rw-r--r--gps/core/LBSProxyBase.h60
-rw-r--r--gps/core/LocAdapterBase.cpp119
-rw-r--r--gps/core/LocAdapterBase.h104
-rw-r--r--gps/core/LocApiBase.cpp475
-rw-r--r--gps/core/LocApiBase.h219
-rw-r--r--gps/core/LocDualContext.cpp132
-rw-r--r--gps/core/LocDualContext.h72
-rw-r--r--gps/core/MsgTask.cpp133
-rw-r--r--gps/core/MsgTask.h66
-rw-r--r--gps/core/UlpProxyBase.h66
-rw-r--r--gps/core/gps_extended.h92
-rw-r--r--gps/core/gps_extended_c.h343
-rw-r--r--gps/core/loc_core_log.cpp257
-rw-r--r--gps/core/loc_core_log.h58
-rw-r--r--gps/flp.conf21
-rw-r--r--gps/gps.conf78
-rw-r--r--gps/izat.conf41
-rw-r--r--gps/libloc_api_50001/Android.mk101
-rw-r--r--gps/libloc_api_50001/LocEngAdapter.cpp297
-rw-r--r--gps/libloc_api_50001/LocEngAdapter.h299
-rw-r--r--gps/libloc_api_50001/Makefile.am76
-rw-r--r--gps/libloc_api_50001/gps.c72
-rw-r--r--gps/libloc_api_50001/loc.cpp907
-rw-r--r--gps/libloc_api_50001/loc.h64
-rw-r--r--gps/libloc_api_50001/loc_eng.cpp2599
-rw-r--r--gps/libloc_api_50001/loc_eng.h241
-rw-r--r--gps/libloc_api_50001/loc_eng_agps.cpp970
-rw-r--r--gps/libloc_api_50001/loc_eng_agps.h419
-rw-r--r--gps/libloc_api_50001/loc_eng_dmn_conn.cpp270
-rw-r--r--gps/libloc_api_50001/loc_eng_dmn_conn.h59
-rw-r--r--gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c223
-rw-r--r--gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h51
-rw-r--r--gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c214
-rw-r--r--gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h50
-rw-r--r--gps/libloc_api_50001/loc_eng_dmn_conn_handler.cpp237
-rw-r--r--gps/libloc_api_50001/loc_eng_dmn_conn_handler.h106
-rw-r--r--gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c399
-rw-r--r--gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h74
-rw-r--r--gps/libloc_api_50001/loc_eng_log.cpp35
-rw-r--r--gps/libloc_api_50001/loc_eng_log.h44
-rw-r--r--gps/libloc_api_50001/loc_eng_msg.h296
-rw-r--r--gps/libloc_api_50001/loc_eng_ni.cpp355
-rw-r--r--gps/libloc_api_50001/loc_eng_ni.h50
-rw-r--r--gps/libloc_api_50001/loc_eng_nmea.cpp833
-rw-r--r--gps/libloc_api_50001/loc_eng_nmea.h42
-rw-r--r--gps/libloc_api_50001/loc_eng_xtra.cpp167
-rw-r--r--gps/libloc_api_50001/loc_eng_xtra.h47
-rw-r--r--gps/platform_lib_abstractions/elapsed_millis_since_boot.cpp46
-rw-r--r--gps/platform_lib_abstractions/platform_lib_includes.h35
-rw-r--r--gps/platform_lib_abstractions/platform_lib_macros.h81
-rw-r--r--gps/platform_lib_abstractions/platform_lib_time.h35
-rw-r--r--gps/sap.conf41
-rw-r--r--gps/utils/Android.mk56
-rw-r--r--gps/utils/Makefile.am44
-rw-r--r--gps/utils/linked_list.c328
-rw-r--r--gps/utils/linked_list.h217
-rw-r--r--gps/utils/loc_cfg.cpp286
-rw-r--r--gps/utils/loc_cfg.h83
-rw-r--r--gps/utils/loc_log.cpp234
-rw-r--r--gps/utils/loc_log.h68
-rw-r--r--gps/utils/loc_target.cpp208
-rw-r--r--gps/utils/loc_target.h68
-rw-r--r--gps/utils/loc_timer.c186
-rw-r--r--gps/utils/loc_timer.h63
-rw-r--r--gps/utils/log_util.h171
-rw-r--r--gps/utils/msg_q.c336
-rw-r--r--gps/utils/msg_q.h207
-rw-r--r--include/device_perms.h27
-rw-r--r--include/private/android_filesystem_capability.h117
-rw-r--r--include/private/android_filesystem_config.h351
-rw-r--r--include/telephony/ril.h4531
-rw-r--r--init/Android.mk13
-rw-r--r--init/init_shinano.c51
-rw-r--r--overlay-radio/frameworks/base/core/res/res/values/config.xml84
-rw-r--r--overlay-radio/frameworks/base/packages/SystemUI/res/values/config.xml33
-rw-r--r--overlay-radio/packages/services/Telephony/res/values/config.xml30
-rw-r--r--overlay/frameworks/base/core/res/res/values/config.xml170
-rw-r--r--overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml21
-rw-r--r--overlay/packages/apps/Camera2/res/values/config.xml22
-rw-r--r--proprietary-files.txt438
-rw-r--r--radio.mk24
-rw-r--r--recovery/Android.mk13
-rw-r--r--recovery/D6x02.sh11
-rw-r--r--recovery/postrecoveryboot.sh1
-rw-r--r--recovery/twrpgraphics.c732
-rw-r--r--releasetools.py28
-rw-r--r--rootdir/chargerbin0 -> 263944 bytes
-rw-r--r--rootdir/fstab.qcom16
-rw-r--r--rootdir/init.qcom.rc795
-rw-r--r--rootdir/init.recovery.qcom.rc13
-rw-r--r--rootdir/sbin/tad_staticbin0 -> 79256 bytes
-rw-r--r--rootdir/sbin/wait4tad_staticbin0 -> 66968 bytes
-rw-r--r--rootdir/system/etc/firmware/wlan/prima/WCNSS_cfg.datbin0 -> 10746 bytes
-rw-r--r--rootdir/system/etc/firmware/wlan/prima/WCNSS_qcom_cfg.ini371
-rw-r--r--rootdir/system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.binbin0 -> 29816 bytes
-rw-r--r--rootdir/system/etc/gps.conf75
-rw-r--r--rootdir/system/etc/init.qcom.bt.sh83
-rw-r--r--rootdir/system/etc/init.qcom.fm.sh106
-rw-r--r--rootdir/system/etc/init.qcom.wifi.sh16
-rw-r--r--rootdir/system/etc/nfcee_access.xml14
-rw-r--r--rootdir/system/etc/nfcee_access_debug.xml17
-rw-r--r--rootdir/system/etc/wifi/p2p_supplicant_overlay.conf1
-rw-r--r--rootdir/system/etc/wifi/wpa_supplicant_overlay.conf1
-rw-r--r--rootdir/system/lib/egl/egl.cfg2
-rw-r--r--rootdir/ueventd.qcom.rc158
-rw-r--r--sepolicy/app.te3
-rw-r--r--sepolicy/device.te2
-rw-r--r--sepolicy/file_contexts2
-rw-r--r--shinano.mk251
126 files changed, 24347 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..d8bc40d
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+
+ifeq ($(BOARD_VENDOR_PLATFORM),shinano)
+ include $(call all-subdir-makefiles,$(LOCAL_PATH))
+
+ $(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/wcd9320_mad_audio.bin \
+ $(TARGET_OUT_ETC)/firmware/wcd9320/wcd9320_mad_audio.bin; \
+ ln -sf /data/misc/audio/mbhc.bin \
+ $(TARGET_OUT_ETC)/firmware/wcd9320/wcd9320_mbhc.bin)
+endif
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
new file mode 100644
index 0000000..d734bb5
--- /dev/null
+++ b/BoardConfigCommon.mk
@@ -0,0 +1,162 @@
+# Copyright (C) 2013 The CyanogenMod 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.
+
+# inherit from Sony common
+include device/sony/common/BoardConfigCommon.mk
+
+BOARD_EGL_CFG := device/sony/shinano-common/rootdir/system/lib/egl/egl.cfg
+
+# inherit from qcom-common
+include device/sony/qcom-common/BoardConfigCommon.mk
+
+TARGET_SPECIFIC_HEADER_PATH := device/sony/shinano-common/include
+
+# Kernel properties
+TARGET_KERNEL_SOURCE := kernel/sony/msm8974
+
+# Platform
+TARGET_BOOTLOADER_BOARD_NAME := MSM8974
+TARGET_BOARD_PLATFORM := msm8974
+BOARD_VENDOR_PLATFORM := shinano
+
+# Architecture
+TARGET_ARCH_VARIANT_CPU := cortex-a9
+TARGET_CPU_VARIANT := krait
+
+# Flags
+COMMON_GLOBAL_CFLAGS += -D__ARM_USE_PLD -D__ARM_CACHE_LINE_SIZE=64
+
+# Krait optimizations
+TARGET_USE_KRAIT_BIONIC_OPTIMIZATION := true
+
+# Kernel information
+BOARD_KERNEL_BASE := 0x00000000
+BOARD_KERNEL_PAGESIZE := 2048
+BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 msm_rtb.enable=0 lpj=192598 dwc3.maximum_speed=high dwc3_msm.prop_chg_detect=Y
+BOARD_MKBOOTIMG_ARGS := --ramdisk_offset 0x02000000 --tags_offset 0x01E00000
+BOARD_CUSTOM_BOOTIMG_MK := device/sony/shinano-common/custombootimg.mk
+BOARD_KERNEL_SEPARATED_DT := true
+
+# Qualcomm
+BOARD_USES_QCOM_HARDWARE := true
+BOARD_USES_QC_TIME_SERVICES := true
+TARGET_USES_QCOM_BSP := true
+TARGET_ENABLE_QC_AV_ENHANCEMENTS := true
+TARGET_QCOM_AUDIO_VARIANT := caf
+TARGET_QCOM_DISPLAY_VARIANT := caf-new
+TARGET_QCOM_MEDIA_VARIANT := caf-new
+
+# Audio
+BOARD_USES_ALSA_AUDIO := true
+AUDIO_FEATURE_DISABLED_USBAUDIO := true
+
+# Bluetooth
+BOARD_HAVE_BLUETOOTH := true
+BOARD_HAVE_BLUETOOTH_QCOM := true
+BLUETOOTH_HCI_USE_MCT := true
+
+# Camera
+COMMON_GLOBAL_CFLAGS += -DNEEDS_VECTORIMPL_SYMBOLS
+BOARD_CAMERA_HAVE_ISO := true
+USE_DEVICE_SPECIFIC_CAMERA := true
+
+# Charger
+BOARD_CHARGER_ENABLE_SUSPEND := true
+
+# CM Hardware
+BOARD_HARDWARE_CLASS := device/sony/shinano-common/cmhw
+
+# Dumpstate
+BOARD_LIB_DUMPSTATE := libdumpstate.sony
+
+# GPS
+TARGET_PROVIDES_GPS_LOC_API := true
+
+# Graphics
+NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3
+OVERRIDE_RS_DRIVER := libRSDriver_adreno.so
+
+# Shader cache config options
+# Maximum size of the GLES Shaders that can be cached for reuse.
+# Increase the size if shaders of size greater than 12KB are used.
+MAX_EGL_CACHE_KEY_SIZE := 12*1024
+
+# Maximum GLES shader cache size for each app to store the compiled shader
+# binaries. Decrease the size if RAM or Flash Storage size is a limitation
+# of the device.
+MAX_EGL_CACHE_SIZE := 2048*1024
+
+# Init
+TARGET_INIT_VENDOR_LIB := libinit_shinano
+
+# SELinux
+BOARD_SEPOLICY_DIRS += \
+ device/sony/shinano-common/sepolicy
+
+# The list below is order dependent
+BOARD_SEPOLICY_UNION := \
+ device.te \
+ app.te \
+ file_contexts
+
+# Wifi
+BOARD_HAS_QCOM_WLAN := true
+BOARD_WLAN_DEVICE := qcwcn
+WPA_SUPPLICANT_VERSION := VER_0_8_X
+BOARD_WPA_SUPPLICANT_DRIVER := NL80211
+BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)
+BOARD_HOSTAPD_DRIVER := NL80211
+BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)
+WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/wlan.ko"
+WIFI_DRIVER_MODULE_NAME := "wlan"
+WIFI_DRIVER_FW_PATH_STA := "sta"
+WIFI_DRIVER_FW_PATH_AP := "ap"
+
+BOARD_USE_SONY_MACUPDATE := true
+
+# Filesystem
+BOARD_FLASH_BLOCK_SIZE := 131072
+TARGET_USERIMAGES_USE_EXT4 := true
+
+# Recovery
+TARGET_RECOVERY_FSTAB := device/sony/shinano-common/rootdir/fstab.qcom
+TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
+BOARD_HAS_NO_SELECT_BUTTON := true
+BOARD_USE_CUSTOM_RECOVERY_FONT := \"roboto_23x41.h\"
+
+# TWRP flags
+DEVICE_RESOLUTION := 1080x1920
+RECOVERY_GRAPHICS_USE_LINELENGTH := true
+RECOVERY_SDCARD_ON_DATA := true
+TW_HAS_NO_RECOVERY_PARTITION := true
+TW_FLASH_FROM_STORAGE := true
+TW_EXTERNAL_STORAGE_PATH := "/external_sd"
+TW_EXTERNAL_STORAGE_MOUNT_POINT := "external_sd"
+TW_DEFAULT_EXTERNAL_STORAGE := true
+# TW_INCLUDE_CRYPTO := true
+TW_INCLUDE_JB_CRYPTO := true
+TW_CRYPTO_FS_TYPE := "ext4"
+TW_CRYPTO_REAL_BLKDEV := "/dev/block/platform/msm_sdcc.1/by-name/userdata"
+TW_CRYPTO_MNT_POINT := "/data"
+TW_CRYPTO_FS_OPTIONS := "nosuid,nodev,barrier=1,noauto_da_alloc,discard"
+TW_CRYPTO_FS_FLAGS := "0x00000406"
+TW_CRYPTO_KEY_LOC := "footer"
+TW_INCLUDE_FUSE_EXFAT := true
+TW_BOARD_CUSTOM_GRAPHICS := ../../../device/sony/shinano-common/recovery/twrpgraphics.c
+TW_BRIGHTNESS_PATH := /sys/class/leds/wled:backlight/brightness
+TW_MAX_BRIGHTNESS := 4095
+TW_NO_USB_STORAGE := true
+
+# Releasetools
+TARGET_RELEASETOOLS_EXTENSIONS := device/sony/shinano-common
diff --git a/CleanSpec.mk b/CleanSpec.mk
new file mode 100644
index 0000000..1b3e6f7
--- /dev/null
+++ b/CleanSpec.mk
@@ -0,0 +1,63 @@
+# Copyright (C) 2012 The Android Open Source Project
+# Copyright (C) 2013 The CyanogenMod 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.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list. These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list. E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/vold.fstab)
+$(call add-clean-step, find $(OUT_DIR) -name "lights.msm8960*" -print0 | xargs -0 rm -f)
+$(call add-clean-step, find $(OUT_DIR) -name "*.default.*so" -print0 | xargs -0 rm -f)
+$(call add-clean-step, find $(PRODUCT_OUT) -name "*.prop" -print0 | xargs -0 rm -f)
+$(call add-clean-step, find $(OUT_DIR) -name "wpa_supplicant*" -print0 | xargs -0 rm -f)
+$(call add-clean-step, find $(PRODUCT_OUT) -name "*.img" -print0 | xargs -0 rm -f)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libhardware_legacy_intermediates/)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/modules/wlan.ko)
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/recovery/root/default.prop)
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/system/build.prop)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/combinedroot/init)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c466597
--- /dev/null
+++ b/README.md
@@ -0,0 +1,5 @@
+Copyright 2013 - The CyanogenMod Project
+
+android_device_sony_shinano-common
+================================
+
diff --git a/cm.dependencies b/cm.dependencies
new file mode 100644
index 0000000..5e67426
--- /dev/null
+++ b/cm.dependencies
@@ -0,0 +1,26 @@
+[
+ {
+ "repository": "android_kernel_sony_msm8974",
+ "target_path": "kernel/sony/msm8974"
+ },
+ {
+ "repository": "android_device_qcom_common",
+ "target_path": "device/qcom/common"
+ },
+ {
+ "repository": "android_device_sony_common",
+ "target_path": "device/sony/common"
+ },
+ {
+ "repository": "android_device_sony_qcom-common",
+ "target_path": "device/sony/qcom-common"
+ },
+ {
+ "repository": "android_hardware_qcom_display-caf-new",
+ "target_path": "hardware/qcom/display-caf-new"
+ },
+ {
+ "repository": "android_hardware_qcom_media-caf-new",
+ "target_path": "hardware/qcom/media-caf-new"
+ }
+]
diff --git a/cmhw/org/cyanogenmod/hardware/VibratorHW.java b/cmhw/org/cyanogenmod/hardware/VibratorHW.java
new file mode 100644
index 0000000..8e26bd1
--- /dev/null
+++ b/cmhw/org/cyanogenmod/hardware/VibratorHW.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2013 The CyanogenMod 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.
+ */
+
+package org.cyanogenmod.hardware;
+
+import org.cyanogenmod.hardware.util.FileUtils;
+
+public class VibratorHW {
+
+ private static String LEVEL_PATH = "/sys/devices/virtual/timed_output/vibrator/vtg_level";
+
+ public static boolean isSupported() {
+ return true;
+ }
+
+ public static int getMaxIntensity() {
+ return 31;
+ }
+ public static int getMinIntensity() {
+ return 21;
+ }
+ public static int getWarningThreshold() {
+ return 30;
+ }
+ public static int getCurIntensity() {
+ return Integer.parseInt(FileUtils.readOneLine(LEVEL_PATH));
+ }
+ public static int getDefaultIntensity() {
+ return 29;
+ }
+ public static boolean setIntensity(int intensity) {
+ return FileUtils.writeLine(LEVEL_PATH, String.valueOf(intensity));
+ }
+}
diff --git a/combinedroot/init.sh b/combinedroot/init.sh
new file mode 100644
index 0000000..0fc3a0f
--- /dev/null
+++ b/combinedroot/init.sh
@@ -0,0 +1,75 @@
+#!/sbin/busybox sh
+set +x
+_PATH="$PATH"
+export PATH=/sbin
+
+busybox cd /
+busybox date >>boot.txt
+exec >>boot.txt 2>&1
+busybox rm /init
+
+# include device specific vars
+source /sbin/bootrec-device
+
+# create directories
+busybox mkdir -m 755 -p /dev/block
+busybox mkdir -m 755 -p /dev/input
+busybox mkdir -m 555 -p /proc
+busybox mkdir -m 755 -p /sys
+
+# create device nodes
+busybox mknod -m 600 /dev/block/mmcblk0 b 179 0
+busybox mknod -m 600 ${BOOTREC_EVENT_NODE}
+busybox mknod -m 666 /dev/null c 1 3
+
+# mount filesystems
+busybox mount -t proc proc /proc
+busybox mount -t sysfs sysfs /sys
+
+# trigger amber LED
+busybox echo 255 > ${BOOTREC_LED_RED}
+busybox echo 0 > ${BOOTREC_LED_GREEN}
+busybox echo 255 > ${BOOTREC_LED_BLUE}
+
+# keycheck
+busybox cat ${BOOTREC_EVENT} > /dev/keycheck&
+busybox sleep 3
+
+# android ramdisk
+load_image=/sbin/ramdisk.cpio
+
+# boot decision
+if [ -s /dev/keycheck ] || busybox grep -q warmboot=0x77665502 /proc/cmdline ; then
+ busybox echo 'RECOVERY BOOT' >>boot.txt
+ # orange led for recoveryboot
+ busybox echo 255 > ${BOOTREC_LED_RED}
+ busybox echo 100 > ${BOOTREC_LED_GREEN}
+ busybox echo 0 > ${BOOTREC_LED_BLUE}
+ # recovery ramdisk
+ busybox mknod -m 600 ${BOOTREC_FOTA_NODE}
+ busybox mount -o remount,rw /
+ busybox ln -sf /sbin/busybox /sbin/sh
+ extract_elf_ramdisk -i ${BOOTREC_FOTA} -o /sbin/ramdisk-recovery.cpio -t / -c
+ busybox rm /sbin/sh
+ load_image=/sbin/ramdisk-recovery.cpio
+else
+ busybox echo 'ANDROID BOOT' >>boot.txt
+ # poweroff LED
+ busybox echo 0 > ${BOOTREC_LED_RED}
+ busybox echo 0 > ${BOOTREC_LED_GREEN}
+ busybox echo 0 > ${BOOTREC_LED_BLUE}
+fi
+
+# kill the keycheck process
+busybox pkill -f "busybox cat ${BOOTREC_EVENT}"
+
+# unpack the ramdisk image
+busybox cpio -i < ${load_image}
+
+busybox umount /proc
+busybox umount /sys
+
+busybox rm -fr /dev/*
+busybox date >>boot.txt
+export PATH="${_PATH}"
+exec /init
diff --git a/custombootimg.mk b/custombootimg.mk
new file mode 100644
index 0000000..3b623b9
--- /dev/null
+++ b/custombootimg.mk
@@ -0,0 +1,64 @@
+LOCAL_PATH := $(call my-dir)
+
+uncompressed_ramdisk := $(PRODUCT_OUT)/ramdisk.cpio
+$(uncompressed_ramdisk): $(INSTALLED_RAMDISK_TARGET)
+ zcat $< > $@
+
+INITSH := device/sony/shinano-common/combinedroot/init.sh
+BOOTREC_DEVICE := $(PRODUCT_OUT)/recovery/bootrec-device
+
+SOMC_BOARD = $(shell echo $(TARGET_KERNEL_CONFIG) | sed -e "s/cm_//" | sed -e "s/_defconfig//")
+KERNEL_CONFIG := $(KERNEL_OUT)/.config
+DTS_NAMES ?= msm8974
+DTS_FILES = $(wildcard $(TOP)/$(KERNEL_SRC)/arch/arm/boot/dts/$(DTS_NAME)*$(SOMC_BOARD).dts)
+DTS_FILE = $(lastword $(subst /, ,$(1)))
+DTB_FILE = $(addprefix $(KERNEL_OUT)/arch/arm/boot/,$(patsubst %.dts,%.dtb,$(call DTS_FILE,$(1))))
+ZIMG_FILE = $(addprefix $(KERNEL_OUT)/arch/arm/boot/,$(patsubst %.dts,%-zImage,$(call DTS_FILE,$(1))))
+KERNEL_ZIMG = $(KERNEL_OUT)/arch/arm/boot/zImage
+DTC = $(KERNEL_OUT)/scripts/dtc/dtc
+
+define append-dtb
+mkdir -p $(KERNEL_OUT)/arch/arm/boot;\
+$(foreach DTS_NAME, $(DTS_NAMES), \
+ $(foreach d, $(DTS_FILES), \
+ $(DTC) -p 1024 -O dtb -o $(call DTB_FILE,$(d)) $(d); \
+ cat $(KERNEL_ZIMG) $(call DTB_FILE,$(d)) > $(call ZIMG_FILE,$(d));))
+endef
+
+DTBTOOL := $(HOST_OUT_EXECUTABLES)/dtbToolCM$(HOST_EXECUTABLE_SUFFIX)
+INSTALLED_DTIMAGE_TARGET := $(PRODUCT_OUT)/dt.img
+
+INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
+$(INSTALLED_BOOTIMAGE_TARGET): $(PRODUCT_OUT)/kernel $(uncompressed_ramdisk) $(recovery_uncompressed_ramdisk) $(INSTALLED_RAMDISK_TARGET) $(INITSH) $(BOOTREC_DEVICE) $(PRODUCT_OUT)/utilities/busybox $(PRODUCT_OUT)/utilities/extract_elf_ramdisk $(MKBOOTIMG) $(MINIGZIP) $(INTERNAL_BOOTIMAGE_FILES) $(DTBTOOL)
+ $(call pretty,"Boot image: $@")
+
+ $(hide) rm -fr $(PRODUCT_OUT)/combinedroot
+ $(hide) mkdir -p $(PRODUCT_OUT)/combinedroot/sbin
+
+ $(hide) mv $(PRODUCT_OUT)/root/logo.rle $(PRODUCT_OUT)/combinedroot/logo.rle
+ $(hide) cp $(uncompressed_ramdisk) $(PRODUCT_OUT)/combinedroot/sbin/
+ $(hide) cp $(recovery_uncompressed_ramdisk) $(PRODUCT_OUT)/combinedroot/sbin/
+ $(hide) cp $(PRODUCT_OUT)/utilities/busybox $(PRODUCT_OUT)/combinedroot/sbin/
+ $(hide) cp $(PRODUCT_OUT)/utilities/extract_elf_ramdisk $(PRODUCT_OUT)/combinedroot/sbin/
+
+ $(hide) cp $(INITSH) $(PRODUCT_OUT)/combinedroot/sbin/init.sh
+ $(hide) chmod 755 $(PRODUCT_OUT)/combinedroot/sbin/init.sh
+ $(hide) ln -s sbin/init.sh $(PRODUCT_OUT)/combinedroot/init
+ $(hide) cp $(BOOTREC_DEVICE) $(PRODUCT_OUT)/combinedroot/sbin/
+
+ $(hide) $(MKBOOTFS) $(PRODUCT_OUT)/combinedroot/ > $(PRODUCT_OUT)/combinedroot.cpio
+ $(hide) cat $(PRODUCT_OUT)/combinedroot.cpio | gzip > $(PRODUCT_OUT)/combinedroot.fs
+
+ $(call append-dtb)
+ $(call pretty,"Target dt image: $(INSTALLED_DTIMAGE_TARGET)")
+ $(hide) $(DTBTOOL) -o $(INSTALLED_DTIMAGE_TARGET) -s $(BOARD_KERNEL_PAGESIZE) -p $(KERNEL_OUT)/scripts/dtc/ $(KERNEL_OUT)/arch/arm/boot/
+
+ $(hide) $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/kernel --ramdisk $(PRODUCT_OUT)/combinedroot.fs --cmdline "$(BOARD_KERNEL_CMDLINE)" --base $(BOARD_KERNEL_BASE) --pagesize $(BOARD_KERNEL_PAGESIZE) --dt $(INSTALLED_DTIMAGE_TARGET) $(BOARD_MKBOOTIMG_ARGS) -o $(INSTALLED_BOOTIMAGE_TARGET)
+
+INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
+$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTIMG) \
+ $(recovery_ramdisk) \
+ $(recovery_kernel)
+ @echo ----- Making recovery image ------
+ $(hide) $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/kernel --ramdisk $(PRODUCT_OUT)/ramdisk-recovery.img --cmdline "$(BOARD_KERNEL_CMDLINE)" --base $(BOARD_KERNEL_BASE) --pagesize $(BOARD_KERNEL_PAGESIZE) $(BOARD_MKBOOTIMG_ARGS) -o $(INSTALLED_RECOVERYIMAGE_TARGET)
+ @echo ----- Made recovery image -------- $@
diff --git a/dumpstate/Android.mk b/dumpstate/Android.mk
new file mode 100644
index 0000000..9c53292
--- /dev/null
+++ b/dumpstate/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2011 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_C_INCLUDES := frameworks/native/cmds/dumpstate
+
+LOCAL_SRC_FILES := dumpstate.c
+
+LOCAL_MODULE := libdumpstate.sony
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/dumpstate/NOTICE b/dumpstate/NOTICE
new file mode 100644
index 0000000..a303bd0
--- /dev/null
+++ b/dumpstate/NOTICE
@@ -0,0 +1,190 @@
+
+ Copyright (C) 2011 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.
+
+ 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.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
diff --git a/dumpstate/dumpstate.c b/dumpstate/dumpstate.c
new file mode 100644
index 0000000..a33cf47
--- /dev/null
+++ b/dumpstate/dumpstate.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright 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 <dumpstate.h>
+
+void dumpstate_board()
+{
+ dump_file("INTERRUPTS", "/proc/interrupts");
+ dump_file("Power Management Stats", "/proc/msm_pm_stats");
+ run_command("SUBSYSTEM TOMBSTONES", 5, SU_PATH, "root", "ls", "-l", "/data/tombstones/ramdump", NULL);
+ dump_file("BAM DMUX Log", "/d/ipc_logging/bam_dmux/log");
+ dump_file("SMD Log", "/d/ipc_logging/smd/log");
+ dump_file("SMD PKT Log", "/d/ipc_logging/smd_pkt/log");
+ dump_file("IPC Router Log", "/d/ipc_logging/ipc_router/log");
+};
diff --git a/extract-files.sh b/extract-files.sh
new file mode 100755
index 0000000..dfd4d18
--- /dev/null
+++ b/extract-files.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+export DEVICE=${PWD##*/}
+export BOARDCONFIGVENDOR=false
+
+../common/extract-files.sh $@
+
+../common/setup-makefiles.sh
diff --git a/gps/Android.mk b/gps/Android.mk
new file mode 100644
index 0000000..87fcdbb
--- /dev/null
+++ b/gps/Android.mk
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2013 The CyanogenMod 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)
+
+ifeq ($(BOARD_VENDOR),sony)
+ifeq ($(TARGET_BOARD_PLATFORM),msm8974)
+include $(call all-subdir-makefiles,$(LOCAL_PATH))
+endif
+endif
diff --git a/gps/CleanSpec.mk b/gps/CleanSpec.mk
new file mode 100644
index 0000000..dd1849d
--- /dev/null
+++ b/gps/CleanSpec.mk
@@ -0,0 +1,50 @@
+# Copyright (C) 2007 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.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list. These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list. E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libloc_api*)
diff --git a/gps/core/Android.mk b/gps/core/Android.mk
new file mode 100644
index 0000000..8bce28f
--- /dev/null
+++ b/gps/core/Android.mk
@@ -0,0 +1,50 @@
+ifneq ($(BUILD_TINY_ANDROID),true)
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libloc_core
+LOCAL_MODULE_OWNER := qcom
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SHARED_LIBRARIES := \
+ libutils \
+ libcutils \
+ libgps.utils \
+ libdl
+
+LOCAL_SRC_FILES += \
+ MsgTask.cpp \
+ 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
+
+LOCAL_COPY_HEADERS_TO:= libloc_core/
+LOCAL_COPY_HEADERS:= \
+ MsgTask.h \
+ LocApiBase.h \
+ LocAdapterBase.h \
+ ContextBase.h \
+ LocDualContext.h \
+ LBSProxyBase.h \
+ UlpProxyBase.h \
+ gps_extended_c.h \
+ gps_extended.h \
+ loc_core_log.h
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif # not BUILD_TINY_ANDROID
diff --git a/gps/core/ContextBase.cpp b/gps/core/ContextBase.cpp
new file mode 100644
index 0000000..1bd138e
--- /dev/null
+++ b/gps/core/ContextBase.cpp
@@ -0,0 +1,99 @@
+/* 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_CtxBase"
+
+#include <dlfcn.h>
+#include <cutils/sched_policy.h>
+#include <unistd.h>
+#include <ContextBase.h>
+#include <msg_q.h>
+#include <loc_target.h>
+#include <log_util.h>
+#include <loc_log.h>
+
+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))) {
+ // only RPC is the option now
+ void* handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW);
+ if (NULL != handle) {
+ getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi");
+ if (NULL != getter) {
+ locApi = (*getter)(mMsgTask, exMask);
+ }
+ }
+ }
+ }
+
+ // locApi could still be NULL at this time
+ // we would then create a dummy one
+ if (NULL == locApi) {
+ locApi = new LocApiBase(mMsgTask, exMask);
+ }
+
+ 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
new file mode 100644
index 0000000..85cbab7
--- /dev/null
+++ b/gps/core/ContextBase.h
@@ -0,0 +1,69 @@
+/* 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_CONTEXT_BASE__
+#define __LOC_CONTEXT_BASE__
+
+#include <stdbool.h>
+#include <ctype.h>
+#include <MsgTask.h>
+#include <LocApiBase.h>
+#include <LBSProxyBase.h>
+
+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 hasAgpsExt() { return mLBSProxy->hasAgpsExt(); }
+ inline bool hasCPIExt() { return mLBSProxy->hasCPIExt(); }
+ inline void requestUlp(LocAdapterBase* adapter,
+ unsigned long capabilities) {
+ mLBSProxy->requestUlp(adapter, capabilities);
+ }
+};
+
+} // namespace loc_core
+
+#endif //__LOC_CONTEXT_BASE__
diff --git a/gps/core/LBSProxyBase.h b/gps/core/LBSProxyBase.h
new file mode 100644
index 0000000..f0d1a32
--- /dev/null
+++ b/gps/core/LBSProxyBase.h
@@ -0,0 +1,60 @@
+/* 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 IZAT_PROXY_BASE_H
+#define IZAT_PROXY_BASE_H
+#include <gps_extended.h>
+#include <MsgTask.h>
+
+namespace loc_core {
+
+class LocApiBase;
+class LocAdapterBase;
+
+class LBSProxyBase {
+ friend class ContextBase;
+ inline virtual LocApiBase*
+ getLocApi(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask) const {
+ return NULL;
+ }
+protected:
+ inline LBSProxyBase() {}
+public:
+ inline virtual ~LBSProxyBase() {}
+ inline virtual void requestUlp(LocAdapterBase* adapter,
+ unsigned long capabilities) const {}
+ inline virtual bool hasAgpsExt() const { return false; }
+ inline virtual bool hasCPIExt() const { return false; }
+};
+
+typedef LBSProxyBase* (getLBSProxy_t)();
+
+} // namespace loc_core
+
+#endif // IZAT_PROXY_BASE_H
diff --git a/gps/core/LocAdapterBase.cpp b/gps/core/LocAdapterBase.cpp
new file mode 100644
index 0000000..8bbe873
--- /dev/null
+++ b/gps/core/LocAdapterBase.cpp
@@ -0,0 +1,119 @@
+/* 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_LocAdapterBase"
+
+#include <dlfcn.h>
+#include <LocAdapterBase.h>
+#include <loc_target.h>
+#include <log_util.h>
+
+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) :
+ mEvtMask(mask), mContext(context),
+ mLocApi(context->getLocApi()), mMsgTask(context->getMsgTask())
+{
+ mLocApi->addAdapter(this);
+}
+
+void LocAdapterBase::
+ handleEngineDownEvent()
+DEFAULT_IMPL()
+
+void LocAdapterBase::
+ reportPosition(UlpLocation &location,
+ GpsLocationExtended &locationExtended,
+ void* locationExt,
+ enum loc_sess_status status,
+ LocPosTechMask loc_technology_mask)
+DEFAULT_IMPL()
+
+void LocAdapterBase::
+ reportSv(GpsSvStatus &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 &notify, const void* data)
+DEFAULT_IMPL(false)
+} // namespace loc_core
diff --git a/gps/core/LocAdapterBase.h b/gps/core/LocAdapterBase.h
new file mode 100644
index 0000000..8222b24
--- /dev/null
+++ b/gps/core/LocAdapterBase.h
@@ -0,0 +1,104 @@
+/* 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_API_ADAPTER_BASE_H
+#define LOC_API_ADAPTER_BASE_H
+
+#include <gps_extended.h>
+#include <UlpProxyBase.h>
+#include <ContextBase.h>
+
+namespace loc_core {
+
+class LocAdapterBase {
+protected:
+ const LOC_API_ADAPTER_EVENT_MASK_T mEvtMask;
+ ContextBase* mContext;
+ LocApiBase* mLocApi;
+ const MsgTask* mMsgTask;
+
+ inline LocAdapterBase(const MsgTask* msgTask) :
+ mEvtMask(0), mContext(NULL), mLocApi(NULL), mMsgTask(msgTask) {}
+public:
+ inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
+ LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
+ ContextBase* context);
+ 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);
+ }
+
+ // This will be overridden by the individual adapters
+ // if necessary.
+ inline virtual void setUlpProxy(UlpProxyBase* ulp) {}
+ inline virtual void handleEngineUpEvent() {}
+ virtual void handleEngineDownEvent();
+ inline virtual void setPositionModeInt(LocPosMode& 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(GpsSvStatus &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 &notify,
+ const void* data);
+ inline virtual bool isInSession() { return false; }
+};
+
+} // namespace loc_core
+
+#endif //LOC_API_ADAPTER_BASE_H
diff --git a/gps/core/LocApiBase.cpp b/gps/core/LocApiBase.cpp
new file mode 100644
index 0000000..80e2375
--- /dev/null
+++ b/gps/core/LocApiBase.cpp
@@ -0,0 +1,475 @@
+/* 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_LocApiBase"
+
+#include <dlfcn.h>
+#include <LocApiBase.h>
+#include <LocAdapterBase.h>
+#include <log_util.h>
+
+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) :
+ mExcludedMask(excludedMask), mMsgTask(msgTask), mMask(0)
+{
+ 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::handleEngineUpEvent()
+{
+ // This will take care of renegotiating the loc handle
+ mMsgTask->sendMsg(new LocSsrMsg(this));
+
+ // 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)
+{
+ // loop through adapters, and deliver to all adapters.
+ TO_ALL_LOCADAPTERS(
+ mLocAdapters[i]->reportPosition(location,
+ locationExtended,
+ locationExt,
+ status,
+ loc_technology_mask)
+ );
+}
+
+void LocApiBase::reportSv(GpsSvStatus &svStatus,
+ GpsLocationExtended &locationExtended,
+ void* svExt)
+{
+ // 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 &notify, const void* data)
+{
+ // loop through adapters, and deliver to the first handling adapter.
+ TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotify(notify, data));
+}
+
+void* LocApiBase :: getSibling()
+ DEFAULT_IMPL(NULL)
+
+LocApiProxyBase* LocApiBase :: getLocApiProxy()
+ DEFAULT_IMPL(NULL)
+
+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)
+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::
+ getZppFix(GpsLocation & zppLoc)
+DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
+
+enum loc_api_adapter_err LocApiBase::
+ getZppFix(GpsLocation & zppLoc, LocPosTechMask & 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(unsigned int lock)
+DEFAULT_IMPL(-1)
+
+int LocApiBase::
+ getGpsLock()
+DEFAULT_IMPL(-1)
+} // namespace loc_core
diff --git a/gps/core/LocApiBase.h b/gps/core/LocApiBase.h
new file mode 100644
index 0000000..e162cfc
--- /dev/null
+++ b/gps/core/LocApiBase.h
@@ -0,0 +1,219 @@
+/* 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_API_BASE_H
+#define LOC_API_BASE_H
+
+#include <stddef.h>
+#include <ctype.h>
+#include <gps_extended.h>
+#include <MsgTask.h>
+#include <log_util.h>
+
+namespace loc_core {
+
+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 <MAX_ADAPTERS && NULL != (adapters)[i] && !(call); i++);
+
+class LocAdapterBase;
+struct LocSsrMsg;
+struct LocOpenMsg;
+
+class LocApiProxyBase {
+public:
+ inline LocApiProxyBase() {}
+ inline virtual ~LocApiProxyBase() {}
+ inline virtual void* getSibling2() { return NULL; }
+};
+
+class LocApiBase {
+ friend struct LocSsrMsg;
+ //LocOpenMsg calls open() which makes it necessary to declare
+ //it as a friend
+ friend struct LocOpenMsg;
+ friend class ContextBase;
+ const MsgTask* mMsgTask;
+
+ LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
+
+protected:
+ virtual enum loc_api_adapter_err
+ open(LOC_API_ADAPTER_EVENT_MASK_T mask);
+ virtual enum loc_api_adapter_err
+ close();
+ LOC_API_ADAPTER_EVENT_MASK_T getEvtMask();
+ LOC_API_ADAPTER_EVENT_MASK_T mMask;
+ LocApiBase(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T excludedMask);
+ inline virtual ~LocApiBase() { close(); }
+ bool isInSession();
+ const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
+
+public:
+ 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(GpsSvStatus &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 &notify, const void* data);
+
+ // 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);
+ 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
+ getZppFix(GpsLocation & zppLoc);
+ virtual enum loc_api_adapter_err
+ getZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask);
+ virtual int initDataServiceClient();
+ virtual int openAndStartDataCall();
+ virtual void stopDataCall();
+ virtual void closeDataCall();
+
+ inline virtual void setInSession(bool inSession) {}
+
+ /*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(unsigned int lock);
+ /*
+ Returns
+ Current value of GPS Lock on success
+ -1 on failure
+ */
+ virtual int getGpsLock(void);
+};
+
+typedef LocApiBase* (getLocApi_t)(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask);
+
+} // namespace loc_core
+
+#endif //LOC_API_BASE_H
diff --git a/gps/core/LocDualContext.cpp b/gps/core/LocDualContext.cpp
new file mode 100644
index 0000000..86c3613
--- /dev/null
+++ b/gps/core/LocDualContext.cpp
@@ -0,0 +1,132 @@
+/* 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_DualCtx"
+
+#include <cutils/sched_policy.h>
+#include <unistd.h>
+#include <LocDualContext.h>
+#include <msg_q.h>
+#include <log_util.h>
+#include <loc_log.h>
+
+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);
+
+const MsgTask* LocDualContext::mMsgTask = NULL;
+ContextBase* LocDualContext::mFgContext = NULL;
+ContextBase* LocDualContext::mBgContext = NULL;
+
+// the name must be shorter than 15 chars
+const char* LocDualContext::mLocationHalName = "Loc_hal_worker";
+const char* LocDualContext::mIzatLibName = "liblbs_core.so";
+
+const MsgTask* LocDualContext::getMsgTask(MsgTask::tCreate tCreator,
+ const char* name)
+{
+ if (NULL == mMsgTask) {
+ mMsgTask = new MsgTask(tCreator, name);
+ }
+ return mMsgTask;
+}
+
+const MsgTask* LocDualContext::getMsgTask(MsgTask::tAssociate tAssociate,
+ const char* name)
+{
+ if (NULL == mMsgTask) {
+ mMsgTask = new MsgTask(tAssociate, name);
+ }
+ return mMsgTask;
+}
+
+ContextBase* LocDualContext::getLocFgContext(MsgTask::tCreate tCreator,
+ const char* name)
+{
+ if (NULL == mFgContext) {
+ const MsgTask* msgTask = getMsgTask(tCreator, name);
+ mFgContext = new LocDualContext(msgTask,
+ mFgExclMask);
+ }
+ return mFgContext;
+}
+
+ContextBase* LocDualContext::getLocFgContext(MsgTask::tAssociate tAssociate,
+ const char* name)
+{
+ if (NULL == mFgContext) {
+ const MsgTask* msgTask = getMsgTask(tAssociate, name);
+ mFgContext = new LocDualContext(msgTask,
+ mFgExclMask);
+ }
+ return mFgContext;
+
+}
+
+ContextBase* LocDualContext::getLocBgContext(MsgTask::tCreate tCreator,
+ const char* name)
+{
+ if (NULL == mBgContext) {
+ const MsgTask* msgTask = getMsgTask(tCreator, name);
+ mBgContext = new LocDualContext(msgTask,
+ mBgExclMask);
+ }
+ return mBgContext;
+}
+
+ContextBase* LocDualContext::getLocBgContext(MsgTask::tAssociate tAssociate,
+ const char* name)
+{
+ if (NULL == mBgContext) {
+ const MsgTask* msgTask = getMsgTask(tAssociate, name);
+ mBgContext = new LocDualContext(msgTask,
+ mBgExclMask);
+ }
+ return mBgContext;
+}
+
+LocDualContext::LocDualContext(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask) :
+ ContextBase(msgTask, exMask, mIzatLibName)
+{
+}
+
+}
diff --git a/gps/core/LocDualContext.h b/gps/core/LocDualContext.h
new file mode 100644
index 0000000..e761e76
--- /dev/null
+++ b/gps/core/LocDualContext.h
@@ -0,0 +1,72 @@
+/* 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_CONTEXT__
+#define __LOC_ENG_CONTEXT__
+
+#include <stdbool.h>
+#include <ctype.h>
+#include <dlfcn.h>
+#include <ContextBase.h>
+
+namespace loc_core {
+
+class LocDualContext : public ContextBase {
+ static const MsgTask* mMsgTask;
+ static ContextBase* mFgContext;
+ static ContextBase* mBgContext;
+
+ static const MsgTask* getMsgTask(MsgTask::tCreate tCreator,
+ const char* name);
+ static const MsgTask* getMsgTask(MsgTask::tAssociate tAssociate,
+ const char* name);
+
+protected:
+ LocDualContext(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask);
+ inline virtual ~LocDualContext() {}
+
+public:
+ static const char* mIzatLibName;
+ 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(MsgTask::tCreate tCreator,
+ const char* name);
+ static ContextBase* getLocFgContext(MsgTask::tAssociate tAssociate,
+ const char* name);
+ static ContextBase* getLocBgContext(MsgTask::tCreate tCreator,
+ const char* name);
+ static ContextBase* getLocBgContext(MsgTask::tAssociate tAssociate,
+ const char* name);
+};
+
+}
+
+#endif //__LOC_ENG_CONTEXT__
diff --git a/gps/core/MsgTask.cpp b/gps/core/MsgTask.cpp
new file mode 100644
index 0000000..3781339
--- /dev/null
+++ b/gps/core/MsgTask.cpp
@@ -0,0 +1,133 @@
+/* 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_MsgTask"
+
+#include <cutils/sched_policy.h>
+#include <unistd.h>
+#include <MsgTask.h>
+#include <msg_q.h>
+#include <log_util.h>
+#include <loc_log.h>
+#include <android_runtime/AndroidRuntime.h>
+
+namespace loc_core {
+
+#define MAX_TASK_COMM_LEN 15
+
+static void LocMsgDestroy(void* msg) {
+ delete (LocMsg*)msg;
+}
+
+MsgTask::MsgTask(tCreate tCreator, const char* threadName) :
+ mQ(msg_q_init2()), mAssociator(NULL){
+ if (tCreator) {
+ tCreator(threadName, loopMain,
+ (void*)new MsgTask(mQ, mAssociator));
+ } else {
+ createPThread(threadName);
+ }
+}
+
+MsgTask::MsgTask(tAssociate tAssociator, const char* threadName) :
+ mQ(msg_q_init2()), mAssociator(tAssociator){
+ createPThread(threadName);
+}
+
+inline
+MsgTask::MsgTask(const void* q, tAssociate associator) :
+ mQ(q), mAssociator(associator){
+}
+
+MsgTask::~MsgTask() {
+ msg_q_unblock((void*)mQ);
+}
+
+void MsgTask::createPThread(const char* threadName) {
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+ pthread_t tid;
+ // create the thread here, then if successful
+ // and a name is given, we set the thread name
+ if (!pthread_create(&tid, &attr, loopMain,
+ (void*)new MsgTask(mQ, mAssociator)) &&
+ NULL != threadName) {
+ char lname[MAX_TASK_COMM_LEN+1];
+ memcpy(lname, threadName, MAX_TASK_COMM_LEN);
+ lname[MAX_TASK_COMM_LEN] = 0;
+ pthread_setname_np(tid, lname);
+ }
+}
+
+void MsgTask::sendMsg(const LocMsg* msg) const {
+ msg_q_snd((void*)mQ, (void*)msg, LocMsgDestroy);
+}
+
+void* MsgTask::loopMain(void* arg) {
+ MsgTask* copy = (MsgTask*)arg;
+
+ // make sure we do not run in background scheduling group
+ set_sched_policy(gettid(), SP_FOREGROUND);
+
+ if (NULL != copy->mAssociator) {
+ copy->mAssociator();
+ }
+
+ LocMsg* msg;
+ int cnt = 0;
+
+ while (1) {
+ LOC_LOGD("MsgTask::loop() %d listening ...\n", cnt++);
+
+ msq_q_err_type result = msg_q_rcv((void*)copy->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));
+ // destroy the Q and exit
+ msg_q_destroy((void**)&(copy->mQ));
+ delete copy;
+ return NULL;
+ }
+
+ msg->log();
+ // there is where each individual msg handling is invoked
+ msg->proc();
+
+ delete msg;
+ }
+
+ delete copy;
+
+ return NULL;
+}
+
+}
diff --git a/gps/core/MsgTask.h b/gps/core/MsgTask.h
new file mode 100644
index 0000000..d09de73
--- /dev/null
+++ b/gps/core/MsgTask.h
@@ -0,0 +1,66 @@
+/* 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 __MSG_TASK__
+#define __MSG_TASK__
+
+#include <stdbool.h>
+#include <ctype.h>
+#include <string.h>
+#include <pthread.h>
+
+namespace loc_core {
+
+struct LocMsg {
+ inline LocMsg() {}
+ inline virtual ~LocMsg() {}
+ virtual void proc() const = 0;
+ inline virtual void log() const {}
+};
+
+class MsgTask {
+public:
+ typedef void* (*tStart)(void*);
+ typedef pthread_t (*tCreate)(const char* name, tStart start, void* arg);
+ typedef int (*tAssociate)();
+ MsgTask(tCreate tCreator, const char* threadName);
+ MsgTask(tAssociate tAssociator, const char* threadName);
+ ~MsgTask();
+ void sendMsg(const LocMsg* msg) const;
+
+private:
+ const void* mQ;
+ tAssociate mAssociator;
+ MsgTask(const void* q, tAssociate associator);
+ static void* loopMain(void* copy);
+ void createPThread(const char* name);
+};
+
+} // namespace loc_core
+
+#endif //__MSG_TASK__
diff --git a/gps/core/UlpProxyBase.h b/gps/core/UlpProxyBase.h
new file mode 100644
index 0000000..0873748
--- /dev/null
+++ b/gps/core/UlpProxyBase.h
@@ -0,0 +1,66 @@
+/* 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 ULP_PROXY_BASE_H
+#define ULP_PROXY_BASE_H
+
+#include <gps_extended.h>
+
+namespace loc_core {
+
+class LocAdapterBase;
+
+class UlpProxyBase {
+public:
+ inline UlpProxyBase() {}
+ inline virtual ~UlpProxyBase() {}
+ inline virtual bool sendStartFix() { return false;}
+ inline virtual bool sendStopFix() { return false;}
+ inline virtual bool sendFixMode(LocPosMode &params) { return false;}
+ inline virtual bool reportPosition(UlpLocation &location,
+ GpsLocationExtended &locationExtended,
+ void* locationExt,
+ enum loc_sess_status status,
+ LocPosTechMask loc_technology_mask) {
+ return false;
+ }
+ inline virtual bool reportSv(GpsSvStatus &svStatus,
+ GpsLocationExtended &locationExtended,
+ void* svExt) {
+ return false;
+ }
+ inline virtual bool reportStatus(GpsStatusValue status) {
+ return false;
+ }
+ inline virtual void setAdapter(LocAdapterBase* adapter) {}
+ inline virtual void setCapabilities(unsigned long capabilities) {}
+};
+
+} // namespace loc_core
+
+#endif // ULP_PROXY_BASE_H
diff --git a/gps/core/gps_extended.h b/gps/core/gps_extended.h
new file mode 100644
index 0000000..88b0415
--- /dev/null
+++ b/gps/core/gps_extended.h
@@ -0,0 +1,92 @@
+/* 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 <gps_extended_c.h>
+
+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
new file mode 100644
index 0000000..f970b64
--- /dev/null
+++ b/gps/core/gps_extended_c.h
@@ -0,0 +1,343 @@
+/* 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_C_H
+#define GPS_EXTENDED_C_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <ctype.h>
+#include <stdbool.h>
+#include <hardware/gps.h>
+
+/** 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
+
+#define ULP_MIN_INTERVAL_INVALID 0xffffffff
+
+
+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;
+ char ipv6_addr[16];
+ 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 */
+
+/** GpsLocationExtended has valid latitude and longitude. */
+#define GPS_LOCATION_EXTENDED_HAS_LAT_LONG (1U<<0)
+/** GpsLocationExtended has valid altitude. */
+#define GPS_LOCATION_EXTENDED_HAS_ALTITUDE (1U<<1)
+/** GpsLocationExtended has valid speed. */
+#define GPS_LOCATION_EXTENDED_HAS_SPEED (1U<<2)
+/** GpsLocationExtended has valid bearing. */
+#define GPS_LOCATION_EXTENDED_HAS_BEARING (1U<<4)
+/** GpsLocationExtended has valid accuracy. */
+#define GPS_LOCATION_EXTENDED_HAS_ACCURACY (1U<<8)
+
+/** GPS extended supports geofencing */
+#define GPS_EXTENDED_CAPABILITY_GEOFENCE 0x0000001
+/** GPS extended supports batching */
+#define GPS_EXTENDED_CAPABILITY_BATCHING 0x0000002
+
+/** 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
+
+/** 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;
+} GpsLocationExtended;
+
+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_ENGINE_DOWN = 100,
+ LOC_API_ADAPTER_ERR_FAILURE,
+ 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_EVENT_MAX
+};
+
+#define LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT (1<<LOC_API_ADAPTER_REPORT_POSITION)
+#define LOC_API_ADAPTER_BIT_SATELLITE_REPORT (1<<LOC_API_ADAPTER_REPORT_SATELLITE)
+#define LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT (1<<LOC_API_ADAPTER_REPORT_NMEA_1HZ)
+#define LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT (1<<LOC_API_ADAPTER_REPORT_NMEA_POSITION)
+#define LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST (1<<LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY)
+#define LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST (1<<LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA)
+#define LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST (1<<LOC_API_ADAPTER_REQUEST_LOCATION_SERVER)
+#define LOC_API_ADAPTER_BIT_IOCTL_REPORT (1<<LOC_API_ADAPTER_REPORT_IOCTL)
+#define LOC_API_ADAPTER_BIT_STATUS_REPORT (1<<LOC_API_ADAPTER_REPORT_STATUS)
+#define LOC_API_ADAPTER_BIT_REQUEST_WIFI (1<<LOC_API_ADAPTER_REQUEST_WIFI)
+#define LOC_API_ADAPTER_BIT_SENSOR_STATUS (1<<LOC_API_ADAPTER_SENSOR_STATUS)
+#define LOC_API_ADAPTER_BIT_REQUEST_TIME_SYNC (1<<LOC_API_ADAPTER_REQUEST_TIME_SYNC)
+#define LOC_API_ADAPTER_BIT_REPORT_SPI (1<<LOC_API_ADAPTER_REPORT_SPI)
+#define LOC_API_ADAPTER_BIT_REPORT_NI_GEOFENCE (1<<LOC_API_ADAPTER_REPORT_NI_GEOFENCE)
+#define LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT (1<<LOC_API_ADAPTER_GEOFENCE_GEN_ALERT)
+#define LOC_API_ADAPTER_BIT_REPORT_GENFENCE_BREACH (1<<LOC_API_ADAPTER_REPORT_GENFENCE_BREACH)
+#define LOC_API_ADAPTER_BIT_PEDOMETER_CTRL (1<<LOC_API_ADAPTER_PEDOMETER_CTRL)
+#define LOC_API_ADAPTER_BIT_MOTION_CTRL (1<<LOC_API_ADAPTER_MOTION_CTRL)
+#define LOC_API_ADAPTER_BIT_REQUEST_WIFI_AP_DATA (1<<LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA)
+#define LOC_API_ADAPTER_BIT_BATCH_FULL (1<<LOC_API_ADAPTER_BATCH_FULL)
+#define LOC_API_ADAPTER_BIT_BATCHED_POSITION_REPORT (1<<LOC_API_ADAPTER_BATCHED_POSITION_REPORT)
+
+typedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T;
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* GPS_EXTENDED_C_H */
+
diff --git a/gps/core/loc_core_log.cpp b/gps/core/loc_core_log.cpp
new file mode 100644
index 0000000..461273f
--- /dev/null
+++ b/gps/core/loc_core_log.cpp
@@ -0,0 +1,257 @@
+/* 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_core_log"
+
+#include <loc_log.h>
+#include <log_util.h>
+#include <loc_core_log.h>
+
+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 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 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 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 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 loc_name_val_s_type loc_eng_position_recurrences[] =
+{
+ NAME_VAL( GPS_POSITION_RECURRENCE_PERIODIC ),
+ NAME_VAL( GPS_POSITION_RECURRENCE_SINGLE )
+};
+static 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 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_ALMANAC_CORR ),
+ NAME_VAL( GPS_DELETE_FREQ_BIAS_EST ),
+ NAME_VAL( GLO_DELETE_EPHEMERIS ),
+ NAME_VAL( GLO_DELETE_ALMANAC ),
+ NAME_VAL( GLO_DELETE_SVDIR ),
+ NAME_VAL( GLO_DELETE_SVSTEER ),
+ NAME_VAL( GLO_DELETE_ALMANAC_CORR ),
+ NAME_VAL( GPS_DELETE_TIME_GPS ),
+ NAME_VAL( GLO_DELETE_TIME ),
+ NAME_VAL( BDS_DELETE_SVDIR ),
+ NAME_VAL( BDS_DELETE_SVSTEER ),
+ NAME_VAL( BDS_DELETE_TIME ),
+ NAME_VAL( BDS_DELETE_ALMANAC_CORR ),
+ NAME_VAL( BDS_DELETE_EPHEMERIS ),
+ NAME_VAL( BDS_DELETE_ALMANAC ),
+ NAME_VAL( GPS_DELETE_ALL)
+};
+static 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 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 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 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 )
+};
+static 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 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 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 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 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 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_IPV4 ),
+ NAME_VAL( AGPS_APN_BEARER_IPV4V6 )
+};
+static 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 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 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 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 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 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 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
new file mode 100644
index 0000000..8a1825a
--- /dev/null
+++ b/gps/core/loc_core_log.h
@@ -0,0 +1,58 @@
+/* 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 <ctype.h>
+#include <gps_extended.h>
+
+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/flp.conf b/gps/flp.conf
new file mode 100644
index 0000000..950c712
--- /dev/null
+++ b/gps/flp.conf
@@ -0,0 +1,21 @@
+################################
+##### FLP settings #####
+################################
+
+# For default batch size, set the following
+BATCH_SIZE=20
+
+# FLP Capabilities bit mask
+# GEOFENCE = 0x01
+# BATCHING = 0x02
+# default = GEOFENCE | BATCHING
+CAPABILITIES=0x03
+
+# FLP accuracy
+# Low accuracy = 0
+# Medium accuracy = 1
+# High accuracy = 2
+ACCURACY=0
+
+# FLP geofence responsiveness
+GEOFENCE_RESPONSIVENESS = 0
diff --git a/gps/gps.conf b/gps/gps.conf
new file mode 100644
index 0000000..dd9586d
--- /dev/null
+++ b/gps/gps.conf
@@ -0,0 +1,78 @@
+#Uncommenting these urls would only enable
+#the power up auto injection and force injection(test case).
+#XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra2.bin
+#XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra2.bin
+#XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra2.bin
+
+# Error Estimate
+# _SET = 1
+# _CLEAR = 0
+ERR_ESTIMATE=0
+
+#Test
+NTP_SERVER=time.gpsonextra.net
+#Asia
+# NTP_SERVER=asia.pool.ntp.org
+#Europe
+# NTP_SERVER=europe.pool.ntp.org
+#North America
+# NTP_SERVER=north-america.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
+
+# supl version 1.0
+SUPL_VER=0x10000
+
+# 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=0x37
+
+# 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
+
+####################################
+# 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
+
+################################
+# EXTRA SETTINGS
+################################
+# NMEA provider (1=Modem Processor, 0=Application Processor)
+NMEA_PROVIDER=0
+
+##################################################
+# Select Positioning Protocol on A-GLONASS system
+##################################################
+# 0x1: RRC CPlane
+# 0x2: RRLP UPlane
+# 0x4: LLP Uplane
+A_GLONASS_POS_PROTOCOL_SELECT = 0
diff --git a/gps/izat.conf b/gps/izat.conf
new file mode 100644
index 0000000..a46f82d
--- /dev/null
+++ b/gps/izat.conf
@@ -0,0 +1,41 @@
+########################################
+# NLP/WIFI positioning options bit mask
+########################################
+# Enable NLP fixes for WIPER/ODCPI feature => WIPER = 0x1
+# Enable free wifi scan injections for GEOFENCE => FREE_WIFI = 0x2
+# Enable SUPL2 MLD wifi => SUPL_WIFI = 0x4
+# default = WIPER | FREE_WIFI | SUPL_WIFI
+NLP_WIFI_LISTENER_MODE = 0
+
+##################################################
+# Select WIFI Wait Timeout value in seconds for SUPL
+##################################################
+WIFI_WAIT_TIMEOUT_SELECT = 0
+
+################################
+# Indoor Positioning Settings
+################################
+# 0: QUIPC disabled, 1: QUIPC enabled, 2: forced QUIPC only
+QUIPC_ENABLED = 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_MODE = 1
+NLP_TOLERANCE_TIME_FIRST = 5000
+NLP_TOLERANCE_TIME_AFTER = 20000
+NLP_THRESHOLD = 3
+NLP_ACCURACY_MULTIPLE = 2
+
+# Threshold period for ZPP triggers
+ZPP_TRIGGER_THRESHOLD=10000
diff --git a/gps/libloc_api_50001/Android.mk b/gps/libloc_api_50001/Android.mk
new file mode 100644
index 0000000..f3743ae
--- /dev/null
+++ b/gps/libloc_api_50001/Android.mk
@@ -0,0 +1,101 @@
+ifneq ($(BUILD_TINY_ANDROID),true)
+#Compile this library only for builds with the latest modem image
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libloc_eng
+LOCAL_MODULE_OWNER := qcom
+
+LOCAL_MODULE_TAGS := optional
+
+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 \
+ device/sony/shinano-common/gps/libloc_api_50001
+
+LOCAL_COPY_HEADERS_TO:= libloc_eng/
+LOCAL_COPY_HEADERS:= \
+ LocEngAdapter.h \
+ loc.h \
+ loc_eng.h \
+ loc_eng_xtra.h \
+ loc_eng_ni.h \
+ loc_eng_agps.h \
+ loc_eng_msg.h \
+ loc_eng_log.h
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := gps.msm8974
+LOCAL_MODULE_OWNER := qcom
+
+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_ \
+
+ifeq ($(TARGET_USES_QCOM_BSP), true)
+LOCAL_CFLAGS += -DTARGET_USES_QCOM_BSP
+endif
+
+## Includes
+LOCAL_C_INCLUDES:= \
+ $(TARGET_OUT_HEADERS)/gps.utils \
+ $(TARGET_OUT_HEADERS)/libloc_core
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif # not BUILD_TINY_ANDROID
diff --git a/gps/libloc_api_50001/LocEngAdapter.cpp b/gps/libloc_api_50001/LocEngAdapter.cpp
new file mode 100644
index 0000000..c8d0885
--- /dev/null
+++ b/gps/libloc_api_50001/LocEngAdapter.cpp
@@ -0,0 +1,297 @@
+/* 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_EngAdapter"
+
+#include <LocEngAdapter.h>
+#include "loc_eng_msg.h"
+#include "loc_log.h"
+
+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));
+}
+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));
+}
+
+LocEngAdapter::LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
+ void* owner, ContextBase* context,
+ MsgTask::tCreate tCreator) :
+ LocAdapterBase(mask,
+ //Get the AFW context if VzW context has not already been intialized in
+ //loc_ext
+ context == NULL?
+ LocDualContext::getLocFgContext(tCreator,
+ LocDualContext::mLocationHalName)
+ :context),
+ mOwner(owner), mInternalAdapter(new LocInternalAdapter(this)),
+ mUlp(new UlpProxyBase()), mNavigating(false),
+ mAgpsEnabled(false), mCPIEnabled(false)
+{
+ 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::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;
+ }
+ delete mUlp;
+ LOC_LOGV("%s] %p", __func__, ulp);
+ if (NULL == ulp) {
+ ulp = new UlpProxyBase();
+ }
+ mUlp = ulp;
+
+ if (LOC_POSITION_MODE_INVALID != mFixCriteria.mode) {
+ // need to send this mode and start msg to ULP
+ mUlp->sendFixMode(mFixCriteria);
+ mUlp->sendStartFix();
+ }
+}
+
+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(GpsSvStatus &svStatus,
+ GpsLocationExtended &locationExtended,
+ void* svExt){
+ sendMsg(new LocEngReportSv(mLocEngAdapter, svStatus,
+ locationExtended, svExt));
+}
+
+void LocEngAdapter::reportSv(GpsSvStatus &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 (mAgpsEnabled) {
+ sendMsg(new LocEngReportXtraServer(mOwner, url1,
+ url2, url3, maxlength));
+ }
+ return mAgpsEnabled;
+}
+
+inline
+bool LocEngAdapter::requestATL(int connHandle, AGpsType agps_type)
+{
+ if (mAgpsEnabled) {
+ sendMsg(new LocEngRequestATL(mOwner,
+ connHandle, agps_type));
+ }
+ return mAgpsEnabled;
+}
+
+inline
+bool LocEngAdapter::releaseATL(int connHandle)
+{
+ if (mAgpsEnabled) {
+ sendMsg(new LocEngReleaseATL(mOwner, connHandle));
+ }
+ return mAgpsEnabled;
+}
+
+inline
+bool LocEngAdapter::requestXtraData()
+{
+ if (mAgpsEnabled) {
+ sendMsg(new LocEngRequestXtra(mOwner));
+ }
+ return mAgpsEnabled;
+}
+
+inline
+bool LocEngAdapter::requestTime()
+{
+ if (mAgpsEnabled) {
+ sendMsg(new LocEngRequestTime(mOwner));
+ }
+ return mAgpsEnabled;
+}
+
+inline
+bool LocEngAdapter::requestNiNotify(GpsNiNotification &notif, const void* data)
+{
+ if (mAgpsEnabled) {
+ notif.size = sizeof(notif);
+ notif.timeout = LOC_NI_NO_RESPONSE_TIME;
+
+ sendMsg(new LocEngRequestNi(mOwner, notif, data));
+ }
+ return mAgpsEnabled;
+}
+
+inline
+bool LocEngAdapter::requestSuplES(int connHandle)
+{
+ if (mAgpsEnabled)
+ sendMsg(new LocEngRequestSuplEs(mOwner, connHandle));
+ return mAgpsEnabled;
+}
+
+inline
+bool LocEngAdapter::reportDataCallOpened()
+{
+ if(mAgpsEnabled)
+ sendMsg(new LocEngSuplEsOpened(mOwner));
+ return mAgpsEnabled;
+}
+
+inline
+bool LocEngAdapter::reportDataCallClosed()
+{
+ if(mAgpsEnabled)
+ sendMsg(new LocEngSuplEsClosed(mOwner));
+ return mAgpsEnabled;
+}
+
+inline
+void LocEngAdapter::handleEngineDownEvent()
+{
+ sendMsg(new LocEngDown(mOwner));
+}
+
+inline
+void LocEngAdapter::handleEngineUpEvent()
+{
+ sendMsg(new LocEngUp(mOwner));
+}
+
diff --git a/gps/libloc_api_50001/LocEngAdapter.h b/gps/libloc_api_50001/LocEngAdapter.h
new file mode 100644
index 0000000..d03dc66
--- /dev/null
+++ b/gps/libloc_api_50001/LocEngAdapter.h
@@ -0,0 +1,299 @@
+/* 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_API_ENG_ADAPTER_H
+#define LOC_API_ENG_ADAPTER_H
+
+#include <ctype.h>
+#include <hardware/gps.h>
+#include <loc.h>
+#include <loc_eng_log.h>
+#include <log_util.h>
+#include <LocAdapterBase.h>
+#include <LocDualContext.h>
+#include <UlpProxyBase.h>
+#include <platform_lib_includes.h>
+
+#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(GpsSvStatus &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;
+
+public:
+ bool mAgpsEnabled;
+ bool mCPIEnabled;
+
+ LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
+ void* owner,ContextBase* context,
+ MsgTask::tCreate tCreator);
+ virtual ~LocEngAdapter();
+
+ virtual void setUlpProxy(UlpProxyBase* ulp);
+ 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 hasAgpsExt() { return mContext->hasAgpsExt(); }
+ inline bool hasCPIExt() { return mContext->hasCPIExt(); }
+ 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
+ setTime(GpsUtcTime time, int64_t timeReference, int uncertainty)
+ {
+ return mLocApi->setTime(time, timeReference, uncertainty);
+ }
+ 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)
+ {
+ return mLocApi->setSensorControlConfig(sensorUsage);
+ }
+ 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->getZppFix(zppLoc, tech_mask);
+ }
+
+ 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(GpsSvStatus &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 &notify, const void* data);
+ virtual bool requestSuplES(int connHandle);
+ virtual bool reportDataCallOpened();
+ virtual bool reportDataCallClosed();
+
+ inline const LocPosMode& getPositionMode() const
+ {return mFixCriteria;}
+ inline virtual bool isInSession()
+ { return mNavigating; }
+ void setInSession(bool inSession);
+
+ /*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(unsigned int lock)
+ {
+ return mLocApi->setGpsLock(lock);
+ }
+ /*
+ Returns
+ Current value of GPS lock on success
+ -1 on failure
+ */
+ inline int getGpsLock()
+ {
+ return mLocApi->getGpsLock();
+ }
+};
+
+#endif //LOC_API_ENG_ADAPTER_H
diff --git a/gps/libloc_api_50001/Makefile.am b/gps/libloc_api_50001/Makefile.am
new file mode 100644
index 0000000..2374357
--- /dev/null
+++ b/gps/libloc_api_50001/Makefile.am
@@ -0,0 +1,76 @@
+AM_CFLAGS = \
+ -I../../utils \
+ -I../../platform_lib_abstractions \
+ -fno-short-enums \
+ -DFEATURE_GNSS_BIT_API
+
+libloc_adapter_so_la_SOURCES = loc_eng_log.cpp LocEngAdapter.cpp
+
+if USE_GLIB
+libloc_adapter_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
+libloc_adapter_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
+libloc_adapter_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
+else
+libloc_adapter_so_la_CFLAGS = $(AM_CFLAGS)
+libloc_adapter_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
+libloc_adapter_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
+endif
+libloc_adapter_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la
+
+
+libloc_eng_so_la_SOURCES = \
+ loc_eng.cpp \
+ loc_eng_agps.cpp \
+ loc_eng_xtra.cpp \
+ loc_eng_ni.cpp \
+ loc_eng_log.cpp \
+ 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
+
+
+if USE_GLIB
+libloc_eng_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
+libloc_eng_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
+libloc_eng_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
+else
+libloc_eng_so_la_CFLAGS = $(AM_CFLAGS)
+libloc_eng_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
+libloc_eng_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
+endif
+
+libloc_eng_so_la_LIBADD = -lstdc++ -lcutils -ldl ../../utils/libgps_utils_so.la libloc_adapter_so.la
+
+
+libgps_default_so_la_SOURCES = \
+ loc.cpp \
+ gps.c
+
+if USE_GLIB
+libgps_default_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
+libgps_default_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
+libgps_default_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
+else
+libgps_default_so_la_CFLAGS = $(AM_CFLAGS)
+libgps_default_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
+libgps_default_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
+endif
+
+libgps_default_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la -ldl libloc_eng_so.la
+
+library_include_HEADERS = \
+ LocEngAdapter.h \
+ loc.h \
+ loc_eng.h \
+ loc_eng_xtra.h \
+ loc_eng_ni.h \
+ loc_eng_agps.h \
+ loc_eng_msg.h \
+ loc_eng_log.h
+
+library_includedir = $(pkgincludedir)/libloc_api_50001
+
+#Create and Install libraries
+lib_LTLIBRARIES = libloc_adapter_so.la libloc_eng_so.la libgps_default_so.la
diff --git a/gps/libloc_api_50001/gps.c b/gps/libloc_api_50001/gps.c
new file mode 100644
index 0000000..b0669af
--- /dev/null
+++ b/gps/libloc_api_50001/gps.c
@@ -0,0 +1,72 @@
+/* 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 <hardware/gps.h>
+
+#include <stdlib.h>
+
+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/libloc_api_50001/loc.cpp b/gps/libloc_api_50001/loc.cpp
new file mode 100644
index 0000000..0b032f0
--- /dev/null
+++ b/gps/libloc_api_50001/loc.cpp
@@ -0,0 +1,907 @@
+/* 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_afw"
+
+#include <hardware/gps.h>
+#include <gps_extended.h>
+#include <loc_eng.h>
+#include <loc_target.h>
+#include <loc_log.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dlfcn.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <LocDualContext.h>
+#include <cutils/properties.h>
+
+using namespace loc_core;
+
+//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 const AGpsInterface sLocEngAGpsInterface =
+{
+ sizeof(AGpsInterface),
+ loc_agps_init,
+ loc_agps_open,
+ loc_agps_closed,
+ loc_agps_open_failed,
+ loc_agps_set_server
+};
+
+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);
+
+const GpsNiInterface sLocEngNiInterface =
+{
+ sizeof(GpsNiInterface),
+ loc_ni_init,
+ loc_ni_respond,
+};
+
+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 loc_eng_data_s_type loc_afw_data;
+static int gss_fd = -1;
+
+/*===========================================================================
+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));
+
+ int gnssType = getTargetGnssType(target);
+ switch (gnssType)
+ {
+ case GNSS_GSS:
+ //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->requestUlp(gps_conf.CAPABILITIES);
+ loc_afw_data.adapter->mAgpsEnabled = !loc_afw_data.adapter->hasAgpsExt();
+ loc_afw_data.adapter->mCPIEnabled = !loc_afw_data.adapter->hasCPIExt();
+
+ 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_eng_cleanup(loc_afw_data);
+ gps_loc_cb = NULL;
+ gps_sv_cb = NULL;
+
+/*
+ if (gss_fd >= 0)
+ {
+ close(gss_fd);
+ gss_fd = -1;
+ LOC_LOGD("GSS shutdown.\n");
+ }
+*/
+
+ 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)
+{
+ static bool initialized = false;
+ static bool enable_cpi = true;
+ accuracy = 1000;
+ ENTRY_LOG();
+
+ if(!initialized)
+ {
+ char value[PROPERTY_VALUE_MAX];
+ memset(value, 0, sizeof(value));
+ (void)property_get("persist.gps.qc_nlp_in_use", value, "0");
+ if(0 == strcmp(value, "1"))
+ {
+ enable_cpi = false;
+ LOC_LOGI("GPS HAL coarse position injection disabled");
+ }
+ else
+ {
+ LOC_LOGI("GPS HAL coarse position injection enabled");
+ }
+ initialized = true;
+ }
+
+ int ret_val = 0;
+ if(enable_cpi)
+ {
+ 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) {
+ 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
+ {
+ 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_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();
+ int ret_val = loc_eng_xtra_init(loc_afw_data, (GpsXtraExtCallbacks*)callbacks);
+
+ 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 = loc_eng_xtra_inject_data(loc_afw_data, data, length);
+
+ EXIT_LOG(%d, ret_val);
+ return ret_val;
+}
+
+/*===========================================================================
+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 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/libloc_api_50001/loc.h b/gps/libloc_api_50001/loc.h
new file mode 100644
index 0000000..c959323
--- /dev/null
+++ b/gps/libloc_api_50001/loc.h
@@ -0,0 +1,64 @@
+/* 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_H__
+#define __LOC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <ctype.h>
+#include <cutils/properties.h>
+#include <hardware/gps.h>
+#include <gps_extended.h>
+
+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/libloc_api_50001/loc_eng.cpp b/gps/libloc_api_50001/loc_eng.cpp
new file mode 100644
index 0000000..f54066b
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng.cpp
@@ -0,0 +1,2599 @@
+/* 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 <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <ctype.h>
+#include <math.h>
+#include <pthread.h>
+#include <arpa/inet.h>
+#include <netinet/in.h> /* struct sockaddr_in */
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <netdb.h>
+#include <time.h>
+
+#include <LocEngAdapter.h>
+
+#include <cutils/sched_policy.h>
+#ifndef USE_GLIB
+#include <utils/SystemClock.h>
+#include <utils/Log.h>
+#endif /* USE_GLIB */
+
+#ifdef USE_GLIB
+#include <glib.h>
+#include <sys/syscall.h>
+#endif /* USE_GLIB */
+
+#include <string.h>
+
+#include <loc_eng.h>
+#include <loc_eng_ni.h>
+#include <loc_eng_dmn_conn.h>
+#include <loc_eng_dmn_conn_handler.h>
+#include <loc_eng_msg.h>
+#include <loc_eng_nmea.h>
+#include <msg_q.h>
+#include <loc.h>
+#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
+
+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 loc_param_s_type loc_parameter_table[] =
+{
+ {"INTERMEDIATE_POS", &gps_conf.INTERMEDIATE_POS, NULL, 'n'},
+ {"ACCURACY_THRES", &gps_conf.ACCURACY_THRES, NULL, 'n'},
+ {"NMEA_PROVIDER", &gps_conf.NMEA_PROVIDER, NULL, 'n'},
+ {"SUPL_VER", &gps_conf.SUPL_VER, NULL, 'n'},
+ {"CAPABILITIES", &gps_conf.CAPABILITIES, NULL, 'n'},
+ {"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'},
+ {"QUIPC_ENABLED", &gps_conf.QUIPC_ENABLED, NULL, 'n'},
+ {"LPP_PROFILE", &gps_conf.LPP_PROFILE, NULL, 'n'},
+ {"A_GLONASS_POS_PROTOCOL_SELECT", &gps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'},
+};
+
+static void loc_default_parameters(void)
+{
+ /* defaults */
+ gps_conf.INTERMEDIATE_POS = 0;
+ gps_conf.ACCURACY_THRES = 0;
+ gps_conf.NMEA_PROVIDER = 0;
+ gps_conf.SUPL_VER = 0x10000;
+ gps_conf.CAPABILITIES = 0x7;
+
+ 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;
+
+ /* 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;
+}
+
+// 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 &notif,
+ 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);
+}
+
+// case LOC_ENG_MSG_SET_TIME:
+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();
+ }
+};
+
+// 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;
+ inline LocEngSensorControlConfig(LocEngAdapter* adapter,
+ int sensorsDisabled) :
+ LocMsg(), mAdapter(adapter), mSensorsDisabled(sensorsDisabled)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mAdapter->setSensorControlConfig(mSensorsDisabled);
+ }
+ inline void locallog() const {
+ LOC_LOGV("LocEngSensorControlConfig - Sensors Disabled: %d",
+ mSensorsDisabled);
+ }
+ 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);
+ }
+
+ if (locEng->generateNmea &&
+ mLocation.position_source == ULP_LOCATION_IS_FROM_GNSS)
+ {
+ 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("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",
+ mLocation.gpsLocation.flags, mLocation.position_source,
+ mLocation.gpsLocation.latitude, mLocation.gpsLocation.longitude,
+ mLocation.gpsLocation.altitude, mLocation.gpsLocation.speed,
+ mLocation.gpsLocation.bearing, mLocation.gpsLocation.accuracy,
+ mLocation.gpsLocation.timestamp, mLocation.rawDataSize,
+ mLocation.rawData, mStatus, mTechMask);
+}
+void LocEngReportPosition::log() const {
+ locallog();
+}
+void LocEngReportPosition::send() const {
+ mAdapter->sendMsg(this);
+}
+
+
+// case LOC_ENG_MSG_REPORT_SV:
+LocEngReportSv::LocEngReportSv(LocAdapterBase* adapter,
+ GpsSvStatus &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("num sv: %d\n ephemeris mask: %dxn almanac mask: %x\n "
+ "used in fix mask: %x\n sv: prn snr "
+ "elevation azimuth",
+ mSvStatus.num_svs, mSvStatus.ephemeris_mask,
+ mSvStatus.almanac_mask, mSvStatus.used_in_fix_mask);
+ for (int i = 0; i < mSvStatus.num_svs && i < GPS_MAX_SVS; i++) {
+ LOC_LOGV(" %d: %d %f %f %f\n ",
+ i,
+ mSvStatus.sv_list[i].prn,
+ mSvStatus.sv_list[i].snr,
+ mSvStatus.sv_list[i].elevation,
+ mSvStatus.sv_list[i].azimuth);
+ }
+}
+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]), mLen(len)
+{
+ memcpy((void*)mNmea, (void*)data, len);
+ 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)])
+{
+ memset(mServers, 0, 3*(mMaxLen+1));
+ strlcpy(mServers, url1, mMaxLen);
+ strlcpy(&(mServers[mMaxLen+1]), url2, mMaxLen);
+ strlcpy(&(mServers[(mMaxLen+1)<<1]), url3, mMaxLen);
+ 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 {
+ 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_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);
+ }
+ 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("LocEngAtlClosed 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();
+ }
+};
+
+
+/*********************************************************************
+ * 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)
+
+/*===========================================================================
+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));
+
+ if (NULL != callbacks->set_capabilities_cb) {
+ callbacks->set_capabilities_cb(gps_conf.CAPABILITIES);
+ }
+
+ // 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.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,
+ (MsgTask::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;
+
+ if (LOC_API_ADAPTER_ERR_SUCCESS == ret_val) {
+ LOC_LOGD("loc_eng_reinit reinit() successful");
+
+ LocEngAdapter* adapter = loc_eng_data.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));
+ 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)));
+ }
+
+ 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)
+ {
+ loc_eng_data.adapter->setInSession(TRUE);
+ loc_inform_gps_status(loc_eng_data, GPS_STATUS_SESSION_BEGIN);
+ }
+ }
+
+ 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();
+ if (ret_val == LOC_API_ADAPTER_ERR_SUCCESS)
+ {
+ loc_inform_gps_status(loc_eng_data, GPS_STATUS_SESSION_END);
+ }
+
+ 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 &params)
+{
+ ENTRY_LOG_CALLFLOW();
+ INIT_CHECK(loc_eng_data.adapter, return -1);
+
+ int gnssType = getTargetGnssType(loc_get_target());
+
+ // The position mode for GSS/QCA1530 can only be standalone
+ bool is1530 = gnssType == GNSS_QCA1530;
+ bool isAPQ = gnssType == GNSS_GSS;
+ if ((isAPQ || is1530) && params.mode != LOC_POSITION_MODE_STANDALONE) {
+ params.mode = LOC_POSITION_MODE_STANDALONE;
+ LOC_LOGD("Position mode changed to standalone for target with 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->mCPIEnabled)
+ {
+ 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);
+ memset(&location, 0, sizeof location);
+
+ 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);
+
+ int gnssType = getTargetGnssType(loc_get_target());
+ bool isAPQ = (gnssType == GNSS_GSS);
+ bool is1530 = (gnssType == GNSS_QCA1530);
+ if (!isAPQ && !is1530) {
+ loc_eng_data.agnss_nif = new AgpsStateMachine(servicerTypeAgps,
+ (void *)loc_eng_data.agps_status_cb,
+ AGPS_TYPE_SUPL,
+ false);
+
+ if (adapter->mAgpsEnabled) {
+ 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: {
+ stateMachine = locEng.ds_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 = 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;
+
+ if (NULL != loc_eng_data.adapter)
+ {
+ ret_val = loc_eng_set_server(loc_eng_data, type, hostname, port);
+ } else {
+ LOC_LOGW("set_server called before init. 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);
+ }
+ }
+
+ 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);
+}
+
+/*===========================================================================
+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);
+
+ 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);
+ }
+
+ loc_eng_report_status(loc_eng_data, GPS_STATUS_ENGINE_ON);
+
+ // 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->setPositionMode(NULL);
+ loc_eng_data.adapter->setInSession(false);
+ loc_eng_start_handler(loc_eng_data);
+ }
+ 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, loc_parameter_table);
+ UTIL_READ_CONF(SAP_CONF_FILE, loc_parameter_table);
+ configAlreadyRead = true;
+ } else {
+ LOC_LOGV("GPS Config file has already been read\n");
+ }
+
+ EXIT_LOG(%d, 0);
+ return 0;
+}
diff --git a/gps/libloc_api_50001/loc_eng.h b/gps/libloc_api_50001/loc_eng.h
new file mode 100644
index 0000000..2dfd50f
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng.h
@@ -0,0 +1,241 @@
+/* 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.
+ *
+ */
+
+#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 <loc.h>
+#include <loc_eng_xtra.h>
+#include <loc_eng_ni.h>
+#include <loc_eng_agps.h>
+#include <loc_cfg.h>
+#include <loc_log.h>
+#include <log_util.h>
+#include <loc_eng_agps.h>
+#include <LocEngAdapter.h>
+
+// 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
+
+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_acquire_wakelock acquire_wakelock_cb;
+ gps_release_wakelock release_wakelock_cb;
+ gps_request_utc_time request_utc_time_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 */
+typedef struct loc_gps_cfg_s
+{
+ unsigned long INTERMEDIATE_POS;
+ unsigned long ACCURACY_THRES;
+ unsigned long SUPL_VER;
+ unsigned long CAPABILITIES;
+ unsigned long QUIPC_ENABLED;
+ unsigned long LPP_PROFILE;
+ uint8_t NMEA_PROVIDER;
+ unsigned long A_GLONASS_POS_PROTOCOL_SELECT;
+} loc_gps_cfg_s_type;
+
+typedef struct
+{
+ uint8_t GYRO_BIAS_RANDOM_WALK_VALID;
+ double GYRO_BIAS_RANDOM_WALK;
+ unsigned long SENSOR_ACCEL_BATCHES_PER_SEC;
+ unsigned long SENSOR_ACCEL_SAMPLES_PER_BATCH;
+ unsigned long SENSOR_GYRO_BATCHES_PER_SEC;
+ unsigned long SENSOR_GYRO_SAMPLES_PER_BATCH;
+ unsigned long SENSOR_ACCEL_BATCHES_PER_SEC_HIGH;
+ unsigned long SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH;
+ unsigned long SENSOR_GYRO_BATCHES_PER_SEC_HIGH;
+ unsigned long SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH;
+ unsigned long SENSOR_CONTROL_MODE;
+ unsigned long SENSOR_USAGE;
+ unsigned long 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;
+} loc_sap_cfg_s_type;
+
+extern loc_gps_cfg_s_type gps_conf;
+extern loc_sap_cfg_s_type sap_conf;
+
+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 &params);
+const void* loc_eng_get_extension(loc_eng_data_s_type &loc_eng_data,
+ const char* name);
+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);
+
+int loc_eng_set_server_proxy(loc_eng_data_s_type &loc_eng_data,
+ LocServerType type, const char *hostname, int port);
+
+
+void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data,
+ int avaiable, const char* apn);
+
+
+bool loc_eng_inject_raw_command(loc_eng_data_s_type &loc_eng_data,
+ char* command, int length);
+
+
+void loc_eng_mute_one_session(loc_eng_data_s_type &loc_eng_data);
+
+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);
+
+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);
+int loc_eng_read_config(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif // LOC_ENG_H
diff --git a/gps/libloc_api_50001/loc_eng_agps.cpp b/gps/libloc_api_50001/loc_eng_agps.cpp
new file mode 100644
index 0000000..d6cc136
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_agps.cpp
@@ -0,0 +1,970 @@
+/* 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_eng_agps.h>
+#include <loc_eng_log.h>
+#include <log_util.h>
+#include <platform_lib_includes.h>
+#include <loc_eng_dmn_conn_handler.h>
+#include <loc_eng_dmn_conn.h>
+#include <sys/time.h>
+
+//======================================================================
+// 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 &notification)
+{
+ 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 &notification)
+{
+ 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 &notification)
+{
+ 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 &notification)
+{
+ 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 &notification)
+{
+ 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*)&notification, 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*)&notification, false);
+ }
+}
+
+void AgpsStateMachine::addSubscriber(Subscriber* subscriber) const
+{
+ Subscriber* s = NULL;
+ Notification notification((const Subscriber*)subscriber);
+ linked_list_search(mSubscribers, (void**)&s,
+ hasSubscriber, (void*)&notification, 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*)&notification, 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;
+ nifRequest.ipv6_addr[0] = 0;
+ nifRequest.ssid[0] = '\0';
+ nifRequest.password[0] = '\0';
+ } else {
+ s->setIPAddresses(nifRequest.ipv4_addr, (char*)nifRequest.ipv6_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(&notification, 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*)&notification, 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*)&notification, 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*)&notification, 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*)&notification, 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/libloc_api_50001/loc_eng_agps.h b/gps/libloc_api_50001/loc_eng_agps.h
new file mode 100644
index 0000000..055d955
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_agps.h
@@ -0,0 +1,419 @@
+/* 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 <stdbool.h>
+#include <ctype.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <hardware/gps.h>
+#include <gps_extended.h>
+#include <loc_core_log.h>
+#include <linked_list.h>
+#include <loc_timer.h>
+#include <LocEngAdapter.h>
+
+// 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;
+ 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 &notification) = 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 &notification);
+};
+
+// 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 &notification);
+
+ inline virtual void setIPAddresses(uint32_t &v4, char* v6)
+ { v4 = ID; memcpy(v6, mIPv6Addr, sizeof(mIPv6Addr)); }
+
+ 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 &notification);
+
+ inline virtual void setIPAddresses(uint32_t &v4, char* v6)
+ { v4 = INADDR_NONE; v6[0] = 0; }
+
+ 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 &notification);
+
+ inline virtual void setIPAddresses(uint32_t &v4, char* v6) {}
+
+ 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) {}
+ virtual Subscriber* clone()
+ {return new DSSubscriber(mStateMachine, ID);}
+ virtual bool notifyRsrcStatus(Notification &notification);
+ 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/libloc_api_50001/loc_eng_dmn_conn.cpp b/gps/libloc_api_50001/loc_eng_dmn_conn.cpp
new file mode 100644
index 0000000..918ae22
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_dmn_conn.cpp
@@ -0,0 +1,270 @@
+/* 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 <stdio.h>
+#include <stdlib.h>
+#include <linux/stat.h>
+#include <fcntl.h>
+#include <linux/types.h>
+#include <unistd.h>
+#include <errno.h>
+#include <grp.h>
+#include <sys/stat.h>
+
+#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 0;
+ }
+
+ 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/libloc_api_50001/loc_eng_dmn_conn.h b/gps/libloc_api_50001/loc_eng_dmn_conn.h
new file mode 100644
index 0000000..c7c100b
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_dmn_conn.h
@@ -0,0 +1,59 @@
+/* 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_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/gpsone_d/gpsone_loc_api_q"
+#define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/gpsone_d/gpsone_loc_api_resp_q"
+#define QUIPC_CTRL_Q_PATH "/data/misc/gpsone_d/quipc_ctrl_q"
+#define MSAPM_CTRL_Q_PATH "/data/misc/gpsone_d/msapm_ctrl_q"
+#define MSAPU_CTRL_Q_PATH "/data/misc/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/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c
new file mode 100644
index 0000000..a1076ff
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c
@@ -0,0 +1,223 @@
+/* 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 <linux/stat.h>
+#include <fcntl.h>
+
+#include <linux/types.h>
+
+#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/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h
new file mode 100644
index 0000000..d685c87
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h
@@ -0,0 +1,51 @@
+/* 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 <linux/types.h>
+#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/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c
new file mode 100644
index 0000000..dffcad0
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c
@@ -0,0 +1,214 @@
+/* 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 <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+// #include <linux/stat.h>
+#include <fcntl.h>
+// #include <linux/types.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#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/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h
new file mode 100644
index 0000000..b2fa3a0
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h
@@ -0,0 +1,50 @@
+/* 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 <linux/types.h>
+
+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/libloc_api_50001/loc_eng_dmn_conn_handler.cpp b/gps/libloc_api_50001/loc_eng_dmn_conn_handler.cpp
new file mode 100644
index 0000000..edd53f2
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_dmn_conn_handler.cpp
@@ -0,0 +1,237 @@
+/* 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#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/libloc_api_50001/loc_eng_dmn_conn_handler.h b/gps/libloc_api_50001/loc_eng_dmn_conn_handler.h
new file mode 100644
index 0000000..1c0edd5
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_dmn_conn_handler.h
@@ -0,0 +1,106 @@
+/* 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 <linux/types.h>
+#include <arpa/inet.h>
+
+//for SSID_BUF_SIZE
+#include <hardware/gps.h>
+
+#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/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c b/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c
new file mode 100644
index 0000000..9fed9d4
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c
@@ -0,0 +1,399 @@
+/* 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 <stdio.h>
+
+#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/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h b/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h
new file mode 100644
index 0000000..89e598b
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h
@@ -0,0 +1,74 @@
+/* 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 <pthread.h>
+
+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/libloc_api_50001/loc_eng_log.cpp b/gps/libloc_api_50001/loc_eng_log.cpp
new file mode 100644
index 0000000..3a34167
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_log.cpp
@@ -0,0 +1,35 @@
+/* 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/libloc_api_50001/loc_eng_log.h b/gps/libloc_api_50001/loc_eng_log.h
new file mode 100644
index 0000000..a68bd84
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_log.h
@@ -0,0 +1,44 @@
+/* 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 <ctype.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LOC_ENG_LOG_H */
diff --git a/gps/libloc_api_50001/loc_eng_msg.h b/gps/libloc_api_50001/loc_eng_msg.h
new file mode 100644
index 0000000..ae962f5
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_msg.h
@@ -0,0 +1,296 @@
+/* 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 <hardware/gps.h>
+#include <gps_extended.h>
+#include <stdlib.h>
+#include <string.h>
+#include <log_util.h>
+#include <loc_eng_log.h>
+#include <loc_eng.h>
+#include <MsgTask.h>
+#include <LocEngAdapter.h>
+
+#ifndef SSID_BUF_SIZE
+ #define SSID_BUF_SIZE (32+1)
+#endif
+#ifdef USE_GLIB
+
+#include <glib.h>
+
+#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 GpsSvStatus mSvStatus;
+ const GpsLocationExtended mLocationExtended;
+ const void* mSvExt;
+ LocEngReportSv(LocAdapterBase* adapter,
+ GpsSvStatus &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 &notif,
+ 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;
+};
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* LOC_ENG_MSG_H */
diff --git a/gps/libloc_api_50001/loc_eng_ni.cpp b/gps/libloc_api_50001/loc_eng_ni.cpp
new file mode 100644
index 0000000..f017cab
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_ni.cpp
@@ -0,0 +1,355 @@
+/* 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 <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <pthread.h>
+#include <errno.h>
+#include <string.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <time.h>
+#include <MsgTask.h>
+
+#include <loc_eng.h>
+
+#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;
+
+ if (NULL == loc_eng_data.ni_notify_cb) {
+ EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
+ return;
+ }
+
+ /* If busy, use default or deny */
+ if (NULL != loc_eng_ni_data_p->rawRequest)
+ {
+ /* XXX Consider sending a NO RESPONSE reply or queue the request */
+ LOC_LOGW("loc_eng_ni_request_handler, notification in progress, new NI request ignored, type: %d",
+ notif->ni_type);
+ if (NULL != passThrough) {
+ free((void*)passThrough);
+ }
+ }
+ else {
+ /* Save request */
+ loc_eng_ni_data_p->rawRequest = (void*)passThrough;
+
+ /* Fill in notification */
+ ((GpsNiNotification*)notif)->notification_id = loc_eng_ni_data_p->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.
+ **/
+ loc_eng_ni_data_p->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", loc_eng_ni_data_p->respTimeLeft);
+
+ int rc = 0;
+ rc = pthread_create(&loc_eng_ni_data_p->thread, NULL, ni_thread_proc, &loc_eng_data);
+ if (rc)
+ {
+ LOC_LOGE("Loc NI thread is not created.\n");
+ }
+ rc = pthread_detach(loc_eng_ni_data_p->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_data_s_type* loc_eng_data_p = (loc_eng_data_s_type*)args;
+ loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data_p->loc_eng_ni_data;
+ 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(&loc_eng_ni_data_p->tLock);
+ /* Calculate absolute expire time */
+ gettimeofday(&present_time, NULL);
+ expire_time.tv_sec = present_time.tv_sec + loc_eng_ni_data_p->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, loc_eng_ni_data_p->respTimeLeft );
+
+ while (!loc_eng_ni_data_p->respRecvd)
+ {
+ rc = pthread_cond_timedwait(&loc_eng_ni_data_p->tCond,
+ &loc_eng_ni_data_p->tLock,
+ &expire_time);
+ if (rc == ETIMEDOUT)
+ {
+ loc_eng_ni_data_p->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 );
+ loc_eng_ni_data_p->respRecvd = FALSE; /* Reset the user response flag for the next session*/
+
+ // 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 = loc_eng_data_p->adapter;
+ LocEngInformNiResponse *msg = NULL;
+
+ if (NULL != loc_eng_ni_data_p->rawRequest) {
+ msg = new LocEngInformNiResponse(adapter,
+ loc_eng_ni_data_p->resp,
+ loc_eng_ni_data_p->rawRequest);
+ loc_eng_ni_data_p->rawRequest = NULL;
+ }
+ pthread_mutex_unlock(&loc_eng_ni_data_p->tLock);
+
+ loc_eng_ni_data_p->respTimeLeft = 0;
+ loc_eng_ni_data_p->reqID++;
+
+ if (NULL != msg) {
+ 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->rawRequest) {
+ free(loc_eng_ni_data_p->rawRequest);
+ loc_eng_ni_data_p->rawRequest = NULL;
+
+ pthread_mutex_lock(&loc_eng_ni_data_p->tLock);
+ // the goal is to wake up ni_thread_proc
+ // and let it exit.
+ loc_eng_ni_data_p->respRecvd = TRUE;
+ pthread_cond_signal(&loc_eng_ni_data_p->tCond);
+ pthread_mutex_unlock(&loc_eng_ni_data_p->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->respTimeLeft = 0;
+ loc_eng_ni_data_p->respRecvd = FALSE;
+ loc_eng_ni_data_p->rawRequest = NULL;
+ loc_eng_ni_data_p->reqID = 0;
+ pthread_cond_init(&loc_eng_ni_data_p->tCond, NULL);
+ pthread_mutex_init(&loc_eng_ni_data_p->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;
+
+ 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->reqID &&
+ NULL != loc_eng_ni_data_p->rawRequest)
+ {
+ LOC_LOGI("loc_eng_ni_respond: send user response %d for notif %d", user_response, notif_id);
+ pthread_mutex_lock(&loc_eng_ni_data_p->tLock);
+ loc_eng_ni_data_p->resp = user_response;
+ loc_eng_ni_data_p->respRecvd = TRUE;
+ pthread_cond_signal(&loc_eng_ni_data_p->tCond);
+ pthread_mutex_unlock(&loc_eng_ni_data_p->tLock);
+ }
+ else {
+ LOC_LOGE("loc_eng_ni_respond: reqID %d and notif_id %d mismatch or rawRequest %p, response: %d",
+ loc_eng_ni_data_p->reqID, notif_id, loc_eng_ni_data_p->rawRequest, user_response);
+ }
+
+ EXIT_LOG(%s, VOID_RET);
+}
diff --git a/gps/libloc_api_50001/loc_eng_ni.h b/gps/libloc_api_50001/loc_eng_ni.h
new file mode 100644
index 0000000..9cbc57d
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_ni.h
@@ -0,0 +1,50 @@
+/* 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_NI_H
+#define LOC_ENG_NI_H
+
+#include <stdbool.h>
+
+#define LOC_NI_NO_RESPONSE_TIME 20 /* secs */
+#define LOC_NI_NOTIF_KEY_ADDRESS "Address"
+
+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;
+} loc_eng_ni_data_s_type;
+
+
+#endif /* LOC_ENG_NI_H */
diff --git a/gps/libloc_api_50001/loc_eng_nmea.cpp b/gps/libloc_api_50001/loc_eng_nmea.cpp
new file mode 100644
index 0000000..842eda1
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_nmea.cpp
@@ -0,0 +1,833 @@
+/* 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 <loc_eng.h>
+#include <loc_eng_nmea.h>
+#include <math.h>
+#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();
+
+ char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0};
+ char* pMarker = sentence;
+ int lengthRemaining = sizeof(sentence);
+ int length = 0;
+
+ time_t utcTime(location.gpsLocation.timestamp/1000);
+ tm * pTm = gmtime(&utcTime);
+ 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 GpsSvStatus &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
+
+ if (svStatus.used_in_fix_mask == 0)
+ { // No sv used, so there will be no position report, so send
+ // blank NMEA sentences
+ 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);
+ }
+ else
+ { // 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.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/libloc_api_50001/loc_eng_nmea.h b/gps/libloc_api_50001/loc_eng_nmea.h
new file mode 100644
index 0000000..40c6dbb
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_nmea.h
@@ -0,0 +1,42 @@
+/* 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 <hardware/gps.h>
+
+#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 GpsSvStatus &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/libloc_api_50001/loc_eng_xtra.cpp b/gps/libloc_api_50001/loc_eng_xtra.cpp
new file mode 100644
index 0000000..4582286
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_xtra.cpp
@@ -0,0 +1,167 @@
+/* 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 <loc_eng.h>
+#include <MsgTask.h>
+#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();
+ }
+};
+
+/*===========================================================================
+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;
+
+ 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;
+ }
+ 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: success
+ >0: failure
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data,
+ char* data, int length)
+{
+ LocEngAdapter* adapter = loc_eng_data.adapter;
+ adapter->sendMsg(new LocEngInjectXtraData(adapter, data, length));
+
+ return 0;
+}
+/*===========================================================================
+FUNCTION loc_eng_xtra_request_server
+
+DESCRIPTION
+ Request the Xtra server url from the modem
+
+DEPENDENCIES
+ N/A
+
+RETURN VALUE
+ length of server string
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data)
+{
+ LocEngAdapter* adapter = loc_eng_data.adapter;
+ adapter->sendMsg(new LocEngRequestXtraServer(adapter));
+
+ return 0;
+
+}
diff --git a/gps/libloc_api_50001/loc_eng_xtra.h b/gps/libloc_api_50001/loc_eng_xtra.h
new file mode 100644
index 0000000..175f497
--- /dev/null
+++ b/gps/libloc_api_50001/loc_eng_xtra.h
@@ -0,0 +1,47 @@
+/* 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 <hardware/gps.h>
+
+// 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/platform_lib_abstractions/elapsed_millis_since_boot.cpp b/gps/platform_lib_abstractions/elapsed_millis_since_boot.cpp
new file mode 100644
index 0000000..e8cb93a
--- /dev/null
+++ b/gps/platform_lib_abstractions/elapsed_millis_since_boot.cpp
@@ -0,0 +1,46 @@
+/* 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 <stdlib.h>
+#include <sys/time.h>
+#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/platform_lib_abstractions/platform_lib_includes.h b/gps/platform_lib_abstractions/platform_lib_includes.h
new file mode 100644
index 0000000..5858674
--- /dev/null
+++ b/gps/platform_lib_abstractions/platform_lib_includes.h
@@ -0,0 +1,35 @@
+/* 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/platform_lib_abstractions/platform_lib_macros.h b/gps/platform_lib_abstractions/platform_lib_macros.h
new file mode 100644
index 0000000..bc48dd9
--- /dev/null
+++ b/gps/platform_lib_abstractions/platform_lib_macros.h
@@ -0,0 +1,81 @@
+/* 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 <sys/time.h>
+
+#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/platform_lib_abstractions/platform_lib_time.h b/gps/platform_lib_abstractions/platform_lib_time.h
new file mode 100644
index 0000000..ce013af
--- /dev/null
+++ b/gps/platform_lib_abstractions/platform_lib_time.h
@@ -0,0 +1,35 @@
+/* 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/gps/sap.conf b/gps/sap.conf
new file mode 100644
index 0000000..25866ef
--- /dev/null
+++ b/gps/sap.conf
@@ -0,0 +1,41 @@
+################################
+# Sensor Settings
+################################
+
+# Needs to be set explicitly based on sensor
+# There is no default value.
+# used in loc_eng_reinit
+#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=1
+
+# 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
diff --git a/gps/utils/Android.mk b/gps/utils/Android.mk
new file mode 100644
index 0000000..1a80b2d
--- /dev/null
+++ b/gps/utils/Android.mk
@@ -0,0 +1,56 @@
+ifneq ($(BUILD_TINY_ANDROID),true)
+#Compile this library only for builds with the latest modem image
+
+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 \
+ loc_timer.c \
+ ../platform_lib_abstractions/elapsed_millis_since_boot.cpp
+
+
+LOCAL_CFLAGS += \
+ -fno-short-enums \
+ -D_ANDROID_
+
+LOCAL_LDFLAGS += -Wl,--export-dynamic
+
+## Includes
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../platform_lib_abstractions
+
+LOCAL_COPY_HEADERS_TO:= gps.utils/
+LOCAL_COPY_HEADERS:= \
+ loc_log.h \
+ loc_cfg.h \
+ log_util.h \
+ linked_list.h \
+ msg_q.h \
+ loc_target.h \
+ loc_timer.h \
+ ../platform_lib_abstractions/platform_lib_includes.h \
+ ../platform_lib_abstractions/platform_lib_time.h \
+ ../platform_lib_abstractions/platform_lib_macros.h
+
+
+LOCAL_MODULE := libgps.utils
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
+include $(BUILD_SHARED_LIBRARY)
+endif # not BUILD_TINY_ANDROID
diff --git a/gps/utils/Makefile.am b/gps/utils/Makefile.am
new file mode 100644
index 0000000..e5935f0
--- /dev/null
+++ b/gps/utils/Makefile.am
@@ -0,0 +1,44 @@
+AM_CFLAGS = -Wundef \
+ -MD \
+ -Wno-trigraphs \
+ -g -O0 \
+ -fno-inline \
+ -fno-short-enums \
+ -fpic \
+ -I../platform_lib_abstractions
+
+libgps_utils_so_la_h_sources = log_util.h \
+ msg_q.h \
+ linked_list.h \
+ loc_cfg.h \
+ loc_log.h \
+ ../platform_lib_abstractions/platform_lib_includes.h \
+ ../platform_lib_abstractions/platform_lib_time.h \
+ ../platform_lib_abstractions/platform_lib_macros.h
+
+libgps_utils_so_la_c_sources = linked_list.c \
+ msg_q.c \
+ loc_cfg.cpp \
+ loc_log.cpp \
+ ../platform_lib_abstractions/elapsed_millis_since_boot.cpp
+
+library_includedir = $(pkgincludedir)/utils
+
+library_include_HEADERS = $(libgps_utils_so_la_h_sources)
+
+libgps_utils_so_la_SOURCES = $(libgps_utils_so_la_c_sources)
+
+if USE_GLIB
+libgps_utils_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
+libgps_utils_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
+libgps_utils_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
+else
+libgps_utils_so_la_CFLAGS = $(AM_CFLAGS)
+libgps_utils_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
+libgps_utils_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
+endif
+
+libgps_utils_so_la_LIBADD = -lstdc++ -lcutils
+
+#Create and Install libraries
+lib_LTLIBRARIES = libgps_utils_so.la
diff --git a/gps/utils/linked_list.c b/gps/utils/linked_list.c
new file mode 100644
index 0000000..92617fe
--- /dev/null
+++ b/gps/utils/linked_list.c
@@ -0,0 +1,328 @@
+/* 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 <stdio.h>
+#include <string.h>
+
+#define LOG_TAG "LocSvc_utils_ll"
+#include "log_util.h"
+#include "platform_lib_includes.h"
+#include <stdlib.h>
+#include <stdint.h>
+
+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_LOGD("%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_LOGD("%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_LOGD("%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
new file mode 100644
index 0000000..a85f09a
--- /dev/null
+++ b/gps/utils/linked_list.h
@@ -0,0 +1,217 @@
+/* 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 <stdbool.h>
+#include <stdlib.h>
+
+/** 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
new file mode 100644
index 0000000..73d1ca4
--- /dev/null
+++ b/gps/utils/loc_cfg.cpp
@@ -0,0 +1,286 @@
+/* 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_utils_cfg"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <string.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <time.h>
+#include <loc_cfg.h>
+#include <log_util.h>
+#ifdef USE_GLIB
+#include <glib.h>
+#endif
+#include "platform_lib_includes.h"
+
+/*=============================================================================
+ *
+ * GLOBAL DATA DECLARATION
+ *
+ *============================================================================*/
+
+/* Parameter data */
+static uint8_t DEBUG_LEVEL = 0xff;
+static uint8_t TIMESTAMP = 0;
+
+/* Parameter spec table */
+static loc_param_s_type loc_parameter_table[] =
+{
+ {"DEBUG_LEVEL", &DEBUG_LEVEL, NULL, 'n'},
+ {"TIMESTAMP", &TIMESTAMP, NULL, 'n'},
+};
+int loc_param_num = sizeof(loc_parameter_table) / sizeof(loc_param_s_type);
+
+/*===========================================================================
+FUNCTION trim_space
+
+DESCRIPTION
+ Removes leading and trailing spaces of the string
+
+DEPENDENCIES
+ N/A
+
+RETURN VALUE
+ None
+
+SIDE EFFECTS
+ N/A
+===========================================================================*/
+void trim_space(char *org_string)
+{
+ char *scan_ptr, *write_ptr;
+ char *first_nonspace = NULL, *last_nonspace = NULL;
+
+ scan_ptr = write_ptr = org_string;
+
+ while (*scan_ptr)
+ {
+ if ( !isspace(*scan_ptr) && first_nonspace == NULL)
+ {
+ first_nonspace = scan_ptr;
+ }
+
+ if (first_nonspace != NULL)
+ {
+ *(write_ptr++) = *scan_ptr;
+ if ( !isspace(*scan_ptr))
+ {
+ last_nonspace = write_ptr;
+ }
+ }
+
+ scan_ptr++;
+ }
+
+ if (last_nonspace) { *last_nonspace = '\0'; }
+}
+
+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
+===========================================================================*/
+void loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value)
+{
+ if(NULL == config_entry || NULL == config_value)
+ {
+ LOC_LOGE("%s: INVALID config entry or parameter", __FUNCTION__);
+ return;
+ }
+
+ 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;
+ }
+ 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;
+ }
+ 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;
+ }
+ break;
+ default:
+ LOC_LOGE("%s: PARAM %s parameter type must be n, f, or s", __FUNCTION__, config_entry->param_name);
+ }
+ }
+}
+
+/*===========================================================================
+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, loc_param_s_type* config_table, uint32_t table_length)
+{
+ FILE *gps_conf_fp = NULL;
+ char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */
+ char *lasts;
+ loc_param_v_type config_value;
+ uint32_t i;
+
+ if((gps_conf_fp = fopen(conf_file_name, "r")) != NULL)
+ {
+ LOC_LOGD("%s: using %s", __FUNCTION__, conf_file_name);
+ }
+ else
+ {
+ LOC_LOGW("%s: no %s file found", __FUNCTION__, conf_file_name);
+ loc_logger_init(DEBUG_LEVEL, TIMESTAMP);
+ return; /* no parameter file */
+ }
+
+ /* Clear all validity bits */
+ for(i = 0; NULL != config_table && i < table_length; i++)
+ {
+ if(NULL != config_table[i].param_set)
+ {
+ *(config_table[i].param_set) = 0;
+ }
+ }
+
+ while(fgets(input_buf, LOC_MAX_PARAM_LINE, gps_conf_fp) != NULL)
+ {
+ memset(&config_value, 0, sizeof(config_value));
+
+ /* Separate variable and value */
+ config_value.param_name = strtok_r(input_buf, "=", &lasts);
+ if (config_value.param_name == NULL) continue; /* skip lines that do not contain "=" */
+ config_value.param_str_value = strtok_r(NULL, "=", &lasts);
+ if (config_value.param_str_value == NULL) continue; /* skip lines that do not contain two operands */
+
+ /* Trim leading and trailing spaces */
+ trim_space(config_value.param_name);
+ trim_space(config_value.param_str_value);
+
+ /* Parse numerical value */
+ if (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(i = 0; NULL != config_table && i < table_length; i++)
+ {
+ loc_set_config_entry(&config_table[i], &config_value);
+ }
+
+ for(i = 0; i < loc_param_num; i++)
+ {
+ loc_set_config_entry(&loc_parameter_table[i], &config_value);
+ }
+ }
+
+ fclose(gps_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
new file mode 100644
index 0000000..df83338
--- /dev/null
+++ b/gps/utils/loc_cfg.h
@@ -0,0 +1,83 @@
+/* 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_CFG_H
+#define LOC_CFG_H
+
+#include <stdint.h>
+
+#define LOC_MAX_PARAM_NAME 48
+#define LOC_MAX_PARAM_STRING 80
+#define LOC_MAX_PARAM_LINE 80
+
+#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
+{
+ char param_name[LOC_MAX_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
+ *
+ *============================================================================*/
+extern void loc_read_conf(const char* conf_file_name,
+ 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
new file mode 100644
index 0000000..597b5b6
--- /dev/null
+++ b/gps/utils/loc_log.cpp
@@ -0,0 +1,234 @@
+/* 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.
+ *
+ */
+
+#define LOG_NDDEBUG 0
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include "loc_log.h"
+#include "msg_q.h"
+#ifdef USE_GLIB
+#include <time.h>
+#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";
+
+/* Logging Mechanism */
+loc_logger_s_type loc_logger;
+
+/* Get names from value */
+const char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, long mask)
+{
+ int 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(loc_name_val_s_type table[], int table_size, long value)
+{
+ int i;
+ for (i = 0; i < table_size; i++)
+ {
+ if (table[i].val == (long) value)
+ {
+ return table[i].name;
+ }
+ }
+ return UNKNOWN_STR;
+}
+
+static 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 int loc_msg_q_status_num = sizeof(loc_msg_q_status) / sizeof(loc_name_val_s_type);
+
+/* 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
+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_UNKNOWN)
+};
+
+static int target_name_num = sizeof(target_name)/sizeof(loc_name_val_s_type);
+
+/*===========================================================================
+
+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 >= target_name_num || index < 0)
+ 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, unsigned long 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;
+ 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
new file mode 100644
index 0000000..82dc636
--- /dev/null
+++ b/gps/utils/loc_log.h
@@ -0,0 +1,68 @@
+/* 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_LOG_H
+#define LOC_LOG_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <ctype.h>
+#include "loc_target.h"
+
+typedef struct
+{
+ char name[128];
+ 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))
+
+/* Get names from value */
+const char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, long mask);
+const char* loc_get_name_from_val(loc_name_val_s_type table[], int 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, unsigned long buf_size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LOC_LOG_H */
diff --git a/gps/utils/loc_target.cpp b/gps/utils/loc_target.cpp
new file mode 100644
index 0000000..a3ef6b3
--- /dev/null
+++ b/gps/utils/loc_target.cpp
@@ -0,0 +1,208 @@
+/* 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.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <hardware/gps.h>
+#include <cutils/properties.h>
+#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 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
+#define QCA1530_DETECT_TIMEOUT 30
+#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[] = "persist.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;
+}
+
+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;
+ }
+
+ property_get("ro.baseband", 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_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;
+}
diff --git a/gps/utils/loc_target.h b/gps/utils/loc_target.h
new file mode 100644
index 0000000..4aebb85
--- /dev/null
+++ b/gps/utils/loc_target.h
@@ -0,0 +1,68 @@
+/* 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_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_UNKNOWN TARGET_SET(GNSS_UNKNOWN, NO_SSC)
+#define getTargetGnssType(target) (target>>1)
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+unsigned int loc_get_target(void);
+
+/* 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_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.c b/gps/utils/loc_timer.c
new file mode 100644
index 0000000..1e4008e
--- /dev/null
+++ b/gps/utils/loc_timer.c
@@ -0,0 +1,186 @@
+/* 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<stdio.h>
+#include<stdlib.h>
+#include<sys/time.h>
+#include "loc_timer.h"
+#include<time.h>
+#include<errno.h>
+
+enum timer_state {
+ READY = 100,
+ WAITING,
+ DONE,
+ ABORT
+};
+
+typedef struct {
+ loc_timer_callback callback_func;
+ void *user_data;
+ unsigned int time_msec;
+ pthread_cond_t timer_cond;
+ pthread_mutex_t timer_mutex;
+ enum timer_state state;
+}timer_data;
+
+static void *timer_thread(void *thread_data)
+{
+ int ret = -ETIMEDOUT;
+ struct timespec ts;
+ struct timeval tv;
+ timer_data* t = (timer_data*)thread_data;
+
+ LOC_LOGD("%s:%d]: Enter. Delay = %d\n", __func__, __LINE__, t->time_msec);
+
+ gettimeofday(&tv, NULL);
+ clock_gettime(CLOCK_REALTIME, &ts);
+ if(t->time_msec >= 1000) {
+ ts.tv_sec += t->time_msec/1000;
+ t->time_msec = t->time_msec % 1000;
+ }
+ if(t->time_msec)
+ ts.tv_nsec += t->time_msec * 1000000;
+ if(ts.tv_nsec > 999999999) {
+ LOC_LOGD("%s:%d]: Large nanosecs\n", __func__, __LINE__);
+ ts.tv_sec += 1;
+ ts.tv_nsec -= 1000000000;
+ }
+ LOC_LOGD("%s:%d]: ts.tv_sec:%d; ts.tv_nsec:%d\n"
+ "\t Current time: %d sec; %d nsec",
+ __func__, __LINE__, (int)ts.tv_sec, (int)ts.tv_nsec,
+ (int)tv.tv_sec, (int)tv.tv_usec*1000);
+
+ pthread_mutex_lock(&(t->timer_mutex));
+ if (READY == t->state) {
+ t->state = WAITING;
+ ret = pthread_cond_timedwait(&t->timer_cond, &t->timer_mutex, &ts);
+ t->state = DONE;
+ }
+ pthread_mutex_unlock(&(t->timer_mutex));
+
+ switch (ret) {
+ case ETIMEDOUT:
+ LOC_LOGV("%s:%d]: loc_timer timed out", __func__, __LINE__);
+ break;
+ case 0:
+ LOC_LOGV("%s:%d]: loc_timer stopped", __func__, __LINE__);
+ break;
+ case -ETIMEDOUT:
+ LOC_LOGV("%s:%d]: loc_timer cancelled", __func__, __LINE__);
+ break;
+ default:
+ LOC_LOGE("%s:%d]: Call to pthread timedwait failed; ret=%d\n",
+ __func__, __LINE__, ret);
+ break;
+ }
+
+ pthread_mutex_destroy(&t->timer_mutex);
+ pthread_cond_destroy(&t->timer_cond);
+
+ if(ETIMEDOUT == ret)
+ t->callback_func(t->user_data, ret);
+
+ free(t);
+ LOC_LOGD("%s:%d]: Exit\n", __func__, __LINE__);
+ return NULL;
+}
+
+void* loc_timer_start(unsigned int msec, loc_timer_callback cb_func,
+ void* caller_data)
+{
+ timer_data *t=NULL;
+ pthread_attr_t tattr;
+ pthread_t id;
+ LOC_LOGD("%s:%d]: Enter\n", __func__, __LINE__);
+ if(cb_func == NULL || msec == 0) {
+ LOC_LOGE("%s:%d]: Error: Wrong parameters\n", __func__, __LINE__);
+ goto _err;
+ }
+ t = (timer_data *)calloc(1, sizeof(timer_data));
+ if(t == NULL) {
+ LOC_LOGE("%s:%d]: Could not allocate memory. Failing.\n",
+ __func__, __LINE__);
+ goto _err;
+ }
+
+ if(pthread_cond_init(&(t->timer_cond), NULL)) {
+ LOC_LOGE("%s:%d]: Pthread cond init failed\n", __func__, __LINE__);
+ goto t_err;
+ }
+ if(pthread_mutex_init(&(t->timer_mutex), NULL)) {
+ LOC_LOGE("%s:%d]: Pthread mutex init failed\n", __func__, __LINE__);
+ goto cond_err;
+ }
+
+ t->callback_func = cb_func;
+ t->user_data = caller_data;
+ t->time_msec = msec;
+ t->state = READY;
+
+ if (pthread_attr_init(&tattr)) {
+ LOC_LOGE("%s:%d]: Pthread mutex init failed\n", __func__, __LINE__);
+ goto mutex_err;
+ }
+ pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
+
+ if(pthread_create(&(id), &tattr, timer_thread, (void *)t)) {
+ LOC_LOGE("%s:%d]: Could not create thread\n", __func__, __LINE__);
+ goto attr_err;
+ }
+
+ LOC_LOGD("%s:%d]: Created thread with id: %d\n",
+ __func__, __LINE__, (int)id);
+ goto _err;
+
+attr_err:
+ pthread_attr_destroy(&tattr);
+mutex_err:
+ pthread_mutex_destroy(&t->timer_mutex);
+cond_err:
+ pthread_cond_destroy(&t->timer_cond);
+t_err:
+ free(t);
+_err:
+ LOC_LOGD("%s:%d]: Exit\n", __func__, __LINE__);
+ return t;
+}
+
+void loc_timer_stop(void* handle) {
+ timer_data* t = (timer_data*)handle;
+
+ if (NULL != t && (READY == t->state || WAITING == t->state)) {
+ pthread_mutex_lock(&(t->timer_mutex));
+ if (READY == t->state || WAITING == t->state) {
+ pthread_cond_signal(&t->timer_cond);
+ t->state = ABORT;
+ }
+ pthread_mutex_unlock(&(t->timer_mutex));
+ }
+}
diff --git a/gps/utils/loc_timer.h b/gps/utils/loc_timer.h
new file mode 100644
index 0000000..0034d27
--- /dev/null
+++ b/gps/utils/loc_timer.h
@@ -0,0 +1,63 @@
+/* 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 __LOC_DELAY_H__
+#define __LOC_DELAY_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#include<pthread.h>
+#include "log_util.h"
+
+/*
+ Return values:
+ Success = 0
+ Failure = Non zero
+*/
+typedef void(*loc_timer_callback)(void *user_data, int result);
+
+
+/*
+ Returns the handle, which can be used to stop the timer
+*/
+void* loc_timer_start(unsigned int delay_msec,
+ loc_timer_callback,
+ void* user_data);
+
+/*
+ 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
new file mode 100644
index 0000000..7fb0c78
--- /dev/null
+++ b/gps/utils/log_util.h
@@ -0,0 +1,171 @@
+/* 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 __LOG_UTIL_H__
+#define __LOG_UTIL_H__
+
+#ifndef USE_GLIB
+#include <utils/Log.h>
+#endif /* USE_GLIB */
+
+#ifdef USE_GLIB
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#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[];
+/*=============================================================================
+ *
+ * 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 LOC_LOGE(...) \
+if ((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("W/"__VA_ARGS__); } \
+else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGE("W/"__VA_ARGS__); }
+
+#define LOC_LOGW(...) \
+if ((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("W/"__VA_ARGS__); } \
+else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGW("W/"__VA_ARGS__); }
+
+#define LOC_LOGI(...) \
+if ((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("I/"__VA_ARGS__); } \
+else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGI("I/"__VA_ARGS__); }
+
+#define LOC_LOGD(...) \
+if ((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("D/"__VA_ARGS__); } \
+else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGD("D/"__VA_ARGS__); }
+
+#define LOC_LOGV(...) \
+if ((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("V/"__VA_ARGS__); } \
+else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGV("V/"__VA_ARGS__); }
+
+#else /* DEBUG_DMN_LOC_API */
+
+#define LOC_LOGE(...) ALOGE("E/"__VA_ARGS__)
+
+#define LOC_LOGW(...) ALOGW("W/"__VA_ARGS__)
+
+#define LOC_LOGI(...) ALOGI("I/"__VA_ARGS__)
+
+#define LOC_LOGD(...) ALOGD("D/"__VA_ARGS__)
+
+#define LOC_LOGV(...) ALOGV("V/"__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 ENTRY_LOG() LOG_V(ENTRY_TAG, __func__, %s, "")
+#define EXIT_LOG(SPEC, VAL) LOG_V(EXIT_TAG, __func__, SPEC, VAL)
+
+
+// Used for logging callflow from Android Framework
+#define ENTRY_LOG_CALLFLOW() LOG_I(FROM_AFW, __func__, %s, "")
+// Used for logging callflow to Modem
+#define EXIT_LOG_CALLFLOW(SPEC, VAL) LOG_I(TO_MODEM, __func__, SPEC, VAL)
+// Used for logging callflow from Modem(TO_MODEM, __func__, %s, "")
+#define MODEM_LOG_CALLFLOW(SPEC, VAL) LOG_I(FROM_MODEM, __func__, 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
new file mode 100644
index 0000000..f82d4c0
--- /dev/null
+++ b/gps/utils/msg_q.c
@@ -0,0 +1,336 @@
+/* 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 <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+
+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_LOGD("%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_LOGD("%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_LOGD("%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_LOGD("%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
new file mode 100644
index 0000000..453b8ce
--- /dev/null
+++ b/gps/utils/msg_q.h
@@ -0,0 +1,207 @@
+/* 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 <stdlib.h>
+
+/** 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/include/device_perms.h b/include/device_perms.h
new file mode 100644
index 0000000..05c914f
--- /dev/null
+++ b/include/device_perms.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod 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 DEVICE_PERMS_H
+#define DEVICE_PERMS_H
+
+#define PROPERTY_PERMS_APPEND \
+ { "camera.", AID_MEDIA, 0 },
+
+#define CONTROL_PERMS_APPEND \
+ { "media.cacao", AID_MEDIA, AID_MEDIA },
+
+#endif /* DEVICE_PERMS_H */
+
diff --git a/include/private/android_filesystem_capability.h b/include/private/android_filesystem_capability.h
new file mode 100644
index 0000000..0505cda
--- /dev/null
+++ b/include/private/android_filesystem_capability.h
@@ -0,0 +1,117 @@
+/*
+ * 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.
+ */
+
+/*
+ * Taken from linux/capability.h, with minor modifications
+ */
+
+#ifndef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_FILESYSTEM_CAPABILITY_H
+#define _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_FILESYSTEM_CAPABILITY_H
+
+#include <stdint.h>
+
+#define __user
+#define __u32 uint32_t
+#define __le32 uint32_t
+
+#define _LINUX_CAPABILITY_VERSION_1 0x19980330
+#define _LINUX_CAPABILITY_U32S_1 1
+#define _LINUX_CAPABILITY_VERSION_2 0x20071026
+#define _LINUX_CAPABILITY_U32S_2 2
+#define _LINUX_CAPABILITY_VERSION_3 0x20080522
+#define _LINUX_CAPABILITY_U32S_3 2
+
+typedef struct __user_cap_header_struct {
+ __u32 version;
+ int pid;
+} __user *cap_user_header_t;
+
+typedef struct __user_cap_data_struct {
+ __u32 effective;
+ __u32 permitted;
+ __u32 inheritable;
+} __user *cap_user_data_t;
+
+#define VFS_CAP_REVISION_MASK 0xFF000000
+#define VFS_CAP_REVISION_SHIFT 24
+#define VFS_CAP_FLAGS_MASK ~VFS_CAP_REVISION_MASK
+#define VFS_CAP_FLAGS_EFFECTIVE 0x000001
+#define VFS_CAP_REVISION_1 0x01000000
+#define VFS_CAP_U32_1 1
+#define XATTR_CAPS_SZ_1 (sizeof(__le32)*(1 + 2*VFS_CAP_U32_1))
+#define VFS_CAP_REVISION_2 0x02000000
+#define VFS_CAP_U32_2 2
+#define XATTR_CAPS_SZ_2 (sizeof(__le32)*(1 + 2*VFS_CAP_U32_2))
+#define XATTR_CAPS_SZ XATTR_CAPS_SZ_2
+#define VFS_CAP_U32 VFS_CAP_U32_2
+#define VFS_CAP_REVISION VFS_CAP_REVISION_2
+
+struct vfs_cap_data {
+ __le32 magic_etc;
+ struct {
+ __le32 permitted;
+ __le32 inheritable;
+ } data[VFS_CAP_U32];
+};
+
+#define _LINUX_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_1
+#define _LINUX_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_1
+#define CAP_CHOWN 0
+#define CAP_DAC_OVERRIDE 1
+#define CAP_DAC_READ_SEARCH 2
+#define CAP_FOWNER 3
+#define CAP_FSETID 4
+#define CAP_KILL 5
+#define CAP_SETGID 6
+#define CAP_SETUID 7
+#define CAP_SETPCAP 8
+#define CAP_LINUX_IMMUTABLE 9
+#define CAP_NET_BIND_SERVICE 10
+#define CAP_NET_BROADCAST 11
+#define CAP_NET_ADMIN 12
+#define CAP_NET_RAW 13
+#define CAP_IPC_LOCK 14
+#define CAP_IPC_OWNER 15
+#define CAP_SYS_MODULE 16
+#define CAP_SYS_RAWIO 17
+#define CAP_SYS_CHROOT 18
+#define CAP_SYS_PTRACE 19
+#define CAP_SYS_PACCT 20
+#define CAP_SYS_ADMIN 21
+#define CAP_SYS_BOOT 22
+#define CAP_SYS_NICE 23
+#define CAP_SYS_RESOURCE 24
+#define CAP_SYS_TIME 25
+#define CAP_SYS_TTY_CONFIG 26
+#define CAP_MKNOD 27
+#define CAP_LEASE 28
+#define CAP_AUDIT_WRITE 29
+#define CAP_AUDIT_CONTROL 30
+#define CAP_SETFCAP 31
+#define CAP_MAC_OVERRIDE 32
+#define CAP_MAC_ADMIN 33
+#define CAP_SYSLOG 34
+#define CAP_WAKE_ALARM 35
+#define CAP_LAST_CAP CAP_WAKE_ALARM
+#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
+#define CAP_TO_INDEX(x) ((x) >> 5)
+#define CAP_TO_MASK(x) (1 << ((x) & 31))
+
+#undef __user
+#undef __u32
+#undef __le32
+
+#endif
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
new file mode 100644
index 0000000..8252f15
--- /dev/null
+++ b/include/private/android_filesystem_config.h
@@ -0,0 +1,351 @@
+/*
+ * Copyright (C) 2007 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.
+ */
+
+/* This file is used to define the properties of the filesystem
+** images generated by build tools (mkbootfs and mkyaffs2image) and
+** by the device side of adb.
+*/
+
+#ifndef _ANDROID_FILESYSTEM_CONFIG_H_
+#define _ANDROID_FILESYSTEM_CONFIG_H_
+
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <stdint.h>
+
+#ifdef HAVE_ANDROID_OS
+#include <linux/capability.h>
+#else
+#include "android_filesystem_capability.h"
+#endif
+
+/* This is the master Users and Groups config for the platform.
+ * DO NOT EVER RENUMBER
+ */
+
+#define AID_ROOT 0 /* traditional unix root user */
+
+#define AID_SYSTEM 1000 /* system server */
+
+#define AID_RADIO 1001 /* telephony subsystem, RIL */
+#define AID_BLUETOOTH 1002 /* bluetooth subsystem */
+#define AID_GRAPHICS 1003 /* graphics devices */
+#define AID_INPUT 1004 /* input devices */
+#define AID_AUDIO 1005 /* audio devices */
+#define AID_CAMERA 1006 /* camera devices */
+#define AID_LOG 1007 /* log devices */
+#define AID_COMPASS 1008 /* compass device */
+#define AID_MOUNT 1009 /* mountd socket */
+#define AID_WIFI 1010 /* wifi subsystem */
+#define AID_ADB 1011 /* android debug bridge (adbd) */
+#define AID_INSTALL 1012 /* group for installing packages */
+#define AID_MEDIA 1013 /* mediaserver process */
+#define AID_DHCP 1014 /* dhcp client */
+#define AID_SDCARD_RW 1015 /* external storage write access */
+#define AID_VPN 1016 /* vpn system */
+#define AID_KEYSTORE 1017 /* keystore subsystem */
+#define AID_USB 1018 /* USB devices */
+#define AID_DRM 1019 /* DRM server */
+#define AID_MDNSR 1020 /* MulticastDNSResponder (service discovery) */
+#define AID_GPS 1021 /* GPS daemon */
+#define AID_UNUSED1 1022 /* deprecated, DO NOT USE */
+#define AID_MEDIA_RW 1023 /* internal media storage write access */
+#define AID_MTP 1024 /* MTP USB driver access */
+#define AID_UNUSED2 1025 /* deprecated, DO NOT USE */
+#define AID_DRMRPC 1026 /* group for drm rpc */
+#define AID_NFC 1027 /* nfc subsystem */
+#define AID_SDCARD_R 1028 /* external storage read access */
+#define AID_CLAT 1029 /* clat part of nat464 */
+#define AID_LOOP_RADIO 1030 /* loop radio devices */
+#define AID_MEDIA_DRM 1031 /* MediaDrm plugins */
+#define AID_PACKAGE_INFO 1032 /* access to installed package details */
+#define AID_SDCARD_PICS 1033 /* external storage photos access */
+#define AID_SDCARD_AV 1034 /* external storage audio/video access */
+#define AID_SDCARD_ALL 1035 /* access all users external storage */
+#define AID_AUDIT 1036 /* audit daemon */
+
+#define AID_THEMEMAN 1300 /* theme manager */
+
+#define AID_SHELL 2000 /* adb and debug shell user */
+#define AID_CACHE 2001 /* cache access */
+#define AID_DIAG 2002 /* access to diagnostic resources */
+
+// SONY_UIDS
+#define AID_SONY_IDD 2987 /* IDD */
+
+/* The 3000 series are intended for use as supplemental group id's only.
+ * They indicate special Android capabilities that the kernel is aware of. */
+#define AID_NET_BT_ADMIN 3001 /* bluetooth: create any socket */
+#define AID_NET_BT 3002 /* bluetooth: create sco, rfcomm or l2cap sockets */
+#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
+#define AID_NET_RAW 3004 /* can create raw INET sockets */
+#define AID_NET_ADMIN 3005 /* can configure interfaces and routing tables. */
+#define AID_NET_BW_STATS 3006 /* read bandwidth statistics */
+#define AID_NET_BW_ACCT 3007 /* change bandwidth statistics accounting */
+#define AID_NET_BT_STACK 3008 /* bluetooth: access config files */
+#define AID_QCOM_ONCRPC 3009 /* can read/write /dev/oncrpc files */
+#define AID_QCOM_DIAG 3010 /* can read/write /dev/diag */
+
+#if defined(MOTOROLA_UIDS)
+#define AID_MOT_OSH 5000 /* OSH */
+#define AID_MOT_ACCY 9000 /* access to accessory */
+#define AID_MOT_PWRIC 9001 /* power IC */
+#define AID_MOT_USB 9002 /* mot usb */
+#define AID_MOT_DRM 9003 /* can access DRM resource. */
+#define AID_MOT_TCMD 9004 /* mot_tcmd */
+#define AID_MOT_SEC_RTC 9005 /* mot cpcap rtc */
+#define AID_MOT_TOMBSTONE 9006
+#define AID_MOT_TPAPI 9007 /* mot_tpapi */
+#define AID_MOT_SECCLKD 9008 /* mot_secclkd */
+#define AID_MOT_WHISPER 9009 /* Whisper Protocol access */
+#define AID_MOT_CAIF 9010 /* can create CAIF sockets */
+#define AID_MOT_DLNA 9011 /* DLNA native */
+#endif // MOTOROLA_UIDS
+
+#define AID_MISC 9998 /* access to misc storage */
+#define AID_NOBODY 9999
+
+#define AID_APP 10000 /* first app user */
+
+#define AID_ISOLATED_START 99000 /* start of uids for fully isolated sandboxed processes */
+#define AID_ISOLATED_END 99999 /* end of uids for fully isolated sandboxed processes */
+
+#define AID_USER 100000 /* offset for uid ranges for each user */
+
+#define AID_SHARED_GID_START 50000 /* start of gids for apps in each user to share */
+#define AID_SHARED_GID_END 59999 /* start of gids for apps in each user to share */
+
+#if !defined(EXCLUDE_FS_CONFIG_STRUCTURES)
+struct android_id_info {
+ const char *name;
+ unsigned aid;
+};
+
+static const struct android_id_info android_ids[] = {
+ { "root", AID_ROOT, },
+
+ { "system", AID_SYSTEM, },
+
+ { "radio", AID_RADIO, },
+ { "bluetooth", AID_BLUETOOTH, },
+ { "graphics", AID_GRAPHICS, },
+ { "input", AID_INPUT, },
+ { "audio", AID_AUDIO, },
+ { "camera", AID_CAMERA, },
+ { "log", AID_LOG, },
+ { "compass", AID_COMPASS, },
+ { "mount", AID_MOUNT, },
+ { "wifi", AID_WIFI, },
+ { "adb", AID_ADB, },
+ { "install", AID_INSTALL, },
+ { "media", AID_MEDIA, },
+ { "dhcp", AID_DHCP, },
+ { "sdcard_rw", AID_SDCARD_RW, },
+ { "vpn", AID_VPN, },
+ { "keystore", AID_KEYSTORE, },
+ { "usb", AID_USB, },
+ { "drm", AID_DRM, },
+ { "mdnsr", AID_MDNSR, },
+ { "gps", AID_GPS, },
+ // AID_UNUSED1
+ { "media_rw", AID_MEDIA_RW, },
+ { "mtp", AID_MTP, },
+ // AID_UNUSED2
+ { "drmrpc", AID_DRMRPC, },
+ { "nfc", AID_NFC, },
+ { "sdcard_r", AID_SDCARD_R, },
+ { "clat", AID_CLAT, },
+ { "loop_radio", AID_LOOP_RADIO, },
+ { "mediadrm", AID_MEDIA_DRM, },
+ { "package_info", AID_PACKAGE_INFO, },
+ { "sdcard_pics", AID_SDCARD_PICS, },
+ { "sdcard_av", AID_SDCARD_AV, },
+ { "sdcard_all", AID_SDCARD_ALL, },
+
+ { "shell", AID_SHELL, },
+ { "cache", AID_CACHE, },
+ { "diag", AID_DIAG, },
+
+ { "net_bt_admin", AID_NET_BT_ADMIN, },
+ { "net_bt", AID_NET_BT, },
+ { "inet", AID_INET, },
+ { "net_raw", AID_NET_RAW, },
+ { "net_admin", AID_NET_ADMIN, },
+ { "net_bw_stats", AID_NET_BW_STATS, },
+ { "net_bw_acct", AID_NET_BW_ACCT, },
+ { "qcom_oncrpc", AID_QCOM_ONCRPC, },
+ { "qcom_diag", AID_QCOM_DIAG, },
+ { "net_bt_stack", AID_NET_BT_STACK, },
+
+// SONY_UIDS
+ { "sony_idd", AID_SONY_IDD, },
+
+#if defined(MOTOROLA_UIDS)
+ { "mot_osh", AID_MOT_OSH, },
+ { "mot_accy", AID_MOT_ACCY, },
+ { "mot_pwric", AID_MOT_PWRIC, },
+ { "mot_usb", AID_MOT_USB, },
+ { "mot_drm", AID_MOT_DRM, },
+ { "mot_tcmd", AID_MOT_TCMD, },
+ { "mot_sec_rtc", AID_MOT_SEC_RTC, },
+ { "mot_tombstone", AID_MOT_TOMBSTONE, },
+ { "mot_tpapi", AID_MOT_TPAPI, },
+ { "mot_secclkd", AID_MOT_SECCLKD, },
+ { "mot_whisper", AID_MOT_WHISPER, },
+ { "mot_caif", AID_MOT_CAIF, },
+ { "mot_dlna", AID_MOT_DLNA, },
+#endif
+
+ { "misc", AID_MISC, },
+ { "nobody", AID_NOBODY, },
+ { "theme_man", AID_THEMEMAN },
+ { "audit", AID_AUDIT, },
+};
+
+#define android_id_count \
+ (sizeof(android_ids) / sizeof(android_ids[0]))
+
+struct fs_path_config {
+ unsigned mode;
+ unsigned uid;
+ unsigned gid;
+ uint64_t capabilities;
+ const char *prefix;
+};
+
+/* Rules for directories.
+** These rules are applied based on "first match", so they
+** should start with the most specific path and work their
+** way up to the root.
+*/
+
+static const struct fs_path_config android_dirs[] = {
+ { 00770, AID_SYSTEM, AID_CACHE, 0, "cache" },
+ { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app" },
+ { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private" },
+ { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/dalvik-cache" },
+ { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/data" },
+ { 00771, AID_SHELL, AID_SHELL, 0, "data/local/tmp" },
+ { 00771, AID_SHELL, AID_SHELL, 0, "data/local" },
+ { 01771, AID_SYSTEM, AID_MISC, 0, "data/misc" },
+ { 00770, AID_DHCP, AID_DHCP, 0, "data/misc/dhcp" },
+ { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media" },
+ { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/Music" },
+ { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data" },
+ { 00750, AID_ROOT, AID_SHELL, 0, "sbin" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/addon.d" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/bin" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/etc/ppp" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "vendor" },
+ { 00777, AID_ROOT, AID_ROOT, 0, "sdcard" },
+ { 00755, AID_ROOT, AID_ROOT, 0, 0 },
+};
+
+/* Rules for files.
+** These rules are applied based on "first match", so they
+** should start with the most specific path and work their
+** way up to the root. Prefixes ending in * denotes wildcard
+** and will allow partial matches.
+*/
+static const struct fs_path_config android_files[] = {
+ { 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.rc" },
+ { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.sh" },
+ { 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.trout.rc" },
+ { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.ril" },
+ { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.testmenu" },
+ { 00550, AID_DHCP, AID_SHELL, 0, "system/etc/dhcpcd/dhcpcd-run-hooks" },
+ { 00444, AID_RADIO, AID_AUDIO, 0, "system/etc/AudioPara4.csv" },
+ { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/ppp/*" },
+ { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/rc.*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/addon.d/*" },
+ { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app/*" },
+ { 00644, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/*" },
+ { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private/*" },
+ { 00644, AID_APP, AID_APP, 0, "data/data/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/bin/ping" },
+
+ /* the following file is INTENTIONALLY set-gid and not set-uid.
+ * Do not change. */
+ { 02750, AID_ROOT, AID_INET, 0, "system/bin/netcfg" },
+
+ /* the following five files are INTENTIONALLY set-uid, but they
+ * are NOT included on user builds. */
+ { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/su" },
+ { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/librank" },
+ { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procrank" },
+ { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procmem" },
+ { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/tcpdump" },
+ { 04770, AID_ROOT, AID_RADIO, 0, "system/bin/pppd-ril" },
+
+ /* the following files have enhanced capabilities and ARE included in user builds. */
+ { 00750, AID_ROOT, AID_SHELL, (1 << CAP_SETUID) | (1 << CAP_SETGID), "system/bin/run-as" },
+
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/lib/valgrind/*" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin/*" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor/bin/*" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "vendor/bin/*" },
+ { 00750, AID_ROOT, AID_SHELL, 0, "sbin/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "bin/*" },
+ { 00750, AID_ROOT, AID_SHELL, 0, "init*" },
+ { 00750, AID_ROOT, AID_SHELL, 0, "charger*" },
+ { 00750, AID_ROOT, AID_SHELL, 0, "sbin/fs_mgr" },
+ { 00640, AID_ROOT, AID_SHELL, 0, "fstab.*" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/etc/init.d/*" },
+ { 00644, AID_ROOT, AID_ROOT, 0, 0 },
+};
+
+static inline void fs_config(const char *path, int dir,
+ unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities)
+{
+ const struct fs_path_config *pc;
+ int plen;
+
+ if (path[0] == '/') {
+ path++;
+ }
+
+ pc = dir ? android_dirs : android_files;
+ plen = strlen(path);
+ for(; pc->prefix; pc++){
+ int len = strlen(pc->prefix);
+ if (dir) {
+ if(plen < len) continue;
+ if(!strncmp(pc->prefix, path, len)) break;
+ continue;
+ }
+ /* If name ends in * then allow partial matches. */
+ if (pc->prefix[len -1] == '*') {
+ if(!strncmp(pc->prefix, path, len - 1)) break;
+ } else if (plen == len){
+ if(!strncmp(pc->prefix, path, len)) break;
+ }
+ }
+ *uid = pc->uid;
+ *gid = pc->gid;
+ *mode = (*mode & (~07777)) | pc->mode;
+ *capabilities = pc->capabilities;
+
+#if 0
+ fprintf(stderr,"< '%s' '%s' %d %d %o >\n",
+ path, pc->prefix ? pc->prefix : "", *uid, *gid, *mode);
+#endif
+}
+#endif
+#endif
diff --git a/include/telephony/ril.h b/include/telephony/ril.h
new file mode 100644
index 0000000..bf9460b
--- /dev/null
+++ b/include/telephony/ril.h
@@ -0,0 +1,4531 @@
+/*
+ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ * Not a Contribution
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_RIL_H
+#define ANDROID_RIL_H 1
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <telephony/ril_cdma_sms.h>
+#include <telephony/ril_msim.h>
+#ifndef FEATURE_UNIT_TEST
+#include <sys/time.h>
+#endif /* !FEATURE_UNIT_TEST */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RIL_VERSION 9 /* Current version */
+#ifdef LEGACY_RIL
+#define RIL_VERSION_MIN 2 /* Minimum RIL_VERSION supported */
+#else
+#define RIL_VERSION_MIN 6 /* Minimum RIL_VERSION supported */
+#endif
+#define RIL_QCOM_VERSION 3 /* Qualcomm internal RIL version */
+
+#define CDMA_ALPHA_INFO_BUFFER_LENGTH 64
+#define CDMA_NUMBER_INFO_BUFFER_LENGTH 81
+
+#define MAX_RILDS 3
+#define MAX_SOCKET_NAME_LENGTH 6
+#define MAX_CLIENT_ID_LENGTH 2
+#define MAX_DEBUG_SOCKET_NAME_LENGTH 12
+#define MAX_QEMU_PIPE_NAME_LENGTH 11
+
+typedef void * RIL_Token;
+
+typedef enum {
+ RIL_E_SUCCESS = 0,
+ RIL_E_RADIO_NOT_AVAILABLE = 1, /* If radio did not start or is resetting */
+ RIL_E_GENERIC_FAILURE = 2,
+ RIL_E_PASSWORD_INCORRECT = 3, /* for PIN/PIN2 methods only! */
+ RIL_E_SIM_PIN2 = 4, /* Operation requires SIM PIN2 to be entered */
+ RIL_E_SIM_PUK2 = 5, /* Operation requires SIM PIN2 to be entered */
+ RIL_E_REQUEST_NOT_SUPPORTED = 6,
+ RIL_E_CANCELLED = 7,
+ RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL = 8, /* data ops are not allowed during voice
+ call on a Class C GPRS device */
+ RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW = 9, /* data ops are not allowed before device
+ registers in network */
+ RIL_E_SMS_SEND_FAIL_RETRY = 10, /* fail to send sms and need retry */
+ RIL_E_SIM_ABSENT = 11, /* fail to set the location where CDMA subscription
+ shall be retrieved because of SIM or RUIM
+ card absent */
+ RIL_E_SUBSCRIPTION_NOT_AVAILABLE = 12, /* fail to find CDMA subscription from specified
+ location */
+ RIL_E_MODE_NOT_SUPPORTED = 13, /* HW does not support preferred network type */
+ RIL_E_FDN_CHECK_FAILURE = 14, /* command failed because recipient is not on FDN list */
+ RIL_E_ILLEGAL_SIM_OR_ME = 15, /* network selection failed due to
+ illegal SIM or ME */
+ RIL_E_UNUSED = 16,
+ RIL_E_DIAL_MODIFIED_TO_USSD = 17, /* DIAL request modified to USSD */
+ RIL_E_DIAL_MODIFIED_TO_SS = 18, /* DIAL request modified to SS */
+ RIL_E_DIAL_MODIFIED_TO_DIAL = 19, /* DIAL request modified to DIAL with different data */
+ RIL_E_USSD_MODIFIED_TO_DIAL = 20, /* USSD request modified to DIAL */
+ RIL_E_USSD_MODIFIED_TO_SS = 21, /* USSD request modified to SS */
+ RIL_E_USSD_MODIFIED_TO_USSD = 22, /* USSD request modified to different USSD request */
+ RIL_E_SS_MODIFIED_TO_DIAL = 23, /* SS request modified to DIAL */
+ RIL_E_SS_MODIFIED_TO_USSD = 24, /* SS request modified to USSD */
+ RIL_E_SS_MODIFIED_TO_SS = 25, /* SS request modified to different SS request */
+ RIL_E_SUBSCRIPTION_NOT_SUPPORTED = 26 /* Subscription not supported by RIL */
+} RIL_Errno;
+
+typedef enum {
+ RIL_CALL_ACTIVE = 0,
+ RIL_CALL_HOLDING = 1,
+ RIL_CALL_DIALING = 2, /* MO call only */
+ RIL_CALL_ALERTING = 3, /* MO call only */
+ RIL_CALL_INCOMING = 4, /* MT call only */
+ RIL_CALL_WAITING = 5 /* MT call only */
+} RIL_CallState;
+
+typedef enum {
+ RADIO_STATE_OFF = 0, /* Radio explictly powered off (eg CFUN=0) */
+ RADIO_STATE_UNAVAILABLE = 1, /* Radio unavailable (eg, resetting or not booted) */
+ /* States 2-9 below are deprecated. Just leaving them here for backward compatibility. */
+ RADIO_STATE_SIM_NOT_READY = 2, /* Radio is on, but the SIM interface is not ready */
+ RADIO_STATE_SIM_LOCKED_OR_ABSENT = 3, /* SIM PIN locked, PUK required, network
+ personalization locked, or SIM absent */
+ RADIO_STATE_SIM_READY = 4, /* Radio is on and SIM interface is available */
+ RADIO_STATE_RUIM_NOT_READY = 5, /* Radio is on, but the RUIM interface is not ready */
+ RADIO_STATE_RUIM_READY = 6, /* Radio is on and the RUIM interface is available */
+ RADIO_STATE_RUIM_LOCKED_OR_ABSENT = 7, /* RUIM PIN locked, PUK required, network
+ personalization locked, or RUIM absent */
+ RADIO_STATE_NV_NOT_READY = 8, /* Radio is on, but the NV interface is not available */
+ RADIO_STATE_NV_READY = 9, /* Radio is on and the NV interface is available */
+ RADIO_STATE_ON = 10 /* Radio is on */
+} RIL_RadioState;
+
+typedef enum {
+ RADIO_TECH_UNKNOWN = 0,
+ RADIO_TECH_GPRS = 1,
+ RADIO_TECH_EDGE = 2,
+ RADIO_TECH_UMTS = 3,
+ RADIO_TECH_IS95A = 4,
+ RADIO_TECH_IS95B = 5,
+ RADIO_TECH_1xRTT = 6,
+ RADIO_TECH_EVDO_0 = 7,
+ RADIO_TECH_EVDO_A = 8,
+ RADIO_TECH_HSDPA = 9,
+ RADIO_TECH_HSUPA = 10,
+ RADIO_TECH_HSPA = 11,
+ RADIO_TECH_EVDO_B = 12,
+ RADIO_TECH_EHRPD = 13,
+ RADIO_TECH_LTE = 14,
+ RADIO_TECH_HSPAP = 15, // HSPA+
+ RADIO_TECH_GSM = 16, // Only supports voice
+ RADIO_TECH_TD_SCDMA = 17,
+ RADIO_TECH_IWLAN = 18,
+ RADIO_TECH_DCHSPAP = 30
+} RIL_RadioTechnology;
+
+// Do we want to split Data from Voice and the use
+// RIL_RadioTechnology for get/setPreferredVoice/Data ?
+typedef enum {
+ PREF_NET_TYPE_GSM_WCDMA = 0, /* GSM/WCDMA (WCDMA preferred) */
+ PREF_NET_TYPE_GSM_ONLY = 1, /* GSM only */
+ PREF_NET_TYPE_WCDMA = 2, /* WCDMA */
+ PREF_NET_TYPE_GSM_WCDMA_AUTO = 3, /* GSM/WCDMA (auto mode, according to PRL) */
+ PREF_NET_TYPE_CDMA_EVDO_AUTO = 4, /* CDMA and EvDo (auto mode, according to PRL) */
+ PREF_NET_TYPE_CDMA_ONLY = 5, /* CDMA only */
+ PREF_NET_TYPE_EVDO_ONLY = 6, /* EvDo only */
+ PREF_NET_TYPE_GSM_WCDMA_CDMA_EVDO_AUTO = 7, /* GSM/WCDMA, CDMA, and EvDo (auto mode, according to PRL) */
+ PREF_NET_TYPE_LTE_CDMA_EVDO = 8, /* LTE, CDMA and EvDo */
+ PREF_NET_TYPE_LTE_GSM_WCDMA = 9, /* LTE, GSM/WCDMA */
+ PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA = 10, /* LTE, CDMA, EvDo, GSM/WCDMA */
+ PREF_NET_TYPE_LTE_ONLY = 11, /* LTE only */
+ PREF_NET_TYPE_LTE_WCDMA = 12, /* LTE/WCDMA */
+ PREF_NET_TYPE_TD_SCDMA_ONLY = 13, /* TD-SCDMA only */
+ PREF_NET_TYPE_TD_SCDMA_WCDMA = 14, /* TD-SCDMA and WCDMA */
+ PREF_NET_TYPE_TD_SCDMA_LTE = 15, /* TD-SCDMA and LTE */
+ PREF_NET_TYPE_TD_SCDMA_GSM = 16, /* TD-SCDMA and GSM */
+ PREF_NET_TYPE_TD_SCDMA_GSM_LTE = 17, /* TD-SCDMA,GSM and LTE */
+ PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA = 18, /* TD-SCDMA, GSM/WCDMA */
+ PREF_NET_TYPE_TD_SCDMA_WCDMA_LTE = 19, /* TD-SCDMA, WCDMA and LTE */
+ PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA_LTE = 20, /* TD-SCDMA, GSM/WCDMA and LTE */
+ PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA_CDMA_EVDO_AUTO = 21, /* TD-SCDMA, GSM/WCDMA, CDMA and EvDo */
+ PREF_NET_TYPE_TD_SCDMA_LTE_CDMA_EVDO_GSM_WCDMA = 22 /* TD-SCDMA, LTE, CDMA, EvDo GSM/WCDMA */
+} RIL_PreferredNetworkType;
+
+/* Source for cdma subscription */
+typedef enum {
+ CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM = 0,
+ CDMA_SUBSCRIPTION_SOURCE_NV = 1
+} RIL_CdmaSubscriptionSource;
+
+/* User-to-User signaling Info activation types derived from 3GPP 23.087 v8.0 */
+typedef enum {
+ RIL_UUS_TYPE1_IMPLICIT = 0,
+ RIL_UUS_TYPE1_REQUIRED = 1,
+ RIL_UUS_TYPE1_NOT_REQUIRED = 2,
+ RIL_UUS_TYPE2_REQUIRED = 3,
+ RIL_UUS_TYPE2_NOT_REQUIRED = 4,
+ RIL_UUS_TYPE3_REQUIRED = 5,
+ RIL_UUS_TYPE3_NOT_REQUIRED = 6
+} RIL_UUS_Type;
+
+/* User-to-User Signaling Information data coding schemes. Possible values for
+ * Octet 3 (Protocol Discriminator field) in the UUIE. The values have been
+ * specified in section 10.5.4.25 of 3GPP TS 24.008 */
+typedef enum {
+ RIL_UUS_DCS_USP = 0, /* User specified protocol */
+ RIL_UUS_DCS_OSIHLP = 1, /* OSI higher layer protocol */
+ RIL_UUS_DCS_X244 = 2, /* X.244 */
+ RIL_UUS_DCS_RMCF = 3, /* Reserved for system mangement
+ convergence function */
+ RIL_UUS_DCS_IA5c = 4 /* IA5 characters */
+} RIL_UUS_DCS;
+
+/* User-to-User Signaling Information defined in 3GPP 23.087 v8.0
+ * This data is passed in RIL_ExtensionRecord and rec contains this
+ * structure when type is RIL_UUS_INFO_EXT_REC */
+typedef struct {
+ RIL_UUS_Type uusType; /* UUS Type */
+ RIL_UUS_DCS uusDcs; /* UUS Data Coding Scheme */
+ int uusLength; /* Length of UUS Data */
+ char * uusData; /* UUS Data */
+} RIL_UUS_Info;
+
+/* CDMA Signal Information Record as defined in C.S0005 section 3.7.5.5 */
+typedef struct {
+ char isPresent; /* non-zero if signal information record is present */
+ char signalType; /* as defined 3.7.5.5-1 */
+ char alertPitch; /* as defined 3.7.5.5-2 */
+ char signal; /* as defined 3.7.5.5-3, 3.7.5.5-4 or 3.7.5.5-5 */
+} RIL_CDMA_SignalInfoRecord;
+
+typedef struct {
+ RIL_CallState state;
+ int index; /* Connection Index for use with, eg, AT+CHLD */
+ int toa; /* type of address, eg 145 = intl */
+ char isMpty; /* nonzero if is mpty call */
+ char isMT; /* nonzero if call is mobile terminated */
+ char als; /* ALS line indicator if available
+ (0 = line 1) */
+ char isVoice; /* nonzero if this is is a voice call */
+ char isVoicePrivacy; /* nonzero if CDMA voice privacy mode is active */
+ char * number; /* Remote party number */
+ int numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown 3=Payphone */
+ char * name; /* Remote party name */
+ int namePresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown 3=Payphone */
+ RIL_UUS_Info * uusInfo; /* NULL or Pointer to User-User Signaling Information */
+} RIL_Call;
+
+/* Deprecated, use RIL_Data_Call_Response_v6 */
+typedef struct {
+ int cid; /* Context ID, uniquely identifies this call */
+ int active; /* 0=inactive, 1=active/physical link down, 2=active/physical link up */
+ char * type; /* One of the PDP_type values in TS 27.007 section 10.1.1.
+ For example, "IP", "IPV6", "IPV4V6", or "PPP". */
+ char * apn; /* ignored */
+ char * address; /* An address, e.g., "192.0.1.3" or "2001:db8::1". */
+} RIL_Data_Call_Response_v4;
+
+/*
+ * Returned by RIL_REQUEST_SETUP_DATA_CALL, RIL_REQUEST_DATA_CALL_LIST
+ * and RIL_UNSOL_DATA_CALL_LIST_CHANGED, on error status != 0.
+ */
+typedef struct {
+ int status; /* A RIL_DataCallFailCause, 0 which is PDP_FAIL_NONE if no error */
+#ifndef HCRADIO
+ int suggestedRetryTime; /* If status != 0, this fields indicates the suggested retry
+ back-off timer value RIL wants to override the one
+ pre-configured in FW.
+ The unit is miliseconds.
+ The value < 0 means no value is suggested.
+ The value 0 means retry should be done ASAP.
+ The value of INT_MAX(0x7fffffff) means no retry. */
+#endif
+ int cid; /* Context ID, uniquely identifies this call */
+ int active; /* 0=inactive, 1=active/physical link down, 2=active/physical link up */
+ char * type; /* One of the PDP_type values in TS 27.007 section 10.1.1.
+ For example, "IP", "IPV6", "IPV4V6", or "PPP". If status is
+ PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED this is the type supported
+ such as "IP" or "IPV6" */
+ char * ifname; /* The network interface name */
+ char * addresses; /* A space-delimited list of addresses with optional "/" prefix length,
+ e.g., "192.0.1.3" or "192.0.1.11/16 2001:db8::1/64".
+ May not be empty, typically 1 IPv4 or 1 IPv6 or
+ one of each. If the prefix length is absent the addresses
+ are assumed to be point to point with IPv4 having a prefix
+ length of 32 and IPv6 128. */
+ char * dnses; /* A space-delimited list of DNS server addresses,
+ e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1".
+ May be empty. */
+ char * gateways; /* A space-delimited list of default gateway addresses,
+ e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1".
+ May be empty in which case the addresses represent point
+ to point connections. */
+} RIL_Data_Call_Response_v6;
+
+typedef enum {
+ RADIO_TECH_3GPP = 1, /* 3GPP Technologies - GSM, WCDMA */
+ RADIO_TECH_3GPP2 = 2 /* 3GPP2 Technologies - CDMA */
+} RIL_RadioTechnologyFamily;
+
+typedef struct {
+ RIL_RadioTechnologyFamily tech;
+ unsigned char retry; /* 0 == not retry, nonzero == retry */
+ int messageRef; /* Valid field if retry is set to nonzero.
+ Contains messageRef from RIL_SMS_Response
+ corresponding to failed MO SMS.
+ */
+
+ union {
+ /* Valid field if tech is RADIO_TECH_3GPP2. See RIL_REQUEST_CDMA_SEND_SMS */
+ RIL_CDMA_SMS_Message* cdmaMessage;
+
+ /* Valid field if tech is RADIO_TECH_3GPP. See RIL_REQUEST_SEND_SMS */
+ char** gsmMessage;
+ } message;
+} RIL_IMS_SMS_Message;
+
+typedef struct {
+ int messageRef; /* TP-Message-Reference for GSM,
+ and BearerData MessageId for CDMA
+ (See 3GPP2 C.S0015-B, v2.0, table 4.5-1). */
+ char *ackPDU; /* or NULL if n/a */
+ int errorCode; /* See 3GPP 27.005, 3.2.5 for GSM/UMTS,
+ 3GPP2 N.S0005 (IS-41C) Table 171 for CDMA,
+ -1 if unknown or not applicable*/
+} RIL_SMS_Response;
+
+/** Used by RIL_REQUEST_WRITE_SMS_TO_SIM */
+typedef struct {
+ int status; /* Status of message. See TS 27.005 3.1, "<stat>": */
+ /* 0 = "REC UNREAD" */
+ /* 1 = "REC READ" */
+ /* 2 = "STO UNSENT" */
+ /* 3 = "STO SENT" */
+ char * pdu; /* PDU of message to write, as an ASCII hex string less the SMSC address,
+ the TP-layer length is "strlen(pdu)/2". */
+ char * smsc; /* SMSC address in GSM BCD format prefixed by a length byte
+ (as expected by TS 27.005) or NULL for default SMSC */
+} RIL_SMS_WriteArgs;
+
+/** Used by RIL_REQUEST_DIAL */
+typedef struct {
+ char * address;
+ int clir;
+ /* (same as 'n' paremeter in TS 27.007 7.7 "+CLIR"
+ * clir == 0 on "use subscription default value"
+ * clir == 1 on "CLIR invocation" (restrict CLI presentation)
+ * clir == 2 on "CLIR suppression" (allow CLI presentation)
+ */
+ RIL_UUS_Info * uusInfo; /* NULL or Pointer to User-User Signaling Information */
+} RIL_Dial;
+
+typedef struct {
+ int command; /* one of the commands listed for TS 27.007 +CRSM*/
+ int fileid; /* EF id */
+ char *path; /* "pathid" from TS 27.007 +CRSM command.
+ Path is in hex asciii format eg "7f205f70"
+ Path must always be provided.
+ */
+ int p1;
+ int p2;
+ int p3;
+ char *data; /* May be NULL*/
+ char *pin2; /* May be NULL*/
+} RIL_SIM_IO_v5;
+
+typedef struct {
+ int command; /* one of the commands listed for TS 27.007 +CRSM*/
+ int fileid; /* EF id */
+ char *path; /* "pathid" from TS 27.007 +CRSM command.
+ Path is in hex asciii format eg "7f205f70"
+ Path must always be provided.
+ */
+ int p1;
+ int p2;
+ int p3;
+ char *data; /* May be NULL*/
+ char *pin2; /* May be NULL*/
+ char *aidPtr; /* AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. */
+} RIL_SIM_IO_v6;
+
+typedef struct {
+ int sw1;
+ int sw2;
+ char *simResponse; /* In hex string format ([a-fA-F0-9]*). */
+} RIL_SIM_IO_Response;
+
+/* See also com.android.internal.telephony.gsm.CallForwardInfo */
+
+typedef struct {
+ int status; /*
+ * For RIL_REQUEST_QUERY_CALL_FORWARD_STATUS
+ * status 1 = active, 0 = not active
+ *
+ * For RIL_REQUEST_SET_CALL_FORWARD:
+ * status is:
+ * 0 = disable
+ * 1 = enable
+ * 2 = interrogate
+ * 3 = registeration
+ * 4 = erasure
+ */
+
+ int reason; /* from TS 27.007 7.11 "reason" */
+ int serviceClass;/* From 27.007 +CCFC/+CLCK "class"
+ See table for Android mapping from
+ MMI service code
+ 0 means user doesn't input class */
+ int toa; /* "type" from TS 27.007 7.11 */
+ char * number; /* "number" from TS 27.007 7.11. May be NULL */
+ int timeSeconds; /* for CF no reply only */
+}RIL_CallForwardInfo;
+
+typedef struct {
+ char * cid; /* Combination of LAC and Cell Id in 32 bits in GSM.
+ * Upper 16 bits is LAC and lower 16 bits
+ * is CID (as described in TS 27.005)
+ * Primary Scrambling Code (as described in TS 25.331)
+ * in 9 bits in UMTS
+ * Valid values are hexadecimal 0x0000 - 0xffffffff.
+ */
+ int rssi; /* Received RSSI in GSM,
+ * Level index of CPICH Received Signal Code Power in UMTS
+ */
+} RIL_NeighboringCell;
+
+/* See RIL_REQUEST_LAST_CALL_FAIL_CAUSE */
+typedef enum {
+ CALL_FAIL_UNOBTAINABLE_NUMBER = 1,
+ CALL_FAIL_NORMAL = 16,
+ CALL_FAIL_BUSY = 17,
+ CALL_FAIL_CONGESTION = 34,
+ CALL_FAIL_ACM_LIMIT_EXCEEDED = 68,
+ CALL_FAIL_CALL_BARRED = 240,
+ CALL_FAIL_FDN_BLOCKED = 241,
+ CALL_FAIL_IMSI_UNKNOWN_IN_VLR = 242,
+ CALL_FAIL_IMEI_NOT_ACCEPTED = 243,
+ CALL_FAIL_DIAL_MODIFIED_TO_USSD = 244, /* STK Call Control */
+ CALL_FAIL_DIAL_MODIFIED_TO_SS = 245,
+ CALL_FAIL_DIAL_MODIFIED_TO_DIAL = 246,
+ CALL_FAIL_CDMA_LOCKED_UNTIL_POWER_CYCLE = 1000,
+ CALL_FAIL_CDMA_DROP = 1001,
+ CALL_FAIL_CDMA_INTERCEPT = 1002,
+ CALL_FAIL_CDMA_REORDER = 1003,
+ CALL_FAIL_CDMA_SO_REJECT = 1004,
+ CALL_FAIL_CDMA_RETRY_ORDER = 1005,
+ CALL_FAIL_CDMA_ACCESS_FAILURE = 1006,
+ CALL_FAIL_CDMA_PREEMPTED = 1007,
+ CALL_FAIL_CDMA_NOT_EMERGENCY = 1008, /* For non-emergency number dialed
+ during emergency callback mode */
+ CALL_FAIL_CDMA_ACCESS_BLOCKED = 1009, /* CDMA network access probes blocked */
+ CALL_FAIL_ERROR_UNSPECIFIED = 0xffff
+} RIL_LastCallFailCause;
+
+/* See RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE */
+typedef enum {
+ PDP_FAIL_NONE = 0, /* No error, connection ok */
+
+ /* an integer cause code defined in TS 24.008
+ section 6.1.3.1.3 or TS 24.301 Release 8+ Annex B.
+ If the implementation does not have access to the exact cause codes,
+ then it should return one of the following values,
+ as the UI layer needs to distinguish these
+ cases for error notification and potential retries. */
+ PDP_FAIL_OPERATOR_BARRED = 0x08, /* no retry */
+ PDP_FAIL_INSUFFICIENT_RESOURCES = 0x1A,
+ PDP_FAIL_MISSING_UKNOWN_APN = 0x1B, /* no retry */
+ PDP_FAIL_UNKNOWN_PDP_ADDRESS_TYPE = 0x1C, /* no retry */
+ PDP_FAIL_USER_AUTHENTICATION = 0x1D, /* no retry */
+ PDP_FAIL_ACTIVATION_REJECT_GGSN = 0x1E, /* no retry */
+ PDP_FAIL_ACTIVATION_REJECT_UNSPECIFIED = 0x1F,
+ PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED = 0x20, /* no retry */
+ PDP_FAIL_SERVICE_OPTION_NOT_SUBSCRIBED = 0x21, /* no retry */
+ PDP_FAIL_SERVICE_OPTION_OUT_OF_ORDER = 0x22,
+ PDP_FAIL_NSAPI_IN_USE = 0x23, /* no retry */
+ PDP_FAIL_REGULAR_DEACTIVATION = 0x24, /* restart radio */
+ PDP_FAIL_ONLY_IPV4_ALLOWED = 0x32, /* no retry */
+ PDP_FAIL_ONLY_IPV6_ALLOWED = 0x33, /* no retry */
+ PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED = 0x34,
+ PDP_FAIL_PROTOCOL_ERRORS = 0x6F, /* no retry */
+
+ /* Not mentioned in the specification */
+ PDP_FAIL_VOICE_REGISTRATION_FAIL = -1,
+ PDP_FAIL_DATA_REGISTRATION_FAIL = -2,
+
+ /* reasons for data call drop - network/modem disconnect */
+ PDP_FAIL_SIGNAL_LOST = -3,
+ PDP_FAIL_PREF_RADIO_TECH_CHANGED = -4,/* preferred technology has changed, should retry
+ with parameters appropriate for new technology */
+ PDP_FAIL_RADIO_POWER_OFF = -5, /* data call was disconnected because radio was resetting,
+ powered off - no retry */
+ PDP_FAIL_TETHERED_CALL_ACTIVE = -6, /* data call was disconnected by modem because tethered
+ mode was up on same APN/data profile - no retry until
+ tethered call is off */
+
+ PDP_FAIL_ERROR_UNSPECIFIED = 0xffff, /* retry silently */
+} RIL_DataCallFailCause;
+
+/* See RIL_REQUEST_SETUP_DATA_CALL */
+typedef enum {
+ RIL_DATA_PROFILE_DEFAULT = 0,
+ RIL_DATA_PROFILE_TETHERED = 1,
+ RIL_DATA_PROFILE_OEM_BASE = 1000 /* Start of OEM-specific profiles */
+} RIL_DataProfile;
+
+/* Used by RIL_UNSOL_SUPP_SVC_NOTIFICATION */
+typedef struct {
+ int notificationType; /*
+ * 0 = MO intermediate result code
+ * 1 = MT unsolicited result code
+ */
+ int code; /* See 27.007 7.17
+ "code1" for MO
+ "code2" for MT. */
+ int index; /* CUG index. See 27.007 7.17. */
+ int type; /* "type" from 27.007 7.17 (MT only). */
+ char * number; /* "number" from 27.007 7.17
+ (MT only, may be NULL). */
+} RIL_SuppSvcNotification;
+
+#define RIL_CARD_MAX_APPS 8
+
+typedef enum {
+ RIL_CARDSTATE_ABSENT = 0,
+ RIL_CARDSTATE_PRESENT = 1,
+ RIL_CARDSTATE_ERROR = 2
+} RIL_CardState;
+
+typedef enum {
+ RIL_PERSOSUBSTATE_UNKNOWN = 0, /* initial state */
+ RIL_PERSOSUBSTATE_IN_PROGRESS = 1, /* in between each lock transition */
+ RIL_PERSOSUBSTATE_READY = 2, /* when either SIM or RUIM Perso is finished
+ since each app can only have 1 active perso
+ involved */
+ RIL_PERSOSUBSTATE_SIM_NETWORK = 3,
+ RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET = 4,
+ RIL_PERSOSUBSTATE_SIM_CORPORATE = 5,
+ RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER = 6,
+ RIL_PERSOSUBSTATE_SIM_SIM = 7,
+ RIL_PERSOSUBSTATE_SIM_NETWORK_PUK = 8, /* The corresponding perso lock is blocked */
+ RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK = 9,
+ RIL_PERSOSUBSTATE_SIM_CORPORATE_PUK = 10,
+ RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK = 11,
+ RIL_PERSOSUBSTATE_SIM_SIM_PUK = 12,
+ RIL_PERSOSUBSTATE_RUIM_NETWORK1 = 13,
+ RIL_PERSOSUBSTATE_RUIM_NETWORK2 = 14,
+ RIL_PERSOSUBSTATE_RUIM_HRPD = 15,
+ RIL_PERSOSUBSTATE_RUIM_CORPORATE = 16,
+ RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER = 17,
+ RIL_PERSOSUBSTATE_RUIM_RUIM = 18,
+ RIL_PERSOSUBSTATE_RUIM_NETWORK1_PUK = 19, /* The corresponding perso lock is blocked */
+ RIL_PERSOSUBSTATE_RUIM_NETWORK2_PUK = 20,
+ RIL_PERSOSUBSTATE_RUIM_HRPD_PUK = 21,
+ RIL_PERSOSUBSTATE_RUIM_CORPORATE_PUK = 22,
+ RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK = 23,
+ RIL_PERSOSUBSTATE_RUIM_RUIM_PUK = 24
+} RIL_PersoSubstate;
+
+typedef enum {
+ RIL_APPSTATE_UNKNOWN = 0,
+ RIL_APPSTATE_DETECTED = 1,
+ RIL_APPSTATE_PIN = 2, /* If PIN1 or UPin is required */
+ RIL_APPSTATE_PUK = 3, /* If PUK1 or Puk for UPin is required */
+ RIL_APPSTATE_SUBSCRIPTION_PERSO = 4, /* perso_substate should be look at
+ when app_state is assigned to this value */
+ RIL_APPSTATE_READY = 5
+} RIL_AppState;
+
+typedef enum {
+ RIL_PINSTATE_UNKNOWN = 0,
+ RIL_PINSTATE_ENABLED_NOT_VERIFIED = 1,
+ RIL_PINSTATE_ENABLED_VERIFIED = 2,
+ RIL_PINSTATE_DISABLED = 3,
+ RIL_PINSTATE_ENABLED_BLOCKED = 4,
+ RIL_PINSTATE_ENABLED_PERM_BLOCKED = 5
+} RIL_PinState;
+
+typedef enum {
+ RIL_APPTYPE_UNKNOWN = 0,
+ RIL_APPTYPE_SIM = 1,
+ RIL_APPTYPE_USIM = 2,
+ RIL_APPTYPE_RUIM = 3,
+ RIL_APPTYPE_CSIM = 4,
+ RIL_APPTYPE_ISIM = 5
+} RIL_AppType;
+
+typedef struct
+{
+ RIL_AppType app_type;
+ RIL_AppState app_state;
+ RIL_PersoSubstate perso_substate; /* applicable only if app_state ==
+ RIL_APPSTATE_SUBSCRIPTION_PERSO */
+ char *aid_ptr; /* null terminated string, e.g., from 0xA0, 0x00 -> 0x41,
+ 0x30, 0x30, 0x30 */
+ char *app_label_ptr; /* null terminated string */
+ int pin1_replaced; /* applicable to USIM, CSIM & ISIM */
+ RIL_PinState pin1;
+ RIL_PinState pin2;
+} RIL_AppStatus;
+
+/* Deprecated, use RIL_CardStatus_v6 */
+typedef struct
+{
+ RIL_CardState card_state;
+ RIL_PinState universal_pin_state; /* applicable to USIM and CSIM: RIL_PINSTATE_xxx */
+ int gsm_umts_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */
+ int cdma_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */
+ int num_applications; /* value <= RIL_CARD_MAX_APPS */
+ RIL_AppStatus applications[RIL_CARD_MAX_APPS];
+} RIL_CardStatus_v5;
+
+typedef struct
+{
+ RIL_CardState card_state;
+ RIL_PinState universal_pin_state; /* applicable to USIM and CSIM: RIL_PINSTATE_xxx */
+ int gsm_umts_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */
+ int cdma_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */
+ int ims_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */
+ int num_applications; /* value <= RIL_CARD_MAX_APPS */
+ RIL_AppStatus applications[RIL_CARD_MAX_APPS];
+} RIL_CardStatus_v6;
+
+/** The result of a SIM refresh, returned in data[0] of RIL_UNSOL_SIM_REFRESH
+ * or as part of RIL_SimRefreshResponse_v7
+ */
+typedef enum {
+ /* A file on SIM has been updated. data[1] contains the EFID. */
+ SIM_FILE_UPDATE = 0,
+ /* SIM initialized. All files should be re-read. */
+ SIM_INIT = 1,
+ /* SIM reset. SIM power required, SIM may be locked and all files should be re-read. */
+ SIM_RESET = 2
+} RIL_SimRefreshResult;
+
+typedef struct {
+ RIL_SimRefreshResult result;
+ int ef_id; /* is the EFID of the updated file if the result is */
+ /* SIM_FILE_UPDATE or 0 for any other result. */
+ char * aid; /* is AID(application ID) of the card application */
+ /* See ETSI 102.221 8.1 and 101.220 4 */
+ /* For SIM_FILE_UPDATE result it can be set to AID of */
+ /* application in which updated EF resides or it can be */
+ /* NULL if EF is outside of an application. */
+ /* For SIM_INIT result this field is set to AID of */
+ /* application that caused REFRESH */
+ /* For SIM_RESET result it is NULL. */
+} RIL_SimRefreshResponse_v7;
+
+/* Deprecated, use RIL_CDMA_CallWaiting_v6 */
+typedef struct {
+ char * number; /* Remote party number */
+ int numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown */
+ char * name; /* Remote party name */
+ RIL_CDMA_SignalInfoRecord signalInfoRecord;
+} RIL_CDMA_CallWaiting_v5;
+
+typedef struct {
+ char * number; /* Remote party number */
+ int numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown */
+ char * name; /* Remote party name */
+ RIL_CDMA_SignalInfoRecord signalInfoRecord;
+ /* Number type/Number plan required to support International Call Waiting */
+ int number_type; /* 0=Unknown, 1=International, 2=National,
+ 3=Network specific, 4=subscriber */
+ int number_plan; /* 0=Unknown, 1=ISDN, 3=Data, 4=Telex, 8=Nat'l, 9=Private */
+} RIL_CDMA_CallWaiting_v6;
+
+/**
+ * Which types of Cell Broadcast Message (CBM) are to be received by the ME
+ *
+ * uFromServiceID - uToServiceID defines a range of CBM message identifiers
+ * whose value is 0x0000 - 0xFFFF as defined in TS 23.041 9.4.1.2.2 for GMS
+ * and 9.4.4.2.2 for UMTS. All other values can be treated as empty
+ * CBM message ID.
+ *
+ * uFromCodeScheme - uToCodeScheme defines a range of CBM data coding schemes
+ * whose value is 0x00 - 0xFF as defined in TS 23.041 9.4.1.2.3 for GMS
+ * and 9.4.4.2.3 for UMTS.
+ * All other values can be treated as empty CBM data coding scheme.
+ *
+ * selected 0 means message types specified in <fromServiceId, toServiceId>
+ * and <fromCodeScheme, toCodeScheme>are not accepted, while 1 means accepted.
+ *
+ * Used by RIL_REQUEST_GSM_GET_BROADCAST_CONFIG and
+ * RIL_REQUEST_GSM_SET_BROADCAST_CONFIG.
+ */
+typedef struct {
+ int fromServiceId;
+ int toServiceId;
+ int fromCodeScheme;
+ int toCodeScheme;
+ unsigned char selected;
+} RIL_GSM_BroadcastSmsConfigInfo;
+
+/* No restriction at all including voice/SMS/USSD/SS/AV64 and packet data. */
+#define RIL_RESTRICTED_STATE_NONE 0x00
+/* Block emergency call due to restriction. But allow all normal voice/SMS/USSD/SS/AV64. */
+#define RIL_RESTRICTED_STATE_CS_EMERGENCY 0x01
+/* Block all normal voice/SMS/USSD/SS/AV64 due to restriction. Only Emergency call allowed. */
+#define RIL_RESTRICTED_STATE_CS_NORMAL 0x02
+/* Block all voice/SMS/USSD/SS/AV64 including emergency call due to restriction.*/
+#define RIL_RESTRICTED_STATE_CS_ALL 0x04
+/* Block packet data access due to restriction. */
+#define RIL_RESTRICTED_STATE_PS_ALL 0x10
+
+/* The status for an OTASP/OTAPA session */
+typedef enum {
+ CDMA_OTA_PROVISION_STATUS_SPL_UNLOCKED,
+ CDMA_OTA_PROVISION_STATUS_SPC_RETRIES_EXCEEDED,
+ CDMA_OTA_PROVISION_STATUS_A_KEY_EXCHANGED,
+ CDMA_OTA_PROVISION_STATUS_SSD_UPDATED,
+ CDMA_OTA_PROVISION_STATUS_NAM_DOWNLOADED,
+ CDMA_OTA_PROVISION_STATUS_MDN_DOWNLOADED,
+ CDMA_OTA_PROVISION_STATUS_IMSI_DOWNLOADED,
+ CDMA_OTA_PROVISION_STATUS_PRL_DOWNLOADED,
+ CDMA_OTA_PROVISION_STATUS_COMMITTED,
+ CDMA_OTA_PROVISION_STATUS_OTAPA_STARTED,
+ CDMA_OTA_PROVISION_STATUS_OTAPA_STOPPED,
+ CDMA_OTA_PROVISION_STATUS_OTAPA_ABORTED
+} RIL_CDMA_OTA_ProvisionStatus;
+
+typedef struct {
+ int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
+ int bitErrorRate; /* bit error rate (0-7, 99) as defined in TS 27.007 8.5 */
+ int WhatIsThatSony; /* What is that Sony ? */
+} RIL_GW_SignalStrength;
+
+typedef struct {
+ int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
+ int bitErrorRate; /* bit error rate (0-7, 99) as defined in TS 27.007 8.5 */
+} RIL_SignalStrengthWcdma;
+
+typedef struct {
+ int dbm; /* Valid values are positive integers. This value is the actual RSSI value
+ * multiplied by -1. Example: If the actual RSSI is -75, then this response
+ * value will be 75.
+ */
+ int ecio; /* Valid values are positive integers. This value is the actual Ec/Io multiplied
+ * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value
+ * will be 125.
+ */
+} RIL_CDMA_SignalStrength;
+
+
+typedef struct {
+ int dbm; /* Valid values are positive integers. This value is the actual RSSI value
+ * multiplied by -1. Example: If the actual RSSI is -75, then this response
+ * value will be 75.
+ */
+ int ecio; /* Valid values are positive integers. This value is the actual Ec/Io multiplied
+ * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value
+ * will be 125.
+ */
+ int signalNoiseRatio; /* Valid values are 0-8. 8 is the highest signal to noise ratio. */
+} RIL_EVDO_SignalStrength;
+
+typedef struct {
+ int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
+ int rsrp; /* The current Reference Signal Receive Power in dBm multipled by -1.
+ * Range: 44 to 140 dBm
+ * INT_MAX: 0x7FFFFFFF denotes invalid value.
+ * Reference: 3GPP TS 36.133 9.1.4 */
+ int rsrq; /* The current Reference Signal Receive Quality in dB multiplied by -1.
+ * Range: 20 to 3 dB.
+ * INT_MAX: 0x7FFFFFFF denotes invalid value.
+ * Reference: 3GPP TS 36.133 9.1.7 */
+ int rssnr; /* The current reference signal signal-to-noise ratio in 0.1 dB units.
+ * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).
+ * INT_MAX : 0x7FFFFFFF denotes invalid value.
+ * Reference: 3GPP TS 36.101 8.1.1 */
+ int cqi; /* The current Channel Quality Indicator.
+ * Range: 0 to 15.
+ * INT_MAX : 0x7FFFFFFF denotes invalid value.
+ * Reference: 3GPP TS 36.101 9.2, 9.3, A.4 */
+} RIL_LTE_SignalStrength;
+
+typedef struct {
+ int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
+ int rsrp; /* The current Reference Signal Receive Power in dBm multipled by -1.
+ * Range: 44 to 140 dBm
+ * INT_MAX: 0x7FFFFFFF denotes invalid value.
+ * Reference: 3GPP TS 36.133 9.1.4 */
+ int rsrq; /* The current Reference Signal Receive Quality in dB multiplied by -1.
+ * Range: 20 to 3 dB.
+ * INT_MAX: 0x7FFFFFFF denotes invalid value.
+ * Reference: 3GPP TS 36.133 9.1.7 */
+ int rssnr; /* The current reference signal signal-to-noise ratio in 0.1 dB units.
+ * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).
+ * INT_MAX : 0x7FFFFFFF denotes invalid value.
+ * Reference: 3GPP TS 36.101 8.1.1 */
+ int cqi; /* The current Channel Quality Indicator.
+ * Range: 0 to 15.
+ * INT_MAX : 0x7FFFFFFF denotes invalid value.
+ * Reference: 3GPP TS 36.101 9.2, 9.3, A.4 */
+ int timingAdvance; /* timing advance in micro seconds for a one way trip from cell to device.
+ * Approximate distance can be calculated using 300m/us * timingAdvance.
+ * Range: 0 to 0x7FFFFFFE
+ * INT_MAX : 0x7FFFFFFF denotes invalid value.
+ * Reference: 3GPP 36.321 section 6.1.3.5
+ * also: http://www.cellular-planningoptimization.com/2010/02/timing-advance-with-calculation.html */
+} RIL_LTE_SignalStrength_v8;
+
+typedef struct {
+ int rscp; /* The Received Signal Code Power in dBm multipled by -1.
+ * Range : 25 to 120
+ * INT_MAX: 0x7FFFFFFF denotes invalid value.
+ * Reference: 3GPP TS 25.123, section 9.1.1.1 */
+} RIL_TD_SCDMA_SignalStrength_CAF;
+
+/* Deprecated, use RIL_SignalStrength_v6 */
+typedef struct {
+ RIL_GW_SignalStrength GW_SignalStrength;
+ RIL_CDMA_SignalStrength CDMA_SignalStrength;
+ RIL_EVDO_SignalStrength EVDO_SignalStrength;
+} RIL_SignalStrength_v5;
+
+typedef struct {
+ RIL_GW_SignalStrength GW_SignalStrength;
+ RIL_CDMA_SignalStrength CDMA_SignalStrength;
+ RIL_EVDO_SignalStrength EVDO_SignalStrength;
+ RIL_LTE_SignalStrength LTE_SignalStrength;
+} RIL_SignalStrength_v6;
+
+typedef struct {
+ RIL_GW_SignalStrength GW_SignalStrength;
+ RIL_CDMA_SignalStrength CDMA_SignalStrength;
+ RIL_EVDO_SignalStrength EVDO_SignalStrength;
+ RIL_LTE_SignalStrength_v8 LTE_SignalStrength;
+} RIL_SignalStrength_v8;
+
+typedef struct {
+ RIL_GW_SignalStrength GW_SignalStrength;
+ RIL_CDMA_SignalStrength CDMA_SignalStrength;
+ RIL_EVDO_SignalStrength EVDO_SignalStrength;
+ RIL_LTE_SignalStrength_v8 LTE_SignalStrength;
+ RIL_TD_SCDMA_SignalStrength_CAF TD_SCDMA_SignalStrength;
+} RIL_SignalStrength_v9_CAF;
+
+/** RIL_CellIdentityGsm */
+typedef struct {
+ int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
+ int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
+ int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
+ int cid; /* 16-bit GSM Cell Identity described in TS 27.007, 0..65535, INT_MAX if unknown */
+} RIL_CellIdentityGsm;
+
+/** RIL_CellIdentityWcdma */
+typedef struct {
+ int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
+ int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
+ int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
+ int cid; /* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */
+ int psc; /* 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511, INT_MAX if unknown */
+} RIL_CellIdentityWcdma;
+
+/** RIL_CellIdentityCdma */
+typedef struct {
+ int networkId; /* Network Id 0..65535, INT_MAX if unknown */
+ int systemId; /* CDMA System Id 0..32767, INT_MAX if unknown */
+ int basestationId; /* Base Station Id 0..65535, INT_MAX if unknown */
+ int longitude; /* Longitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
+ * It is represented in units of 0.25 seconds and ranges from -2592000
+ * to 2592000, both values inclusive (corresponding to a range of -180
+ * to +180 degrees). INT_MAX if unknown */
+
+ int latitude; /* Latitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
+ * It is represented in units of 0.25 seconds and ranges from -1296000
+ * to 1296000, both values inclusive (corresponding to a range of -90
+ * to +90 degrees). INT_MAX if unknown */
+} RIL_CellIdentityCdma;
+
+/** RIL_CellIdentityLte */
+typedef struct {
+ int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
+ int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
+ int ci; /* 28-bit Cell Identity described in TS ???, INT_MAX if unknown */
+ int pci; /* physical cell id 0..503, INT_MAX if unknown */
+ int tac; /* 16-bit tracking area code, INT_MAX if unknown */
+} RIL_CellIdentityLte;
+
+/** RIL_CellInfoGsm */
+typedef struct {
+ RIL_CellIdentityGsm cellIdentityGsm;
+ RIL_GW_SignalStrength signalStrengthGsm;
+} RIL_CellInfoGsm;
+
+/** RIL_CellInfoWcdma */
+typedef struct {
+ RIL_CellIdentityWcdma cellIdentityWcdma;
+ RIL_SignalStrengthWcdma signalStrengthWcdma;
+} RIL_CellInfoWcdma;
+
+/** RIL_CellInfoCdma */
+typedef struct {
+ RIL_CellIdentityCdma cellIdentityCdma;
+ RIL_CDMA_SignalStrength signalStrengthCdma;
+ RIL_EVDO_SignalStrength signalStrengthEvdo;
+} RIL_CellInfoCdma;
+
+/** RIL_CellInfoLte */
+typedef struct {
+ RIL_CellIdentityLte cellIdentityLte;
+ RIL_LTE_SignalStrength_v8 signalStrengthLte;
+} RIL_CellInfoLte;
+
+// Must be the same as CellInfo.TYPE_XXX
+typedef enum {
+ RIL_CELL_INFO_TYPE_GSM = 1,
+ RIL_CELL_INFO_TYPE_CDMA = 2,
+ RIL_CELL_INFO_TYPE_LTE = 3,
+ RIL_CELL_INFO_TYPE_WCDMA = 4,
+} RIL_CellInfoType;
+
+// Must be the same as CellInfo.TIMESTAMP_TYPE_XXX
+typedef enum {
+ RIL_TIMESTAMP_TYPE_UNKNOWN = 0,
+ RIL_TIMESTAMP_TYPE_ANTENNA = 1,
+ RIL_TIMESTAMP_TYPE_MODEM = 2,
+ RIL_TIMESTAMP_TYPE_OEM_RIL = 3,
+ RIL_TIMESTAMP_TYPE_JAVA_RIL = 4,
+} RIL_TimeStampType;
+
+typedef struct {
+ RIL_CellInfoType cellInfoType; /* cell type for selecting from union CellInfo */
+ int registered; /* !0 if this cell is registered 0 if not registered */
+ RIL_TimeStampType timeStampType; /* type of time stamp represented by timeStamp */
+ uint64_t timeStamp; /* Time in nanos as returned by ril_nano_time */
+ union {
+ RIL_CellInfoGsm gsm;
+ RIL_CellInfoCdma cdma;
+ RIL_CellInfoLte lte;
+ RIL_CellInfoWcdma wcdma;
+ } CellInfo;
+} RIL_CellInfo;
+
+/* Names of the CDMA info records (C.S0005 section 3.7.5) */
+typedef enum {
+ RIL_CDMA_DISPLAY_INFO_REC,
+ RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC,
+ RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC,
+ RIL_CDMA_CONNECTED_NUMBER_INFO_REC,
+ RIL_CDMA_SIGNAL_INFO_REC,
+ RIL_CDMA_REDIRECTING_NUMBER_INFO_REC,
+ RIL_CDMA_LINE_CONTROL_INFO_REC,
+ RIL_CDMA_EXTENDED_DISPLAY_INFO_REC,
+ RIL_CDMA_T53_CLIR_INFO_REC,
+ RIL_CDMA_T53_RELEASE_INFO_REC,
+ RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC
+} RIL_CDMA_InfoRecName;
+
+/* Display Info Rec as defined in C.S0005 section 3.7.5.1
+ Extended Display Info Rec as defined in C.S0005 section 3.7.5.16
+ Note: the Extended Display info rec contains multiple records of the
+ form: display_tag, display_len, and display_len occurrences of the
+ chari field if the display_tag is not 10000000 or 10000001.
+ To save space, the records are stored consecutively in a byte buffer.
+ The display_tag, display_len and chari fields are all 1 byte.
+*/
+
+typedef struct {
+ char alpha_len;
+ char alpha_buf[CDMA_ALPHA_INFO_BUFFER_LENGTH];
+} RIL_CDMA_DisplayInfoRecord;
+
+/* Called Party Number Info Rec as defined in C.S0005 section 3.7.5.2
+ Calling Party Number Info Rec as defined in C.S0005 section 3.7.5.3
+ Connected Number Info Rec as defined in C.S0005 section 3.7.5.4
+*/
+
+typedef struct {
+ char len;
+ char buf[CDMA_NUMBER_INFO_BUFFER_LENGTH];
+ char number_type;
+ char number_plan;
+ char pi;
+ char si;
+} RIL_CDMA_NumberInfoRecord;
+
+/* Redirecting Number Information Record as defined in C.S0005 section 3.7.5.11 */
+typedef enum {
+ RIL_REDIRECTING_REASON_UNKNOWN = 0,
+ RIL_REDIRECTING_REASON_CALL_FORWARDING_BUSY = 1,
+ RIL_REDIRECTING_REASON_CALL_FORWARDING_NO_REPLY = 2,
+ RIL_REDIRECTING_REASON_CALLED_DTE_OUT_OF_ORDER = 9,
+ RIL_REDIRECTING_REASON_CALL_FORWARDING_BY_THE_CALLED_DTE = 10,
+ RIL_REDIRECTING_REASON_CALL_FORWARDING_UNCONDITIONAL = 15,
+ RIL_REDIRECTING_REASON_RESERVED
+} RIL_CDMA_RedirectingReason;
+
+typedef struct {
+ RIL_CDMA_NumberInfoRecord redirectingNumber;
+ /* redirectingReason is set to RIL_REDIRECTING_REASON_UNKNOWN if not included */
+ RIL_CDMA_RedirectingReason redirectingReason;
+} RIL_CDMA_RedirectingNumberInfoRecord;
+
+/* Line Control Information Record as defined in C.S0005 section 3.7.5.15 */
+typedef struct {
+ char lineCtrlPolarityIncluded;
+ char lineCtrlToggle;
+ char lineCtrlReverse;
+ char lineCtrlPowerDenial;
+} RIL_CDMA_LineControlInfoRecord;
+
+/* T53 CLIR Information Record */
+typedef struct {
+ char cause;
+} RIL_CDMA_T53_CLIRInfoRecord;
+
+/* T53 Audio Control Information Record */
+typedef struct {
+ char upLink;
+ char downLink;
+} RIL_CDMA_T53_AudioControlInfoRecord;
+
+typedef struct {
+
+ RIL_CDMA_InfoRecName name;
+
+ union {
+ /* Display and Extended Display Info Rec */
+ RIL_CDMA_DisplayInfoRecord display;
+
+ /* Called Party Number, Calling Party Number, Connected Number Info Rec */
+ RIL_CDMA_NumberInfoRecord number;
+
+ /* Signal Info Rec */
+ RIL_CDMA_SignalInfoRecord signal;
+
+ /* Redirecting Number Info Rec */
+ RIL_CDMA_RedirectingNumberInfoRecord redir;
+
+ /* Line Control Info Rec */
+ RIL_CDMA_LineControlInfoRecord lineCtrl;
+
+ /* T53 CLIR Info Rec */
+ RIL_CDMA_T53_CLIRInfoRecord clir;
+
+ /* T53 Audio Control Info Rec */
+ RIL_CDMA_T53_AudioControlInfoRecord audioCtrl;
+ } rec;
+} RIL_CDMA_InformationRecord;
+
+#define RIL_CDMA_MAX_NUMBER_OF_INFO_RECS 10
+
+typedef struct {
+ char numberOfInfoRecs;
+ RIL_CDMA_InformationRecord infoRec[RIL_CDMA_MAX_NUMBER_OF_INFO_RECS];
+} RIL_CDMA_InformationRecords;
+
+/* Data Call Profile: Simple IP User Profile Parameters*/
+typedef struct {
+ int profileId;
+ int priority; /* priority. [0..255], 0 - highest */
+} RIL_DataCallProfileInfo;
+
+typedef enum {
+ SS_CFU,
+ SS_CF_BUSY,
+ SS_CF_NO_REPLY,
+ SS_CF_NOT_REACHABLE,
+ SS_CF_ALL,
+ SS_CF_ALL_CONDITIONAL,
+ SS_CLIP,
+ SS_CLIR,
+ SS_COLP,
+ SS_COLR,
+ SS_WAIT,
+ SS_BAOC,
+ SS_BAOIC,
+ SS_BAOIC_EXC_HOME,
+ SS_BAIC,
+ SS_BAIC_ROAMING,
+ SS_ALL_BARRING,
+ SS_OUTGOING_BARRING,
+ SS_INCOMING_BARRING
+} RIL_SsServiceType;
+
+typedef enum {
+ SS_ACTIVATION,
+ SS_DEACTIVATION,
+ SS_INTERROGATION,
+ SS_REGISTRATION,
+ SS_ERASURE
+} RIL_SsRequestType;
+
+typedef enum {
+ SS_ALL_TELE_AND_BEARER_SERVICES,
+ SS_ALL_TELESEVICES,
+ SS_TELEPHONY,
+ SS_ALL_DATA_TELESERVICES,
+ SS_SMS_SERVICES,
+ SS_ALL_TELESERVICES_EXCEPT_SMS
+} RIL_SsTeleserviceType;
+
+#define SS_INFO_MAX 4
+#define NUM_SERVICE_CLASSES 7
+
+typedef struct {
+ int numValidIndexes; /* This gives the number of valid values in cfInfo.
+ For example if voice is forwarded to one number and data
+ is forwarded to a different one then numValidIndexes will be
+ 2 indicating total number of valid values in cfInfo.
+ Similarly if all the services are forwarded to the same
+ number then the value of numValidIndexes will be 1. */
+
+ RIL_CallForwardInfo cfInfo[NUM_SERVICE_CLASSES]; /* This is the response data
+ for SS request to query call
+ forward status. see
+ RIL_REQUEST_QUERY_CALL_FORWARD_STATUS */
+} RIL_CfData;
+
+typedef struct {
+ RIL_SsServiceType serviceType;
+ RIL_SsRequestType requestType;
+ RIL_SsTeleserviceType teleserviceType;
+ int serviceClass;
+ RIL_Errno result;
+
+ union {
+ int ssInfo[SS_INFO_MAX]; /* This is the response data for most of the SS GET/SET
+ RIL requests. E.g. RIL_REQUSET_GET_CLIR returns
+ two ints, so first two values of ssInfo[] will be
+ used for response if serviceType is SS_CLIR and
+ requestType is SS_INTERROGATION */
+
+ RIL_CfData cfData;
+ };
+} RIL_StkCcUnsolSsResponse;
+
+/**
+ * RIL_REQUEST_GET_SIM_STATUS
+ *
+ * Requests status of the SIM interface and the SIM card
+ *
+ * "data" is NULL
+ *
+ * "response" is const RIL_CardStatus_v6 *
+ *
+ * Valid errors:
+ * Must never fail
+ */
+#define RIL_REQUEST_GET_SIM_STATUS 1
+
+/**
+ * RIL_REQUEST_ENTER_SIM_PIN
+ *
+ * Supplies SIM PIN. Only called if RIL_CardStatus has RIL_APPSTATE_PIN state
+ *
+ * "data" is const char **
+ * ((const char **)data)[0] is PIN value
+ * ((const char **)data)[1] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
+ *
+ * "response" is int *
+ * ((int *)response)[0] is the number of retries remaining, or -1 if unknown
+ *
+ * Valid errors:
+ *
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ * PASSWORD_INCORRECT
+ */
+
+#define RIL_REQUEST_ENTER_SIM_PIN 2
+
+/**
+ * RIL_REQUEST_ENTER_SIM_PUK
+ *
+ * Supplies SIM PUK and new PIN.
+ *
+ * "data" is const char **
+ * ((const char **)data)[0] is PUK value
+ * ((const char **)data)[1] is new PIN value
+ * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
+ *
+ * "response" is int *
+ * ((int *)response)[0] is the number of retries remaining, or -1 if unknown
+ *
+ * Valid errors:
+ *
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ * PASSWORD_INCORRECT
+ * (PUK is invalid)
+ */
+
+#define RIL_REQUEST_ENTER_SIM_PUK 3
+
+/**
+ * RIL_REQUEST_ENTER_SIM_PIN2
+ *
+ * Supplies SIM PIN2. Only called following operation where SIM_PIN2 was
+ * returned as a a failure from a previous operation.
+ *
+ * "data" is const char **
+ * ((const char **)data)[0] is PIN2 value
+ * ((const char **)data)[1] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
+ *
+ * "response" is int *
+ * ((int *)response)[0] is the number of retries remaining, or -1 if unknown
+ *
+ * Valid errors:
+ *
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ * PASSWORD_INCORRECT
+ */
+
+#define RIL_REQUEST_ENTER_SIM_PIN2 4
+
+/**
+ * RIL_REQUEST_ENTER_SIM_PUK2
+ *
+ * Supplies SIM PUK2 and new PIN2.
+ *
+ * "data" is const char **
+ * ((const char **)data)[0] is PUK2 value
+ * ((const char **)data)[1] is new PIN2 value
+ * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
+ *
+ * "response" is int *
+ * ((int *)response)[0] is the number of retries remaining, or -1 if unknown
+ *
+ * Valid errors:
+ *
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ * PASSWORD_INCORRECT
+ * (PUK2 is invalid)
+ */
+
+#define RIL_REQUEST_ENTER_SIM_PUK2 5
+
+/**
+ * RIL_REQUEST_CHANGE_SIM_PIN
+ *
+ * Supplies old SIM PIN and new PIN.
+ *
+ * "data" is const char **
+ * ((const char **)data)[0] is old PIN value
+ * ((const char **)data)[1] is new PIN value
+ * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
+ *
+ * "response" is int *
+ * ((int *)response)[0] is the number of retries remaining, or -1 if unknown
+ *
+ * Valid errors:
+ *
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ * PASSWORD_INCORRECT
+ * (old PIN is invalid)
+ *
+ */
+
+#define RIL_REQUEST_CHANGE_SIM_PIN 6
+
+
+/**
+ * RIL_REQUEST_CHANGE_SIM_PIN2
+ *
+ * Supplies old SIM PIN2 and new PIN2.
+ *
+ * "data" is const char **
+ * ((const char **)data)[0] is old PIN2 value
+ * ((const char **)data)[1] is new PIN2 value
+ * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
+ *
+ * "response" is int *
+ * ((int *)response)[0] is the number of retries remaining, or -1 if unknown
+ *
+ * Valid errors:
+ *
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ * PASSWORD_INCORRECT
+ * (old PIN2 is invalid)
+ *
+ */
+
+#define RIL_REQUEST_CHANGE_SIM_PIN2 7
+
+/**
+ * RIL_REQUEST_ENTER_DEPERSONALIZATION_CODE
+ *
+ * Requests that personlization be deactivated
+ *
+ * "data" is const char **
+ * ((const char **)(data))[0]] is personlization type
+ * ((const char **)(data))[1]] is depersonlization code
+ *
+ * "response" is int *
+ * ((int *)response)[0] is the number of retries remaining, or -1 if unknown
+ *
+ * Valid errors:
+ *
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ * PASSWORD_INCORRECT
+ * (code is invalid)
+ */
+
+#define RIL_REQUEST_ENTER_DEPERSONALIZATION_CODE 8
+
+/**
+ * RIL_REQUEST_GET_CURRENT_CALLS
+ *
+ * Requests current call list
+ *
+ * "data" is NULL
+ *
+ * "response" must be a "const RIL_Call **"
+ *
+ * Valid errors:
+ *
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ * (request will be made again in a few hundred msec)
+ */
+
+#define RIL_REQUEST_GET_CURRENT_CALLS 9
+
+
+/**
+ * RIL_REQUEST_DIAL
+ *
+ * Initiate voice call
+ *
+ * "data" is const RIL_Dial *
+ * "response" is NULL
+ *
+ * This method is never used for supplementary service codes
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * DIAL_MODIFIED_TO_USSD
+ * DIAL_MODIFIED_TO_SS
+ * DIAL_MODIFIED_TO_DIAL
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_DIAL 10
+
+/**
+ * RIL_REQUEST_GET_IMSI
+ *
+ * Get the SIM IMSI
+ *
+ * Only valid when radio state is "RADIO_STATE_ON"
+ *
+ * "data" is const char **
+ * ((const char **)data)[0] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
+ * "response" is a const char * containing the IMSI
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+
+#define RIL_REQUEST_GET_IMSI 11
+
+/**
+ * RIL_REQUEST_HANGUP
+ *
+ * Hang up a specific line (like AT+CHLD=1x)
+ *
+ * After this HANGUP request returns, RIL should show the connection is NOT
+ * active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query.
+ *
+ * "data" is an int *
+ * (int *)data)[0] contains Connection index (value of 'x' in CHLD above)
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+
+#define RIL_REQUEST_HANGUP 12
+
+/**
+ * RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND
+ *
+ * Hang up waiting or held (like AT+CHLD=0)
+ *
+ * After this HANGUP request returns, RIL should show the connection is NOT
+ * active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query.
+ *
+ * "data" is NULL
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+
+#define RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND 13
+
+/**
+ * RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND
+ *
+ * Hang up waiting or held (like AT+CHLD=1)
+ *
+ * After this HANGUP request returns, RIL should show the connection is NOT
+ * active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query.
+ *
+ * "data" is NULL
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+
+#define RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND 14
+
+/**
+ * RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE
+ *
+ * Switch waiting or holding call and active call (like AT+CHLD=2)
+ *
+ * State transitions should be is follows:
+ *
+ * If call 1 is waiting and call 2 is active, then if this re
+ *
+ * BEFORE AFTER
+ * Call 1 Call 2 Call 1 Call 2
+ * ACTIVE HOLDING HOLDING ACTIVE
+ * ACTIVE WAITING HOLDING ACTIVE
+ * HOLDING WAITING HOLDING ACTIVE
+ * ACTIVE IDLE HOLDING IDLE
+ * IDLE IDLE IDLE IDLE
+ *
+ * "data" is NULL
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+
+#define RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE 15
+#define RIL_REQUEST_SWITCH_HOLDING_AND_ACTIVE 15
+
+/**
+ * RIL_REQUEST_CONFERENCE
+ *
+ * Conference holding and active (like AT+CHLD=3)
+
+ * "data" is NULL
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_CONFERENCE 16
+
+/**
+ * RIL_REQUEST_UDUB
+ *
+ * Send UDUB (user determined used busy) to ringing or
+ * waiting call answer)(RIL_BasicRequest r);
+ *
+ * "data" is NULL
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_UDUB 17
+
+/**
+ * RIL_REQUEST_LAST_CALL_FAIL_CAUSE
+ *
+ * Requests the failure cause code for the most recently terminated call
+ *
+ * "data" is NULL
+ * "response" is a "int *"
+ * ((int *)response)[0] is RIL_LastCallFailCause. GSM failure reasons are
+ * mapped to cause codes defined in TS 24.008 Annex H where possible. CDMA
+ * failure reasons are derived from the possible call failure scenarios
+ * described in the "CDMA IS-2000 Release A (C.S0005-A v6.0)" standard.
+ *
+ * The implementation should return CALL_FAIL_ERROR_UNSPECIFIED for blocked
+ * MO calls by restricted state (See RIL_UNSOL_RESTRICTED_STATE_CHANGED)
+ *
+ * If the implementation does not have access to the exact cause codes,
+ * then it should return one of the values listed in RIL_LastCallFailCause,
+ * as the UI layer needs to distinguish these cases for tone generation or
+ * error notification.
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ * See also: RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE
+ */
+#define RIL_REQUEST_LAST_CALL_FAIL_CAUSE 18
+
+/**
+ * RIL_REQUEST_SIGNAL_STRENGTH
+ *
+ * Requests current signal strength and associated information
+ *
+ * Must succeed if radio is on.
+ *
+ * "data" is NULL
+ *
+ * "response" is a const RIL_SignalStrength *
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ */
+#define RIL_REQUEST_SIGNAL_STRENGTH 19
+
+/**
+ * RIL_REQUEST_VOICE_REGISTRATION_STATE
+ *
+ * Request current registration state
+ *
+ * "data" is NULL
+ * "response" is a "char **"
+ * ((const char **)response)[0] is registration state 0-6,
+ * 0 - Not registered, MT is not currently searching
+ * a new operator to register
+ * 1 - Registered, home network
+ * 2 - Not registered, but MT is currently searching
+ * a new operator to register
+ * 3 - Registration denied
+ * 4 - Unknown
+ * 5 - Registered, roaming
+ * 10 - Same as 0, but indicates that emergency calls
+ * are enabled.
+ * 12 - Same as 2, but indicates that emergency calls
+ * are enabled.
+ * 13 - Same as 3, but indicates that emergency calls
+ * are enabled.
+ * 14 - Same as 4, but indicates that emergency calls
+ * are enabled.
+ *
+ * ((const char **)response)[1] is LAC if registered on a GSM/WCDMA system or
+ * NULL if not.Valid LAC are 0x0000 - 0xffff
+ * ((const char **)response)[2] is CID if registered on a * GSM/WCDMA or
+ * NULL if not.
+ * Valid CID are 0x00000000 - 0xffffffff
+ * In GSM, CID is Cell ID (see TS 27.007)
+ * in 16 bits
+ * In UMTS, CID is UMTS Cell Identity
+ * (see TS 25.331) in 28 bits
+ * ((const char **)response)[3] indicates the available voice radio technology,
+ * valid values as defined by RIL_RadioTechnology.
+ * ((const char **)response)[4] is Base Station ID if registered on a CDMA
+ * system or NULL if not. Base Station ID in
+ * decimal format
+ * ((const char **)response)[5] is Base Station latitude if registered on a
+ * CDMA system or NULL if not. Base Station
+ * latitude is a decimal number as specified in
+ * 3GPP2 C.S0005-A v6.0. It is represented in
+ * units of 0.25 seconds and ranges from -1296000
+ * to 1296000, both values inclusive (corresponding
+ * to a range of -90 to +90 degrees).
+ * ((const char **)response)[6] is Base Station longitude if registered on a
+ * CDMA system or NULL if not. Base Station
+ * longitude is a decimal number as specified in
+ * 3GPP2 C.S0005-A v6.0. It is represented in
+ * units of 0.25 seconds and ranges from -2592000
+ * to 2592000, both values inclusive (corresponding
+ * to a range of -180 to +180 degrees).
+ * ((const char **)response)[7] is concurrent services support indicator if
+ * registered on a CDMA system 0-1.
+ * 0 - Concurrent services not supported,
+ * 1 - Concurrent services supported
+ * ((const char **)response)[8] is System ID if registered on a CDMA system or
+ * NULL if not. Valid System ID are 0 - 32767
+ * ((const char **)response)[9] is Network ID if registered on a CDMA system or
+ * NULL if not. Valid System ID are 0 - 65535
+ * ((const char **)response)[10] is the TSB-58 Roaming Indicator if registered
+ * on a CDMA or EVDO system or NULL if not. Valid values
+ * are 0-255.
+ * ((const char **)response)[11] indicates whether the current system is in the
+ * PRL if registered on a CDMA or EVDO system or NULL if
+ * not. 0=not in the PRL, 1=in the PRL
+ * ((const char **)response)[12] is the default Roaming Indicator from the PRL,
+ * if registered on a CDMA or EVDO system or NULL if not.
+ * Valid values are 0-255.
+ * ((const char **)response)[13] if registration state is 3 (Registration
+ * denied) this is an enumerated reason why
+ * registration was denied. See 3GPP TS 24.008,
+ * 10.5.3.6 and Annex G.
+ * 0 - General
+ * 1 - Authentication Failure
+ * 2 - IMSI unknown in HLR
+ * 3 - Illegal MS
+ * 4 - Illegal ME
+ * 5 - PLMN not allowed
+ * 6 - Location area not allowed
+ * 7 - Roaming not allowed
+ * 8 - No Suitable Cells in this Location Area
+ * 9 - Network failure
+ * 10 - Persistent location update reject
+ * 11 - PLMN not allowed
+ * 12 - Location area not allowed
+ * 13 - Roaming not allowed in this Location Area
+ * 15 - No Suitable Cells in this Location Area
+ * 17 - Network Failure
+ * 20 - MAC Failure
+ * 21 - Sync Failure
+ * 22 - Congestion
+ * 23 - GSM Authentication unacceptable
+ * 25 - Not Authorized for this CSG
+ * 32 - Service option not supported
+ * 33 - Requested service option not subscribed
+ * 34 - Service option temporarily out of order
+ * 38 - Call cannot be identified
+ * 48-63 - Retry upon entry into a new cell
+ * 95 - Semantically incorrect message
+ * 96 - Invalid mandatory information
+ * 97 - Message type non-existent or not implemented
+ * 98 - Message not compatible with protocol state
+ * 99 - Information element non-existent or not implemented
+ * 100 - Conditional IE error
+ * 101 - Message not compatible with protocol state
+ * 111 - Protocol error, unspecified
+ * ((const char **)response)[14] is the Primary Scrambling Code of the current
+ * cell as described in TS 25.331, in hexadecimal
+ * format, or NULL if unknown or not registered
+ * to a UMTS network.
+ *
+ * Please note that registration state 4 ("unknown") is treated
+ * as "out of service" in the Android telephony system
+ *
+ * Registration state 3 can be returned if Location Update Reject
+ * (with cause 17 - Network Failure) is received repeatedly from the network,
+ * to facilitate "managed roaming"
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_VOICE_REGISTRATION_STATE 20
+
+/**
+ * RIL_REQUEST_DATA_REGISTRATION_STATE
+ *
+ * Request current DATA registration state
+ *
+ * "data" is NULL
+ * "response" is a "char **"
+ * ((const char **)response)[0] is registration state 0-5 from TS 27.007 10.1.20 AT+CGREG
+ * ((const char **)response)[1] is LAC if registered or NULL if not
+ * ((const char **)response)[2] is CID if registered or NULL if not
+ * ((const char **)response)[3] indicates the available data radio technology,
+ * valid values as defined by RIL_RadioTechnology.
+ * ((const char **)response)[4] if registration state is 3 (Registration
+ * denied) this is an enumerated reason why
+ * registration was denied. See 3GPP TS 24.008,
+ * Annex G.6 "Additonal cause codes for GMM".
+ * 7 == GPRS services not allowed
+ * 8 == GPRS services and non-GPRS services not allowed
+ * 9 == MS identity cannot be derived by the network
+ * 10 == Implicitly detached
+ * 14 == GPRS services not allowed in this PLMN
+ * 16 == MSC temporarily not reachable
+ * 40 == No PDP context activated
+ * ((const char **)response)[5] The maximum number of simultaneous Data Calls that can be
+ * established using RIL_REQUEST_SETUP_DATA_CALL.
+ *
+ * The values at offsets 6..10 are optional LTE location information in decimal.
+ * If a value is unknown that value may be NULL. If all values are NULL,
+ * none need to be present.
+ * ((const char **)response)[6] is TAC, a 16-bit Tracking Area Code.
+ * ((const char **)response)[7] is CID, a 0-503 Physical Cell Identifier.
+ * ((const char **)response)[8] is ECI, a 28-bit E-UTRAN Cell Identifier.
+ * ((const char **)response)[9] is CSGID, a 27-bit Closed Subscriber Group Identity.
+ * ((const char **)response)[10] is TADV, a 6-bit timing advance value.
+ *
+ * LAC and CID are in hexadecimal format.
+ * valid LAC are 0x0000 - 0xffff
+ * valid CID are 0x00000000 - 0x0fffffff
+ *
+ * Please note that registration state 4 ("unknown") is treated
+ * as "out of service" in the Android telephony system
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_DATA_REGISTRATION_STATE 21
+
+/**
+ * RIL_REQUEST_OPERATOR
+ *
+ * Request current operator ONS or EONS
+ *
+ * "data" is NULL
+ * "response" is a "const char **"
+ * ((const char **)response)[0] is long alpha ONS or EONS
+ * or NULL if unregistered
+ *
+ * ((const char **)response)[1] is short alpha ONS or EONS
+ * or NULL if unregistered
+ * ((const char **)response)[2] is 5 or 6 digit numeric code (MCC + MNC)
+ * or NULL if unregistered
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_OPERATOR 22
+
+/**
+ * RIL_REQUEST_RADIO_POWER
+ *
+ * Toggle radio on and off (for "airplane" mode)
+ * If the radio is is turned off/on the radio modem subsystem
+ * is expected return to an initialized state. For instance,
+ * any voice and data calls will be terminated and all associated
+ * lists emptied.
+ *
+ * "data" is int *
+ * ((int *)data)[0] is > 0 for "Radio On"
+ * ((int *)data)[0] is == 0 for "Radio Off"
+ *
+ * "response" is NULL
+ *
+ * Turn radio on if "on" > 0
+ * Turn radio off if "on" == 0
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_RADIO_POWER 23
+
+/**
+ * RIL_REQUEST_DTMF
+ *
+ * Send a DTMF tone
+ *
+ * If the implementation is currently playing a tone requested via
+ * RIL_REQUEST_DTMF_START, that tone should be cancelled and the new tone
+ * should be played instead
+ *
+ * "data" is a char * containing a single character with one of 12 values: 0-9,*,#
+ * "response" is NULL
+ *
+ * FIXME should this block/mute microphone?
+ * How does this interact with local DTMF feedback?
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ * See also: RIL_REQUEST_DTMF_STOP, RIL_REQUEST_DTMF_START
+ *
+ */
+#define RIL_REQUEST_DTMF 24
+
+/**
+ * RIL_REQUEST_SEND_SMS
+ *
+ * Send an SMS message
+ *
+ * "data" is const char **
+ * ((const char **)data)[0] is SMSC address in GSM BCD format prefixed
+ * by a length byte (as expected by TS 27.005) or NULL for default SMSC
+ * ((const char **)data)[1] is SMS in PDU format as an ASCII hex string
+ * less the SMSC address
+ * TP-Layer-Length is be "strlen(((const char **)data)[1])/2"
+ *
+ * "response" is a const RIL_SMS_Response *
+ *
+ * Based on the return error, caller decides to resend if sending sms
+ * fails. SMS_SEND_FAIL_RETRY means retry (i.e. error cause is 332)
+ * and GENERIC_FAILURE means no retry (i.e. error cause is 500)
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * SMS_SEND_FAIL_RETRY
+ * FDN_CHECK_FAILURE
+ * GENERIC_FAILURE
+ *
+ * FIXME how do we specify TP-Message-Reference if we need to resend?
+ */
+#define RIL_REQUEST_SEND_SMS 25
+
+
+/**
+ * RIL_REQUEST_SEND_SMS_EXPECT_MORE
+ *
+ * Send an SMS message. Identical to RIL_REQUEST_SEND_SMS,
+ * except that more messages are expected to be sent soon. If possible,
+ * keep SMS relay protocol link open (eg TS 27.005 AT+CMMS command)
+ *
+ * "data" is const char **
+ * ((const char **)data)[0] is SMSC address in GSM BCD format prefixed
+ * by a length byte (as expected by TS 27.005) or NULL for default SMSC
+ * ((const char **)data)[1] is SMS in PDU format as an ASCII hex string
+ * less the SMSC address
+ * TP-Layer-Length is be "strlen(((const char **)data)[1])/2"
+ *
+ * "response" is a const RIL_SMS_Response *
+ *
+ * Based on the return error, caller decides to resend if sending sms
+ * fails. SMS_SEND_FAIL_RETRY means retry (i.e. error cause is 332)
+ * and GENERIC_FAILURE means no retry (i.e. error cause is 500)
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * SMS_SEND_FAIL_RETRY
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_SEND_SMS_EXPECT_MORE 26
+
+
+/**
+ * RIL_REQUEST_SETUP_DATA_CALL
+ *
+ * Setup a packet data connection. If RIL_Data_Call_Response_v6.status
+ * return success it is added to the list of data calls and a
+ * RIL_UNSOL_DATA_CALL_LIST_CHANGED is sent. The call remains in the
+ * list until RIL_REQUEST_DEACTIVATE_DATA_CALL is issued or the
+ * radio is powered off/on. This list is returned by RIL_REQUEST_DATA_CALL_LIST
+ * and RIL_UNSOL_DATA_CALL_LIST_CHANGED.
+ *
+ * The RIL is expected to:
+ * - Create one data call context.
+ * - Create and configure a dedicated interface for the context
+ * - The interface must be point to point.
+ * - The interface is configured with one or more addresses and
+ * is capable of sending and receiving packets. The prefix length
+ * of the addresses must be /32 for IPv4 and /128 for IPv6.
+ * - Must NOT change the linux routing table.
+ * - Support up to RIL_REQUEST_DATA_REGISTRATION_STATE response[5]
+ * number of simultaneous data call contexts.
+ *
+ * "data" is a const char **
+ * ((const char **)data)[0] Radio technology to use: 0-CDMA, 1-GSM/UMTS, 2...
+ * for values above 2 this is RIL_RadioTechnology + 2.
+ * ((const char **)data)[1] is a RIL_DataProfile (support is optional)
+ * ((const char **)data)[2] is the APN to connect to if radio technology is GSM/UMTS. This APN will
+ * override the one in the profile. NULL indicates no APN overrride.
+ * ((const char **)data)[3] is the username for APN, or NULL
+ * ((const char **)data)[4] is the password for APN, or NULL
+ * ((const char **)data)[5] is the PAP / CHAP auth type. Values:
+ * 0 => PAP and CHAP is never performed.
+ * 1 => PAP may be performed; CHAP is never performed.
+ * 2 => CHAP may be performed; PAP is never performed.
+ * 3 => PAP / CHAP may be performed - baseband dependent.
+ * ((const char **)data)[6] is the connection type to request must be one of the
+ * PDP_type values in TS 27.007 section 10.1.1.
+ * For example, "IP", "IPV6", "IPV4V6", or "PPP".
+ * ((const char **)data)[7] Optional connection property parameters, format to be defined.
+ *
+ * "response" is a RIL_Data_Call_Response_v6
+ *
+ * FIXME may need way to configure QoS settings
+ *
+ * Valid errors:
+ * SUCCESS should be returned on both success and failure of setup with
+ * the RIL_Data_Call_Response_v6.status containing the actual status.
+ * For all other errors the RIL_Data_Call_Resonse_v6 is ignored.
+ *
+ * Other errors could include:
+ * RADIO_NOT_AVAILABLE, GENERIC_FAILURE, OP_NOT_ALLOWED_BEFORE_REG_TO_NW,
+ * OP_NOT_ALLOWED_DURING_VOICE_CALL and REQUEST_NOT_SUPPORTED.
+ *
+ * See also: RIL_REQUEST_DEACTIVATE_DATA_CALL
+ */
+#define RIL_REQUEST_SETUP_DATA_CALL 27
+
+
+/**
+ * RIL_REQUEST_SIM_IO
+ *
+ * Request SIM I/O operation.
+ * This is similar to the TS 27.007 "restricted SIM" operation
+ * where it assumes all of the EF selection will be done by the
+ * callee.
+ *
+ * "data" is a const RIL_SIM_IO_v6 *
+ * Please note that RIL_SIM_IO has a "PIN2" field which may be NULL,
+ * or may specify a PIN2 for operations that require a PIN2 (eg
+ * updating FDN records)
+ *
+ * "response" is a const RIL_SIM_IO_Response *
+ *
+ * Arguments and responses that are unused for certain
+ * values of "command" should be ignored or set to NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ * SIM_PIN2
+ * SIM_PUK2
+ */
+#define RIL_REQUEST_SIM_IO 28
+
+/**
+ * RIL_REQUEST_SEND_USSD
+ *
+ * Send a USSD message
+ *
+ * If a USSD session already exists, the message should be sent in the
+ * context of that session. Otherwise, a new session should be created.
+ *
+ * The network reply should be reported via RIL_UNSOL_ON_USSD
+ *
+ * Only one USSD session may exist at a time, and the session is assumed
+ * to exist until:
+ * a) The android system invokes RIL_REQUEST_CANCEL_USSD
+ * b) The implementation sends a RIL_UNSOL_ON_USSD with a type code
+ * of "0" (USSD-Notify/no further action) or "2" (session terminated)
+ *
+ * "data" is a const char * containing the USSD request in UTF-8 format
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * FDN_CHECK_FAILURE
+ * USSD_MODIFIED_TO_DIAL
+ * USSD_MODIFIED_TO_SS
+ * USSD_MODIFIED_TO_USSD
+ * GENERIC_FAILURE
+ *
+ * See also: RIL_REQUEST_CANCEL_USSD, RIL_UNSOL_ON_USSD
+ */
+
+#define RIL_REQUEST_SEND_USSD 29
+
+/**
+ * RIL_REQUEST_CANCEL_USSD
+ *
+ * Cancel the current USSD session if one exists
+ *
+ * "data" is null
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+
+#define RIL_REQUEST_CANCEL_USSD 30
+
+/**
+ * RIL_REQUEST_GET_CLIR
+ *
+ * Gets current CLIR status
+ * "data" is NULL
+ * "response" is int *
+ * ((int *)data)[0] is "n" parameter from TS 27.007 7.7
+ * ((int *)data)[1] is "m" parameter from TS 27.007 7.7
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * SS_MODIFIED_TO_DIAL
+ * SS_MODIFIED_TO_USSD
+ * SS_MODIFIED_TO_SS
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_GET_CLIR 31
+
+/**
+ * RIL_REQUEST_SET_CLIR
+ *
+ * "data" is int *
+ * ((int *)data)[0] is "n" parameter from TS 27.007 7.7
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * SS_MODIFIED_TO_DIAL
+ * SS_MODIFIED_TO_USSD
+ * SS_MODIFIED_TO_SS
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_SET_CLIR 32
+
+/**
+ * RIL_REQUEST_QUERY_CALL_FORWARD_STATUS
+ *
+ * "data" is const RIL_CallForwardInfo *
+ *
+ * "response" is const RIL_CallForwardInfo **
+ * "response" points to an array of RIL_CallForwardInfo *'s, one for
+ * each distinct registered phone number.
+ *
+ * For example, if data is forwarded to +18005551212 and voice is forwarded
+ * to +18005559999, then two separate RIL_CallForwardInfo's should be returned
+ *
+ * If, however, both data and voice are forwarded to +18005551212, then
+ * a single RIL_CallForwardInfo can be returned with the service class
+ * set to "data + voice = 3")
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * SS_MODIFIED_TO_DIAL
+ * SS_MODIFIED_TO_USSD
+ * SS_MODIFIED_TO_SS
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_QUERY_CALL_FORWARD_STATUS 33
+
+
+/**
+ * RIL_REQUEST_SET_CALL_FORWARD
+ *
+ * Configure call forward rule
+ *
+ * "data" is const RIL_CallForwardInfo *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * SS_MODIFIED_TO_DIAL
+ * SS_MODIFIED_TO_USSD
+ * SS_MODIFIED_TO_SS
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_SET_CALL_FORWARD 34
+
+
+/**
+ * RIL_REQUEST_QUERY_CALL_WAITING
+ *
+ * Query current call waiting state
+ *
+ * "data" is const int *
+ * ((const int *)data)[0] is the TS 27.007 service class to query.
+ * "response" is a const int *
+ * ((const int *)response)[0] is 0 for "disabled" and 1 for "enabled"
+ *
+ * If ((const int *)response)[0] is = 1, then ((const int *)response)[1]
+ * must follow, with the TS 27.007 service class bit vector of services
+ * for which call waiting is enabled.
+ *
+ * For example, if ((const int *)response)[0] is 1 and
+ * ((const int *)response)[1] is 3, then call waiting is enabled for data
+ * and voice and disabled for everything else
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * SS_MODIFIED_TO_DIAL
+ * SS_MODIFIED_TO_USSD
+ * SS_MODIFIED_TO_SS
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_QUERY_CALL_WAITING 35
+
+
+/**
+ * RIL_REQUEST_SET_CALL_WAITING
+ *
+ * Configure current call waiting state
+ *
+ * "data" is const int *
+ * ((const int *)data)[0] is 0 for "disabled" and 1 for "enabled"
+ * ((const int *)data)[1] is the TS 27.007 service class bit vector of
+ * services to modify
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * SS_MODIFIED_TO_DIAL
+ * SS_MODIFIED_TO_USSD
+ * SS_MODIFIED_TO_SS
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_SET_CALL_WAITING 36
+
+/**
+ * RIL_REQUEST_SMS_ACKNOWLEDGE
+ *
+ * Acknowledge successful or failed receipt of SMS previously indicated
+ * via RIL_UNSOL_RESPONSE_NEW_SMS
+ *
+ * "data" is int *
+ * ((int *)data)[0] is 1 on successful receipt
+ * (basically, AT+CNMA=1 from TS 27.005
+ * is 0 on failed receipt
+ * (basically, AT+CNMA=2 from TS 27.005)
+ * ((int *)data)[1] if data[0] is 0, this contains the failure cause as defined
+ * in TS 23.040, 9.2.3.22. Currently only 0xD3 (memory
+ * capacity exceeded) and 0xFF (unspecified error) are
+ * reported.
+ *
+ * "response" is NULL
+ *
+ * FIXME would like request that specified RP-ACK/RP-ERROR PDU
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_SMS_ACKNOWLEDGE 37
+
+/**
+ * RIL_REQUEST_GET_IMEI - DEPRECATED
+ *
+ * Get the device IMEI, including check digit
+ *
+ * The request is DEPRECATED, use RIL_REQUEST_DEVICE_IDENTITY
+ * Valid when RadioState is not RADIO_STATE_UNAVAILABLE
+ *
+ * "data" is NULL
+ * "response" is a const char * containing the IMEI
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+
+#define RIL_REQUEST_GET_IMEI 38
+
+/**
+ * RIL_REQUEST_GET_IMEISV - DEPRECATED
+ *
+ * Get the device IMEISV, which should be two decimal digits
+ *
+ * The request is DEPRECATED, use RIL_REQUEST_DEVICE_IDENTITY
+ * Valid when RadioState is not RADIO_STATE_UNAVAILABLE
+ *
+ * "data" is NULL
+ * "response" is a const char * containing the IMEISV
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+
+#define RIL_REQUEST_GET_IMEISV 39
+
+
+/**
+ * RIL_REQUEST_ANSWER
+ *
+ * Answer incoming call
+ *
+ * Will not be called for WAITING calls.
+ * RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE will be used in this case
+ * instead
+ *
+ * "data" is NULL
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+
+#define RIL_REQUEST_ANSWER 40
+
+/**
+ * RIL_REQUEST_DEACTIVATE_DATA_CALL
+ *
+ * Deactivate packet data connection and remove from the
+ * data call list if SUCCESS is returned. Any other return
+ * values should also try to remove the call from the list,
+ * but that may not be possible. In any event a
+ * RIL_REQUEST_RADIO_POWER off/on must clear the list. An
+ * RIL_UNSOL_DATA_CALL_LIST_CHANGED is not expected to be
+ * issued because of an RIL_REQUEST_DEACTIVATE_DATA_CALL.
+ *
+ * "data" is const char **
+ * ((char**)data)[0] indicating CID
+ * ((char**)data)[1] indicating Disconnect Reason
+ * 0 => No specific reason specified
+ * 1 => Radio shutdown requested
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ * See also: RIL_REQUEST_SETUP_DATA_CALL
+ */
+#define RIL_REQUEST_DEACTIVATE_DATA_CALL 41
+
+/**
+ * RIL_REQUEST_QUERY_FACILITY_LOCK
+ *
+ * Query the status of a facility lock state
+ *
+ * "data" is const char **
+ * ((const char **)data)[0] is the facility string code from TS 27.007 7.4
+ * (eg "AO" for BAOC, "SC" for SIM lock)
+ * ((const char **)data)[1] is the password, or "" if not required
+ * ((const char **)data)[2] is the TS 27.007 service class bit vector of
+ * services to query
+ * ((const char **)data)[3] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
+ * This is only applicable in the case of Fixed Dialing Numbers
+ * (FDN) requests.
+ *
+ * "response" is an int *
+ * ((const int *)response) 0 is the TS 27.007 service class bit vector of
+ * services for which the specified barring facility
+ * is active. "0" means "disabled for all"
+ *
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * SS_MODIFIED_TO_DIAL
+ * SS_MODIFIED_TO_USSD
+ * SS_MODIFIED_TO_SS
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_QUERY_FACILITY_LOCK 42
+
+/**
+ * RIL_REQUEST_SET_FACILITY_LOCK
+ *
+ * Enable/disable one facility lock
+ *
+ * "data" is const char **
+ *
+ * ((const char **)data)[0] = facility string code from TS 27.007 7.4
+ * (eg "AO" for BAOC)
+ * ((const char **)data)[1] = "0" for "unlock" and "1" for "lock"
+ * ((const char **)data)[2] = password
+ * ((const char **)data)[3] = string representation of decimal TS 27.007
+ * service class bit vector. Eg, the string
+ * "1" means "set this facility for voice services"
+ * ((const char **)data)[4] = AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
+ * This is only applicable in the case of Fixed Dialing Numbers
+ * (FDN) requests.
+ *
+ * "response" is int *
+ * ((int *)response)[0] is the number of retries remaining, or -1 if unknown
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * SS_MODIFIED_TO_DIAL
+ * SS_MODIFIED_TO_USSD
+ * SS_MODIFIED_TO_SS
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_SET_FACILITY_LOCK 43
+
+/**
+ * RIL_REQUEST_CHANGE_BARRING_PASSWORD
+ *
+ * Change call barring facility password
+ *
+ * "data" is const char **
+ *
+ * ((const char **)data)[0] = facility string code from TS 27.007 7.4
+ * (eg "AO" for BAOC)
+ * ((const char **)data)[1] = old password
+ * ((const char **)data)[2] = new password
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * SS_MODIFIED_TO_DIAL
+ * SS_MODIFIED_TO_USSD
+ * SS_MODIFIED_TO_SS
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CHANGE_BARRING_PASSWORD 44
+
+/**
+ * RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE
+ *
+ * Query current network selectin mode
+ *
+ * "data" is NULL
+ *
+ * "response" is int *
+ * ((const int *)response)[0] is
+ * 0 for automatic selection
+ * 1 for manual selection
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE 45
+
+/**
+ * RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC
+ *
+ * Specify that the network should be selected automatically
+ *
+ * "data" is NULL
+ * "response" is NULL
+ *
+ * This request must not respond until the new operator is selected
+ * and registered
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * ILLEGAL_SIM_OR_ME
+ * GENERIC_FAILURE
+ *
+ * Note: Returns ILLEGAL_SIM_OR_ME when the failure is permanent and
+ * no retries needed, such as illegal SIM or ME.
+ * Returns GENERIC_FAILURE for all other causes that might be
+ * fixed by retries.
+ *
+ */
+#define RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC 46
+
+/**
+ * RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL
+ *
+ * Manually select a specified network.
+ *
+ * "data" is const char * specifying MCCMNC of network to select (eg "310170")
+ * "response" is NULL
+ *
+ * This request must not respond until the new operator is selected
+ * and registered
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * ILLEGAL_SIM_OR_ME
+ * GENERIC_FAILURE
+ *
+ * Note: Returns ILLEGAL_SIM_OR_ME when the failure is permanent and
+ * no retries needed, such as illegal SIM or ME.
+ * Returns GENERIC_FAILURE for all other causes that might be
+ * fixed by retries.
+ *
+ */
+#define RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL 47
+
+/**
+ * RIL_REQUEST_QUERY_AVAILABLE_NETWORKS
+ *
+ * Scans for available networks
+ *
+ * "data" is NULL
+ * "response" is const char ** that should be an array of n*4 strings, where
+ * n is the number of available networks
+ * For each available network:
+ *
+ * ((const char **)response)[n+0] is long alpha ONS or EONS
+ * ((const char **)response)[n+1] is short alpha ONS or EONS
+ * ((const char **)response)[n+2] is 5 or 6 digit numeric code (MCC + MNC)
+ * ((const char **)response)[n+3] is a string value of the status:
+ * "unknown"
+ * "available"
+ * "current"
+ * "forbidden"
+ *
+ * This request must not respond until the new operator is selected
+ * and registered
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_QUERY_AVAILABLE_NETWORKS 48
+
+/**
+ * RIL_REQUEST_DTMF_START
+ *
+ * Start playing a DTMF tone. Continue playing DTMF tone until
+ * RIL_REQUEST_DTMF_STOP is received
+ *
+ * If a RIL_REQUEST_DTMF_START is received while a tone is currently playing,
+ * it should cancel the previous tone and play the new one.
+ *
+ * "data" is a char *
+ * ((char *)data)[0] is a single character with one of 12 values: 0-9,*,#
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ * See also: RIL_REQUEST_DTMF, RIL_REQUEST_DTMF_STOP
+ */
+#define RIL_REQUEST_DTMF_START 49
+
+/**
+ * RIL_REQUEST_DTMF_STOP
+ *
+ * Stop playing a currently playing DTMF tone.
+ *
+ * "data" is NULL
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ * See also: RIL_REQUEST_DTMF, RIL_REQUEST_DTMF_START
+ */
+#define RIL_REQUEST_DTMF_STOP 50
+
+/**
+ * RIL_REQUEST_BASEBAND_VERSION
+ *
+ * Return string value indicating baseband version, eg
+ * response from AT+CGMR
+ *
+ * "data" is NULL
+ * "response" is const char * containing version string for log reporting
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_BASEBAND_VERSION 51
+
+/**
+ * RIL_REQUEST_SEPARATE_CONNECTION
+ *
+ * Separate a party from a multiparty call placing the multiparty call
+ * (less the specified party) on hold and leaving the specified party
+ * as the only other member of the current (active) call
+ *
+ * Like AT+CHLD=2x
+ *
+ * See TS 22.084 1.3.8.2 (iii)
+ * TS 22.030 6.5.5 "Entering "2X followed by send"
+ * TS 27.007 "AT+CHLD=2x"
+ *
+ * "data" is an int *
+ * (int *)data)[0] contains Connection index (value of 'x' in CHLD above) "response" is NULL
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_SEPARATE_CONNECTION 52
+
+
+/**
+ * RIL_REQUEST_SET_MUTE
+ *
+ * Turn on or off uplink (microphone) mute.
+ *
+ * Will only be sent while voice call is active.
+ * Will always be reset to "disable mute" when a new voice call is initiated
+ *
+ * "data" is an int *
+ * (int *)data)[0] is 1 for "enable mute" and 0 for "disable mute"
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+
+#define RIL_REQUEST_SET_MUTE 53
+
+/**
+ * RIL_REQUEST_GET_MUTE
+ *
+ * Queries the current state of the uplink mute setting
+ *
+ * "data" is NULL
+ * "response" is an int *
+ * (int *)response)[0] is 1 for "mute enabled" and 0 for "mute disabled"
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * SS_MODIFIED_TO_DIAL
+ * SS_MODIFIED_TO_USSD
+ * SS_MODIFIED_TO_SS
+ * GENERIC_FAILURE
+ */
+
+#define RIL_REQUEST_GET_MUTE 54
+
+/**
+ * RIL_REQUEST_QUERY_CLIP
+ *
+ * Queries the status of the CLIP supplementary service
+ *
+ * (for MMI code "*#30#")
+ *
+ * "data" is NULL
+ * "response" is an int *
+ * (int *)response)[0] is 1 for "CLIP provisioned"
+ * and 0 for "CLIP not provisioned"
+ * and 2 for "unknown, e.g. no network etc"
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+
+#define RIL_REQUEST_QUERY_CLIP 55
+
+/**
+ * RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE - Deprecated use the status
+ * field in RIL_Data_Call_Response_v6.
+ *
+ * Requests the failure cause code for the most recently failed PDP
+ * context or CDMA data connection active
+ * replaces RIL_REQUEST_LAST_PDP_FAIL_CAUSE
+ *
+ * "data" is NULL
+ *
+ * "response" is a "int *"
+ * ((int *)response)[0] is an integer cause code defined in TS 24.008
+ * section 6.1.3.1.3 or close approximation
+ *
+ * If the implementation does not have access to the exact cause codes,
+ * then it should return one of the values listed in
+ * RIL_DataCallFailCause, as the UI layer needs to distinguish these
+ * cases for error notification
+ * and potential retries.
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ * See also: RIL_REQUEST_LAST_CALL_FAIL_CAUSE
+ *
+ * Deprecated use the status field in RIL_Data_Call_Response_v6.
+ */
+
+#define RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE 56
+
+/**
+ * RIL_REQUEST_DATA_CALL_LIST
+ *
+ * Returns the data call list. An entry is added when a
+ * RIL_REQUEST_SETUP_DATA_CALL is issued and removed on a
+ * RIL_REQUEST_DEACTIVATE_DATA_CALL. The list is emptied
+ * when RIL_REQUEST_RADIO_POWER off/on is issued.
+ *
+ * "data" is NULL
+ * "response" is an array of RIL_Data_Call_Response_v6
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ *
+ * See also: RIL_UNSOL_DATA_CALL_LIST_CHANGED
+ */
+
+#define RIL_REQUEST_DATA_CALL_LIST 57
+
+/**
+ * RIL_REQUEST_RESET_RADIO - DEPRECATED
+ *
+ * Request a radio reset. The RIL implementation may postpone
+ * the reset until after this request is responded to if the baseband
+ * is presently busy.
+ *
+ * The request is DEPRECATED, use RIL_REQUEST_RADIO_POWER
+ *
+ * "data" is NULL
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ * REQUEST_NOT_SUPPORTED
+ */
+
+#define RIL_REQUEST_RESET_RADIO 58
+
+/**
+ * RIL_REQUEST_OEM_HOOK_RAW
+ *
+ * This request reserved for OEM-specific uses. It passes raw byte arrays
+ * back and forth.
+ *
+ * It can be invoked on the Java side from
+ * com.android.internal.telephony.Phone.invokeOemRilRequestRaw()
+ *
+ * "data" is a char * of bytes copied from the byte[] data argument in java
+ * "response" is a char * of bytes that will returned via the
+ * caller's "response" Message here:
+ * (byte[])(((AsyncResult)response.obj).result)
+ *
+ * An error response here will result in
+ * (((AsyncResult)response.obj).result) == null and
+ * (((AsyncResult)response.obj).exception) being an instance of
+ * com.android.internal.telephony.gsm.CommandException
+ *
+ * Valid errors:
+ * All
+ */
+
+#define RIL_REQUEST_OEM_HOOK_RAW 59
+
+/**
+ * RIL_REQUEST_OEM_HOOK_STRINGS
+ *
+ * This request reserved for OEM-specific uses. It passes strings
+ * back and forth.
+ *
+ * It can be invoked on the Java side from
+ * com.android.internal.telephony.Phone.invokeOemRilRequestStrings()
+ *
+ * "data" is a const char **, representing an array of null-terminated UTF-8
+ * strings copied from the "String[] strings" argument to
+ * invokeOemRilRequestStrings()
+ *
+ * "response" is a const char **, representing an array of null-terminated UTF-8
+ * stings that will be returned via the caller's response message here:
+ *
+ * (String[])(((AsyncResult)response.obj).result)
+ *
+ * An error response here will result in
+ * (((AsyncResult)response.obj).result) == null and
+ * (((AsyncResult)response.obj).exception) being an instance of
+ * com.android.internal.telephony.gsm.CommandException
+ *
+ * Valid errors:
+ * All
+ */
+
+#define RIL_REQUEST_OEM_HOOK_STRINGS 60
+
+/**
+ * RIL_REQUEST_SCREEN_STATE
+ *
+ * Indicates the current state of the screen. When the screen is off, the
+ * RIL should notify the baseband to suppress certain notifications (eg,
+ * signal strength and changes in LAC/CID or BID/SID/NID/latitude/longitude)
+ * in an effort to conserve power. These notifications should resume when the
+ * screen is on.
+ *
+ * "data" is int *
+ * ((int *)data)[0] is == 1 for "Screen On"
+ * ((int *)data)[0] is == 0 for "Screen Off"
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_SCREEN_STATE 61
+
+
+/**
+ * RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION
+ *
+ * Enables/disables supplementary service related notifications
+ * from the network.
+ *
+ * Notifications are reported via RIL_UNSOL_SUPP_SVC_NOTIFICATION.
+ *
+ * "data" is int *
+ * ((int *)data)[0] is == 1 for notifications enabled
+ * ((int *)data)[0] is == 0 for notifications disabled
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ * See also: RIL_UNSOL_SUPP_SVC_NOTIFICATION.
+ */
+#define RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION 62
+
+/**
+ * RIL_REQUEST_WRITE_SMS_TO_SIM
+ *
+ * Stores a SMS message to SIM memory.
+ *
+ * "data" is RIL_SMS_WriteArgs *
+ *
+ * "response" is int *
+ * ((const int *)response)[0] is the record index where the message is stored.
+ *
+ * Valid errors:
+ * SUCCESS
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_WRITE_SMS_TO_SIM 63
+
+/**
+ * RIL_REQUEST_DELETE_SMS_ON_SIM
+ *
+ * Deletes a SMS message from SIM memory.
+ *
+ * "data" is int *
+ * ((int *)data)[0] is the record index of the message to delete.
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_DELETE_SMS_ON_SIM 64
+
+/**
+ * RIL_REQUEST_SET_BAND_MODE
+ *
+ * Assign a specified band for RF configuration.
+ *
+ * "data" is int *
+ * ((int *)data)[0] is == 0 for "unspecified" (selected by baseband automatically)
+ * ((int *)data)[0] is == 1 for "EURO band" (GSM-900 / DCS-1800 / WCDMA-IMT-2000)
+ * ((int *)data)[0] is == 2 for "US band" (GSM-850 / PCS-1900 / WCDMA-850 / WCDMA-PCS-1900)
+ * ((int *)data)[0] is == 3 for "JPN band" (WCDMA-800 / WCDMA-IMT-2000)
+ * ((int *)data)[0] is == 4 for "AUS band" (GSM-900 / DCS-1800 / WCDMA-850 / WCDMA-IMT-2000)
+ * ((int *)data)[0] is == 5 for "AUS band 2" (GSM-900 / DCS-1800 / WCDMA-850)
+ * ((int *)data)[0] is == 6 for "Cellular (800-MHz Band)"
+ * ((int *)data)[0] is == 7 for "PCS (1900-MHz Band)"
+ * ((int *)data)[0] is == 8 for "Band Class 3 (JTACS Band)"
+ * ((int *)data)[0] is == 9 for "Band Class 4 (Korean PCS Band)"
+ * ((int *)data)[0] is == 10 for "Band Class 5 (450-MHz Band)"
+ * ((int *)data)[0] is == 11 for "Band Class 6 (2-GMHz IMT2000 Band)"
+ * ((int *)data)[0] is == 12 for "Band Class 7 (Upper 700-MHz Band)"
+ * ((int *)data)[0] is == 13 for "Band Class 8 (1800-MHz Band)"
+ * ((int *)data)[0] is == 14 for "Band Class 9 (900-MHz Band)"
+ * ((int *)data)[0] is == 15 for "Band Class 10 (Secondary 800-MHz Band)"
+ * ((int *)data)[0] is == 16 for "Band Class 11 (400-MHz European PAMR Band)"
+ * ((int *)data)[0] is == 17 for "Band Class 15 (AWS Band)"
+ * ((int *)data)[0] is == 18 for "Band Class 16 (US 2.5-GHz Band)"
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_SET_BAND_MODE 65
+
+/**
+ * RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE
+ *
+ * Query the list of band mode supported by RF.
+ *
+ * "data" is NULL
+ *
+ * "response" is int *
+ * "response" points to an array of int's, the int[0] is the size of array, reset is one for
+ * each available band mode.
+ *
+ * 0 for "unspecified" (selected by baseband automatically)
+ * 1 for "EURO band" (GSM-900 / DCS-1800 / WCDMA-IMT-2000)
+ * 2 for "US band" (GSM-850 / PCS-1900 / WCDMA-850 / WCDMA-PCS-1900)
+ * 3 for "JPN band" (WCDMA-800 / WCDMA-IMT-2000)
+ * 4 for "AUS band" (GSM-900 / DCS-1800 / WCDMA-850 / WCDMA-IMT-2000)
+ * 5 for "AUS band 2" (GSM-900 / DCS-1800 / WCDMA-850)
+ * 6 for "Cellular (800-MHz Band)"
+ * 7 for "PCS (1900-MHz Band)"
+ * 8 for "Band Class 3 (JTACS Band)"
+ * 9 for "Band Class 4 (Korean PCS Band)"
+ * 10 for "Band Class 5 (450-MHz Band)"
+ * 11 for "Band Class 6 (2-GMHz IMT2000 Band)"
+ * 12 for "Band Class 7 (Upper 700-MHz Band)"
+ * 13 for "Band Class 8 (1800-MHz Band)"
+ * 14 for "Band Class 9 (900-MHz Band)"
+ * 15 for "Band Class 10 (Secondary 800-MHz Band)"
+ * 16 for "Band Class 11 (400-MHz European PAMR Band)"
+ * 17 for "Band Class 15 (AWS Band)"
+ * 18 for "Band Class 16 (US 2.5-GHz Band)"
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ * See also: RIL_REQUEST_SET_BAND_MODE
+ */
+#define RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE 66
+
+/**
+ * RIL_REQUEST_STK_GET_PROFILE
+ *
+ * Requests the profile of SIM tool kit.
+ * The profile indicates the SAT/USAT features supported by ME.
+ * The SAT/USAT features refer to 3GPP TS 11.14 and 3GPP TS 31.111
+ *
+ * "data" is NULL
+ *
+ * "response" is a const char * containing SAT/USAT profile
+ * in hexadecimal format string starting with first byte of terminal profile
+ *
+ * Valid errors:
+ * RIL_E_SUCCESS
+ * RIL_E_RADIO_NOT_AVAILABLE (radio resetting)
+ * RIL_E_GENERIC_FAILURE
+ */
+#define RIL_REQUEST_STK_GET_PROFILE 67
+
+/**
+ * RIL_REQUEST_STK_SET_PROFILE
+ *
+ * Download the STK terminal profile as part of SIM initialization
+ * procedure
+ *
+ * "data" is a const char * containing SAT/USAT profile
+ * in hexadecimal format string starting with first byte of terminal profile
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * RIL_E_SUCCESS
+ * RIL_E_RADIO_NOT_AVAILABLE (radio resetting)
+ * RIL_E_GENERIC_FAILURE
+ */
+#define RIL_REQUEST_STK_SET_PROFILE 68
+
+/**
+ * RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND
+ *
+ * Requests to send a SAT/USAT envelope command to SIM.
+ * The SAT/USAT envelope command refers to 3GPP TS 11.14 and 3GPP TS 31.111
+ *
+ * "data" is a const char * containing SAT/USAT command
+ * in hexadecimal format string starting with command tag
+ *
+ * "response" is a const char * containing SAT/USAT response
+ * in hexadecimal format string starting with first byte of response
+ * (May be NULL)
+ *
+ * Valid errors:
+ * RIL_E_SUCCESS
+ * RIL_E_RADIO_NOT_AVAILABLE (radio resetting)
+ * RIL_E_GENERIC_FAILURE
+ */
+#define RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND 69
+
+/**
+ * RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE
+ *
+ * Requests to send a terminal response to SIM for a received
+ * proactive command
+ *
+ * "data" is a const char * containing SAT/USAT response
+ * in hexadecimal format string starting with first byte of response data
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * RIL_E_SUCCESS
+ * RIL_E_RADIO_NOT_AVAILABLE (radio resetting)
+ * RIL_E_GENERIC_FAILURE
+ */
+#define RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE 70
+
+/**
+ * RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM
+ *
+ * When STK application gets RIL_UNSOL_STK_CALL_SETUP, the call actually has
+ * been initialized by ME already. (We could see the call has been in the 'call
+ * list') So, STK application needs to accept/reject the call according as user
+ * operations.
+ *
+ * "data" is int *
+ * ((int *)data)[0] is > 0 for "accept" the call setup
+ * ((int *)data)[0] is == 0 for "reject" the call setup
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * RIL_E_SUCCESS
+ * RIL_E_RADIO_NOT_AVAILABLE (radio resetting)
+ * RIL_E_GENERIC_FAILURE
+ */
+#define RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM 71
+
+/**
+ * RIL_REQUEST_EXPLICIT_CALL_TRANSFER
+ *
+ * Connects the two calls and disconnects the subscriber from both calls.
+ *
+ * "data" is NULL
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_EXPLICIT_CALL_TRANSFER 72
+
+/**
+ * RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE
+ *
+ * Requests to set the preferred network type for searching and registering
+ * (CS/PS domain, RAT, and operation mode)
+ *
+ * "data" is int * which is RIL_PreferredNetworkType
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ * MODE_NOT_SUPPORTED
+ */
+#define RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE 73
+
+/**
+ * RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE
+ *
+ * Query the preferred network type (CS/PS domain, RAT, and operation mode)
+ * for searching and registering
+ *
+ * "data" is NULL
+ *
+ * "response" is int *
+ * ((int *)reponse)[0] is == RIL_PreferredNetworkType
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ * See also: RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE
+ */
+#define RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE 74
+
+/**
+ * RIL_REQUEST_NEIGHBORING_CELL_IDS
+ *
+ * Request neighboring cell id in GSM network
+ *
+ * "data" is NULL
+ * "response" must be a " const RIL_NeighboringCell** "
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_GET_NEIGHBORING_CELL_IDS 75
+
+/**
+ * RIL_REQUEST_SET_LOCATION_UPDATES
+ *
+ * Enables/disables network state change notifications due to changes in
+ * LAC and/or CID (for GSM) or BID/SID/NID/latitude/longitude (for CDMA).
+ * Basically +CREG=2 vs. +CREG=1 (TS 27.007).
+ *
+ * Note: The RIL implementation should default to "updates enabled"
+ * when the screen is on and "updates disabled" when the screen is off.
+ *
+ * "data" is int *
+ * ((int *)data)[0] is == 1 for updates enabled (+CREG=2)
+ * ((int *)data)[0] is == 0 for updates disabled (+CREG=1)
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ * See also: RIL_REQUEST_SCREEN_STATE, RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED
+ */
+#define RIL_REQUEST_SET_LOCATION_UPDATES 76
+
+/**
+ * RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE
+ *
+ * Request to set the location where the CDMA subscription shall
+ * be retrieved
+ *
+ * "data" is int *
+ * ((int *)data)[0] is == RIL_CdmaSubscriptionSource
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ * SIM_ABSENT
+ * SUBSCRIPTION_NOT_AVAILABLE
+ *
+ * See also: RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE
+ */
+#define RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE 77
+
+/**
+ * RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE
+ *
+ * Request to set the roaming preferences in CDMA
+ *
+ * "data" is int *
+ * ((int *)data)[0] is == 0 for Home Networks only, as defined in PRL
+ * ((int *)data)[0] is == 1 for Roaming on Affiliated networks, as defined in PRL
+ * ((int *)data)[0] is == 2 for Roaming on Any Network, as defined in the PRL
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE 78
+
+/**
+ * RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE
+ *
+ * Request the actual setting of the roaming preferences in CDMA in the modem
+ *
+ * "data" is NULL
+ *
+ * "response" is int *
+ * ((int *)response)[0] is == 0 for Home Networks only, as defined in PRL
+ * ((int *)response)[0] is == 1 for Roaming on Affiliated networks, as defined in PRL
+ * ((int *)response)[0] is == 2 for Roaming on Any Network, as defined in the PRL
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE 79
+
+/**
+ * RIL_REQUEST_SET_TTY_MODE
+ *
+ * Request to set the TTY mode
+ *
+ * "data" is int *
+ * ((int *)data)[0] is == 0 for TTY off
+ * ((int *)data)[0] is == 1 for TTY Full
+ * ((int *)data)[0] is == 2 for TTY HCO (hearing carryover)
+ * ((int *)data)[0] is == 3 for TTY VCO (voice carryover)
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_SET_TTY_MODE 80
+
+/**
+ * RIL_REQUEST_QUERY_TTY_MODE
+ *
+ * Request the setting of TTY mode
+ *
+ * "data" is NULL
+ *
+ * "response" is int *
+ * ((int *)response)[0] is == 0 for TTY off
+ * ((int *)response)[0] is == 1 for TTY Full
+ * ((int *)response)[0] is == 2 for TTY HCO (hearing carryover)
+ * ((int *)response)[0] is == 3 for TTY VCO (voice carryover)
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_QUERY_TTY_MODE 81
+
+/**
+ * RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE
+ *
+ * Request to set the preferred voice privacy mode used in voice
+ * scrambling
+ *
+ * "data" is int *
+ * ((int *)data)[0] is == 0 for Standard Privacy Mode (Public Long Code Mask)
+ * ((int *)data)[0] is == 1 for Enhanced Privacy Mode (Private Long Code Mask)
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE 82
+
+/**
+ * RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE
+ *
+ * Request the setting of preferred voice privacy mode
+ *
+ * "data" is NULL
+ *
+ * "response" is int *
+ * ((int *)response)[0] is == 0 for Standard Privacy Mode (Public Long Code Mask)
+ * ((int *)response)[0] is == 1 for Enhanced Privacy Mode (Private Long Code Mask)
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE 83
+
+/**
+ * RIL_REQUEST_CDMA_FLASH
+ *
+ * Send FLASH
+ *
+ * "data" is const char *
+ * ((const char *)data)[0] is a FLASH string
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_FLASH 84
+
+/**
+ * RIL_REQUEST_CDMA_BURST_DTMF
+ *
+ * Send DTMF string
+ *
+ * "data" is const char **
+ * ((const char **)data)[0] is a DTMF string
+ * ((const char **)data)[1] is the DTMF ON length in milliseconds, or 0 to use
+ * default
+ * ((const char **)data)[2] is the DTMF OFF length in milliseconds, or 0 to use
+ * default
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_BURST_DTMF 85
+
+/**
+ * RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY
+ *
+ * Takes a 26 digit string (20 digit AKEY + 6 digit checksum).
+ * If the checksum is valid the 20 digit AKEY is written to NV,
+ * replacing the existing AKEY no matter what it was before.
+ *
+ * "data" is const char *
+ * ((const char *)data)[0] is a 26 digit string (ASCII digits '0'-'9')
+ * where the last 6 digits are a checksum of the
+ * first 20, as specified in TR45.AHAG
+ * "Common Cryptographic Algorithms, Revision D.1
+ * Section 2.2"
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY 86
+
+/**
+ * RIL_REQUEST_CDMA_SEND_SMS
+ *
+ * Send a CDMA SMS message
+ *
+ * "data" is const RIL_CDMA_SMS_Message *
+ *
+ * "response" is a const RIL_SMS_Response *
+ *
+ * Based on the return error, caller decides to resend if sending sms
+ * fails. The CDMA error class is derived as follows,
+ * SUCCESS is error class 0 (no error)
+ * SMS_SEND_FAIL_RETRY is error class 2 (temporary failure)
+ * and GENERIC_FAILURE is error class 3 (permanent and no retry)
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * SMS_SEND_FAIL_RETRY
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_SEND_SMS 87
+
+/**
+ * RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE
+ *
+ * Acknowledge the success or failure in the receipt of SMS
+ * previously indicated via RIL_UNSOL_RESPONSE_CDMA_NEW_SMS
+ *
+ * "data" is const RIL_CDMA_SMS_Ack *
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE 88
+
+/**
+ * RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG
+ *
+ * Request the setting of GSM/WCDMA Cell Broadcast SMS config.
+ *
+ * "data" is NULL
+ *
+ * "response" is a const RIL_GSM_BroadcastSmsConfigInfo **
+ * "responselen" is count * sizeof (RIL_GSM_BroadcastSmsConfigInfo *)
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG 89
+
+/**
+ * RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG
+ *
+ * Set GSM/WCDMA Cell Broadcast SMS config
+ *
+ * "data" is a const RIL_GSM_BroadcastSmsConfigInfo **
+ * "datalen" is count * sizeof(RIL_GSM_BroadcastSmsConfigInfo *)
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG 90
+
+/**
+ * RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION
+ *
+* Enable or disable the reception of GSM/WCDMA Cell Broadcast SMS
+ *
+ * "data" is const int *
+ * (const int *)data[0] indicates to activate or turn off the
+ * reception of GSM/WCDMA Cell Broadcast SMS, 0-1,
+ * 0 - Activate, 1 - Turn off
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION 91
+
+/**
+ * RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG
+ *
+ * Request the setting of CDMA Broadcast SMS config
+ *
+ * "data" is NULL
+ *
+ * "response" is a const RIL_CDMA_BroadcastSmsConfigInfo **
+ * "responselen" is count * sizeof (RIL_CDMA_BroadcastSmsConfigInfo *)
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG 92
+
+/**
+ * RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG
+ *
+ * Set CDMA Broadcast SMS config
+ *
+ * "data" is an const RIL_CDMA_BroadcastSmsConfigInfo **
+ * "datalen" is count * sizeof(const RIL_CDMA_BroadcastSmsConfigInfo *)
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG 93
+
+/**
+ * RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION
+ *
+ * Enable or disable the reception of CDMA Broadcast SMS
+ *
+ * "data" is const int *
+ * (const int *)data[0] indicates to activate or turn off the
+ * reception of CDMA Broadcast SMS, 0-1,
+ * 0 - Activate, 1 - Turn off
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION 94
+
+/**
+ * RIL_REQUEST_CDMA_SUBSCRIPTION
+ *
+ * Request the device MDN / H_SID / H_NID.
+ *
+ * The request is only allowed when CDMA subscription is available. When CDMA
+ * subscription is changed, application layer should re-issue the request to
+ * update the subscription information.
+ *
+ * If a NULL value is returned for any of the device id, it means that error
+ * accessing the device.
+ *
+ * "response" is const char **
+ * ((const char **)response)[0] is MDN if CDMA subscription is available
+ * ((const char **)response)[1] is a comma separated list of H_SID (Home SID) if
+ * CDMA subscription is available, in decimal format
+ * ((const char **)response)[2] is a comma separated list of H_NID (Home NID) if
+ * CDMA subscription is available, in decimal format
+ * ((const char **)response)[3] is MIN (10 digits, MIN2+MIN1) if CDMA subscription is available
+ * ((const char **)response)[4] is PRL version if CDMA subscription is available
+ *
+ * Valid errors:
+ * SUCCESS
+ * RIL_E_SUBSCRIPTION_NOT_AVAILABLE
+ */
+
+#define RIL_REQUEST_CDMA_SUBSCRIPTION 95
+
+/**
+ * RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM
+ *
+ * Stores a CDMA SMS message to RUIM memory.
+ *
+ * "data" is RIL_CDMA_SMS_WriteArgs *
+ *
+ * "response" is int *
+ * ((const int *)response)[0] is the record index where the message is stored.
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM 96
+
+/**
+ * RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM
+ *
+ * Deletes a CDMA SMS message from RUIM memory.
+ *
+ * "data" is int *
+ * ((int *)data)[0] is the record index of the message to delete.
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM 97
+
+/**
+ * RIL_REQUEST_DEVICE_IDENTITY
+ *
+ * Request the device ESN / MEID / IMEI / IMEISV.
+ *
+ * The request is always allowed and contains GSM and CDMA device identity;
+ * it substitutes the deprecated requests RIL_REQUEST_GET_IMEI and
+ * RIL_REQUEST_GET_IMEISV.
+ *
+ * If a NULL value is returned for any of the device id, it means that error
+ * accessing the device.
+ *
+ * When CDMA subscription is changed the ESN/MEID may change. The application
+ * layer should re-issue the request to update the device identity in this case.
+ *
+ * "response" is const char **
+ * ((const char **)response)[0] is IMEI if GSM subscription is available
+ * ((const char **)response)[1] is IMEISV if GSM subscription is available
+ * ((const char **)response)[2] is ESN if CDMA subscription is available
+ * ((const char **)response)[3] is MEID if CDMA subscription is available
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_DEVICE_IDENTITY 98
+
+/**
+ * RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE
+ *
+ * Request the radio's system selection module to exit emergency
+ * callback mode. RIL will not respond with SUCCESS until the modem has
+ * completely exited from Emergency Callback Mode.
+ *
+ * "data" is NULL
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE 99
+
+/**
+ * RIL_REQUEST_GET_SMSC_ADDRESS
+ *
+ * Queries the default Short Message Service Center address on the device.
+ *
+ * "data" is NULL
+ *
+ * "response" is const char * containing the SMSC address.
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_GET_SMSC_ADDRESS 100
+
+/**
+ * RIL_REQUEST_SET_SMSC_ADDRESS
+ *
+ * Sets the default Short Message Service Center address on the device.
+ *
+ * "data" is const char * containing the SMSC address.
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_SET_SMSC_ADDRESS 101
+
+/**
+ * RIL_REQUEST_REPORT_SMS_MEMORY_STATUS
+ *
+ * Indicates whether there is storage available for new SMS messages.
+ *
+ * "data" is int *
+ * ((int *)data)[0] is 1 if memory is available for storing new messages
+ * is 0 if memory capacity is exceeded
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_REPORT_SMS_MEMORY_STATUS 102
+
+/**
+ * RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING
+ *
+ * Indicates that the StkSerivce is running and is
+ * ready to receive RIL_UNSOL_STK_XXXXX commands.
+ *
+ * "data" is NULL
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING 103
+
+/**
+ * RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE
+ *
+ * Request to query the location where the CDMA subscription shall
+ * be retrieved
+ *
+ * "data" is NULL
+ *
+ * "response" is int *
+ * ((int *)data)[0] is == RIL_CdmaSubscriptionSource
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ * SUBSCRIPTION_NOT_AVAILABLE
+ *
+ * See also: RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE
+ */
+#define RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE 104
+
+/**
+ * RIL_REQUEST_ISIM_AUTHENTICATION
+ *
+ * Request the ISIM application on the UICC to perform AKA
+ * challenge/response algorithm for IMS authentication
+ *
+ * "data" is a const char * containing the challenge string in Base64 format
+ * "response" is a const char * containing the response in Base64 format
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_ISIM_AUTHENTICATION 105
+
+/**
+ * RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU
+ *
+ * Acknowledge successful or failed receipt of SMS previously indicated
+ * via RIL_UNSOL_RESPONSE_NEW_SMS, including acknowledgement TPDU to send
+ * as the RP-User-Data element of the RP-ACK or RP-ERROR PDU.
+ *
+ * "data" is const char **
+ * ((const char **)data)[0] is "1" on successful receipt (send RP-ACK)
+ * is "0" on failed receipt (send RP-ERROR)
+ * ((const char **)data)[1] is the acknowledgement TPDU in hexadecimal format
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU 106
+
+/**
+ * RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS
+ *
+ * Requests to send a SAT/USAT envelope command to SIM.
+ * The SAT/USAT envelope command refers to 3GPP TS 11.14 and 3GPP TS 31.111.
+ *
+ * This request has one difference from RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND:
+ * the SW1 and SW2 status bytes from the UICC response are returned along with
+ * the response data, using the same structure as RIL_REQUEST_SIM_IO.
+ *
+ * The RIL implementation shall perform the normal processing of a '91XX'
+ * response in SW1/SW2 to retrieve the pending proactive command and send it
+ * as an unsolicited response, as RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND does.
+ *
+ * "data" is a const char * containing the SAT/USAT command
+ * in hexadecimal format starting with command tag
+ *
+ * "response" is a const RIL_SIM_IO_Response *
+ *
+ * Valid errors:
+ * RIL_E_SUCCESS
+ * RIL_E_RADIO_NOT_AVAILABLE (radio resetting)
+ * RIL_E_GENERIC_FAILURE
+ */
+#define RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS 107
+
+/**
+ * RIL_REQUEST_VOICE_RADIO_TECH
+ *
+ * Query the radio technology type (3GPP/3GPP2) used for voice. Query is valid only
+ * when radio state is RADIO_STATE_ON
+ *
+ * "data" is NULL
+ * "response" is int *
+ * ((int *) response)[0] is of type const RIL_RadioTechnology
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_VOICE_RADIO_TECH 108
+
+/**
+ * RIL_REQUEST_GET_CELL_INFO_LIST
+ *
+ * Request all of the current cell information known to the radio. The radio
+ * must a list of all current cells, including the neighboring cells. If for a particular
+ * cell information isn't known then the appropriate unknown value will be returned.
+ * This does not cause or change the rate of RIL_UNSOL_CELL_INFO_LIST.
+ *
+ * "data" is NULL
+ *
+ * "response" is an array of RIL_CellInfo.
+ */
+#define RIL_REQUEST_GET_CELL_INFO_LIST 109
+
+/**
+ * RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE
+ *
+ * Sets the minimum time between when RIL_UNSOL_CELL_INFO_LIST should be invoked.
+ * A value of 0, means invoke RIL_UNSOL_CELL_INFO_LIST when any of the reported
+ * information changes. Setting the value to INT_MAX(0x7fffffff) means never issue
+ * a RIL_UNSOL_CELL_INFO_LIST.
+ *
+ * "data" is int *
+ * ((int *)data)[0] is minimum time in milliseconds
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE 110
+
+/**
+ * RIL_REQUEST_SET_INITIAL_ATTACH_APN
+ *
+ * Set an apn to initial attach network
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ * SUBSCRIPTION_NOT_AVAILABLE
+ */
+#define RIL_REQUEST_SET_INITIAL_ATTACH_APN 111
+
+/**
+ * RIL_REQUEST_IMS_REGISTRATION_STATE
+ *
+ * Request current IMS registration state
+ *
+ * "data" is NULL
+ *
+ * "response" is int *
+ * ((int *)response)[0] is registration state:
+ * 0 - Not registered
+ * 1 - Registered
+ *
+ * If ((int*)response)[0] is = 1, then ((int *) response)[1]
+ * must follow with IMS SMS format:
+ *
+ * ((int *) response)[1] is of type RIL_RadioTechnologyFamily
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * GENERIC_FAILURE
+ */
+#define RIL_REQUEST_IMS_REGISTRATION_STATE 112
+
+/**
+ * RIL_REQUEST_IMS_SEND_SMS
+ *
+ * Send a SMS message over IMS
+ *
+ * "data" is const RIL_IMS_SMS_Message *
+ *
+ * "response" is a const RIL_SMS_Response *
+ *
+ * Based on the return error, caller decides to resend if sending sms
+ * fails. SMS_SEND_FAIL_RETRY means retry, and other errors means no retry.
+ * In case of retry, data is encoded based on Voice Technology available.
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE
+ * SMS_SEND_FAIL_RETRY
+ * FDN_CHECK_FAILURE
+ * GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_IMS_SEND_SMS 113
+
+/**
+ * RIL_REQUEST_GET_DATA_CALL_PROFILE
+ *
+ * Get the Data Call Profile for a particular app type
+ *
+ * "data" is const int*
+ * (const int*)data[0] - App type. Value is specified the RUIM spec C.S0023-D
+ *
+ *
+ * "response" is a const char * containing the count and the array of profiles
+ * ((const int *)response)[0] Number RIL_DataCallProfileInfo structs(count)
+ * ((const char *)response)[1] is the buffer that contains 'count' number of
+ * RIL_DataCallProfileInfo structs.
+ *
+ * Valid errors:
+ * SUCCESS
+ * GENERIC_FAILURE
+ * RIL_E_DATA_CALL_PROFILE_ERROR
+ * RIL_E_DATA_CALL_PROFILE_NOT_AVAILABLE
+ *
+ */
+#define RIL_REQUEST_GET_DATA_CALL_PROFILE 114
+
+/**
+ * RIL_REQUEST_SET_UICC_SUBSCRIPTION
+ *
+ * Selection/de-selection of a subscription from a SIM card
+ * "data" is const RIL_SelectUiccSub*
+
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ * SUBSCRIPTION_NOT_SUPPORTED
+ *
+ */
+#define RIL_REQUEST_SET_UICC_SUBSCRIPTION 115
+
+/**
+ * RIL_REQUEST_SET_DATA_SUBSCRIPTION
+ *
+ * Selects a subscription for data call setup
+ * "data" is NULL
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ *
+ * SUCCESS
+ * RADIO_NOT_AVAILABLE (radio resetting)
+ * GENERIC_FAILURE
+ * SUBSCRIPTION_NOT_SUPPORTED
+ *
+ */
+#define RIL_REQUEST_SET_DATA_SUBSCRIPTION 116
+
+/***********************************************************************/
+
+
+#define RIL_UNSOL_RESPONSE_BASE 1000
+
+/**
+ * RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED
+ *
+ * Indicate when value of RIL_RadioState has changed.
+ *
+ * Callee will invoke RIL_RadioStateRequest method on main thread
+ *
+ * "data" is NULL
+ */
+
+#define RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED 1000
+
+
+/**
+ * RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED
+ *
+ * Indicate when call state has changed
+ *
+ * Callee will invoke RIL_REQUEST_GET_CURRENT_CALLS on main thread
+ *
+ * "data" is NULL
+ *
+ * Response should be invoked on, for example,
+ * "RING", "BUSY", "NO CARRIER", and also call state
+ * transitions (DIALING->ALERTING ALERTING->ACTIVE)
+ *
+ * Redundent or extraneous invocations are tolerated
+ */
+#define RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED 1001
+
+
+/**
+ * RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED
+ *
+ * Called when the voice network state changed
+ *
+ * Callee will invoke the following requests on main thread:
+ *
+ * RIL_REQUEST_VOICE_REGISTRATION_STATE
+ * RIL_REQUEST_OPERATOR
+ *
+ * "data" is NULL
+ *
+ * FIXME should this happen when SIM records are loaded? (eg, for
+ * EONS)
+ */
+#define RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED 1002
+
+/**
+ * RIL_UNSOL_RESPONSE_NEW_SMS
+ *
+ * Called when new SMS is received.
+ *
+ * "data" is const char *
+ * This is a pointer to a string containing the PDU of an SMS-DELIVER
+ * as an ascii string of hex digits. The PDU starts with the SMSC address
+ * per TS 27.005 (+CMT:)
+ *
+ * Callee will subsequently confirm the receipt of thei SMS with a
+ * RIL_REQUEST_SMS_ACKNOWLEDGE
+ *
+ * No new RIL_UNSOL_RESPONSE_NEW_SMS
+ * or RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT messages should be sent until a
+ * RIL_REQUEST_SMS_ACKNOWLEDGE has been received
+ */
+
+#define RIL_UNSOL_RESPONSE_NEW_SMS 1003
+
+/**
+ * RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT
+ *
+ * Called when new SMS Status Report is received.
+ *
+ * "data" is const char *
+ * This is a pointer to a string containing the PDU of an SMS-STATUS-REPORT
+ * as an ascii string of hex digits. The PDU starts with the SMSC address
+ * per TS 27.005 (+CDS:).
+ *
+ * Callee will subsequently confirm the receipt of the SMS with a
+ * RIL_REQUEST_SMS_ACKNOWLEDGE
+ *
+ * No new RIL_UNSOL_RESPONSE_NEW_SMS
+ * or RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT messages should be sent until a
+ * RIL_REQUEST_SMS_ACKNOWLEDGE has been received
+ */
+
+#define RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT 1004
+
+/**
+ * RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM
+ *
+ * Called when new SMS has been stored on SIM card
+ *
+ * "data" is const int *
+ * ((const int *)data)[0] contains the slot index on the SIM that contains
+ * the new message
+ */
+
+#define RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM 1005
+
+/**
+ * RIL_UNSOL_ON_USSD
+ *
+ * Called when a new USSD message is received.
+ *
+ * "data" is const char **
+ * ((const char **)data)[0] points to a type code, which is
+ * one of these string values:
+ * "0" USSD-Notify -- text in ((const char **)data)[1]
+ * "1" USSD-Request -- text in ((const char **)data)[1]
+ * "2" Session terminated by network
+ * "3" other local client (eg, SIM Toolkit) has responded
+ * "4" Operation not supported
+ * "5" Network timeout
+ *
+ * The USSD session is assumed to persist if the type code is "1", otherwise
+ * the current session (if any) is assumed to have terminated.
+ *
+ * ((const char **)data)[1] points to a message string if applicable, which
+ * should always be in UTF-8.
+ */
+#define RIL_UNSOL_ON_USSD 1006
+/* Previously #define RIL_UNSOL_ON_USSD_NOTIFY 1006 */
+
+/**
+ * RIL_UNSOL_ON_USSD_REQUEST
+ *
+ * Obsolete. Send via RIL_UNSOL_ON_USSD
+ */
+#define RIL_UNSOL_ON_USSD_REQUEST 1007
+
+/**
+ * RIL_UNSOL_NITZ_TIME_RECEIVED
+ *
+ * Called when radio has received a NITZ time message
+ *
+ * "data" is const char * pointing to NITZ time string
+ * in the form "yy/mm/dd,hh:mm:ss(+/-)tz,dt"
+ */
+#define RIL_UNSOL_NITZ_TIME_RECEIVED 1008
+
+/**
+ * RIL_UNSOL_SIGNAL_STRENGTH
+ *
+ * Radio may report signal strength rather han have it polled.
+ *
+ * "data" is a const RIL_SignalStrength *
+ */
+#define RIL_UNSOL_SIGNAL_STRENGTH 1009
+
+
+/**
+ * RIL_UNSOL_DATA_CALL_LIST_CHANGED
+ *
+ * "data" is an array of RIL_Data_Call_Response_v6 identical to that
+ * returned by RIL_REQUEST_DATA_CALL_LIST. It is the complete list
+ * of current data contexts including new contexts that have been
+ * activated. A data call is only removed from this list when the
+ * framework sends a RIL_REQUEST_DEACTIVATE_DATA_CALL or the radio
+ * is powered off/on.
+ *
+ * See also: RIL_REQUEST_DATA_CALL_LIST
+ */
+
+#define RIL_UNSOL_DATA_CALL_LIST_CHANGED 1010
+
+/**
+ * RIL_UNSOL_SUPP_SVC_NOTIFICATION
+ *
+ * Reports supplementary service related notification from the network.
+ *
+ * "data" is a const RIL_SuppSvcNotification *
+ *
+ */
+
+#define RIL_UNSOL_SUPP_SVC_NOTIFICATION 1011
+
+/**
+ * RIL_UNSOL_STK_SESSION_END
+ *
+ * Indicate when STK session is terminated by SIM.
+ *
+ * "data" is NULL
+ */
+#define RIL_UNSOL_STK_SESSION_END 1012
+
+/**
+ * RIL_UNSOL_STK_PROACTIVE_COMMAND
+ *
+ * Indicate when SIM issue a STK proactive command to applications
+ *
+ * "data" is a const char * containing SAT/USAT proactive command
+ * in hexadecimal format string starting with command tag
+ *
+ */
+#define RIL_UNSOL_STK_PROACTIVE_COMMAND 1013
+
+/**
+ * RIL_UNSOL_STK_EVENT_NOTIFY
+ *
+ * Indicate when SIM notifies applcations some event happens.
+ * Generally, application does not need to have any feedback to
+ * SIM but shall be able to indicate appropriate messages to users.
+ *
+ * "data" is a const char * containing SAT/USAT commands or responses
+ * sent by ME to SIM or commands handled by ME, in hexadecimal format string
+ * starting with first byte of response data or command tag
+ *
+ */
+#define RIL_UNSOL_STK_EVENT_NOTIFY 1014
+
+/**
+ * RIL_UNSOL_STK_CALL_SETUP
+ *
+ * Indicate when SIM wants application to setup a voice call.
+ *
+ * "data" is const int *
+ * ((const int *)data)[0] contains timeout value (in milliseconds)
+ */
+#define RIL_UNSOL_STK_CALL_SETUP 1015
+
+/**
+ * RIL_UNSOL_SIM_SMS_STORAGE_FULL
+ *
+ * Indicates that SMS storage on the SIM is full. Sent when the network
+ * attempts to deliver a new SMS message. Messages cannot be saved on the
+ * SIM until space is freed. In particular, incoming Class 2 messages
+ * cannot be stored.
+ *
+ * "data" is null
+ *
+ */
+#define RIL_UNSOL_SIM_SMS_STORAGE_FULL 1016
+
+/**
+ * RIL_UNSOL_SIM_REFRESH
+ *
+ * Indicates that file(s) on the SIM have been updated, or the SIM
+ * has been reinitialized.
+ *
+ * In the case where RIL is version 6 or older:
+ * "data" is an int *
+ * ((int *)data)[0] is a RIL_SimRefreshResult.
+ * ((int *)data)[1] is the EFID of the updated file if the result is
+ * SIM_FILE_UPDATE or NULL for any other result.
+ *
+ * In the case where RIL is version 7:
+ * "data" is a RIL_SimRefreshResponse_v7 *
+ *
+ * Note: If the SIM state changes as a result of the SIM refresh (eg,
+ * SIM_READY -> SIM_LOCKED_OR_ABSENT), RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED
+ * should be sent.
+ */
+#define RIL_UNSOL_SIM_REFRESH 1017
+
+/**
+ * RIL_UNSOL_CALL_RING
+ *
+ * Ring indication for an incoming call (eg, RING or CRING event).
+ * There must be at least one RIL_UNSOL_CALL_RING at the beginning
+ * of a call and sending multiple is optional. If the system property
+ * ro.telephony.call_ring.multiple is false then the upper layers
+ * will generate the multiple events internally. Otherwise the vendor
+ * ril must generate multiple RIL_UNSOL_CALL_RING if
+ * ro.telephony.call_ring.multiple is true or if it is absent.
+ *
+ * The rate of these events is controlled by ro.telephony.call_ring.delay
+ * and has a default value of 3000 (3 seconds) if absent.
+ *
+ * "data" is null for GSM
+ * "data" is const RIL_CDMA_SignalInfoRecord * if CDMA
+ */
+#define RIL_UNSOL_CALL_RING 1018
+
+/**
+ * RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED
+ *
+ * Indicates that SIM state changes.
+ *
+ * Callee will invoke RIL_REQUEST_GET_SIM_STATUS on main thread
+
+ * "data" is null
+ */
+#define RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED 1019
+
+/**
+ * RIL_UNSOL_RESPONSE_CDMA_NEW_SMS
+ *
+ * Called when new CDMA SMS is received
+ *
+ * "data" is const RIL_CDMA_SMS_Message *
+ *
+ * Callee will subsequently confirm the receipt of the SMS with
+ * a RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE
+ *
+ * No new RIL_UNSOL_RESPONSE_CDMA_NEW_SMS should be sent until
+ * RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE has been received
+ *
+ */
+#define RIL_UNSOL_RESPONSE_CDMA_NEW_SMS 1020
+
+/**
+ * RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS
+ *
+ * Called when new Broadcast SMS is received
+ *
+ * "data" can be one of the following:
+ * If received from GSM network, "data" is const char of 88 bytes
+ * which indicates each page of a CBS Message sent to the MS by the
+ * BTS as coded in 3GPP 23.041 Section 9.4.1.2.
+ * If received from UMTS network, "data" is const char of 90 up to 1252
+ * bytes which contain between 1 and 15 CBS Message pages sent as one
+ * packet to the MS by the BTS as coded in 3GPP 23.041 Section 9.4.2.2.
+ *
+ */
+#define RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS 1021
+
+/**
+ * RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL
+ *
+ * Indicates that SMS storage on the RUIM is full. Messages
+ * cannot be saved on the RUIM until space is freed.
+ *
+ * "data" is null
+ *
+ */
+#define RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL 1022
+
+/**
+ * RIL_UNSOL_RESTRICTED_STATE_CHANGED
+ *
+ * Indicates a restricted state change (eg, for Domain Specific Access Control).
+ *
+ * Radio need send this msg after radio off/on cycle no matter it is changed or not.
+ *
+ * "data" is an int *
+ * ((int *)data)[0] contains a bitmask of RIL_RESTRICTED_STATE_* values.
+ */
+#define RIL_UNSOL_RESTRICTED_STATE_CHANGED 1023
+
+/**
+ * RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE
+ *
+ * Indicates that the radio system selection module has
+ * autonomously entered emergency callback mode.
+ *
+ * "data" is null
+ *
+ */
+#define RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE 1024
+
+/**
+ * RIL_UNSOL_CDMA_CALL_WAITING
+ *
+ * Called when CDMA radio receives a call waiting indication.
+ *
+ * "data" is const RIL_CDMA_CallWaiting *
+ *
+ */
+#define RIL_UNSOL_CDMA_CALL_WAITING 1025
+
+/**
+ * RIL_UNSOL_CDMA_OTA_PROVISION_STATUS
+ *
+ * Called when CDMA radio receives an update of the progress of an
+ * OTASP/OTAPA call.
+ *
+ * "data" is const int *
+ * For CDMA this is an integer OTASP/OTAPA status listed in
+ * RIL_CDMA_OTA_ProvisionStatus.
+ *
+ */
+#define RIL_UNSOL_CDMA_OTA_PROVISION_STATUS 1026
+
+/**
+ * RIL_UNSOL_CDMA_INFO_REC
+ *
+ * Called when CDMA radio receives one or more info recs.
+ *
+ * "data" is const RIL_CDMA_InformationRecords *
+ *
+ */
+#define RIL_UNSOL_CDMA_INFO_REC 1027
+
+/**
+ * RIL_UNSOL_OEM_HOOK_RAW
+ *
+ * This is for OEM specific use.
+ *
+ * "data" is a byte[]
+ */
+#define RIL_UNSOL_OEM_HOOK_RAW 1028
+
+/**
+ * RIL_UNSOL_RINGBACK_TONE
+ *
+ * Indicates that nework doesn't have in-band information, need to
+ * play out-band tone.
+ *
+ * "data" is an int *
+ * ((int *)data)[0] == 0 for stop play ringback tone.
+ * ((int *)data)[0] == 1 for start play ringback tone.
+ */
+#define RIL_UNSOL_RINGBACK_TONE 1029
+
+/**
+ * RIL_UNSOL_RESEND_INCALL_MUTE
+ *
+ * Indicates that framework/application need reset the uplink mute state.
+ *
+ * There may be situations where the mute state becomes out of sync
+ * between the application and device in some GSM infrastructures.
+ *
+ * "data" is null
+ */
+#define RIL_UNSOL_RESEND_INCALL_MUTE 1030
+
+/**
+ * RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED
+ *
+ * Called when CDMA subscription source changed.
+ *
+ * "data" is int *
+ * ((int *)data)[0] is == RIL_CdmaSubscriptionSource
+ */
+#define RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED 1031
+
+/**
+ * RIL_UNSOL_CDMA_PRL_CHANGED
+ *
+ * Called when PRL (preferred roaming list) changes.
+ *
+ * "data" is int *
+ * ((int *)data)[0] is PRL_VERSION as would be returned by RIL_REQUEST_CDMA_SUBSCRIPTION
+ */
+#define RIL_UNSOL_CDMA_PRL_CHANGED 1032
+
+/**
+ * RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE
+ *
+ * Called when Emergency Callback Mode Ends
+ *
+ * Indicates that the radio system selection module has
+ * proactively exited emergency callback mode.
+ *
+ * "data" is NULL
+ *
+ */
+#define RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE 1033
+
+/**
+ * RIL_UNSOL_RIL_CONNECTED
+ *
+ * Called the ril connects and returns the version
+ *
+ * "data" is int *
+ * ((int *)data)[0] is RIL_VERSION
+ */
+#define RIL_UNSOL_RIL_CONNECTED 1034
+
+/**
+ * RIL_UNSOL_VOICE_RADIO_TECH_CHANGED
+ *
+ * Indicates that voice technology has changed. Contains new radio technology
+ * as a data in the message.
+ *
+ * "data" is int *
+ * ((int *)data)[0] is of type const RIL_RadioTechnology
+ *
+ */
+#define RIL_UNSOL_VOICE_RADIO_TECH_CHANGED 1035
+
+/**
+ * RIL_UNSOL_CELL_INFO_LIST
+ *
+ * Same information as returned by RIL_REQUEST_GET_CELL_INFO_LIST, but returned
+ * at the rate no greater than specified by RIL_REQUEST_SET_UNSOL_CELL_INFO_RATE.
+ *
+ * "data" is NULL
+ *
+ * "response" is an array of RIL_CellInfo.
+ */
+#define RIL_UNSOL_CELL_INFO_LIST 1036
+
+/**
+ * RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED
+ *
+ * Called when IMS registration state has changed
+ *
+ * To get IMS registration state and IMS SMS format, callee needs to invoke the
+ * following request on main thread:
+ *
+ * RIL_REQUEST_IMS_REGISTRATION_STATE
+ *
+ * "data" is NULL
+ *
+ */
+#define RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED 1037
+
+/**
+ * RIL_UNSOL_ON_SS
+ *
+ * Called when SS response is received when DIAL/USSD/SS is changed to SS by
+ * call control.
+ *
+ * "data" is const RIL_StkCcUnsolSsResponse *
+ *
+ */
+#define RIL_UNSOL_ON_SS 1038
+
+
+/**
+ * RIL_UNSOL_STK_CC_ALPHA_NOTIFY
+ *
+ * Called when there is an ALPHA from UICC during Call Control.
+ *
+ * "data" is const char * containing ALPHA string from UICC in UTF-8 format.
+ *
+ */
+#define RIL_UNSOL_STK_CC_ALPHA_NOTIFY 1039
+
+/**
+ * RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED
+ *
+ * Indicated when there is a change in subscription status.
+ * This event will be sent in the following scenarios
+ * - subscription readiness at modem, which was selected by telephony layer
+ * - when subscription is deactivated by modem due to UICC card removal
+ * - When network invalidates the subscription i.e. attach reject due to authentication reject
+ *
+ * "data" is const int *
+ * ((const int *)data)[0] == 0 for Subscription Deactivated
+ * ((const int *)data)[0] == 1 for Subscription Activated
+ *
+ */
+#define RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED 1040
+/***********************************************************************/
+
+
+/**
+ * RIL_Request Function pointer
+ *
+ * @param request is one of RIL_REQUEST_*
+ * @param data is pointer to data defined for that RIL_REQUEST_*
+ * data is owned by caller, and should not be modified or freed by callee
+ * @param t should be used in subsequent call to RIL_onResponse
+ * @param datalen the length of data
+ *
+ */
+typedef void (*RIL_RequestFunc) (int request, void *data,
+ size_t datalen, RIL_Token t);
+
+/**
+ * This function should return the current radio state synchronously
+ */
+typedef RIL_RadioState (*RIL_RadioStateRequest)();
+
+/**
+ * This function returns "1" if the specified RIL_REQUEST code is
+ * supported and 0 if it is not
+ *
+ * @param requestCode is one of RIL_REQUEST codes
+ */
+
+typedef int (*RIL_Supports)(int requestCode);
+
+/**
+ * This function is called from a separate thread--not the
+ * thread that calls RIL_RequestFunc--and indicates that a pending
+ * request should be cancelled.
+ *
+ * On cancel, the callee should do its best to abandon the request and
+ * call RIL_onRequestComplete with RIL_Errno CANCELLED at some later point.
+ *
+ * Subsequent calls to RIL_onRequestComplete for this request with
+ * other results will be tolerated but ignored. (That is, it is valid
+ * to ignore the cancellation request)
+ *
+ * RIL_Cancel calls should return immediately, and not wait for cancellation
+ *
+ * Please see ITU v.250 5.6.1 for how one might implement this on a TS 27.007
+ * interface
+ *
+ * @param t token wants to be canceled
+ */
+
+typedef void (*RIL_Cancel)(RIL_Token t);
+
+typedef void (*RIL_TimedCallback) (void *param);
+
+/**
+ * Return a version string for your RIL implementation
+ */
+typedef const char * (*RIL_GetVersion) (void);
+
+typedef struct {
+ int version; /* set to RIL_VERSION */
+ RIL_RequestFunc onRequest;
+ RIL_RadioStateRequest onStateRequest;
+ RIL_Supports supports;
+ RIL_Cancel onCancel;
+ RIL_GetVersion getVersion;
+} RIL_RadioFunctions;
+
+typedef struct {
+ char *apn;
+ char *protocol;
+ int authtype;
+ char *username;
+ char *password;
+} RIL_InitialAttachApn;
+
+#ifdef RIL_SHLIB
+struct RIL_Env {
+ /**
+ * "t" is parameter passed in on previous call to RIL_Notification
+ * routine.
+ *
+ * If "e" != SUCCESS, then response can be null/is ignored
+ *
+ * "response" is owned by caller, and should not be modified or
+ * freed by callee
+ *
+ * RIL_onRequestComplete will return as soon as possible
+ */
+ void (*OnRequestComplete)(RIL_Token t, RIL_Errno e,
+ void *response, size_t responselen);
+
+ /**
+ * "unsolResponse" is one of RIL_UNSOL_RESPONSE_*
+ * "data" is pointer to data defined for that RIL_UNSOL_RESPONSE_*
+ *
+ * "data" is owned by caller, and should not be modified or freed by callee
+ */
+
+ void (*OnUnsolicitedResponse)(int unsolResponse, const void *data,
+ size_t datalen);
+
+ /**
+ * Call user-specifed "callback" function on on the same thread that
+ * RIL_RequestFunc is called. If "relativeTime" is specified, then it specifies
+ * a relative time value at which the callback is invoked. If relativeTime is
+ * NULL or points to a 0-filled structure, the callback will be invoked as
+ * soon as possible
+ */
+
+ void (*RequestTimedCallback) (RIL_TimedCallback callback,
+ void *param, const struct timeval *relativeTime);
+};
+
+
+/**
+ * RIL implementations must defined RIL_Init
+ * argc and argv will be command line arguments intended for the RIL implementation
+ * Return NULL on error
+ *
+ * @param env is environment point defined as RIL_Env
+ * @param argc number of arguments
+ * @param argv list fo arguments
+ *
+ */
+const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **argv);
+
+#else /* RIL_SHLIB */
+
+/**
+ * Call this once at startup to register notification routine
+ *
+ * @param callbacks user-specifed callback function
+ */
+void RIL_register (const RIL_RadioFunctions *callbacks);
+
+
+/**
+ *
+ * RIL_onRequestComplete will return as soon as possible
+ *
+ * @param t is parameter passed in on previous call to RIL_Notification
+ * routine.
+ * @param e error code
+ * if "e" != SUCCESS, then response can be null/is ignored
+ * @param response is owned by caller, and should not be modified or
+ * freed by callee
+ * @param responselen the length of response in byte
+ */
+void RIL_onRequestComplete(RIL_Token t, RIL_Errno e,
+ void *response, size_t responselen);
+
+/**
+ * @param unsolResponse is one of RIL_UNSOL_RESPONSE_*
+ * @param data is pointer to data defined for that RIL_UNSOL_RESPONSE_*
+ * "data" is owned by caller, and should not be modified or freed by callee
+ * @param datalen the length of data in byte
+ */
+
+void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
+ size_t datalen);
+
+
+/**
+ * Call user-specifed "callback" function on on the same thread that
+ * RIL_RequestFunc is called. If "relativeTime" is specified, then it specifies
+ * a relative time value at which the callback is invoked. If relativeTime is
+ * NULL or points to a 0-filled structure, the callback will be invoked as
+ * soon as possible
+ *
+ * @param callback user-specifed callback function
+ * @param param parameter list
+ * @param relativeTime a relative time value at which the callback is invoked
+ */
+
+void RIL_requestTimedCallback (RIL_TimedCallback callback,
+ void *param, const struct timeval *relativeTime);
+
+
+#endif /* RIL_SHLIB */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*ANDROID_RIL_H*/
diff --git a/init/Android.mk b/init/Android.mk
new file mode 100644
index 0000000..0e8d85a
--- /dev/null
+++ b/init/Android.mk
@@ -0,0 +1,13 @@
+ifeq ($(TARGET_INIT_VENDOR_LIB),libinit_shinano)
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := system/core/init
+LOCAL_CFLAGS := -Wall
+LOCAL_SRC_FILES := init_shinano.c
+LOCAL_MODULE := libinit_shinano
+include $(BUILD_STATIC_LIBRARY)
+
+endif
diff --git a/init/init_shinano.c b/init/init_shinano.c
new file mode 100644
index 0000000..e278a41
--- /dev/null
+++ b/init/init_shinano.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2014 The CyanogenMod 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 <stdlib.h>
+
+#include "vendor_init.h"
+#include "property_service.h"
+#include "log.h"
+#include "util.h"
+
+#include <sys/system_properties.h>
+
+static void import_kernel_nv(char *name)
+{
+ char *value = strchr(name, '=');
+ int name_len = strlen(name);
+
+ if (value == 0) return;
+ *value++ = 0;
+ if (name_len == 0) return;
+
+ // We only want the bootloader version
+ if (strcmp(name, "oemandroidboot.s1boot") == 0) {
+ const char *boot_prop_name = name + 15;
+ char prop[PROP_NAME_MAX];
+ int cnt;
+
+ cnt = snprintf(prop, sizeof(prop), "ro.boot.%s", boot_prop_name);
+ if (cnt < PROP_NAME_MAX)
+ property_set(prop, value);
+ }
+}
+
+void vendor_load_properties()
+{
+ import_kernel_cmdline(0, import_kernel_nv);
+}
diff --git a/overlay-radio/frameworks/base/core/res/res/values/config.xml b/overlay-radio/frameworks/base/core/res/res/values/config.xml
new file mode 100644
index 0000000..8890e2a
--- /dev/null
+++ b/overlay-radio/frameworks/base/core/res/res/values/config.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ /*
+** Copyright 2009, The Android Open Source Project
+** Copyright (C) 2013 The CyanogenMod 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.
+*/
+-->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+<resources>
+
+ <!-- The duration (in milliseconds) that the radio will scan for a signal
+ when there's no network connection. If the scan doesn't timeout, use zero -->
+ <integer name="config_radioScanningTimeout">9000</integer>
+
+ <!-- This string array should be overridden by the device to present a list of network
+ attributes. This is used by the connectivity manager to decide which networks can coexist
+ based on the hardware -->
+ <!-- An Array of "[Connection name],[ConnectivityManager.TYPE_xxxx],
+ [associated radio-type],[priority],[restoral-timer(ms)],[dependencyMet] -->
+ <!-- the 5th element "resore-time" indicates the number of milliseconds to delay
+ before automatically restore the default connection. Set -1 if the connection
+ does not require auto-restore. -->
+ <!-- the 6th element indicates boot-time dependency-met value. -->
+ <string-array translatable="false" name="networkAttributes">
+ <item>"wifi,1,1,1,-1,true"</item>
+ <item>"mobile,0,0,0,-1,true"</item>
+ <item>"mobile_mms,2,0,2,60000,true"</item>
+ <item>"mobile_supl,3,0,2,60000,true"</item>
+ <item>"mobile_dun,4,0,2,60000,true"</item>
+ <item>"mobile_hipri,5,0,3,60000,true"</item>
+ <item>"mobile_fota,10,0,2,60000,true"</item>
+ <item>"mobile_ims,11,0,2,60000,true"</item>
+ <item>"mobile_cbs,12,0,2,60000,true"</item>
+ <item>"bluetooth,7,7,2,-1,true"</item>
+ </string-array>
+
+ <!-- This string array should be overridden by the device to present a list of radio
+ attributes. This is used by the connectivity manager to decide which networks can coexist
+ based on the hardware -->
+ <!-- An Array of "[ConnectivityManager connectionType],
+ [# simultaneous connection types]" -->
+ <string-array translatable="false" name="radioAttributes">
+ <item>"1,1"</item>
+ <item>"0,1"</item>
+ <item>"7,1"</item>
+ </string-array>
+
+ <!-- Boolean indicating if restoring network selection should be skipped -->
+ <!-- The restoring is handled by modem if it is true -->
+ <bool translatable="false" name="skip_restoring_network_selection">true</bool>
+
+ <!-- Set to true to add links to Cell Broadcast app from Settings and MMS app. -->
+ <bool name="config_cellBroadcastAppLinks">true</bool>
+
+ <!-- The default iface on which to monitor data use -->
+ <string name="config_datause_iface" translatable="false">rmnet0</string>
+
+ <!-- National language single shift tables to enable for SMS encoding.
+ Decoding is always enabled. 3GPP TS 23.038 states that this feature
+ should not be enabled until a formal request is issued by the relevant
+ national regulatory body. Array elements are codes from the table above.
+ Example 1: devices sold in Turkey must include table 1 to conform with
+ By-Law Number 27230. (http://www.btk.gov.tr/eng/pdf/2009/BY-LAW_SMS.pdf)
+ Example 2: devices sold in India should include tables 4 through 13
+ to enable use of the new Release 9 tables for Indic languages. -->
+ <integer-array name="config_sms_enabled_single_shift_tables">
+ <item>1</item>
+ </integer-array>
+
+</resources>
diff --git a/overlay-radio/frameworks/base/packages/SystemUI/res/values/config.xml b/overlay-radio/frameworks/base/packages/SystemUI/res/values/config.xml
new file mode 100644
index 0000000..8884a5d
--- /dev/null
+++ b/overlay-radio/frameworks/base/packages/SystemUI/res/values/config.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2009, The Android Open Source Project
+** Copyright (C) 2013 The CyanogenMod 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.
+*/
+-->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+<resources>
+
+ <!-- Control whether status bar should distinguish HSPA data icon form UMTS
+ data icon on devices -->
+ <bool name="config_hspa_data_distinguishable">true</bool>
+
+ <!-- Should "4G" be shown instead of "LTE" when the network is
+ NETWORK_TYPE_LTE? -->
+ <bool name="config_show4GForLTE">false</bool>
+
+</resources>
diff --git a/overlay-radio/packages/services/Telephony/res/values/config.xml b/overlay-radio/packages/services/Telephony/res/values/config.xml
new file mode 100644
index 0000000..8323f76
--- /dev/null
+++ b/overlay-radio/packages/services/Telephony/res/values/config.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<!-- Phone app resources that may need to be customized
+ for different hardware or product builds. -->
+<resources>
+ <!-- Determine whether calls to mute the microphone in PhoneUtils
+ are routed through the android.media.AudioManager class (true) or through
+ the com.android.internal.telephony.Phone interface (false). -->
+ <bool name="send_mic_mute_to_AudioManager">true</bool>
+
+ <!-- Flag indicating if the tty is enabled -->
+ <bool name="tty_enabled">true</bool>
+
+ <!-- Show enabled lte option for lte device -->
+ <bool name="config_enabled_lte" translatable="false">true</bool>
+</resources>
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
new file mode 100644
index 0000000..c4a60d7
--- /dev/null
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2009, 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.
+*/
+-->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+<resources>
+
+ <!-- Default color for notification LED is white. -->
+ <color name="config_defaultNotificationColor">#ffffffff</color>
+
+ <!-- Default LED on time for notification LED in milliseconds. -->
+ <integer name="config_defaultNotificationLedOn">1000</integer>
+
+ <!-- Default LED off time for notification LED in milliseconds. -->
+ <integer name="config_defaultNotificationLedOff">6000</integer>
+
+ <!-- If this is true, the screen will come on when you unplug usb/power/whatever. -->
+ <bool name="config_unplugTurnsOnScreen">true</bool>
+
+ <!-- If this is true, the screen will fade off. -->
+ <bool name="config_animateScreenLights">false</bool>
+
+ <!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
+ autodetected from the Configuration. -->
+ <bool name="config_showNavigationBar">true</bool>
+
+ <!-- Flag indicating whether we should enable the automatic brightness in Settings.
+ config_hardware_automatic_brightness_available is not set, so we will use software implementation -->
+ <bool name="config_automatic_brightness_available">true</bool>
+
+ <!-- Array of light sensor LUX values to define our levels for auto backlight brightness support.
+ The N entries of this array define N + 1 zones as follows:
+
+ Zone 0: 0 <= LUX < array[0]
+ Zone 1: array[0] <= LUX < array[1]
+ ...
+ Zone N: array[N - 1] <= LUX < array[N]
+ Zone N + 1: array[N] <= LUX < infinity
+
+ Must be overridden in platform specific overlays
+ -->
+ <integer-array name="config_autoBrightnessLevels">
+ <item>3</item>
+ <item>15</item>
+ <item>50</item>
+ <item>100</item>
+ <item>400</item>
+ <item>800</item>
+ <item>1520</item>
+ </integer-array>
+
+ <!-- Array of output values for LCD backlight corresponding to the LUX values
+ in the config_autoBrightnessLevels array. This array should have size one greater
+ than the size of the config_autoBrightnessLevels array.
+ The brightness values must be between 0 and 255 and be non-decreasing.
+ This must be overridden in platform specific overlays -->
+ <integer-array name="config_autoBrightnessLcdBacklightValues">
+ <item>10</item>
+ <item>20</item>
+ <item>50</item>
+ <item>100</item>
+ <item>150</item>
+ <item>200</item>
+ <item>230</item>
+ <item>255</item>
+ </integer-array>
+
+ <!-- Array of output values for button backlight corresponding to the LUX values
+ in the config_autoBrightnessLevels array. This array should have size one greater
+ than the size of the config_autoBrightnessLevels array.
+ The brightness values must be between 0 and 255 and be non-decreasing.
+ This must be overridden in platform specific overlays -->
+ <integer-array name="config_autoBrightnessButtonBacklightValues">
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ </integer-array>
+
+ <string-array translatable="false" name="config_tether_usb_regexs">
+ <item>"usb\\d"</item>
+ <item>"rndis\\d"</item>
+ </string-array>
+
+ <string-array translatable="false" name="config_tether_wifi_regexs">
+ <item>"wlan0"</item>
+ </string-array>
+
+ <!-- List of regexpressions describing the interface (if any) that represent tetherable
+ bluetooth interfaces. If the device doesn't want to support tethering over bluetooth this
+ should be empty. -->
+ <string-array translatable="false" name="config_tether_bluetooth_regexs">
+ <item>"bt-pan"</item>
+ </string-array>
+
+ <!-- Array of allowable ConnectivityManager network types for tethering -->
+ <!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or
+ [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->
+ <integer-array translatable="false" name="config_tether_upstream_types">
+ <item>0</item>
+ <item>1</item>
+ <item>5</item>
+ <item>7</item>
+ </integer-array>
+
+ <!-- Boolean indicating whether the wifi chipset has background scan support -->
+ <bool translatable="false" name="config_wifi_background_scan_support">true</bool>
+
+ <!-- Boolean indicating whether the wifi chipset has dual frequency band support -->
+ <bool translatable="false" name="config_wifi_dual_band_support">true</bool>
+
+ <!-- reference volume index for music stream to limit headphone volume and display warning -->
+ <integer name="config_safe_media_volume_index">7</integer>
+
+ <bool name="config_enableWifiDisplay">true</bool>
+
+ <!-- Setting this true forces the headset jack switches to use the/dev/input/event subsystem
+ rather than the uevent framework. -->
+ <bool name="config_useDevInputEventForAudioJack">true</bool>
+
+ <!-- Is the notification LED intrusive? Used to decide if there should be a disable option -->
+ <bool name="config_intrusiveNotificationLed">true</bool>
+
+ <!-- Is the battery LED intrusive? Used to decide if there should be a disable option -->
+ <bool name="config_intrusiveBatteryLed">true</bool>
+
+ <!-- Can we change the battery color? -->
+ <bool name="config_multiColorBatteryLed">true</bool>
+
+ <!-- Base "touch slop" value used by ViewConfiguration as a
+ movement threshold where scrolling should begin. -->
+ <dimen name="config_viewConfigurationTouchSlop">13dp</dimen>
+
+ <!-- Enable lockscreen translucent decor -->
+ <bool name="config_enableLockScreenTranslucentDecor">true</bool>
+
+ <!-- Defines the system property to set for performance profile xe: sys.cpu.modes. Leave it
+ blank if the device do not support performance profiles -->
+ <string name="config_perf_profile_prop" translatable="false">sys.perf.profile</string>
+
+ <!-- When config_perf_profile_prop is defined, this value MUST be the index of
+ one of the listes values in frameworks/base/core/res/res/values/cm_arrays.xml
+ for "perf_profile_values" array. Leave it blank if the device do not support
+ performance profiles -->
+ <string name="config_perf_profile_default_entry" translatable="false">1</string>
+
+ <!-- Make things go fast -->
+ <bool name="config_ui_enableFadingMarquee">false</bool>
+
+</resources>
diff --git a/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
new file mode 100644
index 0000000..1ea4f9c
--- /dev/null
+++ b/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2009, 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.
+ */
+-->
+<resources>
+ <bool name="def_screen_brightness_automatic_mode">true</bool>
+</resources>
diff --git a/overlay/packages/apps/Camera2/res/values/config.xml b/overlay/packages/apps/Camera2/res/values/config.xml
new file mode 100644
index 0000000..b98eb58
--- /dev/null
+++ b/overlay/packages/apps/Camera2/res/values/config.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+ 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.
+-->
+
+<!-- Camera app resources that may need to be customized
+ for different hardware or product builds. -->
+<resources>
+ <!-- Use ZSL mode for Qualcomm cameras -->
+ <bool name="enableZSL">true</bool>
+</resources>
diff --git a/proprietary-files.txt b/proprietary-files.txt
new file mode 100644
index 0000000..d3a1ade
--- /dev/null
+++ b/proprietary-files.txt
@@ -0,0 +1,438 @@
+# ACDB
+etc/acdbdata/Fluid/Fluid_Bluetooth_cal.acdb
+etc/acdbdata/Fluid/Fluid_General_cal.acdb
+etc/acdbdata/Fluid/Fluid_Global_cal.acdb
+etc/acdbdata/Fluid/Fluid_Handset_cal.acdb
+etc/acdbdata/Fluid/Fluid_Hdmi_cal.acdb
+etc/acdbdata/Fluid/Fluid_Headset_cal.acdb
+etc/acdbdata/Fluid/Fluid_Speaker_cal.acdb
+etc/acdbdata/Liquid/Liquid_Bluetooth_cal.acdb
+etc/acdbdata/Liquid/Liquid_General_cal.acdb
+etc/acdbdata/Liquid/Liquid_Global_cal.acdb
+etc/acdbdata/Liquid/Liquid_Hdmi_cal.acdb
+etc/acdbdata/Liquid/Liquid_Headset_cal.acdb
+etc/acdbdata/MTP/MTP_Bluetooth_cal.acdb
+etc/acdbdata/MTP/MTP_General_cal.acdb
+etc/acdbdata/MTP/MTP_Global_cal.acdb
+etc/acdbdata/MTP/MTP_Hdmi_cal.acdb
+etc/acdbdata/MTP/MTP_Headset_cal.acdb
+
+# Audio
+etc/audio_policy.conf
+vendor/lib/libacdbloader.so
+vendor/lib/libacdbrtac.so
+vendor/lib/libadiertac.so
+vendor/lib/libaudcal.so
+
+# ADSP
+etc/firmware/adsp.b00
+etc/firmware/adsp.b01
+etc/firmware/adsp.b02
+etc/firmware/adsp.b03
+etc/firmware/adsp.b04
+etc/firmware/adsp.b05
+etc/firmware/adsp.b06
+etc/firmware/adsp.b07
+etc/firmware/adsp.b08
+etc/firmware/adsp.b09
+etc/firmware/adsp.b10
+etc/firmware/adsp.b11
+etc/firmware/adsp.mdt
+vendor/lib/libadsprpc.so
+
+# Bluetooth
+bin/btnvtool
+bin/hci_qcomm_init
+vendor/lib/libbtnv.so
+
+# Camera
+bin/mm-qcamera-daemon
+etc/firmware/cpp_firmware_v1_1_1.fw
+etc/firmware/cpp_firmware_v1_1_6.fw
+etc/firmware/cpp_firmware_v1_2_0.fw
+lib/hw/camera.qcom.so:lib/hw/vendor-camera.qcom.so
+lib/libals.so
+lib/libcamera_clientsemc.so
+lib/libcammw.so
+lib/libmmcamera_interface.so
+lib/libmmjpeg_interface.so
+lib/libqomx_core.so
+vendor/lib/libfastcvopt.so
+vendor/lib/libjpegdhw.so
+vendor/lib/libjpegehw.so
+vendor/lib/libmmcamera2_c2d_module.so
+vendor/lib/libmmcamera2_cpp_module.so
+vendor/lib/libmmcamera2_pproc_modules.so
+vendor/lib/libmmcamera2_vpe_module.so
+vendor/lib/libmmcamera2_wnr_module.so
+vendor/lib/libmmcamera_faceproc.so
+vendor/lib/libmmcamera_hdr_gb_lib.so
+vendor/lib/libmmcamera_hdr_lib.so
+vendor/lib/libmmcamera_imglib.so
+vendor/lib/libmmcamera_sunny_p12v01m_eeprom.so
+vendor/lib/libmmcamera_sunny_p5v23c_eeprom.so
+vendor/lib/libmmcamera_truly_cm7700_eeprom.so
+vendor/lib/libmmcamera_tuning.so
+vendor/lib/libmmcamera_wavelet_lib.so
+vendor/lib/libmmjpeg.so
+vendor/lib/libmmqjpeg_codec.so
+vendor/lib/libqomx_jpegdec.so
+vendor/lib/libqomx_jpegenc.so
+
+# Cacao
+lib/camera/libexcal_halctrl_plugin.so
+lib/camera/libexcal_idtctrl_plugin.so
+lib/libcacao_chokoball.so
+lib/libcacao_client.so
+lib/libcacao_common.so
+lib/libcacao_imgproc.so
+lib/libcacao_jpeg.so
+lib/libcacao_pal.so
+lib/libcacao_parammgr.so
+lib/libcacao_service.so
+lib/libcald_client.so
+lib/libcald_imageutil.so
+lib/libcald_pal.so
+lib/libcald_server.so
+lib/libcald_util.so
+lib/libexcal_core.so
+lib/libexcal_system.so
+lib/libface.so
+lib/libface_wrapper.so
+lib/libsomc_chokoballpal.so
+lib/libsony_chokoball.so
+
+# Chromatix
+vendor/lib/libchromatix_imx134_common.so
+vendor/lib/libchromatix_imx134_default_video.so
+vendor/lib/libchromatix_imx134_hfr_120.so
+vendor/lib/libchromatix_imx134_hfr_60.so
+vendor/lib/libchromatix_imx134_preview.so
+vendor/lib/libchromatix_imx134_snapshot.so
+vendor/lib/libchromatix_imx135_common.so
+vendor/lib/libchromatix_imx135_default_video.so
+vendor/lib/libchromatix_imx135_hfr_120.so
+vendor/lib/libchromatix_imx135_preview.so
+vendor/lib/libchromatix_imx135_snapshot.so
+vendor/lib/libchromatix_imx135_video_hd.so
+vendor/lib/libchromatix_ov2720_common.so
+vendor/lib/libchromatix_ov2720_default_video.so
+vendor/lib/libchromatix_ov2720_hfr.so
+vendor/lib/libchromatix_ov2720_liveshot.so
+vendor/lib/libchromatix_ov2720_preview.so
+vendor/lib/libchromatix_ov2720_zsl.so
+vendor/lib/libchromatix_ov5648_oty5f03_common.so
+vendor/lib/libchromatix_ov5648_oty5f03_default_video.so
+vendor/lib/libchromatix_ov5648_oty5f03_preview.so
+vendor/lib/libchromatix_ov5648_oty5f03_snapshot.so
+vendor/lib/libchromatix_ov5648_oty5f03_zsl.so
+vendor/lib/libchromatix_ov8825_common.so
+vendor/lib/libchromatix_ov8825_default_video.so
+vendor/lib/libchromatix_ov8825_hfr_120fps.so
+vendor/lib/libchromatix_ov8825_hfr_60fps.so
+vendor/lib/libchromatix_ov8825_hfr_90fps.so
+vendor/lib/libchromatix_ov8825_liveshot_hd.so
+vendor/lib/libchromatix_ov8825_liveshot.so
+vendor/lib/libchromatix_ov8825_preview_hd.so
+vendor/lib/libchromatix_ov8825_preview.so
+vendor/lib/libchromatix_ov8825_snapshot_hd.so
+vendor/lib/libchromatix_ov8825_snapshot.so
+vendor/lib/libchromatix_ov8825_video_hd.so
+vendor/lib/libchromatix_ov8825_zsl.so
+vendor/lib/libchromatix_ov8865_q8v18a_common.so
+vendor/lib/libchromatix_ov8865_q8v18a_default_video.so
+vendor/lib/libchromatix_ov8865_q8v18a_hfr_120fps.so
+vendor/lib/libchromatix_ov8865_q8v18a_hfr_60fps.so
+vendor/lib/libchromatix_ov8865_q8v18a_hfr_90fps.so
+vendor/lib/libchromatix_ov8865_q8v18a_liveshot.so
+vendor/lib/libchromatix_ov8865_q8v18a_preview.so
+vendor/lib/libchromatix_ov8865_q8v18a_snapshot.so
+vendor/lib/libchromatix_ov8865_q8v18a_video_hd.so
+vendor/lib/libchromatix_ov8865_q8v18a_zsl.so
+vendor/lib/libchromatix_ov9724_common.so
+vendor/lib/libchromatix_ov9724_default_video.so
+vendor/lib/libchromatix_ov9724_liveshot.so
+vendor/lib/libchromatix_ov9724_preview.so
+vendor/lib/libchromatix_s5k3l1yx_common.so
+vendor/lib/libchromatix_s5k3l1yx_default_video.so
+vendor/lib/libchromatix_s5k3l1yx_hfr_120fps.so
+vendor/lib/libchromatix_s5k3l1yx_hfr_60fps.so
+vendor/lib/libchromatix_s5k3l1yx_hfr_90fps.so
+vendor/lib/libchromatix_s5k3l1yx_liveshot.so
+vendor/lib/libchromatix_s5k3l1yx_preview.so
+vendor/lib/libchromatix_s5k3l1yx_snapshot.so
+vendor/lib/libchromatix_s5k3l1yx_video_hd.so
+vendor/lib/libchromatix_s5k3l1yx_zsl.so
+vendor/lib/libchromatix_SKUAA_ST_gc0339_common.so
+vendor/lib/libchromatix_SKUAA_ST_gc0339_default_video.so
+vendor/lib/libchromatix_SKUAA_ST_gc0339_preview.so
+vendor/lib/libchromatix_skuab_shinetech_gc0339_common.so
+vendor/lib/libchromatix_skuab_shinetech_gc0339_default_video.so
+vendor/lib/libchromatix_skuab_shinetech_gc0339_liveshot.so
+vendor/lib/libchromatix_skuab_shinetech_gc0339_preview.so
+vendor/lib/libchromatix_skuab_shinetech_gc0339_snapshot.so
+vendor/lib/libchromatix_skuab_shinetech_gc0339_zsl.so
+vendor/lib/libchromatix_SKUAB_ST_s5k4e1_common.so
+vendor/lib/libchromatix_SKUAB_ST_s5k4e1_default_video.so
+vendor/lib/libchromatix_SKUAB_ST_s5k4e1_hfr_120fps.so
+vendor/lib/libchromatix_SKUAB_ST_s5k4e1_hfr_60fps.so
+vendor/lib/libchromatix_SKUAB_ST_s5k4e1_hfr_90fps.so
+vendor/lib/libchromatix_SKUAB_ST_s5k4e1_liveshot.so
+vendor/lib/libchromatix_SKUAB_ST_s5k4e1_preview.so
+vendor/lib/libchromatix_SKUAB_ST_s5k4e1_snapshot.so
+vendor/lib/libchromatix_SKUAB_ST_s5k4e1_video_hd.so
+vendor/lib/libchromatix_SKUAB_ST_s5k4e1_zsl.so
+vendor/lib/libchromatix_skuf_ov12830_p12v01c_common.so
+vendor/lib/libchromatix_skuf_ov12830_p12v01c_default_video.so
+vendor/lib/libchromatix_skuf_ov12830_p12v01c_hfr_120fps.so
+vendor/lib/libchromatix_skuf_ov12830_p12v01c_hfr_60fps.so
+vendor/lib/libchromatix_skuf_ov12830_p12v01c_hfr_90fps.so
+vendor/lib/libchromatix_skuf_ov12830_p12v01c_preview.so
+vendor/lib/libchromatix_skuf_ov12830_p12v01c_snapshot.so
+vendor/lib/libchromatix_skuf_ov12830_p12v01c_video_hd.so
+vendor/lib/libchromatix_skuf_ov12830_p12v01c_zsl.so
+vendor/lib/libchromatix_skuf_ov5648_p5v23c_common.so
+vendor/lib/libchromatix_skuf_ov5648_p5v23c_default_video.so
+vendor/lib/libchromatix_skuf_ov5648_p5v23c_preview.so
+vendor/lib/libchromatix_skuf_ov5648_p5v23c_snapshot.so
+
+# Camera firmware
+etc/firmware/venus.b00
+etc/firmware/venus.b01
+etc/firmware/venus.b02
+etc/firmware/venus.b03
+etc/firmware/venus.b04
+etc/firmware/venus.mbn
+etc/firmware/venus.mdt
+
+# CPU
+bin/mpdecision
+vendor/lib/libthermalclient.so
+vendor/lib/libqc-opt.so
+
+# FM
+bin/fmconfig
+bin/fm_qsoc_patches
+lib/libfmradio.so
+lib/libfmradio.sony-iris.so
+
+# GPS
+-app/com.qualcomm.location.apk
+bin/gsiff_daemon
+etc/permissions/com.qualcomm.location.xml
+lib/libloc_api_v02.so
+lib/libloc_ds_api.so
+vendor/lib/hw/flp.default.so
+vendor/lib/libgeofence.so
+vendor/lib/libizat_core.so
+vendor/lib/liblbs_core.so
+vendor/lib/liblocationservice.so
+vendor/lib/libquipc_os_api.so
+vendor/lib/libquipc_ulp_adapter.so
+vendor/lib/libulp2.so
+
+# HDCP
+etc/firmware/tzhdcp.b00
+etc/firmware/tzhdcp.b01
+etc/firmware/tzhdcp.b02
+etc/firmware/tzhdcp.b03
+etc/firmware/tzhdcp.mdt
+
+# HW Config
+etc/hw_config.sh
+etc/pre_hw_config.sh
+
+# IRSC
+bin/irsc_util
+etc/sec_config
+
+# Keylayout
+usr/keylayout/gpio-keys.kl
+usr/keylayout/mhl-rcp.kl
+usr/keylayout/msm8974-taiko-mtp-snd-card_Button_Jack.kl
+
+# Keystore
+vendor/firmware/keymaster/keymaster.b00
+vendor/firmware/keymaster/keymaster.b01
+vendor/firmware/keymaster/keymaster.b02
+vendor/firmware/keymaster/keymaster.b03
+vendor/firmware/keymaster/keymaster.mdt
+
+# Lights
+lib/hw/lights.default.so:lib/hw/vendor-lights.default.so
+lib/liblights-core.so
+
+# Media config
+etc/media_profiles.xml
+
+# Modem
+bin/netmgrd
+bin/qmuxd
+bin/rmt_storage
+bin/sct_service
+lib/libpin-cache.so
+vendor/lib/libdiag.so
+vendor/lib/libdsi_netctrl.so
+vendor/lib/libdsnetutils.so
+vendor/lib/libdsutils.so
+vendor/lib/libidl.so
+vendor/lib/libnetmgr.so
+vendor/lib/libril-qc-qmi-1.so
+
+# Modem firmware
+etc/firmware/c6x02/mba.b00
+etc/firmware/c6x02/modem.b01
+etc/firmware/c6x02/modem.mdt
+etc/firmware/mba.b00
+etc/firmware/mba.mdt
+etc/firmware/modem.b00
+etc/firmware/modem.b01
+etc/firmware/modem.b02
+etc/firmware/modem.b03
+etc/firmware/modem.b04
+etc/firmware/modem.b05
+etc/firmware/modem.b08
+etc/firmware/modem.b11
+etc/firmware/modem.b13
+etc/firmware/modem.b14
+etc/firmware/modem.b15
+etc/firmware/modem.b16
+etc/firmware/modem.b17
+etc/firmware/modem.b18
+etc/firmware/modem.b19
+etc/firmware/modem.b20
+etc/firmware/modem.b21
+etc/firmware/modem.b22
+etc/firmware/modem.b25
+etc/firmware/modem.b26
+etc/firmware/modem.mdt
+
+# NFC
+lib/hw/nfc.msm8974.so
+
+# Playready
+etc/firmware/cmnlib.b00
+etc/firmware/cmnlib.b01
+etc/firmware/cmnlib.b02
+etc/firmware/cmnlib.b03
+etc/firmware/cmnlib.mdt
+
+# Postproc
+bin/mm-pp-daemon
+vendor/lib/libmm-abl-oem.so
+vendor/lib/libmm-abl.so
+
+# QMI
+vendor/lib/libqcci_legacy.so
+vendor/lib/libqdi.so
+vendor/lib/libqdp.so
+vendor/lib/libqmi_cci.so
+vendor/lib/libqmi_client_qmux.so
+vendor/lib/libqmi_common_so.so
+vendor/lib/libqmi_csi.so
+vendor/lib/libqmi_csvt_srvc.so
+vendor/lib/libqmi_encdec.so
+vendor/lib/libqmiservices.so
+vendor/lib/libqmi.so
+
+# QSEECOM
+bin/qseecomd
+vendor/lib/libdrmdiag.so
+vendor/lib/libdrmfs.so
+vendor/lib/libdrmtime.so
+vendor/lib/libQSEEComAPI.so
+
+# Security
+bin/suntrold
+lib/lib_asb_tee.so
+lib/libidd.so
+lib/libkeyctrl.so
+
+# Security firmware
+etc/firmware/tzlibasb.b00
+etc/firmware/tzlibasb.b01
+etc/firmware/tzlibasb.b02
+etc/firmware/tzlibasb.b03
+etc/firmware/tzlibasb.mdt
+etc/firmware/tznautilus.b00
+etc/firmware/tznautilus.b01
+etc/firmware/tznautilus.b02
+etc/firmware/tznautilus.b03
+etc/firmware/tznautilus.mdt
+etc/firmware/tzsuntory.b00
+etc/firmware/tzsuntory.b01
+etc/firmware/tzsuntory.b02
+etc/firmware/tzsuntory.b03
+etc/firmware/tzsuntory.mdt
+
+# TA
+bin/taimport
+bin/ta_param_loader
+bin/ta_qmi_service
+lib/libMiscTaAccessor.so
+lib/libmiscta.so
+lib/libta.so
+
+# Time
+bin/time_daemon
+-vendor/lib/libtime_genoff.so
+
+# Touchscreen
+bin/clearpad_fwloader
+
+# Sensors
+vendor/lib/hw/sensors.msm8974.so
+vendor/lib/libsensor_reg.so
+
+# Sysmon
+bin/system_monitor
+lib/libprotobuf-c.so
+lib/libsysmon_idd.so
+lib/libsysmon.so
+lib/libsys-utils.so
+lib/sysmon/sysmon_batt_therm.so
+lib/sysmon/sysmon_charge_current_limit_level.so
+lib/sysmon/sysmon_charging.so
+lib/sysmon/sysmon_corelimit.so
+lib/sysmon/sysmon_dc_current_limit_value.so
+lib/sysmon/sysmon_emmc_therm.so
+lib/sysmon/sysmon_gpu_perflevel.so
+lib/sysmon/sysmon_lcd_brightness_level.so
+lib/sysmon/sysmon_modem_8974.so
+lib/sysmon/sysmon_msm_thermal_disable.so
+lib/sysmon/sysmon_msm_therm.so
+lib/sysmon/sysmon_pa_therm0.so
+lib/sysmon/sysmon_pa_therm1.so
+lib/sysmon/sysmon_perflevel.so
+lib/sysmon/sysmon_pm8941_tz.so
+lib/sysmon/sysmon_quiet_therm.so
+lib/sysmon/sysmon_test_sensor.so
+lib/sysmon/sysmon_tsens_interrupt.so
+lib/sysmon/sysmon_tsens_tz_sensor0.so
+lib/sysmon/sysmon_tsens_tz_sensor10.so
+lib/sysmon/sysmon_tsens_tz_sensor1.so
+lib/sysmon/sysmon_tsens_tz_sensor2.so
+lib/sysmon/sysmon_tsens_tz_sensor3.so
+lib/sysmon/sysmon_tsens_tz_sensor4.so
+lib/sysmon/sysmon_tsens_tz_sensor5.so
+lib/sysmon/sysmon_tsens_tz_sensor6.so
+lib/sysmon/sysmon_tsens_tz_sensor7.so
+lib/sysmon/sysmon_tsens_tz_sensor8.so
+lib/sysmon/sysmon_tsens_tz_sensor9.so
+lib/sysmon/sysmon_usb_current_limit_value.so
+lib/sysmon/sysmon_wlan_limit.so
+lib/sysmon/sysmon_xo_therm.so
+
+# WiFi
+bin/radish
+
+# WiFi firmware
+etc/firmware/wcnss.b00
+etc/firmware/wcnss.b01
+etc/firmware/wcnss.b02
+etc/firmware/wcnss.b04
+etc/firmware/wcnss.b06
+etc/firmware/wcnss.b07
+etc/firmware/wcnss.b08
+etc/firmware/wcnss.b09
+etc/firmware/wcnss.mdt
diff --git a/radio.mk b/radio.mk
new file mode 100644
index 0000000..d9af3f9
--- /dev/null
+++ b/radio.mk
@@ -0,0 +1,24 @@
+# LTE, GSM/WCDMA
+PRODUCT_PROPERTY_OVERRIDES += \
+ ro.telephony.default_network=9 \
+ telephony.lteOnCdmaDevice=0 \
+ telephony.lteOnGsmDevice=1 \
+ persist.radio.apm_sim_not_pwdn=1 \
+ persist.radio.add_power_save=1 \
+ persist.radio.mode_pref_nv10=1
+
+# Ril sends only one RIL_UNSOL_CALL_RING, so set call_ring.multiple to false
+PRODUCT_PROPERTY_OVERRIDES += \
+ ro.telephony.call_ring.multiple=0
+
+# System props for the data modules
+PRODUCT_PROPERTY_OVERRIDES += \
+ persist.data.netmgrd.qos.enable=false
+
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ rild.libpath=/system/vendor/lib/libril-qc-qmi-1.so
+
+# update 1x signal strength after 2s
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ persist.radio.snapshot_enabled=1 \
+ persist.radio.snapshot_timer=2
diff --git a/recovery/Android.mk b/recovery/Android.mk
new file mode 100644
index 0000000..a66b559
--- /dev/null
+++ b/recovery/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := eng
+LOCAL_C_INCLUDES += bootable/recovery
+LOCAL_SRC_FILES := recovery_ui.cpp
+
+# should match TARGET_RECOVERY_UI_LIB set in BoardConfig.mk
+LOCAL_MODULE := librecovery_ui_shinano
+
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
diff --git a/recovery/D6x02.sh b/recovery/D6x02.sh
new file mode 100644
index 0000000..0bdcfe0
--- /dev/null
+++ b/recovery/D6x02.sh
@@ -0,0 +1,11 @@
+#!/sbin/sh
+
+mkdir -p /lta-label
+mount -o ro /dev/block/platform/msm_sdcc.1/by-name/LTALabel /lta-label
+ls lta-label/*.html | grep -q c6[89]02
+if [ $? -eq 0 ]; then
+ mount /dev/block/platform/msm_sdcc.1/by-name/system /system
+ cp /system/etc/firmware/c6x02/* /system/etc/firmware/
+ umount /system
+fi
+umount /lta-label
diff --git a/recovery/postrecoveryboot.sh b/recovery/postrecoveryboot.sh
new file mode 100644
index 0000000..e3f2098
--- /dev/null
+++ b/recovery/postrecoveryboot.sh
@@ -0,0 +1 @@
+#!/sbin/sh
diff --git a/recovery/twrpgraphics.c b/recovery/twrpgraphics.c
new file mode 100644
index 0000000..c2b3f85
--- /dev/null
+++ b/recovery/twrpgraphics.c
@@ -0,0 +1,732 @@
+/*
+ * Copyright (C) 2007 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 <stdbool.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <fcntl.h>
+#include <stdio.h>
+
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+
+#include <linux/fb.h>
+#include <linux/kd.h>
+
+#include <pixelflinger/pixelflinger.h>
+
+#include "minui.h"
+
+#ifdef BOARD_USE_CUSTOM_RECOVERY_FONT
+#include BOARD_USE_CUSTOM_RECOVERY_FONT
+#else
+#include "font_10x18.h"
+#endif
+
+#ifdef RECOVERY_BGRA
+#define PIXEL_FORMAT GGL_PIXEL_FORMAT_BGRA_8888
+#define PIXEL_SIZE 4
+#endif
+#ifdef RECOVERY_RGBX
+#define PIXEL_FORMAT GGL_PIXEL_FORMAT_RGBX_8888
+#define PIXEL_SIZE 4
+#endif
+#ifndef PIXEL_FORMAT
+#define PIXEL_FORMAT GGL_PIXEL_FORMAT_RGB_565
+#define PIXEL_SIZE 2
+#endif
+
+#define NUM_BUFFERS 2
+
+// #define PRINT_SCREENINFO 1 // Enables printing of screen info to log
+
+typedef struct {
+ GGLSurface texture;
+ unsigned offset[97];
+ unsigned cheight;
+ unsigned ascent;
+} GRFont;
+
+static GRFont *gr_font = 0;
+static GGLContext *gr_context = 0;
+static GGLSurface gr_font_texture;
+static GGLSurface gr_framebuffer[NUM_BUFFERS];
+static GGLSurface gr_mem_surface;
+static unsigned gr_active_fb = 0;
+static unsigned double_buffering = 0;
+
+static int gr_fb_fd = -1;
+static int gr_vt_fd = -1;
+
+static struct fb_var_screeninfo vi;
+static struct fb_fix_screeninfo fi;
+
+#ifdef PRINT_SCREENINFO
+static void print_fb_var_screeninfo()
+{
+ LOGI("vi.xres: %d\n", vi.xres);
+ LOGI("vi.yres: %d\n", vi.yres);
+ LOGI("vi.xres_virtual: %d\n", vi.xres_virtual);
+ LOGI("vi.yres_virtual: %d\n", vi.yres_virtual);
+ LOGI("vi.xoffset: %d\n", vi.xoffset);
+ LOGI("vi.yoffset: %d\n", vi.yoffset);
+ LOGI("vi.bits_per_pixel: %d\n", vi.bits_per_pixel);
+ LOGI("vi.grayscale: %d\n", vi.grayscale);
+}
+#endif
+
+static int get_framebuffer(GGLSurface *fb)
+{
+ int fd;
+ void *bits, *vi2;
+
+ fd = open("/dev/graphics/fb0", O_RDWR);
+ if (fd < 0) {
+ perror("cannot open fb0");
+ return -1;
+ }
+
+ vi2 = malloc(sizeof(vi) + sizeof(__u32));
+
+ if (ioctl(fd, FBIOGET_VSCREENINFO, vi2) < 0) {
+ perror("failed to get fb0 info");
+ close(fd);
+ free(vi2);
+ return -1;
+ }
+ memcpy((void*) &vi, vi2, sizeof(vi));
+ free(vi2);
+ fprintf(stderr, "Pixel format: %dx%d @ %dbpp\n", vi.xres, vi.yres, vi.bits_per_pixel);
+
+ vi.bits_per_pixel = PIXEL_SIZE * 8;
+ if (PIXEL_FORMAT == GGL_PIXEL_FORMAT_BGRA_8888) {
+ fprintf(stderr, "Pixel format: BGRA_8888\n");
+ if (PIXEL_SIZE != 4) fprintf(stderr, "E: Pixel Size mismatch!\n");
+ vi.red.offset = 8;
+ vi.red.length = 8;
+ vi.green.offset = 16;
+ vi.green.length = 8;
+ vi.blue.offset = 24;
+ vi.blue.length = 8;
+ vi.transp.offset = 0;
+ vi.transp.length = 8;
+ } else if (PIXEL_FORMAT == GGL_PIXEL_FORMAT_RGBX_8888) {
+ fprintf(stderr, "Pixel format: RGBX_8888\n");
+ if (PIXEL_SIZE != 4) fprintf(stderr, "E: Pixel Size mismatch!\n");
+ vi.red.offset = 24;
+ vi.red.length = 8;
+ vi.green.offset = 16;
+ vi.green.length = 8;
+ vi.blue.offset = 8;
+ vi.blue.length = 8;
+ vi.transp.offset = 0;
+ vi.transp.length = 8;
+ } else if (PIXEL_FORMAT == GGL_PIXEL_FORMAT_RGB_565) {
+#ifdef RECOVERY_RGB_565
+ fprintf(stderr, "Pixel format: RGB_565\n");
+ vi.blue.offset = 0;
+ vi.green.offset = 5;
+ vi.red.offset = 11;
+#else
+ fprintf(stderr, "Pixel format: BGR_565\n");
+ vi.blue.offset = 11;
+ vi.green.offset = 5;
+ vi.red.offset = 0;
+#endif
+ if (PIXEL_SIZE != 2) fprintf(stderr, "E: Pixel Size mismatch!\n");
+ vi.blue.length = 5;
+ vi.green.length = 6;
+ vi.red.length = 5;
+ vi.blue.msb_right = 0;
+ vi.green.msb_right = 0;
+ vi.red.msb_right = 0;
+ vi.transp.offset = 0;
+ vi.transp.length = 0;
+ }
+ else
+ {
+ perror("unknown pixel format");
+ close(fd);
+ return -1;
+ }
+
+ vi.vmode = FB_VMODE_NONINTERLACED;
+ vi.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE;
+
+ if (ioctl(fd, FBIOPUT_VSCREENINFO, &vi) < 0) {
+ perror("failed to put fb0 info");
+ close(fd);
+ return -1;
+ }
+
+ if (ioctl(fd, FBIOGET_FSCREENINFO, &fi) < 0) {
+ perror("failed to get fb0 info");
+ close(fd);
+ return -1;
+ }
+
+ bits = mmap(0, fi.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (bits == MAP_FAILED) {
+ perror("failed to mmap framebuffer");
+ close(fd);
+ return -1;
+ }
+
+#ifdef RECOVERY_GRAPHICS_USE_LINELENGTH
+ vi.xres_virtual = fi.line_length / PIXEL_SIZE;
+#endif
+
+ fb->version = sizeof(*fb);
+ fb->width = vi.xres;
+ fb->height = vi.yres;
+#ifdef BOARD_HAS_JANKY_BACKBUFFER
+ LOGI("setting JANKY BACKBUFFER\n");
+ fb->stride = fi.line_length/2;
+#else
+ fb->stride = vi.xres_virtual;
+#endif
+ fb->data = bits;
+ fb->format = PIXEL_FORMAT;
+ memset(fb->data, 0, vi.yres * fb->stride * PIXEL_SIZE);
+
+ fb++;
+
+ /* check if we can use double buffering */
+ if (vi.yres * fi.line_length * 2 > fi.smem_len)
+ return fd;
+
+ double_buffering = 1;
+
+ fb->version = sizeof(*fb);
+ fb->width = vi.xres;
+ fb->height = vi.yres;
+#ifdef BOARD_HAS_JANKY_BACKBUFFER
+ fb->stride = fi.line_length/2;
+ fb->data = (void*) (((unsigned) bits) + vi.yres * fi.line_length);
+#else
+ fb->stride = vi.xres_virtual;
+ fb->data = (void*) (((unsigned) bits) + vi.yres * fb->stride * PIXEL_SIZE);
+#endif
+ fb->format = PIXEL_FORMAT;
+ memset(fb->data, 0, vi.yres * fb->stride * PIXEL_SIZE);
+
+#ifdef PRINT_SCREENINFO
+ print_fb_var_screeninfo();
+#endif
+
+ return fd;
+}
+
+static void get_memory_surface(GGLSurface* ms) {
+ ms->version = sizeof(*ms);
+ ms->width = vi.xres;
+ ms->height = vi.yres;
+ ms->stride = vi.xres_virtual;
+ ms->data = malloc(vi.xres_virtual * vi.yres * PIXEL_SIZE);
+ ms->format = PIXEL_FORMAT;
+}
+
+static void set_active_framebuffer(unsigned n)
+{
+ if (n > 1 || !double_buffering) return;
+ vi.yres_virtual = vi.yres * NUM_BUFFERS;
+ vi.yoffset = n * vi.yres;
+// vi.bits_per_pixel = PIXEL_SIZE * 8;
+ if (ioctl(gr_fb_fd, FBIOPUT_VSCREENINFO, &vi) < 0) {
+ perror("active fb swap failed");
+ }
+}
+
+void gr_flip(void)
+{
+ GGLContext *gl = gr_context;
+
+ /* swap front and back buffers */
+ if (double_buffering)
+ gr_active_fb = (gr_active_fb + 1) & 1;
+
+#ifdef BOARD_HAS_FLIPPED_SCREEN
+ /* flip buffer 180 degrees for devices with physicaly inverted screens */
+ unsigned int i;
+ for (i = 1; i < (vi.xres * vi.yres); i++) {
+ unsigned short tmp = gr_mem_surface.data[i];
+ gr_mem_surface.data[i] = gr_mem_surface.data[(vi.xres * vi.yres * 2) - i];
+ gr_mem_surface.data[(vi.xres * vi.yres * 2) - i] = tmp;
+ }
+#endif
+
+ /* copy data from the in-memory surface to the buffer we're about
+ * to make active. */
+ memcpy(gr_framebuffer[gr_active_fb].data, gr_mem_surface.data,
+ vi.xres_virtual * vi.yres * PIXEL_SIZE);
+
+ /* inform the display driver */
+ set_active_framebuffer(gr_active_fb);
+}
+
+void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
+{
+ GGLContext *gl = gr_context;
+ GGLint color[4];
+ color[0] = ((r << 8) | r) + 1;
+ color[1] = ((g << 8) | g) + 1;
+ color[2] = ((b << 8) | b) + 1;
+ color[3] = ((a << 8) | a) + 1;
+ gl->color4xv(gl, color);
+}
+
+int gr_measureEx(const char *s, void* font)
+{
+ GRFont* fnt = (GRFont*) font;
+ int total = 0;
+ unsigned pos;
+ unsigned off;
+
+ if (!fnt) fnt = gr_font;
+
+ while ((off = *s++))
+ {
+ off -= 32;
+ if (off < 96)
+ total += (fnt->offset[off+1] - fnt->offset[off]);
+ }
+ return total;
+}
+
+unsigned character_width(const char *s, void* pFont)
+{
+ GRFont *font = (GRFont*) pFont;
+ unsigned off;
+
+ /* Handle default font */
+ if (!font) font = gr_font;
+
+ off = *s - 32;
+ if (off == 0)
+ return 0;
+
+ return font->offset[off+1] - font->offset[off];
+}
+
+int gr_textEx(int x, int y, const char *s, void* pFont)
+{
+ GGLContext *gl = gr_context;
+ GRFont *font = (GRFont*) pFont;
+ unsigned off;
+ unsigned cwidth;
+
+ /* Handle default font */
+ if (!font) font = gr_font;
+
+ gl->bindTexture(gl, &font->texture);
+ gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE);
+ gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
+ gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
+ gl->enable(gl, GGL_TEXTURE_2D);
+
+ while((off = *s++)) {
+ off -= 32;
+ cwidth = 0;
+ if (off < 96) {
+ cwidth = font->offset[off+1] - font->offset[off];
+ gl->texCoord2i(gl, (font->offset[off]) - x, 0 - y);
+ gl->recti(gl, x, y, x + cwidth, y + font->cheight);
+ x += cwidth;
+ }
+ }
+
+ return x;
+}
+
+int gr_textExW(int x, int y, const char *s, void* pFont, int max_width)
+{
+ GGLContext *gl = gr_context;
+ GRFont *font = (GRFont*) pFont;
+ unsigned off;
+ unsigned cwidth;
+
+ /* Handle default font */
+ if (!font) font = gr_font;
+
+ gl->bindTexture(gl, &font->texture);
+ gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE);
+ gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
+ gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
+ gl->enable(gl, GGL_TEXTURE_2D);
+
+ while((off = *s++)) {
+ off -= 32;
+ cwidth = 0;
+ if (off < 96) {
+ cwidth = font->offset[off+1] - font->offset[off];
+ if ((x + (int)cwidth) < max_width) {
+ gl->texCoord2i(gl, (font->offset[off]) - x, 0 - y);
+ gl->recti(gl, x, y, x + cwidth, y + font->cheight);
+ x += cwidth;
+ } else {
+ gl->texCoord2i(gl, (font->offset[off]) - x, 0 - y);
+ gl->recti(gl, x, y, max_width, y + font->cheight);
+ x = max_width;
+ return x;
+ }
+ }
+ }
+
+ return x;
+}
+
+int gr_textExWH(int x, int y, const char *s, void* pFont, int max_width, int max_height)
+{
+ GGLContext *gl = gr_context;
+ GRFont *font = (GRFont*) pFont;
+ unsigned off;
+ unsigned cwidth;
+ int rect_x, rect_y;
+
+ /* Handle default font */
+ if (!font) font = gr_font;
+
+ gl->bindTexture(gl, &font->texture);
+ gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE);
+ gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
+ gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
+ gl->enable(gl, GGL_TEXTURE_2D);
+
+ while((off = *s++)) {
+ off -= 32;
+ cwidth = 0;
+ if (off < 96) {
+ cwidth = font->offset[off+1] - font->offset[off];
+ if ((x + (int)cwidth) < max_width)
+ rect_x = x + cwidth;
+ else
+ rect_x = max_width;
+ if (y + font->cheight < (unsigned int)(max_height))
+ rect_y = y + font->cheight;
+ else
+ rect_y = max_height;
+
+ gl->texCoord2i(gl, (font->offset[off]) - x, 0 - y);
+ gl->recti(gl, x, y, rect_x, rect_y);
+ x += cwidth;
+ if (x > max_width)
+ return x;
+ }
+ }
+
+ return x;
+}
+
+int twgr_text(int x, int y, const char *s)
+{
+ GGLContext *gl = gr_context;
+ GRFont *font = gr_font;
+ unsigned off;
+ unsigned cwidth = 0;
+
+ y -= font->ascent;
+
+ gl->bindTexture(gl, &font->texture);
+ gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE);
+ gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
+ gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
+ gl->enable(gl, GGL_TEXTURE_2D);
+
+ while((off = *s++)) {
+ off -= 32;
+ if (off < 96) {
+ cwidth = font->offset[off+1] - font->offset[off];
+ gl->texCoord2i(gl, (off * cwidth) - x, 0 - y);
+ gl->recti(gl, x, y, x + cwidth, y + font->cheight);
+ }
+ x += cwidth;
+ }
+
+ return x;
+}
+
+void gr_fill(int x, int y, int w, int h)
+{
+ GGLContext *gl = gr_context;
+ gl->disable(gl, GGL_TEXTURE_2D);
+ gl->recti(gl, x, y, x + w, y + h);
+}
+
+void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy) {
+ if (gr_context == NULL) {
+ return;
+ }
+
+ GGLContext *gl = gr_context;
+ gl->bindTexture(gl, (GGLSurface*) source);
+ gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE);
+ gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
+ gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
+ gl->enable(gl, GGL_TEXTURE_2D);
+ gl->texCoord2i(gl, sx - dx, sy - dy);
+ gl->recti(gl, dx, dy, dx + w, dy + h);
+}
+
+unsigned int gr_get_width(gr_surface surface) {
+ if (surface == NULL) {
+ return 0;
+ }
+ return ((GGLSurface*) surface)->width;
+}
+
+unsigned int gr_get_height(gr_surface surface) {
+ if (surface == NULL) {
+ return 0;
+ }
+ return ((GGLSurface*) surface)->height;
+}
+
+void* gr_loadFont(const char* fontName)
+{
+ int fd;
+ GRFont *font = 0;
+ GGLSurface *ftex;
+ unsigned char *bits, *rle;
+ unsigned char *in, data;
+ unsigned width, height;
+ unsigned element;
+
+ fd = open(fontName, O_RDONLY);
+ if (fd == -1)
+ {
+ char tmp[128];
+
+ sprintf(tmp, "/res/fonts/%s.dat", fontName);
+ fd = open(tmp, O_RDONLY);
+ if (fd == -1)
+ return NULL;
+ }
+
+ font = calloc(sizeof(*font), 1);
+ ftex = &font->texture;
+
+ read(fd, &width, sizeof(unsigned));
+ read(fd, &height, sizeof(unsigned));
+ read(fd, font->offset, sizeof(unsigned) * 96);
+ font->offset[96] = width;
+
+ bits = malloc(width * height);
+ memset(bits, 0, width * height);
+
+ unsigned pos = 0;
+ while (pos < width * height)
+ {
+ int bit;
+
+ read(fd, &data, 1);
+ for (bit = 0; bit < 8; bit++)
+ {
+ if (data & (1 << (7-bit))) bits[pos++] = 255;
+ else bits[pos++] = 0;
+
+ if (pos == width * height) break;
+ }
+ }
+ close(fd);
+
+ ftex->version = sizeof(*ftex);
+ ftex->width = width;
+ ftex->height = height;
+ ftex->stride = width;
+ ftex->data = (void*) bits;
+ ftex->format = GGL_PIXEL_FORMAT_A_8;
+ font->cheight = height;
+ font->ascent = height - 2;
+ return (void*) font;
+}
+
+int gr_getFontDetails(void* font, unsigned* cheight, unsigned* maxwidth)
+{
+ GRFont *fnt = (GRFont*) font;
+
+ if (!fnt) fnt = gr_font;
+ if (!fnt) return -1;
+
+ if (cheight) *cheight = fnt->cheight;
+ if (maxwidth)
+ {
+ int pos;
+ *maxwidth = 0;
+ for (pos = 0; pos < 96; pos++)
+ {
+ unsigned int width = fnt->offset[pos+1] - fnt->offset[pos];
+ if (width > *maxwidth)
+ {
+ *maxwidth = width;
+ }
+ }
+ }
+ return 0;
+}
+
+static void gr_init_font(void)
+{
+ int fontRes;
+ GGLSurface *ftex;
+ unsigned char *bits, *rle;
+ unsigned char *in, data;
+ unsigned width, height;
+ unsigned element;
+
+ gr_font = calloc(sizeof(*gr_font), 1);
+ ftex = &gr_font->texture;
+
+ width = font.width;
+ height = font.height;
+
+ bits = malloc(width * height);
+ rle = bits;
+
+ in = font.rundata;
+ while((data = *in++))
+ {
+ memset(rle, (data & 0x80) ? 255 : 0, data & 0x7f);
+ rle += (data & 0x7f);
+ }
+ for (element = 0; element < 97; element++)
+ {
+ gr_font->offset[element] = (element * font.cwidth);
+ }
+
+ ftex->version = sizeof(*ftex);
+ ftex->width = width;
+ ftex->height = height;
+ ftex->stride = width;
+ ftex->data = (void*) bits;
+ ftex->format = GGL_PIXEL_FORMAT_A_8;
+ gr_font->cheight = height;
+ gr_font->ascent = height - 2;
+ return;
+}
+
+int gr_init(void)
+{
+ gglInit(&gr_context);
+ GGLContext *gl = gr_context;
+
+ gr_init_font();
+ gr_vt_fd = open("/dev/tty0", O_RDWR | O_SYNC);
+ if (gr_vt_fd < 0) {
+ // This is non-fatal; post-Cupcake kernels don't have tty0.
+ } else if (ioctl(gr_vt_fd, KDSETMODE, (void*) KD_GRAPHICS)) {
+ // However, if we do open tty0, we expect the ioctl to work.
+ perror("failed KDSETMODE to KD_GRAPHICS on tty0");
+ gr_exit();
+ return -1;
+ }
+
+ gr_fb_fd = get_framebuffer(gr_framebuffer);
+ if (gr_fb_fd < 0) {
+ perror("Unable to get framebuffer.\n");
+ gr_exit();
+ return -1;
+ }
+
+ get_memory_surface(&gr_mem_surface);
+
+ fprintf(stderr, "framebuffer: fd %d (%d x %d)\n",
+ gr_fb_fd, gr_framebuffer[0].width, gr_framebuffer[0].height);
+
+ /* start with 0 as front (displayed) and 1 as back (drawing) */
+ gr_active_fb = 0;
+ set_active_framebuffer(0);
+ gl->colorBuffer(gl, &gr_mem_surface);
+
+ gl->activeTexture(gl, 0);
+ gl->enable(gl, GGL_BLEND);
+ gl->blendFunc(gl, GGL_SRC_ALPHA, GGL_ONE_MINUS_SRC_ALPHA);
+
+// gr_fb_blank(true);
+// gr_fb_blank(false);
+
+ return 0;
+}
+
+void gr_exit(void)
+{
+ close(gr_fb_fd);
+ gr_fb_fd = -1;
+
+ free(gr_mem_surface.data);
+
+ ioctl(gr_vt_fd, KDSETMODE, (void*) KD_TEXT);
+ close(gr_vt_fd);
+ gr_vt_fd = -1;
+}
+
+int gr_fb_width(void)
+{
+ return gr_framebuffer[0].width;
+}
+
+int gr_fb_height(void)
+{
+ return gr_framebuffer[0].height;
+}
+
+gr_pixel *gr_fb_data(void)
+{
+ return (unsigned short *) gr_mem_surface.data;
+}
+
+int gr_fb_blank(int blank)
+{
+ int ret;
+
+ ret = ioctl(gr_fb_fd, FBIOBLANK, blank ? FB_BLANK_POWERDOWN : FB_BLANK_UNBLANK);
+ if (ret < 0)
+ perror("ioctl(): blank");
+ return ret;
+}
+
+int gr_get_surface(gr_surface* surface)
+{
+ GGLSurface* ms = malloc(sizeof(GGLSurface));
+ if (!ms) return -1;
+
+ // Allocate the data
+ get_memory_surface(ms);
+
+ // Now, copy the data
+ memcpy(ms->data, gr_mem_surface.data, vi.xres * vi.yres * vi.bits_per_pixel / 8);
+
+ *surface = (gr_surface*) ms;
+ return 0;
+}
+
+int gr_free_surface(gr_surface surface)
+{
+ if (!surface)
+ return -1;
+
+ GGLSurface* ms = (GGLSurface*) surface;
+ free(ms->data);
+ free(ms);
+ return 0;
+}
+
+void gr_write_frame_to_file(int fd)
+{
+ write(fd, gr_mem_surface.data, vi.xres * vi.yres * vi.bits_per_pixel / 8);
+}
+
diff --git a/releasetools.py b/releasetools.py
new file mode 100644
index 0000000..54dc6b6
--- /dev/null
+++ b/releasetools.py
@@ -0,0 +1,28 @@
+# Copyright (C) 2012 The Android Open Source Project
+# Copyright (C) 2014 The CyanogenMod 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.
+
+"""Custom OTA Package commands for shinano"""
+
+import os
+
+TARGET_DIR = os.getenv('OUT')
+TARGET_DEVICE = os.getenv('CM_BUILD')
+
+def FullOTA_InstallEnd(self):
+ if TARGET_DEVICE == "honami" or TARGET_DEVICE == "togari":
+ self.output_zip.write(os.path.join(TARGET_DIR, "D6x02.sh"), "D6x02.sh")
+ self.script.AppendExtra('package_extract_file("D6x02.sh", "/tmp/D6x02.sh");')
+ self.script.AppendExtra('set_perm(0, 0, 0777, "/tmp/D6x02.sh");')
+ self.script.AppendExtra('run_program("/tmp/D6x02.sh");')
diff --git a/rootdir/charger b/rootdir/charger
new file mode 100644
index 0000000..fdcd72d
--- /dev/null
+++ b/rootdir/charger
Binary files differ
diff --git a/rootdir/fstab.qcom b/rootdir/fstab.qcom
new file mode 100644
index 0000000..1cafb88
--- /dev/null
+++ b/rootdir/fstab.qcom
@@ -0,0 +1,16 @@
+# Android fstab file.
+#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
+# The filesystem that contains the filesystem checker binary (typically /system) cannot
+# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
+
+/dev/block/platform/msm_sdcc.1/by-name/boot /boot emmc defaults recoveryonly
+/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,barrier=1 wait
+/dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check
+/dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check,encryptable=footer,length=-16384
+/dev/block/platform/msm_sdcc.1/by-name/apps_log /mnt/idd ext4 noatime,nosuid,nodev,noexec,barrier=0,discard wait
+
+/dev/block/platform/msm_sdcc.1/by-name/modemst1 /boot/modem_fs1 emmc n/a n/a
+/dev/block/platform/msm_sdcc.1/by-name/modemst2 /boot/modem_fs2 emmc n/a n/a
+
+/devices/msm_sdcc.2/mmc_host auto auto defaults voldmanaged=sdcard1:auto
+/devices/platform/xhci-hcd audo auto defaults voldmanaged=usbdisk:auto
diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc
new file mode 100644
index 0000000..8150c51
--- /dev/null
+++ b/rootdir/init.qcom.rc
@@ -0,0 +1,795 @@
+#
+# Copyright 2012 The Android Open Source Project
+# Copyright (C) 2013 The CyanogenMod 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.
+#
+
+import init.device.rc
+import init.sony.usb.rc
+
+on early-init
+ mount debugfs debugfs /sys/kernel/debug
+ chown system system /sys/kernel/debug/kgsl/proc
+
+on init
+ mkdir /mnt/shell/emulated 0700 shell shell
+ mkdir /storage/emulated 0555 root root
+ mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
+ mkdir /mnt/media_rw/usbdisk 0700 media_rw media_rw
+ mkdir /storage/sdcard1 0775 system system
+ mkdir /storage/usbdisk 0775 system system
+
+ export EXTERNAL_STORAGE /storage/emulated/legacy
+ export SECONDARY_STORAGE /storage/sdcard1
+ export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
+ export EMULATED_STORAGE_TARGET /storage/emulated
+
+ # for backwards compatibility
+ symlink /storage/emulated/legacy /sdcard
+ symlink /storage/emulated/legacy /mnt/sdcard
+ symlink /storage/emulated/legacy /storage/sdcard0
+ symlink /mnt/shell/emulated/0 /storage/emulated/legacy
+ symlink /storage/sdcard1 /ext_card
+ symlink /storage/sdcard1 /mnt/ext_card
+ symlink /storage/usbdisk /usbdisk
+ symlink /storage/usbdisk /mnt/usbdisk
+
+ mkdir /tmp
+ mount tmpfs tmpfs /tmp nosuid mode=0755,uid=0,gid=0
+ chmod 0664 /proc/rdtag
+ chown root system /proc/rdtag
+
+ mkdir /dev/bus 0755 root root
+ mkdir /dev/bus/usb 0755 root root
+
+ # create directory for scd
+ mkdir /dev/socket/scd 0755 system system
+
+ # Enable ramdumps from subsystems to dump
+ # Should be initialized during init
+ write /sys/bus/msm_subsys/devices/subsys0/restart_level "RELATED"
+ write /sys/bus/msm_subsys/devices/subsys1/restart_level "RELATED"
+ write /sys/bus/msm_subsys/devices/subsys2/restart_level "RELATED"
+ write /sys/bus/msm_subsys/devices/subsys3/restart_level "RELATED"
+
+ # Enable panic on out of memory
+ write /proc/sys/vm/panic_on_oom 2
+
+ # Create a tmpfs for dynamic network mounting
+ mkdir /storage/removable/remote 0700 root system
+ mount tmpfs tmpfs /storage/removable/remote mode=0755,uid=0,gid=0
+
+ # Set the property to indicate type of virtual display to 0
+ # 0 indicates that virtual display is not a Wifi display and that the
+ # session is not exercised through RemoteDisplay in the android framework
+ setprop persist.sys.wfd.virtual 0
+
+on fs
+ mkdir /mnt/idd 0751 sony_idd sony_idd
+
+ mount_all ./fstab.qcom
+ setprop ro.crypto.fuse_sdcard true
+
+ chown sony_idd sony_idd /mnt/idd
+ chmod 0751 /mnt/idd
+
+ mkdir /lta-label 0555 system system
+ wait /dev/block/platform/msm_sdcc.1/by-name/LTALabel
+ mount ext4 /dev/block/platform/msm_sdcc.1/by-name/LTALabel /lta-label nosuid nodev noatime noexec ro barrier=0
+ chown system system /lta-label
+ chmod 0555 /lta-label
+
+ chmod 0755 /data/etc
+ start tad
+ exec /sbin/wait4tad_static
+ exec /system/bin/taimport
+
+ restorecon -R /data/etc
+
+on early-boot
+ # set RLIMIT_MEMLOCK to 64MB
+ setrlimit 8 67108864 67108864
+
+ write /sys/kernel/boot_adsp/boot 1
+
+ start ta_qmi_service
+ start sct_service
+
+ # Run pre_hw_config.sh before entering charge only mode.
+ exec /system/bin/sh /system/etc/pre_hw_config.sh
+
+ exec /system/bin/sh /system/etc/init.qcom.wifi.sh
+
+on boot
+ write /sys/module/qpnp_power_on/parameters/forcecrash_on 1
+ exec /system/bin/btnvtool -O
+ chown bluetooth bluetooth /sys/module/bluetooth_power/parameters/power
+ chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type
+ chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state
+ chown bluetooth bluetooth /proc/bluetooth/sleep/proto
+ chown bluetooth bluetooth /sys/module/hci_uart/parameters/ath_lpm
+ chown bluetooth bluetooth /sys/module/hci_uart/parameters/ath_btwrite
+ chown system system /sys/module/sco/parameters/disable_esco
+ chown bluetooth bluetooth /sys/module/hci_smd/parameters/hcismd_set
+ chmod 0660 /sys/module/bluetooth_power/parameters/power
+ chmod 0660 /sys/module/hci_smd/parameters/hcismd_set
+ chmod 0660 /sys/class/rfkill/rfkill0/state
+ chmod 0660 /proc/bluetooth/sleep/proto
+ chown bluetooth bluetooth /dev/ttyHS0
+ chmod 0660 /sys/module/hci_uart/parameters/ath_lpm
+ chmod 0660 /sys/module/hci_uart/parameters/ath_btwrite
+ chmod 0660 /dev/ttyHS0
+ chown bluetooth bluetooth /sys/devices/platform/msm_serial_hs.0/clock
+ chmod 0660 /sys/devices/platform/msm_serial_hs.0/clock
+
+ chmod 0660 /dev/ttyHS2
+ chown bluetooth bluetooth /dev/ttyHS2
+
+ # Create QMUX deamon socket area
+ mkdir /dev/socket/qmux_radio 0770 radio radio
+ chmod 2770 /dev/socket/qmux_radio
+ mkdir /dev/socket/qmux_audio 0770 media audio
+ chmod 2770 /dev/socket/qmux_audio
+ mkdir /dev/socket/qmux_bluetooth 0770 bluetooth net_bt_stack
+ chmod 2770 /dev/socket/qmux_bluetooth
+ mkdir /dev/socket/qmux_gps 0770 gps gps
+ chmod 2770 /dev/socket/qmux_gps
+
+ setprop ro.telephony.call_ring.multiple false
+
+ # Remove SUID bit for iproute2 ip tool
+ chmod 0755 /system/bin/ip
+
+ # port-bridge
+ chmod 0660 /dev/smd0
+ chown system system /dev/smd0
+
+ # BT DUN port-bridge
+ chmod 0660 /dev/smd7
+ chown bluetooth bluetooth /dev/smd7
+
+ chmod 0444 /sys/devices/platform/msm_hsusb/gadget/usb_state
+
+ # Remove write permissions to video related nodes
+ chown system graphics /sys/class/graphics/fb1/hpd
+ chown system system /sys/class/graphics/fb1/hdcp/tp
+ chown system graphics /sys/class/graphics/fb1/vendor_name
+ chown system graphics /sys/class/graphics/fb1/product_description
+ chmod 0664 /sys/class/graphics/fb1/hpd
+ chmod 0664 /sys/class/graphics/fb1/hdcp/tp
+ chmod 0664 /sys/class/graphics/fb1/vendor_name
+ chmod 0664 /sys/class/graphics/fb1/product_description
+ chmod 0664 /sys/class/graphics/fb1/video_mode
+ chmod 0664 /sys/class/graphics/fb1/format_3d
+
+ # create symlink for fb1 as HDMI
+ symlink /dev/graphics/fb1 /dev/graphics/hdmi
+
+ # Change owner and group to get adopter/device ids from MHL driver
+ chown system system /sys/class/mhl/sii8334/adopter_id
+ chown system system /sys/class/mhl/sii8334/device_id
+
+ # Change permissions for fps_level nodes
+ chown system graphics /sys/class/graphics/fb0/msm_fb_fps_level
+ chown system graphics /sys/class/graphics/fb1/msm_fb_fps_level
+ chown system graphics /sys/class/graphics/fb2/msm_fb_fps_level
+ chmod 644 /sys/class/graphics/fb0/msm_fb_fps_level
+ chmod 400 /sys/class/graphics/fb1/msm_fb_fps_level
+ chmod 400 /sys/class/graphics/fb2/msm_fb_fps_level
+
+ # For bridgemgr daemon to inform the USB driver of the correct transport
+ chown radio radio /sys/class/android_usb/f_rmnet_smd_sdio/transport
+
+ chmod 660 /dev/rtc0
+ chown system system /dev/rtc0
+
+ chown root system /proc/net/ip_conntrack
+
+ # Enable DEBUG_SUSPEND, DEBUG_EXIT_SUSPEND, and DEBUG_WAKEUP
+ write /sys/module/wakelock/parameters/debug_mask 7
+
+ #To allow interfaces to get v6 address when tethering is enabled
+ write /proc/sys/net/ipv6/conf/rmnet0/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet1/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet2/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet3/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet4/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet5/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet6/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet7/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_sdio0/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_sdio1/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_sdio2/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_sdio3/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_sdio4/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_sdio5/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_sdio6/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_sdio7/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_usb0/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_usb1/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_usb2/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_usb3/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_usb0/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_usb1/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_usb2/accept_ra 2
+ write /proc/sys/net/ipv6/conf/rmnet_usb3/accept_ra 2
+
+ # To prevent out of order acknowledgements from making
+ # connection tracking to treat them as not belonging to
+ # the connection they belong to.
+ # Otherwise, a weird issue happens in which some long
+ # connections on high-throughput links get dropped when
+ # an ack packet comes out of order
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_be_liberal 1
+
+ # NFC local data and nfcee xml storage
+ mkdir /data/nfc 0770 nfc nfc
+ mkdir /data/nfc/param 0770 nfc nfc
+
+ # Set the console loglevel to < KERN_INFO
+ # Set the default message loglevel to KERN_INFO
+ write /proc/sys/kernel/printk "6 6 1 7"
+
+# QCOM Sensors
+ insmod /system/lib/modules/adsprpc.ko
+ mkdir /data/system 0775 system system
+ mkdir /data/system/sensors 0775 system system
+ mkdir /data/misc/sensors 0775 system system
+ write /data/system/sensors/settings 1
+ chmod 664 /data/system/sensors/settings
+ chown system /data/system/sensors/settings
+ start sensors
+
+ chown system /sys/devices/virtual/timed_output/vibrator/vtg_level
+
+on post-fs
+ exec /system/bin/chargemon
+ write /sys/class/power_supply/battery/enable_stop_charging_at_low_battery 1
+
+ # Change to socket location on libkeyctrl/suntory for /data encryption
+ mkdir /dev/socket/suntory 0755 system system
+
+# msm specific files that need to be created on /data
+on post-fs-data
+ mkdir /data/media 0770 media_rw media_rw
+
+ # Create the directories used by the Wireless subsystem
+ mkdir /data/misc/wifi 0770 wifi wifi
+ mkdir /data/misc/wifi/sockets 0770 wifi wifi
+ mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi
+ mkdir /data/misc/dhcp 0770 dhcp dhcp
+ # to observe dnsmasq.leases file for dhcp information of soft ap.
+ chown dhcp dhcp /data/misc/dhcp
+
+ # Update WIFI MAC address
+ mkdir /data/misc/wifi/prima 0775 wifi wifi
+ exec /system/bin/mac-update
+
+ mkdir /data/credmgr 0700 system system
+ mkdir /data/tombstones 0755 system system
+ mkdir /data/tombstones/vendor 0755 system system
+ mkdir /data/pc 0700 radio radio
+ mkdir /data/persist 0770 system system
+
+ # Create directory used by audio subsystem
+ mkdir /data/misc/audio 0770 audio audio
+
+ # IR Blaster
+ chown system system /dev/ttyHSL2
+ chmod 0660 /dev/ttyHSL2
+ chown system system /sys/devices/platform/ir_remote_control/enable
+ chmod 0220 /sys/devices/platform/ir_remote_control/enable
+
+ chmod 0664 /sys/devices/platform/msm_sdcc.1/polling
+ chmod 0664 /sys/devices/platform/msm_sdcc.2/polling
+ chmod 0664 /sys/devices/platform/msm_sdcc.3/polling
+ chmod 0664 /sys/devices/platform/msm_sdcc.4/polling
+
+ # Chown polling nodes as needed from UI running on system server
+ chown system system /sys/devices/platform/msm_sdcc.1/polling
+ chown system system /sys/devices/platform/msm_sdcc.2/polling
+ chown system system /sys/devices/platform/msm_sdcc.3/polling
+ chown system system /sys/devices/platform/msm_sdcc.4/polling
+
+ chown system system /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/pwrscale/policy
+
+ # Create directories for gpsone_daemon services
+ mkdir /data/misc/gpsone_d 0770 system gps
+
+ # Create directories for QuIPS
+ mkdir /data/misc/quipc 0770 gps system
+
+ # Create directories for Location services
+ mkdir /data/misc/location 0770 gps gps
+ mkdir /data/misc/location/mq 0770 gps gps
+ mkdir /data/misc/location/xtwifi 0770 gps gps
+
+ # Provide the access to hostapd.conf only to root and group
+ chmod 0660 /data/hostapd/hostapd.conf
+
+ mkdir /data/audio 0770 media audio
+
+ # Create /data/time folder for time-services
+ mkdir /data/time 0700 system system
+
+ # Enable Power save functionality for modem
+ setprop persist.radio.add_power_save 1
+
+ chown system /dev/block/platform/msm_sdcc.1/by-name
+
+ setprop vold.post_fs_data_done 1
+
+ rm /data/local/tmp/adreno_config.txt
+
+ # communicate with mpdecision and thermald
+ mkdir /dev/socket/mpdecision 0770 system system
+ chmod 2770 /dev/socket/mpdecision
+
+ # Enable Power modes and set the CPU Freq Sampling rates
+ write /sys/module/lpm_resources/enable_low_power/l2 1
+ write /sys/module/lpm_resources/enable_low_power/pxo 1
+ write /sys/module/lpm_resources/enable_low_power/vdd_dig 1
+ write /sys/module/lpm_resources/enable_low_power/vdd_mem 1
+ write /sys/module/msm_pm/modes/cpu0/retention/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu1/retention/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu2/retention/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu3/retention/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu0/power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu1/power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu2/power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu3/power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu1/power_collapse/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu2/power_collapse/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu3/power_collapse/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/idle_enabled 1
+ write /sys/module/msm_thermal/core_control/enabled 0
+ write /sys/devices/system/cpu/cpu1/online 1
+ write /sys/devices/system/cpu/cpu2/online 1
+ write /sys/devices/system/cpu/cpu3/online 1
+
+ # ondemand
+ #write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "ondemand"
+ #write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor "ondemand"
+ #write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor "ondemand"
+ #write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor "ondemand"
+ #write /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate 50000
+ #write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold 90
+ #write /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy 1
+ #write /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor 4
+ #write /sys/devices/system/cpu/cpufreq/ondemand/down_differential 10
+ #write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_multi_core 70
+ #write /sys/devices/system/cpu/cpufreq/ondemand/down_differential_multi_core 3
+ #write /sys/devices/system/cpu/cpufreq/ondemand/optimal_freq 918000
+ #write /sys/devices/system/cpu/cpufreq/ondemand/sync_freq 1026000
+ #write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_any_cpu_load 80
+ #chown system /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate
+ #chown system /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
+ #chown system /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy
+
+ # interactive
+ write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "interactive"
+ write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor "interactive"
+ write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor "interactive"
+ write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor "interactive"
+ write /sys/devices/system/cpu/cpufreq/interactive/io_is_busy 1
+ write /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay "20000 1400000:40000 1700000:20000"
+ write /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load 90
+ write /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq 1190400
+ write /sys/devices/system/cpu/cpufreq/interactive/target_loads "85 1500000:90 1800000:70"
+ write /sys/devices/system/cpu/cpufreq/interactive/min_sample_time 40000
+ write /sys/devices/system/cpu/cpufreq/interactive/sampling_down_factor 100000
+
+ write /sys/module/cpu_boost/parameters/boost_ms 20
+ write /sys/module/cpu_boost/parameters/sync_threshold 1728000
+ write /sys/module/cpu_boost/parameters/input_boost_freq 1497600
+ write /sys/module/cpu_boost/parameters/input_boost_ms 40
+
+ write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 300000
+ write /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq 300000
+ write /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq 300000
+ write /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq 300000
+ chown system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
+ chown system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
+ write /sys/module/msm_thermal/core_control/enabled 1
+ chown root system /sys/devices/system/cpu/mfreq
+ chmod 220 /sys/devices/system/cpu/mfreq
+ chown root system /sys/devices/system/cpu/cpu1/online
+ chown root system /sys/devices/system/cpu/cpu2/online
+ chown root system /sys/devices/system/cpu/cpu3/online
+ chmod 664 /sys/devices/system/cpu/cpu1/online
+ chmod 664 /sys/devices/system/cpu/cpu2/online
+ chmod 664 /sys/devices/system/cpu/cpu3/online
+ write /dev/cpuctl/apps/cpu.notify_on_migrate 1
+ # set DCVS parameters for CPU
+ write /sys/module/msm_dcvs/cores/cpu0/slack_time_max_us 40000
+ write /sys/module/msm_dcvs/cores/cpu0/slack_time_min_us 40000
+ write /sys/module/msm_dcvs/cores/cpu0/em_win_size_min_us 100000
+ write /sys/module/msm_dcvs/cores/cpu0/em_win_size_max_us 500000
+ write /sys/module/msm_dcvs/cores/cpu0/slack_mode_dynamic 0
+ write /sys/module/msm_dcvs/cores/cpu0/disable_pc_threshold 1000000
+ write /sys/module/msm_dcvs/cores/cpu1/slack_time_max_us 25000
+ write /sys/module/msm_dcvs/cores/cpu1/slack_time_min_us 25000
+ write /sys/module/msm_dcvs/cores/cpu1/em_win_size_min_us 100000
+ write /sys/module/msm_dcvs/cores/cpu1/em_win_size_max_us 500000
+ write /sys/module/msm_dcvs/cores/cpu1/slack_mode_dynamic 0
+ write /sys/module/msm_dcvs/cores/cpu1/disable_pc_threshold 1000000
+ write /sys/module/msm_dcvs/cores/cpu2/slack_time_max_us 25000
+ write /sys/module/msm_dcvs/cores/cpu2/slack_time_min_us 25000
+ write /sys/module/msm_dcvs/cores/cpu2/em_win_size_min_us 100000
+ write /sys/module/msm_dcvs/cores/cpu2/em_win_size_max_us 500000
+ write /sys/module/msm_dcvs/cores/cpu2/slack_mode_dynamic 0
+ write /sys/module/msm_dcvs/cores/cpu2/disable_pc_threshold 1000000
+ write /sys/module/msm_dcvs/cores/cpu3/slack_time_max_us 25000
+ write /sys/module/msm_dcvs/cores/cpu3/slack_time_min_us 25000
+ write /sys/module/msm_dcvs/cores/cpu3/em_win_size_min_us 100000
+ write /sys/module/msm_dcvs/cores/cpu3/em_win_size_max_us 500000
+ write /sys/module/msm_dcvs/cores/cpu3/slack_mode_dynamic 0
+ write /sys/module/msm_dcvs/cores/cpu3/disable_pc_threshold 1000000
+ # set DCVS parameters for GPU
+ write /sys/module/msm_dcvs/cores/gpu0/slack_time_max_us 20000
+ write /sys/module/msm_dcvs/cores/gpu0/slack_time_min_us 20000
+ write /sys/module/msm_dcvs/cores/gpu0/slack_mode_dynamic 0
+ # set msm_mpdecision parameters
+ write /sys/module/msm_mpdecision/slack_time_max_us 45000
+ write /sys/module/msm_mpdecision/slack_time_min_us 15000
+ write /sys/module/msm_mpdecision/em_win_size_min_us 100000
+ write /sys/module/msm_mpdecision/em_win_size_max_us 1000000
+ write /sys/module/msm_mpdecision/online_util_pct_min 3
+ write /sys/module/msm_mpdecision/online_util_pct_max 25
+ write /sys/module/msm_mpdecision/em_max_util_pct 97
+ write /sys/module/msm_mpdecision/rq_avg_poll_ms 2
+ write /sys/module/msm_mpdecision/mp_em_rounding_point_min 10
+ write /sys/module/msm_mpdecision/mp_em_rounding_point_max 85
+ write /sys/module/msm_mpdecision/iowait_threshold_pct 50
+ # set permissions for the nodes needed by display on/off hook
+ chown system /sys/module/msm_dcvs/cores/cpu0/slack_time_max_us
+ chown system /sys/module/msm_dcvs/cores/cpu0/slack_time_min_us
+ chown system /sys/module/msm_mpdecision/slack_time_max_us
+ chown system /sys/module/msm_mpdecision/slack_time_min_us
+ chmod 664 /sys/module/msm_dcvs/cores/cpu0/slack_time_max_us
+ chmod 664 /sys/module/msm_dcvs/cores/cpu0/slack_time_min_us
+ chmod 664 /sys/module/msm_mpdecision/slack_time_max_us
+ chmod 664 /sys/module/msm_mpdecision/slack_time_min_us
+
+ # SONY: Camera
+ mkdir /data/camera 0770 media camera
+ chown media camera /sys/devices/sony_camera_0/info
+ chmod 0770 /sys/devices/sony_camera_0/info
+ chown media camera /sys/devices/sony_camera_1/info
+ chmod 0770 /sys/devices/sony_camera_1/info
+
+on charger
+ # Enable Power modes and set the CPU Freq Sampling rates
+ write /sys/module/lpm_resources/enable_low_power/l2 1
+ write /sys/module/lpm_resources/enable_low_power/pxo 1
+ write /sys/module/lpm_resources/enable_low_power/vdd_dig 1
+ write /sys/module/lpm_resources/enable_low_power/vdd_mem 1
+ write /sys/module/msm_pm/modes/cpu0/retention/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu0/power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu1/power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu2/power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu3/power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/suspend_enabled 1
+ write /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/idle_enabled 1
+ write /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enabled 1
+ write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "powersave"
+ write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor "powersave"
+ write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor "powersave"
+ write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor "powersave"
+ write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 300000
+ write /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq 300000
+ write /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq 300000
+ write /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq 300000
+ write /sys/devices/system/cpu/cpu1/online 0
+ write /sys/devices/system/cpu/cpu2/online 0
+ write /sys/devices/system/cpu/cpu3/online 0
+
+on property:init.svc.wpa_supplicant=stopped
+ stop dhcpcd
+
+# Update WIFI MAC address
+service mac-update /system/bin/mac-update
+ class main
+ user wifi
+ oneshot
+
+service hciattach /system/bin/sh /system/etc/init.qcom.bt.sh
+ class late_start
+ user bluetooth
+ group qcom_oncrpc bluetooth net_bt_admin system net_bt_stack
+ disabled
+ oneshot
+
+on property:bluetooth.hciattach=true
+ start hciattach
+
+on property:bluetooth.hciattach=false
+ setprop bluetooth.status off
+
+# QMUX must be in multiple groups to support external process connections
+service qmuxd /system/bin/qmuxd
+ class main
+ user radio
+ group radio audio bluetooth gps qcom_diag net_bt_stack
+
+# SONY: TrimArea Daemon
+# Last 2 args: start block(blk size 128k), number of blocks(partitionsize(kb)/128(kb))
+service tad /sbin/tad_static /dev/block/mmcblk0 1,16
+ class core
+ user root
+ group root
+ socket tad stream 0660 system system
+ disabled
+
+service updatemiscta /system/bin/updatemiscta
+ class main
+ user root
+ oneshot
+
+service netmgrd /system/bin/netmgrd
+ class main
+
+# start GNS/Sensor interface daemon
+service gsiff_daemon /system/bin/gsiff_daemon
+ class late_start
+ user gps
+ group gps net_raw misc
+
+service qrngd /system/bin/qrngd -f
+ class main
+ user root
+ group root
+
+service qrngp /system/bin/qrngp
+ class main
+ user root
+ group root
+ oneshot
+ disabled
+
+on property:sys.boot_completed=1
+ start qrngp
+ write /sys/block/mmcblk0/bdi/read_ahead_kb 512
+
+service qseecomd /system/bin/qseecomd
+ class core
+ user root
+ group root
+
+service hw_config /system/bin/sh /system/etc/hw_config.sh
+ class main
+ user root
+ oneshot
+
+service wpa_supplicant /system/bin/wpa_supplicant \
+ -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
+ -I/system/etc/wifi/wpa_supplicant_overlay.conf \
+ -O/data/misc/wifi/sockets \
+ -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
+ # we will start as root and wpa_supplicant will switch to user wifi
+ # after setting up the capabilities required for WEXT
+ # user wifi
+ # group wifi inet keystore
+ class main
+ socket wpa_wlan0 dgram 660 wifi wifi
+ disabled
+ oneshot
+
+service p2p_supplicant /system/bin/wpa_supplicant \
+ -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \
+ -I/system/etc/wifi/p2p_supplicant_overlay.conf -N \
+ -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
+ -I/system/etc/wifi/wpa_supplicant_overlay.conf \
+ -O/data/misc/wifi/sockets -puse_p2p_group_interface=1 \
+ -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
+# we will start as root and wpa_supplicant will switch to user wifi
+# after setting up the capabilities required for WEXT
+# user wifi
+# group wifi inet keystore
+ class main
+ socket wpa_wlan0 dgram 660 wifi wifi
+ disabled
+ oneshot
+
+service dhcpcd_wlan0 /system/bin/dhcpcd -aABDKL
+ class main
+ disabled
+ oneshot
+
+service dhcpcd_p2p /system/bin/dhcpcd -aABKL
+ class main
+ disabled
+ oneshot
+
+service iprenew_wlan0 /system/bin/dhcpcd -n
+ class main
+ disabled
+ oneshot
+
+service iprenew_p2p /system/bin/dhcpcd -n
+ class main
+ disabled
+ oneshot
+
+service dhcpcd_bt-pan /system/bin/dhcpcd -BKLG
+ disabled
+ oneshot
+
+service iprenew_bt-pan /system/bin/dhcpcd -n
+ disabled
+ oneshot
+
+on property:ro.data.large_tcp_window_size=true
+ # Adjust socket buffer to enlarge TCP receive window for high bandwidth (e.g. DO-RevB)
+ write /proc/sys/net/ipv4/tcp_adv_win_scale 2
+
+# virtual sdcard daemon running as media_rw (1023)
+service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated
+ class late_start
+
+service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
+ class late_start
+ disabled
+
+service fuse_usbdisk /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/usbdisk /storage/usbdisk
+ class late_start
+ disabled
+
+service mpdecision /system/bin/mpdecision --avg_comp
+ class main
+ user root
+
+# Start suntrold
+service suntrold /system/bin/suntrold
+ user system
+ group system
+ oneshot
+ class main
+
+# bugreport is triggered by holding down volume down, volume up and power
+service bugreport /system/bin/dumpstate -d -p -B \
+ -o /data/data/com.android.shell/files/bugreports/bugreport
+ class main
+ disabled
+ oneshot
+ keycodes 114 115 116
+
+service fm_dl /system/bin/sh /system/etc/init.qcom.fm.sh
+ class late_start
+ user root
+ group system qcom_oncrpc
+ disabled
+ oneshot
+
+service illumination /system/bin/illumination_service
+ socket illumination stream 0660 system camera
+ class main
+ user root
+
+service scd /system/bin/scd
+ class main
+ user system
+ group system
+
+# Secure Config Transfer service
+service sct_service /system/bin/sct_service
+ user root
+ disabled
+
+# Trim Area QMI service
+service ta_qmi_service /system/bin/ta_qmi_service
+ user root
+ disabled
+
+# Start system_monitor
+service system_monitor /system/bin/system_monitor
+ socket sysmon stream 0660 root system
+ class core
+ user root
+
+service rmt_storage /system/bin/rmt_storage
+ class core
+ user root
+
+service irsc_util /system/bin/irsc_util "/etc/sec_config"
+ class main
+ user root
+ oneshot
+
+service ppd /system/bin/mm-pp-daemon
+ class late_start
+ user system
+ socket pps stream 0660 system system
+ group system graphics qcom_diag
+ disabled
+
+service qcamerasvr /system/bin/mm-qcamera-daemon
+ class late_start
+ user camera
+ group camera system inet input
+
+service sensors /system/bin/sensors.qcom
+ class main
+ user root
+ group root
+ disabled
+
+service wcnss-service /system/bin/wcnss_service
+ class late_start
+ user system
+ group system wifi
+ disabled
+ oneshot
+
+service time_daemon /system/bin/time_daemon
+ class late_start
+ user root
+ group root radio qcom_diag
+
+service ptt_socket_app /system/bin/ptt_socket_app
+ class main
+ user system
+ group system
+ oneshot
+
+on property:init.svc.surfaceflinger=running
+ start ppd
+
+on property:init.svc.surfaceflinger=stopped
+ stop ppd
+
+# Powersave
+on property:sys.perf.profile=0
+ start mpdecision
+ write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor conservative
+ write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor conservative
+ write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor conservative
+ write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor conservative
+ write /sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor ondemand
+
+# Balanced
+on property:sys.perf.profile=1
+ start mpdecision
+ write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor interactive
+ write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor interactive
+ write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor interactive
+ write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor interactive
+ write /sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor ondemand
+
+# High performance
+on property:sys.perf.profile=2
+ stop mpdecision
+ write /sys/devices/system/cpu/cpu0/online 1
+ write /sys/devices/system/cpu/cpu1/online 1
+ write /sys/devices/system/cpu/cpu2/online 1
+ write /sys/devices/system/cpu/cpu3/online 1
+ write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor performance
+ write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor performance
+ write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor performance
+ write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor performance
+ write /sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor performance
diff --git a/rootdir/init.recovery.qcom.rc b/rootdir/init.recovery.qcom.rc
new file mode 100644
index 0000000..e551aee
--- /dev/null
+++ b/rootdir/init.recovery.qcom.rc
@@ -0,0 +1,13 @@
+on init
+
+ write /sys/class/android_usb/android0/idVendor 0fce
+ write /sys/class/android_usb/android0/idProduct 6182
+
+service remap /sbin/remap.sh
+ oneshot
+ disabled
+
+# Remap boot and FOTA for lk if lk is present
+on property:ro.bootloader=lk
+ start remap
+ setprop lk.remap 1
diff --git a/rootdir/sbin/tad_static b/rootdir/sbin/tad_static
new file mode 100644
index 0000000..b30eb27
--- /dev/null
+++ b/rootdir/sbin/tad_static
Binary files differ
diff --git a/rootdir/sbin/wait4tad_static b/rootdir/sbin/wait4tad_static
new file mode 100644
index 0000000..5dc859e
--- /dev/null
+++ b/rootdir/sbin/wait4tad_static
Binary files differ
diff --git a/rootdir/system/etc/firmware/wlan/prima/WCNSS_cfg.dat b/rootdir/system/etc/firmware/wlan/prima/WCNSS_cfg.dat
new file mode 100644
index 0000000..5685e79
--- /dev/null
+++ b/rootdir/system/etc/firmware/wlan/prima/WCNSS_cfg.dat
Binary files differ
diff --git a/rootdir/system/etc/firmware/wlan/prima/WCNSS_qcom_cfg.ini b/rootdir/system/etc/firmware/wlan/prima/WCNSS_qcom_cfg.ini
new file mode 100644
index 0000000..9778686
--- /dev/null
+++ b/rootdir/system/etc/firmware/wlan/prima/WCNSS_qcom_cfg.ini
@@ -0,0 +1,371 @@
+# This file allows user to override the factory
+
+# defaults for the WLAN Driver
+
+
+# Enable IMPS or not
+gEnableImps=1
+
+# Enable/Disable Idle Scan
+
+gEnableIdleScan=0
+
+
+# Increase sleep duration (seconds) during IMPS
+# 0 implies no periodic wake up from IMPS. Periodic wakeup is
+# unnecessary if Idle Scan is disabled.
+gImpsModSleepTime=0
+
+
+# Enable BMPS or not
+gEnableBmps=1
+
+# Enable suspend or not
+
+# 1: Enable standby, 2: Enable Deep sleep, 3: Enable Mcast/Bcast Filter
+
+gEnableSuspend=3
+
+
+# Phy Mode (auto, b, g, n, etc)
+# Valid values are 0-9, with 0 = Auto, 4 = 11n, 9 = 11ac
+gDot11Mode=0
+
+
+# CSR Roaming Enable(1) Disable(0)
+
+gRoamingTime=0
+
+
+# Assigned MAC Addresses - This will be used until NV items are in place
+
+# Each byte of MAC address is represented in Hex format as XX
+
+Intf0MacAddress=000AF58989FF
+Intf1MacAddress=000AF58989FE
+Intf2MacAddress=000AF58989FD
+
+Intf3MacAddress=000AF58989FC
+
+
+# UAPSD service interval for VO,VI, BE, BK traffic
+
+InfraUapsdVoSrvIntv=0
+
+InfraUapsdViSrvIntv=0
+
+InfraUapsdBeSrvIntv=0
+
+InfraUapsdBkSrvIntv=0
+
+# Flag to allow STA send AddTspec even when ACM is Off
+gAddTSWhenACMIsOff=1
+
+# Make 1x1 the default antenna configuration
+
+gNumRxAnt=1
+
+
+# Beacon filtering frequency (unit in beacon intervals)
+
+gNthBeaconFilter=50
+
+
+# Enable WAPI or not
+
+# WAPIIsEnabled=0
+
+
+# Flags to filter Mcast abd Bcast RX packets.
+
+# Value 0: No filtering, 1: Filter all Multicast.
+
+# 2: Filter all Broadcast. 3: Filter all Mcast abd Bcast
+
+McastBcastFilter=3
+
+
+#Flag to enable HostARPOffload feature or not
+
+hostArpOffload=1
+
+
+#SoftAP Related Parameters
+
+# AP MAc addr
+
+gAPMacAddr=000AF589dcab
+
+
+# 802.11n Protection flag
+
+gEnableApProt=1
+
+
+#Enable OBSS protection
+
+gEnableApOBSSProt=1
+
+
+#Enable/Disable UAPSD for SoftAP
+
+gEnableApUapsd=0
+
+
+# Fixed Rate
+
+gFixedRate=0
+
+
+# Maximum Tx power
+
+# gTxPowerCap=30
+
+
+# Fragmentation Threshold
+
+# gFragmentationThreshold=2346
+
+
+# RTS threshold
+
+RTSThreshold=2347
+
+
+# Intra-BSS forward
+
+gDisableIntraBssFwd=0
+
+
+# WMM Enable/Disable
+
+WmmIsEnabled=0
+
+
+# 802.11d support
+
+g11dSupportEnabled=1
+
+# CCX Support and fast transition
+CcxEnabled=0
+FastTransitionEnabled=1
+ImplicitQosIsEnabled=0
+gNeighborScanTimerPeriod=200
+
+gNeighborLookupThreshold=78
+
+gNeighborScanChannelMinTime=20
+gNeighborScanChannelMaxTime=30
+
+# Legacy (non-CCX, non-802.11r) Fast Roaming Support
+# To enable, set FastRoamEnabled=1
+# To disable, set FastRoamEnabled=0
+FastRoamEnabled=1
+
+#Check if the AP to which we are roaming is better than current AP in terms of RSSI.
+#Checking is disabled if set to Zero.Otherwise it will use this value as to how better
+#the RSSI of the new/roamable AP should be for roaming
+RoamRssiDiff=5
+
+# SAP Country code
+
+# Default Country Code is 2 bytes, 3rd byte is optional indoor or out door.
+
+# Example
+
+# US Indoor, USI
+
+# Korea Outdoor, KRO
+
+# Japan without optional byte, JP
+
+# France without optional byte, FR
+
+#gAPCntryCode=USI
+
+
+#Short Guard Interval Enable/disable
+
+gShortGI20Mhz=1
+
+gShortGI40Mhz=1
+
+
+#Auto Shutdown Value in seconds. A value of 0 means Auto shutoff is disabled
+
+gAPAutoShutOff=0
+
+
+# SAP auto channel selection configuration
+
+# 0 = disable auto channel selection
+
+# 1 = enable auto channel selection, channel provided by supplicant will be ignored
+
+gApAutoChannelSelection=0
+
+
+# Listen Energy Detect Mode Configuration
+
+# Valid values 0-128
+
+# 128 means disable Energy Detect feature
+
+# 0-9 are threshold code and 7 is recommended value from system if feature is to be enabled.
+
+# 10-128 are reserved.
+
+# The EDET threshold mapping is as follows in 3dB step:
+
+# 0 = -60 dBm
+
+# 1 = -63 dBm
+
+# 2 = -66 dBm
+
+# ...
+
+# 7 = -81 dBm
+
+# 8 = -84 dBm
+
+# 9 = -87 dBm
+
+# Note: Any of these settings are valid. Setting 0 would yield the highest power saving (in a noisy environment) at the cost of more range. The range impact is approximately #calculated as:
+
+#
+
+# Range Loss (dB) = EDET threshold level (dBm) + 97 dBm.
+
+#
+
+gEnablePhyAgcListenMode=128
+
+
+#Preferred channel to start BT AMP AP mode (0 means, any channel)
+
+BtAmpPreferredChannel=0
+
+
+#Preferred band (both or 2.4 only or 5 only)
+
+BandCapability=0
+
+
+#Beacon Early Termination (1 = enable the BET feature, 0 = disable)
+
+enableBeaconEarlyTermination=1
+
+beaconEarlyTerminationWakeInterval=11
+
+
+#Bluetooth Alternate Mac Phy (1 = enable the BT AMP feature, 0 = disable)
+
+gEnableBtAmp=0
+
+
+#SOFTAP Channel Range selection
+
+gAPChannelSelectStartChannel=1
+
+gAPChannelSelectEndChannel=11
+
+
+#SOFTAP Channel Range selection Operating band
+
+# 0:2.4GHZ 1: LOW-5GHZ 2:MID-5GHZ 3:HIGH-5GHZ 4: 4.9HZ BAND
+
+gAPChannelSelectOperatingBand=0
+
+
+#Channel Bonding
+gChannelBondingMode5GHz=1
+
+
+#Enable Keep alive with non-zero period value
+
+gStaKeepAlivePeriod=30
+
+
+#Say gGoKeepAlivePeriod(5 seconds) and gGoLinkMonitorPeriod(10 seconds).
+#For every 10 seconds DUT sends Qos Null frame(i.e., Keep Alive frame if link is idle for last 10 seconds.)
+#For both active and power save clients.
+
+#Power save clients: DUT set TIM bit from 10th second onwards and till client honors TIM bit.
+#If doesn't honor for 5 seconds then Driver remove client.
+
+#Active clients: DUT send Qos Null frame for 10th seconds onwards if it is not success still DUT try on
+#11th second if not tries on 12th and so on till 15th second. Hence before disconnection DUT will send 5 NULL frames.
+#Hence in any case DUT will detect client got removed in (10+5) seconds. i.e., (gGoKeepAlivePeriod +gGoLinkMonitorPeriod)..
+
+#gGoLinkMonitorPeriod/ gApLinkMonitorPeriod is period where link is idle and it is period
+#where we send NULL frame.
+
+#gApLinkMonitorPeriod = 10
+
+#gGoLinkMonitorPeriod = 10
+
+#gGoKeepAlivePeriod/gApKeepAlivePeriod is time to spend to check whether frame are succeed to send or not.
+#Hence total effective detection time is gGoLinkMonitorPeriod+ gGoKeepAlivePeriod/gApLinkMonitorPeriod+ gApKeepAlivePeriod.
+#gGoKeepAlivePeriod = 5
+
+#gApKeepAlivePeriod = 5
+#If set will start with active scan after driver load, otherwise will start with
+
+#passive scan to find out the domain
+
+#gEnableBypass11d=1
+
+
+#If set to 0, will not scan DFS channels
+
+gEnableDFSChnlScan=1
+
+
+gVhtChannelWidth=2
+gEnableLogp=1
+
+
+# Enable Automatic Tx Power control
+
+gEnableAutomaticTxPowerControl=1
+
+# 0 for OLPC 1 for CLPC and SCPC
+gEnableCloseLoop=1
+
+#Data Inactivity Timeout when in powersave (in ms)
+gDataInactivityTimeout=200
+
+# VHT Tx/Rx MCS values
+# Valid values are 0,1,2. If commented out, the default value is 0.
+# 0=MCS0-7, 1=MCS0-8, 2=MCS0-9
+gVhtRxMCS=2
+gVhtTxMCS=2
+
+gEnableLpwrImgTransition=1
+
+# Enable Tx beamforming
+gTxBFEnable=1
+
+# Enable Tx LDPC
+#gTxLdpcEnable = 1 for HT mode, 2 for VHT mode,3 for both HT and VHT
+gTxLdpcEnable=3
+
+#FlexConnect Power Factor
+#Default is set to 0 (disable)
+gFlexConnectPowerFactor=0
+
+# Valid values are 2048,4096,8192 and so on
+# Please don't use values other than the ones mentioned above
+gMaxMediumTime=4096
+
+# 802.11K support
+gRrmEnable=1
+gRrmOperChanMax=8
+gRrmNonOperChanMax=8
+gRrmRandIntvl=100
+
+END
+
+# Note: Configuration parser would not read anything past the END marker
+
diff --git a/rootdir/system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin b/rootdir/system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin
new file mode 100644
index 0000000..a8dd301
--- /dev/null
+++ b/rootdir/system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin
Binary files differ
diff --git a/rootdir/system/etc/gps.conf b/rootdir/system/etc/gps.conf
new file mode 100644
index 0000000..c07638e
--- /dev/null
+++ b/rootdir/system/etc/gps.conf
@@ -0,0 +1,75 @@
+XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra2.bin
+XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra2.bin
+XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra2.bin
+
+# Error Estimate
+# _SET = 1
+# _CLEAR = 0
+ERR_ESTIMATE=0
+
+#Test
+NTP_SERVER=time.gpsonextra.net
+#Asia
+# NTP_SERVER=asia.pool.ntp.org
+#Europe
+# NTP_SERVER=europe.pool.ntp.org
+#North America
+# NTP_SERVER=north-america.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 = 3
+
+# Intermediate position report, 1=enable, 0=disable
+INTERMEDIATE_POS=0
+
+# supl version 2.0
+SUPL_VER=0x20000
+
+# GPS Capabilities bit mask
+# SCHEDULING = 0x01
+# MSB = 0x02
+# MSA = 0x04
+# ON_DEMAND_TIME = 0x10
+# default = ON_DEMAND_TIME | MSA | MSB | SCHEDULING
+CAPABILITIES=0x3
+
+# 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
+
+####################################
+# 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
+
+################################
+# EXTRA SETTINGS
+################################
+# NMEA provider (1=Modem Processor, 0=Application Processor)
+NMEA_PROVIDER=1
+
+##################################################
+# Select Positioning Protocol on A-GLONASS system
+##################################################
+# 0x1: RRC CPlane
+# 0x2: RRLP UPlane
+# 0x4: LLP Uplane
+A_GLONASS_POS_PROTOCOL_SELECT = 0
diff --git a/rootdir/system/etc/init.qcom.bt.sh b/rootdir/system/etc/init.qcom.bt.sh
new file mode 100644
index 0000000..84820fb
--- /dev/null
+++ b/rootdir/system/etc/init.qcom.bt.sh
@@ -0,0 +1,83 @@
+#!/system/bin/sh
+
+BLUETOOTH_SLEEP_PATH=/proc/bluetooth/sleep/proto
+LOG_TAG="sony-bluetooth"
+LOG_NAME="${0}:"
+
+loge ()
+{
+ /system/bin/log -t $LOG_TAG -p e "$LOG_NAME $@"
+}
+
+logi ()
+{
+ /system/bin/log -t $LOG_TAG -p i "$LOG_NAME $@"
+}
+
+failed ()
+{
+ loge "$1: exit code $2"
+ exit $2
+}
+
+# Note that "hci_qcomm_init -e" prints expressions to set the shell variables
+# BTS_DEVICE, BTS_TYPE, BTS_BAUD, and BTS_ADDRESS.
+
+# BR/EDR & LE power class configurations
+POWER_CLASS=`getprop qcom.bt.dev_power_class`
+LE_POWER_CLASS=`getprop qcom.bt.le_dev_pwr_class`
+
+#find the transport type
+TRANSPORT=`getprop ro.qualcomm.bt.hci_transport`
+logi "Transport : $TRANSPORT"
+
+#load bd addr
+BDADDR=`/system/bin/cat /data/etc/bluetooth_bdaddr`
+
+setprop bluetooth.status off
+
+logi "BDADDR: $BDADDR"
+
+case $POWER_CLASS in
+ 1) PWR_CLASS="-p 0" ;
+ logi "Power Class: 1";;
+ 2) PWR_CLASS="-p 1" ;
+ logi "Power Class: 2";;
+ 3) PWR_CLASS="-p 2" ;
+ logi "Power Class: CUSTOM";;
+ *) PWR_CLASS="";
+ logi "Power Class: Ignored. Default(1) used (1-CLASS1/2-CLASS2/3-CUSTOM)";
+ logi "Power Class: To override, Before turning BT ON; setprop qcom.bt.dev_power_class <1 or 2 or 3>";;
+esac
+
+case $LE_POWER_CLASS in
+ 1) LE_PWR_CLASS="-P 0" ;
+ logi "LE Power Class: 1";;
+ 2) LE_PWR_CLASS="-P 1" ;
+ logi "LE Power Class: 2";;
+ 3) LE_PWR_CLASS="-P 2" ;
+ logi "LE Power Class: CUSTOM";;
+ *) LE_PWR_CLASS="-P 1";
+ logi "LE Power Class: Ignored. Default(2) used (1-CLASS1/2-CLASS2/3-CUSTOM)";
+ logi "LE Power Class: To override, Before turning BT ON; setprop qcom.bt.le_dev_pwr_class <1 or 2 or 3>";;
+esac
+
+if [ -z "$BDADDR" ]
+then
+ logwrapper /system/bin/hci_qcomm_init -e $PWR_CLASS $LE_PWR_CLASS -vv
+else
+ logwrapper /system/bin/hci_qcomm_init -b $BDADDR -e $PWR_CLASS $LE_PWR_CLASS -vv
+fi
+
+case $? in
+ 0) logi "Bluetooth QSoC firmware download succeeded, $PWR_CLASS $BDADDR $TRANSPORT";;
+ *) failed "Bluetooth QSoC firmware download failed" $?;
+ setprop bluetooth.status off;
+ exit $?;;
+esac
+
+setprop bluetooth.status on
+
+logi "start bluetooth smd transport"
+
+exit 0
diff --git a/rootdir/system/etc/init.qcom.fm.sh b/rootdir/system/etc/init.qcom.fm.sh
new file mode 100644
index 0000000..adc7004
--- /dev/null
+++ b/rootdir/system/etc/init.qcom.fm.sh
@@ -0,0 +1,106 @@
+#!/system/bin/sh
+# Copyright (c) 2009-2011, Code Aurora Forum. 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 Code Aurora 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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.
+#
+
+setprop hw.fm.init 0
+
+mode=`getprop hw.fm.mode`
+version=`getprop hw.fm.version`
+isAnalog=`getprop hw.fm.isAnalog`
+
+#find the transport type
+TRANSPORT=`getprop ro.qualcomm.bt.hci_transport`
+
+LOG_TAG="qcom-fm"
+LOG_NAME="${0}:"
+
+loge ()
+{
+ /system/bin/log -t $LOG_TAG -p e "$LOG_NAME $@"
+}
+
+logi ()
+{
+ /system/bin/log -t $LOG_TAG -p i "$LOG_NAME $@"
+}
+
+failed ()
+{
+ loge "$1: exit code $2"
+ exit $2
+}
+
+logi "In FM shell Script"
+logi "mode: $mode"
+logi "isAnalog: $isAnalog"
+logi "Transport : $TRANSPORT"
+logi "Version : $version"
+
+#$fm_qsoc_patches <fm_chipVersion> <enable/disable WCM>
+#
+case $mode in
+ "normal")
+ case $TRANSPORT in
+ "smd")
+ logi "inserting the radio transport module"
+ insmod /system/lib/modules/radio-iris-transport.ko
+ ;;
+ *)
+ logi "default transport case "
+ ;;
+ esac
+ /system/bin/fm_qsoc_patches $version 0
+ ;;
+ "wa_enable")
+ /system/bin/fm_qsoc_patches $version 1
+ ;;
+ "wa_disable")
+ /system/bin/fm_qsoc_patches $version 2
+ ;;
+ "config_dac")
+ /system/bin/fm_qsoc_patches $version 3 $isAnalog
+ ;;
+ *)
+ logi "Shell: Default case"
+ /system/bin/fm_qsoc_patches $version 0
+ ;;
+esac
+
+exit_code_fm_qsoc_patches=$?
+
+case $exit_code_fm_qsoc_patches in
+ 0)
+ logi "FM QSoC calibration and firmware download succeeded"
+ ;;
+ *)
+ failed "FM QSoC firmware download and/or calibration failed" $exit_code_fm_qsoc_patches
+ ;;
+esac
+
+setprop hw.fm.init 1
+
+exit 0
diff --git a/rootdir/system/etc/init.qcom.wifi.sh b/rootdir/system/etc/init.qcom.wifi.sh
new file mode 100644
index 0000000..ea83027
--- /dev/null
+++ b/rootdir/system/etc/init.qcom.wifi.sh
@@ -0,0 +1,16 @@
+#!/system/bin/sh
+
+if [ -e /data/misc/wifi/WCNSS_qcom_wlan_cal.bin ]; then
+ calparm=`ls /sys/module/wcnsscore/parameters/has_calibrated_data`
+ if [ -e $calparm ] && [ ! -e /data/misc/wifi/WCN_FACTORY ]; then
+ echo 1 > $calparm
+ fi
+fi
+
+# There is a device file. Write to the file
+# so that the driver knows userspace is
+# available for firmware download requests
+echo 1 > /dev/wcnss_wlan
+echo $serialno > /sys/devices/fb000000.qcom,wcnss-wlan/serial_number
+
+exit 0
diff --git a/rootdir/system/etc/nfcee_access.xml b/rootdir/system/etc/nfcee_access.xml
new file mode 100644
index 0000000..cabad5f
--- /dev/null
+++ b/rootdir/system/etc/nfcee_access.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Applications granted NFCEE access on user builds
+
+ See packages/apps/Nfc/etc/sample_nfcee_access.xml for full documentation.
+ -->
+
+ <!-- Google wallet release signature -->
+ <signer android:signature="3082044c30820334a003020102020900a8cd17c93da5d990300d06092a864886f70d01010505003077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643301e170d3131303332343031303635335a170d3338303830393031303635335a3077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e464330820120300d06092a864886f70d01010105000382010d00308201080282010100c30f88add9b492096a2c586a5a9a80356bfa026958f8ff0c5dfaf59f49268ad870dee821a53e1f5b170fc96245a3c982a7cb4527053be35e34f396d24b2291ec0c528d6e26927465e06875ea621f7ff98c40e3345b204907cc9354743acdaace65565f48ba74cd4121cdc876df3522badb095c20d934c56a3e5c393ee5f0e02f8fe0621f918d1f35a82489252c6fa6b63392a7686b3e48612d06a9cf6f49bff11d5d96289c9dfe14ac5762439697dd29eafdb9810de3263513a905ac8e8eaf20907e46750a5ab7bf9a77262f47b03f5a3c6e6d7b51343f69c7f725f70bcc1b4ad592250b705a86e6e83ee2ae37fe5701bcbdb26feefdfff60f6a5bdfb5b64793020103a381dc3081d9301d0603551d0e041604141ccece0eea4dc1121fc7515f0d0a0c72e08cc96d3081a90603551d230481a130819e80141ccece0eea4dc1121fc7515f0d0a0c72e08cc96da17ba4793077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643820900a8cd17c93da5d990300c0603551d13040530030101ff300d06092a864886f70d01010505000382010100a470c728e1d31b06d9af6ae768b565046c57806b9843724931d75d4ca10c321520d33ccfed2aa65462234c9ef9b6f910cc676b99cb7f9895d6c06763574fbb78331275dc5cf38fbaa918d7938c051ffba2ade8f303cde8d9e68a048d1fdb9e7c9f2a49b222c68fff422bf15569b85eeeedb04aa30873dbe64b9c9e74f8f2c2f6c40124aaa8d1780d18512b540add28b3e9581971a4170dd868cf5f31e44712b2c23bb51037d7ef9f87a6e5bdb35e2ceb6bb022636c17a56a96bc7a50258c0bd2ed7b31555a18452e17321a0d52838c82f63f742d74ff79586a5cbb7faf7198a84bcf744310e9e927597f00a23dd00660800c2238d90b2fb372dfdbba75bd852e" />
+
+ <!-- SoMC platform signature -->
+ <signer android:signature="3082038e30820276a003020102020103300d06092a864886f70d01010505003065310b3009060355040613025345312f302d060355040a1326536f6e79204572696373736f6e204d6f62696c6520436f6d6d756e69636174696f6e73204142312530230603550403141c536f6e795f4572696373736f6e5f455f43415f546573745f64633730301e170d3030303130313130353830385a170d3335303130313130353830385a3073310b3009060355040613025345312f302d060355040a1326536f6e79204572696373736f6e204d6f62696c6520436f6d6d756e69636174696f6e73204142313330310603550403142a536f6e795f4572696373736f6e5f455f506c6174666f726d5f5369676e696e675f546573745f6463373030820122300d06092a864886f70d01010105000382010f003082010a0282010100c2380e6c1f5e1e45f35a95d16da7aeb6ff0514fe60bc970dbcca245885462259ae3b27a2d61d2f377f6888c87cac7406a0dd36d7ea40f009394fdc2cc42a03f2757531b544a34314ec6c43b6a676f45f96f24f99911e197135ca7dd7ea20e660a9a4f978f434097cba0b7afa1d80e8ae0358a24d9475c98649001ffa659838a57824c6f97c5efd46f6b7decb22d98e2ef19c7d15046e0b6ce5a4b539d0d8d9fe0a1dce8a82e3a56780173f02a99d7d647b0844a9a8df0b80c7fd76a112b5ef4e247b69e89a583664fa6c0ab68d0d087ec01978a554cb72a67c9961744ac4ec605eac92d0fb101497c8ca5c5057f309af5873552d0a3370526223b2efe4004e770203010001a33b3039300f0603551d130101ff04053003020100300e0603551d0f0101ff04040302078030160603551d250101ff040c300a06082b06010505070303300d06092a864886f70d01010505000382010100878daf0080da97a4b7f362c7db516ba8103858eaaeeb4ac2e08e6e6ce7defd257a0058155d5ce1d86907e2837132098d1ed3f2538ae775cee9a2eb411228bb071247614c2cacabcef590245edce4cdf538b76a0ba351b9d69cd87765a0bf0e851205e487bce3481843915acc57467f4ba8e662ae885c662c239757855bb1621513fbbd9849f5355fd6083c9c1953967495b9e7ad97981824168377840fd78cd510b19e5dcd36ca066ab24aaf9774ea084f4245a9c84b1ba21cd17b4de520a7432c24af8f0d8a4c0fe2396469fe7a77d6995875cd97959b247a2a07a789abdf9deea13a2f8db649e84677e454019ef558dd051cbfa5cf21ee5882576b4f9269cf" />
+
+</resources>
diff --git a/rootdir/system/etc/nfcee_access_debug.xml b/rootdir/system/etc/nfcee_access_debug.xml
new file mode 100644
index 0000000..a96a2d1
--- /dev/null
+++ b/rootdir/system/etc/nfcee_access_debug.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Applications granted NFCEE access on userdebug/eng builds
+
+ See packages/apps/Nfc/etc/sample_nfcee_access.xml for full documentation.
+ -->
+
+ <!-- Google Wallet dev signature -->
+ <signer android:signature="3082044c30820334a003020102020900de7695041d7650c0300d06092a864886f70d01010505003077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643301e170d3131303332343031303332345a170d3338303830393031303332345a3077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e464330820120300d06092a864886f70d01010105000382010d00308201080282010100e6ff3defe92aa10d71eb0fa6408bc036b7e243eeed68a6a4763dc7a52a31757cdac61fe510bb73c716e4000104265b347fcecef4c42bf1e1379dd0a876f028227fbbc1f9bdd5d713b2f6a935a379d2cba9c96f92d2d0787c11f1eb19548008a6a072b34b91836cfa0ae1276780e9007530166986a11c9cef46cef7c704806dde9431fb60284d120ab0e7de1d633f07687d468c51139afffdc6bc9a207ca904b8be1da0aa7b4e97756f43606488be5cae3c68e8bb7942cdf51607c930a2fcda655b75d0759cba89ad06e739bd0ba29b1f404296c2c0a85a847f5ab0d067c6c3ec9c49212042ac63a7e53b546c65b46080b4e3e680e23e1f77cfe7f6de744b1a65020103a381dc3081d9301d0603551d0e04160414a2e89064b05d08865c34db930a9d840050117aec3081a90603551d230481a130819e8014a2e89064b05d08865c34db930a9d840050117aeca17ba4793077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643820900de7695041d7650c0300c0603551d13040530030101ff300d06092a864886f70d010105050003820101003771870ce87c3c52ea84899230c6e962d94b4d5f1293c25d88261541fd90b5555d1285cef3b8312c3f5df691a8aae04cb981b305e427fd1d2d9e1987e1d29078f13c8452990f1821980263d8d4bd36519348d8d8ba26d8b99fbf09f5fd3ebb0ea3c2f0c9376f1e1fca76f3a6a405429d081b752a7a90b756e9ab44da41abc8e1e8f88ac2758da743fb73e650719a57840ccb6b7add21b99fc681e456e1872c223d5c074adf55f6abda268c2d8b64ea0a8845eecd968f92b493127e75c753c3ff30cbc678b51c9f52961472f17da20a0dc6274aa2463434c1a9b614df697d8ff5ca8101e7a25c7db3fb055d65569c04b01d389cabba57b3a1703ec2e74a88d334" />
+
+ <!-- Google wallet release signature -->
+ <signer android:signature="3082044c30820334a003020102020900a8cd17c93da5d990300d06092a864886f70d01010505003077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643301e170d3131303332343031303635335a170d3338303830393031303635335a3077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e464330820120300d06092a864886f70d01010105000382010d00308201080282010100c30f88add9b492096a2c586a5a9a80356bfa026958f8ff0c5dfaf59f49268ad870dee821a53e1f5b170fc96245a3c982a7cb4527053be35e34f396d24b2291ec0c528d6e26927465e06875ea621f7ff98c40e3345b204907cc9354743acdaace65565f48ba74cd4121cdc876df3522badb095c20d934c56a3e5c393ee5f0e02f8fe0621f918d1f35a82489252c6fa6b63392a7686b3e48612d06a9cf6f49bff11d5d96289c9dfe14ac5762439697dd29eafdb9810de3263513a905ac8e8eaf20907e46750a5ab7bf9a77262f47b03f5a3c6e6d7b51343f69c7f725f70bcc1b4ad592250b705a86e6e83ee2ae37fe5701bcbdb26feefdfff60f6a5bdfb5b64793020103a381dc3081d9301d0603551d0e041604141ccece0eea4dc1121fc7515f0d0a0c72e08cc96d3081a90603551d230481a130819e80141ccece0eea4dc1121fc7515f0d0a0c72e08cc96da17ba4793077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643820900a8cd17c93da5d990300c0603551d13040530030101ff300d06092a864886f70d01010505000382010100a470c728e1d31b06d9af6ae768b565046c57806b9843724931d75d4ca10c321520d33ccfed2aa65462234c9ef9b6f910cc676b99cb7f9895d6c06763574fbb78331275dc5cf38fbaa918d7938c051ffba2ade8f303cde8d9e68a048d1fdb9e7c9f2a49b222c68fff422bf15569b85eeeedb04aa30873dbe64b9c9e74f8f2c2f6c40124aaa8d1780d18512b540add28b3e9581971a4170dd868cf5f31e44712b2c23bb51037d7ef9f87a6e5bdb35e2ceb6bb022636c17a56a96bc7a50258c0bd2ed7b31555a18452e17321a0d52838c82f63f742d74ff79586a5cbb7faf7198a84bcf744310e9e927597f00a23dd00660800c2238d90b2fb372dfdbba75bd852e" />
+
+ <!-- Platform dev-keys signature -->
+ <signer android:signature="308204a830820390a003020102020900bcdfe81405d5c69e300d06092a864886f70d0101050500308194310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e20566965773110300e060355040a1307416e64726f69643110300e060355040b1307416e64726f69643110300e06035504031307416e64726f69643122302006092a864886f70d0109011613616e64726f696440616e64726f69642e636f6d301e170d3131303931393230303634325a170d3339303230343230303634325a308194310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e20566965773110300e060355040a1307416e64726f69643110300e060355040b1307416e64726f69643110300e06035504031307416e64726f69643122302006092a864886f70d0109011613616e64726f696440616e64726f69642e636f6d30820120300d06092a864886f70d01010105000382010d00308201080282010100ef7a8a34d8151d0479a239903261fe5026c520d5d88cd65920c98e096d2770f49636da9ffc4e80c472b05bd62a435f8266912aa2a34a18f6f4856f9ef52c10b88c267627136726823e8f3389b051ba92920e10bbaae0e38879efbe681b05863b655d81a6f3b75a85eb230b38b23ea4ef56f2161ff01652ae2049881adbe60d3bf8b5386a81f7404c0cf0c111c0a35ab0a9760426e4af12add73327ec433e047e3517f47a2d3674c2b819354d56eb7fd6c9aa67dd05b4bb1ca8a7e1946c2494e9364ea677a25481ac81f434bff3dd56e93e59fccef0e24a753461cd1cf15f22b62251d07416057ac5ca3e03a24f7f4eca876bacc5a1828acbde04c5cfdb608c47020103a381fc3081f9301d0603551d0e0416041402f997668541fa74693bea699a5766893a362a5d3081c90603551d230481c13081be801402f997668541fa74693bea699a5766893a362a5da1819aa48197308194310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e20566965773110300e060355040a1307416e64726f69643110300e060355040b1307416e64726f69643110300e06035504031307416e64726f69643122302006092a864886f70d0109011613616e64726f696440616e64726f69642e636f6d820900bcdfe81405d5c69e300c0603551d13040530030101ff300d06092a864886f70d0101050500038201010047d6fb32cadeae4444c379b3441ff9ba10990c23d10472c54fb7ebd9c33b2a173836337e1c175c980847a8894f6a99782e9c2e2133629254295fe52749f93ec1e39d213dd06d0ba99de3b6b5d4d856fafe74e08113b7b23a1b56f4918ed41218a03b9564456480b665200267d3770a9463db413c6a47bd81d725cb7d39c9d0941693c59cbe727d40415f0815c3c8363fb8fa2e028ceeb3bbfbc6b119db5b72f0edb0bb417bfcbf74d9fa069de22afe56a50bcde7ea1078749bb9ec0adc0e6de045641ee3a82c576645160b4ab9710d3cb3201f23957da8de9084c0bec93ad1c8c2054195f13c926db07c8bdf15673acf6d791ec1d3a0d7e1b3470447acd95873" />
+
+</resources>
diff --git a/rootdir/system/etc/wifi/p2p_supplicant_overlay.conf b/rootdir/system/etc/wifi/p2p_supplicant_overlay.conf
new file mode 100644
index 0000000..acbace2
--- /dev/null
+++ b/rootdir/system/etc/wifi/p2p_supplicant_overlay.conf
@@ -0,0 +1 @@
+disable_scan_offload=1
diff --git a/rootdir/system/etc/wifi/wpa_supplicant_overlay.conf b/rootdir/system/etc/wifi/wpa_supplicant_overlay.conf
new file mode 100644
index 0000000..acbace2
--- /dev/null
+++ b/rootdir/system/etc/wifi/wpa_supplicant_overlay.conf
@@ -0,0 +1 @@
+disable_scan_offload=1
diff --git a/rootdir/system/lib/egl/egl.cfg b/rootdir/system/lib/egl/egl.cfg
new file mode 100644
index 0000000..2a11ba2
--- /dev/null
+++ b/rootdir/system/lib/egl/egl.cfg
@@ -0,0 +1,2 @@
+0 0 android
+0 1 adreno
diff --git a/rootdir/ueventd.qcom.rc b/rootdir/ueventd.qcom.rc
new file mode 100644
index 0000000..d765272
--- /dev/null
+++ b/rootdir/ueventd.qcom.rc
@@ -0,0 +1,158 @@
+/dev/gemini0 0660 system camera
+/dev/jpeg0 0660 system camera
+/dev/jpeg1 0660 system camera
+/dev/jpeg2 0660 system camera
+/dev/genlock 0666 system system
+/dev/hw_random 0660 system system
+/dev/ion 0664 system system
+/dev/kgsl 0666 system system
+/dev/kgsl-3d0 0666 system system
+/dev/kgsl-2d0 0666 root root
+/dev/kgsl-2d1 0666 root root
+/dev/mdm 0660 system radio
+/dev/media* 0660 system camera
+/dev/mercury0 0660 system camera
+/dev/mpu 0600 system system
+/dev/mpuirq 0600 system system
+/dev/msm_camera/* 0660 system camera
+/dev/msm_rotator 0660 system system
+/dev/msm_vidc_reg 0660 system audio
+/dev/msm_vidc_dec 0660 system audio
+/dev/msm_vidc_dec_sec 0660 system audio
+/dev/msm_vidc_enc 0660 system audio
+/dev/msm_vidc_enc_sec 0660 system audio
+/dev/msm_vpe_standalone 0660 system camera
+/dev/pn544 0600 nfc nfc
+/dev/qseecom 0660 system drmrpc
+/dev/rfcomm0 0660 bluetooth bluetooth
+/dev/rmnet_mux_ctrl 0640 radio radio
+/dev/rtc0 0600 system system
+/dev/smd0 0660 system system
+/dev/smd2 0660 bluetooth net_bt_stack
+/dev/smd3 0660 bluetooth net_bt_stack
+/dev/smd4 0660 system system
+/dev/smd5 0660 system system
+/dev/smd6 0660 system system
+/dev/smd7 0660 bluetooth bluetooth
+/dev/smd11 0660 radio radio
+/dev/smd_cxm_qmi 0640 radio radio
+/dev/smdcntl0 0640 radio radio
+/dev/smdcntl1 0640 radio radio
+/dev/smdcntl2 0640 radio radio
+/dev/smdcntl3 0640 radio radio
+/dev/smdcntl4 0640 radio radio
+/dev/smdcntl5 0640 radio radio
+/dev/smdcntl6 0640 radio radio
+/dev/smdcntl7 0640 radio radio
+/dev/smdcntl8 0640 radio radio
+/dev/smdcntl9 0640 radio radio
+/dev/smdcntl10 0640 radio radio
+/dev/smdcntl11 0640 radio radio
+/dev/smdcnt_rev0 0640 radio radio
+/dev/smdcnt_rev1 0640 radio radio
+/dev/smdcnt_rev2 0640 radio radio
+/dev/smdcnt_rev3 0640 radio radio
+/dev/smdcnt_rev4 0640 radio radio
+/dev/smdcnt_rev5 0640 radio radio
+/dev/smdcnt_rev6 0640 radio radio
+/dev/smdcnt_rev7 0640 radio radio
+/dev/smdcnt_rev8 0640 radio radio
+/dev/smuxctl32 0640 radio radio
+/dev/sdioctl0 0640 radio radio
+/dev/sdioctl1 0640 radio radio
+/dev/sdioctl2 0640 radio radio
+/dev/sdioctl3 0640 radio radio
+/dev/sdioctl4 0640 radio radio
+/dev/sdioctl5 0640 radio radio
+/dev/sdioctl6 0640 radio radio
+/dev/sdioctl7 0640 radio radio
+/dev/sdioctl8 0640 radio radio
+/dev/hsicctl0 0640 radio radio
+/dev/hsicctl1 0640 radio radio
+/dev/hsicctl2 0640 radio radio
+/dev/hsicctl3 0640 radio radio
+/dev/hsicctl4 0640 radio radio
+/dev/hsicctl5 0640 radio radio
+/dev/hsicctl6 0640 radio radio
+/dev/hsicctl7 0640 radio radio
+/dev/hsicctl8 0640 radio radio
+/dev/hsicctl9 0640 radio radio
+/dev/hsicctl10 0640 radio radio
+/dev/hsicctl11 0640 radio radio
+/dev/hsicctl12 0640 radio radio
+/dev/hsicctl13 0640 radio radio
+/dev/hsicctl14 0640 radio radio
+/dev/hsicctl15 0640 radio radio
+/dev/hsicctl16 0640 radio radio
+/dev/diag 0660 radio qcom_diag
+/dev/v4l-subdev* 0660 system camera
+/dev/video* 0660 system camera
+/dev/ttyHSL1 0660 system system
+/dev/radio0 0640 system system
+/dev/gss 0660 gps gps
+/dev/rfkill 0660 wifi wifi
+/sys/devices/virtual/smdpkt/smdcntl* open_timeout 0664 radio radio
+
+# permissions for audio
+/dev/msm_qcelp 0660 system audio
+/dev/msm_evrc 0660 system audio
+/dev/msm_wma 0660 system audio
+/dev/msm_wmapro 0660 system audio
+/dev/msm_amrnb 0660 system audio
+/dev/msm_amrwb 0660 system audio
+/dev/msm_amrwbplus 0660 system audio
+/dev/msm_aac 0660 system audio
+/dev/msm_multi_aac 0660 system audio
+/dev/msm_aac_in 0660 system audio
+/dev/msm_qcelp_in 0660 system audio
+/dev/msm_evrc_in 0660 system audio
+/dev/msm_amrnb_in 0640 system audio
+/dev/msm_a2dp_in 0660 system audio
+/dev/msm_ac3 0660 system audio
+/dev/msm_acdb 0660 system audio
+/dev/msm_cad 0660 system audio
+/dev/msm_fm 0660 system audio
+/dev/msm_mvs 0660 system audio
+/dev/msm_pcm_lp_dec 0660 system audio
+/dev/msm_preproc_ctl 0660 system audio
+/dev/msm_rtac 0660 system audio
+/dev/msm_voicememo 0660 system audio
+/dev/input/event8 0660 input camera
+
+/sys/devices/virtual/graphics/fb1 edid_modes 0440 system system
+/sys/devices/virtual/graphics/fb1 product_description 0640 system system
+/sys/devices/virtual/graphics/fb1 vendor_name 0640 system system
+
+# wlan
+/dev/wcnss_wlan 0660 system system
+/dev/wcnss_ctrl 0660 system system
+
+#
+# Change file permission and owner for sensors
+#
+/dev/adsprpc-smd 0664 system system
+
+/sys/devices/f9925000.i2c/i2c-0/0-* enable 0660 input system
+/sys/devices/f9925000.i2c/i2c-0/0-* poll_delay 0660 input system
+/sys/devices/virtual/optical_sensors/proximity ps_adc 0660 input system
+/sys/devices/virtual/optical_sensors/proximity ps_poll_delay 0660 input system
+/sys/devices/virtual/optical_sensors/lightsensor ls_auto 0660 input system
+/sys/devices/virtual/optical_sensors/lightsensor ls_poll_delay 0660 input system
+/sys/devices/virtual/input/input* poll 0660 input system
+/sys/devices/virtual/input/input* pollrate_ms 0660 input system
+
+# BT
+/dev/hidraw0 0666 system system
+/dev/hidraw1 0666 system system
+/dev/hidraw2 0666 system system
+
+# MHL
+/sys/devices/f9967000.i2c/i2c-4/4-0072/mhl/sii8334 mouse_mode 0660 system system
+/sys/devices/f9967000.i2c/i2c-4/4-0072/mhl/sii8334 screen_status 0660 system system
+/sys/devices/f9967000.i2c/i2c-4/4-0072/mhl/sii8334 mouse_move_distance_dx 0660 system system
+/sys/devices/f9967000.i2c/i2c-4/4-0072/mhl/sii8334 mouse_move_distance_dy 0660 system system
+
+# UIO devices
+/dev/uio0 0660 system system
+/dev/uio1 0660 system system
+/dev/uio2 0660 system system
diff --git a/sepolicy/app.te b/sepolicy/app.te
new file mode 100644
index 0000000..eb71391
--- /dev/null
+++ b/sepolicy/app.te
@@ -0,0 +1,3 @@
+# Grant GPU access to all processes started by Zygote.
+# They need that to render the standard UI.
+allow appdomain gpu_device:chr_file rw_file_perms;
diff --git a/sepolicy/device.te b/sepolicy/device.te
new file mode 100644
index 0000000..f29322b
--- /dev/null
+++ b/sepolicy/device.te
@@ -0,0 +1,2 @@
+# GPU (used by most UI apps)
+type gpu_device, dev_type;
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
new file mode 100644
index 0000000..49aff48
--- /dev/null
+++ b/sepolicy/file_contexts
@@ -0,0 +1,2 @@
+# GPU device
+/dev/kgsl-3d0 u:object_r:gpu_device:s0
diff --git a/shinano.mk b/shinano.mk
new file mode 100644
index 0000000..44f1552
--- /dev/null
+++ b/shinano.mk
@@ -0,0 +1,251 @@
+# Copyright (C) 2013 The CyanogenMod 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.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/languages_full.mk)
+
+# qcom common
+$(call inherit-product, device/sony/qcom-common/qcom-common-330.mk)
+
+COMMON_PATH := device/sony/shinano-common
+
+DEVICE_PACKAGE_OVERLAYS += $(COMMON_PATH)/overlay
+
+# Permissions
+PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/android.hardware.audio.low_latency.xml:system/etc/permissions/android.hardware.audio.low_latency.xml \
+ frameworks/native/data/etc/android.hardware.camera.front.xml:system/etc/permissions/android.hardware.camera.front.xml \
+ frameworks/native/data/etc/android.hardware.location.gps.xml:system/etc/permissions/android.hardware.location.gps.xml \
+ frameworks/native/data/etc/android.hardware.nfc.xml:system/etc/permissions/android.hardware.nfc.xml \
+ frameworks/native/data/etc/android.hardware.nfc.hce.xml:system/etc/permissions/android.hardware.nfc.hce.xml \
+ frameworks/native/data/etc/android.hardware.sensor.gyroscope.xml:system/etc/permissions/android.hardware.sensor.gyroscope.xml \
+ frameworks/native/data/etc/android.hardware.sensor.light.xml:system/etc/permissions/android.hardware.sensor.light.xml \
+ frameworks/native/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \
+ frameworks/native/data/etc/android.hardware.usb.accessory.xml:system/etc/permissions/android.hardware.usb.accessory.xml \
+ frameworks/native/data/etc/android.hardware.usb.host.xml:system/etc/permissions/android.hardware.usb.host.xml \
+ frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.direct.xml \
+ frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \
+ frameworks/native/data/etc/android.software.sip.voip.xml:system/etc/permissions/android.software.sip.voip.xml \
+ frameworks/native/data/etc/com.android.nfc_extras.xml:system/etc/permissions/com.google.android.nfc_extras.xml \
+ frameworks/native/data/etc/android.hardware.bluetooth_le.xml:system/etc/permissions/android.hardware.bluetooth_le.xml
+
+# Init
+PRODUCT_COPY_FILES += \
+ $(COMMON_PATH)/rootdir/fstab.qcom:root/fstab.qcom \
+ $(COMMON_PATH)/rootdir/init.qcom.rc:root/init.qcom.rc \
+ $(COMMON_PATH)/rootdir/init.recovery.qcom.rc:root/init.recovery.qcom.rc \
+ $(COMMON_PATH)/rootdir/system/etc/init.qcom.bt.sh:system/etc/init.qcom.bt.sh \
+ $(COMMON_PATH)/rootdir/ueventd.qcom.rc:root/ueventd.qcom.rc
+
+# Recovery
+PRODUCT_PACKAGES += \
+ extract_elf_ramdisk
+
+PRODUCT_COPY_FILES += \
+ $(COMMON_PATH)/recovery/postrecoveryboot.sh:recovery/root/sbin/postrecoveryboot.sh
+
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/recovery/D6x02.sh:D6x02.sh
+
+# Sbin
+PRODUCT_COPY_FILES += \
+ $(COMMON_PATH)/rootdir/charger:root/charger \
+ $(COMMON_PATH)/rootdir/sbin/wait4tad_static:root/sbin/wait4tad_static \
+ $(COMMON_PATH)/rootdir/sbin/tad_static:root/sbin/tad_static
+
+# Audio
+PRODUCT_PACKAGES += \
+ audio.primary.msm8974 \
+ audio.a2dp.default \
+ audio.usb.default \
+ audio.r_submix.default \
+ libaudio-resampler \
+ tinymix
+
+# Display
+PRODUCT_PACKAGES += \
+ hwcomposer.msm8974 \
+ gralloc.msm8974 \
+ copybit.msm8974 \
+ memtrack.msm8974
+
+# Filesystem management tools
+PRODUCT_PACKAGES += \
+ e2fsck
+
+# FM Radio
+PRODUCT_COPY_FILES += \
+ $(COMMON_PATH)/rootdir/system/etc/init.qcom.fm.sh:system/etc/init.qcom.fm.sh
+
+# GPS
+PRODUCT_COPY_FILES += \
+ $(COMMON_PATH)/gps/flp.conf:system/etc/flp.conf \
+ $(COMMON_PATH)/gps/gps.conf:system/etc/gps.conf \
+ $(COMMON_PATH)/gps/izat.conf:system/etc/izat.conf \
+ $(COMMON_PATH)/gps/sap.conf:system/etc/sap.conf
+
+PRODUCT_PACKAGES += \
+ com.qualcomm.location \
+ gps.msm8974
+
+# Keystore
+PRODUCT_PACKAGES += \
+ keystore.msm8974
+
+# NFC
+PRODUCT_PACKAGES += \
+ libnfc \
+ libnfc_jni \
+ Nfc \
+ Tag \
+ com.android.nfc_extras
+
+PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/com.android.nfc_extras.xml:system/etc/permissions/com.android.nfc_extras.xml
+
+# NFCEE access control
+ifeq ($(TARGET_BUILD_VARIANT),user)
+ NFCEE_ACCESS_PATH := $(COMMON_PATH)/rootdir/system/etc/nfcee_access.xml
+else
+ NFCEE_ACCESS_PATH := $(COMMON_PATH)/rootdir/system/etc/nfcee_access_debug.xml
+endif
+
+PRODUCT_COPY_FILES += \
+ $(NFCEE_ACCESS_PATH):system/etc/nfcee_access.xml
+
+# Qualcomm Random Number Generator
+PRODUCT_PACKAGES += \
+ qrngd \
+ qrngp
+
+# USB
+PRODUCT_PACKAGES += \
+ com.android.future.usb.accessory
+
+# WiFi
+PRODUCT_PACKAGES += \
+ mac-update \
+ wcnss_service
+
+PRODUCT_COPY_FILES += \
+ $(COMMON_PATH)/rootdir/system/etc/wifi/wpa_supplicant_overlay.conf:system/etc/wifi/wpa_supplicant_overlay.conf \
+ $(COMMON_PATH)/rootdir/system/etc/wifi/p2p_supplicant_overlay.conf:system/etc/wifi/p2p_supplicant_overlay.conf
+
+PRODUCT_COPY_FILES += \
+ $(COMMON_PATH)/rootdir/system/etc/init.qcom.wifi.sh:system/etc/init.qcom.wifi.sh \
+ $(COMMON_PATH)/rootdir/system/etc/firmware/wlan/prima/WCNSS_cfg.dat:system/etc/firmware/wlan/prima/WCNSS_cfg.dat \
+ $(COMMON_PATH)/rootdir/system/etc/firmware/wlan/prima/WCNSS_qcom_cfg.ini:system/etc/firmware/wlan/prima/WCNSS_qcom_cfg.ini \
+ $(COMMON_PATH)/rootdir/system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin:system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin
+
+# Set default USB interface
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ persist.sys.usb.config=mtp
+
+# We have enough storage space to hold precise GC data
+PRODUCT_TAGS += dalvik.gc.type-precise
+
+# Audio
+PRODUCT_PROPERTY_OVERRIDES += \
+ af.resampler.quality=4
+
+# Audio offload
+PRODUCT_PROPERTY_OVERRIDES += \
+ audio.offload.buffer.size.kb=32 \
+ audio.offload.gapless.enabled=false \
+ av.offload.enable=true
+
+# Enable AAC 5.1 output
+PRODUCT_PROPERTY_OVERRIDES += \
+ media.aac_51_output_enabled=true
+
+# Voice Call
+PRODUCT_PACKAGES += \
+ ro.qc.sdk.audio.fluencetype=none \
+ persist.audio.dualmic.config=endfire \
+ persist.audio.fluence.voicecall=true \
+ persist.audio.fluence.voicerec=false \
+ persist.audio.fluence.speaker=true
+
+# aDSP
+PRODUCT_PROPERTY_OVERRIDES += \
+ ro.qualcomm.sensors.qmd=true \
+ debug.qualcomm.sns.hal=w \
+ ro.qc.sdk.sensors.gestures=false \
+ ro.qc.sensors.max_accel_rate=false \
+ ro.qc.sensors.max_gyro_rate=false \
+ ro.qc.sensors.max_mag_rate=false \
+ ro.qc.sensors.smgr_mag_cal_en=true \
+ ro.qualcomm.sensors.pedometer=false \
+ ro.qc.sensors.step_counter=true \
+ ro.qc.sensors.step_detector=true \
+ ro.qualcomm.sensors.pam=false \
+ ro.qualcomm.sensors.scrn_ortn=false \
+ ro.qualcomm.sensors.georv=true \
+ ro.qualcomm.sensors.smd=sony
+
+PRODUCT_PROPERTY_OVERRIDES += \
+ ro.hwui.texture_cache_size=72 \
+ ro.hwui.layer_cache_size=48 \
+ ro.hwui.r_buffer_cache_size=8 \
+ ro.hwui.path_cache_size=32 \
+ ro.hwui.gradient_cache_size=1 \
+ ro.hwui.drop_shadow_cache_size=6 \
+ ro.hwui.texture_cache_flushrate=0.4 \
+ ro.hwui.text_small_cache_width=1024 \
+ ro.hwui.text_small_cache_height=1024 \
+ ro.hwui.text_large_cache_width=2048 \
+ ro.hwui.text_large_cache_height=1024
+
+# Bluetooth
+PRODUCT_PROPERTY_OVERRIDES += \
+ ro.qualcomm.bt.hci_transport=smd
+
+# GPS
+PRODUCT_PROPERTY_OVERRIDES += \
+ persist.gps.qc_nlp_in_use=0 \
+ ro.gps.agps_provider=1 \
+ ro.qc.sdk.izat.premium_enabled=1 \
+ ro.qc.sdk.izat.service_mask=0x0
+
+# HDMI
+PRODUCT_PROPERTY_OVERRIDES += \
+ persist.demo.hdmirotationlock=false
+
+# MDP
+PRODUCT_PROPERTY_OVERRIDES += \
+ debug.mdpcomp.maxpermixer=3 \
+ debug.mdpcomp.mixedmode.disable=1
+ debug.mdpcomp.logs=0 \
+ debug.mdpcomp.4k2kSplit=true
+
+# Radio
+ifneq ($(BOARD_HAVE_RADIO),false)
+ DEVICE_PACKAGE_OVERLAYS += $(COMMON_PATH)/overlay-radio
+ $(call inherit-product, $(COMMON_PATH)/radio.mk)
+endif
+
+# Time
+PRODUCT_PROPERTY_OVERRIDES += \
+ persist.timed.enable=true
+
+# Touchscreen
+PRODUCT_PROPERTY_OVERRIDES += \
+ ro.input.noresample=1
+
+# WFD
+PRODUCT_PROPERTY_OVERRIDES += \
+ persist.debug.wfd.enable=1 \
+ persist.sys.wfd.virtual=0
+
+# Include non-opensource parts
+$(call inherit-product, vendor/sony/shinano-common/shinano-common-vendor.mk)