mirror of
https://github.com/S3NEO/android_device_samsung_msm8226-common.git
synced 2024-11-06 21:55:45 +00:00
cm-12.1-qc bringup
This commit is contained in:
parent
21cbb3a80e
commit
e5a8bb1405
123 changed files with 21177 additions and 2285 deletions
|
@ -15,31 +15,109 @@
|
|||
# Inherit from qcom-common
|
||||
-include device/samsung/qcom-common/BoardConfigCommon.mk
|
||||
|
||||
VENDOR_PATH := device/samsung/msm8226-common
|
||||
LOCAL_PATH := device/samsung/msm8226-common
|
||||
|
||||
include device/samsung/msm8226-common/board/*.mk
|
||||
TARGET_SPECIFIC_HEADER_PATH := device/samsung/msm8226-common/include
|
||||
|
||||
TARGET_SPECIFIC_HEADER_PATH := $(VENDOR_PATH)/include
|
||||
# Architecture
|
||||
TARGET_CPU_MEMCPY_BASE_OPT_DISABLE := true
|
||||
TARGET_CPU_VARIANT := krait
|
||||
|
||||
TARGET_GLOBAL_CFLAGS += -mfpu=neon -mfloat-abi=softfp
|
||||
TARGET_GLOBAL_CPPFLAGS += -mfpu=neon -mfloat-abi=softfp
|
||||
# Audio
|
||||
AUDIO_FEATURE_ENABLED_LOW_LATENCY_CAPTURE := true
|
||||
BOARD_USES_ALSA_AUDIO := true
|
||||
|
||||
# Bluetooth
|
||||
BOARD_HAVE_BLUETOOTH := true
|
||||
BOARD_HAVE_BLUETOOTH_QCOM := true
|
||||
BLUETOOTH_HCI_USE_MCT := true
|
||||
|
||||
# Bootloader
|
||||
TARGET_BOOTLOADER_BOARD_NAME := MSM8226
|
||||
|
||||
# Camera
|
||||
TARGET_PROVIDES_CAMERA_HAL := true
|
||||
USE_DEVICE_SPECIFIC_CAMERA := true
|
||||
|
||||
# Charger
|
||||
BOARD_BATTERY_DEVICE_NAME := "battery"
|
||||
BOARD_CHARGING_CMDLINE_NAME := "androidboot.mode"
|
||||
BOARD_CHARGING_CMDLINE_VALUE := "charger"
|
||||
BOARD_CHARGER_ENABLE_SUSPEND := true
|
||||
BOARD_CHARGER_SHOW_PERCENTAGE := true
|
||||
|
||||
# CMHW
|
||||
BOARD_HARDWARE_CLASS += $(VENDOR_PATH)/cmhw
|
||||
BOARD_HARDWARE_CLASS += device/samsung/msm8226-common/cmhw
|
||||
|
||||
# Custom RIL class
|
||||
BOARD_RIL_CLASS := ../../../$(VENDOR_PATH)/ril
|
||||
# Display
|
||||
NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3
|
||||
OVERRIDE_RS_DRIVER := libRSDriver_adreno.so
|
||||
|
||||
# QCOM Hardware
|
||||
BOARD_USES_QCOM_HARDWARE := true
|
||||
# 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
|
||||
|
||||
# FM
|
||||
AUDIO_FEATURE_ENABLED_FM := true
|
||||
TARGET_QCOM_NO_FM_FIRMWARE := true
|
||||
|
||||
# Fonts
|
||||
EXTENDED_FONT_FOOTPRINT := true
|
||||
|
||||
# Properties (reset them here, include more in device if needed)
|
||||
TARGET_SYSTEM_PROP := $(VENDOR_PATH)/system.prop
|
||||
# Init
|
||||
TARGET_INIT_VENDOR_LIB := libinit_msm
|
||||
|
||||
# Memory
|
||||
MALLOC_IMPL := dlmalloc
|
||||
|
||||
# Partitions and Vold
|
||||
BOARD_VOLD_EMMC_SHARES_DEV_MAJOR := true
|
||||
TARGET_USERIMAGES_USE_EXT4 := true
|
||||
TARGET_USE_CUSTOM_LUN_FILE_PATH := /sys/devices/platform/msm_hsusb/gadget/lun%d/file
|
||||
|
||||
# Platform
|
||||
TARGET_BOARD_PLATFORM := msm8226
|
||||
TARGET_BOARD_PLATFORM_GPU := qcom-adreno305
|
||||
|
||||
# Power
|
||||
TARGET_POWERHAL_SET_INTERACTIVE_EXT := $(LOCAL_PATH)/power/power_ext.c
|
||||
TARGET_POWERHAL_VARIANT := qcom
|
||||
|
||||
# SELinux
|
||||
-include device/qcom/sepolicy/sepolicy.mk
|
||||
BOARD_SEPOLICY_DIRS += $(VENDOR_PATH)/sepolicy
|
||||
BOARD_SEPOLICY_DIRS += device/samsung/msm8226-common/sepolicy
|
||||
|
||||
BOARD_SEPOLICY_UNION += \
|
||||
hostapd.te \
|
||||
platform_app.te \
|
||||
kernel.te
|
||||
|
||||
# Wifi
|
||||
BOARD_HAS_QCOM_WLAN := true
|
||||
BOARD_HAS_QCOM_WLAN_SDK := true
|
||||
BOARD_WLAN_DEVICE := qcwcn
|
||||
BOARD_HOSTAPD_DRIVER := NL80211
|
||||
BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)
|
||||
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
|
||||
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)
|
||||
TARGET_PROVIDES_WCNSS_QMI := true
|
||||
TARGET_USES_QCOM_WCNSS_QMI := true
|
||||
TARGET_USES_WCNSS_CTRL := true
|
||||
WPA_SUPPLICANT_VERSION := VER_0_8_X
|
||||
WIFI_DRIVER_FW_PATH_STA := "sta"
|
||||
WIFI_DRIVER_FW_PATH_AP := "ap"
|
||||
WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/wlan.ko"
|
||||
WIFI_DRIVER_MODULE_NAME := "wlan"
|
||||
|
||||
WLAN_MODULES:
|
||||
mkdir -p $(KERNEL_MODULES_OUT)/pronto
|
||||
mv $(KERNEL_MODULES_OUT)/wlan.ko $(KERNEL_MODULES_OUT)/pronto/pronto_wlan.ko
|
||||
ln -sf /system/lib/modules/pronto/pronto_wlan.ko $(TARGET_OUT)/lib/modules/wlan.ko
|
||||
|
||||
TARGET_KERNEL_MODULES += WLAN_MODULES
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
ifeq ($(TARGET_PROVIDES_CAMERA_HAL),true)
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
|
@ -15,3 +17,5 @@ LOCAL_MODULE := camera.msm8226
|
|||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
endif
|
||||
|
|
|
@ -55,8 +55,8 @@ camera_module_t HAL_MODULE_INFO_SYM = {
|
|||
.module_api_version = CAMERA_MODULE_API_VERSION_1_0,
|
||||
.hal_api_version = HARDWARE_HAL_API_VERSION,
|
||||
.id = CAMERA_HARDWARE_MODULE_ID,
|
||||
.name = "NeoHomies Cam Wrapper",
|
||||
.author = "The NeoHomies Project",
|
||||
.name = "Samsung MSM8226 Camera Wrapper",
|
||||
.author = "The CyanogenMod Project",
|
||||
.methods = &camera_module_methods,
|
||||
.dso = NULL, /* remove compilation warnings */
|
||||
.reserved = {0}, /* remove compilation warnings */
|
||||
|
@ -66,8 +66,6 @@ camera_module_t HAL_MODULE_INFO_SYM = {
|
|||
.set_callbacks = NULL, /* remove compilation warnings */
|
||||
.get_vendor_tag_ops = NULL, /* remove compilation warnings */
|
||||
.open_legacy = NULL, /* remove compilation warnings */
|
||||
.set_torch_mode = NULL, /* remove compilation warnings */
|
||||
.init = NULL, /* remove compilation warnings */
|
||||
.reserved = {0}, /* remove compilation warnings */
|
||||
};
|
||||
|
||||
|
@ -117,8 +115,19 @@ static char *camera_fixup_getparams(int id, const char *settings)
|
|||
// fix params here
|
||||
params.set(android::CameraParameters::KEY_SUPPORTED_ISO_MODES, iso_values[id]);
|
||||
params.set(android::CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5");
|
||||
params.set(android::CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-5");
|
||||
params.set(android::CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "5");
|
||||
params.set(android::CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-4");
|
||||
params.set(android::CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "4");
|
||||
|
||||
/* If the vendor has HFR values but doesn't also expose that
|
||||
* this can be turned off, fixup the params to tell the Camera
|
||||
* that it really is okay to turn it off.
|
||||
*/
|
||||
const char *hfrValues = params.get(KEY_VIDEO_HFR_VALUES);
|
||||
if (hfrValues && *hfrValues && ! strstr(hfrValues, "off")) {
|
||||
char tmp[strlen(hfrValues) + 4 + 1];
|
||||
sprintf(tmp, "%s,off", hfrValues);
|
||||
params.set(KEY_VIDEO_HFR_VALUES, tmp);
|
||||
}
|
||||
|
||||
/* Enforce video-snapshot-supported to true */
|
||||
params.set(android::CameraParameters::KEY_VIDEO_SNAPSHOT_SUPPORTED, "true");
|
||||
|
|
14
cm.dependencies
Normal file
14
cm.dependencies
Normal file
|
@ -0,0 +1,14 @@
|
|||
[
|
||||
{
|
||||
"repository": "android_device_qcom_common",
|
||||
"target_path": "device/qcom/common"
|
||||
},
|
||||
{
|
||||
"repository": "android_device_samsung_qcom-common",
|
||||
"target_path": "device/samsung/qcom-common"
|
||||
},
|
||||
{
|
||||
"repository": "android_hardware_qcom_fm",
|
||||
"target_path": "hardware/qcom/fm"
|
||||
}
|
||||
]
|
50
cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java
Normal file
50
cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.cyanogenmod.hardware;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Scanner;
|
||||
import org.cyanogenmod.hardware.util.FileUtils;
|
||||
|
||||
public class DisplayColorCalibration {
|
||||
private static final String COLOR_FILE = "/sys/class/graphics/fb0/rgb";
|
||||
|
||||
public static boolean isSupported() {
|
||||
File f = new File(COLOR_FILE);
|
||||
return f.exists();
|
||||
}
|
||||
|
||||
public static int getMaxValue() {
|
||||
return 32768;
|
||||
}
|
||||
|
||||
public static int getMinValue() {
|
||||
return 255;
|
||||
}
|
||||
|
||||
public static int getDefValue() {
|
||||
return getMaxValue();
|
||||
}
|
||||
|
||||
public static String getCurColors() {
|
||||
return FileUtils.readOneLine(COLOR_FILE);
|
||||
}
|
||||
|
||||
public static boolean setColors(String colors) {
|
||||
return FileUtils.writeLine(COLOR_FILE, colors);
|
||||
}
|
||||
}
|
|
@ -16,7 +16,9 @@
|
|||
|
||||
package org.cyanogenmod.hardware;
|
||||
|
||||
import org.cyanogenmod.internal.util.FileUtils;
|
||||
import java.io.File;
|
||||
|
||||
import org.cyanogenmod.hardware.util.FileUtils;
|
||||
|
||||
/*
|
||||
* Disable capacitive keys
|
||||
|
@ -29,14 +31,15 @@ import org.cyanogenmod.internal.util.FileUtils;
|
|||
|
||||
public class KeyDisabler {
|
||||
|
||||
private static final String KEYDISABLER_PATH = "/sys/class/sec/sec_touchkey/keypad_enable";
|
||||
private static String KEYDISABLER_PATH = "/sys/class/sec/sec_touchkey/keypad_enable";
|
||||
/*
|
||||
* All HAF classes should export this boolean.
|
||||
* Real implementations must, of course, return true
|
||||
*/
|
||||
|
||||
public static boolean isSupported() {
|
||||
return FileUtils.isFileWritable(KEYDISABLER_PATH);
|
||||
File f = new File(KEYDISABLER_PATH);
|
||||
return f.exists();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -44,7 +47,10 @@ public class KeyDisabler {
|
|||
*/
|
||||
|
||||
public static boolean isActive() {
|
||||
return FileUtils.readOneLine(KEYDISABLER_PATH).equals("0");
|
||||
int i;
|
||||
i = Integer.parseInt(FileUtils.readOneLine(KEYDISABLER_PATH));
|
||||
|
||||
return i > 0 ? false : true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -52,6 +58,7 @@ public class KeyDisabler {
|
|||
*/
|
||||
|
||||
public static boolean setActive(boolean state) {
|
||||
return FileUtils.writeLine(KEYDISABLER_PATH, state ? "0" : "1");
|
||||
return FileUtils.writeLine(KEYDISABLER_PATH, String.valueOf(state ? 0 : 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,282 +0,0 @@
|
|||
# List of effect libraries to load. Each library element must contain a "path" element
|
||||
# giving the full path of the library .so file.
|
||||
# libraries {
|
||||
# <lib name> {
|
||||
# path <lib path>
|
||||
# }
|
||||
# }
|
||||
libraries {
|
||||
bundle {
|
||||
path /system/lib/soundfx/libbundlewrapper.so
|
||||
}
|
||||
reverb {
|
||||
path /system/lib/soundfx/libreverbwrapper.so
|
||||
}
|
||||
qcbassboost {
|
||||
path /vendor/lib/soundfx/libqcbassboost.so
|
||||
}
|
||||
qcvirt {
|
||||
path /vendor/lib/soundfx/libqcvirt.so
|
||||
}
|
||||
qcreverb {
|
||||
path /vendor/lib/soundfx/libqcreverb.so
|
||||
}
|
||||
visualizer_sw {
|
||||
path /system/lib/soundfx/libvisualizer.so
|
||||
}
|
||||
visualizer_hw {
|
||||
path /system/lib/soundfx/libqcomvisualizer.so
|
||||
}
|
||||
downmix {
|
||||
path /system/lib/soundfx/libdownmix.so
|
||||
}
|
||||
proxy {
|
||||
path /system/lib/soundfx/libeffectproxy.so
|
||||
}
|
||||
offload_bundle {
|
||||
path /system/lib/soundfx/libqcompostprocbundle.so
|
||||
}
|
||||
audio_pre_processing {
|
||||
path /system/lib/soundfx/libqcomvoiceprocessing.so
|
||||
}
|
||||
loudness_enhancer {
|
||||
path /system/lib/soundfx/libldnhncr.so
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Default pre-processing library. Add to audio_effect.conf "libraries" section if
|
||||
# audio HAL implements support for default software audio pre-processing effects
|
||||
#
|
||||
# pre_processing {
|
||||
# path /system/lib/soundfx/libaudiopreprocessing.so
|
||||
# }
|
||||
|
||||
# list of effects to load. Each effect element must contain a "library" and a "uuid" element.
|
||||
# The value of the "library" element must correspond to the name of one library element in the
|
||||
# "libraries" element.
|
||||
# The name of the effect element is indicative, only the value of the "uuid" element
|
||||
# designates the effect.
|
||||
# The uuid is the implementation specific UUID as specified by the effect vendor. This is not the
|
||||
# generic effect type UUID.
|
||||
# effects {
|
||||
# <fx name> {
|
||||
# library <lib name>
|
||||
# uuid <effect uuid>
|
||||
# }
|
||||
# ...
|
||||
# }
|
||||
|
||||
effects {
|
||||
|
||||
# additions for the proxy implementation
|
||||
# Proxy implementation
|
||||
#effectname {
|
||||
#library proxy
|
||||
#uuid xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
|
||||
# SW implemetation of the effect. Added as a node under the proxy to
|
||||
# indicate this as a sub effect.
|
||||
#libsw {
|
||||
#library libSW
|
||||
#uuid yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
|
||||
#} End of SW effect
|
||||
|
||||
# HW implementation of the effect. Added as a node under the proxy to
|
||||
# indicate this as a sub effect.
|
||||
#libhw {
|
||||
#library libHW
|
||||
#uuid zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz
|
||||
#}End of HW effect
|
||||
#} End of effect proxy
|
||||
|
||||
bassboost {
|
||||
library proxy
|
||||
uuid 14804144-a5ee-4d24-aa88-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library qcbassboost
|
||||
uuid 23aca180-44bd-11e2-bcfd-0800200c9a66
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid 2c4a8c24-1581-487f-94f6-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
virtualizer {
|
||||
library proxy
|
||||
uuid d3467faa-acc7-4d34-acaf-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library qcvirt
|
||||
uuid e6c98a16-22a3-11e2-b87b-f23c91aec05e
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid 509a4498-561a-4bea-b3b1-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
equalizer {
|
||||
library proxy
|
||||
uuid c8e70ecd-48ca-456e-8a4f-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library bundle
|
||||
uuid ce772f20-847d-11df-bb17-0002a5d5c51b
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid a0dac280-401c-11e3-9379-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
volume {
|
||||
library bundle
|
||||
uuid 119341a0-8469-11df-81f9-0002a5d5c51b
|
||||
}
|
||||
reverb_env_aux {
|
||||
library proxy
|
||||
uuid 48404ac9-d202-4ccc-bf84-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library qcreverb
|
||||
uuid a8c1e5f3-293d-43cd-95ec-d5e26c02e217
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid 79a18026-18fd-4185-8233-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
reverb_env_ins {
|
||||
library proxy
|
||||
uuid b707403a-a1c1-4291-9573-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library qcreverb
|
||||
uuid 791fff8b-8129-4655-83a4-59bc61034c3a
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid eb64ea04-973b-43d2-8f5e-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
reverb_pre_aux {
|
||||
library proxy
|
||||
uuid 1b78f587-6d1c-422e-8b84-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library qcreverb
|
||||
uuid 53ef1db5-c0c0-445b-b060-e34d20ebb70a
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid 6987be09-b142-4b41-9056-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
reverb_pre_ins {
|
||||
library proxy
|
||||
uuid f3e178d2-ebcb-408e-8357-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library qcreverb
|
||||
uuid b08a0e38-22a5-11e2-b87b-f23c91aec05e
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid aa2bebf6-47cf-4613-9bca-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
visualizer {
|
||||
library proxy
|
||||
uuid 1d0a1a53-7d5d-48f2-8e71-27fbd10d842c
|
||||
|
||||
libsw {
|
||||
library visualizer_sw
|
||||
uuid d069d9e0-8329-11df-9168-0002a5d5c51b
|
||||
}
|
||||
|
||||
libhw {
|
||||
library visualizer_hw
|
||||
uuid 7a8044a0-1a71-11e3-a184-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
loudness_enhancer {
|
||||
library loudness_enhancer
|
||||
uuid fa415329-2034-4bea-b5dc-5b381c8d1e2c
|
||||
}
|
||||
|
||||
downmix {
|
||||
library downmix
|
||||
uuid 93f04452-e4fe-41cc-91f9-e475b6d1d69f
|
||||
}
|
||||
aec {
|
||||
library audio_pre_processing
|
||||
uuid 0f8d0d2a-59e5-45fe-b6e4-248c8a799109
|
||||
}
|
||||
ns {
|
||||
library audio_pre_processing
|
||||
uuid 1d97bb0b-9e2f-4403-9ae3-58c2554306f8
|
||||
}
|
||||
}
|
||||
|
||||
# Default pre-processing effects. Add to audio_effect.conf "effects" section if
|
||||
# audio HAL implements support for them.
|
||||
#
|
||||
# agc {
|
||||
# library pre_processing
|
||||
# uuid aa8130e0-66fc-11e0-bad0-0002a5d5c51b
|
||||
# }
|
||||
# aec {
|
||||
# library pre_processing
|
||||
# uuid bb392ec0-8d4d-11e0-a896-0002a5d5c51b
|
||||
# }
|
||||
# ns {
|
||||
# library pre_processing
|
||||
# uuid c06c8400-8e06-11e0-9cb6-0002a5d5c51b
|
||||
# }
|
||||
|
||||
# Audio preprocessor configurations.
|
||||
# The pre processor configuration consists in a list of elements each describing
|
||||
# pre processor settings for a given input source. Valid input source names are:
|
||||
# "mic", "camcorder", "voice_recognition", "voice_communication"
|
||||
# Each input source element contains a list of effects elements. The name of the effect
|
||||
# element must be the name of one of the effects in the "effects" list of the file.
|
||||
# Each effect element may optionally contain a list of parameters and their
|
||||
# default value to apply when the pre processor effect is created.
|
||||
# A parameter is defined by a "param" element and a "value" element. Each of these elements
|
||||
# consists in one or more elements specifying a type followed by a value.
|
||||
# The types defined are: "int", "short", "float", "bool" and "string"
|
||||
# When both "param" and "value" are a single int, a simple form is allowed where just
|
||||
# the param and value pair is present in the parameter description
|
||||
# pre_processing {
|
||||
# <input source name> {
|
||||
# <fx name> {
|
||||
# <param 1 name> {
|
||||
# param {
|
||||
# int|short|float|bool|string <value>
|
||||
# [ int|short|float|bool|string <value> ]
|
||||
# ...
|
||||
# }
|
||||
# value {
|
||||
# int|short|float|bool|string <value>
|
||||
# [ int|short|float|bool|string <value> ]
|
||||
# ...
|
||||
# }
|
||||
# }
|
||||
# <param 2 name > {<param> <value>}
|
||||
# ...
|
||||
# }
|
||||
# ...
|
||||
# }
|
||||
# ...
|
||||
# }
|
||||
|
||||
#
|
||||
# TODO: add default audio pre processor configurations after debug and tuning phase
|
||||
#
|
|
@ -1,9 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2012-2013, The Linux Foundation. All rights reserved.
|
||||
<!-- Copyright (C) 2012-2013 The Android Open Source Project
|
||||
Copyright (C) 2014 The Linux Foundation. All rights reserved.
|
||||
Not a contribution.
|
||||
|
||||
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
|
||||
|
@ -24,6 +23,7 @@
|
|||
|__________|_________________________________________|
|
||||
| h264 | 1920 1088 30 20 244800 |
|
||||
| mpeg4 | 1920 1088 30 20 244800 |
|
||||
| vp8 | 1920 1088 30 20 244800 |
|
||||
| h263 | 864 480 30 2 48600 |
|
||||
|__________|_________________________________________|
|
||||
|
||||
|
@ -46,9 +46,6 @@
|
|||
<MediaCodecs>
|
||||
<Include href="media_codecs_google_audio.xml" />
|
||||
<Include href="media_codecs_google_telephony.xml" />
|
||||
<Settings>
|
||||
<Setting name="max-video-encoder-input-buffers" value="9" />
|
||||
</Settings>
|
||||
<Encoders>
|
||||
<!-- Audio Hardware -->
|
||||
<MediaCodec name="OMX.qcom.audio.encoder.evrc" type="audio/evrc" >
|
||||
|
@ -69,7 +66,6 @@
|
|||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="244800" />
|
||||
<Limit name="bitrate" range="1-20000000" />
|
||||
<Limit name="concurrent-instances" max="13" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.mpeg4" type="video/mp4v-es" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
|
@ -80,7 +76,6 @@
|
|||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="244800" />
|
||||
<Limit name="bitrate" range="1-20000000" />
|
||||
<Limit name="concurrent-instances" max="13" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.h263" type="video/3gpp" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
|
@ -91,9 +86,19 @@
|
|||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="48600" />
|
||||
<Limit name="bitrate" range="1-2000000" />
|
||||
<Limit name="concurrent-instances" max="13" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.vp8" type="video/x-vnd.on2.vp8" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Quirk name="requires-loaded-to-idle-after-allocation" />
|
||||
<Limit name="size" min="96x64" max="1920x1088" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="244800" />
|
||||
<Limit name="bitrate" range="1-20000000" />
|
||||
</MediaCodec>
|
||||
</Encoders>
|
||||
|
||||
<Decoders>
|
||||
<!-- Audio Hardware -->
|
||||
<MediaCodec name="OMX.qcom.audio.decoder.wma" type="audio/x-ms-wma" >
|
||||
|
@ -125,7 +130,6 @@
|
|||
<Limit name="blocks-per-second" min="1" max="244800" />
|
||||
<Limit name="bitrate" range="1-20000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="13" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.avc.secure" type="video/avc" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
|
@ -137,7 +141,6 @@
|
|||
<Limit name="bitrate" range="1-20000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Feature name="secure-playback" required="true" />
|
||||
<Limit name="concurrent-instances" max="3" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.mpeg2" type="video/mpeg2" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
|
@ -148,7 +151,6 @@
|
|||
<Limit name="blocks-per-second" min="1" max="244800" />
|
||||
<Limit name="bitrate" range="1-20000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="13" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.mpeg4" type="video/mp4v-es" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
|
@ -159,7 +161,6 @@
|
|||
<Limit name="blocks-per-second" min="1" max="244800" />
|
||||
<Limit name="bitrate" range="1-20000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="13" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.h263" type="video/3gpp" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
|
@ -170,7 +171,6 @@
|
|||
<Limit name="blocks-per-second" min="1" max="48600" />
|
||||
<Limit name="bitrate" range="1-2000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="13" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.vc1" type="video/x-ms-wmv" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
|
@ -181,7 +181,6 @@
|
|||
<Limit name="blocks-per-second" min="1" max="244800" />
|
||||
<Limit name="bitrate" range="1-20000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="8" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.divx" type="video/divx" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
|
@ -192,7 +191,6 @@
|
|||
<Limit name="blocks-per-second" min="1" max="244800" />
|
||||
<Limit name="bitrate" range="1-10000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="8" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.divx311" type="video/divx311" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
|
@ -203,7 +201,6 @@
|
|||
<Limit name="blocks-per-second" min="1" max="40500" />
|
||||
<Limit name="bitrate" range="1-2000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="8" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.divx4" type="video/divx4" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
|
@ -214,7 +211,6 @@
|
|||
<Limit name="blocks-per-second" min="1" max="244800" />
|
||||
<Limit name="bitrate" range="1-10000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="8" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.vp8" type="video/x-vnd.on2.vp8" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
|
@ -225,7 +221,6 @@
|
|||
<Limit name="blocks-per-second" min="1" max="244800" />
|
||||
<Limit name="bitrate" range="1-20000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="13" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.hevchybrid" type="video/hevc" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
|
@ -236,7 +231,6 @@
|
|||
<Limit name="blocks-per-second" min="1" max="108000" />
|
||||
<Limit name="bitrate" range="1-2000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="3" />
|
||||
</MediaCodec>
|
||||
</Decoders>
|
||||
<Include href="media_codecs_google_video.xml" />
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.
|
||||
|
||||
Not a Contribution.
|
||||
|
||||
Copyright 2015 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.
|
||||
-->
|
||||
|
||||
<MediaCodecs>
|
||||
<Encoders>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.avc" type="video/avc" update="true">
|
||||
<Limit name="measured-frame-rate-320x240" range="339-339" />
|
||||
<Limit name="measured-frame-rate-720x480" range="95-95" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="41-41" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="16-16" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.h263" type="video/3gpp" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="277-444" />
|
||||
<Limit name="measured-frame-rate-352x288" range="254-277" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.mpeg4" type="video/mp4v-es" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="324-324" />
|
||||
<Limit name="measured-frame-rate-352x288" range="238-238" />
|
||||
<Limit name="measured-frame-rate-640x480" range="105-105" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.h264.encoder" type="video/avc" update="true">
|
||||
<Limit name="measured-frame-rate-320x240" range="285-285" />
|
||||
<Limit name="measured-frame-rate-720x480" range="84-84" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="33-33" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="15-15" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.h263.encoder" type="video/3gpp" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="515-515" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.mpeg4.encoder" type="video/mp4v-es" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="588-588" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.vp8.encoder" type="video/x-vnd.on2.vp8" update="true">
|
||||
<Limit name="measured-frame-rate-320x180" range="312-312" />
|
||||
<Limit name="measured-frame-rate-640x360" range="117-117" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="31-31" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="13-13" />
|
||||
</MediaCodec>
|
||||
</Encoders>
|
||||
<Decoders>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.avc" type="video/avc" update="true">
|
||||
<Limit name="measured-frame-rate-320x240" range="368-368" />
|
||||
<Limit name="measured-frame-rate-720x480" range="197-197" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="97-97" />
|
||||
<Limit name="measured-frame-rate-1920x1088" range="43-43" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.h263" type="video/3gpp" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="608-608" />
|
||||
<Limit name="measured-frame-rate-352x288" range="578-578" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.mpeg4" type="video/mp4v-es" update="true">
|
||||
<Limit name="measured-frame-rate-480x360" range="411-411" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.vp8" type="video/x-vnd.on2.vp8" update="true">
|
||||
<Limit name="measured-frame-rate-320x240" range="303-303" />
|
||||
<Limit name="measured-frame-rate-640x360" range="464-464" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="193-193" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="93-93" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.h264.decoder" type="video/avc" update="true">
|
||||
<Limit name="measured-frame-rate-320x240" range="601-601" />
|
||||
<Limit name="measured-frame-rate-720x480" range="197-197" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="60-60" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="20-20" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.h263.decoder" type="video/3gpp" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="1346-1346" />
|
||||
<Limit name="measured-frame-rate-352x288" range="736-736" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.hevc.decoder" type="video/hevc" update="true">
|
||||
<Limit name="measured-frame-rate-352x288" range="503-503" />
|
||||
<Limit name="measured-frame-rate-720x480" range="336-336" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="118-118" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="54-54" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.vp8.decoder" type="video/x-vnd.on2.vp8" update="true">
|
||||
<Limit name="measured-frame-rate-320x240" range="578-578" />
|
||||
<Limit name="measured-frame-rate-640x360" range="212-212" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="40-40" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="31-31" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.vp9.decoder" type="video/x-vnd.on2.vp9" update="true">
|
||||
<Limit name="measured-frame-rate-320x240" range="287-287" />
|
||||
<Limit name="measured-frame-rate-640x360" range="251-251" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="68-68" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="53-53" />
|
||||
</MediaCodec>
|
||||
</Decoders>
|
||||
</MediaCodecs>
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
## this file is used by NFC Hardware Abstraction Layer at external/libnfc-nci/halimpl/
|
||||
|
||||
###############################################################################
|
||||
#chip hardware version<v.2.0.S> <JNI.NCI_MW.NCI_HAL.KERNEL><SUPPORTED features><unique id>
|
||||
#supported features <SE:swp1,numer of ses><P2P,A F><others><LISTEN ABF B Prime><POLL ABF kovio>
|
||||
NFC_BUILD_ID = V2.1.S.01.01.01.01.1105000707.1112132050
|
||||
# Application logging mask
|
||||
APPL_TRACE_LEVEL=0x00
|
||||
PROTOCOL_TRACE_LEVEL=0x00000000
|
||||
|
||||
#####################################################################################
|
||||
# File used for NFA storage
|
||||
NFA_STORAGE="/data/nfc"
|
||||
|
||||
NFC_WAKE_DELAY=20
|
||||
|
||||
#default
|
||||
NFA_DM_START_UP_CFG={17:80:01:00:08:01:01:11:01:01:AF:02:00:07:AF:02:01:07:C0:01:01:BF:01:02}
|
||||
#####################################################################################
|
||||
# listen to the following technology(s).
|
||||
# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h.
|
||||
# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B.
|
||||
|
||||
UICC_LISTEN_TECH_MASK=0x07
|
||||
# Protocol mask for NFC-A technology protocols(T1T,T2T and 4A).
|
||||
# The bits (for NFC A protocol mask)are defined in nfa_api.h.
|
||||
# Default is T4AT
|
||||
# 0x01- T1T, 0x02- T2T, 0x04- T4AT
|
||||
NFCA_PROTOCOL_MASK=0x04
|
||||
###############################################################################
|
||||
# Force tag polling for the following technology(s).
|
||||
# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h.
|
||||
# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B |
|
||||
# NFA_TECHNOLOGY_MASK_F | NFA_TECHNOLOGY_MASK_ISO15693 |
|
||||
# NFA_TECHNOLOGY_MASK_B_PRIME | NFA_TECHNOLOGY_MASK_A_ACTIVE |
|
||||
# NFA_TECHNOLOGY_MASK_F_ACTIVE.
|
||||
#
|
||||
# 0x01- A, 0x02- B, 0x04- F, 0x20- Kovio
|
||||
POLLING_TECH_MASK=0x27
|
||||
|
||||
# Force P2P to only listen for the following technology(s).
|
||||
# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h.
|
||||
# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_F |
|
||||
# NFA_TECHNOLOGY_MASK_A_ACTIVE | NFA_TECHNOLOGY_MASK_F_ACTIVE
|
||||
# 0x01- NFC DEP A , 0x04:- NFC DEP F
|
||||
P2P_LISTEN_TECH_MASK=0x05
|
||||
|
||||
###############################################################################
|
||||
# Firmware patch file
|
||||
# If the value is not set then patch download is disabled.
|
||||
FW_PATCH="/system/etc/firmware/Signedrompatch.bin"
|
||||
###############################################################################
|
||||
# Firmware patch file
|
||||
#FW_PRE_PATCH="/system/etc/firmware/Signedromprepatch.bin"
|
||||
NVM_FILE_PATH="/system/etc/firmware/nfc_test.bin"
|
||||
FUSED_NVM_FILE_PATH="/system/etc/firmware/fused_nvm.bin"
|
||||
###############################################################################
|
||||
|
||||
#
|
||||
TRANSPORT_DRIVER="/dev/nfc-nci"
|
||||
|
||||
###############################################################################
|
||||
# power control driver
|
||||
|
||||
POWER_CONTROL_DRIVER="/dev/nfc-nci"
|
||||
|
||||
###############################################################################
|
||||
# Maximum Number of Credits to be allowed by the NFCC
|
||||
MAX_RF_DATA_CREDITS=1
|
||||
###############################################################################
|
||||
#Patch and nvm update flags
|
||||
# These flags needs to be set to enable the patch update and nvm update mechanism
|
||||
# of middleware
|
||||
###############################################################################
|
||||
PATCH_UPDATE_ENABLE_FLAG=0x01
|
||||
NVM_UPDATE_ENABLE_FLAG=0x00
|
||||
FUSED_NVM_UPDATE_ENABLE_FLAG=0x00
|
||||
PM_ENABLE_FLAG=0x01
|
||||
SCREEN_OFF_POWER_STATE=0x01
|
||||
###############################################################################
|
||||
# Time out value for closing the connection opened for patch download
|
||||
###############################################################################
|
||||
PATCH_DNLD_NFC_HAL_CMD_TOUT=10000
|
||||
PATCH_VERSION=21
|
||||
###############################################################################
|
||||
#Default listen mode routing table
|
||||
# This is the default listen mode routing configuration for NFCC.
|
||||
# Default is for ISO DEP and NFC DEP
|
||||
DEFAULT_LISTEN_MODE_ROUTING={00:02:0A:01:03:01:01:04:01:03:00:01:05}
|
||||
###############################################################################
|
|
@ -1,11 +0,0 @@
|
|||
<?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" />
|
||||
|
||||
</resources>
|
|
@ -1,17 +0,0 @@
|
|||
<?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>
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright 2016 The CyanogenMod 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.
|
||||
|
@ -14,13 +14,6 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_C_INCLUDES := $(TARGET_POWERHAL_HEADER_PATH)
|
||||
LOCAL_SRC_FILES := power.c
|
||||
LOCAL_SHARED_LIBRARIES := liblog libcutils
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE := power.msm8226
|
||||
LOCAL_PROPRIETARY_MODULE := true
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(call all-subdir-makefiles,$(LOCAL_PATH))
|
|
@ -1,22 +0,0 @@
|
|||
<?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.
|
||||
-->
|
||||
|
||||
<!-- These are the location-related features for devices that include GPS. -->
|
||||
<permissions>
|
||||
<feature name="android.hardware.location" />
|
||||
<feature name="android.hardware.location.network" />
|
||||
<feature name="android.hardware.location.gps" />
|
||||
</permissions>
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 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.
|
||||
-->
|
||||
|
||||
<permissions>
|
||||
<library name="com.android.location.provider"
|
||||
file="/system/framework/com.android.location.provider.jar" />
|
||||
</permissions>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!---******************************************************************************
|
||||
* @file com.qualcomm.location.xml
|
||||
* @brief configuration file for permission mapping
|
||||
* Copyright (c) 2012 Qualcomm Atheros, Inc.
|
||||
* All Rights Reserved.
|
||||
* Qualcomm Atheros Confidential and Proprietary.
|
||||
* *****************************************************************************-->
|
||||
|
||||
|
||||
<permissions>
|
||||
|
||||
<permission name="com.qualcomm.permission.IZAT" >
|
||||
<group gid="gps" />
|
||||
<group gid="net_raw" />
|
||||
<group gid="net_admin" />
|
||||
<group gid="system" />
|
||||
<group gid="qcom_diag" />
|
||||
<group gid="sdcard_rw" />
|
||||
<group gid="media_rw" />
|
||||
<group gid="wifi" />
|
||||
</permission>
|
||||
|
||||
</permissions>
|
||||
|
50
gps/core/Android.mk
Normal file
50
gps/core/Android.mk
Normal file
|
@ -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
|
114
gps/core/ContextBase.cpp
Normal file
114
gps/core/ContextBase.cpp
Normal file
|
@ -0,0 +1,114 @@
|
|||
/* 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))) {
|
||||
void *handle = NULL;
|
||||
//try to see if LocApiV02 is present
|
||||
if((handle = dlopen("libloc_api_v02.so", RTLD_NOW)) != NULL) {
|
||||
LOC_LOGD("%s:%d]: libloc_api_v02.so is present", __func__, __LINE__);
|
||||
getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi");
|
||||
if(getter != NULL) {
|
||||
LOC_LOGD("%s:%d]: getter is not NULL for LocApiV02", __func__, __LINE__);
|
||||
locApi = (*getter)(mMsgTask,exMask);
|
||||
}
|
||||
}
|
||||
// only RPC is the option now
|
||||
else {
|
||||
LOC_LOGD("%s:%d]: libloc_api_v02.so is NOT present. Trying RPC",
|
||||
__func__, __LINE__);
|
||||
handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW);
|
||||
if (NULL != handle) {
|
||||
getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi");
|
||||
if (NULL != getter) {
|
||||
LOC_LOGD("%s:%d]: getter is not NULL in RPC", __func__, __LINE__);
|
||||
locApi = (*getter)(mMsgTask, exMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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())
|
||||
{
|
||||
}
|
||||
|
||||
}
|
69
gps/core/ContextBase.h
Normal file
69
gps/core/ContextBase.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef __LOC_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 hasAgpsExtendedCapabilities() { return mLBSProxy->hasAgpsExtendedCapabilities(); }
|
||||
inline bool hasCPIExtendedCapabilities() { return mLBSProxy->hasCPIExtendedCapabilities(); }
|
||||
inline void requestUlp(LocAdapterBase* adapter,
|
||||
unsigned long capabilities) {
|
||||
mLBSProxy->requestUlp(adapter, capabilities);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif //__LOC_CONTEXT_BASE__
|
60
gps/core/LBSProxyBase.h
Normal file
60
gps/core/LBSProxyBase.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef 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 hasAgpsExtendedCapabilities() const { return false; }
|
||||
inline virtual bool hasCPIExtendedCapabilities() const { return false; }
|
||||
};
|
||||
|
||||
typedef LBSProxyBase* (getLBSProxy_t)();
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif // IZAT_PROXY_BASE_H
|
126
gps/core/LocAdapterBase.cpp
Normal file
126
gps/core/LocAdapterBase.cpp
Normal file
|
@ -0,0 +1,126 @@
|
|||
/* 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::
|
||||
reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet)
|
||||
DEFAULT_IMPL()
|
||||
|
||||
void LocAdapterBase::
|
||||
reportSvPolynomial(GnssSvPolynomial &svPolynomial)
|
||||
DEFAULT_IMPL()
|
||||
|
||||
void LocAdapterBase::
|
||||
reportStatus(GpsStatusValue status)
|
||||
DEFAULT_IMPL()
|
||||
|
||||
|
||||
void LocAdapterBase::
|
||||
reportNmea(const char* nmea, int length)
|
||||
DEFAULT_IMPL()
|
||||
|
||||
bool LocAdapterBase::
|
||||
reportXtraServer(const char* url1, const char* url2,
|
||||
const char* url3, const int maxlength)
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
requestXtraData()
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
requestTime()
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
requestLocation()
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
requestATL(int connHandle, AGpsType agps_type)
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
releaseATL(int connHandle)
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
requestSuplES(int connHandle)
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
reportDataCallOpened()
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
reportDataCallClosed()
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
requestNiNotify(GpsNiNotification ¬ify, const void* data)
|
||||
DEFAULT_IMPL(false)
|
||||
} // namespace loc_core
|
107
gps/core/LocAdapterBase.h
Normal file
107
gps/core/LocAdapterBase.h
Normal file
|
@ -0,0 +1,107 @@
|
|||
/* 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 reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet);
|
||||
virtual void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
|
||||
virtual void reportStatus(GpsStatusValue status);
|
||||
virtual void reportNmea(const char* nmea, int length);
|
||||
virtual bool reportXtraServer(const char* url1, const char* url2,
|
||||
const char* url3, const int maxlength);
|
||||
virtual bool requestXtraData();
|
||||
virtual bool requestTime();
|
||||
virtual bool requestLocation();
|
||||
virtual bool requestATL(int connHandle, AGpsType agps_type);
|
||||
virtual bool releaseATL(int connHandle);
|
||||
virtual bool requestSuplES(int connHandle);
|
||||
virtual bool reportDataCallOpened();
|
||||
virtual bool reportDataCallClosed();
|
||||
virtual bool requestNiNotify(GpsNiNotification ¬ify,
|
||||
const void* data);
|
||||
inline virtual bool isInSession() { return false; }
|
||||
ContextBase* getContext() const { return mContext; }
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif //LOC_API_ADAPTER_BASE_H
|
492
gps/core/LocApiBase.cpp
Normal file
492
gps/core/LocApiBase.cpp
Normal file
|
@ -0,0 +1,492 @@
|
|||
/* 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::reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet)
|
||||
{
|
||||
// loop through adapters, and deliver to all adapters.
|
||||
TO_ALL_LOCADAPTERS(
|
||||
mLocAdapters[i]->reportSvMeasurement(svMeasurementSet)
|
||||
);
|
||||
}
|
||||
|
||||
void LocApiBase::reportSvPolynomial(GnssSvPolynomial &svPolynomial)
|
||||
{
|
||||
// loop through adapters, and deliver to all adapters.
|
||||
TO_ALL_LOCADAPTERS(
|
||||
mLocAdapters[i]->reportSvPolynomial(svPolynomial)
|
||||
);
|
||||
}
|
||||
|
||||
void LocApiBase::reportStatus(GpsStatusValue status)
|
||||
{
|
||||
// loop through adapters, and deliver to all adapters.
|
||||
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportStatus(status));
|
||||
}
|
||||
|
||||
void LocApiBase::reportNmea(const char* nmea, int length)
|
||||
{
|
||||
// loop through adapters, and deliver to all adapters.
|
||||
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmea(nmea, length));
|
||||
}
|
||||
|
||||
void LocApiBase::reportXtraServer(const char* url1, const char* url2,
|
||||
const char* url3, const int maxlength)
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportXtraServer(url1, url2, url3, maxlength));
|
||||
|
||||
}
|
||||
|
||||
void LocApiBase::requestXtraData()
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestXtraData());
|
||||
}
|
||||
|
||||
void LocApiBase::requestTime()
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestTime());
|
||||
}
|
||||
|
||||
void LocApiBase::requestLocation()
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestLocation());
|
||||
}
|
||||
|
||||
void LocApiBase::requestATL(int connHandle, AGpsType agps_type)
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestATL(connHandle, agps_type));
|
||||
}
|
||||
|
||||
void LocApiBase::releaseATL(int connHandle)
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->releaseATL(connHandle));
|
||||
}
|
||||
|
||||
void LocApiBase::requestSuplES(int connHandle)
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestSuplES(connHandle));
|
||||
}
|
||||
|
||||
void LocApiBase::reportDataCallOpened()
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallOpened());
|
||||
}
|
||||
|
||||
void LocApiBase::reportDataCallClosed()
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallClosed());
|
||||
}
|
||||
|
||||
void LocApiBase::requestNiNotify(GpsNiNotification ¬ify, const void* data)
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotify(notify, data));
|
||||
}
|
||||
|
||||
void* LocApiBase :: 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,
|
||||
int sensorProvider)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid,
|
||||
float gyroBiasVarianceRandomWalk,
|
||||
bool accelBiasVarianceRandomWalk_valid,
|
||||
float accelBiasVarianceRandomWalk,
|
||||
bool angleBiasVarianceRandomWalk_valid,
|
||||
float angleBiasVarianceRandomWalk,
|
||||
bool rateBiasVarianceRandomWalk_valid,
|
||||
float rateBiasVarianceRandomWalk,
|
||||
bool velocityBiasVarianceRandomWalk_valid,
|
||||
float velocityBiasVarianceRandomWalk)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setSensorPerfControlConfig(int controlMode,
|
||||
int accelSamplesPerBatch,
|
||||
int accelBatchesPerSec,
|
||||
int gyroSamplesPerBatch,
|
||||
int gyroBatchesPerSec,
|
||||
int accelSamplesPerBatchHigh,
|
||||
int accelBatchesPerSecHigh,
|
||||
int gyroSamplesPerBatchHigh,
|
||||
int gyroBatchesPerSecHigh,
|
||||
int algorithmConfig)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setExtPowerConfig(int isBatteryCharging)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setAGLONASSProtocol(unsigned long aGlonassProtocol)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
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
|
224
gps/core/LocApiBase.h
Normal file
224
gps/core/LocApiBase.h
Normal file
|
@ -0,0 +1,224 @@
|
|||
/* 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:
|
||||
inline void sendMsg(const LocMsg* msg) const {
|
||||
mMsgTask->sendMsg(msg);
|
||||
}
|
||||
|
||||
void addAdapter(LocAdapterBase* adapter);
|
||||
void removeAdapter(LocAdapterBase* adapter);
|
||||
|
||||
// upward calls
|
||||
void handleEngineUpEvent();
|
||||
void handleEngineDownEvent();
|
||||
void reportPosition(UlpLocation &location,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* locationExt,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask loc_technology_mask =
|
||||
LOC_POS_TECH_MASK_DEFAULT);
|
||||
void reportSv(GpsSvStatus &svStatus,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* svExt);
|
||||
void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet);
|
||||
void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
|
||||
void reportStatus(GpsStatusValue status);
|
||||
void reportNmea(const char* nmea, int length);
|
||||
void reportXtraServer(const char* url1, const char* url2,
|
||||
const char* url3, const int maxlength);
|
||||
void requestXtraData();
|
||||
void requestTime();
|
||||
void requestLocation();
|
||||
void requestATL(int connHandle, AGpsType agps_type);
|
||||
void releaseATL(int connHandle);
|
||||
void requestSuplES(int connHandle);
|
||||
void reportDataCallOpened();
|
||||
void reportDataCallClosed();
|
||||
void requestNiNotify(GpsNiNotification ¬ify, const void* data);
|
||||
|
||||
// downward calls
|
||||
// All below functions are to be defined by adapter specific modules:
|
||||
// RPC, QMI, etc. The default implementation is empty.
|
||||
|
||||
virtual void* getSibling();
|
||||
virtual LocApiProxyBase* getLocApiProxy();
|
||||
virtual enum loc_api_adapter_err
|
||||
startFix(const LocPosMode& posMode);
|
||||
virtual enum loc_api_adapter_err
|
||||
stopFix();
|
||||
virtual enum loc_api_adapter_err
|
||||
deleteAidingData(GpsAidingData f);
|
||||
virtual enum loc_api_adapter_err
|
||||
enableData(int enable);
|
||||
virtual enum loc_api_adapter_err
|
||||
setAPN(char* apn, int len);
|
||||
virtual enum loc_api_adapter_err
|
||||
injectPosition(double latitude, double longitude, float accuracy);
|
||||
virtual enum loc_api_adapter_err
|
||||
setTime(GpsUtcTime time, int64_t timeReference, int uncertainty);
|
||||
virtual enum loc_api_adapter_err
|
||||
setXtraData(char* data, int length);
|
||||
virtual enum loc_api_adapter_err
|
||||
requestXtraServer();
|
||||
virtual enum loc_api_adapter_err
|
||||
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType);
|
||||
virtual enum loc_api_adapter_err
|
||||
atlCloseStatus(int handle, int is_succ);
|
||||
virtual enum loc_api_adapter_err
|
||||
setPositionMode(const LocPosMode& posMode);
|
||||
virtual enum loc_api_adapter_err
|
||||
setServer(const char* url, int len);
|
||||
virtual enum loc_api_adapter_err
|
||||
setServer(unsigned int ip, int port,
|
||||
LocServerType type);
|
||||
virtual enum loc_api_adapter_err
|
||||
informNiResponse(GpsUserResponseType userResponse, const void* passThroughData);
|
||||
virtual enum loc_api_adapter_err
|
||||
setSUPLVersion(uint32_t version);
|
||||
virtual enum loc_api_adapter_err
|
||||
setLPPConfig(uint32_t profile);
|
||||
virtual enum loc_api_adapter_err
|
||||
setSensorControlConfig(int sensorUsage, int sensorProvider);
|
||||
virtual enum loc_api_adapter_err
|
||||
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid,
|
||||
float gyroBiasVarianceRandomWalk,
|
||||
bool accelBiasVarianceRandomWalk_valid,
|
||||
float accelBiasVarianceRandomWalk,
|
||||
bool angleBiasVarianceRandomWalk_valid,
|
||||
float angleBiasVarianceRandomWalk,
|
||||
bool rateBiasVarianceRandomWalk_valid,
|
||||
float rateBiasVarianceRandomWalk,
|
||||
bool velocityBiasVarianceRandomWalk_valid,
|
||||
float velocityBiasVarianceRandomWalk);
|
||||
virtual enum loc_api_adapter_err
|
||||
setSensorPerfControlConfig(int controlMode,
|
||||
int accelSamplesPerBatch,
|
||||
int accelBatchesPerSec,
|
||||
int gyroSamplesPerBatch,
|
||||
int gyroBatchesPerSec,
|
||||
int accelSamplesPerBatchHigh,
|
||||
int accelBatchesPerSecHigh,
|
||||
int gyroSamplesPerBatchHigh,
|
||||
int gyroBatchesPerSecHigh,
|
||||
int algorithmConfig);
|
||||
virtual enum loc_api_adapter_err
|
||||
setExtPowerConfig(int isBatteryCharging);
|
||||
virtual enum loc_api_adapter_err
|
||||
setAGLONASSProtocol(unsigned long aGlonassProtocol);
|
||||
virtual enum loc_api_adapter_err
|
||||
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
|
134
gps/core/LocDualContext.cpp
Normal file
134
gps/core/LocDualContext.cpp
Normal file
|
@ -0,0 +1,134 @@
|
|||
/* 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);
|
||||
} else if (tAssociate) {
|
||||
mMsgTask->associate(tAssociate);
|
||||
}
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
72
gps/core/LocDualContext.h
Normal file
72
gps/core/LocDualContext.h
Normal file
|
@ -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__
|
147
gps/core/MsgTask.cpp
Normal file
147
gps/core/MsgTask.cpp
Normal file
|
@ -0,0 +1,147 @@
|
|||
/* 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>
|
||||
|
||||
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::associate(tAssociate tAssociator) const {
|
||||
struct LocAssociateMsg : public LocMsg {
|
||||
tAssociate mAssociator;
|
||||
inline LocAssociateMsg(tAssociate associator) :
|
||||
LocMsg(), mAssociator(associator) {}
|
||||
inline virtual void proc() const {
|
||||
if (mAssociator) {
|
||||
LOC_LOGD("MsgTask::associate");
|
||||
mAssociator();
|
||||
}
|
||||
}
|
||||
};
|
||||
sendMsg(new LocAssociateMsg(tAssociator));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
67
gps/core/MsgTask.h
Normal file
67
gps/core/MsgTask.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* 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;
|
||||
void associate(tAssociate tAssociator) 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__
|
82
gps/core/UlpProxyBase.h
Normal file
82
gps/core/UlpProxyBase.h
Normal file
|
@ -0,0 +1,82 @@
|
|||
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef ULP_PROXY_BASE_H
|
||||
#define ULP_PROXY_BASE_H
|
||||
|
||||
#include <gps_extended.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
class LocAdapterBase;
|
||||
|
||||
class UlpProxyBase {
|
||||
public:
|
||||
LocPosMode mPosMode;
|
||||
bool mFixSet;
|
||||
inline UlpProxyBase() {
|
||||
mPosMode.mode = LOC_POSITION_MODE_INVALID;
|
||||
mFixSet = false;
|
||||
}
|
||||
inline virtual ~UlpProxyBase() {}
|
||||
inline virtual bool sendStartFix() { mFixSet = true; return false; }
|
||||
inline virtual bool sendStopFix() { mFixSet = false; return false; }
|
||||
inline virtual bool sendFixMode(LocPosMode ¶ms) {
|
||||
mPosMode = params;
|
||||
return false;
|
||||
}
|
||||
inline virtual bool reportPosition(UlpLocation &location,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* locationExt,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask loc_technology_mask) {
|
||||
return false;
|
||||
}
|
||||
inline virtual bool reportSv(GpsSvStatus &svStatus,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* svExt) {
|
||||
return false;
|
||||
}
|
||||
inline virtual bool reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline virtual bool reportSvPolynomial(GnssSvPolynomial &svPolynomial)
|
||||
{
|
||||
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
|
92
gps/core/gps_extended.h
Normal file
92
gps/core/gps_extended.h
Normal file
|
@ -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 */
|
||||
|
940
gps/core/gps_extended_c.h
Normal file
940
gps/core/gps_extended_c.h
Normal file
|
@ -0,0 +1,940 @@
|
|||
/* 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
|
||||
/** Position is from a Geofence Breach Event */
|
||||
#define ULP_LOCATION_IS_FROM_GEOFENCE 0X0008
|
||||
/** Position is from a Geofence Breach Event */
|
||||
#define ULP_LOCATION_IS_FROM_EXT_DR 0X0010
|
||||
|
||||
#define ULP_MIN_INTERVAL_INVALID 0xffffffff
|
||||
|
||||
/*Emergency SUPL*/
|
||||
#define GPS_NI_TYPE_EMERGENCY_SUPL 4
|
||||
|
||||
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_INTERNAL = 10,
|
||||
|
||||
/* equating engine down to phone offline, as they are the same errror */
|
||||
LOC_API_ADAPTER_ERR_ENGINE_DOWN = LOC_API_ADAPTER_ERR_PHONE_OFFLINE,
|
||||
LOC_API_ADAPTER_ERR_FAILURE = 101,
|
||||
LOC_API_ADAPTER_ERR_UNKNOWN
|
||||
};
|
||||
|
||||
enum loc_api_adapter_event_index {
|
||||
LOC_API_ADAPTER_REPORT_POSITION = 0, // Position report comes in loc_parsed_position_s_type
|
||||
LOC_API_ADAPTER_REPORT_SATELLITE, // Satellite in view report
|
||||
LOC_API_ADAPTER_REPORT_NMEA_1HZ, // NMEA report at 1HZ rate
|
||||
LOC_API_ADAPTER_REPORT_NMEA_POSITION, // NMEA report at position report rate
|
||||
LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY, // NI notification/verification request
|
||||
LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA, // Assistance data, eg: time, predicted orbits request
|
||||
LOC_API_ADAPTER_REQUEST_LOCATION_SERVER, // Request for location server
|
||||
LOC_API_ADAPTER_REPORT_IOCTL, // Callback report for loc_ioctl
|
||||
LOC_API_ADAPTER_REPORT_STATUS, // Misc status report: eg, engine state
|
||||
LOC_API_ADAPTER_REQUEST_WIFI, //
|
||||
LOC_API_ADAPTER_SENSOR_STATUS, //
|
||||
LOC_API_ADAPTER_REQUEST_TIME_SYNC, //
|
||||
LOC_API_ADAPTER_REPORT_SPI, //
|
||||
LOC_API_ADAPTER_REPORT_NI_GEOFENCE, //
|
||||
LOC_API_ADAPTER_GEOFENCE_GEN_ALERT, //
|
||||
LOC_API_ADAPTER_REPORT_GENFENCE_BREACH, //
|
||||
LOC_API_ADAPTER_PEDOMETER_CTRL, //
|
||||
LOC_API_ADAPTER_MOTION_CTRL, //
|
||||
LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA, // Wifi ap data
|
||||
LOC_API_ADAPTER_BATCH_FULL, // Batching on full
|
||||
LOC_API_ADAPTER_BATCHED_POSITION_REPORT, // Batching on fix
|
||||
LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT, //
|
||||
LOC_API_ADAPTER_GNSS_MEASUREMENT_REPORT, //GNSS Measurement Report
|
||||
LOC_API_ADAPTER_GNSS_SV_POLYNOMIAL_REPORT, //GNSS SV Polynomial Report
|
||||
|
||||
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_BATCHED_GENFENCE_BREACH_REPORT (1<<LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT)
|
||||
#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)
|
||||
#define LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT_REPORT (1<<LOC_API_ADAPTER_GNSS_MEASUREMENT_REPORT)
|
||||
#define LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT (1<<LOC_API_ADAPTER_GNSS_SV_POLYNOMIAL_REPORT)
|
||||
|
||||
|
||||
|
||||
typedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T;
|
||||
|
||||
/*++ ***********************************************
|
||||
** Satellite Measurement and Satellite Polynomial
|
||||
** Structure definitions
|
||||
** ***********************************************
|
||||
--*/
|
||||
#define GNSS_SV_POLY_VELOCITY_COEF_MAX_SIZE 12
|
||||
#define GNSS_SV_POLY_XYZ_0_TH_ORDER_COEFF_MAX_SIZE 3
|
||||
#define GNSS_SV_POLY_XYZ_N_TH_ORDER_COEFF_MAX_SIZE 9
|
||||
#define GNSS_SV_POLY_SV_CLKBIAS_COEFF_MAX_SIZE 4
|
||||
#define GNSS_LOC_SV_MEAS_LIST_MAX_SIZE 16
|
||||
|
||||
enum ulp_gnss_sv_measurement_valid_flags{
|
||||
|
||||
ULP_GNSS_SV_MEAS_GPS_TIME = 0,
|
||||
ULP_GNSS_SV_MEAS_PSUEDO_RANGE,
|
||||
ULP_GNSS_SV_MEAS_MS_IN_WEEK,
|
||||
ULP_GNSS_SV_MEAS_SUB_MSEC,
|
||||
ULP_GNSS_SV_MEAS_CARRIER_PHASE,
|
||||
ULP_GNSS_SV_MEAS_DOPPLER_SHIFT,
|
||||
ULP_GNSS_SV_MEAS_CNO,
|
||||
ULP_GNSS_SV_MEAS_LOSS_OF_LOCK,
|
||||
|
||||
ULP_GNSS_SV_MEAS_MAX_VALID_FLAGS
|
||||
};
|
||||
|
||||
#define ULP_GNSS_SV_MEAS_BIT_GPS_TIME (1<<ULP_GNSS_SV_MEAS_GPS_TIME)
|
||||
#define ULP_GNSS_SV_MEAS_BIT_PSUEDO_RANGE (1<<ULP_GNSS_SV_MEAS_PSUEDO_RANGE)
|
||||
#define ULP_GNSS_SV_MEAS_BIT_MS_IN_WEEK (1<<ULP_GNSS_SV_MEAS_MS_IN_WEEK)
|
||||
#define ULP_GNSS_SV_MEAS_BIT_SUB_MSEC (1<<ULP_GNSS_SV_MEAS_SUB_MSEC)
|
||||
#define ULP_GNSS_SV_MEAS_BIT_CARRIER_PHASE (1<<ULP_GNSS_SV_MEAS_CARRIER_PHASE)
|
||||
#define ULP_GNSS_SV_MEAS_BIT_DOPPLER_SHIFT (1<<ULP_GNSS_SV_MEAS_DOPPLER_SHIFT)
|
||||
#define ULP_GNSS_SV_MEAS_BIT_CNO (1<<ULP_GNSS_SV_MEAS_CNO)
|
||||
#define ULP_GNSS_SV_MEAS_BIT_LOSS_OF_LOCK (1<<ULP_GNSS_SV_MEAS_LOSS_OF_LOCK)
|
||||
|
||||
enum ulp_gnss_sv_poly_valid_flags{
|
||||
|
||||
ULP_GNSS_SV_POLY_GLO_FREQ = 0,
|
||||
ULP_GNSS_SV_POLY_T0,
|
||||
ULP_GNSS_SV_POLY_IODE,
|
||||
ULP_GNSS_SV_POLY_FLAG,
|
||||
ULP_GNSS_SV_POLY_POLYCOEFF_XYZ0,
|
||||
ULP_GNSS_SV_POLY_POLYCOEFF_XYZN,
|
||||
ULP_GNSS_SV_POLY_POLYCOEFF_OTHER,
|
||||
ULP_GNSS_SV_POLY_SV_POSUNC,
|
||||
ULP_GNSS_SV_POLY_IONODELAY,
|
||||
ULP_GNSS_SV_POLY_IONODOT,
|
||||
ULP_GNSS_SV_POLY_SBAS_IONODELAY,
|
||||
ULP_GNSS_SV_POLY_SBAS_IONODOT,
|
||||
ULP_GNSS_SV_POLY_TROPODELAY,
|
||||
ULP_GNSS_SV_POLY_ELEVATION,
|
||||
ULP_GNSS_SV_POLY_ELEVATIONDOT,
|
||||
ULP_GNSS_SV_POLY_ELEVATIONUNC,
|
||||
ULP_GNSS_SV_POLY_VELO_COEFF,
|
||||
|
||||
ULP_GNSS_SV_POLY_VALID_FLAGS
|
||||
|
||||
};
|
||||
|
||||
#define ULP_GNSS_SV_POLY_BIT_GLO_FREQ (1<<ULP_GNSS_SV_POLY_GLO_FREQ)
|
||||
#define ULP_GNSS_SV_POLY_BIT_T0 (1<<ULP_GNSS_SV_POLY_T0)
|
||||
#define ULP_GNSS_SV_POLY_BIT_IODE (1<<ULP_GNSS_SV_POLY_IODE)
|
||||
#define ULP_GNSS_SV_POLY_BIT_FLAG (1<<ULP_GNSS_SV_POLY_FLAG)
|
||||
#define ULP_GNSS_SV_POLY_BIT_POLYCOEFF_XYZ0 (1<<ULP_GNSS_SV_POLY_POLYCOEFF_XYZ0)
|
||||
#define ULP_GNSS_SV_POLY_BIT_POLYCOEFF_XYZN (1<<ULP_GNSS_SV_POLY_POLYCOEFF_XYZN)
|
||||
#define ULP_GNSS_SV_POLY_BIT_POLYCOEFF_OTHER (1<<ULP_GNSS_SV_POLY_POLYCOEFF_OTHER)
|
||||
#define ULP_GNSS_SV_POLY_BIT_SV_POSUNC (1<<ULP_GNSS_SV_POLY_SV_POSUNC)
|
||||
#define ULP_GNSS_SV_POLY_BIT_IONODELAY (1<<ULP_GNSS_SV_POLY_IONODELAY)
|
||||
#define ULP_GNSS_SV_POLY_BIT_IONODOT (1<<ULP_GNSS_SV_POLY_IONODOT)
|
||||
#define ULP_GNSS_SV_POLY_BIT_SBAS_IONODELAY (1<<ULP_GNSS_SV_POLY_SBAS_IONODELAY)
|
||||
#define ULP_GNSS_SV_POLY_BIT_SBAS_IONODOT (1<<ULP_GNSS_SV_POLY_SBAS_IONODOT)
|
||||
#define ULP_GNSS_SV_POLY_BIT_TROPODELAY (1<<ULP_GNSS_SV_POLY_TROPODELAY)
|
||||
#define ULP_GNSS_SV_POLY_BIT_ELEVATION (1<<ULP_GNSS_SV_POLY_ELEVATION)
|
||||
#define ULP_GNSS_SV_POLY_BIT_ELEVATIONDOT (1<<ULP_GNSS_SV_POLY_ELEVATIONDOT)
|
||||
#define ULP_GNSS_SV_POLY_BIT_ELEVATIONUNC (1<<ULP_GNSS_SV_POLY_ELEVATIONUNC)
|
||||
#define ULP_GNSS_SV_POLY_BIT_VELO_COEFF (1<<ULP_GNSS_SV_POLY_VELO_COEFF)
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GNSS_LOC_SV_SYSTEM_GPS = 1,
|
||||
/**< GPS satellite. */
|
||||
GNSS_LOC_SV_SYSTEM_GALILEO = 2,
|
||||
/**< GALILEO satellite. */
|
||||
GNSS_LOC_SV_SYSTEM_SBAS = 3,
|
||||
/**< SBAS satellite. */
|
||||
GNSS_LOC_SV_SYSTEM_COMPASS = 4,
|
||||
/**< COMPASS satellite. */
|
||||
GNSS_LOC_SV_SYSTEM_GLONASS = 5,
|
||||
/**< GLONASS satellite. */
|
||||
GNSS_LOC_SV_SYSTEM_BDS = 6
|
||||
/**< BDS satellite. */
|
||||
} Gnss_LocSvSystemEnumType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GNSS_LOC_FREQ_SOURCE_INVALID = 0,
|
||||
/**< Source of the frequency is invalid */
|
||||
GNSS_LOC_FREQ_SOURCE_EXTERNAL = 1,
|
||||
/**< Source of the frequency is from external injection */
|
||||
GNSS_LOC_FREQ_SOURCE_PE_CLK_REPORT = 2,
|
||||
/**< Source of the frequency is from Navigation engine */
|
||||
GNSS_LOC_FREQ_SOURCE_UNKNOWN = 3
|
||||
/**< Source of the frequency is unknown */
|
||||
} Gnss_LocSourceofFreqEnumType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t size;
|
||||
float clockDrift;
|
||||
/**< Receiver clock Drift \n
|
||||
- Units: meter per sec \n
|
||||
*/
|
||||
float clockDriftUnc;
|
||||
/**< Receiver clock Drift uncertainty \n
|
||||
- Units: meter per sec \n
|
||||
*/
|
||||
Gnss_LocSourceofFreqEnumType sourceOfFreq;
|
||||
}Gnss_LocRcvrClockFrequencyInfoStructType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t size;
|
||||
uint8_t leapSec;
|
||||
/**< GPS time leap second delta to UTC time \n
|
||||
- Units: sec \n
|
||||
*/
|
||||
uint8_t leapSecUnc;
|
||||
/**< Uncertainty for GPS leap second \n
|
||||
- Units: sec \n
|
||||
*/
|
||||
}Gnss_LeapSecondInfoStructType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GNSS_LOC_SYS_TIME_BIAS_VALID = 0x01,
|
||||
/**< System time bias valid */
|
||||
GNSS_LOC_SYS_TIME_BIAS_UNC_VALID = 0x02,
|
||||
/**< System time bias uncertainty valid */
|
||||
}Gnss_LocInterSystemBiasValidMaskType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t size;
|
||||
uint32_t validMask;
|
||||
/* Validity mask as per Gnss_LocInterSystemBiasValidMaskType */
|
||||
|
||||
float timeBias;
|
||||
/**< System-1 to System-2 Time Bias \n
|
||||
- Units: msec \n
|
||||
*/
|
||||
float timeBiasUnc;
|
||||
/**< System-1 to System-2 Time Bias uncertainty \n
|
||||
- Units: msec \n
|
||||
*/
|
||||
}Gnss_InterSystemBiasStructType;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t size;
|
||||
uint16_t systemWeek;
|
||||
/**< System week number for GPS, BDS and GAL satellite systems. \n
|
||||
Set to 65535 when invalid or not available. \n
|
||||
Not valid for GLONASS system. \n
|
||||
*/
|
||||
|
||||
uint32_t systemMsec;
|
||||
/**< System time msec. Time of Week for GPS, BDS, GAL and
|
||||
Time of Day for GLONASS.
|
||||
- Units: msec \n
|
||||
*/
|
||||
float systemClkTimeBias;
|
||||
/**< System clock time bias \n
|
||||
- Units: msec \n
|
||||
System time = systemMsec - systemClkTimeBias \n
|
||||
*/
|
||||
float systemClkTimeUncMs;
|
||||
/**< Single sided maximum time bias uncertainty \n
|
||||
- Units: msec \n
|
||||
*/
|
||||
}Gnss_LocSystemTimeStructType;
|
||||
|
||||
typedef struct {
|
||||
|
||||
size_t size;
|
||||
uint8_t gloFourYear;
|
||||
/**< GLONASS four year number from 1996. Refer to GLONASS ICD.\n
|
||||
Applicable only for GLONASS and shall be ignored for other constellations. \n
|
||||
If unknown shall be set to 255
|
||||
*/
|
||||
|
||||
uint16_t gloDays;
|
||||
/**< GLONASS day number in four years. Refer to GLONASS ICD.
|
||||
Applicable only for GLONASS and shall be ignored for other constellations. \n
|
||||
If unknown shall be set to 65535
|
||||
*/
|
||||
|
||||
uint32_t gloMsec;
|
||||
/**< GLONASS time of day in msec. Refer to GLONASS ICD.
|
||||
- Units: msec \n
|
||||
*/
|
||||
|
||||
float gloClkTimeBias;
|
||||
/**< System clock time bias (sub-millisecond) \n
|
||||
- Units: msec \n
|
||||
System time = systemMsec - systemClkTimeBias \n
|
||||
*/
|
||||
|
||||
float gloClkTimeUncMs;
|
||||
/**< Single sided maximum time bias uncertainty \n
|
||||
- Units: msec \n
|
||||
*/
|
||||
}Gnss_LocGloTimeStructType; /* Type */
|
||||
|
||||
typedef struct {
|
||||
|
||||
size_t size;
|
||||
uint32_t refFCount;
|
||||
/**< Receiver frame counter value at reference tick */
|
||||
|
||||
uint8_t systemRtc_valid;
|
||||
/**< Validity indicator for System RTC */
|
||||
|
||||
uint64_t systemRtcMs;
|
||||
/**< Platform system RTC value \n
|
||||
- Units: msec \n
|
||||
*/
|
||||
|
||||
uint32_t sourceOfTime;
|
||||
/**< Source of time information */
|
||||
|
||||
}Gnss_LocGnssTimeExtStructType;
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GNSS_LOC_MEAS_STATUS_NULL = 0x00000000,
|
||||
/**< No information state */
|
||||
GNSS_LOC_MEAS_STATUS_SM_VALID = 0x00000001,
|
||||
/**< Code phase is known */
|
||||
GNSS_LOC_MEAS_STATUS_SB_VALID = 0x00000002,
|
||||
/**< Sub-bit time is known */
|
||||
GNSS_LOC_MEAS_STATUS_MS_VALID = 0x00000004,
|
||||
/**< Satellite time is known */
|
||||
GNSS_LOC_MEAS_STATUS_BE_CONFIRM = 0x00000008,
|
||||
/**< Bit edge is confirmed from signal */
|
||||
GNSS_LOC_MEAS_STATUS_VELOCITY_VALID = 0x00000010,
|
||||
/**< Satellite Doppler measured */
|
||||
GNSS_LOC_MEAS_STATUS_VELOCITY_FINE = 0x00000020,
|
||||
/**< TRUE: Fine Doppler measured, FALSE: Coarse Doppler measured */
|
||||
GNSS_LOC_MEAS_STATUS_FROM_RNG_DIFF = 0x00000200,
|
||||
/**< Range update from Satellite differences */
|
||||
GNSS_LOC_MEAS_STATUS_FROM_VE_DIFF = 0x00000400,
|
||||
/**< Doppler update from Satellite differences */
|
||||
GNSS_LOC_MEAS_STATUS_DONT_USE_X = 0x00000800,
|
||||
/**< Don't use measurement if bit is set */
|
||||
GNSS_LOC_MEAS_STATUS_DONT_USE_M = 0x000001000,
|
||||
/**< Don't use measurement if bit is set */
|
||||
GNSS_LOC_MEAS_STATUS_DONT_USE_D = 0x000002000,
|
||||
/**< Don't use measurement if bit is set */
|
||||
GNSS_LOC_MEAS_STATUS_DONT_USE_S = 0x000004000,
|
||||
/**< Don't use measurement if bit is set */
|
||||
GNSS_LOC_MEAS_STATUS_DONT_USE_P = 0x000008000
|
||||
/**< Don't use measurement if bit is set */
|
||||
}Gnss_LocSvMeasStatusMaskType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t size;
|
||||
uint32_t svMs;
|
||||
/**< Satellite time milisecond.\n
|
||||
For GPS, BDS, GAL range of 0 thru (604800000-1) \n
|
||||
For GLONASS range of 0 thru (86400000-1) \n
|
||||
Valid when PD_LOC_MEAS_STATUS_MS_VALID bit is set in measurement status \n
|
||||
Note: All SV times in the current measurement block are alredy propagated to common reference time epoch. \n
|
||||
- Units: msec \n
|
||||
*/
|
||||
float svSubMs;
|
||||
/**<Satellite time sub-millisecond. \n
|
||||
Total SV Time = svMs + svSubMs \n
|
||||
- Units: msec \n
|
||||
*/
|
||||
float svTimeUncMs;
|
||||
/**< Satellite Time uncertainty \n
|
||||
- Units: msec \n
|
||||
*/
|
||||
float dopplerShift;
|
||||
/**< Satellite Doppler \n
|
||||
- Units: meter per sec \n
|
||||
*/
|
||||
float dopplerShiftUnc;
|
||||
/**< Satellite Doppler uncertainty\n
|
||||
- Units: meter per sec \n
|
||||
*/
|
||||
}Gnss_LocSVTimeSpeedStructType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GNSS_SV_STATE_IDLE = 0,
|
||||
GNSS_SV_STATE_SEARCH = 1,
|
||||
GNSS_SV_STATE_SEARCH_VERIFY = 2,
|
||||
GNSS_SV_STATE_BIT_EDGE = 3,
|
||||
GNSS_SV_STATE_VERIFY_TRACK = 4,
|
||||
GNSS_SV_STATE_TRACK = 5,
|
||||
GNSS_SV_STATE_RESTART = 6,
|
||||
GNSS_SV_STATE_DPO_TRACK = 7
|
||||
} Gnss_LocSVStateEnumType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GNSS_LOC_SVINFO_MASK_HAS_EPHEMERIS = 0x01,
|
||||
/**< Ephemeris is available for this SV */
|
||||
GNSS_LOC_SVINFO_MASK_HAS_ALMANAC = 0x02
|
||||
/**< Almanac is available for this SV */
|
||||
}Gnss_LocSvInfoMaskT;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GNSS_LOC_SV_SRCH_STATUS_IDLE = 1,
|
||||
/**< SV is not being actively processed */
|
||||
GNSS_LOC_SV_SRCH_STATUS_SEARCH = 2,
|
||||
/**< The system is searching for this SV */
|
||||
GNSS_LOC_SV_SRCH_STATUS_TRACK = 3
|
||||
/**< SV is being tracked */
|
||||
}Gnss_LocSvSearchStatusEnumT;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t size;
|
||||
uint16_t gnssSvId;
|
||||
/**< GNSS SV ID.
|
||||
\begin{itemize1}
|
||||
\item Range: \begin{itemize1}
|
||||
\item For GPS: 1 to 32
|
||||
\item For GLONASS: 1 to 32
|
||||
\item For SBAS: 120 to 151
|
||||
\item For BDS: 201 to 237
|
||||
\end{itemize1} \end{itemize1}
|
||||
The GPS and GLONASS SVs can be disambiguated using the system field.
|
||||
*/
|
||||
uint8_t gloFrequency;
|
||||
/**< GLONASS frequency number + 7 \n
|
||||
Valid only for GLONASS System \n
|
||||
Shall be ignored for all other systems \n
|
||||
- Range: 1 to 14 \n
|
||||
*/
|
||||
Gnss_LocSvSearchStatusEnumT svStatus;
|
||||
/**< Satellite search state \n
|
||||
@ENUM()
|
||||
*/
|
||||
bool healthStatus_valid;
|
||||
/**< SV Health Status validity flag\n
|
||||
- 0: Not valid \n
|
||||
- 1: Valid \n
|
||||
*/
|
||||
uint8_t healthStatus;
|
||||
/**< Health status.
|
||||
\begin{itemize1}
|
||||
\item Range: 0 to 1; 0 = unhealthy, \n 1 = healthy, 2 = unknown
|
||||
\vspace{-0.18in} \end{itemize1}
|
||||
*/
|
||||
Gnss_LocSvInfoMaskT svInfoMask;
|
||||
/**< Indicates whether almanac and ephemeris information is available. \n
|
||||
@MASK()
|
||||
*/
|
||||
uint64_t measurementStatus;
|
||||
/**< Bitmask indicating SV measurement status.
|
||||
Valid bitmasks: \n
|
||||
@MASK()
|
||||
*/
|
||||
uint16_t CNo;
|
||||
/**< Carrier to Noise ratio \n
|
||||
- Units: 0.1 dBHz \n
|
||||
*/
|
||||
uint16_t gloRfLoss;
|
||||
/**< GLONASS Rf loss reference to Antenna. \n
|
||||
- Units: dB, Scale: 0.1 \n
|
||||
*/
|
||||
bool lossOfLock;
|
||||
/**< Loss of signal lock indicator \n
|
||||
- 0: Signal in continuous track \n
|
||||
- 1: Signal not in track \n
|
||||
*/
|
||||
int16_t measLatency;
|
||||
/**< Age of the measurement. Positive value means measurement precedes ref time. \n
|
||||
- Units: msec \n
|
||||
*/
|
||||
Gnss_LocSVTimeSpeedStructType svTimeSpeed;
|
||||
/**< Unfiltered SV Time and Speed information
|
||||
*/
|
||||
float dopplerAccel;
|
||||
/**< Satellite Doppler Accelertion\n
|
||||
- Units: Hz/s \n
|
||||
*/
|
||||
bool multipathEstValid;
|
||||
/**< Multipath estimate validity flag\n
|
||||
- 0: Multipath estimate not valid \n
|
||||
- 1: Multipath estimate valid \n
|
||||
*/
|
||||
float multipathEstimate;
|
||||
/**< Estimate of multipath in measurement\n
|
||||
- Units: Meters \n
|
||||
*/
|
||||
bool fineSpeedValid;
|
||||
/**< Fine speed validity flag\n
|
||||
- 0: Fine speed not valid \n
|
||||
- 1: Fine speed valid \n
|
||||
*/
|
||||
float fineSpeed;
|
||||
/**< Carrier phase derived speed \n
|
||||
- Units: m/s \n
|
||||
*/
|
||||
bool fineSpeedUncValid;
|
||||
/**< Fine speed uncertainty validity flag\n
|
||||
- 0: Fine speed uncertainty not valid \n
|
||||
- 1: Fine speed uncertainty valid \n
|
||||
*/
|
||||
float fineSpeedUnc;
|
||||
/**< Carrier phase derived speed \n
|
||||
- Units: m/s \n
|
||||
*/
|
||||
bool carrierPhaseValid;
|
||||
/**< Carrier Phase measurement validity flag\n
|
||||
- 0: Carrier Phase not valid \n
|
||||
- 1: Carrier Phase valid \n
|
||||
*/
|
||||
double carrierPhase;
|
||||
/**< Carrier phase measurement [L1 cycles] \n
|
||||
*/
|
||||
bool cycleSlipCountValid;
|
||||
/**< Cycle slup count validity flag\n
|
||||
- 0: Not valid \n
|
||||
- 1: Valid \n
|
||||
*/
|
||||
uint8_t cycleSlipCount;
|
||||
/**< Increments when a CSlip is detected */
|
||||
|
||||
bool svDirectionValid;
|
||||
/**< Validity flag for SV direction */
|
||||
|
||||
float svAzimuth;
|
||||
/**< Satellite Azimuth
|
||||
- Units: radians \n
|
||||
*/
|
||||
float svElevation;
|
||||
/**< Satellite Elevation
|
||||
- Units: radians \n
|
||||
*/
|
||||
} Gnss_SVMeasurementStructType;
|
||||
|
||||
/**< Maximum number of satellites in measurement block for given system. */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t size;
|
||||
Gnss_LocSvSystemEnumType system;
|
||||
/**< Specifies the Satellite System Type
|
||||
*/
|
||||
bool isSystemTimeValid;
|
||||
/**< Indicates whether System Time is Valid:\n
|
||||
- 0x01 (TRUE) -- System Time is valid \n
|
||||
- 0x00 (FALSE) -- System Time is not valid
|
||||
*/
|
||||
Gnss_LocSystemTimeStructType systemTime;
|
||||
/**< System Time Information \n
|
||||
*/
|
||||
bool isGloTime_valid;
|
||||
Gnss_LocGloTimeStructType gloTime;
|
||||
|
||||
bool isSystemTimeExt_valid;
|
||||
Gnss_LocGnssTimeExtStructType systemTimeExt;
|
||||
|
||||
uint8_t numSvs;
|
||||
/* Number of SVs in this report block */
|
||||
|
||||
Gnss_SVMeasurementStructType svMeasurement[GNSS_LOC_SV_MEAS_LIST_MAX_SIZE];
|
||||
/**< Satellite measurement Information \n
|
||||
*/
|
||||
} Gnss_ClockMeasurementStructType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t size;
|
||||
uint8_t seqNum;
|
||||
/**< Current message Number */
|
||||
uint8_t maxMessageNum;
|
||||
/**< Maximum number of message that will be sent for present time epoch. */
|
||||
|
||||
bool leapSecValid;
|
||||
Gnss_LeapSecondInfoStructType leapSec;
|
||||
|
||||
Gnss_InterSystemBiasStructType gpsGloInterSystemBias;
|
||||
|
||||
Gnss_InterSystemBiasStructType gpsBdsInterSystemBias;
|
||||
|
||||
Gnss_InterSystemBiasStructType gpsGalInterSystemBias;
|
||||
|
||||
Gnss_InterSystemBiasStructType bdsGloInterSystemBias;
|
||||
|
||||
Gnss_InterSystemBiasStructType galGloInterSystemBias;
|
||||
|
||||
Gnss_InterSystemBiasStructType galBdsInterSystemBias;
|
||||
|
||||
bool clockFreqValid;
|
||||
Gnss_LocRcvrClockFrequencyInfoStructType clockFreq; /* Freq */
|
||||
bool gnssMeasValid;
|
||||
Gnss_ClockMeasurementStructType gnssMeas;
|
||||
} GnssSvMeasurementSet;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GNSS_SV_POLY_COEFF_VALID = 0x01,
|
||||
/**< SV position in orbit coefficients are valid */
|
||||
GNSS_SV_POLY_IONO_VALID = 0x02,
|
||||
/**< Iono estimates are valid */
|
||||
|
||||
GNSS_SV_POLY_TROPO_VALID = 0x04,
|
||||
/**< Tropo estimates are valid */
|
||||
|
||||
GNSS_SV_POLY_ELEV_VALID = 0x08,
|
||||
/**< Elevation, rate, uncertainty are valid */
|
||||
|
||||
GNSS_SV_POLY_SRC_ALM_CORR = 0x10,
|
||||
/**< Polynomials based on XTRA */
|
||||
|
||||
GNSS_SV_POLY_SBAS_IONO_VALID = 0x20,
|
||||
/**< SBAS IONO and rate are valid */
|
||||
|
||||
GNSS_SV_POLY_GLO_STR4 = 0x40
|
||||
/**< GLONASS String 4 has been received */
|
||||
}Gnss_SvPolyStatusMaskType;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t size;
|
||||
uint8_t gnssSvId;
|
||||
/* GPS: 1-32, GLO: 65-96, 0: Invalid
|
||||
All others are reserved
|
||||
*/
|
||||
int8_t freqNum;
|
||||
/* Freq index, only valid if u_SysInd is GLO */
|
||||
|
||||
uint8_t svPolyFlags;
|
||||
/* Indicate the validity of the elements
|
||||
as per Gnss_SvPolyStatusMaskType
|
||||
*/
|
||||
|
||||
uint16_t is_valid;
|
||||
|
||||
uint8_t iode;
|
||||
/* Ephemeris reference time
|
||||
GPS:Issue of Data Ephemeris used [unitless].
|
||||
GLO: Tb 7-bit, refer to ICD02
|
||||
*/
|
||||
double T0;
|
||||
/* Reference time for polynominal calculations
|
||||
GPS: Secs in week.
|
||||
GLO: Full secs since Jan/01/96
|
||||
*/
|
||||
double polyCoeffXYZ0[GNSS_SV_POLY_XYZ_0_TH_ORDER_COEFF_MAX_SIZE];
|
||||
/* C0X, C0Y, C0Z */
|
||||
double polyCoefXYZN[GNSS_SV_POLY_XYZ_N_TH_ORDER_COEFF_MAX_SIZE];
|
||||
/* C1X, C2X ... C2Z, C3Z */
|
||||
float polyCoefOther[GNSS_SV_POLY_SV_CLKBIAS_COEFF_MAX_SIZE];
|
||||
/* C0T, C1T, C2T, C3T */
|
||||
float svPosUnc; /* SV position uncertainty [m]. */
|
||||
float ionoDelay; /* Ionospheric delay at d_T0 [m]. */
|
||||
float ionoDot; /* Iono delay rate [m/s]. */
|
||||
float sbasIonoDelay;/* SBAS Ionospheric delay at d_T0 [m]. */
|
||||
float sbasIonoDot; /* SBAS Iono delay rate [m/s]. */
|
||||
float tropoDelay; /* Tropospheric delay [m]. */
|
||||
float elevation; /* Elevation [rad] at d_T0 */
|
||||
float elevationDot; /* Elevation rate [rad/s] */
|
||||
float elevationUnc; /* SV elevation [rad] uncertainty */
|
||||
double velCoef[GNSS_SV_POLY_VELOCITY_COEF_MAX_SIZE];
|
||||
/* Coefficients of velocity poly */
|
||||
} GnssSvPolynomial;
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* GPS_EXTENDED_C_H */
|
258
gps/core/loc_core_log.cpp
Normal file
258
gps/core/loc_core_log.cpp
Normal file
|
@ -0,0 +1,258 @@
|
|||
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_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 ),
|
||||
NAME_VAL( GPS_NI_TYPE_EMERGENCY_SUPL )
|
||||
};
|
||||
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_IPV6 ),
|
||||
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);
|
||||
}
|
58
gps/core/loc_core_log.h
Normal file
58
gps/core/loc_core_log.h
Normal file
|
@ -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 */
|
|
@ -9,7 +9,7 @@ BATCH_SIZE=20
|
|||
# GEOFENCE = 0x01
|
||||
# BATCHING = 0x02
|
||||
# default = GEOFENCE | BATCHING
|
||||
CAPABILITIES=0x00
|
||||
CAPABILITIES=0x03
|
||||
|
||||
# FLP accuracy
|
||||
# Low accuracy = 0
|
||||
|
|
3
gps/loc_api/Android.mk
Normal file
3
gps/loc_api/Android.mk
Normal file
|
@ -0,0 +1,3 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
101
gps/loc_api/libloc_api_50001/Android.mk
Normal file
101
gps/loc_api/libloc_api_50001/Android.mk
Normal file
|
@ -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 \
|
||||
$(LOCAL_PATH)
|
||||
|
||||
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.$(TARGET_BOARD_PLATFORM)
|
||||
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
|
321
gps/loc_api/libloc_api_50001/LocEngAdapter.cpp
Normal file
321
gps/loc_api/libloc_api_50001/LocEngAdapter.cpp
Normal file
|
@ -0,0 +1,321 @@
|
|||
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_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));
|
||||
}
|
||||
|
||||
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),
|
||||
mSupportsAgpsRequests(false),
|
||||
mSupportsPositionInjection(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 LocInternalAdapter::setUlpProxy(UlpProxyBase* ulp) {
|
||||
struct LocSetUlpProxy : public LocMsg {
|
||||
LocAdapterBase* mAdapter;
|
||||
UlpProxyBase* mUlp;
|
||||
inline LocSetUlpProxy(LocAdapterBase* adapter, UlpProxyBase* ulp) :
|
||||
LocMsg(), mAdapter(adapter), mUlp(ulp) {
|
||||
}
|
||||
virtual void proc() const {
|
||||
LOC_LOGV("%s] ulp %p adapter %p", __func__,
|
||||
mUlp, mAdapter);
|
||||
mAdapter->setUlpProxy(mUlp);
|
||||
}
|
||||
};
|
||||
|
||||
sendMsg(new LocSetUlpProxy(mLocEngAdapter, ulp));
|
||||
}
|
||||
|
||||
void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp)
|
||||
{
|
||||
if (ulp == mUlp) {
|
||||
//This takes care of the case when double initalization happens
|
||||
//and we get the same object back for UlpProxyBase . Do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
LOC_LOGV("%s] %p", __func__, ulp);
|
||||
if (NULL == ulp) {
|
||||
LOC_LOGE("%s:%d]: ulp pointer is NULL", __func__, __LINE__);
|
||||
ulp = new UlpProxyBase();
|
||||
}
|
||||
|
||||
if (LOC_POSITION_MODE_INVALID != mUlp->mPosMode.mode) {
|
||||
// need to send this mode and start msg to ULP
|
||||
ulp->sendFixMode(mUlp->mPosMode);
|
||||
}
|
||||
|
||||
if(mUlp->mFixSet) {
|
||||
ulp->sendStartFix();
|
||||
}
|
||||
|
||||
delete mUlp;
|
||||
mUlp = ulp;
|
||||
}
|
||||
|
||||
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::reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet)
|
||||
{
|
||||
// We send SvMeasurementSet to AmtProxy/ULPProxy to be forwarded as necessary.
|
||||
if (! mUlp->reportSvMeasurement(svMeasurementSet)) {
|
||||
//Send to Internal Adapter later if needed by LA
|
||||
}
|
||||
}
|
||||
|
||||
void LocEngAdapter::reportSvPolynomial(GnssSvPolynomial &svPolynomial)
|
||||
{
|
||||
// We send SvMeasurementSet to AmtProxy/ULPProxy to be forwarded as necessary.
|
||||
if (! mUlp->reportSvPolynomial(svPolynomial)) {
|
||||
//Send to Internal Adapter later if needed by LA
|
||||
}
|
||||
}
|
||||
|
||||
void LocEngAdapter::setInSession(bool inSession)
|
||||
{
|
||||
mNavigating = inSession;
|
||||
mLocApi->setInSession(inSession);
|
||||
if (!mNavigating) {
|
||||
mFixCriteria.mode = LOC_POSITION_MODE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
void LocInternalAdapter::reportStatus(GpsStatusValue status)
|
||||
{
|
||||
sendMsg(new LocEngReportStatus(mLocEngAdapter, status));
|
||||
}
|
||||
|
||||
void LocEngAdapter::reportStatus(GpsStatusValue status)
|
||||
{
|
||||
if (!mUlp->reportStatus(status)) {
|
||||
mInternalAdapter->reportStatus(status);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void LocEngAdapter::reportNmea(const char* nmea, int length)
|
||||
{
|
||||
sendMsg(new LocEngReportNmea(mOwner, nmea, length));
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::reportXtraServer(const char* url1,
|
||||
const char* url2,
|
||||
const char* url3,
|
||||
const int maxlength)
|
||||
{
|
||||
if (mSupportsAgpsRequests) {
|
||||
sendMsg(new LocEngReportXtraServer(mOwner, url1,
|
||||
url2, url3, maxlength));
|
||||
}
|
||||
return mSupportsAgpsRequests;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::requestATL(int connHandle, AGpsType agps_type)
|
||||
{
|
||||
if (mSupportsAgpsRequests) {
|
||||
sendMsg(new LocEngRequestATL(mOwner,
|
||||
connHandle, agps_type));
|
||||
}
|
||||
return mSupportsAgpsRequests;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::releaseATL(int connHandle)
|
||||
{
|
||||
if (mSupportsAgpsRequests) {
|
||||
sendMsg(new LocEngReleaseATL(mOwner, connHandle));
|
||||
}
|
||||
return mSupportsAgpsRequests;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::requestXtraData()
|
||||
{
|
||||
if (mSupportsAgpsRequests) {
|
||||
sendMsg(new LocEngRequestXtra(mOwner));
|
||||
}
|
||||
return mSupportsAgpsRequests;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::requestTime()
|
||||
{
|
||||
if (mSupportsAgpsRequests) {
|
||||
sendMsg(new LocEngRequestTime(mOwner));
|
||||
}
|
||||
return mSupportsAgpsRequests;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::requestNiNotify(GpsNiNotification ¬if, const void* data)
|
||||
{
|
||||
if (mSupportsAgpsRequests) {
|
||||
notif.size = sizeof(notif);
|
||||
notif.timeout = LOC_NI_NO_RESPONSE_TIME;
|
||||
|
||||
sendMsg(new LocEngRequestNi(mOwner, notif, data));
|
||||
}
|
||||
return mSupportsAgpsRequests;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::requestSuplES(int connHandle)
|
||||
{
|
||||
if (mSupportsAgpsRequests)
|
||||
sendMsg(new LocEngRequestSuplEs(mOwner, connHandle));
|
||||
return mSupportsAgpsRequests;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::reportDataCallOpened()
|
||||
{
|
||||
if(mSupportsAgpsRequests)
|
||||
sendMsg(new LocEngSuplEsOpened(mOwner));
|
||||
return mSupportsAgpsRequests;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::reportDataCallClosed()
|
||||
{
|
||||
if(mSupportsAgpsRequests)
|
||||
sendMsg(new LocEngSuplEsClosed(mOwner));
|
||||
return mSupportsAgpsRequests;
|
||||
}
|
||||
|
||||
inline
|
||||
void LocEngAdapter::handleEngineDownEvent()
|
||||
{
|
||||
sendMsg(new LocEngDown(mOwner));
|
||||
}
|
||||
|
||||
inline
|
||||
void LocEngAdapter::handleEngineUpEvent()
|
||||
{
|
||||
sendMsg(new LocEngUp(mOwner));
|
||||
}
|
305
gps/loc_api/libloc_api_50001/LocEngAdapter.h
Normal file
305
gps/loc_api/libloc_api_50001/LocEngAdapter.h
Normal file
|
@ -0,0 +1,305 @@
|
|||
/* 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 mSupportsAgpsRequests;
|
||||
bool mSupportsPositionInjection;
|
||||
|
||||
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 hasAgpsExtendedCapabilities() {
|
||||
return mContext->hasAgpsExtendedCapabilities();
|
||||
}
|
||||
inline bool hasCPIExtendedCapabilities() {
|
||||
return mContext->hasCPIExtendedCapabilities();
|
||||
}
|
||||
inline const MsgTask* getMsgTask() { return mMsgTask; }
|
||||
|
||||
inline enum loc_api_adapter_err
|
||||
startFix()
|
||||
{
|
||||
return mLocApi->startFix(mFixCriteria);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
stopFix()
|
||||
{
|
||||
return mLocApi->stopFix();
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
deleteAidingData(GpsAidingData f)
|
||||
{
|
||||
return mLocApi->deleteAidingData(f);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
enableData(int enable)
|
||||
{
|
||||
return mLocApi->enableData(enable);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
setAPN(char* apn, int len)
|
||||
{
|
||||
return mLocApi->setAPN(apn, len);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
injectPosition(double latitude, double longitude, float accuracy)
|
||||
{
|
||||
return mLocApi->injectPosition(latitude, longitude, accuracy);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
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, int sensorProvider)
|
||||
{
|
||||
return mLocApi->setSensorControlConfig(sensorUsage, sensorProvider);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, float gyroBiasVarianceRandomWalk,
|
||||
bool accelBiasVarianceRandomWalk_valid, float accelBiasVarianceRandomWalk,
|
||||
bool angleBiasVarianceRandomWalk_valid, float angleBiasVarianceRandomWalk,
|
||||
bool rateBiasVarianceRandomWalk_valid, float rateBiasVarianceRandomWalk,
|
||||
bool velocityBiasVarianceRandomWalk_valid, float velocityBiasVarianceRandomWalk)
|
||||
{
|
||||
return mLocApi->setSensorProperties(gyroBiasVarianceRandomWalk_valid, gyroBiasVarianceRandomWalk,
|
||||
accelBiasVarianceRandomWalk_valid, accelBiasVarianceRandomWalk,
|
||||
angleBiasVarianceRandomWalk_valid, angleBiasVarianceRandomWalk,
|
||||
rateBiasVarianceRandomWalk_valid, rateBiasVarianceRandomWalk,
|
||||
velocityBiasVarianceRandomWalk_valid, velocityBiasVarianceRandomWalk);
|
||||
}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setSensorPerfControlConfig(int controlMode, int accelSamplesPerBatch, int accelBatchesPerSec,
|
||||
int gyroSamplesPerBatch, int gyroBatchesPerSec,
|
||||
int accelSamplesPerBatchHigh, int accelBatchesPerSecHigh,
|
||||
int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh, int algorithmConfig)
|
||||
{
|
||||
return mLocApi->setSensorPerfControlConfig(controlMode, accelSamplesPerBatch, accelBatchesPerSec,
|
||||
gyroSamplesPerBatch, gyroBatchesPerSec,
|
||||
accelSamplesPerBatchHigh, accelBatchesPerSecHigh,
|
||||
gyroSamplesPerBatchHigh, gyroBatchesPerSecHigh,
|
||||
algorithmConfig);
|
||||
}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setExtPowerConfig(int isBatteryCharging)
|
||||
{
|
||||
return mLocApi->setExtPowerConfig(isBatteryCharging);
|
||||
}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setAGLONASSProtocol(unsigned long aGlonassProtocol)
|
||||
{
|
||||
return mLocApi->setAGLONASSProtocol(aGlonassProtocol);
|
||||
}
|
||||
inline virtual int initDataServiceClient()
|
||||
{
|
||||
return mLocApi->initDataServiceClient();
|
||||
}
|
||||
inline virtual int openAndStartDataCall()
|
||||
{
|
||||
return mLocApi->openAndStartDataCall();
|
||||
}
|
||||
inline virtual void stopDataCall()
|
||||
{
|
||||
mLocApi->stopDataCall();
|
||||
}
|
||||
inline virtual void closeDataCall()
|
||||
{
|
||||
mLocApi->closeDataCall();
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
getZpp(GpsLocation &zppLoc, LocPosTechMask &tech_mask)
|
||||
{
|
||||
return mLocApi->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 reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet);
|
||||
virtual void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
|
||||
virtual void reportStatus(GpsStatusValue status);
|
||||
virtual void reportNmea(const char* nmea, int length);
|
||||
virtual bool reportXtraServer(const char* url1, const char* url2,
|
||||
const char* url3, const int maxlength);
|
||||
virtual bool requestXtraData();
|
||||
virtual bool requestTime();
|
||||
virtual bool requestATL(int connHandle, AGpsType agps_type);
|
||||
virtual bool releaseATL(int connHandle);
|
||||
virtual bool requestNiNotify(GpsNiNotification ¬ify, const void* data);
|
||||
virtual bool requestSuplES(int connHandle);
|
||||
virtual bool reportDataCallOpened();
|
||||
virtual bool reportDataCallClosed();
|
||||
|
||||
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
|
72
gps/loc_api/libloc_api_50001/gps.c
Normal file
72
gps/loc_api/libloc_api_50001/gps.c
Normal file
|
@ -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,
|
||||
};
|
900
gps/loc_api/libloc_api_50001/loc.cpp
Normal file
900
gps/loc_api/libloc_api_50001/loc.cpp
Normal file
|
@ -0,0 +1,900 @@
|
|||
/* 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:
|
||||
case GNSS_AUTO:
|
||||
//APQ8064
|
||||
gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB);
|
||||
gss_fd = open("/dev/gss", O_RDONLY);
|
||||
if (gss_fd < 0) {
|
||||
LOC_LOGE("GSS open failed: %s\n", strerror(errno));
|
||||
}
|
||||
else {
|
||||
LOC_LOGD("GSS open success! CAPABILITIES %0lx\n",
|
||||
gps_conf.CAPABILITIES);
|
||||
}
|
||||
break;
|
||||
case GNSS_NONE:
|
||||
//MPQ8064
|
||||
LOC_LOGE("No GPS HW on this target. Not returning interface.");
|
||||
return NULL;
|
||||
case GNSS_QCA1530:
|
||||
// qca1530 chip is present
|
||||
gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB);
|
||||
LOC_LOGD("qca1530 present: CAPABILITIES %0lx\n", gps_conf.CAPABILITIES);
|
||||
break;
|
||||
}
|
||||
return &sLocEngInterface;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION loc_init
|
||||
|
||||
DESCRIPTION
|
||||
Initialize the location engine, this include setting up global datas
|
||||
and registers location engien with loc api service.
|
||||
|
||||
DEPENDENCIES
|
||||
None
|
||||
|
||||
RETURN VALUE
|
||||
0: success
|
||||
|
||||
SIDE EFFECTS
|
||||
N/Ax
|
||||
|
||||
===========================================================================*/
|
||||
static int loc_init(GpsCallbacks* callbacks)
|
||||
{
|
||||
int retVal = -1;
|
||||
unsigned int target = (unsigned int) -1;
|
||||
LOC_API_ADAPTER_EVENT_MASK_T event;
|
||||
ENTRY_LOG();
|
||||
|
||||
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;
|
||||
|
||||
target = loc_get_target();
|
||||
|
||||
/*For "auto" platform enable Measurement report and SV Polynomial report*/
|
||||
if(GNSS_AUTO == getTargetGnssType(target))
|
||||
{
|
||||
event |= LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT_REPORT |
|
||||
LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT;
|
||||
}
|
||||
|
||||
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->mSupportsAgpsRequests = !loc_afw_data.adapter->hasAgpsExtendedCapabilities();
|
||||
loc_afw_data.adapter->mSupportsPositionInjection = !loc_afw_data.adapter->hasCPIExtendedCapabilities();
|
||||
|
||||
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)
|
||||
{
|
||||
ENTRY_LOG();
|
||||
|
||||
int ret_val = 0;
|
||||
ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy);
|
||||
|
||||
EXIT_LOG(%d, ret_val);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION loc_delete_aiding_data
|
||||
|
||||
DESCRIPTION
|
||||
This is used by Java native function to delete the aiding data. The function
|
||||
updates the global variable for the aiding data to be deleted. If the GPS
|
||||
engine is off, the aiding data will be deleted. Otherwise, the actual action
|
||||
will happen when gps engine is turned off.
|
||||
|
||||
DEPENDENCIES
|
||||
Assumes the aiding data type specified in GpsAidingData matches with
|
||||
LOC API specification.
|
||||
|
||||
RETURN VALUE
|
||||
None
|
||||
|
||||
SIDE EFFECTS
|
||||
N/A
|
||||
|
||||
===========================================================================*/
|
||||
static void loc_delete_aiding_data(GpsAidingData f)
|
||||
{
|
||||
ENTRY_LOG();
|
||||
loc_eng_delete_aiding_data(loc_afw_data, f);
|
||||
|
||||
EXIT_LOG(%s, VOID_RET);
|
||||
}
|
||||
|
||||
const GpsGeofencingInterface* get_geofence_interface(void)
|
||||
{
|
||||
ENTRY_LOG();
|
||||
void *handle;
|
||||
const char *error;
|
||||
typedef const GpsGeofencingInterface* (*get_gps_geofence_interface_function) (void);
|
||||
get_gps_geofence_interface_function get_gps_geofence_interface;
|
||||
static const GpsGeofencingInterface* geofence_interface = NULL;
|
||||
|
||||
dlerror(); /* Clear any existing error */
|
||||
|
||||
handle = dlopen ("libgeofence.so", RTLD_NOW);
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
if ((error = dlerror()) != NULL) {
|
||||
LOC_LOGE ("%s, dlopen for libgeofence.so failed, error = %s\n", __func__, error);
|
||||
}
|
||||
goto exit;
|
||||
}
|
||||
dlerror(); /* Clear any existing error */
|
||||
get_gps_geofence_interface = (get_gps_geofence_interface_function)dlsym(handle, "gps_geofence_get_interface");
|
||||
if ((error = dlerror()) != NULL && NULL != get_gps_geofence_interface) {
|
||||
LOC_LOGE ("%s, dlsym for get_gps_geofence_interface failed, error = %s\n", __func__, error);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
geofence_interface = get_gps_geofence_interface();
|
||||
|
||||
exit:
|
||||
EXIT_LOG(%d, geofence_interface == NULL);
|
||||
return geofence_interface;
|
||||
}
|
||||
/*===========================================================================
|
||||
FUNCTION loc_get_extension
|
||||
|
||||
DESCRIPTION
|
||||
Get the gps extension to support XTRA.
|
||||
|
||||
DEPENDENCIES
|
||||
N/A
|
||||
|
||||
RETURN VALUE
|
||||
The GPS extension interface.
|
||||
|
||||
SIDE EFFECTS
|
||||
N/A
|
||||
|
||||
===========================================================================*/
|
||||
const void* loc_get_extension(const char* name)
|
||||
{
|
||||
ENTRY_LOG();
|
||||
const void* ret_val = NULL;
|
||||
|
||||
LOC_LOGD("%s:%d] For Interface = %s\n",__func__, __LINE__, name);
|
||||
if (strcmp(name, GPS_XTRA_INTERFACE) == 0)
|
||||
{
|
||||
ret_val = &sLocEngXTRAInterface;
|
||||
}
|
||||
else if (strcmp(name, AGPS_INTERFACE) == 0)
|
||||
{
|
||||
ret_val = &sLocEngAGpsInterface;
|
||||
}
|
||||
else if (strcmp(name, GPS_NI_INTERFACE) == 0)
|
||||
{
|
||||
ret_val = &sLocEngNiInterface;
|
||||
}
|
||||
else if (strcmp(name, AGPS_RIL_INTERFACE) == 0)
|
||||
{
|
||||
char baseband[PROPERTY_VALUE_MAX];
|
||||
property_get("ro.baseband", baseband, "msm");
|
||||
if (strcmp(baseband, "csfb") == 0)
|
||||
{
|
||||
ret_val = &sLocEngAGpsRilInterface;
|
||||
}
|
||||
}
|
||||
else if (strcmp(name, GPS_GEOFENCING_INTERFACE) == 0)
|
||||
{
|
||||
if ((gps_conf.CAPABILITIES | GPS_CAPABILITY_GEOFENCING) == gps_conf.CAPABILITIES ){
|
||||
ret_val = get_geofence_interface();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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 = -1;
|
||||
if( (data != NULL) && ((unsigned int)length <= XTRA_DATA_MAX_SIZE))
|
||||
ret_val = loc_eng_xtra_inject_data(loc_afw_data, data, length);
|
||||
else
|
||||
LOC_LOGE("%s, Could not inject XTRA data. Buffer address: %p, length: %d",
|
||||
__func__, data, length);
|
||||
EXIT_LOG(%d, ret_val);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION loc_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);
|
||||
}
|
66
gps/loc_api/libloc_api_50001/loc.h
Normal file
66
gps/loc_api/libloc_api_50001/loc.h
Normal file
|
@ -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 __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>
|
||||
|
||||
#define XTRA_DATA_MAX_SIZE 100000 /*bytes*/
|
||||
|
||||
typedef void (*loc_location_cb_ext) (UlpLocation* location, void* locExt);
|
||||
typedef void (*loc_sv_status_cb_ext) (GpsSvStatus* sv_status, void* svExt);
|
||||
typedef void* (*loc_ext_parser)(void* data);
|
||||
|
||||
typedef struct {
|
||||
loc_location_cb_ext location_cb;
|
||||
gps_status_callback status_cb;
|
||||
loc_sv_status_cb_ext sv_status_cb;
|
||||
gps_nmea_callback nmea_cb;
|
||||
gps_set_capabilities set_capabilities_cb;
|
||||
gps_acquire_wakelock acquire_wakelock_cb;
|
||||
gps_release_wakelock release_wakelock_cb;
|
||||
gps_create_thread create_thread_cb;
|
||||
loc_ext_parser location_ext_parser;
|
||||
loc_ext_parser sv_ext_parser;
|
||||
gps_request_utc_time request_utc_time_cb;
|
||||
} LocCallbacks;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif //__LOC_H__
|
2638
gps/loc_api/libloc_api_50001/loc_eng.cpp
Normal file
2638
gps/loc_api/libloc_api_50001/loc_eng.cpp
Normal file
File diff suppressed because it is too large
Load diff
248
gps/loc_api/libloc_api_50001/loc_eng.h
Normal file
248
gps/loc_api/libloc_api_50001/loc_eng.h
Normal file
|
@ -0,0 +1,248 @@
|
|||
/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LOC_ENG_H
|
||||
#define LOC_ENG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
// Uncomment to keep all LOG messages (LOGD, LOGI, LOGV, etc.)
|
||||
#define MAX_NUM_ATL_CONNECTIONS 2
|
||||
|
||||
// Define boolean type to be used by libgps on loc api module
|
||||
typedef unsigned char boolean;
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#include <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
|
||||
|
||||
#define MAX_XTRA_SERVER_URL_LENGTH 256
|
||||
|
||||
enum loc_nmea_provider_e_type {
|
||||
NMEA_PROVIDER_AP = 0, // Application Processor Provider of NMEA
|
||||
NMEA_PROVIDER_MP // Modem Processor Provider of NMEA
|
||||
};
|
||||
|
||||
enum loc_mute_session_e_type {
|
||||
LOC_MUTE_SESS_NONE = 0,
|
||||
LOC_MUTE_SESS_WAIT,
|
||||
LOC_MUTE_SESS_IN_SESSION
|
||||
};
|
||||
|
||||
// Module data
|
||||
typedef struct loc_eng_data_s
|
||||
{
|
||||
LocEngAdapter *adapter;
|
||||
loc_location_cb_ext location_cb;
|
||||
gps_status_callback status_cb;
|
||||
loc_sv_status_cb_ext sv_status_cb;
|
||||
agps_status_extended agps_status_cb;
|
||||
gps_nmea_callback nmea_cb;
|
||||
gps_ni_notify_callback ni_notify_cb;
|
||||
gps_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;
|
||||
unsigned long XTRA_VERSION_CHECK;
|
||||
char XTRA_SERVER_1[MAX_XTRA_SERVER_URL_LENGTH];
|
||||
char XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH];
|
||||
char XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH];
|
||||
} 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;
|
||||
unsigned long SENSOR_PROVIDER;
|
||||
} 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 ¶ms);
|
||||
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
|
970
gps/loc_api/libloc_api_50001/loc_eng_agps.cpp
Normal file
970
gps/loc_api/libloc_api_50001/loc_eng_agps.cpp
Normal file
|
@ -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 ¬ification)
|
||||
{
|
||||
if (NULL != notification.rcver) {
|
||||
return equals(notification.rcver);
|
||||
} else {
|
||||
return Notification::BROADCAST_ALL == notification.groupID ||
|
||||
(Notification::BROADCAST_ACTIVE == notification.groupID &&
|
||||
!isInactive()) ||
|
||||
(Notification::BROADCAST_INACTIVE == notification.groupID &&
|
||||
isInactive());
|
||||
}
|
||||
}
|
||||
bool BITSubscriber::equals(const Subscriber *s) const
|
||||
{
|
||||
BITSubscriber* bitS = (BITSubscriber*)s;
|
||||
|
||||
return (ID == bitS->ID &&
|
||||
(INADDR_NONE != (unsigned int)ID ||
|
||||
0 == strncmp(mIPv6Addr, bitS->mIPv6Addr, sizeof(mIPv6Addr))));
|
||||
}
|
||||
|
||||
bool BITSubscriber::notifyRsrcStatus(Notification ¬ification)
|
||||
{
|
||||
bool notify = forMe(notification);
|
||||
|
||||
if (notify) {
|
||||
switch(notification.rsrcStatus)
|
||||
{
|
||||
case RSRC_UNSUBSCRIBE:
|
||||
case RSRC_RELEASED:
|
||||
loc_eng_dmn_conn_loc_api_server_data_conn(
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
|
||||
GPSONE_LOC_API_IF_RELEASE_SUCCESS);
|
||||
break;
|
||||
case RSRC_DENIED:
|
||||
loc_eng_dmn_conn_loc_api_server_data_conn(
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
|
||||
GPSONE_LOC_API_IF_FAILURE);
|
||||
break;
|
||||
case RSRC_GRANTED:
|
||||
loc_eng_dmn_conn_loc_api_server_data_conn(
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
|
||||
GPSONE_LOC_API_IF_REQUEST_SUCCESS);
|
||||
break;
|
||||
default:
|
||||
notify = false;
|
||||
}
|
||||
}
|
||||
|
||||
return notify;
|
||||
}
|
||||
|
||||
bool ATLSubscriber::notifyRsrcStatus(Notification ¬ification)
|
||||
{
|
||||
bool notify = forMe(notification);
|
||||
|
||||
if (notify) {
|
||||
switch(notification.rsrcStatus)
|
||||
{
|
||||
case RSRC_UNSUBSCRIBE:
|
||||
case RSRC_RELEASED:
|
||||
((LocEngAdapter*)mLocAdapter)->atlCloseStatus(ID, 1);
|
||||
break;
|
||||
case RSRC_DENIED:
|
||||
{
|
||||
AGpsExtType type = mBackwardCompatibleMode ?
|
||||
AGPS_TYPE_INVALID : mStateMachine->getType();
|
||||
((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 0,
|
||||
(char*)mStateMachine->getAPN(),
|
||||
mStateMachine->getBearer(),
|
||||
type);
|
||||
}
|
||||
break;
|
||||
case RSRC_GRANTED:
|
||||
{
|
||||
AGpsExtType type = mBackwardCompatibleMode ?
|
||||
AGPS_TYPE_INVALID : mStateMachine->getType();
|
||||
((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 1,
|
||||
(char*)mStateMachine->getAPN(),
|
||||
mStateMachine->getBearer(),
|
||||
type);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
notify = false;
|
||||
}
|
||||
}
|
||||
|
||||
return notify;
|
||||
}
|
||||
|
||||
bool WIFISubscriber::notifyRsrcStatus(Notification ¬ification)
|
||||
{
|
||||
bool notify = forMe(notification);
|
||||
|
||||
if (notify) {
|
||||
switch(notification.rsrcStatus)
|
||||
{
|
||||
case RSRC_UNSUBSCRIBE:
|
||||
break;
|
||||
case RSRC_RELEASED:
|
||||
loc_eng_dmn_conn_loc_api_server_data_conn(
|
||||
senderId,
|
||||
GPSONE_LOC_API_IF_RELEASE_SUCCESS);
|
||||
break;
|
||||
case RSRC_DENIED:
|
||||
loc_eng_dmn_conn_loc_api_server_data_conn(
|
||||
senderId,
|
||||
GPSONE_LOC_API_IF_FAILURE);
|
||||
break;
|
||||
case RSRC_GRANTED:
|
||||
loc_eng_dmn_conn_loc_api_server_data_conn(
|
||||
senderId,
|
||||
GPSONE_LOC_API_IF_REQUEST_SUCCESS);
|
||||
break;
|
||||
default:
|
||||
notify = false;
|
||||
}
|
||||
}
|
||||
|
||||
return notify;
|
||||
}
|
||||
bool DSSubscriber::notifyRsrcStatus(Notification ¬ification)
|
||||
{
|
||||
bool notify = forMe(notification);
|
||||
LOC_LOGD("DSSubscriber::notifyRsrcStatus. notify:%d \n",(int)(notify));
|
||||
if(notify) {
|
||||
switch(notification.rsrcStatus) {
|
||||
case RSRC_UNSUBSCRIBE:
|
||||
case RSRC_RELEASED:
|
||||
case RSRC_DENIED:
|
||||
case RSRC_GRANTED:
|
||||
((DSStateMachine *)mStateMachine)->informStatus(notification.rsrcStatus, ID);
|
||||
break;
|
||||
default:
|
||||
notify = false;
|
||||
}
|
||||
}
|
||||
return notify;
|
||||
}
|
||||
void DSSubscriber :: setInactive()
|
||||
{
|
||||
mIsInactive = true;
|
||||
((DSStateMachine *)mStateMachine)->informStatus(RSRC_UNSUBSCRIBE, ID);
|
||||
}
|
||||
//======================================================================
|
||||
// AgpsState: AgpsReleasedState / AgpsPendingState / AgpsAcquiredState
|
||||
//======================================================================
|
||||
|
||||
// AgpsReleasedState
|
||||
class AgpsReleasedState : public AgpsState
|
||||
{
|
||||
friend class AgpsStateMachine;
|
||||
|
||||
inline AgpsReleasedState(AgpsStateMachine* stateMachine) :
|
||||
AgpsState(stateMachine)
|
||||
{ mReleasedState = this; }
|
||||
|
||||
inline ~AgpsReleasedState() {}
|
||||
public:
|
||||
virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);
|
||||
inline virtual char* whoami() {return (char*)"AgpsReleasedState";}
|
||||
};
|
||||
|
||||
AgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data)
|
||||
{
|
||||
LOC_LOGD("AgpsReleasedState::onRsrcEvent; event:%d\n", (int)event);
|
||||
if (mStateMachine->hasSubscribers()) {
|
||||
LOC_LOGE("Error: %s subscriber list not empty!!!", whoami());
|
||||
// I don't know how to recover from it. I am adding this rather
|
||||
// for debugging purpose.
|
||||
}
|
||||
|
||||
AgpsState* nextState = this;
|
||||
switch (event)
|
||||
{
|
||||
case RSRC_SUBSCRIBE:
|
||||
{
|
||||
// no notification until we get RSRC_GRANTED
|
||||
// but we need to add subscriber to the list
|
||||
mStateMachine->addSubscriber((Subscriber*)data);
|
||||
// request from connecivity service for NIF
|
||||
//The if condition is added so that if the data call setup fails
|
||||
//for DS State Machine, we want to retry in released state.
|
||||
//for AGps State Machine, sendRsrcRequest() will always return success
|
||||
if(!mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN)) {
|
||||
// move the state to PENDING
|
||||
nextState = mPendingState;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RSRC_UNSUBSCRIBE:
|
||||
{
|
||||
// the list should really be empty, nothing to remove.
|
||||
// but we might as well just tell the client it is
|
||||
// unsubscribed. False tolerance, right?
|
||||
Subscriber* subscriber = (Subscriber*) data;
|
||||
Notification notification(subscriber, event, false);
|
||||
subscriber->notifyRsrcStatus(notification);
|
||||
}
|
||||
// break;
|
||||
case RSRC_GRANTED:
|
||||
case RSRC_RELEASED:
|
||||
case RSRC_DENIED:
|
||||
default:
|
||||
LOC_LOGW("%s: unrecognized event %d", whoami(), event);
|
||||
// no state change.
|
||||
break;
|
||||
}
|
||||
|
||||
LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
|
||||
whoami(), nextState->whoami(), event);
|
||||
return nextState;
|
||||
}
|
||||
|
||||
// AgpsPendingState
|
||||
class AgpsPendingState : public AgpsState
|
||||
{
|
||||
friend class AgpsStateMachine;
|
||||
|
||||
inline AgpsPendingState(AgpsStateMachine* stateMachine) :
|
||||
AgpsState(stateMachine)
|
||||
{ mPendingState = this; }
|
||||
|
||||
inline ~AgpsPendingState() {}
|
||||
public:
|
||||
virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);
|
||||
inline virtual char* whoami() {return (char*)"AgpsPendingState";}
|
||||
};
|
||||
|
||||
AgpsState* AgpsPendingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
|
||||
{
|
||||
AgpsState* nextState = this;;
|
||||
LOC_LOGD("AgpsPendingState::onRsrcEvent; event:%d\n", (int)event);
|
||||
switch (event)
|
||||
{
|
||||
case RSRC_SUBSCRIBE:
|
||||
{
|
||||
// already requested for NIF resource,
|
||||
// do nothing until we get RSRC_GRANTED indication
|
||||
// but we need to add subscriber to the list
|
||||
mStateMachine->addSubscriber((Subscriber*)data);
|
||||
// no state change.
|
||||
}
|
||||
break;
|
||||
|
||||
case RSRC_UNSUBSCRIBE:
|
||||
{
|
||||
Subscriber* subscriber = (Subscriber*) data;
|
||||
if (subscriber->waitForCloseComplete()) {
|
||||
subscriber->setInactive();
|
||||
} else {
|
||||
// auto notify this subscriber of the unsubscribe
|
||||
Notification notification(subscriber, event, true);
|
||||
mStateMachine->notifySubscribers(notification);
|
||||
}
|
||||
|
||||
// now check if there is any subscribers left
|
||||
if (!mStateMachine->hasSubscribers()) {
|
||||
// no more subscribers, move to RELEASED state
|
||||
nextState = mReleasedState;
|
||||
|
||||
// tell connecivity service we can release NIF
|
||||
mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);
|
||||
} else if (!mStateMachine->hasActiveSubscribers()) {
|
||||
// only inactive subscribers, move to RELEASING state
|
||||
nextState = mReleasingState;
|
||||
|
||||
// tell connecivity service we can release NIF
|
||||
mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RSRC_GRANTED:
|
||||
{
|
||||
nextState = mAcquiredState;
|
||||
Notification notification(Notification::BROADCAST_ACTIVE, event, false);
|
||||
// notify all subscribers NIF resource GRANTED
|
||||
// by setting false, we keep subscribers on the linked list
|
||||
mStateMachine->notifySubscribers(notification);
|
||||
}
|
||||
break;
|
||||
|
||||
case RSRC_RELEASED:
|
||||
// no state change.
|
||||
// we are expecting either GRANTED or DENIED. Handling RELEASED
|
||||
// may like break our state machine in race conditions.
|
||||
break;
|
||||
|
||||
case RSRC_DENIED:
|
||||
{
|
||||
nextState = mReleasedState;
|
||||
Notification notification(Notification::BROADCAST_ALL, event, true);
|
||||
// notify all subscribers NIF resource RELEASED or DENIED
|
||||
// by setting true, we remove subscribers from the linked list
|
||||
mStateMachine->notifySubscribers(notification);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
LOC_LOGE("%s: unrecognized event %d", whoami(), event);
|
||||
// no state change.
|
||||
}
|
||||
|
||||
LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
|
||||
whoami(), nextState->whoami(), event);
|
||||
return nextState;
|
||||
}
|
||||
|
||||
|
||||
class AgpsAcquiredState : public AgpsState
|
||||
{
|
||||
friend class AgpsStateMachine;
|
||||
|
||||
inline AgpsAcquiredState(AgpsStateMachine* stateMachine) :
|
||||
AgpsState(stateMachine)
|
||||
{ mAcquiredState = this; }
|
||||
|
||||
inline ~AgpsAcquiredState() {}
|
||||
public:
|
||||
virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);
|
||||
inline virtual char* whoami() { return (char*)"AgpsAcquiredState"; }
|
||||
};
|
||||
|
||||
|
||||
AgpsState* AgpsAcquiredState::onRsrcEvent(AgpsRsrcStatus event, void* data)
|
||||
{
|
||||
AgpsState* nextState = this;
|
||||
LOC_LOGD("AgpsAcquiredState::onRsrcEvent; event:%d\n", (int)event);
|
||||
switch (event)
|
||||
{
|
||||
case RSRC_SUBSCRIBE:
|
||||
{
|
||||
// we already have the NIF resource, simply notify subscriber
|
||||
Subscriber* subscriber = (Subscriber*) data;
|
||||
// we have rsrc in hand, so grant it right away
|
||||
Notification notification(subscriber, RSRC_GRANTED, false);
|
||||
subscriber->notifyRsrcStatus(notification);
|
||||
// add subscriber to the list
|
||||
mStateMachine->addSubscriber(subscriber);
|
||||
// no state change.
|
||||
}
|
||||
break;
|
||||
|
||||
case RSRC_UNSUBSCRIBE:
|
||||
{
|
||||
Subscriber* subscriber = (Subscriber*) data;
|
||||
if (subscriber->waitForCloseComplete()) {
|
||||
subscriber->setInactive();
|
||||
} else {
|
||||
// auto notify this subscriber of the unsubscribe
|
||||
Notification notification(subscriber, event, true);
|
||||
mStateMachine->notifySubscribers(notification);
|
||||
}
|
||||
|
||||
// now check if there is any subscribers left
|
||||
if (!mStateMachine->hasSubscribers()) {
|
||||
// no more subscribers, move to RELEASED state
|
||||
nextState = mReleasedState;
|
||||
|
||||
// tell connecivity service we can release NIF
|
||||
mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);
|
||||
} else if (!mStateMachine->hasActiveSubscribers()) {
|
||||
// only inactive subscribers, move to RELEASING state
|
||||
nextState = mReleasingState;
|
||||
|
||||
// tell connecivity service we can release NIF
|
||||
mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RSRC_GRANTED:
|
||||
LOC_LOGW("%s: %d, RSRC_GRANTED already received", whoami(), event);
|
||||
// no state change.
|
||||
break;
|
||||
|
||||
case RSRC_RELEASED:
|
||||
{
|
||||
LOC_LOGW("%s: %d, a force rsrc release", whoami(), event);
|
||||
nextState = mReleasedState;
|
||||
Notification notification(Notification::BROADCAST_ALL, event, true);
|
||||
// by setting true, we remove subscribers from the linked list
|
||||
mStateMachine->notifySubscribers(notification);
|
||||
}
|
||||
break;
|
||||
|
||||
case RSRC_DENIED:
|
||||
// no state change.
|
||||
// we are expecting RELEASED. Handling DENIED
|
||||
// may like break our state machine in race conditions.
|
||||
break;
|
||||
|
||||
default:
|
||||
LOC_LOGE("%s: unrecognized event %d", whoami(), event);
|
||||
// no state change.
|
||||
}
|
||||
|
||||
LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
|
||||
whoami(), nextState->whoami(), event);
|
||||
return nextState;
|
||||
}
|
||||
|
||||
// AgpsPendingState
|
||||
class AgpsReleasingState : public AgpsState
|
||||
{
|
||||
friend class AgpsStateMachine;
|
||||
|
||||
inline AgpsReleasingState(AgpsStateMachine* stateMachine) :
|
||||
AgpsState(stateMachine)
|
||||
{ mReleasingState = this; }
|
||||
|
||||
inline ~AgpsReleasingState() {}
|
||||
public:
|
||||
virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);
|
||||
inline virtual char* whoami() {return (char*)"AgpsReleasingState";}
|
||||
};
|
||||
|
||||
AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
|
||||
{
|
||||
AgpsState* nextState = this;;
|
||||
LOC_LOGD("AgpsReleasingState::onRsrcEvent; event:%d\n", (int)event);
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case RSRC_SUBSCRIBE:
|
||||
{
|
||||
// already requested for NIF resource,
|
||||
// do nothing until we get RSRC_GRANTED indication
|
||||
// but we need to add subscriber to the list
|
||||
mStateMachine->addSubscriber((Subscriber*)data);
|
||||
// no state change.
|
||||
}
|
||||
break;
|
||||
|
||||
case RSRC_UNSUBSCRIBE:
|
||||
{
|
||||
Subscriber* subscriber = (Subscriber*) data;
|
||||
if (subscriber->waitForCloseComplete()) {
|
||||
subscriber->setInactive();
|
||||
} else {
|
||||
// auto notify this subscriber of the unsubscribe
|
||||
Notification notification(subscriber, event, true);
|
||||
mStateMachine->notifySubscribers(notification);
|
||||
}
|
||||
|
||||
// now check if there is any subscribers left
|
||||
if (!mStateMachine->hasSubscribers()) {
|
||||
// no more subscribers, move to RELEASED state
|
||||
nextState = mReleasedState;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RSRC_DENIED:
|
||||
// A race condition subscriber unsubscribes before AFW denies resource.
|
||||
case RSRC_RELEASED:
|
||||
{
|
||||
nextState = mAcquiredState;
|
||||
Notification notification(Notification::BROADCAST_INACTIVE, event, true);
|
||||
// notify all subscribers that are active NIF resource RELEASE
|
||||
// by setting false, we keep subscribers on the linked list
|
||||
mStateMachine->notifySubscribers(notification);
|
||||
|
||||
if (mStateMachine->hasActiveSubscribers()) {
|
||||
nextState = mPendingState;
|
||||
// request from connecivity service for NIF
|
||||
mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN);
|
||||
} else {
|
||||
nextState = mReleasedState;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RSRC_GRANTED:
|
||||
default:
|
||||
LOC_LOGE("%s: unrecognized event %d", whoami(), event);
|
||||
// no state change.
|
||||
}
|
||||
|
||||
LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
|
||||
whoami(), nextState->whoami(), event);
|
||||
return nextState;
|
||||
}
|
||||
//======================================================================
|
||||
//Servicer
|
||||
//======================================================================
|
||||
Servicer* Servicer :: getServicer(servicerType type, void *cb_func)
|
||||
{
|
||||
LOC_LOGD(" Enter getServicer type:%d\n", (int)type);
|
||||
switch(type) {
|
||||
case servicerTypeNoCbParam:
|
||||
return (new Servicer(cb_func));
|
||||
case servicerTypeExt:
|
||||
return (new ExtServicer(cb_func));
|
||||
case servicerTypeAgps:
|
||||
return (new AGpsServicer(cb_func));
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int Servicer :: requestRsrc(void *cb_data)
|
||||
{
|
||||
callback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ExtServicer :: requestRsrc(void *cb_data)
|
||||
{
|
||||
int ret=-1;
|
||||
LOC_LOGD("Enter ExtServicer :: requestRsrc\n");
|
||||
ret = callbackExt(cb_data);
|
||||
LOC_LOGD("Exit ExtServicer :: requestRsrc\n");
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int AGpsServicer :: requestRsrc(void *cb_data)
|
||||
{
|
||||
callbackAGps((AGpsStatus *)cb_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
// AgpsStateMachine
|
||||
//======================================================================
|
||||
|
||||
AgpsStateMachine::AgpsStateMachine(servicerType servType,
|
||||
void *cb_func,
|
||||
AGpsExtType type,
|
||||
bool enforceSingleSubscriber) :
|
||||
mStatePtr(new AgpsReleasedState(this)),mType(type),
|
||||
mAPN(NULL),
|
||||
mAPNLen(0),
|
||||
mBearer(AGPS_APN_BEARER_INVALID),
|
||||
mEnforceSingleSubscriber(enforceSingleSubscriber),
|
||||
mServicer(Servicer :: getServicer(servType, (void *)cb_func))
|
||||
{
|
||||
linked_list_init(&mSubscribers);
|
||||
|
||||
// setting up mReleasedState
|
||||
mStatePtr->mPendingState = new AgpsPendingState(this);
|
||||
mStatePtr->mAcquiredState = new AgpsAcquiredState(this);
|
||||
mStatePtr->mReleasingState = new AgpsReleasingState(this);
|
||||
|
||||
// setting up mAcquiredState
|
||||
mStatePtr->mAcquiredState->mReleasedState = mStatePtr;
|
||||
mStatePtr->mAcquiredState->mPendingState = mStatePtr->mPendingState;
|
||||
mStatePtr->mAcquiredState->mReleasingState = mStatePtr->mReleasingState;
|
||||
|
||||
// setting up mPendingState
|
||||
mStatePtr->mPendingState->mAcquiredState = mStatePtr->mAcquiredState;
|
||||
mStatePtr->mPendingState->mReleasedState = mStatePtr;
|
||||
mStatePtr->mPendingState->mReleasingState = mStatePtr->mReleasingState;
|
||||
|
||||
// setting up mReleasingState
|
||||
mStatePtr->mReleasingState->mReleasedState = mStatePtr;
|
||||
mStatePtr->mReleasingState->mPendingState = mStatePtr->mPendingState;
|
||||
mStatePtr->mReleasingState->mAcquiredState = mStatePtr->mAcquiredState;
|
||||
}
|
||||
|
||||
AgpsStateMachine::~AgpsStateMachine()
|
||||
{
|
||||
dropAllSubscribers();
|
||||
|
||||
// free the 3 states. We must read out all 3 pointers first.
|
||||
// Otherwise we run the risk of getting pointers from already
|
||||
// freed memory.
|
||||
AgpsState* acquiredState = mStatePtr->mAcquiredState;
|
||||
AgpsState* releasedState = mStatePtr->mReleasedState;
|
||||
AgpsState* pendindState = mStatePtr->mPendingState;
|
||||
AgpsState* releasingState = mStatePtr->mReleasingState;
|
||||
|
||||
delete acquiredState;
|
||||
delete releasedState;
|
||||
delete pendindState;
|
||||
delete releasingState;
|
||||
delete mServicer;
|
||||
linked_list_destroy(&mSubscribers);
|
||||
|
||||
if (NULL != mAPN) {
|
||||
delete[] mAPN;
|
||||
mAPN = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void AgpsStateMachine::setAPN(const char* apn, unsigned int len)
|
||||
{
|
||||
if (NULL != mAPN) {
|
||||
delete mAPN;
|
||||
}
|
||||
|
||||
if (NULL != apn) {
|
||||
mAPN = new char[len+1];
|
||||
memcpy(mAPN, apn, len);
|
||||
mAPN[len] = NULL;
|
||||
|
||||
mAPNLen = len;
|
||||
} else {
|
||||
mAPN = NULL;
|
||||
mAPNLen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void AgpsStateMachine::onRsrcEvent(AgpsRsrcStatus event)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case RSRC_GRANTED:
|
||||
case RSRC_RELEASED:
|
||||
case RSRC_DENIED:
|
||||
mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
|
||||
break;
|
||||
default:
|
||||
LOC_LOGW("AgpsStateMachine: unrecognized event %d", event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AgpsStateMachine::notifySubscribers(Notification& notification) const
|
||||
{
|
||||
if (notification.postNotifyDelete) {
|
||||
// just any non NULL value to get started
|
||||
Subscriber* s = (Subscriber*)~0;
|
||||
while (NULL != s) {
|
||||
s = NULL;
|
||||
// if the last param sets to true, _search will delete
|
||||
// the node from the list for us. But the problem is
|
||||
// once that is done, _search returns, leaving the
|
||||
// rest of the list unprocessed. So we need a loop.
|
||||
linked_list_search(mSubscribers, (void**)&s, notifySubscriber,
|
||||
(void*)¬ification, true);
|
||||
delete s;
|
||||
}
|
||||
} else {
|
||||
// no loop needed if it the last param sets to false, which
|
||||
// mean nothing gets deleted from the list.
|
||||
linked_list_search(mSubscribers, NULL, notifySubscriber,
|
||||
(void*)¬ification, false);
|
||||
}
|
||||
}
|
||||
|
||||
void AgpsStateMachine::addSubscriber(Subscriber* subscriber) const
|
||||
{
|
||||
Subscriber* s = NULL;
|
||||
Notification notification((const Subscriber*)subscriber);
|
||||
linked_list_search(mSubscribers, (void**)&s,
|
||||
hasSubscriber, (void*)¬ification, false);
|
||||
|
||||
if (NULL == s) {
|
||||
linked_list_add(mSubscribers, subscriber->clone(), deleteObj);
|
||||
}
|
||||
}
|
||||
|
||||
int AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
|
||||
{
|
||||
Subscriber* s = NULL;
|
||||
Notification notification(Notification::BROADCAST_ACTIVE);
|
||||
linked_list_search(mSubscribers, (void**)&s, hasSubscriber,
|
||||
(void*)¬ification, false);
|
||||
|
||||
if ((NULL == s) == (GPS_RELEASE_AGPS_DATA_CONN == action)) {
|
||||
AGpsExtStatus nifRequest;
|
||||
nifRequest.size = sizeof(nifRequest);
|
||||
nifRequest.type = mType;
|
||||
nifRequest.status = action;
|
||||
|
||||
if (s == NULL) {
|
||||
nifRequest.ipv4_addr = INADDR_NONE;
|
||||
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(¬ification, subscriber);
|
||||
} else {
|
||||
mStatePtr = mStatePtr->onRsrcEvent(RSRC_SUBSCRIBE, (void*)subscriber);
|
||||
}
|
||||
}
|
||||
|
||||
bool AgpsStateMachine::unsubscribeRsrc(Subscriber *subscriber)
|
||||
{
|
||||
Subscriber* s = NULL;
|
||||
Notification notification((const Subscriber*)subscriber);
|
||||
linked_list_search(mSubscribers, (void**)&s,
|
||||
hasSubscriber, (void*)¬ification, false);
|
||||
|
||||
if (NULL != s) {
|
||||
mStatePtr = mStatePtr->onRsrcEvent(RSRC_UNSUBSCRIBE, (void*)s);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AgpsStateMachine::hasActiveSubscribers() const
|
||||
{
|
||||
Subscriber* s = NULL;
|
||||
Notification notification(Notification::BROADCAST_ACTIVE);
|
||||
linked_list_search(mSubscribers, (void**)&s,
|
||||
hasSubscriber, (void*)¬ification, false);
|
||||
return NULL != s;
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
// DSStateMachine
|
||||
//======================================================================
|
||||
void delay_callback(void *callbackData, int result)
|
||||
{
|
||||
if(callbackData) {
|
||||
DSStateMachine *DSSMInstance = (DSStateMachine *)callbackData;
|
||||
DSSMInstance->retryCallback();
|
||||
}
|
||||
else {
|
||||
LOC_LOGE(" NULL argument received. Failing.\n");
|
||||
goto err;
|
||||
}
|
||||
err:
|
||||
return;
|
||||
}
|
||||
|
||||
DSStateMachine :: DSStateMachine(servicerType type, void *cb_func,
|
||||
LocEngAdapter* adapterHandle):
|
||||
AgpsStateMachine(type, cb_func, AGPS_TYPE_INVALID,false),
|
||||
mLocAdapter(adapterHandle)
|
||||
{
|
||||
LOC_LOGD("%s:%d]: New DSStateMachine\n", __func__, __LINE__);
|
||||
mRetries = 0;
|
||||
}
|
||||
|
||||
void DSStateMachine :: retryCallback(void)
|
||||
{
|
||||
DSSubscriber *subscriber = NULL;
|
||||
Notification notification(Notification::BROADCAST_ACTIVE);
|
||||
linked_list_search(mSubscribers, (void**)&subscriber, hasSubscriber,
|
||||
(void*)¬ification, false);
|
||||
if(subscriber)
|
||||
mLocAdapter->requestSuplES(subscriber->ID);
|
||||
else
|
||||
LOC_LOGE("DSStateMachine :: retryCallback: No subscriber found." \
|
||||
"Cannot retry data call\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int DSStateMachine :: sendRsrcRequest(AGpsStatusValue action) const
|
||||
{
|
||||
DSSubscriber* s = NULL;
|
||||
dsCbData cbData;
|
||||
int ret=-1;
|
||||
int connHandle=-1;
|
||||
LOC_LOGD("Enter DSStateMachine :: sendRsrcRequest\n");
|
||||
Notification notification(Notification::BROADCAST_ACTIVE);
|
||||
linked_list_search(mSubscribers, (void**)&s, hasSubscriber,
|
||||
(void*)¬ification, false);
|
||||
if(s) {
|
||||
connHandle = s->ID;
|
||||
LOC_LOGD("DSStateMachine :: sendRsrcRequest - subscriber found\n");
|
||||
}
|
||||
else
|
||||
LOC_LOGD("DSStateMachine :: sendRsrcRequest - No subscriber found\n");
|
||||
|
||||
cbData.action = action;
|
||||
cbData.mAdapter = mLocAdapter;
|
||||
ret = mServicer->requestRsrc((void *)&cbData);
|
||||
//Only the request to start data call returns a success/failure
|
||||
//The request to stop data call will always succeed
|
||||
//Hence, the below block will only be executed when the
|
||||
//request to start the data call fails
|
||||
switch(ret) {
|
||||
case LOC_API_ADAPTER_ERR_ENGINE_BUSY:
|
||||
LOC_LOGD("DSStateMachine :: sendRsrcRequest - Failure returned: %d\n",ret);
|
||||
((DSStateMachine *)this)->incRetries();
|
||||
if(mRetries > MAX_START_DATA_CALL_RETRIES) {
|
||||
LOC_LOGE(" Failed to start Data call. Fallback to normal ATL SUPL\n");
|
||||
informStatus(RSRC_DENIED, connHandle);
|
||||
}
|
||||
else {
|
||||
if(loc_timer_start(DATA_CALL_RETRY_DELAY_MSEC, delay_callback, (void *)this)) {
|
||||
LOC_LOGE("Error: Could not start delay thread\n");
|
||||
ret = -1;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LOC_API_ADAPTER_ERR_UNSUPPORTED:
|
||||
LOC_LOGE("No profile found for emergency call. Fallback to normal SUPL ATL\n");
|
||||
informStatus(RSRC_DENIED, connHandle);
|
||||
break;
|
||||
case LOC_API_ADAPTER_ERR_SUCCESS:
|
||||
LOC_LOGD("%s:%d]: Request to start data call sent\n", __func__, __LINE__);
|
||||
break;
|
||||
case -1:
|
||||
//One of the ways this case can be encountered is if the callback function
|
||||
//receives a null argument, it just exits with -1 error
|
||||
LOC_LOGE("Error: Something went wrong somewhere. Falling back to normal SUPL ATL\n");
|
||||
informStatus(RSRC_DENIED, connHandle);
|
||||
break;
|
||||
default:
|
||||
LOC_LOGE("%s:%d]: Unrecognized return value\n", __func__, __LINE__);
|
||||
}
|
||||
err:
|
||||
LOC_LOGD("EXIT DSStateMachine :: sendRsrcRequest; ret = %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DSStateMachine :: onRsrcEvent(AgpsRsrcStatus event)
|
||||
{
|
||||
void* currState = (void *)mStatePtr;
|
||||
LOC_LOGD("Enter DSStateMachine :: onRsrcEvent. event = %d\n", (int)event);
|
||||
switch (event)
|
||||
{
|
||||
case RSRC_GRANTED:
|
||||
LOC_LOGD("DSStateMachine :: onRsrcEvent RSRC_GRANTED\n");
|
||||
mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
|
||||
break;
|
||||
case RSRC_RELEASED:
|
||||
LOC_LOGD("DSStateMachine :: onRsrcEvent RSRC_RELEASED\n");
|
||||
mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
|
||||
//To handle the case where we get a RSRC_RELEASED in
|
||||
//pending state, we translate that to a RSRC_DENIED state
|
||||
//since the callback from DSI is either RSRC_GRANTED or RSRC_RELEASED
|
||||
//for when the call is connected or disconnected respectively.
|
||||
if((void *)mStatePtr != currState)
|
||||
break;
|
||||
else {
|
||||
event = RSRC_DENIED;
|
||||
LOC_LOGE(" Switching event to RSRC_DENIED\n");
|
||||
}
|
||||
case RSRC_DENIED:
|
||||
mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
|
||||
break;
|
||||
default:
|
||||
LOC_LOGW("AgpsStateMachine: unrecognized event %d", event);
|
||||
break;
|
||||
}
|
||||
LOC_LOGD("Exit DSStateMachine :: onRsrcEvent. event = %d\n", (int)event);
|
||||
}
|
||||
|
||||
void DSStateMachine :: informStatus(AgpsRsrcStatus status, int ID) const
|
||||
{
|
||||
LOC_LOGD("DSStateMachine :: informStatus. Status=%d\n",(int)status);
|
||||
switch(status) {
|
||||
case RSRC_UNSUBSCRIBE:
|
||||
mLocAdapter->atlCloseStatus(ID, 1);
|
||||
break;
|
||||
case RSRC_RELEASED:
|
||||
mLocAdapter->closeDataCall();
|
||||
break;
|
||||
case RSRC_DENIED:
|
||||
((DSStateMachine *)this)->mRetries = 0;
|
||||
mLocAdapter->requestATL(ID, AGPS_TYPE_SUPL);
|
||||
break;
|
||||
case RSRC_GRANTED:
|
||||
mLocAdapter->atlOpenStatus(ID, 1,
|
||||
NULL,
|
||||
AGPS_APN_BEARER_INVALID,
|
||||
AGPS_TYPE_INVALID);
|
||||
break;
|
||||
default:
|
||||
LOC_LOGW("DSStateMachine :: informStatus - unknown status");
|
||||
}
|
||||
return;
|
||||
}
|
419
gps/loc_api/libloc_api_50001/loc_eng_agps.h
Normal file
419
gps/loc_api/libloc_api_50001/loc_eng_agps.h
Normal file
|
@ -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 ¬ification) = 0;
|
||||
|
||||
virtual bool waitForCloseComplete() { return false; }
|
||||
virtual void setInactive() {}
|
||||
virtual bool isInactive() { return false; }
|
||||
|
||||
virtual Subscriber* clone() = 0;
|
||||
// checks if this notification is for me, i.e.
|
||||
// either has my id, or has a broadcast id.
|
||||
bool forMe(Notification ¬ification);
|
||||
};
|
||||
|
||||
// BITSubscriber, created with requests from BIT daemon
|
||||
struct BITSubscriber : public Subscriber {
|
||||
char mIPv6Addr[16];
|
||||
|
||||
inline BITSubscriber(const AgpsStateMachine* stateMachine,
|
||||
unsigned int ipv4, char* ipv6) :
|
||||
Subscriber(ipv4, stateMachine)
|
||||
{
|
||||
if (NULL == ipv6) {
|
||||
mIPv6Addr[0] = 0;
|
||||
} else {
|
||||
memcpy(mIPv6Addr, ipv6, sizeof(mIPv6Addr));
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool notifyRsrcStatus(Notification ¬ification);
|
||||
|
||||
inline virtual void setIPAddresses(uint32_t &v4, char* v6)
|
||||
{ v4 = ID; memcpy(v6, mIPv6Addr, sizeof(mIPv6Addr)); }
|
||||
|
||||
virtual Subscriber* clone()
|
||||
{
|
||||
return new BITSubscriber(mStateMachine, ID, mIPv6Addr);
|
||||
}
|
||||
|
||||
virtual bool equals(const Subscriber *s) const;
|
||||
inline virtual ~BITSubscriber(){}
|
||||
};
|
||||
|
||||
// ATLSubscriber, created with requests from ATL
|
||||
struct ATLSubscriber : public Subscriber {
|
||||
const LocEngAdapter* mLocAdapter;
|
||||
const bool mBackwardCompatibleMode;
|
||||
inline ATLSubscriber(const int id,
|
||||
const AgpsStateMachine* stateMachine,
|
||||
const LocEngAdapter* adapter,
|
||||
const bool compatibleMode) :
|
||||
Subscriber(id, stateMachine), mLocAdapter(adapter),
|
||||
mBackwardCompatibleMode(compatibleMode){}
|
||||
virtual bool notifyRsrcStatus(Notification ¬ification);
|
||||
|
||||
inline virtual void setIPAddresses(uint32_t &v4, char* v6)
|
||||
{ v4 = INADDR_NONE; v6[0] = 0; }
|
||||
|
||||
inline virtual Subscriber* clone()
|
||||
{
|
||||
return new ATLSubscriber(ID, mStateMachine, mLocAdapter,
|
||||
mBackwardCompatibleMode);
|
||||
}
|
||||
inline virtual ~ATLSubscriber(){}
|
||||
};
|
||||
|
||||
// WIFISubscriber, created with requests from MSAPM or QuIPC
|
||||
struct WIFISubscriber : public Subscriber {
|
||||
char * mSSID;
|
||||
char * mPassword;
|
||||
loc_if_req_sender_id_e_type senderId;
|
||||
bool mIsInactive;
|
||||
inline WIFISubscriber(const AgpsStateMachine* stateMachine,
|
||||
char * ssid, char * password, loc_if_req_sender_id_e_type sender_id) :
|
||||
Subscriber(sender_id, stateMachine),
|
||||
mSSID(NULL == ssid ? NULL : new char[SSID_BUF_SIZE]),
|
||||
mPassword(NULL == password ? NULL : new char[SSID_BUF_SIZE]),
|
||||
senderId(sender_id)
|
||||
{
|
||||
if (NULL != mSSID)
|
||||
strlcpy(mSSID, ssid, SSID_BUF_SIZE);
|
||||
if (NULL != mPassword)
|
||||
strlcpy(mPassword, password, SSID_BUF_SIZE);
|
||||
mIsInactive = false;
|
||||
}
|
||||
|
||||
virtual bool notifyRsrcStatus(Notification ¬ification);
|
||||
|
||||
inline virtual void setIPAddresses(uint32_t &v4, char* v6) {}
|
||||
|
||||
inline virtual void 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 ¬ification);
|
||||
inline virtual bool waitForCloseComplete() { return true; }
|
||||
virtual void setInactive();
|
||||
inline virtual bool isInactive()
|
||||
{ return mIsInactive; }
|
||||
inline virtual ~DSSubscriber(){}
|
||||
inline virtual char *whoami() {return (char*)"DSSubscriber";}
|
||||
};
|
||||
|
||||
#endif //__LOC_ENG_AGPS_H__
|
270
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp
Normal file
270
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp
Normal file
|
@ -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 -1;
|
||||
}
|
||||
|
||||
LOC_LOGD("%s:%d] received ctrl_type = %d\n", __func__, __LINE__, p_cmsgbuf->ctrl_type);
|
||||
switch(p_cmsgbuf->ctrl_type) {
|
||||
case GPSONE_LOC_API_IF_REQUEST:
|
||||
result = loc_eng_dmn_conn_loc_api_server_if_request_handler(p_cmsgbuf, length);
|
||||
break;
|
||||
|
||||
case GPSONE_LOC_API_IF_RELEASE:
|
||||
result = loc_eng_dmn_conn_loc_api_server_if_release_handler(p_cmsgbuf, length);
|
||||
break;
|
||||
|
||||
case GPSONE_UNBLOCK:
|
||||
LOC_LOGD("%s:%d] GPSONE_UNBLOCK\n", __func__, __LINE__);
|
||||
break;
|
||||
|
||||
default:
|
||||
LOC_LOGE("%s:%d] unsupported ctrl_type = %d\n",
|
||||
__func__, __LINE__, p_cmsgbuf->ctrl_type);
|
||||
break;
|
||||
}
|
||||
|
||||
free(p_cmsgbuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int loc_api_server_proc_post(void *context)
|
||||
{
|
||||
LOC_LOGD("%s:%d]\n", __func__, __LINE__);
|
||||
loc_eng_dmn_conn_glue_msgremove( global_loc_api_q_path, loc_api_server_msgqid);
|
||||
loc_eng_dmn_conn_glue_msgremove( global_loc_api_resp_q_path, loc_api_resp_msgqid);
|
||||
loc_eng_dmn_conn_glue_msgremove( global_quipc_ctrl_q_path, quipc_msgqid);
|
||||
loc_eng_dmn_conn_glue_msgremove( global_msapm_ctrl_q_path, msapm_msgqid);
|
||||
loc_eng_dmn_conn_glue_msgremove( global_msapu_ctrl_q_path, msapu_msgqid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int loc_eng_dmn_conn_unblock_proc(void)
|
||||
{
|
||||
struct ctrl_msgbuf cmsgbuf;
|
||||
cmsgbuf.ctrl_type = GPSONE_UNBLOCK;
|
||||
LOC_LOGD("%s:%d]\n", __func__, __LINE__);
|
||||
loc_eng_dmn_conn_glue_msgsnd(loc_api_server_msgqid, & cmsgbuf, sizeof(cmsgbuf));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct loc_eng_dmn_conn_thelper thelper;
|
||||
|
||||
int loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread create_thread_cb,
|
||||
const char * loc_api_q_path, const char * resp_q_path, void *agps_handle)
|
||||
{
|
||||
int result;
|
||||
|
||||
loc_api_handle = agps_handle;
|
||||
|
||||
if (loc_api_q_path) global_loc_api_q_path = loc_api_q_path;
|
||||
if (resp_q_path) global_loc_api_resp_q_path = resp_q_path;
|
||||
|
||||
result = loc_eng_dmn_conn_launch_thelper( &thelper,
|
||||
loc_api_server_proc_init,
|
||||
loc_api_server_proc_pre,
|
||||
loc_api_server_proc,
|
||||
loc_api_server_proc_post,
|
||||
create_thread_cb,
|
||||
(char *) global_loc_api_q_path);
|
||||
if (result != 0) {
|
||||
LOC_LOGE("%s:%d]\n", __func__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int loc_eng_dmn_conn_loc_api_server_unblock(void)
|
||||
{
|
||||
loc_eng_dmn_conn_unblock_thelper(&thelper);
|
||||
loc_eng_dmn_conn_unblock_proc();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int loc_eng_dmn_conn_loc_api_server_join(void)
|
||||
{
|
||||
loc_eng_dmn_conn_join_thelper(&thelper);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int loc_eng_dmn_conn_loc_api_server_data_conn(int sender_id, int status) {
|
||||
struct ctrl_msgbuf cmsgbuf;
|
||||
LOC_LOGD("%s:%d] quipc_msgqid = %d\n", __func__, __LINE__, quipc_msgqid);
|
||||
cmsgbuf.ctrl_type = GPSONE_LOC_API_RESPONSE;
|
||||
cmsgbuf.cmsg.cmsg_response.result = status;
|
||||
switch (sender_id) {
|
||||
case LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC: {
|
||||
LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC", __func__, __LINE__);
|
||||
if (loc_eng_dmn_conn_glue_msgsnd(quipc_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {
|
||||
LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM: {
|
||||
LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM", __func__, __LINE__);
|
||||
if (loc_eng_dmn_conn_glue_msgsnd(msapm_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {
|
||||
LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU: {
|
||||
LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU", __func__, __LINE__);
|
||||
if (loc_eng_dmn_conn_glue_msgsnd(msapu_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {
|
||||
LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON: {
|
||||
LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON", __func__, __LINE__);
|
||||
if (loc_eng_dmn_conn_glue_msgsnd(loc_api_resp_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {
|
||||
LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
LOC_LOGD("%s:%d] invalid sender ID!", __func__, __LINE__);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
59
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h
Normal file
59
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/* Copyright (c) 2011-2012,2014 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef LOC_ENG_DATA_SERVER_H
|
||||
#define LOC_ENG_DATA_SERVER_H
|
||||
|
||||
#include "loc_eng_dmn_conn_thread_helper.h"
|
||||
|
||||
#ifdef _ANDROID_
|
||||
|
||||
#define GPSONE_LOC_API_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_q"
|
||||
#define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_resp_q"
|
||||
#define QUIPC_CTRL_Q_PATH "/data/misc/location/gpsone_d/quipc_ctrl_q"
|
||||
#define MSAPM_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapm_ctrl_q"
|
||||
#define MSAPU_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapu_ctrl_q"
|
||||
|
||||
#else
|
||||
|
||||
#define GPSONE_LOC_API_Q_PATH "/tmp/gpsone_loc_api_q"
|
||||
#define GPSONE_LOC_API_RESP_Q_PATH "/tmp/gpsone_loc_api_resp_q"
|
||||
#define QUIPC_CTRL_Q_PATH "/tmp/quipc_ctrl_q"
|
||||
#define MSAPM_CTRL_Q_PATH "/tmp/msapm_ctrl_q"
|
||||
#define MSAPU_CTRL_Q_PATH "/tmp/msapu_ctrl_q"
|
||||
|
||||
#endif
|
||||
|
||||
int loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread create_thread_cb,
|
||||
const char * loc_api_q_path, const char * ctrl_q_path, void *agps_handle);
|
||||
int loc_eng_dmn_conn_loc_api_server_unblock(void);
|
||||
int loc_eng_dmn_conn_loc_api_server_join(void);
|
||||
int loc_eng_dmn_conn_loc_api_server_data_conn(int, int);
|
||||
|
||||
#endif /* LOC_ENG_DATA_SERVER_H */
|
||||
|
223
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c
Normal file
223
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c
Normal file
|
@ -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;
|
||||
}
|
||||
|
51
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h
Normal file
51
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h
Normal file
|
@ -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 */
|
214
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c
Normal file
214
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c
Normal file
|
@ -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;
|
||||
}
|
50
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h
Normal file
50
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h
Normal file
|
@ -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 */
|
237
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp
Normal file
237
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp
Normal file
|
@ -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;
|
||||
}
|
||||
|
106
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h
Normal file
106
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h
Normal file
|
@ -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 */
|
399
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c
Normal file
399
gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c
Normal file
|
@ -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;
|
||||
}
|
||||
|
|
@ -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__ */
|
35
gps/loc_api/libloc_api_50001/loc_eng_log.cpp
Normal file
35
gps/loc_api/libloc_api_50001/loc_eng_log.cpp
Normal file
|
@ -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"
|
||||
|
44
gps/loc_api/libloc_api_50001/loc_eng_log.h
Normal file
44
gps/loc_api/libloc_api_50001/loc_eng_log.h
Normal file
|
@ -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 */
|
296
gps/loc_api/libloc_api_50001/loc_eng_msg.h
Normal file
296
gps/loc_api/libloc_api_50001/loc_eng_msg.h
Normal file
|
@ -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 ¬if,
|
||||
const void* data);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct LocEngDown : public LocMsg {
|
||||
void* mLocEng;
|
||||
LocEngDown(void* locEng);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct LocEngUp : public LocMsg {
|
||||
void* mLocEng;
|
||||
LocEngUp(void* locEng);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct LocEngGetZpp : public LocMsg {
|
||||
LocEngAdapter* mAdapter;
|
||||
LocEngGetZpp(LocEngAdapter* adapter);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
void send() const;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* LOC_ENG_MSG_H */
|
414
gps/loc_api/libloc_api_50001/loc_eng_ni.cpp
Normal file
414
gps/loc_api/libloc_api_50001/loc_eng_ni.cpp
Normal file
|
@ -0,0 +1,414 @@
|
|||
/* 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 <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;
|
||||
loc_eng_ni_session_s_type* pSession = NULL;
|
||||
|
||||
if (NULL == loc_eng_data.ni_notify_cb) {
|
||||
EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (notif->ni_type == GPS_NI_TYPE_EMERGENCY_SUPL) {
|
||||
if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
|
||||
LOC_LOGW("loc_eng_ni_request_handler, supl es NI in progress, new supl es NI ignored, type: %d",
|
||||
notif->ni_type);
|
||||
if (NULL != passThrough) {
|
||||
free((void*)passThrough);
|
||||
}
|
||||
} else {
|
||||
pSession = &loc_eng_ni_data_p->sessionEs;
|
||||
}
|
||||
} else {
|
||||
if (NULL != loc_eng_ni_data_p->session.rawRequest ||
|
||||
NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
|
||||
LOC_LOGW("loc_eng_ni_request_handler, supl NI in progress, new supl NI ignored, type: %d",
|
||||
notif->ni_type);
|
||||
if (NULL != passThrough) {
|
||||
free((void*)passThrough);
|
||||
}
|
||||
} else {
|
||||
pSession = &loc_eng_ni_data_p->session;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (pSession) {
|
||||
/* Save request */
|
||||
pSession->rawRequest = (void*)passThrough;
|
||||
pSession->reqID = ++loc_eng_ni_data_p->reqIDCounter;
|
||||
pSession->adapter = loc_eng_data.adapter;
|
||||
|
||||
/* Fill in notification */
|
||||
((GpsNiNotification*)notif)->notification_id = pSession->reqID;
|
||||
|
||||
if (notif->notify_flags == GPS_NI_PRIVACY_OVERRIDE)
|
||||
{
|
||||
loc_eng_mute_one_session(loc_eng_data);
|
||||
}
|
||||
|
||||
/* Log requestor ID and text for debugging */
|
||||
LOC_LOGI("Notification: notif_type: %d, timeout: %d, default_resp: %d", notif->ni_type, notif->timeout, notif->default_response);
|
||||
LOC_LOGI(" requestor_id: %s (encoding: %d)", notif->requestor_id, notif->requestor_id_encoding);
|
||||
LOC_LOGI(" text: %s text (encoding: %d)", notif->text, notif->text_encoding);
|
||||
if (notif->extras[0])
|
||||
{
|
||||
LOC_LOGI(" extras: %s", notif->extras);
|
||||
}
|
||||
|
||||
/* For robustness, spawn a thread at this point to timeout to clear up the notification status, even though
|
||||
* the OEM layer in java does not do so.
|
||||
**/
|
||||
pSession->respTimeLeft = 5 + (notif->timeout != 0 ? notif->timeout : LOC_NI_NO_RESPONSE_TIME);
|
||||
LOC_LOGI("Automatically sends 'no response' in %d seconds (to clear status)\n", pSession->respTimeLeft);
|
||||
|
||||
int rc = 0;
|
||||
rc = pthread_create(&pSession->thread, NULL, ni_thread_proc, pSession);
|
||||
if (rc)
|
||||
{
|
||||
LOC_LOGE("Loc NI thread is not created.\n");
|
||||
}
|
||||
rc = pthread_detach(pSession->thread);
|
||||
if (rc)
|
||||
{
|
||||
LOC_LOGE("Loc NI thread is not detached.\n");
|
||||
}
|
||||
|
||||
CALLBACK_LOG_CALLFLOW("ni_notify_cb - id", %d, notif->notification_id);
|
||||
loc_eng_data.ni_notify_cb((GpsNiNotification*)notif);
|
||||
}
|
||||
EXIT_LOG(%s, VOID_RET);
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
|
||||
FUNCTION ni_thread_proc
|
||||
|
||||
===========================================================================*/
|
||||
static void* ni_thread_proc(void *args)
|
||||
{
|
||||
ENTRY_LOG();
|
||||
|
||||
loc_eng_ni_session_s_type* pSession = (loc_eng_ni_session_s_type*)args;
|
||||
int rc = 0; /* return code from pthread calls */
|
||||
|
||||
struct timeval present_time;
|
||||
struct timespec expire_time;
|
||||
|
||||
LOC_LOGD("Starting Loc NI thread...\n");
|
||||
pthread_mutex_lock(&pSession->tLock);
|
||||
/* Calculate absolute expire time */
|
||||
gettimeofday(&present_time, NULL);
|
||||
expire_time.tv_sec = present_time.tv_sec + pSession->respTimeLeft;
|
||||
expire_time.tv_nsec = present_time.tv_usec * 1000;
|
||||
LOC_LOGD("ni_thread_proc-Time out set for abs time %ld with delay %d sec\n",
|
||||
(long) expire_time.tv_sec, pSession->respTimeLeft );
|
||||
|
||||
while (!pSession->respRecvd)
|
||||
{
|
||||
rc = pthread_cond_timedwait(&pSession->tCond,
|
||||
&pSession->tLock,
|
||||
&expire_time);
|
||||
if (rc == ETIMEDOUT)
|
||||
{
|
||||
pSession->resp = GPS_NI_RESPONSE_NORESP;
|
||||
LOC_LOGD("ni_thread_proc-Thread time out after valting for specified time. Ret Val %d\n",rc );
|
||||
break;
|
||||
}
|
||||
}
|
||||
LOC_LOGD("ni_thread_proc-Java layer has sent us a user response and return value from "
|
||||
"pthread_cond_timedwait = %d\n",rc );
|
||||
pSession->respRecvd = FALSE; /* Reset the user response flag for the next session*/
|
||||
|
||||
LOC_LOGD("pSession->resp is %d\n",pSession->resp);
|
||||
|
||||
// adding this check to support modem restart, in which case, we need the thread
|
||||
// to exit without calling sending data. We made sure that rawRequest is NULL in
|
||||
// loc_eng_ni_reset_on_engine_restart()
|
||||
LocEngAdapter* adapter = pSession->adapter;
|
||||
LocEngInformNiResponse *msg = NULL;
|
||||
|
||||
if (NULL != pSession->rawRequest) {
|
||||
if (pSession->resp != GPS_NI_RESPONSE_IGNORE) {
|
||||
LOC_LOGD("pSession->resp != GPS_NI_RESPONSE_IGNORE \n");
|
||||
msg = new LocEngInformNiResponse(adapter,
|
||||
pSession->resp,
|
||||
pSession->rawRequest);
|
||||
} else {
|
||||
LOC_LOGD("this is the ignore reply for SUPL ES\n");
|
||||
free(pSession->rawRequest);
|
||||
}
|
||||
pSession->rawRequest = NULL;
|
||||
}
|
||||
pthread_mutex_unlock(&pSession->tLock);
|
||||
|
||||
pSession->respTimeLeft = 0;
|
||||
pSession->reqID = 0;
|
||||
|
||||
if (NULL != msg) {
|
||||
LOC_LOGD("ni_thread_proc: adapter->sendMsg(msg)\n");
|
||||
adapter->sendMsg(msg);
|
||||
}
|
||||
|
||||
EXIT_LOG(%s, VOID_RET);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data)
|
||||
{
|
||||
ENTRY_LOG();
|
||||
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
|
||||
|
||||
if (NULL == loc_eng_data.ni_notify_cb) {
|
||||
EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
|
||||
return;
|
||||
}
|
||||
|
||||
// only if modem has requested but then died.
|
||||
if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
|
||||
free(loc_eng_ni_data_p->sessionEs.rawRequest);
|
||||
loc_eng_ni_data_p->sessionEs.rawRequest = NULL;
|
||||
|
||||
pthread_mutex_lock(&loc_eng_ni_data_p->sessionEs.tLock);
|
||||
// the goal is to wake up ni_thread_proc
|
||||
// and let it exit.
|
||||
loc_eng_ni_data_p->sessionEs.respRecvd = TRUE;
|
||||
pthread_cond_signal(&loc_eng_ni_data_p->sessionEs.tCond);
|
||||
pthread_mutex_unlock(&loc_eng_ni_data_p->sessionEs.tLock);
|
||||
}
|
||||
|
||||
if (NULL != loc_eng_ni_data_p->session.rawRequest) {
|
||||
free(loc_eng_ni_data_p->session.rawRequest);
|
||||
loc_eng_ni_data_p->session.rawRequest = NULL;
|
||||
|
||||
pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock);
|
||||
// the goal is to wake up ni_thread_proc
|
||||
// and let it exit.
|
||||
loc_eng_ni_data_p->session.respRecvd = TRUE;
|
||||
pthread_cond_signal(&loc_eng_ni_data_p->session.tCond);
|
||||
pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock);
|
||||
}
|
||||
|
||||
EXIT_LOG(%s, VOID_RET);
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION loc_eng_ni_init
|
||||
|
||||
DESCRIPTION
|
||||
This function initializes the NI interface
|
||||
|
||||
DEPENDENCIES
|
||||
NONE
|
||||
|
||||
RETURN VALUE
|
||||
None
|
||||
|
||||
SIDE EFFECTS
|
||||
N/A
|
||||
|
||||
===========================================================================*/
|
||||
void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, GpsNiExtCallbacks *callbacks)
|
||||
{
|
||||
ENTRY_LOG_CALLFLOW();
|
||||
|
||||
if(callbacks == NULL)
|
||||
EXIT_LOG(%s, "loc_eng_ni_init: failed, cb is NULL");
|
||||
else if (NULL == callbacks->notify_cb) {
|
||||
EXIT_LOG(%s, "loc_eng_ni_init: failed, no cb.");
|
||||
} else if (NULL != loc_eng_data.ni_notify_cb) {
|
||||
EXIT_LOG(%s, "loc_eng_ni_init: already inited.");
|
||||
} else {
|
||||
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
|
||||
loc_eng_ni_data_p->sessionEs.respTimeLeft = 0;
|
||||
loc_eng_ni_data_p->sessionEs.respRecvd = FALSE;
|
||||
loc_eng_ni_data_p->sessionEs.rawRequest = NULL;
|
||||
loc_eng_ni_data_p->sessionEs.reqID = 0;
|
||||
pthread_cond_init(&loc_eng_ni_data_p->sessionEs.tCond, NULL);
|
||||
pthread_mutex_init(&loc_eng_ni_data_p->sessionEs.tLock, NULL);
|
||||
|
||||
loc_eng_ni_data_p->session.respTimeLeft = 0;
|
||||
loc_eng_ni_data_p->session.respRecvd = FALSE;
|
||||
loc_eng_ni_data_p->session.rawRequest = NULL;
|
||||
loc_eng_ni_data_p->session.reqID = 0;
|
||||
pthread_cond_init(&loc_eng_ni_data_p->session.tCond, NULL);
|
||||
pthread_mutex_init(&loc_eng_ni_data_p->session.tLock, NULL);
|
||||
|
||||
loc_eng_data.ni_notify_cb = callbacks->notify_cb;
|
||||
EXIT_LOG(%s, VOID_RET);
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION loc_eng_ni_respond
|
||||
|
||||
DESCRIPTION
|
||||
This function receives user response from upper layer framework
|
||||
|
||||
DEPENDENCIES
|
||||
NONE
|
||||
|
||||
RETURN VALUE
|
||||
None
|
||||
|
||||
SIDE EFFECTS
|
||||
N/A
|
||||
|
||||
===========================================================================*/
|
||||
void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data,
|
||||
int notif_id, GpsUserResponseType user_response)
|
||||
{
|
||||
ENTRY_LOG_CALLFLOW();
|
||||
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
|
||||
loc_eng_ni_session_s_type* pSession = NULL;
|
||||
|
||||
if (NULL == loc_eng_data.ni_notify_cb) {
|
||||
EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (notif_id == loc_eng_ni_data_p->sessionEs.reqID &&
|
||||
NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
|
||||
pSession = &loc_eng_ni_data_p->sessionEs;
|
||||
// ignore any SUPL NI non-Es session if a SUPL NI ES is accepted
|
||||
if (user_response == GPS_NI_RESPONSE_ACCEPT &&
|
||||
NULL != loc_eng_ni_data_p->session.rawRequest) {
|
||||
pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock);
|
||||
loc_eng_ni_data_p->session.resp = GPS_NI_RESPONSE_IGNORE;
|
||||
loc_eng_ni_data_p->session.respRecvd = TRUE;
|
||||
pthread_cond_signal(&loc_eng_ni_data_p->session.tCond);
|
||||
pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock);
|
||||
}
|
||||
} else if (notif_id == loc_eng_ni_data_p->session.reqID &&
|
||||
NULL != loc_eng_ni_data_p->session.rawRequest) {
|
||||
pSession = &loc_eng_ni_data_p->session;
|
||||
}
|
||||
|
||||
if (pSession) {
|
||||
LOC_LOGI("loc_eng_ni_respond: send user response %d for notif %d", user_response, notif_id);
|
||||
pthread_mutex_lock(&pSession->tLock);
|
||||
pSession->resp = user_response;
|
||||
pSession->respRecvd = TRUE;
|
||||
pthread_cond_signal(&pSession->tCond);
|
||||
pthread_mutex_unlock(&pSession->tLock);
|
||||
}
|
||||
else {
|
||||
LOC_LOGE("loc_eng_ni_respond: notif_id %d not an active session", notif_id);
|
||||
}
|
||||
|
||||
EXIT_LOG(%s, VOID_RET);
|
||||
}
|
59
gps/loc_api/libloc_api_50001/loc_eng_ni.h
Normal file
59
gps/loc_api/libloc_api_50001/loc_eng_ni.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/* Copyright (c) 2009,2011,2014 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LOC_ENG_NI_H
|
||||
#define LOC_ENG_NI_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <LocEngAdapter.h>
|
||||
|
||||
#define LOC_NI_NO_RESPONSE_TIME 20 /* secs */
|
||||
#define LOC_NI_NOTIF_KEY_ADDRESS "Address"
|
||||
#define GPS_NI_RESPONSE_IGNORE 4
|
||||
|
||||
typedef struct {
|
||||
pthread_t thread; /* NI thread */
|
||||
int respTimeLeft; /* examine time for NI response */
|
||||
bool respRecvd; /* NI User reponse received or not from Java layer*/
|
||||
void* rawRequest;
|
||||
int reqID; /* ID to check against response */
|
||||
GpsUserResponseType resp;
|
||||
pthread_cond_t tCond;
|
||||
pthread_mutex_t tLock;
|
||||
LocEngAdapter* adapter;
|
||||
} loc_eng_ni_session_s_type;
|
||||
|
||||
typedef struct {
|
||||
loc_eng_ni_session_s_type session; /* SUPL NI Session */
|
||||
loc_eng_ni_session_s_type sessionEs; /* Emergency SUPL NI Session */
|
||||
int reqIDCounter;
|
||||
} loc_eng_ni_data_s_type;
|
||||
|
||||
|
||||
#endif /* LOC_ENG_NI_H */
|
836
gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp
Normal file
836
gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp
Normal file
|
@ -0,0 +1,836 @@
|
|||
/* 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();
|
||||
time_t utcTime(location.gpsLocation.timestamp/1000);
|
||||
tm * pTm = gmtime(&utcTime);
|
||||
if (NULL == pTm) {
|
||||
LOC_LOGE("gmtime failed");
|
||||
return;
|
||||
}
|
||||
|
||||
char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0};
|
||||
char* pMarker = sentence;
|
||||
int lengthRemaining = sizeof(sentence);
|
||||
int length = 0;
|
||||
int utcYear = pTm->tm_year % 100; // 2 digit year
|
||||
int utcMonth = pTm->tm_mon + 1; // tm_mon starts at zero
|
||||
int utcDay = pTm->tm_mday;
|
||||
int utcHours = pTm->tm_hour;
|
||||
int utcMinutes = pTm->tm_min;
|
||||
int utcSeconds = pTm->tm_sec;
|
||||
|
||||
if (generate_nmea) {
|
||||
// ------------------
|
||||
// ------$GPGSA------
|
||||
// ------------------
|
||||
|
||||
uint32_t svUsedCount = 0;
|
||||
uint32_t svUsedList[32] = {0};
|
||||
uint32_t mask = loc_eng_data_p->sv_used_mask;
|
||||
for (uint8_t i = 1; mask > 0 && svUsedCount < 32; i++)
|
||||
{
|
||||
if (mask & 1)
|
||||
svUsedList[svUsedCount++] = i;
|
||||
mask = mask >> 1;
|
||||
}
|
||||
// clear the cache so they can't be used again
|
||||
loc_eng_data_p->sv_used_mask = 0;
|
||||
|
||||
char fixType;
|
||||
if (svUsedCount == 0)
|
||||
fixType = '1'; // no fix
|
||||
else if (svUsedCount <= 3)
|
||||
fixType = '2'; // 2D fix
|
||||
else
|
||||
fixType = '3'; // 3D fix
|
||||
|
||||
length = snprintf(pMarker, lengthRemaining, "$GPGSA,A,%c,", fixType);
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
|
||||
for (uint8_t i = 0; i < 12; i++) // only the first 12 sv go in sentence
|
||||
{
|
||||
if (i < svUsedCount)
|
||||
length = snprintf(pMarker, lengthRemaining, "%02d,", svUsedList[i]);
|
||||
else
|
||||
length = snprintf(pMarker, lengthRemaining, ",");
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
}
|
||||
|
||||
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)
|
||||
{ // dop is in locationExtended, (QMI)
|
||||
length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f",
|
||||
locationExtended.pdop,
|
||||
locationExtended.hdop,
|
||||
locationExtended.vdop);
|
||||
}
|
||||
else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0)
|
||||
{ // dop was cached from sv report (RPC)
|
||||
length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f",
|
||||
loc_eng_data_p->pdop,
|
||||
loc_eng_data_p->hdop,
|
||||
loc_eng_data_p->vdop);
|
||||
}
|
||||
else
|
||||
{ // no dop
|
||||
length = snprintf(pMarker, lengthRemaining, ",,");
|
||||
}
|
||||
|
||||
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
|
||||
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
|
||||
|
||||
// ------------------
|
||||
// ------$GPVTG------
|
||||
// ------------------
|
||||
|
||||
pMarker = sentence;
|
||||
lengthRemaining = sizeof(sentence);
|
||||
|
||||
if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING)
|
||||
{
|
||||
float magTrack = location.gpsLocation.bearing;
|
||||
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV)
|
||||
{
|
||||
float magTrack = location.gpsLocation.bearing - locationExtended.magneticDeviation;
|
||||
if (magTrack < 0.0)
|
||||
magTrack += 360.0;
|
||||
else if (magTrack > 360.0)
|
||||
magTrack -= 360.0;
|
||||
}
|
||||
|
||||
length = snprintf(pMarker, lengthRemaining, "$GPVTG,%.1lf,T,%.1lf,M,", location.gpsLocation.bearing, magTrack);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = snprintf(pMarker, lengthRemaining, "$GPVTG,,T,,M,");
|
||||
}
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
|
||||
if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED)
|
||||
{
|
||||
float speedKnots = location.gpsLocation.speed * (3600.0/1852.0);
|
||||
float speedKmPerHour = location.gpsLocation.speed * 3.6;
|
||||
|
||||
length = snprintf(pMarker, lengthRemaining, "%.1lf,N,%.1lf,K,", speedKnots, speedKmPerHour);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = snprintf(pMarker, lengthRemaining, ",N,,K,");
|
||||
}
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
|
||||
if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG))
|
||||
length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix
|
||||
else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode)
|
||||
length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous
|
||||
else
|
||||
length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential
|
||||
|
||||
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
|
||||
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
|
||||
|
||||
// ------------------
|
||||
// ------$GPRMC------
|
||||
// ------------------
|
||||
|
||||
pMarker = sentence;
|
||||
lengthRemaining = sizeof(sentence);
|
||||
|
||||
length = snprintf(pMarker, lengthRemaining, "$GPRMC,%02d%02d%02d,A," ,
|
||||
utcHours, utcMinutes, utcSeconds);
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
|
||||
if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)
|
||||
{
|
||||
double latitude = location.gpsLocation.latitude;
|
||||
double longitude = location.gpsLocation.longitude;
|
||||
char latHemisphere;
|
||||
char lonHemisphere;
|
||||
double latMinutes;
|
||||
double lonMinutes;
|
||||
|
||||
if (latitude > 0)
|
||||
{
|
||||
latHemisphere = 'N';
|
||||
}
|
||||
else
|
||||
{
|
||||
latHemisphere = 'S';
|
||||
latitude *= -1.0;
|
||||
}
|
||||
|
||||
if (longitude < 0)
|
||||
{
|
||||
lonHemisphere = 'W';
|
||||
longitude *= -1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
lonHemisphere = 'E';
|
||||
}
|
||||
|
||||
latMinutes = fmod(latitude * 60.0 , 60.0);
|
||||
lonMinutes = fmod(longitude * 60.0 , 60.0);
|
||||
|
||||
length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,",
|
||||
(uint8_t)floor(latitude), latMinutes, latHemisphere,
|
||||
(uint8_t)floor(longitude),lonMinutes, lonHemisphere);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = snprintf(pMarker, lengthRemaining,",,,,");
|
||||
}
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
|
||||
if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED)
|
||||
{
|
||||
float speedKnots = location.gpsLocation.speed * (3600.0/1852.0);
|
||||
length = snprintf(pMarker, lengthRemaining, "%.1lf,", speedKnots);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = snprintf(pMarker, lengthRemaining, ",");
|
||||
}
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
|
||||
if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING)
|
||||
{
|
||||
length = snprintf(pMarker, lengthRemaining, "%.1lf,", location.gpsLocation.bearing);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = snprintf(pMarker, lengthRemaining, ",");
|
||||
}
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
|
||||
length = snprintf(pMarker, lengthRemaining, "%2.2d%2.2d%2.2d,",
|
||||
utcDay, utcMonth, utcYear);
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
|
||||
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV)
|
||||
{
|
||||
float magneticVariation = locationExtended.magneticDeviation;
|
||||
char direction;
|
||||
if (magneticVariation < 0.0)
|
||||
{
|
||||
direction = 'W';
|
||||
magneticVariation *= -1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = 'E';
|
||||
}
|
||||
|
||||
length = snprintf(pMarker, lengthRemaining, "%.1lf,%c,",
|
||||
magneticVariation, direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = snprintf(pMarker, lengthRemaining, ",,");
|
||||
}
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
|
||||
if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG))
|
||||
length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix
|
||||
else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode)
|
||||
length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous
|
||||
else
|
||||
length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential
|
||||
|
||||
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
|
||||
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
|
||||
|
||||
// ------------------
|
||||
// ------$GPGGA------
|
||||
// ------------------
|
||||
|
||||
pMarker = sentence;
|
||||
lengthRemaining = sizeof(sentence);
|
||||
|
||||
length = snprintf(pMarker, lengthRemaining, "$GPGGA,%02d%02d%02d," ,
|
||||
utcHours, utcMinutes, utcSeconds);
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
|
||||
if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)
|
||||
{
|
||||
double latitude = location.gpsLocation.latitude;
|
||||
double longitude = location.gpsLocation.longitude;
|
||||
char latHemisphere;
|
||||
char lonHemisphere;
|
||||
double latMinutes;
|
||||
double lonMinutes;
|
||||
|
||||
if (latitude > 0)
|
||||
{
|
||||
latHemisphere = 'N';
|
||||
}
|
||||
else
|
||||
{
|
||||
latHemisphere = 'S';
|
||||
latitude *= -1.0;
|
||||
}
|
||||
|
||||
if (longitude < 0)
|
||||
{
|
||||
lonHemisphere = 'W';
|
||||
longitude *= -1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
lonHemisphere = 'E';
|
||||
}
|
||||
|
||||
latMinutes = fmod(latitude * 60.0 , 60.0);
|
||||
lonMinutes = fmod(longitude * 60.0 , 60.0);
|
||||
|
||||
length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,",
|
||||
(uint8_t)floor(latitude), latMinutes, latHemisphere,
|
||||
(uint8_t)floor(longitude),lonMinutes, lonHemisphere);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = snprintf(pMarker, lengthRemaining,",,,,");
|
||||
}
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
|
||||
char gpsQuality;
|
||||
if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG))
|
||||
gpsQuality = '0'; // 0 means no fix
|
||||
else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode)
|
||||
gpsQuality = '1'; // 1 means GPS fix
|
||||
else
|
||||
gpsQuality = '2'; // 2 means DGPS fix
|
||||
|
||||
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)
|
||||
{ // dop is in locationExtended, (QMI)
|
||||
length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,",
|
||||
gpsQuality, svUsedCount, locationExtended.hdop);
|
||||
}
|
||||
else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0)
|
||||
{ // dop was cached from sv report (RPC)
|
||||
length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,",
|
||||
gpsQuality, svUsedCount, loc_eng_data_p->hdop);
|
||||
}
|
||||
else
|
||||
{ // no hdop
|
||||
length = snprintf(pMarker, lengthRemaining, "%c,%02d,,",
|
||||
gpsQuality, svUsedCount);
|
||||
}
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
|
||||
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL)
|
||||
{
|
||||
length = snprintf(pMarker, lengthRemaining, "%.1lf,M,",
|
||||
locationExtended.altitudeMeanSeaLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = snprintf(pMarker, lengthRemaining,",,");
|
||||
}
|
||||
|
||||
if (length < 0 || length >= lengthRemaining)
|
||||
{
|
||||
LOC_LOGE("NMEA Error in string formatting");
|
||||
return;
|
||||
}
|
||||
pMarker += length;
|
||||
lengthRemaining -= length;
|
||||
|
||||
if ((location.gpsLocation.flags & GPS_LOCATION_HAS_ALTITUDE) &&
|
||||
(locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL))
|
||||
{
|
||||
length = snprintf(pMarker, lengthRemaining, "%.1lf,M,,",
|
||||
location.gpsLocation.altitude - locationExtended.altitudeMeanSeaLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = snprintf(pMarker, lengthRemaining,",,,");
|
||||
}
|
||||
|
||||
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
|
||||
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
|
||||
|
||||
}
|
||||
//Send blank NMEA reports for non-final fixes
|
||||
else {
|
||||
strlcpy(sentence, "$GPGSA,A,1,,,,,,,,,,,,,,,", sizeof(sentence));
|
||||
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
|
||||
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
|
||||
|
||||
strlcpy(sentence, "$GPVTG,,T,,M,,N,,K,N", sizeof(sentence));
|
||||
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
|
||||
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
|
||||
|
||||
strlcpy(sentence, "$GPRMC,,V,,,,,,,,,,N", sizeof(sentence));
|
||||
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
|
||||
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
|
||||
|
||||
strlcpy(sentence, "$GPGGA,,,,,,0,,,,,,,,", sizeof(sentence));
|
||||
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
|
||||
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
|
||||
}
|
||||
// clear the dop cache so they can't be used again
|
||||
loc_eng_data_p->pdop = 0;
|
||||
loc_eng_data_p->hdop = 0;
|
||||
loc_eng_data_p->vdop = 0;
|
||||
|
||||
EXIT_LOG(%d, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION loc_eng_nmea_generate_sv
|
||||
|
||||
DESCRIPTION
|
||||
Generate NMEA sentences generated based on sv report
|
||||
|
||||
DEPENDENCIES
|
||||
NONE
|
||||
|
||||
RETURN VALUE
|
||||
0
|
||||
|
||||
SIDE EFFECTS
|
||||
N/A
|
||||
|
||||
===========================================================================*/
|
||||
void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p,
|
||||
const 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);
|
||||
}
|
42
gps/loc_api/libloc_api_50001/loc_eng_nmea.h
Normal file
42
gps/loc_api/libloc_api_50001/loc_eng_nmea.h
Normal file
|
@ -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
|
167
gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp
Normal file
167
gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp
Normal file
|
@ -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;
|
||||
|
||||
}
|
47
gps/loc_api/libloc_api_50001/loc_eng_xtra.h
Normal file
47
gps/loc_api/libloc_api_50001/loc_eng_xtra.h
Normal file
|
@ -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
|
46
gps/platform_lib_abstractions/elapsed_millis_since_boot.cpp
Normal file
46
gps/platform_lib_abstractions/elapsed_millis_since_boot.cpp
Normal file
|
@ -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;
|
||||
}
|
35
gps/platform_lib_abstractions/platform_lib_includes.h
Normal file
35
gps/platform_lib_abstractions/platform_lib_includes.h
Normal file
|
@ -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
|
81
gps/platform_lib_abstractions/platform_lib_macros.h
Normal file
81
gps/platform_lib_abstractions/platform_lib_macros.h
Normal file
|
@ -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
|
35
gps/platform_lib_abstractions/platform_lib_time.h
Normal file
35
gps/platform_lib_abstractions/platform_lib_time.h
Normal file
|
@ -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
|
59
gps/utils/Android.mk
Normal file
59
gps/utils/Android.mk
Normal file
|
@ -0,0 +1,59 @@
|
|||
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 += \
|
||||
sec_gps.c \
|
||||
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 \
|
||||
loc_misc_utils.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 \
|
||||
loc_misc_utils.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
|
328
gps/utils/linked_list.c
Normal file
328
gps/utils/linked_list.c
Normal file
|
@ -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;
|
||||
}
|
||||
|
217
gps/utils/linked_list.h
Normal file
217
gps/utils/linked_list.h
Normal file
|
@ -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__ */
|
300
gps/utils/loc_cfg.cpp
Normal file
300
gps/utils/loc_cfg.cpp
Normal file
|
@ -0,0 +1,300 @@
|
|||
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_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>
|
||||
#include <loc_misc_utils.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);
|
||||
|
||||
typedef struct loc_param_v_type
|
||||
{
|
||||
char* param_name;
|
||||
char* param_str_value;
|
||||
int param_int_value;
|
||||
double param_double_value;
|
||||
}loc_param_v_type;
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION loc_set_config_entry
|
||||
|
||||
DESCRIPTION
|
||||
Potentially sets a given configuration table entry based on the passed in
|
||||
configuration value. This is done by using a string comparison of the
|
||||
parameter names and those found in the configuration file.
|
||||
|
||||
PARAMETERS:
|
||||
config_entry: configuration entry in the table to possibly set
|
||||
config_value: value to store in the entry if the parameter names match
|
||||
|
||||
DEPENDENCIES
|
||||
N/A
|
||||
|
||||
RETURN VALUE
|
||||
None
|
||||
|
||||
SIDE EFFECTS
|
||||
N/A
|
||||
===========================================================================*/
|
||||
int loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value)
|
||||
{
|
||||
int ret=-1;
|
||||
if(NULL == config_entry || NULL == config_value)
|
||||
{
|
||||
LOC_LOGE("%s: INVALID config entry or parameter", __FUNCTION__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (strcmp(config_entry->param_name, config_value->param_name) == 0 &&
|
||||
config_entry->param_ptr)
|
||||
{
|
||||
switch (config_entry->param_type)
|
||||
{
|
||||
case 's':
|
||||
if (strcmp(config_value->param_str_value, "NULL") == 0)
|
||||
{
|
||||
*((char*)config_entry->param_ptr) = '\0';
|
||||
}
|
||||
else {
|
||||
strlcpy((char*) config_entry->param_ptr,
|
||||
config_value->param_str_value,
|
||||
LOC_MAX_PARAM_STRING + 1);
|
||||
}
|
||||
/* Log INI values */
|
||||
LOC_LOGD("%s: PARAM %s = %s", __FUNCTION__, config_entry->param_name, (char*)config_entry->param_ptr);
|
||||
|
||||
if(NULL != config_entry->param_set)
|
||||
{
|
||||
*(config_entry->param_set) = 1;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case 'n':
|
||||
*((int *)config_entry->param_ptr) = config_value->param_int_value;
|
||||
/* Log INI values */
|
||||
LOC_LOGD("%s: PARAM %s = %d", __FUNCTION__, config_entry->param_name, config_value->param_int_value);
|
||||
|
||||
if(NULL != config_entry->param_set)
|
||||
{
|
||||
*(config_entry->param_set) = 1;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case 'f':
|
||||
*((double *)config_entry->param_ptr) = config_value->param_double_value;
|
||||
/* Log INI values */
|
||||
LOC_LOGD("%s: PARAM %s = %f", __FUNCTION__, config_entry->param_name, config_value->param_double_value);
|
||||
|
||||
if(NULL != config_entry->param_set)
|
||||
{
|
||||
*(config_entry->param_set) = 1;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
LOC_LOGE("%s: PARAM %s parameter type must be n, f, or s", __FUNCTION__, config_entry->param_name);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION loc_read_conf_r (repetitive)
|
||||
|
||||
DESCRIPTION
|
||||
Reads the specified configuration file and sets defined values based on
|
||||
the passed in configuration table. This table maps strings to values to
|
||||
set along with the type of each of these values.
|
||||
The difference between this and loc_read_conf is that this function returns
|
||||
the file pointer position at the end of filling a config table. Also, it
|
||||
reads a fixed number of parameters at a time which is equal to the length
|
||||
of the configuration table. This functionality enables the caller to
|
||||
repeatedly call the function to read data from the same file.
|
||||
|
||||
PARAMETERS:
|
||||
conf_fp : file pointer
|
||||
config_table: table definition of strings to places to store information
|
||||
table_length: length of the configuration table
|
||||
|
||||
DEPENDENCIES
|
||||
N/A
|
||||
|
||||
RETURN VALUE
|
||||
0: Table filled successfully
|
||||
1: No more parameters to read
|
||||
-1: Error filling table
|
||||
|
||||
SIDE EFFECTS
|
||||
N/A
|
||||
===========================================================================*/
|
||||
int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, uint32_t table_length)
|
||||
{
|
||||
char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */
|
||||
char *lasts;
|
||||
loc_param_v_type config_value;
|
||||
uint32_t i;
|
||||
int ret=0;
|
||||
|
||||
unsigned int num_params=table_length;
|
||||
if(conf_fp == NULL) {
|
||||
LOC_LOGE("%s:%d]: ERROR: File pointer is NULL\n", __func__, __LINE__);
|
||||
ret = -1;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Clear all validity bits */
|
||||
for(i = 0; NULL != config_table && i < table_length; i++)
|
||||
{
|
||||
if(NULL != config_table[i].param_set)
|
||||
{
|
||||
*(config_table[i].param_set) = 0;
|
||||
}
|
||||
}
|
||||
LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params);
|
||||
while(num_params)
|
||||
{
|
||||
if(!fgets(input_buf, LOC_MAX_PARAM_LINE, conf_fp)) {
|
||||
LOC_LOGD("%s:%d]: fgets returned NULL\n", __func__, __LINE__);
|
||||
break;
|
||||
}
|
||||
|
||||
memset(&config_value, 0, sizeof(config_value));
|
||||
|
||||
/* Separate variable and value */
|
||||
config_value.param_name = strtok_r(input_buf, "=", &lasts);
|
||||
/* skip lines that do not contain "=" */
|
||||
if (config_value.param_name == NULL) continue;
|
||||
config_value.param_str_value = strtok_r(NULL, "=", &lasts);
|
||||
/* skip lines that do not contain two operands */
|
||||
if (config_value.param_str_value == NULL) continue;
|
||||
|
||||
/* Trim leading and trailing spaces */
|
||||
loc_util_trim_space(config_value.param_name);
|
||||
loc_util_trim_space(config_value.param_str_value);
|
||||
|
||||
/* Parse numerical value */
|
||||
if ((strlen(config_value.param_str_value) >=3) &&
|
||||
(config_value.param_str_value[0] == '0') &&
|
||||
(tolower(config_value.param_str_value[1]) == 'x'))
|
||||
{
|
||||
/* hex */
|
||||
config_value.param_int_value = (int) strtol(&config_value.param_str_value[2],
|
||||
(char**) NULL, 16);
|
||||
}
|
||||
else {
|
||||
config_value.param_double_value = (double) atof(config_value.param_str_value); /* float */
|
||||
config_value.param_int_value = atoi(config_value.param_str_value); /* dec */
|
||||
}
|
||||
|
||||
for(i = 0; NULL != config_table && i < table_length; i++)
|
||||
{
|
||||
if(!loc_set_config_entry(&config_table[i], &config_value)) {
|
||||
num_params--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION loc_read_conf
|
||||
|
||||
DESCRIPTION
|
||||
Reads the specified configuration file and sets defined values based on
|
||||
the passed in configuration table. This table maps strings to values to
|
||||
set along with the type of each of these values.
|
||||
|
||||
PARAMETERS:
|
||||
conf_file_name: configuration file to read
|
||||
config_table: table definition of strings to places to store information
|
||||
table_length: length of the configuration table
|
||||
|
||||
DEPENDENCIES
|
||||
N/A
|
||||
|
||||
RETURN VALUE
|
||||
None
|
||||
|
||||
SIDE EFFECTS
|
||||
N/A
|
||||
===========================================================================*/
|
||||
void loc_read_conf(const char* conf_file_name, 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);
|
||||
if(table_length && config_table) {
|
||||
loc_read_conf_r(gps_conf_fp, config_table, table_length);
|
||||
rewind(gps_conf_fp);
|
||||
}
|
||||
loc_read_conf_r(gps_conf_fp, loc_parameter_table, loc_param_num);
|
||||
fclose(gps_conf_fp);
|
||||
}
|
||||
/* Initialize logging mechanism with parsed data */
|
||||
loc_logger_init(DEBUG_LEVEL, TIMESTAMP);
|
||||
}
|
84
gps/utils/loc_cfg.h
Normal file
84
gps/utils/loc_cfg.h
Normal file
|
@ -0,0 +1,84 @@
|
|||
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LOC_CFG_H
|
||||
#define LOC_CFG_H
|
||||
|
||||
#include <stdio.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);
|
||||
extern int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, uint32_t table_length);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LOC_CFG_H */
|
235
gps/utils/loc_log.cpp
Normal file
235
gps/utils/loc_log.cpp
Normal file
|
@ -0,0 +1,235 @@
|
|||
/* 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_AUTO),
|
||||
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;
|
||||
}
|
||||
|
68
gps/utils/loc_log.h
Normal file
68
gps/utils/loc_log.h
Normal file
|
@ -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 */
|
114
gps/utils/loc_misc_utils.cpp
Normal file
114
gps/utils/loc_misc_utils.cpp
Normal file
|
@ -0,0 +1,114 @@
|
|||
/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <log_util.h>
|
||||
#include <loc_misc_utils.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_misc_utils"
|
||||
|
||||
int loc_util_split_string(char *raw_string, char **split_strings_ptr,
|
||||
int max_num_substrings, char delimiter)
|
||||
{
|
||||
int raw_string_index=0;
|
||||
int num_split_strings=0;
|
||||
unsigned char end_string=0;
|
||||
int raw_string_length=0;
|
||||
|
||||
if(!raw_string || !split_strings_ptr) {
|
||||
LOC_LOGE("%s:%d]: NULL parameters", __func__, __LINE__);
|
||||
num_split_strings = -1;
|
||||
goto err;
|
||||
}
|
||||
LOC_LOGD("%s:%d]: raw string: %s\n", __func__, __LINE__, raw_string);
|
||||
raw_string_length = strlen(raw_string) + 1;
|
||||
split_strings_ptr[num_split_strings] = &raw_string[raw_string_index];
|
||||
for(raw_string_index=0; raw_string_index < raw_string_length; raw_string_index++) {
|
||||
if(raw_string[raw_string_index] == '\0')
|
||||
end_string=1;
|
||||
if((raw_string[raw_string_index] == delimiter) || end_string) {
|
||||
raw_string[raw_string_index] = '\0';
|
||||
LOC_LOGD("%s:%d]: split string: %s\n",
|
||||
__func__, __LINE__, split_strings_ptr[num_split_strings]);
|
||||
num_split_strings++;
|
||||
if(((raw_string_index + 1) < raw_string_length) &&
|
||||
(num_split_strings < max_num_substrings)) {
|
||||
split_strings_ptr[num_split_strings] = &raw_string[raw_string_index+1];
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(end_string)
|
||||
break;
|
||||
}
|
||||
err:
|
||||
LOC_LOGD("%s:%d]: num_split_strings: %d\n", __func__, __LINE__, num_split_strings);
|
||||
return num_split_strings;
|
||||
}
|
||||
|
||||
void loc_util_trim_space(char *org_string)
|
||||
{
|
||||
char *scan_ptr, *write_ptr;
|
||||
char *first_nonspace = NULL, *last_nonspace = NULL;
|
||||
|
||||
if(org_string == NULL) {
|
||||
LOC_LOGE("%s:%d]: NULL parameter", __func__, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
scan_ptr = write_ptr = org_string;
|
||||
|
||||
while (*scan_ptr) {
|
||||
//Find the first non-space character
|
||||
if ( !isspace(*scan_ptr) && first_nonspace == NULL) {
|
||||
first_nonspace = scan_ptr;
|
||||
}
|
||||
//Once the first non-space character is found in the
|
||||
//above check, keep shifting the characters to the left
|
||||
//to replace the spaces
|
||||
if (first_nonspace != NULL) {
|
||||
*(write_ptr++) = *scan_ptr;
|
||||
//Keep track of which was the last non-space character
|
||||
//encountered
|
||||
//last_nonspace will not be updated in the case where
|
||||
//the string ends with spaces
|
||||
if ( !isspace(*scan_ptr)) {
|
||||
last_nonspace = write_ptr;
|
||||
}
|
||||
}
|
||||
scan_ptr++;
|
||||
}
|
||||
//Add NULL terminator after the last non-space character
|
||||
if (last_nonspace) { *last_nonspace = '\0'; }
|
||||
err:
|
||||
return;
|
||||
}
|
99
gps/utils/loc_misc_utils.h
Normal file
99
gps/utils/loc_misc_utils.h
Normal file
|
@ -0,0 +1,99 @@
|
|||
/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef _LOC_MISC_UTILS_H_
|
||||
#define _LOC_MISC_UTILS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION loc_split_string
|
||||
|
||||
DESCRIPTION:
|
||||
This function is used to split a delimiter separated string into
|
||||
sub-strings. This function does not allocate new memory to store the split
|
||||
strings. Instead, it places '\0' in places of delimiters and assings the
|
||||
starting address of the substring within the raw string as the string address
|
||||
The input raw_string no longer remains to be a collection of sub-strings
|
||||
after this function is executed.
|
||||
Please make a copy of the input string before calling this function if
|
||||
necessary
|
||||
|
||||
PARAMETERS:
|
||||
char *raw_string: is the original string with delimiter separated substrings
|
||||
char **split_strings_ptr: is the arraw of pointers which will hold the addresses
|
||||
of individual substrings
|
||||
int max_num_substrings: is the maximum number of substrings that are expected
|
||||
by the caller. The array of pointers in the above parameter
|
||||
is usually this long
|
||||
char delimiter: is the delimiter that separates the substrings. Examples: ' ', ';'
|
||||
|
||||
DEPENDENCIES
|
||||
N/A
|
||||
|
||||
RETURN VALUE
|
||||
int Number of split strings
|
||||
|
||||
SIDE EFFECTS
|
||||
The input raw_string no longer remains a delimiter separated single string.
|
||||
|
||||
EXAMPLE
|
||||
delimiter = ' ' //space
|
||||
raw_string = "hello new user" //delimiter is space ' '
|
||||
addresses = 0123456789abcd
|
||||
split_strings_ptr[0] = &raw_string[0]; //split_strings_ptr[0] contains "hello"
|
||||
split_strings_ptr[1] = &raw_string[6]; //split_strings_ptr[1] contains "new"
|
||||
split_strings_ptr[2] = &raw_string[a]; //split_strings_ptr[2] contains "user"
|
||||
|
||||
===========================================================================*/
|
||||
int loc_util_split_string(char *raw_string, char **split_strings_ptr, int max_num_substrings,
|
||||
char delimiter);
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION trim_space
|
||||
|
||||
DESCRIPTION
|
||||
Removes leading and trailing spaces of the string
|
||||
|
||||
DEPENDENCIES
|
||||
N/A
|
||||
|
||||
RETURN VALUE
|
||||
None
|
||||
|
||||
SIDE EFFECTS
|
||||
N/A
|
||||
===========================================================================*/
|
||||
void loc_util_trim_space(char *org_string);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //_LOC_MISC_UTILS_H_
|
244
gps/utils/loc_target.cpp
Normal file
244
gps/utils/loc_target.cpp
Normal file
|
@ -0,0 +1,244 @@
|
|||
/* 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 STR_AUTO "auto"
|
||||
#define IS_STR_END(c) ((c) == '\0' || (c) == '\n' || (c) == '\r')
|
||||
#define LENGTH(s) (sizeof(s) - 1)
|
||||
#define GPS_CHECK_NO_ERROR 0
|
||||
#define GPS_CHECK_NO_GPS_HW 1
|
||||
#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;
|
||||
}
|
||||
|
||||
/*The character array passed to this function should have length
|
||||
of atleast PROPERTY_VALUE_MAX*/
|
||||
void loc_get_target_baseband(char *baseband, int array_length)
|
||||
{
|
||||
if(baseband && (array_length >= PROPERTY_VALUE_MAX)) {
|
||||
property_get("ro.baseband", baseband, "");
|
||||
LOC_LOGD("%s:%d]: Baseband: %s\n", __func__, __LINE__, baseband);
|
||||
}
|
||||
else {
|
||||
LOC_LOGE("%s:%d]: NULL parameter or array length less than PROPERTY_VALUE_MAX\n",
|
||||
__func__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
/*The character array passed to this function should have length
|
||||
of atleast PROPERTY_VALUE_MAX*/
|
||||
void loc_get_platform_name(char *platform_name, int array_length)
|
||||
{
|
||||
if(platform_name && (array_length >= PROPERTY_VALUE_MAX)) {
|
||||
property_get("ro.board.platform", platform_name, "");
|
||||
LOC_LOGD("%s:%d]: Target name: %s\n", __func__, __LINE__, platform_name);
|
||||
}
|
||||
else {
|
||||
LOC_LOGE("%s:%d]: Null parameter or array length less than PROPERTY_VALUE_MAX\n",
|
||||
__func__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int loc_get_target(void)
|
||||
{
|
||||
if (gTarget != (unsigned int)-1)
|
||||
return gTarget;
|
||||
|
||||
static const char hw_platform[] = "/sys/devices/soc0/hw_platform";
|
||||
static const char id[] = "/sys/devices/soc0/soc_id";
|
||||
static const char hw_platform_dep[] =
|
||||
"/sys/devices/system/soc/soc0/hw_platform";
|
||||
static const char id_dep[] = "/sys/devices/system/soc/soc0/id";
|
||||
static const char mdm[] = "/dev/mdm"; // No such file or directory
|
||||
|
||||
char rd_hw_platform[LINE_LEN];
|
||||
char rd_id[LINE_LEN];
|
||||
char rd_mdm[LINE_LEN];
|
||||
char baseband[LINE_LEN];
|
||||
|
||||
if (is_qca1530()) {
|
||||
gTarget = TARGET_QCA1530;
|
||||
goto detected;
|
||||
}
|
||||
|
||||
loc_get_target_baseband(baseband, sizeof(baseband));
|
||||
|
||||
if (!access(hw_platform, F_OK)) {
|
||||
read_a_line(hw_platform, rd_hw_platform, LINE_LEN);
|
||||
} else {
|
||||
read_a_line(hw_platform_dep, rd_hw_platform, LINE_LEN);
|
||||
}
|
||||
if (!access(id, F_OK)) {
|
||||
read_a_line(id, rd_id, LINE_LEN);
|
||||
} else {
|
||||
read_a_line(id_dep, rd_id, LINE_LEN);
|
||||
}
|
||||
|
||||
if( !memcmp(baseband, STR_AUTO, LENGTH(STR_AUTO)) )
|
||||
{
|
||||
gTarget = TARGET_AUTO;
|
||||
goto detected;
|
||||
}
|
||||
|
||||
if( !memcmp(baseband, STR_APQ, LENGTH(STR_APQ)) ){
|
||||
if( !memcmp(rd_id, MPQ8064_ID_1, LENGTH(MPQ8064_ID_1))
|
||||
&& IS_STR_END(rd_id[LENGTH(MPQ8064_ID_1)]) )
|
||||
gTarget = TARGET_MPQ;
|
||||
else
|
||||
gTarget = TARGET_APQ_SA;
|
||||
}
|
||||
else {
|
||||
if( (!memcmp(rd_hw_platform, STR_LIQUID, LENGTH(STR_LIQUID))
|
||||
&& IS_STR_END(rd_hw_platform[LENGTH(STR_LIQUID)])) ||
|
||||
(!memcmp(rd_hw_platform, STR_SURF, LENGTH(STR_SURF))
|
||||
&& IS_STR_END(rd_hw_platform[LENGTH(STR_SURF)])) ||
|
||||
(!memcmp(rd_hw_platform, STR_MTP, LENGTH(STR_MTP))
|
||||
&& IS_STR_END(rd_hw_platform[LENGTH(STR_MTP)]))) {
|
||||
|
||||
if (!read_a_line( mdm, rd_mdm, LINE_LEN))
|
||||
gTarget = TARGET_MDM;
|
||||
}
|
||||
else if( (!memcmp(rd_id, MSM8930_ID_1, LENGTH(MSM8930_ID_1))
|
||||
&& IS_STR_END(rd_id[LENGTH(MSM8930_ID_1)])) ||
|
||||
(!memcmp(rd_id, MSM8930_ID_2, LENGTH(MSM8930_ID_2))
|
||||
&& IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) )
|
||||
gTarget = TARGET_MSM_NO_SSC;
|
||||
else
|
||||
gTarget = TARGET_UNKNOWN;
|
||||
}
|
||||
|
||||
detected:
|
||||
LOC_LOGD("HAL: %s returned %d", __FUNCTION__, gTarget);
|
||||
return gTarget;
|
||||
}
|
77
gps/utils/loc_target.h
Normal file
77
gps/utils/loc_target.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef LOC_TARGET_H
|
||||
#define LOC_TARGET_H
|
||||
#define TARGET_SET(gnss,ssc) ( (gnss<<1)|ssc )
|
||||
#define TARGET_DEFAULT TARGET_SET(GNSS_MSM, HAS_SSC)
|
||||
#define TARGET_MDM TARGET_SET(GNSS_MDM, HAS_SSC)
|
||||
#define TARGET_APQ_SA TARGET_SET(GNSS_GSS, NO_SSC)
|
||||
#define TARGET_MPQ TARGET_SET(GNSS_NONE,NO_SSC)
|
||||
#define TARGET_MSM_NO_SSC TARGET_SET(GNSS_MSM, NO_SSC)
|
||||
#define TARGET_QCA1530 TARGET_SET(GNSS_QCA1530, NO_SSC)
|
||||
#define TARGET_AUTO TARGET_SET(GNSS_AUTO, NO_SSC)
|
||||
#define TARGET_UNKNOWN TARGET_SET(GNSS_UNKNOWN, NO_SSC)
|
||||
#define getTargetGnssType(target) (target>>1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
unsigned int loc_get_target(void);
|
||||
|
||||
/*The character array passed to this function should have length
|
||||
of atleast PROPERTY_VALUE_MAX*/
|
||||
void loc_get_target_baseband(char *baseband, int array_length);
|
||||
/*The character array passed to this function should have length
|
||||
of atleast PROPERTY_VALUE_MAX*/
|
||||
void loc_get_platform_name(char *platform_name, int array_length);
|
||||
|
||||
/* Please remember to update 'target_name' in loc_log.cpp,
|
||||
if do any changes to this enum. */
|
||||
typedef enum {
|
||||
GNSS_NONE = 0,
|
||||
GNSS_MSM,
|
||||
GNSS_GSS,
|
||||
GNSS_MDM,
|
||||
GNSS_QCA1530,
|
||||
GNSS_AUTO,
|
||||
GNSS_UNKNOWN
|
||||
}GNSS_TARGET;
|
||||
|
||||
typedef enum {
|
||||
NO_SSC = 0,
|
||||
HAS_SSC
|
||||
}SSC_TYPE;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*LOC_TARGET_H*/
|
202
gps/utils/loc_timer.c
Normal file
202
gps/utils/loc_timer.c
Normal file
|
@ -0,0 +1,202 @@
|
|||
/* 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;
|
||||
}
|
||||
|
||||
if(ETIMEDOUT == ret)
|
||||
t->callback_func(t->user_data, ret);
|
||||
|
||||
// A (should be rare) race condition is that, when the loc_time_stop is called
|
||||
// and acquired mutex, we reach here. pthread_mutex_destroy will fail with
|
||||
// error code EBUSY. We give it 6 tries in 5 seconds. Should be eanough time
|
||||
// for loc_timer_stop to complete. With the 7th try, we also perform unlock
|
||||
// prior to destroy.
|
||||
{
|
||||
int i;
|
||||
for (i = 0; EBUSY == pthread_mutex_destroy(&t->timer_mutex) && i <= 5; i++) {
|
||||
if (i < 5) {
|
||||
sleep(1);
|
||||
} else {
|
||||
// nah, forget it, something is seriously wrong. Mutex has been
|
||||
// held too long. Unlock the mutext here.
|
||||
pthread_mutex_unlock(&t->timer_mutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
pthread_cond_destroy(&t->timer_cond);
|
||||
|
||||
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)) == 0) {
|
||||
if (READY == t->state || WAITING == t->state) {
|
||||
pthread_cond_signal(&t->timer_cond);
|
||||
t->state = ABORT;
|
||||
}
|
||||
pthread_mutex_unlock(&(t->timer_mutex));
|
||||
}
|
||||
}
|
63
gps/utils/loc_timer.h
Normal file
63
gps/utils/loc_timer.h
Normal file
|
@ -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__
|
181
gps/utils/log_util.h
Normal file
181
gps/utils/log_util.h
Normal file
|
@ -0,0 +1,181 @@
|
|||
/* Copyright (c) 2011-2014 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LOG_UTIL_H__
|
||||
#define __LOG_UTIL_H__
|
||||
|
||||
#ifndef USE_GLIB
|
||||
#include <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 IF_LOC_LOGE if((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5))
|
||||
|
||||
#define IF_LOC_LOGW if((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5))
|
||||
|
||||
#define IF_LOC_LOGI if((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5))
|
||||
|
||||
#define IF_LOC_LOGD if((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5))
|
||||
|
||||
#define IF_LOC_LOGV if((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5))
|
||||
|
||||
#define LOC_LOGE(...) \
|
||||
IF_LOC_LOGE { ALOGE("E/" __VA_ARGS__); } \
|
||||
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGE("E/" __VA_ARGS__); }
|
||||
|
||||
#define LOC_LOGW(...) \
|
||||
IF_LOC_LOGW { ALOGE("W/" __VA_ARGS__); } \
|
||||
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGW("W/" __VA_ARGS__); }
|
||||
|
||||
#define LOC_LOGI(...) \
|
||||
IF_LOC_LOGI { ALOGE("I/" __VA_ARGS__); } \
|
||||
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGI("I/" __VA_ARGS__); }
|
||||
|
||||
#define LOC_LOGD(...) \
|
||||
IF_LOC_LOGD { ALOGE("D/" __VA_ARGS__); } \
|
||||
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGD("D/" __VA_ARGS__); }
|
||||
|
||||
#define LOC_LOGV(...) \
|
||||
IF_LOC_LOGV { 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__
|
336
gps/utils/msg_q.c
Normal file
336
gps/utils/msg_q.c
Normal file
|
@ -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;
|
||||
}
|
207
gps/utils/msg_q.h
Normal file
207
gps/utils/msg_q.h
Normal file
|
@ -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__ */
|
12
gps/utils/sec_gps.c
Normal file
12
gps/utils/sec_gps.c
Normal file
|
@ -0,0 +1,12 @@
|
|||
|
||||
|
||||
int sec_gps_conf(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Sec_Configuration(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ const char CameraParameters::EFFECT_VINTAGE_WARM[] = "vintage-warm"; \
|
|||
const char CameraParameters::EFFECT_WASHED[] = "washed"; \
|
||||
const char CameraParameters::SCENE_MODE_BACKLIGHT[] = "backlight"; \
|
||||
const char CameraParameters::SCENE_MODE_ASD[] = "asd"; \
|
||||
int CameraParameters::getInt64(__attribute__((__unused__)) const char *key) const { return -1; } \
|
||||
int CameraParameters::getInt64(const char *key) const { return -1; }; \
|
||||
const char *CameraParameters::getPreviewFrameRateMode() const { return get(KEY_PREVIEW_FRAME_RATE_MODE); }; \
|
||||
void CameraParameters::setPreviewFrameRateMode(const char *mode) { set(KEY_PREVIEW_FRAME_RATE_MODE, mode); }; \
|
||||
void CameraParameters::getMeteringAreaCenter(int *x, int *y) const { }; \
|
||||
|
|
File diff suppressed because it is too large
Load diff
4613
include/telephony/ril.h
Normal file
4613
include/telephony/ril.h
Normal file
File diff suppressed because it is too large
Load diff
104
msm8226.mk
104
msm8226.mk
|
@ -12,6 +12,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
LOCAL_PATH := device/samsung/msm8226-common
|
||||
|
||||
$(call inherit-product, $(SRC_TARGET_DIR)/product/languages_full.mk)
|
||||
|
||||
# Overlay
|
||||
|
@ -25,6 +27,15 @@ PRODUCT_AAPT_PREF_CONFIG := xhdpi
|
|||
TARGET_SCREEN_HEIGHT := 1280
|
||||
TARGET_SCREEN_WIDTH := 720
|
||||
|
||||
# Dalvik VM config for 1536MB (1.5GB) RAM devices
|
||||
PRODUCT_PROPERTY_OVERRIDES += \
|
||||
dalvik.vm.heapstartsize=8m \
|
||||
dalvik.vm.heapgrowthlimit=128m \
|
||||
dalvik.vm.heapsize=512m \
|
||||
dalvik.vm.heaptargetutilization=0.75 \
|
||||
dalvik.vm.heapminfree=2m \
|
||||
dalvik.vm.heapmaxfree=8m
|
||||
|
||||
# Audio
|
||||
PRODUCT_PACKAGES += \
|
||||
audiod \
|
||||
|
@ -40,22 +51,10 @@ PRODUCT_PACKAGES += \
|
|||
libqcomvoiceprocessing \
|
||||
tinymix
|
||||
|
||||
# Audio configuration
|
||||
#PRODUCT_COPY_FILES += \
|
||||
# $(LOCAL_PATH)/configs/audio_effects.conf:system/vendor/etc/audio_effects.conf
|
||||
|
||||
PRODUCT_PACKAGES += \
|
||||
libwvm_shim \
|
||||
imx175_shim
|
||||
|
||||
# Camera
|
||||
PRODUCT_PACKAGES += \
|
||||
camera.vendor.msm8226 \
|
||||
camera.msm8226 \
|
||||
libboringssl-compat \
|
||||
libstlport \
|
||||
libxml2 \
|
||||
Snap
|
||||
libxml2
|
||||
|
||||
# CRDA
|
||||
PRODUCT_PACKAGES += \
|
||||
|
@ -79,16 +78,19 @@ PRODUCT_PACKAGES += \
|
|||
|
||||
# FM
|
||||
PRODUCT_PACKAGES += \
|
||||
FMRadio \
|
||||
libfmjni
|
||||
FM2 \
|
||||
FMRecord \
|
||||
libqcomfm_jni \
|
||||
qcom.fmradio
|
||||
|
||||
# GPS
|
||||
PRODUCT_PACKAGES += \
|
||||
gps.msm8226
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(LOCAL_PATH)/gps/flp.conf:system/etc/flp.conf \
|
||||
$(LOCAL_PATH)/gps/gps.conf:system/etc/gps.conf \
|
||||
$(LOCAL_PATH)/gps/sap.conf:system/etc/sap.conf \
|
||||
$(LOCAL_PATH)/gps/android.hardware.location.gps.xml:system/etc/permissions/android.hardware.location.gps.xml \
|
||||
$(LOCAL_PATH)/gps/com.android.location.provider.xml:system/etc/permission/com.android.location.provider.xml \
|
||||
$(LOCAL_PATH)/gps/com.qualcomm.location.xml:system/etc/permissions/com.qualcomm.location.xml
|
||||
$(LOCAL_PATH)/gps/sap.conf:system/etc/sap.conf
|
||||
|
||||
# Keylayouts
|
||||
PRODUCT_COPY_FILES += \
|
||||
|
@ -106,35 +108,25 @@ PRODUCT_COPY_FILES += \
|
|||
frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \
|
||||
frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \
|
||||
frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
|
||||
$(LOCAL_PATH)/configs/media_codecs_performance.xml:system/etc/media_codecs_performance.xml \
|
||||
$(LOCAL_PATH)/configs/media_codecs.xml:system/etc/media_codecs.xml
|
||||
|
||||
# NFC
|
||||
|
||||
PRODUCT_PACKAGES += \
|
||||
libnfc \
|
||||
libnfc_jni \
|
||||
Nfc \
|
||||
Tag \
|
||||
com.android.nfc_extras
|
||||
|
||||
ifeq ($(TARGET_BUILD_VARIANT),user)
|
||||
NFCEE_ACCESS_PATH := $(LOCAL_PATH)/configs/nfcee_access.xml
|
||||
else
|
||||
NFCEE_ACCESS_PATH := $(LOCAL_PATH)/configs/nfcee_access_debug.xml
|
||||
endif
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(NFCEE_ACCESS_PATH):system/etc/nfcee_access.xml \
|
||||
$(LOCAL_PATH)/configs/nfc-nci.conf:system/etc/nfc-nci.conf
|
||||
|
||||
# OMX
|
||||
PRODUCT_PACKAGES += \
|
||||
libdashplayer \
|
||||
libOmxAacEnc \
|
||||
libOmxAmrEnc \
|
||||
libOmxCore \
|
||||
libOmxEvrcEnc \
|
||||
libOmxQcelp13Enc \
|
||||
libOmxVdec \
|
||||
libOmxVdecHevc \
|
||||
libOmxVenc \
|
||||
libstagefrighthw
|
||||
|
||||
libstagefrighthw \
|
||||
qcmediaplayer
|
||||
|
||||
PRODUCT_BOOT_JARS += \
|
||||
qcmediaplayer
|
||||
|
||||
# Permissions
|
||||
PRODUCT_COPY_FILES += \
|
||||
frameworks/native/data/etc/android.hardware.audio.low_latency.xml:system/etc/permissions/android.hardware.audio.low_latency.xml \
|
||||
|
@ -144,6 +136,7 @@ PRODUCT_COPY_FILES += \
|
|||
frameworks/native/data/etc/android.hardware.camera.flash-autofocus.xml:system/etc/permissions/android.hardware.camera.flash-autofocus.xml \
|
||||
frameworks/native/data/etc/android.hardware.camera.front.xml:system/etc/permissions/android.hardware.camera.front.xml \
|
||||
frameworks/native/data/etc/android.hardware.camera.xml:system/etc/permissions/android.hardware.camera.xml \
|
||||
frameworks/native/data/etc/android.hardware.location.gps.xml:system/etc/permissions/android.hardware.location.gps.xml \
|
||||
frameworks/native/data/etc/android.hardware.sensor.accelerometer.xml:system/etc/permissions/android.hardware.sensor.accelerometer.xml \
|
||||
frameworks/native/data/etc/android.hardware.sensor.compass.xml:system/etc/permissions/android.hardware.sensor.compass.xml \
|
||||
frameworks/native/data/etc/android.hardware.sensor.light.xml:system/etc/permissions/android.hardware.sensor.light.xml \
|
||||
|
@ -156,9 +149,7 @@ PRODUCT_COPY_FILES += \
|
|||
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/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml \
|
||||
frameworks/native/data/etc/android.software.midi.xml:system/etc/permissions/android.software.midi.xml \
|
||||
frameworks/native/data/etc/com.android.nfc_extras.xml:system/etc/permissions/com.android.nfc_extras.xml
|
||||
frameworks/native/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml
|
||||
|
||||
# Power
|
||||
PRODUCT_PACKAGES += \
|
||||
|
@ -166,18 +157,17 @@ PRODUCT_PACKAGES += \
|
|||
|
||||
# Radio
|
||||
PRODUCT_PACKAGES += \
|
||||
libril_shim
|
||||
rild \
|
||||
librilutils \
|
||||
libril
|
||||
|
||||
# Ramdisk
|
||||
PRODUCT_PACKAGES += \
|
||||
init.qcom.bt.sh
|
||||
# USB
|
||||
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
|
||||
persist.sys.isUsbOtgEnabled=true \
|
||||
persist.sys.usb.config=mtp
|
||||
|
||||
PRODUCT_PACKAGES += \
|
||||
init.qcom.power.rc \
|
||||
init.qcom.rc \
|
||||
init.qcom.usb.rc \
|
||||
init.recovery.qcom.rc \
|
||||
ueventd.qcom.rc
|
||||
com.android.future.usb.accessory
|
||||
|
||||
# Wifi
|
||||
PRODUCT_PACKAGES += \
|
||||
|
@ -186,14 +176,6 @@ PRODUCT_PACKAGES += \
|
|||
wpa_supplicant \
|
||||
wpa_supplicant.conf
|
||||
|
||||
# Torch
|
||||
PRODUCT_PACKAGES += \
|
||||
Torch
|
||||
|
||||
# QC Perf
|
||||
PRODUCT_PROPERTY_OVERRIDES += \
|
||||
ro.vendor.extension_library=/system/lib/libqc-opt.so
|
||||
|
||||
PRODUCT_PACKAGES += \
|
||||
libcurl \
|
||||
libqsap_sdk \
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2015, 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!-- Set this to true to enable the platform's auto-power-save modes like doze and
|
||||
app standby. These are not enabled by default because they require a standard
|
||||
cloud-to-device messaging service for apps to interact correctly with the modes
|
||||
(such as to be able to deliver an instant message to the device even when it is
|
||||
dozing). This should be enabled if you have such services and expect apps to
|
||||
correctly use them when installed on your device. Otherwise, keep this disabled
|
||||
so that applications can still use their own mechanisms. -->
|
||||
<bool name="config_enableAutoPowerModes">true</bool>
|
||||
|
||||
<!-- ComponentName of a dream to show whenever the system would otherwise have
|
||||
gone to sleep. When the PowerManager is asked to go to sleep, it will instead
|
||||
try to start this dream if possible. The dream should typically call startDozing()
|
||||
to put the display into a low power state and allow the application processor
|
||||
to be suspended. When the dream ends, the system will go to sleep as usual.
|
||||
Specify the component name or an empty string if none.
|
||||
Note that doze dreams are not subject to the same start conditions as ordinary dreams.
|
||||
Doze dreams will run whenever the power manager is in a dozing state. -->
|
||||
<string name="config_dozeComponent">com.android.systemui/com.android.systemui.doze.DozeService</string>
|
||||
|
||||
<!-- Screen brightness used to dim the screen while dozing in a very low power state.
|
||||
May be less than the minimum allowed brightness setting
|
||||
that can be set by the user. -->
|
||||
<integer name="config_screenBrightnessDoze">20</integer>
|
||||
|
||||
<!-- If true, the doze component is not started until after the screen has been
|
||||
turned off and the screen off animation has been performed. -->
|
||||
<bool name="config_dozeAfterScreenOff">true</bool>
|
||||
|
||||
<!-- Power Management: Specifies whether to decouple the interactive state of the
|
||||
device from the display on/off state.
|
||||
When false, setInteractive(..., true) will be called before the display is turned on
|
||||
and setInteractive(..., false) will be called after the display is turned off.
|
||||
This mode provides best compatibility for devices that expect the interactive
|
||||
state to be tied to the display state.
|
||||
When true, setInteractive(...) will be called independently of whether the display
|
||||
is being turned on or off. This mode enables the power manager to reduce
|
||||
clocks and disable the touch controller while the display is on.
|
||||
This resource should be set to "true" when a doze component has been specified
|
||||
to maximize power savings but not all devices support it.
|
||||
Refer to power.h for details.
|
||||
-->
|
||||
<bool name="config_powerDecoupleInteractiveModeFromDisplay">true</bool>
|
||||
|
||||
<!-- Base "touch slop" value used by ViewConfiguration as a
|
||||
movement threshold where scrolling should begin. -->
|
||||
<dimen name="config_viewConfigurationTouchSlop">4dp</dimen>
|
||||
|
||||
<!-- Enable UI blur feature -->
|
||||
<bool name="config_uiBlurEnabled">true</bool>
|
||||
|
||||
<!-- Indicate whether to allow the device to suspend when the screen is off
|
||||
due to the proximity sensor. This resource should only be set to true
|
||||
if the sensor HAL correctly handles the proximity sensor as a wake-up source.
|
||||
Otherwise, the device may fail to wake out of suspend reliably.
|
||||
The default is false. -->
|
||||
<bool name="config_suspendWhenScreenOffDueToProximity">true</bool>
|
||||
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?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 -->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- Threshold in micro amperes below which a charger is rated as "slow" -->
|
||||
<integer name="config_chargingSlowlyThreshold">600000</integer>
|
||||
|
||||
</resources>
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2016, 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!-- Doze: pulse parameter - how long does it take to fade in? -->
|
||||
<integer name="doze_pulse_duration_in">900</integer>
|
||||
|
||||
<!-- Doze: pulse parameter - once faded in, how long does it stay visible? -->
|
||||
<integer name="doze_pulse_duration_visible">3000</integer>
|
||||
|
||||
<!-- Doze: pulse parameter - how long does it take to fade out? -->
|
||||
<integer name="doze_pulse_duration_out">600</integer>
|
||||
|
||||
<!-- Doze: when to pulse after a buzzworthy notification arrives -->
|
||||
<string name="doze_pulse_schedule" translatable="false">5s,15s,30s,60s</string>
|
||||
|
||||
</resources>
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2012 The Android Open Source Project
|
||||
2015-2016 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.
|
||||
-->
|
||||
<!-- Camera app resources that may need to be customized
|
||||
for different hardware or product builds. -->
|
||||
<resources>
|
||||
<!-- Opens back camera using openLegacy() -->
|
||||
<bool name="back_camera_open_legacy">false</bool>
|
||||
|
||||
<!-- Opens front camera using openLegacy() -->
|
||||
<bool name="front_camera_open_legacy">false</bool>
|
||||
|
||||
<!-- Restart preview for back camera onPictureTaken -->
|
||||
<bool name="back_camera_restart_preview_onPictureTaken">true</bool>
|
||||
|
||||
<!-- Restart preview for front camera onPictureTaken -->
|
||||
<bool name="front_camera_restart_preview_onPictureTaken">true</bool>
|
||||
</resources>
|
|
@ -1,33 +0,0 @@
|
|||
<!--
|
||||
/*
|
||||
** Copyright 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- Full path to the sysfs toggle -->
|
||||
<string name="flashDevice">/sys/class/leds/led:flash_torch/brightness</string>
|
||||
|
||||
<!-- Lowest setting -->
|
||||
<integer name="valueOn">5</integer>
|
||||
<!-- Middle setting -->
|
||||
<integer name="valueHigh">175</integer>
|
||||
<!-- Highest setting, leave -1 if it doesn't exist -->
|
||||
<integer name="valueDeathRay">255</integer>
|
||||
|
||||
<!-- If the device supports high brightness mode, enable this -->
|
||||
<bool name="hasHighBrightness">true</bool>
|
||||
|
||||
</resources>
|
|
@ -1,23 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 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.
|
||||
-->
|
||||
<resources>
|
||||
|
||||
<!-- BurnIn protection. This should be enabled on devices that have OLED displays -->
|
||||
<bool name="config_enableBurnInProtection">true</bool>
|
||||
|
||||
<!-- Default value for proximity check on screen wake
|
||||
NOTE ! - Enable for devices that have a fast response proximity sensor (ideally < 300ms)-->
|
||||
<bool name="config_proximityCheckOnWake">true</bool>
|
||||
|
||||
</resources>
|
274
power/power.c
274
power/power.c
|
@ -1,274 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
#define LOG_TAG "PowerHAL"
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "power.h"
|
||||
|
||||
#define CPUFREQ_PATH "/sys/devices/system/cpu/cpu0/cpufreq/"
|
||||
#define INTERACTIVE_PATH "/sys/devices/system/cpu/cpufreq/interactive/"
|
||||
|
||||
/* touchkeys */
|
||||
#define TK_POWER "/sys/class/input/input1/enabled"
|
||||
/* touchscreen */
|
||||
#define TS_POWER "/sys/class/input/input2/enabled"
|
||||
|
||||
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int boostpulse_fd = -1;
|
||||
|
||||
static int current_power_profile = -1;
|
||||
static int requested_power_profile = -1;
|
||||
|
||||
static int sysfs_write_str(char *path, char *s)
|
||||
{
|
||||
char buf[80];
|
||||
int len;
|
||||
int ret = 0;
|
||||
int fd;
|
||||
|
||||
fd = open(path, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error opening %s: %s\n", path, buf);
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
len = write(fd, s, strlen(s));
|
||||
if (len < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error writing to %s: %s\n", path, buf);
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int sysfs_write_int(char *path, int value)
|
||||
{
|
||||
char buf[80];
|
||||
snprintf(buf, 80, "%d", value);
|
||||
return sysfs_write_str(path, buf);
|
||||
}
|
||||
|
||||
static int is_profile_valid(int profile)
|
||||
{
|
||||
return profile >= 0 && profile < PROFILE_MAX;
|
||||
}
|
||||
|
||||
static void power_init(__attribute__((unused)) struct power_module *module)
|
||||
{
|
||||
ALOGI("%s", __func__);
|
||||
}
|
||||
|
||||
static int boostpulse_open()
|
||||
{
|
||||
pthread_mutex_lock(&lock);
|
||||
if (boostpulse_fd < 0) {
|
||||
boostpulse_fd = open(INTERACTIVE_PATH "boostpulse", O_WRONLY);
|
||||
}
|
||||
pthread_mutex_unlock(&lock);
|
||||
|
||||
return boostpulse_fd;
|
||||
}
|
||||
|
||||
static void power_set_interactive_ext(int on) {
|
||||
ALOGD("%s: %s input devices", __func__, on ? "enabling" : "disabling");
|
||||
sysfs_write_str(TK_POWER, on ? "1" : "0");
|
||||
sysfs_write_str(TS_POWER, on ? "1" : "0");
|
||||
}
|
||||
|
||||
static void power_set_interactive(__attribute__((unused)) struct power_module *module, int on)
|
||||
{
|
||||
if (!is_profile_valid(current_power_profile)) {
|
||||
ALOGD("%s: no power profile selected yet", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
power_set_interactive_ext(on);
|
||||
|
||||
if (on) {
|
||||
sysfs_write_int(INTERACTIVE_PATH "hispeed_freq",
|
||||
profiles[current_power_profile].hispeed_freq);
|
||||
sysfs_write_int(INTERACTIVE_PATH "go_hispeed_load",
|
||||
profiles[current_power_profile].go_hispeed_load);
|
||||
sysfs_write_int(INTERACTIVE_PATH "target_loads",
|
||||
profiles[current_power_profile].target_loads);
|
||||
sysfs_write_int(CPUFREQ_PATH "scaling_min_freq",
|
||||
profiles[current_power_profile].scaling_min_freq);
|
||||
} else {
|
||||
sysfs_write_int(INTERACTIVE_PATH "hispeed_freq",
|
||||
profiles[current_power_profile].hispeed_freq_off);
|
||||
sysfs_write_int(INTERACTIVE_PATH "go_hispeed_load",
|
||||
profiles[current_power_profile].go_hispeed_load_off);
|
||||
sysfs_write_int(INTERACTIVE_PATH "target_loads",
|
||||
profiles[current_power_profile].target_loads_off);
|
||||
sysfs_write_int(CPUFREQ_PATH "scaling_min_freq",
|
||||
profiles[current_power_profile].scaling_min_freq_off);
|
||||
}
|
||||
}
|
||||
|
||||
static void set_power_profile(int profile)
|
||||
{
|
||||
if (!is_profile_valid(profile)) {
|
||||
ALOGE("%s: unknown profile: %d", __func__, profile);
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile == current_power_profile)
|
||||
return;
|
||||
|
||||
ALOGD("%s: setting profile %d", __func__, profile);
|
||||
|
||||
sysfs_write_int(INTERACTIVE_PATH "boost",
|
||||
profiles[profile].boost);
|
||||
sysfs_write_int(INTERACTIVE_PATH "boostpulse_duration",
|
||||
profiles[profile].boostpulse_duration);
|
||||
sysfs_write_int(INTERACTIVE_PATH "go_hispeed_load",
|
||||
profiles[profile].go_hispeed_load);
|
||||
sysfs_write_int(INTERACTIVE_PATH "hispeed_freq",
|
||||
profiles[profile].hispeed_freq);
|
||||
sysfs_write_int(INTERACTIVE_PATH "min_sample_time",
|
||||
profiles[profile].min_sample_time);
|
||||
sysfs_write_int(INTERACTIVE_PATH "timer_rate",
|
||||
profiles[profile].timer_rate);
|
||||
sysfs_write_int(INTERACTIVE_PATH "above_hispeed_delay",
|
||||
profiles[profile].above_hispeed_delay);
|
||||
sysfs_write_int(INTERACTIVE_PATH "target_loads",
|
||||
profiles[profile].target_loads);
|
||||
sysfs_write_int(CPUFREQ_PATH "scaling_max_freq",
|
||||
profiles[profile].scaling_max_freq);
|
||||
sysfs_write_int(CPUFREQ_PATH "scaling_min_freq",
|
||||
profiles[profile].scaling_min_freq);
|
||||
|
||||
current_power_profile = profile;
|
||||
}
|
||||
|
||||
static void power_hint(__attribute__((unused)) struct power_module *module,
|
||||
power_hint_t hint, void *data)
|
||||
{
|
||||
char buf[80];
|
||||
int len;
|
||||
|
||||
switch (hint) {
|
||||
case POWER_HINT_INTERACTION:
|
||||
if (!is_profile_valid(current_power_profile)) {
|
||||
ALOGD("%s: no power profile selected yet", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!profiles[current_power_profile].boostpulse_duration)
|
||||
return;
|
||||
|
||||
if (boostpulse_open() >= 0) {
|
||||
snprintf(buf, sizeof(buf), "%d", 1);
|
||||
len = write(boostpulse_fd, &buf, sizeof(buf));
|
||||
if (len < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error writing to boostpulse: %s\n", buf);
|
||||
|
||||
pthread_mutex_lock(&lock);
|
||||
close(boostpulse_fd);
|
||||
boostpulse_fd = -1;
|
||||
pthread_mutex_unlock(&lock);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case POWER_HINT_SET_PROFILE:
|
||||
pthread_mutex_lock(&lock);
|
||||
set_power_profile(*(int32_t *)data);
|
||||
pthread_mutex_unlock(&lock);
|
||||
break;
|
||||
case POWER_HINT_LOW_POWER:
|
||||
/* This hint is handled by the framework */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int get_feature(__attribute__((unused)) struct power_module *module,
|
||||
feature_t feature)
|
||||
{
|
||||
if (feature == POWER_FEATURE_SUPPORTED_PROFILES) {
|
||||
return PROFILE_MAX;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int power_open(const hw_module_t* module, const char* name,
|
||||
hw_device_t** device)
|
||||
{
|
||||
ALOGD("%s: enter; name=%s", __FUNCTION__, name);
|
||||
|
||||
if (strcmp(name, POWER_HARDWARE_MODULE_ID)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
power_module_t *dev = (power_module_t *)calloc(1,
|
||||
sizeof(power_module_t));
|
||||
|
||||
if (!dev) {
|
||||
ALOGD("%s: failed to allocate memory", __FUNCTION__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dev->common.tag = HARDWARE_MODULE_TAG;
|
||||
dev->common.module_api_version = POWER_MODULE_API_VERSION_0_2;
|
||||
dev->common.hal_api_version = HARDWARE_HAL_API_VERSION;
|
||||
|
||||
dev->init = power_init;
|
||||
dev->powerHint = power_hint; // This is handled by framework
|
||||
dev->setInteractive = power_set_interactive;
|
||||
dev->getFeature = get_feature;
|
||||
|
||||
*device = (hw_device_t*)dev;
|
||||
|
||||
ALOGD("%s: exit", __FUNCTION__);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct hw_module_methods_t power_module_methods = {
|
||||
.open = power_open,
|
||||
};
|
||||
|
||||
struct power_module HAL_MODULE_INFO_SYM = {
|
||||
.common = {
|
||||
.tag = HARDWARE_MODULE_TAG,
|
||||
.module_api_version = POWER_MODULE_API_VERSION_0_2,
|
||||
.hal_api_version = HARDWARE_HAL_API_VERSION,
|
||||
.id = POWER_HARDWARE_MODULE_ID,
|
||||
.name = "msm8226 Power HAL",
|
||||
.author = "The LineageOS Project",
|
||||
.methods = &power_module_methods,
|
||||
},
|
||||
|
||||
.init = power_init,
|
||||
.setInteractive = power_set_interactive,
|
||||
.powerHint = power_hint,
|
||||
.getFeature = get_feature
|
||||
};
|
110
power/power.h
110
power/power.h
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
|
||||
enum {
|
||||
PROFILE_POWER_SAVE = 0,
|
||||
PROFILE_BALANCED,
|
||||
PROFILE_HIGH_PERFORMANCE,
|
||||
PROFILE_BIAS_POWER_SAVE,
|
||||
PROFILE_MAX
|
||||
};
|
||||
|
||||
typedef struct governor_settings {
|
||||
int is_interactive;
|
||||
int boost;
|
||||
int boostpulse_duration;
|
||||
int go_hispeed_load;
|
||||
int go_hispeed_load_off;
|
||||
int hispeed_freq;
|
||||
int hispeed_freq_off;
|
||||
int min_sample_time;
|
||||
int timer_rate;
|
||||
int above_hispeed_delay;
|
||||
int target_loads;
|
||||
int target_loads_off;
|
||||
int scaling_max_freq;
|
||||
int scaling_min_freq;
|
||||
int scaling_min_freq_off;
|
||||
} power_profile;
|
||||
|
||||
static power_profile profiles[PROFILE_MAX] = {
|
||||
[PROFILE_POWER_SAVE] = {
|
||||
.boost = 0,
|
||||
.boostpulse_duration = 0,
|
||||
.go_hispeed_load = 90,
|
||||
.go_hispeed_load_off = 90,
|
||||
.hispeed_freq = 787200,
|
||||
.hispeed_freq_off = 787200,
|
||||
.min_sample_time = 60000,
|
||||
.timer_rate = 20000,
|
||||
.above_hispeed_delay = 20000,
|
||||
.target_loads = 90,
|
||||
.target_loads_off = 90,
|
||||
.scaling_max_freq = 998400,
|
||||
.scaling_min_freq = 384000,
|
||||
.scaling_min_freq_off = 300000,
|
||||
},
|
||||
[PROFILE_BALANCED] = {
|
||||
.boost = 0,
|
||||
.boostpulse_duration = 60000,
|
||||
.go_hispeed_load = 80,
|
||||
.go_hispeed_load_off = 90,
|
||||
.hispeed_freq = 998400,
|
||||
.hispeed_freq_off = 787200,
|
||||
.min_sample_time = 60000,
|
||||
.timer_rate = 20000,
|
||||
.above_hispeed_delay = 20000,
|
||||
.target_loads = 80,
|
||||
.target_loads_off = 90,
|
||||
.scaling_max_freq = 1401600,
|
||||
.scaling_min_freq = 787200,
|
||||
.scaling_min_freq_off = 300000,
|
||||
},
|
||||
[PROFILE_HIGH_PERFORMANCE] = {
|
||||
.boost = 1,
|
||||
/* The CPU is already boosted, set duration to zero
|
||||
* to avoid unneccessary writes to boostpulse */
|
||||
.boostpulse_duration = 0,
|
||||
.go_hispeed_load = 60,
|
||||
.go_hispeed_load_off = 70,
|
||||
.hispeed_freq = 998400,
|
||||
.hispeed_freq_off = 998400,
|
||||
.min_sample_time = 60000,
|
||||
.timer_rate = 20000,
|
||||
.above_hispeed_delay = 20000,
|
||||
.target_loads = 60,
|
||||
.target_loads_off = 70,
|
||||
.scaling_max_freq = 1401600,
|
||||
.scaling_min_freq = 787200,
|
||||
.scaling_min_freq_off = 300000,
|
||||
},
|
||||
[PROFILE_BIAS_POWER_SAVE] = {
|
||||
.boost = 0,
|
||||
.boostpulse_duration = 40000,
|
||||
.go_hispeed_load = 90,
|
||||
.go_hispeed_load_off = 90,
|
||||
.hispeed_freq = 787200,
|
||||
.hispeed_freq_off = 787200,
|
||||
.min_sample_time = 60000,
|
||||
.timer_rate = 20000,
|
||||
.above_hispeed_delay = 20000,
|
||||
.target_loads = 90,
|
||||
.target_loads_off = 90,
|
||||
.scaling_max_freq = 1190400,
|
||||
.scaling_min_freq = 384000,
|
||||
.scaling_min_freq_off = 300000,
|
||||
},
|
||||
};
|
54
power/power_ext.c
Normal file
54
power/power_ext.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* 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 <errno.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define LOG_TAG "PowerHAL_H_Ext"
|
||||
#include <utils/Log.h>
|
||||
|
||||
/* touchkeys */
|
||||
#define TK_POWER "/sys/class/input/input1/enabled"
|
||||
|
||||
/* touchscreen */
|
||||
#define TS_POWER "/sys/class/input/input2/enabled"
|
||||
|
||||
static void sysfs_write(char *path, char *s) {
|
||||
char buf[80];
|
||||
int len;
|
||||
int fd = open(path, O_WRONLY);
|
||||
|
||||
if (fd < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error opening %s: %s\n", path, buf);
|
||||
return;
|
||||
}
|
||||
|
||||
len = write(fd, s, strlen(s));
|
||||
if (len < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error writing to %s: %s\n", path, buf);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void cm_power_set_interactive_ext(int on) {
|
||||
ALOGD("%s: %s input devices", __func__, on ? "enabling" : "disabling");
|
||||
sysfs_write(TK_POWER, on ? "1" : "0");
|
||||
sysfs_write(TS_POWER, on ? "1" : "0");
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
# Qualcomm MSM camera
|
||||
type camera, domain;
|
||||
type camera_exec, exec_type, file_type;
|
||||
|
||||
# Started by init
|
||||
init_daemon_domain(camera)
|
||||
|
||||
allow camera self:process execmem;
|
||||
|
||||
allow camera camera_device:dir search;
|
||||
allow camera { video_device camera_device }:chr_file rw_file_perms;
|
||||
allow camera { surfaceflinger mediaserver }:fd use;
|
||||
|
||||
# Create /data/cam_socket0 as camera_socket
|
||||
type_transition camera system_data_file:sock_file camera_socket "cam_socket0";
|
||||
type_transition camera system_data_file:sock_file camera_socket "cam_socket1";
|
||||
allow camera camera_socket:sock_file { create unlink };
|
||||
allow camera system_data_file:dir remove_name;
|
||||
allow camera system_data_file:sock_file unlink;
|
||||
|
||||
# All others under /data get camera_data_file
|
||||
file_type_auto_trans(camera, system_data_file, camera_data_file);
|
||||
allow camera camera_data_file:dir { write add_name };
|
||||
allow camera camera_data_file:file create_file_perms;
|
||||
|
||||
# Connect to /data/app/sensor_ctl_socket
|
||||
unix_socket_connect(camera, sensors, sensors)
|
||||
allow camera sensors_socket:sock_file read;
|
||||
|
||||
allow camera devpts:chr_file { read write getattr };
|
||||
allow camera device:chr_file { ioctl };
|
||||
allow camera mpdecision:unix_stream_socket connectto;
|
||||
allow camera servicemanager:binder call;
|
||||
allow camera socket_device:sock_file write;
|
||||
#allow camera system:binder call;
|
||||
#allow camera system:unix_stream_socket { read write setopt };
|
||||
allow camera system_data_file:file { open };
|
|
@ -1,3 +0,0 @@
|
|||
allow cameraserver system_data_file:sock_file write;
|
||||
allow cameraserver camera_socket:sock_file write;
|
||||
allow cameraserver mpctl_socket:dir search;
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue