├── Android.mk ├── BoardConfigCommon.mk ├── README.md ├── bump └── bump.py ├── camera ├── Android.mk └── CameraWrapper.cpp ├── cm.dependencies ├── cmhw └── org │ └── cyanogenmod │ └── hardware │ └── VibratorHW.java ├── configs ├── Android.mk ├── audio │ ├── audio_effects.conf │ ├── audio_platform_info_bcm.xml │ ├── audio_platform_info_qcwcn.xml │ ├── audio_policy.conf │ ├── mixer_paths_bcm.xml │ └── mixer_paths_qcwcn.xml ├── hostapd_default.conf ├── izat.conf ├── media_codecs.xml ├── media_profiles.xml ├── nfc │ ├── libnfc-brcm.conf │ ├── libnfc-nxp.conf │ └── nfcee_access.xml ├── sec_config └── thermal-engine-8974.conf ├── extract-files.sh ├── g3.mk ├── gps ├── Android.mk ├── core │ ├── Android.mk │ ├── ContextBase.cpp │ ├── ContextBase.h │ ├── LBSProxyBase.h │ ├── LocAdapterBase.cpp │ ├── LocAdapterBase.h │ ├── LocAdapterProxyBase.h │ ├── LocApiBase.cpp │ ├── LocApiBase.h │ ├── LocDualContext.cpp │ ├── LocDualContext.h │ ├── MsgTask.cpp │ ├── MsgTask.h │ ├── UlpProxyBase.h │ ├── gps_extended.h │ ├── gps_extended_c.h │ ├── loc_core_log.cpp │ └── loc_core_log.h ├── libloc_api_50001 │ ├── Android.mk │ ├── LocEngAdapter.cpp │ ├── LocEngAdapter.h │ ├── Makefile.am │ ├── gps.c │ ├── loc.cpp │ ├── loc.h │ ├── loc_eng.cpp │ ├── loc_eng.h │ ├── loc_eng_agps.cpp │ ├── loc_eng_agps.h │ ├── loc_eng_dmn_conn.cpp │ ├── loc_eng_dmn_conn.h │ ├── loc_eng_dmn_conn_glue_msg.c │ ├── loc_eng_dmn_conn_glue_msg.h │ ├── loc_eng_dmn_conn_glue_pipe.c │ ├── loc_eng_dmn_conn_glue_pipe.h │ ├── loc_eng_dmn_conn_handler.cpp │ ├── loc_eng_dmn_conn_handler.h │ ├── loc_eng_dmn_conn_thread_helper.c │ ├── loc_eng_dmn_conn_thread_helper.h │ ├── loc_eng_log.cpp │ ├── loc_eng_log.h │ ├── loc_eng_msg.h │ ├── loc_eng_ni.cpp │ ├── loc_eng_ni.h │ ├── loc_eng_nmea.cpp │ ├── loc_eng_nmea.h │ ├── loc_eng_xtra.cpp │ └── loc_eng_xtra.h ├── platform_lib_abstractions │ ├── elapsed_millis_since_boot.cpp │ ├── platform_lib_includes.h │ ├── platform_lib_macros.h │ └── platform_lib_time.h └── utils │ ├── Android.mk │ ├── Makefile.am │ ├── linked_list.c │ ├── linked_list.h │ ├── loc_cfg.cpp │ ├── loc_cfg.h │ ├── loc_log.cpp │ ├── loc_log.h │ ├── loc_misc_utils.cpp │ ├── loc_misc_utils.h │ ├── loc_target.cpp │ ├── loc_target.h │ ├── loc_timer.c │ ├── loc_timer.h │ ├── log_util.h │ ├── msg_q.c │ └── msg_q.h ├── hwaddrs ├── Android.mk └── getmac.c ├── include └── camera │ └── CameraParametersExtra.h ├── liblge ├── Android.mk └── lge_ril.cpp ├── liblight ├── Android.mk ├── NOTICE └── lights.c ├── mkbootimg.mk ├── overlay ├── frameworks │ └── base │ │ ├── core │ │ └── res │ │ │ └── res │ │ │ ├── values │ │ │ └── config.xml │ │ │ └── xml │ │ │ └── power_profile.xml │ │ └── packages │ │ ├── SettingsProvider │ │ └── res │ │ │ └── values │ │ │ └── default.xml │ │ └── SystemUI │ │ └── res │ │ └── values │ │ ├── config.xml │ │ └── dimens.xml ├── packages │ ├── apps │ │ ├── CarrierConfig │ │ │ └── res │ │ │ │ └── xml │ │ │ │ └── vendor.xml │ │ ├── Dialer │ │ │ └── res │ │ │ │ └── values │ │ │ │ └── config.xml │ │ └── Snap │ │ │ └── res │ │ │ └── values │ │ │ └── config.xml │ └── services │ │ └── Telephony │ │ └── res │ │ └── values │ │ └── config.xml └── vendor │ └── cmsdk │ └── cm │ └── res │ └── res │ └── values │ └── config.xml ├── proprietary-files.txt ├── ril └── telephony │ └── java │ └── com │ └── android │ └── internal │ └── telephony │ └── LgeLteRIL.java ├── rootdir ├── Android.mk └── etc │ ├── init.baseband.sh │ ├── init.g3.power.rc │ ├── init.g3.rc │ ├── init.g3.usb.rc │ ├── init.msm8974.sensor.sh │ ├── init.qcom.bt.sh │ ├── init.qcom.sh │ ├── init.sensors.sh │ └── ueventd.g3.rc ├── sepolicy ├── device.te ├── file_contexts ├── fsck.te ├── genfs_contexts ├── hwaddrs.te ├── kernel.te ├── mediacodec.te ├── mediaserver.te ├── mpdecision.te ├── property_contexts ├── qti_init_shell.te ├── radio.te ├── servicemanager.te ├── system_server.te ├── thermal-engine.te ├── tune2fs.te ├── type.te ├── vold.te ├── wcnss_service.te └── wpa.te ├── setup-makefiles.sh ├── system_prop.mk ├── wcnss ├── WCNSS_cfg.dat ├── WCNSS_qcom_cfg.ini ├── WCNSS_qcom_wlan_nv.bin ├── p2p_supplicant_overlay.conf └── wpa_supplicant_overlay.conf └── wcnss_lge ├── Android.mk └── wcnss_lge_client.c /Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2014 The CyanogenMod Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH := $(call my-dir) 18 | 19 | ifneq ($(filter g3 d850 d851 d852 d855 ls990 vs985 f400, $(TARGET_DEVICE)),) 20 | 21 | include $(call all-makefiles-under,$(LOCAL_PATH)) 22 | 23 | include $(CLEAR_VARS) 24 | 25 | define vfatfilename 26 | $(foreach f,$(1),$(shell echo $(f) | \ 27 | awk 'BEGIN { FS="."; } { printf("%s.%s", substr($$1,1,8), $$2); }')) 28 | endef 29 | 30 | DXHDCP2_IMAGES := \ 31 | dxhdcp2.b00 dxhdcp2.b01 dxhdcp2.b02 dxhdcp2.b03 dxhdcp2.mdt 32 | 33 | DXHDCP2_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(DXHDCP2_IMAGES)) 34 | $(DXHDCP2_SYMLINKS): $(LOCAL_INSTALLED_MODULE) 35 | @echo "dxhdcp2 firmware link: $@" 36 | @mkdir -p $(dir $@) 37 | @rm -rf $@ 38 | $(hide) ln -sf /firmware/image/$(call vfatfilename,$(notdir $@)) $@ 39 | 40 | ALL_DEFAULT_INSTALLED_MODULES += $(DXHDCP2_SYMLINKS) 41 | 42 | KEYMASTER_IMAGES := \ 43 | keymaste.b00 keymaste.b01 keymaste.b02 keymaste.b03 keymaste.mdt 44 | 45 | KEYMASTER_SYMLINKS :=$(addprefix $(TARGET_OUT_ETC)/firmware/,$(KEYMASTER_IMAGES)) 46 | $(KEYMASTER_SYMLINKS): $(LOCAL_INSTALLED_MODULE) 47 | @echo "keymaster firmware link: $@" 48 | @mkdir -p $(dir $@) 49 | @rm -rf $@ 50 | $(hide) ln -sf /firmware/image/$(call vfatfilename,$(notdir $@)) $@ 51 | 52 | ALL_DEFAULT_INSTALLED_MODULES += $(KEYMASTER_SYMLINKS) 53 | 54 | MLSERVERAPP_IMAGES := \ 55 | mlserverapp.b00 mlserverapp.b01 mlserverapp.b02 mlserverapp.b03 mlserverapp.mdt 56 | 57 | MLSERVERAPP_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(MLSERVERAPP_IMAGES)) 58 | $(MLSERVERAPP_SYMLINKS): $(LOCAL_INSTALLED_MODULE) 59 | @echo "mlserverapp firmware link: $@" 60 | @mkdir -p $(dir $@) 61 | @rm -rf $@ 62 | $(hide) ln -sf /firmware/image/$(call vfatfilename,$(notdir $@)) $@ 63 | 64 | ALL_DEFAULT_INSTALLED_MODULES += $(MLSERVERAPP_SYMLINKS) 65 | 66 | TQS_IMAGES := \ 67 | tqs.b00 tqs.b01 tqs.b02 tqs.b03 tqs.mdt 68 | 69 | TQS_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(TQS_IMAGES)) 70 | $(TQS_SYMLINKS): $(LOCAL_INSTALLED_MODULE) 71 | @echo "tqs firmware link: $@" 72 | @mkdir -p $(dir $@) 73 | @rm -rf $@ 74 | $(hide) ln -sf /firmware/image/$(call vfatfilename,$(notdir $@)) $@ 75 | 76 | ALL_DEFAULT_INSTALLED_MODULES += $(TQS_SYMLINKS) 77 | 78 | WCD9320_IMAGES := \ 79 | wcd9320_anc.bin wcd9320_mad_audio.bin wcd9320_mbhc.bin 80 | 81 | WCD9320_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/wcd9320/,$(WCD9320_IMAGES)) 82 | $(WCD9320_SYMLINKS): $(LOCAL_INSTALLED_MODULE) 83 | @echo "wcd9320 firmware link: $@" 84 | @mkdir -p $(dir $@) 85 | @rm -rf $@ 86 | tf=$(notdir $@); if [ "$$tf" = "wcd9320_mbhc.bin" ]; then tf="mbhc.bin"; fi; ln -sf /data/misc/audio/$$tf $@ 87 | 88 | ALL_DEFAULT_INSTALLED_MODULES += $(WCD9320_SYMLINKS) 89 | 90 | WIDEVINE_IMAGES := \ 91 | widevine.b00 widevine.b01 widevine.b02 widevine.b03 widevine.mdt 92 | 93 | WIDEVINE_SYMLINKS := $(addprefix $(TARGET_OUT_VENDOR)/firmware/,$(WIDEVINE_IMAGES)) 94 | $(WIDEVINE_SYMLINKS): $(LOCAL_INSTALLED_MODULE) 95 | @echo "widevine firmware link: $@" 96 | @mkdir -p $(dir $@) 97 | @rm -rf $@ 98 | $(hide) ln -sf /firmware/image/$(call vfatfilename,$(notdir $@)) $@ 99 | 100 | ALL_DEFAULT_INSTALLED_MODULES += $(WIDEVINE_SYMLINKS) 101 | 102 | endif 103 | -------------------------------------------------------------------------------- /BoardConfigCommon.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2016 The CyanogenMod Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # inherit from the proprietary version 17 | -include vendor/lge/g3-common/BoardConfigVendor.mk 18 | 19 | LOCAL_PATH := device/lge/g3-common 20 | 21 | TARGET_SPECIFIC_HEADER_PATH := $(LOCAL_PATH)/include 22 | 23 | # Platform 24 | TARGET_BOARD_PLATFORM := msm8974 25 | TARGET_BOARD_PLATFORM_GPU := qcom-adreno330 26 | 27 | # Architecture 28 | TARGET_ARCH := arm 29 | TARGET_ARCH_VARIANT := armv7-a-neon 30 | TARGET_CPU_ABI := armeabi-v7a 31 | TARGET_CPU_ABI2 := armeabi 32 | TARGET_CPU_VARIANT := krait 33 | 34 | # Bootloader 35 | TARGET_BOOTLOADER_BOARD_NAME := MSM8974 36 | TARGET_NO_BOOTLOADER := true 37 | TARGET_NO_RADIOIMAGE := true 38 | 39 | # Kernel 40 | BOARD_CUSTOM_BOOTIMG := true 41 | BOARD_CUSTOM_BOOTIMG_MK := $(LOCAL_PATH)/mkbootimg.mk 42 | BOARD_KERNEL_CMDLINE := console=none androidboot.hardware=g3 user_debug=31 msm_rtb.filter=0x0 43 | BOARD_KERNEL_BASE := 0x00000000 44 | BOARD_KERNEL_PAGESIZE := 2048 45 | BOARD_KERNEL_SEPARATED_DT := true 46 | BOARD_MKBOOTIMG_ARGS := --kernel_offset 0x0008000 --ramdisk_offset 0x2000000 47 | TARGET_KERNEL_SOURCE := kernel/lge/g3 48 | 49 | # Audio 50 | AUDIO_FEATURE_ENABLED_COMPRESS_VOIP := false 51 | AUDIO_FEATURE_ENABLED_FLUENCE := true 52 | AUDIO_FEATURE_ENABLED_HWDEP_CAL := true 53 | AUDIO_FEATURE_ENABLED_MULTI_VOICE_SESSIONS := true 54 | AUDIO_FEATURE_ENABLED_NEW_SAMPLE_RATE := true 55 | BOARD_USES_ALSA_AUDIO := true 56 | USE_CUSTOM_AUDIO_POLICY := 1 57 | 58 | # Bluetooth 59 | BOARD_HAVE_BLUETOOTH := true 60 | 61 | # Camera 62 | USE_DEVICE_SPECIFIC_CAMERA := true 63 | BOARD_GLOBAL_CFLAGS += -DCAMERA_VENDOR_L_COMPAT 64 | TARGET_HAS_LEGACY_CAMERA_HAL1 := true 65 | 66 | # CMHW 67 | BOARD_HARDWARE_CLASS := $(LOCAL_PATH)/cmhw/ 68 | TARGET_TAP_TO_WAKE_NODE := "/sys/devices/virtual/input/lge_touch/tap_to_wake" 69 | 70 | # Crypto 71 | TARGET_HW_DISK_ENCRYPTION := true 72 | 73 | # Display 74 | MAX_EGL_CACHE_KEY_SIZE := 12*1024 75 | MAX_EGL_CACHE_SIZE := 2048*1024 76 | OVERRIDE_RS_DRIVER:= libRSDriver_adreno.so 77 | TARGET_USES_C2D_COMPOSITION := true 78 | TARGET_USES_ION := true 79 | USE_OPENGL_RENDERER := true 80 | 81 | # Lights 82 | TARGET_PROVIDES_LIBLIGHT := true 83 | 84 | # Offmode Charging 85 | BOARD_CHARGING_CMDLINE_NAME := "androidboot.mode" 86 | BOARD_CHARGING_CMDLINE_VALUE := "chargerlogo" 87 | 88 | # Partitions 89 | BOARD_FLASH_BLOCK_SIZE := 131072 90 | BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4 91 | 92 | # Power 93 | TARGET_POWERHAL_VARIANT := qcom 94 | 95 | # RIL 96 | BOARD_RIL_CLASS += ../../../device/lge/g3-common/ril 97 | 98 | # Qualcomm support 99 | BOARD_USES_QCOM_HARDWARE := true 100 | 101 | # Recovery 102 | BOARD_NO_SECURE_DISCARD := true 103 | BOARD_SUPPRESS_EMMC_WIPE := true 104 | TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888" 105 | TARGET_USERIMAGES_USE_EXT4 := true 106 | 107 | # SDClang 108 | TARGET_USE_SDCLANG := true 109 | 110 | # SELinux 111 | include device/qcom/sepolicy/sepolicy.mk 112 | BOARD_SEPOLICY_DIRS += device/lge/g3-common/sepolicy 113 | 114 | # Time services 115 | BOARD_USES_QC_TIME_SERVICES := true 116 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Copyright 2014 - The CyanogenMod Project 2 | 3 | Device configuration for LG G3. 4 | ===================================== 5 | 6 | Basic | Spec Sheet 7 | -------:|:------------------------- 8 | CPU | Quad-core 2.5 GHz Krait 400 9 | CHIPSET | Qualcomm MSM8974AC Snapdragon 801 10 | GPU | Adreno 330 11 | Memory | 16GB model: 2GB RAM. 32GB model: 3GB RAM 12 | Shipped Android Version | 4.4.2 13 | Storage | 16/32GB 14 | MicroSD | Up to 128GB 15 | Battery | 3000 mAh 16 | Dimensions | 146.3 x 74.6 x 8.9 mm 17 | Display | 2560 x 1440 pixels, 5.5 in IPS LCD 18 | Rear Camera | 13 MP, Hybrid infared autofocus 19 | Front Camera | 2.1 MP 20 | Release Date | May 2014 21 | 22 | 23 | ![LG G3](http://upload.wikimedia.org/wikipedia/commons/7/7f/LG_G3.png "LG G3") 24 | -------------------------------------------------------------------------------- /bump/bump.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import print_function 4 | 5 | import binascii 6 | import os 7 | import struct 8 | import sys 9 | 10 | usage = """\ 11 | Usage: open_bump.py "" "" 12 | image_file - path to the image file to bump 13 | output_image - path to output the bumped file to (defaults to _bumped.img\ 14 | """ 15 | 16 | lg_magic = "41a9e467744d1d1ba429f2ecea655279" 17 | 18 | def bumped(image_data): 19 | d = binascii.hexlify(image_data[-1024:]) 20 | return d.endswith(lg_magic) or d.startswith(lg_magic) 21 | 22 | 23 | def pair_reverse(s): 24 | n = len(s) / 2 25 | fmt = '%dh' % n 26 | return struct.pack(fmt, *reversed(struct.unpack(fmt, s))) 27 | 28 | 29 | def get_page_size(image_name): 30 | with open(image_name, 'rb') as f_img: 31 | f_img.seek(36, 0) 32 | return int(pair_reverse(binascii.hexlify(f_img.read(4))), 16) 33 | 34 | 35 | def get_size_from_kernel(f_image, page_size, seek_size): 36 | f_image.seek(seek_size, 0) 37 | return (int(pair_reverse(binascii.hexlify(f_image.read(4))), 16) / page_size) * page_size 38 | 39 | 40 | def pad_image(image_name): 41 | page_size = get_page_size(image_name) 42 | image_size = os.path.getsize(image_name) 43 | num_pages = image_size / page_size 44 | 45 | f_image = open(image_name, 'a+b') 46 | 47 | paged_kernel_size = get_size_from_kernel(f_image, page_size, 8) 48 | paged_ramdisk_size = get_size_from_kernel(f_image, page_size, 16) 49 | paged_second_size = get_size_from_kernel(f_image, page_size, 24) 50 | if paged_second_size <= 0: 51 | paged_second_size = 0 52 | paged_dt_size = get_size_from_kernel(f_image, page_size, 40) 53 | if paged_dt_size <= 0: 54 | paged_dt_size = 0 55 | calculated_size = page_size + paged_kernel_size + paged_ramdisk_size + paged_second_size + paged_dt_size 56 | 57 | if calculated_size > image_size: 58 | print("Invalid image: %s: calculated size greater than actual size" % image_name) 59 | f_image.close() 60 | sys.exit(1) 61 | if image_size > calculated_size: 62 | difference = image_size - calculated_size 63 | if difference not in [page_size, page_size*2]: 64 | if difference not in [1024, page_size + 1024, 2 * page_size + 1024]: 65 | print("Image already padded. Attempting to remove padding...") 66 | print("Beware: this may invalidate your image.") 67 | i = num_pages - 1 68 | f_image.seek(0, 0) 69 | while i >= 0: 70 | f_image.seek(page_size * i, 0) 71 | data = f_image.read(page_size) 72 | data = data.split('\x00')[0] 73 | if not data: 74 | f_image.truncate(page_size * i) 75 | i -= 1 76 | else: 77 | break 78 | else: 79 | print("%s: Image already patched. Bailing out" % image_name) 80 | sys.exit(1) 81 | f_image.close() 82 | 83 | 84 | def finish(out_image): 85 | print("bumped image: %s" % out_image) 86 | sys.exit(0) 87 | 88 | 89 | def main(in_image, out_image): 90 | d_in_image = open(in_image, 'rb').read() 91 | open(out_image, 'wb').write(d_in_image) 92 | if bumped(d_in_image): 93 | print("Image already bumped") 94 | finish(out_image) 95 | pad_image(out_image) 96 | magic = binascii.unhexlify(lg_magic) 97 | with open(out_image, 'a+b') as f_out_image: 98 | f_out_image.write(magic) 99 | finish(out_image) 100 | 101 | 102 | def cli(): 103 | if len(sys.argv) < 2: 104 | print(usage) 105 | sys.exit(1) 106 | if sys.argv[1] in ["-h", "--help", "help"]: 107 | print(usage) 108 | sys.exit(0) 109 | image_name = sys.argv[1] 110 | if not os.path.isfile(image_name): 111 | print("file not found: %s" % image_name) 112 | sys.exit(1) 113 | if len(sys.argv) >= 3: 114 | out_image = sys.argv[2] 115 | else: 116 | out_split = os.path.splitext(image_name) 117 | out_image = out_split[0] + "_bumped" + out_split[1] 118 | main(image_name, out_image) 119 | 120 | 121 | if __name__ == '__main__': 122 | cli() 123 | -------------------------------------------------------------------------------- /camera/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_SRC_FILES := \ 5 | CameraWrapper.cpp 6 | 7 | LOCAL_SHARED_LIBRARIES := \ 8 | libhardware liblog libcamera_client libutils 9 | 10 | LOCAL_C_INCLUDES += \ 11 | system/media/camera/include 12 | 13 | LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 14 | LOCAL_MODULE := camera.$(TARGET_BOARD_PLATFORM) 15 | LOCAL_MODULE_TAGS := optional 16 | 17 | include $(BUILD_SHARED_LIBRARY) 18 | #include $(BUILD_HEAPTRACKED_SHARED_LIBRARY) 19 | -------------------------------------------------------------------------------- /cm.dependencies: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "repository": "android_kernel_lge_g3", 4 | "target_path": "kernel/lge/g3" 5 | }, 6 | { 7 | "repository": "android_device_qcom_common", 8 | "target_path": "device/qcom/common" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /cmhw/org/cyanogenmod/hardware/VibratorHW.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The CyanogenMod Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.cyanogenmod.hardware; 18 | 19 | import org.cyanogenmod.internal.util.FileUtils; 20 | 21 | public class VibratorHW { 22 | 23 | private static String NFORCE_PATH = "/sys/devices/platform/tspdrv/nforce_timed"; 24 | 25 | public static boolean isSupported() { 26 | return FileUtils.isFileWritable(NFORCE_PATH); 27 | } 28 | 29 | public static int getMaxIntensity() { 30 | return 127; 31 | } 32 | public static int getMinIntensity() { 33 | return 1; 34 | } 35 | public static int getWarningThreshold() { 36 | return 90; 37 | } 38 | public static int getCurIntensity() { 39 | return Integer.parseInt(FileUtils.readOneLine(NFORCE_PATH)); 40 | } 41 | public static int getDefaultIntensity() { 42 | return 65; 43 | } 44 | public static boolean setIntensity(int intensity) { 45 | return FileUtils.writeLine(NFORCE_PATH, String.valueOf(intensity)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /configs/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2014 The CyanogenMod Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH := $(call my-dir) 18 | 19 | include $(CLEAR_VARS) 20 | LOCAL_MODULE := hostapd_default.conf 21 | LOCAL_MODULE_TAGS := optional 22 | LOCAL_MODULE_CLASS := ETC 23 | LOCAL_SRC_FILES := $(LOCAL_MODULE) 24 | LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/hostapd 25 | include $(BUILD_PREBUILT) 26 | -------------------------------------------------------------------------------- /configs/audio/audio_platform_info_bcm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /configs/audio/audio_platform_info_qcwcn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /configs/audio/audio_policy.conf: -------------------------------------------------------------------------------- 1 | # Global configuration section: lists input and output devices always present on the device 2 | # as well as the output device selected by default. 3 | # Devices are designated by a string that corresponds to the enum in audio.h 4 | 5 | global_configuration { 6 | attached_output_devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER 7 | default_output_device AUDIO_DEVICE_OUT_SPEAKER 8 | attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_REMOTE_SUBMIX|AUDIO_DEVICE_IN_VOICE_CALL|AUDIO_DEVICE_IN_FM_TUNER 9 | } 10 | 11 | # audio hardware module section: contains descriptors for all audio hw modules present on the 12 | # device. Each hw module node is named after the corresponding hw module library base name. 13 | # For instance, "primary" corresponds to audio.primary..so. 14 | # The "primary" module is mandatory and must include at least one output with 15 | # AUDIO_OUTPUT_FLAG_PRIMARY flag. 16 | # Each module descriptor contains one or more output profile descriptors and zero or more 17 | # input profile descriptors. Each profile lists all the parameters supported by a given output 18 | # or input stream category. 19 | # The "channel_masks", "formats", "devices" and "flags" are specified using strings corresponding 20 | # to enums in audio.h and audio_policy.h. They are concatenated by use of "|" without space or "\n". 21 | 22 | audio_hw_modules { 23 | primary { 24 | outputs { 25 | primary { 26 | sampling_rates 44100|48000 27 | channel_masks AUDIO_CHANNEL_OUT_STEREO 28 | formats AUDIO_FORMAT_PCM_16_BIT 29 | devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_AUX_DIGITAL|AUDIO_DEVICE_OUT_PROXY|AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET|AUDIO_DEVICE_OUT_FM|AUDIO_DEVICE_OUT_FM_TX 30 | flags AUDIO_OUTPUT_FLAG_PRIMARY 31 | } 32 | low_latency { 33 | sampling_rates 44100|48000 34 | channel_masks AUDIO_CHANNEL_OUT_STEREO 35 | formats AUDIO_FORMAT_PCM_16_BIT 36 | devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_AUX_DIGITAL|AUDIO_DEVICE_OUT_PROXY|AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET|AUDIO_DEVICE_OUT_FM|AUDIO_DEVICE_OUT_FM_TX 37 | flags AUDIO_OUTPUT_FLAG_FAST 38 | } 39 | hdmi { 40 | sampling_rates 44100|48000 41 | channel_masks dynamic 42 | formats AUDIO_FORMAT_PCM_16_BIT 43 | devices AUDIO_DEVICE_OUT_AUX_DIGITAL 44 | flags AUDIO_OUTPUT_FLAG_DIRECT 45 | } 46 | voip_rx { 47 | sampling_rates 8000|16000 48 | channel_masks AUDIO_CHANNEL_OUT_MONO 49 | formats AUDIO_FORMAT_PCM_16_BIT|AUDIO_FORMAT_AMR_NB|AUDIO_FORMAT_AMR_WB|AUDIO_FORMAT_QCELP|AUDIO_FORMAT_EVRC|AUDIO_FORMAT_EVRCB|AUDIO_FORMAT_EVRCWB|AUDIO_FORMAT_EVRCNW 50 | devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET|AUDIO_DEVICE_OUT_ALL_SCO 51 | flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_VOIP_RX 52 | } 53 | } 54 | inputs { 55 | primary { 56 | sampling_rates 8000|11025|12000|16000|22050|24000|32000|44100|48000 57 | channel_masks AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_STEREO|AUDIO_CHANNEL_IN_FRONT_BACK 58 | formats AUDIO_FORMAT_PCM_16_BIT|AUDIO_FORMAT_AMR_NB|AUDIO_FORMAT_AMR_WB|AUDIO_FORMAT_QCELP|AUDIO_FORMAT_EVRC|AUDIO_FORMAT_EVRCB|AUDIO_FORMAT_EVRCWB|AUDIO_FORMAT_EVRCNW 59 | devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_WIRED_HEADSET|AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET|AUDIO_DEVICE_IN_VOICE_CALL|AUDIO_DEVICE_IN_FM_TUNER 60 | } 61 | } 62 | } 63 | a2dp { 64 | outputs { 65 | a2dp { 66 | sampling_rates 44100 67 | channel_masks AUDIO_CHANNEL_OUT_STEREO 68 | formats AUDIO_FORMAT_PCM_16_BIT 69 | devices AUDIO_DEVICE_OUT_ALL_A2DP 70 | } 71 | } 72 | } 73 | usb { 74 | outputs { 75 | usb_accessory { 76 | sampling_rates 44100 77 | channel_masks AUDIO_CHANNEL_OUT_STEREO 78 | formats AUDIO_FORMAT_PCM_16_BIT 79 | devices AUDIO_DEVICE_OUT_USB_ACCESSORY 80 | } 81 | usb_device { 82 | sampling_rates 44100 83 | channel_masks AUDIO_CHANNEL_OUT_STEREO 84 | formats AUDIO_FORMAT_PCM_16_BIT 85 | devices AUDIO_DEVICE_OUT_USB_DEVICE 86 | } 87 | } 88 | inputs { 89 | usb_device { 90 | sampling_rates dynamic 91 | channel_masks AUDIO_CHANNEL_IN_STEREO 92 | formats AUDIO_FORMAT_PCM_16_BIT 93 | devices AUDIO_DEVICE_IN_USB_DEVICE 94 | } 95 | } 96 | } 97 | r_submix { 98 | outputs { 99 | submix { 100 | sampling_rates 48000 101 | channel_masks AUDIO_CHANNEL_OUT_STEREO 102 | formats AUDIO_FORMAT_PCM_16_BIT 103 | devices AUDIO_DEVICE_OUT_REMOTE_SUBMIX 104 | } 105 | } 106 | inputs { 107 | submix { 108 | sampling_rates 48000 109 | channel_masks AUDIO_CHANNEL_IN_STEREO 110 | formats AUDIO_FORMAT_PCM_16_BIT 111 | devices AUDIO_DEVICE_IN_REMOTE_SUBMIX 112 | } 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /configs/nfc/nfcee_access.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /configs/thermal-engine-8974.conf: -------------------------------------------------------------------------------- 1 | sampling 5000 2 | c_mode 3 3 | 4 | [CPU_LCD_management] 5 | algo_type monitor 6 | sensor xo_therm_pu2 7 | sampling 10000 8 | thresholds 45000 47000 49000 51000 53000 55000 9 | thresholds_clr 44000 45500 47500 49500 51500 53500 10 | actions cpu+lcd cpu+lcd cpu+lcd cpu+lcd cpu+lcd cpu+lcd 11 | action_info FFFFFFF+255 1728000+235 1497600+235 1267200+235 1190400+215 1190400+215 12 | action_type 25000 13 | 14 | [GPU_management] 15 | algo_type monitor 16 | sensor xo_therm_pu2 17 | sampling 10000 18 | thresholds 47000 50000 53000 19 | thresholds_clr 46500 47500 50500 20 | actions gpu gpu gpu 21 | action_info 462400000 389000000 330000000 22 | action_type 25000 23 | 24 | [battery_monitor] 25 | algo_type monitor 26 | sensor xo_batt 27 | sampling 10000 28 | thresholds 47000 48000 49000 50000 51000 29 | thresholds_clr 46000 47000 48000 49000 50000 30 | actions battery battery battery battery battery 31 | action_info 1024 768 512 410 307 32 | 33 | [iusb_monitor] 34 | algo_type monitor 35 | sensor xo_therm_pu2 36 | sampling 10000 37 | thresholds 47000 38 | thresholds_clr 45000 39 | actions iusb 40 | action_info 1500 41 | 42 | [wlchg_monitor] 43 | algo_type monitor 44 | sensor xo_therm_pu2 45 | sampling 10000 46 | thresholds 52000 47 | thresholds_clr 50000 48 | actions wlchg 49 | action_info 512 50 | 51 | [wlchg_volt_monitor] 52 | algo_type monitor 53 | sensor batt_volt 54 | sampling 10000 55 | thresholds 4100 56 | thresholds_clr 4000 57 | actions wlchg 58 | action_info 512 59 | 60 | [GBMONITOR] 61 | algo_type monitor 62 | sensor xo_therm 63 | sampling 10000 64 | thresholds 43000 45000 55000 65 | thresholds_clr 41500 43500 53500 66 | actions gbmonitor gbmonitor gbmonitor 67 | action_info 0 1 2 68 | 69 | [CPU0_MONITOR] 70 | algo_type monitor 71 | sensor cpu0 72 | sampling 65 73 | thresholds 120000 74 | thresholds_clr 115000 75 | actions shutdown 76 | action_info 0 77 | 78 | [CPU1_MONITOR] 79 | algo_type monitor 80 | sensor cpu1 81 | sampling 65 82 | thresholds 120000 83 | thresholds_clr 115000 84 | actions shutdown 85 | action_info 0 86 | 87 | [CPU2_MONITOR] 88 | algo_type monitor 89 | sensor cpu2 90 | sampling 65 91 | thresholds 120000 92 | thresholds_clr 115000 93 | actions shutdown 94 | action_info 0 95 | 96 | [CPU3_MONITOR] 97 | algo_type monitor 98 | sensor cpu3 99 | sampling 65 100 | thresholds 120000 101 | thresholds_clr 115000 102 | actions shutdown 103 | action_info 0 104 | 105 | [SS-CPU0] 106 | algo_type ss 107 | sampling 65 108 | sensor cpu0 109 | device cpu 110 | set_point 85000 111 | set_point_clr 55000 112 | action_type 10000 113 | 114 | [SS-CPU1] 115 | algo_type ss 116 | sampling 65 117 | sensor cpu1 118 | device cpu 119 | set_point 85000 120 | set_point_clr 55000 121 | action_type 10000 122 | 123 | [SS-CPU2] 124 | algo_type ss 125 | sampling 65 126 | sensor cpu2 127 | device cpu 128 | set_point 85000 129 | set_point_clr 55000 130 | action_type 10000 131 | 132 | [SS-CPU3] 133 | algo_type ss 134 | sampling 65 135 | sensor cpu3 136 | device cpu 137 | set_point 85000 138 | set_point_clr 55000 139 | action_type 10000 140 | 141 | [SS-POPMEM] 142 | algo_type ss 143 | sampling 65 144 | sensor pop_mem 145 | device cpu 146 | set_point 80000 147 | set_point_clr 55000 148 | time_constant 16 149 | 150 | -------------------------------------------------------------------------------- /extract-files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2016 The CyanogenMod Project 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | set -e 19 | 20 | DEVICE_COMMON=g3-common 21 | VENDOR=lge 22 | 23 | # Load extractutils and do some sanity checks 24 | MY_DIR="${BASH_SOURCE%/*}" 25 | if [[ ! -d "$MY_DIR" ]]; then MY_DIR="$PWD"; fi 26 | 27 | CM_ROOT="$MY_DIR"/../../.. 28 | 29 | HELPER="$CM_ROOT"/vendor/cm/build/tools/extract_utils.sh 30 | if [ ! -f "$HELPER" ]; then 31 | echo "Unable to find helper script at $HELPER" 32 | exit 1 33 | fi 34 | . "$HELPER" 35 | 36 | if [ $# -eq 0 ]; then 37 | SRC=adb 38 | else 39 | if [ $# -eq 1 ]; then 40 | SRC=$1 41 | else 42 | echo "$0: bad number of arguments" 43 | echo "" 44 | echo "usage: $0 [PATH_TO_EXPANDED_ROM]" 45 | echo "" 46 | echo "If PATH_TO_EXPANDED_ROM is not specified, blobs will be extracted from" 47 | echo "the device using adb pull." 48 | exit 1 49 | fi 50 | fi 51 | 52 | # Initialize the helper for common device 53 | setup_vendor "$DEVICE_COMMON" "$VENDOR" "$CM_ROOT" true 54 | 55 | extract "$MY_DIR"/proprietary-files.txt "$SRC" 56 | 57 | # Initialize the helper for device 58 | setup_vendor "$DEVICE" "$VENDOR" "$CM_ROOT" 59 | 60 | extract "$MY_DIR"/../$DEVICE/proprietary-files.txt "$SRC" 61 | 62 | "$MY_DIR"/setup-makefiles.sh 63 | -------------------------------------------------------------------------------- /gps/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(call all-makefiles-under,$(LOCAL_PATH)) 4 | -------------------------------------------------------------------------------- /gps/core/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libloc_core 6 | LOCAL_MODULE_OWNER := qcom 7 | 8 | LOCAL_MODULE_TAGS := optional 9 | 10 | ifeq ($(TARGET_DEVICE),apq8026_lw) 11 | LOCAL_CFLAGS += -DPDK_FEATURE_SET 12 | endif 13 | 14 | LOCAL_SHARED_LIBRARIES := \ 15 | libutils \ 16 | libcutils \ 17 | libgps.utils \ 18 | libdl 19 | 20 | LOCAL_SRC_FILES += \ 21 | MsgTask.cpp \ 22 | LocApiBase.cpp \ 23 | LocAdapterBase.cpp \ 24 | ContextBase.cpp \ 25 | LocDualContext.cpp \ 26 | loc_core_log.cpp 27 | 28 | LOCAL_CFLAGS += \ 29 | -fno-short-enums \ 30 | -D_ANDROID_ 31 | 32 | LOCAL_C_INCLUDES:= \ 33 | $(TARGET_OUT_HEADERS)/gps.utils 34 | 35 | LOCAL_COPY_HEADERS_TO:= libloc_core/ 36 | LOCAL_COPY_HEADERS:= \ 37 | MsgTask.h \ 38 | LocApiBase.h \ 39 | LocAdapterBase.h \ 40 | ContextBase.h \ 41 | LocDualContext.h \ 42 | LBSProxyBase.h \ 43 | UlpProxyBase.h \ 44 | gps_extended_c.h \ 45 | gps_extended.h \ 46 | loc_core_log.h \ 47 | LocAdapterProxyBase.h 48 | 49 | LOCAL_PRELINK_MODULE := false 50 | 51 | include $(BUILD_SHARED_LIBRARY) 52 | -------------------------------------------------------------------------------- /gps/core/ContextBase.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #define LOG_NDDEBUG 0 30 | #define LOG_TAG "LocSvc_CtxBase" 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | namespace loc_core { 42 | 43 | LBSProxyBase* ContextBase::getLBSProxy(const char* libName) 44 | { 45 | LBSProxyBase* proxy = NULL; 46 | LOC_LOGD("%s:%d]: getLBSProxy libname: %s\n", __func__, __LINE__, libName); 47 | void* lib = dlopen(libName, RTLD_NOW); 48 | 49 | if ((void*)NULL != lib) { 50 | getLBSProxy_t* getter = (getLBSProxy_t*)dlsym(lib, "getLBSProxy"); 51 | if (NULL != getter) { 52 | proxy = (*getter)(); 53 | } 54 | } 55 | if (NULL == proxy) { 56 | proxy = new LBSProxyBase(); 57 | } 58 | LOC_LOGD("%s:%d]: Exiting\n", __func__, __LINE__); 59 | return proxy; 60 | } 61 | 62 | LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask) 63 | { 64 | LocApiBase* locApi = NULL; 65 | 66 | // first if can not be MPQ 67 | if (TARGET_MPQ != loc_get_target()) { 68 | if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask, this))) { 69 | void *handle = NULL; 70 | //try to see if LocApiV02 is present 71 | if((handle = dlopen("libloc_api_v02.so", RTLD_NOW)) != NULL) { 72 | LOC_LOGD("%s:%d]: libloc_api_v02.so is present", __func__, __LINE__); 73 | getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi"); 74 | if(getter != NULL) { 75 | LOC_LOGD("%s:%d]: getter is not NULL for LocApiV02", __func__, __LINE__); 76 | locApi = (*getter)(mMsgTask, exMask, this); 77 | } 78 | } 79 | // only RPC is the option now 80 | else { 81 | LOC_LOGD("%s:%d]: libloc_api_v02.so is NOT present. Trying RPC", 82 | __func__, __LINE__); 83 | handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW); 84 | if (NULL != handle) { 85 | getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi"); 86 | if (NULL != getter) { 87 | LOC_LOGD("%s:%d]: getter is not NULL in RPC", __func__, __LINE__); 88 | locApi = (*getter)(mMsgTask, exMask, this); 89 | } 90 | } 91 | } 92 | } 93 | } 94 | 95 | // locApi could still be NULL at this time 96 | // we would then create a dummy one 97 | if (NULL == locApi) { 98 | locApi = new LocApiBase(mMsgTask, exMask, this); 99 | } 100 | 101 | return locApi; 102 | } 103 | 104 | ContextBase::ContextBase(const MsgTask* msgTask, 105 | LOC_API_ADAPTER_EVENT_MASK_T exMask, 106 | const char* libName) : 107 | mLBSProxy(getLBSProxy(libName)), 108 | mMsgTask(msgTask), 109 | mLocApi(createLocApi(exMask)), 110 | mLocApiProxy(mLocApi->getLocApiProxy()) 111 | { 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /gps/core/ContextBase.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef __LOC_CONTEXT_BASE__ 30 | #define __LOC_CONTEXT_BASE__ 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | namespace loc_core { 39 | 40 | class LocAdapterBase; 41 | 42 | class ContextBase { 43 | static LBSProxyBase* getLBSProxy(const char* libName); 44 | LocApiBase* createLocApi(LOC_API_ADAPTER_EVENT_MASK_T excludedMask); 45 | protected: 46 | const LBSProxyBase* mLBSProxy; 47 | const MsgTask* mMsgTask; 48 | LocApiBase* mLocApi; 49 | LocApiProxyBase *mLocApiProxy; 50 | public: 51 | ContextBase(const MsgTask* msgTask, 52 | LOC_API_ADAPTER_EVENT_MASK_T exMask, 53 | const char* libName); 54 | inline virtual ~ContextBase() { delete mLocApi; delete mLBSProxy; } 55 | 56 | inline const MsgTask* getMsgTask() { return mMsgTask; } 57 | inline LocApiBase* getLocApi() { return mLocApi; } 58 | inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; } 59 | inline bool hasAgpsExtendedCapabilities() { return mLBSProxy->hasAgpsExtendedCapabilities(); } 60 | inline bool hasCPIExtendedCapabilities() { return mLBSProxy->hasCPIExtendedCapabilities(); } 61 | inline void requestUlp(LocAdapterBase* adapter, 62 | unsigned long capabilities) { 63 | mLBSProxy->requestUlp(adapter, capabilities); 64 | } 65 | inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); } 66 | }; 67 | 68 | } // namespace loc_core 69 | 70 | #endif //__LOC_CONTEXT_BASE__ 71 | -------------------------------------------------------------------------------- /gps/core/LBSProxyBase.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef IZAT_PROXY_BASE_H 30 | #define IZAT_PROXY_BASE_H 31 | #include 32 | #include 33 | 34 | namespace loc_core { 35 | 36 | class LocApiBase; 37 | class LocAdapterBase; 38 | class ContextBase; 39 | 40 | class LBSProxyBase { 41 | friend class ContextBase; 42 | inline virtual LocApiBase* 43 | getLocApi(const MsgTask* msgTask, 44 | LOC_API_ADAPTER_EVENT_MASK_T exMask, 45 | ContextBase* context) const { 46 | return NULL; 47 | } 48 | protected: 49 | inline LBSProxyBase() {} 50 | public: 51 | inline virtual ~LBSProxyBase() {} 52 | inline virtual void requestUlp(LocAdapterBase* adapter, 53 | unsigned long capabilities) const {} 54 | inline virtual bool hasAgpsExtendedCapabilities() const { return false; } 55 | inline virtual bool hasCPIExtendedCapabilities() const { return false; } 56 | virtual void injectFeatureConfig(ContextBase* context) const {} 57 | }; 58 | 59 | typedef LBSProxyBase* (getLBSProxy_t)(); 60 | 61 | } // namespace loc_core 62 | 63 | #endif // IZAT_PROXY_BASE_H 64 | -------------------------------------------------------------------------------- /gps/core/LocAdapterBase.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #define LOG_NDDEBUG 0 30 | #define LOG_TAG "LocSvc_LocAdapterBase" 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | namespace loc_core { 39 | 40 | // This is the top level class, so the constructor will 41 | // always gets called. Here we prepare for the default. 42 | // But if getLocApi(targetEnumType target) is overriden, 43 | // the right locApi should get created. 44 | LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, 45 | ContextBase* context, LocAdapterProxyBase *adapterProxyBase) : 46 | mEvtMask(mask), mContext(context), 47 | mLocApi(context->getLocApi()), mLocAdapterProxyBase(adapterProxyBase), 48 | mMsgTask(context->getMsgTask()) 49 | { 50 | mLocApi->addAdapter(this); 51 | } 52 | 53 | void LocAdapterBase::handleEngineUpEvent() 54 | { 55 | if (mLocAdapterProxyBase) { 56 | mLocAdapterProxyBase->handleEngineUpEvent(); 57 | } 58 | } 59 | 60 | void LocAdapterBase::handleEngineDownEvent() 61 | { 62 | if (mLocAdapterProxyBase) { 63 | mLocAdapterProxyBase->handleEngineDownEvent(); 64 | } 65 | } 66 | 67 | void LocAdapterBase:: 68 | reportPosition(UlpLocation &location, 69 | GpsLocationExtended &locationExtended, 70 | void* locationExt, 71 | enum loc_sess_status status, 72 | LocPosTechMask loc_technology_mask) 73 | DEFAULT_IMPL() 74 | 75 | void LocAdapterBase:: 76 | reportSv(GpsSvStatus &svStatus, 77 | GpsLocationExtended &locationExtended, 78 | void* svExt) 79 | DEFAULT_IMPL() 80 | 81 | 82 | void LocAdapterBase:: 83 | reportStatus(GpsStatusValue status) 84 | DEFAULT_IMPL() 85 | 86 | 87 | void LocAdapterBase:: 88 | reportNmea(const char* nmea, int length) 89 | DEFAULT_IMPL() 90 | 91 | bool LocAdapterBase:: 92 | reportXtraServer(const char* url1, const char* url2, 93 | const char* url3, const int maxlength) 94 | DEFAULT_IMPL(false) 95 | 96 | bool LocAdapterBase:: 97 | requestXtraData() 98 | DEFAULT_IMPL(false) 99 | 100 | bool LocAdapterBase:: 101 | requestTime() 102 | DEFAULT_IMPL(false) 103 | 104 | bool LocAdapterBase:: 105 | requestLocation() 106 | DEFAULT_IMPL(false) 107 | 108 | bool LocAdapterBase:: 109 | requestATL(int connHandle, AGpsType agps_type) 110 | DEFAULT_IMPL(false) 111 | 112 | bool LocAdapterBase:: 113 | releaseATL(int connHandle) 114 | DEFAULT_IMPL(false) 115 | 116 | bool LocAdapterBase:: 117 | requestSuplES(int connHandle) 118 | DEFAULT_IMPL(false) 119 | 120 | bool LocAdapterBase:: 121 | reportDataCallOpened() 122 | DEFAULT_IMPL(false) 123 | 124 | bool LocAdapterBase:: 125 | reportDataCallClosed() 126 | DEFAULT_IMPL(false) 127 | 128 | bool LocAdapterBase:: 129 | requestNiNotify(GpsNiNotification ¬ify, const void* data) 130 | DEFAULT_IMPL(false) 131 | 132 | void LocAdapterBase:: 133 | shutdown() 134 | DEFAULT_IMPL() 135 | } // namespace loc_core 136 | -------------------------------------------------------------------------------- /gps/core/LocAdapterBase.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef LOC_API_ADAPTER_BASE_H 30 | #define LOC_API_ADAPTER_BASE_H 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | namespace loc_core { 37 | 38 | class LocAdapterProxyBase; 39 | 40 | class LocAdapterBase { 41 | protected: 42 | LOC_API_ADAPTER_EVENT_MASK_T mEvtMask; 43 | ContextBase* mContext; 44 | LocApiBase* mLocApi; 45 | LocAdapterProxyBase* mLocAdapterProxyBase; 46 | const MsgTask* mMsgTask; 47 | 48 | inline LocAdapterBase(const MsgTask* msgTask) : 49 | mEvtMask(0), mContext(NULL), mLocApi(NULL), 50 | mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {} 51 | public: 52 | inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); } 53 | LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, 54 | ContextBase* context, LocAdapterProxyBase *adapterProxyBase = NULL); 55 | inline LOC_API_ADAPTER_EVENT_MASK_T 56 | checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const { 57 | return mEvtMask & mask; 58 | } 59 | 60 | inline LOC_API_ADAPTER_EVENT_MASK_T getEvtMask() const { 61 | return mEvtMask; 62 | } 63 | 64 | inline void sendMsg(const LocMsg* msg) const { 65 | mMsgTask->sendMsg(msg); 66 | } 67 | 68 | inline void sendMsg(const LocMsg* msg) { 69 | mMsgTask->sendMsg(msg); 70 | } 71 | 72 | inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event, 73 | loc_registration_mask_status isEnabled) 74 | { 75 | mEvtMask = 76 | isEnabled == LOC_REGISTRATION_MASK_ENABLED ? (mEvtMask|event):(mEvtMask&~event); 77 | 78 | mLocApi->updateEvtMask(); 79 | } 80 | 81 | // This will be overridden by the individual adapters 82 | // if necessary. 83 | inline virtual void setUlpProxy(UlpProxyBase* ulp) {} 84 | virtual void handleEngineUpEvent(); 85 | virtual void handleEngineDownEvent(); 86 | inline virtual void setPositionModeInt(LocPosMode& posMode) {} 87 | virtual void startFixInt() {} 88 | virtual void stopFixInt() {} 89 | virtual void getZppInt() {} 90 | virtual void reportPosition(UlpLocation &location, 91 | GpsLocationExtended &locationExtended, 92 | void* locationExt, 93 | enum loc_sess_status status, 94 | LocPosTechMask loc_technology_mask); 95 | virtual void reportSv(GpsSvStatus &svStatus, 96 | GpsLocationExtended &locationExtended, 97 | void* svExt); 98 | virtual void reportStatus(GpsStatusValue status); 99 | virtual void reportNmea(const char* nmea, int length); 100 | virtual bool reportXtraServer(const char* url1, const char* url2, 101 | const char* url3, const int maxlength); 102 | virtual bool requestXtraData(); 103 | virtual bool requestTime(); 104 | virtual bool requestLocation(); 105 | virtual bool requestATL(int connHandle, AGpsType agps_type); 106 | virtual bool releaseATL(int connHandle); 107 | virtual bool requestSuplES(int connHandle); 108 | virtual bool reportDataCallOpened(); 109 | virtual bool reportDataCallClosed(); 110 | virtual bool requestNiNotify(GpsNiNotification ¬ify, 111 | const void* data); 112 | inline virtual bool isInSession() { return false; } 113 | virtual void shutdown(); 114 | ContextBase* getContext() const { return mContext; } 115 | }; 116 | 117 | } // namespace loc_core 118 | 119 | #endif //LOC_API_ADAPTER_BASE_H 120 | -------------------------------------------------------------------------------- /gps/core/LocAdapterProxyBase.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef LOC_ADAPTER_PROXY_BASE_H 31 | #define LOC_ADAPTER_PROXY_BASE_H 32 | 33 | #include 34 | #include 35 | 36 | namespace loc_core { 37 | 38 | class LocAdapterProxyBase { 39 | private: 40 | LocAdapterBase *mLocAdapterBase; 41 | protected: 42 | inline LocAdapterProxyBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, 43 | ContextBase* context): 44 | mLocAdapterBase(new LocAdapterBase(mask, context, this)) { 45 | } 46 | inline virtual ~LocAdapterProxyBase() { 47 | delete mLocAdapterBase; 48 | } 49 | ContextBase* getContext() const { 50 | return mLocAdapterBase->getContext(); 51 | } 52 | inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event, 53 | loc_registration_mask_status isEnabled) { 54 | mLocAdapterBase->updateEvtMask(event,isEnabled); 55 | } 56 | 57 | public: 58 | inline virtual void handleEngineUpEvent() {}; 59 | inline virtual void handleEngineDownEvent() {}; 60 | }; 61 | 62 | } // namespace loc_core 63 | 64 | #endif //LOC_ADAPTER_PROXY_BASE_H 65 | -------------------------------------------------------------------------------- /gps/core/LocDualContext.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef __LOC_ENG_CONTEXT__ 30 | #define __LOC_ENG_CONTEXT__ 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace loc_core { 38 | 39 | class LocDualContext : public ContextBase { 40 | static const MsgTask* mMsgTask; 41 | static ContextBase* mFgContext; 42 | static ContextBase* mBgContext; 43 | static ContextBase* mInjectContext; 44 | static const MsgTask* getMsgTask(MsgTask::tCreate tCreator, 45 | const char* name); 46 | static const MsgTask* getMsgTask(MsgTask::tAssociate tAssociate, 47 | const char* name); 48 | static pthread_mutex_t mGetLocContextMutex; 49 | 50 | protected: 51 | LocDualContext(const MsgTask* msgTask, 52 | LOC_API_ADAPTER_EVENT_MASK_T exMask); 53 | inline virtual ~LocDualContext() {} 54 | 55 | public: 56 | static const char* mLBSLibName; 57 | static const LOC_API_ADAPTER_EVENT_MASK_T mFgExclMask; 58 | static const LOC_API_ADAPTER_EVENT_MASK_T mBgExclMask; 59 | static const char* mLocationHalName; 60 | 61 | static ContextBase* getLocFgContext(MsgTask::tCreate tCreator, 62 | const char* name); 63 | static ContextBase* getLocFgContext(MsgTask::tAssociate tAssociate, 64 | const char* name); 65 | static ContextBase* getLocBgContext(MsgTask::tCreate tCreator, 66 | const char* name); 67 | static ContextBase* getLocBgContext(MsgTask::tAssociate tAssociate, 68 | const char* name); 69 | static void injectFeatureConfig(ContextBase *context); 70 | }; 71 | 72 | } 73 | 74 | #endif //__LOC_ENG_CONTEXT__ 75 | -------------------------------------------------------------------------------- /gps/core/MsgTask.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #define LOG_NDDEBUG 0 30 | #define LOG_TAG "LocSvc_MsgTask" 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | namespace loc_core { 40 | 41 | #define MAX_TASK_COMM_LEN 15 42 | 43 | static void LocMsgDestroy(void* msg) { 44 | delete (LocMsg*)msg; 45 | } 46 | 47 | MsgTask::MsgTask(tCreate tCreator, const char* threadName) : 48 | mQ(msg_q_init2()), mAssociator(NULL){ 49 | if (tCreator) { 50 | tCreator(threadName, loopMain, 51 | (void*)new MsgTask(mQ, mAssociator)); 52 | } else { 53 | createPThread(threadName); 54 | } 55 | } 56 | 57 | MsgTask::MsgTask(tAssociate tAssociator, const char* threadName) : 58 | mQ(msg_q_init2()), mAssociator(tAssociator){ 59 | createPThread(threadName); 60 | } 61 | 62 | inline 63 | MsgTask::MsgTask(const void* q, tAssociate associator) : 64 | mQ(q), mAssociator(associator){ 65 | } 66 | 67 | MsgTask::~MsgTask() { 68 | msg_q_unblock((void*)mQ); 69 | } 70 | 71 | void MsgTask::associate(tAssociate tAssociator) const { 72 | struct LocAssociateMsg : public LocMsg { 73 | tAssociate mAssociator; 74 | inline LocAssociateMsg(tAssociate associator) : 75 | LocMsg(), mAssociator(associator) {} 76 | inline virtual void proc() const { 77 | if (mAssociator) { 78 | LOC_LOGD("MsgTask::associate"); 79 | mAssociator(); 80 | } 81 | } 82 | }; 83 | sendMsg(new LocAssociateMsg(tAssociator)); 84 | } 85 | 86 | void MsgTask::createPThread(const char* threadName) { 87 | pthread_attr_t attr; 88 | pthread_attr_init(&attr); 89 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 90 | 91 | pthread_t tid; 92 | // create the thread here, then if successful 93 | // and a name is given, we set the thread name 94 | if (!pthread_create(&tid, &attr, loopMain, 95 | (void*)new MsgTask(mQ, mAssociator)) && 96 | NULL != threadName) { 97 | char lname[MAX_TASK_COMM_LEN+1]; 98 | memcpy(lname, threadName, MAX_TASK_COMM_LEN); 99 | lname[MAX_TASK_COMM_LEN] = 0; 100 | pthread_setname_np(tid, lname); 101 | } 102 | } 103 | 104 | void MsgTask::sendMsg(const LocMsg* msg) const { 105 | msg_q_snd((void*)mQ, (void*)msg, LocMsgDestroy); 106 | } 107 | 108 | void* MsgTask::loopMain(void* arg) { 109 | MsgTask* copy = (MsgTask*)arg; 110 | 111 | // make sure we do not run in background scheduling group 112 | set_sched_policy(gettid(), SP_FOREGROUND); 113 | 114 | if (NULL != copy->mAssociator) { 115 | copy->mAssociator(); 116 | } 117 | 118 | LocMsg* msg; 119 | int cnt = 0; 120 | 121 | while (1) { 122 | LOC_LOGD("MsgTask::loop() %d listening ...\n", cnt++); 123 | 124 | msq_q_err_type result = msg_q_rcv((void*)copy->mQ, (void **)&msg); 125 | 126 | if (eMSG_Q_SUCCESS != result) { 127 | LOC_LOGE("%s:%d] fail receiving msg: %s\n", __func__, __LINE__, 128 | loc_get_msg_q_status(result)); 129 | // destroy the Q and exit 130 | msg_q_destroy((void**)&(copy->mQ)); 131 | delete copy; 132 | return NULL; 133 | } 134 | 135 | msg->log(); 136 | // there is where each individual msg handling is invoked 137 | msg->proc(); 138 | 139 | delete msg; 140 | } 141 | 142 | delete copy; 143 | 144 | return NULL; 145 | } 146 | 147 | } 148 | -------------------------------------------------------------------------------- /gps/core/MsgTask.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef __MSG_TASK__ 30 | #define __MSG_TASK__ 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace loc_core { 38 | 39 | struct LocMsg { 40 | inline LocMsg() {} 41 | inline virtual ~LocMsg() {} 42 | virtual void proc() const = 0; 43 | inline virtual void log() const {} 44 | }; 45 | 46 | class MsgTask { 47 | public: 48 | typedef void* (*tStart)(void*); 49 | typedef pthread_t (*tCreate)(const char* name, tStart start, void* arg); 50 | typedef int (*tAssociate)(); 51 | MsgTask(tCreate tCreator, const char* threadName); 52 | MsgTask(tAssociate tAssociator, const char* threadName); 53 | ~MsgTask(); 54 | void sendMsg(const LocMsg* msg) const; 55 | void associate(tAssociate tAssociator) const; 56 | 57 | private: 58 | const void* mQ; 59 | tAssociate mAssociator; 60 | MsgTask(const void* q, tAssociate associator); 61 | static void* loopMain(void* copy); 62 | void createPThread(const char* name); 63 | }; 64 | 65 | } // namespace loc_core 66 | 67 | #endif //__MSG_TASK__ 68 | -------------------------------------------------------------------------------- /gps/core/UlpProxyBase.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef ULP_PROXY_BASE_H 30 | #define ULP_PROXY_BASE_H 31 | 32 | #include 33 | 34 | namespace loc_core { 35 | 36 | class LocAdapterBase; 37 | 38 | class UlpProxyBase { 39 | public: 40 | LocPosMode mPosMode; 41 | bool mFixSet; 42 | inline UlpProxyBase() { 43 | mPosMode.mode = LOC_POSITION_MODE_INVALID; 44 | mFixSet = false; 45 | } 46 | inline virtual ~UlpProxyBase() {} 47 | inline virtual bool sendStartFix() { mFixSet = true; return false; } 48 | inline virtual bool sendStopFix() { mFixSet = false; return false; } 49 | inline virtual bool sendFixMode(LocPosMode ¶ms) { 50 | mPosMode = params; 51 | return false; 52 | } 53 | 54 | inline virtual bool reportPosition(UlpLocation &location, 55 | GpsLocationExtended &locationExtended, 56 | void* locationExt, 57 | enum loc_sess_status status, 58 | LocPosTechMask loc_technology_mask) { 59 | return false; 60 | } 61 | inline virtual bool reportSv(GpsSvStatus &svStatus, 62 | GpsLocationExtended &locationExtended, 63 | void* svExt) { 64 | return false; 65 | } 66 | inline virtual bool reportStatus(GpsStatusValue status) { 67 | return false; 68 | } 69 | inline virtual void setAdapter(LocAdapterBase* adapter) {} 70 | inline virtual void setCapabilities(unsigned long capabilities) {} 71 | inline virtual bool reportBatchingSession(GpsExtBatchOptions &options, 72 | bool active) { 73 | return false; 74 | } 75 | inline virtual bool reportPositions(GpsExtLocation * locations, 76 | int32_t number_of_locations, 77 | enum loc_sess_status status, 78 | LocPosTechMask techMask) { 79 | return false; 80 | } 81 | }; 82 | 83 | } // namespace loc_core 84 | 85 | #endif // ULP_PROXY_BASE_H 86 | -------------------------------------------------------------------------------- /gps/core/gps_extended.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef GPS_EXTENDED_H 30 | #define GPS_EXTENDED_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif /* __cplusplus */ 35 | 36 | #include 37 | #include 38 | 39 | struct LocPosMode 40 | { 41 | LocPositionMode mode; 42 | GpsPositionRecurrence recurrence; 43 | uint32_t min_interval; 44 | uint32_t preferred_accuracy; 45 | uint32_t preferred_time; 46 | char credentials[14]; 47 | char provider[8]; 48 | LocPosMode(LocPositionMode m, GpsPositionRecurrence recr, 49 | uint32_t gap, uint32_t accu, uint32_t time, 50 | const char* cred, const char* prov) : 51 | mode(m), recurrence(recr), 52 | min_interval(gap < MIN_POSSIBLE_FIX_INTERVAL ? MIN_POSSIBLE_FIX_INTERVAL : gap), 53 | preferred_accuracy(accu), preferred_time(time) { 54 | memset(credentials, 0, sizeof(credentials)); 55 | memset(provider, 0, sizeof(provider)); 56 | if (NULL != cred) { 57 | memcpy(credentials, cred, sizeof(credentials)-1); 58 | } 59 | if (NULL != prov) { 60 | memcpy(provider, prov, sizeof(provider)-1); 61 | } 62 | } 63 | 64 | inline LocPosMode() : 65 | mode(LOC_POSITION_MODE_MS_BASED), 66 | recurrence(GPS_POSITION_RECURRENCE_PERIODIC), 67 | min_interval(MIN_POSSIBLE_FIX_INTERVAL), 68 | preferred_accuracy(50), preferred_time(120000) { 69 | memset(credentials, 0, sizeof(credentials)); 70 | memset(provider, 0, sizeof(provider)); 71 | } 72 | 73 | inline bool equals(const LocPosMode &anotherMode) const 74 | { 75 | return anotherMode.mode == mode && 76 | anotherMode.recurrence == recurrence && 77 | anotherMode.min_interval == min_interval && 78 | anotherMode.preferred_accuracy == preferred_accuracy && 79 | anotherMode.preferred_time == preferred_time && 80 | !strncmp(anotherMode.credentials, credentials, sizeof(credentials)-1) && 81 | !strncmp(anotherMode.provider, provider, sizeof(provider)-1); 82 | } 83 | 84 | void logv() const; 85 | }; 86 | 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif /* __cplusplus */ 91 | 92 | #endif /* GPS_EXTENDED_H */ 93 | 94 | -------------------------------------------------------------------------------- /gps/core/loc_core_log.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef LOC_CORE_LOG_H 31 | #define LOC_CORE_LOG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif 37 | 38 | #include 39 | #include 40 | 41 | const char* loc_get_gps_status_name(GpsStatusValue gps_status); 42 | const char* loc_get_position_mode_name(GpsPositionMode mode); 43 | const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur); 44 | const char* loc_get_aiding_data_mask_names(GpsAidingData data); 45 | const char* loc_get_agps_type_name(AGpsType type); 46 | const char* loc_get_ni_type_name(GpsNiType type); 47 | const char* loc_get_ni_response_name(GpsUserResponseType response); 48 | const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding); 49 | const char* loc_get_agps_bear_name(AGpsBearerType bear); 50 | const char* loc_get_server_type_name(LocServerType type); 51 | const char* loc_get_position_sess_status_name(enum loc_sess_status status); 52 | const char* loc_get_agps_status_name(AGpsStatusValue status); 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif /* LOC_CORE_LOG_H */ 59 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/Android.mk: -------------------------------------------------------------------------------- 1 | #Compile this library only for builds with the latest modem image 2 | 3 | LOCAL_PATH := $(call my-dir) 4 | 5 | include $(CLEAR_VARS) 6 | 7 | LOCAL_MODULE := libloc_eng 8 | LOCAL_MODULE_OWNER := qcom 9 | 10 | LOCAL_MODULE_TAGS := optional 11 | 12 | LOCAL_SHARED_LIBRARIES := \ 13 | libutils \ 14 | libcutils \ 15 | libdl \ 16 | liblog \ 17 | libloc_core \ 18 | libgps.utils 19 | 20 | LOCAL_SRC_FILES += \ 21 | loc_eng.cpp \ 22 | loc_eng_agps.cpp \ 23 | loc_eng_xtra.cpp \ 24 | loc_eng_ni.cpp \ 25 | loc_eng_log.cpp \ 26 | loc_eng_nmea.cpp \ 27 | LocEngAdapter.cpp 28 | 29 | LOCAL_SRC_FILES += \ 30 | loc_eng_dmn_conn.cpp \ 31 | loc_eng_dmn_conn_handler.cpp \ 32 | loc_eng_dmn_conn_thread_helper.c \ 33 | loc_eng_dmn_conn_glue_msg.c \ 34 | loc_eng_dmn_conn_glue_pipe.c 35 | 36 | LOCAL_CFLAGS += \ 37 | -fno-short-enums \ 38 | -D_ANDROID_ 39 | 40 | LOCAL_C_INCLUDES:= \ 41 | $(TARGET_OUT_HEADERS)/gps.utils \ 42 | $(TARGET_OUT_HEADERS)/libloc_core \ 43 | $(LOCAL_PATH) 44 | 45 | LOCAL_COPY_HEADERS_TO:= libloc_eng/ 46 | LOCAL_COPY_HEADERS:= \ 47 | LocEngAdapter.h \ 48 | loc.h \ 49 | loc_eng.h \ 50 | loc_eng_xtra.h \ 51 | loc_eng_ni.h \ 52 | loc_eng_agps.h \ 53 | loc_eng_msg.h \ 54 | loc_eng_log.h 55 | 56 | LOCAL_PRELINK_MODULE := false 57 | 58 | include $(BUILD_SHARED_LIBRARY) 59 | 60 | include $(CLEAR_VARS) 61 | 62 | LOCAL_MODULE := gps.$(TARGET_BOARD_PLATFORM) 63 | LOCAL_MODULE_OWNER := qcom 64 | 65 | LOCAL_MODULE_TAGS := optional 66 | 67 | ## Libs 68 | 69 | LOCAL_SHARED_LIBRARIES := \ 70 | libutils \ 71 | libcutils \ 72 | liblog \ 73 | libloc_eng \ 74 | libloc_core \ 75 | libgps.utils \ 76 | libdl 77 | 78 | LOCAL_SRC_FILES += \ 79 | loc.cpp \ 80 | gps.c 81 | 82 | LOCAL_CFLAGS += \ 83 | -fno-short-enums \ 84 | -D_ANDROID_ \ 85 | 86 | ifeq ($(TARGET_USES_QCOM_BSP), true) 87 | LOCAL_CFLAGS += -DTARGET_USES_QCOM_BSP 88 | endif 89 | 90 | ## Includes 91 | LOCAL_C_INCLUDES:= \ 92 | $(TARGET_OUT_HEADERS)/gps.utils \ 93 | $(TARGET_OUT_HEADERS)/libloc_core 94 | 95 | LOCAL_PRELINK_MODULE := false 96 | LOCAL_MODULE_RELATIVE_PATH := hw 97 | 98 | include $(BUILD_SHARED_LIBRARY) 99 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CFLAGS = \ 2 | -I../../utils \ 3 | -I../../platform_lib_abstractions \ 4 | -fno-short-enums \ 5 | -DFEATURE_GNSS_BIT_API 6 | 7 | libloc_adapter_so_la_SOURCES = loc_eng_log.cpp LocEngAdapter.cpp 8 | 9 | if USE_GLIB 10 | libloc_adapter_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ 11 | libloc_adapter_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 12 | libloc_adapter_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ 13 | else 14 | libloc_adapter_so_la_CFLAGS = $(AM_CFLAGS) 15 | libloc_adapter_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 16 | libloc_adapter_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) 17 | endif 18 | libloc_adapter_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la 19 | 20 | 21 | libloc_eng_so_la_SOURCES = \ 22 | loc_eng.cpp \ 23 | loc_eng_agps.cpp \ 24 | loc_eng_xtra.cpp \ 25 | loc_eng_ni.cpp \ 26 | loc_eng_log.cpp \ 27 | loc_eng_dmn_conn.cpp \ 28 | loc_eng_dmn_conn_handler.cpp \ 29 | loc_eng_dmn_conn_thread_helper.c \ 30 | loc_eng_dmn_conn_glue_msg.c \ 31 | loc_eng_dmn_conn_glue_pipe.c 32 | 33 | 34 | if USE_GLIB 35 | libloc_eng_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ 36 | libloc_eng_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 37 | libloc_eng_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ 38 | else 39 | libloc_eng_so_la_CFLAGS = $(AM_CFLAGS) 40 | libloc_eng_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 41 | libloc_eng_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) 42 | endif 43 | 44 | libloc_eng_so_la_LIBADD = -lstdc++ -lcutils -ldl ../../utils/libgps_utils_so.la libloc_adapter_so.la 45 | 46 | 47 | libgps_default_so_la_SOURCES = \ 48 | loc.cpp \ 49 | gps.c 50 | 51 | if USE_GLIB 52 | libgps_default_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ 53 | libgps_default_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 54 | libgps_default_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ 55 | else 56 | libgps_default_so_la_CFLAGS = $(AM_CFLAGS) 57 | libgps_default_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 58 | libgps_default_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) 59 | endif 60 | 61 | libgps_default_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la -ldl libloc_eng_so.la 62 | 63 | library_include_HEADERS = \ 64 | LocEngAdapter.h \ 65 | loc.h \ 66 | loc_eng.h \ 67 | loc_eng_xtra.h \ 68 | loc_eng_ni.h \ 69 | loc_eng_agps.h \ 70 | loc_eng_msg.h \ 71 | loc_eng_log.h 72 | 73 | library_includedir = $(pkgincludedir)/libloc_api_50001 74 | 75 | #Create and Install libraries 76 | lib_LTLIBRARIES = libloc_adapter_so.la libloc_eng_so.la libgps_default_so.la 77 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/gps.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #include 31 | 32 | #include 33 | 34 | extern const GpsInterface* get_gps_interface(); 35 | 36 | const GpsInterface* gps__get_gps_interface(struct gps_device_t* dev) 37 | { 38 | return get_gps_interface(); 39 | } 40 | 41 | static int open_gps(const struct hw_module_t* module, char const* name, 42 | struct hw_device_t** device) 43 | { 44 | struct gps_device_t *dev = (struct gps_device_t *) malloc(sizeof(struct gps_device_t)); 45 | 46 | if(dev == NULL) 47 | return -1; 48 | 49 | memset(dev, 0, sizeof(*dev)); 50 | 51 | dev->common.tag = HARDWARE_DEVICE_TAG; 52 | dev->common.version = 0; 53 | dev->common.module = (struct hw_module_t*)module; 54 | dev->get_gps_interface = gps__get_gps_interface; 55 | 56 | *device = (struct hw_device_t*)dev; 57 | return 0; 58 | } 59 | 60 | static struct hw_module_methods_t gps_module_methods = { 61 | .open = open_gps 62 | }; 63 | 64 | struct hw_module_t HAL_MODULE_INFO_SYM = { 65 | .tag = HARDWARE_MODULE_TAG, 66 | .module_api_version = 1, 67 | .hal_api_version = 0, 68 | .id = GPS_HARDWARE_MODULE_ID, 69 | .name = "loc_api GPS Module", 70 | .author = "Qualcomm USA, Inc.", 71 | .methods = &gps_module_methods, 72 | }; 73 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/loc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011,2014 The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __LOC_H__ 31 | #define __LOC_H__ 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif /* __cplusplus */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #define XTRA_DATA_MAX_SIZE 100000 /*bytes*/ 43 | 44 | typedef void (*loc_location_cb_ext) (UlpLocation* location, void* locExt); 45 | typedef void (*loc_sv_status_cb_ext) (GpsSvStatus* sv_status, void* svExt); 46 | typedef void* (*loc_ext_parser)(void* data); 47 | typedef void (*loc_shutdown_cb) (void); 48 | 49 | typedef struct { 50 | loc_location_cb_ext location_cb; 51 | gps_status_callback status_cb; 52 | loc_sv_status_cb_ext sv_status_cb; 53 | gps_nmea_callback nmea_cb; 54 | gps_set_capabilities set_capabilities_cb; 55 | gps_acquire_wakelock acquire_wakelock_cb; 56 | gps_release_wakelock release_wakelock_cb; 57 | gps_create_thread create_thread_cb; 58 | loc_ext_parser location_ext_parser; 59 | loc_ext_parser sv_ext_parser; 60 | gps_request_utc_time request_utc_time_cb; 61 | loc_shutdown_cb shutdown_cb; 62 | } LocCallbacks; 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif /* __cplusplus */ 67 | 68 | #endif //__LOC_H__ 69 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/loc_eng_dmn_conn.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2012,2014 The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef LOC_ENG_DATA_SERVER_H 30 | #define LOC_ENG_DATA_SERVER_H 31 | 32 | #include "loc_eng_dmn_conn_thread_helper.h" 33 | 34 | #ifdef _ANDROID_ 35 | 36 | #define GPSONE_LOC_API_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_q" 37 | #define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_resp_q" 38 | #define QUIPC_CTRL_Q_PATH "/data/misc/location/gpsone_d/quipc_ctrl_q" 39 | #define MSAPM_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapm_ctrl_q" 40 | #define MSAPU_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapu_ctrl_q" 41 | 42 | #else 43 | 44 | #define GPSONE_LOC_API_Q_PATH "/tmp/gpsone_loc_api_q" 45 | #define GPSONE_LOC_API_RESP_Q_PATH "/tmp/gpsone_loc_api_resp_q" 46 | #define QUIPC_CTRL_Q_PATH "/tmp/quipc_ctrl_q" 47 | #define MSAPM_CTRL_Q_PATH "/tmp/msapm_ctrl_q" 48 | #define MSAPU_CTRL_Q_PATH "/tmp/msapu_ctrl_q" 49 | 50 | #endif 51 | 52 | int loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread create_thread_cb, 53 | const char * loc_api_q_path, const char * ctrl_q_path, void *agps_handle); 54 | int loc_eng_dmn_conn_loc_api_server_unblock(void); 55 | int loc_eng_dmn_conn_loc_api_server_join(void); 56 | int loc_eng_dmn_conn_loc_api_server_data_conn(int, int); 57 | 58 | #endif /* LOC_ENG_DATA_SERVER_H */ 59 | 60 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef LOC_ENG_DMN_CONN_GLUE_MSG_H 30 | #define LOC_ENG_DMN_CONN_GLUE_MSG_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif /* __cplusplus */ 35 | 36 | 37 | #include 38 | #include "loc_eng_dmn_conn_glue_pipe.h" 39 | 40 | int loc_eng_dmn_conn_glue_msgget(const char * q_path, int mode); 41 | int loc_eng_dmn_conn_glue_msgremove(const char * q_path, int msgqid); 42 | int loc_eng_dmn_conn_glue_msgsnd(int msgqid, const void * msgp, size_t msgsz); 43 | int loc_eng_dmn_conn_glue_msgrcv(int msgqid, void *msgp, size_t msgsz); 44 | int loc_eng_dmn_conn_glue_msgflush(int msgqid); 45 | int loc_eng_dmn_conn_glue_msgunblock(int msgqid); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif /* __cplusplus */ 50 | 51 | #endif /* LOC_ENG_DMN_CONN_GLUE_MSG_H */ 52 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #include 30 | #include 31 | #include 32 | 33 | // #include 34 | #include 35 | // #include 36 | #include 37 | #include 38 | 39 | #include "loc_eng_dmn_conn_glue_pipe.h" 40 | #include "log_util.h" 41 | #include "platform_lib_includes.h" 42 | /*=========================================================================== 43 | FUNCTION loc_eng_dmn_conn_glue_pipeget 44 | 45 | DESCRIPTION 46 | create a named pipe. 47 | 48 | pipe_name - pipe name path 49 | mode - mode 50 | 51 | DEPENDENCIES 52 | None 53 | 54 | RETURN VALUE 55 | 0: success or negative value for failure 56 | 57 | SIDE EFFECTS 58 | N/A 59 | 60 | ===========================================================================*/ 61 | int loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode) 62 | { 63 | int fd; 64 | int result; 65 | 66 | LOC_LOGD("%s, mode = %d\n", pipe_name, mode); 67 | result = mkfifo(pipe_name, 0660); 68 | 69 | if ((result == -1) && (errno != EEXIST)) { 70 | LOC_LOGE("failed: %s\n", strerror(errno)); 71 | return result; 72 | } 73 | 74 | // The mode in mkfifo is not honoured and does not provide the 75 | // group permissions. Doing chmod to add group permissions. 76 | result = chmod (pipe_name, 0660); 77 | if (result != 0){ 78 | LOC_LOGE ("%s failed to change mode for %s, error = %s\n", __func__, 79 | pipe_name, strerror(errno)); 80 | } 81 | 82 | fd = open(pipe_name, mode); 83 | if (fd <= 0) 84 | { 85 | LOC_LOGE("failed: %s\n", strerror(errno)); 86 | } 87 | LOC_LOGD("fd = %d, %s\n", fd, pipe_name); 88 | return fd; 89 | } 90 | 91 | /*=========================================================================== 92 | FUNCTION loc_eng_dmn_conn_glue_piperemove 93 | 94 | DESCRIPTION 95 | remove a pipe 96 | 97 | pipe_name - pipe name path 98 | fd - fd for the pipe 99 | 100 | DEPENDENCIES 101 | None 102 | 103 | RETURN VALUE 104 | 0: success 105 | 106 | SIDE EFFECTS 107 | N/A 108 | 109 | ===========================================================================*/ 110 | int loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd) 111 | { 112 | close(fd); 113 | if (pipe_name) unlink(pipe_name); 114 | LOC_LOGD("fd = %d, %s\n", fd, pipe_name); 115 | return 0; 116 | } 117 | 118 | /*=========================================================================== 119 | FUNCTION loc_eng_dmn_conn_glue_pipewrite 120 | 121 | DESCRIPTION 122 | write to a pipe 123 | 124 | fd - fd of a pipe 125 | buf - buffer for the data to write 126 | sz - size of the data in buffer 127 | 128 | DEPENDENCIES 129 | None 130 | 131 | RETURN VALUE 132 | number of bytes written or negative value for failure 133 | 134 | SIDE EFFECTS 135 | N/A 136 | 137 | ===========================================================================*/ 138 | int loc_eng_dmn_conn_glue_pipewrite(int fd, const void * buf, size_t sz) 139 | { 140 | int result; 141 | 142 | result = write(fd, buf, sz); 143 | 144 | /* @todo check for non EINTR & EAGAIN, shall not do select again, select_tut Law 7) */ 145 | 146 | /* LOC_LOGD("fd = %d, buf = 0x%lx, size = %d, result = %d\n", fd, (long) buf, (int) sz, (int) result); */ 147 | return result; 148 | } 149 | 150 | /*=========================================================================== 151 | FUNCTION loc_eng_dmn_conn_glue_piperead 152 | 153 | DESCRIPTION 154 | read from a pipe 155 | 156 | fd - fd for the pipe 157 | buf - buffer to hold the data read from pipe 158 | sz - size of the buffer 159 | 160 | DEPENDENCIES 161 | None 162 | 163 | RETURN VALUE 164 | number of bytes read from pipe or negative value for failure 165 | 166 | SIDE EFFECTS 167 | N/A 168 | 169 | ===========================================================================*/ 170 | int loc_eng_dmn_conn_glue_piperead(int fd, void * buf, size_t sz) 171 | { 172 | int len; 173 | 174 | len = read(fd, buf, sz); 175 | 176 | /* @todo check for non EINTR & EAGAIN, shall not do select again, select_tut Law 7) */ 177 | 178 | /* LOC_LOGD("fd = %d, buf = 0x%lx, size = %d, len = %d\n", fd, (long) buf, (int) sz, len); */ 179 | return len; 180 | } 181 | 182 | /*=========================================================================== 183 | FUNCTION loc_eng_dmn_conn_glue_pipeunblock 184 | 185 | DESCRIPTION 186 | unblock a pipe 187 | 188 | fd - fd for the pipe 189 | 190 | DEPENDENCIES 191 | None 192 | 193 | RETURN VALUE 194 | 0 for success or negative value for failure 195 | 196 | SIDE EFFECTS 197 | N/A 198 | 199 | ===========================================================================*/ 200 | int loc_eng_dmn_conn_glue_pipeunblock(int fd) 201 | { 202 | int result; 203 | struct flock flock_v; 204 | LOC_LOGD("\n"); 205 | // result = fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NDELAY); 206 | flock_v.l_type = F_UNLCK; 207 | flock_v.l_len = 32; 208 | result = fcntl(fd, F_SETLK, &flock_v); 209 | if (result < 0) { 210 | LOC_LOGE("fcntl failure, %s\n", strerror(errno)); 211 | } 212 | 213 | return result; 214 | } 215 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef LOC_ENG_DMN_CONN_GLUE_PIPE_H 30 | #define LOC_ENG_DMN_CONN_GLUE_PIPE_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif /* __cplusplus */ 35 | 36 | #include 37 | 38 | int loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode); 39 | int loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd); 40 | int loc_eng_dmn_conn_glue_pipewrite(int fd, const void * buf, size_t sz); 41 | int loc_eng_dmn_conn_glue_piperead(int fd, void * buf, size_t sz); 42 | 43 | int loc_eng_dmn_conn_glue_pipeflush(int fd); 44 | int loc_eng_dmn_conn_glue_pipeunblock(int fd); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif /* __cplusplus */ 49 | 50 | #endif /* LOC_ENG_DMN_CONN_GLUE_PIPE_H */ 51 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/loc_eng_dmn_conn_handler.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef LOC_ENG_DATA_SERVER_HANDLER 30 | #define LOC_ENG_DATA_SERVER_HANDLER 31 | 32 | #include 33 | #include 34 | 35 | //for SSID_BUF_SIZE 36 | #include 37 | 38 | #ifndef SSID_BUF_SIZE 39 | #define SSID_BUF_SIZE (32+1) 40 | #endif 41 | 42 | enum { 43 | /* 0x0 - 0xEF is reserved for daemon internal */ 44 | GPSONE_LOC_API_IF_REQUEST = 0xF0, 45 | GPSONE_LOC_API_IF_RELEASE, 46 | GPSONE_LOC_API_RESPONSE, 47 | GPSONE_UNBLOCK, 48 | }; 49 | 50 | enum { 51 | GPSONE_LOC_API_IF_REQUEST_SUCCESS = 0xF0, 52 | GPSONE_LOC_API_IF_RELEASE_SUCCESS, 53 | GPSONE_LOC_API_IF_FAILURE, 54 | }; 55 | 56 | 57 | struct ctrl_msg_response { 58 | int result; 59 | }; 60 | 61 | struct ctrl_msg_unblock { 62 | int reserved; 63 | }; 64 | 65 | typedef enum { 66 | IF_REQUEST_TYPE_SUPL = 0, 67 | IF_REQUEST_TYPE_WIFI, 68 | IF_REQUEST_TYPE_ANY 69 | } ctrl_if_req_type_e_type; 70 | 71 | typedef enum { 72 | IF_REQUEST_SENDER_ID_QUIPC = 0, 73 | IF_REQUEST_SENDER_ID_MSAPM, 74 | IF_REQUEST_SENDER_ID_MSAPU, 75 | IF_REQUEST_SENDER_ID_GPSONE_DAEMON, 76 | IF_REQUEST_SENDER_ID_MODEM 77 | } ctrl_if_req_sender_id_e_type; 78 | 79 | struct ctrl_msg_if_request { 80 | ctrl_if_req_type_e_type type; 81 | ctrl_if_req_sender_id_e_type sender_id; 82 | unsigned long ipv4_addr; 83 | unsigned char ipv6_addr[16]; 84 | char ssid[SSID_BUF_SIZE]; 85 | char password[SSID_BUF_SIZE]; 86 | }; 87 | 88 | /* do not change this structure */ 89 | struct ctrl_msgbuf { 90 | size_t msgsz; 91 | uint16_t reserved1; 92 | uint32_t reserved2; 93 | uint8_t ctrl_type; 94 | union { 95 | struct ctrl_msg_response cmsg_response; 96 | struct ctrl_msg_unblock cmsg_unblock; 97 | struct ctrl_msg_if_request cmsg_if_request; 98 | } cmsg; 99 | }; 100 | 101 | extern void* loc_api_handle; 102 | 103 | int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg, int len); 104 | int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg, int len); 105 | 106 | #endif /* LOC_ENG_DATA_SERVER_HANDLER */ 107 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ 30 | #define __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif /* __cplusplus */ 35 | 36 | #include 37 | 38 | struct loc_eng_dmn_conn_thelper { 39 | unsigned char thread_exit; 40 | unsigned char thread_ready; 41 | pthread_cond_t thread_cond; 42 | pthread_mutex_t thread_mutex; 43 | pthread_t thread_id; 44 | void * thread_context; 45 | int (*thread_proc_init) (void * context); 46 | int (*thread_proc_pre) (void * context); 47 | int (*thread_proc) (void * context); 48 | int (*thread_proc_post) (void * context); 49 | }; 50 | 51 | typedef pthread_t (* thelper_create_thread)(const char* name, void (*start)(void *), void* arg); 52 | int loc_eng_dmn_conn_launch_thelper(struct loc_eng_dmn_conn_thelper * thelper, 53 | int (*thread_proc_init) (void * context), 54 | int (*thread_proc_pre) (void * context), 55 | int (*thread_proc) (void * context), 56 | int (*thread_proc_post) (void * context), 57 | thelper_create_thread create_thread_cb, 58 | void * context); 59 | 60 | int loc_eng_dmn_conn_unblock_thelper(struct loc_eng_dmn_conn_thelper * thelper); 61 | int loc_eng_dmn_conn_join_thelper(struct loc_eng_dmn_conn_thelper * thelper); 62 | 63 | /* if only need to use signal */ 64 | int thelper_signal_init(struct loc_eng_dmn_conn_thelper * thelper); 65 | int thelper_signal_destroy(struct loc_eng_dmn_conn_thelper * thelper); 66 | int thelper_signal_wait(struct loc_eng_dmn_conn_thelper * thelper); 67 | int thelper_signal_ready(struct loc_eng_dmn_conn_thelper * thelper); 68 | int thelper_signal_block(struct loc_eng_dmn_conn_thelper * thelper); 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif /* __cplusplus */ 73 | 74 | #endif /* __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ */ 75 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/loc_eng_log.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #define LOG_NDDEBUG 0 31 | #define LOG_TAG "LocSvc_eng" 32 | 33 | #include "loc_log.h" 34 | #include "loc_eng_log.h" 35 | 36 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/loc_eng_log.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef LOC_ENG_LOG_H 31 | #define LOC_ENG_LOG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif 37 | 38 | #include 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif /* LOC_ENG_LOG_H */ 45 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/loc_eng_ni.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009,2011,2014 The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef LOC_ENG_NI_H 31 | #define LOC_ENG_NI_H 32 | 33 | #include 34 | #include 35 | 36 | #define LOC_NI_NO_RESPONSE_TIME 20 /* secs */ 37 | #define LOC_NI_NOTIF_KEY_ADDRESS "Address" 38 | #define GPS_NI_RESPONSE_IGNORE 4 39 | 40 | typedef struct { 41 | pthread_t thread; /* NI thread */ 42 | int respTimeLeft; /* examine time for NI response */ 43 | bool respRecvd; /* NI User reponse received or not from Java layer*/ 44 | void* rawRequest; 45 | int reqID; /* ID to check against response */ 46 | GpsUserResponseType resp; 47 | pthread_cond_t tCond; 48 | pthread_mutex_t tLock; 49 | LocEngAdapter* adapter; 50 | } loc_eng_ni_session_s_type; 51 | 52 | typedef struct { 53 | loc_eng_ni_session_s_type session; /* SUPL NI Session */ 54 | loc_eng_ni_session_s_type sessionEs; /* Emergency SUPL NI Session */ 55 | int reqIDCounter; 56 | } loc_eng_ni_data_s_type; 57 | 58 | 59 | #endif /* LOC_ENG_NI_H */ 60 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/loc_eng_nmea.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef LOC_ENG_NMEA_H 31 | #define LOC_ENG_NMEA_H 32 | 33 | #include 34 | 35 | #define NMEA_SENTENCE_MAX_LENGTH 200 36 | 37 | void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p); 38 | int loc_eng_nmea_put_checksum(char *pNmea, int maxSize); 39 | void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, const GpsSvStatus &svStatus, const GpsLocationExtended &locationExtended); 40 | void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, const UlpLocation &location, const GpsLocationExtended &locationExtended, unsigned char generate_nmea); 41 | 42 | #endif // LOC_ENG_NMEA_H 43 | -------------------------------------------------------------------------------- /gps/libloc_api_50001/loc_eng_xtra.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef LOC_ENG_XTRA_H 31 | #define LOC_ENG_XTRA_H 32 | 33 | #include 34 | 35 | // Module data 36 | typedef struct 37 | { 38 | // loc_eng_ioctl_cb_data_s_type ioctl_cb_data; 39 | gps_xtra_download_request download_request_cb; 40 | report_xtra_server report_xtra_server_cb; 41 | 42 | // XTRA data buffer 43 | char *xtra_data_for_injection; // NULL if no pending data 44 | int xtra_data_len; 45 | } loc_eng_xtra_data_s_type; 46 | 47 | #endif // LOC_ENG_XTRA_H 48 | -------------------------------------------------------------------------------- /gps/platform_lib_abstractions/elapsed_millis_since_boot.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include 30 | #include 31 | #include "platform_lib_time.h" 32 | 33 | int64_t systemTime(int clock) 34 | { 35 | struct timeval t; 36 | t.tv_sec = t.tv_usec = 0; 37 | gettimeofday(&t, NULL); 38 | return t.tv_sec*1000000LL + t.tv_usec; 39 | } 40 | 41 | 42 | int64_t elapsedMillisSinceBoot() 43 | { 44 | int64_t t_us = systemTime(0); 45 | return (int64_t) t_us / 1000LL; 46 | } 47 | -------------------------------------------------------------------------------- /gps/platform_lib_abstractions/platform_lib_includes.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _PLATFORM_LIB_INCLUDES_H_ 30 | #define _PLATFORM_LIB_INCLUDES_H_ 31 | 32 | #include "platform_lib_time.h" 33 | #include "platform_lib_macros.h" 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /gps/platform_lib_abstractions/platform_lib_macros.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef __PLATFORM_LIB_MACROS_H__ 30 | #define __PLATFORM_LIB_MACROS_H__ 31 | 32 | #include 33 | 34 | #define TS_PRINTF(format, x...) \ 35 | { \ 36 | struct timeval tv; \ 37 | struct timezone tz; \ 38 | int hh, mm, ss; \ 39 | gettimeofday(&tv, &tz); \ 40 | hh = tv.tv_sec/3600%24; \ 41 | mm = (tv.tv_sec%3600)/60; \ 42 | ss = tv.tv_sec%60; \ 43 | fprintf(stdout,"%02d:%02d:%02d.%06ld]" format "\n", hh, mm, ss, tv.tv_usec,##x); \ 44 | } 45 | 46 | 47 | #ifdef USE_GLIB 48 | 49 | #define strlcat g_strlcat 50 | #define strlcpy g_strlcpy 51 | 52 | #define ALOGE(format, x...) TS_PRINTF("E/%s (%d): " format , LOG_TAG, getpid(), ##x) 53 | #define ALOGW(format, x...) TS_PRINTF("W/%s (%d): " format , LOG_TAG, getpid(), ##x) 54 | #define ALOGI(format, x...) TS_PRINTF("I/%s (%d): " format , LOG_TAG, getpid(), ##x) 55 | #define ALOGD(format, x...) TS_PRINTF("D/%s (%d): " format , LOG_TAG, getpid(), ##x) 56 | #define ALOGV(format, x...) TS_PRINTF("V/%s (%d): " format , LOG_TAG, getpid(), ##x) 57 | 58 | #define GETTID_PLATFORM_LIB_ABSTRACTION (syscall(SYS_gettid)) 59 | 60 | #define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION createPthread 61 | #define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (elapsedMillisSinceBoot()) 62 | 63 | 64 | #else 65 | 66 | #ifdef __cplusplus 67 | extern "C" { 68 | #endif 69 | pid_t gettid(void); 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #define GETTID_PLATFORM_LIB_ABSTRACTION (gettid()) 76 | #define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION android::AndroidRuntime::createJavaThread 77 | #define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (android::elapsedRealtime()) 78 | 79 | #endif 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /gps/platform_lib_abstractions/platform_lib_time.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _PLATFORM_LIB_TIME_H_ 30 | #define _PLATFORM_LIB_TIME_H_ 31 | 32 | int64_t systemTime(int clock); 33 | int64_t elapsedMillisSinceBoot(); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /gps/utils/Android.mk: -------------------------------------------------------------------------------- 1 | #Compile this library only for builds with the latest modem image 2 | 3 | LOCAL_PATH := $(call my-dir) 4 | 5 | include $(CLEAR_VARS) 6 | 7 | ## Libs 8 | LOCAL_SHARED_LIBRARIES := \ 9 | libutils \ 10 | libcutils \ 11 | liblog 12 | 13 | LOCAL_SRC_FILES += \ 14 | loc_log.cpp \ 15 | loc_cfg.cpp \ 16 | msg_q.c \ 17 | linked_list.c \ 18 | loc_target.cpp \ 19 | loc_timer.c \ 20 | ../platform_lib_abstractions/elapsed_millis_since_boot.cpp \ 21 | loc_misc_utils.cpp 22 | 23 | LOCAL_CFLAGS += \ 24 | -fno-short-enums \ 25 | -D_ANDROID_ 26 | 27 | ifeq ($(TARGET_BUILD_VARIANT),user) 28 | LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER 29 | endif 30 | 31 | LOCAL_LDFLAGS += -Wl,--export-dynamic 32 | 33 | ## Includes 34 | LOCAL_C_INCLUDES:= \ 35 | $(LOCAL_PATH)/../platform_lib_abstractions 36 | 37 | LOCAL_COPY_HEADERS_TO:= gps.utils/ 38 | LOCAL_COPY_HEADERS:= \ 39 | loc_log.h \ 40 | loc_cfg.h \ 41 | log_util.h \ 42 | linked_list.h \ 43 | msg_q.h \ 44 | loc_target.h \ 45 | loc_timer.h \ 46 | ../platform_lib_abstractions/platform_lib_includes.h \ 47 | ../platform_lib_abstractions/platform_lib_time.h \ 48 | ../platform_lib_abstractions/platform_lib_macros.h \ 49 | loc_misc_utils.h 50 | 51 | LOCAL_MODULE := libgps.utils 52 | 53 | LOCAL_MODULE_TAGS := optional 54 | 55 | LOCAL_PRELINK_MODULE := false 56 | 57 | include $(BUILD_SHARED_LIBRARY) 58 | -------------------------------------------------------------------------------- /gps/utils/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CFLAGS = -Wundef \ 2 | -MD \ 3 | -Wno-trigraphs \ 4 | -g -O0 \ 5 | -fno-inline \ 6 | -fno-short-enums \ 7 | -fpic \ 8 | -I../platform_lib_abstractions 9 | 10 | libgps_utils_so_la_h_sources = log_util.h \ 11 | msg_q.h \ 12 | linked_list.h \ 13 | loc_cfg.h \ 14 | loc_log.h \ 15 | ../platform_lib_abstractions/platform_lib_includes.h \ 16 | ../platform_lib_abstractions/platform_lib_time.h \ 17 | ../platform_lib_abstractions/platform_lib_macros.h 18 | 19 | libgps_utils_so_la_c_sources = linked_list.c \ 20 | msg_q.c \ 21 | loc_cfg.cpp \ 22 | loc_log.cpp \ 23 | ../platform_lib_abstractions/elapsed_millis_since_boot.cpp 24 | 25 | library_includedir = $(pkgincludedir)/utils 26 | 27 | library_include_HEADERS = $(libgps_utils_so_la_h_sources) 28 | 29 | libgps_utils_so_la_SOURCES = $(libgps_utils_so_la_c_sources) 30 | 31 | if USE_GLIB 32 | libgps_utils_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ 33 | libgps_utils_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 34 | libgps_utils_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ 35 | else 36 | libgps_utils_so_la_CFLAGS = $(AM_CFLAGS) 37 | libgps_utils_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 38 | libgps_utils_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) 39 | endif 40 | 41 | libgps_utils_so_la_LIBADD = -lstdc++ -lcutils 42 | 43 | #Create and Install libraries 44 | lib_LTLIBRARIES = libgps_utils_so.la 45 | -------------------------------------------------------------------------------- /gps/utils/loc_cfg.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef LOC_CFG_H 31 | #define LOC_CFG_H 32 | 33 | #include 34 | #include 35 | 36 | #define LOC_MAX_PARAM_NAME 80 37 | #define LOC_MAX_PARAM_STRING 80 38 | #define LOC_MAX_PARAM_LINE (LOC_MAX_PARAM_NAME + LOC_MAX_PARAM_STRING) 39 | 40 | #define UTIL_UPDATE_CONF(conf_data, len, config_table) \ 41 | loc_update_conf((conf_data), (len), (config_table), \ 42 | sizeof(config_table) / sizeof(config_table[0])) 43 | 44 | #define UTIL_READ_CONF_DEFAULT(filename) \ 45 | loc_read_conf((filename), NULL, 0); 46 | 47 | #define UTIL_READ_CONF(filename, config_table) \ 48 | loc_read_conf((filename), (config_table), sizeof(config_table) / sizeof(config_table[0])) 49 | 50 | /*============================================================================= 51 | * 52 | * MODULE TYPE DECLARATION 53 | * 54 | *============================================================================*/ 55 | typedef struct 56 | { 57 | char param_name[LOC_MAX_PARAM_NAME]; 58 | void *param_ptr; 59 | uint8_t *param_set; /* was this value set by config file? */ 60 | char param_type; /* 'n' for number, 61 | 's' for string, 62 | 'f' for float */ 63 | } loc_param_s_type; 64 | 65 | /*============================================================================= 66 | * 67 | * MODULE EXTERNAL DATA 68 | * 69 | *============================================================================*/ 70 | 71 | #ifdef __cplusplus 72 | extern "C" { 73 | #endif 74 | 75 | /*============================================================================= 76 | * 77 | * MODULE EXPORTED FUNCTIONS 78 | * 79 | *============================================================================*/ 80 | void loc_read_conf(const char* conf_file_name, 81 | loc_param_s_type* config_table, 82 | uint32_t table_length); 83 | int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, 84 | uint32_t table_length); 85 | int loc_update_conf(const char* conf_data, int32_t length, 86 | loc_param_s_type* config_table, uint32_t table_length); 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* LOC_CFG_H */ 92 | -------------------------------------------------------------------------------- /gps/utils/loc_log.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef LOC_LOG_H 31 | #define LOC_LOG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif 37 | 38 | #include 39 | #include "loc_target.h" 40 | 41 | typedef struct 42 | { 43 | char name[128]; 44 | long val; 45 | } loc_name_val_s_type; 46 | 47 | #define NAME_VAL(x) {"" #x "", x } 48 | 49 | #define UNKNOWN_STR "UNKNOWN" 50 | 51 | #define CHECK_MASK(type, value, mask_var, mask) \ 52 | ((mask_var & mask) ? (type) value : (type) (-1)) 53 | 54 | /* Get names from value */ 55 | const char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, long mask); 56 | const char* loc_get_name_from_val(loc_name_val_s_type table[], int table_size, long value); 57 | const char* loc_get_msg_q_status(int status); 58 | const char* loc_get_target_name(unsigned int target); 59 | 60 | extern const char* log_succ_fail_string(int is_succ); 61 | 62 | extern char *loc_get_time(char *time_string, unsigned long buf_size); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif /* LOC_LOG_H */ 69 | -------------------------------------------------------------------------------- /gps/utils/loc_misc_utils.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #define LOG_NDDEBUG 0 36 | #define LOG_TAG "LocSvc_misc_utils" 37 | 38 | int loc_util_split_string(char *raw_string, char **split_strings_ptr, 39 | int max_num_substrings, char delimiter) 40 | { 41 | int raw_string_index=0; 42 | int num_split_strings=0; 43 | unsigned char end_string=0; 44 | int raw_string_length=0; 45 | 46 | if(!raw_string || !split_strings_ptr) { 47 | LOC_LOGE("%s:%d]: NULL parameters", __func__, __LINE__); 48 | num_split_strings = -1; 49 | goto err; 50 | } 51 | LOC_LOGD("%s:%d]: raw string: %s\n", __func__, __LINE__, raw_string); 52 | raw_string_length = strlen(raw_string) + 1; 53 | split_strings_ptr[num_split_strings] = &raw_string[raw_string_index]; 54 | for(raw_string_index=0; raw_string_index < raw_string_length; raw_string_index++) { 55 | if(raw_string[raw_string_index] == '\0') 56 | end_string=1; 57 | if((raw_string[raw_string_index] == delimiter) || end_string) { 58 | raw_string[raw_string_index] = '\0'; 59 | LOC_LOGD("%s:%d]: split string: %s\n", 60 | __func__, __LINE__, split_strings_ptr[num_split_strings]); 61 | num_split_strings++; 62 | if(((raw_string_index + 1) < raw_string_length) && 63 | (num_split_strings < max_num_substrings)) { 64 | split_strings_ptr[num_split_strings] = &raw_string[raw_string_index+1]; 65 | } 66 | else { 67 | break; 68 | } 69 | } 70 | if(end_string) 71 | break; 72 | } 73 | err: 74 | LOC_LOGD("%s:%d]: num_split_strings: %d\n", __func__, __LINE__, num_split_strings); 75 | return num_split_strings; 76 | } 77 | 78 | void loc_util_trim_space(char *org_string) 79 | { 80 | char *scan_ptr, *write_ptr; 81 | char *first_nonspace = NULL, *last_nonspace = NULL; 82 | 83 | if(org_string == NULL) { 84 | LOC_LOGE("%s:%d]: NULL parameter", __func__, __LINE__); 85 | goto err; 86 | } 87 | 88 | scan_ptr = write_ptr = org_string; 89 | 90 | while (*scan_ptr) { 91 | //Find the first non-space character 92 | if ( !isspace(*scan_ptr) && first_nonspace == NULL) { 93 | first_nonspace = scan_ptr; 94 | } 95 | //Once the first non-space character is found in the 96 | //above check, keep shifting the characters to the left 97 | //to replace the spaces 98 | if (first_nonspace != NULL) { 99 | *(write_ptr++) = *scan_ptr; 100 | //Keep track of which was the last non-space character 101 | //encountered 102 | //last_nonspace will not be updated in the case where 103 | //the string ends with spaces 104 | if ( !isspace(*scan_ptr)) { 105 | last_nonspace = write_ptr; 106 | } 107 | } 108 | scan_ptr++; 109 | } 110 | //Add NULL terminator after the last non-space character 111 | if (last_nonspace) { *last_nonspace = '\0'; } 112 | err: 113 | return; 114 | } 115 | -------------------------------------------------------------------------------- /gps/utils/loc_misc_utils.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef _LOC_MISC_UTILS_H_ 30 | #define _LOC_MISC_UTILS_H_ 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /*=========================================================================== 37 | FUNCTION loc_split_string 38 | 39 | DESCRIPTION: 40 | This function is used to split a delimiter separated string into 41 | sub-strings. This function does not allocate new memory to store the split 42 | strings. Instead, it places '\0' in places of delimiters and assings the 43 | starting address of the substring within the raw string as the string address 44 | The input raw_string no longer remains to be a collection of sub-strings 45 | after this function is executed. 46 | Please make a copy of the input string before calling this function if 47 | necessary 48 | 49 | PARAMETERS: 50 | char *raw_string: is the original string with delimiter separated substrings 51 | char **split_strings_ptr: is the arraw of pointers which will hold the addresses 52 | of individual substrings 53 | int max_num_substrings: is the maximum number of substrings that are expected 54 | by the caller. The array of pointers in the above parameter 55 | is usually this long 56 | char delimiter: is the delimiter that separates the substrings. Examples: ' ', ';' 57 | 58 | DEPENDENCIES 59 | N/A 60 | 61 | RETURN VALUE 62 | int Number of split strings 63 | 64 | SIDE EFFECTS 65 | The input raw_string no longer remains a delimiter separated single string. 66 | 67 | EXAMPLE 68 | delimiter = ' ' //space 69 | raw_string = "hello new user" //delimiter is space ' ' 70 | addresses = 0123456789abcd 71 | split_strings_ptr[0] = &raw_string[0]; //split_strings_ptr[0] contains "hello" 72 | split_strings_ptr[1] = &raw_string[6]; //split_strings_ptr[1] contains "new" 73 | split_strings_ptr[2] = &raw_string[a]; //split_strings_ptr[2] contains "user" 74 | 75 | ===========================================================================*/ 76 | int loc_util_split_string(char *raw_string, char **split_strings_ptr, int max_num_substrings, 77 | char delimiter); 78 | 79 | /*=========================================================================== 80 | FUNCTION trim_space 81 | 82 | DESCRIPTION 83 | Removes leading and trailing spaces of the string 84 | 85 | DEPENDENCIES 86 | N/A 87 | 88 | RETURN VALUE 89 | None 90 | 91 | SIDE EFFECTS 92 | N/A 93 | ===========================================================================*/ 94 | void loc_util_trim_space(char *org_string); 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif //_LOC_MISC_UTILS_H_ 100 | -------------------------------------------------------------------------------- /gps/utils/loc_target.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef LOC_TARGET_H 30 | #define LOC_TARGET_H 31 | #define TARGET_SET(gnss,ssc) ( (gnss<<1)|ssc ) 32 | #define TARGET_DEFAULT TARGET_SET(GNSS_MSM, HAS_SSC) 33 | #define TARGET_MDM TARGET_SET(GNSS_MDM, HAS_SSC) 34 | #define TARGET_APQ_SA TARGET_SET(GNSS_GSS, NO_SSC) 35 | #define TARGET_MPQ TARGET_SET(GNSS_NONE,NO_SSC) 36 | #define TARGET_MSM_NO_SSC TARGET_SET(GNSS_MSM, NO_SSC) 37 | #define TARGET_QCA1530 TARGET_SET(GNSS_QCA1530, NO_SSC) 38 | #define TARGET_AUTO TARGET_SET(GNSS_AUTO, NO_SSC) 39 | #define TARGET_UNKNOWN TARGET_SET(GNSS_UNKNOWN, NO_SSC) 40 | #define getTargetGnssType(target) (target>>1) 41 | 42 | #ifdef __cplusplus 43 | extern "C" 44 | { 45 | #endif 46 | 47 | unsigned int loc_get_target(void); 48 | 49 | /*The character array passed to this function should have length 50 | of atleast PROPERTY_VALUE_MAX*/ 51 | void loc_get_target_baseband(char *baseband, int array_length); 52 | /*The character array passed to this function should have length 53 | of atleast PROPERTY_VALUE_MAX*/ 54 | void loc_get_platform_name(char *platform_name, int array_length); 55 | 56 | /* Please remember to update 'target_name' in loc_log.cpp, 57 | if do any changes to this enum. */ 58 | typedef enum { 59 | GNSS_NONE = 0, 60 | GNSS_MSM, 61 | GNSS_GSS, 62 | GNSS_MDM, 63 | GNSS_QCA1530, 64 | GNSS_AUTO, 65 | GNSS_UNKNOWN 66 | }GNSS_TARGET; 67 | 68 | typedef enum { 69 | NO_SSC = 0, 70 | HAS_SSC 71 | }SSC_TYPE; 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif /*LOC_TARGET_H*/ 78 | -------------------------------------------------------------------------------- /gps/utils/loc_timer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation, nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __LOC_DELAY_H__ 31 | #define __LOC_DELAY_H__ 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif /* __cplusplus */ 36 | #include 37 | #include "log_util.h" 38 | 39 | /* 40 | Return values: 41 | Success = 0 42 | Failure = Non zero 43 | */ 44 | typedef void(*loc_timer_callback)(void *user_data, int result); 45 | 46 | 47 | /* 48 | Returns the handle, which can be used to stop the timer 49 | */ 50 | void* loc_timer_start(unsigned int delay_msec, 51 | loc_timer_callback, 52 | void* user_data); 53 | 54 | /* 55 | handle becomes invalid upon the return of the callback 56 | */ 57 | void loc_timer_stop(void* handle); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif /* __cplusplus */ 62 | 63 | #endif //__LOC_DELAY_H__ 64 | -------------------------------------------------------------------------------- /hwaddrs/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2016 The CyanogenMod project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | LOCAL_PATH:= $(call my-dir) 17 | include $(CLEAR_VARS) 18 | 19 | LOCAL_MODULE_TAGS := optional 20 | 21 | LOCAL_SRC_FILES := getmac.c 22 | 23 | LOCAL_PRELINK_MODULE := false 24 | 25 | LOCAL_MODULE := hwaddrs 26 | 27 | include $(BUILD_EXECUTABLE) 28 | -------------------------------------------------------------------------------- /hwaddrs/getmac.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The CyanogenMod Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | int blank(int fd, int offset); 24 | 25 | /* Read plain address from misc partiton and set the Wifi and BT mac addresses accordingly */ 26 | 27 | int main() { 28 | int fd1, fd2; 29 | char macbyte; 30 | char macbuf[3]; 31 | int i; 32 | 33 | fd1 = open("/dev/block/platform/msm_sdcc.1/by-name/misc", O_RDONLY); 34 | fd2 = open("/data/misc/wifi/config", O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); 35 | 36 | if (!blank(fd1, 0x3000)) 37 | { 38 | write(fd2, "cur_etheraddr=", 14); 39 | 40 | for(i = 0; i < 6; i++) { 41 | lseek(fd1, 0x3000 + i, SEEK_SET); 42 | lseek(fd2, 0, SEEK_END); 43 | read(fd1, &macbyte, 1); 44 | sprintf(macbuf, "%02x", macbyte); 45 | write(fd2, &macbuf, 2); 46 | if(i != 5) write(fd2, ":", 1); 47 | } 48 | 49 | write(fd2, "\n", 1); 50 | } 51 | 52 | close(fd2); 53 | 54 | if (!blank(fd1, 0x4000)) 55 | { 56 | fd2 = open("/data/misc/bluetooth/bdaddr", O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); 57 | for(i = 0; i < 6; i++) { 58 | lseek(fd1, 0x4000 + i, SEEK_SET); 59 | lseek(fd2, 0, SEEK_END); 60 | read(fd1, &macbyte, 1); 61 | sprintf(macbuf, "%02x", macbyte); 62 | write(fd2, &macbuf, 2); 63 | if(i != 5) write(fd2, ":", 1); 64 | } 65 | } 66 | 67 | close(fd2); 68 | close(fd1); 69 | 70 | return 0; 71 | } 72 | 73 | int blank(int fd, int offset) 74 | { 75 | char macbyte; 76 | int i, count = 0; 77 | 78 | for(i = 0; i < 6; i++) { 79 | lseek(fd, offset + i, SEEK_SET); 80 | read(fd, &macbyte, 1); 81 | 82 | if (!macbyte) 83 | count++; 84 | else 85 | count = 0; 86 | 87 | if (count > 2) 88 | return 1; 89 | } 90 | 91 | return 0; 92 | } 93 | -------------------------------------------------------------------------------- /include/camera/CameraParametersExtra.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The CyanogenMod Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define CAMERA_PARAMETERS_EXTRA_C \ 18 | const char CameraParameters::AUDIO_ZOOM_OFF[] = "audio-zoom"; \ 19 | const char CameraParameters::AUDIO_ZOOM_ON[] = "audio-zoom"; \ 20 | const char CameraParameters::BEAUTY_SHOT_OFF[] = "beauty-shot"; \ 21 | const char CameraParameters::BEAUTY_SHOT_ON[] = "beauty-shot"; \ 22 | const char CameraParameters::BURST_SHOT_OFF[] = "burst-shot"; \ 23 | const char CameraParameters::BURST_SHOT_ON[] = "burst-shot"; \ 24 | const char CameraParameters::KEY_AUDIO_ZOOM[] = "audio-zoom"; \ 25 | const char CameraParameters::KEY_AUDIO_ZOOM_SUPPORTED[] = "audio-zoom-supported"; \ 26 | const char CameraParameters::KEY_BEAUTY_SHOT[] = "beauty-shot"; \ 27 | const char CameraParameters::KEY_BEAUTY_SHOT_SUPPORTED[] = "beauty-shot-supported"; \ 28 | const char CameraParameters::KEY_BURST_SHOT[] = "burst-shot"; \ 29 | const char CameraParameters::KEY_BURST_SHOT_SUPPORTED[] = "burst-shot-supported"; \ 30 | const char CameraParameters::KEY_FOCUS_MODE_OBJECT_TRACKING[] = "object-tracking"; \ 31 | const char CameraParameters::KEY_FOCUS_MODE_OBJECT_TRACKING_SUPPORTED[] = "object-tracking-supported"; \ 32 | const char CameraParameters::KEY_ISO_MODE[] = "iso"; \ 33 | const char CameraParameters::KEY_LGE_CAMERA[] = "lge-camera"; \ 34 | const char CameraParameters::KEY_LGE_ISO_MODE[] = "lg-iso"; \ 35 | const char CameraParameters::KEY_SUPPORTED_ISO_MODES[] = "iso-values"; \ 36 | const char CameraParameters::KEY_VIDEO_WDR[] = "video-wdr"; \ 37 | const char CameraParameters::KEY_VIDEO_WDR_SUPPORTED[] = "video-wdr-supported"; \ 38 | const char CameraParameters::VIDEO_WDR_OFF[] = "video-wdr"; \ 39 | const char CameraParameters::VIDEO_WDR_ON[] = "video-wdr"; \ 40 | const char CameraParameters::OBJECT_TRACKING_ON[] = "object-tracking"; \ 41 | const char CameraParameters::OBJECT_TRACKING_OFF[] = "object-tracking"; \ 42 | 43 | #define CAMERA_PARAMETERS_EXTRA_H \ 44 | static const char AUDIO_ZOOM_OFF[]; \ 45 | static const char AUDIO_ZOOM_ON[]; \ 46 | static const char BEAUTY_SHOT_OFF[]; \ 47 | static const char BEAUTY_SHOT_ON[]; \ 48 | static const char BURST_SHOT_OFF[]; \ 49 | static const char BURST_SHOT_ON[]; \ 50 | static const char KEY_AUDIO_ZOOM[]; \ 51 | static const char KEY_AUDIO_ZOOM_SUPPORTED[]; \ 52 | static const char KEY_BEAUTY_SHOT[]; \ 53 | static const char KEY_BEAUTY_SHOT_SUPPORTED[]; \ 54 | static const char KEY_BURST_SHOT[]; \ 55 | static const char KEY_BURST_SHOT_SUPPORTED[]; \ 56 | static const char KEY_FOCUS_MODE_OBJECT_TRACKING[]; \ 57 | static const char KEY_FOCUS_MODE_OBJECT_TRACKING_SUPPORTED[]; \ 58 | static const char KEY_ISO_MODE[]; \ 59 | static const char KEY_LGE_CAMERA[]; \ 60 | static const char KEY_LGE_ISO_MODE[]; \ 61 | static const char KEY_SUPPORTED_ISO_MODES[]; \ 62 | static const char KEY_VIDEO_WDR[]; \ 63 | static const char KEY_VIDEO_WDR_SUPPORTED[]; \ 64 | static const char VIDEO_WDR_OFF[]; \ 65 | static const char VIDEO_WDR_ON[]; \ 66 | static const char OBJECT_TRACKING_ON[]; \ 67 | static const char OBJECT_TRACKING_OFF[]; \ 68 | -------------------------------------------------------------------------------- /liblge/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The CyanogenMod Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH := $(call my-dir) 16 | 17 | include $(CLEAR_VARS) 18 | 19 | LOCAL_SRC_FILES := \ 20 | lge_ril.cpp 21 | 22 | LOCAL_SHARED_LIBRARIES := libbinder 23 | 24 | LOCAL_MODULE := liblge 25 | LOCAL_MODULE_TAGS := optional 26 | LOCAL_MODULE_CLASS := SHARED_LIBRARIES 27 | 28 | include $(BUILD_SHARED_LIBRARY) 29 | -------------------------------------------------------------------------------- /liblge/lge_ril.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The CyanogenMod Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | /* status_t Parcel::readuInt64 */ 20 | extern "C" int _ZNK7android6Parcel10readUint64EPy(uint64_t *pArg); 21 | extern "C" int _ZNK7android6Parcel10readuInt64EPy(uint64_t *pArg) { 22 | return _ZNK7android6Parcel10readUint64EPy(pArg); 23 | } 24 | 25 | /* status_t Parcel::writeString16 */ 26 | extern "C" int _ZN7android6Parcel13writeString16EPKDsj(); 27 | extern "C" int _ZN7android6Parcel13writeString16EPKtj() { 28 | return _ZN7android6Parcel13writeString16EPKDsj(); 29 | } 30 | 31 | extern "C" void RIL_register_socket() {} 32 | -------------------------------------------------------------------------------- /liblight/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The CyanogenMod Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:= $(call my-dir) 16 | include $(CLEAR_VARS) 17 | 18 | LOCAL_SRC_FILES := lights.c 19 | LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 20 | LOCAL_SHARED_LIBRARIES := liblog libcutils 21 | LOCAL_MODULE := lights.$(TARGET_BOARD_PLATFORM) 22 | LOCAL_MODULE_TAGS := optional 23 | 24 | include $(BUILD_SHARED_LIBRARY) 25 | -------------------------------------------------------------------------------- /mkbootimg.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | ## Build and run dtbtool 4 | BUMP := $(LOCAL_PATH)/bump/bump.py 5 | DTBTOOL := $(HOST_OUT_EXECUTABLES)/dtbToolCM$(HOST_EXECUTABLE_SUFFIX) 6 | INSTALLED_DTIMAGE_TARGET := $(PRODUCT_OUT)/dt.img 7 | 8 | $(INSTALLED_DTIMAGE_TARGET): $(DTBTOOL) $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr $(INSTALLED_KERNEL_TARGET) 9 | @echo -e ${CL_CYN}"Start DT image: $@"${CL_RST} 10 | $(call pretty,"Target dt image: $(INSTALLED_DTIMAGE_TARGET)") 11 | $(hide) $(DTBTOOL) -o $(INSTALLED_DTIMAGE_TARGET) -s $(BOARD_KERNEL_PAGESIZE) -p $(KERNEL_OUT)/scripts/dtc/ $(KERNEL_OUT)/arch/arm/boot/ 12 | @echo -e ${CL_CYN}"Made DT image: $@"${CL_RST} 13 | 14 | 15 | ## Overload bootimg generation: Same as the original, + --dt arg 16 | $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(INSTALLED_DTIMAGE_TARGET) 17 | $(call pretty,"Target boot image: $@") 18 | $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --dt $(INSTALLED_DTIMAGE_TARGET) --output $@ 19 | $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw) 20 | ifeq ($(TARGET_REQUIRES_BUMP),true) 21 | $(hide) $(BUMP) $@ $@ 22 | endif 23 | @echo -e ${CL_CYN}"Made boot image: $@"${CL_RST} 24 | 25 | ## Overload recoveryimg generation: Same as the original, + --dt arg 26 | $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DTIMAGE_TARGET) \ 27 | $(recovery_ramdisk) \ 28 | $(recovery_kernel) 29 | $(call build-recoveryimage-target, $@) 30 | $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --dt $(INSTALLED_DTIMAGE_TARGET) --output $@ 31 | ifeq ($(TARGET_REQUIRES_BUMP),true) 32 | $(hide) $(BUMP) $@ $@ 33 | endif 34 | @echo -e ${CL_CYN}"Made recovery image: $@"${CL_RST} 35 | -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/xml/power_profile.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0 4 | 136.43 5 | 52.76 6 | 0.73 7 | 228.00 8 | 0.1 9 | 60 10 | 23.11 11 | 0.1 12 | 0.1 13 | 131.10 14 | 132.10 15 | 76.97 16 | 17 | 78.60 18 | 1.98 19 | 20 | 21 | 300000 22 | 422400 23 | 652800 24 | 729600 25 | 883200 26 | 960000 27 | 1036800 28 | 1190400 29 | 1267200 30 | 1497600 31 | 1574400 32 | 1728000 33 | 1958400 34 | 2265600 35 | 2457600 36 | 37 | 3.57 38 | 34.40 39 | 40 | 68.23 41 | 88.03 42 | 98.33 43 | 104.47 44 | 116.10 45 | 130.13 46 | 136.27 47 | 146.00 48 | 197.87 49 | 218.13 50 | 227.23 51 | 242.83 52 | 267.63 53 | 307.60 54 | 338.20 55 | 56 | 3000 57 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SettingsProvider/res/values/default.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | true 22 | 23 | 24 | 82 25 | 26 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 22 | 23 | 24 | 26 | true 27 | 28 | 29 | 10 30 | 31 | 32 | false 33 | 34 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 4000dp 20 | 4000dp 21 | 1500dp 22 | 6000dp 23 | 24 | -------------------------------------------------------------------------------- /overlay/packages/apps/CarrierConfig/res/xml/vendor.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /overlay/packages/apps/Dialer/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | true 19 | 4 20 | 21 | -------------------------------------------------------------------------------- /overlay/packages/apps/Snap/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | 20 | 21 | true 22 | 23 | 24 | false 25 | 26 | 27 | true 28 | 29 | 31 | lge-camera=1 32 | 33 | 36 | lg-iso 37 | lg-iso-values 38 | 39 | 41 | true 42 | 43 | 44 | true 45 | 46 | -------------------------------------------------------------------------------- /overlay/packages/services/Telephony/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 21 | true 22 | 23 | 24 | true 25 | 26 | 27 | -------------------------------------------------------------------------------- /overlay/vendor/cmsdk/cm/res/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 25 | 26 | true 27 | 28 | 29 | 100 30 | 31 | 32 | true 33 | 34 | 47 | 11 48 | 49 | 50 | -------------------------------------------------------------------------------- /ril/telephony/java/com/android/internal/telephony/LgeLteRIL.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The CyanogenMod Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | import static com.android.internal.telephony.RILConstants.*; 20 | 21 | import android.content.Context; 22 | import android.os.AsyncResult; 23 | import android.os.Message; 24 | import android.os.Parcel; 25 | 26 | /** 27 | * Custom Qualcomm RIL for G3 28 | * 29 | * {@hide} 30 | */ 31 | public class LgeLteRIL extends RIL implements CommandsInterface { 32 | public LgeLteRIL(Context context, int preferredNetworkType, int cdmaSubscription) { 33 | super(context, preferredNetworkType, cdmaSubscription, null); 34 | } 35 | 36 | public LgeLteRIL(Context context, int preferredNetworkType, 37 | int cdmaSubscription, Integer instanceId) { 38 | super(context, preferredNetworkType, cdmaSubscription, instanceId); 39 | } 40 | 41 | @Override 42 | protected Object 43 | responseFailCause(Parcel p) { 44 | int numInts; 45 | int response[]; 46 | 47 | numInts = p.readInt(); 48 | response = new int[numInts]; 49 | for (int i = 0 ; i < numInts ; i++) { 50 | response[i] = p.readInt(); 51 | } 52 | LastCallFailCause failCause = new LastCallFailCause(); 53 | failCause.causeCode = response[0]; 54 | if (p.dataAvail() > 0) { 55 | failCause.vendorCause = p.readString(); 56 | } 57 | return failCause; 58 | } 59 | 60 | @Override 61 | public void getRadioCapability(Message response) { 62 | riljLog("getRadioCapability: returning static radio capability"); 63 | if (response != null) { 64 | Object ret = makeStaticRadioCapability(); 65 | AsyncResult.forMessage(response, ret, null); 66 | response.sendToTarget(); 67 | } 68 | } 69 | 70 | @Override 71 | public void 72 | setNetworkSelectionModeManual(String operatorNumeric, Message response) { 73 | RILRequest rr 74 | = RILRequest.obtain(RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL, 75 | response); 76 | 77 | if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 78 | + " " + operatorNumeric); 79 | 80 | rr.mParcel.writeInt(2); 81 | rr.mParcel.writeString(operatorNumeric); 82 | rr.mParcel.writeString("2"); // NOCHANGE 83 | 84 | send(rr); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /rootdir/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | # Init scripts 4 | 5 | include $(CLEAR_VARS) 6 | LOCAL_MODULE := init.g3.rc 7 | LOCAL_MODULE_TAGS := optional eng 8 | LOCAL_MODULE_CLASS := ETC 9 | LOCAL_SRC_FILES := etc/init.g3.rc 10 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) 11 | include $(BUILD_PREBUILT) 12 | 13 | include $(CLEAR_VARS) 14 | LOCAL_MODULE := init.g3.power.rc 15 | LOCAL_MODULE_TAGS := optional eng 16 | LOCAL_MODULE_CLASS := ETC 17 | LOCAL_SRC_FILES := etc/init.g3.power.rc 18 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) 19 | include $(BUILD_PREBUILT) 20 | 21 | include $(CLEAR_VARS) 22 | LOCAL_MODULE := init.g3.usb.rc 23 | LOCAL_MODULE_TAGS := optional eng 24 | LOCAL_MODULE_CLASS := ETC 25 | LOCAL_SRC_FILES := etc/init.g3.usb.rc 26 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) 27 | include $(BUILD_PREBUILT) 28 | 29 | include $(CLEAR_VARS) 30 | LOCAL_MODULE := init.msm8974.sensor.sh 31 | LOCAL_MODULE_TAGS := optional eng 32 | LOCAL_MODULE_CLASS := ETC 33 | LOCAL_SRC_FILES := etc/init.msm8974.sensor.sh 34 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) 35 | include $(BUILD_PREBUILT) 36 | 37 | include $(CLEAR_VARS) 38 | LOCAL_MODULE := init.qcom.sh 39 | LOCAL_MODULE_TAGS := optional eng 40 | LOCAL_MODULE_CLASS := ETC 41 | LOCAL_SRC_FILES := etc/init.qcom.sh 42 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) 43 | include $(BUILD_PREBUILT) 44 | 45 | include $(CLEAR_VARS) 46 | LOCAL_MODULE := init.qcom.bt.sh 47 | LOCAL_MODULE_TAGS := optional eng 48 | LOCAL_MODULE_CLASS := ETC 49 | LOCAL_SRC_FILES := etc/init.qcom.bt.sh 50 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) 51 | include $(BUILD_PREBUILT) 52 | 53 | include $(CLEAR_VARS) 54 | LOCAL_MODULE := init.baseband.sh 55 | LOCAL_MODULE_TAGS := optional eng 56 | LOCAL_MODULE_CLASS := ETC 57 | LOCAL_SRC_FILES := etc/init.baseband.sh 58 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) 59 | include $(BUILD_PREBUILT) 60 | 61 | include $(CLEAR_VARS) 62 | LOCAL_MODULE := init.sensors.sh 63 | LOCAL_MODULE_TAGS := optional eng 64 | LOCAL_MODULE_CLASS := ETC 65 | LOCAL_SRC_FILES := etc/init.sensors.sh 66 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) 67 | include $(BUILD_PREBUILT) 68 | 69 | include $(CLEAR_VARS) 70 | LOCAL_MODULE := ueventd.g3.rc 71 | LOCAL_MODULE_TAGS := optional eng 72 | LOCAL_MODULE_CLASS := ETC 73 | LOCAL_SRC_FILES := etc/ueventd.g3.rc 74 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) 75 | include $(BUILD_PREBUILT) 76 | -------------------------------------------------------------------------------- /rootdir/etc/init.baseband.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # Copyright (c) 2015, CyanogenMod. All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # * Redistributions of source code must retain the above copyright 7 | # notice, this list of conditions and the following disclaimer. 8 | # * Redistributions in binary form must reproduce the above copyright 9 | # notice, this list of conditions and the following disclaimer in the 10 | # documentation and/or other materials provided with the distribution. 11 | # * Neither the name of The Linux Foundation nor 12 | # the names of its contributors may be used to endorse or promote 13 | # products derived from this software without specific prior written 14 | # permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | 29 | # grep the modem partition for baseband version and set it 30 | setprop gsm.version.baseband `strings /dev/block/platform/msm_sdcc.1/by-name/modem 2>/dev/null | grep -m 1 "^MPSS.DI."` 31 | -------------------------------------------------------------------------------- /rootdir/etc/init.g3.power.rc: -------------------------------------------------------------------------------- 1 | on early-init 2 | write /sys/module/msm_thermal/core_control/enabled 0 3 | write /sys/devices/system/cpu/cpu1/online 1 4 | write /sys/devices/system/cpu/cpu2/online 1 5 | write /sys/devices/system/cpu/cpu3/online 1 6 | write /sys/module/msm_thermal/core_control/enabled 1 7 | 8 | on enable-low-power 9 | write /sys/module/lpm_levels/enable_low_power/l2 4 10 | write /sys/module/msm_pm/modes/cpu0/power_collapse/suspend_enabled 1 11 | write /sys/module/msm_pm/modes/cpu1/power_collapse/suspend_enabled 1 12 | write /sys/module/msm_pm/modes/cpu2/power_collapse/suspend_enabled 1 13 | write /sys/module/msm_pm/modes/cpu3/power_collapse/suspend_enabled 1 14 | write /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enabled 1 15 | write /sys/module/msm_pm/modes/cpu1/power_collapse/idle_enabled 1 16 | write /sys/module/msm_pm/modes/cpu2/power_collapse/idle_enabled 1 17 | write /sys/module/msm_pm/modes/cpu3/power_collapse/idle_enabled 1 18 | write /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/suspend_enabled 1 19 | write /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/suspend_enabled 1 20 | write /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/suspend_enabled 1 21 | write /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/suspend_enabled 1 22 | write /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/idle_enabled 1 23 | write /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/idle_enabled 1 24 | write /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/idle_enabled 1 25 | write /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/idle_enabled 1 26 | write /sys/module/msm_pm/modes/cpu0/retention/idle_enabled 1 27 | write /sys/module/msm_pm/modes/cpu1/retention/idle_enabled 1 28 | write /sys/module/msm_pm/modes/cpu2/retention/idle_enabled 1 29 | write /sys/module/msm_pm/modes/cpu3/retention/idle_enabled 1 30 | 31 | write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "interactive" 32 | write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor "interactive" 33 | write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor "interactive" 34 | write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor "interactive" 35 | write /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load 90 36 | write /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq 1497600 37 | write /sys/devices/system/cpu/cpufreq/interactive/io_is_busy 1 38 | write /sys/devices/system/cpu/cpufreq/interactive/min_sample_time 40000 39 | write /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay "20000 1400000:40000 1700000:20000" 40 | write /sys/devices/system/cpu/cpufreq/interactive/target_loads "85 1500000:90 1800000:70" 41 | write /sys/devices/system/cpu/cpufreq/interactive/timer_rate 30000 42 | write /sys/devices/system/cpu/cpufreq/interactive/timer_slack 30000 43 | write /sys/devices/system/cpu/cpufreq/interactive/sampling_down_factor 100000 44 | write /sys/devices/system/cpu/cpufreq/interactive/up_threshold_any_cpu_load 50 45 | write /sys/devices/system/cpu/cpufreq/interactive/sync_freq 1036800 46 | write /sys/devices/system/cpu/cpufreq/interactive/up_threshold_any_cpu_freq 1190400 47 | 48 | write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 300000 49 | write /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq 300000 50 | write /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq 300000 51 | write /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq 300000 52 | chown system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 53 | chown root.system /sys/devices/system/cpu/cpu1/online 54 | chown root.system /sys/devices/system/cpu/cpu2/online 55 | chown root.system /sys/devices/system/cpu/cpu3/online 56 | chmod 664 /sys/devices/system/cpu/cpu1/online 57 | chmod 664 /sys/devices/system/cpu/cpu2/online 58 | chmod 664 /sys/devices/system/cpu/cpu3/online 59 | 60 | write /sys/module/cpu_boost/parameters/input_boost_freq 1497600 61 | write /sys/module/cpu_boost/parameters/input_boost_ms 40 62 | write /sys/module/cpu_boost/parameters/sync_threshold 1728000 63 | 64 | write /sys/class/devfreq/qcom,cpubw.41/governor "cpubw_hwmon" 65 | write /sys/class/kgsl/kgsl-3d0/devfreq/governor msm-adreno-tz 66 | 67 | on charger 68 | # Enable Power modes and set the CPU Freq Sampling rates 69 | write /sys/module/lpm_levels/enable_low_power/l2 4 70 | write /sys/module/msm_pm/modes/cpu0/power_collapse/suspend_enabled 1 71 | write /sys/module/msm_pm/modes/cpu1/power_collapse/suspend_enabled 1 72 | write /sys/module/msm_pm/modes/cpu2/power_collapse/suspend_enabled 1 73 | write /sys/module/msm_pm/modes/cpu3/power_collapse/suspend_enabled 1 74 | write /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enabled 1 75 | write /sys/module/msm_thermal/core_control/enabled 0 76 | write /sys/devices/system/cpu/cpu1/online 1 77 | write /sys/devices/system/cpu/cpu2/online 1 78 | write /sys/devices/system/cpu/cpu3/online 1 79 | write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "powersave" 80 | write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor "powersave" 81 | write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor "powersave" 82 | write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor "powersave" 83 | write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 300000 84 | write /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq 300000 85 | write /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq 300000 86 | write /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq 300000 87 | write /sys/module/msm_thermal/core_control/enabled 1 88 | write /sys/devices/system/cpu/cpu1/online 0 89 | write /sys/devices/system/cpu/cpu2/online 0 90 | write /sys/devices/system/cpu/cpu3/online 0 91 | 92 | on boot 93 | trigger enable-low-power 94 | 95 | on property:sys.boot_completed=1 96 | trigger enable-low-power 97 | 98 | setprop sys.io.scheduler bfq 99 | setprop ro.qualcomm.perf.cores_online 2 100 | start mpdecision 101 | 102 | on property:init.svc.recovery=running 103 | trigger enable-low-power 104 | 105 | on property:recovery.perf.mode=1 106 | write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "performance" 107 | 108 | on property:recovery.perf.mode=0 109 | write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "interactive" 110 | -------------------------------------------------------------------------------- /rootdir/etc/init.g3.usb.rc: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | on init 16 | write /sys/class/android_usb/android0/f_rndis/manufacturer LGE 17 | write /sys/class/android_usb/android0/f_rndis/vendorID 18D1 18 | write /sys/class/android_usb/android0/f_rndis/wceis 1 19 | 20 | on boot 21 | write /sys/class/android_usb/android0/iSerial ${ro.serialno} 22 | write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer} 23 | write /sys/class/android_usb/android0/iProduct ${ro.product.model} 24 | 25 | # MTP 26 | on property:sys.usb.config=mtp 27 | stop adbd 28 | write /sys/class/android_usb/android0/enable 0 29 | write /sys/class/android_usb/android0/idVendor 18D1 30 | write /sys/class/android_usb/android0/idProduct 4EE1 31 | write /sys/class/android_usb/android0/bDeviceClass 0 32 | write /sys/class/android_usb/android0/bDeviceSubClass 0 33 | write /sys/class/android_usb/android0/bDeviceProtocol 0 34 | write /sys/class/android_usb/android0/functions mtp 35 | write /sys/class/android_usb/android0/enable 1 36 | setprop sys.usb.state ${sys.usb.config} 37 | 38 | on property:sys.usb.config=mtp,adb 39 | write /sys/class/android_usb/android0/enable 0 40 | write /sys/class/android_usb/android0/idVendor 18D1 41 | write /sys/class/android_usb/android0/idProduct 4EE2 42 | write /sys/class/android_usb/android0/bDeviceClass 0 43 | write /sys/class/android_usb/android0/bDeviceSubClass 0 44 | write /sys/class/android_usb/android0/bDeviceProtocol 0 45 | write /sys/class/android_usb/android0/functions mtp,adb 46 | write /sys/class/android_usb/android0/enable 1 47 | start adbd 48 | setprop sys.usb.state ${sys.usb.config} 49 | 50 | # rndis 51 | on property:sys.usb.config=rndis 52 | stop adbd 53 | write /sys/class/android_usb/android0/enable 0 54 | write /sys/class/android_usb/android0/idVendor 18D1 55 | write /sys/class/android_usb/android0/idProduct 4EE3 56 | write /sys/class/android_usb/android0/bDeviceClass 239 57 | write /sys/class/android_usb/android0/bDeviceSubClass 2 58 | write /sys/class/android_usb/android0/bDeviceProtocol 1 59 | write /sys/class/android_usb/android0/functions rndis 60 | write /sys/class/android_usb/android0/enable 1 61 | setprop sys.usb.state ${sys.usb.config} 62 | 63 | on property:sys.usb.config=rndis,adb 64 | write /sys/class/android_usb/android0/enable 0 65 | write /sys/class/android_usb/android0/idVendor 18D1 66 | write /sys/class/android_usb/android0/idProduct 4EE4 67 | write /sys/class/android_usb/android0/bDeviceClass 239 68 | write /sys/class/android_usb/android0/bDeviceSubClass 2 69 | write /sys/class/android_usb/android0/bDeviceProtocol 1 70 | write /sys/class/android_usb/android0/functions rndis,adb 71 | write /sys/class/android_usb/android0/enable 1 72 | start adbd 73 | setprop sys.usb.state ${sys.usb.config} 74 | 75 | # PTP 76 | on property:sys.usb.config=ptp 77 | stop adbd 78 | write /sys/class/android_usb/android0/enable 0 79 | write /sys/class/android_usb/android0/idVendor 18D1 80 | write /sys/class/android_usb/android0/idProduct 4EE5 81 | write /sys/class/android_usb/android0/bDeviceClass 0 82 | write /sys/class/android_usb/android0/bDeviceSubClass 0 83 | write /sys/class/android_usb/android0/bDeviceProtocol 0 84 | write /sys/class/android_usb/android0/functions ptp 85 | write /sys/class/android_usb/android0/enable 1 86 | setprop sys.usb.state ${sys.usb.config} 87 | 88 | on property:sys.usb.config=ptp,adb 89 | write /sys/class/android_usb/android0/enable 0 90 | write /sys/class/android_usb/android0/idVendor 18D1 91 | write /sys/class/android_usb/android0/idProduct 4EE6 92 | write /sys/class/android_usb/android0/bDeviceClass 0 93 | write /sys/class/android_usb/android0/bDeviceSubClass 0 94 | write /sys/class/android_usb/android0/bDeviceProtocol 0 95 | write /sys/class/android_usb/android0/functions ptp,adb 96 | write /sys/class/android_usb/android0/enable 1 97 | start adbd 98 | setprop sys.usb.state ${sys.usb.config} 99 | 100 | # diag 101 | on property:sys.usb.config=diag 102 | stop adbd 103 | write /sys/class/android_usb/android0/enable 0 104 | write /sys/class/android_usb/android0/idVendor 1004 105 | write /sys/class/android_usb/android0/idProduct 61F1 106 | write /sys/class/android_usb/android0/bDeviceClass 239 107 | write /sys/class/android_usb/android0/bDeviceSubClass 2 108 | write /sys/class/android_usb/android0/bDeviceProtocol 1 109 | write /sys/class/android_usb/android0/f_acm/acm_transports smd 110 | write /sys/class/android_usb/android0/f_diag/clients diag 111 | write /sys/class/android_usb/android0/functions acm,diag,mtp,adb 112 | write /sys/class/android_usb/android0/enable 1 113 | start adbd 114 | setprop sys.usb.state ${sys.usb.config} 115 | 116 | on property:sys.usb.config=diag,adb 117 | stop adbd 118 | write /sys/class/android_usb/android0/enable 0 119 | write /sys/class/android_usb/android0/idVendor 1004 120 | write /sys/class/android_usb/android0/idProduct 61F1 121 | write /sys/class/android_usb/android0/bDeviceClass 239 122 | write /sys/class/android_usb/android0/bDeviceSubClass 2 123 | write /sys/class/android_usb/android0/bDeviceProtocol 1 124 | write /sys/class/android_usb/android0/f_acm/acm_transports smd 125 | write /sys/class/android_usb/android0/f_diag/clients diag 126 | write /sys/class/android_usb/android0/functions acm,diag,mtp,adb 127 | write /sys/class/android_usb/android0/enable 1 128 | start adbd 129 | setprop sys.usb.state ${sys.usb.config} 130 | 131 | on property:sys.usb.config=charging 132 | write /sys/class/android_usb/android0/enable 0 133 | write /sys/class/android_usb/android0/idVendor 18D1 134 | write /sys/class/android_usb/android0/idProduct 61A6 135 | write /sys/class/android_usb/android0/bDeviceClass 0 136 | write /sys/class/android_usb/android0/bDeviceSubClass 0 137 | write /sys/class/android_usb/android0/bDeviceProtocol 0 138 | write /sys/class/android_usb/android0/functions charging 139 | write /sys/class/android_usb/android0/enable 1 140 | setprop sys.usb.state ${sys.usb.config} 141 | -------------------------------------------------------------------------------- /rootdir/etc/init.msm8974.sensor.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # Copyright (c) 2009-2015, The Linux Foundation. All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # * Redistributions of source code must retain the above copyright 7 | # notice, this list of conditions and the following disclaimer. 8 | # * Redistributions in binary form must reproduce the above copyright 9 | # notice, this list of conditions and the following disclaimer in the 10 | # documentation and/or other materials provided with the distribution. 11 | # * Neither the name of The Linux Foundation nor 12 | # the names of its contributors may be used to endorse or promote 13 | # products derived from this software without specific prior written 14 | # permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | 29 | # 30 | # Function to start sensors for DSPS enabled platforms 31 | # 32 | start_sensors() 33 | { 34 | if [ -c /dev/msm_dsps -o -c /dev/sensors ]; then 35 | 36 | if [ ! -s /persist/sensors/sensors_settings ]; then 37 | # If the settings file is empty, enable sensors HAL 38 | # Otherwise leave the file with it's current contents 39 | mkdir -p /persist/sensors 40 | echo 1 > /persist/sensors/sensors_settings 41 | fi 42 | 43 | chmod -h 775 /persist/sensors 44 | chmod -h 664 /persist/sensors/sensors_settings 45 | chown -h system.root /persist/sensors/sensors_settings 46 | 47 | mkdir -p /data/misc/sensors 48 | chmod -h 775 /data/misc/sensors 49 | 50 | start sensors 51 | fi 52 | } 53 | 54 | start_sensors 55 | -------------------------------------------------------------------------------- /rootdir/etc/init.qcom.bt.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | if [ -f /system/bin/hci_qcomm_init ]; then 4 | setprop ro.qualcomm.bt.hci_transport smd 5 | setprop bluetooth.status off 6 | /system/bin/hci_qcomm_init -b `cat /data/misc/bluetooth/bdaddr` 7 | setprop bluetooth.status on 8 | fi 9 | 10 | exit 0 -------------------------------------------------------------------------------- /rootdir/etc/init.qcom.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # Copyright (c) 2009-2013, The Linux Foundation. All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # * Redistributions of source code must retain the above copyright 7 | # notice, this list of conditions and the following disclaimer. 8 | # * Redistributions in binary form must reproduce the above copyright 9 | # notice, this list of conditions and the following disclaimer in the 10 | # documentation and/or other materials provided with the distribution. 11 | # * Neither the name of The Linux Foundation nor 12 | # the names of its contributors may be used to endorse or promote 13 | # products derived from this software without specific prior written 14 | # permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | 29 | # 30 | # Suppress default route installation during RA for IPV6; user space will take 31 | # care of this 32 | # exception default ifc 33 | for file in /proc/sys/net/ipv6/conf/* 34 | do 35 | echo 0 > $file/accept_ra_defrtr 36 | done 37 | echo 1 > /proc/sys/net/ipv6/conf/default/accept_ra_defrtr 38 | -------------------------------------------------------------------------------- /rootdir/etc/init.sensors.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | if [[ ! -f /sns/cal/calb && -f /system/etc/sensors/sensor_def_variable.conf ]]; then 4 | rm /sns/cal/sns.reg 5 | touch /sns/cal/calb 6 | fi 7 | 8 | exit 0 -------------------------------------------------------------------------------- /sepolicy/device.te: -------------------------------------------------------------------------------- 1 | type cir_device, dev_type; 2 | type rfkill_device, dev_type; 3 | 4 | type encrypt_block_device, dev_type; 5 | type modem_block_device, dev_type; 6 | -------------------------------------------------------------------------------- /sepolicy/file_contexts: -------------------------------------------------------------------------------- 1 | /dev/diag_lge u:object_r:diag_device:s0 2 | /dev/pn547 u:object_r:nfc_device:s0 3 | /dev/rfkill u:object_r:rfkill_device:s0 4 | /dev/ttyHSL1 u:object_r:cir_device:s0 5 | 6 | /dev/block/platform/msm_sdcc\.1/by-name/encrypt u:object_r:encrypt_block_device:s0 7 | /dev/block/platform/msm_sdcc\.1/by-name/modem u:object_r:modem_block_device:s0 8 | 9 | /sns(/.*)? u:object_r:sensors_persist_file:s0 10 | 11 | /sys/devices/fdb00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/gpuclk u:object_r:sysfs_thermal:s0 12 | /sys/devices/virtual/input/lge_touch/tap_to_wake u:object_r:sysfs_tap2wake:s0 13 | 14 | /system/bin/thermal-engine u:object_r:thermal-engine_exec:s0 15 | /system/bin/tune2fs u:object_r:tune2fs_exec:s0 16 | /system/bin/hwaddrs u:object_r:hwaddrs_exec:s0 17 | -------------------------------------------------------------------------------- /sepolicy/fsck.te: -------------------------------------------------------------------------------- 1 | allow fsck proc_swaps:file r_file_perms; 2 | -------------------------------------------------------------------------------- /sepolicy/genfs_contexts: -------------------------------------------------------------------------------- 1 | genfscon proc /bluetooth/sleep/btwrite u:object_r:proc_bluetooth_writable:s0 2 | genfscon proc /bluetooth/sleep/lpm u:object_r:proc_bluetooth_writable:s0 3 | genfscon proc /swaps u:object_r:proc_swaps:s0 4 | -------------------------------------------------------------------------------- /sepolicy/hwaddrs.te: -------------------------------------------------------------------------------- 1 | type hwaddrs, domain; 2 | type hwaddrs_exec, exec_type, file_type; 3 | 4 | init_daemon_domain(hwaddrs) 5 | 6 | allow hwaddrs misc_block_device:blk_file r_file_perms; 7 | 8 | allow hwaddrs bluetooth_data_file:dir w_dir_perms; 9 | allow hwaddrs bluetooth_data_file:file create_file_perms; 10 | 11 | allow hwaddrs wifi_data_file:dir w_dir_perms; 12 | allow hwaddrs wifi_data_file:file create_file_perms; 13 | -------------------------------------------------------------------------------- /sepolicy/kernel.te: -------------------------------------------------------------------------------- 1 | allow kernel sensors_persist_file:dir search; 2 | -------------------------------------------------------------------------------- /sepolicy/mediacodec.te: -------------------------------------------------------------------------------- 1 | allow mediacodec persist_drm_file:dir search; 2 | -------------------------------------------------------------------------------- /sepolicy/mediaserver.te: -------------------------------------------------------------------------------- 1 | allow mediaserver camera_prop:property_service set; 2 | -------------------------------------------------------------------------------- /sepolicy/mpdecision.te: -------------------------------------------------------------------------------- 1 | allow mpdecision socket_device:dir w_dir_perms; 2 | allow mpdecision socket_device:sock_file create_file_perms; 3 | file_type_auto_trans(mpdecision, socket_device, mpctl_socket); 4 | -------------------------------------------------------------------------------- /sepolicy/property_contexts: -------------------------------------------------------------------------------- 1 | persist.data.front.minfps u:object_r:camera_prop:s0 2 | persist.data.rear.minfps u:object_r:camera_prop:s0 3 | -------------------------------------------------------------------------------- /sepolicy/qti_init_shell.te: -------------------------------------------------------------------------------- 1 | allow qti_init_shell bluetooth_data_file:dir search; 2 | allow qti_init_shell bluetooth_data_file:file r_file_perms; 3 | allow qti_init_shell modem_block_device:blk_file r_file_perms; 4 | allow qti_init_shell qmuxd:unix_stream_socket connectto; 5 | allow qti_init_shell qmuxd_socket:dir w_dir_perms; 6 | allow qti_init_shell qmuxd_socket:sock_file create_file_perms; 7 | allow qti_init_shell qmuxd_socket:unix_stream_socket connectto; 8 | allow qti_init_shell radio_prop:property_service set; 9 | -------------------------------------------------------------------------------- /sepolicy/radio.te: -------------------------------------------------------------------------------- 1 | allow radio net_radio_prop:property_service set; 2 | -------------------------------------------------------------------------------- /sepolicy/servicemanager.te: -------------------------------------------------------------------------------- 1 | allow servicemanager thermal-engine:dir search; 2 | allow servicemanager thermal-engine:file r_file_perms; 3 | allow servicemanager thermal-engine:process getattr; 4 | -------------------------------------------------------------------------------- /sepolicy/system_server.te: -------------------------------------------------------------------------------- 1 | allow system_server cir_device:chr_file { rw_file_perms ioctl }; 2 | allow system_server sysfs_tap2wake:file rw_file_perms; 3 | -------------------------------------------------------------------------------- /sepolicy/thermal-engine.te: -------------------------------------------------------------------------------- 1 | allow thermal-engine power_service:service_manager find; 2 | allow thermal-engine servicemanager:binder call; 3 | allow thermal-engine sysfs_usb_supply:dir search; 4 | allow thermal-engine sysfs_usb_supply:file r_file_perms; 5 | allow thermal-engine system_server:binder call; 6 | -------------------------------------------------------------------------------- /sepolicy/tune2fs.te: -------------------------------------------------------------------------------- 1 | type tune2fs, domain; 2 | type tune2fs_exec, exec_type, file_type; 3 | 4 | # Started by init 5 | init_daemon_domain(tune2fs) 6 | 7 | allow tune2fs userdata_block_device:blk_file { rw_file_perms ioctl }; 8 | allow tune2fs proc_swaps:file r_file_perms; 9 | -------------------------------------------------------------------------------- /sepolicy/type.te: -------------------------------------------------------------------------------- 1 | type proc_swaps, fs_type; 2 | type sysfs_tap2wake, fs_type, sysfs_type; 3 | -------------------------------------------------------------------------------- /sepolicy/vold.te: -------------------------------------------------------------------------------- 1 | allow vold encrypt_block_device:blk_file rw_file_perms; 2 | -------------------------------------------------------------------------------- /sepolicy/wcnss_service.te: -------------------------------------------------------------------------------- 1 | allow wcnss_service misc_block_device:blk_file r_file_perms; 2 | -------------------------------------------------------------------------------- /sepolicy/wpa.te: -------------------------------------------------------------------------------- 1 | allow wpa rfkill_device:chr_file r_file_perms; 2 | -------------------------------------------------------------------------------- /setup-makefiles.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2016 The CyanogenMod Project 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | set -e 19 | 20 | DEVICE_COMMON=g3-common 21 | VENDOR=lge 22 | 23 | # Load extract_utils and do some sanity checks 24 | MY_DIR="${BASH_SOURCE%/*}" 25 | if [[ ! -d "$MY_DIR" ]]; then MY_DIR="$PWD"; fi 26 | 27 | CM_ROOT="$MY_DIR"/../../.. 28 | 29 | HELPER="$CM_ROOT"/vendor/cm/build/tools/extract_utils.sh 30 | if [ ! -f "$HELPER" ]; then 31 | echo "Unable to find helper script at $HELPER" 32 | exit 1 33 | fi 34 | . "$HELPER" 35 | 36 | # Initialize the helper for common device 37 | setup_vendor "$DEVICE_COMMON" "$VENDOR" "$CM_ROOT" true 38 | 39 | # Copyright headers and common guards 40 | write_headers "g3 d850 d851 d852 d855 ls990 vs985 f400" 41 | 42 | # The common blobs 43 | write_makefiles "$MY_DIR"/proprietary-files.txt 44 | 45 | # We are done with common 46 | write_footers 47 | 48 | # Initialize the helper for device 49 | setup_vendor "$DEVICE" "$VENDOR" "$CM_ROOT" 50 | 51 | # Copyright headers and guards 52 | write_headers 53 | 54 | # The device blobs 55 | write_makefiles "$MY_DIR"/../$DEVICE/proprietary-files.txt 56 | 57 | # We are done with device 58 | write_footers 59 | -------------------------------------------------------------------------------- /system_prop.mk: -------------------------------------------------------------------------------- 1 | # Audio 2 | PRODUCT_PROPERTY_OVERRIDES += \ 3 | af.fast_track_multiplier=1 \ 4 | audio_hal.period_size=192 \ 5 | media.aac_51_output_enabled=true \ 6 | use.voice.path.for.pcm.voip=true 7 | 8 | PRODUCT_PROPERTY_OVERRIDES += \ 9 | persist.audio.fluence.voicecall=true \ 10 | persist.audio.fluence.voicerec=false \ 11 | persist.audio.fluence.speaker=true \ 12 | ro.qc.sdk.audio.fluencetype=fluence 13 | 14 | # Camera 15 | PRODUCT_PROPERTY_OVERRIDES += \ 16 | camera2.portability.force_api=1 \ 17 | media.stagefright.legacyencoder=true \ 18 | media.stagefright.less-secure=true 19 | 20 | # Bluetooth 21 | PRODUCT_PROPERTY_OVERRIDES += \ 22 | ro.bt.bdaddr_path="/data/misc/bluetooth/bdaddr" 23 | 24 | # Display 25 | PRODUCT_PROPERTY_OVERRIDES += \ 26 | persist.hwc.mdpcomp.enable=true \ 27 | persist.hwc.ptor.enable=true \ 28 | persist.metadata_dynfps.disable=true \ 29 | ro.opengles.version=196608 \ 30 | ro.sf.lcd_density=560 31 | 32 | # Qualcomm 33 | PRODUCT_PROPERTY_OVERRIDES += \ 34 | persist.timed.enable=true \ 35 | ro.vendor.extension_library=/vendor/lib/libqti-perfd-client.so 36 | 37 | # Radio 38 | PRODUCT_PROPERTY_OVERRIDES += \ 39 | persist.radio.apm_sim_not_pwdn=1 \ 40 | persist.telephony.oosisdc=false \ 41 | ril.subscription.types=NV,RUIM \ 42 | ro.ril.telephony.mqanelements=5 43 | 44 | PRODUCT_PROPERTY_OVERRIDES += \ 45 | persist.data.netmgrd.qos.enable=false \ 46 | persist.data.qmi.adb_logmask=0 \ 47 | persist.qcril.disable_retry=true \ 48 | ro.use_data_netmgrd=true 49 | 50 | # Sensors 51 | PRODUCT_PROPERTY_OVERRIDES += \ 52 | debug.qualcomm.sns.daemon=e \ 53 | debug.qualcomm.sns.hal=e \ 54 | debug.qualcomm.sns.libsensor1=e 55 | 56 | # Storage 57 | PRODUCT_PROPERTY_OVERRIDES += \ 58 | ro.sys.sdcardfs=true 59 | -------------------------------------------------------------------------------- /wcnss/WCNSS_cfg.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_device_lge_g3-common/585edbd435f52512c998bf80942ecdc39985c9f1/wcnss/WCNSS_cfg.dat -------------------------------------------------------------------------------- /wcnss/WCNSS_qcom_wlan_nv.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_device_lge_g3-common/585edbd435f52512c998bf80942ecdc39985c9f1/wcnss/WCNSS_qcom_wlan_nv.bin -------------------------------------------------------------------------------- /wcnss/p2p_supplicant_overlay.conf: -------------------------------------------------------------------------------- 1 | ble_scan_offload=1 2 | -------------------------------------------------------------------------------- /wcnss/wpa_supplicant_overlay.conf: -------------------------------------------------------------------------------- 1 | disable_scan_offload=1 2 | p2p_disabled=1 3 | p2p_no_group_iface=1 4 | driver_param=use_multi_chan_concurrent=1 5 | -------------------------------------------------------------------------------- /wcnss_lge/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011 The CyanogenMod project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ifneq ($(filter d850 d852 d855 vs985,$(TARGET_DEVICE)),) 16 | 17 | LOCAL_PATH:= $(call my-dir) 18 | 19 | include $(CLEAR_VARS) 20 | 21 | LOCAL_SRC_FILES := wcnss_lge_client.c 22 | LOCAL_C_INCLUDES += hardware/qcom/wlan/wcnss_service 23 | LOCAL_CFLAGS += -Wall 24 | LOCAL_SHARED_LIBRARIES := libc libcutils libutils liblog 25 | LOCAL_MODULE_TAGS := optional 26 | LOCAL_MODULE := libwcnss_qmi 27 | 28 | include $(BUILD_SHARED_LIBRARY) 29 | 30 | endif 31 | -------------------------------------------------------------------------------- /wcnss_lge/wcnss_lge_client.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, The CyanogenMod Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | //#define LOG_NDEBUG 0 18 | 19 | #define LOG_TAG "wcnss_lge" 20 | 21 | #define SUCCESS 0 22 | #define FAILED -1 23 | 24 | #define CALIBRATION_PATH "/dev/block/platform/msm_sdcc.1/by-name/misc" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | int wcnss_init_qmi(void) 35 | { 36 | /* empty */ 37 | return SUCCESS; 38 | } 39 | 40 | int wcnss_qmi_get_wlan_address(unsigned char *pBdAddr) 41 | { 42 | FILE *fd; 43 | int ret; 44 | 45 | fd = fopen(CALIBRATION_PATH, "r"); 46 | if (fd == NULL) { 47 | ALOGE("Failure opening calibration path: %d\n", errno); 48 | return FAILED; 49 | } 50 | 51 | fseek(fd, 0x3000, SEEK_SET); 52 | 53 | ret = fread(pBdAddr, sizeof(pBdAddr[0]), 6, fd); 54 | 55 | if (ret < 0) { 56 | ALOGE("Failure to read calibration data: %d\n", errno); 57 | fclose(fd); 58 | return FAILED; 59 | } 60 | 61 | ALOGI("Found MAC address: %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n", 62 | pBdAddr[0], 63 | pBdAddr[1], 64 | pBdAddr[2], 65 | pBdAddr[3], 66 | pBdAddr[4], 67 | pBdAddr[5]); 68 | 69 | fclose(fd); 70 | 71 | return SUCCESS; 72 | } 73 | 74 | void wcnss_qmi_deinit(void) 75 | { 76 | /* empty */ 77 | } 78 | --------------------------------------------------------------------------------