From 22e1bcc46ab9e02fcacee50860575ce6ddc488d0 Mon Sep 17 00:00:00 2001 From: Valera1978 Date: Mon, 1 Jan 2018 00:53:06 +0300 Subject: [PATCH] init Oreo --- BoardConfig.mk | 29 +- audio/audio_effects.conf | 277 ++ bluetooth/bdroid_buildcfg.h | 6 +- bluetooth/vnd_viennalte.txt | 15 +- camera/Android.mk | 38 +- camera/CameraWrapper.cpp | 40 +- config.fs | 8 + configs/izat.conf | 6 +- device.mk | 38 +- include/camera/CameraParametersExtra.h | 249 - include/hardware/gps.h | 4244 ++++++++--------- init/init_viennalte.cpp | 10 +- libsecnativefeature/Android.mk | 20 + libsecnativefeature/SecNativeFeature.h | 31 + libsecnativefeature/SecNativeFeatureCIf.cpp | 85 + libsecnativefeature/SecNativeFeatureCIf.h | 24 + libsecnativefeature/SecNativeFeatureCppIf.cpp | 187 + libsecnativefeature/SecNativeFeatureCppIf.h | 27 + libsecnativefeature/SecNativeFeatureTagAll.h | 20 + .../SecNativeFeatureTagCommon.h | 9 + .../SecNativeFeatureTagFramework.h | 16 + libsecnativefeature/SecNativeFeatureTagWeb.h | 150 + libshims/Android.mk | 17 + {ril => libshims/libshim_camera}/Android.mk | 6 +- libshims/libshim_camera/camera_shim.c | 33 + lineage.mk | 20 +- manifest.xml | 60 + .../base/core/res/res/values/config.xml | 14 +- .../SettingsProvider/res/values/config.xml | 1 + ril/ril_shim.c | 70 - .../internal/telephony/NoteProRIL.java | 414 -- rootdir/etc/fstab.full | 23 + rootdir/etc/fstab.qcom | 9 +- rootdir/etc/init.qcom.rc | 87 +- rootdir/etc/ueventd.qcom.rc | 10 +- sepolicy/file_contexts | 10 + sepolicy/fingerprintd.te | 14 + sepolicy/shell.te | 4 + system.prop | 5 +- 39 files changed, 3232 insertions(+), 3094 deletions(-) create mode 100755 audio/audio_effects.conf create mode 100755 config.fs delete mode 100755 include/camera/CameraParametersExtra.h create mode 100755 libsecnativefeature/Android.mk create mode 100755 libsecnativefeature/SecNativeFeature.h create mode 100755 libsecnativefeature/SecNativeFeatureCIf.cpp create mode 100755 libsecnativefeature/SecNativeFeatureCIf.h create mode 100755 libsecnativefeature/SecNativeFeatureCppIf.cpp create mode 100755 libsecnativefeature/SecNativeFeatureCppIf.h create mode 100755 libsecnativefeature/SecNativeFeatureTagAll.h create mode 100755 libsecnativefeature/SecNativeFeatureTagCommon.h create mode 100755 libsecnativefeature/SecNativeFeatureTagFramework.h create mode 100755 libsecnativefeature/SecNativeFeatureTagWeb.h create mode 100755 libshims/Android.mk rename {ril => libshims/libshim_camera}/Android.mk (56%) create mode 100755 libshims/libshim_camera/camera_shim.c create mode 100755 manifest.xml delete mode 100755 ril/ril_shim.c delete mode 100755 ril/telephony/java/com/android/internal/telephony/NoteProRIL.java create mode 100755 rootdir/etc/fstab.full create mode 100755 sepolicy/fingerprintd.te create mode 100755 sepolicy/shell.te diff --git a/BoardConfig.mk b/BoardConfig.mk index 8952c7f..8ce0c0c 100755 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -14,7 +14,7 @@ # limitations under the License. # inherit from common msm8974 --include device/samsung/msm8974-common/BoardConfigCommon.mk +include device/samsung/msm8974-common/BoardConfigCommon.mk LOCAL_PATH := device/samsung/viennalte @@ -28,12 +28,17 @@ TARGET_OTA_ASSERT_DEVICE := viennalte,viennaltexx # Use Snapdragon LLVM if available on build server TARGET_USE_SDCLANG := true +# ADB Legacy Interface +TARGET_USES_LEGACY_ADB_INTERFACE := true + # Bootloader TARGET_BOOTLOADER_BOARD_NAME := MSM8974 # Kernel BOARD_KERNEL_BASE := 0x00000000 -BOARD_KERNEL_CMDLINE := console=null androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 +#BOARD_KERNEL_CMDLINE := console=null androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 +BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 androidboot.selinux=permissive +BOARD_KERNEL_IMAGE_NAME := zImage BOARD_KERNEL_PAGESIZE := 2048 BOARD_KERNEL_SEPARATED_DT := true BOARD_MKBOOTIMG_ARGS := --ramdisk_offset 0x02000000 --tags_offset 0x01E00000 @@ -51,6 +56,9 @@ TARGET_LIBINIT_MSM8974_DEFINES_FILE := device/samsung/viennalte/init/init_vienna BOARD_HAVE_NEW_QCOM_CSDCLIENT := true USE_CUSTOM_AUDIO_POLICY := 1 +# Binder API version +TARGET_USES_64_BIT_BINDER := true + # Bluetooth BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := $(LOCAL_PATH)/bluetooth BOARD_CUSTOM_BT_CONFIG := $(LOCAL_PATH)/bluetooth/vnd_viennalte.txt @@ -61,8 +69,11 @@ BOARD_HAVE_BLUETOOTH_BCM := true TARGET_HAS_LEGACY_CAMERA_HAL1 := true USE_DEVICE_SPECIFIC_CAMERA := true -# CMHW -BOARD_HARDWARE_CLASS += $(LOCAL_PATH)/cmhw +# Filesystem +TARGET_FS_CONFIG_GEN := $(LOCAL_PATH)/config.fs + +# HIDL +DEVICE_MANIFEST_FILE += $(LOCAL_PATH)/manifest.xml # Legacy BLOB Support TARGET_NEEDS_PLATFORM_TEXT_RELOCATIONS := true @@ -86,7 +97,8 @@ TARGET_POWERHAL_SET_INTERACTIVE_EXT := $(LOCAL_PATH)/power/power_ext.c TARGET_POWERHAL_VARIANT := qcom # Radio -BOARD_RIL_CLASS := ../../../device/samsung/viennalte/ril +#BOARD_PROVIDES_LIBRIL := true +#TARGET_RIL_VARIANT := caf # Recovery BOARD_CUSTOM_RECOVERY_KEYMAPPING := ../../device/samsung/viennalte/recovery/recovery_keys.c @@ -96,14 +108,13 @@ BOARD_HAS_LARGE_FILESYSTEM := true BOARD_HAS_NO_MISC_PARTITION := true BOARD_HAS_NO_SELECT_BUTTON := true BOARD_RECOVERY_SWIPE := true -TARGET_RECOVERY_FSTAB := $(LOCAL_PATH)/rootdir/etc/fstab.qcom +TARGET_RECOVERY_FSTAB := $(LOCAL_PATH)/rootdir/etc/fstab.full # SELinux -include device/qcom/sepolicy/sepolicy.mk -BOARD_SEPOLICY_DIRS += $(LOCAL_PATH)/sepolicy -# Sensors -#TARGET_NO_SENSOR_PERMISSION_CHECK := true +BOARD_SEPOLICY_DIRS += \ + $(COMMON_PATH)/sepolicy # TWRP Support - Optional ifeq ($(WITH_TWRP),true) diff --git a/audio/audio_effects.conf b/audio/audio_effects.conf new file mode 100755 index 0000000..6e62107 --- /dev/null +++ b/audio/audio_effects.conf @@ -0,0 +1,277 @@ +# List of effect libraries to load. Each library element must contain a "path" element +# giving the full path of the library .so file. +# libraries { +# { +# path +# } +# } +libraries { + bundle { + path /vendor/lib/soundfx/libbundlewrapper.so + } + reverb { + path /vendor/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 /vendor/lib/soundfx/libvisualizer.so + } + visualizer_hw { + path /vendor/lib/soundfx/libqcomvisualizer.so + } + downmix { + path /vendor/lib/soundfx/libdownmix.so + } + loudness_enhancer { + path /vendor/lib/soundfx/libldnhncr.so + } + proxy { + path /vendor/lib/soundfx/libeffectproxy.so + } + offload_bundle { + path /vendor/lib/soundfx/libqcompostprocbundle.so + } + audio_pre_processing { + path /vendor/lib/soundfx/libqcomvoiceprocessing.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 { +# { +# library +# 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 + } + } + downmix { + library downmix + uuid 93f04452-e4fe-41cc-91f9-e475b6d1d69f + } + loudness_enhancer { + library loudness_enhancer + uuid fa415329-2034-4bea-b5dc-5b381c8d1e2c + } +# aec { +# library audio_pre_processing +# uuid 29dfd020-e88b-11e5-b505-0002a5d5c51b +# } +# agc { +# library audio_pre_processing +# uuid e6cdbac0-4a7c-11e4-a018-0002a5d5c51b +# } +# ns { +# library audio_pre_processing +# uuid e4eb6b40-e88b-11e5-b6ad-0002a5d5c51b +# } +} + +# Default pre-processing effects. Add to audio_effect.conf "effects" section if +# audio HAL implements support for them. +# +# aec { +# library pre_processing +# uuid bb392ec0-8d4d-11e0-a896-0002a5d5c51b +# } +# agc { +# library pre_processing +# uuid aa8130e0-66fc-11e0-bad0-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 { +# { +# { +# { +# param { +# int|short|float|bool|string +# [ int|short|float|bool|string ] +# ... +# } +# value { +# int|short|float|bool|string +# [ int|short|float|bool|string ] +# ... +# } +# } +# { } +# ... +# } +# ... +# } +# ... +# } + +# +# TODO: add default audio pre processor configurations after debug and tuning phase +# diff --git a/bluetooth/bdroid_buildcfg.h b/bluetooth/bdroid_buildcfg.h index 4df3873..f6dab4a 100755 --- a/bluetooth/bdroid_buildcfg.h +++ b/bluetooth/bdroid_buildcfg.h @@ -20,9 +20,9 @@ #define BTM_DEF_LOCAL_NAME "Samsung Galaxy Note Pro 12.2" -#define BTM_WBS_INCLUDED TRUE +#define BTA_DISABLE_DELAY 1000 /* in milliseconds */ -/* Defined if the kernel does not have support for CLOCK_BOOTTIME_ALARM */ -#define KERNEL_MISSING_CLOCK_BOOTTIME_ALARM TRUE +#define BTM_WBS_INCLUDED TRUE /* Enable WBS */ +#define BTIF_HF_WBS_PREFERRED TRUE /* Use WBS */ #endif diff --git a/bluetooth/vnd_viennalte.txt b/bluetooth/vnd_viennalte.txt index 2f600b2..5c4dc93 100755 --- a/bluetooth/vnd_viennalte.txt +++ b/bluetooth/vnd_viennalte.txt @@ -1,13 +1,16 @@ BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyHS0" -FW_PATCHFILE_LOCATION = "/vendor/firmware" +FW_PATCHFILE_LOCATION = "/vendor/firmware/" BT_WAKE_VIA_PROC = TRUE +BT_WAKE_VIA_PROC_NOTIFY_DEASSERT=TRUE +PROC_BTWRITE_TIMER_TIMEOUT_MS = 0 +UART_TARGET_BAUD_RATE = 4000000 LPM_IDLE_TIMEOUT_MULTIPLE = 5 +LPM_BT_WAKE_POLARITY = 0 +LPM_HOST_WAKE_POLARITY = 0 +SCO_USE_I2S_INTERFACE = FALSE +SCO_WBS_SAMPLE_RATE = 0 +SCO_I2SPCM_IF_ROLE = 0 BTVND_DBG = FALSE BTHW_DBG = TRUE VNDUSERIAL_DBG = FALSE UPIO_DBG = FALSE -UART_TARGET_BAUD_RATE = 3000000 -FW_PATCH_SETTLEMENT_DELAY_MS = 100 -USE_AXI_BRIDGE_LOCK = TRUE -UART_FORCE_TWO_STOPBITS = TRUE -LPM_COMBINE_SLEEP_MODE_AND_LPM = 0 diff --git a/camera/Android.mk b/camera/Android.mk index c77d114..baed356 100755 --- a/camera/Android.mk +++ b/camera/Android.mk @@ -1,17 +1,23 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - CameraWrapper.cpp - -LOCAL_SHARED_LIBRARIES := \ - libhardware liblog libcamera_client libutils - -LOCAL_C_INCLUDES += \ - system/media/camera/include - -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw -LOCAL_MODULE := camera.$(TARGET_BOARD_PLATFORM) -LOCAL_MODULE_TAGS := optional - +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_C_INCLUDES := \ + system/media/camera/include + +LOCAL_SRC_FILES := \ + CameraWrapper.cpp + +LOCAL_STATIC_LIBRARIES := libbase libarect +LOCAL_SHARED_LIBRARIES := \ + libhardware liblog libcamera_client libutils libcutils libdl \ + android.hidl.token@1.0-utils \ + android.hardware.graphics.bufferqueue@1.0 + +LOCAL_HEADER_LIBRARIES := libnativebase_headers + +LOCAL_MODULE := camera.$(TARGET_BOARD_PLATFORM) +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_MODULE_TAGS := optional +LOCAL_PROPRIETARY_MODULE := true + include $(BUILD_SHARED_LIBRARY) diff --git a/camera/CameraWrapper.cpp b/camera/CameraWrapper.cpp index 458f311..0c67b5b 100755 --- a/camera/CameraWrapper.cpp +++ b/camera/CameraWrapper.cpp @@ -34,9 +34,21 @@ #include #include +static const char KEY_DIS[] = "dis"; +static const char DIS_DISABLE[] = "disable"; +static const char KEY_ZSL[] = "zsl"; +static const char ZSL_ON[] = "on"; +static const char ZSL_OFF[] = "off"; + static android::Mutex gCameraWrapperLock; static camera_module_t *gVendorModule = 0; +static camera_notify_callback gUserNotifyCb = NULL; +static camera_data_callback gUserDataCb = NULL; +static camera_data_timestamp_callback gUserDataCbTimestamp = NULL; +static camera_request_memory gUserGetMemory = NULL; +static void *gUserCameraDevice = NULL; + static char **fixed_set_params = NULL; static int camera_device_open(const hw_module_t* module, const char* name, @@ -217,6 +229,25 @@ int camera_set_preview_window(struct camera_device * device, return VENDOR_CALL(device, set_preview_window, window); } +void camera_notify_cb(int32_t msg_type, int32_t ext1, int32_t ext2, void *user) { + gUserNotifyCb(msg_type, ext1, ext2, gUserCameraDevice); +} + +void camera_data_cb(int32_t msg_type, const camera_memory_t *data, unsigned int index, + camera_frame_metadata_t *metadata, void *user) { + gUserDataCb(msg_type, data, index, metadata, gUserCameraDevice); +} + +void camera_data_cb_timestamp(nsecs_t timestamp, int32_t msg_type, + const camera_memory_t *data, unsigned index, void *user) { + gUserDataCbTimestamp(timestamp, msg_type, data, index, gUserCameraDevice); +} + +camera_memory_t* camera_get_memory(int fd, size_t buf_size, + uint_t num_bufs, void *user) { + return gUserGetMemory(fd, buf_size, num_bufs, gUserCameraDevice); +} + void camera_set_callbacks(struct camera_device * device, camera_notify_callback notify_cb, camera_data_callback data_cb, @@ -230,7 +261,14 @@ void camera_set_callbacks(struct camera_device * device, if(!device) return; - VENDOR_CALL(device, set_callbacks, notify_cb, data_cb, data_cb_timestamp, get_memory, user); + gUserNotifyCb = notify_cb; + gUserDataCb = data_cb; + gUserDataCbTimestamp = data_cb_timestamp; + gUserGetMemory = get_memory; + gUserCameraDevice = user; + + VENDOR_CALL(device, set_callbacks, camera_notify_cb, camera_data_cb, + camera_data_cb_timestamp, camera_get_memory, user); } void camera_enable_msg_type(struct camera_device * device, int32_t msg_type) diff --git a/config.fs b/config.fs new file mode 100755 index 0000000..14d23f5 --- /dev/null +++ b/config.fs @@ -0,0 +1,8 @@ +[AID_QCOM_DIAG] +value:2950 + +[AID_RFS] +value:2951 + +[AID_RFS_SHARED] +value:2952 diff --git a/configs/izat.conf b/configs/izat.conf index 95edee6..07fc034 100755 --- a/configs/izat.conf +++ b/configs/izat.conf @@ -129,7 +129,7 @@ BASEBAND=all PROCESS_NAME=/system/bin/lowi-server PROCESS_STATE=ENABLED -PROCESS_GROUPS=gps net_admin wifi inet qcom_diag net_raw +PROCESS_GROUPS=gps net_admin wifi inet oem_2950 net_raw PREMIUM_FEATURE=1 IZAT_FEATURE_MASK=0x333 PLATFORMS=all @@ -161,7 +161,7 @@ BASEBAND=all PROCESS_NAME=/system/bin/xtwifi-client PROCESS_STATE=ENABLED -PROCESS_GROUPS=net_admin wifi inet gps +PROCESS_GROUPS=net_admin wifi inet gps net_raw oem_2952 PREMIUM_FEATURE=1 IZAT_FEATURE_MASK=0x30f PLATFORMS=all @@ -169,7 +169,7 @@ BASEBAND=all PROCESS_NAME=/system/vendor/bin/slim_ap_daemon PROCESS_STATE=ENABLED -PROCESS_GROUPS=gps net_raw misc qcom_oncrpc qcom_diag +PROCESS_GROUPS=gps net_raw oem_2950 PREMIUM_FEATURE=1 IZAT_FEATURE_MASK=0xf0 PLATFORMS=all diff --git a/device.mk b/device.mk index 75d7804..3d926dd 100755 --- a/device.mk +++ b/device.mk @@ -51,9 +51,10 @@ PRODUCT_COPY_FILES += \ # Audio PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/audio/audio_platform_info.xml:system/etc/audio_platform_info.xml \ - $(LOCAL_PATH)/audio/audio_policy.conf:system/etc/audio_policy.conf \ - $(LOCAL_PATH)/audio/mixer_paths.xml:system/etc/mixer_paths.xml + $(LOCAL_PATH)/audio/audio_effects.conf:system/vendor/etc/audio_effects.conf \ + $(LOCAL_PATH)/audio/audio_platform_info.xml:system/vendor/etc/audio_platform_info.xml \ + $(LOCAL_PATH)/audio/audio_policy.conf:system/vendor/etc/audio_policy.conf \ + $(LOCAL_PATH)/audio/mixer_paths.xml:system/vendor/etc/mixer_paths.xml # GPS PRODUCT_PACKAGES += \ @@ -66,18 +67,24 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/configs/izat.conf:system/etc/izat.conf \ $(LOCAL_PATH)/configs/sap.conf:system/etc/sap.conf +# Bluetooth +PRODUCT_PACKAGES += \ + libbt-vendor + # Camera PRODUCT_PACKAGES += \ + android.hardware.camera.provider@2.4-impl \ + camera.device@1.0-impl \ camera.msm8974 \ - libstlport \ + libshim_camera \ libxml2 #PRODUCT_PACKAGES += \ # Snap # Doze -PRODUCT_PACKAGES += \ - SamsungDoze +#PRODUCT_PACKAGES += \ +# SamsungDoze # IPv6 tethering PRODUCT_PACKAGES += \ @@ -85,8 +92,8 @@ PRODUCT_PACKAGES += \ ethertypes # IR Blaster -PRODUCT_PACKAGES += \ - consumerir.msm8974 +#PRODUCT_PACKAGES += \ +# consumerir.msm8974 # Input device PRODUCT_COPY_FILES += \ @@ -104,6 +111,7 @@ PRODUCT_COPY_FILES += \ # Lights PRODUCT_PACKAGES += \ + android.hardware.light@2.0-impl \ lights.MSM8974 # Media @@ -112,7 +120,8 @@ PRODUCT_COPY_FILES += \ # Radio PRODUCT_PACKAGES += \ - libril_shim + libsecnativefeature \ + libshim_cutils_atomic # Ramdisk PRODUCT_PACKAGES += \ @@ -126,18 +135,15 @@ PRODUCT_PACKAGES += \ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/configs/thermal-engine-8974.conf:system/etc/thermal-engine-8974.conf +# Vibrator +PRODUCT_PACKAGES += \ + android.hardware.vibrator@1.0-impl + # Wifi PRODUCT_PACKAGES += \ libnetcmdiface \ macloader -PRODUCT_PACKAGES += \ - hostapd.accept \ - hostapd.deny \ - hostapd \ - wpa_supplicant \ - wpa_supplicant.conf - PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/configs/wpa_supplicant_overlay.conf:system/etc/wifi/wpa_supplicant_overlay.conf \ $(LOCAL_PATH)/configs/p2p_supplicant_overlay.conf:system/etc/wifi/p2p_supplicant_overlay.conf diff --git a/include/camera/CameraParametersExtra.h b/include/camera/CameraParametersExtra.h deleted file mode 100755 index 7aac3c5..0000000 --- a/include/camera/CameraParametersExtra.h +++ /dev/null @@ -1,249 +0,0 @@ -/* - * 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. - */ - -#define CAMERA_PARAMETERS_EXTRA_C \ -const char CameraParameters::KEY_DIS[] = "dis"; \ -const char CameraParameters::DIS_DISABLE[] = "disable"; \ -const char CameraParameters::KEY_DYNAMIC_RANGE_CONTROL[] = "dynamic-range-control"; \ -const char CameraParameters::KEY_SUPPORTED_DYNAMIC_RANGE_CONTROL[] = "dynamic-range-control-values"; \ -const char CameraParameters::DRC_ON[] = "on"; \ -const char CameraParameters::DRC_OFF[] = "off"; \ -\ -const char CameraParameters::KEY_PHASE_AF[] = "phase-af"; \ -const char CameraParameters::KEY_SUPPORTED_PHASE_AF[] = "phase-af-values"; \ -const char CameraParameters::PAF_ON[] = "on"; \ -const char CameraParameters::PAF_OFF[] = "off"; \ -\ -const char CameraParameters::KEY_RT_HDR[] = "rt-hdr"; \ -const char CameraParameters::KEY_SUPPORTED_RT_HDR[] = "rt-hdr-values"; \ -const char CameraParameters::RTHDR_ON[] = "on"; \ -const char CameraParameters::RTHDR_OFF[] = "off"; \ -const char CameraParameters::KEY_SUPPORTED_ISO_MODES[] = "iso-values"; \ -const char CameraParameters::KEY_FACE_DETECTION[] = "face-detection"; \ -const char CameraParameters::KEY_SUPPORTED_FACE_DETECTION[] = "face-detection-values"; \ -const char CameraParameters::FACE_DETECTION_OFF[] = "off"; \ -const char CameraParameters::FACE_DETECTION_ON[] = "on"; \ -const char CameraParameters::KEY_ZSL[] = "zsl"; \ -const char CameraParameters::KEY_SUPPORTED_ZSL_MODES[] = "zsl-values"; \ -const char CameraParameters::ZSL_OFF[] = "off"; \ -const char CameraParameters::ZSL_ON[] = "on"; \ -const char CameraParameters::KEY_ISO_MODE[] = "iso"; \ -const char CameraParameters::KEY_CAMERA_MODE[] = "camera-mode"; \ -const char CameraParameters::KEY_SAMSUNG_CAMERA_MODE[] = "cam_mode"; \ -const char CameraParameters::KEY_SELECTABLE_ZONE_AF[] = "selectable-zone-af"; \ -const char CameraParameters::KEY_SUPPORTED_SELECTABLE_ZONE_AF[] = "selectable-zone-af-values"; \ -const char CameraParameters::SELECTABLE_ZONE_AF_AUTO[] = "auto"; \ -const char CameraParameters::SELECTABLE_ZONE_AF_SPOT_METERING[] = "spot-metering"; \ -const char CameraParameters::SELECTABLE_ZONE_AF_CENTER_WEIGHTED[] = "center-weighted"; \ -const char CameraParameters::SELECTABLE_ZONE_AF_FRAME_AVERAGE[] = "frame-average"; \ -const char CameraParameters::KEY_PREVIEW_FRAME_RATE_MODE[] = "preview-frame-rate-mode"; \ -const char CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATE_MODES[] = "preview-frame-rate-modes"; \ -const char CameraParameters::KEY_PREVIEW_FRAME_RATE_AUTO_MODE[] = "frame-rate-auto"; \ -const char CameraParameters::KEY_PREVIEW_FRAME_RATE_FIXED_MODE[] = "frame-rate-fixed"; \ -const char CameraParameters::KEY_SHARPNESS[] = "sharpness"; \ -const char CameraParameters::KEY_SATURATION[] = "saturation"; \ -const char CameraParameters::KEY_CONTRAST[] = "contrast"; \ -const char CameraParameters::KEY_SCENE_DETECT[] = "scene-detect"; \ -const char CameraParameters::KEY_SUPPORTED_SCENE_DETECT[] = "scene-detect-values"; \ -const char CameraParameters::SCENE_DETECT_OFF[] = "off"; \ -const char CameraParameters::SCENE_DETECT_ON[] = "on"; \ -const char CameraParameters::KEY_WEATHER[] = "weather"; \ -const char CameraParameters::KEY_CITYID[] = "contextualtag-cityid"; \ -const char CameraParameters::KEY_TOUCH_AF_AEC[] = "touch-af-aec"; \ -const char CameraParameters::KEY_SUPPORTED_TOUCH_AF_AEC[] = "touch-af-aec-values"; \ -const char CameraParameters::TOUCH_AF_AEC_OFF[] = "touch-off"; \ -const char CameraParameters::TOUCH_AF_AEC_ON[] = "touch-on"; \ -const char CameraParameters::KEY_MEMORY_COLOR_ENHANCEMENT[] = "mce"; \ -const char CameraParameters::KEY_LENSSHADE[] = "lensshade"; \ -const char CameraParameters::KEY_REDEYE_REDUCTION[] = "redeye-reduction"; \ -const char CameraParameters::KEY_SUPPORTED_REDEYE_REDUCTION[] = "redeye-reduction-values"; \ -const char CameraParameters::REDEYE_REDUCTION_ENABLE[] = "enable"; \ -const char CameraParameters::REDEYE_REDUCTION_DISABLE[] = "disable"; \ -const char CameraParameters::KEY_GPS_LATITUDE_REF[] = "gps-latitude-ref"; \ -const char CameraParameters::KEY_GPS_LONGITUDE_REF[] = "gps-longitude-ref"; \ -const char CameraParameters::KEY_GPS_ALTITUDE_REF[] = "gps-altitude-ref"; \ -const char CameraParameters::KEY_GPS_STATUS[] = "gps-status"; \ -const char CameraParameters::KEY_EXIF_DATETIME[] = "exif-datetime"; \ -const char CameraParameters::KEY_AUTO_EXPOSURE[] = "auto-exposure"; \ -const char CameraParameters::KEY_SUPPORTED_AUTO_EXPOSURE[] = "auto-exposure-values"; \ -const char CameraParameters::KEY_SUPPORTED_LENSSHADE_MODES[] = "lensshade-values"; \ -const char CameraParameters::LENSSHADE_ENABLE[] = "enable"; \ -const char CameraParameters::LENSSHADE_DISABLE[] = "disable"; \ -const char CameraParameters::MCE_ENABLE[] = "enable"; \ -const char CameraParameters::MCE_DISABLE[] = "disable"; \ -const char CameraParameters::ISO_AUTO[] = "auto"; \ -const char CameraParameters::ISO_HJR[] = "ISO_HJR"; \ -const char CameraParameters::ISO_100[] = "ISO100"; \ -const char CameraParameters::ISO_200[] = "ISO200"; \ -const char CameraParameters::ISO_400[] = "ISO400"; \ -const char CameraParameters::ISO_800[] = "ISO800"; \ -const char CameraParameters::ISO_1600[] = "ISO1600"; \ -const char CameraParameters::ISO_3200[] = "ISO3200"; \ -const char CameraParameters::ISO_6400[] = "ISO6400"; \ -const char CameraParameters::KEY_SUPPORTED_HFR_SIZES[] = "hfr-size-values"; \ -const char CameraParameters::KEY_SUPPORTED_MEM_COLOR_ENHANCE_MODES[] = "mce-values"; \ -const char CameraParameters::VIDEO_HFR_OFF[] = "off"; \ -const char CameraParameters::VIDEO_HFR_2X[] = "60"; \ -const char CameraParameters::VIDEO_HFR_3X[] = "90"; \ -const char CameraParameters::VIDEO_HFR_4X[] = "120"; \ -const char CameraParameters::KEY_VIDEO_HIGH_FRAME_RATE[] = "video-hfr"; \ -const char CameraParameters::KEY_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES[] = "video-hfr-values"; \ -const char CameraParameters::KEY_HISTOGRAM[] = "histogram"; \ -const char CameraParameters::KEY_SUPPORTED_HISTOGRAM_MODES[] = "histogram-values"; \ -const char CameraParameters::HISTOGRAM_ENABLE[] = "enable"; \ -const char CameraParameters::HISTOGRAM_DISABLE[] = "disable"; \ -const char CameraParameters::SKIN_TONE_ENHANCEMENT_ENABLE[] = "enable"; \ -const char CameraParameters::SKIN_TONE_ENHANCEMENT_DISABLE[] = "disable"; \ -const char CameraParameters::KEY_SKIN_TONE_ENHANCEMENT[] = "skinToneEnhancement"; \ -const char CameraParameters::KEY_SUPPORTED_SKIN_TONE_ENHANCEMENT_MODES[] = "skinToneEnhancement-values"; \ -const char CameraParameters::DENOISE_OFF[] = "denoise-off"; \ -const char CameraParameters::DENOISE_ON[] = "denoise-on"; \ -const char CameraParameters::KEY_DENOISE[] = "denoise"; \ -const char CameraParameters::KEY_SUPPORTED_DENOISE[] = "denoise-values"; \ -const char CameraParameters::EFFECT_EMBOSS[] = "emboss"; \ -const char CameraParameters::EFFECT_SKETCH[] = "sketch"; \ -const char CameraParameters::EFFECT_NEON[] = "neon"; \ -const char CameraParameters::SCENE_MODE_FLOWERS[] = "flowers"; \ -const char CameraParameters::SCENE_MODE_AR[] = "AR"; \ -const char CameraParameters::PIXEL_FORMAT_YUV420SP_ADRENO[] = "yuv420sp-adreno"; \ -const char CameraParameters::PIXEL_FORMAT_RAW[] = "raw"; \ -const char CameraParameters::PIXEL_FORMAT_YV12[] = "yuv420p"; \ -const char CameraParameters::PIXEL_FORMAT_NV12[] = "nv12"; \ -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 { }; \ -void CameraParameters::setTouchIndexAec(int x, int y) { }; \ -void CameraParameters::setTouchIndexAf(int x, int y) { }; \ -void CameraParameters::setPreviewFpsRange(int minFPS, int maxFPS) { }; - -#define CAMERA_PARAMETERS_EXTRA_H \ - static const char KEY_DIS[]; \ - static const char DIS_DISABLE[]; \ - \ - static const char KEY_DYNAMIC_RANGE_CONTROL[]; \ - static const char KEY_SUPPORTED_DYNAMIC_RANGE_CONTROL[]; \ - static const char DRC_ON[]; \ - static const char DRC_OFF[]; \ - \ - static const char KEY_PHASE_AF[]; \ - static const char KEY_SUPPORTED_PHASE_AF[]; \ - static const char PAF_ON[]; \ - static const char PAF_OFF[]; \ - \ - static const char KEY_RT_HDR[]; \ - static const char KEY_SUPPORTED_RT_HDR[]; \ - static const char RTHDR_ON[]; \ - static const char RTHDR_OFF[]; \ - \ - static const char KEY_SUPPORTED_ISO_MODES[]; \ - static const char KEY_FACE_DETECTION[]; \ - static const char KEY_SUPPORTED_FACE_DETECTION[]; \ - static const char FACE_DETECTION_OFF[]; \ - static const char FACE_DETECTION_ON[]; \ - static const char KEY_ZSL[]; \ - static const char KEY_SUPPORTED_ZSL_MODES[]; \ - static const char ZSL_OFF[]; \ - static const char ZSL_ON[]; \ - static const char KEY_ISO_MODE[]; \ - static const char KEY_CAMERA_MODE[]; \ - static const char KEY_SAMSUNG_CAMERA_MODE[]; \ - static const char KEY_SELECTABLE_ZONE_AF[]; \ - static const char KEY_SUPPORTED_SELECTABLE_ZONE_AF[]; \ - static const char SELECTABLE_ZONE_AF_AUTO[]; \ - static const char SELECTABLE_ZONE_AF_SPOT_METERING[]; \ - static const char SELECTABLE_ZONE_AF_CENTER_WEIGHTED[]; \ - static const char SELECTABLE_ZONE_AF_FRAME_AVERAGE[]; \ - static const char KEY_PREVIEW_FRAME_RATE_MODE[]; \ - static const char KEY_SUPPORTED_PREVIEW_FRAME_RATE_MODES[]; \ - static const char KEY_PREVIEW_FRAME_RATE_AUTO_MODE[]; \ - static const char KEY_PREVIEW_FRAME_RATE_FIXED_MODE[]; \ - static const char KEY_SHARPNESS[]; \ - static const char KEY_SATURATION[]; \ - static const char KEY_CONTRAST[]; \ - static const char KEY_SCENE_DETECT[]; \ - static const char KEY_SUPPORTED_SCENE_DETECT[]; \ - static const char SCENE_DETECT_OFF[]; \ - static const char SCENE_DETECT_ON[]; \ - static const char KEY_WEATHER[]; \ - static const char KEY_CITYID[]; \ - static const char KEY_TOUCH_AF_AEC[]; \ - static const char KEY_SUPPORTED_TOUCH_AF_AEC[]; \ - static const char TOUCH_AF_AEC_OFF[]; \ - static const char TOUCH_AF_AEC_ON[]; \ - static const char KEY_MEMORY_COLOR_ENHANCEMENT[]; \ - static const char KEY_LENSSHADE[]; \ - static const char KEY_REDEYE_REDUCTION[]; \ - static const char KEY_SUPPORTED_REDEYE_REDUCTION[]; \ - static const char REDEYE_REDUCTION_ENABLE[]; \ - static const char REDEYE_REDUCTION_DISABLE[]; \ - static const char KEY_GPS_LATITUDE_REF[]; \ - static const char KEY_GPS_LONGITUDE_REF[]; \ - static const char KEY_GPS_ALTITUDE_REF[]; \ - static const char KEY_GPS_STATUS[]; \ - static const char KEY_EXIF_DATETIME[]; \ - static const char KEY_AUTO_EXPOSURE[]; \ - static const char KEY_SUPPORTED_AUTO_EXPOSURE[]; \ - static const char KEY_SUPPORTED_LENSSHADE_MODES[]; \ - static const char LENSSHADE_ENABLE[]; \ - static const char LENSSHADE_DISABLE[]; \ - static const char MCE_ENABLE[]; \ - static const char MCE_DISABLE[]; \ - static const char ISO_AUTO[]; \ - static const char ISO_HJR[]; \ - static const char ISO_100[]; \ - static const char ISO_200[]; \ - static const char ISO_400[]; \ - static const char ISO_800[]; \ - static const char ISO_1600[]; \ - static const char ISO_3200[]; \ - static const char ISO_6400[]; \ - static const char KEY_SUPPORTED_HFR_SIZES[]; \ - static const char KEY_SUPPORTED_MEM_COLOR_ENHANCE_MODES[]; \ - static const char VIDEO_HFR_OFF[]; \ - static const char VIDEO_HFR_2X[]; \ - static const char VIDEO_HFR_3X[]; \ - static const char VIDEO_HFR_4X[]; \ - static const char KEY_VIDEO_HIGH_FRAME_RATE[]; \ - static const char KEY_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES[]; \ - static const char KEY_HISTOGRAM[]; \ - static const char KEY_SUPPORTED_HISTOGRAM_MODES[]; \ - static const char HISTOGRAM_ENABLE[]; \ - static const char HISTOGRAM_DISABLE[]; \ - static const char SKIN_TONE_ENHANCEMENT_ENABLE[]; \ - static const char SKIN_TONE_ENHANCEMENT_DISABLE[]; \ - static const char KEY_SKIN_TONE_ENHANCEMENT[]; \ - static const char KEY_SUPPORTED_SKIN_TONE_ENHANCEMENT_MODES[]; \ - static const char DENOISE_OFF[]; \ - static const char DENOISE_ON[]; \ - static const char KEY_DENOISE[]; \ - static const char KEY_SUPPORTED_DENOISE[];\ - static const char EFFECT_EMBOSS[]; \ - static const char EFFECT_SKETCH[]; \ - static const char EFFECT_NEON[]; \ - static const char SCENE_MODE_FLOWERS[]; \ - static const char SCENE_MODE_AR[]; \ - static const char PIXEL_FORMAT_YUV420SP_ADRENO[]; \ - static const char PIXEL_FORMAT_RAW[]; \ - static const char PIXEL_FORMAT_YV12[]; \ - static const char PIXEL_FORMAT_NV12[]; \ - int getInt64(const char *key) const; \ - const char *getPreviewFrameRateMode() const; \ - void setPreviewFrameRateMode(const char *mode); \ - void getMeteringAreaCenter(int *x, int *y) const; \ - void setTouchIndexAec(int x, int y); \ - void setTouchIndexAf(int x, int y); \ - void setPreviewFpsRange(int minFPS, int maxFPS); diff --git a/include/hardware/gps.h b/include/hardware/gps.h index 6932204..0158a0c 100755 --- a/include/hardware/gps.h +++ b/include/hardware/gps.h @@ -1,2229 +1,2015 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_GPS_H -#define ANDROID_INCLUDE_HARDWARE_GPS_H - -#include -#include -#include -#include -#include -#include - -#include - -__BEGIN_DECLS - -/** - * The id of this module - */ -#define GPS_HARDWARE_MODULE_ID "gps" - - -/** Milliseconds since January 1, 1970 */ -typedef int64_t GpsUtcTime; - -/** Maximum number of SVs for gps_sv_status_callback(). */ -#define GPS_MAX_SVS 32 -/** Maximum number of SVs for gps_sv_status_callback(). */ -#define GNSS_MAX_SVS 64 - -/** Maximum number of Measurements in gps_measurement_callback(). */ -#define GPS_MAX_MEASUREMENT 32 - -/** Maximum number of Measurements in gnss_measurement_callback(). */ -#define GNSS_MAX_MEASUREMENT 64 - -/** Requested operational mode for GPS operation. */ -typedef uint32_t GpsPositionMode; -/* IMPORTANT: Note that the following values must match - * constants in GpsLocationProvider.java. */ -/** Mode for running GPS standalone (no assistance). */ -#define GPS_POSITION_MODE_STANDALONE 0 -/** AGPS MS-Based mode. */ -#define GPS_POSITION_MODE_MS_BASED 1 -/** - * AGPS MS-Assisted mode. This mode is not maintained by the platform anymore. - * It is strongly recommended to use GPS_POSITION_MODE_MS_BASED instead. - */ -#define GPS_POSITION_MODE_MS_ASSISTED 2 - -/** Requested recurrence mode for GPS operation. */ -typedef uint32_t GpsPositionRecurrence; -/* IMPORTANT: Note that the following values must match - * constants in GpsLocationProvider.java. */ -/** Receive GPS fixes on a recurring basis at a specified period. */ -#define GPS_POSITION_RECURRENCE_PERIODIC 0 -/** Request a single shot GPS fix. */ -#define GPS_POSITION_RECURRENCE_SINGLE 1 - -/** GPS status event values. */ -typedef uint16_t GpsStatusValue; -/* IMPORTANT: Note that the following values must match - * constants in GpsLocationProvider.java. */ -/** GPS status unknown. */ -#define GPS_STATUS_NONE 0 -/** GPS has begun navigating. */ -#define GPS_STATUS_SESSION_BEGIN 1 -/** GPS has stopped navigating. */ -#define GPS_STATUS_SESSION_END 2 -/** GPS has powered on but is not navigating. */ -#define GPS_STATUS_ENGINE_ON 3 -/** GPS is powered off. */ -#define GPS_STATUS_ENGINE_OFF 4 - -/** Flags to indicate which values are valid in a GpsLocation. */ -typedef uint16_t GpsLocationFlags; -/* IMPORTANT: Note that the following values must match - * constants in GpsLocationProvider.java. */ -/** GpsLocation has valid latitude and longitude. */ -#define GPS_LOCATION_HAS_LAT_LONG 0x0001 -/** GpsLocation has valid altitude. */ -#define GPS_LOCATION_HAS_ALTITUDE 0x0002 -/** GpsLocation has valid speed. */ -#define GPS_LOCATION_HAS_SPEED 0x0004 -/** GpsLocation has valid bearing. */ -#define GPS_LOCATION_HAS_BEARING 0x0008 -/** GpsLocation has valid accuracy. */ -#define GPS_LOCATION_HAS_ACCURACY 0x0010 - -/** Flags for the gps_set_capabilities callback. */ - -/** - * GPS HAL schedules fixes for GPS_POSITION_RECURRENCE_PERIODIC mode. If this is - * not set, then the framework will use 1000ms for min_interval and will start - * and call start() and stop() to schedule the GPS. - */ -#define GPS_CAPABILITY_SCHEDULING (1 << 0) -/** GPS supports MS-Based AGPS mode */ -#define GPS_CAPABILITY_MSB (1 << 1) -/** GPS supports MS-Assisted AGPS mode */ -#define GPS_CAPABILITY_MSA (1 << 2) -/** GPS supports single-shot fixes */ -#define GPS_CAPABILITY_SINGLE_SHOT (1 << 3) -/** GPS supports on demand time injection */ -#define GPS_CAPABILITY_ON_DEMAND_TIME (1 << 4) -/** GPS supports Geofencing */ -#define GPS_CAPABILITY_GEOFENCING (1 << 5) -/** GPS supports Measurements. */ -#define GPS_CAPABILITY_MEASUREMENTS (1 << 6) -/** GPS supports Navigation Messages */ -#define GPS_CAPABILITY_NAV_MESSAGES (1 << 7) - -/** - * Flags used to specify which aiding data to delete when calling - * delete_aiding_data(). - */ -typedef uint32_t GpsAidingData; -/* IMPORTANT: Note that the following values must match - * constants in GpsLocationProvider.java. */ -#define GPS_DELETE_EPHEMERIS 0x00000001 -#define GPS_DELETE_ALMANAC 0x00000002 -#define GPS_DELETE_POSITION 0x00000004 -#define GPS_DELETE_TIME 0x00000008 -#define GPS_DELETE_IONO 0x00000010 -#define GPS_DELETE_UTC 0x00000020 -#define GPS_DELETE_HEALTH 0x00000040 -#define GPS_DELETE_SVDIR 0x00000080 -#define GPS_DELETE_SVSTEER 0x00000100 -#define GPS_DELETE_SADATA 0x00000200 -#define GPS_DELETE_RTI 0x00000400 -#define GPS_DELETE_CELLDB_INFO 0x00000800 -#define GPS_DELETE_ALMANAC_CORR 0x00001000 -#define GPS_DELETE_FREQ_BIAS_EST 0x00002000 -#define GLO_DELETE_EPHEMERIS 0x00004000 -#define GLO_DELETE_ALMANAC 0x00008000 -#define GLO_DELETE_SVDIR 0x00010000 -#define GLO_DELETE_SVSTEER 0x00020000 -#define GLO_DELETE_ALMANAC_CORR 0x00040000 -#define GPS_DELETE_TIME_GPS 0x00080000 -#define GLO_DELETE_TIME 0x00100000 -#define BDS_DELETE_SVDIR 0X00200000 -#define BDS_DELETE_SVSTEER 0X00400000 -#define BDS_DELETE_TIME 0X00800000 -#define BDS_DELETE_ALMANAC_CORR 0X01000000 -#define BDS_DELETE_EPHEMERIS 0X02000000 -#define BDS_DELETE_ALMANAC 0X04000000 - -#define GPS_DELETE_ALL 0xFFFFFFFF - -/** AGPS type */ -typedef uint16_t AGpsType; -#define AGPS_TYPE_SUPL 1 -#define AGPS_TYPE_C2K 2 - -typedef uint16_t AGpsSetIDType; -#define AGPS_SETID_TYPE_NONE 0 -#define AGPS_SETID_TYPE_IMSI 1 -#define AGPS_SETID_TYPE_MSISDN 2 - -typedef uint16_t ApnIpType; -#define APN_IP_INVALID 0 -#define APN_IP_IPV4 1 -#define APN_IP_IPV6 2 -#define APN_IP_IPV4V6 3 - -/** - * String length constants - */ -#define GPS_NI_SHORT_STRING_MAXLEN 256 -#define GPS_NI_LONG_STRING_MAXLEN 2048 - -/** - * GpsNiType constants - */ -typedef uint32_t GpsNiType; -#define GPS_NI_TYPE_VOICE 1 -#define GPS_NI_TYPE_UMTS_SUPL 2 -#define GPS_NI_TYPE_UMTS_CTRL_PLANE 3 - -/** - * GpsNiNotifyFlags constants - */ -typedef uint32_t GpsNiNotifyFlags; -/** NI requires notification */ -#define GPS_NI_NEED_NOTIFY 0x0001 -/** NI requires verification */ -#define GPS_NI_NEED_VERIFY 0x0002 -/** NI requires privacy override, no notification/minimal trace */ -#define GPS_NI_PRIVACY_OVERRIDE 0x0004 - -/** - * GPS NI responses, used to define the response in - * NI structures - */ -typedef int GpsUserResponseType; -#define GPS_NI_RESPONSE_ACCEPT 1 -#define GPS_NI_RESPONSE_DENY 2 -#define GPS_NI_RESPONSE_NORESP 3 - -/** - * NI data encoding scheme - */ -typedef int GpsNiEncodingType; -#define GPS_ENC_NONE 0 -#define GPS_ENC_SUPL_GSM_DEFAULT 1 -#define GPS_ENC_SUPL_UTF8 2 -#define GPS_ENC_SUPL_UCS2 3 -#define GPS_ENC_UNKNOWN -1 - -/** AGPS status event values. */ -typedef uint16_t AGpsStatusValue; -/** GPS requests data connection for AGPS. */ -#define GPS_REQUEST_AGPS_DATA_CONN 1 -/** GPS releases the AGPS data connection. */ -#define GPS_RELEASE_AGPS_DATA_CONN 2 -/** AGPS data connection initiated */ -#define GPS_AGPS_DATA_CONNECTED 3 -/** AGPS data connection completed */ -#define GPS_AGPS_DATA_CONN_DONE 4 -/** AGPS data connection failed */ -#define GPS_AGPS_DATA_CONN_FAILED 5 - -typedef uint16_t AGpsRefLocationType; -#define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1 -#define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2 -#define AGPS_REF_LOCATION_TYPE_MAC 3 -#define AGPS_REF_LOCATION_TYPE_LTE_CELLID 4 - -/* Deprecated, to be removed in the next Android release. */ -#define AGPS_REG_LOCATION_TYPE_MAC 3 - -/** Network types for update_network_state "type" parameter */ -#define AGPS_RIL_NETWORK_TYPE_MOBILE 0 -#define AGPS_RIL_NETWORK_TYPE_WIFI 1 -#define AGPS_RIL_NETWORK_TYPE_MOBILE_MMS 2 -#define AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL 3 -#define AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN 4 -#define AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI 5 -#define AGPS_RIL_NETWORK_TTYPE_WIMAX 6 - -/* The following typedef together with its constants below are deprecated, and - * will be removed in the next release. */ -typedef uint16_t GpsClockFlags; -#define GPS_CLOCK_HAS_LEAP_SECOND (1<<0) -#define GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1) -#define GPS_CLOCK_HAS_FULL_BIAS (1<<2) -#define GPS_CLOCK_HAS_BIAS (1<<3) -#define GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4) -#define GPS_CLOCK_HAS_DRIFT (1<<5) -#define GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6) - -/** - * Flags to indicate what fields in GnssClock are valid. - */ -typedef uint16_t GnssClockFlags; -/** A valid 'leap second' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_LEAP_SECOND (1<<0) -/** A valid 'time uncertainty' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1) -/** A valid 'full bias' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_FULL_BIAS (1<<2) -/** A valid 'bias' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_BIAS (1<<3) -/** A valid 'bias uncertainty' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4) -/** A valid 'drift' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_DRIFT (1<<5) -/** A valid 'drift uncertainty' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6) - -/* The following typedef together with its constants below are deprecated, and - * will be removed in the next release. */ -typedef uint8_t GpsClockType; -#define GPS_CLOCK_TYPE_UNKNOWN 0 -#define GPS_CLOCK_TYPE_LOCAL_HW_TIME 1 -#define GPS_CLOCK_TYPE_GPS_TIME 2 - -/* The following typedef together with its constants below are deprecated, and - * will be removed in the next release. */ -typedef uint32_t GpsMeasurementFlags; -#define GPS_MEASUREMENT_HAS_SNR (1<<0) -#define GPS_MEASUREMENT_HAS_ELEVATION (1<<1) -#define GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2) -#define GPS_MEASUREMENT_HAS_AZIMUTH (1<<3) -#define GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4) -#define GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5) -#define GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6) -#define GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7) -#define GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8) -#define GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9) -#define GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10) -#define GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11) -#define GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12) -#define GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13) -#define GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14) -#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15) -#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16) -#define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17) -#define GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE (1<<18) - -/** - * Flags to indicate what fields in GnssMeasurement are valid. - */ -typedef uint32_t GnssMeasurementFlags; -/** A valid 'snr' is stored in the data structure. */ -#define GNSS_MEASUREMENT_HAS_SNR (1<<0) -/** A valid 'carrier frequency' is stored in the data structure. */ -#define GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9) -/** A valid 'carrier cycles' is stored in the data structure. */ -#define GNSS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10) -/** A valid 'carrier phase' is stored in the data structure. */ -#define GNSS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11) -/** A valid 'carrier phase uncertainty' is stored in the data structure. */ -#define GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12) - -/* The following typedef together with its constants below are deprecated, and - * will be removed in the next release. */ -typedef uint8_t GpsLossOfLock; -#define GPS_LOSS_OF_LOCK_UNKNOWN 0 -#define GPS_LOSS_OF_LOCK_OK 1 -#define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2 - -/* The following typedef together with its constants below are deprecated, and - * will be removed in the next release. Use GnssMultipathIndicator instead. - */ -typedef uint8_t GpsMultipathIndicator; -#define GPS_MULTIPATH_INDICATOR_UNKNOWN 0 -#define GPS_MULTIPATH_INDICATOR_DETECTED 1 -#define GPS_MULTIPATH_INDICATOR_NOT_USED 2 - -/** - * Enumeration of available values for the GNSS Measurement's multipath - * indicator. - */ -typedef uint8_t GnssMultipathIndicator; -/** The indicator is not available or unknown. */ -#define GNSS_MULTIPATH_INDICATOR_UNKNOWN 0 -/** The measurement is indicated to be affected by multipath. */ -#define GNSS_MULTIPATH_INDICATOR_PRESENT 1 -/** The measurement is indicated to be not affected by multipath. */ -#define GNSS_MULTIPATH_INDICATOR_NOT_PRESENT 2 - -/* The following typedef together with its constants below are deprecated, and - * will be removed in the next release. */ -typedef uint16_t GpsMeasurementState; -#define GPS_MEASUREMENT_STATE_UNKNOWN 0 -#define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0) -#define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1) -#define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2) -#define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3) -#define GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4) - -/** - * Flags indicating the GNSS measurement state. - * - * The expected behavior here is for GPS HAL to set all the flags that applies. - * For example, if the state for a satellite is only C/A code locked and bit - * synchronized, and there is still millisecond ambiguity, the state should be - * set as: - * - * GNSS_MEASUREMENT_STATE_CODE_LOCK | GNSS_MEASUREMENT_STATE_BIT_SYNC | - * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS - * - * If GNSS is still searching for a satellite, the corresponding state should be - * set to GNSS_MEASUREMENT_STATE_UNKNOWN(0). - */ -typedef uint32_t GnssMeasurementState; -#define GNSS_MEASUREMENT_STATE_UNKNOWN 0 -#define GNSS_MEASUREMENT_STATE_CODE_LOCK (1<<0) -#define GNSS_MEASUREMENT_STATE_BIT_SYNC (1<<1) -#define GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2) -#define GNSS_MEASUREMENT_STATE_TOW_DECODED (1<<3) -#define GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4) -#define GNSS_MEASUREMENT_STATE_SYMBOL_SYNC (1<<5) -#define GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC (1<<6) -#define GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED (1<<7) -#define GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC (1<<8) -#define GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC (1<<9) -#define GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK (1<<10) -#define GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK (1<<11) -#define GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC (1<<12) -#define GNSS_MEASUREMENT_STATE_SBAS_SYNC (1<<13) - -/* The following typedef together with its constants below are deprecated, and - * will be removed in the next release. */ -typedef uint16_t GpsAccumulatedDeltaRangeState; -#define GPS_ADR_STATE_UNKNOWN 0 -#define GPS_ADR_STATE_VALID (1<<0) -#define GPS_ADR_STATE_RESET (1<<1) -#define GPS_ADR_STATE_CYCLE_SLIP (1<<2) - -/** - * Flags indicating the Accumulated Delta Range's states. - */ -typedef uint16_t GnssAccumulatedDeltaRangeState; -#define GNSS_ADR_STATE_UNKNOWN 0 -#define GNSS_ADR_STATE_VALID (1<<0) -#define GNSS_ADR_STATE_RESET (1<<1) -#define GNSS_ADR_STATE_CYCLE_SLIP (1<<2) - -/* The following typedef together with its constants below are deprecated, and - * will be removed in the next release. */ -typedef uint8_t GpsNavigationMessageType; -#define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0 -#define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1 -#define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2 -#define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3 -#define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4 - -/** - * Enumeration of available values to indicate the GNSS Navigation message - * types. - * - * For convenience, first byte is the GnssConstellationType on which that signal - * is typically transmitted - */ -typedef int16_t GnssNavigationMessageType; - -#define GNSS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0 -/** GPS L1 C/A message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L1CA 0x0101 -/** GPS L2-CNAV message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L2CNAV 0x0102 -/** GPS L5-CNAV message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L5CNAV 0x0103 -/** GPS CNAV-2 message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_CNAV2 0x0104 -/** Glonass L1 CA message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GLO_L1CA 0x0301 -/** Beidou D1 message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D1 0x0501 -/** Beidou D2 message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D2 0x0502 -/** Galileo I/NAV message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_I 0x0601 -/** Galileo F/NAV message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_F 0x0602 - -/** - * Status of Navigation Message - * When a message is received properly without any parity error in its navigation words, the - * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received - * with words that failed parity check, but GPS is able to correct those words, the status - * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT. - * No need to send any navigation message that contains words with parity error and cannot be - * corrected. - */ -typedef uint16_t NavigationMessageStatus; -#define NAV_MESSAGE_STATUS_UNKNOWN 0 -#define NAV_MESSAGE_STATUS_PARITY_PASSED (1<<0) -#define NAV_MESSAGE_STATUS_PARITY_REBUILT (1<<1) - -/* This constant is deprecated, and will be removed in the next release. */ -#define NAV_MESSAGE_STATUS_UNKONW 0 - -/** - * Flags that indicate information about the satellite - */ -typedef uint8_t GnssSvFlags; -#define GNSS_SV_FLAGS_NONE 0 -#define GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA (1 << 0) -#define GNSS_SV_FLAGS_HAS_ALMANAC_DATA (1 << 1) -#define GNSS_SV_FLAGS_USED_IN_FIX (1 << 2) - -/** - * Constellation type of GnssSvInfo - */ -typedef uint8_t GnssConstellationType; -#define GNSS_CONSTELLATION_UNKNOWN 0 -#define GNSS_CONSTELLATION_GPS 1 -#define GNSS_CONSTELLATION_SBAS 2 -#define GNSS_CONSTELLATION_GLONASS 3 -#define GNSS_CONSTELLATION_QZSS 4 -#define GNSS_CONSTELLATION_BEIDOU 5 -#define GNSS_CONSTELLATION_GALILEO 6 - -/** - * Name for the GPS XTRA interface. - */ -#define GPS_XTRA_INTERFACE "gps-xtra" - -/** - * Name for the GPS DEBUG interface. - */ -#define GPS_DEBUG_INTERFACE "gps-debug" - -/** - * Name for the AGPS interface. - */ -#define AGPS_INTERFACE "agps" - -/** - * Name of the Supl Certificate interface. - */ -#define SUPL_CERTIFICATE_INTERFACE "supl-certificate" - -/** - * Name for NI interface - */ -#define GPS_NI_INTERFACE "gps-ni" - -/** - * Name for the AGPS-RIL interface. - */ -#define AGPS_RIL_INTERFACE "agps_ril" - -/** - * Name for the GPS_Geofencing interface. - */ -#define GPS_GEOFENCING_INTERFACE "gps_geofencing" - -/** - * Name of the GPS Measurements interface. - */ -#define GPS_MEASUREMENT_INTERFACE "gps_measurement" - -/** - * Name of the GPS navigation message interface. - */ -#define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message" - -/** - * Name of the GNSS/GPS configuration interface. - */ -#define GNSS_CONFIGURATION_INTERFACE "gnss_configuration" - - -/** Represents a location. */ -typedef struct { - /** set to sizeof(GpsLocation) */ - size_t size; - /** Contains GpsLocationFlags bits. */ - uint16_t flags; - /** Represents latitude in degrees. */ - double latitude; - /** Represents longitude in degrees. */ - double longitude; - /** - * Represents altitude in meters above the WGS 84 reference ellipsoid. - */ - double altitude; - /** Represents speed in meters per second. */ - float speed; - /** Represents heading in degrees. */ - float bearing; - /** Represents expected accuracy in meters. */ - float accuracy; - /** Timestamp for the location fix. */ - GpsUtcTime timestamp; -} GpsLocation; - -/** Represents the status. */ -typedef struct { - /** set to sizeof(GpsStatus) */ - size_t size; - GpsStatusValue status; -} GpsStatus; - -/** - * Legacy struct to represents SV information. - * Deprecated, to be removed in the next Android release. - * Use GnssSvInfo instead. - */ -typedef struct { - /** set to sizeof(GpsSvInfo) */ - size_t size; - /** Pseudo-random number for the SV. */ - int prn; - /** Signal to noise ratio. */ - float snr; - /** Elevation of SV in degrees. */ - float elevation; - /** Azimuth of SV in degrees. */ - float azimuth; - /** Samsung-added field */ - int used; -} GpsSvInfo; - -typedef struct { - /** set to sizeof(GnssSvInfo) */ - size_t size; - - /** - * Pseudo-random number for the SV, or FCN/OSN number for Glonass. The - * distinction is made by looking at constellation field. Values should be - * in the range of: - * - * - GPS: 1-32 - * - SBAS: 120-151, 183-192 - * - GLONASS: 1-24, the orbital slot number (OSN), if known. Or, if not: - * 93-106, the frequency channel number (FCN) (-7 to +6) offset by + 100 - * i.e. report an FCN of -7 as 93, FCN of 0 as 100, and FCN of +6 as 106. - * - QZSS: 193-200 - * - Galileo: 1-36 - * - Beidou: 1-37 - */ - int16_t svid; - - /** - * Defines the constellation of the given SV. Value should be one of those - * GNSS_CONSTELLATION_* constants - */ - GnssConstellationType constellation; - - /** - * Carrier-to-noise density in dB-Hz, typically in the range [0, 63]. - * It contains the measured C/N0 value for the signal at the antenna port. - * - * This is a mandatory value. - */ - float c_n0_dbhz; - - /** Elevation of SV in degrees. */ - float elevation; - - /** Azimuth of SV in degrees. */ - float azimuth; - - /** - * Contains additional data about the given SV. Value should be one of those - * GNSS_SV_FLAGS_* constants - */ - GnssSvFlags flags; - -} GnssSvInfo; - -/** - * Legacy struct to represents SV status. - * Deprecated, to be removed in the next Android release. - * Use GnssSvStatus instead. - */ -typedef struct { - /** set to sizeof(GpsSvStatus) */ - size_t size; - int num_svs; - GpsSvInfo sv_list[GPS_MAX_SVS]; - uint32_t ephemeris_mask; - uint32_t almanac_mask; - uint32_t used_in_fix_mask; -} GpsSvStatus; - -/** - * Represents SV status. - */ -typedef struct { - /** set to sizeof(GnssSvStatus) */ - size_t size; - - /** Number of GPS SVs currently visible, refers to the SVs stored in sv_list */ - int num_svs; - /** - * Pointer to an array of SVs information for all GNSS constellations, - * except GPS, which is reported using sv_list - */ - GnssSvInfo gnss_sv_list[GNSS_MAX_SVS]; - -} GnssSvStatus; - -/* CellID for 2G, 3G and LTE, used in AGPS. */ -typedef struct { - AGpsRefLocationType type; - /** Mobile Country Code. */ - uint16_t mcc; - /** Mobile Network Code .*/ - uint16_t mnc; - /** Location Area Code in 2G, 3G and LTE. In 3G lac is discarded. In LTE, - * lac is populated with tac, to ensure that we don't break old clients that - * might rely in the old (wrong) behavior. - */ - uint16_t lac; - /** Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */ - uint32_t cid; - /** Tracking Area Code in LTE. */ - uint16_t tac; - /** Physical Cell id in LTE (not used in 2G and 3G) */ - uint16_t pcid; -} AGpsRefLocationCellID; - -typedef struct { - uint8_t mac[6]; -} AGpsRefLocationMac; - -/** Represents ref locations */ -typedef struct { - AGpsRefLocationType type; - union { - AGpsRefLocationCellID cellID; - AGpsRefLocationMac mac; - } u; -} AGpsRefLocation; - -/** - * Callback with location information. Can only be called from a thread created - * by create_thread_cb. - */ -typedef void (* gps_location_callback)(GpsLocation* location); - -/** - * Callback with status information. Can only be called from a thread created by - * create_thread_cb. - */ -typedef void (* gps_status_callback)(GpsStatus* status); - -/** - * Legacy callback with SV status information. - * Can only be called from a thread created by create_thread_cb. - * - * This callback is deprecated, and will be removed in the next release. Use - * gnss_sv_status_callback() instead. - */ -typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); - -/** - * Callback with SV status information. - * Can only be called from a thread created by create_thread_cb. - */ -typedef void (* gnss_sv_status_callback)(GnssSvStatus* sv_info); - -/** - * Callback for reporting NMEA sentences. Can only be called from a thread - * created by create_thread_cb. - */ -typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length); - -/** - * Callback to inform framework of the GPS engine's capabilities. Capability - * parameter is a bit field of GPS_CAPABILITY_* flags. - */ -typedef void (* gps_set_capabilities)(uint32_t capabilities); - -/** - * Callback utility for acquiring the GPS wakelock. This can be used to prevent - * the CPU from suspending while handling GPS events. - */ -typedef void (* gps_acquire_wakelock)(); - -/** Callback utility for releasing the GPS wakelock. */ -typedef void (* gps_release_wakelock)(); - -/** Callback for requesting NTP time */ -typedef void (* gps_request_utc_time)(); - -/** - * Callback for creating a thread that can call into the Java framework code. - * This must be used to create any threads that report events up to the - * framework. - */ -typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg); - -/** - * Provides information about how new the underlying GPS/GNSS hardware and - * software is. - * - * This information will be available for Android Test Applications. If a GPS - * HAL does not provide this information, it will be considered "2015 or - * earlier". - * - * If a GPS HAL does provide this information, then newer years will need to - * meet newer CTS standards. E.g. if the date are 2016 or above, then N+ level - * GpsMeasurement support will be verified. - */ -typedef struct { - /** Set to sizeof(GnssSystemInfo) */ - size_t size; - /* year in which the last update was made to the underlying hardware/firmware - * used to capture GNSS signals, e.g. 2016 */ - uint16_t year_of_hw; -} GnssSystemInfo; - -/** - * Callback to inform framework of the engine's hardware version information. - */ -typedef void (*gnss_set_system_info)(const GnssSystemInfo* info); - -/** New GPS callback structure. */ -typedef struct { - /** set to sizeof(GpsCallbacks) */ - size_t size; - gps_location_callback location_cb; - gps_status_callback status_cb; - gps_sv_status_callback 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; - gps_request_utc_time request_utc_time_cb; - - gnss_set_system_info set_system_info_cb; - gnss_sv_status_callback gnss_sv_status_cb; -} GpsCallbacks; - -/** Represents the standard GPS interface. */ -typedef struct { - /** set to sizeof(GpsInterface) */ - size_t size; - /** - * Opens the interface and provides the callback routines - * to the implementation of this interface. - */ - int (*init)( GpsCallbacks* callbacks ); - - /** Starts navigating. */ - int (*start)( void ); - - /** Stops navigating. */ - int (*stop)( void ); - - /** Closes the interface. */ - void (*cleanup)( void ); - - /** Injects the current time. */ - int (*inject_time)(GpsUtcTime time, int64_t timeReference, - int uncertainty); - - /** - * Injects current location from another location provider (typically cell - * ID). Latitude and longitude are measured in degrees expected accuracy is - * measured in meters - */ - int (*inject_location)(double latitude, double longitude, float accuracy); - - /** - * Specifies that the next call to start will not use the - * information defined in the flags. GPS_DELETE_ALL is passed for - * a cold start. - */ - void (*delete_aiding_data)(GpsAidingData flags); - - /** - * min_interval represents the time between fixes in milliseconds. - * preferred_accuracy represents the requested fix accuracy in meters. - * preferred_time represents the requested time to first fix in milliseconds. - * - * 'mode' parameter should be one of GPS_POSITION_MODE_MS_BASED - * or GPS_POSITION_MODE_STANDALONE. - * It is allowed by the platform (and it is recommended) to fallback to - * GPS_POSITION_MODE_MS_BASED if GPS_POSITION_MODE_MS_ASSISTED is passed in, and - * GPS_POSITION_MODE_MS_BASED is supported. - */ - int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence, - uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); - - /** Get a pointer to extension information. */ - const void* (*get_extension)(const char* name); -} GpsInterface; - -/** - * Callback to request the client to download XTRA data. The client should - * download XTRA data and inject it by calling inject_xtra_data(). Can only be - * called from a thread created by create_thread_cb. - */ -typedef void (* gps_xtra_download_request)(); - -/** Callback structure for the XTRA interface. */ -typedef struct { - gps_xtra_download_request download_request_cb; - gps_create_thread create_thread_cb; -} GpsXtraCallbacks; - -/** Extended interface for XTRA support. */ -typedef struct { - /** set to sizeof(GpsXtraInterface) */ - size_t size; - /** - * Opens the XTRA interface and provides the callback routines - * to the implementation of this interface. - */ - int (*init)( GpsXtraCallbacks* callbacks ); - /** Injects XTRA data into the GPS. */ - int (*inject_xtra_data)( char* data, int length ); -} GpsXtraInterface; - -/** Extended interface for DEBUG support. */ -typedef struct { - /** set to sizeof(GpsDebugInterface) */ - size_t size; - - /** - * This function should return any information that the native - * implementation wishes to include in a bugreport. - */ - size_t (*get_internal_state)(char* buffer, size_t bufferSize); -} GpsDebugInterface; - -/* - * Represents the status of AGPS augmented to support IPv4 and IPv6. - */ -typedef struct { - /** set to sizeof(AGpsStatus) */ - size_t size; - - AGpsType type; - AGpsStatusValue status; - - /** - * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4 - * address, or set to INADDR_NONE otherwise. - */ - uint32_t ipaddr; - - /** - * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report. - * Any other value of addr.ss_family will be rejected. - */ - struct sockaddr_storage addr; -} AGpsStatus; - -/** - * Callback with AGPS status information. Can only be called from a thread - * created by create_thread_cb. - */ -typedef void (* agps_status_callback)(AGpsStatus* status); - -/** Callback structure for the AGPS interface. */ -typedef struct { - agps_status_callback status_cb; - gps_create_thread create_thread_cb; -} AGpsCallbacks; - -/** - * Extended interface for AGPS support, it is augmented to enable to pass - * extra APN data. - */ -typedef struct { - /** set to sizeof(AGpsInterface) */ - size_t size; - - /** - * Opens the AGPS interface and provides the callback routines to the - * implementation of this interface. - */ - void (*init)(AGpsCallbacks* callbacks); - /** - * Deprecated. - * If the HAL supports AGpsInterface_v2 this API will not be used, see - * data_conn_open_with_apn_ip_type for more information. - */ - int (*data_conn_open)(const char* apn); - /** - * Notifies that the AGPS data connection has been closed. - */ - int (*data_conn_closed)(); - /** - * Notifies that a data connection is not available for AGPS. - */ - int (*data_conn_failed)(); - /** - * Sets the hostname and port for the AGPS server. - */ - int (*set_server)(AGpsType type, const char* hostname, int port); - - /** - * Notifies that a data connection is available and sets the name of the - * APN, and its IP type, to be used for SUPL connections. - */ - int (*data_conn_open_with_apn_ip_type)( - const char* apn, - ApnIpType apnIpType); -} AGpsInterface; - -/** Error codes associated with certificate operations */ -#define AGPS_CERTIFICATE_OPERATION_SUCCESS 0 -#define AGPS_CERTIFICATE_ERROR_GENERIC -100 -#define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101 - -/** A data structure that represents an X.509 certificate using DER encoding */ -typedef struct { - size_t length; - u_char* data; -} DerEncodedCertificate; - -/** - * A type definition for SHA1 Fingerprints used to identify X.509 Certificates - * The Fingerprint is a digest of the DER Certificate that uniquely identifies it. - */ -typedef struct { - u_char data[20]; -} Sha1CertificateFingerprint; - -/** AGPS Interface to handle SUPL certificate operations */ -typedef struct { - /** set to sizeof(SuplCertificateInterface) */ - size_t size; - - /** - * Installs a set of Certificates used for SUPL connections to the AGPS server. - * If needed the HAL should find out internally any certificates that need to be removed to - * accommodate the certificates to install. - * The certificates installed represent a full set of valid certificates needed to connect to - * AGPS SUPL servers. - * The list of certificates is required, and all must be available at the same time, when trying - * to establish a connection with the AGPS Server. - * - * Parameters: - * certificates - A pointer to an array of DER encoded certificates that are need to be - * installed in the HAL. - * length - The number of certificates to install. - * Returns: - * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully - * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of - * certificates attempted to be installed, the state of the certificates stored should - * remain the same as before on this error case. - * - * IMPORTANT: - * If needed the HAL should find out internally the set of certificates that need to be - * removed to accommodate the certificates to install. - */ - int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length ); - - /** - * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is - * expected that the given set of certificates is removed from the internal store of the HAL. - * - * Parameters: - * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of - * certificates to revoke. - * length - The number of fingerprints provided. - * Returns: - * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully. - * - * IMPORTANT: - * If any of the certificates provided (through its fingerprint) is not known by the HAL, - * it should be ignored and continue revoking/deleting the rest of them. - */ - int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length ); -} SuplCertificateInterface; - -/** Represents an NI request */ -typedef struct { - /** set to sizeof(GpsNiNotification) */ - size_t size; - - /** - * An ID generated by HAL to associate NI notifications and UI - * responses - */ - int notification_id; - - /** - * An NI type used to distinguish different categories of NI - * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ... - */ - GpsNiType ni_type; - - /** - * Notification/verification options, combinations of GpsNiNotifyFlags constants - */ - GpsNiNotifyFlags notify_flags; - - /** - * Timeout period to wait for user response. - * Set to 0 for no time out limit. - */ - int timeout; - - /** - * Default response when time out. - */ - GpsUserResponseType default_response; - - /** - * Requestor ID - */ - char requestor_id[GPS_NI_SHORT_STRING_MAXLEN]; - - /** - * Notification message. It can also be used to store client_id in some cases - */ - char text[GPS_NI_LONG_STRING_MAXLEN]; - - /** - * Client name decoding scheme - */ - GpsNiEncodingType requestor_id_encoding; - - /** - * Client name decoding scheme - */ - GpsNiEncodingType text_encoding; - - /** - * A pointer to extra data. Format: - * key_1 = value_1 - * key_2 = value_2 - */ - char extras[GPS_NI_LONG_STRING_MAXLEN]; - -} GpsNiNotification; - -/** - * Callback with NI notification. Can only be called from a thread created by - * create_thread_cb. - */ -typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification); - -/** 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; -} GpsNiCallbacks; - -/** - * Extended interface for Network-initiated (NI) support. - */ -typedef struct -{ - /** set to sizeof(GpsNiInterface) */ - size_t size; - - /** Registers the callbacks for HAL to use. */ - void (*init) (GpsNiCallbacks *callbacks); - - /** Sends a response to HAL. */ - void (*respond) (int notif_id, GpsUserResponseType user_response); -} GpsNiInterface; - -struct gps_device_t { - struct hw_device_t common; - - /** - * Set the provided lights to the provided values. - * - * Returns: 0 on succes, error code on failure. - */ - const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev); -}; - -#define AGPS_RIL_REQUEST_SETID_IMSI (1<<0L) -#define AGPS_RIL_REQUEST_SETID_MSISDN (1<<1L) - -#define AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L) -#define AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L) - -typedef void (*agps_ril_request_set_id)(uint32_t flags); -typedef void (*agps_ril_request_ref_loc)(uint32_t flags); - -typedef struct { - agps_ril_request_set_id request_setid; - agps_ril_request_ref_loc request_refloc; - gps_create_thread create_thread_cb; -} AGpsRilCallbacks; - -/** Extended interface for AGPS_RIL support. */ -typedef struct { - /** set to sizeof(AGpsRilInterface) */ - size_t size; - /** - * Opens the AGPS interface and provides the callback routines - * to the implementation of this interface. - */ - void (*init)( AGpsRilCallbacks* callbacks ); - - /** - * Sets the reference location. - */ - void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct); - /** - * Sets the set ID. - */ - void (*set_set_id) (AGpsSetIDType type, const char* setid); - - /** - * Send network initiated message. - */ - void (*ni_message) (uint8_t *msg, size_t len); - - /** - * Notify GPS of network status changes. - * These parameters match values in the android.net.NetworkInfo class. - */ - void (*update_network_state) (int connected, int type, int roaming, const char* extra_info); - - /** - * Notify GPS of network status changes. - * These parameters match values in the android.net.NetworkInfo class. - */ - void (*update_network_availability) (int avaiable, const char* apn); -} AGpsRilInterface; - -/** - * GPS Geofence. - * There are 3 states associated with a Geofence: Inside, Outside, Unknown. - * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. - * - * An example state diagram with confidence level: 95% and Unknown time limit - * set as 30 secs is shown below. (confidence level and Unknown time limit are - * explained latter) - * ____________________________ - * | Unknown (30 secs) | - * """""""""""""""""""""""""""" - * ^ | | ^ - * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN - * | v v | - * ________ EXITED _________ - * | Inside | -----------> | Outside | - * | | <----------- | | - * """""""" ENTERED """"""""" - * - * Inside state: We are 95% confident that the user is inside the geofence. - * Outside state: We are 95% confident that the user is outside the geofence - * Unknown state: Rest of the time. - * - * The Unknown state is better explained with an example: - * - * __________ - * | c| - * | ___ | _______ - * | |a| | | b | - * | """ | """"""" - * | | - * """""""""" - * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy - * circle reported by the GPS subsystem. Now with regard to "b", the system is - * confident that the user is outside. But with regard to "a" is not confident - * whether it is inside or outside the geofence. If the accuracy remains the - * same for a sufficient period of time, the UNCERTAIN transition would be - * triggered with the state set to Unknown. If the accuracy improves later, an - * appropriate transition should be triggered. This "sufficient period of time" - * is defined by the parameter in the add_geofence_area API. - * In other words, Unknown state can be interpreted as a state in which the - * GPS subsystem isn't confident enough that the user is either inside or - * outside the Geofence. It moves to Unknown state only after the expiry of the - * timeout. - * - * The geofence callback needs to be triggered for the ENTERED and EXITED - * transitions, when the GPS system is confident that the user has entered - * (Inside state) or exited (Outside state) the Geofence. An implementation - * which uses a value of 95% as the confidence is recommended. The callback - * should be triggered only for the transitions requested by the - * add_geofence_area call. - * - * Even though the diagram and explanation talks about states and transitions, - * the callee is only interested in the transistions. The states are mentioned - * here for illustrative purposes. - * - * Startup Scenario: When the device boots up, if an application adds geofences, - * and then we get an accurate GPS location fix, it needs to trigger the - * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. - * By default, all the Geofences will be in the Unknown state. - * - * When the GPS system is unavailable, gps_geofence_status_callback should be - * called to inform the upper layers of the same. Similarly, when it becomes - * available the callback should be called. This is a global state while the - * UNKNOWN transition described above is per geofence. - * - * An important aspect to note is that users of this API (framework), will use - * other subsystems like wifi, sensors, cell to handle Unknown case and - * hopefully provide a definitive state transition to the third party - * application. GPS Geofence will just be a signal indicating what the GPS - * subsystem knows about the Geofence. - * - */ -#define GPS_GEOFENCE_ENTERED (1<<0L) -#define GPS_GEOFENCE_EXITED (1<<1L) -#define GPS_GEOFENCE_UNCERTAIN (1<<2L) - -#define GPS_GEOFENCE_UNAVAILABLE (1<<0L) -#define GPS_GEOFENCE_AVAILABLE (1<<1L) - -#define GPS_GEOFENCE_OPERATION_SUCCESS 0 -#define GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES -100 -#define GPS_GEOFENCE_ERROR_ID_EXISTS -101 -#define GPS_GEOFENCE_ERROR_ID_UNKNOWN -102 -#define GPS_GEOFENCE_ERROR_INVALID_TRANSITION -103 -#define GPS_GEOFENCE_ERROR_GENERIC -149 - -/** - * The callback associated with the geofence. - * Parameters: - * geofence_id - The id associated with the add_geofence_area. - * location - The current GPS location. - * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED, - * GPS_GEOFENCE_UNCERTAIN. - * timestamp - Timestamp when the transition was detected. - * - * The callback should only be called when the caller is interested in that - * particular transition. For instance, if the caller is interested only in - * ENTERED transition, then the callback should NOT be called with the EXITED - * transition. - * - * IMPORTANT: If a transition is triggered resulting in this callback, the GPS - * subsystem will wake up the application processor, if its in suspend state. - */ -typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location, - int32_t transition, GpsUtcTime timestamp); - -/** - * The callback associated with the availability of the GPS system for geofencing - * monitoring. If the GPS system determines that it cannot monitor geofences - * because of lack of reliability or unavailability of the GPS signals, it will - * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter. - * - * Parameters: - * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE. - * last_location - Last known location. - */ -typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location); - -/** - * The callback associated with the add_geofence call. - * - * Parameter: - * geofence_id - Id of the geofence. - * status - GPS_GEOFENCE_OPERATION_SUCCESS - * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. - * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists - * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an - * invalid transition - * GPS_GEOFENCE_ERROR_GENERIC - for other errors. - */ -typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status); - -/** - * The callback associated with the remove_geofence call. - * - * Parameter: - * geofence_id - Id of the geofence. - * status - GPS_GEOFENCE_OPERATION_SUCCESS - * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id - * GPS_GEOFENCE_ERROR_GENERIC for others. - */ -typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status); - - -/** - * The callback associated with the pause_geofence call. - * - * Parameter: - * geofence_id - Id of the geofence. - * status - GPS_GEOFENCE_OPERATION_SUCCESS - * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id - * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - - * when monitor_transitions is invalid - * GPS_GEOFENCE_ERROR_GENERIC for others. - */ -typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status); - -/** - * The callback associated with the resume_geofence call. - * - * Parameter: - * geofence_id - Id of the geofence. - * status - GPS_GEOFENCE_OPERATION_SUCCESS - * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id - * GPS_GEOFENCE_ERROR_GENERIC for others. - */ -typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status); - -typedef struct { - gps_geofence_transition_callback geofence_transition_callback; - gps_geofence_status_callback geofence_status_callback; - gps_geofence_add_callback geofence_add_callback; - gps_geofence_remove_callback geofence_remove_callback; - gps_geofence_pause_callback geofence_pause_callback; - gps_geofence_resume_callback geofence_resume_callback; - gps_create_thread create_thread_cb; -} GpsGeofenceCallbacks; - -/** Extended interface for GPS_Geofencing support */ -typedef struct { - /** set to sizeof(GpsGeofencingInterface) */ - size_t size; - - /** - * Opens the geofence interface and provides the callback routines - * to the implementation of this interface. - */ - void (*init)( GpsGeofenceCallbacks* callbacks ); - - /** - * Add a geofence area. This api currently supports circular geofences. - * Parameters: - * geofence_id - The id for the geofence. If a geofence with this id - * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS) - * should be returned. - * latitude, longtitude, radius_meters - The lat, long and radius - * (in meters) for the geofence - * last_transition - The current state of the geofence. For example, if - * the system already knows that the user is inside the geofence, - * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it - * will be GPS_GEOFENCE_UNCERTAIN. - * monitor_transition - Which transitions to monitor. Bitwise OR of - * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and - * GPS_GEOFENCE_UNCERTAIN. - * notification_responsiveness_ms - Defines the best-effort description - * of how soon should the callback be called when the transition - * associated with the Geofence is triggered. For instance, if set - * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback - * should be called 1000 milliseconds within entering the geofence. - * This parameter is defined in milliseconds. - * NOTE: This is not to be confused with the rate that the GPS is - * polled at. It is acceptable to dynamically vary the rate of - * sampling the GPS for power-saving reasons; thus the rate of - * sampling may be faster or slower than this. - * unknown_timer_ms - The time limit after which the UNCERTAIN transition - * should be triggered. This parameter is defined in milliseconds. - * See above for a detailed explanation. - */ - void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude, - double radius_meters, int last_transition, int monitor_transitions, - int notification_responsiveness_ms, int unknown_timer_ms); - - /** - * Pause monitoring a particular geofence. - * Parameters: - * geofence_id - The id for the geofence. - */ - void (*pause_geofence) (int32_t geofence_id); - - /** - * Resume monitoring a particular geofence. - * Parameters: - * geofence_id - The id for the geofence. - * monitor_transitions - Which transitions to monitor. Bitwise OR of - * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and - * GPS_GEOFENCE_UNCERTAIN. - * This supersedes the value associated provided in the - * add_geofence_area call. - */ - void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); - - /** - * Remove a geofence area. After the function returns, no notifications - * should be sent. - * Parameter: - * geofence_id - The id for the geofence. - */ - void (*remove_geofence_area) (int32_t geofence_id); -} GpsGeofencingInterface; - -/** - * Legacy struct to represent an estimate of the GPS clock time. - * Deprecated, to be removed in the next Android release. - * Use GnssClock instead. - */ -typedef struct { - /** set to sizeof(GpsClock) */ - size_t size; - GpsClockFlags flags; - int16_t leap_second; - GpsClockType type; - int64_t time_ns; - double time_uncertainty_ns; - int64_t full_bias_ns; - double bias_ns; - double bias_uncertainty_ns; - double drift_nsps; - double drift_uncertainty_nsps; -} GpsClock; - -/** - * Represents an estimate of the GPS clock time. - */ -typedef struct { - /** set to sizeof(GnssClock) */ - size_t size; - - /** - * A set of flags indicating the validity of the fields in this data - * structure. - */ - GnssClockFlags flags; - - /** - * Leap second data. - * The sign of the value is defined by the following equation: - * utc_time_ns = time_ns - (full_bias_ns + bias_ns) - leap_second * - * 1,000,000,000 - * - * If the data is available 'flags' must contain GNSS_CLOCK_HAS_LEAP_SECOND. - */ - int16_t leap_second; - - /** - * The GNSS receiver internal clock value. This is the local hardware clock - * value. - * - * For local hardware clock, this value is expected to be monotonically - * increasing while the hardware clock remains power on. (For the case of a - * HW clock that is not continuously on, see the - * hw_clock_discontinuity_count field). The receiver's estimate of GPS time - * can be derived by substracting the sum of full_bias_ns and bias_ns (when - * available) from this value. - * - * This GPS time is expected to be the best estimate of current GPS time - * that GNSS receiver can achieve. - * - * Sub-nanosecond accuracy can be provided by means of the 'bias_ns' field. - * The value contains the 'time uncertainty' in it. - * - * This field is mandatory. - */ - int64_t time_ns; - - /** - * 1-Sigma uncertainty associated with the clock's time in nanoseconds. - * The uncertainty is represented as an absolute (single sided) value. - * - * If the data is available, 'flags' must contain - * GNSS_CLOCK_HAS_TIME_UNCERTAINTY. This value is effectively zero (it is - * the reference local clock, by which all other times and time - * uncertainties are measured.) (And thus this field can be not provided, - * per GNSS_CLOCK_HAS_TIME_UNCERTAINTY flag, or provided & set to 0.) - */ - double time_uncertainty_ns; - - /** - * The difference between hardware clock ('time' field) inside GPS receiver - * and the true GPS time since 0000Z, January 6, 1980, in nanoseconds. - * - * The sign of the value is defined by the following equation: - * local estimate of GPS time = time_ns - (full_bias_ns + bias_ns) - * - * This value is mandatory if the receiver has estimated GPS time. If the - * computed time is for a non-GPS constellation, the time offset of that - * constellation to GPS has to be applied to fill this value. The error - * estimate for the sum of this and the bias_ns is the bias_uncertainty_ns, - * and the caller is responsible for using this uncertainty (it can be very - * large before the GPS time has been solved for.) If the data is available - * 'flags' must contain GNSS_CLOCK_HAS_FULL_BIAS. - */ - int64_t full_bias_ns; - - /** - * Sub-nanosecond bias. - * The error estimate for the sum of this and the full_bias_ns is the - * bias_uncertainty_ns - * - * If the data is available 'flags' must contain GNSS_CLOCK_HAS_BIAS. If GPS - * has computed a position fix. This value is mandatory if the receiver has - * estimated GPS time. - */ - double bias_ns; - - /** - * 1-Sigma uncertainty associated with the local estimate of GPS time (clock - * bias) in nanoseconds. The uncertainty is represented as an absolute - * (single sided) value. - * - * If the data is available 'flags' must contain - * GNSS_CLOCK_HAS_BIAS_UNCERTAINTY. This value is mandatory if the receiver - * has estimated GPS time. - */ - double bias_uncertainty_ns; - - /** - * The clock's drift in nanoseconds (per second). - * - * A positive value means that the frequency is higher than the nominal - * frequency, and that the (full_bias_ns + bias_ns) is growing more positive - * over time. - * - * The value contains the 'drift uncertainty' in it. - * If the data is available 'flags' must contain GNSS_CLOCK_HAS_DRIFT. - * - * This value is mandatory if the receiver has estimated GNSS time - */ - double drift_nsps; - - /** - * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second). - * The uncertainty is represented as an absolute (single sided) value. - * - * If the data is available 'flags' must contain - * GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY. If GPS has computed a position fix this - * field is mandatory and must be populated. - */ - double drift_uncertainty_nsps; - - /** - * When there are any discontinuities in the HW clock, this field is - * mandatory. - * - * A "discontinuity" is meant to cover the case of a switch from one source - * of clock to another. A single free-running crystal oscillator (XO) - * should generally not have any discontinuities, and this can be set and - * left at 0. - * - * If, however, the time_ns value (HW clock) is derived from a composite of - * sources, that is not as smooth as a typical XO, or is otherwise stopped & - * restarted, then this value shall be incremented each time a discontinuity - * occurs. (E.g. this value may start at zero at device boot-up and - * increment each time there is a change in clock continuity. In the - * unlikely event that this value reaches full scale, rollover (not - * clamping) is required, such that this value continues to change, during - * subsequent discontinuity events.) - * - * While this number stays the same, between GnssClock reports, it can be - * safely assumed that the time_ns value has been running continuously, e.g. - * derived from a single, high quality clock (XO like, or better, that's - * typically used during continuous GNSS signal sampling.) - * - * It is expected, esp. during periods where there are few GNSS signals - * available, that the HW clock be discontinuity-free as long as possible, - * as this avoids the need to use (waste) a GNSS measurement to fully - * re-solve for the GPS clock bias and drift, when using the accompanying - * measurements, from consecutive GnssData reports. - */ - uint32_t hw_clock_discontinuity_count; - -} GnssClock; - -/** - * Legacy struct to represent a GPS Measurement, it contains raw and computed - * information. - * Deprecated, to be removed in the next Android release. - * Use GnssMeasurement instead. - */ -typedef struct { - /** set to sizeof(GpsMeasurement) */ - size_t size; - GpsMeasurementFlags flags; - int8_t prn; - double time_offset_ns; - GpsMeasurementState state; - int64_t received_gps_tow_ns; - int64_t received_gps_tow_uncertainty_ns; - double c_n0_dbhz; - double pseudorange_rate_mps; - double pseudorange_rate_uncertainty_mps; - GpsAccumulatedDeltaRangeState accumulated_delta_range_state; - double accumulated_delta_range_m; - double accumulated_delta_range_uncertainty_m; - double pseudorange_m; - double pseudorange_uncertainty_m; - double code_phase_chips; - double code_phase_uncertainty_chips; - float carrier_frequency_hz; - int64_t carrier_cycles; - double carrier_phase; - double carrier_phase_uncertainty; - GpsLossOfLock loss_of_lock; - int32_t bit_number; - int16_t time_from_last_bit_ms; - double doppler_shift_hz; - double doppler_shift_uncertainty_hz; - GpsMultipathIndicator multipath_indicator; - double snr_db; - double elevation_deg; - double elevation_uncertainty_deg; - double azimuth_deg; - double azimuth_uncertainty_deg; - bool used_in_fix; -} GpsMeasurement; - -/** - * Represents a GNSS Measurement, it contains raw and computed information. - * - * Independence - All signal measurement information (e.g. sv_time, - * pseudorange_rate, multipath_indicator) reported in this struct should be - * based on GNSS signal measurements only. You may not synthesize measurements - * by calculating or reporting expected measurements based on known or estimated - * position, velocity, or time. - */ -typedef struct { - /** set to sizeof(GpsMeasurement) */ - size_t size; - - /** A set of flags indicating the validity of the fields in this data structure. */ - GnssMeasurementFlags flags; - - /** - * Satellite vehicle ID number, as defined in GnssSvInfo::svid - * This is a mandatory value. - */ - int16_t svid; - - /** - * Defines the constellation of the given SV. Value should be one of those - * GNSS_CONSTELLATION_* constants - */ - GnssConstellationType constellation; - - /** - * Time offset at which the measurement was taken in nanoseconds. - * The reference receiver's time is specified by GpsData::clock::time_ns and should be - * interpreted in the same way as indicated by GpsClock::type. - * - * The sign of time_offset_ns is given by the following equation: - * measurement time = GpsClock::time_ns + time_offset_ns - * - * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy. - * This is a mandatory value. - */ - double time_offset_ns; - - /** - * Per satellite sync state. It represents the current sync state for the associated satellite. - * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly. - * - * This is a mandatory value. - */ - GnssMeasurementState state; - - /** - * The received GNSS Time-of-Week at the measurement time, in nanoseconds. - * Ensure that this field is independent (see comment at top of - * GnssMeasurement struct.) - * - * For GPS & QZSS, this is: - * Received GPS Time-of-Week at the measurement time, in nanoseconds. - * The value is relative to the beginning of the current GPS week. - * - * Given the highest sync state that can be achieved, per each satellite, valid range - * for this field can be: - * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN - * C/A code lock : [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set - * Bit sync : [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set - * Subframe sync : [ 0 6s ] : GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set - * TOW decoded : [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set - * - * Note well: if there is any ambiguity in integer millisecond, - * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field. - * - * This value must be populated if 'state' != GNSS_MEASUREMENT_STATE_UNKNOWN. - * - * For Glonass, this is: - * Received Glonass time of day, at the measurement time in nanoseconds. - * - * Given the highest sync state that can be achieved, per each satellite, valid range for - * this field can be: - * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN - * C/A code lock : [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set - * Symbol sync : [ 0 10ms ] : GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set - * Bit sync : [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set - * String sync : [ 0 2s ] : GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC is set - * Time of day : [ 0 1day ] : GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED is set - * - * For Beidou, this is: - * Received Beidou time of week, at the measurement time in nanoseconds. - * - * Given the highest sync state that can be achieved, per each satellite, valid range for - * this field can be: - * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN - * C/A code lock: [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set - * Bit sync (D2): [ 0 2ms ] : GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC is set - * Bit sync (D1): [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set - * Subframe (D2): [ 0 0.6s ] : GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC is set - * Subframe (D1): [ 0 6s ] : GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set - * Time of week : [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set - * - * For Galileo, this is: - * Received Galileo time of week, at the measurement time in nanoseconds. - * - * E1BC code lock : [ 0 4ms ] : GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK is set - * E1C 2nd code lock: [ 0 100ms ] : - * GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK is set - * - * E1B page : [ 0 2s ] : GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC is set - * Time of week: [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set - * - * For SBAS, this is: - * Received SBAS time, at the measurement time in nanoseconds. - * - * Given the highest sync state that can be achieved, per each satellite, - * valid range for this field can be: - * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN - * C/A code lock: [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set - * Symbol sync : [ 0 2ms ] : GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set - * Message : [ 0 1s ] : GNSS_MEASUREMENT_STATE_SBAS_SYNC is set - */ - int64_t received_sv_time_in_ns; - - /** - * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds. - * - * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN. - */ - int64_t received_sv_time_uncertainty_in_ns; - - /** - * Carrier-to-noise density in dB-Hz, typically in the range [0, 63]. - * It contains the measured C/N0 value for the signal at the antenna port. - * - * This is a mandatory value. - */ - double c_n0_dbhz; - - /** - * Pseudorange rate at the timestamp in m/s. The correction of a given - * Pseudorange Rate value includes corrections for receiver and satellite - * clock frequency errors. Ensure that this field is independent (see - * comment at top of GnssMeasurement struct.) - * - * It is mandatory to provide the 'uncorrected' 'pseudorange rate', and provide GpsClock's - * 'drift' field as well (When providing the uncorrected pseudorange rate, do not apply the - * corrections described above.) - * - * The value includes the 'pseudorange rate uncertainty' in it. - * A positive 'uncorrected' value indicates that the SV is moving away from the receiver. - * - * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler - * shift' is given by the equation: - * pseudorange rate = -k * doppler shift (where k is a constant) - * - * This should be the most accurate pseudorange rate available, based on - * fresh signal measurements from this channel. - * - * It is mandatory that this value be provided at typical carrier phase PRR - * quality (few cm/sec per second of uncertainty, or better) - when signals - * are sufficiently strong & stable, e.g. signals from a GPS simulator at >= - * 35 dB-Hz. - */ - double pseudorange_rate_mps; - - /** - * 1-Sigma uncertainty of the pseudorange_rate_mps. - * The uncertainty is represented as an absolute (single sided) value. - * - * This is a mandatory value. - */ - double pseudorange_rate_uncertainty_mps; - - /** - * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip - * (indicating loss of lock). - * - * This is a mandatory value. - */ - GnssAccumulatedDeltaRangeState accumulated_delta_range_state; - - /** - * Accumulated delta range since the last channel reset in meters. - * A positive value indicates that the SV is moving away from the receiver. - * - * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase' - * is given by the equation: - * accumulated delta range = -k * carrier phase (where k is a constant) - * - * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. - * However, it is expected that the data is only accurate when: - * 'accumulated delta range state' == GPS_ADR_STATE_VALID. - */ - double accumulated_delta_range_m; - - /** - * 1-Sigma uncertainty of the accumulated delta range in meters. - * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. - */ - double accumulated_delta_range_uncertainty_m; - - /** - * Carrier frequency at which codes and messages are modulated, it can be L1 or L2. - * If the field is not set, the carrier frequency is assumed to be L1. - * - * If the data is available, 'flags' must contain - * GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY. - */ - float carrier_frequency_hz; - - /** - * The number of full carrier cycles between the satellite and the receiver. - * The reference frequency is given by the field 'carrier_frequency_hz'. - * Indications of possible cycle slips and resets in the accumulation of - * this value can be inferred from the accumulated_delta_range_state flags. - * - * If the data is available, 'flags' must contain - * GNSS_MEASUREMENT_HAS_CARRIER_CYCLES. - */ - int64_t carrier_cycles; - - /** - * The RF phase detected by the receiver, in the range [0.0, 1.0]. - * This is usually the fractional part of the complete carrier phase measurement. - * - * The reference frequency is given by the field 'carrier_frequency_hz'. - * The value contains the 'carrier-phase uncertainty' in it. - * - * If the data is available, 'flags' must contain - * GNSS_MEASUREMENT_HAS_CARRIER_PHASE. - */ - double carrier_phase; - - /** - * 1-Sigma uncertainty of the carrier-phase. - * If the data is available, 'flags' must contain - * GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY. - */ - double carrier_phase_uncertainty; - - /** - * An enumeration that indicates the 'multipath' state of the event. - * - * The multipath Indicator is intended to report the presence of overlapping - * signals that manifest as distorted correlation peaks. - * - * - if there is a distorted correlation peak shape, report that multipath - * is GNSS_MULTIPATH_INDICATOR_PRESENT. - * - if there is not a distorted correlation peak shape, report - * GNSS_MULTIPATH_INDICATOR_NOT_PRESENT - * - if signals are too weak to discern this information, report - * GNSS_MULTIPATH_INDICATOR_UNKNOWN - * - * Example: when doing the standardized overlapping Multipath Performance - * test (3GPP TS 34.171) the Multipath indicator should report - * GNSS_MULTIPATH_INDICATOR_PRESENT for those signals that are tracked, and - * contain multipath, and GNSS_MULTIPATH_INDICATOR_NOT_PRESENT for those - * signals that are tracked and do not contain multipath. - */ - GnssMultipathIndicator multipath_indicator; - - /** - * Signal-to-noise ratio at correlator output in dB. - * If the data is available, 'flags' must contain GNSS_MEASUREMENT_HAS_SNR. - * This is the power ratio of the "correlation peak height above the - * observed noise floor" to "the noise RMS". - */ - double snr_db; -} GnssMeasurement; - -/** - * Legacy struct to represents a reading of GPS measurements. - * Deprecated, to be removed in the next Android release. - * Use GnssData instead. - */ -typedef struct { - /** set to sizeof(GpsData) */ - size_t size; - size_t measurement_count; - GpsMeasurement measurements[GPS_MAX_MEASUREMENT]; - - /** The GPS clock time reading. */ - GpsClock clock; -} GpsData; - -/** - * Represents a reading of GNSS measurements. For devices where GnssSystemInfo's - * year_of_hw is set to 2016+, it is mandatory that these be provided, on - * request, when the GNSS receiver is searching/tracking signals. - * - * - Reporting of GPS constellation measurements is mandatory. - * - Reporting of all tracked constellations are encouraged. - */ -typedef struct { - /** set to sizeof(GnssData) */ - size_t size; - - /** Number of measurements. */ - size_t measurement_count; - - /** The array of measurements. */ - GnssMeasurement measurements[GNSS_MAX_MEASUREMENT]; - - /** The GPS clock time reading. */ - GnssClock clock; -} GnssData; - -/** - * The legacy callback for to report measurements from the HAL. - * - * This callback is deprecated, and will be removed in the next release. Use - * gnss_measurement_callback() instead. - * - * Parameters: - * data - A data structure containing the measurements. - */ -typedef void (*gps_measurement_callback) (GpsData* data); - -/** - * The callback for to report measurements from the HAL. - * - * Parameters: - * data - A data structure containing the measurements. - */ -typedef void (*gnss_measurement_callback) (GnssData* data); - -typedef struct { - /** set to sizeof(GpsMeasurementCallbacks) */ - size_t size; - gps_measurement_callback measurement_callback; - gnss_measurement_callback gnss_measurement_callback; -} GpsMeasurementCallbacks; - -#define GPS_MEASUREMENT_OPERATION_SUCCESS 0 -#define GPS_MEASUREMENT_ERROR_ALREADY_INIT -100 -#define GPS_MEASUREMENT_ERROR_GENERIC -101 - -/** - * Extended interface for GPS Measurements support. - */ -typedef struct { - /** Set to sizeof(GpsMeasurementInterface) */ - size_t size; - - /** - * Initializes the interface and registers the callback routines with the HAL. - * After a successful call to 'init' the HAL must begin to provide updates at its own phase. - * - * Status: - * GPS_MEASUREMENT_OPERATION_SUCCESS - * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a - * corresponding call to 'close' - * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL - * will not generate any updates upon returning this error code. - */ - int (*init) (GpsMeasurementCallbacks* callbacks); - - /** - * Stops updates from the HAL, and unregisters the callback routines. - * After a call to stop, the previously registered callbacks must be considered invalid by the - * HAL. - * If stop is invoked without a previous 'init', this function should perform no work. - */ - void (*close) (); - -} GpsMeasurementInterface; - -/** - * Legacy struct to represents a GPS navigation message (or a fragment of it). - * Deprecated, to be removed in the next Android release. - * Use GnssNavigationMessage instead. - */ -typedef struct { - /** set to sizeof(GpsNavigationMessage) */ - size_t size; - int8_t prn; - GpsNavigationMessageType type; - NavigationMessageStatus status; - int16_t message_id; - int16_t submessage_id; - size_t data_length; - uint8_t* data; -} GpsNavigationMessage; - -/** Represents a GPS navigation message (or a fragment of it). */ -typedef struct { - /** set to sizeof(GnssNavigationMessage) */ - size_t size; - - /** - * Satellite vehicle ID number, as defined in GnssSvInfo::svid - * This is a mandatory value. - */ - int16_t svid; - - /** - * The type of message contained in the structure. - * This is a mandatory value. - */ - GnssNavigationMessageType type; - - /** - * The status of the received navigation message. - * No need to send any navigation message that contains words with parity error and cannot be - * corrected. - */ - NavigationMessageStatus status; - - /** - * Message identifier. It provides an index so the complete Navigation - * Message can be assembled. - * - * - For GPS L1 C/A subframe 4 and 5, this value corresponds to the 'frame - * id' of the navigation message, in the range of 1-25 (Subframe 1, 2, 3 - * does not contain a 'frame id' and this value can be set to -1.) - * - * - For Glonass L1 C/A, this refers to the frame ID, in the range of 1-5. - * - * - For BeiDou D1, this refers to the frame number in the range of 1-24 - * - * - For Beidou D2, this refers to the frame number, in the range of 1-120 - * - * - For Galileo F/NAV nominal frame structure, this refers to the subframe - * number, in the range of 1-12 - * - * - For Galileo I/NAV nominal frame structure, this refers to the subframe - * number in the range of 1-24 - */ - int16_t message_id; - - /** - * Sub-message identifier. If required by the message 'type', this value - * contains a sub-index within the current message (or frame) that is being - * transmitted. - * - * - For GPS L1 C/A, BeiDou D1 & BeiDou D2, the submessage id corresponds to - * the subframe number of the navigation message, in the range of 1-5. - * - * - For Glonass L1 C/A, this refers to the String number, in the range from - * 1-15 - * - * - For Galileo F/NAV, this refers to the page type in the range 1-6 - * - * - For Galileo I/NAV, this refers to the word type in the range 1-10+ - */ - int16_t submessage_id; - - /** - * The length of the data (in bytes) contained in the current message. - * If this value is different from zero, 'data' must point to an array of the same size. - * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word). - * - * This is a mandatory value. - */ - size_t data_length; - - /** - * The data of the reported GPS message. The bytes (or words) specified - * using big endian format (MSB first). - * - * - For GPS L1 C/A, Beidou D1 & Beidou D2, each subframe contains 10 30-bit - * words. Each word (30 bits) should be fit into the last 30 bits in a - * 4-byte word (skip B31 and B32), with MSB first, for a total of 40 - * bytes, covering a time period of 6, 6, and 0.6 seconds, respectively. - * - * - For Glonass L1 C/A, each string contains 85 data bits, including the - * checksum. These bits should be fit into 11 bytes, with MSB first (skip - * B86-B88), covering a time period of 2 seconds. - * - * - For Galileo F/NAV, each word consists of 238-bit (sync & tail symbols - * excluded). Each word should be fit into 30-bytes, with MSB first (skip - * B239, B240), covering a time period of 10 seconds. - * - * - For Galileo I/NAV, each page contains 2 page parts, even and odd, with - * a total of 2x114 = 228 bits, (sync & tail excluded) that should be fit - * into 29 bytes, with MSB first (skip B229-B232). - */ - uint8_t* data; - -} GnssNavigationMessage; - -/** - * The legacy callback to report an available fragment of a GPS navigation - * messages from the HAL. - * - * This callback is deprecated, and will be removed in the next release. Use - * gnss_navigation_message_callback() instead. - * - * Parameters: - * message - The GPS navigation submessage/subframe representation. - */ -typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message); - -/** - * The callback to report an available fragment of a GPS navigation messages from the HAL. - * - * Parameters: - * message - The GPS navigation submessage/subframe representation. - */ -typedef void (*gnss_navigation_message_callback) (GnssNavigationMessage* message); - -typedef struct { - /** set to sizeof(GpsNavigationMessageCallbacks) */ - size_t size; - gps_navigation_message_callback navigation_message_callback; - gnss_navigation_message_callback gnss_navigation_message_callback; -} GpsNavigationMessageCallbacks; - -#define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS 0 -#define GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT -100 -#define GPS_NAVIGATION_MESSAGE_ERROR_GENERIC -101 - -/** - * Extended interface for GPS navigation message reporting support. - */ -typedef struct { - /** Set to sizeof(GpsNavigationMessageInterface) */ - size_t size; - - /** - * Initializes the interface and registers the callback routines with the HAL. - * After a successful call to 'init' the HAL must begin to provide updates as they become - * available. - * - * Status: - * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS - * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered - * without a corresponding call to 'close'. - * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that - * the HAL will not generate any updates upon returning this error code. - */ - int (*init) (GpsNavigationMessageCallbacks* callbacks); - - /** - * Stops updates from the HAL, and unregisters the callback routines. - * After a call to stop, the previously registered callbacks must be considered invalid by the - * HAL. - * If stop is invoked without a previous 'init', this function should perform no work. - */ - void (*close) (); - -} GpsNavigationMessageInterface; - -/** - * Interface for passing GNSS configuration contents from platform to HAL. - */ -typedef struct { - /** Set to sizeof(GnssConfigurationInterface) */ - size_t size; - - /** - * Deliver GNSS configuration contents to HAL. - * Parameters: - * config_data - a pointer to a char array which holds what usually is expected from - file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'. - * length - total number of UTF8 characters in configuraiton data. - * - * IMPORTANT: - * GPS HAL should expect this function can be called multiple times. And it may be - * called even when GpsLocationProvider is already constructed and enabled. GPS HAL - * should maintain the existing requests for various callback regardless the change - * in configuration data. - */ - void (*configuration_update) (const char* config_data, int32_t length); -} GnssConfigurationInterface; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */ - +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_INCLUDE_HARDWARE_GPS_H +#define ANDROID_INCLUDE_HARDWARE_GPS_H + +#include +#include +#include +#include +#include +#include + +#include + +#include + +__BEGIN_DECLS + +/* + * Enums defined in HIDL in hardware/interfaces are auto-generated and present + * in gnss-base.h. + */ + +/* for compatibility */ + +/** Maximum number of SVs for gps_sv_status_callback(). */ +#define GNSS_MAX_SVS GNSS_MAX_SVS_COUNT +/** Maximum number of Measurements in gnss_measurement_callback(). */ +#define GNSS_MAX_MEASUREMENT GNSS_MAX_SVS_COUNT + +#define GPS_REQUEST_AGPS_DATA_CONN GNSS_REQUEST_AGNSS_DATA_CONN +#define GPS_RELEASE_AGPS_DATA_CONN GNSS_RELEASE_AGNSS_DATA_CONN +#define GPS_AGPS_DATA_CONNECTED GNSS_AGNSS_DATA_CONNECTED +#define GPS_AGPS_DATA_CONN_DONE GNSS_AGNSS_DATA_CONN_DONE +#define GPS_AGPS_DATA_CONN_FAILED GNSS_AGNSS_DATA_CONN_FAILED +#define AGPS_RIL_NETWORK_TYPE_MOBILE_MMS AGPS_RIL_NETWORK_TYPE_MMS +#define AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL AGPS_RIL_NETWORK_TYPE_SUPL +#define AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN AGPS_RIL_NETWORK_TYPE_DUN +#define AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI AGPS_RIL_NETWORK_TYPE_HIPRI +#define AGPS_RIL_NETWORK_TTYPE_WIMAX AGPS_RIL_NETWORK_TYPE_WIMAX +#define GNSS_MULTIPATH_INDICATOR_NOT_PRESENT GNSS_MULTIPATH_INDICATIOR_NOT_PRESENT +#define AGPS_SETID_TYPE_MSISDN AGPS_SETID_TYPE_MSISDM +#define GPS_MEASUREMENT_OPERATION_SUCCESS GPS_MEASUREMENT_SUCCESS +#define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS GPS_NAVIGATION_MESSAGE_SUCCESS +#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L1CA GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_L1CA +#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L2CNAV GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_L2CNAV +#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L5CNAV GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_L5CNAV +#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_CNAV2 GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_CNAV2 + +/** + * The id of this module + */ +#define GPS_HARDWARE_MODULE_ID "gps" + + +/** Milliseconds since January 1, 1970 */ +typedef int64_t GpsUtcTime; + +/** Maximum number of SVs for gps_sv_status_callback(). */ +#define GPS_MAX_SVS 32 + +/** Maximum number of Measurements in gps_measurement_callback(). */ +#define GPS_MAX_MEASUREMENT 32 + +/** Requested operational mode for GPS operation. */ +typedef uint32_t GpsPositionMode; + +/** Requested recurrence mode for GPS operation. */ +typedef uint32_t GpsPositionRecurrence; + +/** GPS status event values. */ +typedef uint16_t GpsStatusValue; + +/** Flags to indicate which values are valid in a GpsLocation. */ +typedef uint16_t GpsLocationFlags; + +/** + * Flags used to specify which aiding data to delete when calling + * delete_aiding_data(). + */ +typedef uint16_t GpsAidingData; +/* IMPORTANT: Note that the following values must match + * constants in GpsLocationProvider.java. */ + +/** AGPS type */ +typedef uint16_t AGpsType; + +typedef uint16_t AGpsSetIDType; + +typedef uint16_t ApnIpType; + +/** + * String length constants + */ +#define GPS_NI_SHORT_STRING_MAXLEN 256 +#define GPS_NI_LONG_STRING_MAXLEN 2048 + +/** + * GpsNiType constants + */ +typedef uint32_t GpsNiType; + +/** + * GpsNiNotifyFlags constants + */ +typedef uint32_t GpsNiNotifyFlags; + +/** + * GPS NI responses, used to define the response in + * NI structures + */ +typedef int GpsUserResponseType; + +/** + * NI data encoding scheme + */ +typedef int GpsNiEncodingType; + +/** AGPS status event values. */ +typedef uint16_t AGpsStatusValue; + +typedef uint16_t AGpsRefLocationType; + +/* Deprecated, to be removed in the next Android release. */ +#define AGPS_REG_LOCATION_TYPE_MAC 3 + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint16_t GpsClockFlags; +#define GPS_CLOCK_HAS_LEAP_SECOND (1<<0) +#define GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1) +#define GPS_CLOCK_HAS_FULL_BIAS (1<<2) +#define GPS_CLOCK_HAS_BIAS (1<<3) +#define GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4) +#define GPS_CLOCK_HAS_DRIFT (1<<5) +#define GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6) + +/** + * Flags to indicate what fields in GnssClock are valid. + */ +typedef uint16_t GnssClockFlags; + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint8_t GpsClockType; +#define GPS_CLOCK_TYPE_UNKNOWN 0 +#define GPS_CLOCK_TYPE_LOCAL_HW_TIME 1 +#define GPS_CLOCK_TYPE_GPS_TIME 2 + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint32_t GpsMeasurementFlags; +#define GPS_MEASUREMENT_HAS_SNR (1<<0) +#define GPS_MEASUREMENT_HAS_ELEVATION (1<<1) +#define GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2) +#define GPS_MEASUREMENT_HAS_AZIMUTH (1<<3) +#define GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4) +#define GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5) +#define GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6) +#define GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7) +#define GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8) +#define GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9) +#define GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10) +#define GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11) +#define GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12) +#define GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13) +#define GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14) +#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15) +#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16) +#define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17) +#define GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE (1<<18) + +/** + * Flags to indicate what fields in GnssMeasurement are valid. + */ +typedef uint32_t GnssMeasurementFlags; + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint8_t GpsLossOfLock; +#define GPS_LOSS_OF_LOCK_UNKNOWN 0 +#define GPS_LOSS_OF_LOCK_OK 1 +#define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2 + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. Use GnssMultipathIndicator instead. + */ +typedef uint8_t GpsMultipathIndicator; +#define GPS_MULTIPATH_INDICATOR_UNKNOWN 0 +#define GPS_MULTIPATH_INDICATOR_DETECTED 1 +#define GPS_MULTIPATH_INDICATOR_NOT_USED 2 + +/** + * Enumeration of available values for the GNSS Measurement's multipath + * indicator. + */ +typedef uint8_t GnssMultipathIndicator; + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint16_t GpsMeasurementState; +#define GPS_MEASUREMENT_STATE_UNKNOWN 0 +#define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0) +#define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1) +#define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2) +#define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3) +#define GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4) + +/** + * Flags indicating the GNSS measurement state. + * + * The expected behavior here is for GPS HAL to set all the flags that applies. + * For example, if the state for a satellite is only C/A code locked and bit + * synchronized, and there is still millisecond ambiguity, the state should be + * set as: + * + * GNSS_MEASUREMENT_STATE_CODE_LOCK | GNSS_MEASUREMENT_STATE_BIT_SYNC | + * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS + * + * If GNSS is still searching for a satellite, the corresponding state should be + * set to GNSS_MEASUREMENT_STATE_UNKNOWN(0). + */ +typedef uint32_t GnssMeasurementState; + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint16_t GpsAccumulatedDeltaRangeState; +#define GPS_ADR_STATE_UNKNOWN 0 +#define GPS_ADR_STATE_VALID (1<<0) +#define GPS_ADR_STATE_RESET (1<<1) +#define GPS_ADR_STATE_CYCLE_SLIP (1<<2) + +/** + * Flags indicating the Accumulated Delta Range's states. + */ +typedef uint16_t GnssAccumulatedDeltaRangeState; + +/* The following typedef together with its constants below are deprecated, and + * will be removed in the next release. */ +typedef uint8_t GpsNavigationMessageType; +#define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0 +#define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1 +#define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2 +#define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3 +#define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4 + +/** + * Enumeration of available values to indicate the GNSS Navigation message + * types. + * + * For convenience, first byte is the GnssConstellationType on which that signal + * is typically transmitted + */ +typedef int16_t GnssNavigationMessageType; + +/** + * Status of Navigation Message + * When a message is received properly without any parity error in its navigation words, the + * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received + * with words that failed parity check, but GPS is able to correct those words, the status + * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT. + * No need to send any navigation message that contains words with parity error and cannot be + * corrected. + */ +typedef uint16_t NavigationMessageStatus; + +/* This constant is deprecated, and will be removed in the next release. */ +#define NAV_MESSAGE_STATUS_UNKONW 0 + +/** + * Flags that indicate information about the satellite + */ +typedef uint8_t GnssSvFlags; + +/** + * Constellation type of GnssSvInfo + */ +typedef uint8_t GnssConstellationType; + +/** + * Name for the GPS XTRA interface. + */ +#define GPS_XTRA_INTERFACE "gps-xtra" + +/** + * Name for the GPS DEBUG interface. + */ +#define GPS_DEBUG_INTERFACE "gps-debug" + +/** + * Name for the AGPS interface. + */ +#define AGPS_INTERFACE "agps" + +/** + * Name of the Supl Certificate interface. + */ +#define SUPL_CERTIFICATE_INTERFACE "supl-certificate" + +/** + * Name for NI interface + */ +#define GPS_NI_INTERFACE "gps-ni" + +/** + * Name for the AGPS-RIL interface. + */ +#define AGPS_RIL_INTERFACE "agps_ril" + +/** + * The GPS chipset can use Psc for AGPS + */ +#define AGPS_USE_PSC + +/** + * Name for the GPS_Geofencing interface. + */ +#define GPS_GEOFENCING_INTERFACE "gps_geofencing" + +/** + * Name of the GPS Measurements interface. + */ +#define GPS_MEASUREMENT_INTERFACE "gps_measurement" + +/** + * Name of the GPS navigation message interface. + */ +#define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message" + +/** + * Name of the GNSS/GPS configuration interface. + */ +#define GNSS_CONFIGURATION_INTERFACE "gnss_configuration" + + +/** Represents a location. */ +typedef struct { + /** set to sizeof(GpsLocation) */ + size_t size; + /** Contains GpsLocationFlags bits. */ + uint16_t flags; + /** Represents latitude in degrees. */ + double latitude; + /** Represents longitude in degrees. */ + double longitude; + /** + * Represents altitude in meters above the WGS 84 reference ellipsoid. + */ + double altitude; + /** Represents speed in meters per second. */ + float speed; + /** Represents heading in degrees. */ + float bearing; + /** Represents expected accuracy in meters. */ + float accuracy; + /** Timestamp for the location fix. */ + GpsUtcTime timestamp; +} GpsLocation; + +/** Represents the status. */ +typedef struct { + /** set to sizeof(GpsStatus) */ + size_t size; + GpsStatusValue status; +} GpsStatus; + +/** + * Legacy struct to represents SV information. + * Deprecated, to be removed in the next Android release. + * Use GnssSvInfo instead. + */ +typedef struct { + /** set to sizeof(GpsSvInfo) */ + size_t size; + /** Pseudo-random number for the SV. */ + int prn; + /** Signal to noise ratio. */ + float snr; + /** Elevation of SV in degrees. */ + float elevation; + /** Azimuth of SV in degrees. */ + float azimuth; + /** Placeholder for Samsung ABI compat. */ + int unknown; +} GpsSvInfo; + +typedef struct { + /** set to sizeof(GnssSvInfo) */ + size_t size; + + /** + * Pseudo-random number for the SV, or FCN/OSN number for Glonass. The + * distinction is made by looking at constellation field. Values should be + * in the range of: + * + * - GPS: 1-32 + * - SBAS: 120-151, 183-192 + * - GLONASS: 1-24, the orbital slot number (OSN), if known. Or, if not: + * 93-106, the frequency channel number (FCN) (-7 to +6) offset by + 100 + * i.e. report an FCN of -7 as 93, FCN of 0 as 100, and FCN of +6 as 106. + * - QZSS: 193-200 + * - Galileo: 1-36 + * - Beidou: 1-37 + */ + int16_t svid; + + /** + * Defines the constellation of the given SV. Value should be one of those + * GNSS_CONSTELLATION_* constants + */ + GnssConstellationType constellation; + + /** + * Carrier-to-noise density in dB-Hz, typically in the range [0, 63]. + * It contains the measured C/N0 value for the signal at the antenna port. + * + * This is a mandatory value. + */ + float c_n0_dbhz; + + /** Elevation of SV in degrees. */ + float elevation; + + /** Azimuth of SV in degrees. */ + float azimuth; + + /** + * Contains additional data about the given SV. Value should be one of those + * GNSS_SV_FLAGS_* constants + */ + GnssSvFlags flags; + +} GnssSvInfo; + +/** + * Legacy struct to represents SV status. + * Deprecated, to be removed in the next Android release. + * Use GnssSvStatus instead. + */ +typedef struct { + /** set to sizeof(GpsSvStatus) */ + size_t size; + int num_svs; + GpsSvInfo sv_list[GPS_MAX_SVS]; + uint32_t ephemeris_mask; + uint32_t almanac_mask; + uint32_t used_in_fix_mask; +} GpsSvStatus; + +/** + * Represents SV status. + */ +typedef struct { + /** set to sizeof(GnssSvStatus) */ + size_t size; + + /** Number of GPS SVs currently visible, refers to the SVs stored in sv_list */ + int num_svs; + /** + * Pointer to an array of SVs information for all GNSS constellations, + * except GPS, which is reported using sv_list + */ + GnssSvInfo gnss_sv_list[GNSS_MAX_SVS]; + +} GnssSvStatus; + +/* CellID for 2G, 3G and LTE, used in AGPS. */ +typedef struct { + AGpsRefLocationType type; + /** Mobile Country Code. */ + uint16_t mcc; + /** Mobile Network Code .*/ + uint16_t mnc; + /** Location Area Code in 2G, 3G and LTE. In 3G lac is discarded. In LTE, + * lac is populated with tac, to ensure that we don't break old clients that + * might rely in the old (wrong) behavior. + */ + uint16_t lac; +#ifdef AGPS_USE_PSC + uint16_t psc; +#endif + /** Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */ + uint32_t cid; + /** Tracking Area Code in LTE. */ + uint16_t tac; + /** Physical Cell id in LTE (not used in 2G and 3G) */ + uint16_t pcid; +} AGpsRefLocationCellID; + +typedef struct { + uint8_t mac[6]; +} AGpsRefLocationMac; + +/** Represents ref locations */ +typedef struct { + AGpsRefLocationType type; + union { + AGpsRefLocationCellID cellID; + AGpsRefLocationMac mac; + } u; +} AGpsRefLocation; + +/** + * Callback with location information. Can only be called from a thread created + * by create_thread_cb. + */ +typedef void (* gps_location_callback)(GpsLocation* location); + +/** + * Callback with status information. Can only be called from a thread created by + * create_thread_cb. + */ +typedef void (* gps_status_callback)(GpsStatus* status); + +/** + * Legacy callback with SV status information. + * Can only be called from a thread created by create_thread_cb. + * + * This callback is deprecated, and will be removed in the next release. Use + * gnss_sv_status_callback() instead. + */ +typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); + +/** + * Callback with SV status information. + * Can only be called from a thread created by create_thread_cb. + */ +typedef void (* gnss_sv_status_callback)(GnssSvStatus* sv_info); + +/** + * Callback for reporting NMEA sentences. Can only be called from a thread + * created by create_thread_cb. + */ +typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length); + +/** + * Callback to inform framework of the GPS engine's capabilities. Capability + * parameter is a bit field of GPS_CAPABILITY_* flags. + */ +typedef void (* gps_set_capabilities)(uint32_t capabilities); + +/** + * Callback utility for acquiring the GPS wakelock. This can be used to prevent + * the CPU from suspending while handling GPS events. + */ +typedef void (* gps_acquire_wakelock)(); + +/** Callback utility for releasing the GPS wakelock. */ +typedef void (* gps_release_wakelock)(); + +/** Callback for requesting NTP time */ +typedef void (* gps_request_utc_time)(); + +/** + * Callback for creating a thread that can call into the Java framework code. + * This must be used to create any threads that report events up to the + * framework. + */ +typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg); + +/** + * Provides information about how new the underlying GPS/GNSS hardware and + * software is. + * + * This information will be available for Android Test Applications. If a GPS + * HAL does not provide this information, it will be considered "2015 or + * earlier". + * + * If a GPS HAL does provide this information, then newer years will need to + * meet newer CTS standards. E.g. if the date are 2016 or above, then N+ level + * GpsMeasurement support will be verified. + */ +typedef struct { + /** Set to sizeof(GnssSystemInfo) */ + size_t size; + /* year in which the last update was made to the underlying hardware/firmware + * used to capture GNSS signals, e.g. 2016 */ + uint16_t year_of_hw; +} GnssSystemInfo; + +/** + * Callback to inform framework of the engine's hardware version information. + */ +typedef void (*gnss_set_system_info)(const GnssSystemInfo* info); + +/** New GPS callback structure. */ +typedef struct { + /** set to sizeof(GpsCallbacks) */ + size_t size; + gps_location_callback location_cb; + gps_status_callback status_cb; + gps_sv_status_callback 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; + gps_request_utc_time request_utc_time_cb; + + gnss_set_system_info set_system_info_cb; + gnss_sv_status_callback gnss_sv_status_cb; +} GpsCallbacks; + +/** Represents the standard GPS interface. */ +typedef struct { + /** set to sizeof(GpsInterface) */ + size_t size; + /** + * Opens the interface and provides the callback routines + * to the implementation of this interface. + */ + int (*init)( GpsCallbacks* callbacks ); + + /** Starts navigating. */ + int (*start)( void ); + + /** Stops navigating. */ + int (*stop)( void ); + + /** Closes the interface. */ + void (*cleanup)( void ); + + /** Injects the current time. */ + int (*inject_time)(GpsUtcTime time, int64_t timeReference, + int uncertainty); + + /** + * Injects current location from another location provider (typically cell + * ID). Latitude and longitude are measured in degrees expected accuracy is + * measured in meters + */ + int (*inject_location)(double latitude, double longitude, float accuracy); + + /** + * Specifies that the next call to start will not use the + * information defined in the flags. GPS_DELETE_ALL is passed for + * a cold start. + */ + void (*delete_aiding_data)(GpsAidingData flags); + + /** + * min_interval represents the time between fixes in milliseconds. + * preferred_accuracy represents the requested fix accuracy in meters. + * preferred_time represents the requested time to first fix in milliseconds. + * + * 'mode' parameter should be one of GPS_POSITION_MODE_MS_BASED + * or GPS_POSITION_MODE_STANDALONE. + * It is allowed by the platform (and it is recommended) to fallback to + * GPS_POSITION_MODE_MS_BASED if GPS_POSITION_MODE_MS_ASSISTED is passed in, and + * GPS_POSITION_MODE_MS_BASED is supported. + */ + int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence, + uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); + + /** Get a pointer to extension information. */ + const void* (*get_extension)(const char* name); +} GpsInterface; + +/** + * Callback to request the client to download XTRA data. The client should + * download XTRA data and inject it by calling inject_xtra_data(). Can only be + * called from a thread created by create_thread_cb. + */ +typedef void (* gps_xtra_download_request)(); + +/** Callback structure for the XTRA interface. */ +typedef struct { + gps_xtra_download_request download_request_cb; + gps_create_thread create_thread_cb; +} GpsXtraCallbacks; + +/** Extended interface for XTRA support. */ +typedef struct { + /** set to sizeof(GpsXtraInterface) */ + size_t size; + /** + * Opens the XTRA interface and provides the callback routines + * to the implementation of this interface. + */ + int (*init)( GpsXtraCallbacks* callbacks ); + /** Injects XTRA data into the GPS. */ + int (*inject_xtra_data)( char* data, int length ); +} GpsXtraInterface; + +/** Extended interface for DEBUG support. */ +typedef struct { + /** set to sizeof(GpsDebugInterface) */ + size_t size; + + /** + * This function should return any information that the native + * implementation wishes to include in a bugreport. + */ + size_t (*get_internal_state)(char* buffer, size_t bufferSize); +} GpsDebugInterface; + +/* + * Represents the status of AGPS augmented to support IPv4 and IPv6. + */ +typedef struct { + /** set to sizeof(AGpsStatus) */ + size_t size; + + AGpsType type; + AGpsStatusValue status; + + /** + * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4 + * address, or set to INADDR_NONE otherwise. + */ + uint32_t ipaddr; + + /** + * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report. + * Any other value of addr.ss_family will be rejected. + */ + struct sockaddr_storage addr; +} AGpsStatus; + +/** + * Callback with AGPS status information. Can only be called from a thread + * created by create_thread_cb. + */ +typedef void (* agps_status_callback)(AGpsStatus* status); + +/** Callback structure for the AGPS interface. */ +typedef struct { + agps_status_callback status_cb; + gps_create_thread create_thread_cb; +} AGpsCallbacks; + +/** + * Extended interface for AGPS support, it is augmented to enable to pass + * extra APN data. + */ +typedef struct { + /** set to sizeof(AGpsInterface) */ + size_t size; + + /** + * Opens the AGPS interface and provides the callback routines to the + * implementation of this interface. + */ + void (*init)(AGpsCallbacks* callbacks); + /** + * Deprecated. + * If the HAL supports AGpsInterface_v2 this API will not be used, see + * data_conn_open_with_apn_ip_type for more information. + */ + int (*data_conn_open)(const char* apn); + /** + * Notifies that the AGPS data connection has been closed. + */ + int (*data_conn_closed)(); + /** + * Notifies that a data connection is not available for AGPS. + */ + int (*data_conn_failed)(); + /** + * Sets the hostname and port for the AGPS server. + */ + int (*set_server)(AGpsType type, const char* hostname, int port); + + /** + * Notifies that a data connection is available and sets the name of the + * APN, and its IP type, to be used for SUPL connections. + */ + int (*data_conn_open_with_apn_ip_type)( + const char* apn, + ApnIpType apnIpType); +} AGpsInterface; + +/** Error codes associated with certificate operations */ +#define AGPS_CERTIFICATE_OPERATION_SUCCESS 0 +#define AGPS_CERTIFICATE_ERROR_GENERIC -100 +#define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101 + +/** A data structure that represents an X.509 certificate using DER encoding */ +typedef struct { + size_t length; + u_char* data; +} DerEncodedCertificate; + +/** + * A type definition for SHA1 Fingerprints used to identify X.509 Certificates + * The Fingerprint is a digest of the DER Certificate that uniquely identifies it. + */ +typedef struct { + u_char data[20]; +} Sha1CertificateFingerprint; + +/** AGPS Interface to handle SUPL certificate operations */ +typedef struct { + /** set to sizeof(SuplCertificateInterface) */ + size_t size; + + /** + * Installs a set of Certificates used for SUPL connections to the AGPS server. + * If needed the HAL should find out internally any certificates that need to be removed to + * accommodate the certificates to install. + * The certificates installed represent a full set of valid certificates needed to connect to + * AGPS SUPL servers. + * The list of certificates is required, and all must be available at the same time, when trying + * to establish a connection with the AGPS Server. + * + * Parameters: + * certificates - A pointer to an array of DER encoded certificates that are need to be + * installed in the HAL. + * length - The number of certificates to install. + * Returns: + * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully + * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of + * certificates attempted to be installed, the state of the certificates stored should + * remain the same as before on this error case. + * + * IMPORTANT: + * If needed the HAL should find out internally the set of certificates that need to be + * removed to accommodate the certificates to install. + */ + int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length ); + + /** + * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is + * expected that the given set of certificates is removed from the internal store of the HAL. + * + * Parameters: + * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of + * certificates to revoke. + * length - The number of fingerprints provided. + * Returns: + * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully. + * + * IMPORTANT: + * If any of the certificates provided (through its fingerprint) is not known by the HAL, + * it should be ignored and continue revoking/deleting the rest of them. + */ + int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length ); +} SuplCertificateInterface; + +/** Represents an NI request */ +typedef struct { + /** set to sizeof(GpsNiNotification) */ + size_t size; + + /** + * An ID generated by HAL to associate NI notifications and UI + * responses + */ + int notification_id; + + /** + * An NI type used to distinguish different categories of NI + * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ... + */ + GpsNiType ni_type; + + /** + * Notification/verification options, combinations of GpsNiNotifyFlags constants + */ + GpsNiNotifyFlags notify_flags; + + /** + * Timeout period to wait for user response. + * Set to 0 for no time out limit. + */ + int timeout; + + /** + * Default response when time out. + */ + GpsUserResponseType default_response; + + /** + * Requestor ID + */ + char requestor_id[GPS_NI_SHORT_STRING_MAXLEN]; + + /** + * Notification message. It can also be used to store client_id in some cases + */ + char text[GPS_NI_LONG_STRING_MAXLEN]; + + /** + * Client name decoding scheme + */ + GpsNiEncodingType requestor_id_encoding; + + /** + * Client name decoding scheme + */ + GpsNiEncodingType text_encoding; + + /** + * A pointer to extra data. Format: + * key_1 = value_1 + * key_2 = value_2 + */ + char extras[GPS_NI_LONG_STRING_MAXLEN]; + +} GpsNiNotification; + +/** + * Callback with NI notification. Can only be called from a thread created by + * create_thread_cb. + */ +typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification); + +/** 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; +} GpsNiCallbacks; + +/** + * Extended interface for Network-initiated (NI) support. + */ +typedef struct +{ + /** set to sizeof(GpsNiInterface) */ + size_t size; + + /** Registers the callbacks for HAL to use. */ + void (*init) (GpsNiCallbacks *callbacks); + + /** Sends a response to HAL. */ + void (*respond) (int notif_id, GpsUserResponseType user_response); +} GpsNiInterface; + +struct gps_device_t { + struct hw_device_t common; + + /** + * Set the provided lights to the provided values. + * + * Returns: 0 on succes, error code on failure. + */ + const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev); +}; + +#define AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L) +#define AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L) + +typedef void (*agps_ril_request_set_id)(uint32_t flags); +typedef void (*agps_ril_request_ref_loc)(uint32_t flags); + +typedef struct { + agps_ril_request_set_id request_setid; + agps_ril_request_ref_loc request_refloc; + gps_create_thread create_thread_cb; +} AGpsRilCallbacks; + +/** Extended interface for AGPS_RIL support. */ +typedef struct { + /** set to sizeof(AGpsRilInterface) */ + size_t size; + /** + * Opens the AGPS interface and provides the callback routines + * to the implementation of this interface. + */ + void (*init)( AGpsRilCallbacks* callbacks ); + + /** + * Sets the reference location. + */ + void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct); + /** + * Sets the set ID. + */ + void (*set_set_id) (AGpsSetIDType type, const char* setid); + + /** + * Send network initiated message. + */ + void (*ni_message) (uint8_t *msg, size_t len); + + /** + * Notify GPS of network status changes. + * These parameters match values in the android.net.NetworkInfo class. + */ + void (*update_network_state) (int connected, int type, int roaming, const char* extra_info); + + /** + * Notify GPS of network status changes. + * These parameters match values in the android.net.NetworkInfo class. + */ + void (*update_network_availability) (int avaiable, const char* apn); +} AGpsRilInterface; + +/** + * GPS Geofence. + * There are 3 states associated with a Geofence: Inside, Outside, Unknown. + * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. + * + * An example state diagram with confidence level: 95% and Unknown time limit + * set as 30 secs is shown below. (confidence level and Unknown time limit are + * explained latter) + * ____________________________ + * | Unknown (30 secs) | + * """""""""""""""""""""""""""" + * ^ | | ^ + * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN + * | v v | + * ________ EXITED _________ + * | Inside | -----------> | Outside | + * | | <----------- | | + * """""""" ENTERED """"""""" + * + * Inside state: We are 95% confident that the user is inside the geofence. + * Outside state: We are 95% confident that the user is outside the geofence + * Unknown state: Rest of the time. + * + * The Unknown state is better explained with an example: + * + * __________ + * | c| + * | ___ | _______ + * | |a| | | b | + * | """ | """"""" + * | | + * """""""""" + * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy + * circle reported by the GPS subsystem. Now with regard to "b", the system is + * confident that the user is outside. But with regard to "a" is not confident + * whether it is inside or outside the geofence. If the accuracy remains the + * same for a sufficient period of time, the UNCERTAIN transition would be + * triggered with the state set to Unknown. If the accuracy improves later, an + * appropriate transition should be triggered. This "sufficient period of time" + * is defined by the parameter in the add_geofence_area API. + * In other words, Unknown state can be interpreted as a state in which the + * GPS subsystem isn't confident enough that the user is either inside or + * outside the Geofence. It moves to Unknown state only after the expiry of the + * timeout. + * + * The geofence callback needs to be triggered for the ENTERED and EXITED + * transitions, when the GPS system is confident that the user has entered + * (Inside state) or exited (Outside state) the Geofence. An implementation + * which uses a value of 95% as the confidence is recommended. The callback + * should be triggered only for the transitions requested by the + * add_geofence_area call. + * + * Even though the diagram and explanation talks about states and transitions, + * the callee is only interested in the transistions. The states are mentioned + * here for illustrative purposes. + * + * Startup Scenario: When the device boots up, if an application adds geofences, + * and then we get an accurate GPS location fix, it needs to trigger the + * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. + * By default, all the Geofences will be in the Unknown state. + * + * When the GPS system is unavailable, gps_geofence_status_callback should be + * called to inform the upper layers of the same. Similarly, when it becomes + * available the callback should be called. This is a global state while the + * UNKNOWN transition described above is per geofence. + * + * An important aspect to note is that users of this API (framework), will use + * other subsystems like wifi, sensors, cell to handle Unknown case and + * hopefully provide a definitive state transition to the third party + * application. GPS Geofence will just be a signal indicating what the GPS + * subsystem knows about the Geofence. + * + */ + +/** + * The callback associated with the geofence. + * Parameters: + * geofence_id - The id associated with the add_geofence_area. + * location - The current GPS location. + * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED, + * GPS_GEOFENCE_UNCERTAIN. + * timestamp - Timestamp when the transition was detected. + * + * The callback should only be called when the caller is interested in that + * particular transition. For instance, if the caller is interested only in + * ENTERED transition, then the callback should NOT be called with the EXITED + * transition. + * + * IMPORTANT: If a transition is triggered resulting in this callback, the GPS + * subsystem will wake up the application processor, if its in suspend state. + */ +typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location, + int32_t transition, GpsUtcTime timestamp); + +/** + * The callback associated with the availability of the GPS system for geofencing + * monitoring. If the GPS system determines that it cannot monitor geofences + * because of lack of reliability or unavailability of the GPS signals, it will + * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter. + * + * Parameters: + * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE. + * last_location - Last known location. + */ +typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location); + +/** + * The callback associated with the add_geofence call. + * + * Parameter: + * geofence_id - Id of the geofence. + * status - GPS_GEOFENCE_OPERATION_SUCCESS + * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. + * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists + * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an + * invalid transition + * GPS_GEOFENCE_ERROR_GENERIC - for other errors. + */ +typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status); + +/** + * The callback associated with the remove_geofence call. + * + * Parameter: + * geofence_id - Id of the geofence. + * status - GPS_GEOFENCE_OPERATION_SUCCESS + * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id + * GPS_GEOFENCE_ERROR_GENERIC for others. + */ +typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status); + + +/** + * The callback associated with the pause_geofence call. + * + * Parameter: + * geofence_id - Id of the geofence. + * status - GPS_GEOFENCE_OPERATION_SUCCESS + * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id + * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - + * when monitor_transitions is invalid + * GPS_GEOFENCE_ERROR_GENERIC for others. + */ +typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status); + +/** + * The callback associated with the resume_geofence call. + * + * Parameter: + * geofence_id - Id of the geofence. + * status - GPS_GEOFENCE_OPERATION_SUCCESS + * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id + * GPS_GEOFENCE_ERROR_GENERIC for others. + */ +typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status); + +typedef struct { + gps_geofence_transition_callback geofence_transition_callback; + gps_geofence_status_callback geofence_status_callback; + gps_geofence_add_callback geofence_add_callback; + gps_geofence_remove_callback geofence_remove_callback; + gps_geofence_pause_callback geofence_pause_callback; + gps_geofence_resume_callback geofence_resume_callback; + gps_create_thread create_thread_cb; +} GpsGeofenceCallbacks; + +/** Extended interface for GPS_Geofencing support */ +typedef struct { + /** set to sizeof(GpsGeofencingInterface) */ + size_t size; + + /** + * Opens the geofence interface and provides the callback routines + * to the implementation of this interface. + */ + void (*init)( GpsGeofenceCallbacks* callbacks ); + + /** + * Add a geofence area. This api currently supports circular geofences. + * Parameters: + * geofence_id - The id for the geofence. If a geofence with this id + * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS) + * should be returned. + * latitude, longtitude, radius_meters - The lat, long and radius + * (in meters) for the geofence + * last_transition - The current state of the geofence. For example, if + * the system already knows that the user is inside the geofence, + * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it + * will be GPS_GEOFENCE_UNCERTAIN. + * monitor_transition - Which transitions to monitor. Bitwise OR of + * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and + * GPS_GEOFENCE_UNCERTAIN. + * notification_responsiveness_ms - Defines the best-effort description + * of how soon should the callback be called when the transition + * associated with the Geofence is triggered. For instance, if set + * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback + * should be called 1000 milliseconds within entering the geofence. + * This parameter is defined in milliseconds. + * NOTE: This is not to be confused with the rate that the GPS is + * polled at. It is acceptable to dynamically vary the rate of + * sampling the GPS for power-saving reasons; thus the rate of + * sampling may be faster or slower than this. + * unknown_timer_ms - The time limit after which the UNCERTAIN transition + * should be triggered. This parameter is defined in milliseconds. + * See above for a detailed explanation. + */ + void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude, + double radius_meters, int last_transition, int monitor_transitions, + int notification_responsiveness_ms, int unknown_timer_ms); + + /** + * Pause monitoring a particular geofence. + * Parameters: + * geofence_id - The id for the geofence. + */ + void (*pause_geofence) (int32_t geofence_id); + + /** + * Resume monitoring a particular geofence. + * Parameters: + * geofence_id - The id for the geofence. + * monitor_transitions - Which transitions to monitor. Bitwise OR of + * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and + * GPS_GEOFENCE_UNCERTAIN. + * This supersedes the value associated provided in the + * add_geofence_area call. + */ + void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); + + /** + * Remove a geofence area. After the function returns, no notifications + * should be sent. + * Parameter: + * geofence_id - The id for the geofence. + */ + void (*remove_geofence_area) (int32_t geofence_id); +} GpsGeofencingInterface; + +/** + * Legacy struct to represent an estimate of the GPS clock time. + * Deprecated, to be removed in the next Android release. + * Use GnssClock instead. + */ +typedef struct { + /** set to sizeof(GpsClock) */ + size_t size; + GpsClockFlags flags; + int16_t leap_second; + GpsClockType type; + int64_t time_ns; + double time_uncertainty_ns; + int64_t full_bias_ns; + double bias_ns; + double bias_uncertainty_ns; + double drift_nsps; + double drift_uncertainty_nsps; +} GpsClock; + +/** + * Represents an estimate of the GPS clock time. + */ +typedef struct { + /** set to sizeof(GnssClock) */ + size_t size; + + /** + * A set of flags indicating the validity of the fields in this data + * structure. + */ + GnssClockFlags flags; + + /** + * Leap second data. + * The sign of the value is defined by the following equation: + * utc_time_ns = time_ns - (full_bias_ns + bias_ns) - leap_second * + * 1,000,000,000 + * + * If the data is available 'flags' must contain GNSS_CLOCK_HAS_LEAP_SECOND. + */ + int16_t leap_second; + + /** + * The GNSS receiver internal clock value. This is the local hardware clock + * value. + * + * For local hardware clock, this value is expected to be monotonically + * increasing while the hardware clock remains power on. (For the case of a + * HW clock that is not continuously on, see the + * hw_clock_discontinuity_count field). The receiver's estimate of GPS time + * can be derived by substracting the sum of full_bias_ns and bias_ns (when + * available) from this value. + * + * This GPS time is expected to be the best estimate of current GPS time + * that GNSS receiver can achieve. + * + * Sub-nanosecond accuracy can be provided by means of the 'bias_ns' field. + * The value contains the 'time uncertainty' in it. + * + * This field is mandatory. + */ + int64_t time_ns; + + /** + * 1-Sigma uncertainty associated with the clock's time in nanoseconds. + * The uncertainty is represented as an absolute (single sided) value. + * + * If the data is available, 'flags' must contain + * GNSS_CLOCK_HAS_TIME_UNCERTAINTY. This value is effectively zero (it is + * the reference local clock, by which all other times and time + * uncertainties are measured.) (And thus this field can be not provided, + * per GNSS_CLOCK_HAS_TIME_UNCERTAINTY flag, or provided & set to 0.) + */ + double time_uncertainty_ns; + + /** + * The difference between hardware clock ('time' field) inside GPS receiver + * and the true GPS time since 0000Z, January 6, 1980, in nanoseconds. + * + * The sign of the value is defined by the following equation: + * local estimate of GPS time = time_ns - (full_bias_ns + bias_ns) + * + * This value is mandatory if the receiver has estimated GPS time. If the + * computed time is for a non-GPS constellation, the time offset of that + * constellation to GPS has to be applied to fill this value. The error + * estimate for the sum of this and the bias_ns is the bias_uncertainty_ns, + * and the caller is responsible for using this uncertainty (it can be very + * large before the GPS time has been solved for.) If the data is available + * 'flags' must contain GNSS_CLOCK_HAS_FULL_BIAS. + */ + int64_t full_bias_ns; + + /** + * Sub-nanosecond bias. + * The error estimate for the sum of this and the full_bias_ns is the + * bias_uncertainty_ns + * + * If the data is available 'flags' must contain GNSS_CLOCK_HAS_BIAS. If GPS + * has computed a position fix. This value is mandatory if the receiver has + * estimated GPS time. + */ + double bias_ns; + + /** + * 1-Sigma uncertainty associated with the local estimate of GPS time (clock + * bias) in nanoseconds. The uncertainty is represented as an absolute + * (single sided) value. + * + * If the data is available 'flags' must contain + * GNSS_CLOCK_HAS_BIAS_UNCERTAINTY. This value is mandatory if the receiver + * has estimated GPS time. + */ + double bias_uncertainty_ns; + + /** + * The clock's drift in nanoseconds (per second). + * + * A positive value means that the frequency is higher than the nominal + * frequency, and that the (full_bias_ns + bias_ns) is growing more positive + * over time. + * + * The value contains the 'drift uncertainty' in it. + * If the data is available 'flags' must contain GNSS_CLOCK_HAS_DRIFT. + * + * This value is mandatory if the receiver has estimated GNSS time + */ + double drift_nsps; + + /** + * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second). + * The uncertainty is represented as an absolute (single sided) value. + * + * If the data is available 'flags' must contain + * GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY. If GPS has computed a position fix this + * field is mandatory and must be populated. + */ + double drift_uncertainty_nsps; + + /** + * When there are any discontinuities in the HW clock, this field is + * mandatory. + * + * A "discontinuity" is meant to cover the case of a switch from one source + * of clock to another. A single free-running crystal oscillator (XO) + * should generally not have any discontinuities, and this can be set and + * left at 0. + * + * If, however, the time_ns value (HW clock) is derived from a composite of + * sources, that is not as smooth as a typical XO, or is otherwise stopped & + * restarted, then this value shall be incremented each time a discontinuity + * occurs. (E.g. this value may start at zero at device boot-up and + * increment each time there is a change in clock continuity. In the + * unlikely event that this value reaches full scale, rollover (not + * clamping) is required, such that this value continues to change, during + * subsequent discontinuity events.) + * + * While this number stays the same, between GnssClock reports, it can be + * safely assumed that the time_ns value has been running continuously, e.g. + * derived from a single, high quality clock (XO like, or better, that's + * typically used during continuous GNSS signal sampling.) + * + * It is expected, esp. during periods where there are few GNSS signals + * available, that the HW clock be discontinuity-free as long as possible, + * as this avoids the need to use (waste) a GNSS measurement to fully + * re-solve for the GPS clock bias and drift, when using the accompanying + * measurements, from consecutive GnssData reports. + */ + uint32_t hw_clock_discontinuity_count; + +} GnssClock; + +/** + * Legacy struct to represent a GPS Measurement, it contains raw and computed + * information. + * Deprecated, to be removed in the next Android release. + * Use GnssMeasurement instead. + */ +typedef struct { + /** set to sizeof(GpsMeasurement) */ + size_t size; + GpsMeasurementFlags flags; + int8_t prn; + double time_offset_ns; + GpsMeasurementState state; + int64_t received_gps_tow_ns; + int64_t received_gps_tow_uncertainty_ns; + double c_n0_dbhz; + double pseudorange_rate_mps; + double pseudorange_rate_uncertainty_mps; + GpsAccumulatedDeltaRangeState accumulated_delta_range_state; + double accumulated_delta_range_m; + double accumulated_delta_range_uncertainty_m; + double pseudorange_m; + double pseudorange_uncertainty_m; + double code_phase_chips; + double code_phase_uncertainty_chips; + float carrier_frequency_hz; + int64_t carrier_cycles; + double carrier_phase; + double carrier_phase_uncertainty; + GpsLossOfLock loss_of_lock; + int32_t bit_number; + int16_t time_from_last_bit_ms; + double doppler_shift_hz; + double doppler_shift_uncertainty_hz; + GpsMultipathIndicator multipath_indicator; + double snr_db; + double elevation_deg; + double elevation_uncertainty_deg; + double azimuth_deg; + double azimuth_uncertainty_deg; + bool used_in_fix; +} GpsMeasurement; + +/** + * Represents a GNSS Measurement, it contains raw and computed information. + * + * Independence - All signal measurement information (e.g. sv_time, + * pseudorange_rate, multipath_indicator) reported in this struct should be + * based on GNSS signal measurements only. You may not synthesize measurements + * by calculating or reporting expected measurements based on known or estimated + * position, velocity, or time. + */ +typedef struct { + /** set to sizeof(GpsMeasurement) */ + size_t size; + + /** A set of flags indicating the validity of the fields in this data structure. */ + GnssMeasurementFlags flags; + + /** + * Satellite vehicle ID number, as defined in GnssSvInfo::svid + * This is a mandatory value. + */ + int16_t svid; + + /** + * Defines the constellation of the given SV. Value should be one of those + * GNSS_CONSTELLATION_* constants + */ + GnssConstellationType constellation; + + /** + * Time offset at which the measurement was taken in nanoseconds. + * The reference receiver's time is specified by GpsData::clock::time_ns and should be + * interpreted in the same way as indicated by GpsClock::type. + * + * The sign of time_offset_ns is given by the following equation: + * measurement time = GpsClock::time_ns + time_offset_ns + * + * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy. + * This is a mandatory value. + */ + double time_offset_ns; + + /** + * Per satellite sync state. It represents the current sync state for the associated satellite. + * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly. + * + * This is a mandatory value. + */ + GnssMeasurementState state; + + /** + * The received GNSS Time-of-Week at the measurement time, in nanoseconds. + * Ensure that this field is independent (see comment at top of + * GnssMeasurement struct.) + * + * For GPS & QZSS, this is: + * Received GPS Time-of-Week at the measurement time, in nanoseconds. + * The value is relative to the beginning of the current GPS week. + * + * Given the highest sync state that can be achieved, per each satellite, valid range + * for this field can be: + * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN + * C/A code lock : [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set + * Bit sync : [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set + * Subframe sync : [ 0 6s ] : GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set + * TOW decoded : [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set + * + * Note well: if there is any ambiguity in integer millisecond, + * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field. + * + * This value must be populated if 'state' != GNSS_MEASUREMENT_STATE_UNKNOWN. + * + * For Glonass, this is: + * Received Glonass time of day, at the measurement time in nanoseconds. + * + * Given the highest sync state that can be achieved, per each satellite, valid range for + * this field can be: + * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN + * C/A code lock : [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set + * Symbol sync : [ 0 10ms ] : GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set + * Bit sync : [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set + * String sync : [ 0 2s ] : GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC is set + * Time of day : [ 0 1day ] : GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED is set + * + * For Beidou, this is: + * Received Beidou time of week, at the measurement time in nanoseconds. + * + * Given the highest sync state that can be achieved, per each satellite, valid range for + * this field can be: + * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN + * C/A code lock: [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set + * Bit sync (D2): [ 0 2ms ] : GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC is set + * Bit sync (D1): [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set + * Subframe (D2): [ 0 0.6s ] : GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC is set + * Subframe (D1): [ 0 6s ] : GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set + * Time of week : [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set + * + * For Galileo, this is: + * Received Galileo time of week, at the measurement time in nanoseconds. + * + * E1BC code lock : [ 0 4ms ] : GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK is set + * E1C 2nd code lock: [ 0 100ms ] : + * GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK is set + * + * E1B page : [ 0 2s ] : GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC is set + * Time of week: [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set + * + * For SBAS, this is: + * Received SBAS time, at the measurement time in nanoseconds. + * + * Given the highest sync state that can be achieved, per each satellite, + * valid range for this field can be: + * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN + * C/A code lock: [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set + * Symbol sync : [ 0 2ms ] : GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set + * Message : [ 0 1s ] : GNSS_MEASUREMENT_STATE_SBAS_SYNC is set + */ + int64_t received_sv_time_in_ns; + + /** + * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds. + * + * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN. + */ + int64_t received_sv_time_uncertainty_in_ns; + + /** + * Carrier-to-noise density in dB-Hz, typically in the range [0, 63]. + * It contains the measured C/N0 value for the signal at the antenna port. + * + * This is a mandatory value. + */ + double c_n0_dbhz; + + /** + * Pseudorange rate at the timestamp in m/s. The correction of a given + * Pseudorange Rate value includes corrections for receiver and satellite + * clock frequency errors. Ensure that this field is independent (see + * comment at top of GnssMeasurement struct.) + * + * It is mandatory to provide the 'uncorrected' 'pseudorange rate', and provide GpsClock's + * 'drift' field as well (When providing the uncorrected pseudorange rate, do not apply the + * corrections described above.) + * + * The value includes the 'pseudorange rate uncertainty' in it. + * A positive 'uncorrected' value indicates that the SV is moving away from the receiver. + * + * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler + * shift' is given by the equation: + * pseudorange rate = -k * doppler shift (where k is a constant) + * + * This should be the most accurate pseudorange rate available, based on + * fresh signal measurements from this channel. + * + * It is mandatory that this value be provided at typical carrier phase PRR + * quality (few cm/sec per second of uncertainty, or better) - when signals + * are sufficiently strong & stable, e.g. signals from a GPS simulator at >= + * 35 dB-Hz. + */ + double pseudorange_rate_mps; + + /** + * 1-Sigma uncertainty of the pseudorange_rate_mps. + * The uncertainty is represented as an absolute (single sided) value. + * + * This is a mandatory value. + */ + double pseudorange_rate_uncertainty_mps; + + /** + * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip + * (indicating loss of lock). + * + * This is a mandatory value. + */ + GnssAccumulatedDeltaRangeState accumulated_delta_range_state; + + /** + * Accumulated delta range since the last channel reset in meters. + * A positive value indicates that the SV is moving away from the receiver. + * + * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase' + * is given by the equation: + * accumulated delta range = -k * carrier phase (where k is a constant) + * + * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. + * However, it is expected that the data is only accurate when: + * 'accumulated delta range state' == GPS_ADR_STATE_VALID. + */ + double accumulated_delta_range_m; + + /** + * 1-Sigma uncertainty of the accumulated delta range in meters. + * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. + */ + double accumulated_delta_range_uncertainty_m; + + /** + * Carrier frequency at which codes and messages are modulated, it can be L1 or L2. + * If the field is not set, the carrier frequency is assumed to be L1. + * + * If the data is available, 'flags' must contain + * GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY. + */ + float carrier_frequency_hz; + + /** + * The number of full carrier cycles between the satellite and the receiver. + * The reference frequency is given by the field 'carrier_frequency_hz'. + * Indications of possible cycle slips and resets in the accumulation of + * this value can be inferred from the accumulated_delta_range_state flags. + * + * If the data is available, 'flags' must contain + * GNSS_MEASUREMENT_HAS_CARRIER_CYCLES. + */ + int64_t carrier_cycles; + + /** + * The RF phase detected by the receiver, in the range [0.0, 1.0]. + * This is usually the fractional part of the complete carrier phase measurement. + * + * The reference frequency is given by the field 'carrier_frequency_hz'. + * The value contains the 'carrier-phase uncertainty' in it. + * + * If the data is available, 'flags' must contain + * GNSS_MEASUREMENT_HAS_CARRIER_PHASE. + */ + double carrier_phase; + + /** + * 1-Sigma uncertainty of the carrier-phase. + * If the data is available, 'flags' must contain + * GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY. + */ + double carrier_phase_uncertainty; + + /** + * An enumeration that indicates the 'multipath' state of the event. + * + * The multipath Indicator is intended to report the presence of overlapping + * signals that manifest as distorted correlation peaks. + * + * - if there is a distorted correlation peak shape, report that multipath + * is GNSS_MULTIPATH_INDICATOR_PRESENT. + * - if there is not a distorted correlation peak shape, report + * GNSS_MULTIPATH_INDICATOR_NOT_PRESENT + * - if signals are too weak to discern this information, report + * GNSS_MULTIPATH_INDICATOR_UNKNOWN + * + * Example: when doing the standardized overlapping Multipath Performance + * test (3GPP TS 34.171) the Multipath indicator should report + * GNSS_MULTIPATH_INDICATOR_PRESENT for those signals that are tracked, and + * contain multipath, and GNSS_MULTIPATH_INDICATOR_NOT_PRESENT for those + * signals that are tracked and do not contain multipath. + */ + GnssMultipathIndicator multipath_indicator; + + /** + * Signal-to-noise ratio at correlator output in dB. + * If the data is available, 'flags' must contain GNSS_MEASUREMENT_HAS_SNR. + * This is the power ratio of the "correlation peak height above the + * observed noise floor" to "the noise RMS". + */ + double snr_db; +} GnssMeasurement; + +/** + * Legacy struct to represents a reading of GPS measurements. + * Deprecated, to be removed in the next Android release. + * Use GnssData instead. + */ +typedef struct { + /** set to sizeof(GpsData) */ + size_t size; + size_t measurement_count; + GpsMeasurement measurements[GPS_MAX_MEASUREMENT]; + + /** The GPS clock time reading. */ + GpsClock clock; +} GpsData; + +/** + * Represents a reading of GNSS measurements. For devices where GnssSystemInfo's + * year_of_hw is set to 2016+, it is mandatory that these be provided, on + * request, when the GNSS receiver is searching/tracking signals. + * + * - Reporting of GPS constellation measurements is mandatory. + * - Reporting of all tracked constellations are encouraged. + */ +typedef struct { + /** set to sizeof(GnssData) */ + size_t size; + + /** Number of measurements. */ + size_t measurement_count; + + /** The array of measurements. */ + GnssMeasurement measurements[GNSS_MAX_MEASUREMENT]; + + /** The GPS clock time reading. */ + GnssClock clock; +} GnssData; + +/** + * The legacy callback for to report measurements from the HAL. + * + * This callback is deprecated, and will be removed in the next release. Use + * gnss_measurement_callback() instead. + * + * Parameters: + * data - A data structure containing the measurements. + */ +typedef void (*gps_measurement_callback) (GpsData* data); + +/** + * The callback for to report measurements from the HAL. + * + * Parameters: + * data - A data structure containing the measurements. + */ +typedef void (*gnss_measurement_callback) (GnssData* data); + +typedef struct { + /** set to sizeof(GpsMeasurementCallbacks) */ + size_t size; + gps_measurement_callback measurement_callback; + gnss_measurement_callback gnss_measurement_callback; +} GpsMeasurementCallbacks; + +/** + * Extended interface for GPS Measurements support. + */ +typedef struct { + /** Set to sizeof(GpsMeasurementInterface) */ + size_t size; + + /** + * Initializes the interface and registers the callback routines with the HAL. + * After a successful call to 'init' the HAL must begin to provide updates at its own phase. + * + * Status: + * GPS_MEASUREMENT_OPERATION_SUCCESS + * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a + * corresponding call to 'close' + * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL + * will not generate any updates upon returning this error code. + */ + int (*init) (GpsMeasurementCallbacks* callbacks); + + /** + * Stops updates from the HAL, and unregisters the callback routines. + * After a call to stop, the previously registered callbacks must be considered invalid by the + * HAL. + * If stop is invoked without a previous 'init', this function should perform no work. + */ + void (*close) (); + +} GpsMeasurementInterface; + +/** + * Legacy struct to represents a GPS navigation message (or a fragment of it). + * Deprecated, to be removed in the next Android release. + * Use GnssNavigationMessage instead. + */ +typedef struct { + /** set to sizeof(GpsNavigationMessage) */ + size_t size; + int8_t prn; + GpsNavigationMessageType type; + NavigationMessageStatus status; + int16_t message_id; + int16_t submessage_id; + size_t data_length; + uint8_t* data; +} GpsNavigationMessage; + +/** Represents a GPS navigation message (or a fragment of it). */ +typedef struct { + /** set to sizeof(GnssNavigationMessage) */ + size_t size; + + /** + * Satellite vehicle ID number, as defined in GnssSvInfo::svid + * This is a mandatory value. + */ + int16_t svid; + + /** + * The type of message contained in the structure. + * This is a mandatory value. + */ + GnssNavigationMessageType type; + + /** + * The status of the received navigation message. + * No need to send any navigation message that contains words with parity error and cannot be + * corrected. + */ + NavigationMessageStatus status; + + /** + * Message identifier. It provides an index so the complete Navigation + * Message can be assembled. + * + * - For GPS L1 C/A subframe 4 and 5, this value corresponds to the 'frame + * id' of the navigation message, in the range of 1-25 (Subframe 1, 2, 3 + * does not contain a 'frame id' and this value can be set to -1.) + * + * - For Glonass L1 C/A, this refers to the frame ID, in the range of 1-5. + * + * - For BeiDou D1, this refers to the frame number in the range of 1-24 + * + * - For Beidou D2, this refers to the frame number, in the range of 1-120 + * + * - For Galileo F/NAV nominal frame structure, this refers to the subframe + * number, in the range of 1-12 + * + * - For Galileo I/NAV nominal frame structure, this refers to the subframe + * number in the range of 1-24 + */ + int16_t message_id; + + /** + * Sub-message identifier. If required by the message 'type', this value + * contains a sub-index within the current message (or frame) that is being + * transmitted. + * + * - For GPS L1 C/A, BeiDou D1 & BeiDou D2, the submessage id corresponds to + * the subframe number of the navigation message, in the range of 1-5. + * + * - For Glonass L1 C/A, this refers to the String number, in the range from + * 1-15 + * + * - For Galileo F/NAV, this refers to the page type in the range 1-6 + * + * - For Galileo I/NAV, this refers to the word type in the range 1-10+ + */ + int16_t submessage_id; + + /** + * The length of the data (in bytes) contained in the current message. + * If this value is different from zero, 'data' must point to an array of the same size. + * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word). + * + * This is a mandatory value. + */ + size_t data_length; + + /** + * The data of the reported GPS message. The bytes (or words) specified + * using big endian format (MSB first). + * + * - For GPS L1 C/A, Beidou D1 & Beidou D2, each subframe contains 10 30-bit + * words. Each word (30 bits) should be fit into the last 30 bits in a + * 4-byte word (skip B31 and B32), with MSB first, for a total of 40 + * bytes, covering a time period of 6, 6, and 0.6 seconds, respectively. + * + * - For Glonass L1 C/A, each string contains 85 data bits, including the + * checksum. These bits should be fit into 11 bytes, with MSB first (skip + * B86-B88), covering a time period of 2 seconds. + * + * - For Galileo F/NAV, each word consists of 238-bit (sync & tail symbols + * excluded). Each word should be fit into 30-bytes, with MSB first (skip + * B239, B240), covering a time period of 10 seconds. + * + * - For Galileo I/NAV, each page contains 2 page parts, even and odd, with + * a total of 2x114 = 228 bits, (sync & tail excluded) that should be fit + * into 29 bytes, with MSB first (skip B229-B232). + */ + uint8_t* data; + +} GnssNavigationMessage; + +/** + * The legacy callback to report an available fragment of a GPS navigation + * messages from the HAL. + * + * This callback is deprecated, and will be removed in the next release. Use + * gnss_navigation_message_callback() instead. + * + * Parameters: + * message - The GPS navigation submessage/subframe representation. + */ +typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message); + +/** + * The callback to report an available fragment of a GPS navigation messages from the HAL. + * + * Parameters: + * message - The GPS navigation submessage/subframe representation. + */ +typedef void (*gnss_navigation_message_callback) (GnssNavigationMessage* message); + +typedef struct { + /** set to sizeof(GpsNavigationMessageCallbacks) */ + size_t size; + gps_navigation_message_callback navigation_message_callback; + gnss_navigation_message_callback gnss_navigation_message_callback; +} GpsNavigationMessageCallbacks; + +/** + * Extended interface for GPS navigation message reporting support. + */ +typedef struct { + /** Set to sizeof(GpsNavigationMessageInterface) */ + size_t size; + + /** + * Initializes the interface and registers the callback routines with the HAL. + * After a successful call to 'init' the HAL must begin to provide updates as they become + * available. + * + * Status: + * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS + * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered + * without a corresponding call to 'close'. + * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that + * the HAL will not generate any updates upon returning this error code. + */ + int (*init) (GpsNavigationMessageCallbacks* callbacks); + + /** + * Stops updates from the HAL, and unregisters the callback routines. + * After a call to stop, the previously registered callbacks must be considered invalid by the + * HAL. + * If stop is invoked without a previous 'init', this function should perform no work. + */ + void (*close) (); + +} GpsNavigationMessageInterface; + +/** + * Interface for passing GNSS configuration contents from platform to HAL. + */ +typedef struct { + /** Set to sizeof(GnssConfigurationInterface) */ + size_t size; + + /** + * Deliver GNSS configuration contents to HAL. + * Parameters: + * config_data - a pointer to a char array which holds what usually is expected from + file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'. + * length - total number of UTF8 characters in configuraiton data. + * + * IMPORTANT: + * GPS HAL should expect this function can be called multiple times. And it may be + * called even when GpsLocationProvider is already constructed and enabled. GPS HAL + * should maintain the existing requests for various callback regardless the change + * in configuration data. + */ + void (*configuration_update) (const char* config_data, int32_t length); +} GnssConfigurationInterface; + +__END_DECLS + +#endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */ diff --git a/init/init_viennalte.cpp b/init/init_viennalte.cpp index 617b694..c162b71 100755 --- a/init/init_viennalte.cpp +++ b/init/init_viennalte.cpp @@ -31,13 +31,17 @@ #include #include -#include "vendor_init.h" +#include +#include + #include "property_service.h" -#include "log.h" -#include "util.h" +#include "vendor_init.h" #include "init_msm8974.h" +using android::base::GetProperty; +using android::init::property_set; + void init_target_properties() { property_override("ro.build.fingerprint", "samsung/viennaltexx/viennalte:5.0.2/LRX22G/P905XXUABPE2:user/release-keys"); diff --git a/libsecnativefeature/Android.mk b/libsecnativefeature/Android.mk new file mode 100755 index 0000000..2276655 --- /dev/null +++ b/libsecnativefeature/Android.mk @@ -0,0 +1,20 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := \ + SecNativeFeatureCIf.cpp \ + SecNativeFeatureCppIf.cpp + +LOCAL_C_INCLUDES += \ + external/expat/lib + +LOCAL_SHARED_LIBRARIES := \ + libexpat + +LOCAL_CFLAGS := -Wall -Werror + +LOCAL_MODULE := libsecnativefeature + +include $(BUILD_SHARED_LIBRARY) diff --git a/libsecnativefeature/SecNativeFeature.h b/libsecnativefeature/SecNativeFeature.h new file mode 100755 index 0000000..4de0283 --- /dev/null +++ b/libsecnativefeature/SecNativeFeature.h @@ -0,0 +1,31 @@ +#ifndef SEC_NATIVE_FEATURE_H +#define SEC_NATIVE_FEATURE_H + +#include "SecNativeFeatureTagAll.h" + +// define TAG for default value +/* +#define Str_NoTag "" +#define Bool_NoTag false +#define Int_NoTag (0) + +#define TAG_BOOLEAN_TEST_TRUE "CscFeature_BooleanTestTrue" +#define TAG_BOOLEAN_TEST_FALSE "CscFeature_BooleanTestFalse" +#define TAG_BOOLEAN_TEST_NULL "CscFeature_BooleanTestNull" +#define TAG_STRING_TEST "CscFeature_StringTest" +#define TAG_STRING_TEST_NULL "CscFeature_StringTestNull" +#define TAG_INTEGER_TEST "CscFeature_IntegerTest" +#define TAG_INTEGER_TEST_NULL "CscFeature_IntegerTestNull" + +#define TAG_FMRADIO_RTPLUS "CscFeature_FMRadioRTPlus" +#define TAG_FMRADIO_SEASETTING "CscFeature_FMRadioSEASetting" +*/ + +#ifdef __cplusplus +#include "SecNativeFeatureCppIf.h" +#else +#include "SecNativeFeatureCIf.h" +#endif + +#endif // SEC_NATIVE_FEATURE_H + diff --git a/libsecnativefeature/SecNativeFeatureCIf.cpp b/libsecnativefeature/SecNativeFeatureCIf.cpp new file mode 100755 index 0000000..88a5405 --- /dev/null +++ b/libsecnativefeature/SecNativeFeatureCIf.cpp @@ -0,0 +1,85 @@ +#include +#include +#include "SecNativeFeatureCppIf.h" +#include "SecNativeFeatureCIf.h" +#include +#include + + +int +SecNativeFeature_getEnableStatus(const char* tag) +{ + SecNativeFeature* instance = SecNativeFeature::getInstance(); + + if (instance) + { + return instance->getEnableStatus(tag); + } + + return 0; +} + +int +SecNativeFeature_getEnableStatusWithDefault(const char* tag, int defaultValue) +{ + SecNativeFeature* instance = SecNativeFeature::getInstance(); + + if (instance) + { + return instance->getEnableStatus(tag, defaultValue); + } + + return defaultValue; +} + +int +SecNativeFeature_getInteger(const char* tag) +{ + SecNativeFeature* instance = SecNativeFeature::getInstance(); + + if (instance) + { + return instance->getInteger(tag); + } + + return -1; +} + +int +SecNativeFeature_getIntegerWithDefault(const char* tag, int defaultValue) +{ + SecNativeFeature* instance = SecNativeFeature::getInstance(); + + if (instance) + { + return instance->getInteger(tag, defaultValue); + } + + return defaultValue; +} + +const char* +SecNativeFeature_getString(const char* tag) +{ + SecNativeFeature* instance = SecNativeFeature::getInstance(); + + if (instance) + { + return instance->getString(tag); + } + + return NULL; +} + +const char* +SecNativeFeature_getStringWithDefault(const char* tag, char* defaultValue) +{ + SecNativeFeature* instance = SecNativeFeature::getInstance(); + + if (instance) + { + return instance->getString(tag, defaultValue); + } + + return defaultValue; +} diff --git a/libsecnativefeature/SecNativeFeatureCIf.h b/libsecnativefeature/SecNativeFeatureCIf.h new file mode 100755 index 0000000..3d26168 --- /dev/null +++ b/libsecnativefeature/SecNativeFeatureCIf.h @@ -0,0 +1,24 @@ +#ifndef SEC_NATIVE_FEATURE_CIF_H +#define SEC_NATIVE_FEATURE_CIF_H + +#ifdef __cplusplus +#define DECLARE_BEGIN_C extern "C" { +#define DECLARE_END_C } +#else +#define DECLARE_BEGIN_C +#define DECLARE_END_C +#endif + +DECLARE_BEGIN_C + +int SecNativeFeature_getEnableStatus(const char* tag); +int SecNativeFeature_getEnableStatusWithDefault(const char* tag, int defaultValue); +int SecNativeFeature_getInteger(const char* tag); +int SecNativeFeature_getIntegerWithDefault(const char* tag, int defaultValue); +const char* SecNativeFeature_getString(const char* tag); +const char* SecNativeFeature_getStringWithDefault(const char* tag, char* defaultValue); + +DECLARE_END_C + +#endif // SEC_NATIVE_FEATURE_CIF_H + diff --git a/libsecnativefeature/SecNativeFeatureCppIf.cpp b/libsecnativefeature/SecNativeFeatureCppIf.cpp new file mode 100755 index 0000000..d70ebe7 --- /dev/null +++ b/libsecnativefeature/SecNativeFeatureCppIf.cpp @@ -0,0 +1,187 @@ +#include +#include +#include "SecNativeFeatureCppIf.h" +#include +#include + +// feature file location (which should be "/system/csc/feature.xml") +#define FEATURE_FILE "/system/csc/feature.xml" +// feature file location (which should be "/system/csc/others.xml") +#define MPS_FEATURE_FILE "/system/csc/others.xml" + +// XML parsing using expat lib - handlers +typedef struct{ + std::string curr_name; + std::map *pFeatures; + int depth; +} ParserUserData; + +static void XMLCALL +charDataHandler(void *userData, const char *s, int len){ + ParserUserData* pData = (ParserUserData*)userData; + std::string value(s, len); + std::string curr_name = pData->curr_name; + + if(!curr_name.empty()){ + std::map::iterator result = (*pData->pFeatures).find(curr_name); + + if (result != (*pData->pFeatures).end()) { + value = result->second + value; + (*pData->pFeatures).erase(curr_name); + } + + std::map::iterator begin; + begin = (*pData->pFeatures).begin(); + std::pair feature(curr_name,value); + (*pData->pFeatures).insert(begin, feature); + } + // else{ + // // printf("no name\n"); + // } +} + +static void XMLCALL +startElement(void *userData, const char *name, const char **atts __unused) +{ + ParserUserData* pData = (ParserUserData*)userData; + pData->curr_name.assign(name); + pData->depth += 1; +} + +static void XMLCALL +endElement(void *userData, const char *name __unused) +{ + ParserUserData* pData = (ParserUserData*)userData; + pData->curr_name.clear(); + pData->depth -= 1; +} + +// SecNativeFeture class implementation +SecNativeFeature* SecNativeFeature::_instance = NULL; +SecNativeFeature::SecNativeFeature() { + int load_result = 0; + _features.clear(); + load_result = _loadFeature(); + if (load_result == -1){ + // todo : handle _loadFeature errors here. + } +} + +SecNativeFeature::~SecNativeFeature() { + delete _instance; +} +SecNativeFeature* SecNativeFeature::getInstance() { + if(_instance == NULL) { + _instance = new SecNativeFeature(); + } + return _instance; +} + +bool SecNativeFeature::getEnableStatus(const char* tag) { + std::map::iterator found; + found = _features.find(tag); + + if(found == _features.end()) { + return false; + } + + if(found->second.compare("true") == 0 || found->second.compare("TRUE") == 0) { + return true; + } + return false; +} + +bool SecNativeFeature::getEnableStatus(const char* tag, bool defaultValue) { + std::map::iterator found; + found = _features.find(tag); + + if(found == _features.end()) { + return defaultValue; + } + + if(found->second.compare("true") == 0 || found->second.compare("TRUE") == 0) { + return true; + } + return defaultValue; +} + +const char* SecNativeFeature::getString(const char* tag) { + std::map::iterator found; + found = _features.find(tag); + + if(found == _features.end()) { + return ""; + } + return found->second.c_str(); +} + +const char* SecNativeFeature::getString(const char* tag, char* defaultValue) { + std::map::iterator found; + found = _features.find(tag); + + if(found == _features.end()) { + return defaultValue; + } + return found->second.c_str(); +} + +int SecNativeFeature::getInteger(const char* tag) { + std::map::iterator found; + found = _features.find(tag); + + if(found == _features.end()) { + return -1; + } + std::string raw_value = _features.find(tag)->second; + return atoi(raw_value.c_str()); +} + +int SecNativeFeature::getInteger(const char* tag, int defaultValue) { + std::map::iterator found; + found = _features.find(tag); + + if(found == _features.end()) { + return defaultValue; + } + std::string raw_value = _features.find(tag)->second; + return atoi(raw_value.c_str()); +} + +int SecNativeFeature::_loadFeature(){ + char buf[BUFSIZ]; + XML_Parser parser = XML_ParserCreate(NULL); + int done; + FILE * pFeatureFile = NULL; + ParserUserData userData; + userData.curr_name = std::string (); + userData.pFeatures = &_features; + userData.depth = 0; + + pFeatureFile = fopen(FEATURE_FILE, "r"); + if (pFeatureFile == NULL) { + pFeatureFile = fopen(MPS_FEATURE_FILE, "r"); + if (pFeatureFile == NULL) { + return -1; + } + } + XML_SetUserData(parser, &userData); + XML_SetElementHandler(parser, startElement, endElement); + XML_SetCharacterDataHandler(parser, charDataHandler); + do { + size_t len = fread(buf, 1, sizeof(buf), pFeatureFile); + if ((len != sizeof(buf)) && (ferror(pFeatureFile))){ + fclose(pFeatureFile); + return -1; + } + done = len < sizeof(buf); + if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) { + if(pFeatureFile) { + fclose(pFeatureFile); + } + return -1; + } + } while (!done); + XML_ParserFree(parser); + fclose(pFeatureFile); + return 0; +} diff --git a/libsecnativefeature/SecNativeFeatureCppIf.h b/libsecnativefeature/SecNativeFeatureCppIf.h new file mode 100755 index 0000000..37cb085 --- /dev/null +++ b/libsecnativefeature/SecNativeFeatureCppIf.h @@ -0,0 +1,27 @@ +#ifndef SEC_NATIVE_FEATURE_CPPIF_H +#define SEC_NATIVE_FEATURE_CPPIF_H + +#include +#include + +class SecNativeFeature { +public: + bool getEnableStatus(const char* tag); + bool getEnableStatus(const char* tag, bool defaultValue); + const char* getString(const char* tag); + const char* getString(const char* tag, char* defaultValue); + int getInteger(const char* tag); + int getInteger(const char* tag, int defaultValue); + + static SecNativeFeature* getInstance(); +private: + static SecNativeFeature* _instance; + SecNativeFeature(); + ~SecNativeFeature(); + int _loadFeature(); + int _loadDefault(); + std::map _features; +}; + +#endif // SEC_NATIVE_FEATURE_CPPIF_H + diff --git a/libsecnativefeature/SecNativeFeatureTagAll.h b/libsecnativefeature/SecNativeFeatureTagAll.h new file mode 100755 index 0000000..1bbc23f --- /dev/null +++ b/libsecnativefeature/SecNativeFeatureTagAll.h @@ -0,0 +1,20 @@ +/* + * CSC Features + * Auto generated by gen_cscfeaturetag_ih.pl + * DO NOT EDIT THIS FILE + */ + +/* +#include "SecNativeFeatureTagGMS.h" +#include "SecNativeFeatureTagIMS.h" +#include "SecNativeFeatureTagMediaProvider.h" +#include "SecNativeFeatureTagNFC.h" +#include "SecNativeFeatureTagRIL.h" +#include "SecNativeFeatureTagStreaming.h" +#include "SecNativeFeatureTagWiFi.h" +#include "SecNativeFeatureTagBT.h" +*/ + +#include "SecNativeFeatureTagFramework.h" +#include "SecNativeFeatureTagCommon.h" +#include "SecNativeFeatureTagWeb.h" diff --git a/libsecnativefeature/SecNativeFeatureTagCommon.h b/libsecnativefeature/SecNativeFeatureTagCommon.h new file mode 100755 index 0000000..7439806 --- /dev/null +++ b/libsecnativefeature/SecNativeFeatureTagCommon.h @@ -0,0 +1,9 @@ +#ifndef SEC_NATIVE_FEATURE_TAG_COMMON_H +#define SEC_NATIVE_FEATURE_TAG_COMMON_H + +// Note +// The string must be same as the string in CSCFeatureTagCommon.java +// Because one feature coulde be implemented both in java layer and in native layer +#define TAG_CSCFEATURE_COMMON_USECHAMELEON "CscFeature_Common_UseChameleon" + +#endif // SEC_NATIVE_FEATURE_TAG_COMMON_H diff --git a/libsecnativefeature/SecNativeFeatureTagFramework.h b/libsecnativefeature/SecNativeFeatureTagFramework.h new file mode 100755 index 0000000..a29d67c --- /dev/null +++ b/libsecnativefeature/SecNativeFeatureTagFramework.h @@ -0,0 +1,16 @@ +#ifndef SEC_NATIVE_FEATURE_TAG_FRAMEWORK_H +#define SEC_NATIVE_FEATURE_TAG_FRAMEWORK_H + + +// Note +// The string must be same as the string in CSCFeatureTagFramework.java +// Because one feature coulde be implemented both in java layer and in native layer + + +#define TAG_CSCFEATURE_FRAMEWORK_ENABLEBIDIRECTION "CscFeature_Framework_EnableBidirection" + +#define TAG_CSCFEATURE_FRAMEWORK_ENABLEHARFBUZZ "CscFeature_Framework_EnableHarfbuzz" + +#define TAG_CSCFEATURE_FRAMEWORK_ENABLETHAIVIETRESHAPING "CscFeature_Framework_EnableThaiVietReshaping" + +#endif // SEC_NATIVE_FEATURE_TAG_FRAMEWORK_H diff --git a/libsecnativefeature/SecNativeFeatureTagWeb.h b/libsecnativefeature/SecNativeFeatureTagWeb.h new file mode 100755 index 0000000..100448a --- /dev/null +++ b/libsecnativefeature/SecNativeFeatureTagWeb.h @@ -0,0 +1,150 @@ +#ifndef SEC_NATIVE_FEATURE_TAG_WEB_H +#define SEC_NATIVE_FEATURE_TAG_WEB_H + + +// Note +// The string must be same as the string in CSCFeatureTagWeb.java +// Because one feature coulde be implemented both in java layer and in native layer + +// The default values for each types +// This means the specified TAG is not defined +#define CSCFeatureTagWeb_Str_NoTag "" +#define CSCFeatureTagWeb_Bool_NoTag false +#define CSCFeatureTagWeb_Int_NoTag 0 + +// To define custom UserAgent string +// If this value is not defined, the default Android UserAgent will be sent to server +#define CSCFeatureTagWeb_SetUserAgent "CscFeature_Web_SetUserAgent" + + +// To define UAProfile string +// If this value is not defined, UAProfile will not be sent to server +#define CSCFeatureTagWeb_SetUAProfile "CscFeature_Web_SetUAProfile" + +// Change homepage_base regardless language and APN +#define CscFeatureTagWeb_SetHomepageURL "CscFeature_Web_SetHomepageURL" +// Disable RSS button on the url bar +#define CscFeatureTagWeb_DisableRSS "CscFeature_Web_DisableRSS" +// Remove voicesearch button on the url bar +#define CscFeatureTagWeb_DisableVoiceSearch "CscFeature_Web_DisableVoiceSearch" +// Disable showing activity chooser on redirecting in case when 3rd party browser also installed +#define CscFeatureTagWeb_DisableRedirectionChooser "CscFeature_Web_DisableRedirectionChooser" + +// Enable UAProfile in Header +#define CscFeatureTagWeb_Bool_EnableUAProfile "CscFeature_Web_Bool_EnableUAProfile" + +// To Enable the GateConfig Logs(USA STA requirement for stability test) +#define CscFeatureTagWeb_Bool_EnableGateConfig "CscFeature_Web_EnableLogStabililtyTest" + +//add for Handling Operator UA +#define CscFeature_Web_OverrideUserAgent "CscFeature_Web_OverrideUserAgent" + +// add menu clear today history +#define CscFeatureTagWeb_EnableDeletingTodayHistory "CscFeature_Web_EnableDeletingTodayHistory" + + // To enable bookmark overwrite +#define CscFeatureTagWeb_EnableOverwritingBookmark "CscFeature_Web_EnableOverwritingBookmark" + +// To enable downloaded folder notification +#define CscFeatureTagWeb_EnableDownloadedFolderInNotificationBar "CscFeature_Web_EnableDownloadedFolderInNotificationBar" + + //Enable DeviceID at Header(USA ATT Requirement) +#define CscFeatureTag_Web_Bool_DeviceID "CscFeature_Web_UseDeviceIdInHeader" + +// support uploading contacts in VCard format (China-Telecom requirement) +#define CscFeatureTagWeb_SupportVcfUpload "CscFeature_Web_SupportVcfUpload" +//Parse XHTML document as HTML (ignore parse error. China-Telecom requirement) +#define CscFeatureTagWeb_ParseXHtmlToHtml "CscFeature_Web_ParseXHtmlToHtml" + + //Block SD & CD download ( NAGSM common requirement) +#define CscFeatureTag_Web_Bool_BlockSDCDDownload "CscFeature_Web_BlockSDCDDownload" + +// display download progress on notification bar (China-Telecom requirement) +#define CscFeatureTagWeb_ShowDownloadProgressOnNotification "CscFeature_Web_ShowDownloadProgressOnNotification" + +// show browser version in browser settings (China-Telecom requirement) +#define CscFeatureTagWeb_ShowVersionInSetting "CscFeature_Web_ShowVersionInSetting" + +// support "exit browser" option (China-Telecom requirement) +#define CscFeatureTagWeb_AddOptionToTerminate "CscFeature_Web_AddOptionToTerminate" +// Add "Delete-all" function at Download list (China-Telecom requirement) +#define CscFeatureTagWeb_EnableDeleteAllOnDownloadList "CscFeature_Web_EnableDeleteAllOnDownloadList" +// Support save-as function and default folder by mime-type (China-Telecom requirement) +#define CscFeatureTagWeb_SupportDownloadSaveAs "CscFeature_Web_SupportDownloadSaveAs" +// support delete-all option in bookmarks page (China-Telecom requirement) +#define CscFeatureTagWeb_EnableDeleteAllBookmarks "CscFeature_Web_EnableDeleteAllBookmarks" +// Add "FullHandwriting IME issue "(China-Common requirement) +#define CscFeatureTagWeb_EnableOptionEditTextDuringFullHwr "CscFeature_Web_EnableOptionEditTextDuringFullHwr" +// support offline-startup page includes bookmarks, history, search dialog (China-Telecom requirement) +#define CscFeatureTagWeb_SupportOfflineStartupPage "CscFeature_Web_SupportOfflineStartupPage" + +// support not to set factory-reset-homepage to PREF_HOMEPAGE +#define CscFeatureTagWeb_Bool_DisableSetFactoryResetHomeToPrefHome "CscFeature_Web_Bool_DisableSetFactoryResetHomeToPrefHome" + +// Show roaming dialog (ATT Requirement) +#define CscFeatureTagWeb_Bool_ShowRoamingDialog "CscFeature_Web_EnableRoamingDialog" + +// set download folder by mime-type for China-Telecom requirement +#define CscFeatureTagWeb_SetDownloadFolderNameByMimeType "CscFeature_Web_SetDownloadFolderNameByMimeType" + +// Disable showing activity chooser for defined string +#define CscFeature_Web_DisableChooser4 "CscFeature_Web_DisableChooser4" + +// Enable download hebrew filename +#define CscFeature_Web_SupportHebrewFileName "CscFeature_Web_SupportHebrewFileName" + +// remove google in search engine list +#define CscFeatureTagWeb_DisableGoogleInBrowserSearchEngine "CscFeature_Web_DisableGoogleInBrowserSearchEngine" + +// set off overview mode as default (CTC Requirement) +#define CscFeatureTagWeb_SetOffOverviewModeAsDefault "CscFeature_Web_SetOffOverviewModeAsDefault" + +// Disable setting homepage as it is set in APN when SIM changed +#define CscFeature_Web_EnableAutoSimHomeUrlInProfile "CscFeature_Web_EnableAutoSimHomeUrlInProfile" + +// Add download file name decode feature for China region +#define CscFeatureTagWeb_SupportDownloadedFileNameInChineseChar "CscFeature_Web_SupportDownloadedFileNameInChineseChar" + +// support multiAPN (CMCC Requirement) +#define CscFeatureTagWeb_EnableMultipleApn4 "CscFeature_Web_EnableMultipleApn4" + +// Enable Ask to exit on back (CMCC Requirement) +#define CscFeatureTagWeb_EnablePromptToExit "CscFeature_Web_EnablePromptToExit" + + +// Enable EMOJI for JPN +#define CscFeatureTagWeb_EnableEmoji "CscFeature_Web_Bool_EnableEmoji" + +// Show Wifi AP List when WIFI switch is on (CMCC Requirement) +#define CscFeatureTagWeb_ShowWifiAPList "CscFeature_Web_ShowWifiAPList" + + // Enable Operator's toolbar (ATT Requirement) +#define CscFeatureTagWeb_EnableOperatorToolbar "CscFeature_Web_EnableOperatorToolbar" + +// Set TCP Connection timout (China Requirement) +#define CscFeatureTagWeb_SetTcpConnTimeoutAs "CscFeature_Web_SetTcpConnTimeoutAs" + +// Add WML mime type to Accept Header (CMCC Requirement) +#define CscFeatureTagWeb_AddWmlToHttpAcceptHeader4 "CscFeature_Web_AddWmlToHttpAcceptHeader4" + +// change block zoom method to position based touch block zoom (Australia Requirement) +#define CscFeature_Web_BlockZoomBaseOnTouchPosition "CscFeature_Web_BlockZoomBaseOnTouchPosition" + +// Remove Partial View During Horizontal Scroll in Nav Screen (Australia Requirement) +#define CscFeature_Web_RemovePartialViewDuringHorizontalScroll "CscFeature_Web_RemovePartialViewDuringHorizontalScroll" + +// Show Popup for MaxLength reached during Url input (CMCC Requirement) +#define CscFeatureTagWeb_EnablePopup4MaxLengthReachedDuringUrlInput "CscFeature_Web_EnablePopup4MaxLengthReachedDuringUrlInput" + +// Support Tel Number in the page to go to dialing app (KOR Requirement) +#define CscFeature_Web_RecognizeTelNumber "CscFeature_Web_RecognizeTelNumber" + +// Large file transfer in Internet download (VZW Requirement) +#define CscFeature_Web_EnableWifiOption4LargeFileDownload "CscFeature_Web_EnableWifiOption4LargeFileDownload" + +// Add additional accept charset to Accept Header (CTC Requirement) +#define CscFeature_Web_AddCharSetToHttpHeader "CscFeature_Web_AddCharSetToHttpHeader" + +// max connection per host for performance +#define CscFeature_Web_MaxConnectionPerHost "CscFeature_Web_MaxConnectionPerHost" +#endif // SEC_NATIVE_FEATURE_TAG_WEB_H diff --git a/libshims/Android.mk b/libshims/Android.mk new file mode 100755 index 0000000..37483e0 --- /dev/null +++ b/libshims/Android.mk @@ -0,0 +1,17 @@ +# +# Copyright (C) 2017 The LineageOS Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include $(call first-makefiles-under,$(call my-dir)) diff --git a/ril/Android.mk b/libshims/libshim_camera/Android.mk similarity index 56% rename from ril/Android.mk rename to libshims/libshim_camera/Android.mk index 14178e7..238e965 100755 --- a/ril/Android.mk +++ b/libshims/libshim_camera/Android.mk @@ -1,9 +1,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_SRC_FILES := ril_shim.c -LOCAL_SHARED_LIBRARIES := liblog libcutils libbinder libutils -LOCAL_MODULE := libril_shim +LOCAL_SRC_FILES := camera_shim.c +LOCAL_MODULE := libshim_camera LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_PROPRIETARY_MODULE := true include $(BUILD_SHARED_LIBRARY) diff --git a/libshims/libshim_camera/camera_shim.c b/libshims/libshim_camera/camera_shim.c new file mode 100755 index 0000000..d0c4929 --- /dev/null +++ b/libshims/libshim_camera/camera_shim.c @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2017 The LineageOS Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// rt hdr +const char *_ZN7android16CameraParameters10KEY_RT_HDRE = "rt-hdr"; +const char *_ZN7android16CameraParameters20KEY_SUPPORTED_RT_HDRE = "rt-hdr-values"; +const char *_ZN7android16CameraParameters9RTHDR_OFFE = "off"; +const char *_ZN7android16CameraParameters8RTHDR_ONE = "on"; + +// phase af +const char *_ZN7android16CameraParameters12KEY_PHASE_AFE = "phase-af"; +const char *_ZN7android16CameraParameters22KEY_SUPPORTED_PHASE_AFE = "phase-af-values"; +const char *_ZN7android16CameraParameters7PAF_OFFE = "off"; +const char *_ZN7android16CameraParameters6PAF_ONE = "on"; + +// dynamic range control +const char *_ZN7android16CameraParameters25KEY_DYNAMIC_RANGE_CONTROLE = "dynamic-range-control"; +const char *_ZN7android16CameraParameters35KEY_SUPPORTED_DYNAMIC_RANGE_CONTROLE = "dynamic-range-control-values"; +const char *_ZN7android16CameraParameters7DRC_OFFE = "off"; +const char *_ZN7android16CameraParameters6DRC_ONE = "on"; diff --git a/lineage.mk b/lineage.mk index 0225e79..b6aa927 100755 --- a/lineage.mk +++ b/lineage.mk @@ -1,4 +1,22 @@ -$(call inherit-product, vendor/cm/config/common_full_phone.mk) +# +# Copyright (C) 2014-2016 The CyanogenMod Project +# Copyright (C) 2017 The LineageOS Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Inherit some common LineageOS stuff. +$(call inherit-product, vendor/lineage/config/common_full_phone.mk) $(call inherit-product, device/samsung/viennalte/full_viennalte.mk) diff --git a/manifest.xml b/manifest.xml new file mode 100755 index 0000000..354ba97 --- /dev/null +++ b/manifest.xml @@ -0,0 +1,60 @@ + + + android.hardware.camera.provider + passthrough + 2.4 + + ICameraProvider + legacy/0 + + + + android.hardware.light + passthrough + 2.0 + + ILight + default + + + + android.hardware.nfc + passthrough + 1.0 + + INfc + default + + + + android.hardware.radio + hwbinder + 1.0 + + IRadio + slot1 + + + ISap + slot1 + + + + android.hardware.radio.deprecated + hwbinder + 1.0 + + IOemHook + slot1 + + + + android.hardware.vibrator + passthrough + 1.0 + + IVibrator + default + + + diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml index 86a3556..1c05819 100755 --- a/overlay/frameworks/base/core/res/res/values/config.xml +++ b/overlay/frameworks/base/core/res/res/values/config.xml @@ -208,12 +208,12 @@ - + @@ -241,7 +241,7 @@ false - true + - 83 + - 65 + true @@ -302,7 +302,7 @@ - false + - true + diff --git a/overlay/frameworks/base/packages/SettingsProvider/res/values/config.xml b/overlay/frameworks/base/packages/SettingsProvider/res/values/config.xml index 95f087f..156b6dc 100755 --- a/overlay/frameworks/base/packages/SettingsProvider/res/values/config.xml +++ b/overlay/frameworks/base/packages/SettingsProvider/res/values/config.xml @@ -17,6 +17,7 @@ */ --> + false true true diff --git a/ril/ril_shim.c b/ril/ril_shim.c deleted file mode 100755 index 3cd7605..0000000 --- a/ril/ril_shim.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2017 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "SEC_RIL_SHIM" -#include -#include -#include - -#include - -//various funcs we'll need to call, in their mangled form - -//android::Parcel::writeString16(char16_t const*, unsigned int) -extern void _ZN7android6Parcel13writeString16EPKDsj(void **str16P, - uint16_t const *str, unsigned int len); - -//code exports we provide - -void _ZN7android6Parcel13writeString16EPKtj(void **str16P, - unsigned short const *str, unsigned int len); - -//library on-load and on-unload handlers (to help us set things up and tear them down) -void libEvtLoading(void) __attribute__((constructor)); -void libEvtUnloading(void) __attribute__((destructor)); - -/* - * FUNCTION: android::Parcel::writeString16(unsigned short const*, unsigned int) - * USE: INTERPOSE: write String16 to binder - * NOTES: This function no longer exists in M, instead now one must pass - * in a char16_t instead of a short. M So we'll craft the same call here. - */ -void _ZN7android6Parcel13writeString16EPKtj(void **str16P, - unsigned short const *str, unsigned int len) -{ - _ZN7android6Parcel13writeString16EPKDsj(str16P, str, len); -} - -/* - * FUNCTION: libEvtLoading() - * USE: Handle library loading - * NOTES: This is a good time to log the fact that we were loaded and plan to - * do our thing. - */ -void libEvtLoading(void) -{ - ALOGV("libbinder interposition library loaded"); -} - -/* - * FUNCTION: libEvtUnloading() - * USE: Handle library unloading - * NOTES: This is a good time to free whatever is unfreed and say goodbye - */ -void libEvtUnloading(void) -{ - ALOGV("libbinder interposition library unloading. Goodbye..."); -} diff --git a/ril/telephony/java/com/android/internal/telephony/NoteProRIL.java b/ril/telephony/java/com/android/internal/telephony/NoteProRIL.java deleted file mode 100755 index 8b3df11..0000000 --- a/ril/telephony/java/com/android/internal/telephony/NoteProRIL.java +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Copyright (c) 2014, The CyanogenMod Project. All rights reserved. - * - * 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 com.android.internal.telephony; - -import static com.android.internal.telephony.RILConstants.*; - -import android.content.Context; -import android.telephony.Rlog; -import android.os.AsyncResult; -import android.os.Message; -import android.os.Parcel; -import android.os.SystemProperties; -import android.telephony.PhoneNumberUtils; -import android.telephony.SignalStrength; -import com.android.internal.telephony.cdma.CdmaInformationRecords; -import com.android.internal.telephony.cdma.CdmaInformationRecords.CdmaSignalInfoRec; -import com.android.internal.telephony.cdma.SignalToneUtil; -import com.android.internal.telephony.uicc.IccCardApplicationStatus; -import com.android.internal.telephony.uicc.IccCardStatus; -import com.android.internal.telephony.uicc.IccUtils; -import java.util.ArrayList; -import java.util.Collections; - -/** - * RIL customization for Galaxy Note Pro 12.2 LTE devices - * - * {@hide} - */ -public class NoteProRIL extends RIL { - - private static final int RIL_UNSOL_ON_SS_LL = 11055; - - private boolean mIsGsm = false; - - public NoteProRIL(Context context, int networkMode, int cdmaSubscription) { - super(context, networkMode, cdmaSubscription, null); - mQANElements = 6; - } - - public NoteProRIL(Context context, int preferredNetworkType, - int cdmaSubscription, Integer instanceId) { - super(context, preferredNetworkType, cdmaSubscription, instanceId); - mQANElements = 6; - } - - private void - fixNitz(Parcel p) { - int dataPosition = p.dataPosition(); - String nitz = p.readString(); - long nitzReceiveTime = p.readLong(); - - String[] nitzParts = nitz.split(","); - if (nitzParts.length >= 4) { - // 0=date, 1=time+zone, 2=dst, 3(+)=garbage that confuses ServiceStateTracker - nitz = nitzParts[0] + "," + nitzParts[1] + "," + nitzParts[2]; - p.setDataPosition(dataPosition); - p.writeString(nitz); - p.writeLong(nitzReceiveTime); - // The string is shorter now, drop the extra bytes - p.setDataSize(p.dataPosition()); - } - } - - @Override - public void - dial(String address, int clirMode, UUSInfo uusInfo, Message result) { - - RILRequest rr = RILRequest.obtain(RIL_REQUEST_DIAL, result); - - rr.mParcel.writeString(address); - rr.mParcel.writeInt(clirMode); - rr.mParcel.writeInt(0); // CallDetails.call_type - rr.mParcel.writeInt(1); // CallDetails.call_domain - rr.mParcel.writeString(""); // CallDetails.getCsvFromExtras - - if (uusInfo == null) { - rr.mParcel.writeInt(0); // UUS information is absent - } else { - rr.mParcel.writeInt(1); // UUS information is present - rr.mParcel.writeInt(uusInfo.getType()); - rr.mParcel.writeInt(uusInfo.getDcs()); - rr.mParcel.writeByteArray(uusInfo.getUserData()); - } - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); - - send(rr); - } - - @Override - protected Object - responseIccCardStatus(Parcel p) { - IccCardApplicationStatus appStatus; - - IccCardStatus cardStatus = new IccCardStatus(); - cardStatus.setCardState(p.readInt()); - cardStatus.setUniversalPinState(p.readInt()); - cardStatus.mGsmUmtsSubscriptionAppIndex = p.readInt(); - cardStatus.mCdmaSubscriptionAppIndex = p.readInt(); - cardStatus.mImsSubscriptionAppIndex = p.readInt(); - - int numApplications = p.readInt(); - - // limit to maximum allowed applications - if (numApplications > IccCardStatus.CARD_MAX_APPS) { - numApplications = IccCardStatus.CARD_MAX_APPS; - } - cardStatus.mApplications = new IccCardApplicationStatus[numApplications]; - - appStatus = new IccCardApplicationStatus(); - for (int i = 0 ; i < numApplications ; i++) { - if (i!=0) { - appStatus = new IccCardApplicationStatus(); - } - appStatus.app_type = appStatus.AppTypeFromRILInt(p.readInt()); - appStatus.app_state = appStatus.AppStateFromRILInt(p.readInt()); - appStatus.perso_substate = appStatus.PersoSubstateFromRILInt(p.readInt()); - appStatus.aid = p.readString(); - appStatus.app_label = p.readString(); - appStatus.pin1_replaced = p.readInt(); - appStatus.pin1 = appStatus.PinStateFromRILInt(p.readInt()); - appStatus.pin2 = appStatus.PinStateFromRILInt(p.readInt()); - p.readInt(); // pin1_num_retries - p.readInt(); // puk1_num_retries - p.readInt(); // pin2_num_retries - p.readInt(); // puk2_num_retries - p.readInt(); // perso_unblock_retries - cardStatus.mApplications[i] = appStatus; - } - // For Sprint LTE only SIM - if (numApplications==1 && !mIsGsm && appStatus.app_type == appStatus.AppTypeFromRILInt(2)) { - cardStatus.mApplications = new IccCardApplicationStatus[numApplications+2]; - cardStatus.mGsmUmtsSubscriptionAppIndex = 0; - cardStatus.mApplications[cardStatus.mGsmUmtsSubscriptionAppIndex]=appStatus; - cardStatus.mCdmaSubscriptionAppIndex = 1; - cardStatus.mImsSubscriptionAppIndex = 2; - - IccCardApplicationStatus appStatus2 = new IccCardApplicationStatus(); - appStatus2.app_type = appStatus2.AppTypeFromRILInt(4); // csim state - appStatus2.app_state = appStatus.app_state; - appStatus2.perso_substate = appStatus.perso_substate; - appStatus2.aid = appStatus.aid; - appStatus2.app_label = appStatus.app_label; - appStatus2.pin1_replaced = appStatus.pin1_replaced; - appStatus2.pin1 = appStatus.pin1; - appStatus2.pin2 = appStatus.pin2; - cardStatus.mApplications[cardStatus.mCdmaSubscriptionAppIndex] = appStatus2; - - IccCardApplicationStatus appStatus3 = new IccCardApplicationStatus(); - appStatus3.app_type = appStatus3.AppTypeFromRILInt(5); // ims state - appStatus3.app_state = appStatus.app_state; - appStatus3.perso_substate = appStatus.perso_substate; - appStatus3.aid = appStatus.aid; - appStatus3.app_label = appStatus.app_label; - appStatus3.pin1_replaced = appStatus.pin1_replaced; - appStatus3.pin1 = appStatus.pin1; - appStatus3.pin2 = appStatus.pin2; - cardStatus.mApplications[cardStatus.mImsSubscriptionAppIndex] = appStatus3; - } - return cardStatus; - } - - @Override - protected Object - responseCallList(Parcel p) { - int num; - int voiceSettings; - ArrayList response; - DriverCall dc; - - num = p.readInt(); - response = new ArrayList(num); - - if (RILJ_LOGV) { - riljLog("responseCallList: num=" + num + - " mEmergencyCallbackModeRegistrant=" + mEmergencyCallbackModeRegistrant + - " mTestingEmergencyCall=" + mTestingEmergencyCall.get()); - } - for (int i = 0 ; i < num ; i++) { - dc = new DriverCall(); - - dc.state = DriverCall.stateFromCLCC(p.readInt()); - dc.index = p.readInt() & 0xff; - dc.TOA = p.readInt(); - dc.isMpty = (0 != p.readInt()); - dc.isMT = (0 != p.readInt()); - dc.als = p.readInt(); - voiceSettings = p.readInt(); - dc.isVoice = (0 != voiceSettings); - int call_type = p.readInt(); // Samsung CallDetails - int call_domain = p.readInt(); // Samsung CallDetails - String csv = p.readString(); // Samsung CallDetails - dc.isVoicePrivacy = (0 != p.readInt()); - dc.number = p.readString(); - int np = p.readInt(); - dc.numberPresentation = DriverCall.presentationFromCLIP(np); - dc.name = p.readString(); - dc.namePresentation = DriverCall.presentationFromCLIP(p.readInt()); - int uusInfoPresent = p.readInt(); - if (uusInfoPresent == 1) { - dc.uusInfo = new UUSInfo(); - dc.uusInfo.setType(p.readInt()); - dc.uusInfo.setDcs(p.readInt()); - byte[] userData = p.createByteArray(); - dc.uusInfo.setUserData(userData); - riljLogv(String.format("Incoming UUS : type=%d, dcs=%d, length=%d", - dc.uusInfo.getType(), dc.uusInfo.getDcs(), - dc.uusInfo.getUserData().length)); - riljLogv("Incoming UUS : data (string)=" - + new String(dc.uusInfo.getUserData())); - riljLogv("Incoming UUS : data (hex): " - + IccUtils.bytesToHexString(dc.uusInfo.getUserData())); - } else { - riljLogv("Incoming UUS : NOT present!"); - } - - // Make sure there's a leading + on addresses with a TOA of 145 - dc.number = PhoneNumberUtils.stringFromStringAndTOA(dc.number, dc.TOA); - - response.add(dc); - - if (dc.isVoicePrivacy) { - mVoicePrivacyOnRegistrants.notifyRegistrants(); - riljLog("InCall VoicePrivacy is enabled"); - } else { - mVoicePrivacyOffRegistrants.notifyRegistrants(); - riljLog("InCall VoicePrivacy is disabled"); - } - } - - Collections.sort(response); - - if ((num == 0) && mTestingEmergencyCall.getAndSet(false)) { - if (mEmergencyCallbackModeRegistrant != null) { - riljLog("responseCallList: call ended, testing emergency call," + - " notify ECM Registrants"); - mEmergencyCallbackModeRegistrant.notifyRegistrant(); - } - } - - return response; - } - - @Override - protected Object responseSignalStrength(Parcel p) { - int numInts = 12; - int response[]; - - // Get raw data - response = new int[numInts]; - for (int i = 0; i < numInts; i++) { - response[i] = p.readInt(); - } - //gsm - response[0] &= 0xff; - //cdma - response[2] %= 256; - response[4] %= 256; - response[7] &= 0xff; - - return new SignalStrength(response[0], response[1], response[2], response[3], response[4], response[5], response[6], response[7], response[8], response[9], response[10], response[11], true); - - } - - @Override - protected void notifyRegistrantsCdmaInfoRec(CdmaInformationRecords infoRec) { - final int response = RIL_UNSOL_CDMA_INFO_REC; - - if (infoRec.record instanceof CdmaSignalInfoRec) { - CdmaSignalInfoRec rec = (CdmaSignalInfoRec) infoRec.record; - if (rec != null - && rec.isPresent - && rec.signalType == SignalToneUtil.IS95_CONST_IR_SIGNAL_IS54B - && rec.alertPitch == SignalToneUtil.IS95_CONST_IR_ALERT_MED - && rec.signal == SignalToneUtil.IS95_CONST_IR_SIG_IS54B_L) { - /* Drop record, otherwise IS95_CONST_IR_SIG_IS54B_L tone will - * continue to play after the call is connected */ - return; - } - } - super.notifyRegistrantsCdmaInfoRec(infoRec); - } - - @Override - public void setPhoneType(int phoneType) { - super.setPhoneType(phoneType); - mIsGsm = (phoneType != RILConstants.CDMA_PHONE); - } - - @Override - protected void - processUnsolicited (Parcel p, int type) { - Object ret; - int dataPosition = p.dataPosition(); - int response = p.readInt(); - int newResponse = response; - - switch(response) { - case RIL_UNSOL_NITZ_TIME_RECEIVED: - fixNitz(p); - break; - case RIL_UNSOL_ON_SS_LL: - newResponse = RIL_UNSOL_ON_SS; - break; - } - if (newResponse != response) { - p.setDataPosition(dataPosition); - p.writeInt(newResponse); - } - p.setDataPosition(dataPosition); - super.processUnsolicited(p, type); - } - - @Override - public void - acceptCall (Message result) { - RILRequest rr - = RILRequest.obtain(RIL_REQUEST_ANSWER, result); - - rr.mParcel.writeInt(1); - rr.mParcel.writeInt(0); - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); - - send(rr); - } - - @Override - protected RILRequest - processSolicited (Parcel p, int type) { - int serial, error; - boolean found = false; - int dataPosition = p.dataPosition(); // save off position within the Parcel - serial = p.readInt(); - error = p.readInt(); - RILRequest rr = null; - /* Pre-process the reply before popping it */ - synchronized (mRequestList) { - RILRequest tr = mRequestList.get(serial); - if (tr != null && tr.mSerial == serial) { - if (error == 0 || p.dataAvail() > 0) { - try {switch (tr.mRequest) { - /* Get those we're interested in */ - case RIL_REQUEST_DATA_REGISTRATION_STATE: - rr = tr; - break; - }} catch (Throwable thr) { - // Exceptions here usually mean invalid RIL responses - if (tr.mResult != null) { - AsyncResult.forMessage(tr.mResult, null, thr); - tr.mResult.sendToTarget(); - } - return tr; - } - } - } - } - if (rr == null) { - /* Nothing we care about, go up */ - p.setDataPosition(dataPosition); - // Forward responses that we are not overriding to the super class - return super.processSolicited(p, type); - } - rr = findAndRemoveRequestFromList(serial); - if (rr == null) { - return rr; - } - Object ret = null; - if (error == 0 || p.dataAvail() > 0) { - switch (rr.mRequest) { - case RIL_REQUEST_DATA_REGISTRATION_STATE: ret = responseDataRegistrationState(p); break; - default: - throw new RuntimeException("Unrecognized solicited response: " + rr.mRequest); - } - //break; - } - if (RILJ_LOGD) riljLog(rr.serialString() + "< " + requestToString(rr.mRequest) - + " " + retToString(rr.mRequest, ret)); - if (rr.mResult != null) { - AsyncResult.forMessage(rr.mResult, ret, null); - rr.mResult.sendToTarget(); - } - return rr; - } - - private Object - responseDataRegistrationState(Parcel p) { - String response[] = (String[])responseStrings(p); - /* DANGER WILL ROBINSON - * In some cases from Vodaphone we are receiving a RAT of 102 - * while in tunnels of the metro. Lets Assume that if we - * receive 102 we actually want a RAT of 2 for EDGE service */ - if (response.length > 4 && - response[0].equals("1") && - response[3].equals("102")) { - response[3] = "2"; - } - return response; - } -} diff --git a/rootdir/etc/fstab.full b/rootdir/etc/fstab.full new file mode 100755 index 0000000..d1c77d1 --- /dev/null +++ b/rootdir/etc/fstab.full @@ -0,0 +1,23 @@ +# Android fstab file. +# The filesystem that contains the filesystem e2fsck binary (typically /system) cannot +# specify 'check', and must come before any filesystems that do specify 'check' + +# +/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,errors=panic wait +/dev/block/platform/msm_sdcc.1/by-name/userdata /data f2fs nosuid,nodev,noatime,rw,inline_xattr wait,check,formattable,encryptable=footer,length=-16384 +/dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 nosuid,nodev,noatime,noauto_da_alloc,errors=continue,commit=20 wait,check,formattable,encryptable=footer,length=-16384 +/dev/block/platform/msm_sdcc.1/by-name/cache /cache f2fs nosuid,nodev,noatime,rw,inline_xattr wait,check,formattable +/dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 nosuid,nodev,noatime,noauto_da_alloc,errors=continue,commit=20 wait,check,formattable +/dev/block/platform/msm_sdcc.1/by-name/apnhlos /firmware vfat ro,shortname=lower,uid=1000,gid=1026,dmask=227,fmask=337,context=u:object_r:firmware_file:s0 wait +/dev/block/platform/msm_sdcc.1/by-name/modem /firmware-modem vfat ro,shortname=lower,uid=1000,gid=1026,dmask=227,fmask=337,context=u:object_r:firmware_file:s0 wait +/dev/block/platform/msm_sdcc.1/by-name/efs /efs ext4 nosuid,nodev,noatime,noauto_da_alloc,journal_async_commit,errors=panic wait,check +/dev/block/platform/msm_sdcc.1/by-name/fota /misc emmc defaults defaults + +/dev/block/platform/msm_sdcc.1/by-name/boot /boot emmc defaults recoveryonly +/dev/block/platform/msm_sdcc.1/by-name/recovery /recovery emmc defaults recoveryonly + +/devices/msm_sdcc.3/mmc_host/mmc* auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata + +/dev/block/zram0 none swap defaults zramsize=25%,zramstreams=4,swapprio=10,notrim + +/devices/platform/xhci-hcd* auto auto defaults voldmanaged=usb:auto diff --git a/rootdir/etc/fstab.qcom b/rootdir/etc/fstab.qcom index 1d4e623..03a85bc 100755 --- a/rootdir/etc/fstab.qcom +++ b/rootdir/etc/fstab.qcom @@ -1,12 +1,11 @@ # Android fstab file. -# The filesystem that contains the filesystem checker binary (typically /system) cannot -# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK +# The filesystem that contains the filesystem e2fsck binary (typically /system) cannot +# specify 'check', and must come before any filesystems that do specify 'check' -#TODO: Add 'check' as fs_mgr_flags with data partition. -# Currently we dont have e2fsck compiled. So fs check would failed. +# NOTE: /system partition is now early-mounted and the fstab entry is specified in device tree: +# /proc/device-tree/firmware/android/fstab/system # -/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,errors=panic wait /dev/block/platform/msm_sdcc.1/by-name/userdata /data f2fs nosuid,nodev,noatime,rw,inline_xattr wait,check,formattable,encryptable=footer,length=-16384 /dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 nosuid,nodev,noatime,noauto_da_alloc,errors=continue,commit=20 wait,check,formattable,encryptable=footer,length=-16384 /dev/block/platform/msm_sdcc.1/by-name/cache /cache f2fs nosuid,nodev,noatime,rw,inline_xattr wait,check,formattable diff --git a/rootdir/etc/init.qcom.rc b/rootdir/etc/init.qcom.rc index 658fa21..4012cf8 100755 --- a/rootdir/etc/init.qcom.rc +++ b/rootdir/etc/init.qcom.rc @@ -1,4 +1,5 @@ # Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved. +# 2017, The LineageOS Project. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -29,7 +30,7 @@ import init.qcom.usb.rc import init.target.rc on early-init - export LD_SHIM_LIBS /system/lib/libril.so|libril_shim.so + export LD_SHIM_LIBS /system/lib/hw/camera.vendor.msm8974.so|libshim_camera.so:/system/lib/libcutils.so|libshim_cutils_atomic.so mount debugfs debugfs /sys/kernel/debug chmod 0755 /sys/kernel/debug @@ -48,7 +49,6 @@ on early-init symlink /data/tombstones /tombstones on init - # Support legacy paths symlink /sdcard /storage/sdcard0 @@ -56,7 +56,6 @@ on init on fs mount_all fstab.qcom - write /proc/sys/vm/swappiness 100 swapon_all fstab.qcom restorecon_recursive /efs @@ -294,6 +293,8 @@ on boot mkdir /dev/socket/qmux_gps 0770 gps gps chmod 2770 /dev/socket/qmux_gps + mkdir /persist/bluetooth 0770 bluetooth bluetooth + # Allow QMUX daemon to assign port open wait time chown radio radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait @@ -801,13 +802,13 @@ on boot # permissions for bluetooth. setprop ro.bt.bdaddr_path "/efs/bluetooth/bt_addr" - chown bluetooth net_bt_stack ro.bt.bdaddr_path - chown radio net_bt_stack /efs/bluetooth/bt_addr + chown bluetooth bluetooth ro.bt.bdaddr_path + chown radio bluetooth /efs/bluetooth/bt_addr chmod 0640 /efs/bluetooth/bt_addr restorecon_recursive /efs/bluetooth chmod 0660 /sys/class/rfkill/rfkill0/state - chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/state - chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/type + chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state + chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type # DualWave chown system system /sys/kernel/DualWave/sound/DUALWAVE_CONFIG @@ -815,8 +816,8 @@ on boot # bluetooth LPM chmod 0660 /proc/bluetooth/sleep/lpm chmod 0220 /proc/bluetooth/sleep/btwrite - chown bluetooth net_bt_stack /proc/bluetooth/sleep/lpm - chown bluetooth net_bt_stack /proc/bluetooth/sleep/btwrite + chown bluetooth bluetooth /proc/bluetooth/sleep/lpm + chown bluetooth bluetooth /proc/bluetooth/sleep/btwrite # Sensors chown system system /efs/prox_cal @@ -831,9 +832,12 @@ on boot chmod 0640 /efs/gyro_cal_data restorecon /efs/gyro_cal_data + # Set permissions for firmware path control + chown wifi wifi /sys/module/dhd/parameters/firmware_path + # Services begin here -service adsprpcd /system/bin/adsprpcd +service adsprpcd /vendor/bin/adsprpcd class main user media group media @@ -841,20 +845,20 @@ service adsprpcd /system/bin/adsprpcd service qcamerasvr /system/bin/mm-qcamera-daemon class main user camera - group camera system inet input graphics net_bt_stack + group camera system inet input graphics bluetooth -service qseecomd /system/bin/qseecomd +service qseecomd /vendor/bin/qseecomd class core user root group root -service mpdecision /system/bin/mpdecision --avg_comp +service mpdecision /vendor/bin/mpdecision --avg_comp class main user root group root readproc disabled -service thermal-engine /system/vendor/bin/thermal-engine +service thermal-engine /vendor/bin/thermal-engine class main user root socket thermal-send-client stream 0666 system system @@ -862,7 +866,7 @@ service thermal-engine /system/vendor/bin/thermal-engine socket thermal-recv-passive-client stream 0666 system system group root -service time_daemon /system/bin/time_daemon +service time_daemon /vendor/bin/time_daemon class late_start user root group root @@ -872,72 +876,43 @@ service audiod /system/bin/audiod user system group system -service irsc_util /system/bin/irsc_util "/etc/sec_config" +service irsc_util /vendor/bin/irsc_util "/vendor/etc/sec_config" class main user root oneshot -service rfs_access /system/bin/rfs_access +service rfs_access /vendor/bin/rfs_access class core user system group system net_raw -service rmt_storage /system/bin/rmt_storage +service rmt_storage /vendor/bin/rmt_storage class core user root group system wakelock -service qmuxd /system/bin/qmuxd +service qmuxd /vendor/bin/qmuxd class core user radio - group radio audio bluetooth gps qcom_diag log + group radio audio bluetooth gps oem_2950 log -service wpa_supplicant /system/bin/wpa_supplicant \ - -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \ - -I/system/etc/wifi/wpa_supplicant_overlay.conf \ - -O/data/misc/wifi/sockets \ - -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0 - # we will start as root and wpa_supplicant will switch to user wifi - # after setting up the capabilities required for WEXT - # user wifi - # group wifi inet keystore - class main - socket wpa_wlan0 dgram 660 wifi wifi - disabled - group system wakelock - oneshot - -service p2p_supplicant /system/bin/wpa_supplicant \ +service wpa_supplicant /vendor/bin/hw/wpa_supplicant \ -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \ -I/system/etc/wifi/wpa_supplicant_overlay.conf -N \ -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \ -I/system/etc/wifi/p2p_supplicant_overlay.conf \ - -O/data/misc/wifi/sockets -puse_p2p_group_interface=1 \ - -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0 -# we will start as root and wpa_supplicant will switch to user wifi -# after setting up the capabilities required for WEXT -# user wifi -# group wifi inet keystore + -puse_p2p_group_interface=1 -e/data/misc/wifi/entropy.bin \ + -g@android:wpa_wlan0 class main socket wpa_wlan0 dgram 660 wifi wifi disabled - group system wakelock oneshot -service macloader /system/bin/macloader +service macloader /vendor/bin/macloader class late_start oneshot seclabel u:r:macloader:s0 -service ril-daemon /system/bin/rild - class main - socket rild stream 660 root radio - socket sap_uim_socket1 stream 660 bluetooth bluetooth - socket rild-debug stream 660 radio system - socket rild-cas stream 660 casdrm mmb - user root - group radio cache inet misc audio log system wakelock qcom_diag - on property:wlan.driver.status=ok start macloader @@ -977,6 +952,9 @@ on property:sys.boot_completed=1 # Configure the CPU governor write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor interactive + write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor interactive + write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor interactive + write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor interactive write /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay "19000 1400000:39000 1700000:19000" write /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load 99 write /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq 1497600 @@ -986,6 +964,9 @@ on property:sys.boot_completed=1 write /sys/devices/system/cpu/cpufreq/interactive/timer_rate 30000 write /sys/devices/system/cpu/cpufreq/interactive/sampling_down_factor 100000 write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 300000 + write /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq 300000 + write /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq 300000 + write /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq 300000 chown root system /sys/devices/system/cpu/cpu1/online chown root system /sys/devices/system/cpu/cpu2/online diff --git a/rootdir/etc/ueventd.qcom.rc b/rootdir/etc/ueventd.qcom.rc index 664a1df..4c3ce55 100755 --- a/rootdir/etc/ueventd.qcom.rc +++ b/rootdir/etc/ueventd.qcom.rc @@ -26,7 +26,7 @@ # # the DIAG device node is not world writable/readable. -/dev/diag 0660 system qcom_diag +/dev/diag 0660 system oem_2950 /dev/genlock 0666 system system /dev/kgsl 0666 system system @@ -44,6 +44,7 @@ #permissions for CSVT /dev/smd11 0660 radio radio +/dev/radio0 0640 system system /dev/rfcomm0 0660 bluetooth bluetooth /dev/smdcntl0 0640 radio radio /dev/smdcntl1 0640 radio radio @@ -134,8 +135,9 @@ /dev/msm_preproc_ctl 0660 system audio /dev/msm_rtac 0660 system audio /dev/msm_voicememo 0660 system audio -/dev/smd3 0660 bluetooth net_bt_stack -/dev/smd2 0660 bluetooth net_bt_stack +/dev/radio0 0640 fm_radio fm_radio +/dev/smd3 0660 bluetooth bluetooth +/dev/smd2 0660 bluetooth bluetooth /dev/ttyHSL1 0660 system system /dev/mdm 0660 system radio /sys/devices/virtual/smdpkt/smdcntl* open_timeout 0664 radio radio @@ -149,7 +151,7 @@ /dev/ttyHS3 0660 media audio # Bluetooth -/dev/ttyHS0 0660 bluetooth net_bt_stack +/dev/ttyHS0 0660 bluetooth bluetooth /dev/ttyHS2 0660 bluetooth bluetooth # bluetooth LPM diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts index ca37b2b..3aaf30c 100755 --- a/sepolicy/file_contexts +++ b/sepolicy/file_contexts @@ -19,9 +19,19 @@ # EFS /dev/block/platform/msm_sdcc.1/by-name/efs u:object_r:modem_efs_partition_device:s0 +# Fingerprint +/data/validity(/.*)? u:object_r:vcs_data_file:s0 +/dev/validity(/.*)? u:object_r:vcs_device:s0 +/dev/vfsspi u:object_r:vcs_device:s0 + # Macloader /system/bin/macloader u:object_r:macloader_exec:s0 +# NFC +/dev/bcm2079x u:object_r:nfc_device:s0 +/dev/pn547 u:object_r:nfc_device:s0 +/dev/sec-nfc u:object_r:nfc_device:s0 + # RIL /data/data/com.android.providers.telephony/databases(/.*)? u:object_r:radio_data_file:s0 /data/data/com.android.providers.telephony/shared_prefs(/.*)? u:object_r:radio_data_file:s0 diff --git a/sepolicy/fingerprintd.te b/sepolicy/fingerprintd.te new file mode 100755 index 0000000..4a25a4c --- /dev/null +++ b/sepolicy/fingerprintd.te @@ -0,0 +1,14 @@ +allow fingerprintd vcs_data_file:dir create_dir_perms; +allow fingerprintd vcs_data_file:file create_file_perms; + +allow fingerprintd vcs_device:dir create_dir_perms; +allow fingerprintd vcs_device:file create_file_perms; +allow fingerprintd vcs_device:fifo_file create_file_perms; +allow fingerprintd vcs_device:chr_file create_file_perms; + +allow fingerprintd tee_device:chr_file rw_file_perms; + +allow fingerprintd firmware_file:dir r_dir_perms; +allow fingerprintd firmware_file:file r_file_perms; + +allow fingerprintd vfat:file { getattr open read }; diff --git a/sepolicy/shell.te b/sepolicy/shell.te new file mode 100755 index 0000000..4e8e4b6 --- /dev/null +++ b/sepolicy/shell.te @@ -0,0 +1,4 @@ +allow shell exfat:dir create_dir_perms; +allow shell exfat:file create_file_perms; +allow shell fuseblk:dir create_dir_perms; +allow shell fuseblk:file create_file_perms; diff --git a/system.prop b/system.prop index ee46882..0d62e9c 100755 --- a/system.prop +++ b/system.prop @@ -25,6 +25,7 @@ ro.hdcp2.rx=tz ro.qualcomm.cabl=1 ro.secwvk=144 ro.sf.lcd_density=320 +debug.hwui.use_buffer_age=false # GPS persist.gps.qc_nlp_in_use=0 @@ -35,6 +36,7 @@ ro.qc.sdk.izat.service_mask=0x0 # Media media.stagefright.legacyencoder=true media.stagefright.less-secure=true +persist.media.treble_omx=false # Perf ro.vendor.extension_library=/vendor/lib/libqti-perfd-client.so @@ -45,7 +47,6 @@ persist.data.qmi.adb_logmask=0 persist.radio.add_power_save=1 persist.radio.lte_vrat_report=1 ro.telephony.mms_data_profile=5 -ro.telephony.ril_class=NoteProRIL rild.libargs=-d /dev/smd0 rild.libpath=/system/lib/libsec-ril.so @@ -58,7 +59,7 @@ ro.telephony.call_ring.multiple=0 debug.sensors=1 # Storage -ro.sys.sdcardfs=true +ro.sys.sdcardfs=false # Tethering net.tethering.noprovisioning=true