From b1670b6c4bdbe7498ecd7227fe4a9d542d2fb2dc Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Fri, 25 Sep 2020 01:53:37 +0800 Subject: [PATCH 001/191] kitakami-common: libril: Upgrade to AOSP 11.0 sources * https://android.googlesource.com/platform/hardware/ril/+/refs/tags/android-11.0.0_r3 --- include/telephony/ril.h | 1 + include/telephony/ril_cdma_sms.h | 2 +- include/telephony/ril_mcc.h | 71 ++++++++++++++++++++++++++++++++ libril/Android.mk | 4 +- libril/ril.cpp | 2 - libril/ril_service.cpp | 30 ++++++++++---- 6 files changed, 96 insertions(+), 14 deletions(-) create mode 100644 include/telephony/ril_mcc.h diff --git a/include/telephony/ril.h b/include/telephony/ril.h index e189777..7530146 100644 --- a/include/telephony/ril.h +++ b/include/telephony/ril.h @@ -107,6 +107,7 @@ extern "C" { #define MAX_BANDS 8 #define MAX_CHANNELS 32 #define MAX_RADIO_ACCESS_NETWORKS 8 +#define MAX_BROADCAST_SMS_CONFIG_INFO 25 typedef void * RIL_Token; diff --git a/include/telephony/ril_cdma_sms.h b/include/telephony/ril_cdma_sms.h index bcf6b30..835bc92 100644 --- a/include/telephony/ril_cdma_sms.h +++ b/include/telephony/ril_cdma_sms.h @@ -113,7 +113,7 @@ typedef struct { /* Used only when digitMode is 8-bit */ unsigned char number_of_digits; unsigned char digits[ RIL_CDMA_SMS_ADDRESS_MAX ]; - /* Each byte in this array represnts a 40bit or 8-bit digit of address data */ + /* Each byte in this array represnts a 4-bit or 8-bit digit of address data */ } RIL_CDMA_SMS_Address; typedef enum { diff --git a/include/telephony/ril_mcc.h b/include/telephony/ril_mcc.h new file mode 100644 index 0000000..dc56b12 --- /dev/null +++ b/include/telephony/ril_mcc.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef RIL_MCC_H +#define RIL_MCC_H + +#include +#include +#include + +namespace ril { +namespace util { +namespace mcc { + +/** + * Decode an integer mcc and encode as 3 digit string + * + * @param an integer mcc, its range should be in 0 to 999. + * + * @return string representation of an encoded MCC or an empty string + * if the MCC is not a valid MCC value. + */ +static inline std::string decode(int mcc) { + char mccStr[4] = {0}; + if (mcc > 999 || mcc < 0) return ""; + + snprintf(mccStr, sizeof(mccStr), "%03d", mcc); + return mccStr; +} + +// echo -e "#include \"hardware/ril/include/telephony/ril_mcc.h\"\nint main()"\ +// "{ return ril::util::mcc::test(); }" > ril_test.cpp \ +// && g++ -o /tmp/ril_test -DTEST_RIL_MCC ril_test.cpp; \ +// rm ril_test.cpp; /tmp/ril_test && [ $? ] && echo "passed" +#ifdef TEST_RIL_MCC +static int test() { + const struct mcc_ints { const int in; const char * out; } legacy_mccs[] = { + {INT_MAX, ""}, + {1, "001"}, + {11, "011"}, + {111, "111"}, + {0, "000"}, + {9999, ""}, + {-12, ""}, + }; + + for (int i=0; i < sizeof(legacy_mccs) / sizeof(struct mcc_ints); i++) { + if (decode(legacy_mccs[i].in).compare(legacy_mccs[i].out)) return 1; + } + + return 0; +} +#endif + +} +} +} +#endif /* !defined(RIL_MCC_H) */ diff --git a/libril/Android.mk b/libril/Android.mk index e14d5f4..a3ab34a 100644 --- a/libril/Android.mk +++ b/libril/Android.mk @@ -21,9 +21,7 @@ LOCAL_SHARED_LIBRARIES := \ android.hardware.radio@1.0 \ android.hardware.radio@1.1 \ android.hardware.radio.deprecated@1.0 \ - libhidlbase \ - libhidltransport \ - libhwbinder + libhidlbase \ LOCAL_STATIC_LIBRARIES := \ libprotobuf-c-nano-enable_malloc-32bit \ diff --git a/libril/ril.cpp b/libril/ril.cpp index c60cd6b..b9aeb29 100644 --- a/libril/ril.cpp +++ b/libril/ril.cpp @@ -21,13 +21,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include diff --git a/libril/ril_service.cpp b/libril/ril_service.cpp index 79403dc..f9b2f30 100755 --- a/libril/ril_service.cpp +++ b/libril/ril_service.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -1826,6 +1827,12 @@ Return RadioImpl::setGsmBroadcastConfig(int32_t serial, } int num = configInfo.size(); + if (num > MAX_BROADCAST_SMS_CONFIG_INFO) { + RLOGE("setGsmBroadcastConfig: Invalid configInfo length %s", + requestToString(pRI->pCI->requestNumber)); + sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS); + return Void(); + } RIL_GSM_BroadcastSmsConfigInfo gsmBci[num]; RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num]; @@ -1873,6 +1880,12 @@ Return RadioImpl::setCdmaBroadcastConfig(int32_t serial, } int num = configInfo.size(); + if (num > MAX_BROADCAST_SMS_CONFIG_INFO) { + RLOGE("setCdmaBroadcastConfig: Invalid configInfo length %s", + requestToString(pRI->pCI->requestNumber)); + sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS); + return Void(); + } RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num]; RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num]; @@ -3590,7 +3603,7 @@ void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 & case RIL_CELL_INFO_TYPE_GSM: { cellIdentity.cellIdentityGsm.resize(1); cellIdentity.cellIdentityGsm[0].mcc = - std::to_string(rilCellIdentity.cellIdentityGsm.mcc); + ril::util::mcc::decode(rilCellIdentity.cellIdentityGsm.mcc); cellIdentity.cellIdentityGsm[0].mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc); @@ -3608,7 +3621,7 @@ void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 & case RIL_CELL_INFO_TYPE_WCDMA: { cellIdentity.cellIdentityWcdma.resize(1); cellIdentity.cellIdentityWcdma[0].mcc = - std::to_string(rilCellIdentity.cellIdentityWcdma.mcc); + ril::util::mcc::decode(rilCellIdentity.cellIdentityWcdma.mcc); cellIdentity.cellIdentityWcdma[0].mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc); @@ -3637,7 +3650,7 @@ void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 & case RIL_CELL_INFO_TYPE_LTE: { cellIdentity.cellIdentityLte.resize(1); cellIdentity.cellIdentityLte[0].mcc = - std::to_string(rilCellIdentity.cellIdentityLte.mcc); + ril::util::mcc::decode(rilCellIdentity.cellIdentityLte.mcc); cellIdentity.cellIdentityLte[0].mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc); @@ -3655,7 +3668,7 @@ void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 & case RIL_CELL_INFO_TYPE_TD_SCDMA: { cellIdentity.cellIdentityTdscdma.resize(1); cellIdentity.cellIdentityTdscdma[0].mcc = - std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc); + ril::util::mcc::decode(rilCellIdentity.cellIdentityTdscdma.mcc); cellIdentity.cellIdentityTdscdma[0].mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc); @@ -8077,7 +8090,7 @@ void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_veccellIdentityGsm.mcc = - std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc); + ril::util::mcc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc); cellInfoGsm->cellIdentityGsm.mnc = ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc); cellInfoGsm->cellIdentityGsm.lac = @@ -8101,7 +8114,7 @@ void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_veccellIdentityWcdma.mcc = - std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc); + ril::util::mcc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc); cellInfoWcdma->cellIdentityWcdma.mnc = ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc); cellInfoWcdma->cellIdentityWcdma.lac = @@ -8149,7 +8162,7 @@ void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_veccellIdentityLte.mcc = - std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc); + ril::util::mcc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc); cellInfoLte->cellIdentityLte.mnc = ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc); cellInfoLte->cellIdentityLte.ci = @@ -8179,7 +8192,8 @@ void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_veccellIdentityTdscdma.mcc = - std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc); + ril::util::mcc::decode( + rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc); cellInfoTdscdma->cellIdentityTdscdma.mnc = ril::util::mnc::decode( rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc); -- GitLab From 0e7fd598ac7caa2cdc4315a5c0a54eb6f7c7b94a Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Wed, 30 Sep 2020 12:09:23 +0200 Subject: [PATCH 002/191] Removed unknown sepolicy entry Change-Id: Id2dbc8807286f6f37b86d52b0c66ccaa601f3d2f --- BoardConfigCommon.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 1350bab..9b130c6 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -200,7 +200,7 @@ TARGET_LD_SHIM_LIBS := \ /system/bin/secd|/system/lib64/lib-preload64.so # SELinux -include device/qcom/sepolicy-legacy/sepolicy.mk +# include device/qcom/sepolicy-legacy/sepolicy.mk BOARD_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/vendor # WiFi -- GitLab From 331ed2ddfd2c90718f657429c6a7d03b9a6abab1 Mon Sep 17 00:00:00 2001 From: Arian Date: Tue, 22 Sep 2020 20:06:14 +0200 Subject: [PATCH 003/191] kitakami-common: Build new aidl qti power HAL Change-Id: I4bdea354e54d34d0dfe9b811e228fc6f8762d2ed --- device-common.mk | 2 +- manifest.xml | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/device-common.mk b/device-common.mk index 9fd0b0f..b21dc04 100644 --- a/device-common.mk +++ b/device-common.mk @@ -264,7 +264,7 @@ PRODUCT_PACKAGES += \ # Power PRODUCT_PACKAGES += \ - android.hardware.power@1.2-service-qti + android.hardware.power-service-qti # Public Libraries PRODUCT_COPY_FILES += \ diff --git a/manifest.xml b/manifest.xml index 13c371a..367d95a 100644 --- a/manifest.xml +++ b/manifest.xml @@ -162,15 +162,6 @@ default - - android.hardware.power - hwbinder - 1.2 - - IPower - default - - android.hardware.radio hwbinder -- GitLab From 5c20dc35636dd15083a23575fcb8cd1b3e79a833 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Fri, 18 Sep 2020 13:10:00 +0200 Subject: [PATCH 004/191] kitakami-common: Remove vintf entries that are now fragments Change-Id: I22b105b1340dff648bc5011b80f735b33d5fe370 --- manifest.xml | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/manifest.xml b/manifest.xml index 367d95a..379b796 100644 --- a/manifest.xml +++ b/manifest.xml @@ -67,8 +67,6 @@ default widevine - @1.2::ICryptoFactory/clearkey - @1.2::IDrmFactory/clearkey @1.1::ICryptoFactory/widevine @1.1::IDrmFactory/widevine @@ -223,33 +221,6 @@ default - - android.hardware.wifi - hwbinder - 1.3 - - IWifi - default - - - - android.hardware.wifi.hostapd - hwbinder - 1.1 - - IHostapd - default - - - - android.hardware.wifi.supplicant - hwbinder - 1.2 - - ISupplicant - default - - vendor.lineage.livedisplay hwbinder -- GitLab From 91ab9bc0c55829da5350afcd24f8b0dd1a85dc6c Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Fri, 18 Sep 2020 14:36:05 +0200 Subject: [PATCH 005/191] kitakami-common: Build libhidltransport/libhwbinder * Needed for old blobs Change-Id: I43fc0e46547dfc126a4b2ac9dcc82c7c4f2ee172 --- device-common.mk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/device-common.mk b/device-common.mk index b21dc04..e28d260 100644 --- a/device-common.mk +++ b/device-common.mk @@ -189,6 +189,13 @@ PRODUCT_COPY_FILES += \ PRODUCT_PACKAGES += \ android.hardware.health@1.0-impl +# HIDL +PRODUCT_PACKAGES += \ + libhidltransport \ + libhidltransport.vendor \ + libhwbinder \ + libhwbinder.vendor + # Init PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/rootdir/fstab.qcom:root/fstab.qcom \ -- GitLab From 68ba0b8a7d4bb54efe76e19848941a53228c97d3 Mon Sep 17 00:00:00 2001 From: ix5 Date: Wed, 29 Apr 2020 21:08:37 +0200 Subject: [PATCH 006/191] kitakami-common: Add protobuf vendorcompat lib Our blobs are compiled against libprotobuf-full-cpp.so, but starting in R, Android is using a versioned naming approach, e.g. libprotobuf-cpp-full-3.9.1.so. See https://r.android.com/1109518 The entry in public.libraries.txt is needed to allow the linker to find and use the lib outside the VNDK. See https://source.android.com/devices/tech/config/namespaces_libraries [wight554: added libprotobuf-cpp-lite as well] Signed-off-by: Volodymyr Zhdanov Change-Id: I28222c89e1e07017867088492a726ee9d45d8e6f --- configs/public.libraries.txt | 2 ++ device-common.mk | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/configs/public.libraries.txt b/configs/public.libraries.txt index 19c3863..b4d355e 100644 --- a/configs/public.libraries.txt +++ b/configs/public.libraries.txt @@ -1,3 +1,5 @@ libqti-perfd-client.so libadsprpc.so libOpenCL.so +libprotobuf-cpp-full.so +libprotobuf-cpp-lite.so diff --git a/device-common.mk b/device-common.mk index e28d260..9e0643e 100644 --- a/device-common.mk +++ b/device-common.mk @@ -273,6 +273,11 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ android.hardware.power-service-qti +# Protobuf +PRODUCT_PACKAGES += \ + libprotobuf-cpp-full-vendorcompat \ + libprotobuf-cpp-lite-vendorcompat + # Public Libraries PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/configs/public.libraries.txt:$(TARGET_COPY_OUT_VENDOR)/etc/public.libraries.txt -- GitLab From 455baf1655b036ada7bc82c144993fc798344aac Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Wed, 2 Oct 2019 12:49:15 -0700 Subject: [PATCH 007/191] kitakami-common: Remove libhidltransport dependency Since these were combined into libhidlbase. Bug: 135686713 Test: build only (libhwbinder/libhidltransport are empty) Change-Id: Iba2cd20b8b20fac3e7564de6b853b475fd4ebd2a --- fingerprint/Android.bp | 1 - 1 file changed, 1 deletion(-) diff --git a/fingerprint/Android.bp b/fingerprint/Android.bp index f37d7c2..aec3cf3 100644 --- a/fingerprint/Android.bp +++ b/fingerprint/Android.bp @@ -23,7 +23,6 @@ cc_binary { "libutils", "liblog", "libhidlbase", - "libhidltransport", "libhardware", "libhwbinder", "android.hardware.biometrics.fingerprint@2.1", -- GitLab From 76529c87e7f5feb0b87a2b3a77c3da6e40d1b4d1 Mon Sep 17 00:00:00 2001 From: dianlujitao Date: Sat, 12 Sep 2020 20:38:07 +0800 Subject: [PATCH 008/191] kitakami-common: Remove fingerprint entry from manifest Change-Id: Ib283c51f0ed4240568e5ccdb68e9a89612d7fca6 --- manifest.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/manifest.xml b/manifest.xml index 379b796..18f2088 100644 --- a/manifest.xml +++ b/manifest.xml @@ -17,15 +17,6 @@ default - - android.hardware.biometrics.fingerprint - hwbinder - 2.1 - - IBiometricsFingerprint - default - - android.hardware.bluetooth hwbinder -- GitLab From e596faa6a14d1f0fb7b8b3f949dd6581d21a7994 Mon Sep 17 00:00:00 2001 From: "P.Adarsh Reddy" Date: Mon, 9 Mar 2020 12:16:37 +0530 Subject: [PATCH 009/191] kitakami-common: Add build broken flags in BoardConfig.mk BUILD_BROKEN_USES_BUILD_COPY_HEADERS Change-Id: I7b115f5bb7990c438c595b4b1ff536598786d529 --- BoardConfigCommon.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 9b130c6..603f278 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -47,6 +47,7 @@ TARGET_USES_64_BIT_BINDER := true TARGET_USES_64_BIT_BCMDHD := true ENABLE_CPUSETS := true +BUILD_BROKEN_USES_BUILD_COPY_HEADERS := true # Boot image/kernel BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-5 loop.max_part=7 dwc3_msm.hvdcp_max_current=1500 dwc3_msm.prop_chg_detect=Y coherent_pool=2M swiotlb=2048 -- GitLab From fd7a425900366ee4fbf13db81ed03d772f455987 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Thu, 24 Sep 2020 17:47:06 +0800 Subject: [PATCH 010/191] kitakami-common: Switch DRM clearkey to 1.3 --- device-common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-common.mk b/device-common.mk index 9e0643e..cbd86b0 100644 --- a/device-common.mk +++ b/device-common.mk @@ -148,7 +148,7 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ android.hardware.drm@1.0-impl \ android.hardware.drm@1.0-service \ - android.hardware.drm@1.2-service.clearkey + android.hardware.drm@1.3-service.clearkey # Display PRODUCT_PACKAGES += \ -- GitLab From 9b4038020fee0fb8fa3b3dd6dd6ae0fb6c9862b1 Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Fri, 22 Nov 2019 10:56:29 -0800 Subject: [PATCH 011/191] kitakami-common: Switch to Audio HAL V6 Switch msm8956 to Audio HAL V6 Bug: 141989952 Test: atest VtsHalAudioV6_0TargetTest atest VtsHalAudioEffectV6_0TargetTest manual audio "smoke" test on taimen and walleye Change-Id: Ieb1cc5c7fdcc5416a328a0a5c4a1996258b81ac8 --- device-common.mk | 6 ++++-- manifest.xml | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/device-common.mk b/device-common.mk index cbd86b0..739093d 100644 --- a/device-common.mk +++ b/device-common.mk @@ -82,10 +82,12 @@ PRODUCT_PACKAGES += \ audiod \ audio.a2dp.default \ android.hardware.audio@2.0-impl \ - android.hardware.audio@4.0-impl \ + android.hardware.audio@6.0-impl \ + android.hardware.audio.common@6.0 \ + android.hardware.audio.common@6.0-util \ android.hardware.audio@2.0-service \ android.hardware.audio.effect@2.0-impl \ - android.hardware.audio.effect@4.0-impl \ + android.hardware.audio.effect@6.0-impl \ audio.primary.msm8994 \ audio.r_submix.default \ audio.usb.default \ diff --git a/manifest.xml b/manifest.xml index 18f2088..e1c0798 100644 --- a/manifest.xml +++ b/manifest.xml @@ -2,7 +2,7 @@ android.hardware.audio hwbinder - 4.0 + 6.0 IDevicesFactory default @@ -11,7 +11,7 @@ android.hardware.audio.effect hwbinder - 4.0 + 6.0 IEffectsFactory default -- GitLab From 5d83317a9075ba85231aaf7ea992434f8bb610bf Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Mon, 15 Jul 2019 16:43:26 -0700 Subject: [PATCH 012/191] kitakami-common: Replace BOARD_CHARGER_ENABLE_SUSPEND with ro.charger.enable_suspend Test: charger mode Bug: 124118169 Change-Id: I3825d08e38d677bd7154879609857de302348b6f --- BoardConfigCommon.mk | 1 - system.prop | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 603f278..520dc98 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -103,7 +103,6 @@ TARGET_PROCESS_SDK_VERSION_OVERRIDE := \ /system/bin/sensors.qcom=25 # Charger -BOARD_CHARGER_ENABLE_SUSPEND := true BOARD_CHARGER_SHOW_PERCENTAGE := true BOARD_CHARGER_DISABLE_INIT_BLANK := true diff --git a/system.prop b/system.prop index 6a2b313..6e9b3a2 100644 --- a/system.prop +++ b/system.prop @@ -27,6 +27,9 @@ ro.qc.sdk.gestures.camera=false ro.qc.sdk.camera.facialproc=false camera.disable_zsl_mode=1 +# Charger +ro.charger.enable_suspend=true + # Bluetooth bluetooth.enable_timeout_ms=12000 ro.bluetooth.hfp.ver=1.6 -- GitLab From 5ccb3700000550911df41bdc07a76508a1ede012 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Mon, 5 Oct 2020 11:55:36 +0200 Subject: [PATCH 013/191] Used another sepolicy entry Change-Id: I587d70e6cd12524addf233ee6d94a8e4460792be --- BoardConfigCommon.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 520dc98..06206cc 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -200,7 +200,7 @@ TARGET_LD_SHIM_LIBS := \ /system/bin/secd|/system/lib64/lib-preload64.so # SELinux -# include device/qcom/sepolicy-legacy/sepolicy.mk +include device/lineage/sepolicy/qcom/sepolicy.mk BOARD_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/vendor # WiFi -- GitLab From 30487719983dc27b078e8cf3bd93f1c781663a88 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Mon, 5 Oct 2020 12:06:59 +0200 Subject: [PATCH 014/191] kitakami-common: Remove libhwbinder dependency Since it is combined into libhidlbase. Change-Id: Ib4e4564a1ec1688c4779b58b036ae6eaf53dfa63 --- fingerprint/Android.bp | 1 - 1 file changed, 1 deletion(-) diff --git a/fingerprint/Android.bp b/fingerprint/Android.bp index aec3cf3..f6357a0 100644 --- a/fingerprint/Android.bp +++ b/fingerprint/Android.bp @@ -24,7 +24,6 @@ cc_binary { "liblog", "libhidlbase", "libhardware", - "libhwbinder", "android.hardware.biometrics.fingerprint@2.1", ], proprietary: true, -- GitLab From e7e8132e20525d4430158338bb5e6f4bf78f10a1 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Mon, 5 Oct 2020 16:32:04 +0200 Subject: [PATCH 015/191] Don't use USE_CUSTOM_AUDIO_POLICY Change-Id: I2aee5fbfbfb2ed36152aba23bd99b4eb339ab3a1 --- BoardConfigCommon.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 06206cc..ed802c6 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -80,7 +80,7 @@ AUDIO_FEATURE_ENABLED_PROXY_DEVICE := true AUDIO_USE_LL_AS_PRIMARY_OUTPUT := true BOARD_USES_ALSA_AUDIO := true -USE_CUSTOM_AUDIO_POLICY := 1 +USE_CUSTOM_AUDIO_POLICY := 0 USE_XML_AUDIO_POLICY_CONF := 1 # Bluetooth -- GitLab From 00820ca7927ec99722db6f0a5a7cbd0b72e86146 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Thu, 8 Oct 2020 17:06:52 +0800 Subject: [PATCH 016/191] Revert "kitakami-common: Switch to legacy Wi-Fi service" * Seems like Google fixed the mac address issues on 11. This reverts commit 6702cc6096f95b2f63bce23b1ae9b586800cc3d9. --- device-common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-common.mk b/device-common.mk index 739093d..4f332ce 100644 --- a/device-common.mk +++ b/device-common.mk @@ -331,7 +331,7 @@ PRODUCT_PACKAGES += \ # Wifi PRODUCT_PACKAGES += \ - android.hardware.wifi@1.0-service.legacy \ + android.hardware.wifi@1.0-service \ p2p_supplicant.conf \ hostapd \ libwifi-hal-bcm \ -- GitLab From cd07ba72cb8f1e7eadcde7fee5bcccc5664025e3 Mon Sep 17 00:00:00 2001 From: dianlujitao Date: Sun, 13 Sep 2020 16:18:28 +0800 Subject: [PATCH 017/191] kitakami-common: Add prebuilt protobuf from sdk28 Change-Id: I980a9e66cc0f99b5292210428c6ae9737e5b3969 --- device-common.mk | 7 +++++++ extract-files.sh | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/device-common.mk b/device-common.mk index 4f332ce..5b4426a 100644 --- a/device-common.mk +++ b/device-common.mk @@ -280,6 +280,13 @@ PRODUCT_PACKAGES += \ libprotobuf-cpp-full-vendorcompat \ libprotobuf-cpp-lite-vendorcompat +# Prebuilt Protobuf +PRODUCT_COPY_FILES += \ + prebuilts/vndk/v28/arm64/arch-arm-armv8-a/shared/vndk-core/libprotobuf-cpp-lite.so:$(TARGET_COPY_OUT_VENDOR)/lib/libprotobuf-cpp-lite-v28.so \ + prebuilts/vndk/v28/arm64/arch-arm64-armv8-a/shared/vndk-core/libprotobuf-cpp-full.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libprotobuf-cpp-full-v28.so \ + prebuilts/vndk/v28/arm64/arch-arm-armv8-a/shared/vndk-core/libprotobuf-cpp-full.so:$(TARGET_COPY_OUT_VENDOR)/lib/libprotobuf-cpp-full-v28.so \ + prebuilts/vndk/v28/arm64/arch-arm64-armv8-a/shared/vndk-core/libprotobuf-cpp-lite.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libprotobuf-cpp-lite-v28.so + # Public Libraries PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/configs/public.libraries.txt:$(TARGET_COPY_OUT_VENDOR)/etc/public.libraries.txt diff --git a/extract-files.sh b/extract-files.sh index 226a4d0..0923582 100755 --- a/extract-files.sh +++ b/extract-files.sh @@ -33,6 +33,19 @@ if [ ! -f "$HELPER" ]; then fi . "$HELPER" +function blob_fixup() { + case "${1}" in + vendor/lib/mediadrm/libwvdrmengine.so) + patchelf --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v28.so" "${2}" + ;; + vendor/lib64/libwvhidl.so) + patchelf --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v28.so" "${2}" + ;; + vendor/lib64/libsettings.so) + patchelf --replace-needed "libprotobuf-cpp-full.so" "libprotobuf-cpp-full-v28.so" "${2}" + ;; + esac +} # Default to sanitizing the vendor folder before extraction CLEAN_VENDOR=true -- GitLab From daf114ee877c1b2de5ce6241ee8315cb1bd1b094 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Fri, 9 Oct 2020 00:33:52 +0800 Subject: [PATCH 018/191] kitakami-common: Build Health HAL 2.0 --- device-common.mk | 5 +++-- manifest.xml | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/device-common.mk b/device-common.mk index 5b4426a..7d1526e 100644 --- a/device-common.mk +++ b/device-common.mk @@ -187,9 +187,10 @@ PRODUCT_PACKAGES += \ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/configs/flashled_calc_parameters.cfg:system/etc/flashled_calc_parameters.cfg -# Health +# Health HAL PRODUCT_PACKAGES += \ - android.hardware.health@1.0-impl + android.hardware.health@2.0-impl \ + android.hardware.health@2.0-service # HIDL PRODUCT_PACKAGES += \ diff --git a/manifest.xml b/manifest.xml index e1c0798..b05b089 100644 --- a/manifest.xml +++ b/manifest.xml @@ -108,8 +108,8 @@ android.hardware.health - passthrough - 1.0 + hwbinder + 2.0 IHealth default -- GitLab From 717d992004cea01678c5ea4b6689908e7e67f314 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Fri, 9 Oct 2020 00:34:16 +0800 Subject: [PATCH 019/191] kitakami-common: manifest: Remove configstore interface --- manifest.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/manifest.xml b/manifest.xml index b05b089..db0701c 100644 --- a/manifest.xml +++ b/manifest.xml @@ -35,15 +35,6 @@ legacy/0 - - android.hardware.configstore - hwbinder - 1.0 - - ISurfaceFlingerConfigs - default - - android.hardware.drm hwbinder -- GitLab From 71a5b9540e7a47f002b0ee83eb33291e614c5955 Mon Sep 17 00:00:00 2001 From: Pietro Ivan Cerrato Date: Wed, 30 Sep 2020 04:18:34 +0300 Subject: [PATCH 020/191] kitakami-common: Add mock dumpstate@1.1 service to make dev options happy --- device-common.mk | 4 + dumpstate/Android.bp | 26 ++++ ...hardware.dumpstate@1.1-service-kitakami.rc | 8 ++ ...ardware.dumpstate@1.1-service-kitakami.xml | 11 ++ dumpstate/main.cpp | 118 ++++++++++++++++++ 5 files changed, 167 insertions(+) create mode 100644 dumpstate/Android.bp create mode 100644 dumpstate/android.hardware.dumpstate@1.1-service-kitakami.rc create mode 100644 dumpstate/android.hardware.dumpstate@1.1-service-kitakami.xml create mode 100644 dumpstate/main.cpp diff --git a/device-common.mk b/device-common.mk index 7d1526e..f39f941 100644 --- a/device-common.mk +++ b/device-common.mk @@ -166,6 +166,10 @@ PRODUCT_PACKAGES += \ libtinyxml \ memtrack.msm8994 +# DumpState +PRODUCT_PACKAGES += \ + android.hardware.dumpstate@1.1-service-kitakami + # Gatekeeper PRODUCT_PACKAGES += \ android.hardware.gatekeeper@1.0-impl diff --git a/dumpstate/Android.bp b/dumpstate/Android.bp new file mode 100644 index 0000000..a5e0b16 --- /dev/null +++ b/dumpstate/Android.bp @@ -0,0 +1,26 @@ +cc_binary { + name: "android.hardware.dumpstate@1.1-service-kitakami", + vendor: true, + relative_install_path: "hw", + defaults: ["hidl_defaults"], + init_rc: [ + "android.hardware.dumpstate@1.1-service-kitakami.rc", + ], + vintf_fragments: [ + "android.hardware.dumpstate@1.1-service-kitakami.xml", + ], + srcs: ["main.cpp"], + shared_libs: [ + "android.hardware.dumpstate@1.0", + "android.hardware.dumpstate@1.1", + "libbase", + "libcutils", + "libdumpstateutil", + "libhidlbase", + "liblog", + "libutils", + ], + cflags: [ + "-DLOG_TAG=\"android.hardware.dumpstate@1.1-service-kitakami\"", + ], +} diff --git a/dumpstate/android.hardware.dumpstate@1.1-service-kitakami.rc b/dumpstate/android.hardware.dumpstate@1.1-service-kitakami.rc new file mode 100644 index 0000000..e934227 --- /dev/null +++ b/dumpstate/android.hardware.dumpstate@1.1-service-kitakami.rc @@ -0,0 +1,8 @@ +service dumpstate-1-1 /vendor/bin/hw/android.hardware.dumpstate@1.1-service-kitakami + class hal + user nobody + group nobody + interface android.hardware.dumpstate@1.0::IDumpstateDevice default + interface android.hardware.dumpstate@1.1::IDumpstateDevice default + oneshot + disabled diff --git a/dumpstate/android.hardware.dumpstate@1.1-service-kitakami.xml b/dumpstate/android.hardware.dumpstate@1.1-service-kitakami.xml new file mode 100644 index 0000000..775e8c8 --- /dev/null +++ b/dumpstate/android.hardware.dumpstate@1.1-service-kitakami.xml @@ -0,0 +1,11 @@ + + + android.hardware.dumpstate + hwbinder + 1.1 + + IDumpstateDevice + default + + + diff --git a/dumpstate/main.cpp b/dumpstate/main.cpp new file mode 100644 index 0000000..e2c1b6a --- /dev/null +++ b/dumpstate/main.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "DumpstateUtil.h" + +namespace { +using ::android::hardware::hidl_handle; +using ::android::hardware::Return; +using ::android::hardware::Void; + +using ::android::hardware::dumpstate::V1_1::DumpstateMode; +using ::android::hardware::dumpstate::V1_1::DumpstateStatus; +using ::android::hardware::dumpstate::V1_1::IDumpstateDevice; + +using ::android::os::dumpstate::DumpFileToFd; + +const char kVerboseLoggingProperty[] = "persist.dumpstate.verbose_logging.enabled"; + +struct DumpstateDevice : public IDumpstateDevice { + // 1.1 + Return dumpstateBoard_1_1(const hidl_handle& handle, const DumpstateMode mode, + uint64_t /*timeoutMillis*/) override { + if (handle == nullptr || handle->numFds < 1) { + ALOGE("no FDs\n"); + return DumpstateStatus::ILLEGAL_ARGUMENT; + } + + int fd = handle->data[0]; + if (fd < 0) { + ALOGE("invalid FD: %d\n", fd); + return DumpstateStatus::ILLEGAL_ARGUMENT; + } + + switch (mode) { + case DumpstateMode::FULL: + return dumpstateBoardImpl(fd, true); + + case DumpstateMode::DEFAULT: + return dumpstateBoardImpl(fd, false); + + case DumpstateMode::INTERACTIVE: + case DumpstateMode::REMOTE: + case DumpstateMode::WEAR: + case DumpstateMode::CONNECTIVITY: + case DumpstateMode::WIFI: + case DumpstateMode::PROTO: + ALOGE("The requested mode is not supported: %s\n", toString(mode).c_str()); + return DumpstateStatus::UNSUPPORTED_MODE; + + default: + ALOGE("The requested mode is invalid: %s\n", toString(mode).c_str()); + return DumpstateStatus::ILLEGAL_ARGUMENT; + } + } + + Return setVerboseLoggingEnabled(bool enable) override { + ::android::base::SetProperty(kVerboseLoggingProperty, enable ? "true" : "false"); + return Void(); + } + + Return getVerboseLoggingEnabled() override { return getVerboseLoggingEnabledImpl(); } + + // 1.0 + Return dumpstateBoard(const hidl_handle& h) override { + dumpstateBoard_1_1(h, DumpstateMode::DEFAULT, 0); + return Void(); + } + + DumpstateStatus dumpstateBoardImpl(const int /*fd*/, const bool /*full*/) { + return DumpstateStatus::OK; + } + + static bool getVerboseLoggingEnabledImpl() { + return ::android::base::GetBoolProperty(kVerboseLoggingProperty, false); + } +}; +} // namespace + +int main(int, char**) { + using ::android::sp; + using ::android::hardware::configureRpcThreadpool; + using ::android::hardware::joinRpcThreadpool; + using ::android::hardware::LazyServiceRegistrar; + + configureRpcThreadpool(1, true); + + sp dumpstate(new DumpstateDevice); + auto serviceRegistrar = LazyServiceRegistrar::getInstance(); + + if (serviceRegistrar.registerService(dumpstate) != ::android::OK) { + ALOGE("Could not register service."); + return 1; + } + + joinRpcThreadpool(); + return 0; +} -- GitLab From ae39370826f0f784e0c9f0986be5519ecaf6bf08 Mon Sep 17 00:00:00 2001 From: Dyneteve Date: Thu, 17 Sep 2020 18:46:02 +0200 Subject: [PATCH 021/191] kitakami-common: sepolicy: Label dumpstate hal --- sepolicy/vendor/file_contexts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 1842259..0493907 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -22,6 +22,9 @@ # Camera /sys/devices(/soc\.0)?/pmi8994-flash-27(/.*)? u:object_r:sysfs_camera_torch:s0 +# Dumpstate HAL +/vendor/bin/hw/android\.hardware\.dumpstate@1\.1-service\.kitakami u:object_r:hal_dumpstate_impl_exec:s0 + # HCI /dev/ttyHS0 u:object_r:hci_attach_dev:s0 /dev/brcm_bt_drv u:object_r:hci_attach_dev:s0 -- GitLab From fac71ff89cab8946e1d1101c709a03f19ad0921a Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Fri, 9 Oct 2020 16:32:17 +0800 Subject: [PATCH 022/191] kitakami-common: libshim: Update camera shims to R --- libshim/camera.qcom_shim.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/libshim/camera.qcom_shim.cpp b/libshim/camera.qcom_shim.cpp index 1a7289c..deb67f9 100644 --- a/libshim/camera.qcom_shim.cpp +++ b/libshim/camera.qcom_shim.cpp @@ -108,7 +108,7 @@ extern "C" void _ZN7android13GraphicBufferC1Ejjij( // PixelFormat format, uint32_t flags, // SurfaceControl* parent, // LayerMetadata metadata); -extern "C" void* _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8EjjijPNS_14SurfaceControlENS_13LayerMetadataE( +/*extern "C" void* _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8EjjijPNS_14SurfaceControlENS_13LayerMetadataE( const android::String8& name,// name of the surface uint32_t w, // width in pixel uint32_t h, // height in pixel @@ -116,16 +116,16 @@ extern "C" void* _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8 uint32_t flags, // usage flags SurfaceControl* parent, // parent android::LayerMetadata metadata -); +);*/ -extern "C" void* _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8Ejjij( +/*extern "C" void* _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8Ejjij( const android::String8& name, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags) { android::LayerMetadata metadata; sc = _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8EjjijPNS_14SurfaceControlENS_13LayerMetadataE(name, w, h, format, flags, nullptr, metadata); return sc; -} +}*/ // status_t setLayer(uint32_t layer); extern "C" status_t _ZN7android14SurfaceControl8setLayerEj(uint32_t layer) { @@ -147,14 +147,6 @@ extern "C" void _ZN7android21SurfaceComposerClient17setDisplaySurfaceERKNS_2spIN t->setDisplaySurface(token, bufferProducer); } -extern "C" void _ZN7android21SurfaceComposerClient20setDisplayProjectionERKNS_2spINS_7IBinderEEEjRKNS_4RectES8_( - const sp& token, - uint32_t orientation, - const android::Rect& layerStackRect, - const android::Rect& displayRect) { - t->setDisplayProjection(token, orientation, layerStackRect, displayRect); -} - extern "C" void _ZN7android21SurfaceComposerClient20setDisplayLayerStackERKNS_2spINS_7IBinderEEEj( const sp& token, uint32_t layerStack){ t->setDisplayLayerStack(token, layerStack); @@ -184,11 +176,11 @@ extern "C" void* _ZN7android21SurfaceComposerClient17getBuiltInDisplayEi(int32_t return _ZN7android21SurfaceComposerClient23getPhysicalDisplayTokenEy(static_cast(id)); } -extern "C" void _ZN7android14SurfaceControl7destroyEv(void); +/*extern "C" void _ZN7android14SurfaceControl7destroyEv(void); extern "C" void _ZN7android14SurfaceControl5clearEv(void){ _ZN7android14SurfaceControl7destroyEv(); -} +}*/ //android::GraphicBuffer::lock(uint32_t inUsage, void** vaddr, int32_t* outBytesPerPixel, // int32_t* outBytesPerStride); -- GitLab From 96a3e5065762ce621c79d69644b06fe575996823 Mon Sep 17 00:00:00 2001 From: Hrutvik Jagtap Date: Sat, 12 Sep 2020 21:00:12 +0530 Subject: [PATCH 023/191] kitakami-common: overlay: Disable wifi ap mac randomization * WIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION is deprecated --- overlay/frameworks/base/core/res/res/values/config.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml index b25c366..efaac2d 100644 --- a/overlay/frameworks/base/core/res/res/values/config.xml +++ b/overlay/frameworks/base/core/res/res/values/config.xml @@ -324,4 +324,6 @@ --> true + + false -- GitLab From ea7e0d2320bce63fda16256c0b988ba5ac27e6ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Patron?= Date: Wed, 23 Sep 2020 05:38:33 +0000 Subject: [PATCH 024/191] kitakami-common: Set PRODUCT_ENFORCE_VINTF_MANIFEST_OVERRIDE := true * Apparently this is now required on all non full treble devices since google added a sleep(1) in libhidl... Signed-off-by: MASTERGUY --- BoardConfigCommon.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index ed802c6..0d3cf30 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -149,6 +149,7 @@ TARGET_PROVIDES_LIBLIGHT := true # HIDL DEVICE_MANIFEST_FILE := $(COMMON_PATH)/manifest.xml +PRODUCT_ENFORCE_VINTF_MANIFEST_OVERRIDE := true # Init TARGET_PLATFORM_DEVICE_BASE := /devices/soc.0/ -- GitLab From c88fdce680c5c1c37efec9681b19c4d6b0570457 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Sun, 11 Oct 2020 01:48:01 +0800 Subject: [PATCH 025/191] kitakami-common: Disable traced service --- system.prop | 3 +++ 1 file changed, 3 insertions(+) diff --git a/system.prop b/system.prop index 6e9b3a2..98f342b 100644 --- a/system.prop +++ b/system.prop @@ -120,6 +120,9 @@ ro.sony.sensors.dpc=false ro.sony.sensors.pug=false ro.qc.sdk.sensors.gestures=true +# Traced +persist.traced.enable=0 + # Wifi wifi.interface=wlan0 wifi.direct.interface=p2p-dev-wlan0 -- GitLab From 94bfb4b10c734b354c87bbd805a20425720ae0ea Mon Sep 17 00:00:00 2001 From: Akash Mondal Date: Sat, 28 Sep 2019 02:22:45 +0530 Subject: [PATCH 026/191] kitakami-common: build power stats hal fix: Cannot find entry android.hardware.power.stats@1.0::IPowerStats/default in either framework or device manifest. Signed-off-by: Akash Mondal --- device-common.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/device-common.mk b/device-common.mk index f39f941..4976091 100644 --- a/device-common.mk +++ b/device-common.mk @@ -278,7 +278,8 @@ PRODUCT_PACKAGES += \ # Power PRODUCT_PACKAGES += \ - android.hardware.power-service-qti + android.hardware.power-service-qti \ + android.hardware.power.stats@1.0-service.mock # Protobuf PRODUCT_PACKAGES += \ -- GitLab From c565bc65e40e9c4c5045606617315a9831d71efb Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Sun, 11 Oct 2020 12:55:31 +0800 Subject: [PATCH 027/191] Revert "kitakami-common: libshim: Update camera shims to R" This reverts commit 79d26922bc7de2d31b0f61d72265f73f0da56693. --- libshim/camera.qcom_shim.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libshim/camera.qcom_shim.cpp b/libshim/camera.qcom_shim.cpp index deb67f9..1a7289c 100644 --- a/libshim/camera.qcom_shim.cpp +++ b/libshim/camera.qcom_shim.cpp @@ -108,7 +108,7 @@ extern "C" void _ZN7android13GraphicBufferC1Ejjij( // PixelFormat format, uint32_t flags, // SurfaceControl* parent, // LayerMetadata metadata); -/*extern "C" void* _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8EjjijPNS_14SurfaceControlENS_13LayerMetadataE( +extern "C" void* _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8EjjijPNS_14SurfaceControlENS_13LayerMetadataE( const android::String8& name,// name of the surface uint32_t w, // width in pixel uint32_t h, // height in pixel @@ -116,16 +116,16 @@ extern "C" void _ZN7android13GraphicBufferC1Ejjij( uint32_t flags, // usage flags SurfaceControl* parent, // parent android::LayerMetadata metadata -);*/ +); -/*extern "C" void* _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8Ejjij( +extern "C" void* _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8Ejjij( const android::String8& name, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags) { android::LayerMetadata metadata; sc = _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8EjjijPNS_14SurfaceControlENS_13LayerMetadataE(name, w, h, format, flags, nullptr, metadata); return sc; -}*/ +} // status_t setLayer(uint32_t layer); extern "C" status_t _ZN7android14SurfaceControl8setLayerEj(uint32_t layer) { @@ -147,6 +147,14 @@ extern "C" void _ZN7android21SurfaceComposerClient17setDisplaySurfaceERKNS_2spIN t->setDisplaySurface(token, bufferProducer); } +extern "C" void _ZN7android21SurfaceComposerClient20setDisplayProjectionERKNS_2spINS_7IBinderEEEjRKNS_4RectES8_( + const sp& token, + uint32_t orientation, + const android::Rect& layerStackRect, + const android::Rect& displayRect) { + t->setDisplayProjection(token, orientation, layerStackRect, displayRect); +} + extern "C" void _ZN7android21SurfaceComposerClient20setDisplayLayerStackERKNS_2spINS_7IBinderEEEj( const sp& token, uint32_t layerStack){ t->setDisplayLayerStack(token, layerStack); @@ -176,11 +184,11 @@ extern "C" void* _ZN7android21SurfaceComposerClient17getBuiltInDisplayEi(int32_t return _ZN7android21SurfaceComposerClient23getPhysicalDisplayTokenEy(static_cast(id)); } -/*extern "C" void _ZN7android14SurfaceControl7destroyEv(void); +extern "C" void _ZN7android14SurfaceControl7destroyEv(void); extern "C" void _ZN7android14SurfaceControl5clearEv(void){ _ZN7android14SurfaceControl7destroyEv(); -}*/ +} //android::GraphicBuffer::lock(uint32_t inUsage, void** vaddr, int32_t* outBytesPerPixel, // int32_t* outBytesPerStride); -- GitLab From d69f9156b0251f7d6ab60cb8a1f76f862586eac1 Mon Sep 17 00:00:00 2001 From: Joel Stein Date: Tue, 6 Oct 2020 08:01:44 +0200 Subject: [PATCH 028/191] kitakami-common: libshim: update camera_shim to R Change-Id: I47cc6f4a9aa9729f3df46a7e2613f41ee7b80fc5 --- libshim/camera.qcom_shim.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/libshim/camera.qcom_shim.cpp b/libshim/camera.qcom_shim.cpp index 1a7289c..445294f 100644 --- a/libshim/camera.qcom_shim.cpp +++ b/libshim/camera.qcom_shim.cpp @@ -107,23 +107,21 @@ extern "C" void _ZN7android13GraphicBufferC1Ejjij( //sp SurfaceComposerClient::createSurface(const String8& name, uint32_t w, uint32_t h, // PixelFormat format, uint32_t flags, // SurfaceControl* parent, -// LayerMetadata metadata); -extern "C" void* _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8EjjijPNS_14SurfaceControlENS_13LayerMetadataE( - const android::String8& name,// name of the surface - uint32_t w, // width in pixel - uint32_t h, // height in pixel - PixelFormat format, // pixel-format desired - uint32_t flags, // usage flags - SurfaceControl* parent, // parent - android::LayerMetadata metadata -); +// LayerMetadata metadata, +// uint32_t* outTransformHint) +extern "C" void* _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8EjjijPNS_14SurfaceControlENS_13LayerMetadataEPj(const android::String8& name, uint32_t w, uint32_t h, + PixelFormat format, uint32_t flags, + SurfaceControl* parent, + android::LayerMetadata metadata, + uint32_t* outTransformHint); + extern "C" void* _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8Ejjij( const android::String8& name, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags) { android::LayerMetadata metadata; - sc = _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8EjjijPNS_14SurfaceControlENS_13LayerMetadataE(name, w, h, format, flags, nullptr, metadata); + sc = _ZN7android21SurfaceComposerClient13createSurfaceERKNS_7String8EjjijPNS_14SurfaceControlENS_13LayerMetadataEPj(name, w, h, format, flags, nullptr, metadata, nullptr); return sc; } @@ -152,7 +150,7 @@ extern "C" void _ZN7android21SurfaceComposerClient20setDisplayProjectionERKNS_2s uint32_t orientation, const android::Rect& layerStackRect, const android::Rect& displayRect) { - t->setDisplayProjection(token, orientation, layerStackRect, displayRect); + t->setDisplayProjection(token, static_cast(orientation), layerStackRect, displayRect); } extern "C" void _ZN7android21SurfaceComposerClient20setDisplayLayerStackERKNS_2spINS_7IBinderEEEj( @@ -184,10 +182,13 @@ extern "C" void* _ZN7android21SurfaceComposerClient17getBuiltInDisplayEi(int32_t return _ZN7android21SurfaceComposerClient23getPhysicalDisplayTokenEy(static_cast(id)); } -extern "C" void _ZN7android14SurfaceControl7destroyEv(void); + +extern "C" void _ZN7android14SurfaceControlD0Ev(void); +extern "C" void _ZN7android14SurfaceControlD1Ev(void); +extern "C" void _ZN7android14SurfaceControlD2Ev(void); extern "C" void _ZN7android14SurfaceControl5clearEv(void){ - _ZN7android14SurfaceControl7destroyEv(); + _ZN7android14SurfaceControlD0Ev(); } //android::GraphicBuffer::lock(uint32_t inUsage, void** vaddr, int32_t* outBytesPerPixel, -- GitLab From 074c9718a69190d9177c5188a8efba56ca818d5a Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Sun, 11 Oct 2020 13:00:10 +0800 Subject: [PATCH 029/191] Revert "kitakami-common: Remove fingerprint entry from manifest" This reverts commit 3475f4bfdd121210666ee8eccf3f622448897bc9. --- manifest.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/manifest.xml b/manifest.xml index db0701c..ddb6ed7 100644 --- a/manifest.xml +++ b/manifest.xml @@ -17,6 +17,15 @@ default + + android.hardware.biometrics.fingerprint + hwbinder + 2.1 + + IBiometricsFingerprint + default + + android.hardware.bluetooth hwbinder -- GitLab From e0f57ff57df9fa113e654a9d5269b3ef9a6fd34d Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sun, 11 Oct 2020 12:58:05 +0200 Subject: [PATCH 030/191] kitakami-common: manifest: Defined 'level' attribute in device manifest to suppress this warning: Warning: Shipping FCM Version cannot be inferred Change-Id: If013a88ab65ae3b96c7ea205c1c884ef90366269 --- manifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.xml b/manifest.xml index ddb6ed7..d85c8f9 100644 --- a/manifest.xml +++ b/manifest.xml @@ -1,4 +1,4 @@ - + android.hardware.audio hwbinder -- GitLab From e5d5eb14bc809f1380ed04675318aa027d7ea6c8 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Sun, 11 Oct 2020 17:16:26 +0800 Subject: [PATCH 031/191] kitakami-common: overlay: Move fp hax overlay to lineage-sdk --- .../core/res/res/values/lineage_config.xml | 24 ------------------- .../lineage/res/res/values/config.xml | 7 ++++++ 2 files changed, 7 insertions(+), 24 deletions(-) delete mode 100644 overlay/frameworks/base/core/res/res/values/lineage_config.xml diff --git a/overlay/frameworks/base/core/res/res/values/lineage_config.xml b/overlay/frameworks/base/core/res/res/values/lineage_config.xml deleted file mode 100644 index e0873d8..0000000 --- a/overlay/frameworks/base/core/res/res/values/lineage_config.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - true - - - false - diff --git a/overlay/lineage-sdk/lineage/res/res/values/config.xml b/overlay/lineage-sdk/lineage/res/res/values/config.xml index 25868e4..2894e86 100644 --- a/overlay/lineage-sdk/lineage/res/res/values/config.xml +++ b/overlay/lineage-sdk/lineage/res/res/values/config.xml @@ -57,4 +57,11 @@ For example, a device with Home, Back and Menu keys would set this config to 7. --> 64 + + + true + + + false -- GitLab From 25d50c5e0e4de44965ec7b2a5b1540def40aeb12 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sun, 11 Oct 2020 15:54:49 +0200 Subject: [PATCH 032/191] Revert "Used another sepolicy entry" This reverts commit 5ccb3700000550911df41bdc07a76508a1ede012. --- BoardConfigCommon.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 0d3cf30..71a331c 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -201,7 +201,7 @@ TARGET_LD_SHIM_LIBS := \ /system/bin/secd|/system/lib64/lib-preload64.so # SELinux -include device/lineage/sepolicy/qcom/sepolicy.mk +# include device/qcom/sepolicy-legacy/sepolicy.mk BOARD_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/vendor # WiFi -- GitLab From 39b9261bca03bc7caa20c6b6ee1a3a3e34ff8641 Mon Sep 17 00:00:00 2001 From: Han Wang <416810799@qq.com> Date: Sat, 19 Sep 2020 16:08:55 +0200 Subject: [PATCH 033/191] kitakami-common: Update loader config for media swcodec to 11 * Head at bb8f985d773f63f9e943103cb1faae5bfba8e1e1. Change-Id: I4fb2bc8e40406b2fd8d6d002330f666b7fe5823e --- configs/ld.config.txt | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/configs/ld.config.txt b/configs/ld.config.txt index 29a600d..222182d 100644 --- a/configs/ld.config.txt +++ b/configs/ld.config.txt @@ -22,12 +22,18 @@ namespace.default.visible = true namespace.default.search.paths = /apex/com.android.media.swcodec/${LIB} namespace.default.asan.search.paths = /apex/com.android.media.swcodec/${LIB} +# Below lines are required to be able to access libs in APEXes which are +# actually symlinks to the files under /system/lib. The symlinks exist for +# bundled APEXes to reduce space. +namespace.default.permitted.paths = /system/${LIB} +namespace.default.asan.permitted.paths = /system/${LIB} + namespace.default.links = platform # TODO: replace the following when apex has a way to auto-generate this list # namespace.default.link.platform.shared_libs = %LLNDK_LIBRARIES% # namespace.default.link.platform.shared_libs += %SANITIZER_RUNTIME_LIBRARIES% -namespace.default.link.platform.shared_libs = libEGL.so:libGLESv1_CM.so:libGLESv2.so:libGLESv3.so:libRS.so:libandroid_net.so:libc.so:libcgrouprc.so:libclang_rt.asan-aarch64-android.so:libclang_rt.asan-arm-android.so:libclang_rt.hwasan-aarch64-android.so:libclang_rt.asan-i686-android.so:libclang_rt.asan-x86_64-android.so:libdl.so:libft2.so:liblog.so:libm.so:libmediandk.so:libnativewindow.so:libneuralnetworks.so:libsync.so:libvndksupport.so:libdl_android.so:libvulkan.so:libashmemd_client.so +namespace.default.link.platform.shared_libs = libEGL.so:libGLESv1_CM.so:libGLESv2.so:libGLESv3.so:libRS.so:libandroid_net.so:libc.so:libcgrouprc.so:libclang_rt.asan-aarch64-android.so:libclang_rt.asan-arm-android.so:libclang_rt.hwasan-aarch64-android.so:libclang_rt.asan-i686-android.so:libclang_rt.asan-x86_64-android.so:libdl.so:libft2.so:liblog.so:libm.so:libmediandk.so:libnativewindow.so:libneuralnetworks.so:libsync.so:libvndksupport.so:libdl_android.so:libvulkan.so:libashmemd_client.so:libbinder_ndk.so ############################################################################### # "platform" namespace @@ -38,13 +44,18 @@ namespace.default.link.platform.shared_libs = libEGL.so:libGLESv1_CM.so:libGLESv namespace.platform.isolated = true namespace.platform.search.paths = /system/${LIB} -namespace.platform.search.paths += /apex/com.android.runtime/${LIB} namespace.platform.asan.search.paths = /data/asan/system/${LIB} namespace.platform.asan.search.paths += /system/${LIB} + +# TODO(b/140790209): These directories are wrong in R and later because they +# only contain Bionic internal libraries dependencies that should not be +# accessed from the outside. However, they may be necessary for APEX builds that +# are pushed to Q. Remove them as soon as Q compatibility is no longer required. +namespace.platform.search.paths += /apex/com.android.runtime/${LIB} namespace.platform.asan.search.paths += /apex/com.android.runtime/${LIB} # /system/lib/libc.so, etc are symlinks to /apex/com.android.lib/lib/bionic/libc.so, etc. -# Add /apex/... pat to the permitted paths because linker uses realpath(3) +# Add /apex/... path to the permitted paths because linker uses realpath(3) # to check the accessibility of the lib. We could add this to search.paths # instead but that makes the resolution of bionic libs be dependent on # the order of /system/lib and /apex/... in search.paths. If /apex/... @@ -130,7 +141,13 @@ namespace.sphal.links = platform # TODO: replace the following when apex has a way to auto-generate this list # namespace.sphal.link.platform.shared_libs = %LLNDK_LIBRARIES% # namespace.sphal.link.platform.shared_libs += %SANITIZER_RUNTIME_LIBRARIES% -namespace.sphal.link.platform.shared_libs = libEGL.so:libGLESv1_CM.so:libGLESv2.so:libGLESv3.so:libRS.so:libandroid_net.so:libc.so:libcgrouprc.so:libclang_rt.asan-aarch64-android.so:libclang_rt.asan-arm-android.so:libclang_rt.hwasan-aarch64-android.so:libclang_rt.asan-i686-android.so:libclang_rt.asan-x86_64-android.so:libdl.so:libft2.so:liblog.so:libm.so:libmediandk.so:libnativewindow.so:libneuralnetworks.so:libsync.so:libvndksupport.so:libvulkan.so +namespace.sphal.link.platform.shared_libs = libEGL.so:libGLESv1_CM.so:libGLESv2.so:libGLESv3.so:libRS.so:libandroid_net.so:libc.so:libcgrouprc.so:libclang_rt.asan-aarch64-android.so:libclang_rt.asan-arm-android.so:libclang_rt.hwasan-aarch64-android.so:libclang_rt.asan-i686-android.so:libclang_rt.asan-x86_64-android.so:libdl.so:libft2.so:liblog.so:libm.so:libmediandk.so:libnativewindow.so:libneuralnetworks.so:libsync.so:libvndksupport.so:libvulkan.so:libbinder_ndk.so # Add a link for libz.so which is llndk on devices where VNDK is not enforced. namespace.sphal.link.platform.shared_libs += libz.so + +# With VNDK APEX, /system/${LIB}/vndk-sp${VNDK_VER} is a symlink to the following. +# Add /apex/... path to the permitted paths because linker uses realpath(3) +# to check the accessibility of the lib. +namespace.sphal.permitted.paths += /apex/com.android.vndk.${VNDK_APEX_VER}/${LIB} +namespace.sphal.asan.permitted.paths += /apex/com.android.vndk.${VNDK_APEX_VER}/${LIB} -- GitLab From b0001d8e80161a84f243d8e4dabbd2fd731eed8c Mon Sep 17 00:00:00 2001 From: inthewaves Date: Sun, 20 Sep 2020 11:03:06 -0700 Subject: [PATCH 034/191] kitakami-common: add config overlay for biometric sensors Change-Id: Iad81cd680fbeedd1ac3f216727e367d790834423 --- overlay/frameworks/base/core/res/res/values/config.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml index efaac2d..ba872aa 100644 --- a/overlay/frameworks/base/core/res/res/values/config.xml +++ b/overlay/frameworks/base/core/res/res/values/config.xml @@ -326,4 +326,13 @@ false + + + + + 0:2:15 + -- GitLab From 1b8c72336cbfd5caecdd0f667d5bd6f9c5febfe8 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Wed, 21 Oct 2020 12:05:26 +0800 Subject: [PATCH 035/191] kitakami-common: Uprev DRM widevine to 1.3 --- manifest.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.xml b/manifest.xml index d85c8f9..026537e 100644 --- a/manifest.xml +++ b/manifest.xml @@ -37,7 +37,7 @@ android.hardware.camera.provider - passthrough + passthrough 2.4 ICameraProvider @@ -58,8 +58,8 @@ default widevine - @1.1::ICryptoFactory/widevine - @1.1::IDrmFactory/widevine + @1.3::ICryptoFactory/widevine + @1.3::IDrmFactory/widevine android.hardware.gatekeeper -- GitLab From 260d165f1ee9082f9b3280783526b64f84159ce6 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Wed, 21 Oct 2020 13:32:23 +0800 Subject: [PATCH 036/191] kitakami-common: manifest: Add OMX Service entry --- manifest.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/manifest.xml b/manifest.xml index 026537e..5f079ee 100644 --- a/manifest.xml +++ b/manifest.xml @@ -151,6 +151,19 @@ default + + android.hardware.media.omx + hwbinder + 1.0 + + IOmx + default + + + IOmxStore + default + + android.hardware.radio hwbinder -- GitLab From 48007cfae4ebdfb44d475574979c56047153ebf7 Mon Sep 17 00:00:00 2001 From: Stephane Lee Date: Thu, 19 Dec 2019 14:57:04 -0800 Subject: [PATCH 037/191] kitakami-common: health HAL 2.1 Bug: b/137790244 Test: lshal debug (health service) Change-Id: Id15d203bd791d0867972da98f6998610723b9332 --- device-common.mk | 4 ++-- manifest.xml | 9 --------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/device-common.mk b/device-common.mk index 4976091..b4abf40 100644 --- a/device-common.mk +++ b/device-common.mk @@ -193,8 +193,8 @@ PRODUCT_COPY_FILES += \ # Health HAL PRODUCT_PACKAGES += \ - android.hardware.health@2.0-impl \ - android.hardware.health@2.0-service + android.hardware.health@2.1-impl \ + android.hardware.health@2.1-service # HIDL PRODUCT_PACKAGES += \ diff --git a/manifest.xml b/manifest.xml index 5f079ee..5504d44 100644 --- a/manifest.xml +++ b/manifest.xml @@ -106,15 +106,6 @@ default - - android.hardware.health - hwbinder - 2.0 - - IHealth - default - - android.hardware.keymaster passthrough -- GitLab From fec90bc2da4686fea21e52d41db740ccc62c667f Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Mon, 26 Oct 2020 16:34:42 +0100 Subject: [PATCH 038/191] kitakami-common: sepolicy: Switch to permissive mode for now Change-Id: I058db0dcc64d91a86effa5a784937cf11649ee7c --- BoardConfigCommon.mk | 1 + sepolicy/vendor/adbd.te | 1 - sepolicy/vendor/adsprpcd.te | 1 - sepolicy/vendor/apexd.te | 1 - sepolicy/vendor/ashmemd.te | 1 - sepolicy/vendor/audioserver.te | 4 - sepolicy/vendor/bootanim.te | 1 - sepolicy/vendor/bootstat.te | 1 - sepolicy/vendor/cameraserver.te | 18 --- sepolicy/vendor/charger.te | 5 - sepolicy/vendor/clatd.te | 1 - sepolicy/vendor/device.te | 3 - sepolicy/vendor/drmserver.te | 1 - sepolicy/vendor/file.te | 23 ---- sepolicy/vendor/flags_health_check.te | 25 ---- sepolicy/vendor/fsck.te | 5 - sepolicy/vendor/fsck_untrusted.te | 1 - sepolicy/vendor/gatekeeperd.te | 2 - sepolicy/vendor/gpuservice.te | 1 - sepolicy/vendor/hal_audio_default.te | 3 - sepolicy/vendor/hal_bluetooth_default.te | 7 -- sepolicy/vendor/hal_camera_default.te | 4 - sepolicy/vendor/hal_cas_default.te | 1 - sepolicy/vendor/hal_configstore_default.te | 1 - sepolicy/vendor/hal_drm_default.te | 1 - sepolicy/vendor/hal_fingerprint_default.te | 18 --- .../vendor/hal_graphics_allocator_default.te | 2 - sepolicy/vendor/hal_keymaster_qti.te | 1 - sepolicy/vendor/hal_light_default.te | 2 - .../vendor/hal_lineage_livedisplay_qti.te | 2 - .../vendor/hal_lineage_livedisplay_sysfs.te | 2 - sepolicy/vendor/hal_lineage_trust_default.te | 1 - sepolicy/vendor/hal_memtrack_default.te | 1 - sepolicy/vendor/hal_power_default.te | 2 - sepolicy/vendor/hal_ril_default.te | 6 - sepolicy/vendor/hal_ril_wrapper.te | 6 - sepolicy/vendor/hal_usb_default.te | 1 - sepolicy/vendor/hal_wifi_default.te | 7 -- .../vendor/hal_wifi_supplicant_default.te | 1 - sepolicy/vendor/healthd.te | 2 - sepolicy/vendor/hwservicemanager.te | 4 - sepolicy/vendor/iddd.te | 20 ---- sepolicy/vendor/idmap.te | 1 - sepolicy/vendor/incidentd.te | 1 - sepolicy/vendor/init-power-sh.te | 38 ------ sepolicy/vendor/init.te | 50 -------- sepolicy/vendor/installd.te | 2 - sepolicy/vendor/irsc_util.te | 1 - sepolicy/vendor/kernel.te | 6 - sepolicy/vendor/keystore.te | 2 - sepolicy/vendor/lmkd.te | 1 - sepolicy/vendor/loc_launcher.te | 15 --- sepolicy/vendor/logd.te | 1 - sepolicy/vendor/mediacodec.te | 4 - sepolicy/vendor/mediadrmserver.te | 1 - sepolicy/vendor/mediaextractor.te | 1 - sepolicy/vendor/mediametrics.te | 1 - sepolicy/vendor/mediaserver.te | 5 - sepolicy/vendor/mediaswcodec.te | 2 - sepolicy/vendor/mlog_qmi_service.te | 15 --- sepolicy/vendor/msm_irqbalance.te | 14 --- sepolicy/vendor/netd.te | 2 - sepolicy/vendor/netmgrd.te | 4 - sepolicy/vendor/per_mgr.te | 7 -- sepolicy/vendor/per_proxy.te | 14 --- sepolicy/vendor/perfd.te | 3 - sepolicy/vendor/platform_app.te | 1 - sepolicy/vendor/ppd.te | 23 ---- sepolicy/vendor/priv_app.te | 7 -- sepolicy/vendor/property.te | 4 - sepolicy/vendor/qcamerasvr.te | 23 ---- sepolicy/vendor/qmuxd.te | 3 - sepolicy/vendor/radio.te | 2 - sepolicy/vendor/recovery_persist.te | 1 - sepolicy/vendor/rild.te | 25 ---- sepolicy/vendor/rmt_storage.te | 1 - sepolicy/vendor/sct_service.te | 15 --- sepolicy/vendor/sdcardd.te | 1 - sepolicy/vendor/secd.te | 22 ---- sepolicy/vendor/sensors.te | 7 -- sepolicy/vendor/service.te | 1 - sepolicy/vendor/servicemanager.te | 10 -- sepolicy/vendor/shell.te | 109 ------------------ sepolicy/vendor/statsd.te | 1 - sepolicy/vendor/surfaceflinger.te | 4 - sepolicy/vendor/system_app.te | 12 -- sepolicy/vendor/system_server.te | 16 --- sepolicy/vendor/ta_qmi_service.te | 24 ---- sepolicy/vendor/tad.te | 14 --- sepolicy/vendor/taimport.te | 15 --- sepolicy/vendor/tee.te | 28 ----- sepolicy/vendor/thermal-engine.te | 9 -- sepolicy/vendor/timekeep.te | 25 ---- sepolicy/vendor/tombstoned.te | 1 - sepolicy/vendor/toolbox.te | 6 - sepolicy/vendor/tzdatacheck.te | 1 - sepolicy/vendor/ueventd.te | 9 -- sepolicy/vendor/updatemiscta.te | 14 --- sepolicy/vendor/usbd.te | 1 - sepolicy/vendor/vdc.te | 1 - sepolicy/vendor/vendor_init.te | 1 - sepolicy/vendor/vndservicemanager.te | 1 - sepolicy/vendor/vold.te | 5 - sepolicy/vendor/vold_prepare_subdirs.te | 1 - sepolicy/vendor/wificond.te | 1 - sepolicy/vendor/zygote.te | 3 - 106 files changed, 1 insertion(+), 829 deletions(-) delete mode 100644 sepolicy/vendor/adbd.te delete mode 100644 sepolicy/vendor/adsprpcd.te delete mode 100644 sepolicy/vendor/apexd.te delete mode 100644 sepolicy/vendor/ashmemd.te delete mode 100644 sepolicy/vendor/audioserver.te delete mode 100644 sepolicy/vendor/bootanim.te delete mode 100644 sepolicy/vendor/bootstat.te delete mode 100644 sepolicy/vendor/cameraserver.te delete mode 100644 sepolicy/vendor/charger.te delete mode 100644 sepolicy/vendor/clatd.te delete mode 100644 sepolicy/vendor/device.te delete mode 100644 sepolicy/vendor/drmserver.te delete mode 100644 sepolicy/vendor/file.te delete mode 100644 sepolicy/vendor/flags_health_check.te delete mode 100644 sepolicy/vendor/fsck.te delete mode 100644 sepolicy/vendor/fsck_untrusted.te delete mode 100644 sepolicy/vendor/gatekeeperd.te delete mode 100644 sepolicy/vendor/gpuservice.te delete mode 100644 sepolicy/vendor/hal_audio_default.te delete mode 100644 sepolicy/vendor/hal_bluetooth_default.te delete mode 100644 sepolicy/vendor/hal_camera_default.te delete mode 100644 sepolicy/vendor/hal_cas_default.te delete mode 100644 sepolicy/vendor/hal_configstore_default.te delete mode 100644 sepolicy/vendor/hal_drm_default.te delete mode 100644 sepolicy/vendor/hal_fingerprint_default.te delete mode 100644 sepolicy/vendor/hal_graphics_allocator_default.te delete mode 100644 sepolicy/vendor/hal_keymaster_qti.te delete mode 100644 sepolicy/vendor/hal_light_default.te delete mode 100644 sepolicy/vendor/hal_lineage_livedisplay_qti.te delete mode 100644 sepolicy/vendor/hal_lineage_livedisplay_sysfs.te delete mode 100644 sepolicy/vendor/hal_lineage_trust_default.te delete mode 100644 sepolicy/vendor/hal_memtrack_default.te delete mode 100644 sepolicy/vendor/hal_power_default.te delete mode 100644 sepolicy/vendor/hal_ril_default.te delete mode 100644 sepolicy/vendor/hal_ril_wrapper.te delete mode 100644 sepolicy/vendor/hal_usb_default.te delete mode 100644 sepolicy/vendor/hal_wifi_default.te delete mode 100644 sepolicy/vendor/hal_wifi_supplicant_default.te delete mode 100644 sepolicy/vendor/healthd.te delete mode 100644 sepolicy/vendor/hwservicemanager.te delete mode 100644 sepolicy/vendor/iddd.te delete mode 100644 sepolicy/vendor/idmap.te delete mode 100644 sepolicy/vendor/incidentd.te delete mode 100644 sepolicy/vendor/init-power-sh.te delete mode 100644 sepolicy/vendor/init.te delete mode 100644 sepolicy/vendor/installd.te delete mode 100644 sepolicy/vendor/irsc_util.te delete mode 100644 sepolicy/vendor/kernel.te delete mode 100644 sepolicy/vendor/keystore.te delete mode 100644 sepolicy/vendor/lmkd.te delete mode 100644 sepolicy/vendor/loc_launcher.te delete mode 100644 sepolicy/vendor/logd.te delete mode 100644 sepolicy/vendor/mediacodec.te delete mode 100644 sepolicy/vendor/mediadrmserver.te delete mode 100644 sepolicy/vendor/mediaextractor.te delete mode 100644 sepolicy/vendor/mediametrics.te delete mode 100644 sepolicy/vendor/mediaserver.te delete mode 100644 sepolicy/vendor/mediaswcodec.te delete mode 100644 sepolicy/vendor/mlog_qmi_service.te delete mode 100644 sepolicy/vendor/msm_irqbalance.te delete mode 100644 sepolicy/vendor/netd.te delete mode 100644 sepolicy/vendor/netmgrd.te delete mode 100644 sepolicy/vendor/per_mgr.te delete mode 100644 sepolicy/vendor/per_proxy.te delete mode 100644 sepolicy/vendor/perfd.te delete mode 100644 sepolicy/vendor/platform_app.te delete mode 100644 sepolicy/vendor/ppd.te delete mode 100644 sepolicy/vendor/priv_app.te delete mode 100644 sepolicy/vendor/property.te delete mode 100644 sepolicy/vendor/qcamerasvr.te delete mode 100644 sepolicy/vendor/qmuxd.te delete mode 100644 sepolicy/vendor/radio.te delete mode 100644 sepolicy/vendor/recovery_persist.te delete mode 100644 sepolicy/vendor/rild.te delete mode 100644 sepolicy/vendor/rmt_storage.te delete mode 100644 sepolicy/vendor/sct_service.te delete mode 100644 sepolicy/vendor/sdcardd.te delete mode 100644 sepolicy/vendor/secd.te delete mode 100644 sepolicy/vendor/sensors.te delete mode 100644 sepolicy/vendor/service.te delete mode 100644 sepolicy/vendor/servicemanager.te delete mode 100644 sepolicy/vendor/shell.te delete mode 100644 sepolicy/vendor/statsd.te delete mode 100644 sepolicy/vendor/surfaceflinger.te delete mode 100644 sepolicy/vendor/system_app.te delete mode 100644 sepolicy/vendor/system_server.te delete mode 100644 sepolicy/vendor/ta_qmi_service.te delete mode 100644 sepolicy/vendor/tad.te delete mode 100644 sepolicy/vendor/taimport.te delete mode 100644 sepolicy/vendor/tee.te delete mode 100644 sepolicy/vendor/thermal-engine.te delete mode 100644 sepolicy/vendor/timekeep.te delete mode 100644 sepolicy/vendor/tombstoned.te delete mode 100644 sepolicy/vendor/toolbox.te delete mode 100644 sepolicy/vendor/tzdatacheck.te delete mode 100644 sepolicy/vendor/ueventd.te delete mode 100644 sepolicy/vendor/updatemiscta.te delete mode 100644 sepolicy/vendor/usbd.te delete mode 100644 sepolicy/vendor/vdc.te delete mode 100644 sepolicy/vendor/vendor_init.te delete mode 100644 sepolicy/vendor/vndservicemanager.te delete mode 100644 sepolicy/vendor/vold.te delete mode 100644 sepolicy/vendor/vold_prepare_subdirs.te delete mode 100644 sepolicy/vendor/wificond.te delete mode 100644 sepolicy/vendor/zygote.te diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 71a331c..dc93e1b 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -51,6 +51,7 @@ BUILD_BROKEN_USES_BUILD_COPY_HEADERS := true # Boot image/kernel BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-5 loop.max_part=7 dwc3_msm.hvdcp_max_current=1500 dwc3_msm.prop_chg_detect=Y coherent_pool=2M swiotlb=2048 +BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive BOARD_KERNEL_IMAGE_NAME := Image.gz-dtb BOARD_KERNEL_PAGESIZE := 4096 BOARD_KERNEL_BASE := 0x00000000 diff --git a/sepolicy/vendor/adbd.te b/sepolicy/vendor/adbd.te deleted file mode 100644 index e78f756..0000000 --- a/sepolicy/vendor/adbd.te +++ /dev/null @@ -1 +0,0 @@ -allow adbd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/adsprpcd.te b/sepolicy/vendor/adsprpcd.te deleted file mode 100644 index 365465b..0000000 --- a/sepolicy/vendor/adsprpcd.te +++ /dev/null @@ -1 +0,0 @@ -allow adsprpcd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/apexd.te b/sepolicy/vendor/apexd.te deleted file mode 100644 index a1e4b88..0000000 --- a/sepolicy/vendor/apexd.te +++ /dev/null @@ -1 +0,0 @@ -allow apexd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/ashmemd.te b/sepolicy/vendor/ashmemd.te deleted file mode 100644 index 7e0f69d..0000000 --- a/sepolicy/vendor/ashmemd.te +++ /dev/null @@ -1 +0,0 @@ -allow ashmemd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/audioserver.te b/sepolicy/vendor/audioserver.te deleted file mode 100644 index e2c2a8a..0000000 --- a/sepolicy/vendor/audioserver.te +++ /dev/null @@ -1,4 +0,0 @@ -allow audioserver tad_socket:sock_file write; -allow audioserver perfd:unix_stream_socket connectto; -allow audioserver socket_device:sock_file write; -allow audioserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/bootanim.te b/sepolicy/vendor/bootanim.te deleted file mode 100644 index 85e51f3..0000000 --- a/sepolicy/vendor/bootanim.te +++ /dev/null @@ -1 +0,0 @@ -allow bootanim secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/bootstat.te b/sepolicy/vendor/bootstat.te deleted file mode 100644 index 0198e07..0000000 --- a/sepolicy/vendor/bootstat.te +++ /dev/null @@ -1 +0,0 @@ -allow bootstat secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/cameraserver.te b/sepolicy/vendor/cameraserver.te deleted file mode 100644 index e64396d..0000000 --- a/sepolicy/vendor/cameraserver.te +++ /dev/null @@ -1,18 +0,0 @@ -allow cameraserver camera_data_file:sock_file write; -allow cameraserver gpu_device:chr_file rw_file_perms; -allow cameraserver perfd:unix_stream_socket connectto; -allow cameraserver rootfs:lnk_file getattr; -allow cameraserver sysfs_camera_torch:file rw_file_perms; -allow cameraserver sysfs_camera_torch:dir search; -allow cameraserver sysfs_camera_torch:lnk_file read; -allow cameraserver ta_data_file:dir search; -allow cameraserver secd_socket:sock_file write; -allow cameraserver hal_configstore_ISurfaceFlingerConfigs:hwservice_manager find; -allow cameraserver hal_configstore_default:binder call; -allow cameraserver socket_device:sock_file write; -allow cameraserver sysfs_graphics:file { getattr open read }; -allow cameraserver init:unix_dgram_socket sendto; -allow cameraserver qcamerasvr:unix_dgram_socket sendto; -allow cameraserver qcamerasvr:unix_stream_socket connectto; -allow cameraserver secd:unix_stream_socket connectto; -allow cameraserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/charger.te b/sepolicy/vendor/charger.te deleted file mode 100644 index 76c42b1..0000000 --- a/sepolicy/vendor/charger.te +++ /dev/null @@ -1,5 +0,0 @@ -allow charger self:capability { dac_override dac_read_search }; -allow charger sysfs:file { open read getattr }; -allow charger sysfs_usb_supply:file { open read getattr }; -allow charger sysfs_battery_supply:file { open read getattr }; -allow charger device:dir { open read }; diff --git a/sepolicy/vendor/clatd.te b/sepolicy/vendor/clatd.te deleted file mode 100644 index 03c2def..0000000 --- a/sepolicy/vendor/clatd.te +++ /dev/null @@ -1 +0,0 @@ -allow clatd system_file:file lock; diff --git a/sepolicy/vendor/device.te b/sepolicy/vendor/device.te deleted file mode 100644 index d5da1bc..0000000 --- a/sepolicy/vendor/device.te +++ /dev/null @@ -1,3 +0,0 @@ -type trim_area_partition_device, dev_type; -type diag_partition_device, dev_type; -type subsys_modem_device, dev_type; diff --git a/sepolicy/vendor/drmserver.te b/sepolicy/vendor/drmserver.te deleted file mode 100644 index a00eeb3..0000000 --- a/sepolicy/vendor/drmserver.te +++ /dev/null @@ -1 +0,0 @@ -allow drmserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/file.te b/sepolicy/vendor/file.te deleted file mode 100644 index 7365abe..0000000 --- a/sepolicy/vendor/file.te +++ /dev/null @@ -1,23 +0,0 @@ -# TAD -type tad_socket, file_type; -type ta_data_file, file_type; -type secd_socket, file_type; -type secd_data_file, file_type; - -# Timekeep -type timekeep_data_file, file_type, data_file_type; -type sysfs_timekeep, fs_type, sysfs_type; - -# Macaddr -type sysfs_addrsetup, fs_type, sysfs_type; -type proc_kernel_sched, fs_type; -type sysfs_camera_torch, sysfs_type, file_type; -type sysfs_performance, sysfs_type, fs_type; -type sysfs_msm_subsys, sysfs_type, fs_type; - -# Fingerprint -type fpc_data_file, file_type; - -# Camera -type sysfs_camera, sysfs_type, fs_type; - diff --git a/sepolicy/vendor/flags_health_check.te b/sepolicy/vendor/flags_health_check.te deleted file mode 100644 index d3fe883..0000000 --- a/sepolicy/vendor/flags_health_check.te +++ /dev/null @@ -1,25 +0,0 @@ -allow flags_health_check alarm_boot_prop:file { getattr open }; -allow flags_health_check alarm_handled_prop:file { getattr open }; -allow flags_health_check crash_prop:file { getattr open }; -allow flags_health_check ctl_LKCore_prop:file { getattr open }; -allow flags_health_check ctl_adbd_prop:file { getattr open }; -allow flags_health_check ctl_interface_start_prop:file { getattr open }; -allow flags_health_check ctl_interface_stop_prop:file open; -allow flags_health_check ctl_vendor_wigigsvc_prop:file open; -allow flags_health_check qemu_gles_prop:file getattr; -allow flags_health_check qti_prop:file open; -allow flags_health_check scr_enabled_prop:file getattr; -allow flags_health_check sdm_idle_time_prop:file { getattr open }; -allow flags_health_check sensors_prop:file { getattr open }; -allow flags_health_check serialno_prop:file { getattr open }; -allow flags_health_check spcomlib_prop:file { getattr open }; -allow flags_health_check sys_usb_configfs_prop:file { getattr open }; -allow flags_health_check sys_usb_controller_prop:file { getattr open }; -allow flags_health_check sys_usb_tethering_prop:file { getattr open }; -allow flags_health_check system_boot_reason_prop:file { getattr open }; -allow flags_health_check system_lmk_prop:file { getattr open }; -allow flags_health_check test_boot_reason_prop:file { getattr open }; -allow flags_health_check alarm_instance_prop:file { getattr open }; -allow flags_health_check apexd_prop:file { getattr open }; -allow flags_health_check bg_boot_complete_prop:file { getattr open }; -allow flags_health_check secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/fsck.te b/sepolicy/vendor/fsck.te deleted file mode 100644 index ca3bdf2..0000000 --- a/sepolicy/vendor/fsck.te +++ /dev/null @@ -1,5 +0,0 @@ -allow fsck diag_partition_device:blk_file { read write }; -allow fsck self:capability { dac_override dac_read_search }; -allow fsck secd_exec:file { getattr read }; -allow fsck tmpfs:blk_file getattr; -allow fsck persist_file:dir getattr; diff --git a/sepolicy/vendor/fsck_untrusted.te b/sepolicy/vendor/fsck_untrusted.te deleted file mode 100644 index 06445b3..0000000 --- a/sepolicy/vendor/fsck_untrusted.te +++ /dev/null @@ -1 +0,0 @@ -allow fsck_untrusted vold_device:blk_file ioctl; diff --git a/sepolicy/vendor/gatekeeperd.te b/sepolicy/vendor/gatekeeperd.te deleted file mode 100644 index 0c9feaa..0000000 --- a/sepolicy/vendor/gatekeeperd.te +++ /dev/null @@ -1,2 +0,0 @@ -allow gatekeeperd tee_prop:file { getattr open read }; -allow gatekeeperd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/gpuservice.te b/sepolicy/vendor/gpuservice.te deleted file mode 100644 index 72bb0a8..0000000 --- a/sepolicy/vendor/gpuservice.te +++ /dev/null @@ -1 +0,0 @@ -allow gpuservice secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_audio_default.te b/sepolicy/vendor/hal_audio_default.te deleted file mode 100644 index 0b91688..0000000 --- a/sepolicy/vendor/hal_audio_default.te +++ /dev/null @@ -1,3 +0,0 @@ -allow hal_audio_default tad_socket:sock_file { create_file_perms write }; -allow hal_audio_default secd_exec:file { getattr read }; -allow hal_audio_default tad:unix_stream_socket connectto; diff --git a/sepolicy/vendor/hal_bluetooth_default.te b/sepolicy/vendor/hal_bluetooth_default.te deleted file mode 100644 index 49bf694..0000000 --- a/sepolicy/vendor/hal_bluetooth_default.te +++ /dev/null @@ -1,7 +0,0 @@ -allow hal_bluetooth_default firmware_file:file { open read }; -allow hal_bluetooth_default sysfs:file write; -allow hal_bluetooth_default system_data_file:file { open read }; -allow hal_bluetooth_default firmware_file:dir search; -allow hal_bluetooth_default ta_data_file:dir search; -allow hal_bluetooth_default ta_data_file:file { open read }; -allow hal_bluetooth_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_camera_default.te b/sepolicy/vendor/hal_camera_default.te deleted file mode 100644 index d487c22..0000000 --- a/sepolicy/vendor/hal_camera_default.te +++ /dev/null @@ -1,4 +0,0 @@ -allow hal_camera_default camera_data_file:sock_file write; -allow hal_camera_default hal_configstore_ISurfaceFlingerConfigs:hwservice_manager find; -allow hal_camera_default hal_configstore_default:binder call; -allow hal_camera_default socket_device:sock_file write; diff --git a/sepolicy/vendor/hal_cas_default.te b/sepolicy/vendor/hal_cas_default.te deleted file mode 100644 index d9855aa..0000000 --- a/sepolicy/vendor/hal_cas_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_cas_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_configstore_default.te b/sepolicy/vendor/hal_configstore_default.te deleted file mode 100644 index 08a5161..0000000 --- a/sepolicy/vendor/hal_configstore_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_configstore_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_drm_default.te b/sepolicy/vendor/hal_drm_default.te deleted file mode 100644 index 9e8cbf8..0000000 --- a/sepolicy/vendor/hal_drm_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_drm_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_fingerprint_default.te b/sepolicy/vendor/hal_fingerprint_default.te deleted file mode 100644 index 10ecae5..0000000 --- a/sepolicy/vendor/hal_fingerprint_default.te +++ /dev/null @@ -1,18 +0,0 @@ -allow hal_fingerprint_default tee_device:chr_file ioctl; -allow hal_fingerprint_default firmware_file:dir search; -allow hal_fingerprint_default sysfs:file write; -allow hal_fingerprint_default tee_device:chr_file { open read write }; -allow hal_fingerprint_default firmware_file:file { getattr open read }; -allow hal_fingerprint_default input_device:chr_file { ioctl open read }; -allow hal_fingerprint_default input_device:dir { open read }; -allow hal_fingerprint_default system_data_file:dir { add_name remove_name write }; -allow hal_fingerprint_default system_data_file:sock_file { create unlink }; -allow hal_fingerprint_default diag_data_file:sock_file write; -allow hal_fingerprint_default fpc_data_file:dir { add_name remove_name write }; -allow hal_fingerprint_default fpc_data_file:sock_file { create unlink }; -allow hal_fingerprint_default init:unix_dgram_socket sendto; -allow hal_fingerprint_default iddd:unix_dgram_socket sendto; -allow hal_fingerprint_default firmware_file:lnk_file read; -allow hal_fingerprint_default fpc_data_file:dir search; -allow hal_fingerprint_default input_device:dir search; -allow hal_fingerprint_default diag_data_file:dir search; diff --git a/sepolicy/vendor/hal_graphics_allocator_default.te b/sepolicy/vendor/hal_graphics_allocator_default.te deleted file mode 100644 index 747f5f9..0000000 --- a/sepolicy/vendor/hal_graphics_allocator_default.te +++ /dev/null @@ -1,2 +0,0 @@ -allow hal_graphics_allocator_default sysfs_graphics:file { getattr open read }; -allow hal_graphics_allocator_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_keymaster_qti.te b/sepolicy/vendor/hal_keymaster_qti.te deleted file mode 100644 index bdb3e7e..0000000 --- a/sepolicy/vendor/hal_keymaster_qti.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_keymaster_qti secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_light_default.te b/sepolicy/vendor/hal_light_default.te deleted file mode 100644 index bd66cd3..0000000 --- a/sepolicy/vendor/hal_light_default.te +++ /dev/null @@ -1,2 +0,0 @@ -allow hal_light_default secd_exec:file { getattr read }; -allow hal_light_default sysfs:file { open read write }; diff --git a/sepolicy/vendor/hal_lineage_livedisplay_qti.te b/sepolicy/vendor/hal_lineage_livedisplay_qti.te deleted file mode 100644 index 3501957..0000000 --- a/sepolicy/vendor/hal_lineage_livedisplay_qti.te +++ /dev/null @@ -1,2 +0,0 @@ -allow hal_lineage_livedisplay_qti ppd:unix_stream_socket connectto; -allow hal_lineage_livedisplay_qti secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_lineage_livedisplay_sysfs.te b/sepolicy/vendor/hal_lineage_livedisplay_sysfs.te deleted file mode 100644 index 8ffb130..0000000 --- a/sepolicy/vendor/hal_lineage_livedisplay_sysfs.te +++ /dev/null @@ -1,2 +0,0 @@ -allow hal_lineage_livedisplay_sysfs ppd:unix_stream_socket connectto; -allow hal_lineage_livedisplay_sysfs secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_lineage_trust_default.te b/sepolicy/vendor/hal_lineage_trust_default.te deleted file mode 100644 index 072ed4e..0000000 --- a/sepolicy/vendor/hal_lineage_trust_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_lineage_trust_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_memtrack_default.te b/sepolicy/vendor/hal_memtrack_default.te deleted file mode 100644 index 39f4066..0000000 --- a/sepolicy/vendor/hal_memtrack_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_memtrack_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_power_default.te b/sepolicy/vendor/hal_power_default.te deleted file mode 100644 index ff818ec..0000000 --- a/sepolicy/vendor/hal_power_default.te +++ /dev/null @@ -1,2 +0,0 @@ -allow hal_power_default sysfs:file { open write }; -allow hal_power_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_ril_default.te b/sepolicy/vendor/hal_ril_default.te deleted file mode 100644 index 1614904..0000000 --- a/sepolicy/vendor/hal_ril_default.te +++ /dev/null @@ -1,6 +0,0 @@ -type hal_ril_default, domain; -hwbinder_use(hal_ril_default) -vndbinder_use(hal_ril_default) - -type hal_ril_default_exec, exec_type, vendor_file_type, file_type; -init_daemon_domain(hal_ril_default) diff --git a/sepolicy/vendor/hal_ril_wrapper.te b/sepolicy/vendor/hal_ril_wrapper.te deleted file mode 100644 index 9c6274d..0000000 --- a/sepolicy/vendor/hal_ril_wrapper.te +++ /dev/null @@ -1,6 +0,0 @@ -type hal_ril_wrapper, domain; -hwbinder_use(hal_ril_wrapper) -vndbinder_use(hal_ril_wrapper) - -type hal_ril_wrapper_exec, exec_type, vendor_file_type, file_type; -init_daemon_domain(hal_ril_wrapper) diff --git a/sepolicy/vendor/hal_usb_default.te b/sepolicy/vendor/hal_usb_default.te deleted file mode 100644 index a94b4ef..0000000 --- a/sepolicy/vendor/hal_usb_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_usb_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_wifi_default.te b/sepolicy/vendor/hal_wifi_default.te deleted file mode 100644 index 11073f7..0000000 --- a/sepolicy/vendor/hal_wifi_default.te +++ /dev/null @@ -1,7 +0,0 @@ -allow hal_wifi_default firmware_file:file { open read }; -allow hal_wifi_default sysfs:file write; -allow hal_wifi_default system_data_file:file { open read }; -allow hal_wifi_default ta_data_file:dir search; -allow hal_wifi_default ta_data_file:file { open read }; -allow hal_wifi_default firmware_file:dir search; -allow hal_wifi_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_wifi_supplicant_default.te b/sepolicy/vendor/hal_wifi_supplicant_default.te deleted file mode 100644 index d4683de..0000000 --- a/sepolicy/vendor/hal_wifi_supplicant_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_wifi_supplicant_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/healthd.te b/sepolicy/vendor/healthd.te deleted file mode 100644 index 73e96ff..0000000 --- a/sepolicy/vendor/healthd.te +++ /dev/null @@ -1,2 +0,0 @@ -allow healthd sysfs:file { getattr open read }; -allow healthd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hwservicemanager.te b/sepolicy/vendor/hwservicemanager.te deleted file mode 100644 index c211c11..0000000 --- a/sepolicy/vendor/hwservicemanager.te +++ /dev/null @@ -1,4 +0,0 @@ -allow hwservicemanager init:dir search; -allow hwservicemanager init:file { open read }; -allow hwservicemanager init:process getattr; -allow hwservicemanager secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/iddd.te b/sepolicy/vendor/iddd.te deleted file mode 100644 index edf8959..0000000 --- a/sepolicy/vendor/iddd.te +++ /dev/null @@ -1,20 +0,0 @@ -# iddd service -type iddd, domain; -type iddd_exec, exec_type, file_type; - -# Started by init -init_daemon_domain(iddd) - -allow iddd diag_data_file:dir { add_name search write }; -allow iddd diag_data_file:file { create lock open read write }; -allow iddd diag_data_file:dir { getattr open read remove_name }; -allow iddd diag_data_file:file { getattr rename unlink }; -allow iddd diag_data_file:sock_file { create setattr }; -allow iddd socket_device:sock_file write; -allow iddd diag_data_file:sock_file unlink; -allow iddd tad:unix_stream_socket connectto; -allow iddd tad_socket:sock_file write; -allow iddd diag_data_file:dir { create rmdir }; -allow iddd diag_data_file:sock_file write; -allow iddd firmware_file:dir search; -allow iddd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/idmap.te b/sepolicy/vendor/idmap.te deleted file mode 100644 index 8c5d8a5..0000000 --- a/sepolicy/vendor/idmap.te +++ /dev/null @@ -1 +0,0 @@ -allow idmap secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/incidentd.te b/sepolicy/vendor/incidentd.te deleted file mode 100644 index 45eadf1..0000000 --- a/sepolicy/vendor/incidentd.te +++ /dev/null @@ -1 +0,0 @@ -allow incidentd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/init-power-sh.te b/sepolicy/vendor/init-power-sh.te deleted file mode 100644 index b3f1a59..0000000 --- a/sepolicy/vendor/init-power-sh.te +++ /dev/null @@ -1,38 +0,0 @@ -type init-power-sh, domain; -type init-power-sh_exec, exec_type, file_type; - -# Started by init -init_daemon_domain(init-power-sh) - -allow init-power-sh shell_exec:file r_file_perms; -allow init-power-sh sysfs_devices_system_cpu:file w_file_perms; -allow init-power-sh sysfs_performance:dir r_dir_perms; -allow init-power-sh sysfs_performance:file w_file_perms; -allow init-power-sh sysfs_thermal:dir r_dir_perms; -allow init-power-sh sysfs_thermal:file rw_file_perms; -allow init-power-sh proc_kernel_sched:file w_file_perms; -allow init-power-sh sysfs_rqstats:dir read; -allow init-power-sh proc:file write; -allow init-power-sh sysfs_rqstats:dir {r_dir_perms open}; -allow init-power-sh sysfs_rqstats:file r_file_perms; - -# allow labeling of interactive /sys files created post-initial restorecon -allow init-power-sh sysfs:{ dir file lnk_file } relabelfrom; -allow init-power-sh sysfs_devices_system_cpu:{ dir file lnk_file } relabelto; - -# allow writes to sysfs files that have not yet been labeled -allow init-power-sh sysfs:file rw_file_perms; -allow init-power-sh sysfs_usb:file w_file_perms; - -# execute toybox/toolbox -allow init-power-sh toolbox_exec:file rx_file_perms; - -allow init-power-sh sysfs:dir { open read }; -allow init-power-sh sysfs_kgsl:file { open write }; -allow init-power-sh file_contexts_file:file { getattr open read }; -allow init-power-sh sysfs_msm_perf:dir search; -allow init-power-sh sysfs_msm_perf:file { open write }; -allow init-power-sh proc:file open; -allow init-power-sh sysfs_cpu_boost:dir search; -allow init-power-sh sysfs_cpu_boost:file { open write }; -allow init-power-sh secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/init.te b/sepolicy/vendor/init.te deleted file mode 100644 index 7bbcfd6..0000000 --- a/sepolicy/vendor/init.te +++ /dev/null @@ -1,50 +0,0 @@ -#For sdcard -allow init tmpfs:lnk_file create_file_perms; -allow init proc_kernel_sched:file write; -allow init proc_dirty_ratio:file write; -allow init persist_file:dir mounton; -allow init debugfs:file w_file_perms; - -#TAD -allow init tad_socket:sock_file create; - -#Torch -allow init sysfs_camera_torch:lnk_file read; - -allow init trim_area_partition_device:blk_file { write setattr }; -allow init block_device:blk_file setattr; -allow init socket_device:sock_file { create setattr }; -allow init socket_device:sock_file unlink; -allow init cameraserver:fd use; -allow init diag_data_file:file { lock rename }; -allow init diag_data_file:sock_file write; -allow init ion_device:chr_file ioctl; -allow init property_socket:sock_file write; -allow init rpmb_device:blk_file write; -allow init self:capability2 block_suspend; -allow init self:socket { read write }; -allow init ssd_device:blk_file write; -allow init tad_socket:sock_file write; -allow init tee_device:chr_file { ioctl write }; -allow init video_device:chr_file { ioctl write }; -allow init secd_data_file:file { ioctl lock }; -allow init servicemanager:binder call; -allow init vfat:file { getattr open read }; -allow init proc_interrupts:file getattr; -allow init diag_data_file:dir mounton; -allow init hal_drm_hwservice:hwservice_manager add; -allow init hal_fingerprint_hwservice:hwservice_manager add; -allow init hal_light_hwservice:hwservice_manager add; -allow init hidl_base_hwservice:hwservice_manager add; -allow init hwservicemanager:binder { call transfer }; -allow init iddd:unix_dgram_socket sendto; -allow init ion_device:chr_file { open read }; -allow init proc:file write; -allow init sysfs:file { open read setattr write }; -allow init sysfs_battery_supply:file { open read }; -allow init sysfs_graphics:file { open read write }; -allow init tee_device:chr_file { open read }; -allow init vendor_file:file execute_no_trans; -allow init vndbinder_device:chr_file { ioctl open read write }; -allow init fingerprintd_data_file:file rename; -allow init system_server:binder call; diff --git a/sepolicy/vendor/installd.te b/sepolicy/vendor/installd.te deleted file mode 100644 index 974c9d3..0000000 --- a/sepolicy/vendor/installd.te +++ /dev/null @@ -1,2 +0,0 @@ -allow installd device:file { open write }; -allow installd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/irsc_util.te b/sepolicy/vendor/irsc_util.te deleted file mode 100644 index 48280e0..0000000 --- a/sepolicy/vendor/irsc_util.te +++ /dev/null @@ -1 +0,0 @@ -allow irsc_util secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/kernel.te b/sepolicy/vendor/kernel.te deleted file mode 100644 index e650c4c..0000000 --- a/sepolicy/vendor/kernel.te +++ /dev/null @@ -1,6 +0,0 @@ -allow kernel device:dir create_dir_perms; -allow kernel tmpfs:file create_file_perms; -allow kernel tmpfs:dir create_dir_perms; -allow kernel block_device:blk_file rw_file_perms; -allow kernel touchfusion_exec:file relabelto; -allow kernel self:socket create; diff --git a/sepolicy/vendor/keystore.te b/sepolicy/vendor/keystore.te deleted file mode 100644 index 6455c97..0000000 --- a/sepolicy/vendor/keystore.te +++ /dev/null @@ -1,2 +0,0 @@ -allow keystore tee_prop:file { getattr open read }; -allow keystore secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/lmkd.te b/sepolicy/vendor/lmkd.te deleted file mode 100644 index 1799135..0000000 --- a/sepolicy/vendor/lmkd.te +++ /dev/null @@ -1 +0,0 @@ -allow lmkd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/loc_launcher.te b/sepolicy/vendor/loc_launcher.te deleted file mode 100644 index c520f4e..0000000 --- a/sepolicy/vendor/loc_launcher.te +++ /dev/null @@ -1,15 +0,0 @@ -# loc_launcher service -type loc_launcher, domain; -type loc_launcher_exec, exec_type, file_type; - -init_daemon_domain(loc_launcher) - -allow loc_launcher self:capability setuid; -allow loc_launcher system_data_file:dir { add_name remove_name write }; -allow loc_launcher system_data_file:sock_file { create setattr unlink }; -allow loc_launcher location_data_file:dir { add_name remove_name write }; -allow loc_launcher location_data_file:sock_file { create setattr }; -allow loc_launcher location_socket:sock_file unlink; -allow loc_launcher location_data_file:sock_file unlink; -allow loc_launcher location_data_file:dir search; -allow loc_launcher secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/logd.te b/sepolicy/vendor/logd.te deleted file mode 100644 index 93ec406..0000000 --- a/sepolicy/vendor/logd.te +++ /dev/null @@ -1 +0,0 @@ -allow logd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediacodec.te b/sepolicy/vendor/mediacodec.te deleted file mode 100644 index 0ba5bfe..0000000 --- a/sepolicy/vendor/mediacodec.te +++ /dev/null @@ -1,4 +0,0 @@ -allow mediacodec mpctl_socket:dir search; -allow mediacodec perfd:unix_stream_socket connectto; -allow mediacodec socket_device:sock_file write; -allow mediacodec secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediadrmserver.te b/sepolicy/vendor/mediadrmserver.te deleted file mode 100644 index 316f94f..0000000 --- a/sepolicy/vendor/mediadrmserver.te +++ /dev/null @@ -1 +0,0 @@ -allow mediadrmserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediaextractor.te b/sepolicy/vendor/mediaextractor.te deleted file mode 100644 index 71f9a54..0000000 --- a/sepolicy/vendor/mediaextractor.te +++ /dev/null @@ -1 +0,0 @@ -allow mediaextractor secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediametrics.te b/sepolicy/vendor/mediametrics.te deleted file mode 100644 index 2dca25e..0000000 --- a/sepolicy/vendor/mediametrics.te +++ /dev/null @@ -1 +0,0 @@ -allow mediametrics secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediaserver.te b/sepolicy/vendor/mediaserver.te deleted file mode 100644 index f5ee855..0000000 --- a/sepolicy/vendor/mediaserver.te +++ /dev/null @@ -1,5 +0,0 @@ -allow mediaserver hal_configstore_ISurfaceFlingerConfigs:hwservice_manager find; -allow mediaserver sensorservice_service:service_manager find; -allow mediaserver sysfs_graphics:file { getattr open read }; -allow mediaserver system_server:unix_stream_socket read; -allow mediaserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediaswcodec.te b/sepolicy/vendor/mediaswcodec.te deleted file mode 100644 index c338257..0000000 --- a/sepolicy/vendor/mediaswcodec.te +++ /dev/null @@ -1,2 +0,0 @@ -allow mediaswcodec servicemanager:binder call; -allow mediaswcodec secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mlog_qmi_service.te b/sepolicy/vendor/mlog_qmi_service.te deleted file mode 100644 index 3466981..0000000 --- a/sepolicy/vendor/mlog_qmi_service.te +++ /dev/null @@ -1,15 +0,0 @@ -# mlog_qmi_service service -type mlog_qmi_service, domain; -type mlog_qmi_service_exec, exec_type, vendor_file_type, file_type; - -# Started by init -init_daemon_domain(mlog_qmi_service) - -# Allow mlog_qmi_service to create self:socket -allow mlog_qmi_service self:socket create_socket_perms; -allow mlog_qmi_service self:socket { create read write }; -allowxperm mlog_qmi_service self:socket ioctl msm_sock_ipc_ioctls; - -# Allow mlog_qmi_service to use net_raw capability -allow mlog_qmi_service self:capability net_raw; -allow mlog_qmi_service secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/msm_irqbalance.te b/sepolicy/vendor/msm_irqbalance.te deleted file mode 100644 index 542eae4..0000000 --- a/sepolicy/vendor/msm_irqbalance.te +++ /dev/null @@ -1,14 +0,0 @@ -# msm_irqbalance service -type msm_irqbalance, domain; -type msm_irqbalance_exec, exec_type, file_type; - -# Started by init -init_daemon_domain(msm_irqbalance) - -allow msm_irqbalance proc:file { getattr open read write }; -allow msm_irqbalance self:capability dac_override; -allow msm_irqbalance sysfs_devices_system_cpu:file write; -allow msm_irqbalance self:capability { setgid setuid }; -allow msm_irqbalance proc_interrupts:file { getattr open read }; -allow msm_irqbalance proc_stat:file { getattr open read }; -allow msm_irqbalance secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/netd.te b/sepolicy/vendor/netd.te deleted file mode 100644 index 7f82d40..0000000 --- a/sepolicy/vendor/netd.te +++ /dev/null @@ -1,2 +0,0 @@ -allow netd device:file { open write }; -allow netd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/netmgrd.te b/sepolicy/vendor/netmgrd.te deleted file mode 100644 index 54aa1fa..0000000 --- a/sepolicy/vendor/netmgrd.te +++ /dev/null @@ -1,4 +0,0 @@ -allow netmgrd self:capability dac_override; -allow netmgrd toolbox_exec:file { execute execute_no_trans getattr open read }; -allow netmgrd net_data_file:dir read; -allow netmgrd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/per_mgr.te b/sepolicy/vendor/per_mgr.te deleted file mode 100644 index 832dd28..0000000 --- a/sepolicy/vendor/per_mgr.te +++ /dev/null @@ -1,7 +0,0 @@ -allow per_mgr per_mgr_service:service_manager add; -allow per_mgr subsys_modem_device:chr_file r_file_perms; -allow per_mgr self:capability net_raw; -allow per_mgr self:socket create_socket_perms; -allowxperm per_mgr self:socket ioctl msm_sock_ipc_ioctls; -allow per_mgr per_proxy:binder call; -allow per_mgr secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/per_proxy.te b/sepolicy/vendor/per_proxy.te deleted file mode 100644 index 9be5831..0000000 --- a/sepolicy/vendor/per_proxy.te +++ /dev/null @@ -1,14 +0,0 @@ -# per_proxy service -type per_proxy, domain; -type per_proxy_exec, exec_type, file_type; - -# Started by init -init_daemon_domain(per_proxy) - -allow per_proxy default_android_service:service_manager find; -allow per_proxy per_mgr:binder call; -allow per_proxy servicemanager:binder call; -allow per_proxy sysfs:file { open read }; -allow per_proxy per_mgr:binder transfer; -allow per_proxy binder_per_mgr_service:service_manager find; -allow per_proxy secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/perfd.te b/sepolicy/vendor/perfd.te deleted file mode 100644 index 20670cb..0000000 --- a/sepolicy/vendor/perfd.te +++ /dev/null @@ -1,3 +0,0 @@ -allow perfd sysfs_memory:dir search; -allow perfd sysfs_memory:file { open read write }; -allow perfd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/platform_app.te b/sepolicy/vendor/platform_app.te deleted file mode 100644 index d7fa3af..0000000 --- a/sepolicy/vendor/platform_app.te +++ /dev/null @@ -1 +0,0 @@ -allow platform_app system_app_data_file:dir getattr; diff --git a/sepolicy/vendor/ppd.te b/sepolicy/vendor/ppd.te deleted file mode 100644 index eed967b..0000000 --- a/sepolicy/vendor/ppd.te +++ /dev/null @@ -1,23 +0,0 @@ -# ppd service -type ppd, domain; -type ppd_exec, exec_type, file_type; - -# Started by init -init_daemon_domain(ppd) - -allow ppd ion_device:chr_file write; -set_prop(ppd, display_prop); -allow ppd system_prop:property_service set; -allow ppd diag_device:chr_file { ioctl open read write }; -allow ppd graphics_device:chr_file { ioctl open read write }; -allow ppd ion_device:chr_file { open read }; -allow ppd persist_display_file:dir search; -allow ppd postprocessing_prop:file { getattr open read }; -allow ppd postprocessing_prop:property_service set; -allow ppd sysfs_graphics:dir search; -allow ppd sysfs_graphics:file { getattr open read write }; -allow ppd sysfs_leds:dir search; -allow ppd graphics_device:dir search; -allow ppd persist_file:dir search; -allow ppd display_vendor_data_file:dir search; -allow ppd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/priv_app.te b/sepolicy/vendor/priv_app.te deleted file mode 100644 index d87000e..0000000 --- a/sepolicy/vendor/priv_app.te +++ /dev/null @@ -1,7 +0,0 @@ -allow priv_app device:dir open; -allow priv_app proc_interrupts:file open; -allow priv_app alarm_boot_prop:file open; -allow priv_app alarm_instance_prop:file getattr; -allow priv_app proc:file open; -allow priv_app sysfs_android_usb:file open; -allow priv_app secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/property.te b/sepolicy/vendor/property.te deleted file mode 100644 index 1bd735a..0000000 --- a/sepolicy/vendor/property.te +++ /dev/null @@ -1,4 +0,0 @@ -type timekeep_prop, property_type; -type tee_prop, property_type; -type ta_prop, property_type; -type display_prop, property_type; diff --git a/sepolicy/vendor/qcamerasvr.te b/sepolicy/vendor/qcamerasvr.te deleted file mode 100644 index 7f84e40..0000000 --- a/sepolicy/vendor/qcamerasvr.te +++ /dev/null @@ -1,23 +0,0 @@ -# qcamerasvr service -type qcamerasvr, domain; -type qcamerasvr_exec, exec_type, file_type; - -# Started by init -init_daemon_domain(qcamerasvr) - -allow qcamerasvr camera_data_file:dir { add_name remove_name write }; -allow qcamerasvr camera_data_file:sock_file { create unlink }; -allow qcamerasvr hal_camera_default:fd use; -allow qcamerasvr ion_device:chr_file { open read ioctl }; -allow qcamerasvr mediaserver:fd use; -allow qcamerasvr sysfs:file { open read write }; -allow qcamerasvr video_device:chr_file { ioctl open read write }; -allow qcamerasvr camera_prop:file { getattr open read }; -allow qcamerasvr cameraserver:fd use; -allow qcamerasvr camera_data_file:dir search; -allow qcamerasvr camera_socket:sock_file unlink; -allow qcamerasvr sysfs_graphics:file { open read }; -allow qcamerasvr ta_data_file:dir search; -allow qcamerasvr secd_exec:file { getattr read }; -allow qcamerasvr vendor_camera_data_file:dir { add_name remove_name write }; -allow qcamerasvr vendor_camera_data_file:sock_file { create unlink }; diff --git a/sepolicy/vendor/qmuxd.te b/sepolicy/vendor/qmuxd.te deleted file mode 100644 index f2fcafb..0000000 --- a/sepolicy/vendor/qmuxd.te +++ /dev/null @@ -1,3 +0,0 @@ -allow qmuxd diag_device:chr_file { ioctl open read write }; -allow qmuxd sysfs:file read; -allow qmuxd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/radio.te b/sepolicy/vendor/radio.te deleted file mode 100644 index 35ae984..0000000 --- a/sepolicy/vendor/radio.te +++ /dev/null @@ -1,2 +0,0 @@ -allow radio gpuservice:binder call; -allow radio system_app_data_file:dir getattr; diff --git a/sepolicy/vendor/recovery_persist.te b/sepolicy/vendor/recovery_persist.te deleted file mode 100644 index 18809a7..0000000 --- a/sepolicy/vendor/recovery_persist.te +++ /dev/null @@ -1 +0,0 @@ -allow recovery_persist secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/rild.te b/sepolicy/vendor/rild.te deleted file mode 100644 index e3f441c..0000000 --- a/sepolicy/vendor/rild.te +++ /dev/null @@ -1,25 +0,0 @@ -allow rild cache_file:dir { rw_file_perms remove_name }; -allow rild cache_file:file { r_file_perms unlink }; -allow rild tad_socket:sock_file write; -allow rild tee_device:chr_file { read write open ioctl}; -allow rild radio_data_file:file { getattr lock open read write }; -allow rild default_android_service:service_manager find; -allow rild radio_data_file:dir { add_name getattr open read remove_name write }; -allow rild radio_data_file:file { create ioctl setattr unlink }; -allow rild self:capability dac_override; -allow rild servicemanager:binder call; -allow rild tee_device:chr_file { open read write }; -allow rild firmware_file:file { getattr open read }; -allow rild ion_device:chr_file { ioctl open read }; -allow rild self:capability sys_module; -allow rild socket_device:sock_file write; -allow rild tee_device:chr_file ioctl; -allow rild audioserver_service:service_manager find; -allow rild self:capability chown; -allow rild radio_data_file:dir search; -allow rild vendor_file:file ioctl; -allow rild tad:unix_stream_socket connectto; -allow rild cache_file:dir search; -allow rild firmware_file:dir search; -allow rild device:file { open write }; -allow rild secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/rmt_storage.te b/sepolicy/vendor/rmt_storage.te deleted file mode 100644 index 58b7f41..0000000 --- a/sepolicy/vendor/rmt_storage.te +++ /dev/null @@ -1 +0,0 @@ -allow rmt_storage secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/sct_service.te b/sepolicy/vendor/sct_service.te deleted file mode 100644 index acbdfde..0000000 --- a/sepolicy/vendor/sct_service.te +++ /dev/null @@ -1,15 +0,0 @@ -# sct_service service -type sct_service, domain; -type sct_service_exec, exec_type, file_type; - -# Started by init -init_daemon_domain(sct_service) - -# Allow sct_service to use net_raw capability -allow sct_service self:capability net_raw; - -# Allow sct_service to create self:socket -allow sct_service self:socket create_socket_perms; -allow sct_service self:socket { create read write }; -allowxperm sct_service self:socket ioctl msm_sock_ipc_ioctls; -allow sct_service secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/sdcardd.te b/sepolicy/vendor/sdcardd.te deleted file mode 100644 index 68c2942..0000000 --- a/sepolicy/vendor/sdcardd.te +++ /dev/null @@ -1 +0,0 @@ -allow sdcardd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/secd.te b/sepolicy/vendor/secd.te deleted file mode 100644 index fcc65e8..0000000 --- a/sepolicy/vendor/secd.te +++ /dev/null @@ -1,22 +0,0 @@ -# secd service -type secd, domain; -type secd_exec, exec_type, file_type; - -# Started by init -init_daemon_domain(secd) - -allow secd tad:unix_stream_socket connectto; -allow secd tad_socket:sock_file write; -allow secd tee_device:chr_file { ioctl open read write }; -allow secd secd_data_file:file { lock open write create getattr read setattr unlink }; -allow secd secd_data_file:dir { rw_file_perms add_name remove_name search }; -allow secd diag_partition_device:dir search; -allow secd diag_data_file:dir search; -allow secd diag_data_file:sock_file write; -allow secd firmware_file:dir search; -allow secd firmware_file:file { getattr open read }; -allow secd iddd:unix_dgram_socket sendto; -allow secd ion_device:chr_file { ioctl open read }; -allow secd socket_device:sock_file write; -allow secd tee_device:chr_file { ioctl open read write }; -allow secd secd_data_file:file ioctl; diff --git a/sepolicy/vendor/sensors.te b/sepolicy/vendor/sensors.te deleted file mode 100644 index 99094dc..0000000 --- a/sepolicy/vendor/sensors.te +++ /dev/null @@ -1,7 +0,0 @@ -allow sensors device:dir { write add_name }; -allow sensors input_device:chr_file { relabelfrom getattr link }; -allow sensors input_device:dir search; -allow sensors tmpfs:file rw_file_perms; -allow sensors tad_socket:sock_file { write }; -allow sensors sysfs:file { open read }; -allow sensors secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/service.te b/sepolicy/vendor/service.te deleted file mode 100644 index 5b53ee5..0000000 --- a/sepolicy/vendor/service.te +++ /dev/null @@ -1 +0,0 @@ -type timekeep_service, service_manager_type; diff --git a/sepolicy/vendor/servicemanager.te b/sepolicy/vendor/servicemanager.te deleted file mode 100644 index 75da12d..0000000 --- a/sepolicy/vendor/servicemanager.te +++ /dev/null @@ -1,10 +0,0 @@ -allow servicemanager init:dir search; -allow servicemanager init:file { open read }; -allow servicemanager init:process getattr; -allow servicemanager per_proxy:dir search; -allow servicemanager per_proxy:file { open read }; -allow servicemanager per_proxy:process getattr; -allow servicemanager mediaswcodec:dir search; -allow servicemanager mediaswcodec:file { open read }; -allow servicemanager mediaswcodec:process getattr; -allow servicemanager secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/shell.te b/sepolicy/vendor/shell.te deleted file mode 100644 index 904da06..0000000 --- a/sepolicy/vendor/shell.te +++ /dev/null @@ -1,109 +0,0 @@ -allow shell alarm_boot_prop:file { getattr open }; -allow shell alarm_handled_prop:file { getattr open }; -allow shell alarm_instance_prop:file { getattr open }; -allow shell apexd_prop:file { getattr open }; -allow shell bg_boot_complete_prop:file { getattr open }; -allow shell bg_daemon_prop:file { getattr open }; -allow shell bluetooth_prop:file { getattr open }; -allow shell boot_animation_prop:file { getattr open }; -allow shell boot_mode_prop:file { getattr open }; -allow shell boottime_prop:file { getattr open }; -allow shell bpf_progs_loaded_prop:file { getattr open }; -allow shell coresight_prop:file { getattr open }; -allow shell crash_prop:file { getattr open }; -allow shell ctl_LKCore_prop:file { getattr open }; -allow shell ctl_adbd_prop:file { getattr open }; -allow shell ctl_bootanim_prop:file { getattr open read }; -allow shell ctl_console_prop:file { getattr open }; -allow shell ctl_default_prop:file { getattr open }; -allow shell ctl_fuse_prop:file { getattr open }; -allow shell ctl_hbtp_prop:file { getattr open }; -allow shell ctl_interface_restart_prop:file { getattr open }; -allow shell ctl_interface_start_prop:file { getattr open }; -allow shell ctl_interface_stop_prop:file { getattr open }; -allow shell ctl_mdnsd_prop:file { getattr open }; -allow shell ctl_netmgrd_prop:file { getattr open }; -allow shell ctl_port-bridge_prop:file { getattr open }; -allow shell ctl_qmuxd_prop:file { getattr open }; -allow shell ctl_restart_prop:file { getattr open }; -allow shell ctl_rildaemon_prop:file { getattr open }; -allow shell ctl_sigstop_prop:file { getattr open }; -allow shell ctl_start_prop:file { getattr open }; -allow shell ctl_stop_prop:file { getattr open }; -allow shell ctl_vendor_imsrcsservice_prop:file { getattr open }; -allow shell ctl_vendor_wigigsvc_prop:file { getattr open }; -allow shell device_config_activity_manager_native_boot_prop:file { getattr open }; -allow shell device_config_boot_count_prop:file { getattr open }; -allow shell device_config_input_native_boot_prop:file { getattr open }; -allow shell device_config_media_native_prop:file { getattr open }; -allow shell device_config_netd_native_prop:file { getattr open }; -allow shell device_config_reset_performed_prop:file { getattr open }; -allow shell device_config_runtime_native_boot_prop:file { getattr open }; -allow shell device_config_runtime_native_prop:file { getattr open }; -allow shell diag_mdlog_prop:file { getattr open }; -allow shell dolby_prop:file { getattr open }; -allow shell dumpstate_options_prop:file { getattr open }; -allow shell firstboot_prop:file { getattr open }; -allow shell fm_prop:file { getattr open }; -allow shell freq_prop:file { getattr open }; -allow shell fst_prop:file { getattr open }; -allow shell gamed_prop:file { getattr open }; -allow shell gsid_prop:file { getattr open }; -allow shell ipacm-diag_prop:file { getattr open }; -allow shell ipacm_prop:file { getattr open }; -allow shell llkd_prop:file { getattr open }; -allow shell location_prop:file { getattr open }; -allow shell lowpan_prop:file { getattr open }; -allow shell mdm_helper_prop:file { getattr open }; -allow shell mmc_prop:file { getattr open }; -allow shell mmi_prop:file { getattr open }; -allow shell mpdecision_prop:file { getattr open }; -allow shell msm_irqbalance_prop:file { getattr open }; -allow shell msm_irqbl_sdm630_prop:file { getattr open }; -allow shell net_dns_prop:file { getattr open }; -allow shell netd_prop:file { getattr open }; -allow shell netd_stable_secret_prop:file { getattr open }; -allow shell nfc_nq_prop:file { getattr open }; -allow shell opengles_prop:file { getattr open }; -allow shell overlay_prop:file { getattr open }; -allow shell per_mgr_state_prop:file { getattr open }; -allow shell perfd_prop:file { getattr open }; -allow shell persistent_properties_ready_prop:file { getattr open }; -allow shell postprocessing_prop:file { getattr open }; -allow shell ppd_prop:file { getattr open }; -allow shell qcom_ims_prop:file { getattr open }; -allow shell qdma_prop:file { getattr open }; -allow shell qemu_gles_prop:file { getattr open }; -allow shell qti_prop:file { getattr open }; -allow shell rmnet_mux_prop:file { getattr open }; -allow shell safemode_prop:file { getattr open }; -allow shell scr_enabled_prop:file { getattr open }; -allow shell sdm_idle_time_prop:file { getattr open }; -allow shell secd_exec:file { getattr read }; -allow shell sensors_prop:file { getattr open }; -allow shell spcomlib_prop:file { getattr open }; -allow shell sys_usb_configfs_prop:file { getattr open }; -allow shell sys_usb_controller_prop:file { getattr open }; -allow shell sys_usb_tethering_prop:file { getattr open }; -allow shell system_lmk_prop:file { getattr open }; -allow shell system_trace_prop:file { getattr open }; -allow shell ta_prop:file { getattr open }; -allow shell tee_prop:file { getattr open }; -allow shell test_boot_reason_prop:file { getattr open }; -allow shell theme_prop:file { getattr open }; -allow shell time_prop:file { getattr open }; -allow shell timekeep_prop:file { getattr open }; -allow shell traced_lazy_prop:file { getattr open }; -allow shell uicc_prop:file { getattr open }; -allow shell usf_prop:file { getattr open }; -allow shell vendor_mpctl_prop:file { getattr open }; -allow shell vendor_rild_libpath_prop:file { getattr open }; -allow shell vendor_system_prop:file { getattr open }; -allow shell vendor_wifi_prop:file { getattr open }; -allow shell vendor_wifi_version:file { getattr open }; -allow shell vm_bms_prop:file { getattr open }; -allow shell wifi_prop:file { getattr open }; -allow shell wififtmd_prop:file { getattr open }; -allow shell wigig_prop:file { getattr open }; -allow shell xlat_prop:file { getattr open }; -allow shell secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/statsd.te b/sepolicy/vendor/statsd.te deleted file mode 100644 index 990f691..0000000 --- a/sepolicy/vendor/statsd.te +++ /dev/null @@ -1 +0,0 @@ -allow statsd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/surfaceflinger.te b/sepolicy/vendor/surfaceflinger.te deleted file mode 100644 index 96ddacc..0000000 --- a/sepolicy/vendor/surfaceflinger.te +++ /dev/null @@ -1,4 +0,0 @@ -allow surfaceflinger perfd:unix_stream_socket connectto; -allow surfaceflinger socket_device:sock_file write; -allow surfaceflinger default_android_service:service_manager { add find }; -allow surfaceflinger secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/system_app.te b/sepolicy/vendor/system_app.te deleted file mode 100644 index b01135d..0000000 --- a/sepolicy/vendor/system_app.te +++ /dev/null @@ -1,12 +0,0 @@ -allow system_app time_data_file:dir search; -allow system_app timekeep_data_file:file { getattr open write }; -allow system_app timekeep_prop:file { getattr open }; -allow system_app timekeep_prop:property_service set; -allow system_app timekeep_prop:file read; -allow system_app sysfs_rtc:dir search; -allow system_app time_data_file:file { getattr open write }; -allow system_app vendor_default_prop:property_service set; -allow system_app apex_service:service_manager find; -allow system_app proc_pagetypeinfo:file read; -allow system_app sysfs_zram:dir search; -allow system_app system_suspend_control_service:service_manager find; diff --git a/sepolicy/vendor/system_server.te b/sepolicy/vendor/system_server.te deleted file mode 100644 index ea19fed..0000000 --- a/sepolicy/vendor/system_server.te +++ /dev/null @@ -1,16 +0,0 @@ -allow system_server ppd:unix_stream_socket connectto; -allow system_server pps_socket:sock_file write; -allow system_server self:capability sys_module; -allow system_server system_app_data_file:dir r_dir_perms; -allow system_server ta_data_file:dir search; -allow system_server ta_data_file:file r_file_perms; -allow system_server persist_file:dir rw_file_perms; -allow system_server perfd:unix_stream_socket connectto; -allow system_server socket_device:sock_file write; -allow system_server sensors:unix_stream_socket connectto; -allow system_server sensors_device:chr_file getattr; -allow system_server sensors_socket:sock_file write; -allow system_server unlabeled:file unlink; -allow system_server default_android_service:service_manager find; -allow system_server init:binder { call transfer }; -allow system_server exfat:dir rw_dir_perms; diff --git a/sepolicy/vendor/ta_qmi_service.te b/sepolicy/vendor/ta_qmi_service.te deleted file mode 100644 index b39f3b0..0000000 --- a/sepolicy/vendor/ta_qmi_service.te +++ /dev/null @@ -1,24 +0,0 @@ -# ta_qmi_service service -type ta_qmi_service, domain; -type ta_qmi_service_exec, exec_type, vendor_file_type, file_type; - -# Started by init -init_daemon_domain(ta_qmi_service) - -# Allow ta_qmi_service to access tad -unix_socket_connect(ta_qmi_service, tad, tad) - -# Allow ta_qmi_service to use net_raw, setgid and setuid capabilities -allow ta_qmi_service self:capability { net_raw setgid setuid }; - -# Allow ta_qmi_service to create self:socket -allow ta_qmi_service self:socket create_socket_perms; -allow ta_qmi_service self:socket { create read write }; -allowxperm ta_qmi_service self:socket ioctl msm_sock_ipc_ioctls; - -allow ta_qmi_service self:capability2 block_suspend; -allow ta_qmi_service socket_device:sock_file write; -allow ta_qmi_service sysfs_wake_lock:file { append open }; -allow ta_qmi_service tad:unix_stream_socket connectto; -allow ta_qmi_service tad_socket:sock_file write; -allow ta_qmi_service secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/tad.te b/sepolicy/vendor/tad.te deleted file mode 100644 index 383a182..0000000 --- a/sepolicy/vendor/tad.te +++ /dev/null @@ -1,14 +0,0 @@ -type tad, domain; -type tad_exec, exec_type, file_type; -type_transition tad socket_device:sock_file tad_socket "tad"; - -# Started by init -init_daemon_domain(tad) - -# Read /proc/stat -allow tad proc:file r_file_perms; - -# Allow tad to work it's magic -allow tad trim_area_partition_device:blk_file { ioctl rw_file_perms }; -allow tad block_device:dir search; -allow tad tmpfs:file rw_file_perms; diff --git a/sepolicy/vendor/taimport.te b/sepolicy/vendor/taimport.te deleted file mode 100644 index 339c4f6..0000000 --- a/sepolicy/vendor/taimport.te +++ /dev/null @@ -1,15 +0,0 @@ -# taimport service -type taimport, domain; -type taimport_exec, exec_type, file_type; - -# Started by init -init_daemon_domain(taimport) - -allow taimport tad_socket:sock_file { write }; -allow taimport ta_data_file:dir { read search write add_name create remove_name }; -allow taimport ta_data_file:file { read write create getattr open unlink}; -allow taimport self:capability { dac_override setgid }; -allow taimport socket_device:sock_file write; -allow taimport system_data_file:dir { add_name remove_name write }; -allow taimport init:unix_stream_socket connectto; -allow taimport secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/tee.te b/sepolicy/vendor/tee.te deleted file mode 100644 index 683afe1..0000000 --- a/sepolicy/vendor/tee.te +++ /dev/null @@ -1,28 +0,0 @@ -# tee starts as root, and drops privileges -allow tee self:capability { - setuid - setgid -}; - -# allow tee to load firmware images -r_dir_file(tee, firmware_file) - -binder_use(tee) - -# Provide tee ability to access QMUXD/IPCRouter for QMI -qmux_socket(tee); - -set_prop(tee, tee_prop) - -# Need to directly manipulate certain block devices -# for anti-rollback protection -allow tee block_device:dir r_dir_perms; -allow tee rpmb_device:blk_file rw_file_perms; - -# Provide tee access to ssd partition for HW FDE -allow tee ssd_device:blk_file rw_file_perms; - -allow tee system_data_file:dir r_dir_perms; -allow tee vfat:file { getattr open read }; -allow tee vfat:dir search; -allow tee secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/thermal-engine.te b/sepolicy/vendor/thermal-engine.te deleted file mode 100644 index 46f80fc..0000000 --- a/sepolicy/vendor/thermal-engine.te +++ /dev/null @@ -1,9 +0,0 @@ -allow thermal-engine ta_data_file:dir search; -allow thermal-engine ta_data_file:file r_file_perms; -allow thermal-engine diag_partition_device:dir search; -allow thermal-engine diag_data_file:dir search; -allow thermal-engine diag_data_file:sock_file write; -allow thermal-engine socket_device:sock_file { create setattr }; -allow thermal-engine init:unix_dgram_socket sendto; -allow thermal-engine iddd:unix_dgram_socket sendto; -allow thermal-engine secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/timekeep.te b/sepolicy/vendor/timekeep.te deleted file mode 100644 index 3a6874c..0000000 --- a/sepolicy/vendor/timekeep.te +++ /dev/null @@ -1,25 +0,0 @@ -# timekeep service -type timekeep, domain; -type timekeep_exec, exec_type, file_type; - -# Started by init -init_daemon_domain(timekeep) - -set_prop(timekeep, timekeep_prop) - -r_dir_file(timekeep, sysfs_timekeep) - -allow timekeep self:capability { - fowner - fsetid - sys_time - dac_override - dac_read_search -}; -allow timekeep timekeep_data_file:file create_file_perms; -allow timekeep timekeep_data_file:dir { create_dir_perms search }; -allow timekeep time_data_file:dir { create_dir_perms search }; -allow timekeep time_data_file:file { write open getattr setattr }; -allow timekeep sysfs:file {read open }; -allow timekeep sysfs_rtc:dir search; -allow timekeep secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/tombstoned.te b/sepolicy/vendor/tombstoned.te deleted file mode 100644 index cc69697..0000000 --- a/sepolicy/vendor/tombstoned.te +++ /dev/null @@ -1 +0,0 @@ -allow tombstoned secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/toolbox.te b/sepolicy/vendor/toolbox.te deleted file mode 100644 index a593ea5..0000000 --- a/sepolicy/vendor/toolbox.te +++ /dev/null @@ -1,6 +0,0 @@ -allow toolbox diag_data_file:dir { getattr open read remove_name rmdir write }; -allow toolbox self:capability dac_override; -allow toolbox diag_data_file:dir search; -allow toolbox firmware_file:dir { open read rmdir write }; -allow toolbox firmware_file:dir search; -allow toolbox secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/tzdatacheck.te b/sepolicy/vendor/tzdatacheck.te deleted file mode 100644 index 315ff85..0000000 --- a/sepolicy/vendor/tzdatacheck.te +++ /dev/null @@ -1 +0,0 @@ -allow tzdatacheck secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/ueventd.te b/sepolicy/vendor/ueventd.te deleted file mode 100644 index 29c49eb..0000000 --- a/sepolicy/vendor/ueventd.te +++ /dev/null @@ -1,9 +0,0 @@ -# Allow firmware_file access to load Non-HLOS images -r_dir_file(ueventd, firmware_file) - -allow ueventd device:file relabelfrom; -allow ueventd sysfs_camera_torch:file { open write }; -allow ueventd vfat:dir search; -allow ueventd vfat:file { getattr open read }; -allow ueventd self:capability sys_nice; -allow ueventd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/updatemiscta.te b/sepolicy/vendor/updatemiscta.te deleted file mode 100644 index 2ef7cb7..0000000 --- a/sepolicy/vendor/updatemiscta.te +++ /dev/null @@ -1,14 +0,0 @@ -# updatemiscta service -type updatemiscta, domain; -type updatemiscta_exec, exec_type, file_type; - -# Started by init -init_daemon_domain(updatemiscta) - -unix_socket_connect(taimport, tad, tad) - -allow updatemiscta socket_device:sock_file write; -allow updatemiscta tad:unix_stream_socket connectto; -allow updatemiscta ta_prop:file { getattr open read }; -allow updatemiscta tad_socket:sock_file write; -allow updatemiscta secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/usbd.te b/sepolicy/vendor/usbd.te deleted file mode 100644 index 5aacbbb..0000000 --- a/sepolicy/vendor/usbd.te +++ /dev/null @@ -1 +0,0 @@ -allow usbd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vdc.te b/sepolicy/vendor/vdc.te deleted file mode 100644 index 8aea92e..0000000 --- a/sepolicy/vendor/vdc.te +++ /dev/null @@ -1 +0,0 @@ -allow vdc secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vendor_init.te b/sepolicy/vendor/vendor_init.te deleted file mode 100644 index 8e95520..0000000 --- a/sepolicy/vendor/vendor_init.te +++ /dev/null @@ -1 +0,0 @@ -allow vendor_init secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vndservicemanager.te b/sepolicy/vendor/vndservicemanager.te deleted file mode 100644 index 533f601..0000000 --- a/sepolicy/vendor/vndservicemanager.te +++ /dev/null @@ -1 +0,0 @@ -allow vndservicemanager secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vold.te b/sepolicy/vendor/vold.te deleted file mode 100644 index 755eff5..0000000 --- a/sepolicy/vendor/vold.te +++ /dev/null @@ -1,5 +0,0 @@ -allow vold diag_data_file:dir { read open ioctl }; -allow vold firmware_file:dir search; -allow vold firmware_file:file { getattr open read }; -allow vold secd_exec:file { getattr read }; -allow vold tee_prop:file { r_file_perms }; diff --git a/sepolicy/vendor/vold_prepare_subdirs.te b/sepolicy/vendor/vold_prepare_subdirs.te deleted file mode 100644 index e4c4bb4..0000000 --- a/sepolicy/vendor/vold_prepare_subdirs.te +++ /dev/null @@ -1 +0,0 @@ -allow vold_prepare_subdirs secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/wificond.te b/sepolicy/vendor/wificond.te deleted file mode 100644 index 73ca465..0000000 --- a/sepolicy/vendor/wificond.te +++ /dev/null @@ -1 +0,0 @@ -allow wificond secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/zygote.te b/sepolicy/vendor/zygote.te deleted file mode 100644 index 850d576..0000000 --- a/sepolicy/vendor/zygote.te +++ /dev/null @@ -1,3 +0,0 @@ -allow zygote proc_cmdline:file { getattr open read }; -allow zygote secd_exec:file { getattr read }; -allow zygote device:file rw_file_perms; -- GitLab From f106eb5481ba78c546fbd93204269171f14a9335 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Mon, 26 Oct 2020 01:48:58 +0800 Subject: [PATCH 039/191] kitakami-common: rootdir: Remove service overrides --- rootdir/init.qcom.rc | 64 -------------------------------------------- 1 file changed, 64 deletions(-) diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index 981f912..f3989d1 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -689,70 +689,6 @@ service secd /system/bin/secd socket secd_devsec_sock stream 0660 system oem_2996 socket secd_credmgr_sock stream 0660 system oem_2996 -#service camera-provider-2-4 /vendor/bin/hw/android.hardware.camera.provider@2.4-service -# class hal -# user cameraserver -# group audio camera input drmrpc oem_2996 oem_2993 -# ioprio rt 4 -# capabilities SYS_NICE -# writepid /dev/cpuset/camera-daemon/tasks /dev/stune/top-app/tasks - -service vendor.audio-hal-2-0 /vendor/bin/hw/android.hardware.audio@2.0-service - override - class hal - user audioserver - # media gid needed for /dev/fm (radio) and for /data/misc/media (tee) - group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct wakelock oem_2993 - capabilities BLOCK_SUSPEND - ioprio rt 4 - writepid /dev/cpuset/foreground/tasks /dev/stune/foreground/tasks - # audioflinger restarts itself when it loses connection with the hal - # and its .rc file has an "onrestart restart audio-hal" rule, thus - # an additional auto-restart from the init process isn't needed. - oneshot - interface android.hardware.audio@4.0::IDevicesFactory default - interface android.hardware.audio@2.0::IDevicesFactory default - -service cameraserver /system/bin/cameraserver - override - class main - user cameraserver - group audio camera input drmrpc oem_2996 oem_2993 - ioprio rt 4 - writepid /dev/cpuset/camera-daemon/tasks /dev/stune/top-app/tasks - rlimit rtprio 10 10 - -service audioserver /system/bin/audioserver - override - class core - user audioserver - # media gid needed for /dev/fm (radio) and for /data/misc/media (tee) - group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct wakelock oem_2993 - capabilities BLOCK_SUSPEND - ioprio rt 4 - writepid /dev/cpuset/foreground/tasks /dev/stune/foreground/tasks - onrestart restart vendor.audio-hal-2-0 - onrestart restart vendor.audio-hal-4-0-msd - # Keep the original service name for backward compatibility when upgrading - # O-MR1 devices with framework-only. - onrestart restart audio-hal-2-0 - -service mediadrm /system/bin/mediadrmserver - override - class main - user media - group mediadrm drmrpc oem_2993 - ioprio rt 4 - writepid /dev/cpuset/foreground/tasks - -service media /system/bin/mediaserver - override - class main - user media - group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc mediadrm oem_2996 - ioprio rt 4 - writepid /dev/cpuset/foreground/tasks /dev/stune/foreground/tasks - service iddd /system/bin/iddd class core user oem_2987 -- GitLab From 6117d7cb530624010ea34c4ea7a491165f7ed943 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Mon, 26 Oct 2020 02:01:52 +0800 Subject: [PATCH 040/191] kitakami-common: rootdir: Disable iddd for now --- rootdir/init.qcom.rc | 1 + 1 file changed, 1 insertion(+) diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index f3989d1..dbbf6fd 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -693,6 +693,7 @@ service iddd /system/bin/iddd class core user oem_2987 group oem_2987 log inet oem_2993 + disabled on property:service.usb.otg.switch=check write /sys/module/qpnp_smbcharger_extension/parameters/start_id_polling 1 -- GitLab From e8c6c6f6370515e35a5e46d7c2f27b9c22321529 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Mon, 26 Oct 2020 02:02:34 +0800 Subject: [PATCH 041/191] kitakami-common: camera: Directly open camera3 device * Open camera2 device causing errors. --- camera/CameraWrapper.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/camera/CameraWrapper.cpp b/camera/CameraWrapper.cpp index 120e4f4..34abe8d 100644 --- a/camera/CameraWrapper.cpp +++ b/camera/CameraWrapper.cpp @@ -80,14 +80,7 @@ static int camera_device_open(const hw_module_t* module, const char* name, if (name != NULL) { if (check_vendor_module()) return -EINVAL; - - if (isHAL3Enabled) { - ALOGV("%s: using HAL3", __FUNCTION__); - rv = camera3_device_open(module, name, device); - } else { - ALOGV("%s: using HAL2", __FUNCTION__); - rv = camera2_device_open(module, name, device); - } + rv = camera3_device_open(module, name, device); } ALOGV("%s: rv = %d", __FUNCTION__, rv); -- GitLab From c03d83fa7f8fb742631d2a2609bef2fc0143c862 Mon Sep 17 00:00:00 2001 From: razorloves Date: Wed, 1 May 2019 23:01:46 -0500 Subject: [PATCH 042/191] kitakami-common: Snap: Set the default video quality to 1080p Change-Id: I74d4656f13b2d174a01606f9b6185e5698d54410 --- .../apps/Snap/res/values/qcomstrings.xml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 overlay/packages/apps/Snap/res/values/qcomstrings.xml diff --git a/overlay/packages/apps/Snap/res/values/qcomstrings.xml b/overlay/packages/apps/Snap/res/values/qcomstrings.xml new file mode 100644 index 0000000..0a635be --- /dev/null +++ b/overlay/packages/apps/Snap/res/values/qcomstrings.xml @@ -0,0 +1,20 @@ + + + + 1920x1080 + -- GitLab From fff182e56e46816485386e3b1eaab519791d0ba9 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Mon, 26 Oct 2020 10:13:12 +0800 Subject: [PATCH 043/191] kitakami-common: overlay: Update overlays for Snap * Disabled open_legacy. * Disabled Camera API v2. * Disabled preview restart. * Set default preview size to 720P. --- overlay/packages/apps/Snap/res/values/config.xml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/overlay/packages/apps/Snap/res/values/config.xml b/overlay/packages/apps/Snap/res/values/config.xml index bbbcc7f..b843fae 100644 --- a/overlay/packages/apps/Snap/res/values/config.xml +++ b/overlay/packages/apps/Snap/res/values/config.xml @@ -19,16 +19,22 @@ - true + false - true + false + + + false - true + false - true + false + + + 1280x720 sony-iso -- GitLab From 80d7c3b0c11154edf5d6b7ee50f7e97b58904777 Mon Sep 17 00:00:00 2001 From: Quallenauge Date: Wed, 21 Oct 2020 21:19:01 +0200 Subject: [PATCH 044/191] kitakami-common: Force build scudo free 32 bit variant of libc. We have issues with camera blobs which doesn't play well with scudo allocation/deallocation tracking. Scudo reports corrupted header when stopping a video recording. Because we aren't alone with this (also upstream seems to have trouble with camera modules) use the 32 libc which is used only by a few components, like camera and audio. Because docs states, that libc with the svelte take less RSS, but is a little bit slower. https://android.googlesource.com/platform/bionic/+/master/docs/native_allocator.md This is the reason to not enable this target wide. Change-Id: Ic0d950817238a227218f59b95e5fd2ffd66e786a --- BoardConfigCommon.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index dc93e1b..c7555aa 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -92,6 +92,7 @@ BOARD_HAVE_BLUETOOTH_BCM := true # Camera TARGET_USES_MEDIA_EXTENSIONS := true +MALLOC_SVELTE_FOR_LIBC32 := true TARGET_PROCESS_SDK_VERSION_OVERRIDE := \ /system/bin/cameraserver=25 \ -- GitLab From 03fc5c22a7ac537712e553221ca6c9b77761e306 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Mon, 26 Oct 2020 17:29:34 +0800 Subject: [PATCH 045/191] Revert "kitakami-common: camera: defer start_preview until surface is valid" This reverts commit a4aa4dbe758c4392b9e14ac65d13c40398a5f4de. --- camera/Camera2Wrapper.cpp | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/camera/Camera2Wrapper.cpp b/camera/Camera2Wrapper.cpp index e652531..dbe7fa9 100644 --- a/camera/Camera2Wrapper.cpp +++ b/camera/Camera2Wrapper.cpp @@ -38,8 +38,6 @@ typedef struct wrapper_camera2_device { #define CAMERA_ID(device) (((wrapper_camera2_device_t *)(device))->id) static camera_module_t *gVendorModule = 0; -static preview_stream_ops *gPreviewWindow = 0; -static bool gPreviewStartDeferred = false; static camera_notify_callback gUserNotifyCb = NULL; static camera_data_callback gUserDataCb = NULL; @@ -113,25 +111,12 @@ static char * camera2_fixup_setparams(int id __unused, const char * settings) static int camera2_set_preview_window(struct camera_device * device, struct preview_stream_ops *window) { - int rc = 0; ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera2_device_t*)device)->vendor)); - if(!device) + if(!device || !window) return -EINVAL; - gPreviewWindow = window; - - if (gPreviewWindow != 0) { - rc = VENDOR_CALL(device, set_preview_window, window); - - if (gPreviewStartDeferred) { - ALOGV("%s call deferred start_preview", __FUNCTION__); - gPreviewStartDeferred = false; - VENDOR_CALL(device, start_preview); - } - } - - return rc; + return VENDOR_CALL(device, set_preview_window, window); } void camera_notify_cb(int32_t msg_type, int32_t ext1, int32_t ext2, void *user) { @@ -213,13 +198,7 @@ static int camera2_start_preview(struct camera_device * device) if(!device) return -EINVAL; - if (gPreviewWindow != 0) { - rc = VENDOR_CALL(device, start_preview); - } else { - ALOGV("%s invalid preview window, defer start_preview", __FUNCTION__); - gPreviewStartDeferred = true; - } - + rc = VENDOR_CALL(device, start_preview); return rc; } @@ -240,12 +219,7 @@ static int camera2_preview_enabled(struct camera_device * device) if(!device) return -EINVAL; - if (gPreviewStartDeferred) { - ALOGV("%s deferred start_preview, return 1", __FUNCTION__); - return 1; - } else { - return VENDOR_CALL(device, preview_enabled); - } + return VENDOR_CALL(device, preview_enabled); } static int camera2_store_meta_data_in_buffers(struct camera_device * device, int enable) @@ -453,8 +427,6 @@ static int camera2_device_close(hw_device_t* device) free(wrapper_dev->base.ops); free(wrapper_dev); done: - gPreviewWindow = 0; - gPreviewStartDeferred = false; return ret; } -- GitLab From 6dc059f19bc037bc5309dc9d10ab63c3d3d5066d Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Thu, 29 Oct 2020 10:26:42 +0100 Subject: [PATCH 046/191] Revert "kitakami-common: sepolicy: Switch to permissive mode for now" This reverts commit fec90bc2da4686fea21e52d41db740ccc62c667f. --- BoardConfigCommon.mk | 1 - sepolicy/vendor/adbd.te | 1 + sepolicy/vendor/adsprpcd.te | 1 + sepolicy/vendor/apexd.te | 1 + sepolicy/vendor/ashmemd.te | 1 + sepolicy/vendor/audioserver.te | 4 + sepolicy/vendor/bootanim.te | 1 + sepolicy/vendor/bootstat.te | 1 + sepolicy/vendor/cameraserver.te | 18 +++ sepolicy/vendor/charger.te | 5 + sepolicy/vendor/clatd.te | 1 + sepolicy/vendor/device.te | 3 + sepolicy/vendor/drmserver.te | 1 + sepolicy/vendor/file.te | 23 ++++ sepolicy/vendor/flags_health_check.te | 25 ++++ sepolicy/vendor/fsck.te | 5 + sepolicy/vendor/fsck_untrusted.te | 1 + sepolicy/vendor/gatekeeperd.te | 2 + sepolicy/vendor/gpuservice.te | 1 + sepolicy/vendor/hal_audio_default.te | 3 + sepolicy/vendor/hal_bluetooth_default.te | 7 ++ sepolicy/vendor/hal_camera_default.te | 4 + sepolicy/vendor/hal_cas_default.te | 1 + sepolicy/vendor/hal_configstore_default.te | 1 + sepolicy/vendor/hal_drm_default.te | 1 + sepolicy/vendor/hal_fingerprint_default.te | 18 +++ .../vendor/hal_graphics_allocator_default.te | 2 + sepolicy/vendor/hal_keymaster_qti.te | 1 + sepolicy/vendor/hal_light_default.te | 2 + .../vendor/hal_lineage_livedisplay_qti.te | 2 + .../vendor/hal_lineage_livedisplay_sysfs.te | 2 + sepolicy/vendor/hal_lineage_trust_default.te | 1 + sepolicy/vendor/hal_memtrack_default.te | 1 + sepolicy/vendor/hal_power_default.te | 2 + sepolicy/vendor/hal_ril_default.te | 6 + sepolicy/vendor/hal_ril_wrapper.te | 6 + sepolicy/vendor/hal_usb_default.te | 1 + sepolicy/vendor/hal_wifi_default.te | 7 ++ .../vendor/hal_wifi_supplicant_default.te | 1 + sepolicy/vendor/healthd.te | 2 + sepolicy/vendor/hwservicemanager.te | 4 + sepolicy/vendor/iddd.te | 20 ++++ sepolicy/vendor/idmap.te | 1 + sepolicy/vendor/incidentd.te | 1 + sepolicy/vendor/init-power-sh.te | 38 ++++++ sepolicy/vendor/init.te | 50 ++++++++ sepolicy/vendor/installd.te | 2 + sepolicy/vendor/irsc_util.te | 1 + sepolicy/vendor/kernel.te | 6 + sepolicy/vendor/keystore.te | 2 + sepolicy/vendor/lmkd.te | 1 + sepolicy/vendor/loc_launcher.te | 15 +++ sepolicy/vendor/logd.te | 1 + sepolicy/vendor/mediacodec.te | 4 + sepolicy/vendor/mediadrmserver.te | 1 + sepolicy/vendor/mediaextractor.te | 1 + sepolicy/vendor/mediametrics.te | 1 + sepolicy/vendor/mediaserver.te | 5 + sepolicy/vendor/mediaswcodec.te | 2 + sepolicy/vendor/mlog_qmi_service.te | 15 +++ sepolicy/vendor/msm_irqbalance.te | 14 +++ sepolicy/vendor/netd.te | 2 + sepolicy/vendor/netmgrd.te | 4 + sepolicy/vendor/per_mgr.te | 7 ++ sepolicy/vendor/per_proxy.te | 14 +++ sepolicy/vendor/perfd.te | 3 + sepolicy/vendor/platform_app.te | 1 + sepolicy/vendor/ppd.te | 23 ++++ sepolicy/vendor/priv_app.te | 7 ++ sepolicy/vendor/property.te | 4 + sepolicy/vendor/qcamerasvr.te | 23 ++++ sepolicy/vendor/qmuxd.te | 3 + sepolicy/vendor/radio.te | 2 + sepolicy/vendor/recovery_persist.te | 1 + sepolicy/vendor/rild.te | 25 ++++ sepolicy/vendor/rmt_storage.te | 1 + sepolicy/vendor/sct_service.te | 15 +++ sepolicy/vendor/sdcardd.te | 1 + sepolicy/vendor/secd.te | 22 ++++ sepolicy/vendor/sensors.te | 7 ++ sepolicy/vendor/service.te | 1 + sepolicy/vendor/servicemanager.te | 10 ++ sepolicy/vendor/shell.te | 109 ++++++++++++++++++ sepolicy/vendor/statsd.te | 1 + sepolicy/vendor/surfaceflinger.te | 4 + sepolicy/vendor/system_app.te | 12 ++ sepolicy/vendor/system_server.te | 16 +++ sepolicy/vendor/ta_qmi_service.te | 24 ++++ sepolicy/vendor/tad.te | 14 +++ sepolicy/vendor/taimport.te | 15 +++ sepolicy/vendor/tee.te | 28 +++++ sepolicy/vendor/thermal-engine.te | 9 ++ sepolicy/vendor/timekeep.te | 25 ++++ sepolicy/vendor/tombstoned.te | 1 + sepolicy/vendor/toolbox.te | 6 + sepolicy/vendor/tzdatacheck.te | 1 + sepolicy/vendor/ueventd.te | 9 ++ sepolicy/vendor/updatemiscta.te | 14 +++ sepolicy/vendor/usbd.te | 1 + sepolicy/vendor/vdc.te | 1 + sepolicy/vendor/vendor_init.te | 1 + sepolicy/vendor/vndservicemanager.te | 1 + sepolicy/vendor/vold.te | 5 + sepolicy/vendor/vold_prepare_subdirs.te | 1 + sepolicy/vendor/wificond.te | 1 + sepolicy/vendor/zygote.te | 3 + 106 files changed, 829 insertions(+), 1 deletion(-) create mode 100644 sepolicy/vendor/adbd.te create mode 100644 sepolicy/vendor/adsprpcd.te create mode 100644 sepolicy/vendor/apexd.te create mode 100644 sepolicy/vendor/ashmemd.te create mode 100644 sepolicy/vendor/audioserver.te create mode 100644 sepolicy/vendor/bootanim.te create mode 100644 sepolicy/vendor/bootstat.te create mode 100644 sepolicy/vendor/cameraserver.te create mode 100644 sepolicy/vendor/charger.te create mode 100644 sepolicy/vendor/clatd.te create mode 100644 sepolicy/vendor/device.te create mode 100644 sepolicy/vendor/drmserver.te create mode 100644 sepolicy/vendor/file.te create mode 100644 sepolicy/vendor/flags_health_check.te create mode 100644 sepolicy/vendor/fsck.te create mode 100644 sepolicy/vendor/fsck_untrusted.te create mode 100644 sepolicy/vendor/gatekeeperd.te create mode 100644 sepolicy/vendor/gpuservice.te create mode 100644 sepolicy/vendor/hal_audio_default.te create mode 100644 sepolicy/vendor/hal_bluetooth_default.te create mode 100644 sepolicy/vendor/hal_camera_default.te create mode 100644 sepolicy/vendor/hal_cas_default.te create mode 100644 sepolicy/vendor/hal_configstore_default.te create mode 100644 sepolicy/vendor/hal_drm_default.te create mode 100644 sepolicy/vendor/hal_fingerprint_default.te create mode 100644 sepolicy/vendor/hal_graphics_allocator_default.te create mode 100644 sepolicy/vendor/hal_keymaster_qti.te create mode 100644 sepolicy/vendor/hal_light_default.te create mode 100644 sepolicy/vendor/hal_lineage_livedisplay_qti.te create mode 100644 sepolicy/vendor/hal_lineage_livedisplay_sysfs.te create mode 100644 sepolicy/vendor/hal_lineage_trust_default.te create mode 100644 sepolicy/vendor/hal_memtrack_default.te create mode 100644 sepolicy/vendor/hal_power_default.te create mode 100644 sepolicy/vendor/hal_ril_default.te create mode 100644 sepolicy/vendor/hal_ril_wrapper.te create mode 100644 sepolicy/vendor/hal_usb_default.te create mode 100644 sepolicy/vendor/hal_wifi_default.te create mode 100644 sepolicy/vendor/hal_wifi_supplicant_default.te create mode 100644 sepolicy/vendor/healthd.te create mode 100644 sepolicy/vendor/hwservicemanager.te create mode 100644 sepolicy/vendor/iddd.te create mode 100644 sepolicy/vendor/idmap.te create mode 100644 sepolicy/vendor/incidentd.te create mode 100644 sepolicy/vendor/init-power-sh.te create mode 100644 sepolicy/vendor/init.te create mode 100644 sepolicy/vendor/installd.te create mode 100644 sepolicy/vendor/irsc_util.te create mode 100644 sepolicy/vendor/kernel.te create mode 100644 sepolicy/vendor/keystore.te create mode 100644 sepolicy/vendor/lmkd.te create mode 100644 sepolicy/vendor/loc_launcher.te create mode 100644 sepolicy/vendor/logd.te create mode 100644 sepolicy/vendor/mediacodec.te create mode 100644 sepolicy/vendor/mediadrmserver.te create mode 100644 sepolicy/vendor/mediaextractor.te create mode 100644 sepolicy/vendor/mediametrics.te create mode 100644 sepolicy/vendor/mediaserver.te create mode 100644 sepolicy/vendor/mediaswcodec.te create mode 100644 sepolicy/vendor/mlog_qmi_service.te create mode 100644 sepolicy/vendor/msm_irqbalance.te create mode 100644 sepolicy/vendor/netd.te create mode 100644 sepolicy/vendor/netmgrd.te create mode 100644 sepolicy/vendor/per_mgr.te create mode 100644 sepolicy/vendor/per_proxy.te create mode 100644 sepolicy/vendor/perfd.te create mode 100644 sepolicy/vendor/platform_app.te create mode 100644 sepolicy/vendor/ppd.te create mode 100644 sepolicy/vendor/priv_app.te create mode 100644 sepolicy/vendor/property.te create mode 100644 sepolicy/vendor/qcamerasvr.te create mode 100644 sepolicy/vendor/qmuxd.te create mode 100644 sepolicy/vendor/radio.te create mode 100644 sepolicy/vendor/recovery_persist.te create mode 100644 sepolicy/vendor/rild.te create mode 100644 sepolicy/vendor/rmt_storage.te create mode 100644 sepolicy/vendor/sct_service.te create mode 100644 sepolicy/vendor/sdcardd.te create mode 100644 sepolicy/vendor/secd.te create mode 100644 sepolicy/vendor/sensors.te create mode 100644 sepolicy/vendor/service.te create mode 100644 sepolicy/vendor/servicemanager.te create mode 100644 sepolicy/vendor/shell.te create mode 100644 sepolicy/vendor/statsd.te create mode 100644 sepolicy/vendor/surfaceflinger.te create mode 100644 sepolicy/vendor/system_app.te create mode 100644 sepolicy/vendor/system_server.te create mode 100644 sepolicy/vendor/ta_qmi_service.te create mode 100644 sepolicy/vendor/tad.te create mode 100644 sepolicy/vendor/taimport.te create mode 100644 sepolicy/vendor/tee.te create mode 100644 sepolicy/vendor/thermal-engine.te create mode 100644 sepolicy/vendor/timekeep.te create mode 100644 sepolicy/vendor/tombstoned.te create mode 100644 sepolicy/vendor/toolbox.te create mode 100644 sepolicy/vendor/tzdatacheck.te create mode 100644 sepolicy/vendor/ueventd.te create mode 100644 sepolicy/vendor/updatemiscta.te create mode 100644 sepolicy/vendor/usbd.te create mode 100644 sepolicy/vendor/vdc.te create mode 100644 sepolicy/vendor/vendor_init.te create mode 100644 sepolicy/vendor/vndservicemanager.te create mode 100644 sepolicy/vendor/vold.te create mode 100644 sepolicy/vendor/vold_prepare_subdirs.te create mode 100644 sepolicy/vendor/wificond.te create mode 100644 sepolicy/vendor/zygote.te diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index c7555aa..6210e2d 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -51,7 +51,6 @@ BUILD_BROKEN_USES_BUILD_COPY_HEADERS := true # Boot image/kernel BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-5 loop.max_part=7 dwc3_msm.hvdcp_max_current=1500 dwc3_msm.prop_chg_detect=Y coherent_pool=2M swiotlb=2048 -BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive BOARD_KERNEL_IMAGE_NAME := Image.gz-dtb BOARD_KERNEL_PAGESIZE := 4096 BOARD_KERNEL_BASE := 0x00000000 diff --git a/sepolicy/vendor/adbd.te b/sepolicy/vendor/adbd.te new file mode 100644 index 0000000..e78f756 --- /dev/null +++ b/sepolicy/vendor/adbd.te @@ -0,0 +1 @@ +allow adbd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/adsprpcd.te b/sepolicy/vendor/adsprpcd.te new file mode 100644 index 0000000..365465b --- /dev/null +++ b/sepolicy/vendor/adsprpcd.te @@ -0,0 +1 @@ +allow adsprpcd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/apexd.te b/sepolicy/vendor/apexd.te new file mode 100644 index 0000000..a1e4b88 --- /dev/null +++ b/sepolicy/vendor/apexd.te @@ -0,0 +1 @@ +allow apexd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/ashmemd.te b/sepolicy/vendor/ashmemd.te new file mode 100644 index 0000000..7e0f69d --- /dev/null +++ b/sepolicy/vendor/ashmemd.te @@ -0,0 +1 @@ +allow ashmemd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/audioserver.te b/sepolicy/vendor/audioserver.te new file mode 100644 index 0000000..e2c2a8a --- /dev/null +++ b/sepolicy/vendor/audioserver.te @@ -0,0 +1,4 @@ +allow audioserver tad_socket:sock_file write; +allow audioserver perfd:unix_stream_socket connectto; +allow audioserver socket_device:sock_file write; +allow audioserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/bootanim.te b/sepolicy/vendor/bootanim.te new file mode 100644 index 0000000..85e51f3 --- /dev/null +++ b/sepolicy/vendor/bootanim.te @@ -0,0 +1 @@ +allow bootanim secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/bootstat.te b/sepolicy/vendor/bootstat.te new file mode 100644 index 0000000..0198e07 --- /dev/null +++ b/sepolicy/vendor/bootstat.te @@ -0,0 +1 @@ +allow bootstat secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/cameraserver.te b/sepolicy/vendor/cameraserver.te new file mode 100644 index 0000000..e64396d --- /dev/null +++ b/sepolicy/vendor/cameraserver.te @@ -0,0 +1,18 @@ +allow cameraserver camera_data_file:sock_file write; +allow cameraserver gpu_device:chr_file rw_file_perms; +allow cameraserver perfd:unix_stream_socket connectto; +allow cameraserver rootfs:lnk_file getattr; +allow cameraserver sysfs_camera_torch:file rw_file_perms; +allow cameraserver sysfs_camera_torch:dir search; +allow cameraserver sysfs_camera_torch:lnk_file read; +allow cameraserver ta_data_file:dir search; +allow cameraserver secd_socket:sock_file write; +allow cameraserver hal_configstore_ISurfaceFlingerConfigs:hwservice_manager find; +allow cameraserver hal_configstore_default:binder call; +allow cameraserver socket_device:sock_file write; +allow cameraserver sysfs_graphics:file { getattr open read }; +allow cameraserver init:unix_dgram_socket sendto; +allow cameraserver qcamerasvr:unix_dgram_socket sendto; +allow cameraserver qcamerasvr:unix_stream_socket connectto; +allow cameraserver secd:unix_stream_socket connectto; +allow cameraserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/charger.te b/sepolicy/vendor/charger.te new file mode 100644 index 0000000..76c42b1 --- /dev/null +++ b/sepolicy/vendor/charger.te @@ -0,0 +1,5 @@ +allow charger self:capability { dac_override dac_read_search }; +allow charger sysfs:file { open read getattr }; +allow charger sysfs_usb_supply:file { open read getattr }; +allow charger sysfs_battery_supply:file { open read getattr }; +allow charger device:dir { open read }; diff --git a/sepolicy/vendor/clatd.te b/sepolicy/vendor/clatd.te new file mode 100644 index 0000000..03c2def --- /dev/null +++ b/sepolicy/vendor/clatd.te @@ -0,0 +1 @@ +allow clatd system_file:file lock; diff --git a/sepolicy/vendor/device.te b/sepolicy/vendor/device.te new file mode 100644 index 0000000..d5da1bc --- /dev/null +++ b/sepolicy/vendor/device.te @@ -0,0 +1,3 @@ +type trim_area_partition_device, dev_type; +type diag_partition_device, dev_type; +type subsys_modem_device, dev_type; diff --git a/sepolicy/vendor/drmserver.te b/sepolicy/vendor/drmserver.te new file mode 100644 index 0000000..a00eeb3 --- /dev/null +++ b/sepolicy/vendor/drmserver.te @@ -0,0 +1 @@ +allow drmserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/file.te b/sepolicy/vendor/file.te new file mode 100644 index 0000000..7365abe --- /dev/null +++ b/sepolicy/vendor/file.te @@ -0,0 +1,23 @@ +# TAD +type tad_socket, file_type; +type ta_data_file, file_type; +type secd_socket, file_type; +type secd_data_file, file_type; + +# Timekeep +type timekeep_data_file, file_type, data_file_type; +type sysfs_timekeep, fs_type, sysfs_type; + +# Macaddr +type sysfs_addrsetup, fs_type, sysfs_type; +type proc_kernel_sched, fs_type; +type sysfs_camera_torch, sysfs_type, file_type; +type sysfs_performance, sysfs_type, fs_type; +type sysfs_msm_subsys, sysfs_type, fs_type; + +# Fingerprint +type fpc_data_file, file_type; + +# Camera +type sysfs_camera, sysfs_type, fs_type; + diff --git a/sepolicy/vendor/flags_health_check.te b/sepolicy/vendor/flags_health_check.te new file mode 100644 index 0000000..d3fe883 --- /dev/null +++ b/sepolicy/vendor/flags_health_check.te @@ -0,0 +1,25 @@ +allow flags_health_check alarm_boot_prop:file { getattr open }; +allow flags_health_check alarm_handled_prop:file { getattr open }; +allow flags_health_check crash_prop:file { getattr open }; +allow flags_health_check ctl_LKCore_prop:file { getattr open }; +allow flags_health_check ctl_adbd_prop:file { getattr open }; +allow flags_health_check ctl_interface_start_prop:file { getattr open }; +allow flags_health_check ctl_interface_stop_prop:file open; +allow flags_health_check ctl_vendor_wigigsvc_prop:file open; +allow flags_health_check qemu_gles_prop:file getattr; +allow flags_health_check qti_prop:file open; +allow flags_health_check scr_enabled_prop:file getattr; +allow flags_health_check sdm_idle_time_prop:file { getattr open }; +allow flags_health_check sensors_prop:file { getattr open }; +allow flags_health_check serialno_prop:file { getattr open }; +allow flags_health_check spcomlib_prop:file { getattr open }; +allow flags_health_check sys_usb_configfs_prop:file { getattr open }; +allow flags_health_check sys_usb_controller_prop:file { getattr open }; +allow flags_health_check sys_usb_tethering_prop:file { getattr open }; +allow flags_health_check system_boot_reason_prop:file { getattr open }; +allow flags_health_check system_lmk_prop:file { getattr open }; +allow flags_health_check test_boot_reason_prop:file { getattr open }; +allow flags_health_check alarm_instance_prop:file { getattr open }; +allow flags_health_check apexd_prop:file { getattr open }; +allow flags_health_check bg_boot_complete_prop:file { getattr open }; +allow flags_health_check secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/fsck.te b/sepolicy/vendor/fsck.te new file mode 100644 index 0000000..ca3bdf2 --- /dev/null +++ b/sepolicy/vendor/fsck.te @@ -0,0 +1,5 @@ +allow fsck diag_partition_device:blk_file { read write }; +allow fsck self:capability { dac_override dac_read_search }; +allow fsck secd_exec:file { getattr read }; +allow fsck tmpfs:blk_file getattr; +allow fsck persist_file:dir getattr; diff --git a/sepolicy/vendor/fsck_untrusted.te b/sepolicy/vendor/fsck_untrusted.te new file mode 100644 index 0000000..06445b3 --- /dev/null +++ b/sepolicy/vendor/fsck_untrusted.te @@ -0,0 +1 @@ +allow fsck_untrusted vold_device:blk_file ioctl; diff --git a/sepolicy/vendor/gatekeeperd.te b/sepolicy/vendor/gatekeeperd.te new file mode 100644 index 0000000..0c9feaa --- /dev/null +++ b/sepolicy/vendor/gatekeeperd.te @@ -0,0 +1,2 @@ +allow gatekeeperd tee_prop:file { getattr open read }; +allow gatekeeperd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/gpuservice.te b/sepolicy/vendor/gpuservice.te new file mode 100644 index 0000000..72bb0a8 --- /dev/null +++ b/sepolicy/vendor/gpuservice.te @@ -0,0 +1 @@ +allow gpuservice secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_audio_default.te b/sepolicy/vendor/hal_audio_default.te new file mode 100644 index 0000000..0b91688 --- /dev/null +++ b/sepolicy/vendor/hal_audio_default.te @@ -0,0 +1,3 @@ +allow hal_audio_default tad_socket:sock_file { create_file_perms write }; +allow hal_audio_default secd_exec:file { getattr read }; +allow hal_audio_default tad:unix_stream_socket connectto; diff --git a/sepolicy/vendor/hal_bluetooth_default.te b/sepolicy/vendor/hal_bluetooth_default.te new file mode 100644 index 0000000..49bf694 --- /dev/null +++ b/sepolicy/vendor/hal_bluetooth_default.te @@ -0,0 +1,7 @@ +allow hal_bluetooth_default firmware_file:file { open read }; +allow hal_bluetooth_default sysfs:file write; +allow hal_bluetooth_default system_data_file:file { open read }; +allow hal_bluetooth_default firmware_file:dir search; +allow hal_bluetooth_default ta_data_file:dir search; +allow hal_bluetooth_default ta_data_file:file { open read }; +allow hal_bluetooth_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_camera_default.te b/sepolicy/vendor/hal_camera_default.te new file mode 100644 index 0000000..d487c22 --- /dev/null +++ b/sepolicy/vendor/hal_camera_default.te @@ -0,0 +1,4 @@ +allow hal_camera_default camera_data_file:sock_file write; +allow hal_camera_default hal_configstore_ISurfaceFlingerConfigs:hwservice_manager find; +allow hal_camera_default hal_configstore_default:binder call; +allow hal_camera_default socket_device:sock_file write; diff --git a/sepolicy/vendor/hal_cas_default.te b/sepolicy/vendor/hal_cas_default.te new file mode 100644 index 0000000..d9855aa --- /dev/null +++ b/sepolicy/vendor/hal_cas_default.te @@ -0,0 +1 @@ +allow hal_cas_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_configstore_default.te b/sepolicy/vendor/hal_configstore_default.te new file mode 100644 index 0000000..08a5161 --- /dev/null +++ b/sepolicy/vendor/hal_configstore_default.te @@ -0,0 +1 @@ +allow hal_configstore_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_drm_default.te b/sepolicy/vendor/hal_drm_default.te new file mode 100644 index 0000000..9e8cbf8 --- /dev/null +++ b/sepolicy/vendor/hal_drm_default.te @@ -0,0 +1 @@ +allow hal_drm_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_fingerprint_default.te b/sepolicy/vendor/hal_fingerprint_default.te new file mode 100644 index 0000000..10ecae5 --- /dev/null +++ b/sepolicy/vendor/hal_fingerprint_default.te @@ -0,0 +1,18 @@ +allow hal_fingerprint_default tee_device:chr_file ioctl; +allow hal_fingerprint_default firmware_file:dir search; +allow hal_fingerprint_default sysfs:file write; +allow hal_fingerprint_default tee_device:chr_file { open read write }; +allow hal_fingerprint_default firmware_file:file { getattr open read }; +allow hal_fingerprint_default input_device:chr_file { ioctl open read }; +allow hal_fingerprint_default input_device:dir { open read }; +allow hal_fingerprint_default system_data_file:dir { add_name remove_name write }; +allow hal_fingerprint_default system_data_file:sock_file { create unlink }; +allow hal_fingerprint_default diag_data_file:sock_file write; +allow hal_fingerprint_default fpc_data_file:dir { add_name remove_name write }; +allow hal_fingerprint_default fpc_data_file:sock_file { create unlink }; +allow hal_fingerprint_default init:unix_dgram_socket sendto; +allow hal_fingerprint_default iddd:unix_dgram_socket sendto; +allow hal_fingerprint_default firmware_file:lnk_file read; +allow hal_fingerprint_default fpc_data_file:dir search; +allow hal_fingerprint_default input_device:dir search; +allow hal_fingerprint_default diag_data_file:dir search; diff --git a/sepolicy/vendor/hal_graphics_allocator_default.te b/sepolicy/vendor/hal_graphics_allocator_default.te new file mode 100644 index 0000000..747f5f9 --- /dev/null +++ b/sepolicy/vendor/hal_graphics_allocator_default.te @@ -0,0 +1,2 @@ +allow hal_graphics_allocator_default sysfs_graphics:file { getattr open read }; +allow hal_graphics_allocator_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_keymaster_qti.te b/sepolicy/vendor/hal_keymaster_qti.te new file mode 100644 index 0000000..bdb3e7e --- /dev/null +++ b/sepolicy/vendor/hal_keymaster_qti.te @@ -0,0 +1 @@ +allow hal_keymaster_qti secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_light_default.te b/sepolicy/vendor/hal_light_default.te new file mode 100644 index 0000000..bd66cd3 --- /dev/null +++ b/sepolicy/vendor/hal_light_default.te @@ -0,0 +1,2 @@ +allow hal_light_default secd_exec:file { getattr read }; +allow hal_light_default sysfs:file { open read write }; diff --git a/sepolicy/vendor/hal_lineage_livedisplay_qti.te b/sepolicy/vendor/hal_lineage_livedisplay_qti.te new file mode 100644 index 0000000..3501957 --- /dev/null +++ b/sepolicy/vendor/hal_lineage_livedisplay_qti.te @@ -0,0 +1,2 @@ +allow hal_lineage_livedisplay_qti ppd:unix_stream_socket connectto; +allow hal_lineage_livedisplay_qti secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_lineage_livedisplay_sysfs.te b/sepolicy/vendor/hal_lineage_livedisplay_sysfs.te new file mode 100644 index 0000000..8ffb130 --- /dev/null +++ b/sepolicy/vendor/hal_lineage_livedisplay_sysfs.te @@ -0,0 +1,2 @@ +allow hal_lineage_livedisplay_sysfs ppd:unix_stream_socket connectto; +allow hal_lineage_livedisplay_sysfs secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_lineage_trust_default.te b/sepolicy/vendor/hal_lineage_trust_default.te new file mode 100644 index 0000000..072ed4e --- /dev/null +++ b/sepolicy/vendor/hal_lineage_trust_default.te @@ -0,0 +1 @@ +allow hal_lineage_trust_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_memtrack_default.te b/sepolicy/vendor/hal_memtrack_default.te new file mode 100644 index 0000000..39f4066 --- /dev/null +++ b/sepolicy/vendor/hal_memtrack_default.te @@ -0,0 +1 @@ +allow hal_memtrack_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_power_default.te b/sepolicy/vendor/hal_power_default.te new file mode 100644 index 0000000..ff818ec --- /dev/null +++ b/sepolicy/vendor/hal_power_default.te @@ -0,0 +1,2 @@ +allow hal_power_default sysfs:file { open write }; +allow hal_power_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_ril_default.te b/sepolicy/vendor/hal_ril_default.te new file mode 100644 index 0000000..1614904 --- /dev/null +++ b/sepolicy/vendor/hal_ril_default.te @@ -0,0 +1,6 @@ +type hal_ril_default, domain; +hwbinder_use(hal_ril_default) +vndbinder_use(hal_ril_default) + +type hal_ril_default_exec, exec_type, vendor_file_type, file_type; +init_daemon_domain(hal_ril_default) diff --git a/sepolicy/vendor/hal_ril_wrapper.te b/sepolicy/vendor/hal_ril_wrapper.te new file mode 100644 index 0000000..9c6274d --- /dev/null +++ b/sepolicy/vendor/hal_ril_wrapper.te @@ -0,0 +1,6 @@ +type hal_ril_wrapper, domain; +hwbinder_use(hal_ril_wrapper) +vndbinder_use(hal_ril_wrapper) + +type hal_ril_wrapper_exec, exec_type, vendor_file_type, file_type; +init_daemon_domain(hal_ril_wrapper) diff --git a/sepolicy/vendor/hal_usb_default.te b/sepolicy/vendor/hal_usb_default.te new file mode 100644 index 0000000..a94b4ef --- /dev/null +++ b/sepolicy/vendor/hal_usb_default.te @@ -0,0 +1 @@ +allow hal_usb_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_wifi_default.te b/sepolicy/vendor/hal_wifi_default.te new file mode 100644 index 0000000..11073f7 --- /dev/null +++ b/sepolicy/vendor/hal_wifi_default.te @@ -0,0 +1,7 @@ +allow hal_wifi_default firmware_file:file { open read }; +allow hal_wifi_default sysfs:file write; +allow hal_wifi_default system_data_file:file { open read }; +allow hal_wifi_default ta_data_file:dir search; +allow hal_wifi_default ta_data_file:file { open read }; +allow hal_wifi_default firmware_file:dir search; +allow hal_wifi_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_wifi_supplicant_default.te b/sepolicy/vendor/hal_wifi_supplicant_default.te new file mode 100644 index 0000000..d4683de --- /dev/null +++ b/sepolicy/vendor/hal_wifi_supplicant_default.te @@ -0,0 +1 @@ +allow hal_wifi_supplicant_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/healthd.te b/sepolicy/vendor/healthd.te new file mode 100644 index 0000000..73e96ff --- /dev/null +++ b/sepolicy/vendor/healthd.te @@ -0,0 +1,2 @@ +allow healthd sysfs:file { getattr open read }; +allow healthd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hwservicemanager.te b/sepolicy/vendor/hwservicemanager.te new file mode 100644 index 0000000..c211c11 --- /dev/null +++ b/sepolicy/vendor/hwservicemanager.te @@ -0,0 +1,4 @@ +allow hwservicemanager init:dir search; +allow hwservicemanager init:file { open read }; +allow hwservicemanager init:process getattr; +allow hwservicemanager secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/iddd.te b/sepolicy/vendor/iddd.te new file mode 100644 index 0000000..edf8959 --- /dev/null +++ b/sepolicy/vendor/iddd.te @@ -0,0 +1,20 @@ +# iddd service +type iddd, domain; +type iddd_exec, exec_type, file_type; + +# Started by init +init_daemon_domain(iddd) + +allow iddd diag_data_file:dir { add_name search write }; +allow iddd diag_data_file:file { create lock open read write }; +allow iddd diag_data_file:dir { getattr open read remove_name }; +allow iddd diag_data_file:file { getattr rename unlink }; +allow iddd diag_data_file:sock_file { create setattr }; +allow iddd socket_device:sock_file write; +allow iddd diag_data_file:sock_file unlink; +allow iddd tad:unix_stream_socket connectto; +allow iddd tad_socket:sock_file write; +allow iddd diag_data_file:dir { create rmdir }; +allow iddd diag_data_file:sock_file write; +allow iddd firmware_file:dir search; +allow iddd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/idmap.te b/sepolicy/vendor/idmap.te new file mode 100644 index 0000000..8c5d8a5 --- /dev/null +++ b/sepolicy/vendor/idmap.te @@ -0,0 +1 @@ +allow idmap secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/incidentd.te b/sepolicy/vendor/incidentd.te new file mode 100644 index 0000000..45eadf1 --- /dev/null +++ b/sepolicy/vendor/incidentd.te @@ -0,0 +1 @@ +allow incidentd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/init-power-sh.te b/sepolicy/vendor/init-power-sh.te new file mode 100644 index 0000000..b3f1a59 --- /dev/null +++ b/sepolicy/vendor/init-power-sh.te @@ -0,0 +1,38 @@ +type init-power-sh, domain; +type init-power-sh_exec, exec_type, file_type; + +# Started by init +init_daemon_domain(init-power-sh) + +allow init-power-sh shell_exec:file r_file_perms; +allow init-power-sh sysfs_devices_system_cpu:file w_file_perms; +allow init-power-sh sysfs_performance:dir r_dir_perms; +allow init-power-sh sysfs_performance:file w_file_perms; +allow init-power-sh sysfs_thermal:dir r_dir_perms; +allow init-power-sh sysfs_thermal:file rw_file_perms; +allow init-power-sh proc_kernel_sched:file w_file_perms; +allow init-power-sh sysfs_rqstats:dir read; +allow init-power-sh proc:file write; +allow init-power-sh sysfs_rqstats:dir {r_dir_perms open}; +allow init-power-sh sysfs_rqstats:file r_file_perms; + +# allow labeling of interactive /sys files created post-initial restorecon +allow init-power-sh sysfs:{ dir file lnk_file } relabelfrom; +allow init-power-sh sysfs_devices_system_cpu:{ dir file lnk_file } relabelto; + +# allow writes to sysfs files that have not yet been labeled +allow init-power-sh sysfs:file rw_file_perms; +allow init-power-sh sysfs_usb:file w_file_perms; + +# execute toybox/toolbox +allow init-power-sh toolbox_exec:file rx_file_perms; + +allow init-power-sh sysfs:dir { open read }; +allow init-power-sh sysfs_kgsl:file { open write }; +allow init-power-sh file_contexts_file:file { getattr open read }; +allow init-power-sh sysfs_msm_perf:dir search; +allow init-power-sh sysfs_msm_perf:file { open write }; +allow init-power-sh proc:file open; +allow init-power-sh sysfs_cpu_boost:dir search; +allow init-power-sh sysfs_cpu_boost:file { open write }; +allow init-power-sh secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/init.te b/sepolicy/vendor/init.te new file mode 100644 index 0000000..7bbcfd6 --- /dev/null +++ b/sepolicy/vendor/init.te @@ -0,0 +1,50 @@ +#For sdcard +allow init tmpfs:lnk_file create_file_perms; +allow init proc_kernel_sched:file write; +allow init proc_dirty_ratio:file write; +allow init persist_file:dir mounton; +allow init debugfs:file w_file_perms; + +#TAD +allow init tad_socket:sock_file create; + +#Torch +allow init sysfs_camera_torch:lnk_file read; + +allow init trim_area_partition_device:blk_file { write setattr }; +allow init block_device:blk_file setattr; +allow init socket_device:sock_file { create setattr }; +allow init socket_device:sock_file unlink; +allow init cameraserver:fd use; +allow init diag_data_file:file { lock rename }; +allow init diag_data_file:sock_file write; +allow init ion_device:chr_file ioctl; +allow init property_socket:sock_file write; +allow init rpmb_device:blk_file write; +allow init self:capability2 block_suspend; +allow init self:socket { read write }; +allow init ssd_device:blk_file write; +allow init tad_socket:sock_file write; +allow init tee_device:chr_file { ioctl write }; +allow init video_device:chr_file { ioctl write }; +allow init secd_data_file:file { ioctl lock }; +allow init servicemanager:binder call; +allow init vfat:file { getattr open read }; +allow init proc_interrupts:file getattr; +allow init diag_data_file:dir mounton; +allow init hal_drm_hwservice:hwservice_manager add; +allow init hal_fingerprint_hwservice:hwservice_manager add; +allow init hal_light_hwservice:hwservice_manager add; +allow init hidl_base_hwservice:hwservice_manager add; +allow init hwservicemanager:binder { call transfer }; +allow init iddd:unix_dgram_socket sendto; +allow init ion_device:chr_file { open read }; +allow init proc:file write; +allow init sysfs:file { open read setattr write }; +allow init sysfs_battery_supply:file { open read }; +allow init sysfs_graphics:file { open read write }; +allow init tee_device:chr_file { open read }; +allow init vendor_file:file execute_no_trans; +allow init vndbinder_device:chr_file { ioctl open read write }; +allow init fingerprintd_data_file:file rename; +allow init system_server:binder call; diff --git a/sepolicy/vendor/installd.te b/sepolicy/vendor/installd.te new file mode 100644 index 0000000..974c9d3 --- /dev/null +++ b/sepolicy/vendor/installd.te @@ -0,0 +1,2 @@ +allow installd device:file { open write }; +allow installd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/irsc_util.te b/sepolicy/vendor/irsc_util.te new file mode 100644 index 0000000..48280e0 --- /dev/null +++ b/sepolicy/vendor/irsc_util.te @@ -0,0 +1 @@ +allow irsc_util secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/kernel.te b/sepolicy/vendor/kernel.te new file mode 100644 index 0000000..e650c4c --- /dev/null +++ b/sepolicy/vendor/kernel.te @@ -0,0 +1,6 @@ +allow kernel device:dir create_dir_perms; +allow kernel tmpfs:file create_file_perms; +allow kernel tmpfs:dir create_dir_perms; +allow kernel block_device:blk_file rw_file_perms; +allow kernel touchfusion_exec:file relabelto; +allow kernel self:socket create; diff --git a/sepolicy/vendor/keystore.te b/sepolicy/vendor/keystore.te new file mode 100644 index 0000000..6455c97 --- /dev/null +++ b/sepolicy/vendor/keystore.te @@ -0,0 +1,2 @@ +allow keystore tee_prop:file { getattr open read }; +allow keystore secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/lmkd.te b/sepolicy/vendor/lmkd.te new file mode 100644 index 0000000..1799135 --- /dev/null +++ b/sepolicy/vendor/lmkd.te @@ -0,0 +1 @@ +allow lmkd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/loc_launcher.te b/sepolicy/vendor/loc_launcher.te new file mode 100644 index 0000000..c520f4e --- /dev/null +++ b/sepolicy/vendor/loc_launcher.te @@ -0,0 +1,15 @@ +# loc_launcher service +type loc_launcher, domain; +type loc_launcher_exec, exec_type, file_type; + +init_daemon_domain(loc_launcher) + +allow loc_launcher self:capability setuid; +allow loc_launcher system_data_file:dir { add_name remove_name write }; +allow loc_launcher system_data_file:sock_file { create setattr unlink }; +allow loc_launcher location_data_file:dir { add_name remove_name write }; +allow loc_launcher location_data_file:sock_file { create setattr }; +allow loc_launcher location_socket:sock_file unlink; +allow loc_launcher location_data_file:sock_file unlink; +allow loc_launcher location_data_file:dir search; +allow loc_launcher secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/logd.te b/sepolicy/vendor/logd.te new file mode 100644 index 0000000..93ec406 --- /dev/null +++ b/sepolicy/vendor/logd.te @@ -0,0 +1 @@ +allow logd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediacodec.te b/sepolicy/vendor/mediacodec.te new file mode 100644 index 0000000..0ba5bfe --- /dev/null +++ b/sepolicy/vendor/mediacodec.te @@ -0,0 +1,4 @@ +allow mediacodec mpctl_socket:dir search; +allow mediacodec perfd:unix_stream_socket connectto; +allow mediacodec socket_device:sock_file write; +allow mediacodec secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediadrmserver.te b/sepolicy/vendor/mediadrmserver.te new file mode 100644 index 0000000..316f94f --- /dev/null +++ b/sepolicy/vendor/mediadrmserver.te @@ -0,0 +1 @@ +allow mediadrmserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediaextractor.te b/sepolicy/vendor/mediaextractor.te new file mode 100644 index 0000000..71f9a54 --- /dev/null +++ b/sepolicy/vendor/mediaextractor.te @@ -0,0 +1 @@ +allow mediaextractor secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediametrics.te b/sepolicy/vendor/mediametrics.te new file mode 100644 index 0000000..2dca25e --- /dev/null +++ b/sepolicy/vendor/mediametrics.te @@ -0,0 +1 @@ +allow mediametrics secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediaserver.te b/sepolicy/vendor/mediaserver.te new file mode 100644 index 0000000..f5ee855 --- /dev/null +++ b/sepolicy/vendor/mediaserver.te @@ -0,0 +1,5 @@ +allow mediaserver hal_configstore_ISurfaceFlingerConfigs:hwservice_manager find; +allow mediaserver sensorservice_service:service_manager find; +allow mediaserver sysfs_graphics:file { getattr open read }; +allow mediaserver system_server:unix_stream_socket read; +allow mediaserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediaswcodec.te b/sepolicy/vendor/mediaswcodec.te new file mode 100644 index 0000000..c338257 --- /dev/null +++ b/sepolicy/vendor/mediaswcodec.te @@ -0,0 +1,2 @@ +allow mediaswcodec servicemanager:binder call; +allow mediaswcodec secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mlog_qmi_service.te b/sepolicy/vendor/mlog_qmi_service.te new file mode 100644 index 0000000..3466981 --- /dev/null +++ b/sepolicy/vendor/mlog_qmi_service.te @@ -0,0 +1,15 @@ +# mlog_qmi_service service +type mlog_qmi_service, domain; +type mlog_qmi_service_exec, exec_type, vendor_file_type, file_type; + +# Started by init +init_daemon_domain(mlog_qmi_service) + +# Allow mlog_qmi_service to create self:socket +allow mlog_qmi_service self:socket create_socket_perms; +allow mlog_qmi_service self:socket { create read write }; +allowxperm mlog_qmi_service self:socket ioctl msm_sock_ipc_ioctls; + +# Allow mlog_qmi_service to use net_raw capability +allow mlog_qmi_service self:capability net_raw; +allow mlog_qmi_service secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/msm_irqbalance.te b/sepolicy/vendor/msm_irqbalance.te new file mode 100644 index 0000000..542eae4 --- /dev/null +++ b/sepolicy/vendor/msm_irqbalance.te @@ -0,0 +1,14 @@ +# msm_irqbalance service +type msm_irqbalance, domain; +type msm_irqbalance_exec, exec_type, file_type; + +# Started by init +init_daemon_domain(msm_irqbalance) + +allow msm_irqbalance proc:file { getattr open read write }; +allow msm_irqbalance self:capability dac_override; +allow msm_irqbalance sysfs_devices_system_cpu:file write; +allow msm_irqbalance self:capability { setgid setuid }; +allow msm_irqbalance proc_interrupts:file { getattr open read }; +allow msm_irqbalance proc_stat:file { getattr open read }; +allow msm_irqbalance secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/netd.te b/sepolicy/vendor/netd.te new file mode 100644 index 0000000..7f82d40 --- /dev/null +++ b/sepolicy/vendor/netd.te @@ -0,0 +1,2 @@ +allow netd device:file { open write }; +allow netd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/netmgrd.te b/sepolicy/vendor/netmgrd.te new file mode 100644 index 0000000..54aa1fa --- /dev/null +++ b/sepolicy/vendor/netmgrd.te @@ -0,0 +1,4 @@ +allow netmgrd self:capability dac_override; +allow netmgrd toolbox_exec:file { execute execute_no_trans getattr open read }; +allow netmgrd net_data_file:dir read; +allow netmgrd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/per_mgr.te b/sepolicy/vendor/per_mgr.te new file mode 100644 index 0000000..832dd28 --- /dev/null +++ b/sepolicy/vendor/per_mgr.te @@ -0,0 +1,7 @@ +allow per_mgr per_mgr_service:service_manager add; +allow per_mgr subsys_modem_device:chr_file r_file_perms; +allow per_mgr self:capability net_raw; +allow per_mgr self:socket create_socket_perms; +allowxperm per_mgr self:socket ioctl msm_sock_ipc_ioctls; +allow per_mgr per_proxy:binder call; +allow per_mgr secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/per_proxy.te b/sepolicy/vendor/per_proxy.te new file mode 100644 index 0000000..9be5831 --- /dev/null +++ b/sepolicy/vendor/per_proxy.te @@ -0,0 +1,14 @@ +# per_proxy service +type per_proxy, domain; +type per_proxy_exec, exec_type, file_type; + +# Started by init +init_daemon_domain(per_proxy) + +allow per_proxy default_android_service:service_manager find; +allow per_proxy per_mgr:binder call; +allow per_proxy servicemanager:binder call; +allow per_proxy sysfs:file { open read }; +allow per_proxy per_mgr:binder transfer; +allow per_proxy binder_per_mgr_service:service_manager find; +allow per_proxy secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/perfd.te b/sepolicy/vendor/perfd.te new file mode 100644 index 0000000..20670cb --- /dev/null +++ b/sepolicy/vendor/perfd.te @@ -0,0 +1,3 @@ +allow perfd sysfs_memory:dir search; +allow perfd sysfs_memory:file { open read write }; +allow perfd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/platform_app.te b/sepolicy/vendor/platform_app.te new file mode 100644 index 0000000..d7fa3af --- /dev/null +++ b/sepolicy/vendor/platform_app.te @@ -0,0 +1 @@ +allow platform_app system_app_data_file:dir getattr; diff --git a/sepolicy/vendor/ppd.te b/sepolicy/vendor/ppd.te new file mode 100644 index 0000000..eed967b --- /dev/null +++ b/sepolicy/vendor/ppd.te @@ -0,0 +1,23 @@ +# ppd service +type ppd, domain; +type ppd_exec, exec_type, file_type; + +# Started by init +init_daemon_domain(ppd) + +allow ppd ion_device:chr_file write; +set_prop(ppd, display_prop); +allow ppd system_prop:property_service set; +allow ppd diag_device:chr_file { ioctl open read write }; +allow ppd graphics_device:chr_file { ioctl open read write }; +allow ppd ion_device:chr_file { open read }; +allow ppd persist_display_file:dir search; +allow ppd postprocessing_prop:file { getattr open read }; +allow ppd postprocessing_prop:property_service set; +allow ppd sysfs_graphics:dir search; +allow ppd sysfs_graphics:file { getattr open read write }; +allow ppd sysfs_leds:dir search; +allow ppd graphics_device:dir search; +allow ppd persist_file:dir search; +allow ppd display_vendor_data_file:dir search; +allow ppd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/priv_app.te b/sepolicy/vendor/priv_app.te new file mode 100644 index 0000000..d87000e --- /dev/null +++ b/sepolicy/vendor/priv_app.te @@ -0,0 +1,7 @@ +allow priv_app device:dir open; +allow priv_app proc_interrupts:file open; +allow priv_app alarm_boot_prop:file open; +allow priv_app alarm_instance_prop:file getattr; +allow priv_app proc:file open; +allow priv_app sysfs_android_usb:file open; +allow priv_app secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/property.te b/sepolicy/vendor/property.te new file mode 100644 index 0000000..1bd735a --- /dev/null +++ b/sepolicy/vendor/property.te @@ -0,0 +1,4 @@ +type timekeep_prop, property_type; +type tee_prop, property_type; +type ta_prop, property_type; +type display_prop, property_type; diff --git a/sepolicy/vendor/qcamerasvr.te b/sepolicy/vendor/qcamerasvr.te new file mode 100644 index 0000000..7f84e40 --- /dev/null +++ b/sepolicy/vendor/qcamerasvr.te @@ -0,0 +1,23 @@ +# qcamerasvr service +type qcamerasvr, domain; +type qcamerasvr_exec, exec_type, file_type; + +# Started by init +init_daemon_domain(qcamerasvr) + +allow qcamerasvr camera_data_file:dir { add_name remove_name write }; +allow qcamerasvr camera_data_file:sock_file { create unlink }; +allow qcamerasvr hal_camera_default:fd use; +allow qcamerasvr ion_device:chr_file { open read ioctl }; +allow qcamerasvr mediaserver:fd use; +allow qcamerasvr sysfs:file { open read write }; +allow qcamerasvr video_device:chr_file { ioctl open read write }; +allow qcamerasvr camera_prop:file { getattr open read }; +allow qcamerasvr cameraserver:fd use; +allow qcamerasvr camera_data_file:dir search; +allow qcamerasvr camera_socket:sock_file unlink; +allow qcamerasvr sysfs_graphics:file { open read }; +allow qcamerasvr ta_data_file:dir search; +allow qcamerasvr secd_exec:file { getattr read }; +allow qcamerasvr vendor_camera_data_file:dir { add_name remove_name write }; +allow qcamerasvr vendor_camera_data_file:sock_file { create unlink }; diff --git a/sepolicy/vendor/qmuxd.te b/sepolicy/vendor/qmuxd.te new file mode 100644 index 0000000..f2fcafb --- /dev/null +++ b/sepolicy/vendor/qmuxd.te @@ -0,0 +1,3 @@ +allow qmuxd diag_device:chr_file { ioctl open read write }; +allow qmuxd sysfs:file read; +allow qmuxd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/radio.te b/sepolicy/vendor/radio.te new file mode 100644 index 0000000..35ae984 --- /dev/null +++ b/sepolicy/vendor/radio.te @@ -0,0 +1,2 @@ +allow radio gpuservice:binder call; +allow radio system_app_data_file:dir getattr; diff --git a/sepolicy/vendor/recovery_persist.te b/sepolicy/vendor/recovery_persist.te new file mode 100644 index 0000000..18809a7 --- /dev/null +++ b/sepolicy/vendor/recovery_persist.te @@ -0,0 +1 @@ +allow recovery_persist secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/rild.te b/sepolicy/vendor/rild.te new file mode 100644 index 0000000..e3f441c --- /dev/null +++ b/sepolicy/vendor/rild.te @@ -0,0 +1,25 @@ +allow rild cache_file:dir { rw_file_perms remove_name }; +allow rild cache_file:file { r_file_perms unlink }; +allow rild tad_socket:sock_file write; +allow rild tee_device:chr_file { read write open ioctl}; +allow rild radio_data_file:file { getattr lock open read write }; +allow rild default_android_service:service_manager find; +allow rild radio_data_file:dir { add_name getattr open read remove_name write }; +allow rild radio_data_file:file { create ioctl setattr unlink }; +allow rild self:capability dac_override; +allow rild servicemanager:binder call; +allow rild tee_device:chr_file { open read write }; +allow rild firmware_file:file { getattr open read }; +allow rild ion_device:chr_file { ioctl open read }; +allow rild self:capability sys_module; +allow rild socket_device:sock_file write; +allow rild tee_device:chr_file ioctl; +allow rild audioserver_service:service_manager find; +allow rild self:capability chown; +allow rild radio_data_file:dir search; +allow rild vendor_file:file ioctl; +allow rild tad:unix_stream_socket connectto; +allow rild cache_file:dir search; +allow rild firmware_file:dir search; +allow rild device:file { open write }; +allow rild secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/rmt_storage.te b/sepolicy/vendor/rmt_storage.te new file mode 100644 index 0000000..58b7f41 --- /dev/null +++ b/sepolicy/vendor/rmt_storage.te @@ -0,0 +1 @@ +allow rmt_storage secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/sct_service.te b/sepolicy/vendor/sct_service.te new file mode 100644 index 0000000..acbdfde --- /dev/null +++ b/sepolicy/vendor/sct_service.te @@ -0,0 +1,15 @@ +# sct_service service +type sct_service, domain; +type sct_service_exec, exec_type, file_type; + +# Started by init +init_daemon_domain(sct_service) + +# Allow sct_service to use net_raw capability +allow sct_service self:capability net_raw; + +# Allow sct_service to create self:socket +allow sct_service self:socket create_socket_perms; +allow sct_service self:socket { create read write }; +allowxperm sct_service self:socket ioctl msm_sock_ipc_ioctls; +allow sct_service secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/sdcardd.te b/sepolicy/vendor/sdcardd.te new file mode 100644 index 0000000..68c2942 --- /dev/null +++ b/sepolicy/vendor/sdcardd.te @@ -0,0 +1 @@ +allow sdcardd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/secd.te b/sepolicy/vendor/secd.te new file mode 100644 index 0000000..fcc65e8 --- /dev/null +++ b/sepolicy/vendor/secd.te @@ -0,0 +1,22 @@ +# secd service +type secd, domain; +type secd_exec, exec_type, file_type; + +# Started by init +init_daemon_domain(secd) + +allow secd tad:unix_stream_socket connectto; +allow secd tad_socket:sock_file write; +allow secd tee_device:chr_file { ioctl open read write }; +allow secd secd_data_file:file { lock open write create getattr read setattr unlink }; +allow secd secd_data_file:dir { rw_file_perms add_name remove_name search }; +allow secd diag_partition_device:dir search; +allow secd diag_data_file:dir search; +allow secd diag_data_file:sock_file write; +allow secd firmware_file:dir search; +allow secd firmware_file:file { getattr open read }; +allow secd iddd:unix_dgram_socket sendto; +allow secd ion_device:chr_file { ioctl open read }; +allow secd socket_device:sock_file write; +allow secd tee_device:chr_file { ioctl open read write }; +allow secd secd_data_file:file ioctl; diff --git a/sepolicy/vendor/sensors.te b/sepolicy/vendor/sensors.te new file mode 100644 index 0000000..99094dc --- /dev/null +++ b/sepolicy/vendor/sensors.te @@ -0,0 +1,7 @@ +allow sensors device:dir { write add_name }; +allow sensors input_device:chr_file { relabelfrom getattr link }; +allow sensors input_device:dir search; +allow sensors tmpfs:file rw_file_perms; +allow sensors tad_socket:sock_file { write }; +allow sensors sysfs:file { open read }; +allow sensors secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/service.te b/sepolicy/vendor/service.te new file mode 100644 index 0000000..5b53ee5 --- /dev/null +++ b/sepolicy/vendor/service.te @@ -0,0 +1 @@ +type timekeep_service, service_manager_type; diff --git a/sepolicy/vendor/servicemanager.te b/sepolicy/vendor/servicemanager.te new file mode 100644 index 0000000..75da12d --- /dev/null +++ b/sepolicy/vendor/servicemanager.te @@ -0,0 +1,10 @@ +allow servicemanager init:dir search; +allow servicemanager init:file { open read }; +allow servicemanager init:process getattr; +allow servicemanager per_proxy:dir search; +allow servicemanager per_proxy:file { open read }; +allow servicemanager per_proxy:process getattr; +allow servicemanager mediaswcodec:dir search; +allow servicemanager mediaswcodec:file { open read }; +allow servicemanager mediaswcodec:process getattr; +allow servicemanager secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/shell.te b/sepolicy/vendor/shell.te new file mode 100644 index 0000000..904da06 --- /dev/null +++ b/sepolicy/vendor/shell.te @@ -0,0 +1,109 @@ +allow shell alarm_boot_prop:file { getattr open }; +allow shell alarm_handled_prop:file { getattr open }; +allow shell alarm_instance_prop:file { getattr open }; +allow shell apexd_prop:file { getattr open }; +allow shell bg_boot_complete_prop:file { getattr open }; +allow shell bg_daemon_prop:file { getattr open }; +allow shell bluetooth_prop:file { getattr open }; +allow shell boot_animation_prop:file { getattr open }; +allow shell boot_mode_prop:file { getattr open }; +allow shell boottime_prop:file { getattr open }; +allow shell bpf_progs_loaded_prop:file { getattr open }; +allow shell coresight_prop:file { getattr open }; +allow shell crash_prop:file { getattr open }; +allow shell ctl_LKCore_prop:file { getattr open }; +allow shell ctl_adbd_prop:file { getattr open }; +allow shell ctl_bootanim_prop:file { getattr open read }; +allow shell ctl_console_prop:file { getattr open }; +allow shell ctl_default_prop:file { getattr open }; +allow shell ctl_fuse_prop:file { getattr open }; +allow shell ctl_hbtp_prop:file { getattr open }; +allow shell ctl_interface_restart_prop:file { getattr open }; +allow shell ctl_interface_start_prop:file { getattr open }; +allow shell ctl_interface_stop_prop:file { getattr open }; +allow shell ctl_mdnsd_prop:file { getattr open }; +allow shell ctl_netmgrd_prop:file { getattr open }; +allow shell ctl_port-bridge_prop:file { getattr open }; +allow shell ctl_qmuxd_prop:file { getattr open }; +allow shell ctl_restart_prop:file { getattr open }; +allow shell ctl_rildaemon_prop:file { getattr open }; +allow shell ctl_sigstop_prop:file { getattr open }; +allow shell ctl_start_prop:file { getattr open }; +allow shell ctl_stop_prop:file { getattr open }; +allow shell ctl_vendor_imsrcsservice_prop:file { getattr open }; +allow shell ctl_vendor_wigigsvc_prop:file { getattr open }; +allow shell device_config_activity_manager_native_boot_prop:file { getattr open }; +allow shell device_config_boot_count_prop:file { getattr open }; +allow shell device_config_input_native_boot_prop:file { getattr open }; +allow shell device_config_media_native_prop:file { getattr open }; +allow shell device_config_netd_native_prop:file { getattr open }; +allow shell device_config_reset_performed_prop:file { getattr open }; +allow shell device_config_runtime_native_boot_prop:file { getattr open }; +allow shell device_config_runtime_native_prop:file { getattr open }; +allow shell diag_mdlog_prop:file { getattr open }; +allow shell dolby_prop:file { getattr open }; +allow shell dumpstate_options_prop:file { getattr open }; +allow shell firstboot_prop:file { getattr open }; +allow shell fm_prop:file { getattr open }; +allow shell freq_prop:file { getattr open }; +allow shell fst_prop:file { getattr open }; +allow shell gamed_prop:file { getattr open }; +allow shell gsid_prop:file { getattr open }; +allow shell ipacm-diag_prop:file { getattr open }; +allow shell ipacm_prop:file { getattr open }; +allow shell llkd_prop:file { getattr open }; +allow shell location_prop:file { getattr open }; +allow shell lowpan_prop:file { getattr open }; +allow shell mdm_helper_prop:file { getattr open }; +allow shell mmc_prop:file { getattr open }; +allow shell mmi_prop:file { getattr open }; +allow shell mpdecision_prop:file { getattr open }; +allow shell msm_irqbalance_prop:file { getattr open }; +allow shell msm_irqbl_sdm630_prop:file { getattr open }; +allow shell net_dns_prop:file { getattr open }; +allow shell netd_prop:file { getattr open }; +allow shell netd_stable_secret_prop:file { getattr open }; +allow shell nfc_nq_prop:file { getattr open }; +allow shell opengles_prop:file { getattr open }; +allow shell overlay_prop:file { getattr open }; +allow shell per_mgr_state_prop:file { getattr open }; +allow shell perfd_prop:file { getattr open }; +allow shell persistent_properties_ready_prop:file { getattr open }; +allow shell postprocessing_prop:file { getattr open }; +allow shell ppd_prop:file { getattr open }; +allow shell qcom_ims_prop:file { getattr open }; +allow shell qdma_prop:file { getattr open }; +allow shell qemu_gles_prop:file { getattr open }; +allow shell qti_prop:file { getattr open }; +allow shell rmnet_mux_prop:file { getattr open }; +allow shell safemode_prop:file { getattr open }; +allow shell scr_enabled_prop:file { getattr open }; +allow shell sdm_idle_time_prop:file { getattr open }; +allow shell secd_exec:file { getattr read }; +allow shell sensors_prop:file { getattr open }; +allow shell spcomlib_prop:file { getattr open }; +allow shell sys_usb_configfs_prop:file { getattr open }; +allow shell sys_usb_controller_prop:file { getattr open }; +allow shell sys_usb_tethering_prop:file { getattr open }; +allow shell system_lmk_prop:file { getattr open }; +allow shell system_trace_prop:file { getattr open }; +allow shell ta_prop:file { getattr open }; +allow shell tee_prop:file { getattr open }; +allow shell test_boot_reason_prop:file { getattr open }; +allow shell theme_prop:file { getattr open }; +allow shell time_prop:file { getattr open }; +allow shell timekeep_prop:file { getattr open }; +allow shell traced_lazy_prop:file { getattr open }; +allow shell uicc_prop:file { getattr open }; +allow shell usf_prop:file { getattr open }; +allow shell vendor_mpctl_prop:file { getattr open }; +allow shell vendor_rild_libpath_prop:file { getattr open }; +allow shell vendor_system_prop:file { getattr open }; +allow shell vendor_wifi_prop:file { getattr open }; +allow shell vendor_wifi_version:file { getattr open }; +allow shell vm_bms_prop:file { getattr open }; +allow shell wifi_prop:file { getattr open }; +allow shell wififtmd_prop:file { getattr open }; +allow shell wigig_prop:file { getattr open }; +allow shell xlat_prop:file { getattr open }; +allow shell secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/statsd.te b/sepolicy/vendor/statsd.te new file mode 100644 index 0000000..990f691 --- /dev/null +++ b/sepolicy/vendor/statsd.te @@ -0,0 +1 @@ +allow statsd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/surfaceflinger.te b/sepolicy/vendor/surfaceflinger.te new file mode 100644 index 0000000..96ddacc --- /dev/null +++ b/sepolicy/vendor/surfaceflinger.te @@ -0,0 +1,4 @@ +allow surfaceflinger perfd:unix_stream_socket connectto; +allow surfaceflinger socket_device:sock_file write; +allow surfaceflinger default_android_service:service_manager { add find }; +allow surfaceflinger secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/system_app.te b/sepolicy/vendor/system_app.te new file mode 100644 index 0000000..b01135d --- /dev/null +++ b/sepolicy/vendor/system_app.te @@ -0,0 +1,12 @@ +allow system_app time_data_file:dir search; +allow system_app timekeep_data_file:file { getattr open write }; +allow system_app timekeep_prop:file { getattr open }; +allow system_app timekeep_prop:property_service set; +allow system_app timekeep_prop:file read; +allow system_app sysfs_rtc:dir search; +allow system_app time_data_file:file { getattr open write }; +allow system_app vendor_default_prop:property_service set; +allow system_app apex_service:service_manager find; +allow system_app proc_pagetypeinfo:file read; +allow system_app sysfs_zram:dir search; +allow system_app system_suspend_control_service:service_manager find; diff --git a/sepolicy/vendor/system_server.te b/sepolicy/vendor/system_server.te new file mode 100644 index 0000000..ea19fed --- /dev/null +++ b/sepolicy/vendor/system_server.te @@ -0,0 +1,16 @@ +allow system_server ppd:unix_stream_socket connectto; +allow system_server pps_socket:sock_file write; +allow system_server self:capability sys_module; +allow system_server system_app_data_file:dir r_dir_perms; +allow system_server ta_data_file:dir search; +allow system_server ta_data_file:file r_file_perms; +allow system_server persist_file:dir rw_file_perms; +allow system_server perfd:unix_stream_socket connectto; +allow system_server socket_device:sock_file write; +allow system_server sensors:unix_stream_socket connectto; +allow system_server sensors_device:chr_file getattr; +allow system_server sensors_socket:sock_file write; +allow system_server unlabeled:file unlink; +allow system_server default_android_service:service_manager find; +allow system_server init:binder { call transfer }; +allow system_server exfat:dir rw_dir_perms; diff --git a/sepolicy/vendor/ta_qmi_service.te b/sepolicy/vendor/ta_qmi_service.te new file mode 100644 index 0000000..b39f3b0 --- /dev/null +++ b/sepolicy/vendor/ta_qmi_service.te @@ -0,0 +1,24 @@ +# ta_qmi_service service +type ta_qmi_service, domain; +type ta_qmi_service_exec, exec_type, vendor_file_type, file_type; + +# Started by init +init_daemon_domain(ta_qmi_service) + +# Allow ta_qmi_service to access tad +unix_socket_connect(ta_qmi_service, tad, tad) + +# Allow ta_qmi_service to use net_raw, setgid and setuid capabilities +allow ta_qmi_service self:capability { net_raw setgid setuid }; + +# Allow ta_qmi_service to create self:socket +allow ta_qmi_service self:socket create_socket_perms; +allow ta_qmi_service self:socket { create read write }; +allowxperm ta_qmi_service self:socket ioctl msm_sock_ipc_ioctls; + +allow ta_qmi_service self:capability2 block_suspend; +allow ta_qmi_service socket_device:sock_file write; +allow ta_qmi_service sysfs_wake_lock:file { append open }; +allow ta_qmi_service tad:unix_stream_socket connectto; +allow ta_qmi_service tad_socket:sock_file write; +allow ta_qmi_service secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/tad.te b/sepolicy/vendor/tad.te new file mode 100644 index 0000000..383a182 --- /dev/null +++ b/sepolicy/vendor/tad.te @@ -0,0 +1,14 @@ +type tad, domain; +type tad_exec, exec_type, file_type; +type_transition tad socket_device:sock_file tad_socket "tad"; + +# Started by init +init_daemon_domain(tad) + +# Read /proc/stat +allow tad proc:file r_file_perms; + +# Allow tad to work it's magic +allow tad trim_area_partition_device:blk_file { ioctl rw_file_perms }; +allow tad block_device:dir search; +allow tad tmpfs:file rw_file_perms; diff --git a/sepolicy/vendor/taimport.te b/sepolicy/vendor/taimport.te new file mode 100644 index 0000000..339c4f6 --- /dev/null +++ b/sepolicy/vendor/taimport.te @@ -0,0 +1,15 @@ +# taimport service +type taimport, domain; +type taimport_exec, exec_type, file_type; + +# Started by init +init_daemon_domain(taimport) + +allow taimport tad_socket:sock_file { write }; +allow taimport ta_data_file:dir { read search write add_name create remove_name }; +allow taimport ta_data_file:file { read write create getattr open unlink}; +allow taimport self:capability { dac_override setgid }; +allow taimport socket_device:sock_file write; +allow taimport system_data_file:dir { add_name remove_name write }; +allow taimport init:unix_stream_socket connectto; +allow taimport secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/tee.te b/sepolicy/vendor/tee.te new file mode 100644 index 0000000..683afe1 --- /dev/null +++ b/sepolicy/vendor/tee.te @@ -0,0 +1,28 @@ +# tee starts as root, and drops privileges +allow tee self:capability { + setuid + setgid +}; + +# allow tee to load firmware images +r_dir_file(tee, firmware_file) + +binder_use(tee) + +# Provide tee ability to access QMUXD/IPCRouter for QMI +qmux_socket(tee); + +set_prop(tee, tee_prop) + +# Need to directly manipulate certain block devices +# for anti-rollback protection +allow tee block_device:dir r_dir_perms; +allow tee rpmb_device:blk_file rw_file_perms; + +# Provide tee access to ssd partition for HW FDE +allow tee ssd_device:blk_file rw_file_perms; + +allow tee system_data_file:dir r_dir_perms; +allow tee vfat:file { getattr open read }; +allow tee vfat:dir search; +allow tee secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/thermal-engine.te b/sepolicy/vendor/thermal-engine.te new file mode 100644 index 0000000..46f80fc --- /dev/null +++ b/sepolicy/vendor/thermal-engine.te @@ -0,0 +1,9 @@ +allow thermal-engine ta_data_file:dir search; +allow thermal-engine ta_data_file:file r_file_perms; +allow thermal-engine diag_partition_device:dir search; +allow thermal-engine diag_data_file:dir search; +allow thermal-engine diag_data_file:sock_file write; +allow thermal-engine socket_device:sock_file { create setattr }; +allow thermal-engine init:unix_dgram_socket sendto; +allow thermal-engine iddd:unix_dgram_socket sendto; +allow thermal-engine secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/timekeep.te b/sepolicy/vendor/timekeep.te new file mode 100644 index 0000000..3a6874c --- /dev/null +++ b/sepolicy/vendor/timekeep.te @@ -0,0 +1,25 @@ +# timekeep service +type timekeep, domain; +type timekeep_exec, exec_type, file_type; + +# Started by init +init_daemon_domain(timekeep) + +set_prop(timekeep, timekeep_prop) + +r_dir_file(timekeep, sysfs_timekeep) + +allow timekeep self:capability { + fowner + fsetid + sys_time + dac_override + dac_read_search +}; +allow timekeep timekeep_data_file:file create_file_perms; +allow timekeep timekeep_data_file:dir { create_dir_perms search }; +allow timekeep time_data_file:dir { create_dir_perms search }; +allow timekeep time_data_file:file { write open getattr setattr }; +allow timekeep sysfs:file {read open }; +allow timekeep sysfs_rtc:dir search; +allow timekeep secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/tombstoned.te b/sepolicy/vendor/tombstoned.te new file mode 100644 index 0000000..cc69697 --- /dev/null +++ b/sepolicy/vendor/tombstoned.te @@ -0,0 +1 @@ +allow tombstoned secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/toolbox.te b/sepolicy/vendor/toolbox.te new file mode 100644 index 0000000..a593ea5 --- /dev/null +++ b/sepolicy/vendor/toolbox.te @@ -0,0 +1,6 @@ +allow toolbox diag_data_file:dir { getattr open read remove_name rmdir write }; +allow toolbox self:capability dac_override; +allow toolbox diag_data_file:dir search; +allow toolbox firmware_file:dir { open read rmdir write }; +allow toolbox firmware_file:dir search; +allow toolbox secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/tzdatacheck.te b/sepolicy/vendor/tzdatacheck.te new file mode 100644 index 0000000..315ff85 --- /dev/null +++ b/sepolicy/vendor/tzdatacheck.te @@ -0,0 +1 @@ +allow tzdatacheck secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/ueventd.te b/sepolicy/vendor/ueventd.te new file mode 100644 index 0000000..29c49eb --- /dev/null +++ b/sepolicy/vendor/ueventd.te @@ -0,0 +1,9 @@ +# Allow firmware_file access to load Non-HLOS images +r_dir_file(ueventd, firmware_file) + +allow ueventd device:file relabelfrom; +allow ueventd sysfs_camera_torch:file { open write }; +allow ueventd vfat:dir search; +allow ueventd vfat:file { getattr open read }; +allow ueventd self:capability sys_nice; +allow ueventd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/updatemiscta.te b/sepolicy/vendor/updatemiscta.te new file mode 100644 index 0000000..2ef7cb7 --- /dev/null +++ b/sepolicy/vendor/updatemiscta.te @@ -0,0 +1,14 @@ +# updatemiscta service +type updatemiscta, domain; +type updatemiscta_exec, exec_type, file_type; + +# Started by init +init_daemon_domain(updatemiscta) + +unix_socket_connect(taimport, tad, tad) + +allow updatemiscta socket_device:sock_file write; +allow updatemiscta tad:unix_stream_socket connectto; +allow updatemiscta ta_prop:file { getattr open read }; +allow updatemiscta tad_socket:sock_file write; +allow updatemiscta secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/usbd.te b/sepolicy/vendor/usbd.te new file mode 100644 index 0000000..5aacbbb --- /dev/null +++ b/sepolicy/vendor/usbd.te @@ -0,0 +1 @@ +allow usbd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vdc.te b/sepolicy/vendor/vdc.te new file mode 100644 index 0000000..8aea92e --- /dev/null +++ b/sepolicy/vendor/vdc.te @@ -0,0 +1 @@ +allow vdc secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vendor_init.te b/sepolicy/vendor/vendor_init.te new file mode 100644 index 0000000..8e95520 --- /dev/null +++ b/sepolicy/vendor/vendor_init.te @@ -0,0 +1 @@ +allow vendor_init secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vndservicemanager.te b/sepolicy/vendor/vndservicemanager.te new file mode 100644 index 0000000..533f601 --- /dev/null +++ b/sepolicy/vendor/vndservicemanager.te @@ -0,0 +1 @@ +allow vndservicemanager secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vold.te b/sepolicy/vendor/vold.te new file mode 100644 index 0000000..755eff5 --- /dev/null +++ b/sepolicy/vendor/vold.te @@ -0,0 +1,5 @@ +allow vold diag_data_file:dir { read open ioctl }; +allow vold firmware_file:dir search; +allow vold firmware_file:file { getattr open read }; +allow vold secd_exec:file { getattr read }; +allow vold tee_prop:file { r_file_perms }; diff --git a/sepolicy/vendor/vold_prepare_subdirs.te b/sepolicy/vendor/vold_prepare_subdirs.te new file mode 100644 index 0000000..e4c4bb4 --- /dev/null +++ b/sepolicy/vendor/vold_prepare_subdirs.te @@ -0,0 +1 @@ +allow vold_prepare_subdirs secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/wificond.te b/sepolicy/vendor/wificond.te new file mode 100644 index 0000000..73ca465 --- /dev/null +++ b/sepolicy/vendor/wificond.te @@ -0,0 +1 @@ +allow wificond secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/zygote.te b/sepolicy/vendor/zygote.te new file mode 100644 index 0000000..850d576 --- /dev/null +++ b/sepolicy/vendor/zygote.te @@ -0,0 +1,3 @@ +allow zygote proc_cmdline:file { getattr open read }; +allow zygote secd_exec:file { getattr read }; +allow zygote device:file rw_file_perms; -- GitLab From 9ea5fd3be2d9797053de0b5fc54bfa8db522f785 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Fri, 18 Sep 2020 13:10:00 +0200 Subject: [PATCH 047/191] kitakami-common: Remove usb entry from manifest - This is now a vintf fragment Change-Id: I45b9dfd468c690c257b7ef726d850bc405abf2bc --- manifest.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/manifest.xml b/manifest.xml index 5504d44..e071d0c 100644 --- a/manifest.xml +++ b/manifest.xml @@ -198,15 +198,6 @@ default - - android.hardware.usb - hwbinder - 1.0 - - IUsb - default - - android.hardware.vibrator passthrough -- GitLab From a8237ad58c9a96bd861663d3f71a4e8f61f39e1f Mon Sep 17 00:00:00 2001 From: Jan Altensen Date: Sat, 17 Oct 2020 18:25:12 +0200 Subject: [PATCH 048/191] kitakami-common: enable TARGET_HAS_MEMFD_BACKPORT Change-Id: I3f729908f822567ff874cf909341c319e2955470 --- BoardConfigCommon.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 6210e2d..e1dc81f 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -173,6 +173,9 @@ TARGET_NO_RPC := true # Keymaster TARGET_PROVIDES_KEYMASTER := true +# memfd +TARGET_HAS_MEMFD_BACKPORT := true + # NFC NFC_NXP_CHIP_TYPE := PN547C2 BOARD_NFC_CHIPSET := pn547 -- GitLab From 75d3aac85b5648744b7581c3fa797752530ab974 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Thu, 29 Oct 2020 10:19:58 +0800 Subject: [PATCH 049/191] kitakami-common: sepolicy: Update policies for R Change-Id: Iff1da880aeda9a6c68769b413f48a7afc8194be1 --- sepolicy/vendor/charger.te | 2 ++ sepolicy/vendor/clatd.te | 3 +++ sepolicy/vendor/file_contexts | 5 ++++- sepolicy/vendor/hal_dumpstate_impl.te | 9 +++++++++ sepolicy/vendor/hal_power_service.te | 3 +++ sepolicy/vendor/servicemanager.te | 3 +++ sepolicy/vendor/tee.te | 1 + 7 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 sepolicy/vendor/hal_dumpstate_impl.te create mode 100644 sepolicy/vendor/hal_power_service.te diff --git a/sepolicy/vendor/charger.te b/sepolicy/vendor/charger.te index 76c42b1..b07eeee 100644 --- a/sepolicy/vendor/charger.te +++ b/sepolicy/vendor/charger.te @@ -3,3 +3,5 @@ allow charger sysfs:file { open read getattr }; allow charger sysfs_usb_supply:file { open read getattr }; allow charger sysfs_battery_supply:file { open read getattr }; allow charger device:dir { open read }; +allow charger persist_block_device:file { create rw_file_perms }; +allow charger system_file:file { entrypoint read execute getattr }; diff --git a/sepolicy/vendor/clatd.te b/sepolicy/vendor/clatd.te index 03c2def..c99aad7 100644 --- a/sepolicy/vendor/clatd.te +++ b/sepolicy/vendor/clatd.te @@ -1 +1,4 @@ +type clatd, domain; +type clatd_exec, exec_type, file_type; + allow clatd system_file:file lock; diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 0493907..0f699b6 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -23,7 +23,7 @@ /sys/devices(/soc\.0)?/pmi8994-flash-27(/.*)? u:object_r:sysfs_camera_torch:s0 # Dumpstate HAL -/vendor/bin/hw/android\.hardware\.dumpstate@1\.1-service\.kitakami u:object_r:hal_dumpstate_impl_exec:s0 +/(vendor|system/vendor)/bin/hw/android\.hardware\.dumpstate@1\.1-service-kitakami u:object_r:hal_dumpstate_impl_exec:s0 # HCI /dev/ttyHS0 u:object_r:hci_attach_dev:s0 @@ -50,6 +50,9 @@ /idd(/.*)? u:object_r:diag_data_file:s0 /rca(/.*)? u:object_r:firmware_file:s0 +# Power Stats +/(vendor|system/vendor)/bin/hw/android\.hardware\.power\.stats@1\.0-service\.mock u:object_r:hal_power_stats_default_exec:s0 + # TimeKeep /data/time(/.*) u:object_r:timekeep_data_file:s0 diff --git a/sepolicy/vendor/hal_dumpstate_impl.te b/sepolicy/vendor/hal_dumpstate_impl.te new file mode 100644 index 0000000..10db39e --- /dev/null +++ b/sepolicy/vendor/hal_dumpstate_impl.te @@ -0,0 +1,9 @@ +type hal_dumpstate_impl, domain; +type hal_dumpstate_impl_exec, exec_type, file_type, vendor_file_type; + +init_daemon_domain(hal_dumpstate_impl) + +allow hal_dumpstate_impl hal_dumpstate_impl_exec:file execute_no_trans; +allow hal_dumpstate_impl hwservicemanager:binder { call transfer }; +allow hal_dumpstate_impl hwservicemanager_prop:file { getattr map open read }; +allow hal_dumpstate_impl hidl_base_hwservice:hwservice_manager add; diff --git a/sepolicy/vendor/hal_power_service.te b/sepolicy/vendor/hal_power_service.te new file mode 100644 index 0000000..da6262b --- /dev/null +++ b/sepolicy/vendor/hal_power_service.te @@ -0,0 +1,3 @@ +binder_call(hal_power_service, servicemanager) +allow servicemanager hal_power_service:file { rw_file_perms }; +allow servicemanager hal_power_service:dir { rw_dir_perms }; diff --git a/sepolicy/vendor/servicemanager.te b/sepolicy/vendor/servicemanager.te index 75da12d..20da122 100644 --- a/sepolicy/vendor/servicemanager.te +++ b/sepolicy/vendor/servicemanager.te @@ -8,3 +8,6 @@ allow servicemanager mediaswcodec:dir search; allow servicemanager mediaswcodec:file { open read }; allow servicemanager mediaswcodec:process getattr; allow servicemanager secd_exec:file { getattr read }; +allow servicemanager hal_power_default:dir { rw_dir_perms }; +allow servicemanager hal_power_default:file { rw_file_perms }; +allow servicemanager hal_power_default:process { getattr }; diff --git a/sepolicy/vendor/tee.te b/sepolicy/vendor/tee.te index 683afe1..3b5d8e0 100644 --- a/sepolicy/vendor/tee.te +++ b/sepolicy/vendor/tee.te @@ -26,3 +26,4 @@ allow tee system_data_file:dir r_dir_perms; allow tee vfat:file { getattr open read }; allow tee vfat:dir search; allow tee secd_exec:file { getattr read }; +allow tee system_data_root_file:dir rw_dir_perms; -- GitLab From b18ff5c9a1345f2c088a80223244fd8a4dd2d647 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Thu, 29 Oct 2020 13:34:00 +0800 Subject: [PATCH 050/191] kitakami-common: sepolicy: Address Dumpstate HAL denials * Also address vendor SPL props denial. Change-Id: I8febaae09b340b12542f4188309fe2e6092a4d9f --- sepolicy/vendor/hal_dumpstate_impl.te | 1 + sepolicy/vendor/hwservicemanager.te | 4 ++++ sepolicy/vendor/system_app.te | 1 + sepolicy/vendor/system_server.te | 1 + 4 files changed, 7 insertions(+) diff --git a/sepolicy/vendor/hal_dumpstate_impl.te b/sepolicy/vendor/hal_dumpstate_impl.te index 10db39e..d380fcf 100644 --- a/sepolicy/vendor/hal_dumpstate_impl.te +++ b/sepolicy/vendor/hal_dumpstate_impl.te @@ -7,3 +7,4 @@ allow hal_dumpstate_impl hal_dumpstate_impl_exec:file execute_no_trans; allow hal_dumpstate_impl hwservicemanager:binder { call transfer }; allow hal_dumpstate_impl hwservicemanager_prop:file { getattr map open read }; allow hal_dumpstate_impl hidl_base_hwservice:hwservice_manager add; +allow hal_dumpstate_impl hal_dumpstate_hwservice:hwservice_manager { add find }; diff --git a/sepolicy/vendor/hwservicemanager.te b/sepolicy/vendor/hwservicemanager.te index c211c11..5d9f3f8 100644 --- a/sepolicy/vendor/hwservicemanager.te +++ b/sepolicy/vendor/hwservicemanager.te @@ -2,3 +2,7 @@ allow hwservicemanager init:dir search; allow hwservicemanager init:file { open read }; allow hwservicemanager init:process getattr; allow hwservicemanager secd_exec:file { getattr read }; +allow hwservicemanager hal_dumpstate_impl:dir { rw_dir_perms }; +allow hwservicemanager hal_dumpstate_impl:file { rw_file_perms }; +allow hwservicemanager hal_dumpstate_impl:binder { call transfer }; +allow hwservicemanager hal_dumpstate_impl:process getattr; diff --git a/sepolicy/vendor/system_app.te b/sepolicy/vendor/system_app.te index b01135d..eaab107 100644 --- a/sepolicy/vendor/system_app.te +++ b/sepolicy/vendor/system_app.te @@ -10,3 +10,4 @@ allow system_app apex_service:service_manager find; allow system_app proc_pagetypeinfo:file read; allow system_app sysfs_zram:dir search; allow system_app system_suspend_control_service:service_manager find; +allow system_app hal_dumpstate_impl:binder call; diff --git a/sepolicy/vendor/system_server.te b/sepolicy/vendor/system_server.te index ea19fed..9a57a2d 100644 --- a/sepolicy/vendor/system_server.te +++ b/sepolicy/vendor/system_server.te @@ -14,3 +14,4 @@ allow system_server unlabeled:file unlink; allow system_server default_android_service:service_manager find; allow system_server init:binder { call transfer }; allow system_server exfat:dir rw_dir_perms; +allow system_server vendor_security_patch_level_prop:file { r_file_perms }; -- GitLab From d65cf2b9b7a8697a0ae122c457c0235cf96d0e6a Mon Sep 17 00:00:00 2001 From: David Sehr Date: Fri, 23 Oct 2020 01:50:00 +0530 Subject: [PATCH 051/191] kitakami-common: Use dex2oat64 Enable dex2oat64 usage on device Bug: 153380900 Test: boot and install an application. Change-Id: Ifff726eb2f8bd315a42c02bdca9ff10cf027a06c --- system.prop | 3 +++ 1 file changed, 3 insertions(+) diff --git a/system.prop b/system.prop index 98f342b..02dd1f5 100644 --- a/system.prop +++ b/system.prop @@ -59,6 +59,9 @@ dalvik.vm.boot-dex2oat-threads=4 dalvik.vm.dex2oat-threads=2 dalvik.vm.image-dex2oat-threads=4 +# Dalvik dex2oat +dalvik.vm.dex2oat64.enabled=true + # lmkd options ro.lmk.low=1001 ro.lmk.medium=800 -- GitLab From 2e75bcff94e1e449d246df54d63ac63887960c51 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Fri, 30 Oct 2020 00:26:39 +0800 Subject: [PATCH 052/191] kitakami-common: sepolicy: Address more denials Change-Id: I8e1b56b6cbb3ddf31526d04f6dc19f3b12f99930 --- sepolicy/vendor/clatd.te | 4 ---- sepolicy/vendor/fsck.te | 2 ++ sepolicy/vendor/hal_health_default.te | 1 + sepolicy/vendor/init.te | 5 +++++ sepolicy/vendor/tad.te | 2 +- sepolicy/vendor/ueventd.te | 1 + 6 files changed, 10 insertions(+), 5 deletions(-) delete mode 100644 sepolicy/vendor/clatd.te create mode 100644 sepolicy/vendor/hal_health_default.te diff --git a/sepolicy/vendor/clatd.te b/sepolicy/vendor/clatd.te deleted file mode 100644 index c99aad7..0000000 --- a/sepolicy/vendor/clatd.te +++ /dev/null @@ -1,4 +0,0 @@ -type clatd, domain; -type clatd_exec, exec_type, file_type; - -allow clatd system_file:file lock; diff --git a/sepolicy/vendor/fsck.te b/sepolicy/vendor/fsck.te index ca3bdf2..c68ada2 100644 --- a/sepolicy/vendor/fsck.te +++ b/sepolicy/vendor/fsck.te @@ -3,3 +3,5 @@ allow fsck self:capability { dac_override dac_read_search }; allow fsck secd_exec:file { getattr read }; allow fsck tmpfs:blk_file getattr; allow fsck persist_file:dir getattr; +allow fsck persist_file:dir rw_dir_perms; +allow fsck tmpfs:blk_file rw_file_perms; diff --git a/sepolicy/vendor/hal_health_default.te b/sepolicy/vendor/hal_health_default.te new file mode 100644 index 0000000..ea0c28d --- /dev/null +++ b/sepolicy/vendor/hal_health_default.te @@ -0,0 +1 @@ +allow hal_health_default sysfs:file { rw_file_perms }; \ No newline at end of file diff --git a/sepolicy/vendor/init.te b/sepolicy/vendor/init.te index 7bbcfd6..5f80bc0 100644 --- a/sepolicy/vendor/init.te +++ b/sepolicy/vendor/init.te @@ -48,3 +48,8 @@ allow init vendor_file:file execute_no_trans; allow init vndbinder_device:chr_file { ioctl open read write }; allow init fingerprintd_data_file:file rename; allow init system_server:binder call; +allow init hal_drm_hwservice:hwservice_manager { add find }; +allow init hal_fingerprint_hwservice:hwservice_manager { add find }; +allow init iorapd_data_file:file rw_file_perms; +allow init system_file:dir relabelfrom; +allow init system_file:file { execute_no_trans relabelfrom }; diff --git a/sepolicy/vendor/tad.te b/sepolicy/vendor/tad.te index 383a182..da37bba 100644 --- a/sepolicy/vendor/tad.te +++ b/sepolicy/vendor/tad.te @@ -11,4 +11,4 @@ allow tad proc:file r_file_perms; # Allow tad to work it's magic allow tad trim_area_partition_device:blk_file { ioctl rw_file_perms }; allow tad block_device:dir search; -allow tad tmpfs:file rw_file_perms; +allow tad tmpfs:file rw_file_perms; \ No newline at end of file diff --git a/sepolicy/vendor/ueventd.te b/sepolicy/vendor/ueventd.te index 29c49eb..100a149 100644 --- a/sepolicy/vendor/ueventd.te +++ b/sepolicy/vendor/ueventd.te @@ -7,3 +7,4 @@ allow ueventd vfat:dir search; allow ueventd vfat:file { getattr open read }; allow ueventd self:capability sys_nice; allow ueventd secd_exec:file { getattr read }; +allow ueventd proc:file { getattr open read }; -- GitLab From 3c89783e4723ab3a12277d8776a01cae74350401 Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Tue, 29 Sep 2020 22:18:32 +0100 Subject: [PATCH 053/191] kitakami-common: Define shipping FCM version in the manifest Shipping API level 22 corresponds to legacy FCM version. This addresses the following build warning: Warning: Shipping FCM Version is inferred from Shipping API level. Declare Shipping FCM Version in device manifest directly. Change-Id: Ib230c345ff7deb552597824838b8809ceefbbe8a --- manifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.xml b/manifest.xml index e071d0c..d59f3d4 100644 --- a/manifest.xml +++ b/manifest.xml @@ -1,4 +1,4 @@ - + android.hardware.audio hwbinder -- GitLab From 7e329330fba01ff7b7e0b132f2f8a632b3a530d2 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Fri, 30 Oct 2020 01:36:30 +0800 Subject: [PATCH 054/191] kitakami-common: sepolicy: Address fingerprint hal denails --- sepolicy/vendor/file_contexts | 3 +++ sepolicy/vendor/hal_fingerprint_default.te | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 0f699b6..368d10d 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -35,6 +35,9 @@ /data/etc u:object_r:ta_data_file:s0 /data/etc(/.*) u:object_r:ta_data_file:s0 +# Fingerprint +/(vendor|system/vendor)/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.0-service.kitakami u:object_r:hal_fingerprint_default_exec:s0 + # Fingerprint sensor SPI device /data/fpc(/.*)? u:object_r:fpc_data_file:s0 /data/fpcd(/.*)? u:object_r:fpc_data_file:s0 diff --git a/sepolicy/vendor/hal_fingerprint_default.te b/sepolicy/vendor/hal_fingerprint_default.te index 10ecae5..77fc75a 100644 --- a/sepolicy/vendor/hal_fingerprint_default.te +++ b/sepolicy/vendor/hal_fingerprint_default.te @@ -16,3 +16,7 @@ allow hal_fingerprint_default firmware_file:lnk_file read; allow hal_fingerprint_default fpc_data_file:dir search; allow hal_fingerprint_default input_device:dir search; allow hal_fingerprint_default diag_data_file:dir search; +allow hal_fingerprint_default fingerprintd_data_file:dir create_dir_perms; +allow hal_fingerprint_default sysfs_battery_supply:dir create_dir_perms; +allow hal_fingerprint_default fingerprintd_data_file:file create_file_perms; +allow hal_fingerprint_default sysfs_battery_supply:file create_file_perms; \ No newline at end of file -- GitLab From 3ec227315b0520963301e7f7b3113d2c2fa7e1b9 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Sun, 1 Nov 2020 22:17:57 +0800 Subject: [PATCH 055/191] kitakami-common: rootdir: Add 1.3 interface to supplicant service --- rootdir/init.qcom.rc | 1 + 1 file changed, 1 insertion(+) diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index dbbf6fd..32ee3ab 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -498,6 +498,7 @@ service wpa_supplicant /vendor/bin/hw/wpa_supplicant \ interface android.hardware.wifi.supplicant@1.0::ISupplicant default interface android.hardware.wifi.supplicant@1.1::ISupplicant default interface android.hardware.wifi.supplicant@1.2::ISupplicant default + interface android.hardware.wifi.supplicant@1.3::ISupplicant default class main socket wpa_wlan0 dgram 660 wifi wifi disabled -- GitLab From 5109f092591642ded8109197d1cc7f0b3610db2b Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Tue, 3 Nov 2020 10:29:29 +0100 Subject: [PATCH 056/191] kitakami-common: sepolicy: Some minor changes to allow R to be built. Change-Id: I3fa1a26c1863a4a5e96cdeefda6f6f917f9368d2 --- BoardConfigCommon.mk | 2 +- sepolicy/vendor/ashmemd.te | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 sepolicy/vendor/ashmemd.te diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index e1dc81f..fcbeafd 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -205,7 +205,7 @@ TARGET_LD_SHIM_LIBS := \ /system/bin/secd|/system/lib64/lib-preload64.so # SELinux -# include device/qcom/sepolicy-legacy/sepolicy.mk +include device/qcom/sepolicy-legacy/sepolicy.mk BOARD_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/vendor # WiFi diff --git a/sepolicy/vendor/ashmemd.te b/sepolicy/vendor/ashmemd.te deleted file mode 100644 index 7e0f69d..0000000 --- a/sepolicy/vendor/ashmemd.te +++ /dev/null @@ -1 +0,0 @@ -allow ashmemd secd_exec:file { getattr read }; -- GitLab From 64f3fae6d1170c24d54aaabf5dde579f73d29e89 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Tue, 3 Nov 2020 15:04:29 +0100 Subject: [PATCH 057/191] kitakami-common: sepolicy: Switch to permissive mode for now. Change-Id: Ifddfabb2bdcc1026c8e4d3fe00893ed8a18e06b8 --- BoardConfigCommon.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index fcbeafd..63ef708 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -51,6 +51,7 @@ BUILD_BROKEN_USES_BUILD_COPY_HEADERS := true # Boot image/kernel BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-5 loop.max_part=7 dwc3_msm.hvdcp_max_current=1500 dwc3_msm.prop_chg_detect=Y coherent_pool=2M swiotlb=2048 +BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive BOARD_KERNEL_IMAGE_NAME := Image.gz-dtb BOARD_KERNEL_PAGESIZE := 4096 BOARD_KERNEL_BASE := 0x00000000 -- GitLab From 2aa9bac4ad5272105ccd20482229ecbd96bca6b5 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Tue, 3 Nov 2020 15:37:45 +0100 Subject: [PATCH 058/191] kitakami-common: Added DRM services and labeled them. Change-Id: Iadfadf590c618a626aa728cc9c739d06f8a3f515 --- device-common.mk | 3 ++- sepolicy/vendor/file_contexts | 4 ++++ sepolicy/vendor/hal_drm_clearkey.te | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 sepolicy/vendor/hal_drm_clearkey.te diff --git a/device-common.mk b/device-common.mk index b4abf40..87eec45 100644 --- a/device-common.mk +++ b/device-common.mk @@ -150,7 +150,8 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ android.hardware.drm@1.0-impl \ android.hardware.drm@1.0-service \ - android.hardware.drm@1.3-service.clearkey + android.hardware.drm@1.3-service.clearkey \ + android.hardware.drm@1.3-service.widevine # Display PRODUCT_PACKAGES += \ diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 368d10d..1b1016b 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -25,6 +25,10 @@ # Dumpstate HAL /(vendor|system/vendor)/bin/hw/android\.hardware\.dumpstate@1\.1-service-kitakami u:object_r:hal_dumpstate_impl_exec:s0 +# DRM +/(vendor|system/vendor)/bin/hw/android\.hardware\.drm@1\.3-service.clearkey u:object_r:hal_drm_clearkey_exec:s0 +/(vendor|system/vendor)/bin/hw/android\.hardware\.drm@1\.3-service.widevine u:object_r:hal_drm_widevine_exec:s0 + # HCI /dev/ttyHS0 u:object_r:hci_attach_dev:s0 /dev/brcm_bt_drv u:object_r:hci_attach_dev:s0 diff --git a/sepolicy/vendor/hal_drm_clearkey.te b/sepolicy/vendor/hal_drm_clearkey.te new file mode 100644 index 0000000..40c1275 --- /dev/null +++ b/sepolicy/vendor/hal_drm_clearkey.te @@ -0,0 +1,6 @@ +type hal_drm_clearkey, domain; +hwbinder_use(hal_drm_clearkey) +vndbinder_use(hal_drm_clearkey) + +type hal_drm_clearkey_exec, exec_type, vendor_file_type, file_type; +init_daemon_domain(hal_drm_clearkey) -- GitLab From 063f0ac2ea3cbf2fc14ad2592d9edb36815c51f1 Mon Sep 17 00:00:00 2001 From: Han Wang <416810799@qq.com> Date: Sat, 19 Sep 2020 09:52:14 +0200 Subject: [PATCH 059/191] kitakami-common: Make shim for AudioSystem::setErrorCallback() * Commit 000c3e4 in fw/av changed setErrorCallback() to addErrorCallback() to support multiple instances, but this breaks our old blob. Change-Id: I03495e5746a4ad75a09a0e24bb7faf265a8b0bda --- BoardConfigCommon.mk | 3 ++- device-common.mk | 1 + libshim/Android.mk | 10 ++++++++++ libshim/libaudioclient_shim.cpp | 25 +++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 libshim/libaudioclient_shim.cpp diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 63ef708..24962dd 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -203,7 +203,8 @@ TARGET_LD_SHIM_LIBS := \ /system/lib/libcammw.so|libsensor.so \ /system/vendor/lib/libizat_core.so|/system/vendor/lib/libshim_gps.so \ /system/vendor/lib64/libizat_core.so|/system/vendor/lib64/libshim_gps.so \ - /system/bin/secd|/system/lib64/lib-preload64.so + /system/bin/secd|/system/lib64/lib-preload64.so \ + /system/vendor/lib64/libril-qc-qmi-1.so|libaudioclient_shim.so # SELinux include device/qcom/sepolicy-legacy/sepolicy.mk diff --git a/device-common.mk b/device-common.mk index 87eec45..d70acbe 100644 --- a/device-common.mk +++ b/device-common.mk @@ -308,6 +308,7 @@ PRODUCT_PACKAGES += \ # RIL PRODUCT_PACKAGES += \ + libaudioclient_shim \ libxml2 # RIL Wrapper diff --git a/libshim/Android.mk b/libshim/Android.mk index 1552be5..d351c2d 100644 --- a/libshim/Android.mk +++ b/libshim/Android.mk @@ -47,3 +47,13 @@ LOCAL_MODULE_TAGS := optional LOCAL_PROPRIETARY_MODULE := true include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := libaudioclient_shim.cpp +LOCAL_MODULE := libaudioclient_shim +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_SHARED_LIBRARIES := libaudioclient +LOCAL_VENDOR_MODULE := true + +include $(BUILD_SHARED_LIBRARY) diff --git a/libshim/libaudioclient_shim.cpp b/libshim/libaudioclient_shim.cpp new file mode 100644 index 0000000..b930189 --- /dev/null +++ b/libshim/libaudioclient_shim.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 The LineageOS Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +extern "C" uintptr_t _ZN7android11AudioSystem16addErrorCallbackEPFviE( + android::audio_error_callback cb); + +extern "C" void _ZN7android11AudioSystem16setErrorCallbackEPFviE( + android::audio_error_callback cb) { + _ZN7android11AudioSystem16addErrorCallbackEPFviE(cb); +} -- GitLab From 80b65194927401789ad90f40aa7550422f8b6bb1 Mon Sep 17 00:00:00 2001 From: mosimchah Date: Thu, 23 Aug 2018 05:49:06 -0400 Subject: [PATCH 060/191] kitakami-common: Convert audio_effects.conf to audio_effects.xml * https://github.com/luk1337/aeffects-conf2xml Fixes: 09-04 19:18:03.152 689 689 E EffectsConfig: Failed to parse /vendor/etc/audio_effects.xml: Tinyxml2 error (3): /vendor/etc/audio_effects.xml (null) 09-04 19:18:03.152 689 689 W AudioPolicyEffects: Failed to load XML effect configuration, fallback to .conf Change-Id: Ibd985bea0441c7d5cffd37e0b3f65d5c27a16891 --- audio/audio_effects.conf | 222 --------------------------------------- audio/audio_effects.xml | 33 ++++++ device-common.mk | 2 +- 3 files changed, 34 insertions(+), 223 deletions(-) delete mode 100644 audio/audio_effects.conf create mode 100644 audio/audio_effects.xml diff --git a/audio/audio_effects.conf b/audio/audio_effects.conf deleted file mode 100644 index 0612af2..0000000 --- a/audio/audio_effects.conf +++ /dev/null @@ -1,222 +0,0 @@ -# List of effect libraries to load. Each library element must contain a "path" element -# giving the full path of the library .so file. -# libraries { -# { -# path -# } -# } -libraries { -# This is a proxy library that will be an abstraction for -# the HW and SW effects - - #proxy { - #path /system/lib/soundfx/libeffectproxy.so - #} - -# This is the SW implementation library of the effect - #libSW { - #path /system/lib/soundfx/libswwrapper.so - #} - -# This is the HW implementation library for the effect - #libHW { - #path /system/lib/soundfx/libhwwrapper.so - #} - - bundle { - path /system/lib/soundfx/libbundlewrapper.so - } - reverb { - path /system/lib/soundfx/libreverbwrapper.so - } - visualizer { - path /system/lib/soundfx/libvisualizer.so - } - downmix { - path /system/lib/soundfx/libdownmix.so - } - loudness_enhancer { - path /system/lib/soundfx/libldnhncr.so - } - audio_pre_processing { - path /system/lib/soundfx/libqcomvoiceprocessing.so - } - proxy { - path /system/lib/soundfx/libeffectproxy.so - } - sonyeffect_sw { - path /system/lib/soundfx/libsonysweffect.so - } - sonyeffect_hw { - path /system/lib/soundfx/libsonypostprocbundle.so - } -} - -# Default pre-processing library. Add to audio_effect.conf "libraries" section if -# audio HAL implements support for default software audio pre-processing effects -# -# pre_processing { -# path /system/lib/soundfx/libaudiopreprocessing.so -# } - -# list of effects to load. Each effect element must contain a "library" and a "uuid" element. -# The value of the "library" element must correspond to the name of one library element in the -# "libraries" element. -# The name of the effect element is indicative, only the value of the "uuid" element -# designates the effect. -# The uuid is the implementation specific UUID as specified by the effect vendor. This is not the -# generic effect type UUID. -# effects { -# { -# library -# uuid -# } -# ... -# } - -effects { - -# additions for the proxy implementation -# Proxy implementation - #effectname { - #library proxy - #uuid xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - - # SW implemetation of the effect. Added as a node under the proxy to - # indicate this as a sub effect. - #libsw { - #library libSW - #uuid yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy - #} End of SW effect - - # HW implementation of the effect. Added as a node under the proxy to - # indicate this as a sub effect. - #libhw { - #library libHW - #uuid zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz - #}End of HW effect - #} End of effect proxy - - bassboost { - library bundle - uuid 8631f300-72e2-11df-b57e-0002a5d5c51b - } - virtualizer { - library bundle - uuid 1d4033c0-8557-11df-9f2d-0002a5d5c51b - } - equalizer { - library bundle - uuid ce772f20-847d-11df-bb17-0002a5d5c51b - } - volume { - library bundle - uuid 119341a0-8469-11df-81f9-0002a5d5c51b - } - reverb_env_aux { - library reverb - uuid 4a387fc0-8ab3-11df-8bad-0002a5d5c51b - } - reverb_env_ins { - library reverb - uuid c7a511a0-a3bb-11df-860e-0002a5d5c51b - } - reverb_pre_aux { - library reverb - uuid f29a1400-a3bb-11df-8ddc-0002a5d5c51b - } - reverb_pre_ins { - library reverb - uuid 172cdf00-a3bc-11df-a72f-0002a5d5c51b - } - visualizer { - library visualizer - uuid d069d9e0-8329-11df-9168-0002a5d5c51b - } - downmix { - library downmix - uuid 93f04452-e4fe-41cc-91f9-e475b6d1d69f - } - loudness_enhancer { - library loudness_enhancer - uuid fa415329-2034-4bea-b5dc-5b381c8d1e2c - } - aec { - library audio_pre_processing - uuid 0f8d0d2a-59e5-45fe-b6e4-248c8a799109 - } - ns { - library audio_pre_processing - uuid 1d97bb0b-9e2f-4403-9ae3-58c2554306f8 - } - sonyeffect { - library proxy - uuid af8da7e0-2ca1-11e3-b71d-0002a5d5c51b - - libsw { - library sonyeffect_sw - uuid 50786e95-da76-4557-976b-7981bdf6feb9 - } - - libhw { - library sonyeffect_hw - uuid f9ed8ae0-1b9c-11e4-8900-0002a5d5c51b - } - } -} - -# Default pre-processing effects. Add to audio_effect.conf "effects" section if -# audio HAL implements support for them. -# -# agc { -# library pre_processing -# uuid aa8130e0-66fc-11e0-bad0-0002a5d5c51b -# } -# aec { -# library pre_processing -# uuid bb392ec0-8d4d-11e0-a896-0002a5d5c51b -# } -# ns { -# library pre_processing -# uuid c06c8400-8e06-11e0-9cb6-0002a5d5c51b -# } - -# Audio preprocessor configurations. -# The pre processor configuration consists in a list of elements each describing -# pre processor settings for a given input source. Valid input source names are: -# "mic", "camcorder", "voice_recognition", "voice_communication" -# Each input source element contains a list of effects elements. The name of the effect -# element must be the name of one of the effects in the "effects" list of the file. -# Each effect element may optionally contain a list of parameters and their -# default value to apply when the pre processor effect is created. -# A parameter is defined by a "param" element and a "value" element. Each of these elements -# consists in one or more elements specifying a type followed by a value. -# The types defined are: "int", "short", "float", "bool" and "string" -# When both "param" and "value" are a single int, a simple form is allowed where just -# the param and value pair is present in the parameter description -# pre_processing { -# { -# { -# { -# param { -# int|short|float|bool|string -# [ int|short|float|bool|string ] -# ... -# } -# value { -# int|short|float|bool|string -# [ int|short|float|bool|string ] -# ... -# } -# } -# { } -# ... -# } -# ... -# } -# ... -# } - -# -# TODO: add default audio pre processor configurations after debug and tuning phase -# diff --git a/audio/audio_effects.xml b/audio/audio_effects.xml new file mode 100644 index 0000000..3b87058 --- /dev/null +++ b/audio/audio_effects.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/device-common.mk b/device-common.mk index d70acbe..b935ac0 100644 --- a/device-common.mk +++ b/device-common.mk @@ -108,7 +108,7 @@ PRODUCT_COPY_FILES += \ # Audio configuration PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/audio/audio_effects.conf:$(TARGET_COPY_OUT_VENDOR)/etc/audio_effects.conf \ + $(LOCAL_PATH)/audio/audio_effects.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_effects.xml \ $(LOCAL_PATH)/audio/audio_output_policy.conf:$(TARGET_COPY_OUT_VENDOR)/etc/audio_output_policy.conf \ $(LOCAL_PATH)/audio/audio_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_platform_info.xml \ $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml -- GitLab From 4b777f5a525f2241c567a880b921235254e15c14 Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Fri, 11 May 2018 23:32:31 +0100 Subject: [PATCH 061/191] kitakami-common: Restore audio tuning mixer control * After all, this still seems to be needed for ACDB MCS init, as seen bellow. Just let ACDB loader be happy. Without the tuning mixer file: E ACDB-MCS: acdb_mcs_init: /vendor/etc/audio_tuning_mixer_tasha.txt not present, using /vendor/etc/audio_tuning_mixer.txt config file E MCS-RT-CTL: Can't open the configuration file /vendor/etc/audio_tuning_mixer.txt. E ACDB-MCS: acdb_mcs_init: MCS routing control initialization failed. With the tuning mixer file: E ACDB-MCS: acdb_mcs_init: /vendor/etc/audio_tuning_mixer_tasha.txt not present, using /vendor/etc/audio_tuning_mixer.txt config file D : [ACPH]->MCS RTC service registered with ACPH Change-Id: I6e4b1fe27547a354eaa4132aba8e3df04d6184b3 --- audio/audio_tuning_mixer.txt | 171 +++++++++++++++++++++++++++++++++++ device-common.mk | 3 +- 2 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 audio/audio_tuning_mixer.txt diff --git a/audio/audio_tuning_mixer.txt b/audio/audio_tuning_mixer.txt new file mode 100644 index 0000000..aa2d2aa --- /dev/null +++ b/audio/audio_tuning_mixer.txt @@ -0,0 +1,171 @@ +# Copyright (c) 2014, 2016, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of The Linux Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ANC_TEST_P_PATH_MIC_STEREO Capture +acdb_dev_id:85 +!Capture +Txdevice:0 + +enable +TX7 HPF Switch:1 +TX8 HPF Switch:1 +AIF1_CAP Mixer SLIM TX7:1 +AIF1_CAP Mixer SLIM TX8:1 +SLIM TX7 MUX:DEC9 +DEC9 MUX:DMIC4 +SLIM TX8 MUX:DEC10 +DEC10 MUX:DMIC3 +SLIM_0_TX Channels:Two +MultiMedia1 Mixer SLIM_0_TX:1 + +disable +MultiMedia1 Mixer SLIM_0_TX:0 +AIF1_CAP Mixer SLIM TX7:0 +AIF1_CAP Mixer SLIM TX8:0 +SLIM TX7 MUX:ZERO +SLIM TX8 MUX:ZERO +DEC9 MUX:ZERO +DEC10 MUX:ZERO +TX7 HPF Switch:0 +TX8 HPF Switch:0 + +#ANC_TEST_S_PATH_MIC_STEREO Capture +acdb_dev_id:88 +!Capture +Txdevice:0 + +enable +TX7 HPF Switch:1 +TX8 HPF Switch:1 +AIF1_CAP Mixer SLIM TX7:1 +AIF1_CAP Mixer SLIM TX8:1 +SLIM TX7 MUX:DEC8 +DEC7 MUX:ANC2_FB +ANC2 MUX:DMIC3 +SLIM TX8 MUX:DEC7 +DEC8 MUX:ANC1_FB +ANC1 MUX:DMIC3 +ANC1 FB MUX:EAR_HPH_L +SLIM_0_TX Channels:Two +MultiMedia1 Mixer SLIM_0_TX:1 + +disable +MultiMedia1 Mixer SLIM_0_TX:0 +AIF1_CAP Mixer SLIM TX7:0 +AIF1_CAP Mixer SLIM TX8:0 +SLIM TX7 MUX:ZERO +SLIM TX8 MUX:ZERO +DEC7 MUX:ZERO +ANC2 MUX:ZERO +ANC1 MUX:ZERO +DEC8 MUX:ZERO +ANC1 FB MUX:ZERO +TX7 HPF Switch:0 +TX8 HPF Switch:0 + +#ANC_TEST_E_PATH_MIC_STEREO Capture +acdb_dev_id:91 +!Capture +Txdevice:0 + +enable +TX7 HPF Switch:1 +TX8 HPF Switch:1 +AIF1_CAP Mixer SLIM TX7:1 +AIF1_CAP Mixer SLIM TX8:1 +SLIM TX7 MUX:DEC8 +DEC7 MUX:ANC2_FB +ANC2 MUX:DMIC4 +ANC1 MUX:DMIC4 +SLIM TX8 MUX:DEC7 +DEC8 MUX:ANC1_FB +ANC1 FB MUX:EAR_HPH_L +SLIM_0_TX Channels:Two +MultiMedia1 Mixer SLIM_0_TX:1 + +disable +MultiMedia1 Mixer SLIM_0_TX:0 +AIF1_CAP Mixer SLIM TX7:0 +AIF1_CAP Mixer SLIM TX8:0 +SLIM TX7 MUX:ZERO +SLIM TX8 MUX:ZERO +DEC7 MUX:ZERO +ANC2 MUX:ZERO +DEC10 MUX:ZERO +ANC1 FB MUX:ZERO +TX7 HPF Switch:0 +TX8 HPF Switch:0 + +#ANC_TEST_S_PATH_HANDSET_SPKR_ANC_MONO +acdb_dev_id:86 +!Playback +Rxdevice:0 + +enable +ANC Function:ON +SLIM RX1 MUX:AIF1_PB +SLIM_0_RX Channels:One +RX1 MIX1 INP1:RX1 +CLASS_H_DSM MUX:DSM_HPHL_RX1 +RX1 Digital Volume:87 +DAC1 Switch:1 +ANC Slot:7 +SLIMBUS_0_RX Audio Mixer MultiMedia1:1 + +disable +SLIMBUS_0_RX Audio Mixer MultiMedia1:0 +ANC Slot:0 +SLIM RX1 MUX:ZERO +RX1 MIX1 INP1:ZERO +RX1 Digital Volume:0 +DAC1 Switch:0 +ANC Function:OFF + +#ANC_TEST_E_PATH_HANDSET_SPKR_ANC_MONO +acdb_dev_id:89 +!Playback +Rxdevice:0 + +enable +ANC Function:ON +SLIM RX1 MUX:AIF1_PB +SLIM_0_RX Channels:One +RX1 MIX1 INP1:RX1 +CLASS_H_DSM MUX:DSM_HPHL_RX1 +RX1 Digital Volume:87 +DAC1 Switch:1 +ANC Slot:8 +SLIMBUS_0_RX Audio Mixer MultiMedia1:1 + +disable +SLIMBUS_0_RX Audio Mixer MultiMedia1:0 +ANC Slot:0 +SLIM RX1 MUX:ZERO +RX1 MIX1 INP1:ZERO +RX1 Digital Volume:0 +DAC1 Switch:0 +ANC Function:OFF diff --git a/device-common.mk b/device-common.mk index b935ac0..db35440 100644 --- a/device-common.mk +++ b/device-common.mk @@ -111,7 +111,8 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/audio/audio_effects.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_effects.xml \ $(LOCAL_PATH)/audio/audio_output_policy.conf:$(TARGET_COPY_OUT_VENDOR)/etc/audio_output_policy.conf \ $(LOCAL_PATH)/audio/audio_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_platform_info.xml \ - $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml + $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \ + $(LOCAL_PATH)/audio/audio_tuning_mixer.txt:$(TARGET_COPY_OUT_VENDOR)/etc/audio_tuning_mixer.txt PRODUCT_COPY_FILES += \ frameworks/av/services/audiopolicy/config/a2dp_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_audio_policy_configuration.xml \ -- GitLab From 7fe34d154226dae265cd99a93a399f3acfac25d9 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sat, 23 May 2020 20:49:51 +0200 Subject: [PATCH 062/191] Rename audio_tuning_mixer.txt to aanc_tuning_mixer.txt logcat: E MCS-RT-CTL: Can't open the configuration file /system/etc/aanc_tuning_mixer.txt. Change-Id: If41179d70cf9dfbc5c2ad43011927aaabc391a6e --- audio/{audio_tuning_mixer.txt => aanc_tuning_mixer.txt} | 0 device-common.mk | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename audio/{audio_tuning_mixer.txt => aanc_tuning_mixer.txt} (100%) diff --git a/audio/audio_tuning_mixer.txt b/audio/aanc_tuning_mixer.txt similarity index 100% rename from audio/audio_tuning_mixer.txt rename to audio/aanc_tuning_mixer.txt diff --git a/device-common.mk b/device-common.mk index db35440..5102c7c 100644 --- a/device-common.mk +++ b/device-common.mk @@ -112,7 +112,7 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/audio/audio_output_policy.conf:$(TARGET_COPY_OUT_VENDOR)/etc/audio_output_policy.conf \ $(LOCAL_PATH)/audio/audio_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_platform_info.xml \ $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \ - $(LOCAL_PATH)/audio/audio_tuning_mixer.txt:$(TARGET_COPY_OUT_VENDOR)/etc/audio_tuning_mixer.txt + $(LOCAL_PATH)/audio/aanc_tuning_mixer.txt:$(TARGET_COPY_OUT_VENDOR)/etc/aanc_tuning_mixer.txt PRODUCT_COPY_FILES += \ frameworks/av/services/audiopolicy/config/a2dp_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_audio_policy_configuration.xml \ -- GitLab From c202d42ebbc0fda9bd12fb6f520c16bcbfa3f084 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sun, 24 May 2020 14:41:51 +0200 Subject: [PATCH 063/191] Changed output directory of aanc_tuning_mixer.txt The file aanc_tuning_mixer.txt has to be in /system/etc because: E MCS-RT-CTL: Can't open the configuration file /system/etc/aanc_tuning_mixer.txt. Change-Id: Ie8a28b4486aeebbc76facca1bc7a593b33229583 --- device-common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-common.mk b/device-common.mk index 5102c7c..bca412b 100644 --- a/device-common.mk +++ b/device-common.mk @@ -112,7 +112,7 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/audio/audio_output_policy.conf:$(TARGET_COPY_OUT_VENDOR)/etc/audio_output_policy.conf \ $(LOCAL_PATH)/audio/audio_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_platform_info.xml \ $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \ - $(LOCAL_PATH)/audio/aanc_tuning_mixer.txt:$(TARGET_COPY_OUT_VENDOR)/etc/aanc_tuning_mixer.txt + $(LOCAL_PATH)/audio/aanc_tuning_mixer.txt:$(TARGET_COPY_OUT_SYSTEM)/etc/aanc_tuning_mixer.txt PRODUCT_COPY_FILES += \ frameworks/av/services/audiopolicy/config/a2dp_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_audio_policy_configuration.xml \ -- GitLab From a42367f1cee4348abf9df298240e6cfcb113eff4 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Wed, 4 Nov 2020 13:43:50 +0800 Subject: [PATCH 064/191] kitakami-common: fingerprint: Proper implement 2.1 functions * Rename it to 2.1 properly. --- fingerprint/Android.bp | 4 +- fingerprint/BiometricsFingerprint.cpp | 39 +++++++------------ ...trics.fingerprint@2.1-service.kitakami.rc} | 2 +- sepolicy/vendor/file_contexts | 2 +- 4 files changed, 17 insertions(+), 30 deletions(-) rename fingerprint/{android.hardware.biometrics.fingerprint@2.0-service.kitakami.rc => android.hardware.biometrics.fingerprint@2.1-service.kitakami.rc} (91%) diff --git a/fingerprint/Android.bp b/fingerprint/Android.bp index f6357a0..bcaade1 100644 --- a/fingerprint/Android.bp +++ b/fingerprint/Android.bp @@ -14,10 +14,10 @@ // See the License for the specific language governing permissions and // limitations under the License. cc_binary { - name: "android.hardware.biometrics.fingerprint@2.0-service.kitakami", + name: "android.hardware.biometrics.fingerprint@2.1-service.kitakami", defaults: ["hidl_defaults"], relative_install_path: "hw", - init_rc: ["android.hardware.biometrics.fingerprint@2.0-service.kitakami.rc"], + init_rc: ["android.hardware.biometrics.fingerprint@2.1-service.kitakami.rc"], srcs: ["service.cpp", "BiometricsFingerprint.cpp"], shared_libs: [ "libutils", diff --git a/fingerprint/BiometricsFingerprint.cpp b/fingerprint/BiometricsFingerprint.cpp index 7ecf5b3..c8f1a65 100644 --- a/fingerprint/BiometricsFingerprint.cpp +++ b/fingerprint/BiometricsFingerprint.cpp @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#define LOG_TAG "android.hardware.biometrics.fingerprint@2.0-service.kitakami" -#define LOG_VERBOSE "android.hardware.biometrics.fingerprint@2.0-service.kitakami" +#define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service.kitakami" +#define LOG_VERBOSE "android.hardware.biometrics.fingerprint@2.1-service.kitakami" #include @@ -184,30 +184,8 @@ Return BiometricsFingerprint::cancel() { return ErrorFilter(ret); } -#define MAX_FINGERPRINTS 100 - -typedef int (*enumerate_2_0)(struct fingerprint_device *dev, fingerprint_finger_id_t *results, - uint32_t *max_size); - Return BiometricsFingerprint::enumerate() { - fingerprint_finger_id_t results[MAX_FINGERPRINTS]; - uint32_t n = MAX_FINGERPRINTS; - enumerate_2_0 enumerate = (enumerate_2_0) mDevice->enumerate; - int ret = enumerate(mDevice, results, &n); - - if (ret == 0 && mClientCallback != nullptr) { - ALOGD("Got %d enumerated templates", n); - for (uint32_t i = 0; i < n; i++) { - const uint64_t devId = reinterpret_cast(mDevice); - const auto& fp = results[i]; - ALOGD("onEnumerate(fid=%d, gid=%d)", fp.fid, fp.gid); - if (!mClientCallback->onEnumerate(devId, fp.fid, fp.gid, n - i - 1).isOk()) { - ALOGE("failed to invoke fingerprint onEnumerate callback"); - } - } - } - - return ErrorFilter(ret); + return ErrorFilter(mDevice->enumerate(mDevice)); } Return BiometricsFingerprint::remove(uint32_t gid, uint32_t fid) { @@ -365,7 +343,16 @@ void BiometricsFingerprint::notify(const fingerprint_msg_t *msg) { } break; case FINGERPRINT_TEMPLATE_ENUMERATING: - // ignored, won't happen for 2.0 HALs + ALOGD("onEnumerate(fid=%d, gid=%d, rem=%d)", + msg->data.enumerated.finger.fid, + msg->data.enumerated.finger.gid, + msg->data.enumerated.remaining_templates); + if (!thisPtr->mClientCallback->onEnumerate(devId, + msg->data.enumerated.finger.fid, + msg->data.enumerated.finger.gid, + msg->data.enumerated.remaining_templates).isOk()) { + ALOGE("failed to invoke fingerprint onEnumerate callback"); + } break; } } diff --git a/fingerprint/android.hardware.biometrics.fingerprint@2.0-service.kitakami.rc b/fingerprint/android.hardware.biometrics.fingerprint@2.1-service.kitakami.rc similarity index 91% rename from fingerprint/android.hardware.biometrics.fingerprint@2.0-service.kitakami.rc rename to fingerprint/android.hardware.biometrics.fingerprint@2.1-service.kitakami.rc index 748a773..a32e3e9 100644 --- a/fingerprint/android.hardware.biometrics.fingerprint@2.0-service.kitakami.rc +++ b/fingerprint/android.hardware.biometrics.fingerprint@2.1-service.kitakami.rc @@ -1,4 +1,4 @@ -service vendor.fps_hal /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.0-service.kitakami +service vendor.fps_hal /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.1-service.kitakami # "class hal" causes a race condition on some devices due to files created # in /data. As a workaround, postpone startup until later in boot once # /data is mounted. diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 1b1016b..856bbb6 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -40,7 +40,7 @@ /data/etc(/.*) u:object_r:ta_data_file:s0 # Fingerprint -/(vendor|system/vendor)/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.0-service.kitakami u:object_r:hal_fingerprint_default_exec:s0 +/(vendor|system/vendor)/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.1-service.kitakami u:object_r:hal_fingerprint_default_exec:s0 # Fingerprint sensor SPI device /data/fpc(/.*)? u:object_r:fpc_data_file:s0 -- GitLab From 88264d54f351305b33b9bee3d6d00042219693b6 Mon Sep 17 00:00:00 2001 From: Saurabh Srivastava Date: Fri, 19 Jan 2018 21:21:56 +0530 Subject: [PATCH 065/191] kitakami-common: rootdir: Moving location sockets from /data to /dev Keeping sockets in /data/vendor/location prevents unmounting of /data partition after build load. CRs-Fixed: 2175511 Change-Id: Ide726a84b6b5f8df0c18d7d7dcbc1ee469b6d934 --- rootdir/init.qcom.rc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index 32ee3ab..9b5c9d6 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -422,6 +422,9 @@ on post-fs-data mkdir /data/misc/location/gpsone_d 0770 system gps mkdir /data/misc/location/quipc 0770 gps system mkdir /data/misc/location/gsiff 0770 gps gps + mkdir /dev/socket/location 0770 gps gps + mkdir /dev/socket/location/mq 0770 gps gps + mkdir /dev/socket/location/xtra 0770 gps gps #Create directory from IMS services mkdir /data/shared 0755 -- GitLab From ee4885bec41d8817151f142adcee79a7b8b354d9 Mon Sep 17 00:00:00 2001 From: Alessandro Astone Date: Sat, 7 Mar 2020 17:16:52 +0100 Subject: [PATCH 066/191] kitakami-common: Switch gps xtra servers to xtrapath{4, 5, 6} * Servers xtrapath1 and xtrapath3 are reporting the wrong week number (week rollover). Switch to servers xtrapath{4, 5, 6} as seen at https://developer.gemalto.com/threads/gps-time-info-error?page=1 * I've verified the week numbers in the downloaded xtra data following this example https://docs.legato.io/17_10/c_gnssSampleCodeXtra.html Bug: https://gitlab.com/LineageOS/issues/android/-/issues/1446 Change-Id: I92ef3760124a34f3bb7afc7760f89e707ae1b202 --- gps/gps.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gps/gps.conf b/gps/gps.conf index e0ce546..88a4323 100644 --- a/gps/gps.conf +++ b/gps/gps.conf @@ -1,8 +1,8 @@ #Uncommenting these urls would only enable #the power up auto injection and force injection(test case). -XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin -XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin -XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin +XTRA_SERVER_1=https://xtrapath4.izatcloud.net/xtra3grc.bin +XTRA_SERVER_2=https://xtrapath5.izatcloud.net/xtra3grc.bin +XTRA_SERVER_3=https://xtrapath6.izatcloud.net/xtra3grc.bin #Version check for XTRA #DISABLE = 0 -- GitLab From 7d3996eceddd1ecc1ad5c68506d937d2c1f0f140 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Thu, 5 Nov 2020 13:20:03 +0100 Subject: [PATCH 067/191] kitakami-common: sepolicy: Switched back to enforced SELinux mode. Change-Id: I565f1ea6a77e2b9667ddd039b8dcccf3656e1273 --- BoardConfigCommon.mk | 1 - sepolicy/vendor/bootanim.te | 1 + sepolicy/vendor/credstore.te | 1 + sepolicy/vendor/hal_drm_clearkey.te | 5 +++++ sepolicy/vendor/hal_drm_widevine.te | 1 + sepolicy/vendor/hal_dumpstate_impl.te | 1 + sepolicy/vendor/hal_fingerprint_default.te | 3 ++- sepolicy/vendor/hal_health_default.te | 3 ++- sepolicy/vendor/hal_power_stats_default.te | 1 + sepolicy/vendor/init.te | 1 + sepolicy/vendor/iorap_prefetcherd.te | 1 + sepolicy/vendor/iorapd.te | 1 + sepolicy/vendor/platform_app.te | 1 + sepolicy/vendor/system_server.te | 3 +++ sepolicy/vendor/vendor_install_recovery.te | 2 ++ sepolicy/vendor/vold.te | 1 + sepolicy/vendor/zygote.te | 1 + 17 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 sepolicy/vendor/credstore.te create mode 100644 sepolicy/vendor/hal_drm_widevine.te create mode 100644 sepolicy/vendor/hal_power_stats_default.te create mode 100644 sepolicy/vendor/iorap_prefetcherd.te create mode 100644 sepolicy/vendor/iorapd.te create mode 100644 sepolicy/vendor/vendor_install_recovery.te diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 24962dd..a998b55 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -51,7 +51,6 @@ BUILD_BROKEN_USES_BUILD_COPY_HEADERS := true # Boot image/kernel BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-5 loop.max_part=7 dwc3_msm.hvdcp_max_current=1500 dwc3_msm.prop_chg_detect=Y coherent_pool=2M swiotlb=2048 -BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive BOARD_KERNEL_IMAGE_NAME := Image.gz-dtb BOARD_KERNEL_PAGESIZE := 4096 BOARD_KERNEL_BASE := 0x00000000 diff --git a/sepolicy/vendor/bootanim.te b/sepolicy/vendor/bootanim.te index 85e51f3..9d50ea1 100644 --- a/sepolicy/vendor/bootanim.te +++ b/sepolicy/vendor/bootanim.te @@ -1 +1,2 @@ allow bootanim secd_exec:file { getattr read }; +allow bootanim userspace_reboot_exported_prop:file { getattr open read }; diff --git a/sepolicy/vendor/credstore.te b/sepolicy/vendor/credstore.te new file mode 100644 index 0000000..48eb746 --- /dev/null +++ b/sepolicy/vendor/credstore.te @@ -0,0 +1 @@ +allow credstore secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_drm_clearkey.te b/sepolicy/vendor/hal_drm_clearkey.te index 40c1275..b4753cc 100644 --- a/sepolicy/vendor/hal_drm_clearkey.te +++ b/sepolicy/vendor/hal_drm_clearkey.te @@ -4,3 +4,8 @@ vndbinder_use(hal_drm_clearkey) type hal_drm_clearkey_exec, exec_type, vendor_file_type, file_type; init_daemon_domain(hal_drm_clearkey) + +allow hal_drm_clearkey hal_drm_hwservice:hwservice_manager { add find }; +allow hal_drm_clearkey hidl_base_hwservice:hwservice_manager add; +allow hal_drm_clearkey hwservicemanager_prop:file { getattr open read }; +allow hal_drm_clearkey secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_drm_widevine.te b/sepolicy/vendor/hal_drm_widevine.te new file mode 100644 index 0000000..3c756f7 --- /dev/null +++ b/sepolicy/vendor/hal_drm_widevine.te @@ -0,0 +1 @@ +allow hal_drm_widevine secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_dumpstate_impl.te b/sepolicy/vendor/hal_dumpstate_impl.te index d380fcf..a602598 100644 --- a/sepolicy/vendor/hal_dumpstate_impl.te +++ b/sepolicy/vendor/hal_dumpstate_impl.te @@ -8,3 +8,4 @@ allow hal_dumpstate_impl hwservicemanager:binder { call transfer }; allow hal_dumpstate_impl hwservicemanager_prop:file { getattr map open read }; allow hal_dumpstate_impl hidl_base_hwservice:hwservice_manager add; allow hal_dumpstate_impl hal_dumpstate_hwservice:hwservice_manager { add find }; +allow hal_dumpstate_impl secd_exec:file read; diff --git a/sepolicy/vendor/hal_fingerprint_default.te b/sepolicy/vendor/hal_fingerprint_default.te index 77fc75a..71b0645 100644 --- a/sepolicy/vendor/hal_fingerprint_default.te +++ b/sepolicy/vendor/hal_fingerprint_default.te @@ -19,4 +19,5 @@ allow hal_fingerprint_default diag_data_file:dir search; allow hal_fingerprint_default fingerprintd_data_file:dir create_dir_perms; allow hal_fingerprint_default sysfs_battery_supply:dir create_dir_perms; allow hal_fingerprint_default fingerprintd_data_file:file create_file_perms; -allow hal_fingerprint_default sysfs_battery_supply:file create_file_perms; \ No newline at end of file +allow hal_fingerprint_default sysfs_battery_supply:file create_file_perms; +allow hal_fingerprint_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_health_default.te b/sepolicy/vendor/hal_health_default.te index ea0c28d..b0eaff8 100644 --- a/sepolicy/vendor/hal_health_default.te +++ b/sepolicy/vendor/hal_health_default.te @@ -1 +1,2 @@ -allow hal_health_default sysfs:file { rw_file_perms }; \ No newline at end of file +allow hal_health_default sysfs:file { rw_file_perms }; +allow hal_health_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_power_stats_default.te b/sepolicy/vendor/hal_power_stats_default.te new file mode 100644 index 0000000..e4fb440 --- /dev/null +++ b/sepolicy/vendor/hal_power_stats_default.te @@ -0,0 +1 @@ +allow hal_power_stats_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/init.te b/sepolicy/vendor/init.te index 5f80bc0..340f6c0 100644 --- a/sepolicy/vendor/init.te +++ b/sepolicy/vendor/init.te @@ -53,3 +53,4 @@ allow init hal_fingerprint_hwservice:hwservice_manager { add find }; allow init iorapd_data_file:file rw_file_perms; allow init system_file:dir relabelfrom; allow init system_file:file { execute_no_trans relabelfrom }; +allow init sysfs_livedisplay_tuneable:file setattr; diff --git a/sepolicy/vendor/iorap_prefetcherd.te b/sepolicy/vendor/iorap_prefetcherd.te new file mode 100644 index 0000000..e7173ff --- /dev/null +++ b/sepolicy/vendor/iorap_prefetcherd.te @@ -0,0 +1 @@ +allow iorap_prefetcherd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/iorapd.te b/sepolicy/vendor/iorapd.te new file mode 100644 index 0000000..8a9b418 --- /dev/null +++ b/sepolicy/vendor/iorapd.te @@ -0,0 +1 @@ +allow iorapd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/platform_app.te b/sepolicy/vendor/platform_app.te index d7fa3af..c8e132f 100644 --- a/sepolicy/vendor/platform_app.te +++ b/sepolicy/vendor/platform_app.te @@ -1 +1,2 @@ allow platform_app system_app_data_file:dir getattr; +allow platform_app exported_camera_prop:file read; diff --git a/sepolicy/vendor/system_server.te b/sepolicy/vendor/system_server.te index 9a57a2d..62d64b3 100644 --- a/sepolicy/vendor/system_server.te +++ b/sepolicy/vendor/system_server.te @@ -15,3 +15,6 @@ allow system_server default_android_service:service_manager find; allow system_server init:binder { call transfer }; allow system_server exfat:dir rw_dir_perms; allow system_server vendor_security_patch_level_prop:file { r_file_perms }; +allow system_server userspace_reboot_config_prop:file { getattr open read }; +allow system_server userspace_reboot_exported_prop:file { getattr open read }; +allow system_server exported_camera_prop:file read; diff --git a/sepolicy/vendor/vendor_install_recovery.te b/sepolicy/vendor/vendor_install_recovery.te new file mode 100644 index 0000000..197298e --- /dev/null +++ b/sepolicy/vendor/vendor_install_recovery.te @@ -0,0 +1,2 @@ +allow vendor_install_recovery block_device:blk_file { open read }; +allow vendor_install_recovery secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vold.te b/sepolicy/vendor/vold.te index 755eff5..90208e5 100644 --- a/sepolicy/vendor/vold.te +++ b/sepolicy/vendor/vold.te @@ -3,3 +3,4 @@ allow vold firmware_file:dir search; allow vold firmware_file:file { getattr open read }; allow vold secd_exec:file { getattr read }; allow vold tee_prop:file { r_file_perms }; +allow vold sysfs_mmc_host:file write; diff --git a/sepolicy/vendor/zygote.te b/sepolicy/vendor/zygote.te index 850d576..52116bf 100644 --- a/sepolicy/vendor/zygote.te +++ b/sepolicy/vendor/zygote.te @@ -1,3 +1,4 @@ allow zygote proc_cmdline:file { getattr open read }; allow zygote secd_exec:file { getattr read }; allow zygote device:file rw_file_perms; +allow zygote exported_camera_prop:file { getattr open read }; -- GitLab From dfa068b706fbba475d4065ff66b93d6c127d5e25 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Thu, 5 Nov 2020 13:39:12 +0100 Subject: [PATCH 068/191] kitakami-common: sepolicy: Changed one more property in cameraserver. Change-Id: I2da9f71b970a1f94db74a2afd7ecf7580744761c --- sepolicy/vendor/cameraserver.te | 1 + 1 file changed, 1 insertion(+) diff --git a/sepolicy/vendor/cameraserver.te b/sepolicy/vendor/cameraserver.te index e64396d..0a113b7 100644 --- a/sepolicy/vendor/cameraserver.te +++ b/sepolicy/vendor/cameraserver.te @@ -16,3 +16,4 @@ allow cameraserver qcamerasvr:unix_dgram_socket sendto; allow cameraserver qcamerasvr:unix_stream_socket connectto; allow cameraserver secd:unix_stream_socket connectto; allow cameraserver secd_exec:file { getattr read }; +allow cameraserver sysfs_battery_supply:dir search; -- GitLab From 1f5726914b7488c457dc39be913e24104b6f621a Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Thu, 5 Nov 2020 16:47:15 +0100 Subject: [PATCH 069/191] kitakami-common: sepolicy: Changed one more property in system_server. Change-Id: I27f466c8b890949cdadab477de9a387843b1c3d6 --- sepolicy/vendor/system_server.te | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sepolicy/vendor/system_server.te b/sepolicy/vendor/system_server.te index 62d64b3..ee499e2 100644 --- a/sepolicy/vendor/system_server.te +++ b/sepolicy/vendor/system_server.te @@ -17,4 +17,4 @@ allow system_server exfat:dir rw_dir_perms; allow system_server vendor_security_patch_level_prop:file { r_file_perms }; allow system_server userspace_reboot_config_prop:file { getattr open read }; allow system_server userspace_reboot_exported_prop:file { getattr open read }; -allow system_server exported_camera_prop:file read; +allow system_server exported_camera_prop:file { r_file_perms }; -- GitLab From 0f1879fb7f7ca8ac5eb7eab60b0adb24900e6532 Mon Sep 17 00:00:00 2001 From: Joel16 Date: Fri, 23 Oct 2020 23:18:06 -0400 Subject: [PATCH 070/191] kitakami-common: Include missing audio resampler lib --- proprietary-files.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/proprietary-files.txt b/proprietary-files.txt index 26a4810..452174a 100644 --- a/proprietary-files.txt +++ b/proprietary-files.txt @@ -5,8 +5,10 @@ vendor/lib/libadsprpc.so vendor/lib/libfastcvopt.so # Audio +lib/libaudioresampler.so lib/soundfx/libsonypostprocbundle.so lib/soundfx/libsonysweffect.so +lib64/libaudioresampler.so vendor/lib/libacdb-fts.so vendor/lib/libacdbloader.so vendor/lib/libacdbrtac.so -- GitLab From 144ee18d54a2400e36556b7f5d420a01e86adc69 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Wed, 4 Nov 2020 17:33:00 +0800 Subject: [PATCH 071/191] kitakami-common: gps: Tweak configs * Max out flp BATCH_SIZE to 40. * Disable izat process. --- gps/flp.conf | 2 +- gps/izat.conf | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gps/flp.conf b/gps/flp.conf index 78f4a62..ba237c9 100644 --- a/gps/flp.conf +++ b/gps/flp.conf @@ -12,7 +12,7 @@ # of batched locations that can be allocated, # which is limited by memory. The default # batch size defined as 20 as below. -BATCH_SIZE=20 +BATCH_SIZE=40 ################################### # FLP BATCHING SESSION TIMEOUT diff --git a/gps/izat.conf b/gps/izat.conf index 52bf9f3..c7f411c 100644 --- a/gps/izat.conf +++ b/gps/izat.conf @@ -137,7 +137,7 @@ WIFI_SUPPLICANT_INFO=DISABLED #DISABLED -> if this process is to be disabled on lean and mean targets PROCESS_NAME=/system/bin/garden_app PROCESS_ARGUMENT=-u 0 -q 0 -j 0 -g 0 -l 0 -Z 0 -T 1 -PROCESS_STATE=ENABLED +PROCESS_STATE=DISABLED PROCESS_GROUPS=gps net_raw PREMIUM_FEATURE=0 IZAT_FEATURE_MASK=0 @@ -147,7 +147,7 @@ LEAN_TARGETS=DISABLED PROCESS_NAME=/system/bin/gpsone_daemon PROCESS_ARGUMENT= -PROCESS_STATE=ENABLED +PROCESS_STATE=DISABLED PROCESS_GROUPS=inet net_raw PREMIUM_FEATURE=0 IZAT_FEATURE_MASK=0 @@ -157,7 +157,7 @@ LEAN_TARGETS=DISABLED PROCESS_NAME=/system/bin/lowi-server PROCESS_ARGUMENT= -PROCESS_STATE=ENABLED +PROCESS_STATE=DISABLED PROCESS_GROUPS=gps net_admin wifi inet oem_2950 net_raw PREMIUM_FEATURE=0 IZAT_FEATURE_MASK=0xf303 @@ -167,7 +167,7 @@ LEAN_TARGETS=DISABLED PROCESS_NAME=/system/bin/xtwifi-inet-agent PROCESS_ARGUMENT= -PROCESS_STATE=ENABLED +PROCESS_STATE=DISABLED PROCESS_GROUPS=inet gps PREMIUM_FEATURE=1 IZAT_FEATURE_MASK=0xc0f @@ -177,7 +177,7 @@ LEAN_TARGETS=DISABLED PROCESS_NAME=/system/bin/xtwifi-client PROCESS_ARGUMENT= -PROCESS_STATE=ENABLED +PROCESS_STATE=DISABLED PROCESS_GROUPS=net_admin wifi inet gps net_raw oem_2952 PREMIUM_FEATURE=1 IZAT_FEATURE_MASK=0xf0f @@ -187,7 +187,7 @@ LEAN_TARGETS=DISABLED PROCESS_NAME=/system/vendor/bin/slim_daemon PROCESS_ARGUMENT= -PROCESS_STATE=ENABLED +PROCESS_STATE=DISABLED PROCESS_GROUPS=gps net_raw oem_2950 PREMIUM_FEATURE=1 IZAT_FEATURE_MASK=0xf0 -- GitLab From 570b938096f3b450e6eda6b790c300bb08f23227 Mon Sep 17 00:00:00 2001 From: Karthik Gopalan Date: Sun, 4 Oct 2020 12:34:13 +0100 Subject: [PATCH 072/191] kitakami-common: memory: Enable SVELTE memory configuration Enable SVELTE memory configuration. Change-Id: I2653de0eb18b207ee453fdd549a5d1a69f3ad33e --- BoardConfigCommon.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index a998b55..9d49ab3 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -176,6 +176,9 @@ TARGET_PROVIDES_KEYMASTER := true # memfd TARGET_HAS_MEMFD_BACKPORT := true +# Memory +MALLOC_SVELTE := true + # NFC NFC_NXP_CHIP_TYPE := PN547C2 BOARD_NFC_CHIPSET := pn547 -- GitLab From 0072f1e2273c7656fb6633b27aac09c0ade44757 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Fri, 6 Nov 2020 14:08:46 +0800 Subject: [PATCH 073/191] Revert "kitakami-common: Force build scudo free 32 bit variant of libc." This reverts commit acb3cf1793247961bd4b94c63bfa05d9317abf30. --- BoardConfigCommon.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 9d49ab3..0ecbf87 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -91,7 +91,6 @@ BOARD_HAVE_BLUETOOTH_BCM := true # Camera TARGET_USES_MEDIA_EXTENSIONS := true -MALLOC_SVELTE_FOR_LIBC32 := true TARGET_PROCESS_SDK_VERSION_OVERRIDE := \ /system/bin/cameraserver=25 \ -- GitLab From 1f0f5b240d1035ca194b70f67c86d69f1ca43e42 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Fri, 6 Nov 2020 13:01:13 +0100 Subject: [PATCH 074/191] kitakami-common: Set USE_CUSTOM_AUDIO_POLICY to "1". Change-Id: I6010e527877a9686abce5afa9250c8a322495b65 --- BoardConfigCommon.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 0ecbf87..e679768 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -80,7 +80,7 @@ AUDIO_FEATURE_ENABLED_PROXY_DEVICE := true AUDIO_USE_LL_AS_PRIMARY_OUTPUT := true BOARD_USES_ALSA_AUDIO := true -USE_CUSTOM_AUDIO_POLICY := 0 +USE_CUSTOM_AUDIO_POLICY := 1 USE_XML_AUDIO_POLICY_CONF := 1 # Bluetooth -- GitLab From 7ea5f56345d2e96970cea07e9d3dd2eb458322a1 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Fri, 6 Nov 2020 13:02:38 +0100 Subject: [PATCH 075/191] kitakami-common: sepolicy: Changed some properties. Change-Id: I04ece21ded9041613de90636a4d2413331e3180c --- sepolicy/vendor/cameraserver.te | 1 + sepolicy/vendor/fsck.te | 1 - sepolicy/vendor/hal_light_default.te | 2 +- sepolicy/vendor/qcamerasvr.te | 1 + 4 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sepolicy/vendor/cameraserver.te b/sepolicy/vendor/cameraserver.te index 0a113b7..a9dde92 100644 --- a/sepolicy/vendor/cameraserver.te +++ b/sepolicy/vendor/cameraserver.te @@ -17,3 +17,4 @@ allow cameraserver qcamerasvr:unix_stream_socket connectto; allow cameraserver secd:unix_stream_socket connectto; allow cameraserver secd_exec:file { getattr read }; allow cameraserver sysfs_battery_supply:dir search; +allow cameraserver sysfs_battery_supply:file { getattr open read } diff --git a/sepolicy/vendor/fsck.te b/sepolicy/vendor/fsck.te index c68ada2..e3d3e4b 100644 --- a/sepolicy/vendor/fsck.te +++ b/sepolicy/vendor/fsck.te @@ -1,7 +1,6 @@ allow fsck diag_partition_device:blk_file { read write }; allow fsck self:capability { dac_override dac_read_search }; allow fsck secd_exec:file { getattr read }; -allow fsck tmpfs:blk_file getattr; allow fsck persist_file:dir getattr; allow fsck persist_file:dir rw_dir_perms; allow fsck tmpfs:blk_file rw_file_perms; diff --git a/sepolicy/vendor/hal_light_default.te b/sepolicy/vendor/hal_light_default.te index bd66cd3..0c7e844 100644 --- a/sepolicy/vendor/hal_light_default.te +++ b/sepolicy/vendor/hal_light_default.te @@ -1,2 +1,2 @@ allow hal_light_default secd_exec:file { getattr read }; -allow hal_light_default sysfs:file { open read write }; +allow hal_light_default sysfs:file rw_file_perms; diff --git a/sepolicy/vendor/qcamerasvr.te b/sepolicy/vendor/qcamerasvr.te index 7f84e40..1883677 100644 --- a/sepolicy/vendor/qcamerasvr.te +++ b/sepolicy/vendor/qcamerasvr.te @@ -21,3 +21,4 @@ allow qcamerasvr ta_data_file:dir search; allow qcamerasvr secd_exec:file { getattr read }; allow qcamerasvr vendor_camera_data_file:dir { add_name remove_name write }; allow qcamerasvr vendor_camera_data_file:sock_file { create unlink }; +allow qcamerasvr hal_graphics_allocator_default:fd use -- GitLab From 4b1b5dec7668a34207629ce5d7318ee8827dc512 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Fri, 6 Nov 2020 14:04:09 +0100 Subject: [PATCH 076/191] kitakami-common: Removed useless entry. Change-Id: I07165a432137fd8ac8ad26b4adca4ca77687ee18 --- device-common.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/device-common.mk b/device-common.mk index bca412b..28d4d90 100644 --- a/device-common.mk +++ b/device-common.mk @@ -151,8 +151,7 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ android.hardware.drm@1.0-impl \ android.hardware.drm@1.0-service \ - android.hardware.drm@1.3-service.clearkey \ - android.hardware.drm@1.3-service.widevine + android.hardware.drm@1.3-service.clearkey # Display PRODUCT_PACKAGES += \ -- GitLab From 0460e3002c2f2de639d580ad2c13a8265ad8c9d8 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Fri, 6 Nov 2020 14:25:05 +0100 Subject: [PATCH 077/191] kitakami-common: camera: Removed useless entry. Change-Id: I1a527daf84155681f850ab59b23db08827fa72d7 --- camera/Android.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/camera/Android.mk b/camera/Android.mk index becb0e1..f6cb53d 100644 --- a/camera/Android.mk +++ b/camera/Android.mk @@ -28,7 +28,6 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libcamera_client \ libgui \ - libhidltransport \ libsensor \ libutils \ libcutils \ -- GitLab From 8b8354e5692cc3aa50a3737fe639fddbc08c1bae Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sun, 24 May 2020 14:46:13 +0200 Subject: [PATCH 078/191] Changed permissions of /dev/qseecom because: E QSEECOMAPI: : Error::Failed to open /dev/qseecom device Change-Id: Ib7dabf4f5457171e3599c64f31917f478081f6d2 --- rootdir/init.qcom.rc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index 9b5c9d6..20b1397 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -50,6 +50,9 @@ on init # default is root radio 0440 chmod 0644 /proc/cmdline + # E: Failed to open /dev/qseecom device + chmod 0666 /dev/qseecom + write /sys/devices/soc.0/f98a4900.sdhci/mmc_host/mmc1/clkgate_delay 1 # Avoid long waits for rcu grace periods write /sys/kernel/rcu_expedited 1 -- GitLab From 2ba45871d63e289c1f926f40d56ed36cbd943529 Mon Sep 17 00:00:00 2001 From: Haran Govindan <32816717+YourDeathWish@users.noreply.github.com> Date: Wed, 12 Dec 2018 12:52:02 +0200 Subject: [PATCH 079/191] kitakami-common: rootdir: Give proper permissions for /dev/diag * This gives proper permission to /dev/diag node so that diag driver can load successfully Before in log: Diag_Lib: Diag_LSM_Init: Failed to open handle to diag driver, error = 13 After in log: Diag_Lib: qpLogDiagInit <== result : 1 Diag_Lib: QMID : gIsQXDMDisabled 0, gIsADBDisabled 1, gIsDebugDisabled 0, gIsIMSLogsDisabled 0 --- rootdir/ueventd.qcom.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootdir/ueventd.qcom.rc b/rootdir/ueventd.qcom.rc index 0d2940e..4267268 100644 --- a/rootdir/ueventd.qcom.rc +++ b/rootdir/ueventd.qcom.rc @@ -27,7 +27,7 @@ # # the DIAG device node is not world writable/readable. -/dev/diag 0660 system oem_2950 +/dev/diag 0666 system oem_2950 /dev/genlock 0666 system system /dev/kgsl 0666 system system -- GitLab From 13ba4b7a7f9ad00014f710603989c35ac16b0d4d Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Tue, 10 Nov 2020 18:14:00 +0100 Subject: [PATCH 080/191] kitakami-common: sepolicy: Completely rewritten due to several error messages! Change-Id: Ie0c3192939e38e56e247b4b9b14b9d24e8ff21fa --- sepolicy/vendor/adbd.te | 1 - sepolicy/vendor/adsprpcd.te | 1 - sepolicy/vendor/apexd.te | 1 - sepolicy/vendor/audioserver.te | 4 - sepolicy/vendor/bootanim.te | 1 - sepolicy/vendor/bootstat.te | 1 - sepolicy/vendor/cameraserver.te | 18 +-- sepolicy/vendor/charger.te | 7 - sepolicy/vendor/crash_dump.te | 2 + sepolicy/vendor/credstore.te | 1 - sepolicy/vendor/device.te | 3 +- sepolicy/vendor/drmserver.te | 1 - sepolicy/vendor/file.te | 28 +--- sepolicy/vendor/file_contexts | 23 ++- sepolicy/vendor/flags_health_check.te | 145 ++++++++++++++++-- sepolicy/vendor/fsck.te | 7 +- sepolicy/vendor/fsck_untrusted.te | 1 - sepolicy/vendor/gatekeeperd.te | 2 - sepolicy/vendor/gpuservice.te | 1 - sepolicy/vendor/hal_audio_default.te | 3 - sepolicy/vendor/hal_bluetooth_default.te | 7 +- sepolicy/vendor/hal_camera_default.te | 4 - sepolicy/vendor/hal_cas_default.te | 1 - sepolicy/vendor/hal_configstore_default.te | 1 - sepolicy/vendor/hal_drm_clearkey.te | 7 +- sepolicy/vendor/hal_drm_default.te | 1 - sepolicy/vendor/hal_drm_widevine.te | 1 - sepolicy/vendor/hal_dumpstate_impl.te | 11 -- sepolicy/vendor/hal_fingerprint_default.te | 29 ++-- .../vendor/hal_graphics_allocator_default.te | 2 - sepolicy/vendor/hal_health_default.te | 3 +- sepolicy/vendor/hal_keymaster_qti.te | 1 - sepolicy/vendor/hal_light_default.te | 3 +- .../vendor/hal_lineage_livedisplay_qti.te | 1 - .../vendor/hal_lineage_livedisplay_sysfs.te | 2 - sepolicy/vendor/hal_lineage_trust_default.te | 1 - sepolicy/vendor/hal_memtrack_default.te | 1 - sepolicy/vendor/hal_power_default.te | 1 - sepolicy/vendor/hal_power_service.te | 3 - sepolicy/vendor/hal_power_stats_default.te | 1 - sepolicy/vendor/hal_ril_default.te | 6 - sepolicy/vendor/hal_ril_wrapper.te | 6 - sepolicy/vendor/hal_usb_default.te | 1 - sepolicy/vendor/hal_wifi_default.te | 5 +- .../vendor/hal_wifi_supplicant_default.te | 1 - sepolicy/vendor/healthd.te | 2 - sepolicy/vendor/hwservicemanager.te | 8 +- sepolicy/vendor/iddd.te | 13 -- sepolicy/vendor/idmap.te | 1 - sepolicy/vendor/incidentd.te | 1 - sepolicy/vendor/init-power-sh.te | 39 ++--- sepolicy/vendor/init.te | 77 ++++------ sepolicy/vendor/installd.te | 2 - sepolicy/vendor/iorap_prefetcherd.te | 1 - sepolicy/vendor/iorapd.te | 1 - sepolicy/vendor/irsc_util.te | 1 - sepolicy/vendor/kernel.te | 6 - sepolicy/vendor/keystore.te | 2 - sepolicy/vendor/lmkd.te | 1 - sepolicy/vendor/loc_launcher.te | 12 +- sepolicy/vendor/logd.te | 1 - sepolicy/vendor/mediacodec.te | 4 - sepolicy/vendor/mediadrmserver.te | 1 - sepolicy/vendor/mediaextractor.te | 1 - sepolicy/vendor/mediametrics.te | 1 - sepolicy/vendor/mediaserver.te | 5 - sepolicy/vendor/mediaswcodec.te | 2 - sepolicy/vendor/mlog_qmi_service.te | 11 +- sepolicy/vendor/msm_irqbalance.te | 7 +- sepolicy/vendor/netd.te | 2 - sepolicy/vendor/netmgrd.te | 4 - sepolicy/vendor/per_mgr.te | 9 +- sepolicy/vendor/per_proxy.te | 8 +- sepolicy/vendor/perfd.te | 3 - sepolicy/vendor/platform_app.te | 2 +- sepolicy/vendor/ppd.te | 22 +-- sepolicy/vendor/priv_app.te | 7 - sepolicy/vendor/property.te | 3 - sepolicy/vendor/property_contexts | 6 +- sepolicy/vendor/qcamerasvr.te | 16 +- sepolicy/vendor/qmuxd.te | 3 - sepolicy/vendor/radio.te | 2 - sepolicy/vendor/recovery_persist.te | 1 - sepolicy/vendor/rild.te | 30 +--- sepolicy/vendor/rmt_storage.te | 1 - sepolicy/vendor/sct_service.te | 9 +- sepolicy/vendor/sdcardd.te | 1 - sepolicy/vendor/secd.te | 17 +- sepolicy/vendor/sensors.te | 7 - sepolicy/vendor/service.te | 1 - sepolicy/vendor/service_contexts | 2 +- sepolicy/vendor/servicemanager.te | 15 +- sepolicy/vendor/shell.te | 109 ------------- sepolicy/vendor/statsd.te | 1 - sepolicy/vendor/surfaceflinger.te | 3 - sepolicy/vendor/system_app.te | 14 +- sepolicy/vendor/system_server.te | 21 +-- sepolicy/vendor/ta_qmi_service.te | 16 +- sepolicy/vendor/tad.te | 9 +- sepolicy/vendor/taimport.te | 12 +- sepolicy/vendor/tee.te | 30 +--- sepolicy/vendor/thermal-engine.te | 9 +- sepolicy/vendor/timekeep.te | 22 +-- sepolicy/vendor/tombstoned.te | 1 - sepolicy/vendor/toolbox.te | 11 +- sepolicy/vendor/tzdatacheck.te | 1 - sepolicy/vendor/ueventd.te | 10 +- sepolicy/vendor/updatemiscta.te | 5 - sepolicy/vendor/usbd.te | 1 - sepolicy/vendor/vdc.te | 1 - sepolicy/vendor/vendor_init.te | 1 - sepolicy/vendor/vendor_install_recovery.te | 2 - sepolicy/vendor/vndservicemanager.te | 1 - sepolicy/vendor/vold.te | 7 +- sepolicy/vendor/vold_prepare_subdirs.te | 1 - sepolicy/vendor/wificond.te | 1 - sepolicy/vendor/zygote.te | 4 +- 117 files changed, 307 insertions(+), 708 deletions(-) delete mode 100644 sepolicy/vendor/adbd.te delete mode 100644 sepolicy/vendor/adsprpcd.te delete mode 100644 sepolicy/vendor/apexd.te delete mode 100644 sepolicy/vendor/audioserver.te delete mode 100644 sepolicy/vendor/bootstat.te delete mode 100644 sepolicy/vendor/charger.te create mode 100644 sepolicy/vendor/crash_dump.te delete mode 100644 sepolicy/vendor/credstore.te delete mode 100644 sepolicy/vendor/drmserver.te delete mode 100644 sepolicy/vendor/fsck_untrusted.te delete mode 100644 sepolicy/vendor/gatekeeperd.te delete mode 100644 sepolicy/vendor/gpuservice.te delete mode 100644 sepolicy/vendor/hal_audio_default.te delete mode 100644 sepolicy/vendor/hal_camera_default.te delete mode 100644 sepolicy/vendor/hal_cas_default.te delete mode 100644 sepolicy/vendor/hal_configstore_default.te delete mode 100644 sepolicy/vendor/hal_drm_default.te delete mode 100644 sepolicy/vendor/hal_drm_widevine.te delete mode 100644 sepolicy/vendor/hal_dumpstate_impl.te delete mode 100644 sepolicy/vendor/hal_graphics_allocator_default.te delete mode 100644 sepolicy/vendor/hal_keymaster_qti.te delete mode 100644 sepolicy/vendor/hal_lineage_livedisplay_sysfs.te delete mode 100644 sepolicy/vendor/hal_lineage_trust_default.te delete mode 100644 sepolicy/vendor/hal_memtrack_default.te delete mode 100644 sepolicy/vendor/hal_power_service.te delete mode 100644 sepolicy/vendor/hal_power_stats_default.te delete mode 100644 sepolicy/vendor/hal_ril_default.te delete mode 100644 sepolicy/vendor/hal_ril_wrapper.te delete mode 100644 sepolicy/vendor/hal_usb_default.te delete mode 100644 sepolicy/vendor/hal_wifi_supplicant_default.te delete mode 100644 sepolicy/vendor/healthd.te delete mode 100644 sepolicy/vendor/idmap.te delete mode 100644 sepolicy/vendor/incidentd.te delete mode 100644 sepolicy/vendor/installd.te delete mode 100644 sepolicy/vendor/iorap_prefetcherd.te delete mode 100644 sepolicy/vendor/iorapd.te delete mode 100644 sepolicy/vendor/irsc_util.te delete mode 100644 sepolicy/vendor/kernel.te delete mode 100644 sepolicy/vendor/keystore.te delete mode 100644 sepolicy/vendor/lmkd.te delete mode 100644 sepolicy/vendor/logd.te delete mode 100644 sepolicy/vendor/mediacodec.te delete mode 100644 sepolicy/vendor/mediadrmserver.te delete mode 100644 sepolicy/vendor/mediaextractor.te delete mode 100644 sepolicy/vendor/mediametrics.te delete mode 100644 sepolicy/vendor/mediaserver.te delete mode 100644 sepolicy/vendor/mediaswcodec.te delete mode 100644 sepolicy/vendor/netd.te delete mode 100644 sepolicy/vendor/netmgrd.te delete mode 100644 sepolicy/vendor/perfd.te delete mode 100644 sepolicy/vendor/priv_app.te delete mode 100644 sepolicy/vendor/qmuxd.te delete mode 100644 sepolicy/vendor/radio.te delete mode 100644 sepolicy/vendor/recovery_persist.te delete mode 100644 sepolicy/vendor/rmt_storage.te delete mode 100644 sepolicy/vendor/sdcardd.te delete mode 100644 sepolicy/vendor/sensors.te delete mode 100644 sepolicy/vendor/service.te delete mode 100644 sepolicy/vendor/shell.te delete mode 100644 sepolicy/vendor/statsd.te delete mode 100644 sepolicy/vendor/tombstoned.te delete mode 100644 sepolicy/vendor/tzdatacheck.te delete mode 100644 sepolicy/vendor/usbd.te delete mode 100644 sepolicy/vendor/vdc.te delete mode 100644 sepolicy/vendor/vendor_init.te delete mode 100644 sepolicy/vendor/vendor_install_recovery.te delete mode 100644 sepolicy/vendor/vndservicemanager.te delete mode 100644 sepolicy/vendor/vold_prepare_subdirs.te delete mode 100644 sepolicy/vendor/wificond.te diff --git a/sepolicy/vendor/adbd.te b/sepolicy/vendor/adbd.te deleted file mode 100644 index e78f756..0000000 --- a/sepolicy/vendor/adbd.te +++ /dev/null @@ -1 +0,0 @@ -allow adbd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/adsprpcd.te b/sepolicy/vendor/adsprpcd.te deleted file mode 100644 index 365465b..0000000 --- a/sepolicy/vendor/adsprpcd.te +++ /dev/null @@ -1 +0,0 @@ -allow adsprpcd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/apexd.te b/sepolicy/vendor/apexd.te deleted file mode 100644 index a1e4b88..0000000 --- a/sepolicy/vendor/apexd.te +++ /dev/null @@ -1 +0,0 @@ -allow apexd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/audioserver.te b/sepolicy/vendor/audioserver.te deleted file mode 100644 index e2c2a8a..0000000 --- a/sepolicy/vendor/audioserver.te +++ /dev/null @@ -1,4 +0,0 @@ -allow audioserver tad_socket:sock_file write; -allow audioserver perfd:unix_stream_socket connectto; -allow audioserver socket_device:sock_file write; -allow audioserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/bootanim.te b/sepolicy/vendor/bootanim.te index 9d50ea1..1fccd3b 100644 --- a/sepolicy/vendor/bootanim.te +++ b/sepolicy/vendor/bootanim.te @@ -1,2 +1 @@ -allow bootanim secd_exec:file { getattr read }; allow bootanim userspace_reboot_exported_prop:file { getattr open read }; diff --git a/sepolicy/vendor/bootstat.te b/sepolicy/vendor/bootstat.te deleted file mode 100644 index 0198e07..0000000 --- a/sepolicy/vendor/bootstat.te +++ /dev/null @@ -1 +0,0 @@ -allow bootstat secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/cameraserver.te b/sepolicy/vendor/cameraserver.te index a9dde92..b1576db 100644 --- a/sepolicy/vendor/cameraserver.te +++ b/sepolicy/vendor/cameraserver.te @@ -1,20 +1,6 @@ -allow cameraserver camera_data_file:sock_file write; -allow cameraserver gpu_device:chr_file rw_file_perms; -allow cameraserver perfd:unix_stream_socket connectto; -allow cameraserver rootfs:lnk_file getattr; -allow cameraserver sysfs_camera_torch:file rw_file_perms; -allow cameraserver sysfs_camera_torch:dir search; -allow cameraserver sysfs_camera_torch:lnk_file read; -allow cameraserver ta_data_file:dir search; -allow cameraserver secd_socket:sock_file write; allow cameraserver hal_configstore_ISurfaceFlingerConfigs:hwservice_manager find; -allow cameraserver hal_configstore_default:binder call; -allow cameraserver socket_device:sock_file write; -allow cameraserver sysfs_graphics:file { getattr open read }; allow cameraserver init:unix_dgram_socket sendto; allow cameraserver qcamerasvr:unix_dgram_socket sendto; allow cameraserver qcamerasvr:unix_stream_socket connectto; -allow cameraserver secd:unix_stream_socket connectto; -allow cameraserver secd_exec:file { getattr read }; -allow cameraserver sysfs_battery_supply:dir search; -allow cameraserver sysfs_battery_supply:file { getattr open read } +allow cameraserver sysfs_graphics:file { getattr open read }; +allow cameraserver ta_data_file:dir search; diff --git a/sepolicy/vendor/charger.te b/sepolicy/vendor/charger.te deleted file mode 100644 index b07eeee..0000000 --- a/sepolicy/vendor/charger.te +++ /dev/null @@ -1,7 +0,0 @@ -allow charger self:capability { dac_override dac_read_search }; -allow charger sysfs:file { open read getattr }; -allow charger sysfs_usb_supply:file { open read getattr }; -allow charger sysfs_battery_supply:file { open read getattr }; -allow charger device:dir { open read }; -allow charger persist_block_device:file { create rw_file_perms }; -allow charger system_file:file { entrypoint read execute getattr }; diff --git a/sepolicy/vendor/crash_dump.te b/sepolicy/vendor/crash_dump.te new file mode 100644 index 0000000..1b4554e --- /dev/null +++ b/sepolicy/vendor/crash_dump.te @@ -0,0 +1,2 @@ +allow crash_dump camera_prop:file { getattr open }; +allow crash_dump init:process ptrace; diff --git a/sepolicy/vendor/credstore.te b/sepolicy/vendor/credstore.te deleted file mode 100644 index 48eb746..0000000 --- a/sepolicy/vendor/credstore.te +++ /dev/null @@ -1 +0,0 @@ -allow credstore secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/device.te b/sepolicy/vendor/device.te index d5da1bc..3e6c456 100644 --- a/sepolicy/vendor/device.te +++ b/sepolicy/vendor/device.te @@ -1,3 +1,2 @@ -type trim_area_partition_device, dev_type; -type diag_partition_device, dev_type; type subsys_modem_device, dev_type; +type trim_area_partition_device, dev_type; diff --git a/sepolicy/vendor/drmserver.te b/sepolicy/vendor/drmserver.te deleted file mode 100644 index a00eeb3..0000000 --- a/sepolicy/vendor/drmserver.te +++ /dev/null @@ -1 +0,0 @@ -allow drmserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/file.te b/sepolicy/vendor/file.te index 7365abe..00787e5 100644 --- a/sepolicy/vendor/file.te +++ b/sepolicy/vendor/file.te @@ -1,23 +1,11 @@ -# TAD -type tad_socket, file_type; -type ta_data_file, file_type; -type secd_socket, file_type; +type diag_partition_device, file_type; +type fpc_data_file, file_type; type secd_data_file, file_type; - -# Timekeep -type timekeep_data_file, file_type, data_file_type; -type sysfs_timekeep, fs_type, sysfs_type; - -# Macaddr +type secd_socket, file_type; type sysfs_addrsetup, fs_type, sysfs_type; -type proc_kernel_sched, fs_type; type sysfs_camera_torch, sysfs_type, file_type; -type sysfs_performance, sysfs_type, fs_type; -type sysfs_msm_subsys, sysfs_type, fs_type; - -# Fingerprint -type fpc_data_file, file_type; - -# Camera -type sysfs_camera, sysfs_type, fs_type; - +type sysfs_performance, sysfs_type, file_type; +type sysfs_timekeep, fs_type, sysfs_type; +type tad_socket, file_type; +type ta_data_file, file_type; +type timekeep_data_file, file_type, data_file_type; diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 856bbb6..d86551a 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -19,16 +19,13 @@ /sys/devices/platform/bcmdhd_wlan/macaddr u:object_r:sysfs_addrsetup:s0 /sys/devices(/soc\.0)?/bcmdhd_wlan.83/macaddr u:object_r:sysfs_addrsetup:s0 -# Camera -/sys/devices(/soc\.0)?/pmi8994-flash-27(/.*)? u:object_r:sysfs_camera_torch:s0 - -# Dumpstate HAL -/(vendor|system/vendor)/bin/hw/android\.hardware\.dumpstate@1\.1-service-kitakami u:object_r:hal_dumpstate_impl_exec:s0 - # DRM /(vendor|system/vendor)/bin/hw/android\.hardware\.drm@1\.3-service.clearkey u:object_r:hal_drm_clearkey_exec:s0 /(vendor|system/vendor)/bin/hw/android\.hardware\.drm@1\.3-service.widevine u:object_r:hal_drm_widevine_exec:s0 +# Camera +/sys/devices(/soc\.0)?/pmi8994-flash-27(/.*)? u:object_r:sysfs_camera_torch:s0 + # HCI /dev/ttyHS0 u:object_r:hci_attach_dev:s0 /dev/brcm_bt_drv u:object_r:hci_attach_dev:s0 @@ -39,13 +36,13 @@ /data/etc u:object_r:ta_data_file:s0 /data/etc(/.*) u:object_r:ta_data_file:s0 -# Fingerprint -/(vendor|system/vendor)/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.1-service.kitakami u:object_r:hal_fingerprint_default_exec:s0 - # Fingerprint sensor SPI device /data/fpc(/.*)? u:object_r:fpc_data_file:s0 /data/fpcd(/.*)? u:object_r:fpc_data_file:s0 +# Fingerprint +/(vendor|system/vendor)/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.1-service.kitakami u:object_r:hal_fingerprint_default_exec:s0 + # TA /dev/socket/tad u:object_r:tad_socket:s0 /dev/socket/secd_credmgr_sock u:object_r:secd_socket:s0 @@ -57,12 +54,12 @@ /idd(/.*)? u:object_r:diag_data_file:s0 /rca(/.*)? u:object_r:firmware_file:s0 -# Power Stats -/(vendor|system/vendor)/bin/hw/android\.hardware\.power\.stats@1\.0-service\.mock u:object_r:hal_power_stats_default_exec:s0 - # TimeKeep /data/time(/.*) u:object_r:timekeep_data_file:s0 +# Power Stats +/(vendor|system/vendor)/bin/hw/android\.hardware\.power\.stats@1\.0-service\.mock u:object_r:hal_power_stats_default_exec:s0 + # Misc /system/bin/adsprpcd u:object_r:adsprpcd_exec:s0 /system/bin/iddd u:object_r:iddd_exec:s0 @@ -89,5 +86,3 @@ /system/vendor/bin/perfd u:object_r:perfd_exec:s0 /system/vendor/bin/timekeep u:object_r:timekeep_exec:s0 -/system/vendor/(lib|lib64)/libril-wrapper\.so u:object_r:hal_ril_wrapper_exec:s0 - diff --git a/sepolicy/vendor/flags_health_check.te b/sepolicy/vendor/flags_health_check.te index d3fe883..7b23ee5 100644 --- a/sepolicy/vendor/flags_health_check.te +++ b/sepolicy/vendor/flags_health_check.te @@ -1,25 +1,152 @@ +allow flags_health_check adbd_prop:file { getattr open }; allow flags_health_check alarm_boot_prop:file { getattr open }; allow flags_health_check alarm_handled_prop:file { getattr open }; +allow flags_health_check alarm_instance_prop:file { getattr open }; +allow flags_health_check apexd_prop:file { getattr open }; +allow flags_health_check apk_verity_prop:file { getattr open }; +allow flags_health_check bg_boot_complete_prop:file { getattr open }; +allow flags_health_check bg_daemon_prop:file { getattr open }; +allow flags_health_check bluetooth_a2dp_offload_prop:file { getattr open }; +allow flags_health_check bluetooth_audio_hal_prop:file { getattr open }; +allow flags_health_check bluetooth_prop:file { getattr open }; +allow flags_health_check boot_animation_prop:file { getattr open }; +allow flags_health_check boot_mode_prop:file { getattr open }; +allow flags_health_check bootloader_boot_reason_prop:file { getattr open }; +allow flags_health_check boottime_prop:file { getattr open }; +allow flags_health_check boottime_public_prop:file { getattr open }; +allow flags_health_check bpf_progs_loaded_prop:file { getattr open }; +allow flags_health_check bservice_prop:file { getattr open }; +allow flags_health_check camera_prop:file { getattr open }; +allow flags_health_check charger_prop:file { getattr open }; +allow flags_health_check cold_boot_done_prop:file { getattr open }; +allow flags_health_check coresight_prop:file { getattr open }; +allow flags_health_check cpu_variant_prop:file { getattr open }; allow flags_health_check crash_prop:file { getattr open }; allow flags_health_check ctl_LKCore_prop:file { getattr open }; allow flags_health_check ctl_adbd_prop:file { getattr open }; +allow flags_health_check ctl_apexd_prop:file { getattr open }; +allow flags_health_check ctl_bootanim_prop:file { getattr open }; +allow flags_health_check ctl_bugreport_prop:file { getattr open }; +allow flags_health_check ctl_console_prop:file { getattr open }; +allow flags_health_check ctl_default_prop:file { getattr open }; +allow flags_health_check ctl_dumpstate_prop:file { getattr open }; +allow flags_health_check ctl_fuse_prop:file { getattr open read }; +allow flags_health_check ctl_gsid_prop:file { getattr open }; +allow flags_health_check ctl_hbtp_prop:file { getattr open }; +allow flags_health_check ctl_interface_restart_prop:file { getattr open }; allow flags_health_check ctl_interface_start_prop:file { getattr open }; -allow flags_health_check ctl_interface_stop_prop:file open; -allow flags_health_check ctl_vendor_wigigsvc_prop:file open; -allow flags_health_check qemu_gles_prop:file getattr; -allow flags_health_check qti_prop:file open; -allow flags_health_check scr_enabled_prop:file getattr; +allow flags_health_check ctl_interface_stop_prop:file { getattr open }; +allow flags_health_check ctl_mdnsd_prop:file { getattr open }; +allow flags_health_check ctl_netmgrd_prop:file { getattr open }; +allow flags_health_check ctl_port-bridge_prop:file { getattr open }; +allow flags_health_check ctl_qmuxd_prop:file { getattr open }; +allow flags_health_check ctl_restart_prop:file { getattr open }; +allow flags_health_check ctl_rildaemon_prop:file { getattr open }; +allow flags_health_check ctl_sigstop_prop:file { getattr open }; +allow flags_health_check ctl_start_prop:file { getattr open }; +allow flags_health_check ctl_stop_prop:file { getattr open }; +allow flags_health_check ctl_vendor_imsrcsservice_prop:file { getattr open }; +allow flags_health_check ctl_vendor_wigigsvc_prop:file { getattr open }; +allow flags_health_check device_logging_prop:file { getattr open }; +allow flags_health_check diag_mdlog_prop:file { getattr open }; +allow flags_health_check dolby_prop:file { getattr open }; +allow flags_health_check dumpstate_options_prop:file { getattr open }; +allow flags_health_check dynamic_system_prop:file { getattr open }; +allow flags_health_check exported_audio_prop:file { getattr open }; +allow flags_health_check exported_bluetooth_prop:file { getattr open }; +allow flags_health_check exported_camera_prop:file { getattr open }; +allow flags_health_check exported_overlay_prop:file { getattr open }; +allow flags_health_check exported_wifi_prop:file { getattr open }; +allow flags_health_check fastbootd_protocol_prop:file { getattr open }; +allow flags_health_check firstboot_prop:file { getattr open }; +allow flags_health_check fm_prop:file { getattr open }; +allow flags_health_check freq_prop:file { getattr open }; +allow flags_health_check fst_prop:file { getattr open }; +allow flags_health_check gamed_prop:file { getattr open }; +allow flags_health_check graphics_config_prop:file { getattr open }; +allow flags_health_check graphics_vulkan_prop:file { getattr open }; +allow flags_health_check gsid_prop:file { getattr open }; +allow flags_health_check heapprofd_enabled_prop:file { getattr open }; +allow flags_health_check hwservicemanager_prop:file { getattr open }; +allow flags_health_check hwui_prop:file { getattr open }; +allow flags_health_check incremental_prop:file { getattr open }; +allow flags_health_check init_perf_lsm_hooks_prop:file { getattr open }; +allow flags_health_check init_svc_debug_prop:file { getattr open }; +allow flags_health_check ipacm-diag_prop:file { getattr open }; +allow flags_health_check ipacm_prop:file { getattr open }; +allow flags_health_check last_boot_reason_prop:file { getattr open }; +allow flags_health_check llkd_prop:file { getattr open }; +allow flags_health_check lmkd_prop:file { getattr open }; +allow flags_health_check location_prop:file { getattr open }; +allow flags_health_check logpersistd_logging_prop:file { getattr open }; +allow flags_health_check lowpan_prop:file { getattr open }; +allow flags_health_check lpdumpd_prop:file { getattr open }; +allow flags_health_check mdm_helper_prop:file { getattr open }; +allow flags_health_check media_variant_prop:file { getattr open }; +allow flags_health_check mmc_prop:file { getattr open }; +allow flags_health_check mmi_prop:file { getattr open }; +allow flags_health_check mock_ota_prop:file { getattr open }; +allow flags_health_check mpdecision_prop:file { getattr open }; +allow flags_health_check msm_irqbalance_prop:file { getattr open }; +allow flags_health_check msm_irqbl_sdm630_prop:file { getattr open }; +allow flags_health_check net_dns_prop:file { getattr open }; +allow flags_health_check netd_prop:file { getattr open }; +allow flags_health_check netd_stable_secret_prop:file { getattr open }; +allow flags_health_check nfc_nq_prop:file { getattr open }; +allow flags_health_check nnapi_ext_deny_product_prop:file { getattr open }; +allow flags_health_check opengles_prop:file { getattr open }; +allow flags_health_check overlay_prop:file { getattr open }; +allow flags_health_check per_mgr_state_prop:file { getattr open }; +allow flags_health_check perfd_prop:file { getattr open }; +allow flags_health_check persistent_properties_ready_prop:file { getattr open }; +allow flags_health_check postprocessing_prop:file { getattr open }; +allow flags_health_check ppd_prop:file { getattr open }; +allow flags_health_check qcom_ims_prop:file { getattr open }; +allow flags_health_check qdma_prop:file { getattr open }; +allow flags_health_check qemu_gles_prop:file { getattr open }; +allow flags_health_check qti_prop:file { getattr open }; +allow flags_health_check rebootescrow_hal_prop:file { getattr open }; +allow flags_health_check reschedule_service_prop:file { getattr open }; +allow flags_health_check rmnet_mux_prop:file { getattr open }; +allow flags_health_check safemode_prop:file { getattr open }; +allow flags_health_check scr_enabled_prop:file { getattr open }; allow flags_health_check sdm_idle_time_prop:file { getattr open }; allow flags_health_check sensors_prop:file { getattr open }; allow flags_health_check serialno_prop:file { getattr open }; allow flags_health_check spcomlib_prop:file { getattr open }; +allow flags_health_check storage_config_prop:file { getattr open }; +allow flags_health_check surfaceflinger_display_prop:file { getattr open }; allow flags_health_check sys_usb_configfs_prop:file { getattr open }; allow flags_health_check sys_usb_controller_prop:file { getattr open }; allow flags_health_check sys_usb_tethering_prop:file { getattr open }; +allow flags_health_check system_adbd_prop:file { getattr open }; allow flags_health_check system_boot_reason_prop:file { getattr open }; +allow flags_health_check system_jvmti_agent_prop:file { getattr open read }; allow flags_health_check system_lmk_prop:file { getattr open }; +allow flags_health_check system_trace_prop:file { getattr open }; allow flags_health_check test_boot_reason_prop:file { getattr open }; -allow flags_health_check alarm_instance_prop:file { getattr open }; -allow flags_health_check apexd_prop:file { getattr open }; -allow flags_health_check bg_boot_complete_prop:file { getattr open }; -allow flags_health_check secd_exec:file { getattr read }; +allow flags_health_check test_harness_prop:file { getattr open }; +allow flags_health_check theme_prop:file { getattr open }; +allow flags_health_check time_prop:file { getattr open }; +allow flags_health_check traced_enabled_prop:file { getattr open }; +allow flags_health_check traced_lazy_prop:file { getattr open }; +allow flags_health_check traced_perf_enabled_prop:file { getattr open }; +allow flags_health_check uicc_prop:file { getattr open }; +allow flags_health_check userspace_reboot_config_prop:file { getattr open }; +allow flags_health_check userspace_reboot_exported_prop:file { getattr open }; +allow flags_health_check userspace_reboot_log_prop:file { getattr open }; +allow flags_health_check userspace_reboot_test_prop:file { getattr open }; +allow flags_health_check usf_prop:file { getattr open }; +allow flags_health_check vehicle_hal_prop:file { getattr open }; +allow flags_health_check vendor_mpctl_prop:file { getattr open }; +allow flags_health_check vendor_rild_libpath_prop:file { getattr open }; +allow flags_health_check vendor_security_patch_level_prop:file { getattr open }; +allow flags_health_check vendor_system_prop:file { getattr open }; +allow flags_health_check vendor_wifi_prop:file { getattr open }; +allow flags_health_check vendor_wifi_version:file { getattr open }; +allow flags_health_check virtual_ab_prop:file { getattr open }; +allow flags_health_check vm_bms_prop:file { getattr open }; +allow flags_health_check wifi_prop:file { getattr open }; +allow flags_health_check wififtmd_prop:file { getattr open }; +allow flags_health_check wigig_prop:file { getattr open }; +allow flags_health_check xlat_prop:file { getattr open }; diff --git a/sepolicy/vendor/fsck.te b/sepolicy/vendor/fsck.te index e3d3e4b..f8c4fc8 100644 --- a/sepolicy/vendor/fsck.te +++ b/sepolicy/vendor/fsck.te @@ -1,6 +1 @@ -allow fsck diag_partition_device:blk_file { read write }; -allow fsck self:capability { dac_override dac_read_search }; -allow fsck secd_exec:file { getattr read }; -allow fsck persist_file:dir getattr; -allow fsck persist_file:dir rw_dir_perms; -allow fsck tmpfs:blk_file rw_file_perms; +allow fsck block_device:blk_file { read write }; diff --git a/sepolicy/vendor/fsck_untrusted.te b/sepolicy/vendor/fsck_untrusted.te deleted file mode 100644 index 06445b3..0000000 --- a/sepolicy/vendor/fsck_untrusted.te +++ /dev/null @@ -1 +0,0 @@ -allow fsck_untrusted vold_device:blk_file ioctl; diff --git a/sepolicy/vendor/gatekeeperd.te b/sepolicy/vendor/gatekeeperd.te deleted file mode 100644 index 0c9feaa..0000000 --- a/sepolicy/vendor/gatekeeperd.te +++ /dev/null @@ -1,2 +0,0 @@ -allow gatekeeperd tee_prop:file { getattr open read }; -allow gatekeeperd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/gpuservice.te b/sepolicy/vendor/gpuservice.te deleted file mode 100644 index 72bb0a8..0000000 --- a/sepolicy/vendor/gpuservice.te +++ /dev/null @@ -1 +0,0 @@ -allow gpuservice secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_audio_default.te b/sepolicy/vendor/hal_audio_default.te deleted file mode 100644 index 0b91688..0000000 --- a/sepolicy/vendor/hal_audio_default.te +++ /dev/null @@ -1,3 +0,0 @@ -allow hal_audio_default tad_socket:sock_file { create_file_perms write }; -allow hal_audio_default secd_exec:file { getattr read }; -allow hal_audio_default tad:unix_stream_socket connectto; diff --git a/sepolicy/vendor/hal_bluetooth_default.te b/sepolicy/vendor/hal_bluetooth_default.te index 49bf694..bc98076 100644 --- a/sepolicy/vendor/hal_bluetooth_default.te +++ b/sepolicy/vendor/hal_bluetooth_default.te @@ -1,7 +1,6 @@ +allow hal_bluetooth_default firmware_file:dir search; allow hal_bluetooth_default firmware_file:file { open read }; allow hal_bluetooth_default sysfs:file write; allow hal_bluetooth_default system_data_file:file { open read }; -allow hal_bluetooth_default firmware_file:dir search; -allow hal_bluetooth_default ta_data_file:dir search; -allow hal_bluetooth_default ta_data_file:file { open read }; -allow hal_bluetooth_default secd_exec:file { getattr read }; +allow hal_bluetooth_default ta_data_file:dir { read search }; +allow hal_bluetooth_default ta_data_file:file { open read }; diff --git a/sepolicy/vendor/hal_camera_default.te b/sepolicy/vendor/hal_camera_default.te deleted file mode 100644 index d487c22..0000000 --- a/sepolicy/vendor/hal_camera_default.te +++ /dev/null @@ -1,4 +0,0 @@ -allow hal_camera_default camera_data_file:sock_file write; -allow hal_camera_default hal_configstore_ISurfaceFlingerConfigs:hwservice_manager find; -allow hal_camera_default hal_configstore_default:binder call; -allow hal_camera_default socket_device:sock_file write; diff --git a/sepolicy/vendor/hal_cas_default.te b/sepolicy/vendor/hal_cas_default.te deleted file mode 100644 index d9855aa..0000000 --- a/sepolicy/vendor/hal_cas_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_cas_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_configstore_default.te b/sepolicy/vendor/hal_configstore_default.te deleted file mode 100644 index 08a5161..0000000 --- a/sepolicy/vendor/hal_configstore_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_configstore_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_drm_clearkey.te b/sepolicy/vendor/hal_drm_clearkey.te index b4753cc..c0ecc94 100644 --- a/sepolicy/vendor/hal_drm_clearkey.te +++ b/sepolicy/vendor/hal_drm_clearkey.te @@ -1,11 +1,10 @@ type hal_drm_clearkey, domain; -hwbinder_use(hal_drm_clearkey) -vndbinder_use(hal_drm_clearkey) +type hal_drm_clearkey_exec, exec_type, file_type; -type hal_drm_clearkey_exec, exec_type, vendor_file_type, file_type; +# Started by init init_daemon_domain(hal_drm_clearkey) allow hal_drm_clearkey hal_drm_hwservice:hwservice_manager { add find }; allow hal_drm_clearkey hidl_base_hwservice:hwservice_manager add; +allow hal_drm_clearkey hwservicemanager:binder { call transfer }; allow hal_drm_clearkey hwservicemanager_prop:file { getattr open read }; -allow hal_drm_clearkey secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_drm_default.te b/sepolicy/vendor/hal_drm_default.te deleted file mode 100644 index 9e8cbf8..0000000 --- a/sepolicy/vendor/hal_drm_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_drm_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_drm_widevine.te b/sepolicy/vendor/hal_drm_widevine.te deleted file mode 100644 index 3c756f7..0000000 --- a/sepolicy/vendor/hal_drm_widevine.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_drm_widevine secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_dumpstate_impl.te b/sepolicy/vendor/hal_dumpstate_impl.te deleted file mode 100644 index a602598..0000000 --- a/sepolicy/vendor/hal_dumpstate_impl.te +++ /dev/null @@ -1,11 +0,0 @@ -type hal_dumpstate_impl, domain; -type hal_dumpstate_impl_exec, exec_type, file_type, vendor_file_type; - -init_daemon_domain(hal_dumpstate_impl) - -allow hal_dumpstate_impl hal_dumpstate_impl_exec:file execute_no_trans; -allow hal_dumpstate_impl hwservicemanager:binder { call transfer }; -allow hal_dumpstate_impl hwservicemanager_prop:file { getattr map open read }; -allow hal_dumpstate_impl hidl_base_hwservice:hwservice_manager add; -allow hal_dumpstate_impl hal_dumpstate_hwservice:hwservice_manager { add find }; -allow hal_dumpstate_impl secd_exec:file read; diff --git a/sepolicy/vendor/hal_fingerprint_default.te b/sepolicy/vendor/hal_fingerprint_default.te index 71b0645..7520e4b 100644 --- a/sepolicy/vendor/hal_fingerprint_default.te +++ b/sepolicy/vendor/hal_fingerprint_default.te @@ -1,23 +1,16 @@ -allow hal_fingerprint_default tee_device:chr_file ioctl; +allow hal_fingerprint_default diag_data_file:dir search; +allow hal_fingerprint_default fingerprintd_data_file:dir { add_name remove_name search write }; +allow hal_fingerprint_default fingerprintd_data_file:file { create getattr open read rename unlink write }; allow hal_fingerprint_default firmware_file:dir search; -allow hal_fingerprint_default sysfs:file write; -allow hal_fingerprint_default tee_device:chr_file { open read write }; allow hal_fingerprint_default firmware_file:file { getattr open read }; +allow hal_fingerprint_default firmware_file:lnk_file read; +allow hal_fingerprint_default fpc_data_file:dir { add_name remove_name search write }; +allow hal_fingerprint_default fpc_data_file:sock_file { create unlink }; allow hal_fingerprint_default input_device:chr_file { ioctl open read }; -allow hal_fingerprint_default input_device:dir { open read }; +allow hal_fingerprint_default input_device:dir { open read search }; +allow hal_fingerprint_default sysfs:file write; +allow hal_fingerprint_default sysfs_battery_supply:dir search; +allow hal_fingerprint_default sysfs_battery_supply:file { getattr open read }; allow hal_fingerprint_default system_data_file:dir { add_name remove_name write }; allow hal_fingerprint_default system_data_file:sock_file { create unlink }; -allow hal_fingerprint_default diag_data_file:sock_file write; -allow hal_fingerprint_default fpc_data_file:dir { add_name remove_name write }; -allow hal_fingerprint_default fpc_data_file:sock_file { create unlink }; -allow hal_fingerprint_default init:unix_dgram_socket sendto; -allow hal_fingerprint_default iddd:unix_dgram_socket sendto; -allow hal_fingerprint_default firmware_file:lnk_file read; -allow hal_fingerprint_default fpc_data_file:dir search; -allow hal_fingerprint_default input_device:dir search; -allow hal_fingerprint_default diag_data_file:dir search; -allow hal_fingerprint_default fingerprintd_data_file:dir create_dir_perms; -allow hal_fingerprint_default sysfs_battery_supply:dir create_dir_perms; -allow hal_fingerprint_default fingerprintd_data_file:file create_file_perms; -allow hal_fingerprint_default sysfs_battery_supply:file create_file_perms; -allow hal_fingerprint_default secd_exec:file { getattr read }; +allow hal_fingerprint_default tee_device:chr_file { ioctl open read write }; diff --git a/sepolicy/vendor/hal_graphics_allocator_default.te b/sepolicy/vendor/hal_graphics_allocator_default.te deleted file mode 100644 index 747f5f9..0000000 --- a/sepolicy/vendor/hal_graphics_allocator_default.te +++ /dev/null @@ -1,2 +0,0 @@ -allow hal_graphics_allocator_default sysfs_graphics:file { getattr open read }; -allow hal_graphics_allocator_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_health_default.te b/sepolicy/vendor/hal_health_default.te index b0eaff8..64e4b19 100644 --- a/sepolicy/vendor/hal_health_default.te +++ b/sepolicy/vendor/hal_health_default.te @@ -1,2 +1 @@ -allow hal_health_default sysfs:file { rw_file_perms }; -allow hal_health_default secd_exec:file { getattr read }; +allow hal_health_default sysfs:file { getattr open read }; diff --git a/sepolicy/vendor/hal_keymaster_qti.te b/sepolicy/vendor/hal_keymaster_qti.te deleted file mode 100644 index bdb3e7e..0000000 --- a/sepolicy/vendor/hal_keymaster_qti.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_keymaster_qti secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_light_default.te b/sepolicy/vendor/hal_light_default.te index 0c7e844..c9b8d45 100644 --- a/sepolicy/vendor/hal_light_default.te +++ b/sepolicy/vendor/hal_light_default.te @@ -1,2 +1 @@ -allow hal_light_default secd_exec:file { getattr read }; -allow hal_light_default sysfs:file rw_file_perms; +allow hal_light_default sysfs:file { open read write }; diff --git a/sepolicy/vendor/hal_lineage_livedisplay_qti.te b/sepolicy/vendor/hal_lineage_livedisplay_qti.te index 3501957..79c0f35 100644 --- a/sepolicy/vendor/hal_lineage_livedisplay_qti.te +++ b/sepolicy/vendor/hal_lineage_livedisplay_qti.te @@ -1,2 +1 @@ allow hal_lineage_livedisplay_qti ppd:unix_stream_socket connectto; -allow hal_lineage_livedisplay_qti secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_lineage_livedisplay_sysfs.te b/sepolicy/vendor/hal_lineage_livedisplay_sysfs.te deleted file mode 100644 index 8ffb130..0000000 --- a/sepolicy/vendor/hal_lineage_livedisplay_sysfs.te +++ /dev/null @@ -1,2 +0,0 @@ -allow hal_lineage_livedisplay_sysfs ppd:unix_stream_socket connectto; -allow hal_lineage_livedisplay_sysfs secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_lineage_trust_default.te b/sepolicy/vendor/hal_lineage_trust_default.te deleted file mode 100644 index 072ed4e..0000000 --- a/sepolicy/vendor/hal_lineage_trust_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_lineage_trust_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_memtrack_default.te b/sepolicy/vendor/hal_memtrack_default.te deleted file mode 100644 index 39f4066..0000000 --- a/sepolicy/vendor/hal_memtrack_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_memtrack_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_power_default.te b/sepolicy/vendor/hal_power_default.te index ff818ec..323806d 100644 --- a/sepolicy/vendor/hal_power_default.te +++ b/sepolicy/vendor/hal_power_default.te @@ -1,2 +1 @@ allow hal_power_default sysfs:file { open write }; -allow hal_power_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_power_service.te b/sepolicy/vendor/hal_power_service.te deleted file mode 100644 index da6262b..0000000 --- a/sepolicy/vendor/hal_power_service.te +++ /dev/null @@ -1,3 +0,0 @@ -binder_call(hal_power_service, servicemanager) -allow servicemanager hal_power_service:file { rw_file_perms }; -allow servicemanager hal_power_service:dir { rw_dir_perms }; diff --git a/sepolicy/vendor/hal_power_stats_default.te b/sepolicy/vendor/hal_power_stats_default.te deleted file mode 100644 index e4fb440..0000000 --- a/sepolicy/vendor/hal_power_stats_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_power_stats_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_ril_default.te b/sepolicy/vendor/hal_ril_default.te deleted file mode 100644 index 1614904..0000000 --- a/sepolicy/vendor/hal_ril_default.te +++ /dev/null @@ -1,6 +0,0 @@ -type hal_ril_default, domain; -hwbinder_use(hal_ril_default) -vndbinder_use(hal_ril_default) - -type hal_ril_default_exec, exec_type, vendor_file_type, file_type; -init_daemon_domain(hal_ril_default) diff --git a/sepolicy/vendor/hal_ril_wrapper.te b/sepolicy/vendor/hal_ril_wrapper.te deleted file mode 100644 index 9c6274d..0000000 --- a/sepolicy/vendor/hal_ril_wrapper.te +++ /dev/null @@ -1,6 +0,0 @@ -type hal_ril_wrapper, domain; -hwbinder_use(hal_ril_wrapper) -vndbinder_use(hal_ril_wrapper) - -type hal_ril_wrapper_exec, exec_type, vendor_file_type, file_type; -init_daemon_domain(hal_ril_wrapper) diff --git a/sepolicy/vendor/hal_usb_default.te b/sepolicy/vendor/hal_usb_default.te deleted file mode 100644 index a94b4ef..0000000 --- a/sepolicy/vendor/hal_usb_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_usb_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_wifi_default.te b/sepolicy/vendor/hal_wifi_default.te index 11073f7..ab89521 100644 --- a/sepolicy/vendor/hal_wifi_default.te +++ b/sepolicy/vendor/hal_wifi_default.te @@ -1,7 +1,6 @@ +allow hal_wifi_default firmware_file:dir search; allow hal_wifi_default firmware_file:file { open read }; allow hal_wifi_default sysfs:file write; allow hal_wifi_default system_data_file:file { open read }; -allow hal_wifi_default ta_data_file:dir search; +allow hal_wifi_default ta_data_file:dir { read search }; allow hal_wifi_default ta_data_file:file { open read }; -allow hal_wifi_default firmware_file:dir search; -allow hal_wifi_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hal_wifi_supplicant_default.te b/sepolicy/vendor/hal_wifi_supplicant_default.te deleted file mode 100644 index d4683de..0000000 --- a/sepolicy/vendor/hal_wifi_supplicant_default.te +++ /dev/null @@ -1 +0,0 @@ -allow hal_wifi_supplicant_default secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/healthd.te b/sepolicy/vendor/healthd.te deleted file mode 100644 index 73e96ff..0000000 --- a/sepolicy/vendor/healthd.te +++ /dev/null @@ -1,2 +0,0 @@ -allow healthd sysfs:file { getattr open read }; -allow healthd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/hwservicemanager.te b/sepolicy/vendor/hwservicemanager.te index 5d9f3f8..99d0d97 100644 --- a/sepolicy/vendor/hwservicemanager.te +++ b/sepolicy/vendor/hwservicemanager.te @@ -1,8 +1,6 @@ +allow hwservicemanager hal_drm_clearkey:dir search; +allow hwservicemanager hal_drm_clearkey:file { open read }; +allow hwservicemanager hal_drm_clearkey:process getattr; allow hwservicemanager init:dir search; allow hwservicemanager init:file { open read }; allow hwservicemanager init:process getattr; -allow hwservicemanager secd_exec:file { getattr read }; -allow hwservicemanager hal_dumpstate_impl:dir { rw_dir_perms }; -allow hwservicemanager hal_dumpstate_impl:file { rw_file_perms }; -allow hwservicemanager hal_dumpstate_impl:binder { call transfer }; -allow hwservicemanager hal_dumpstate_impl:process getattr; diff --git a/sepolicy/vendor/iddd.te b/sepolicy/vendor/iddd.te index edf8959..45b3a1a 100644 --- a/sepolicy/vendor/iddd.te +++ b/sepolicy/vendor/iddd.te @@ -5,16 +5,3 @@ type iddd_exec, exec_type, file_type; # Started by init init_daemon_domain(iddd) -allow iddd diag_data_file:dir { add_name search write }; -allow iddd diag_data_file:file { create lock open read write }; -allow iddd diag_data_file:dir { getattr open read remove_name }; -allow iddd diag_data_file:file { getattr rename unlink }; -allow iddd diag_data_file:sock_file { create setattr }; -allow iddd socket_device:sock_file write; -allow iddd diag_data_file:sock_file unlink; -allow iddd tad:unix_stream_socket connectto; -allow iddd tad_socket:sock_file write; -allow iddd diag_data_file:dir { create rmdir }; -allow iddd diag_data_file:sock_file write; -allow iddd firmware_file:dir search; -allow iddd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/idmap.te b/sepolicy/vendor/idmap.te deleted file mode 100644 index 8c5d8a5..0000000 --- a/sepolicy/vendor/idmap.te +++ /dev/null @@ -1 +0,0 @@ -allow idmap secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/incidentd.te b/sepolicy/vendor/incidentd.te deleted file mode 100644 index 45eadf1..0000000 --- a/sepolicy/vendor/incidentd.te +++ /dev/null @@ -1 +0,0 @@ -allow incidentd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/init-power-sh.te b/sepolicy/vendor/init-power-sh.te index b3f1a59..f8a8cd1 100644 --- a/sepolicy/vendor/init-power-sh.te +++ b/sepolicy/vendor/init-power-sh.te @@ -4,35 +4,22 @@ type init-power-sh_exec, exec_type, file_type; # Started by init init_daemon_domain(init-power-sh) -allow init-power-sh shell_exec:file r_file_perms; +allow init-power-sh file_contexts_file:file r_file_perms; +allow init-power-sh proc:file rw_file_perms; +allow init-power-sh self:capability sys_resource; +allow init-power-sh shell_exec:file rw_file_perms; +allow init-power-sh sysfs:dir r_file_perms; +allow init-power-sh sysfs:file rw_file_perms; +allow init-power-sh sysfs_cpu_boost:dir search; +allow init-power-sh sysfs_cpu_boost:file rw_file_perms; allow init-power-sh sysfs_devices_system_cpu:file w_file_perms; +allow init-power-sh sysfs_kgsl:file rw_file_perms; +allow init-power-sh sysfs_msm_perf:dir search; +allow init-power-sh sysfs_msm_perf:file { open write }; allow init-power-sh sysfs_performance:dir r_dir_perms; allow init-power-sh sysfs_performance:file w_file_perms; allow init-power-sh sysfs_thermal:dir r_dir_perms; allow init-power-sh sysfs_thermal:file rw_file_perms; -allow init-power-sh proc_kernel_sched:file w_file_perms; -allow init-power-sh sysfs_rqstats:dir read; -allow init-power-sh proc:file write; -allow init-power-sh sysfs_rqstats:dir {r_dir_perms open}; -allow init-power-sh sysfs_rqstats:file r_file_perms; - -# allow labeling of interactive /sys files created post-initial restorecon -allow init-power-sh sysfs:{ dir file lnk_file } relabelfrom; -allow init-power-sh sysfs_devices_system_cpu:{ dir file lnk_file } relabelto; - -# allow writes to sysfs files that have not yet been labeled -allow init-power-sh sysfs:file rw_file_perms; allow init-power-sh sysfs_usb:file w_file_perms; - -# execute toybox/toolbox -allow init-power-sh toolbox_exec:file rx_file_perms; - -allow init-power-sh sysfs:dir { open read }; -allow init-power-sh sysfs_kgsl:file { open write }; -allow init-power-sh file_contexts_file:file { getattr open read }; -allow init-power-sh sysfs_msm_perf:dir search; -allow init-power-sh sysfs_msm_perf:file { open write }; -allow init-power-sh proc:file open; -allow init-power-sh sysfs_cpu_boost:dir search; -allow init-power-sh sysfs_cpu_boost:file { open write }; -allow init-power-sh secd_exec:file { getattr read }; +allow init-power-sh toolbox_exec:file { execute execute_no_trans rw_file_perms }; +allow init-power-sh vendor_toolbox_exec:file { execute_no_trans rx_file_perms }; diff --git a/sepolicy/vendor/init.te b/sepolicy/vendor/init.te index 340f6c0..be7ff16 100644 --- a/sepolicy/vendor/init.te +++ b/sepolicy/vendor/init.te @@ -1,56 +1,35 @@ -#For sdcard -allow init tmpfs:lnk_file create_file_perms; -allow init proc_kernel_sched:file write; -allow init proc_dirty_ratio:file write; -allow init persist_file:dir mounton; -allow init debugfs:file w_file_perms; - -#TAD -allow init tad_socket:sock_file create; - -#Torch -allow init sysfs_camera_torch:lnk_file read; - -allow init trim_area_partition_device:blk_file { write setattr }; -allow init block_device:blk_file setattr; -allow init socket_device:sock_file { create setattr }; -allow init socket_device:sock_file unlink; +allow init binder_per_mgr_service:service_manager find; +allow init block_device:blk_file { ioctl setattr write }; allow init cameraserver:fd use; -allow init diag_data_file:file { lock rename }; -allow init diag_data_file:sock_file write; -allow init ion_device:chr_file ioctl; -allow init property_socket:sock_file write; -allow init rpmb_device:blk_file write; -allow init self:capability2 block_suspend; -allow init self:socket { read write }; -allow init ssd_device:blk_file write; -allow init tad_socket:sock_file write; -allow init tee_device:chr_file { ioctl write }; -allow init video_device:chr_file { ioctl write }; -allow init secd_data_file:file { ioctl lock }; -allow init servicemanager:binder call; -allow init vfat:file { getattr open read }; -allow init proc_interrupts:file getattr; allow init diag_data_file:dir mounton; -allow init hal_drm_hwservice:hwservice_manager add; -allow init hal_fingerprint_hwservice:hwservice_manager add; -allow init hal_light_hwservice:hwservice_manager add; +allow init diag_partition_device:blk_file r_file_perms; +allow init hal_drm_hwservice:hwservice_manager { add find }; +allow init hal_dumpstate_hwservice:hwservice_manager { add find }; allow init hidl_base_hwservice:hwservice_manager add; allow init hwservicemanager:binder { call transfer }; -allow init iddd:unix_dgram_socket sendto; -allow init ion_device:chr_file { open read }; +allow init ion_device:chr_file { ioctl open read }; +allow init iorapd_data_file:file getattr; +allow init per_mgr:binder { call transfer }; allow init proc:file write; +allow init proc_dirty_ratio:file write; +allow init proc_interrupts:file { getattr open read }; +allow init self:capability2 block_suspend; +allow init self:socket { bind create ioctl read write }; +allow init servicemanager:binder call; +allow init socket_device:sock_file { create setattr unlink write }; allow init sysfs:file { open read setattr write }; -allow init sysfs_battery_supply:file { open read }; -allow init sysfs_graphics:file { open read write }; -allow init tee_device:chr_file { open read }; -allow init vendor_file:file execute_no_trans; -allow init vndbinder_device:chr_file { ioctl open read write }; -allow init fingerprintd_data_file:file rename; -allow init system_server:binder call; -allow init hal_drm_hwservice:hwservice_manager { add find }; -allow init hal_fingerprint_hwservice:hwservice_manager { add find }; -allow init iorapd_data_file:file rw_file_perms; -allow init system_file:dir relabelfrom; -allow init system_file:file { execute_no_trans relabelfrom }; +allow init sysfs_camera_torch:lnk_file read; +allow init sysfs_cpu_boost:file { open write }; +allow init sysfs_devices_system_cpu:file write; +allow init sysfs_graphics:file { open read }; +allow init sysfs_kgsl:file { open write }; allow init sysfs_livedisplay_tuneable:file setattr; +allow init sysfs_msm_perf:file { open write }; +allow init sysfs_thermal:file write; +allow init sysfs_wake_lock:file { append open }; +allow init system_data_file:file { ioctl lock }; +allow init system_file:file execute_no_trans; +allow init tee_device:chr_file { ioctl open read write }; +allow init trim_area_partition_device:blk_file setattr; +allow init vendor_file:file execute_no_trans; +allow init video_device:chr_file { ioctl open read write }; diff --git a/sepolicy/vendor/installd.te b/sepolicy/vendor/installd.te deleted file mode 100644 index 974c9d3..0000000 --- a/sepolicy/vendor/installd.te +++ /dev/null @@ -1,2 +0,0 @@ -allow installd device:file { open write }; -allow installd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/iorap_prefetcherd.te b/sepolicy/vendor/iorap_prefetcherd.te deleted file mode 100644 index e7173ff..0000000 --- a/sepolicy/vendor/iorap_prefetcherd.te +++ /dev/null @@ -1 +0,0 @@ -allow iorap_prefetcherd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/iorapd.te b/sepolicy/vendor/iorapd.te deleted file mode 100644 index 8a9b418..0000000 --- a/sepolicy/vendor/iorapd.te +++ /dev/null @@ -1 +0,0 @@ -allow iorapd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/irsc_util.te b/sepolicy/vendor/irsc_util.te deleted file mode 100644 index 48280e0..0000000 --- a/sepolicy/vendor/irsc_util.te +++ /dev/null @@ -1 +0,0 @@ -allow irsc_util secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/kernel.te b/sepolicy/vendor/kernel.te deleted file mode 100644 index e650c4c..0000000 --- a/sepolicy/vendor/kernel.te +++ /dev/null @@ -1,6 +0,0 @@ -allow kernel device:dir create_dir_perms; -allow kernel tmpfs:file create_file_perms; -allow kernel tmpfs:dir create_dir_perms; -allow kernel block_device:blk_file rw_file_perms; -allow kernel touchfusion_exec:file relabelto; -allow kernel self:socket create; diff --git a/sepolicy/vendor/keystore.te b/sepolicy/vendor/keystore.te deleted file mode 100644 index 6455c97..0000000 --- a/sepolicy/vendor/keystore.te +++ /dev/null @@ -1,2 +0,0 @@ -allow keystore tee_prop:file { getattr open read }; -allow keystore secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/lmkd.te b/sepolicy/vendor/lmkd.te deleted file mode 100644 index 1799135..0000000 --- a/sepolicy/vendor/lmkd.te +++ /dev/null @@ -1 +0,0 @@ -allow lmkd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/loc_launcher.te b/sepolicy/vendor/loc_launcher.te index c520f4e..83ec18e 100644 --- a/sepolicy/vendor/loc_launcher.te +++ b/sepolicy/vendor/loc_launcher.te @@ -1,15 +1,9 @@ -# loc_launcher service type loc_launcher, domain; type loc_launcher_exec, exec_type, file_type; +# Started by init init_daemon_domain(loc_launcher) +allow loc_launcher location_data_file:dir { add_name remove_name search write }; +allow loc_launcher location_data_file:sock_file { create setattr unlink }; allow loc_launcher self:capability setuid; -allow loc_launcher system_data_file:dir { add_name remove_name write }; -allow loc_launcher system_data_file:sock_file { create setattr unlink }; -allow loc_launcher location_data_file:dir { add_name remove_name write }; -allow loc_launcher location_data_file:sock_file { create setattr }; -allow loc_launcher location_socket:sock_file unlink; -allow loc_launcher location_data_file:sock_file unlink; -allow loc_launcher location_data_file:dir search; -allow loc_launcher secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/logd.te b/sepolicy/vendor/logd.te deleted file mode 100644 index 93ec406..0000000 --- a/sepolicy/vendor/logd.te +++ /dev/null @@ -1 +0,0 @@ -allow logd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediacodec.te b/sepolicy/vendor/mediacodec.te deleted file mode 100644 index 0ba5bfe..0000000 --- a/sepolicy/vendor/mediacodec.te +++ /dev/null @@ -1,4 +0,0 @@ -allow mediacodec mpctl_socket:dir search; -allow mediacodec perfd:unix_stream_socket connectto; -allow mediacodec socket_device:sock_file write; -allow mediacodec secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediadrmserver.te b/sepolicy/vendor/mediadrmserver.te deleted file mode 100644 index 316f94f..0000000 --- a/sepolicy/vendor/mediadrmserver.te +++ /dev/null @@ -1 +0,0 @@ -allow mediadrmserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediaextractor.te b/sepolicy/vendor/mediaextractor.te deleted file mode 100644 index 71f9a54..0000000 --- a/sepolicy/vendor/mediaextractor.te +++ /dev/null @@ -1 +0,0 @@ -allow mediaextractor secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediametrics.te b/sepolicy/vendor/mediametrics.te deleted file mode 100644 index 2dca25e..0000000 --- a/sepolicy/vendor/mediametrics.te +++ /dev/null @@ -1 +0,0 @@ -allow mediametrics secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediaserver.te b/sepolicy/vendor/mediaserver.te deleted file mode 100644 index f5ee855..0000000 --- a/sepolicy/vendor/mediaserver.te +++ /dev/null @@ -1,5 +0,0 @@ -allow mediaserver hal_configstore_ISurfaceFlingerConfigs:hwservice_manager find; -allow mediaserver sensorservice_service:service_manager find; -allow mediaserver sysfs_graphics:file { getattr open read }; -allow mediaserver system_server:unix_stream_socket read; -allow mediaserver secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mediaswcodec.te b/sepolicy/vendor/mediaswcodec.te deleted file mode 100644 index c338257..0000000 --- a/sepolicy/vendor/mediaswcodec.te +++ /dev/null @@ -1,2 +0,0 @@ -allow mediaswcodec servicemanager:binder call; -allow mediaswcodec secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/mlog_qmi_service.te b/sepolicy/vendor/mlog_qmi_service.te index 3466981..7758a7a 100644 --- a/sepolicy/vendor/mlog_qmi_service.te +++ b/sepolicy/vendor/mlog_qmi_service.te @@ -1,15 +1,8 @@ -# mlog_qmi_service service type mlog_qmi_service, domain; -type mlog_qmi_service_exec, exec_type, vendor_file_type, file_type; +type mlog_qmi_service_exec, exec_type, file_type; # Started by init init_daemon_domain(mlog_qmi_service) -# Allow mlog_qmi_service to create self:socket -allow mlog_qmi_service self:socket create_socket_perms; -allow mlog_qmi_service self:socket { create read write }; -allowxperm mlog_qmi_service self:socket ioctl msm_sock_ipc_ioctls; - -# Allow mlog_qmi_service to use net_raw capability allow mlog_qmi_service self:capability net_raw; -allow mlog_qmi_service secd_exec:file { getattr read }; +allow mlog_qmi_service self:socket { bind create ioctl read write }; diff --git a/sepolicy/vendor/msm_irqbalance.te b/sepolicy/vendor/msm_irqbalance.te index 542eae4..53f24af 100644 --- a/sepolicy/vendor/msm_irqbalance.te +++ b/sepolicy/vendor/msm_irqbalance.te @@ -1,4 +1,3 @@ -# msm_irqbalance service type msm_irqbalance, domain; type msm_irqbalance_exec, exec_type, file_type; @@ -6,9 +5,7 @@ type msm_irqbalance_exec, exec_type, file_type; init_daemon_domain(msm_irqbalance) allow msm_irqbalance proc:file { getattr open read write }; -allow msm_irqbalance self:capability dac_override; -allow msm_irqbalance sysfs_devices_system_cpu:file write; -allow msm_irqbalance self:capability { setgid setuid }; allow msm_irqbalance proc_interrupts:file { getattr open read }; allow msm_irqbalance proc_stat:file { getattr open read }; -allow msm_irqbalance secd_exec:file { getattr read }; +allow msm_irqbalance self:capability { dac_override setgid setuid }; +allow msm_irqbalance sysfs_devices_system_cpu:file write; diff --git a/sepolicy/vendor/netd.te b/sepolicy/vendor/netd.te deleted file mode 100644 index 7f82d40..0000000 --- a/sepolicy/vendor/netd.te +++ /dev/null @@ -1,2 +0,0 @@ -allow netd device:file { open write }; -allow netd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/netmgrd.te b/sepolicy/vendor/netmgrd.te deleted file mode 100644 index 54aa1fa..0000000 --- a/sepolicy/vendor/netmgrd.te +++ /dev/null @@ -1,4 +0,0 @@ -allow netmgrd self:capability dac_override; -allow netmgrd toolbox_exec:file { execute execute_no_trans getattr open read }; -allow netmgrd net_data_file:dir read; -allow netmgrd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/per_mgr.te b/sepolicy/vendor/per_mgr.te index 832dd28..a92dfba 100644 --- a/sepolicy/vendor/per_mgr.te +++ b/sepolicy/vendor/per_mgr.te @@ -1,7 +1,4 @@ -allow per_mgr per_mgr_service:service_manager add; -allow per_mgr subsys_modem_device:chr_file r_file_perms; -allow per_mgr self:capability net_raw; -allow per_mgr self:socket create_socket_perms; -allowxperm per_mgr self:socket ioctl msm_sock_ipc_ioctls; +allow per_mgr init:binder call; allow per_mgr per_proxy:binder call; -allow per_mgr secd_exec:file { getattr read }; +allow per_mgr self:capability net_raw; +allow per_mgr subsys_modem_device:chr_file rw_file_perms; diff --git a/sepolicy/vendor/per_proxy.te b/sepolicy/vendor/per_proxy.te index 9be5831..b68955d 100644 --- a/sepolicy/vendor/per_proxy.te +++ b/sepolicy/vendor/per_proxy.te @@ -5,10 +5,6 @@ type per_proxy_exec, exec_type, file_type; # Started by init init_daemon_domain(per_proxy) -allow per_proxy default_android_service:service_manager find; -allow per_proxy per_mgr:binder call; -allow per_proxy servicemanager:binder call; -allow per_proxy sysfs:file { open read }; -allow per_proxy per_mgr:binder transfer; allow per_proxy binder_per_mgr_service:service_manager find; -allow per_proxy secd_exec:file { getattr read }; +allow per_proxy per_mgr:binder { call transfer }; +allow per_proxy servicemanager:binder call; diff --git a/sepolicy/vendor/perfd.te b/sepolicy/vendor/perfd.te deleted file mode 100644 index 20670cb..0000000 --- a/sepolicy/vendor/perfd.te +++ /dev/null @@ -1,3 +0,0 @@ -allow perfd sysfs_memory:dir search; -allow perfd sysfs_memory:file { open read write }; -allow perfd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/platform_app.te b/sepolicy/vendor/platform_app.te index c8e132f..97c9d6b 100644 --- a/sepolicy/vendor/platform_app.te +++ b/sepolicy/vendor/platform_app.te @@ -1,2 +1,2 @@ -allow platform_app system_app_data_file:dir getattr; allow platform_app exported_camera_prop:file read; +allow platform_app system_app_data_file:dir getattr; diff --git a/sepolicy/vendor/ppd.te b/sepolicy/vendor/ppd.te index eed967b..f1882ce 100644 --- a/sepolicy/vendor/ppd.te +++ b/sepolicy/vendor/ppd.te @@ -5,19 +5,19 @@ type ppd_exec, exec_type, file_type; # Started by init init_daemon_domain(ppd) -allow ppd ion_device:chr_file write; set_prop(ppd, display_prop); -allow ppd system_prop:property_service set; -allow ppd diag_device:chr_file { ioctl open read write }; -allow ppd graphics_device:chr_file { ioctl open read write }; -allow ppd ion_device:chr_file { open read }; + +allow ppd diag_device:chr_file rw_file_perms; +allow ppd display_vendor_data_file:dir search; +allow ppd graphics_device:dir search; +allow ppd graphics_device:chr_file rw_file_perms; +allow ppd init:unix_stream_socket connectto; +allow ppd ion_device:chr_file rw_file_perms; allow ppd persist_display_file:dir search; -allow ppd postprocessing_prop:file { getattr open read }; +allow ppd persist_file:dir search; +allow ppd postprocessing_prop:file r_file_perms; allow ppd postprocessing_prop:property_service set; +allow ppd property_socket:sock_file write; allow ppd sysfs_graphics:dir search; -allow ppd sysfs_graphics:file { getattr open read write }; +allow ppd sysfs_graphics:file rw_file_perms; allow ppd sysfs_leds:dir search; -allow ppd graphics_device:dir search; -allow ppd persist_file:dir search; -allow ppd display_vendor_data_file:dir search; -allow ppd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/priv_app.te b/sepolicy/vendor/priv_app.te deleted file mode 100644 index d87000e..0000000 --- a/sepolicy/vendor/priv_app.te +++ /dev/null @@ -1,7 +0,0 @@ -allow priv_app device:dir open; -allow priv_app proc_interrupts:file open; -allow priv_app alarm_boot_prop:file open; -allow priv_app alarm_instance_prop:file getattr; -allow priv_app proc:file open; -allow priv_app sysfs_android_usb:file open; -allow priv_app secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/property.te b/sepolicy/vendor/property.te index 1bd735a..f624f54 100644 --- a/sepolicy/vendor/property.te +++ b/sepolicy/vendor/property.te @@ -1,4 +1 @@ -type timekeep_prop, property_type; -type tee_prop, property_type; -type ta_prop, property_type; type display_prop, property_type; diff --git a/sepolicy/vendor/property_contexts b/sepolicy/vendor/property_contexts index e731b0b..14d989c 100644 --- a/sepolicy/vendor/property_contexts +++ b/sepolicy/vendor/property_contexts @@ -1,5 +1 @@ -sys.keymaster.loaded u:object_r:tee_prop:s0 -sys.listeners.registered u:object_r:tee_prop:s0 -persist.sys.timeadjust u:object_r:timekeep_prop:s0 -persist.service.bdroid.bdaddr u:object_r:bluetooth_prop:s0 -persist.tareset.notfirstboot u:object_r:ta_prop:s0 +persist.service.bdroid.bdaddr u:object_r:bluetooth_prop:s0 diff --git a/sepolicy/vendor/qcamerasvr.te b/sepolicy/vendor/qcamerasvr.te index 1883677..7ef9d28 100644 --- a/sepolicy/vendor/qcamerasvr.te +++ b/sepolicy/vendor/qcamerasvr.te @@ -5,20 +5,12 @@ type qcamerasvr_exec, exec_type, file_type; # Started by init init_daemon_domain(qcamerasvr) -allow qcamerasvr camera_data_file:dir { add_name remove_name write }; +allow qcamerasvr camera_data_file:dir { add_name remove_name search write }; allow qcamerasvr camera_data_file:sock_file { create unlink }; -allow qcamerasvr hal_camera_default:fd use; -allow qcamerasvr ion_device:chr_file { open read ioctl }; -allow qcamerasvr mediaserver:fd use; -allow qcamerasvr sysfs:file { open read write }; -allow qcamerasvr video_device:chr_file { ioctl open read write }; allow qcamerasvr camera_prop:file { getattr open read }; allow qcamerasvr cameraserver:fd use; -allow qcamerasvr camera_data_file:dir search; -allow qcamerasvr camera_socket:sock_file unlink; +allow qcamerasvr ion_device:chr_file { open read }; +allow qcamerasvr sysfs:file { open read }; allow qcamerasvr sysfs_graphics:file { open read }; allow qcamerasvr ta_data_file:dir search; -allow qcamerasvr secd_exec:file { getattr read }; -allow qcamerasvr vendor_camera_data_file:dir { add_name remove_name write }; -allow qcamerasvr vendor_camera_data_file:sock_file { create unlink }; -allow qcamerasvr hal_graphics_allocator_default:fd use +allow qcamerasvr video_device:chr_file { ioctl open read write }; diff --git a/sepolicy/vendor/qmuxd.te b/sepolicy/vendor/qmuxd.te deleted file mode 100644 index f2fcafb..0000000 --- a/sepolicy/vendor/qmuxd.te +++ /dev/null @@ -1,3 +0,0 @@ -allow qmuxd diag_device:chr_file { ioctl open read write }; -allow qmuxd sysfs:file read; -allow qmuxd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/radio.te b/sepolicy/vendor/radio.te deleted file mode 100644 index 35ae984..0000000 --- a/sepolicy/vendor/radio.te +++ /dev/null @@ -1,2 +0,0 @@ -allow radio gpuservice:binder call; -allow radio system_app_data_file:dir getattr; diff --git a/sepolicy/vendor/recovery_persist.te b/sepolicy/vendor/recovery_persist.te deleted file mode 100644 index 18809a7..0000000 --- a/sepolicy/vendor/recovery_persist.te +++ /dev/null @@ -1 +0,0 @@ -allow recovery_persist secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/rild.te b/sepolicy/vendor/rild.te index e3f441c..1b327b5 100644 --- a/sepolicy/vendor/rild.te +++ b/sepolicy/vendor/rild.te @@ -1,25 +1,11 @@ -allow rild cache_file:dir { rw_file_perms remove_name }; -allow rild cache_file:file { r_file_perms unlink }; -allow rild tad_socket:sock_file write; -allow rild tee_device:chr_file { read write open ioctl}; -allow rild radio_data_file:file { getattr lock open read write }; -allow rild default_android_service:service_manager find; -allow rild radio_data_file:dir { add_name getattr open read remove_name write }; -allow rild radio_data_file:file { create ioctl setattr unlink }; -allow rild self:capability dac_override; -allow rild servicemanager:binder call; -allow rild tee_device:chr_file { open read write }; +# Allow rild to access tad +unix_socket_connect(rild, tad, tad) + +# Misc +allow rild cache_file:dir { rw_file_perms remove_name search }; +allow rild firmware_file:dir search; allow rild firmware_file:file { getattr open read }; allow rild ion_device:chr_file { ioctl open read }; -allow rild self:capability sys_module; +allow rild self:capability { dac_override sys_module }; allow rild socket_device:sock_file write; -allow rild tee_device:chr_file ioctl; -allow rild audioserver_service:service_manager find; -allow rild self:capability chown; -allow rild radio_data_file:dir search; -allow rild vendor_file:file ioctl; -allow rild tad:unix_stream_socket connectto; -allow rild cache_file:dir search; -allow rild firmware_file:dir search; -allow rild device:file { open write }; -allow rild secd_exec:file { getattr read }; +allow rild tee_device:chr_file { ioctl open read write }; diff --git a/sepolicy/vendor/rmt_storage.te b/sepolicy/vendor/rmt_storage.te deleted file mode 100644 index 58b7f41..0000000 --- a/sepolicy/vendor/rmt_storage.te +++ /dev/null @@ -1 +0,0 @@ -allow rmt_storage secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/sct_service.te b/sepolicy/vendor/sct_service.te index acbdfde..02eb5dc 100644 --- a/sepolicy/vendor/sct_service.te +++ b/sepolicy/vendor/sct_service.te @@ -1,15 +1,8 @@ -# sct_service service type sct_service, domain; type sct_service_exec, exec_type, file_type; # Started by init init_daemon_domain(sct_service) -# Allow sct_service to use net_raw capability allow sct_service self:capability net_raw; - -# Allow sct_service to create self:socket -allow sct_service self:socket create_socket_perms; -allow sct_service self:socket { create read write }; -allowxperm sct_service self:socket ioctl msm_sock_ipc_ioctls; -allow sct_service secd_exec:file { getattr read }; +allow sct_service self:socket { bind create ioctl read write }; diff --git a/sepolicy/vendor/sdcardd.te b/sepolicy/vendor/sdcardd.te deleted file mode 100644 index 68c2942..0000000 --- a/sepolicy/vendor/sdcardd.te +++ /dev/null @@ -1 +0,0 @@ -allow sdcardd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/secd.te b/sepolicy/vendor/secd.te index fcc65e8..628668c 100644 --- a/sepolicy/vendor/secd.te +++ b/sepolicy/vendor/secd.te @@ -1,22 +1,15 @@ -# secd service type secd, domain; type secd_exec, exec_type, file_type; # Started by init init_daemon_domain(secd) -allow secd tad:unix_stream_socket connectto; -allow secd tad_socket:sock_file write; -allow secd tee_device:chr_file { ioctl open read write }; -allow secd secd_data_file:file { lock open write create getattr read setattr unlink }; -allow secd secd_data_file:dir { rw_file_perms add_name remove_name search }; -allow secd diag_partition_device:dir search; -allow secd diag_data_file:dir search; -allow secd diag_data_file:sock_file write; allow secd firmware_file:dir search; allow secd firmware_file:file { getattr open read }; -allow secd iddd:unix_dgram_socket sendto; allow secd ion_device:chr_file { ioctl open read }; -allow secd socket_device:sock_file write; +allow secd secd_data_file:dir search; +allow secd secd_data_file:file rw_file_perms; +allow secd system_data_file:file { getattr ioctl lock open read write }; +allow secd tad:unix_stream_socket connectto; +allow secd tad_socket:sock_file write; allow secd tee_device:chr_file { ioctl open read write }; -allow secd secd_data_file:file ioctl; diff --git a/sepolicy/vendor/sensors.te b/sepolicy/vendor/sensors.te deleted file mode 100644 index 99094dc..0000000 --- a/sepolicy/vendor/sensors.te +++ /dev/null @@ -1,7 +0,0 @@ -allow sensors device:dir { write add_name }; -allow sensors input_device:chr_file { relabelfrom getattr link }; -allow sensors input_device:dir search; -allow sensors tmpfs:file rw_file_perms; -allow sensors tad_socket:sock_file { write }; -allow sensors sysfs:file { open read }; -allow sensors secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/service.te b/sepolicy/vendor/service.te deleted file mode 100644 index 5b53ee5..0000000 --- a/sepolicy/vendor/service.te +++ /dev/null @@ -1 +0,0 @@ -type timekeep_service, service_manager_type; diff --git a/sepolicy/vendor/service_contexts b/sepolicy/vendor/service_contexts index 4cbcf34..def6bc6 100644 --- a/sepolicy/vendor/service_contexts +++ b/sepolicy/vendor/service_contexts @@ -1 +1 @@ -com.sony.timekeep u:object_r:timekeep_service:s0 +com.sony.timekeep u:object_r:timekeep_service:s0 diff --git a/sepolicy/vendor/servicemanager.te b/sepolicy/vendor/servicemanager.te index 20da122..88a2747 100644 --- a/sepolicy/vendor/servicemanager.te +++ b/sepolicy/vendor/servicemanager.te @@ -1,13 +1,10 @@ +allow servicemanager hal_power_default:dir search; +allow servicemanager hal_power_default:file { open read }; +allow servicemanager hal_power_default:process getattr; +allow servicemanager init:binder transfer; allow servicemanager init:dir search; -allow servicemanager init:file { open read }; +allow servicemanager init:file r_file_perms; allow servicemanager init:process getattr; allow servicemanager per_proxy:dir search; -allow servicemanager per_proxy:file { open read }; +allow servicemanager per_proxy:file r_file_perms; allow servicemanager per_proxy:process getattr; -allow servicemanager mediaswcodec:dir search; -allow servicemanager mediaswcodec:file { open read }; -allow servicemanager mediaswcodec:process getattr; -allow servicemanager secd_exec:file { getattr read }; -allow servicemanager hal_power_default:dir { rw_dir_perms }; -allow servicemanager hal_power_default:file { rw_file_perms }; -allow servicemanager hal_power_default:process { getattr }; diff --git a/sepolicy/vendor/shell.te b/sepolicy/vendor/shell.te deleted file mode 100644 index 904da06..0000000 --- a/sepolicy/vendor/shell.te +++ /dev/null @@ -1,109 +0,0 @@ -allow shell alarm_boot_prop:file { getattr open }; -allow shell alarm_handled_prop:file { getattr open }; -allow shell alarm_instance_prop:file { getattr open }; -allow shell apexd_prop:file { getattr open }; -allow shell bg_boot_complete_prop:file { getattr open }; -allow shell bg_daemon_prop:file { getattr open }; -allow shell bluetooth_prop:file { getattr open }; -allow shell boot_animation_prop:file { getattr open }; -allow shell boot_mode_prop:file { getattr open }; -allow shell boottime_prop:file { getattr open }; -allow shell bpf_progs_loaded_prop:file { getattr open }; -allow shell coresight_prop:file { getattr open }; -allow shell crash_prop:file { getattr open }; -allow shell ctl_LKCore_prop:file { getattr open }; -allow shell ctl_adbd_prop:file { getattr open }; -allow shell ctl_bootanim_prop:file { getattr open read }; -allow shell ctl_console_prop:file { getattr open }; -allow shell ctl_default_prop:file { getattr open }; -allow shell ctl_fuse_prop:file { getattr open }; -allow shell ctl_hbtp_prop:file { getattr open }; -allow shell ctl_interface_restart_prop:file { getattr open }; -allow shell ctl_interface_start_prop:file { getattr open }; -allow shell ctl_interface_stop_prop:file { getattr open }; -allow shell ctl_mdnsd_prop:file { getattr open }; -allow shell ctl_netmgrd_prop:file { getattr open }; -allow shell ctl_port-bridge_prop:file { getattr open }; -allow shell ctl_qmuxd_prop:file { getattr open }; -allow shell ctl_restart_prop:file { getattr open }; -allow shell ctl_rildaemon_prop:file { getattr open }; -allow shell ctl_sigstop_prop:file { getattr open }; -allow shell ctl_start_prop:file { getattr open }; -allow shell ctl_stop_prop:file { getattr open }; -allow shell ctl_vendor_imsrcsservice_prop:file { getattr open }; -allow shell ctl_vendor_wigigsvc_prop:file { getattr open }; -allow shell device_config_activity_manager_native_boot_prop:file { getattr open }; -allow shell device_config_boot_count_prop:file { getattr open }; -allow shell device_config_input_native_boot_prop:file { getattr open }; -allow shell device_config_media_native_prop:file { getattr open }; -allow shell device_config_netd_native_prop:file { getattr open }; -allow shell device_config_reset_performed_prop:file { getattr open }; -allow shell device_config_runtime_native_boot_prop:file { getattr open }; -allow shell device_config_runtime_native_prop:file { getattr open }; -allow shell diag_mdlog_prop:file { getattr open }; -allow shell dolby_prop:file { getattr open }; -allow shell dumpstate_options_prop:file { getattr open }; -allow shell firstboot_prop:file { getattr open }; -allow shell fm_prop:file { getattr open }; -allow shell freq_prop:file { getattr open }; -allow shell fst_prop:file { getattr open }; -allow shell gamed_prop:file { getattr open }; -allow shell gsid_prop:file { getattr open }; -allow shell ipacm-diag_prop:file { getattr open }; -allow shell ipacm_prop:file { getattr open }; -allow shell llkd_prop:file { getattr open }; -allow shell location_prop:file { getattr open }; -allow shell lowpan_prop:file { getattr open }; -allow shell mdm_helper_prop:file { getattr open }; -allow shell mmc_prop:file { getattr open }; -allow shell mmi_prop:file { getattr open }; -allow shell mpdecision_prop:file { getattr open }; -allow shell msm_irqbalance_prop:file { getattr open }; -allow shell msm_irqbl_sdm630_prop:file { getattr open }; -allow shell net_dns_prop:file { getattr open }; -allow shell netd_prop:file { getattr open }; -allow shell netd_stable_secret_prop:file { getattr open }; -allow shell nfc_nq_prop:file { getattr open }; -allow shell opengles_prop:file { getattr open }; -allow shell overlay_prop:file { getattr open }; -allow shell per_mgr_state_prop:file { getattr open }; -allow shell perfd_prop:file { getattr open }; -allow shell persistent_properties_ready_prop:file { getattr open }; -allow shell postprocessing_prop:file { getattr open }; -allow shell ppd_prop:file { getattr open }; -allow shell qcom_ims_prop:file { getattr open }; -allow shell qdma_prop:file { getattr open }; -allow shell qemu_gles_prop:file { getattr open }; -allow shell qti_prop:file { getattr open }; -allow shell rmnet_mux_prop:file { getattr open }; -allow shell safemode_prop:file { getattr open }; -allow shell scr_enabled_prop:file { getattr open }; -allow shell sdm_idle_time_prop:file { getattr open }; -allow shell secd_exec:file { getattr read }; -allow shell sensors_prop:file { getattr open }; -allow shell spcomlib_prop:file { getattr open }; -allow shell sys_usb_configfs_prop:file { getattr open }; -allow shell sys_usb_controller_prop:file { getattr open }; -allow shell sys_usb_tethering_prop:file { getattr open }; -allow shell system_lmk_prop:file { getattr open }; -allow shell system_trace_prop:file { getattr open }; -allow shell ta_prop:file { getattr open }; -allow shell tee_prop:file { getattr open }; -allow shell test_boot_reason_prop:file { getattr open }; -allow shell theme_prop:file { getattr open }; -allow shell time_prop:file { getattr open }; -allow shell timekeep_prop:file { getattr open }; -allow shell traced_lazy_prop:file { getattr open }; -allow shell uicc_prop:file { getattr open }; -allow shell usf_prop:file { getattr open }; -allow shell vendor_mpctl_prop:file { getattr open }; -allow shell vendor_rild_libpath_prop:file { getattr open }; -allow shell vendor_system_prop:file { getattr open }; -allow shell vendor_wifi_prop:file { getattr open }; -allow shell vendor_wifi_version:file { getattr open }; -allow shell vm_bms_prop:file { getattr open }; -allow shell wifi_prop:file { getattr open }; -allow shell wififtmd_prop:file { getattr open }; -allow shell wigig_prop:file { getattr open }; -allow shell xlat_prop:file { getattr open }; -allow shell secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/statsd.te b/sepolicy/vendor/statsd.te deleted file mode 100644 index 990f691..0000000 --- a/sepolicy/vendor/statsd.te +++ /dev/null @@ -1 +0,0 @@ -allow statsd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/surfaceflinger.te b/sepolicy/vendor/surfaceflinger.te index 96ddacc..c6de4ce 100644 --- a/sepolicy/vendor/surfaceflinger.te +++ b/sepolicy/vendor/surfaceflinger.te @@ -1,4 +1 @@ -allow surfaceflinger perfd:unix_stream_socket connectto; -allow surfaceflinger socket_device:sock_file write; allow surfaceflinger default_android_service:service_manager { add find }; -allow surfaceflinger secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/system_app.te b/sepolicy/vendor/system_app.te index eaab107..1ba7323 100644 --- a/sepolicy/vendor/system_app.te +++ b/sepolicy/vendor/system_app.te @@ -1,13 +1,5 @@ -allow system_app time_data_file:dir search; -allow system_app timekeep_data_file:file { getattr open write }; -allow system_app timekeep_prop:file { getattr open }; -allow system_app timekeep_prop:property_service set; -allow system_app timekeep_prop:file read; +allow system_app init:binder call; allow system_app sysfs_rtc:dir search; -allow system_app time_data_file:file { getattr open write }; +allow system_app time_data_file:dir search; +allow system_app time_data_file:file rw_file_perms; allow system_app vendor_default_prop:property_service set; -allow system_app apex_service:service_manager find; -allow system_app proc_pagetypeinfo:file read; -allow system_app sysfs_zram:dir search; -allow system_app system_suspend_control_service:service_manager find; -allow system_app hal_dumpstate_impl:binder call; diff --git a/sepolicy/vendor/system_server.te b/sepolicy/vendor/system_server.te index ee499e2..1c0afe1 100644 --- a/sepolicy/vendor/system_server.te +++ b/sepolicy/vendor/system_server.te @@ -1,20 +1,5 @@ -allow system_server ppd:unix_stream_socket connectto; -allow system_server pps_socket:sock_file write; -allow system_server self:capability sys_module; -allow system_server system_app_data_file:dir r_dir_perms; -allow system_server ta_data_file:dir search; -allow system_server ta_data_file:file r_file_perms; -allow system_server persist_file:dir rw_file_perms; -allow system_server perfd:unix_stream_socket connectto; -allow system_server socket_device:sock_file write; -allow system_server sensors:unix_stream_socket connectto; -allow system_server sensors_device:chr_file getattr; -allow system_server sensors_socket:sock_file write; -allow system_server unlabeled:file unlink; -allow system_server default_android_service:service_manager find; -allow system_server init:binder { call transfer }; -allow system_server exfat:dir rw_dir_perms; -allow system_server vendor_security_patch_level_prop:file { r_file_perms }; +allow system_server exported_camera_prop:file { getattr open read }; +allow system_server hal_light_default:process signal; allow system_server userspace_reboot_config_prop:file { getattr open read }; allow system_server userspace_reboot_exported_prop:file { getattr open read }; -allow system_server exported_camera_prop:file { r_file_perms }; +allow system_server vendor_security_patch_level_prop:file { getattr open read }; diff --git a/sepolicy/vendor/ta_qmi_service.te b/sepolicy/vendor/ta_qmi_service.te index b39f3b0..d369511 100644 --- a/sepolicy/vendor/ta_qmi_service.te +++ b/sepolicy/vendor/ta_qmi_service.te @@ -1,24 +1,12 @@ -# ta_qmi_service service type ta_qmi_service, domain; -type ta_qmi_service_exec, exec_type, vendor_file_type, file_type; +type ta_qmi_service_exec, exec_type, file_type; # Started by init init_daemon_domain(ta_qmi_service) -# Allow ta_qmi_service to access tad -unix_socket_connect(ta_qmi_service, tad, tad) - -# Allow ta_qmi_service to use net_raw, setgid and setuid capabilities allow ta_qmi_service self:capability { net_raw setgid setuid }; - -# Allow ta_qmi_service to create self:socket -allow ta_qmi_service self:socket create_socket_perms; -allow ta_qmi_service self:socket { create read write }; -allowxperm ta_qmi_service self:socket ioctl msm_sock_ipc_ioctls; - allow ta_qmi_service self:capability2 block_suspend; -allow ta_qmi_service socket_device:sock_file write; +allow ta_qmi_service self:socket { bind create ioctl read write }; allow ta_qmi_service sysfs_wake_lock:file { append open }; allow ta_qmi_service tad:unix_stream_socket connectto; allow ta_qmi_service tad_socket:sock_file write; -allow ta_qmi_service secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/tad.te b/sepolicy/vendor/tad.te index da37bba..c79402b 100644 --- a/sepolicy/vendor/tad.te +++ b/sepolicy/vendor/tad.te @@ -1,14 +1,9 @@ type tad, domain; type tad_exec, exec_type, file_type; -type_transition tad socket_device:sock_file tad_socket "tad"; # Started by init init_daemon_domain(tad) -# Read /proc/stat -allow tad proc:file r_file_perms; - -# Allow tad to work it's magic -allow tad trim_area_partition_device:blk_file { ioctl rw_file_perms }; +allow tad block_device:blk_file rw_file_perms; allow tad block_device:dir search; -allow tad tmpfs:file rw_file_perms; \ No newline at end of file +allow tad trim_area_partition_device:blk_file rw_file_perms; diff --git a/sepolicy/vendor/taimport.te b/sepolicy/vendor/taimport.te index 339c4f6..796a78a 100644 --- a/sepolicy/vendor/taimport.te +++ b/sepolicy/vendor/taimport.te @@ -1,15 +1,13 @@ -# taimport service type taimport, domain; type taimport_exec, exec_type, file_type; # Started by init init_daemon_domain(taimport) -allow taimport tad_socket:sock_file { write }; -allow taimport ta_data_file:dir { read search write add_name create remove_name }; -allow taimport ta_data_file:file { read write create getattr open unlink}; allow taimport self:capability { dac_override setgid }; -allow taimport socket_device:sock_file write; allow taimport system_data_file:dir { add_name remove_name write }; -allow taimport init:unix_stream_socket connectto; -allow taimport secd_exec:file { getattr read }; +allow taimport system_data_file:file { create getattr open unlink write }; +allow taimport tad:unix_stream_socket connectto; +allow taimport ta_data_file:dir { add_name create read remove_name search write }; +allow taimport ta_data_file:file { create getattr open read unlink write }; +allow taimport tad_socket:sock_file write; diff --git a/sepolicy/vendor/tee.te b/sepolicy/vendor/tee.te index 3b5d8e0..2af3b21 100644 --- a/sepolicy/vendor/tee.te +++ b/sepolicy/vendor/tee.te @@ -1,29 +1,3 @@ -# tee starts as root, and drops privileges -allow tee self:capability { - setuid - setgid -}; - -# allow tee to load firmware images -r_dir_file(tee, firmware_file) - -binder_use(tee) - -# Provide tee ability to access QMUXD/IPCRouter for QMI -qmux_socket(tee); - -set_prop(tee, tee_prop) - -# Need to directly manipulate certain block devices -# for anti-rollback protection -allow tee block_device:dir r_dir_perms; -allow tee rpmb_device:blk_file rw_file_perms; - -# Provide tee access to ssd partition for HW FDE -allow tee ssd_device:blk_file rw_file_perms; - -allow tee system_data_file:dir r_dir_perms; -allow tee vfat:file { getattr open read }; allow tee vfat:dir search; -allow tee secd_exec:file { getattr read }; -allow tee system_data_root_file:dir rw_dir_perms; +allow tee vfat:file { getattr open read }; + diff --git a/sepolicy/vendor/thermal-engine.te b/sepolicy/vendor/thermal-engine.te index 46f80fc..9701c70 100644 --- a/sepolicy/vendor/thermal-engine.te +++ b/sepolicy/vendor/thermal-engine.te @@ -1,9 +1,2 @@ -allow thermal-engine ta_data_file:dir search; -allow thermal-engine ta_data_file:file r_file_perms; -allow thermal-engine diag_partition_device:dir search; allow thermal-engine diag_data_file:dir search; -allow thermal-engine diag_data_file:sock_file write; -allow thermal-engine socket_device:sock_file { create setattr }; -allow thermal-engine init:unix_dgram_socket sendto; -allow thermal-engine iddd:unix_dgram_socket sendto; -allow thermal-engine secd_exec:file { getattr read }; +allow thermal-engine ta_data_file:dir search; diff --git a/sepolicy/vendor/timekeep.te b/sepolicy/vendor/timekeep.te index 3a6874c..f5a178f 100644 --- a/sepolicy/vendor/timekeep.te +++ b/sepolicy/vendor/timekeep.te @@ -1,25 +1,11 @@ -# timekeep service type timekeep, domain; type timekeep_exec, exec_type, file_type; # Started by init init_daemon_domain(timekeep) -set_prop(timekeep, timekeep_prop) - -r_dir_file(timekeep, sysfs_timekeep) - -allow timekeep self:capability { - fowner - fsetid - sys_time - dac_override - dac_read_search -}; -allow timekeep timekeep_data_file:file create_file_perms; -allow timekeep timekeep_data_file:dir { create_dir_perms search }; -allow timekeep time_data_file:dir { create_dir_perms search }; -allow timekeep time_data_file:file { write open getattr setattr }; -allow timekeep sysfs:file {read open }; +allow timekeep self:capability sys_time; allow timekeep sysfs_rtc:dir search; -allow timekeep secd_exec:file { getattr read }; +allow timekeep sysfs:file { open read }; +allow timekeep time_data_file:dir search; +allow timekeep time_data_file:file { getattr open write }; diff --git a/sepolicy/vendor/tombstoned.te b/sepolicy/vendor/tombstoned.te deleted file mode 100644 index cc69697..0000000 --- a/sepolicy/vendor/tombstoned.te +++ /dev/null @@ -1 +0,0 @@ -allow tombstoned secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/toolbox.te b/sepolicy/vendor/toolbox.te index a593ea5..0913c5d 100644 --- a/sepolicy/vendor/toolbox.te +++ b/sepolicy/vendor/toolbox.te @@ -1,6 +1,7 @@ -allow toolbox diag_data_file:dir { getattr open read remove_name rmdir write }; -allow toolbox self:capability dac_override; -allow toolbox diag_data_file:dir search; -allow toolbox firmware_file:dir { open read rmdir write }; +allow toolbox diag_data_file:dir { getattr open read remove_name rmdir search write }; +allow toolbox file_contexts_file:file { getattr open read }; allow toolbox firmware_file:dir search; -allow toolbox secd_exec:file { getattr read }; +allow toolbox init:fifo_file { getattr write }; +allow toolbox self:capability dac_override; +allow toolbox sysfs:file { open read }; +allow toolbox sysfs_devices_system_cpu:file write; diff --git a/sepolicy/vendor/tzdatacheck.te b/sepolicy/vendor/tzdatacheck.te deleted file mode 100644 index 315ff85..0000000 --- a/sepolicy/vendor/tzdatacheck.te +++ /dev/null @@ -1 +0,0 @@ -allow tzdatacheck secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/ueventd.te b/sepolicy/vendor/ueventd.te index 100a149..04f953a 100644 --- a/sepolicy/vendor/ueventd.te +++ b/sepolicy/vendor/ueventd.te @@ -1,10 +1,4 @@ -# Allow firmware_file access to load Non-HLOS images -r_dir_file(ueventd, firmware_file) - -allow ueventd device:file relabelfrom; -allow ueventd sysfs_camera_torch:file { open write }; +allow ueventd diag_partition_device:blk_file { create getattr setattr }; +allow ueventd proc:file { getattr open read }; allow ueventd vfat:dir search; allow ueventd vfat:file { getattr open read }; -allow ueventd self:capability sys_nice; -allow ueventd secd_exec:file { getattr read }; -allow ueventd proc:file { getattr open read }; diff --git a/sepolicy/vendor/updatemiscta.te b/sepolicy/vendor/updatemiscta.te index 2ef7cb7..c0342b3 100644 --- a/sepolicy/vendor/updatemiscta.te +++ b/sepolicy/vendor/updatemiscta.te @@ -1,14 +1,9 @@ -# updatemiscta service type updatemiscta, domain; type updatemiscta_exec, exec_type, file_type; # Started by init init_daemon_domain(updatemiscta) -unix_socket_connect(taimport, tad, tad) - allow updatemiscta socket_device:sock_file write; allow updatemiscta tad:unix_stream_socket connectto; -allow updatemiscta ta_prop:file { getattr open read }; allow updatemiscta tad_socket:sock_file write; -allow updatemiscta secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/usbd.te b/sepolicy/vendor/usbd.te deleted file mode 100644 index 5aacbbb..0000000 --- a/sepolicy/vendor/usbd.te +++ /dev/null @@ -1 +0,0 @@ -allow usbd secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vdc.te b/sepolicy/vendor/vdc.te deleted file mode 100644 index 8aea92e..0000000 --- a/sepolicy/vendor/vdc.te +++ /dev/null @@ -1 +0,0 @@ -allow vdc secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vendor_init.te b/sepolicy/vendor/vendor_init.te deleted file mode 100644 index 8e95520..0000000 --- a/sepolicy/vendor/vendor_init.te +++ /dev/null @@ -1 +0,0 @@ -allow vendor_init secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vendor_install_recovery.te b/sepolicy/vendor/vendor_install_recovery.te deleted file mode 100644 index 197298e..0000000 --- a/sepolicy/vendor/vendor_install_recovery.te +++ /dev/null @@ -1,2 +0,0 @@ -allow vendor_install_recovery block_device:blk_file { open read }; -allow vendor_install_recovery secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vndservicemanager.te b/sepolicy/vendor/vndservicemanager.te deleted file mode 100644 index 533f601..0000000 --- a/sepolicy/vendor/vndservicemanager.te +++ /dev/null @@ -1 +0,0 @@ -allow vndservicemanager secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/vold.te b/sepolicy/vendor/vold.te index 90208e5..87db41c 100644 --- a/sepolicy/vendor/vold.te +++ b/sepolicy/vendor/vold.te @@ -1,6 +1,3 @@ -allow vold diag_data_file:dir { read open ioctl }; -allow vold firmware_file:dir search; -allow vold firmware_file:file { getattr open read }; -allow vold secd_exec:file { getattr read }; -allow vold tee_prop:file { r_file_perms }; +allow vold diag_data_file:dir { ioctl open read }; +allow vold hal_bootctl_hwservice:hwservice_manager find; allow vold sysfs_mmc_host:file write; diff --git a/sepolicy/vendor/vold_prepare_subdirs.te b/sepolicy/vendor/vold_prepare_subdirs.te deleted file mode 100644 index e4c4bb4..0000000 --- a/sepolicy/vendor/vold_prepare_subdirs.te +++ /dev/null @@ -1 +0,0 @@ -allow vold_prepare_subdirs secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/wificond.te b/sepolicy/vendor/wificond.te deleted file mode 100644 index 73ca465..0000000 --- a/sepolicy/vendor/wificond.te +++ /dev/null @@ -1 +0,0 @@ -allow wificond secd_exec:file { getattr read }; diff --git a/sepolicy/vendor/zygote.te b/sepolicy/vendor/zygote.te index 52116bf..c3f0115 100644 --- a/sepolicy/vendor/zygote.te +++ b/sepolicy/vendor/zygote.te @@ -1,4 +1,2 @@ -allow zygote proc_cmdline:file { getattr open read }; -allow zygote secd_exec:file { getattr read }; -allow zygote device:file rw_file_perms; allow zygote exported_camera_prop:file { getattr open read }; +allow zygote proc_cmdline:file { getattr open read }; -- GitLab From 8e15782db832f274464745125856092be6515ae0 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Wed, 11 Nov 2020 13:36:41 +0100 Subject: [PATCH 081/191] Revert "Revert "kitakami-common: Kang Perf/Thermal stack from angler & hima"" This reverts commit 5baf84cba61f8d1148fb72b4d493b7ad8ad18ee9. --- configs/thermal-engine.conf | 524 ++++++++++++++++++++++++++++++++++++ device-common.mk | 7 + proprietary-files.txt | 13 +- rootdir/init.qcom.rc | 24 +- thermal/Android.bp | 28 ++ thermal/thermal.c | 280 +++++++++++++++++++ 6 files changed, 860 insertions(+), 16 deletions(-) create mode 100644 configs/thermal-engine.conf create mode 100644 thermal/Android.bp create mode 100644 thermal/thermal.c diff --git a/configs/thermal-engine.conf b/configs/thermal-engine.conf new file mode 100644 index 0000000..656305d --- /dev/null +++ b/configs/thermal-engine.conf @@ -0,0 +1,524 @@ +# SENSOR : ALIAS +# tsens_tz_sensor8 : cpu1 +# tsens_tz_sensor7 : cpu0 +# tsens_tz_sensor6 : cpu7 +# tsens_tz_sensor2 : pop_mem +# tsens_tz_sensor15 : cpu6 +# tsens_tz_sensor14 : cpu5 +# tsens_tz_sensor13 : cpu4 +# tsens_tz_sensor12 : gpu +# tsens_tz_sensor10 : cpu3 +# tsens_tz_sensor9 : cpu2 + +sampling 5000 +#Conf file: /vendor/etc/thermal-engine.conf + +[CAMERA_MONITOR] +algo_type monitor +sampling 100 +sensor cpu0 +thresholds 60000 65000 75000 +thresholds_clr 50000 60000 65000 +actions camcorder camcorder camcorder +action_info 0 1 2 + +[SS-EMMCTHERM-CLUSTER0] +algo_type ss +sampling 500 +sensor emmc_therm +device cluster0 +set_point 45000 +set_point_clr 44000 +time_constant 0 + +[CPU7_HOTPLUG_MONITOR] +algo_type monitor +sampling 100 +sensor cpu7 +thresholds 75000 +thresholds_clr 60000 +actions hotplug_7 +action_info 1 + +[CPU6_HOTPLUG_MONITOR] +algo_type monitor +sampling 100 +sensor cpu6 +thresholds 75000 +thresholds_clr 60000 +actions hotplug_6 +action_info 1 + +[CPU5_HOTPLUG_MONITOR] +algo_type monitor +sampling 100 +sensor cpu5 +thresholds 75000 +thresholds_clr 60000 +actions hotplug_5 +action_info 1 + +[CPU4_HOTPLUG_MONITOR] +algo_type monitor +sampling 100 +sensor cpu4 +thresholds 75000 +thresholds_clr 60000 +actions hotplug_4 +action_info 1 + +[CPU3_HOTPLUG_MONITOR] +algo_type monitor +sampling 100 +sensor cpu3 +thresholds 90000 +thresholds_clr 75000 +actions hotplug_3 +action_info 1 + +[CPU2_HOTPLUG_MONITOR] +algo_type monitor +sampling 100 +sensor cpu2 +thresholds 90000 +thresholds_clr 75000 +actions hotplug_2 +action_info 1 + +[CPU1_HOTPLUG_MONITOR] +algo_type monitor +sampling 100 +sensor cpu1 +thresholds 90000 +thresholds_clr 75000 +actions hotplug_1 +action_info 1 + +[SS-CPU7-FINAL] +algo_type ss +sampling 100 +sensor cpu7 +device final_cluster1 +set_point 85000 +set_point_clr 70000 +time_constant 0 + +[SS-CPU6-FINAL] +algo_type ss +sampling 100 +sensor cpu6 +device final_cluster1 +set_point 85000 +set_point_clr 70000 +time_constant 0 + +[SS-CPU5-FINAL] +algo_type ss +sampling 100 +sensor cpu5 +device final_cluster1 +set_point 85000 +set_point_clr 70000 +time_constant 0 + +[SS-CPU4-FINAL] +algo_type ss +sampling 100 +sensor cpu4 +device final_cluster1 +set_point 85000 +set_point_clr 70000 +time_constant 0 + +[SS-CPU3-FINAL] +algo_type ss +sampling 100 +sensor cpu3 +device final_cluster0 +set_point 90000 +set_point_clr 75000 +time_constant 0 + +[SS-CPU2-FINAL] +algo_type ss +sampling 100 +sensor cpu2 +device final_cluster0 +set_point 90000 +set_point_clr 75000 +time_constant 0 + +[SS-CPU1-FINAL] +algo_type ss +sampling 100 +sensor cpu1 +device final_cluster0 +set_point 90000 +set_point_clr 75000 +time_constant 0 + +[SS-CPU0-FINAL] +algo_type ss +sampling 100 +sensor cpu0 +device final_cluster0 +set_point 90000 +set_point_clr 75000 +time_constant 0 + +[EMMC_MONITOR] +algo_type monitor +sampling 1000 +sensor emmc_therm +thresholds 32000 33000 34000 35000 37000 38000 40000 41000 43000 45000 48000 +thresholds_clr 31000 32000 33000 34000 36000 37000 39000 40000 42000 44000 47000 +actions emmc emmc emmc emmc emmc emmc emmc emmc emmc emmc emmc +action_info 2 2 3 3 4 4 4 4 2 3 10 + +[CPU3_MONITOR] +algo_type monitor +sampling 65 +sensor cpu3 +thresholds 100000 105000 110000 115000 +thresholds_clr 97000 102000 107000 95000 +actions Uevent_Notify Uevent_Notify Uevent_Notify shutdown +action_info 1 2 3 1000 + +[CPU2_MONITOR] +algo_type monitor +sampling 65 +sensor cpu2 +thresholds 100000 105000 110000 115000 +thresholds_clr 97000 102000 107000 95000 +actions Uevent_Notify Uevent_Notify Uevent_Notify shutdown +action_info 1 2 3 1000 + +[CPU1_MONITOR] +algo_type monitor +sampling 65 +sensor cpu1 +thresholds 100000 105000 110000 115000 +thresholds_clr 97000 102000 107000 95000 +actions Uevent_Notify Uevent_Notify Uevent_Notify shutdown +action_info 1 2 3 1000 + +[CPU0_MONITOR] +algo_type monitor +sampling 1000 +sensor cpu0 +thresholds 100000 105000 110000 115000 +thresholds_clr 97000 102000 107000 95000 +actions Uevent_Notify Uevent_Notify Uevent_Notify shutdown +action_info 1 2 3 1000 + +[SS-GPU] +#algo_type ss +sampling 250 +sensor gpu +device gpu +set_point 82000 +set_point_clr 52000 +time_constant 0 + +[SS-POPMEM] +#algo_type ss +sampling 10 +sensor pop_mem +device cluster1 +set_point 80000 +set_point_clr 55000 +time_constant 16 + +[SS-CPU7] +#algo_type ss +sampling 100 +sensor cpu7 +device cluster1 +set_point 75000 +set_point_clr 60000 +time_constant 0 + +[SS-CPU6] +#algo_type ss +sampling 100 +sensor cpu6 +device cluster1 +set_point 75000 +set_point_clr 60000 +time_constant 0 + +[SS-CPU5] +#algo_type ss +sampling 100 +sensor cpu5 +device cluster1 +set_point 75000 +set_point_clr 60000 +time_constant 0 + +[SS-CPU4] +#algo_type ss +sampling 100 +sensor cpu4 +device cluster1 +set_point 75000 +set_point_clr 60000 +time_constant 0 + +[SS-CPU3] +#algo_type ss +sampling 100 +sensor cpu3 +device cluster0 +set_point 75000 +set_point_clr 60000 +time_constant 0 + +[SS-CPU2] +#algo_type ss +sampling 100 +sensor cpu2 +device cluster0 +set_point 75000 +set_point_clr 60000 +time_constant 0 + +[SS-CPU1] +#algo_type ss +sampling 100 +sensor cpu1 +device cluster0 +set_point 75000 +set_point_clr 60000 +time_constant 0 + +[SS-CPU0] +#algo_type ss +sampling 100 +sensor cpu0 +device cluster0 +set_point 75000 +set_point_clr 60000 +time_constant 0 + +[SPEAKER-CAL] +sampling 30000 30000 10 1800000 +sensor pm8994_tz +sensors tsens_tz_sensor1 tsens_tz_sensor2 tsens_tz_sensor3 tsens_tz_sensor4 tsens_tz_sensor5 tsens_tz_sensor11 tsens_tz_sensor12 +temp_range 6000 10000 2000 +max_temp 45000 +offset -4000 + +[PMIC-ALARM-MONITOR] +#algo_type monitor +sampling 1000 +sensor pm8994_tz +thresholds 107000 127000 +thresholds_clr 103000 123000 +actions hotplug_7+hotplug_6+hotplug_5+hotplug_4+hotplug_3+hotplug_2+hotplug_1+cluster1+cluster0 hotplug_7+hotplug_6+hotplug_5+hotplug_4+hotplug_3+hotplug_2+hotplug_1 +action_info 0+0+0+0+0+0+0+302400+302400 1+1+1+1+1+1+1 + +[VDD_RSTR_MONITOR-TSENS15] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor15 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS14] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor14 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS13] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor13 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS12] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor12 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS11] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor11 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS10] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor10 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS9] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor9 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS8] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor8 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS7] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor7 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS6] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor6 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS5] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor5 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS4] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor4 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS3] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor3 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS2] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor2 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS1] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor1 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[VDD_RSTR_MONITOR-TSENS0] +#algo_type monitor +sampling 1000 +sensor tsens_tz_sensor0 +thresholds 5000 +thresholds_clr 10000 +actions vdd_restriction +action_info 1 +descending + +[GPU_MONITOR] +algo_type monitor +sensor msm_therm +sampling 1000 +thresholds 40000 42000 45000 47000 +thresholds_clr 38000 40000 43000 45000 +actions gpu gpu gpu gpu +action_info 510000000 450000000 390000000 305000000 + +[FINAL-GPU_MONITOR] +algo_type monitor +sensor gpu +sampling 1000 +thresholds 76000 80000 85000 90000 +thresholds_clr 67000 75000 80000 85000 +actions gpu gpu gpu gpu +action_info 510000000 450000000 390000000 305000000 + +[LC_MONITOR] +algo_type monitor +sensor msm_therm +sampling 1000 +thresholds 37000 43000 +thresholds_clr 35000 40000 +actions cluster0 cluster0 +action_info 1344000 960000 + +[BC_MONITOR] +algo_type monitor +sensor msm_therm +sampling 1000 +thresholds 36000 38000 41000 +thresholds_clr 34000 36000 40000 +actions cluster1 cluster1 cluster1 +action_info 1536000 1344000 960000 + +[MODEM_MONITOR] +algo_type monitor +sensor emmc_therm +sampling 1000 +thresholds 47000 +thresholds_clr 44000 +actions modem +action_info 1 diff --git a/device-common.mk b/device-common.mk index 28d4d90..d4f1d4f 100644 --- a/device-common.mk +++ b/device-common.mk @@ -327,6 +327,13 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ camera.qcom_shim +# Thermal +PRODUCT_PACKAGES += \ + thermal.qcom + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/configs/thermal-engine.conf:$(TARGET_COPY_OUT_VENDOR)/etc/thermal-engine.conf + # TimeKeep PRODUCT_PACKAGES += \ timekeep \ diff --git a/proprietary-files.txt b/proprietary-files.txt index 452174a..2d65c3e 100644 --- a/proprietary-files.txt +++ b/proprietary-files.txt @@ -135,17 +135,20 @@ vendor/lib/libconnctrl.so # Perf bin/msm_irqbalance -vendor/bin/perfd +vendor/bin/perfd|3abbda7d519d567429cfab3294ae5e62d8e8d5eb +vendor/bin/thermal-engine|d501a7b6261f606cd79c188548d747f4c3ec1b03 vendor/etc/perf-profile0.conf vendor/etc/perf-profile1.conf vendor/etc/perf-profile2.conf vendor/etc/perf-profile3.conf vendor/etc/perf-profile4.conf vendor/etc/perf-profile5.conf -vendor/lib64/libqti-perfd-client.so -vendor/lib64/libqti_performance.so -vendor/lib/libqti-perfd-client.so -vendor/lib/libqti_performance.so +vendor/lib/libqti-perfd-client.so|a52d27399fd4ca2522a4ca3a97697346ed9cb7d1 +vendor/lib64/libqti-perfd-client.so|eb3bb8c51fd022efe89341ffb91d238e388256e9 +vendor/lib64/libsettings.so|3e459839d90a27d2eb23a3c9d030f46a5c4bfaf1 +vendor/lib/libthermalclient.so|6b84a374b99baef6218886c8a8b87081c054de84 +vendor/lib64/libthermalclient.so.so|b8b3af940651f0e06a6c769051eed76a208ffbd6 +vendor/lib64/libthermalioctl.so|6165b829945d8133f02e3f2d368399a06ede9f5a # Peripheral manager from Nexus 6P bin/pm-proxy diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index 20b1397..73387e8 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -454,8 +454,6 @@ on post-fs-data chmod 2755 /data/misc/perfd mkdir /data/system/perfd 0770 root system chmod 2770 /data/system/perfd - rm /data/system/perfd/default_values - start perfd # SONY: Camera mkdir /data/camera 0770 media camera @@ -548,18 +546,18 @@ on property:sys.listeners.registered=* service perfd /vendor/bin/perfd class main user root - group system + group root readproc disabled - socket perfd seqpacket 0666 root system writepid /dev/cpuset/system-background/tasks -service thermal-engine /system/vendor/bin/thermal-engine - class main - user root - group root - socket thermal-send-client stream 0666 system system - socket thermal-recv-client stream 0660 system system - socket thermal-recv-passive-client stream 0666 system system +service vendor.thermal-engine /vendor/bin/thermal-engine -c /vendor/etc/thermal-engine.conf + class main + user root + socket thermal-send-client stream 0660 system system + socket thermal-recv-client stream 0660 system system + socket thermal-recv-passive-client stream 0660 system system + group root + writepid /dev/cpuset/system-background/tasks service adsprpcd /system/bin/adsprpcd class main @@ -702,6 +700,10 @@ service iddd /system/bin/iddd group oem_2987 log inet oem_2993 disabled +on property:sys.boot_completed=1 + rm /data/system/perfd/default_values + start perfd + on property:service.usb.otg.switch=check write /sys/module/qpnp_smbcharger_extension/parameters/start_id_polling 1 setprop service.usb.otg_switch check_done diff --git a/thermal/Android.bp b/thermal/Android.bp new file mode 100644 index 0000000..5131527 --- /dev/null +++ b/thermal/Android.bp @@ -0,0 +1,28 @@ +// +// Copyright 2016 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +cc_library_shared { + cflags: ["-Wno-unused-parameter"], + relative_install_path: "hw", + proprietary: true, + srcs: ["thermal.c"], + shared_libs: [ + "liblog", + "libcutils", + ], + + name: "thermal.qcom", +} diff --git a/thermal/thermal.c b/thermal/thermal.c new file mode 100644 index 0000000..aa40f54 --- /dev/null +++ b/thermal/thermal.c @@ -0,0 +1,280 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +#define LOG_TAG "ThermalHAL" +#include + +#include +#include + +#define MAX_LENGTH 50 + +#define CPU_USAGE_FILE "/proc/stat" +#define TEMPERATURE_FILE_FORMAT "/sys/class/thermal/thermal_zone%d/temp" +#define CPU_ONLINE_FILE_FORMAT "/sys/devices/system/cpu/cpu%d/online" + +#define BATTERY_SENSOR_NUM 2 +#define GPU_SENSOR_NUM 13 +#define SKIN_SENSOR_NUM 18 + +const int CPU_SENSORS[] = {8, 9, 10, 11, 14, 15, 16, 7}; + +#define CPU_NUM (sizeof(CPU_SENSORS) / sizeof(int)) +#define TEMPERATURE_NUM 21 + +//qcom, therm-reset-temp +#define CPU_SHUTDOWN_THRESHOLD 115 +//qcom, limit-temp +#define CPU_THROTTLING_THRESHOLD 60 +#define BATTERY_SHUTDOWN_THRESHOLD 60 +// device/huawei/angler/thermal-engine-angler.conf +#define SKIN_THROTTLING_THRESHOLD 41 +#define SKIN_SHUTDOWN_THRESHOLD 64 +#define VR_THROTTLED_BELOW_MIN 47 + +#define GPU_LABEL "GPU" +#define BATTERY_LABEL "battery" +#define SKIN_LABEL "skin" + +const char *CPU_LABEL[] = {"CPU0", "CPU1", "CPU2", "CPU3", "CPU4", "CPU5", "CPU6", "CPU7"}; + +/** + * Reads device temperature. + * + * @param sensor_num Number of sensor file with temperature. + * @param type Device temperature type. + * @param name Device temperature name. + * @param mult Multiplier used to translate temperature to Celsius. + * @param throttling_threshold Throttling threshold for the temperature. + * @param shutdown_threshold Shutdown threshold for the temperature. + * @param out Pointer to temperature_t structure that will be filled with current + * values. + * + * @return 0 on success or negative value -errno on error. + */ +static ssize_t read_temperature(int sensor_num, int type, const char *name, float mult, + float throttling_threshold, float shutdown_threshold, float vr_throttling_threshold, + temperature_t *out) { + FILE *file; + char file_name[MAX_LENGTH]; + float temp; + + sprintf(file_name, TEMPERATURE_FILE_FORMAT, sensor_num); + file = fopen(file_name, "r"); + if (file == NULL) { + ALOGE("%s: failed to open: %s", __func__, strerror(errno)); + return -errno; + } + if (1 != fscanf(file, "%f", &temp)) { + fclose(file); + ALOGE("%s: failed to read a float: %s", __func__, strerror(errno)); + return errno ? -errno : -EIO; + } + + fclose(file); + + (*out) = (temperature_t) { + .type = type, + .name = name, + .current_value = temp * mult, + .throttling_threshold = throttling_threshold, + .shutdown_threshold = shutdown_threshold, + .vr_throttling_threshold = vr_throttling_threshold + }; + + return 0; +} + +static ssize_t get_cpu_temperatures(temperature_t *list, size_t size) { + size_t cpu; + + for (cpu = 0; cpu < CPU_NUM; cpu++) { + if (cpu >= size) { + break; + } + // tsens_tz_sensor[7,8,9,10,11,14,15,6]: temperature in Celsius. + ssize_t result = read_temperature(CPU_SENSORS[cpu], DEVICE_TEMPERATURE_CPU, CPU_LABEL[cpu], + 1, CPU_THROTTLING_THRESHOLD, CPU_SHUTDOWN_THRESHOLD, UNKNOWN_TEMPERATURE, + &list[cpu]); + if (result != 0) { + return result; + } + } + return cpu; +} + +static ssize_t get_temperatures(thermal_module_t *module, temperature_t *list, size_t size) { + ssize_t result = 0; + size_t current_index = 0; + + if (list == NULL) { + return TEMPERATURE_NUM; + } + + result = get_cpu_temperatures(list, size); + if (result < 0) { + return result; + } + current_index += result; + + // GPU temperature. + if (current_index < size) { + // tsens_tz_sensor12: temperature in Celsius. + result = read_temperature(GPU_SENSOR_NUM, DEVICE_TEMPERATURE_GPU, GPU_LABEL, 1, + UNKNOWN_TEMPERATURE, UNKNOWN_TEMPERATURE, UNKNOWN_TEMPERATURE, + &list[current_index]); + if (result < 0) { + return result; + } + current_index++; + } + + // Battery temperature. + if (current_index < size) { + // hwmon sensor: battery: temperature in millidegrees Celsius. + result = read_temperature(BATTERY_SENSOR_NUM, DEVICE_TEMPERATURE_BATTERY, BATTERY_LABEL, + 0.001, UNKNOWN_TEMPERATURE, BATTERY_SHUTDOWN_THRESHOLD, UNKNOWN_TEMPERATURE, + &list[current_index]); + if (result < 0) { + return result; + } + current_index++; + } + + // Skin temperature. + if (current_index < size) { + // msm_thermal: temperature in Celsius. + result = read_temperature(SKIN_SENSOR_NUM, DEVICE_TEMPERATURE_SKIN, SKIN_LABEL, 1, + SKIN_THROTTLING_THRESHOLD, SKIN_SHUTDOWN_THRESHOLD, VR_THROTTLED_BELOW_MIN, + &list[current_index]); + if (result < 0) { + return result; + } + current_index++; + } + return TEMPERATURE_NUM; +} + +static ssize_t get_cpu_usages(thermal_module_t *module, cpu_usage_t *list) { + int vals, cpu_num, online; + ssize_t read; + uint64_t user, nice, system, idle, active, total; + char *line = NULL; + size_t len = 0; + size_t size = 0; + char file_name[MAX_LENGTH]; + FILE *file; + FILE *cpu_file; + + if (list == NULL) { + return CPU_NUM; + } + + file = fopen(CPU_USAGE_FILE, "r"); + if (file == NULL) { + ALOGE("%s: failed to open: %s", __func__, strerror(errno)); + return -errno; + } + + while ((read = getline(&line, &len, file)) != -1) { + // Skip non "cpu[0-9]" lines. + if (strnlen(line, read) < 4 || strncmp(line, "cpu", 3) != 0 || !isdigit(line[3])) { + free(line); + line = NULL; + len = 0; + continue; + } + + vals = sscanf(line, "cpu%d %" SCNu64 " %" SCNu64 " %" SCNu64 " %" SCNu64, &cpu_num, &user, + &nice, &system, &idle); + + free(line); + line = NULL; + len = 0; + + if (vals != 5 || size == CPU_NUM) { + if (vals != 5) { + ALOGE("%s: failed to read CPU information from file: %s", __func__, + strerror(errno)); + } else { + ALOGE("/proc/stat file has incorrect format."); + } + fclose(file); + return errno ? -errno : -EIO; + } + + active = user + nice + system; + total = active + idle; + + // Read online CPU information. + snprintf(file_name, MAX_LENGTH, CPU_ONLINE_FILE_FORMAT, cpu_num); + cpu_file = fopen(file_name, "r"); + online = 0; + if (cpu_file == NULL) { + ALOGE("%s: failed to open file: %s (%s)", __func__, file_name, strerror(errno)); + fclose(file); + return -errno; + } + if (1 != fscanf(cpu_file, "%d", &online)) { + ALOGE("%s: failed to read CPU online information from file: %s (%s)", __func__, + file_name, strerror(errno)); + fclose(file); + fclose(cpu_file); + return errno ? -errno : -EIO; + } + fclose(cpu_file); + + list[size] = (cpu_usage_t) { + .name = CPU_LABEL[size], + .active = active, + .total = total, + .is_online = online + }; + + size++; + } + fclose(file); + + if (size != CPU_NUM) { + ALOGE("/proc/stat file has incorrect format."); + return -EIO; + } + return CPU_NUM; +} + +static struct hw_module_methods_t thermal_module_methods = { + .open = NULL, +}; + +thermal_module_t HAL_MODULE_INFO_SYM = { + .common = { + .tag = HARDWARE_MODULE_TAG, + .module_api_version = THERMAL_HARDWARE_MODULE_API_VERSION_0_1, + .hal_api_version = HARDWARE_HAL_API_VERSION, + .id = THERMAL_HARDWARE_MODULE_ID, + .name = "Kitakami Thermal HAL", + .author = "The Android Open Source Project", + .methods = &thermal_module_methods, + }, + .getTemperatures = get_temperatures, + .getCpuUsages = get_cpu_usages, +}; -- GitLab From ace53bd13bcdd287bd71cbd918235dcc67e55da2 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Fri, 13 Nov 2020 12:19:06 +0100 Subject: [PATCH 082/191] Commonized fingerprint HAL Change-Id: I37a3d59fcf510871b9b8ac9d27f3b72e0b6db8f9 --- device-common.mk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/device-common.mk b/device-common.mk index d4f1d4f..27f30bc 100644 --- a/device-common.mk +++ b/device-common.mk @@ -171,6 +171,13 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ android.hardware.dumpstate@1.1-service-kitakami +# Fingerprint +PRODUCT_COPY_FILES += \ + frameworks/native/data/etc/android.hardware.fingerprint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.fingerprint.xml + +PRODUCT_PACKAGES += \ + android.hardware.biometrics.fingerprint@2.1-service.kitakami + # Gatekeeper PRODUCT_PACKAGES += \ android.hardware.gatekeeper@1.0-impl -- GitLab From ef49dcda5de5a36ebbaf4ce56a14d5271eb496ae Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Fri, 13 Nov 2020 13:54:36 +0100 Subject: [PATCH 083/191] kitakami-common: sepolicy: Added some more properties for system_app. Change-Id: If278b64c99cfb8e508a1f1c089a13390c2c8d456 --- sepolicy/vendor/system_app.te | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sepolicy/vendor/system_app.te b/sepolicy/vendor/system_app.te index 1ba7323..f7a776f 100644 --- a/sepolicy/vendor/system_app.te +++ b/sepolicy/vendor/system_app.te @@ -1,5 +1,16 @@ +allow system_app default_android_service:service_manager find; +allow system_app hal_power_default:binder call; allow system_app init:binder call; +allow system_app installd:binder call; +allow system_app iorapd:binder call; +allow system_app netd:binder call; +allow system_app proc_pagetypeinfo:file r_file_perms; allow system_app sysfs_rtc:dir search; +allow system_app sysfs_zram:dir search; +allow system_app sysfs_zram:file r_file_perms; +allow system_app system_suspend_control_service:service_manager find; allow system_app time_data_file:dir search; allow system_app time_data_file:file rw_file_perms; allow system_app vendor_default_prop:property_service set; +allow system_app vold:binder call; +allow system_app wificond:binder call; -- GitLab From 60a17a8a6592fa13a60b116d75d680085a55eea1 Mon Sep 17 00:00:00 2001 From: Dyneteve Date: Thu, 17 Sep 2020 18:46:02 +0200 Subject: [PATCH 084/191] kitakami-common: sepolicy: Label dumpstate hal --- sepolicy/vendor/file_contexts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index d86551a..9b4128a 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -26,6 +26,9 @@ # Camera /sys/devices(/soc\.0)?/pmi8994-flash-27(/.*)? u:object_r:sysfs_camera_torch:s0 +# Dumpstate HAL +/vendor/bin/hw/android\.hardware\.dumpstate@1\.1-service\.kitakami u:object_r:hal_dumpstate_impl_exec:s0 + # HCI /dev/ttyHS0 u:object_r:hci_attach_dev:s0 /dev/brcm_bt_drv u:object_r:hci_attach_dev:s0 -- GitLab From 599cddda38b1f062fde1c25b07e4ec93d7e6760f Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Thu, 29 Oct 2020 13:34:00 +0800 Subject: [PATCH 085/191] kitakami-common: sepolicy: Address Dumpstate HAL denials * Also address vendor SPL props denial. Change-Id: I1a0875a06a7a5f26f30270fc0902e236293b666e --- sepolicy/vendor/hal_dumpstate_impl.te | 10 ++++++++++ sepolicy/vendor/hwservicemanager.te | 4 ++++ sepolicy/vendor/system_app.te | 1 + sepolicy/vendor/system_server.te | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 sepolicy/vendor/hal_dumpstate_impl.te diff --git a/sepolicy/vendor/hal_dumpstate_impl.te b/sepolicy/vendor/hal_dumpstate_impl.te new file mode 100644 index 0000000..d380fcf --- /dev/null +++ b/sepolicy/vendor/hal_dumpstate_impl.te @@ -0,0 +1,10 @@ +type hal_dumpstate_impl, domain; +type hal_dumpstate_impl_exec, exec_type, file_type, vendor_file_type; + +init_daemon_domain(hal_dumpstate_impl) + +allow hal_dumpstate_impl hal_dumpstate_impl_exec:file execute_no_trans; +allow hal_dumpstate_impl hwservicemanager:binder { call transfer }; +allow hal_dumpstate_impl hwservicemanager_prop:file { getattr map open read }; +allow hal_dumpstate_impl hidl_base_hwservice:hwservice_manager add; +allow hal_dumpstate_impl hal_dumpstate_hwservice:hwservice_manager { add find }; diff --git a/sepolicy/vendor/hwservicemanager.te b/sepolicy/vendor/hwservicemanager.te index 99d0d97..b56a7dd 100644 --- a/sepolicy/vendor/hwservicemanager.te +++ b/sepolicy/vendor/hwservicemanager.te @@ -1,6 +1,10 @@ allow hwservicemanager hal_drm_clearkey:dir search; allow hwservicemanager hal_drm_clearkey:file { open read }; allow hwservicemanager hal_drm_clearkey:process getattr; +allow hwservicemanager hal_dumpstate_impl:dir rw_dir_perms; +allow hwservicemanager hal_dumpstate_impl:file rw_file_perms; +allow hwservicemanager hal_dumpstate_impl:binder { call transfer }; +allow hwservicemanager hal_dumpstate_impl:process getattr; allow hwservicemanager init:dir search; allow hwservicemanager init:file { open read }; allow hwservicemanager init:process getattr; diff --git a/sepolicy/vendor/system_app.te b/sepolicy/vendor/system_app.te index f7a776f..68a8e31 100644 --- a/sepolicy/vendor/system_app.te +++ b/sepolicy/vendor/system_app.te @@ -1,5 +1,6 @@ allow system_app default_android_service:service_manager find; allow system_app hal_power_default:binder call; +allow system_app hal_dumpstate_impl:binder call; allow system_app init:binder call; allow system_app installd:binder call; allow system_app iorapd:binder call; diff --git a/sepolicy/vendor/system_server.te b/sepolicy/vendor/system_server.te index 1c0afe1..1579d65 100644 --- a/sepolicy/vendor/system_server.te +++ b/sepolicy/vendor/system_server.te @@ -2,4 +2,4 @@ allow system_server exported_camera_prop:file { getattr open read }; allow system_server hal_light_default:process signal; allow system_server userspace_reboot_config_prop:file { getattr open read }; allow system_server userspace_reboot_exported_prop:file { getattr open read }; -allow system_server vendor_security_patch_level_prop:file { getattr open read }; +allow system_server vendor_security_patch_level_prop:file r_file_perms; -- GitLab From d406ac4e0eebf458ac169675c3b04d59f5a3a20a Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Fri, 13 Nov 2020 21:13:47 +0800 Subject: [PATCH 086/191] Revert "kitakami-common: memory: Enable SVELTE memory configuration" This reverts commit 58622a463e05650a6b18adaad485bec3b423ae03. --- BoardConfigCommon.mk | 3 --- 1 file changed, 3 deletions(-) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index e679768..b54829e 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -175,9 +175,6 @@ TARGET_PROVIDES_KEYMASTER := true # memfd TARGET_HAS_MEMFD_BACKPORT := true -# Memory -MALLOC_SVELTE := true - # NFC NFC_NXP_CHIP_TYPE := PN547C2 BOARD_NFC_CHIPSET := pn547 -- GitLab From c4db59068624d241e9b123931058494717295382 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Sat, 14 Nov 2020 01:14:25 +0800 Subject: [PATCH 087/191] kitakami-common: Kang OSS GPS sources from Oneplus2 --- BoardConfigCommon.mk | 2 - device-common.mk | 12 +- gps/Android.mk | 19 + gps/core/Android.mk | 47 + gps/core/ContextBase.cpp | 114 + gps/core/ContextBase.h | 74 + gps/core/LBSProxyBase.h | 79 + gps/core/LocAdapterBase.cpp | 142 + gps/core/LocAdapterBase.h | 125 + gps/core/LocAdapterProxyBase.h | 75 + gps/core/LocApiBase.cpp | 553 +++ gps/core/LocApiBase.h | 267 ++ gps/core/LocDualContext.cpp | 147 + gps/core/LocDualContext.h | 76 + gps/core/UlpProxyBase.h | 105 + gps/core/fused_location_extended.h | 86 + gps/core/gps_extended.h | 92 + gps/core/gps_extended_c.h | 436 +++ gps/core/loc_core_log.cpp | 243 ++ gps/core/loc_core_log.h | 58 + gps/etc/Android.mk | 33 + gps/{ => etc}/flp.conf | 4 +- gps/{ => etc}/gps.conf | 39 +- gps/{ => etc}/izat.conf | 2 +- gps/{ => etc}/sap.conf | 3 +- gps/loc_api/Android.mk | 17 + gps/loc_api/libloc_api_50001/Android.mk | 92 + .../libloc_api_50001/LocEngAdapter.cpp | 598 ++++ gps/loc_api/libloc_api_50001/LocEngAdapter.h | 351 ++ gps/loc_api/libloc_api_50001/gps.c | 73 + gps/loc_api/libloc_api_50001/loc.cpp | 1076 ++++++ gps/loc_api/libloc_api_50001/loc.h | 66 + gps/loc_api/libloc_api_50001/loc_eng.cpp | 2999 +++++++++++++++++ gps/loc_api/libloc_api_50001/loc_eng.h | 271 ++ gps/loc_api/libloc_api_50001/loc_eng_agps.cpp | 970 ++++++ gps/loc_api/libloc_api_50001/loc_eng_agps.h | 431 +++ .../libloc_api_50001/loc_eng_dmn_conn.cpp | 270 ++ .../libloc_api_50001/loc_eng_dmn_conn.h | 59 + .../loc_eng_dmn_conn_glue_msg.c | 223 ++ .../loc_eng_dmn_conn_glue_msg.h | 51 + .../loc_eng_dmn_conn_glue_pipe.c | 214 ++ .../loc_eng_dmn_conn_glue_pipe.h | 50 + .../loc_eng_dmn_conn_handler.cpp | 237 ++ .../loc_eng_dmn_conn_handler.h | 106 + .../loc_eng_dmn_conn_thread_helper.c | 399 +++ .../loc_eng_dmn_conn_thread_helper.h | 74 + gps/loc_api/libloc_api_50001/loc_eng_log.cpp | 35 + gps/loc_api/libloc_api_50001/loc_eng_log.h | 44 + gps/loc_api/libloc_api_50001/loc_eng_msg.h | 306 ++ gps/loc_api/libloc_api_50001/loc_eng_ni.cpp | 414 +++ gps/loc_api/libloc_api_50001/loc_eng_ni.h | 59 + gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp | 922 +++++ gps/loc_api/libloc_api_50001/loc_eng_nmea.h | 43 + gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp | 213 ++ gps/loc_api/libloc_api_50001/loc_eng_xtra.h | 47 + gps/utils/Android.mk | 64 + gps/utils/LocHeap.cpp | 354 ++ gps/utils/LocHeap.h | 96 + gps/utils/LocSharedLock.h | 59 + gps/utils/LocThread.cpp | 262 ++ gps/utils/LocThread.h | 92 + gps/utils/LocTimer.cpp | 742 ++++ gps/utils/LocTimer.h | 74 + gps/utils/MsgTask.cpp | 102 + gps/utils/MsgTask.h | 67 + gps/utils/linked_list.c | 328 ++ gps/utils/linked_list.h | 217 ++ gps/utils/loc_cfg.cpp | 400 +++ gps/utils/loc_cfg.h | 91 + gps/utils/loc_log.cpp | 242 ++ gps/utils/loc_log.h | 68 + gps/utils/loc_misc_utils.cpp | 114 + gps/utils/loc_misc_utils.h | 99 + gps/utils/loc_target.cpp | 261 ++ gps/utils/loc_target.h | 82 + gps/utils/loc_timer.h | 73 + gps/utils/log_util.h | 167 + gps/utils/msg_q.c | 336 ++ gps/utils/msg_q.h | 207 ++ .../elapsed_millis_since_boot.cpp | 46 + .../platform_lib_includes.h | 35 + .../platform_lib_macros.h | 81 + .../platform_lib_time.h | 35 + rootdir/init.qcom.rc | 5 - 84 files changed, 18301 insertions(+), 41 deletions(-) create mode 100644 gps/Android.mk create mode 100644 gps/core/Android.mk create mode 100644 gps/core/ContextBase.cpp create mode 100644 gps/core/ContextBase.h create mode 100644 gps/core/LBSProxyBase.h create mode 100644 gps/core/LocAdapterBase.cpp create mode 100644 gps/core/LocAdapterBase.h create mode 100644 gps/core/LocAdapterProxyBase.h create mode 100644 gps/core/LocApiBase.cpp create mode 100644 gps/core/LocApiBase.h create mode 100644 gps/core/LocDualContext.cpp create mode 100644 gps/core/LocDualContext.h create mode 100644 gps/core/UlpProxyBase.h create mode 100644 gps/core/fused_location_extended.h create mode 100644 gps/core/gps_extended.h create mode 100644 gps/core/gps_extended_c.h create mode 100644 gps/core/loc_core_log.cpp create mode 100644 gps/core/loc_core_log.h create mode 100644 gps/etc/Android.mk rename gps/{ => etc}/flp.conf (98%) rename gps/{ => etc}/gps.conf (80%) rename gps/{ => etc}/izat.conf (99%) rename gps/{ => etc}/sap.conf (99%) create mode 100644 gps/loc_api/Android.mk create mode 100644 gps/loc_api/libloc_api_50001/Android.mk create mode 100644 gps/loc_api/libloc_api_50001/LocEngAdapter.cpp create mode 100644 gps/loc_api/libloc_api_50001/LocEngAdapter.h create mode 100644 gps/loc_api/libloc_api_50001/gps.c create mode 100644 gps/loc_api/libloc_api_50001/loc.cpp create mode 100644 gps/loc_api/libloc_api_50001/loc.h create mode 100644 gps/loc_api/libloc_api_50001/loc_eng.cpp create mode 100644 gps/loc_api/libloc_api_50001/loc_eng.h create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_agps.cpp create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_agps.h create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_log.cpp create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_log.h create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_msg.h create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_ni.cpp create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_ni.h create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_nmea.h create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp create mode 100644 gps/loc_api/libloc_api_50001/loc_eng_xtra.h create mode 100644 gps/utils/Android.mk create mode 100644 gps/utils/LocHeap.cpp create mode 100644 gps/utils/LocHeap.h create mode 100644 gps/utils/LocSharedLock.h create mode 100644 gps/utils/LocThread.cpp create mode 100644 gps/utils/LocThread.h create mode 100644 gps/utils/LocTimer.cpp create mode 100644 gps/utils/LocTimer.h create mode 100644 gps/utils/MsgTask.cpp create mode 100644 gps/utils/MsgTask.h create mode 100644 gps/utils/linked_list.c create mode 100644 gps/utils/linked_list.h create mode 100644 gps/utils/loc_cfg.cpp create mode 100644 gps/utils/loc_cfg.h create mode 100644 gps/utils/loc_log.cpp create mode 100644 gps/utils/loc_log.h create mode 100644 gps/utils/loc_misc_utils.cpp create mode 100644 gps/utils/loc_misc_utils.h create mode 100644 gps/utils/loc_target.cpp create mode 100644 gps/utils/loc_target.h create mode 100644 gps/utils/loc_timer.h create mode 100644 gps/utils/log_util.h create mode 100644 gps/utils/msg_q.c create mode 100644 gps/utils/msg_q.h create mode 100644 gps/utils/platform_lib_abstractions/elapsed_millis_since_boot.cpp create mode 100644 gps/utils/platform_lib_abstractions/platform_lib_includes.h create mode 100644 gps/utils/platform_lib_abstractions/platform_lib_macros.h create mode 100644 gps/utils/platform_lib_abstractions/platform_lib_time.h diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index b54829e..4299578 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -199,8 +199,6 @@ TARGET_LD_SHIM_LIBS := \ /system/vendor/lib/hw/camera.vendor.msm8994.so|/system/vendor/lib/camera.qcom_shim.so \ /system/lib64/libsys-utils.so|libsensor.so \ /system/lib/libcammw.so|libsensor.so \ - /system/vendor/lib/libizat_core.so|/system/vendor/lib/libshim_gps.so \ - /system/vendor/lib64/libizat_core.so|/system/vendor/lib64/libshim_gps.so \ /system/bin/secd|/system/lib64/lib-preload64.so \ /system/vendor/lib64/libril-qc-qmi-1.so|libaudioclient_shim.so diff --git a/device-common.mk b/device-common.mk index 27f30bc..0ce8cfd 100644 --- a/device-common.mk +++ b/device-common.mk @@ -184,13 +184,11 @@ PRODUCT_PACKAGES += \ # GPS PRODUCT_PACKAGES += \ - libshim_gps - -PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/gps/flp.conf:system/etc/flp.conf \ - $(LOCAL_PATH)/gps/gps.conf:system/etc/gps.conf \ - $(LOCAL_PATH)/gps/izat.conf:system/etc/izat.conf \ - $(LOCAL_PATH)/gps/sap.conf:system/etc/sap.conf + gps.msm8994 \ + flp.conf \ + gps.conf \ + izat.conf \ + sap.conf PRODUCT_PACKAGES += \ android.hardware.gnss@1.0-impl diff --git a/gps/Android.mk b/gps/Android.mk new file mode 100644 index 0000000..87cdb03 --- /dev/null +++ b/gps/Android.mk @@ -0,0 +1,19 @@ +# +# Copyright (C) 2015 The CyanogenMod Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +LOCAL_PATH := $(call my-dir) + +include $(call all-subdir-makefiles,$(LOCAL_PATH)) diff --git a/gps/core/Android.mk b/gps/core/Android.mk new file mode 100644 index 0000000..19eadd8 --- /dev/null +++ b/gps/core/Android.mk @@ -0,0 +1,47 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := libloc_core +LOCAL_MODULE_OWNER := qcom +LOCAL_VENDOR_MODULE := true + +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := \ + liblog \ + libutils \ + libcutils \ + libgps.utils \ + libdl + +LOCAL_SRC_FILES += \ + LocApiBase.cpp \ + LocAdapterBase.cpp \ + ContextBase.cpp \ + LocDualContext.cpp \ + loc_core_log.cpp + +LOCAL_CFLAGS += \ + -fno-short-enums \ + -D_ANDROID_ + +LOCAL_C_INCLUDES:= \ + $(TARGET_OUT_HEADERS)/gps.utils \ + $(TARGET_OUT_HEADERS)/libflp + +LOCAL_COPY_HEADERS_TO:= libloc_core/ +LOCAL_COPY_HEADERS:= \ + LocApiBase.h \ + LocAdapterBase.h \ + ContextBase.h \ + LocDualContext.h \ + LBSProxyBase.h \ + UlpProxyBase.h \ + gps_extended_c.h \ + gps_extended.h \ + loc_core_log.h \ + LocAdapterProxyBase.h \ + fused_location_extended.h + +include $(BUILD_SHARED_LIBRARY) diff --git a/gps/core/ContextBase.cpp b/gps/core/ContextBase.cpp new file mode 100644 index 0000000..9f6c4aa --- /dev/null +++ b/gps/core/ContextBase.cpp @@ -0,0 +1,114 @@ +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_CtxBase" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace loc_core { + +LBSProxyBase* ContextBase::getLBSProxy(const char* libName) +{ + LBSProxyBase* proxy = NULL; + LOC_LOGD("%s:%d]: getLBSProxy libname: %s\n", __func__, __LINE__, libName); + void* lib = dlopen(libName, RTLD_NOW); + + if ((void*)NULL != lib) { + getLBSProxy_t* getter = (getLBSProxy_t*)dlsym(lib, "getLBSProxy"); + if (NULL != getter) { + proxy = (*getter)(); + } + } + if (NULL == proxy) { + proxy = new LBSProxyBase(); + } + LOC_LOGD("%s:%d]: Exiting\n", __func__, __LINE__); + return proxy; +} + +LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask) +{ + LocApiBase* locApi = NULL; + + // first if can not be MPQ + if (TARGET_MPQ != loc_get_target()) { + if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask, this))) { + void *handle = NULL; + //try to see if LocApiV02 is present + if((handle = dlopen("libloc_api_v02.so", RTLD_NOW)) != NULL) { + LOC_LOGD("%s:%d]: libloc_api_v02.so is present", __func__, __LINE__); + getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi"); + if(getter != NULL) { + LOC_LOGD("%s:%d]: getter is not NULL for LocApiV02", __func__, __LINE__); + locApi = (*getter)(mMsgTask, exMask, this); + } + } + // only RPC is the option now + else { + LOC_LOGD("%s:%d]: libloc_api_v02.so is NOT present. Trying RPC", + __func__, __LINE__); + handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW); + if (NULL != handle) { + getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi"); + if (NULL != getter) { + LOC_LOGD("%s:%d]: getter is not NULL in RPC", __func__, __LINE__); + locApi = (*getter)(mMsgTask, exMask, this); + } + } + } + } + } + + // locApi could still be NULL at this time + // we would then create a dummy one + if (NULL == locApi) { + locApi = new LocApiBase(mMsgTask, exMask, this); + } + + return locApi; +} + +ContextBase::ContextBase(const MsgTask* msgTask, + LOC_API_ADAPTER_EVENT_MASK_T exMask, + const char* libName) : + mLBSProxy(getLBSProxy(libName)), + mMsgTask(msgTask), + mLocApi(createLocApi(exMask)), + mLocApiProxy(mLocApi->getLocApiProxy()) +{ +} + +} diff --git a/gps/core/ContextBase.h b/gps/core/ContextBase.h new file mode 100644 index 0000000..fe0b860 --- /dev/null +++ b/gps/core/ContextBase.h @@ -0,0 +1,74 @@ +/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __LOC_CONTEXT_BASE__ +#define __LOC_CONTEXT_BASE__ + +#include +#include +#include +#include +#include + +namespace loc_core { + +class LocAdapterBase; + +class ContextBase { + static LBSProxyBase* getLBSProxy(const char* libName); + LocApiBase* createLocApi(LOC_API_ADAPTER_EVENT_MASK_T excludedMask); +protected: + const LBSProxyBase* mLBSProxy; + const MsgTask* mMsgTask; + LocApiBase* mLocApi; + LocApiProxyBase *mLocApiProxy; +public: + ContextBase(const MsgTask* msgTask, + LOC_API_ADAPTER_EVENT_MASK_T exMask, + const char* libName); + inline virtual ~ContextBase() { delete mLocApi; delete mLBSProxy; } + + inline const MsgTask* getMsgTask() { return mMsgTask; } + inline LocApiBase* getLocApi() { return mLocApi; } + inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; } + inline bool hasAgpsExtendedCapabilities() { return mLBSProxy->hasAgpsExtendedCapabilities(); } + inline bool hasCPIExtendedCapabilities() { return mLBSProxy->hasCPIExtendedCapabilities(); } + inline void modemPowerVote(bool power) const { return mLBSProxy->modemPowerVote(power); } + inline void requestUlp(LocAdapterBase* adapter, + unsigned long capabilities) { + mLBSProxy->requestUlp(adapter, capabilities); + } + inline IzatDevId_t getIzatDevId() const { + return mLBSProxy->getIzatDevId(); + } + inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); } +}; + +} // namespace loc_core + +#endif //__LOC_CONTEXT_BASE__ diff --git a/gps/core/LBSProxyBase.h b/gps/core/LBSProxyBase.h new file mode 100644 index 0000000..b3736c2 --- /dev/null +++ b/gps/core/LBSProxyBase.h @@ -0,0 +1,79 @@ +/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef IZAT_PROXY_BASE_H +#define IZAT_PROXY_BASE_H +#include +#include + +namespace loc_core { + +class LocApiBase; +class LocAdapterBase; +class ContextBase; + +class LBSProxyBase { + friend class ContextBase; + inline virtual LocApiBase* + getLocApi(const MsgTask* msgTask, + LOC_API_ADAPTER_EVENT_MASK_T exMask, + ContextBase* context) const { + + (void)msgTask; + (void)exMask; + (void)context; + return NULL; + } +protected: + inline LBSProxyBase() {} +public: + inline virtual ~LBSProxyBase() {} + inline virtual void requestUlp(LocAdapterBase* adapter, + unsigned long capabilities) const { + + (void)adapter; + (void)capabilities; + } + inline virtual bool hasAgpsExtendedCapabilities() const { return false; } + inline virtual bool hasCPIExtendedCapabilities() const { return false; } + inline virtual void modemPowerVote(bool power) const { + + (void)power; + } + virtual void injectFeatureConfig(ContextBase* context) const { + + (void)context; + } + inline virtual IzatDevId_t getIzatDevId() const { return 0; } +}; + +typedef LBSProxyBase* (getLBSProxy_t)(); + +} // namespace loc_core + +#endif // IZAT_PROXY_BASE_H diff --git a/gps/core/LocAdapterBase.cpp b/gps/core/LocAdapterBase.cpp new file mode 100644 index 0000000..fbd077a --- /dev/null +++ b/gps/core/LocAdapterBase.cpp @@ -0,0 +1,142 @@ +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_LocAdapterBase" + +#include +#include +#include +#include +#include + +namespace loc_core { + +// This is the top level class, so the constructor will +// always gets called. Here we prepare for the default. +// But if getLocApi(targetEnumType target) is overriden, +// the right locApi should get created. +LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, + ContextBase* context, LocAdapterProxyBase *adapterProxyBase) : + mEvtMask(mask), mContext(context), + mLocApi(context->getLocApi()), mLocAdapterProxyBase(adapterProxyBase), + mMsgTask(context->getMsgTask()) +{ + mLocApi->addAdapter(this); +} + +void LocAdapterBase::handleEngineUpEvent() +{ + if (mLocAdapterProxyBase) { + mLocAdapterProxyBase->handleEngineUpEvent(); + } +} + +void LocAdapterBase::handleEngineDownEvent() +{ + if (mLocAdapterProxyBase) { + mLocAdapterProxyBase->handleEngineDownEvent(); + } +} + +void LocAdapterBase:: + reportPosition(UlpLocation &location, + GpsLocationExtended &locationExtended, + void* locationExt, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask) { + if (mLocAdapterProxyBase == NULL || + !mLocAdapterProxyBase->reportPosition(location, + locationExtended, + status, + loc_technology_mask)) { + DEFAULT_IMPL() + } +} + +void LocAdapterBase:: + reportSv(QcomSvStatus &svStatus, + GpsLocationExtended &locationExtended, + void* svExt) +DEFAULT_IMPL() + + +void LocAdapterBase:: + reportStatus(GpsStatusValue status) +DEFAULT_IMPL() + + +void LocAdapterBase:: + reportNmea(const char* nmea, int length) +DEFAULT_IMPL() + +bool LocAdapterBase:: + reportXtraServer(const char* url1, const char* url2, + const char* url3, const int maxlength) +DEFAULT_IMPL(false) + +bool LocAdapterBase:: + requestXtraData() +DEFAULT_IMPL(false) + +bool LocAdapterBase:: + requestTime() +DEFAULT_IMPL(false) + +bool LocAdapterBase:: + requestLocation() +DEFAULT_IMPL(false) + +bool LocAdapterBase:: + requestATL(int connHandle, AGpsType agps_type) +DEFAULT_IMPL(false) + +bool LocAdapterBase:: + releaseATL(int connHandle) +DEFAULT_IMPL(false) + +bool LocAdapterBase:: + requestSuplES(int connHandle) +DEFAULT_IMPL(false) + +bool LocAdapterBase:: + reportDataCallOpened() +DEFAULT_IMPL(false) + +bool LocAdapterBase:: + reportDataCallClosed() +DEFAULT_IMPL(false) + +bool LocAdapterBase:: + requestNiNotify(GpsNiNotification ¬ify, const void* data) +DEFAULT_IMPL(false) + +void LocAdapterBase:: + reportGpsMeasurementData(GpsData &gpsMeasurementData) +DEFAULT_IMPL() +} // namespace loc_core diff --git a/gps/core/LocAdapterBase.h b/gps/core/LocAdapterBase.h new file mode 100644 index 0000000..2268062 --- /dev/null +++ b/gps/core/LocAdapterBase.h @@ -0,0 +1,125 @@ +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef LOC_API_ADAPTER_BASE_H +#define LOC_API_ADAPTER_BASE_H + +#include +#include +#include + +namespace loc_core { + +class LocAdapterProxyBase; + +class LocAdapterBase { +protected: + LOC_API_ADAPTER_EVENT_MASK_T mEvtMask; + ContextBase* mContext; + LocApiBase* mLocApi; + LocAdapterProxyBase* mLocAdapterProxyBase; + const MsgTask* mMsgTask; + + inline LocAdapterBase(const MsgTask* msgTask) : + mEvtMask(0), mContext(NULL), mLocApi(NULL), + mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {} +public: + inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); } + LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, + ContextBase* context, LocAdapterProxyBase *adapterProxyBase = NULL); + inline LOC_API_ADAPTER_EVENT_MASK_T + checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const { + return mEvtMask & mask; + } + + inline LOC_API_ADAPTER_EVENT_MASK_T getEvtMask() const { + return mEvtMask; + } + + inline void sendMsg(const LocMsg* msg) const { + mMsgTask->sendMsg(msg); + } + + inline void sendMsg(const LocMsg* msg) { + mMsgTask->sendMsg(msg); + } + + inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event, + loc_registration_mask_status isEnabled) + { + mEvtMask = + isEnabled == LOC_REGISTRATION_MASK_ENABLED ? (mEvtMask|event):(mEvtMask&~event); + + mLocApi->updateEvtMask(); + } + + // This will be overridden by the individual adapters + // if necessary. + inline virtual void setUlpProxy(UlpProxyBase* ulp) { + + (void)ulp; + } + virtual void handleEngineUpEvent(); + virtual void handleEngineDownEvent(); + inline virtual void setPositionModeInt(LocPosMode& posMode) { + + (void)posMode; + } + virtual void startFixInt() {} + virtual void stopFixInt() {} + virtual void getZppInt() {} + virtual void reportPosition(UlpLocation &location, + GpsLocationExtended &locationExtended, + void* locationExt, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask); + virtual void reportSv(QcomSvStatus &svStatus, + GpsLocationExtended &locationExtended, + void* svExt); + virtual void reportStatus(GpsStatusValue status); + virtual void reportNmea(const char* nmea, int length); + virtual bool reportXtraServer(const char* url1, const char* url2, + const char* url3, const int maxlength); + virtual bool requestXtraData(); + virtual bool requestTime(); + virtual bool requestLocation(); + virtual bool requestATL(int connHandle, AGpsType agps_type); + virtual bool releaseATL(int connHandle); + virtual bool requestSuplES(int connHandle); + virtual bool reportDataCallOpened(); + virtual bool reportDataCallClosed(); + virtual bool requestNiNotify(GpsNiNotification ¬ify, + const void* data); + inline virtual bool isInSession() { return false; } + ContextBase* getContext() const { return mContext; } + virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData); +}; + +} // namespace loc_core + +#endif //LOC_API_ADAPTER_BASE_H diff --git a/gps/core/LocAdapterProxyBase.h b/gps/core/LocAdapterProxyBase.h new file mode 100644 index 0000000..11859de --- /dev/null +++ b/gps/core/LocAdapterProxyBase.h @@ -0,0 +1,75 @@ +/* Copyright (c) 2014 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef LOC_ADAPTER_PROXY_BASE_H +#define LOC_ADAPTER_PROXY_BASE_H + +#include +#include + +namespace loc_core { + +class LocAdapterProxyBase { +private: + LocAdapterBase *mLocAdapterBase; +protected: + inline LocAdapterProxyBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, + ContextBase* context): + mLocAdapterBase(new LocAdapterBase(mask, context, this)) { + } + inline virtual ~LocAdapterProxyBase() { + delete mLocAdapterBase; + } + ContextBase* getContext() const { + return mLocAdapterBase->getContext(); + } + inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event, + loc_registration_mask_status isEnabled) { + mLocAdapterBase->updateEvtMask(event,isEnabled); + } + +public: + inline virtual void handleEngineUpEvent() {}; + inline virtual void handleEngineDownEvent() {}; + inline virtual bool reportPosition(UlpLocation &location, + GpsLocationExtended &locationExtended, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask) { + + (void)location; + (void)locationExtended; + (void)status; + (void)loc_technology_mask; + return false; + } +}; + +} // namespace loc_core + +#endif //LOC_ADAPTER_PROXY_BASE_H diff --git a/gps/core/LocApiBase.cpp b/gps/core/LocApiBase.cpp new file mode 100644 index 0000000..8247d0a --- /dev/null +++ b/gps/core/LocApiBase.cpp @@ -0,0 +1,553 @@ +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_LocApiBase" + +#include +#include +#include +#include +#include + +namespace loc_core { + +#define TO_ALL_LOCADAPTERS(call) TO_ALL_ADAPTERS(mLocAdapters, (call)) +#define TO_1ST_HANDLING_LOCADAPTERS(call) TO_1ST_HANDLING_ADAPTER(mLocAdapters, (call)) + +int hexcode(char *hexstring, int string_size, + const char *data, int data_size) +{ + int i; + for (i = 0; i < data_size; i++) + { + char ch = data[i]; + if (i*2 + 3 <= string_size) + { + snprintf(&hexstring[i*2], 3, "%02X", ch); + } + else { + break; + } + } + return i; +} + +int decodeAddress(char *addr_string, int string_size, + const char *data, int data_size) +{ + const char addr_prefix = 0x91; + int i, idxOutput = 0; + + if (!data || !addr_string) { return 0; } + + if (data[0] != addr_prefix) + { + LOC_LOGW("decodeAddress: address prefix is not 0x%x but 0x%x", addr_prefix, data[0]); + addr_string[0] = '\0'; + return 0; // prefix not correct + } + + for (i = 1; i < data_size; i++) + { + unsigned char ch = data[i], low = ch & 0x0F, hi = ch >> 4; + if (low <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = low + '0'; } + if (hi <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = hi + '0'; } + } + + addr_string[idxOutput] = '\0'; // Terminates the string + + return idxOutput; +} + +struct LocSsrMsg : public LocMsg { + LocApiBase* mLocApi; + inline LocSsrMsg(LocApiBase* locApi) : + LocMsg(), mLocApi(locApi) + { + locallog(); + } + inline virtual void proc() const { + mLocApi->close(); + mLocApi->open(mLocApi->getEvtMask()); + } + inline void locallog() { + LOC_LOGV("LocSsrMsg"); + } + inline virtual void log() { + locallog(); + } +}; + +struct LocOpenMsg : public LocMsg { + LocApiBase* mLocApi; + LOC_API_ADAPTER_EVENT_MASK_T mMask; + inline LocOpenMsg(LocApiBase* locApi, + LOC_API_ADAPTER_EVENT_MASK_T mask) : + LocMsg(), mLocApi(locApi), mMask(mask) + { + locallog(); + } + inline virtual void proc() const { + mLocApi->open(mMask); + } + inline void locallog() { + LOC_LOGV("%s:%d]: LocOpen Mask: %x\n", + __func__, __LINE__, mMask); + } + inline virtual void log() { + locallog(); + } +}; + +LocApiBase::LocApiBase(const MsgTask* msgTask, + LOC_API_ADAPTER_EVENT_MASK_T excludedMask, + ContextBase* context) : + mExcludedMask(excludedMask), mMsgTask(msgTask), + mMask(0), mSupportedMsg(0), mContext(context) +{ + memset(mLocAdapters, 0, sizeof(mLocAdapters)); +} + +LOC_API_ADAPTER_EVENT_MASK_T LocApiBase::getEvtMask() +{ + LOC_API_ADAPTER_EVENT_MASK_T mask = 0; + + TO_ALL_LOCADAPTERS(mask |= mLocAdapters[i]->getEvtMask()); + + return mask & ~mExcludedMask; +} + +bool LocApiBase::isInSession() +{ + bool inSession = false; + + for (int i = 0; + !inSession && i < MAX_ADAPTERS && NULL != mLocAdapters[i]; + i++) { + inSession = mLocAdapters[i]->isInSession(); + } + + return inSession; +} + +void LocApiBase::addAdapter(LocAdapterBase* adapter) +{ + for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) { + if (mLocAdapters[i] == NULL) { + mLocAdapters[i] = adapter; + mMsgTask->sendMsg(new LocOpenMsg(this, + (adapter->getEvtMask()))); + break; + } + } +} + +void LocApiBase::removeAdapter(LocAdapterBase* adapter) +{ + for (int i = 0; + i < MAX_ADAPTERS && NULL != mLocAdapters[i]; + i++) { + if (mLocAdapters[i] == adapter) { + mLocAdapters[i] = NULL; + + // shift the rest of the adapters up so that the pointers + // in the array do not have holes. This should be more + // performant, because the array maintenance is much much + // less frequent than event handlings, which need to linear + // search all the adapters + int j = i; + while (++i < MAX_ADAPTERS && mLocAdapters[i] != NULL); + + // i would be MAX_ADAPTERS or point to a NULL + i--; + // i now should point to a none NULL adapter within valid + // range although i could be equal to j, but it won't hurt. + // No need to check it, as it gains nothing. + mLocAdapters[j] = mLocAdapters[i]; + // this makes sure that we exit the for loop + mLocAdapters[i] = NULL; + + // if we have an empty list of adapters + if (0 == i) { + close(); + } else { + // else we need to remove the bit + mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask())); + } + } + } +} + +void LocApiBase::updateEvtMask() +{ + mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask())); +} + +void LocApiBase::handleEngineUpEvent() +{ + // This will take care of renegotiating the loc handle + mMsgTask->sendMsg(new LocSsrMsg(this)); + + LocDualContext::injectFeatureConfig(mContext); + + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent()); +} + +void LocApiBase::handleEngineDownEvent() +{ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineDownEvent()); +} + +void LocApiBase::reportPosition(UlpLocation &location, + GpsLocationExtended &locationExtended, + void* locationExt, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask) +{ + // print the location info before delivering + LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n " + "altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n " + "timestamp: %lld\n rawDataSize: %d\n rawData: %p\n " + "Session status: %d\n Technology mask: %u", + location.gpsLocation.flags, location.position_source, + location.gpsLocation.latitude, location.gpsLocation.longitude, + location.gpsLocation.altitude, location.gpsLocation.speed, + location.gpsLocation.bearing, location.gpsLocation.accuracy, + location.gpsLocation.timestamp, location.rawDataSize, + location.rawData, status, loc_technology_mask); + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS( + mLocAdapters[i]->reportPosition(location, + locationExtended, + locationExt, + status, + loc_technology_mask) + ); +} + +void LocApiBase::reportSv(QcomSvStatus &svStatus, + GpsLocationExtended &locationExtended, + void* svExt) +{ + // print the SV info before delivering + LOC_LOGV("num sv: %d\n ephemeris mask: %dxn almanac mask: %x\n gps/glo/bds in use" + " mask: %x/%x/%x\n sv: prn snr elevation azimuth", + svStatus.num_svs, svStatus.ephemeris_mask, + svStatus.almanac_mask, svStatus.gps_used_in_fix_mask, + svStatus.glo_used_in_fix_mask, svStatus.bds_used_in_fix_mask); + for (int i = 0; i < svStatus.num_svs && i < GPS_MAX_SVS; i++) { + LOC_LOGV(" %d: %d %f %f %f", + i, + svStatus.sv_list[i].prn, + svStatus.sv_list[i].snr, + svStatus.sv_list[i].elevation, + svStatus.sv_list[i].azimuth); + } + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS( + mLocAdapters[i]->reportSv(svStatus, + locationExtended, + svExt) + ); +} + +void LocApiBase::reportStatus(GpsStatusValue status) +{ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportStatus(status)); +} + +void LocApiBase::reportNmea(const char* nmea, int length) +{ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmea(nmea, length)); +} + +void LocApiBase::reportXtraServer(const char* url1, const char* url2, + const char* url3, const int maxlength) +{ + // loop through adapters, and deliver to the first handling adapter. + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportXtraServer(url1, url2, url3, maxlength)); + +} + +void LocApiBase::requestXtraData() +{ + // loop through adapters, and deliver to the first handling adapter. + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestXtraData()); +} + +void LocApiBase::requestTime() +{ + // loop through adapters, and deliver to the first handling adapter. + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestTime()); +} + +void LocApiBase::requestLocation() +{ + // loop through adapters, and deliver to the first handling adapter. + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestLocation()); +} + +void LocApiBase::requestATL(int connHandle, AGpsType agps_type) +{ + // loop through adapters, and deliver to the first handling adapter. + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestATL(connHandle, agps_type)); +} + +void LocApiBase::releaseATL(int connHandle) +{ + // loop through adapters, and deliver to the first handling adapter. + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->releaseATL(connHandle)); +} + +void LocApiBase::requestSuplES(int connHandle) +{ + // loop through adapters, and deliver to the first handling adapter. + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestSuplES(connHandle)); +} + +void LocApiBase::reportDataCallOpened() +{ + // loop through adapters, and deliver to the first handling adapter. + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallOpened()); +} + +void LocApiBase::reportDataCallClosed() +{ + // loop through adapters, and deliver to the first handling adapter. + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallClosed()); +} + +void LocApiBase::requestNiNotify(GpsNiNotification ¬ify, const void* data) +{ + // loop through adapters, and deliver to the first handling adapter. + TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotify(notify, data)); +} + +void LocApiBase::saveSupportedMsgList(uint64_t supportedMsgList) +{ + mSupportedMsg = supportedMsgList; +} + +void* LocApiBase :: getSibling() + DEFAULT_IMPL(NULL) + +LocApiProxyBase* LocApiBase :: getLocApiProxy() + DEFAULT_IMPL(NULL) + +void LocApiBase::reportGpsMeasurementData(GpsData &gpsMeasurementData) +{ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGpsMeasurementData(gpsMeasurementData)); +} + +enum loc_api_adapter_err LocApiBase:: + open(LOC_API_ADAPTER_EVENT_MASK_T mask) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + close() +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + startFix(const LocPosMode& posMode) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + stopFix() +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + deleteAidingData(GpsAidingData f) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + enableData(int enable) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + setAPN(char* apn, int len) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + injectPosition(double latitude, double longitude, float accuracy) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + setTime(GpsUtcTime time, int64_t timeReference, int uncertainty) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + setXtraData(char* data, int length) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + requestXtraServer() +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + atlOpenStatus(int handle, int is_succ, char* apn, + AGpsBearerType bear, AGpsType agpsType) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + atlCloseStatus(int handle, int is_succ) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + setPositionMode(const LocPosMode& posMode) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + setServer(const char* url, int len) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + setServer(unsigned int ip, int port, + LocServerType type) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + informNiResponse(GpsUserResponseType userResponse, + const void* passThroughData) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + setSUPLVersion(uint32_t version) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + setLPPConfig(uint32_t profile) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + setSensorControlConfig(int sensorUsage, + int sensorProvider) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, + float gyroBiasVarianceRandomWalk, + bool accelBiasVarianceRandomWalk_valid, + float accelBiasVarianceRandomWalk, + bool angleBiasVarianceRandomWalk_valid, + float angleBiasVarianceRandomWalk, + bool rateBiasVarianceRandomWalk_valid, + float rateBiasVarianceRandomWalk, + bool velocityBiasVarianceRandomWalk_valid, + float velocityBiasVarianceRandomWalk) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + setSensorPerfControlConfig(int controlMode, + int accelSamplesPerBatch, + int accelBatchesPerSec, + int gyroSamplesPerBatch, + int gyroBatchesPerSec, + int accelSamplesPerBatchHigh, + int accelBatchesPerSecHigh, + int gyroSamplesPerBatchHigh, + int gyroBatchesPerSecHigh, + int algorithmConfig) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + setExtPowerConfig(int isBatteryCharging) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + setAGLONASSProtocol(unsigned long aGlonassProtocol) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + getWwanZppFix(GpsLocation& zppLoc) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + getBestAvailableZppFix(GpsLocation& zppLoc) +{ + memset(&zppLoc, 0, sizeof(zppLoc)); + DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +} + +enum loc_api_adapter_err LocApiBase:: + getBestAvailableZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask) +{ + memset(&zppLoc, 0, sizeof(zppLoc)); + memset(&tech_mask, 0, sizeof(tech_mask)); + DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +} + +int LocApiBase:: + initDataServiceClient() +DEFAULT_IMPL(-1) + +int LocApiBase:: + openAndStartDataCall() +DEFAULT_IMPL(-1) + +void LocApiBase:: + stopDataCall() +DEFAULT_IMPL() + +void LocApiBase:: + closeDataCall() +DEFAULT_IMPL() + +int LocApiBase:: + setGpsLock(LOC_GPS_LOCK_MASK lock) +DEFAULT_IMPL(-1) + +void LocApiBase:: + installAGpsCert(const DerEncodedCertificate* pData, + size_t length, + uint32_t slotBitMask) +DEFAULT_IMPL() + +int LocApiBase:: + getGpsLock() +DEFAULT_IMPL(-1) + +enum loc_api_adapter_err LocApiBase:: + setXtraVersionCheck(enum xtra_version_check check) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +int LocApiBase:: + updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event, + loc_registration_mask_status isEnabled) +DEFAULT_IMPL(-1) + +bool LocApiBase:: + gnssConstellationConfig() +DEFAULT_IMPL(false) + +} // namespace loc_core diff --git a/gps/core/LocApiBase.h b/gps/core/LocApiBase.h new file mode 100644 index 0000000..18f8623 --- /dev/null +++ b/gps/core/LocApiBase.h @@ -0,0 +1,267 @@ +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef LOC_API_BASE_H +#define LOC_API_BASE_H + +#include +#include +#include +#include +#include + +namespace loc_core { +class ContextBase; + +int hexcode(char *hexstring, int string_size, + const char *data, int data_size); +int decodeAddress(char *addr_string, int string_size, + const char *data, int data_size); + +#define MAX_ADAPTERS 10 + +#define TO_ALL_ADAPTERS(adapters, call) \ + for (int i = 0; i < MAX_ADAPTERS && NULL != (adapters)[i]; i++) { \ + call; \ + } + +#define TO_1ST_HANDLING_ADAPTER(adapters, call) \ + for (int i = 0; i sendMsg(msg); + } + + void addAdapter(LocAdapterBase* adapter); + void removeAdapter(LocAdapterBase* adapter); + + // upward calls + void handleEngineUpEvent(); + void handleEngineDownEvent(); + void reportPosition(UlpLocation &location, + GpsLocationExtended &locationExtended, + void* locationExt, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask = + LOC_POS_TECH_MASK_DEFAULT); + void reportSv(QcomSvStatus &svStatus, + GpsLocationExtended &locationExtended, + void* svExt); + void reportStatus(GpsStatusValue status); + void reportNmea(const char* nmea, int length); + void reportXtraServer(const char* url1, const char* url2, + const char* url3, const int maxlength); + void requestXtraData(); + void requestTime(); + void requestLocation(); + void requestATL(int connHandle, AGpsType agps_type); + void releaseATL(int connHandle); + void requestSuplES(int connHandle); + void reportDataCallOpened(); + void reportDataCallClosed(); + void requestNiNotify(GpsNiNotification ¬ify, const void* data); + void saveSupportedMsgList(uint64_t supportedMsgList); + void reportGpsMeasurementData(GpsData &gpsMeasurementData); + + // downward calls + // All below functions are to be defined by adapter specific modules: + // RPC, QMI, etc. The default implementation is empty. + + virtual void* getSibling(); + virtual LocApiProxyBase* getLocApiProxy(); + virtual enum loc_api_adapter_err + startFix(const LocPosMode& posMode); + virtual enum loc_api_adapter_err + stopFix(); + virtual enum loc_api_adapter_err + deleteAidingData(GpsAidingData f); + virtual enum loc_api_adapter_err + enableData(int enable); + virtual enum loc_api_adapter_err + setAPN(char* apn, int len); + virtual enum loc_api_adapter_err + injectPosition(double latitude, double longitude, float accuracy); + virtual enum loc_api_adapter_err + setTime(GpsUtcTime time, int64_t timeReference, int uncertainty); + virtual enum loc_api_adapter_err + setXtraData(char* data, int length); + virtual enum loc_api_adapter_err + requestXtraServer(); + virtual enum loc_api_adapter_err + atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType); + virtual enum loc_api_adapter_err + atlCloseStatus(int handle, int is_succ); + virtual enum loc_api_adapter_err + setPositionMode(const LocPosMode& posMode); + virtual enum loc_api_adapter_err + setServer(const char* url, int len); + virtual enum loc_api_adapter_err + setServer(unsigned int ip, int port, + LocServerType type); + virtual enum loc_api_adapter_err + informNiResponse(GpsUserResponseType userResponse, const void* passThroughData); + virtual enum loc_api_adapter_err + setSUPLVersion(uint32_t version); + virtual enum loc_api_adapter_err + setLPPConfig(uint32_t profile); + virtual enum loc_api_adapter_err + setSensorControlConfig(int sensorUsage, int sensorProvider); + virtual enum loc_api_adapter_err + setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, + float gyroBiasVarianceRandomWalk, + bool accelBiasVarianceRandomWalk_valid, + float accelBiasVarianceRandomWalk, + bool angleBiasVarianceRandomWalk_valid, + float angleBiasVarianceRandomWalk, + bool rateBiasVarianceRandomWalk_valid, + float rateBiasVarianceRandomWalk, + bool velocityBiasVarianceRandomWalk_valid, + float velocityBiasVarianceRandomWalk); + virtual enum loc_api_adapter_err + setSensorPerfControlConfig(int controlMode, + int accelSamplesPerBatch, + int accelBatchesPerSec, + int gyroSamplesPerBatch, + int gyroBatchesPerSec, + int accelSamplesPerBatchHigh, + int accelBatchesPerSecHigh, + int gyroSamplesPerBatchHigh, + int gyroBatchesPerSecHigh, + int algorithmConfig); + virtual enum loc_api_adapter_err + setExtPowerConfig(int isBatteryCharging); + virtual enum loc_api_adapter_err + setAGLONASSProtocol(unsigned long aGlonassProtocol); + virtual enum loc_api_adapter_err + getWwanZppFix(GpsLocation & zppLoc); + virtual enum loc_api_adapter_err + getBestAvailableZppFix(GpsLocation & zppLoc); + virtual enum loc_api_adapter_err + getBestAvailableZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask); + virtual int initDataServiceClient(); + virtual int openAndStartDataCall(); + virtual void stopDataCall(); + virtual void closeDataCall(); + virtual void installAGpsCert(const DerEncodedCertificate* pData, + size_t length, + uint32_t slotBitMask); + inline virtual void setInSession(bool inSession) { + + (void)inSession; + } + inline bool isMessageSupported (LocCheckingMessagesID msgID) const { + + // confirm if msgID is not larger than the number of bits in + // mSupportedMsg + if ((uint64_t)msgID > (sizeof(mSupportedMsg) << 3)) { + return false; + } else { + uint32_t messageChecker = 1 << msgID; + return (messageChecker & mSupportedMsg) == messageChecker; + } + } + void updateEvtMask(); + + /*Values for lock + 1 = Do not lock any position sessions + 2 = Lock MI position sessions + 3 = Lock MT position sessions + 4 = Lock all position sessions + */ + virtual int setGpsLock(LOC_GPS_LOCK_MASK lock); + /* + Returns + Current value of GPS Lock on success + -1 on failure + */ + virtual int getGpsLock(void); + + virtual enum loc_api_adapter_err setXtraVersionCheck(enum xtra_version_check check); + + /* + Update gps reporting events + */ + virtual int updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event, + loc_registration_mask_status isEnabled); + /* + Check if the modem support the service + */ + virtual bool gnssConstellationConfig(); +}; + +typedef LocApiBase* (getLocApi_t)(const MsgTask* msgTask, + LOC_API_ADAPTER_EVENT_MASK_T exMask, + ContextBase *context); + +} // namespace loc_core + +#endif //LOC_API_BASE_H diff --git a/gps/core/LocDualContext.cpp b/gps/core/LocDualContext.cpp new file mode 100644 index 0000000..578421c --- /dev/null +++ b/gps/core/LocDualContext.cpp @@ -0,0 +1,147 @@ +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_DualCtx" + +#include +#include +#include +#include +#include +#include + +namespace loc_core { + +// nothing exclude for foreground +const LOC_API_ADAPTER_EVENT_MASK_T +LocDualContext::mFgExclMask = 0; +// excluded events for background clients +const LOC_API_ADAPTER_EVENT_MASK_T +LocDualContext::mBgExclMask = + (LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT | + LOC_API_ADAPTER_BIT_SATELLITE_REPORT | + LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT | + LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT | + LOC_API_ADAPTER_BIT_IOCTL_REPORT | + LOC_API_ADAPTER_BIT_STATUS_REPORT | + LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT | + LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT); + +const MsgTask* LocDualContext::mMsgTask = NULL; +ContextBase* LocDualContext::mFgContext = NULL; +ContextBase* LocDualContext::mBgContext = NULL; +ContextBase* LocDualContext::mInjectContext = NULL; +// the name must be shorter than 15 chars +const char* LocDualContext::mLocationHalName = "Loc_hal_worker"; +const char* LocDualContext::mLBSLibName = "liblbs_core.so"; + +pthread_mutex_t LocDualContext::mGetLocContextMutex = PTHREAD_MUTEX_INITIALIZER; + +const MsgTask* LocDualContext::getMsgTask(LocThread::tCreate tCreator, + const char* name, bool joinable) +{ + if (NULL == mMsgTask) { + mMsgTask = new MsgTask(tCreator, name, joinable); + } + return mMsgTask; +} + +inline +const MsgTask* LocDualContext::getMsgTask(const char* name, bool joinable) { + return getMsgTask((LocThread::tCreate)NULL, name, joinable); +} + +ContextBase* LocDualContext::getLocFgContext(LocThread::tCreate tCreator, + LocMsg* firstMsg, const char* name, bool joinable) +{ + pthread_mutex_lock(&LocDualContext::mGetLocContextMutex); + LOC_LOGD("%s:%d]: querying ContextBase with tCreator", __func__, __LINE__); + if (NULL == mFgContext) { + LOC_LOGD("%s:%d]: creating msgTask with tCreator", __func__, __LINE__); + const MsgTask* msgTask = getMsgTask(tCreator, name, joinable); + mFgContext = new LocDualContext(msgTask, + mFgExclMask); + } + if(NULL == mInjectContext) { + LOC_LOGD("%s:%d]: mInjectContext is FgContext", __func__, __LINE__); + mInjectContext = mFgContext; + injectFeatureConfig(mInjectContext); + } + pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex); + + if (firstMsg) { + mFgContext->sendMsg(firstMsg); + } + + return mFgContext; +} + +ContextBase* LocDualContext::getLocBgContext(LocThread::tCreate tCreator, + LocMsg* firstMsg, const char* name, bool joinable) +{ + pthread_mutex_lock(&LocDualContext::mGetLocContextMutex); + LOC_LOGD("%s:%d]: querying ContextBase with tCreator", __func__, __LINE__); + if (NULL == mBgContext) { + LOC_LOGD("%s:%d]: creating msgTask with tCreator", __func__, __LINE__); + const MsgTask* msgTask = getMsgTask(tCreator, name, joinable); + mBgContext = new LocDualContext(msgTask, + mBgExclMask); + } + if(NULL == mInjectContext) { + LOC_LOGD("%s:%d]: mInjectContext is BgContext", __func__, __LINE__); + mInjectContext = mBgContext; + injectFeatureConfig(mInjectContext); + } + pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex); + + if (firstMsg) { + mBgContext->sendMsg(firstMsg); + } + + return mBgContext; +} + +void LocDualContext :: injectFeatureConfig(ContextBase *curContext) +{ + LOC_LOGD("%s:%d]: Enter", __func__, __LINE__); + if(curContext == mInjectContext) { + LOC_LOGD("%s:%d]: Calling LBSProxy (%p) to inject feature config", + __func__, __LINE__, ((LocDualContext *)mInjectContext)->mLBSProxy); + ((LocDualContext *)mInjectContext)->mLBSProxy->injectFeatureConfig(curContext); + } + LOC_LOGD("%s:%d]: Exit", __func__, __LINE__); +} + +LocDualContext::LocDualContext(const MsgTask* msgTask, + LOC_API_ADAPTER_EVENT_MASK_T exMask) : + ContextBase(msgTask, exMask, mLBSLibName) +{ +} + +} diff --git a/gps/core/LocDualContext.h b/gps/core/LocDualContext.h new file mode 100644 index 0000000..ce77a1a --- /dev/null +++ b/gps/core/LocDualContext.h @@ -0,0 +1,76 @@ +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __LOC_ENG_CONTEXT__ +#define __LOC_ENG_CONTEXT__ + +#include +#include +#include +#include + +namespace loc_core { + +class LocDualContext : public ContextBase { + static const MsgTask* mMsgTask; + static ContextBase* mFgContext; + static ContextBase* mBgContext; + static ContextBase* mInjectContext; + static const MsgTask* getMsgTask(LocThread::tCreate tCreator, + const char* name, bool joinable = true); + static const MsgTask* getMsgTask(const char* name, bool joinable = true); + static pthread_mutex_t mGetLocContextMutex; + +protected: + LocDualContext(const MsgTask* msgTask, + LOC_API_ADAPTER_EVENT_MASK_T exMask); + inline virtual ~LocDualContext() {} + +public: + static const char* mLBSLibName; + static const LOC_API_ADAPTER_EVENT_MASK_T mFgExclMask; + static const LOC_API_ADAPTER_EVENT_MASK_T mBgExclMask; + static const char* mLocationHalName; + + static ContextBase* getLocFgContext(LocThread::tCreate tCreator, LocMsg* firstMsg, + const char* name, bool joinable = true); + inline static ContextBase* getLocFgContext(const char* name, bool joinable = true) { + return getLocFgContext(NULL, NULL, name, joinable); + } + static ContextBase* getLocBgContext(LocThread::tCreate tCreator, LocMsg* firstMsg, + const char* name, bool joinable = true); + inline static ContextBase* getLocBgContext(const char* name, bool joinable = true) { + return getLocBgContext(NULL, NULL, name, joinable); + } + + static void injectFeatureConfig(ContextBase *context); +}; + +} + +#endif //__LOC_ENG_CONTEXT__ diff --git a/gps/core/UlpProxyBase.h b/gps/core/UlpProxyBase.h new file mode 100644 index 0000000..359822b --- /dev/null +++ b/gps/core/UlpProxyBase.h @@ -0,0 +1,105 @@ +/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef ULP_PROXY_BASE_H +#define ULP_PROXY_BASE_H + +#include +#include "fused_location_extended.h" + +namespace loc_core { + +class LocAdapterBase; + +class UlpProxyBase { +public: + LocPosMode mPosMode; + bool mFixSet; + inline UlpProxyBase() { + mPosMode.mode = LOC_POSITION_MODE_INVALID; + mFixSet = false; + } + inline virtual ~UlpProxyBase() {} + inline virtual bool sendStartFix() { mFixSet = true; return false; } + inline virtual bool sendStopFix() { mFixSet = false; return false; } + inline virtual bool sendFixMode(LocPosMode ¶ms) { + mPosMode = params; + return false; + } + + inline virtual bool reportPosition(UlpLocation &location, + GpsLocationExtended &locationExtended, + void* locationExt, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask) { + (void)location; + (void)locationExtended; + (void)locationExt; + (void)status; + (void)loc_technology_mask; + return false; + } + inline virtual bool reportSv(QcomSvStatus &svStatus, + GpsLocationExtended &locationExtended, + void* svExt) { + (void)svStatus; + (void)locationExtended; + (void)svExt; + return false; + } + inline virtual bool reportStatus(GpsStatusValue status) { + + (void)status; + return false; + } + inline virtual void setAdapter(LocAdapterBase* adapter) { + + (void)adapter; + } + inline virtual void setCapabilities(unsigned long capabilities) { + + (void)capabilities; + } + inline virtual bool reportBatchingSession(FlpExtBatchOptions &options, + bool active) { + + (void)options; + (void)active; + return false; + } + inline virtual bool reportPositions(const FlpExtLocation* locations, + int32_t number_of_locations) { + (void)locations; + (void)number_of_locations; + return false; + } +}; + +} // namespace loc_core + +#endif // ULP_PROXY_BASE_H diff --git a/gps/core/fused_location_extended.h b/gps/core/fused_location_extended.h new file mode 100644 index 0000000..f65150a --- /dev/null +++ b/gps/core/fused_location_extended.h @@ -0,0 +1,86 @@ +/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef FUSED_LOCATION_EXTENDED_H +#define FUSED_LOCATION_EXTENDED_H + +/** Batching default ID for dummy batching session*/ +#define GPS_BATCHING_DEFAULT_ID 1 + +/** This cap is used to decide the FLP session cache +size on AP. If the BATCH_SIZE in flp.conf is less than +GPS_AP_BATCHING_SIZE_CAP, FLP session cache size will +be twice the BATCH_SIZE defined in flp.conf. Otherwise, +FLP session cache size will be equal to the BATCH_SIZE.*/ +#define GPS_AP_BATCHING_SIZE_CAP 40 + +#define GPS_BATCHING_OPERATION_SUCCEESS 1 +#define GPS_BATCHING_OPERATION_FAILURE 0 + +/** GPS extended batching flags*/ +#define GPS_EXT_BATCHING_ON_FULL 0x0000001 +#define GPS_EXT_BATCHING_ON_FIX 0x000000 + +typedef struct { + double max_power_allocation_mW; + uint32_t sources_to_use; + uint32_t flags; + int64_t period_ns; +} FlpExtBatchOptions; + +/** GpsLocationExtended has valid latitude and longitude. */ +#define GPS_LOCATION_EXTENDED_HAS_LAT_LONG (1U<<0) +/** GpsLocationExtended has valid altitude. */ +#define GPS_LOCATION_EXTENDED_HAS_ALTITUDE (1U<<1) +/** GpsLocationExtended has valid speed. */ +#define GPS_LOCATION_EXTENDED_HAS_SPEED (1U<<2) +/** GpsLocationExtended has valid bearing. */ +#define GPS_LOCATION_EXTENDED_HAS_BEARING (1U<<4) +/** GpsLocationExtended has valid accuracy. */ +#define GPS_LOCATION_EXTENDED_HAS_ACCURACY (1U<<8) + +/** GPS extended supports geofencing */ +#define GPS_EXTENDED_CAPABILITY_GEOFENCE 0x0000001 +/** GPS extended supports batching */ +#define GPS_EXTENDED_CAPABILITY_BATCHING 0x0000002 + +typedef struct FlpExtLocation_s { + size_t size; + uint16_t flags; + double latitude; + double longitude; + double altitude; + float speed; + float bearing; + float accuracy; + int64_t timestamp; + uint32_t sources_used; +} FlpExtLocation; + +#endif /* FUSED_LOCATION_EXTENDED_H */ diff --git a/gps/core/gps_extended.h b/gps/core/gps_extended.h new file mode 100644 index 0000000..88b0415 --- /dev/null +++ b/gps/core/gps_extended.h @@ -0,0 +1,92 @@ +/* Copyright (c) 2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef GPS_EXTENDED_H +#define GPS_EXTENDED_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include + +struct LocPosMode +{ + LocPositionMode mode; + GpsPositionRecurrence recurrence; + uint32_t min_interval; + uint32_t preferred_accuracy; + uint32_t preferred_time; + char credentials[14]; + char provider[8]; + LocPosMode(LocPositionMode m, GpsPositionRecurrence recr, + uint32_t gap, uint32_t accu, uint32_t time, + const char* cred, const char* prov) : + mode(m), recurrence(recr), + min_interval(gap < MIN_POSSIBLE_FIX_INTERVAL ? MIN_POSSIBLE_FIX_INTERVAL : gap), + preferred_accuracy(accu), preferred_time(time) { + memset(credentials, 0, sizeof(credentials)); + memset(provider, 0, sizeof(provider)); + if (NULL != cred) { + memcpy(credentials, cred, sizeof(credentials)-1); + } + if (NULL != prov) { + memcpy(provider, prov, sizeof(provider)-1); + } + } + + inline LocPosMode() : + mode(LOC_POSITION_MODE_MS_BASED), + recurrence(GPS_POSITION_RECURRENCE_PERIODIC), + min_interval(MIN_POSSIBLE_FIX_INTERVAL), + preferred_accuracy(50), preferred_time(120000) { + memset(credentials, 0, sizeof(credentials)); + memset(provider, 0, sizeof(provider)); + } + + inline bool equals(const LocPosMode &anotherMode) const + { + return anotherMode.mode == mode && + anotherMode.recurrence == recurrence && + anotherMode.min_interval == min_interval && + anotherMode.preferred_accuracy == preferred_accuracy && + anotherMode.preferred_time == preferred_time && + !strncmp(anotherMode.credentials, credentials, sizeof(credentials)-1) && + !strncmp(anotherMode.provider, provider, sizeof(provider)-1); + } + + void logv() const; +}; + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* GPS_EXTENDED_H */ + diff --git a/gps/core/gps_extended_c.h b/gps/core/gps_extended_c.h new file mode 100644 index 0000000..ee26da5 --- /dev/null +++ b/gps/core/gps_extended_c.h @@ -0,0 +1,436 @@ +/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef GPS_EXTENDED_C_H +#define GPS_EXTENDED_C_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include +#include +#include +#include + +/** Location has valid source information. */ +#define LOCATION_HAS_SOURCE_INFO 0x0020 +/** GpsLocation has valid "is indoor?" flag */ +#define GPS_LOCATION_HAS_IS_INDOOR 0x0040 +/** GpsLocation has valid floor number */ +#define GPS_LOCATION_HAS_FLOOR_NUMBER 0x0080 +/** GpsLocation has valid map URL*/ +#define GPS_LOCATION_HAS_MAP_URL 0x0100 +/** GpsLocation has valid map index */ +#define GPS_LOCATION_HAS_MAP_INDEX 0x0200 + +/** Sizes for indoor fields */ +#define GPS_LOCATION_MAP_URL_SIZE 400 +#define GPS_LOCATION_MAP_INDEX_SIZE 16 + +/** Position source is ULP */ +#define ULP_LOCATION_IS_FROM_HYBRID 0x0001 +/** Position source is GNSS only */ +#define ULP_LOCATION_IS_FROM_GNSS 0x0002 +/** Position source is ZPP only */ +#define ULP_LOCATION_IS_FROM_ZPP 0x0004 +/** Position is from a Geofence Breach Event */ +#define ULP_LOCATION_IS_FROM_GEOFENCE 0X0008 +/** Position is from Hardware FLP */ +#define ULP_LOCATION_IS_FROM_HW_FLP 0x0010 +/** Position is from NLP */ +#define ULP_LOCATION_IS_FROM_NLP 0x0020 +/** Position is from PIP */ +#define ULP_LOCATION_IS_FROM_PIP 0x0040 + +#define ULP_MIN_INTERVAL_INVALID 0xffffffff + +/*Emergency SUPL*/ +#define GPS_NI_TYPE_EMERGENCY_SUPL 4 + +#define AGPS_CERTIFICATE_MAX_LENGTH 2000 +#define AGPS_CERTIFICATE_MAX_SLOTS 10 + +enum loc_registration_mask_status { + LOC_REGISTRATION_MASK_ENABLED, + LOC_REGISTRATION_MASK_DISABLED +}; + +typedef struct { + /** set to sizeof(UlpLocation) */ + size_t size; + GpsLocation gpsLocation; + /* Provider indicator for HYBRID or GPS */ + uint16_t position_source; + /*allows HAL to pass additional information related to the location */ + int rawDataSize; /* in # of bytes */ + void * rawData; + bool is_indoor; + float floor_number; + char map_url[GPS_LOCATION_MAP_URL_SIZE]; + unsigned char map_index[GPS_LOCATION_MAP_INDEX_SIZE]; +} UlpLocation; + +/** AGPS type */ +typedef int16_t AGpsExtType; +#define AGPS_TYPE_INVALID -1 +#define AGPS_TYPE_ANY 0 +#define AGPS_TYPE_SUPL 1 +#define AGPS_TYPE_C2K 2 +#define AGPS_TYPE_WWAN_ANY 3 +#define AGPS_TYPE_WIFI 4 +#define AGPS_TYPE_SUPL_ES 5 + +/** SSID length */ +#define SSID_BUF_SIZE (32+1) + +typedef int16_t AGpsBearerType; +#define AGPS_APN_BEARER_INVALID -1 +#define AGPS_APN_BEARER_IPV4 0 +#define AGPS_APN_BEARER_IPV6 1 +#define AGPS_APN_BEARER_IPV4V6 2 + +/** GPS extended callback structure. */ +typedef struct { + /** set to sizeof(GpsCallbacks) */ + size_t size; + gps_set_capabilities set_capabilities_cb; + gps_acquire_wakelock acquire_wakelock_cb; + gps_release_wakelock release_wakelock_cb; + gps_create_thread create_thread_cb; + gps_request_utc_time request_utc_time_cb; +} GpsExtCallbacks; + +/** Callback to report the xtra server url to the client. + * The client should use this url when downloading xtra unless overwritten + * in the gps.conf file + */ +typedef void (* report_xtra_server)(const char*, const char*, const char*); + +/** Callback structure for the XTRA interface. */ +typedef struct { + gps_xtra_download_request download_request_cb; + gps_create_thread create_thread_cb; + report_xtra_server report_xtra_server_cb; +} GpsXtraExtCallbacks; + +/** Represents the status of AGPS. */ +typedef struct { + /** set to sizeof(AGpsExtStatus) */ + size_t size; + + AGpsExtType type; + AGpsStatusValue status; + uint32_t ipv4_addr; + struct sockaddr_storage addr; + char ssid[SSID_BUF_SIZE]; + char password[SSID_BUF_SIZE]; +} AGpsExtStatus; + +/** Callback with AGPS status information. + * Can only be called from a thread created by create_thread_cb. + */ +typedef void (* agps_status_extended)(AGpsExtStatus* status); + +/** Callback structure for the AGPS interface. */ +typedef struct { + agps_status_extended status_cb; + gps_create_thread create_thread_cb; +} AGpsExtCallbacks; + + +/** GPS NI callback structure. */ +typedef struct +{ + /** + * Sends the notification request from HAL to GPSLocationProvider. + */ + gps_ni_notify_callback notify_cb; + gps_create_thread create_thread_cb; +} GpsNiExtCallbacks; + +typedef enum loc_server_type { + LOC_AGPS_CDMA_PDE_SERVER, + LOC_AGPS_CUSTOM_PDE_SERVER, + LOC_AGPS_MPC_SERVER, + LOC_AGPS_SUPL_SERVER +} LocServerType; + +typedef enum loc_position_mode_type { + LOC_POSITION_MODE_INVALID = -1, + LOC_POSITION_MODE_STANDALONE = 0, + LOC_POSITION_MODE_MS_BASED, + LOC_POSITION_MODE_MS_ASSISTED, + LOC_POSITION_MODE_RESERVED_1, + LOC_POSITION_MODE_RESERVED_2, + LOC_POSITION_MODE_RESERVED_3, + LOC_POSITION_MODE_RESERVED_4, + LOC_POSITION_MODE_RESERVED_5 + +} LocPositionMode; + +#define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */ + +/** Flags to indicate which values are valid in a GpsLocationExtended. */ +typedef uint16_t GpsLocationExtendedFlags; +/** GpsLocationExtended has valid pdop, hdop, vdop. */ +#define GPS_LOCATION_EXTENDED_HAS_DOP 0x0001 +/** GpsLocationExtended has valid altitude mean sea level. */ +#define GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL 0x0002 +/** UlpLocation has valid magnetic deviation. */ +#define GPS_LOCATION_EXTENDED_HAS_MAG_DEV 0x0004 +/** UlpLocation has valid mode indicator. */ +#define GPS_LOCATION_EXTENDED_HAS_MODE_IND 0x0008 +/** GpsLocationExtended has valid vertical uncertainty */ +#define GPS_LOCATION_EXTENDED_HAS_VERT_UNC 0x0010 +/** GpsLocationExtended has valid speed uncertainty */ +#define GPS_LOCATION_EXTENDED_HAS_SPEED_UNC 0x0020 +/** GpsLocationExtended has valid heading uncertainty */ +#define GPS_LOCATION_EXTENDED_HAS_BEARING_UNC 0x0040 +/** GpsLocationExtended has valid horizontal reliability */ +#define GPS_LOCATION_EXTENDED_HAS_HOR_RELIABILITY 0x0080 +/** GpsLocationExtended has valid vertical reliability */ +#define GPS_LOCATION_EXTENDED_HAS_VERT_RELIABILITY 0x0100 + +typedef enum { + LOC_RELIABILITY_NOT_SET = 0, + LOC_RELIABILITY_VERY_LOW = 1, + LOC_RELIABILITY_LOW = 2, + LOC_RELIABILITY_MEDIUM = 3, + LOC_RELIABILITY_HIGH = 4 +}LocReliability; + +/** Represents gps location extended. */ +typedef struct { + /** set to sizeof(GpsLocationExtended) */ + size_t size; + /** Contains GpsLocationExtendedFlags bits. */ + uint16_t flags; + /** Contains the Altitude wrt mean sea level */ + float altitudeMeanSeaLevel; + /** Contains Position Dilusion of Precision. */ + float pdop; + /** Contains Horizontal Dilusion of Precision. */ + float hdop; + /** Contains Vertical Dilusion of Precision. */ + float vdop; + /** Contains Magnetic Deviation. */ + float magneticDeviation; + /** vertical uncertainty in meters */ + float vert_unc; + /** speed uncertainty in m/s */ + float speed_unc; + /** heading uncertainty in degrees (0 to 359.999) */ + float bearing_unc; + /** horizontal reliability. */ + LocReliability horizontal_reliability; + /** vertical reliability. */ + LocReliability vertical_reliability; +} GpsLocationExtended; + +/** Represents SV status. */ +typedef struct { + /** set to sizeof(QcomSvStatus) */ + size_t size; + + /** Number of SVs currently visible. */ + int num_svs; + + /** Contains an array of SV information. */ + GpsSvInfo sv_list[GPS_MAX_SVS]; + + /** Represents a bit mask indicating which SVs + * have ephemeris data. + */ + uint32_t ephemeris_mask; + + /** Represents a bit mask indicating which SVs + * have almanac data. + */ + uint32_t almanac_mask; + + /** + * Represents a bit mask indicating which GPS SVs + * were used for computing the most recent position fix. + */ + uint32_t gps_used_in_fix_mask; + + /** + * Represents a bit mask indicating which GLONASS SVs + * were used for computing the most recent position fix. + */ + uint32_t glo_used_in_fix_mask; + + /** + * Represents a bit mask indicating which BDS SVs + * were used for computing the most recent position fix. + */ + uint64_t bds_used_in_fix_mask; + +} QcomSvStatus; + +enum loc_sess_status { + LOC_SESS_SUCCESS, + LOC_SESS_INTERMEDIATE, + LOC_SESS_FAILURE +}; + +typedef uint32_t LocPosTechMask; +#define LOC_POS_TECH_MASK_DEFAULT ((LocPosTechMask)0x00000000) +#define LOC_POS_TECH_MASK_SATELLITE ((LocPosTechMask)0x00000001) +#define LOC_POS_TECH_MASK_CELLID ((LocPosTechMask)0x00000002) +#define LOC_POS_TECH_MASK_WIFI ((LocPosTechMask)0x00000004) +#define LOC_POS_TECH_MASK_SENSORS ((LocPosTechMask)0x00000008) +#define LOC_POS_TECH_MASK_REFERENCE_LOCATION ((LocPosTechMask)0x00000010) +#define LOC_POS_TECH_MASK_INJECTED_COARSE_POSITION ((LocPosTechMask)0x00000020) +#define LOC_POS_TECH_MASK_AFLT ((LocPosTechMask)0x00000040) +#define LOC_POS_TECH_MASK_HYBRID ((LocPosTechMask)0x00000080) + +typedef enum { + LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0, + LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM, + LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU, + LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, + LOC_ENG_IF_REQUEST_SENDER_ID_MODEM, + LOC_ENG_IF_REQUEST_SENDER_ID_UNKNOWN +} loc_if_req_sender_id_e_type; + + +#define smaller_of(a, b) (((a) > (b)) ? (b) : (a)) +#define MAX_APN_LEN 100 + +// This will be overridden by the individual adapters +// if necessary. +#define DEFAULT_IMPL(rtv) \ +{ \ + LOC_LOGD("%s: default implementation invoked", __func__); \ + return rtv; \ +} + +enum loc_api_adapter_err { + LOC_API_ADAPTER_ERR_SUCCESS = 0, + LOC_API_ADAPTER_ERR_GENERAL_FAILURE = 1, + LOC_API_ADAPTER_ERR_UNSUPPORTED = 2, + LOC_API_ADAPTER_ERR_INVALID_HANDLE = 4, + LOC_API_ADAPTER_ERR_INVALID_PARAMETER = 5, + LOC_API_ADAPTER_ERR_ENGINE_BUSY = 6, + LOC_API_ADAPTER_ERR_PHONE_OFFLINE = 7, + LOC_API_ADAPTER_ERR_TIMEOUT = 8, + LOC_API_ADAPTER_ERR_SERVICE_NOT_PRESENT = 9, + LOC_API_ADAPTER_ERR_INTERNAL = 10, + + /* equating engine down to phone offline, as they are the same errror */ + LOC_API_ADAPTER_ERR_ENGINE_DOWN = LOC_API_ADAPTER_ERR_PHONE_OFFLINE, + LOC_API_ADAPTER_ERR_FAILURE = 101, + LOC_API_ADAPTER_ERR_UNKNOWN +}; + +enum loc_api_adapter_event_index { + LOC_API_ADAPTER_REPORT_POSITION = 0, // Position report comes in loc_parsed_position_s_type + LOC_API_ADAPTER_REPORT_SATELLITE, // Satellite in view report + LOC_API_ADAPTER_REPORT_NMEA_1HZ, // NMEA report at 1HZ rate + LOC_API_ADAPTER_REPORT_NMEA_POSITION, // NMEA report at position report rate + LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY, // NI notification/verification request + LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA, // Assistance data, eg: time, predicted orbits request + LOC_API_ADAPTER_REQUEST_LOCATION_SERVER, // Request for location server + LOC_API_ADAPTER_REPORT_IOCTL, // Callback report for loc_ioctl + LOC_API_ADAPTER_REPORT_STATUS, // Misc status report: eg, engine state + LOC_API_ADAPTER_REQUEST_WIFI, // + LOC_API_ADAPTER_SENSOR_STATUS, // + LOC_API_ADAPTER_REQUEST_TIME_SYNC, // + LOC_API_ADAPTER_REPORT_SPI, // + LOC_API_ADAPTER_REPORT_NI_GEOFENCE, // + LOC_API_ADAPTER_GEOFENCE_GEN_ALERT, // + LOC_API_ADAPTER_REPORT_GENFENCE_BREACH, // + LOC_API_ADAPTER_PEDOMETER_CTRL, // + LOC_API_ADAPTER_MOTION_CTRL, // + LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA, // Wifi ap data + LOC_API_ADAPTER_BATCH_FULL, // Batching on full + LOC_API_ADAPTER_BATCHED_POSITION_REPORT, // Batching on fix + LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT, // + LOC_API_ADAPTER_GDT_UPLOAD_BEGIN_REQ, // GDT upload start request + LOC_API_ADAPTER_GDT_UPLOAD_END_REQ, // GDT upload end request + LOC_API_ADAPTER_GNSS_MEASUREMENT, // GNSS Measurement report + LOC_API_ADAPTER_REQUEST_TIMEZONE, // Timezone injection request + LOC_API_ADAPTER_EVENT_MAX +}; + +#define LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT (1< +#include +#include + +void LocPosMode::logv() const +{ + LOC_LOGV ("Position mode: %s\n Position recurrence: %s\n " + "min interval: %d\n preferred accuracy: %d\n " + "preferred time: %d\n credentials: %s provider: %s", + loc_get_position_mode_name(mode), + loc_get_position_recurrence_name(recurrence), + min_interval, + preferred_accuracy, + preferred_time, + credentials, + provider); +} + +/* GPS status names */ +static loc_name_val_s_type gps_status_name[] = +{ + NAME_VAL( GPS_STATUS_NONE ), + NAME_VAL( GPS_STATUS_SESSION_BEGIN ), + NAME_VAL( GPS_STATUS_SESSION_END ), + NAME_VAL( GPS_STATUS_ENGINE_ON ), + NAME_VAL( GPS_STATUS_ENGINE_OFF ), +}; +static int gps_status_num = sizeof(gps_status_name) / sizeof(loc_name_val_s_type); + +/* Find Android GPS status name */ +const char* loc_get_gps_status_name(GpsStatusValue gps_status) +{ + return loc_get_name_from_val(gps_status_name, gps_status_num, + (long) gps_status); +} + + + +static loc_name_val_s_type loc_eng_position_modes[] = +{ + NAME_VAL( LOC_POSITION_MODE_STANDALONE ), + NAME_VAL( LOC_POSITION_MODE_MS_BASED ), + NAME_VAL( LOC_POSITION_MODE_MS_ASSISTED ), + NAME_VAL( LOC_POSITION_MODE_RESERVED_1 ), + NAME_VAL( LOC_POSITION_MODE_RESERVED_2 ), + NAME_VAL( LOC_POSITION_MODE_RESERVED_3 ), + NAME_VAL( LOC_POSITION_MODE_RESERVED_4 ), + NAME_VAL( LOC_POSITION_MODE_RESERVED_5 ) +}; +static int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type); + +const char* loc_get_position_mode_name(GpsPositionMode mode) +{ + return loc_get_name_from_val(loc_eng_position_modes, loc_eng_position_mode_num, (long) mode); +} + + + +static loc_name_val_s_type loc_eng_position_recurrences[] = +{ + NAME_VAL( GPS_POSITION_RECURRENCE_PERIODIC ), + NAME_VAL( GPS_POSITION_RECURRENCE_SINGLE ) +}; +static int loc_eng_position_recurrence_num = sizeof(loc_eng_position_recurrences) / sizeof(loc_name_val_s_type); + +const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur) +{ + return loc_get_name_from_val(loc_eng_position_recurrences, loc_eng_position_recurrence_num, (long) recur); +} + + + +static loc_name_val_s_type loc_eng_aiding_data_bits[] = +{ + NAME_VAL( GPS_DELETE_EPHEMERIS ), + NAME_VAL( GPS_DELETE_ALMANAC ), + NAME_VAL( GPS_DELETE_POSITION ), + NAME_VAL( GPS_DELETE_TIME ), + NAME_VAL( GPS_DELETE_IONO ), + NAME_VAL( GPS_DELETE_UTC ), + NAME_VAL( GPS_DELETE_HEALTH ), + NAME_VAL( GPS_DELETE_SVDIR ), + NAME_VAL( GPS_DELETE_SVSTEER ), + NAME_VAL( GPS_DELETE_SADATA ), + NAME_VAL( GPS_DELETE_RTI ), + NAME_VAL( GPS_DELETE_CELLDB_INFO ), + NAME_VAL( GPS_DELETE_ALL) +}; +static int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type); + +const char* loc_get_aiding_data_mask_names(GpsAidingData data) +{ + return NULL; +} + + +static loc_name_val_s_type loc_eng_agps_types[] = +{ + NAME_VAL( AGPS_TYPE_INVALID ), + NAME_VAL( AGPS_TYPE_ANY ), + NAME_VAL( AGPS_TYPE_SUPL ), + NAME_VAL( AGPS_TYPE_C2K ), + NAME_VAL( AGPS_TYPE_WWAN_ANY ) +}; +static int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type); + +const char* loc_get_agps_type_name(AGpsType type) +{ + return loc_get_name_from_val(loc_eng_agps_types, loc_eng_agps_type_num, (long) type); +} + + +static loc_name_val_s_type loc_eng_ni_types[] = +{ + NAME_VAL( GPS_NI_TYPE_VOICE ), + NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ), + NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE ), + NAME_VAL( GPS_NI_TYPE_EMERGENCY_SUPL ) +}; +static int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type); + +const char* loc_get_ni_type_name(GpsNiType type) +{ + return loc_get_name_from_val(loc_eng_ni_types, loc_eng_ni_type_num, (long) type); +} + + +static loc_name_val_s_type loc_eng_ni_responses[] = +{ + NAME_VAL( GPS_NI_RESPONSE_ACCEPT ), + NAME_VAL( GPS_NI_RESPONSE_DENY ), + NAME_VAL( GPS_NI_RESPONSE_DENY ) +}; +static int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type); + +const char* loc_get_ni_response_name(GpsUserResponseType response) +{ + return loc_get_name_from_val(loc_eng_ni_responses, loc_eng_ni_reponse_num, (long) response); +} + + +static loc_name_val_s_type loc_eng_ni_encodings[] = +{ + NAME_VAL( GPS_ENC_NONE ), + NAME_VAL( GPS_ENC_SUPL_GSM_DEFAULT ), + NAME_VAL( GPS_ENC_SUPL_UTF8 ), + NAME_VAL( GPS_ENC_SUPL_UCS2 ), + NAME_VAL( GPS_ENC_UNKNOWN ) +}; +static int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type); + +const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding) +{ + return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding); +} + +static loc_name_val_s_type loc_eng_agps_bears[] = +{ + NAME_VAL( AGPS_APN_BEARER_INVALID ), + NAME_VAL( AGPS_APN_BEARER_IPV4 ), + NAME_VAL( AGPS_APN_BEARER_IPV6 ), + NAME_VAL( AGPS_APN_BEARER_IPV4V6 ) +}; +static int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type); + +const char* loc_get_agps_bear_name(AGpsBearerType bearer) +{ + return loc_get_name_from_val(loc_eng_agps_bears, loc_eng_agps_bears_num, (long) bearer); +} + +static loc_name_val_s_type loc_eng_server_types[] = +{ + NAME_VAL( LOC_AGPS_CDMA_PDE_SERVER ), + NAME_VAL( LOC_AGPS_CUSTOM_PDE_SERVER ), + NAME_VAL( LOC_AGPS_MPC_SERVER ), + NAME_VAL( LOC_AGPS_SUPL_SERVER ) +}; +static int loc_eng_server_types_num = sizeof(loc_eng_server_types) / sizeof(loc_name_val_s_type); + +const char* loc_get_server_type_name(LocServerType type) +{ + return loc_get_name_from_val(loc_eng_server_types, loc_eng_server_types_num, (long) type); +} + +static loc_name_val_s_type loc_eng_position_sess_status_types[] = +{ + NAME_VAL( LOC_SESS_SUCCESS ), + NAME_VAL( LOC_SESS_INTERMEDIATE ), + NAME_VAL( LOC_SESS_FAILURE ) +}; +static int loc_eng_position_sess_status_num = sizeof(loc_eng_position_sess_status_types) / sizeof(loc_name_val_s_type); + +const char* loc_get_position_sess_status_name(enum loc_sess_status status) +{ + return loc_get_name_from_val(loc_eng_position_sess_status_types, loc_eng_position_sess_status_num, (long) status); +} + +static loc_name_val_s_type loc_eng_agps_status_names[] = +{ + NAME_VAL( GPS_REQUEST_AGPS_DATA_CONN ), + NAME_VAL( GPS_RELEASE_AGPS_DATA_CONN ), + NAME_VAL( GPS_AGPS_DATA_CONNECTED ), + NAME_VAL( GPS_AGPS_DATA_CONN_DONE ), + NAME_VAL( GPS_AGPS_DATA_CONN_FAILED ) +}; +static int loc_eng_agps_status_num = sizeof(loc_eng_agps_status_names) / sizeof(loc_name_val_s_type); + +const char* loc_get_agps_status_name(AGpsStatusValue status) +{ + return loc_get_name_from_val(loc_eng_agps_status_names, loc_eng_agps_status_num, (long) status); +} diff --git a/gps/core/loc_core_log.h b/gps/core/loc_core_log.h new file mode 100644 index 0000000..8a1825a --- /dev/null +++ b/gps/core/loc_core_log.h @@ -0,0 +1,58 @@ +/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef LOC_CORE_LOG_H +#define LOC_CORE_LOG_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +const char* loc_get_gps_status_name(GpsStatusValue gps_status); +const char* loc_get_position_mode_name(GpsPositionMode mode); +const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur); +const char* loc_get_aiding_data_mask_names(GpsAidingData data); +const char* loc_get_agps_type_name(AGpsType type); +const char* loc_get_ni_type_name(GpsNiType type); +const char* loc_get_ni_response_name(GpsUserResponseType response); +const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding); +const char* loc_get_agps_bear_name(AGpsBearerType bear); +const char* loc_get_server_type_name(LocServerType type); +const char* loc_get_position_sess_status_name(enum loc_sess_status status); +const char* loc_get_agps_status_name(AGpsStatusValue status); + +#ifdef __cplusplus +} +#endif + +#endif /* LOC_CORE_LOG_H */ diff --git a/gps/etc/Android.mk b/gps/etc/Android.mk new file mode 100644 index 0000000..5b00dda --- /dev/null +++ b/gps/etc/Android.mk @@ -0,0 +1,33 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_MODULE := flp.conf +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/ +LOCAL_SRC_FILES := flp.conf +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := gps.conf +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/ +LOCAL_SRC_FILES := gps.conf +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := izat.conf +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/ +LOCAL_SRC_FILES := izat.conf +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := sap.conf +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/ +LOCAL_SRC_FILES := sap.conf +include $(BUILD_PREBUILT) \ No newline at end of file diff --git a/gps/flp.conf b/gps/etc/flp.conf similarity index 98% rename from gps/flp.conf rename to gps/etc/flp.conf index ba237c9..7d6002f 100644 --- a/gps/flp.conf +++ b/gps/etc/flp.conf @@ -12,7 +12,7 @@ # of batched locations that can be allocated, # which is limited by memory. The default # batch size defined as 20 as below. -BATCH_SIZE=40 +BATCH_SIZE=20 ################################### # FLP BATCHING SESSION TIMEOUT @@ -29,7 +29,7 @@ BATCH_SIZE=40 # GEOFENCE = 0x01 # BATCHING = 0x02 # default = GEOFENCE | BATCHING -CAPABILITIES=0x01 +CAPABILITIES=0x03 ################################### # FLP BATCHING ACCURACY diff --git a/gps/gps.conf b/gps/etc/gps.conf similarity index 80% rename from gps/gps.conf rename to gps/etc/gps.conf index 88a4323..2ee366f 100644 --- a/gps/gps.conf +++ b/gps/etc/gps.conf @@ -1,15 +1,14 @@ -#Uncommenting these urls would only enable -#the power up auto injection and force injection(test case). -XTRA_SERVER_1=https://xtrapath4.izatcloud.net/xtra3grc.bin -XTRA_SERVER_2=https://xtrapath5.izatcloud.net/xtra3grc.bin -XTRA_SERVER_3=https://xtrapath6.izatcloud.net/xtra3grc.bin +#URLs from which to download XTRA data +XTRA_SERVER_1=https://xtrapath1.izatcloud.net/xtra3grc.bin +XTRA_SERVER_2=https://xtrapath2.izatcloud.net/xtra3grc.bin +XTRA_SERVER_3=https://xtrapath3.izatcloud.net/xtra3grc.bin #Version check for XTRA #DISABLE = 0 #AUTO = 1 #XTRA2 = 2 #XTRA3 = 3 -XTRA_VERSION_CHECK=0 +XTRA_VERSION_CHECK=1 # Error Estimate # _SET = 1 @@ -38,13 +37,13 @@ INTERMEDIATE_POS=0 # Set bit 0x1 if MO GPS functionalities are to be locked # Set bit 0x2 if NI GPS functionalities are to be locked # default - non is locked for backward compatibility -GPS_LOCK = 3 +#GPS_LOCK = 0 -# supl version 2.0 -SUPL_VER=0x20000 +# supl version 1.0 +SUPL_VER=0x10000 # Emergency SUPL, 1=enable, 0=disable -SUPL_ES=0 +SUPL_ES=1 #Choose PDN for Emergency SUPL #1 - Use emergency PDN @@ -65,7 +64,7 @@ USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL=1 # ON_DEMAND_TIME = 0x10 # GEOFENCE = 0x20 # default = ON_DEMAND_TIME | MSA | MSB | SCHEDULING | GEOFENCE -CAPABILITIES=0x13 +CAPABILITIES=0x31 # Accuracy threshold for intermediate positions # less accurate positions are ignored, 0 for passing all positions @@ -76,8 +75,8 @@ CAPABILITIES=0x13 ################################ # FOR SUPL SUPPORT, set the following -SUPL_HOST=supl.sonyericsson.com -SUPL_PORT=7275 +# SUPL_HOST=supl.host.com or IP +# SUPL_PORT=1234 # FOR C2K PDE SUPPORT, set the following # C2K_HOST=c2k.pde.com or IP @@ -114,12 +113,8 @@ SGLTE_TARGET=0 # 0x1: RRC CPlane # 0x2: RRLP UPlane # 0x4: LLP Uplane -A_GLONASS_POS_PROTOCOL_SELECT = 0x2 - -########################################### -# Enable/Disable reading H-SLP address and -# certificates from the SIM card -########################################### -# 0: Disable (Default) -# 1: Enable -ENABLE_READ_FROM_SIM = 0 +#ifndef zuoyonghua@oneplus.cn enable all bit mask for GLONASS +#A_GLONASS_POS_PROTOCOL_SELECT = 0 +#else +A_GLONASS_POS_PROTOCOL_SELECT = 15 +#endif diff --git a/gps/izat.conf b/gps/etc/izat.conf similarity index 99% rename from gps/izat.conf rename to gps/etc/izat.conf index c7f411c..827fe3d 100644 --- a/gps/izat.conf +++ b/gps/etc/izat.conf @@ -193,4 +193,4 @@ PREMIUM_FEATURE=1 IZAT_FEATURE_MASK=0xf0 PLATFORMS=all BASEBAND=all -LEAN_TARGETS=DISABLED +LEAN_TARGETS=DISABLED \ No newline at end of file diff --git a/gps/sap.conf b/gps/etc/sap.conf similarity index 99% rename from gps/sap.conf rename to gps/etc/sap.conf index 35426da..eede024 100644 --- a/gps/sap.conf +++ b/gps/etc/sap.conf @@ -31,7 +31,7 @@ SENSOR_CONTROL_MODE=0 # Enable or Disable Sensors for GPS use (0=Enable, 1=Disable) # used in loc_eng_reinit -SENSOR_USAGE=1 +SENSOR_USAGE=0 # Choose GSIFF sensor provider (1=Snapdragon Sensors Core, 2=Android NDK) SENSOR_PROVIDER=1 @@ -50,4 +50,3 @@ SENSOR_ALGORITHM_CONFIG_MASK=0x1 # 3 - CLOCK_REALTIME # 4 - CLOCK_BOOTTIME using Alarm timer interface NDK_PROVIDER_TIME_SOURCE=1 - diff --git a/gps/loc_api/Android.mk b/gps/loc_api/Android.mk new file mode 100644 index 0000000..8359a30 --- /dev/null +++ b/gps/loc_api/Android.mk @@ -0,0 +1,17 @@ +# +# Copyright (C) 2015 The CyanogenMod Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include $(call all-subdir-makefiles) diff --git a/gps/loc_api/libloc_api_50001/Android.mk b/gps/loc_api/libloc_api_50001/Android.mk new file mode 100644 index 0000000..03bd12a --- /dev/null +++ b/gps/loc_api/libloc_api_50001/Android.mk @@ -0,0 +1,92 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := libloc_eng +LOCAL_MODULE_OWNER := qcom +LOCAL_VENDOR_MODULE := true + +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := \ + libutils \ + libcutils \ + libdl \ + liblog \ + libloc_core \ + libgps.utils + +LOCAL_SRC_FILES += \ + loc_eng.cpp \ + loc_eng_agps.cpp \ + loc_eng_xtra.cpp \ + loc_eng_ni.cpp \ + loc_eng_log.cpp \ + loc_eng_nmea.cpp \ + LocEngAdapter.cpp + +LOCAL_SRC_FILES += \ + loc_eng_dmn_conn.cpp \ + loc_eng_dmn_conn_handler.cpp \ + loc_eng_dmn_conn_thread_helper.c \ + loc_eng_dmn_conn_glue_msg.c \ + loc_eng_dmn_conn_glue_pipe.c + +LOCAL_CFLAGS += \ + -fno-short-enums \ + -D_ANDROID_ + +LOCAL_C_INCLUDES:= \ + $(TARGET_OUT_HEADERS)/gps.utils \ + $(TARGET_OUT_HEADERS)/libloc_core \ + $(LOCAL_PATH) \ + $(TARGET_OUT_HEADERS)/libflp + +LOCAL_COPY_HEADERS_TO:= libloc_eng/ +LOCAL_COPY_HEADERS:= \ + LocEngAdapter.h \ + loc.h \ + loc_eng.h \ + loc_eng_xtra.h \ + loc_eng_ni.h \ + loc_eng_agps.h \ + loc_eng_msg.h \ + loc_eng_log.h + +include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) + +LOCAL_MODULE := gps.$(TARGET_BOARD_PLATFORM) +LOCAL_MODULE_OWNER := qcom +LOCAL_VENDOR_MODULE := true + +LOCAL_MODULE_TAGS := optional + +## Libs +LOCAL_SHARED_LIBRARIES := \ + libutils \ + libcutils \ + liblog \ + libloc_eng \ + libloc_core \ + libgps.utils \ + libdl + +LOCAL_SRC_FILES += \ + loc.cpp \ + gps.c + +LOCAL_CFLAGS += \ + -fno-short-enums \ + -D_ANDROID_ \ + +## Includes +LOCAL_C_INCLUDES:= \ + $(TARGET_OUT_HEADERS)/gps.utils \ + $(TARGET_OUT_HEADERS)/libloc_core \ + $(TARGET_OUT_HEADERS)/libflp + +LOCAL_MODULE_RELATIVE_PATH := hw + +include $(BUILD_SHARED_LIBRARY) diff --git a/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp b/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp new file mode 100644 index 0000000..364b2d9 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp @@ -0,0 +1,598 @@ +/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_EngAdapter" + +#include +#include +#include +#include +#include +#include "loc_eng_msg.h" +#include "loc_log.h" + +#define CHIPSET_SERIAL_NUMBER_MAX_LEN 16 +#define USER_AGENT_MAX_LEN 512 + +using namespace loc_core; + +LocInternalAdapter::LocInternalAdapter(LocEngAdapter* adapter) : + LocAdapterBase(adapter->getMsgTask()), + mLocEngAdapter(adapter) +{ +} +void LocInternalAdapter::setPositionModeInt(LocPosMode& posMode) { + sendMsg(new LocEngPositionMode(mLocEngAdapter, posMode)); +} +void LocInternalAdapter::startFixInt() { + sendMsg(new LocEngStartFix(mLocEngAdapter)); +} +void LocInternalAdapter::stopFixInt() { + sendMsg(new LocEngStopFix(mLocEngAdapter)); +} +void LocInternalAdapter::getZppInt() { + sendMsg(new LocEngGetZpp(mLocEngAdapter)); +} + +LocEngAdapter::LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask, + void* owner, ContextBase* context, + LocThread::tCreate tCreator) : + LocAdapterBase(mask, + //Get the AFW context if VzW context has not already been intialized in + //loc_ext + context == NULL? + LocDualContext::getLocFgContext(tCreator, + NULL, + LocDualContext::mLocationHalName, + false) + :context), + mOwner(owner), mInternalAdapter(new LocInternalAdapter(this)), + mUlp(new UlpProxyBase()), mNavigating(false), + mSupportsAgpsRequests(false), + mSupportsPositionInjection(false), + mSupportsTimeInjection(false), + mPowerVote(0) +{ + memset(&mFixCriteria, 0, sizeof(mFixCriteria)); + mFixCriteria.mode = LOC_POSITION_MODE_INVALID; + LOC_LOGD("LocEngAdapter created"); +} + +inline +LocEngAdapter::~LocEngAdapter() +{ + delete mInternalAdapter; + LOC_LOGV("LocEngAdapter deleted"); +} + +void LocEngAdapter::setXtraUserAgent() { + struct LocSetXtraUserAgent : public LocMsg { + const ContextBase* const mContext; + inline LocSetXtraUserAgent(ContextBase* context) : + LocMsg(), mContext(context) { + } + virtual void proc() const { + char release[PROPERTY_VALUE_MAX]; + char manufacture[PROPERTY_VALUE_MAX]; + char model[PROPERTY_VALUE_MAX]; + char board[PROPERTY_VALUE_MAX]; + char brand[PROPERTY_VALUE_MAX]; + char chipsetsn[CHIPSET_SERIAL_NUMBER_MAX_LEN]; + char userAgent[USER_AGENT_MAX_LEN]; + const char defVal[] = "-"; + + property_get("ro.build.version.release", release, defVal); + property_get("ro.product.manufacturer", manufacture, defVal); + property_get("ro.product.model", model, defVal); + property_get("ro.product.board", board, defVal); + property_get("ro.product.brand", brand, defVal); + getChipsetSerialNo(chipsetsn, sizeof(chipsetsn), defVal); + + encodeInPlace(release, PROPERTY_VALUE_MAX); + encodeInPlace(manufacture, PROPERTY_VALUE_MAX); + encodeInPlace(model, PROPERTY_VALUE_MAX); + encodeInPlace(board, PROPERTY_VALUE_MAX); + encodeInPlace(brand, PROPERTY_VALUE_MAX); + + snprintf(userAgent, sizeof(userAgent), "A/%s/%s/%s/%s/-/QCX3/s%u/-/%s/-/%s/-/-/-", + release, manufacture, model, board, + mContext->getIzatDevId(), chipsetsn, brand); + + for (int i = 0; i < sizeof(userAgent) && userAgent[i]; i++) { + if (' ' == userAgent[i]) userAgent[i] = '#'; + } + + saveUserAgentString(userAgent, strlen(userAgent)); + LOC_LOGV("%s] UserAgent %s", __func__, userAgent); + } + + void saveUserAgentString(const char* data, const int len) const { + const char XTRA_FOLDER[] = "/data/misc/location/xtra"; + const char USER_AGENT_FILE[] = "/data/misc/location/xtra/useragent.txt"; + + if (data == NULL || len < 1) { + LOC_LOGE("%s:%d]: invalid input data = %p len = %d", __func__, __LINE__, data, len); + return; + } + + struct stat s; + int err = stat(XTRA_FOLDER, &s); + if (err < 0) { + if (ENOENT == errno) { + if (mkdir(XTRA_FOLDER, 0700) < 0) { + LOC_LOGE("%s:%d]: make XTRA_FOLDER failed", __func__, __LINE__); + return; + } + } else { + LOC_LOGE("%s:%d]: XTRA_FOLDER invalid", __func__, __LINE__); + return; + } + } + + FILE* file = fopen(USER_AGENT_FILE, "wt"); + if (file == NULL) { + LOC_LOGE("%s:%d]: open USER_AGENT_FILE failed", __func__, __LINE__); + return; + } + + size_t written = fwrite(data, 1, len, file); + fclose(file); + file = NULL; + + // set file permission + chmod(USER_AGENT_FILE, 0600); + + if (written != len) { + LOC_LOGE("%s:%d]: write USER_AGENT_FILE failed", __func__, __LINE__); + } + } + + void getChipsetSerialNo(char buf[], int buflen, const char def[]) const { + const char SOC_SERIAL_NUMBER[] = "/sys/devices/soc0/serial_number"; + + FILE* file = fopen(SOC_SERIAL_NUMBER, "rt"); + if (file == NULL) { + // use default upon unreadable file + strlcpy(buf, def, buflen); + + } else { + size_t size = fread(buf, 1, buflen - 1, file); + if (size == 0) { + // use default upon empty file + strlcpy(buf, def, buflen); + + } else { + buf[size] = '\0'; + } + + fclose(file); + + // remove trailing spaces + size_t len = strlen(buf); + while (--len >= 0 && isspace(buf[len])) { + buf[len] = '\0'; + } + } + + return; + } + + /** + * encode the given string value such that all separator characters ('/','+','|','%') + * in the string are repaced by their corresponding encodings (%2F","%2B","%7C", "%25") + */ + static void encodeInPlace(char value[], const int size) { + char buffer[size]; + + struct ENCODE { + const char ch; + const char *code; + }; + + const ENCODE encodings[] = { {'/', "%2F"}, {'+', "%2B"}, {'|', "%7C",}, {'%', "%25"} }; + const int nencodings = (int)sizeof(encodings) / sizeof(encodings[0]); + + int inpos = 0, outpos = 0; + while(value[inpos] != '\0' && outpos < size - 1) { + // check if escaped character + int escchar = 0; + while(escchar < nencodings && encodings[escchar].ch != value[inpos]) { + escchar++; + } + + if (escchar == nencodings) { + // non escaped character + buffer[outpos++] = value[inpos++]; + continue; + } + + // escaped character + int codepos = 0; + #define NUM_CHARS_IN_CODE 3 + + if (outpos + NUM_CHARS_IN_CODE >= size) { + // skip last character if there is insufficient space + break; + } + + while(outpos < size - 1 && codepos < NUM_CHARS_IN_CODE) { + buffer[outpos++] = encodings[escchar].code[codepos++]; + } + inpos++; + } + + // copy to ouput + value[outpos] = '\0'; + while(--outpos >= 0) { + value[outpos] = buffer[outpos]; + } + } + }; + + sendMsg(new LocSetXtraUserAgent(mContext)); +} + +void LocInternalAdapter::setUlpProxy(UlpProxyBase* ulp) { + struct LocSetUlpProxy : public LocMsg { + LocAdapterBase* mAdapter; + UlpProxyBase* mUlp; + inline LocSetUlpProxy(LocAdapterBase* adapter, UlpProxyBase* ulp) : + LocMsg(), mAdapter(adapter), mUlp(ulp) { + } + virtual void proc() const { + LOC_LOGV("%s] ulp %p adapter %p", __func__, + mUlp, mAdapter); + mAdapter->setUlpProxy(mUlp); + } + }; + + sendMsg(new LocSetUlpProxy(mLocEngAdapter, ulp)); +} + +void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp) +{ + if (ulp == mUlp) { + //This takes care of the case when double initalization happens + //and we get the same object back for UlpProxyBase . Do nothing + return; + } + + LOC_LOGV("%s] %p", __func__, ulp); + if (NULL == ulp) { + LOC_LOGE("%s:%d]: ulp pointer is NULL", __func__, __LINE__); + ulp = new UlpProxyBase(); + } + + if (LOC_POSITION_MODE_INVALID != mUlp->mPosMode.mode) { + // need to send this mode and start msg to ULP + ulp->sendFixMode(mUlp->mPosMode); + } + + if(mUlp->mFixSet) { + ulp->sendStartFix(); + } + + delete mUlp; + mUlp = ulp; +} + +int LocEngAdapter::setGpsLockMsg(LOC_GPS_LOCK_MASK lockMask) +{ + struct LocEngAdapterGpsLock : public LocMsg { + LocEngAdapter* mAdapter; + LOC_GPS_LOCK_MASK mLockMask; + inline LocEngAdapterGpsLock(LocEngAdapter* adapter, LOC_GPS_LOCK_MASK lockMask) : + LocMsg(), mAdapter(adapter), mLockMask(lockMask) + { + locallog(); + } + inline virtual void proc() const { + mAdapter->setGpsLock(mLockMask); + } + inline void locallog() const { + LOC_LOGV("LocEngAdapterGpsLock - mLockMask: %x", mLockMask); + } + inline virtual void log() const { + locallog(); + } + }; + sendMsg(new LocEngAdapterGpsLock(this, lockMask)); + return 0; +} + +void LocEngAdapter::requestPowerVote() +{ + if (getPowerVoteRight()) { + /* Power voting without engine lock: + * 101: vote down, 102-104 - vote up + * These codes are used not to confuse with actual engine lock + * functionality, that can't be used in SSR scenario, as it + * conflicts with initialization sequence. + */ + bool powerUp = getPowerVote(); + LOC_LOGV("LocEngAdapterVotePower - Vote Power: %d", (int)powerUp); + setGpsLock(powerUp ? 103 : 101); + } +} + +void LocInternalAdapter::reportPosition(UlpLocation &location, + GpsLocationExtended &locationExtended, + void* locationExt, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask) +{ + sendMsg(new LocEngReportPosition(mLocEngAdapter, + location, + locationExtended, + locationExt, + status, + loc_technology_mask)); +} + + +void LocEngAdapter::reportPosition(UlpLocation &location, + GpsLocationExtended &locationExtended, + void* locationExt, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask) +{ + if (! mUlp->reportPosition(location, + locationExtended, + locationExt, + status, + loc_technology_mask )) { + mInternalAdapter->reportPosition(location, + locationExtended, + locationExt, + status, + loc_technology_mask); + } +} + +void LocInternalAdapter::reportSv(QcomSvStatus &svStatus, + GpsLocationExtended &locationExtended, + void* svExt){ + sendMsg(new LocEngReportSv(mLocEngAdapter, svStatus, + locationExtended, svExt)); +} + +void LocEngAdapter::reportSv(QcomSvStatus &svStatus, + GpsLocationExtended &locationExtended, + void* svExt) +{ + + // We want to send SV info to ULP to help it in determining GNSS + // signal strength ULP will forward the SV reports to HAL without + // any modifications + if (! mUlp->reportSv(svStatus, locationExtended, svExt)) { + mInternalAdapter->reportSv(svStatus, locationExtended, svExt); + } +} + +void LocEngAdapter::setInSession(bool inSession) +{ + mNavigating = inSession; + mLocApi->setInSession(inSession); + if (!mNavigating) { + mFixCriteria.mode = LOC_POSITION_MODE_INVALID; + } +} + +void LocInternalAdapter::reportStatus(GpsStatusValue status) +{ + sendMsg(new LocEngReportStatus(mLocEngAdapter, status)); +} + +void LocEngAdapter::reportStatus(GpsStatusValue status) +{ + if (!mUlp->reportStatus(status)) { + mInternalAdapter->reportStatus(status); + } +} + +inline +void LocEngAdapter::reportNmea(const char* nmea, int length) +{ + sendMsg(new LocEngReportNmea(mOwner, nmea, length)); +} + +inline +bool LocEngAdapter::reportXtraServer(const char* url1, + const char* url2, + const char* url3, + const int maxlength) +{ + if (mSupportsAgpsRequests) { + sendMsg(new LocEngReportXtraServer(mOwner, url1, + url2, url3, maxlength)); + } + return mSupportsAgpsRequests; +} + +inline +bool LocEngAdapter::requestATL(int connHandle, AGpsType agps_type) +{ + if (mSupportsAgpsRequests) { + sendMsg(new LocEngRequestATL(mOwner, + connHandle, agps_type)); + } + return mSupportsAgpsRequests; +} + +inline +bool LocEngAdapter::releaseATL(int connHandle) +{ + if (mSupportsAgpsRequests) { + sendMsg(new LocEngReleaseATL(mOwner, connHandle)); + } + return mSupportsAgpsRequests; +} + +inline +bool LocEngAdapter::requestXtraData() +{ + if (mSupportsAgpsRequests) { + sendMsg(new LocEngRequestXtra(mOwner)); + } + return mSupportsAgpsRequests; +} + +inline +bool LocEngAdapter::requestTime() +{ + if (mSupportsAgpsRequests) { + sendMsg(new LocEngRequestTime(mOwner)); + } + return mSupportsAgpsRequests; +} + +inline +bool LocEngAdapter::requestNiNotify(GpsNiNotification ¬if, const void* data) +{ + if (mSupportsAgpsRequests) { + notif.size = sizeof(notif); + notif.timeout = LOC_NI_NO_RESPONSE_TIME; + + sendMsg(new LocEngRequestNi(mOwner, notif, data)); + } + return mSupportsAgpsRequests; +} + +inline +bool LocEngAdapter::requestSuplES(int connHandle) +{ + if (mSupportsAgpsRequests) + sendMsg(new LocEngRequestSuplEs(mOwner, connHandle)); + return mSupportsAgpsRequests; +} + +inline +bool LocEngAdapter::reportDataCallOpened() +{ + if(mSupportsAgpsRequests) + sendMsg(new LocEngSuplEsOpened(mOwner)); + return mSupportsAgpsRequests; +} + +inline +bool LocEngAdapter::reportDataCallClosed() +{ + if(mSupportsAgpsRequests) + sendMsg(new LocEngSuplEsClosed(mOwner)); + return mSupportsAgpsRequests; +} + +inline +void LocEngAdapter::handleEngineDownEvent() +{ + sendMsg(new LocEngDown(mOwner)); +} + +inline +void LocEngAdapter::handleEngineUpEvent() +{ + sendMsg(new LocEngUp(mOwner)); +} + +enum loc_api_adapter_err LocEngAdapter::setTime(GpsUtcTime time, + int64_t timeReference, + int uncertainty) +{ + loc_api_adapter_err result = LOC_API_ADAPTER_ERR_SUCCESS; + + LOC_LOGD("%s:%d]: mSupportsTimeInjection is %d", + __func__, __LINE__, mSupportsTimeInjection); + + if (mSupportsTimeInjection) { + LOC_LOGD("%s:%d]: Injecting time", __func__, __LINE__); + result = mLocApi->setTime(time, timeReference, uncertainty); + } else { + mSupportsTimeInjection = true; + } + return result; +} + +enum loc_api_adapter_err LocEngAdapter::setXtraVersionCheck(int check) +{ + enum loc_api_adapter_err ret; + ENTRY_LOG(); + enum xtra_version_check eCheck; + switch (check) { + case 0: + eCheck = DISABLED; + break; + case 1: + eCheck = AUTO; + break; + case 2: + eCheck = XTRA2; + break; + case 3: + eCheck = XTRA3; + break; + default: + eCheck = DISABLED; + } + ret = mLocApi->setXtraVersionCheck(eCheck); + EXIT_LOG(%d, ret); + return ret; +} + +void LocEngAdapter::reportGpsMeasurementData(GpsData &gpsMeasurementData) +{ + sendMsg(new LocEngReportGpsMeasurement(mOwner, + gpsMeasurementData)); +} + +/* + Update Registration Mask + */ +void LocEngAdapter::updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event, + loc_registration_mask_status isEnabled) +{ + LOC_LOGD("entering %s", __func__); + int result = LOC_API_ADAPTER_ERR_FAILURE; + result = mLocApi->updateRegistrationMask(event, isEnabled); + if (result == LOC_API_ADAPTER_ERR_SUCCESS) { + LOC_LOGD("%s] update registration mask succeed.", __func__); + } else { + LOC_LOGE("%s] update registration mask failed.", __func__); + } +} + +/* + Set Gnss Constellation Config + */ +bool LocEngAdapter::gnssConstellationConfig() +{ + LOC_LOGD("entering %s", __func__); + bool result = false; + result = mLocApi->gnssConstellationConfig(); + return result; +} diff --git a/gps/loc_api/libloc_api_50001/LocEngAdapter.h b/gps/loc_api/libloc_api_50001/LocEngAdapter.h new file mode 100644 index 0000000..8964ede --- /dev/null +++ b/gps/loc_api/libloc_api_50001/LocEngAdapter.h @@ -0,0 +1,351 @@ +/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef LOC_API_ENG_ADAPTER_H +#define LOC_API_ENG_ADAPTER_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_URL_LEN 256 + +using namespace loc_core; + +class LocEngAdapter; + +class LocInternalAdapter : public LocAdapterBase { + LocEngAdapter* mLocEngAdapter; +public: + LocInternalAdapter(LocEngAdapter* adapter); + + virtual void reportPosition(UlpLocation &location, + GpsLocationExtended &locationExtended, + void* locationExt, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask); + virtual void reportSv(QcomSvStatus &svStatus, + GpsLocationExtended &locationExtended, + void* svExt); + virtual void reportStatus(GpsStatusValue status); + virtual void setPositionModeInt(LocPosMode& posMode); + virtual void startFixInt(); + virtual void stopFixInt(); + virtual void getZppInt(); + virtual void setUlpProxy(UlpProxyBase* ulp); +}; + +typedef void (*loc_msg_sender)(void* loc_eng_data_p, void* msgp); + +class LocEngAdapter : public LocAdapterBase { + void* mOwner; + LocInternalAdapter* mInternalAdapter; + UlpProxyBase* mUlp; + LocPosMode mFixCriteria; + bool mNavigating; + // mPowerVote is encoded as + // mPowerVote & 0x20 -- powerVoteRight + // mPowerVote & 0x10 -- power On / Off + unsigned int mPowerVote; + static const unsigned int POWER_VOTE_RIGHT = 0x20; + static const unsigned int POWER_VOTE_VALUE = 0x10; + +public: + bool mSupportsAgpsRequests; + bool mSupportsPositionInjection; + bool mSupportsTimeInjection; + + LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask, + void* owner, ContextBase* context, + LocThread::tCreate tCreator); + virtual ~LocEngAdapter(); + + virtual void setUlpProxy(UlpProxyBase* ulp); + void setXtraUserAgent(); + inline void requestUlp(unsigned long capabilities) { + mContext->requestUlp(mInternalAdapter, capabilities); + } + inline LocInternalAdapter* getInternalAdapter() { return mInternalAdapter; } + inline UlpProxyBase* getUlpProxy() { return mUlp; } + inline void* getOwner() { return mOwner; } + inline bool hasAgpsExtendedCapabilities() { + return mContext->hasAgpsExtendedCapabilities(); + } + inline bool hasCPIExtendedCapabilities() { + return mContext->hasCPIExtendedCapabilities(); + } + inline const MsgTask* getMsgTask() { return mMsgTask; } + + inline enum loc_api_adapter_err + startFix() + { + return mLocApi->startFix(mFixCriteria); + } + inline enum loc_api_adapter_err + stopFix() + { + return mLocApi->stopFix(); + } + inline enum loc_api_adapter_err + deleteAidingData(GpsAidingData f) + { + return mLocApi->deleteAidingData(f); + } + inline enum loc_api_adapter_err + enableData(int enable) + { + return mLocApi->enableData(enable); + } + inline enum loc_api_adapter_err + setAPN(char* apn, int len) + { + return mLocApi->setAPN(apn, len); + } + inline enum loc_api_adapter_err + injectPosition(double latitude, double longitude, float accuracy) + { + return mLocApi->injectPosition(latitude, longitude, accuracy); + } + inline enum loc_api_adapter_err + setXtraData(char* data, int length) + { + return mLocApi->setXtraData(data, length); + } + inline enum loc_api_adapter_err + requestXtraServer() + { + return mLocApi->requestXtraServer(); + } + inline enum loc_api_adapter_err + atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, AGpsType agpsType) + { + return mLocApi->atlOpenStatus(handle, is_succ, apn, bearer, agpsType); + } + inline enum loc_api_adapter_err + atlCloseStatus(int handle, int is_succ) + { + return mLocApi->atlCloseStatus(handle, is_succ); + } + inline enum loc_api_adapter_err + setPositionMode(const LocPosMode *posMode) + { + if (NULL != posMode) { + mFixCriteria = *posMode; + } + return mLocApi->setPositionMode(mFixCriteria); + } + inline enum loc_api_adapter_err + setServer(const char* url, int len) + { + return mLocApi->setServer(url, len); + } + inline enum loc_api_adapter_err + setServer(unsigned int ip, int port, + LocServerType type) + { + return mLocApi->setServer(ip, port, type); + } + inline enum loc_api_adapter_err + informNiResponse(GpsUserResponseType userResponse, const void* passThroughData) + { + return mLocApi->informNiResponse(userResponse, passThroughData); + } + inline enum loc_api_adapter_err + setSUPLVersion(uint32_t version) + { + return mLocApi->setSUPLVersion(version); + } + inline enum loc_api_adapter_err + setLPPConfig(uint32_t profile) + { + return mLocApi->setLPPConfig(profile); + } + inline enum loc_api_adapter_err + setSensorControlConfig(int sensorUsage, int sensorProvider) + { + return mLocApi->setSensorControlConfig(sensorUsage, sensorProvider); + } + inline enum loc_api_adapter_err + setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, float gyroBiasVarianceRandomWalk, + bool accelBiasVarianceRandomWalk_valid, float accelBiasVarianceRandomWalk, + bool angleBiasVarianceRandomWalk_valid, float angleBiasVarianceRandomWalk, + bool rateBiasVarianceRandomWalk_valid, float rateBiasVarianceRandomWalk, + bool velocityBiasVarianceRandomWalk_valid, float velocityBiasVarianceRandomWalk) + { + return mLocApi->setSensorProperties(gyroBiasVarianceRandomWalk_valid, gyroBiasVarianceRandomWalk, + accelBiasVarianceRandomWalk_valid, accelBiasVarianceRandomWalk, + angleBiasVarianceRandomWalk_valid, angleBiasVarianceRandomWalk, + rateBiasVarianceRandomWalk_valid, rateBiasVarianceRandomWalk, + velocityBiasVarianceRandomWalk_valid, velocityBiasVarianceRandomWalk); + } + inline virtual enum loc_api_adapter_err + setSensorPerfControlConfig(int controlMode, int accelSamplesPerBatch, int accelBatchesPerSec, + int gyroSamplesPerBatch, int gyroBatchesPerSec, + int accelSamplesPerBatchHigh, int accelBatchesPerSecHigh, + int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh, int algorithmConfig) + { + return mLocApi->setSensorPerfControlConfig(controlMode, accelSamplesPerBatch, accelBatchesPerSec, + gyroSamplesPerBatch, gyroBatchesPerSec, + accelSamplesPerBatchHigh, accelBatchesPerSecHigh, + gyroSamplesPerBatchHigh, gyroBatchesPerSecHigh, + algorithmConfig); + } + inline virtual enum loc_api_adapter_err + setExtPowerConfig(int isBatteryCharging) + { + return mLocApi->setExtPowerConfig(isBatteryCharging); + } + inline virtual enum loc_api_adapter_err + setAGLONASSProtocol(unsigned long aGlonassProtocol) + { + return mLocApi->setAGLONASSProtocol(aGlonassProtocol); + } + inline virtual int initDataServiceClient() + { + return mLocApi->initDataServiceClient(); + } + inline virtual int openAndStartDataCall() + { + return mLocApi->openAndStartDataCall(); + } + inline virtual void stopDataCall() + { + mLocApi->stopDataCall(); + } + inline virtual void closeDataCall() + { + mLocApi->closeDataCall(); + } + inline enum loc_api_adapter_err + getZpp(GpsLocation &zppLoc, LocPosTechMask &tech_mask) + { + return mLocApi->getBestAvailableZppFix(zppLoc, tech_mask); + } + enum loc_api_adapter_err setTime(GpsUtcTime time, + int64_t timeReference, + int uncertainty); + enum loc_api_adapter_err setXtraVersionCheck(int check); + inline virtual void installAGpsCert(const DerEncodedCertificate* pData, + size_t length, + uint32_t slotBitMask) + { + mLocApi->installAGpsCert(pData, length, slotBitMask); + } + virtual void handleEngineDownEvent(); + virtual void handleEngineUpEvent(); + virtual void reportPosition(UlpLocation &location, + GpsLocationExtended &locationExtended, + void* locationExt, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask); + virtual void reportSv(QcomSvStatus &svStatus, + GpsLocationExtended &locationExtended, + void* svExt); + virtual void reportStatus(GpsStatusValue status); + virtual void reportNmea(const char* nmea, int length); + virtual bool reportXtraServer(const char* url1, const char* url2, + const char* url3, const int maxlength); + virtual bool requestXtraData(); + virtual bool requestTime(); + virtual bool requestATL(int connHandle, AGpsType agps_type); + virtual bool releaseATL(int connHandle); + virtual bool requestNiNotify(GpsNiNotification ¬ify, const void* data); + virtual bool requestSuplES(int connHandle); + virtual bool reportDataCallOpened(); + virtual bool reportDataCallClosed(); + virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData); + + inline const LocPosMode& getPositionMode() const + {return mFixCriteria;} + inline virtual bool isInSession() + { return mNavigating; } + void setInSession(bool inSession); + + // Permit/prohibit power voting + inline void setPowerVoteRight(bool powerVoteRight) { + mPowerVote = powerVoteRight ? (mPowerVote | POWER_VOTE_RIGHT) : + (mPowerVote & ~POWER_VOTE_RIGHT); + } + inline bool getPowerVoteRight() const { + return (mPowerVote & POWER_VOTE_RIGHT) != 0 ; + } + // Set the power voting up/down and do actual operation if permitted + inline void setPowerVote(bool powerOn) { + mPowerVote = powerOn ? (mPowerVote | POWER_VOTE_VALUE) : + (mPowerVote & ~POWER_VOTE_VALUE); + requestPowerVote(); + mContext->modemPowerVote(powerOn); + } + inline bool getPowerVote() const { + return (mPowerVote & POWER_VOTE_VALUE) != 0 ; + } + // Do power voting according to last settings if permitted + void requestPowerVote(); + + /*Values for lock + 1 = Do not lock any position sessions + 2 = Lock MI position sessions + 3 = Lock MT position sessions + 4 = Lock all position sessions + */ + inline int setGpsLock(LOC_GPS_LOCK_MASK lock) + { + return mLocApi->setGpsLock(lock); + } + + int setGpsLockMsg(LOC_GPS_LOCK_MASK lock); + + /* + Returns + Current value of GPS lock on success + -1 on failure + */ + inline int getGpsLock() + { + return mLocApi->getGpsLock(); + } + + /* + Update Registration Mask + */ + void updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event, + loc_registration_mask_status isEnabled); + + /* + Set Gnss Constellation Config + */ + bool gnssConstellationConfig(); +}; + +#endif //LOC_API_ENG_ADAPTER_H diff --git a/gps/loc_api/libloc_api_50001/gps.c b/gps/loc_api/libloc_api_50001/gps.c new file mode 100644 index 0000000..29f20f4 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/gps.c @@ -0,0 +1,73 @@ +/* Copyright (c) 2011,2015 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include +#include + +extern const GpsInterface* get_gps_interface(); + +const GpsInterface* gps__get_gps_interface(struct gps_device_t* dev) +{ + return get_gps_interface(); +} + +static int open_gps(const struct hw_module_t* module, char const* name, + struct hw_device_t** device) +{ + struct gps_device_t *dev = (struct gps_device_t *) malloc(sizeof(struct gps_device_t)); + + if(dev == NULL) + return -1; + + memset(dev, 0, sizeof(*dev)); + + dev->common.tag = HARDWARE_DEVICE_TAG; + dev->common.version = 0; + dev->common.module = (struct hw_module_t*)module; + dev->get_gps_interface = gps__get_gps_interface; + + *device = (struct hw_device_t*)dev; + return 0; +} + +static struct hw_module_methods_t gps_module_methods = { + .open = open_gps +}; + +struct hw_module_t HAL_MODULE_INFO_SYM = { + .tag = HARDWARE_MODULE_TAG, + .module_api_version = 1, + .hal_api_version = 0, + .id = GPS_HARDWARE_MODULE_ID, + .name = "loc_api GPS Module", + .author = "Qualcomm USA, Inc.", + .methods = &gps_module_methods, +}; diff --git a/gps/loc_api/libloc_api_50001/loc.cpp b/gps/loc_api/libloc_api_50001/loc.cpp new file mode 100644 index 0000000..8a438f7 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc.cpp @@ -0,0 +1,1076 @@ +/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_afw" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace loc_core; + +#define LOC_PM_CLIENT_NAME "GPS" + +//Globals defns +static gps_location_callback gps_loc_cb = NULL; +static gps_sv_status_callback gps_sv_cb = NULL; + +static void local_loc_cb(UlpLocation* location, void* locExt); +static void local_sv_cb(GpsSvStatus* sv_status, void* svExt); + +static const GpsGeofencingInterface* get_geofence_interface(void); + +// Function declarations for sLocEngInterface +static int loc_init(GpsCallbacks* callbacks); +static int loc_start(); +static int loc_stop(); +static void loc_cleanup(); +static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty); +static int loc_inject_location(double latitude, double longitude, float accuracy); +static void loc_delete_aiding_data(GpsAidingData f); +static int loc_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence recurrence, + uint32_t min_interval, uint32_t preferred_accuracy, + uint32_t preferred_time); +static const void* loc_get_extension(const char* name); +// Defines the GpsInterface in gps.h +static const GpsInterface sLocEngInterface = +{ + sizeof(GpsInterface), + loc_init, + loc_start, + loc_stop, + loc_cleanup, + loc_inject_time, + loc_inject_location, + loc_delete_aiding_data, + loc_set_position_mode, + loc_get_extension +}; + +// Function declarations for sLocEngAGpsInterface +static void loc_agps_init(AGpsCallbacks* callbacks); +static int loc_agps_open(const char* apn); +static int loc_agps_closed(); +static int loc_agps_open_failed(); +static int loc_agps_set_server(AGpsType type, const char *hostname, int port); +static int loc_agps_open_with_apniptype( const char* apn, ApnIpType apnIpType); + +static const AGpsInterface sLocEngAGpsInterface = +{ + sizeof(AGpsInterface), + loc_agps_init, + loc_agps_open, + loc_agps_closed, + loc_agps_open_failed, + loc_agps_set_server, + loc_agps_open_with_apniptype +}; + +static int loc_xtra_init(GpsXtraCallbacks* callbacks); +static int loc_xtra_inject_data(char* data, int length); + +static const GpsXtraInterface sLocEngXTRAInterface = +{ + sizeof(GpsXtraInterface), + loc_xtra_init, + loc_xtra_inject_data +}; + +static void loc_ni_init(GpsNiCallbacks *callbacks); +static void loc_ni_respond(int notif_id, GpsUserResponseType user_response); + +static const GpsNiInterface sLocEngNiInterface = +{ + sizeof(GpsNiInterface), + loc_ni_init, + loc_ni_respond, +}; + +static int loc_gps_measurement_init(GpsMeasurementCallbacks* callbacks); +static void loc_gps_measurement_close(); + +static const GpsMeasurementInterface sLocEngGpsMeasurementInterface = +{ + sizeof(GpsMeasurementInterface), + loc_gps_measurement_init, + loc_gps_measurement_close +}; + +static void loc_agps_ril_init( AGpsRilCallbacks* callbacks ); +static void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct); +static void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid); +static void loc_agps_ril_ni_message(uint8_t *msg, size_t len); +static void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info); +static void loc_agps_ril_update_network_availability(int avaiable, const char* apn); + +static const AGpsRilInterface sLocEngAGpsRilInterface = +{ + sizeof(AGpsRilInterface), + loc_agps_ril_init, + loc_agps_ril_set_ref_location, + loc_agps_ril_set_set_id, + loc_agps_ril_ni_message, + loc_agps_ril_update_network_state, + loc_agps_ril_update_network_availability +}; + +static int loc_agps_install_certificates(const DerEncodedCertificate* certificates, + size_t length); +static int loc_agps_revoke_certificates(const Sha1CertificateFingerprint* fingerprints, + size_t length); + +static const SuplCertificateInterface sLocEngAGpsCertInterface = +{ + sizeof(SuplCertificateInterface), + loc_agps_install_certificates, + loc_agps_revoke_certificates +}; + +static void loc_configuration_update(const char* config_data, int32_t length); + +static const GnssConfigurationInterface sLocEngConfigInterface = +{ + sizeof(GnssConfigurationInterface), + loc_configuration_update +}; + +static loc_eng_data_s_type loc_afw_data; +static int gss_fd = -1; +static int sGnssType = GNSS_UNKNOWN; +/*=========================================================================== +FUNCTION gps_get_hardware_interface + +DESCRIPTION + Returns the GPS hardware interaface based on LOC API + if GPS is enabled. + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +const GpsInterface* gps_get_hardware_interface () +{ + ENTRY_LOG_CALLFLOW(); + const GpsInterface* ret_val; + + char propBuf[PROPERTY_VALUE_MAX]; + + loc_eng_read_config(); + + // check to see if GPS should be disabled + property_get("gps.disable", propBuf, ""); + if (propBuf[0] == '1') + { + LOC_LOGD("gps_get_interface returning NULL because gps.disable=1\n"); + ret_val = NULL; + } else { + ret_val = &sLocEngInterface; + } + + loc_eng_read_config(); + + EXIT_LOG(%p, ret_val); + return ret_val; +} + +// for gps.c +extern "C" const GpsInterface* get_gps_interface() +{ + unsigned int target = TARGET_DEFAULT; + loc_eng_read_config(); + + target = loc_get_target(); + LOC_LOGD("Target name check returned %s", loc_get_target_name(target)); + + sGnssType = getTargetGnssType(target); + switch (sGnssType) + { + case GNSS_GSS: + case GNSS_AUTO: + //APQ8064 + gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); + gss_fd = open("/dev/gss", O_RDONLY); + if (gss_fd < 0) { + LOC_LOGE("GSS open failed: %s\n", strerror(errno)); + } + else { + LOC_LOGD("GSS open success! CAPABILITIES %0lx\n", + gps_conf.CAPABILITIES); + } + break; + case GNSS_NONE: + //MPQ8064 + LOC_LOGE("No GPS HW on this target. Not returning interface."); + return NULL; + case GNSS_QCA1530: + // qca1530 chip is present + gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); + LOC_LOGD("qca1530 present: CAPABILITIES %0lx\n", gps_conf.CAPABILITIES); + break; + } + return &sLocEngInterface; +} + +/*=========================================================================== +FUNCTION loc_init + +DESCRIPTION + Initialize the location engine, this include setting up global datas + and registers location engien with loc api service. + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/Ax + +===========================================================================*/ +static int loc_init(GpsCallbacks* callbacks) +{ + int retVal = -1; + ENTRY_LOG(); + LOC_API_ADAPTER_EVENT_MASK_T event; + + if (NULL == callbacks) { + LOC_LOGE("loc_init failed. cb = NULL\n"); + EXIT_LOG(%d, retVal); + return retVal; + } + + event = LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT | + LOC_API_ADAPTER_BIT_SATELLITE_REPORT | + LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST | + LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST | + LOC_API_ADAPTER_BIT_IOCTL_REPORT | + LOC_API_ADAPTER_BIT_STATUS_REPORT | + LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT | + LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST; + + LocCallbacks clientCallbacks = {local_loc_cb, /* location_cb */ + callbacks->status_cb, /* status_cb */ + local_sv_cb, /* sv_status_cb */ + callbacks->nmea_cb, /* nmea_cb */ + callbacks->set_capabilities_cb, /* set_capabilities_cb */ + callbacks->acquire_wakelock_cb, /* acquire_wakelock_cb */ + callbacks->release_wakelock_cb, /* release_wakelock_cb */ + callbacks->create_thread_cb, /* create_thread_cb */ + NULL, /* location_ext_parser */ + NULL, /* sv_ext_parser */ + callbacks->request_utc_time_cb, /* request_utc_time_cb */ + }; + + gps_loc_cb = callbacks->location_cb; + gps_sv_cb = callbacks->sv_status_cb; + + retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event, NULL); + loc_afw_data.adapter->mSupportsAgpsRequests = !loc_afw_data.adapter->hasAgpsExtendedCapabilities(); + loc_afw_data.adapter->mSupportsPositionInjection = !loc_afw_data.adapter->hasCPIExtendedCapabilities(); + loc_afw_data.adapter->mSupportsTimeInjection = !loc_afw_data.adapter->hasCPIExtendedCapabilities(); + loc_afw_data.adapter->setGpsLockMsg(0); + loc_afw_data.adapter->requestUlp(getCarrierCapabilities()); + loc_afw_data.adapter->setXtraUserAgent(); + + if(retVal) { + LOC_LOGE("loc_eng_init() fail!"); + goto err; + } + + loc_afw_data.adapter->setPowerVoteRight(loc_get_target() == TARGET_QCA1530); + loc_afw_data.adapter->setPowerVote(true); + + LOC_LOGD("loc_eng_init() success!"); + +err: + EXIT_LOG(%d, retVal); + return retVal; +} + +/*=========================================================================== +FUNCTION loc_cleanup + +DESCRIPTION + Cleans location engine. The location client handle will be released. + +DEPENDENCIES + None + +RETURN VALUE + None + +SIDE EFFECTS + N/A + +===========================================================================*/ +static void loc_cleanup() +{ + ENTRY_LOG(); + + loc_afw_data.adapter->setGpsLockMsg(gps_conf.GPS_LOCK); + + loc_eng_cleanup(loc_afw_data); + gps_loc_cb = NULL; + gps_sv_cb = NULL; + + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== +FUNCTION loc_start + +DESCRIPTION + Starts the tracking session + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_start() +{ + ENTRY_LOG(); + int ret_val = loc_eng_start(loc_afw_data); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_stop + +DESCRIPTION + Stops the tracking session + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_stop() +{ + ENTRY_LOG(); + int ret_val = -1; + ret_val = loc_eng_stop(loc_afw_data); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_set_position_mode + +DESCRIPTION + Sets the mode and fix frequency for the tracking session. + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_set_position_mode(GpsPositionMode mode, + GpsPositionRecurrence recurrence, + uint32_t min_interval, + uint32_t preferred_accuracy, + uint32_t preferred_time) +{ + ENTRY_LOG(); + int ret_val = -1; + LocPositionMode locMode; + switch (mode) { + case GPS_POSITION_MODE_MS_BASED: + locMode = LOC_POSITION_MODE_MS_BASED; + break; + case GPS_POSITION_MODE_MS_ASSISTED: + locMode = LOC_POSITION_MODE_MS_ASSISTED; + break; + default: + locMode = LOC_POSITION_MODE_STANDALONE; + break; + } + + LocPosMode params(locMode, recurrence, min_interval, + preferred_accuracy, preferred_time, NULL, NULL); + ret_val = loc_eng_set_position_mode(loc_afw_data, params); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_inject_time + +DESCRIPTION + This is used by Java native function to do time injection. + +DEPENDENCIES + None + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty) +{ + ENTRY_LOG(); + int ret_val = 0; + + ret_val = loc_eng_inject_time(loc_afw_data, time, + timeReference, uncertainty); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + + +/*=========================================================================== +FUNCTION loc_inject_location + +DESCRIPTION + This is used by Java native function to do location injection. + +DEPENDENCIES + None + +RETURN VALUE + 0 : Successful + error code : Failure + +SIDE EFFECTS + N/A +===========================================================================*/ +static int loc_inject_location(double latitude, double longitude, float accuracy) +{ + ENTRY_LOG(); + + int ret_val = 0; + ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + + +/*=========================================================================== +FUNCTION loc_delete_aiding_data + +DESCRIPTION + This is used by Java native function to delete the aiding data. The function + updates the global variable for the aiding data to be deleted. If the GPS + engine is off, the aiding data will be deleted. Otherwise, the actual action + will happen when gps engine is turned off. + +DEPENDENCIES + Assumes the aiding data type specified in GpsAidingData matches with + LOC API specification. + +RETURN VALUE + None + +SIDE EFFECTS + N/A + +===========================================================================*/ +static void loc_delete_aiding_data(GpsAidingData f) +{ + ENTRY_LOG(); + loc_eng_delete_aiding_data(loc_afw_data, f); + + EXIT_LOG(%s, VOID_RET); +} + +const GpsGeofencingInterface* get_geofence_interface(void) +{ + ENTRY_LOG(); + void *handle; + const char *error; + typedef const GpsGeofencingInterface* (*get_gps_geofence_interface_function) (void); + get_gps_geofence_interface_function get_gps_geofence_interface; + static const GpsGeofencingInterface* geofence_interface = NULL; + + dlerror(); /* Clear any existing error */ + + handle = dlopen ("libgeofence.so", RTLD_NOW); + + if (!handle) + { + if ((error = dlerror()) != NULL) { + LOC_LOGE ("%s, dlopen for libgeofence.so failed, error = %s\n", __func__, error); + } + goto exit; + } + dlerror(); /* Clear any existing error */ + get_gps_geofence_interface = (get_gps_geofence_interface_function)dlsym(handle, "gps_geofence_get_interface"); + if ((error = dlerror()) != NULL || NULL == get_gps_geofence_interface) { + LOC_LOGE ("%s, dlsym for get_gps_geofence_interface failed, error = %s\n", __func__, error); + goto exit; + } + + geofence_interface = get_gps_geofence_interface(); + +exit: + EXIT_LOG(%d, geofence_interface == NULL); + return geofence_interface; +} +/*=========================================================================== +FUNCTION loc_get_extension + +DESCRIPTION + Get the gps extension to support XTRA. + +DEPENDENCIES + N/A + +RETURN VALUE + The GPS extension interface. + +SIDE EFFECTS + N/A + +===========================================================================*/ +const void* loc_get_extension(const char* name) +{ + ENTRY_LOG(); + const void* ret_val = NULL; + + LOC_LOGD("%s:%d] For Interface = %s\n",__func__, __LINE__, name); + if (strcmp(name, GPS_XTRA_INTERFACE) == 0) + { + ret_val = &sLocEngXTRAInterface; + } + else if (strcmp(name, AGPS_INTERFACE) == 0) + { + ret_val = &sLocEngAGpsInterface; + } + else if (strcmp(name, GPS_NI_INTERFACE) == 0) + { + ret_val = &sLocEngNiInterface; + } + else if (strcmp(name, AGPS_RIL_INTERFACE) == 0) + { + char baseband[PROPERTY_VALUE_MAX]; + property_get("ro.baseband", baseband, "msm"); + if (strcmp(baseband, "csfb") == 0) + { + ret_val = &sLocEngAGpsRilInterface; + } + } + else if (strcmp(name, GPS_GEOFENCING_INTERFACE) == 0) + { + if ((gps_conf.CAPABILITIES | GPS_CAPABILITY_GEOFENCING) == gps_conf.CAPABILITIES ){ + ret_val = get_geofence_interface(); + } + } + else if (strcmp(name, SUPL_CERTIFICATE_INTERFACE) == 0) + { + ret_val = &sLocEngAGpsCertInterface; + } + else if (strcmp(name, GNSS_CONFIGURATION_INTERFACE) == 0) + { + ret_val = &sLocEngConfigInterface; + } + else if (strcmp(name, GPS_MEASUREMENT_INTERFACE) == 0) + { + ret_val = &sLocEngGpsMeasurementInterface; + } + else + { + LOC_LOGE ("get_extension: Invalid interface passed in\n"); + } + EXIT_LOG(%p, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_agps_init + +DESCRIPTION + Initialize the AGps interface. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +static void loc_agps_init(AGpsCallbacks* callbacks) +{ + ENTRY_LOG(); + loc_eng_agps_init(loc_afw_data, (AGpsExtCallbacks*)callbacks); + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== +FUNCTION loc_agps_open + +DESCRIPTION + This function is called when on-demand data connection opening is successful. +It should inform ARM 9 about the data open result. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_agps_open(const char* apn) +{ + ENTRY_LOG(); + AGpsType agpsType = AGPS_TYPE_SUPL; + AGpsBearerType bearerType = AGPS_APN_BEARER_IPV4; + int ret_val = loc_eng_agps_open(loc_afw_data, agpsType, apn, bearerType); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_agps_open_with_apniptype + +DESCRIPTION + This function is called when on-demand data connection opening is successful. +It should inform ARM 9 about the data open result. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_agps_open_with_apniptype(const char* apn, ApnIpType apnIpType) +{ + ENTRY_LOG(); + AGpsType agpsType = AGPS_TYPE_SUPL; + AGpsBearerType bearerType; + + switch (apnIpType) { + case APN_IP_IPV4: + bearerType = AGPS_APN_BEARER_IPV4; + break; + case APN_IP_IPV6: + bearerType = AGPS_APN_BEARER_IPV6; + break; + case APN_IP_IPV4V6: + bearerType = AGPS_APN_BEARER_IPV4V6; + break; + default: + bearerType = AGPS_APN_BEARER_IPV4; + break; + } + + int ret_val = loc_eng_agps_open(loc_afw_data, agpsType, apn, bearerType); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_agps_closed + +DESCRIPTION + This function is called when on-demand data connection closing is done. +It should inform ARM 9 about the data close result. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_agps_closed() +{ + ENTRY_LOG(); + AGpsType agpsType = AGPS_TYPE_SUPL; + int ret_val = loc_eng_agps_closed(loc_afw_data, agpsType); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_agps_open_failed + +DESCRIPTION + This function is called when on-demand data connection opening has failed. +It should inform ARM 9 about the data open result. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_agps_open_failed() +{ + ENTRY_LOG(); + AGpsType agpsType = AGPS_TYPE_SUPL; + int ret_val = loc_eng_agps_open_failed(loc_afw_data, agpsType); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_agps_set_server + +DESCRIPTION + If loc_eng_set_server is called before loc_eng_init, it doesn't work. This + proxy buffers server settings and calls loc_eng_set_server when the client is + open. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_agps_set_server(AGpsType type, const char* hostname, int port) +{ + ENTRY_LOG(); + LocServerType serverType; + switch (type) { + case AGPS_TYPE_SUPL: + serverType = LOC_AGPS_SUPL_SERVER; + break; + case AGPS_TYPE_C2K: + serverType = LOC_AGPS_CDMA_PDE_SERVER; + break; + default: + serverType = LOC_AGPS_SUPL_SERVER; + } + int ret_val = loc_eng_set_server_proxy(loc_afw_data, serverType, hostname, port); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTIONf571 + loc_xtra_init + +DESCRIPTION + Initialize XTRA module. + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_xtra_init(GpsXtraCallbacks* callbacks) +{ + ENTRY_LOG(); + GpsXtraExtCallbacks extCallbacks; + memset(&extCallbacks, 0, sizeof(extCallbacks)); + extCallbacks.download_request_cb = callbacks->download_request_cb; + int ret_val = loc_eng_xtra_init(loc_afw_data, &extCallbacks); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + + +/*=========================================================================== +FUNCTION loc_xtra_inject_data + +DESCRIPTION + Initialize XTRA module. + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_xtra_inject_data(char* data, int length) +{ + ENTRY_LOG(); + int ret_val = -1; + if( (data != NULL) && ((unsigned int)length <= XTRA_DATA_MAX_SIZE)) + ret_val = loc_eng_xtra_inject_data(loc_afw_data, data, length); + else + LOC_LOGE("%s, Could not inject XTRA data. Buffer address: %p, length: %d", + __func__, data, length); + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_gps_measurement_init + +DESCRIPTION + This function initializes the gps measurement interface + +DEPENDENCIES + NONE + +RETURN VALUE + None + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_gps_measurement_init(GpsMeasurementCallbacks* callbacks) +{ + ENTRY_LOG(); + int ret_val = loc_eng_gps_measurement_init(loc_afw_data, + callbacks); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_gps_measurement_close + +DESCRIPTION + This function closes the gps measurement interface + +DEPENDENCIES + NONE + +RETURN VALUE + None + +SIDE EFFECTS + N/A + +===========================================================================*/ +static void loc_gps_measurement_close() +{ + ENTRY_LOG(); + loc_eng_gps_measurement_close(loc_afw_data); + + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== +FUNCTION loc_ni_init + +DESCRIPTION + This function initializes the NI interface + +DEPENDENCIES + NONE + +RETURN VALUE + None + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_ni_init(GpsNiCallbacks *callbacks) +{ + ENTRY_LOG(); + loc_eng_ni_init(loc_afw_data,(GpsNiExtCallbacks*) callbacks); + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== +FUNCTION loc_ni_respond + +DESCRIPTION + This function sends an NI respond to the modem processor + +DEPENDENCIES + NONE + +RETURN VALUE + None + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_ni_respond(int notif_id, GpsUserResponseType user_response) +{ + ENTRY_LOG(); + loc_eng_ni_respond(loc_afw_data, notif_id, user_response); + EXIT_LOG(%s, VOID_RET); +} + +// Below stub functions are members of sLocEngAGpsRilInterface +static void loc_agps_ril_init( AGpsRilCallbacks* callbacks ) {} +static void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct) {} +static void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid) {} +static void loc_agps_ril_ni_message(uint8_t *msg, size_t len) {} +static void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info) {} + +/*=========================================================================== +FUNCTION loc_agps_ril_update_network_availability + +DESCRIPTION + Sets data call allow vs disallow flag to modem + This is the only member of sLocEngAGpsRilInterface implemented. + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +static void loc_agps_ril_update_network_availability(int available, const char* apn) +{ + ENTRY_LOG(); + loc_eng_agps_ril_update_network_availability(loc_afw_data, available, apn); + EXIT_LOG(%s, VOID_RET); +} + +static int loc_agps_install_certificates(const DerEncodedCertificate* certificates, + size_t length) +{ + ENTRY_LOG(); + int ret_val = loc_eng_agps_install_certificates(loc_afw_data, certificates, length); + EXIT_LOG(%d, ret_val); + return ret_val; +} +static int loc_agps_revoke_certificates(const Sha1CertificateFingerprint* fingerprints, + size_t length) +{ + ENTRY_LOG(); + LOC_LOGE("%s:%d]: agps_revoke_certificates not supported"); + int ret_val = AGPS_CERTIFICATE_ERROR_GENERIC; + EXIT_LOG(%d, ret_val); + return ret_val; +} + +static void loc_configuration_update(const char* config_data, int32_t length) +{ + ENTRY_LOG(); + loc_eng_configuration_update(loc_afw_data, config_data, length); + switch (sGnssType) + { + case GNSS_GSS: + case GNSS_AUTO: + case GNSS_QCA1530: + //APQ + gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); + break; + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_loc_cb(UlpLocation* location, void* locExt) +{ + ENTRY_LOG(); + if (NULL != location) { + CALLBACK_LOG_CALLFLOW("location_cb - from", %d, location->position_source); + + if (NULL != gps_loc_cb) { + gps_loc_cb(&location->gpsLocation); + } + } + EXIT_LOG(%s, VOID_RET); +} + +static void local_sv_cb(GpsSvStatus* sv_status, void* svExt) +{ + ENTRY_LOG(); + if (NULL != gps_sv_cb) { + CALLBACK_LOG_CALLFLOW("sv_status_cb -", %d, sv_status->num_svs); + gps_sv_cb(sv_status); + } + EXIT_LOG(%s, VOID_RET); +} + diff --git a/gps/loc_api/libloc_api_50001/loc.h b/gps/loc_api/libloc_api_50001/loc.h new file mode 100644 index 0000000..e56fdcf --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc.h @@ -0,0 +1,66 @@ +/* Copyright (c) 2011,2014 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __LOC_H__ +#define __LOC_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include +#include +#include + +#define XTRA_DATA_MAX_SIZE 100000 /*bytes*/ + +typedef void (*loc_location_cb_ext) (UlpLocation* location, void* locExt); +typedef void (*loc_sv_status_cb_ext) (GpsSvStatus* sv_status, void* svExt); +typedef void* (*loc_ext_parser)(void* data); + +typedef struct { + loc_location_cb_ext location_cb; + gps_status_callback status_cb; + loc_sv_status_cb_ext sv_status_cb; + gps_nmea_callback nmea_cb; + gps_set_capabilities set_capabilities_cb; + gps_acquire_wakelock acquire_wakelock_cb; + gps_release_wakelock release_wakelock_cb; + gps_create_thread create_thread_cb; + loc_ext_parser location_ext_parser; + loc_ext_parser sv_ext_parser; + gps_request_utc_time request_utc_time_cb; +} LocCallbacks; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif //__LOC_H__ diff --git a/gps/loc_api/libloc_api_50001/loc_eng.cpp b/gps/loc_api/libloc_api_50001/loc_eng.cpp new file mode 100644 index 0000000..ef7011e --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng.cpp @@ -0,0 +1,2999 @@ +/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_eng" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* struct sockaddr_in */ +#include +#include +#include +#include +#include +#include + +#include +#ifndef USE_GLIB +#include +#include +#endif /* USE_GLIB */ + +#ifdef USE_GLIB +#include +#include +#endif /* USE_GLIB */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include "log_util.h" +#include "platform_lib_includes.h" +#include "loc_core_log.h" +#include "loc_eng_log.h" + +#define SUCCESS TRUE +#define FAILURE FALSE + +#ifndef GPS_CONF_FILE +#define GPS_CONF_FILE "/etc/gps.conf" //??? platform independent +#endif + +#ifndef SAP_CONF_FILE +#define SAP_CONF_FILE "/etc/sap.conf" +#endif + +#define XTRA1_GPSONEXTRA "xtra1.gpsonextra.net" + +using namespace loc_core; + +boolean configAlreadyRead = false; +unsigned int agpsStatus = 0; +loc_gps_cfg_s_type gps_conf; +loc_sap_cfg_s_type sap_conf; + +/* Parameter spec table */ +static loc_param_s_type gps_conf_table[] = +{ + {"GPS_LOCK", &gps_conf.GPS_LOCK, NULL, 'n'}, + {"SUPL_VER", &gps_conf.SUPL_VER, NULL, 'n'}, + {"LPP_PROFILE", &gps_conf.LPP_PROFILE, NULL, 'n'}, + {"A_GLONASS_POS_PROTOCOL_SELECT", &gps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'}, + {"AGPS_CERT_WRITABLE_MASK", &gps_conf.AGPS_CERT_WRITABLE_MASK, NULL, 'n'}, + {"SUPL_MODE", &gps_conf.SUPL_MODE, NULL, 'n'}, + {"INTERMEDIATE_POS", &gps_conf.INTERMEDIATE_POS, NULL, 'n'}, + {"ACCURACY_THRES", &gps_conf.ACCURACY_THRES, NULL, 'n'}, + {"NMEA_PROVIDER", &gps_conf.NMEA_PROVIDER, NULL, 'n'}, + {"CAPABILITIES", &gps_conf.CAPABILITIES, NULL, 'n'}, + {"XTRA_VERSION_CHECK", &gps_conf.XTRA_VERSION_CHECK, NULL, 'n'}, + {"XTRA_SERVER_1", &gps_conf.XTRA_SERVER_1, NULL, 's'}, + {"XTRA_SERVER_2", &gps_conf.XTRA_SERVER_2, NULL, 's'}, + {"XTRA_SERVER_3", &gps_conf.XTRA_SERVER_3, NULL, 's'}, + {"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL", &gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'}, +}; + +static loc_param_s_type sap_conf_table[] = +{ + {"GYRO_BIAS_RANDOM_WALK", &sap_conf.GYRO_BIAS_RANDOM_WALK, &sap_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'}, + {"ACCEL_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'}, + {"ANGLE_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'}, + {"RATE_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'}, + {"VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'}, + {"SENSOR_ACCEL_BATCHES_PER_SEC", &sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC, NULL, 'n'}, + {"SENSOR_ACCEL_SAMPLES_PER_BATCH", &sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, NULL, 'n'}, + {"SENSOR_GYRO_BATCHES_PER_SEC", &sap_conf.SENSOR_GYRO_BATCHES_PER_SEC, NULL, 'n'}, + {"SENSOR_GYRO_SAMPLES_PER_BATCH", &sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH, NULL, 'n'}, + {"SENSOR_ACCEL_BATCHES_PER_SEC_HIGH", &sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, NULL, 'n'}, + {"SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH", &sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, NULL, 'n'}, + {"SENSOR_GYRO_BATCHES_PER_SEC_HIGH", &sap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, NULL, 'n'}, + {"SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH", &sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, NULL, 'n'}, + {"SENSOR_CONTROL_MODE", &sap_conf.SENSOR_CONTROL_MODE, NULL, 'n'}, + {"SENSOR_USAGE", &sap_conf.SENSOR_USAGE, NULL, 'n'}, + {"SENSOR_ALGORITHM_CONFIG_MASK", &sap_conf.SENSOR_ALGORITHM_CONFIG_MASK, NULL, 'n'}, + {"SENSOR_PROVIDER", &sap_conf.SENSOR_PROVIDER, NULL, 'n'} +}; + +static void loc_default_parameters(void) +{ + /*Defaults for gps.conf*/ + gps_conf.INTERMEDIATE_POS = 0; + gps_conf.ACCURACY_THRES = 0; + gps_conf.NMEA_PROVIDER = 0; + gps_conf.GPS_LOCK = 0; + gps_conf.SUPL_VER = 0x10000; + gps_conf.SUPL_MODE = 0x3; + gps_conf.CAPABILITIES = 0x7; + /* LTE Positioning Profile configuration is disable by default*/ + gps_conf.LPP_PROFILE = 0; + /*By default no positioning protocol is selected on A-GLONASS system*/ + gps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0; + /*XTRA version check is disabled by default*/ + gps_conf.XTRA_VERSION_CHECK=0; + /*Use emergency PDN by default*/ + gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = 1; + + /*Defaults for sap.conf*/ + sap_conf.GYRO_BIAS_RANDOM_WALK = 0; + sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC = 2; + sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH = 5; + sap_conf.SENSOR_GYRO_BATCHES_PER_SEC = 2; + sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH = 5; + sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH = 4; + sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH = 25; + sap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH = 4; + sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH = 25; + sap_conf.SENSOR_CONTROL_MODE = 0; /* AUTO */ + sap_conf.SENSOR_USAGE = 0; /* Enabled */ + sap_conf.SENSOR_ALGORITHM_CONFIG_MASK = 0; /* INS Disabled = FALSE*/ + /* Values MUST be set by OEMs in configuration for sensor-assisted + navigation to work. There are NO default values */ + sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY = 0; + sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY = 0; + sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY = 0; + sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY = 0; + sap_conf.GYRO_BIAS_RANDOM_WALK_VALID = 0; + sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; + sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; + sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; + sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0; + /* default provider is SSC */ + sap_conf.SENSOR_PROVIDER = 1; + + /* None of the 10 slots for agps certificates are writable by default */ + gps_conf.AGPS_CERT_WRITABLE_MASK = 0; +} + +// 2nd half of init(), singled out for +// modem restart to use. +static int loc_eng_reinit(loc_eng_data_s_type &loc_eng_data); +static void loc_eng_agps_reinit(loc_eng_data_s_type &loc_eng_data); + +static int loc_eng_set_server(loc_eng_data_s_type &loc_eng_data, + LocServerType type, const char *hostname, int port); +// Internal functions +static void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data, + GpsStatusValue status); +static void loc_eng_report_status(loc_eng_data_s_type &loc_eng_data, + GpsStatusValue status); +static void loc_eng_process_conn_request(loc_eng_data_s_type &loc_eng_data, + int connHandle, AGpsType agps_type); +static void loc_eng_agps_close_status(loc_eng_data_s_type &loc_eng_data, int is_succ); +static void loc_eng_handle_engine_down(loc_eng_data_s_type &loc_eng_data) ; +static void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data) ; + +static int loc_eng_start_handler(loc_eng_data_s_type &loc_eng_data); +static int loc_eng_stop_handler(loc_eng_data_s_type &loc_eng_data); +static int loc_eng_get_zpp_handler(loc_eng_data_s_type &loc_eng_data); +static void deleteAidingData(loc_eng_data_s_type &logEng); +static AgpsStateMachine* +getAgpsStateMachine(loc_eng_data_s_type& logEng, AGpsExtType agpsType); +static int dataCallCb(void *cb_data); +static void update_aiding_data_for_deletion(loc_eng_data_s_type& loc_eng_data) { + if (loc_eng_data.engine_status != GPS_STATUS_ENGINE_ON && + loc_eng_data.aiding_data_for_deletion != 0) + { + loc_eng_data.adapter->deleteAidingData(loc_eng_data.aiding_data_for_deletion); + loc_eng_data.aiding_data_for_deletion = 0; + } +} + +static void* noProc(void* data) +{ + return NULL; +} + +/********************************************************************* + * definitions of the static messages used in the file + *********************************************************************/ +// case LOC_ENG_MSG_REQUEST_NI: +LocEngRequestNi::LocEngRequestNi(void* locEng, + GpsNiNotification ¬if, + const void* data) : + LocMsg(), mLocEng(locEng), mNotify(notif), mPayload(data) { + locallog(); +} +void LocEngRequestNi::proc() const { + loc_eng_ni_request_handler(*((loc_eng_data_s_type*)mLocEng), + &mNotify, mPayload); +} +void LocEngRequestNi::locallog() const +{ + LOC_LOGV("id: %d\n type: %s\n flags: %d\n time out: %d\n " + "default response: %s\n requestor id encoding: %s\n" + " text encoding: %s\n passThroughData: %p", + mNotify.notification_id, + loc_get_ni_type_name(mNotify.ni_type), + mNotify.notify_flags, + mNotify.timeout, + loc_get_ni_response_name(mNotify.default_response), + loc_get_ni_encoding_name(mNotify.requestor_id_encoding), + loc_get_ni_encoding_name(mNotify.text_encoding), + mPayload); +} +inline void LocEngRequestNi::log() const { + locallog(); +} + +// case LOC_ENG_MSG_INFORM_NI_RESPONSE: +// in loc_eng_ni.cpp + +// case LOC_ENG_MSG_START_FIX: +LocEngStartFix::LocEngStartFix(LocEngAdapter* adapter) : + LocMsg(), mAdapter(adapter) +{ + locallog(); +} +inline void LocEngStartFix::proc() const +{ + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mAdapter->getOwner(); + loc_eng_start_handler(*locEng); +} +inline void LocEngStartFix::locallog() const +{ + LOC_LOGV("LocEngStartFix"); +} +inline void LocEngStartFix::log() const +{ + locallog(); +} +void LocEngStartFix::send() const { + mAdapter->sendMsg(this); +} + +// case LOC_ENG_MSG_STOP_FIX: +LocEngStopFix::LocEngStopFix(LocEngAdapter* adapter) : + LocMsg(), mAdapter(adapter) +{ + locallog(); +} +inline void LocEngStopFix::proc() const +{ + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mAdapter->getOwner(); + loc_eng_stop_handler(*locEng); +} +inline void LocEngStopFix::locallog() const +{ + LOC_LOGV("LocEngStopFix"); +} +inline void LocEngStopFix::log() const +{ + locallog(); +} +void LocEngStopFix::send() const { + mAdapter->sendMsg(this); +} + +// case LOC_ENG_MSG_SET_POSITION_MODE: +LocEngPositionMode::LocEngPositionMode(LocEngAdapter* adapter, + LocPosMode &mode) : + LocMsg(), mAdapter(adapter), mPosMode(mode) +{ + mPosMode.logv(); +} +inline void LocEngPositionMode::proc() const { + mAdapter->setPositionMode(&mPosMode); +} +inline void LocEngPositionMode::log() const { + mPosMode.logv(); +} +void LocEngPositionMode::send() const { + mAdapter->sendMsg(this); +} + +LocEngGetZpp::LocEngGetZpp(LocEngAdapter* adapter) : + LocMsg(), mAdapter(adapter) +{ + locallog(); +} +inline void LocEngGetZpp::proc() const +{ + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mAdapter->getOwner(); + loc_eng_get_zpp_handler(*locEng); +} +inline void LocEngGetZpp::locallog() const +{ + LOC_LOGV("LocEngGetZpp"); +} +inline void LocEngGetZpp::log() const +{ + locallog(); +} +void LocEngGetZpp::send() const { + mAdapter->sendMsg(this); +} + +struct LocEngSetTime : public LocMsg { + LocEngAdapter* mAdapter; + const GpsUtcTime mTime; + const int64_t mTimeReference; + const int mUncertainty; + inline LocEngSetTime(LocEngAdapter* adapter, + GpsUtcTime t, int64_t tf, int unc) : + LocMsg(), mAdapter(adapter), + mTime(t), mTimeReference(tf), mUncertainty(unc) + { + locallog(); + } + inline virtual void proc() const { + mAdapter->setTime(mTime, mTimeReference, mUncertainty); + } + inline void locallog() const { + LOC_LOGV("time: %lld\n timeReference: %lld\n uncertainty: %d", + mTime, mTimeReference, mUncertainty); + } + inline virtual void log() const { + locallog(); + } +}; + + // case LOC_ENG_MSG_INJECT_LOCATION: +struct LocEngInjectLocation : public LocMsg { + LocEngAdapter* mAdapter; + const double mLatitude; + const double mLongitude; + const float mAccuracy; + inline LocEngInjectLocation(LocEngAdapter* adapter, + double lat, double lon, float accur) : + LocMsg(), mAdapter(adapter), + mLatitude(lat), mLongitude(lon), mAccuracy(accur) + { + locallog(); + } + inline virtual void proc() const { + mAdapter->injectPosition(mLatitude, mLongitude, mAccuracy); + } + inline void locallog() const { + LOC_LOGV("latitude: %f\n longitude: %f\n accuracy: %f", + mLatitude, mLongitude, mAccuracy); + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_SET_SERVER_IPV4: +struct LocEngSetServerIpv4 : public LocMsg { + LocEngAdapter* mAdapter; + const unsigned int mNlAddr; + const int mPort; + const LocServerType mServerType; + inline LocEngSetServerIpv4(LocEngAdapter* adapter, + unsigned int ip, + int port, + LocServerType type) : + LocMsg(), mAdapter(adapter), + mNlAddr(ip), mPort(port), mServerType(type) + { + locallog(); + } + inline virtual void proc() const { + mAdapter->setServer(mNlAddr, mPort, mServerType); + } + inline void locallog() const { + LOC_LOGV("LocEngSetServerIpv4 - addr: %x, port: %d, type: %s", + mNlAddr, mPort, loc_get_server_type_name(mServerType)); + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_SET_SERVER_URL: +struct LocEngSetServerUrl : public LocMsg { + LocEngAdapter* mAdapter; + const int mLen; + char* mUrl; + inline LocEngSetServerUrl(LocEngAdapter* adapter, + char* urlString, + int url_len) : + LocMsg(), mAdapter(adapter), + mLen(url_len), mUrl(new char[mLen+1]) + { + memcpy((void*)mUrl, (void*)urlString, url_len); + mUrl[mLen] = 0; + locallog(); + } + inline ~LocEngSetServerUrl() + { + delete[] mUrl; + } + inline virtual void proc() const { + mAdapter->setServer(mUrl, mLen); + } + inline void locallog() const { + LOC_LOGV("LocEngSetServerUrl - url: %s", mUrl); + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_A_GLONASS_PROTOCOL: +struct LocEngAGlonassProtocol : public LocMsg { + LocEngAdapter* mAdapter; + const unsigned long mAGlonassProtocl; + inline LocEngAGlonassProtocol(LocEngAdapter* adapter, + unsigned long protocol) : + LocMsg(), mAdapter(adapter), mAGlonassProtocl(protocol) + { + locallog(); + } + inline virtual void proc() const { + mAdapter->setAGLONASSProtocol(mAGlonassProtocl); + } + inline void locallog() const { + LOC_LOGV("A-GLONASS protocol: 0x%lx", mAGlonassProtocl); + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_SUPL_VERSION: +struct LocEngSuplVer : public LocMsg { + LocEngAdapter* mAdapter; + const int mSuplVer; + inline LocEngSuplVer(LocEngAdapter* adapter, + int suplVer) : + LocMsg(), mAdapter(adapter), mSuplVer(suplVer) + { + locallog(); + } + inline virtual void proc() const { + mAdapter->setSUPLVersion(mSuplVer); + } + inline void locallog() const { + LOC_LOGV("SUPL Version: %d", mSuplVer); + } + inline virtual void log() const { + locallog(); + } +}; + +struct LocEngSuplMode : public LocMsg { + UlpProxyBase* mUlp; + + inline LocEngSuplMode(UlpProxyBase* ulp) : + LocMsg(), mUlp(ulp) + { + locallog(); + } + inline virtual void proc() const { + mUlp->setCapabilities(getCarrierCapabilities()); + } + inline void locallog() const { + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_LPP_CONFIG: +struct LocEngLppConfig : public LocMsg { + LocEngAdapter* mAdapter; + const int mLppConfig; + inline LocEngLppConfig(LocEngAdapter* adapter, + int lppConfig) : + LocMsg(), mAdapter(adapter), mLppConfig(lppConfig) + { + locallog(); + } + inline virtual void proc() const { + mAdapter->setLPPConfig(mLppConfig); + } + inline void locallog() const { + LOC_LOGV("LocEngLppConfig - profile: %d", mLppConfig); + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_SET_SENSOR_CONTROL_CONFIG: +struct LocEngSensorControlConfig : public LocMsg { + LocEngAdapter* mAdapter; + const int mSensorsDisabled; + const int mSensorProvider; + inline LocEngSensorControlConfig(LocEngAdapter* adapter, + int sensorsDisabled, int sensorProvider) : + LocMsg(), mAdapter(adapter), mSensorsDisabled(sensorsDisabled), + mSensorProvider(sensorProvider) + { + locallog(); + } + inline virtual void proc() const { + mAdapter->setSensorControlConfig(mSensorsDisabled, mSensorProvider); + } + inline void locallog() const { + LOC_LOGV("LocEngSensorControlConfig - Sensors Disabled: %d, Sensor Provider: %d", + mSensorsDisabled, mSensorProvider); + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_SET_SENSOR_PROPERTIES: +struct LocEngSensorProperties : public LocMsg { + LocEngAdapter* mAdapter; + const bool mGyroBiasVarianceRandomWalkValid; + const float mGyroBiasVarianceRandomWalk; + const bool mAccelRandomWalkValid; + const float mAccelRandomWalk; + const bool mAngleRandomWalkValid; + const float mAngleRandomWalk; + const bool mRateRandomWalkValid; + const float mRateRandomWalk; + const bool mVelocityRandomWalkValid; + const float mVelocityRandomWalk; + inline LocEngSensorProperties(LocEngAdapter* adapter, + bool gyroBiasRandomWalk_valid, + float gyroBiasRandomWalk, + bool accelRandomWalk_valid, + float accelRandomWalk, + bool angleRandomWalk_valid, + float angleRandomWalk, + bool rateRandomWalk_valid, + float rateRandomWalk, + bool velocityRandomWalk_valid, + float velocityRandomWalk) : + LocMsg(), mAdapter(adapter), + mGyroBiasVarianceRandomWalkValid(gyroBiasRandomWalk_valid), + mGyroBiasVarianceRandomWalk(gyroBiasRandomWalk), + mAccelRandomWalkValid(accelRandomWalk_valid), + mAccelRandomWalk(accelRandomWalk), + mAngleRandomWalkValid(angleRandomWalk_valid), + mAngleRandomWalk(angleRandomWalk), + mRateRandomWalkValid(rateRandomWalk_valid), + mRateRandomWalk(rateRandomWalk), + mVelocityRandomWalkValid(velocityRandomWalk_valid), + mVelocityRandomWalk(velocityRandomWalk) + { + locallog(); + } + inline virtual void proc() const { + mAdapter->setSensorProperties(mGyroBiasVarianceRandomWalkValid, + mGyroBiasVarianceRandomWalk, + mAccelRandomWalkValid, + mAccelRandomWalk, + mAngleRandomWalkValid, + mAngleRandomWalk, + mRateRandomWalkValid, + mRateRandomWalk, + mVelocityRandomWalkValid, + mVelocityRandomWalk); + } + inline void locallog() const { + LOC_LOGV("Sensor properties validity, Gyro Random walk: %d " + "Accel Random Walk: %d " + "Angle Random Walk: %d Rate Random Walk: %d " + "Velocity Random Walk: %d\n" + "Sensor properties, Gyro Random walk: %f " + "Accel Random Walk: %f " + "Angle Random Walk: %f Rate Random Walk: %f " + "Velocity Random Walk: %f", + mGyroBiasVarianceRandomWalkValid, + mAccelRandomWalkValid, + mAngleRandomWalkValid, + mRateRandomWalkValid, + mVelocityRandomWalkValid, + mGyroBiasVarianceRandomWalk, + mAccelRandomWalk, + mAngleRandomWalk, + mRateRandomWalk, + mVelocityRandomWalk + ); + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_SET_SENSOR_PERF_CONTROL_CONFIG: +struct LocEngSensorPerfControlConfig : public LocMsg { + LocEngAdapter* mAdapter; + const int mControlMode; + const int mAccelSamplesPerBatch; + const int mAccelBatchesPerSec; + const int mGyroSamplesPerBatch; + const int mGyroBatchesPerSec; + const int mAccelSamplesPerBatchHigh; + const int mAccelBatchesPerSecHigh; + const int mGyroSamplesPerBatchHigh; + const int mGyroBatchesPerSecHigh; + const int mAlgorithmConfig; + inline LocEngSensorPerfControlConfig(LocEngAdapter* adapter, + int controlMode, + int accelSamplesPerBatch, + int accelBatchesPerSec, + int gyroSamplesPerBatch, + int gyroBatchesPerSec, + int accelSamplesPerBatchHigh, + int accelBatchesPerSecHigh, + int gyroSamplesPerBatchHigh, + int gyroBatchesPerSecHigh, + int algorithmConfig) : + LocMsg(), mAdapter(adapter), + mControlMode(controlMode), + mAccelSamplesPerBatch(accelSamplesPerBatch), + mAccelBatchesPerSec(accelBatchesPerSec), + mGyroSamplesPerBatch(gyroSamplesPerBatch), + mGyroBatchesPerSec(gyroBatchesPerSec), + mAccelSamplesPerBatchHigh(accelSamplesPerBatchHigh), + mAccelBatchesPerSecHigh(accelBatchesPerSecHigh), + mGyroSamplesPerBatchHigh(gyroSamplesPerBatchHigh), + mGyroBatchesPerSecHigh(gyroBatchesPerSecHigh), + mAlgorithmConfig(algorithmConfig) + { + locallog(); + } + inline virtual void proc() const { + mAdapter->setSensorPerfControlConfig(mControlMode, + mAccelSamplesPerBatch, + mAccelBatchesPerSec, + mGyroSamplesPerBatch, + mGyroBatchesPerSec, + mAccelSamplesPerBatchHigh, + mAccelBatchesPerSecHigh, + mGyroSamplesPerBatchHigh, + mGyroBatchesPerSecHigh, + mAlgorithmConfig); + } + inline void locallog() const { + LOC_LOGV("Sensor Perf Control Config (performanceControlMode)(%u) " + "accel(#smp,#batches) (%u,%u) " + "gyro(#smp,#batches) (%u,%u), " + "accel_high(#smp,#batches) (%u,%u) " + "gyro_high(#smp,#batches) (%u,%u), " + "algorithmConfig(%u)\n", + mControlMode, + mAccelSamplesPerBatch, mAccelBatchesPerSec, + mGyroSamplesPerBatch, mGyroBatchesPerSec, + mAccelSamplesPerBatchHigh, mAccelBatchesPerSecHigh, + mGyroSamplesPerBatchHigh, mGyroBatchesPerSecHigh, + mAlgorithmConfig); + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_EXT_POWER_CONFIG: +struct LocEngExtPowerConfig : public LocMsg { + LocEngAdapter* mAdapter; + const int mIsBatteryCharging; + inline LocEngExtPowerConfig(LocEngAdapter* adapter, + int isBatteryCharging) : + LocMsg(), mAdapter(adapter), + mIsBatteryCharging(isBatteryCharging) + { + locallog(); + } + inline virtual void proc() const { + mAdapter->setExtPowerConfig(mIsBatteryCharging); + } + inline void locallog() const { + LOC_LOGV("LocEngExtPowerConfig - isBatteryCharging: %d", + mIsBatteryCharging); + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_REPORT_POSITION: +LocEngReportPosition::LocEngReportPosition(LocAdapterBase* adapter, + UlpLocation &loc, + GpsLocationExtended &locExtended, + void* locExt, + enum loc_sess_status st, + LocPosTechMask technology) : + LocMsg(), mAdapter(adapter), mLocation(loc), + mLocationExtended(locExtended), + mLocationExt(((loc_eng_data_s_type*) + ((LocEngAdapter*) + (mAdapter))->getOwner())->location_ext_parser(locExt)), + mStatus(st), mTechMask(technology) +{ + locallog(); +} +void LocEngReportPosition::proc() const { + LocEngAdapter* adapter = (LocEngAdapter*)mAdapter; + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)adapter->getOwner(); + + if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION) { + bool reported = false; + if (locEng->location_cb != NULL) { + if (LOC_SESS_FAILURE == mStatus) { + // in case we want to handle the failure case + locEng->location_cb(NULL, NULL); + reported = true; + } + // what's in the else if is... (line by line) + // 1. this is a final fix; and + // 1.1 it is a Satellite fix; or + // 1.2 it is a sensor fix + // 2. (must be intermediate fix... implicit) + // 2.1 we accepte intermediate; and + // 2.2 it is NOT the case that + // 2.2.1 there is inaccuracy; and + // 2.2.2 we care about inaccuracy; and + // 2.2.3 the inaccuracy exceeds our tolerance + else if ((LOC_SESS_SUCCESS == mStatus && + ((LOC_POS_TECH_MASK_SATELLITE | + LOC_POS_TECH_MASK_SENSORS | + LOC_POS_TECH_MASK_HYBRID) & + mTechMask)) || + (LOC_SESS_INTERMEDIATE == locEng->intermediateFix && + !((mLocation.gpsLocation.flags & + GPS_LOCATION_HAS_ACCURACY) && + (gps_conf.ACCURACY_THRES != 0) && + (mLocation.gpsLocation.accuracy > + gps_conf.ACCURACY_THRES)))) { + locEng->location_cb((UlpLocation*)&(mLocation), + (void*)mLocationExt); + reported = true; + } + } + + // if we have reported this fix + if (reported && + // and if this is a singleshot + GPS_POSITION_RECURRENCE_SINGLE == + locEng->adapter->getPositionMode().recurrence) { + if (LOC_SESS_INTERMEDIATE == mStatus) { + // modem could be still working for a final fix, + // although we no longer need it. So stopFix(). + locEng->adapter->stopFix(); + } + // turn off the session flag. + locEng->adapter->setInSession(false); + } + + LOC_LOGV("LocEngReportPosition::proc() - generateNmea: %d, position source: %d, " + "engine_status: %d, isInSession: %d", + locEng->generateNmea, mLocation.position_source, + locEng->engine_status, locEng->adapter->isInSession()); + + if (locEng->generateNmea && + locEng->adapter->isInSession()) + { + unsigned char generate_nmea = reported && + (mStatus != LOC_SESS_FAILURE); + loc_eng_nmea_generate_pos(locEng, mLocation, mLocationExtended, + generate_nmea); + } + + // Free the allocated memory for rawData + UlpLocation* gp = (UlpLocation*)&(mLocation); + if (gp != NULL && gp->rawData != NULL) + { + delete (char*)gp->rawData; + gp->rawData = NULL; + gp->rawDataSize = 0; + } + } +} +void LocEngReportPosition::locallog() const { + LOC_LOGV("LocEngReportPosition"); +} +void LocEngReportPosition::log() const { + locallog(); +} +void LocEngReportPosition::send() const { + mAdapter->sendMsg(this); +} + + +// case LOC_ENG_MSG_REPORT_SV: +LocEngReportSv::LocEngReportSv(LocAdapterBase* adapter, + QcomSvStatus &sv, + GpsLocationExtended &locExtended, + void* svExt) : + LocMsg(), mAdapter(adapter), mSvStatus(sv), + mLocationExtended(locExtended), + mSvExt(((loc_eng_data_s_type*) + ((LocEngAdapter*) + (mAdapter))->getOwner())->sv_ext_parser(svExt)) +{ + locallog(); +} +void LocEngReportSv::proc() const { + LocEngAdapter* adapter = (LocEngAdapter*)mAdapter; + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)adapter->getOwner(); + + if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION) + { + if (locEng->sv_status_cb != NULL) { + locEng->sv_status_cb((GpsSvStatus*)&(mSvStatus), + (void*)mSvExt); + } + + if (locEng->generateNmea) + { + loc_eng_nmea_generate_sv(locEng, mSvStatus, mLocationExtended); + } + } +} +void LocEngReportSv::locallog() const { + LOC_LOGV("%s:%d] LocEngReportSv",__func__, __LINE__); +} +inline void LocEngReportSv::log() const { + locallog(); +} +void LocEngReportSv::send() const { + mAdapter->sendMsg(this); +} + +// case LOC_ENG_MSG_REPORT_STATUS: +LocEngReportStatus::LocEngReportStatus(LocAdapterBase* adapter, + GpsStatusValue engineStatus) : + LocMsg(), mAdapter(adapter), mStatus(engineStatus) +{ + locallog(); +} +inline void LocEngReportStatus::proc() const +{ + LocEngAdapter* adapter = (LocEngAdapter*)mAdapter; + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)adapter->getOwner(); + + loc_eng_report_status(*locEng, mStatus); + update_aiding_data_for_deletion(*locEng); +} +inline void LocEngReportStatus::locallog() const { + LOC_LOGV("LocEngReportStatus"); +} +inline void LocEngReportStatus::log() const { + locallog(); +} + +// case LOC_ENG_MSG_REPORT_NMEA: +LocEngReportNmea::LocEngReportNmea(void* locEng, + const char* data, int len) : + LocMsg(), mLocEng(locEng), mNmea(new char[len+1]), mLen(len) +{ + strlcpy(mNmea, data, len+1); + locallog(); +} +void LocEngReportNmea::proc() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*) mLocEng; + + struct timeval tv; + gettimeofday(&tv, (struct timezone *) NULL); + int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000; + + if (locEng->nmea_cb != NULL) + locEng->nmea_cb(now, mNmea, mLen); +} +inline void LocEngReportNmea::locallog() const { + LOC_LOGV("LocEngReportNmea"); +} +inline void LocEngReportNmea::log() const { + locallog(); +} + +// case LOC_ENG_MSG_REPORT_XTRA_SERVER: +LocEngReportXtraServer::LocEngReportXtraServer(void* locEng, + const char *url1, + const char *url2, + const char *url3, + const int maxlength) : + LocMsg(), mLocEng(locEng), mMaxLen(maxlength), + mServers(new char[3*(mMaxLen+1)]) +{ + char * cptr = mServers; + memset(mServers, 0, 3*(mMaxLen+1)); + + // Override modem URLs with uncommented gps.conf urls + if( gps_conf.XTRA_SERVER_1[0] != '\0' ) { + url1 = &gps_conf.XTRA_SERVER_1[0]; + } + if( gps_conf.XTRA_SERVER_2[0] != '\0' ) { + url2 = &gps_conf.XTRA_SERVER_2[0]; + } + if( gps_conf.XTRA_SERVER_3[0] != '\0' ) { + url3 = &gps_conf.XTRA_SERVER_3[0]; + } + // copy non xtra1.gpsonextra.net URLs into the forwarding buffer. + if( NULL == strcasestr(url1, XTRA1_GPSONEXTRA) ) { + strlcpy(cptr, url1, mMaxLen + 1); + cptr += mMaxLen + 1; + } + if( NULL == strcasestr(url2, XTRA1_GPSONEXTRA) ) { + strlcpy(cptr, url2, mMaxLen + 1); + cptr += mMaxLen + 1; + } + if( NULL == strcasestr(url3, XTRA1_GPSONEXTRA) ) { + strlcpy(cptr, url3, mMaxLen + 1); + } + locallog(); +} + +void LocEngReportXtraServer::proc() const { + loc_eng_xtra_data_s_type* locEngXtra = + &(((loc_eng_data_s_type*)mLocEng)->xtra_module_data); + + if (locEngXtra->report_xtra_server_cb != NULL) { + CALLBACK_LOG_CALLFLOW("report_xtra_server_cb", %s, mServers); + locEngXtra->report_xtra_server_cb(mServers, + &(mServers[mMaxLen+1]), + &(mServers[(mMaxLen+1)<<1])); + } else { + LOC_LOGE("Callback function for request xtra is NULL"); + } +} +inline void LocEngReportXtraServer::locallog() const { + LOC_LOGV("LocEngReportXtraServers: server1: %s\n server2: %s\n" + " server3: %s\n", + mServers, &mServers[mMaxLen+1], &mServers[(mMaxLen+1)<<1]); +} +inline void LocEngReportXtraServer::log() const { + locallog(); +} + +// case LOC_ENG_MSG_REQUEST_BIT: +// case LOC_ENG_MSG_RELEASE_BIT: +LocEngReqRelBIT::LocEngReqRelBIT(void* locEng, AGpsExtType type, + int ipv4, char* ipv6, bool isReq) : + LocMsg(), mLocEng(locEng), mType(type), mIPv4Addr(ipv4), + mIPv6Addr(ipv6 ? new char[16] : NULL), mIsReq(isReq) { + if (NULL != ipv6) + memcpy(mIPv6Addr, ipv6, 16); + locallog(); +} +inline LocEngReqRelBIT::~LocEngReqRelBIT() { + if (mIPv6Addr) { + delete[] mIPv6Addr; + } +} +void LocEngReqRelBIT::proc() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; + BITSubscriber s(getAgpsStateMachine(*locEng, mType), + mIPv4Addr, mIPv6Addr); + AgpsStateMachine* sm = (AgpsStateMachine*)s.mStateMachine; + + if (mIsReq) { + sm->subscribeRsrc((Subscriber*)&s); + } else { + sm->unsubscribeRsrc((Subscriber*)&s); + } +} +inline void LocEngReqRelBIT::locallog() const { + LOC_LOGV("LocEngRequestBIT - ipv4: %d.%d.%d.%d, ipv6: %s", + (unsigned char)mIPv4Addr, + (unsigned char)(mIPv4Addr>>8), + (unsigned char)(mIPv4Addr>>16), + (unsigned char)(mIPv4Addr>>24), + NULL != mIPv6Addr ? mIPv6Addr : ""); +} +inline void LocEngReqRelBIT::log() const { + locallog(); +} +void LocEngReqRelBIT::send() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; + locEng->adapter->sendMsg(this); +} + +// case LOC_ENG_MSG_RELEASE_BIT: +struct LocEngReleaseBIT : public LocMsg { + const BITSubscriber mSubscriber; + inline LocEngReleaseBIT(const AgpsStateMachine* stateMachine, + unsigned int ipv4, char* ipv6) : + LocMsg(), + mSubscriber(stateMachine, ipv4, ipv6) + { + locallog(); + } + inline virtual void proc() const + { + AgpsStateMachine* sm = (AgpsStateMachine*)mSubscriber.mStateMachine; + sm->unsubscribeRsrc((Subscriber*)&mSubscriber); + } + inline void locallog() const { + LOC_LOGV("LocEngReleaseBIT - ipv4: %d.%d.%d.%d, ipv6: %s", + (unsigned char)(mSubscriber.ID>>24), + (unsigned char)(mSubscriber.ID>>16), + (unsigned char)(mSubscriber.ID>>8), + (unsigned char)mSubscriber.ID, + NULL != mSubscriber.mIPv6Addr ? mSubscriber.mIPv6Addr : ""); + } + virtual void log() const { + locallog(); + } +}; + +// LocEngSuplEsOpened +LocEngSuplEsOpened::LocEngSuplEsOpened(void* locEng) : + LocMsg(), mLocEng(locEng) { + locallog(); +} +void LocEngSuplEsOpened::proc() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; + if (locEng->ds_nif) { + AgpsStateMachine* sm = locEng->ds_nif; + sm->onRsrcEvent(RSRC_GRANTED); + } +} +void LocEngSuplEsOpened::locallog() const { + LOC_LOGV("LocEngSuplEsOpened"); +} +void LocEngSuplEsOpened::log() const { + locallog(); +} + +// LocEngSuplEsClosed +LocEngSuplEsClosed::LocEngSuplEsClosed(void* locEng) : + LocMsg(), mLocEng(locEng) { + locallog(); +} +void LocEngSuplEsClosed::proc() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; + if (locEng->ds_nif) { + AgpsStateMachine* sm = locEng->ds_nif; + sm->onRsrcEvent(RSRC_RELEASED); + } +} +void LocEngSuplEsClosed::locallog() const { + LOC_LOGV("LocEngSuplEsClosed"); +} +void LocEngSuplEsClosed::log() const { + locallog(); +} + + +// case LOC_ENG_MSG_REQUEST_SUPL_ES: +LocEngRequestSuplEs::LocEngRequestSuplEs(void* locEng, int id) : + LocMsg(), mLocEng(locEng), mID(id) { + locallog(); +} +void LocEngRequestSuplEs::proc() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; + if (locEng->ds_nif) { + AgpsStateMachine* sm = locEng->ds_nif; + DSSubscriber s(sm, mID); + sm->subscribeRsrc((Subscriber*)&s); + } + else if (locEng->agnss_nif) { + AgpsStateMachine *sm = locEng->agnss_nif; + ATLSubscriber s(mID, + sm, + locEng->adapter, + false); + sm->subscribeRsrc((Subscriber*)&s); + LOC_LOGD("%s:%d]: Using regular ATL for SUPL ES", __func__, __LINE__); + } + else { + locEng->adapter->atlOpenStatus(mID, 0, NULL, -1, -1); + } +} +inline void LocEngRequestSuplEs::locallog() const { + LOC_LOGV("LocEngRequestSuplEs"); +} +inline void LocEngRequestSuplEs::log() const { + locallog(); +} + +// case LOC_ENG_MSG_REQUEST_ATL: +LocEngRequestATL::LocEngRequestATL(void* locEng, int id, + AGpsExtType agps_type) : + LocMsg(), mLocEng(locEng), mID(id), mType(agps_type) { + locallog(); +} +void LocEngRequestATL::proc() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; + AgpsStateMachine* sm = (AgpsStateMachine*) + getAgpsStateMachine(*locEng, mType); + if (sm) { + ATLSubscriber s(mID, + sm, + locEng->adapter, + AGPS_TYPE_INVALID == mType); + sm->subscribeRsrc((Subscriber*)&s); + } else { + locEng->adapter->atlOpenStatus(mID, 0, NULL, -1, mType); + } +} +inline void LocEngRequestATL::locallog() const { + LOC_LOGV("LocEngRequestATL"); +} +inline void LocEngRequestATL::log() const { + locallog(); +} + +// case LOC_ENG_MSG_RELEASE_ATL: +LocEngReleaseATL::LocEngReleaseATL(void* locEng, int id) : + LocMsg(), mLocEng(locEng), mID(id) { + locallog(); +} +void LocEngReleaseATL::proc() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; + + if (locEng->agnss_nif) { + ATLSubscriber s1(mID, locEng->agnss_nif, locEng->adapter, false); + if (locEng->agnss_nif->unsubscribeRsrc((Subscriber*)&s1)) { + LOC_LOGD("%s:%d]: Unsubscribed from agnss_nif", + __func__, __LINE__); + return; + } + } + + if (locEng->internet_nif) { + ATLSubscriber s2(mID, locEng->internet_nif, locEng->adapter, false); + if (locEng->internet_nif->unsubscribeRsrc((Subscriber*)&s2)) { + LOC_LOGD("%s:%d]: Unsubscribed from internet_nif", + __func__, __LINE__); + return; + } + } + + if (locEng->ds_nif) { + DSSubscriber s3(locEng->ds_nif, mID); + if (locEng->ds_nif->unsubscribeRsrc((Subscriber*)&s3)) { + LOC_LOGD("%s:%d]: Unsubscribed from ds_nif", + __func__, __LINE__); + return; + } + } + + LOC_LOGW("%s:%d]: Could not release ATL. " + "No subscribers found\n", + __func__, __LINE__); + locEng->adapter->atlCloseStatus(mID, 0); +} +inline void LocEngReleaseATL::locallog() const { + LOC_LOGV("LocEngReleaseATL"); +} +inline void LocEngReleaseATL::log() const { + locallog(); +} + +// case LOC_ENG_MSG_REQUEST_WIFI: +// case LOC_ENG_MSG_RELEASE_WIFI: +LocEngReqRelWifi::LocEngReqRelWifi(void* locEng, AGpsExtType type, + loc_if_req_sender_id_e_type sender_id, + char* s, char* p, bool isReq) : + LocMsg(), mLocEng(locEng), mType(type), mSenderId(sender_id), + mSSID(NULL == s ? NULL : new char[SSID_BUF_SIZE]), + mPassword(NULL == p ? NULL : new char[SSID_BUF_SIZE]), + mIsReq(isReq) { + if (NULL != s) + strlcpy(mSSID, s, SSID_BUF_SIZE); + if (NULL != p) + strlcpy(mPassword, p, SSID_BUF_SIZE); + locallog(); +} +LocEngReqRelWifi::~LocEngReqRelWifi() { + if (NULL != mSSID) { + delete[] mSSID; + } + if (NULL != mPassword) { + delete[] mPassword; + } +} +void LocEngReqRelWifi::proc() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; + if (locEng->wifi_nif) { + WIFISubscriber s(locEng->wifi_nif, mSSID, mPassword, mSenderId); + if (mIsReq) { + locEng->wifi_nif->subscribeRsrc((Subscriber*)&s); + } else { + locEng->wifi_nif->unsubscribeRsrc((Subscriber*)&s); + } + } else { + locEng->adapter->atlOpenStatus(mSenderId, 0, NULL, -1, mType); + } +} +inline void LocEngReqRelWifi::locallog() const { + LOC_LOGV("%s - senderId: %d, ssid: %s, password: %s", + mIsReq ? "LocEngRequestWifi" : "LocEngReleaseWifi", + mSenderId, + NULL != mSSID ? mSSID : "", + NULL != mPassword ? mPassword : ""); +} +inline void LocEngReqRelWifi::log() const { + locallog(); +} +void LocEngReqRelWifi::send() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; + locEng->adapter->sendMsg(this); +} + +// case LOC_ENG_MSG_REQUEST_XTRA_DATA: +LocEngRequestXtra::LocEngRequestXtra(void* locEng) : + mLocEng(locEng) { + locallog(); +} +void LocEngRequestXtra::proc() const +{ + loc_eng_xtra_data_s_type* locEngXtra = + &(((loc_eng_data_s_type*)mLocEng)->xtra_module_data); + + if (locEngXtra->download_request_cb != NULL) { + CALLBACK_LOG_CALLFLOW("download_request_cb", %p, mLocEng); + locEngXtra->download_request_cb(); + } else { + LOC_LOGE("Callback function for request xtra is NULL"); + } +} +inline void LocEngRequestXtra::locallog() const { + LOC_LOGV("LocEngReqXtra"); +} +inline void LocEngRequestXtra::log() const { + locallog(); +} + +// case LOC_ENG_MSG_REQUEST_TIME: +LocEngRequestTime::LocEngRequestTime(void* locEng) : + LocMsg(), mLocEng(locEng) +{ + locallog(); +} +void LocEngRequestTime::proc() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; + if (gps_conf.CAPABILITIES & GPS_CAPABILITY_ON_DEMAND_TIME) { + if (locEng->request_utc_time_cb != NULL) { + locEng->request_utc_time_cb(); + } else { + LOC_LOGE("Callback function for request time is NULL"); + } + } +} +inline void LocEngRequestTime::locallog() const { + LOC_LOGV("LocEngReqTime"); +} +inline void LocEngRequestTime::log() const { + locallog(); +} + +// case LOC_ENG_MSG_DELETE_AIDING_DATA: +struct LocEngDelAidData : public LocMsg { + loc_eng_data_s_type* mLocEng; + const GpsAidingData mType; + inline LocEngDelAidData(loc_eng_data_s_type* locEng, + GpsAidingData f) : + LocMsg(), mLocEng(locEng), mType(f) + { + locallog(); + } + inline virtual void proc() const { + mLocEng->aiding_data_for_deletion = mType; + update_aiding_data_for_deletion(*mLocEng); + } + inline void locallog() const { + LOC_LOGV("aiding data msak %d", mType); + } + virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_ENABLE_DATA: +struct LocEngEnableData : public LocMsg { + LocEngAdapter* mAdapter; + const int mEnable; + char* mAPN; + const int mLen; + inline LocEngEnableData(LocEngAdapter* adapter, + const char* name, int len, int enable) : + LocMsg(), mAdapter(adapter), + mEnable(enable), mAPN(NULL), mLen(len) + { + if (NULL != name) { + mAPN = new char[len+1]; + memcpy((void*)mAPN, (void*)name, len); + mAPN[len] = 0; + } + locallog(); + } + inline ~LocEngEnableData() { + if (NULL != mAPN) { + delete[] mAPN; + } + } + inline virtual void proc() const { + mAdapter->enableData(mEnable); + if (NULL != mAPN) { + mAdapter->setAPN(mAPN, mLen); + } + } + inline void locallog() const { + LOC_LOGV("apn: %s\n enable: %d", + (NULL == mAPN) ? "NULL" : mAPN, mEnable); + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_INJECT_XTRA_DATA: +// loc_eng_xtra.cpp + +// case LOC_ENG_MSG_SET_CAPABILITIES: +struct LocEngSetCapabilities : public LocMsg { + loc_eng_data_s_type* mLocEng; + inline LocEngSetCapabilities(loc_eng_data_s_type* locEng) : + LocMsg(), mLocEng(locEng) + { + locallog(); + } + inline virtual void proc() const { + if (NULL != mLocEng->set_capabilities_cb) { + LOC_LOGV("calling set_capabilities_cb 0x%x", + gps_conf.CAPABILITIES); + mLocEng->set_capabilities_cb(gps_conf.CAPABILITIES); + } else { + LOC_LOGV("set_capabilities_cb is NULL.\n"); + } + } + inline void locallog() const + { + LOC_LOGV("LocEngSetCapabilities"); + } + inline virtual void log() const + { + locallog(); + } +}; + +// case LOC_ENG_MSG_LOC_INIT: +struct LocEngInit : public LocMsg { + loc_eng_data_s_type* mLocEng; + inline LocEngInit(loc_eng_data_s_type* locEng) : + LocMsg(), mLocEng(locEng) + { + locallog(); + } + inline virtual void proc() const { + loc_eng_reinit(*mLocEng); + // set the capabilities + mLocEng->adapter->sendMsg(new LocEngSetCapabilities(mLocEng)); + } + inline void locallog() const + { + LOC_LOGV("LocEngInit"); + } + inline virtual void log() const + { + locallog(); + } +}; + +// case LOC_ENG_MSG_REQUEST_XTRA_SERVER: +// loc_eng_xtra.cpp + +// case LOC_ENG_MSG_ATL_OPEN_SUCCESS: +struct LocEngAtlOpenSuccess : public LocMsg { + AgpsStateMachine* mStateMachine; + const int mLen; + char* mAPN; + const AGpsBearerType mBearerType; + inline LocEngAtlOpenSuccess(AgpsStateMachine* statemachine, + const char* name, + int len, + AGpsBearerType btype) : + LocMsg(), + mStateMachine(statemachine), mLen(len), + mAPN(new char[len+1]), mBearerType(btype) + { + memcpy((void*)mAPN, (void*)name, len); + mAPN[len] = 0; + locallog(); + } + inline ~LocEngAtlOpenSuccess() + { + delete[] mAPN; + } + inline virtual void proc() const { + mStateMachine->setBearer(mBearerType); + mStateMachine->setAPN(mAPN, mLen); + mStateMachine->onRsrcEvent(RSRC_GRANTED); + } + inline void locallog() const { + LOC_LOGV("LocEngAtlOpenSuccess agps type: %s\n apn: %s\n" + " bearer type: %s", + loc_get_agps_type_name(mStateMachine->getType()), + mAPN, + loc_get_agps_bear_name(mBearerType)); + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_ATL_CLOSED: +struct LocEngAtlClosed : public LocMsg { + AgpsStateMachine* mStateMachine; + inline LocEngAtlClosed(AgpsStateMachine* statemachine) : + LocMsg(), mStateMachine(statemachine) { + locallog(); + } + inline virtual void proc() const { + mStateMachine->onRsrcEvent(RSRC_RELEASED); + } + inline void locallog() const { + LOC_LOGV("LocEngAtlClosed"); + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_ATL_OPEN_FAILED: +struct LocEngAtlOpenFailed : public LocMsg { + AgpsStateMachine* mStateMachine; + inline LocEngAtlOpenFailed(AgpsStateMachine* statemachine) : + LocMsg(), mStateMachine(statemachine) { + locallog(); + } + inline virtual void proc() const { + mStateMachine->onRsrcEvent(RSRC_DENIED); + } + inline void locallog() const { + LOC_LOGV("LocEngAtlOpenFailed"); + } + inline virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_ENGINE_DOWN: +LocEngDown::LocEngDown(void* locEng) : + LocMsg(), mLocEng(locEng) { + locallog(); +} +inline void LocEngDown::proc() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; + loc_eng_handle_engine_down(*locEng); +} +inline void LocEngDown::locallog() const { + LOC_LOGV("LocEngDown"); +} +inline void LocEngDown::log() const { + locallog(); +} + +// case LOC_ENG_MSG_ENGINE_UP: +LocEngUp::LocEngUp(void* locEng) : + LocMsg(), mLocEng(locEng) { + locallog(); +} +inline void LocEngUp::proc() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; + loc_eng_handle_engine_up(*locEng); +} +inline void LocEngUp::locallog() const { + LOC_LOGV("LocEngUp"); +} +inline void LocEngUp::log() const { + locallog(); +} + +struct LocEngDataClientInit : public LocMsg { + loc_eng_data_s_type* mLocEng; + inline LocEngDataClientInit(loc_eng_data_s_type* locEng) : + LocMsg(), mLocEng(locEng) { + locallog(); + } + virtual void proc() const { + loc_eng_data_s_type *locEng = (loc_eng_data_s_type *)mLocEng; + if(!locEng->adapter->initDataServiceClient()) { + locEng->ds_nif = new DSStateMachine(servicerTypeExt, + (void *)dataCallCb, + locEng->adapter); + } + } + void locallog() const { + LOC_LOGV("LocEngDataClientInit\n"); + } + virtual void log() const { + locallog(); + } +}; + +struct LocEngInstallAGpsCert : public LocMsg { + LocEngAdapter* mpAdapter; + const size_t mNumberOfCerts; + const uint32_t mSlotBitMask; + DerEncodedCertificate* mpData; + inline LocEngInstallAGpsCert(LocEngAdapter* adapter, + const DerEncodedCertificate* pData, + size_t numberOfCerts, + uint32_t slotBitMask) : + LocMsg(), mpAdapter(adapter), + mNumberOfCerts(numberOfCerts), mSlotBitMask(slotBitMask), + mpData(new DerEncodedCertificate[mNumberOfCerts]) + { + for (int i=0; i < mNumberOfCerts; i++) { + mpData[i].data = new u_char[pData[i].length]; + if (mpData[i].data) { + memcpy(mpData[i].data, (void*)pData[i].data, pData[i].length); + mpData[i].length = pData[i].length; + } else { + LOC_LOGE("malloc failed for cert#%d", i); + break; + } + } + locallog(); + } + inline ~LocEngInstallAGpsCert() + { + for (int i=0; i < mNumberOfCerts; i++) { + if (mpData[i].data) { + delete[] mpData[i].data; + } + } + delete[] mpData; + } + inline virtual void proc() const { + mpAdapter->installAGpsCert(mpData, mNumberOfCerts, mSlotBitMask); + } + inline void locallog() const { + LOC_LOGV("LocEngInstallAGpsCert - certs=%u mask=%u", + mNumberOfCerts, mSlotBitMask); + } + inline virtual void log() const { + locallog(); + } +}; + +struct LocEngUpdateRegistrationMask : public LocMsg { + loc_eng_data_s_type* mLocEng; + LOC_API_ADAPTER_EVENT_MASK_T mMask; + loc_registration_mask_status mIsEnabled; + inline LocEngUpdateRegistrationMask(loc_eng_data_s_type* locEng, + LOC_API_ADAPTER_EVENT_MASK_T mask, + loc_registration_mask_status isEnabled) : + LocMsg(), mLocEng(locEng), mMask(mask), mIsEnabled(isEnabled) { + locallog(); + } + inline virtual void proc() const { + loc_eng_data_s_type *locEng = (loc_eng_data_s_type *)mLocEng; + locEng->adapter->updateRegistrationMask(mMask, + mIsEnabled); + } + void locallog() const { + LOC_LOGV("LocEngUpdateRegistrationMask\n"); + } + virtual void log() const { + locallog(); + } +}; + +struct LocEngGnssConstellationConfig : public LocMsg { + LocEngAdapter* mAdapter; + inline LocEngGnssConstellationConfig(LocEngAdapter* adapter) : + LocMsg(), mAdapter(adapter) { + locallog(); + } + inline virtual void proc() const { + if (mAdapter->gnssConstellationConfig()) { + LOC_LOGV("Modem supports GNSS measurements\n"); + gps_conf.CAPABILITIES |= GPS_CAPABILITY_MEASUREMENTS; + } else { + LOC_LOGV("Modem does not support GNSS measurements\n"); + } + } + void locallog() const { + LOC_LOGV("LocEngGnssConstellationConfig\n"); + } + virtual void log() const { + locallog(); + } +}; + +// case LOC_ENG_MSG_REPORT_GNSS_MEASUREMENT: +LocEngReportGpsMeasurement::LocEngReportGpsMeasurement(void* locEng, + GpsData &gpsData) : + LocMsg(), mLocEng(locEng), mGpsData(gpsData) +{ + locallog(); +} +void LocEngReportGpsMeasurement::proc() const { + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*) mLocEng; + if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION) + { + if (locEng->gps_measurement_cb != NULL) { + locEng->gps_measurement_cb((GpsData*)&(mGpsData)); + } + } +} +void LocEngReportGpsMeasurement::locallog() const { + IF_LOC_LOGV { + LOC_LOGV("%s:%d]: Received in GPS HAL." + "GNSS Measurements count: %d \n", + __func__, __LINE__, mGpsData.measurement_count); + for (int i =0; i< mGpsData.measurement_count && i < GPS_MAX_SVS; i++) { + LOC_LOGV(" GNSS measurement data in GPS HAL: \n" + " GPS_HAL => Measurement ID | prn | time_offset_ns | state |" + " received_gps_tow_ns| c_n0_dbhz | pseudorange_rate_mps |" + " pseudorange_rate_uncertainty_mps |" + " accumulated_delta_range_state | flags \n" + " GPS_HAL => %d | %d | %f | %d | %lld | %f | %f | %f | %d | %d \n", + i, + mGpsData.measurements[i].prn, + mGpsData.measurements[i].time_offset_ns, + mGpsData.measurements[i].state, + mGpsData.measurements[i].received_gps_tow_ns, + mGpsData.measurements[i].c_n0_dbhz, + mGpsData.measurements[i].pseudorange_rate_mps, + mGpsData.measurements[i].pseudorange_rate_uncertainty_mps, + mGpsData.measurements[i].accumulated_delta_range_state, + mGpsData.measurements[i].flags); + } + LOC_LOGV(" GPS_HAL => Clocks Info: type | time_ns \n" + " GPS_HAL => Clocks Info: %d | %lld", mGpsData.clock.type, + mGpsData.clock.time_ns); + } +} +inline void LocEngReportGpsMeasurement::log() const { + locallog(); +} + +/********************************************************************* + * Initialization checking macros + *********************************************************************/ +#define STATE_CHECK(ctx, x, ret) \ + if (!(ctx)) \ + { \ + /* Not intialized, abort */\ + LOC_LOGE("%s: log_eng state error: %s", __func__, x); \ + EXIT_LOG(%s, x); \ + ret; \ + } +#define INIT_CHECK(ctx, ret) STATE_CHECK(ctx, "instance not initialized", ret) + +uint32_t getCarrierCapabilities() { + #define carrierMSA (uint32_t)0x2 + #define carrierMSB (uint32_t)0x1 + #define gpsConfMSA (uint32_t)0x4 + #define gpsConfMSB (uint32_t)0x2 + uint32_t capabilities = gps_conf.CAPABILITIES; + if ((gps_conf.SUPL_MODE & carrierMSA) != carrierMSA) { + capabilities &= ~gpsConfMSA; + } + if ((gps_conf.SUPL_MODE & carrierMSB) != carrierMSB) { + capabilities &= ~gpsConfMSB; + } + + LOC_LOGV("getCarrierCapabilities: CAPABILITIES %x, SUPL_MODE %x, carrier capabilities %x", + gps_conf.CAPABILITIES, gps_conf.SUPL_MODE, capabilities); + return capabilities; +} + +/*=========================================================================== +FUNCTION loc_eng_init + +DESCRIPTION + Initialize the location engine, this include setting up global datas + and registers location engien with loc api service. + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks, + LOC_API_ADAPTER_EVENT_MASK_T event, ContextBase* context) + +{ + int ret_val = 0; + + ENTRY_LOG_CALLFLOW(); + if (NULL == callbacks || 0 == event) { + LOC_LOGE("loc_eng_init: bad parameters cb %p eMask %d", callbacks, event); + ret_val = -1; + EXIT_LOG(%d, ret_val); + return ret_val; + } + + STATE_CHECK((NULL == loc_eng_data.adapter), + "instance already initialized", return 0); + + memset(&loc_eng_data, 0, sizeof (loc_eng_data)); + + // Save callbacks + loc_eng_data.location_cb = callbacks->location_cb; + loc_eng_data.sv_status_cb = callbacks->sv_status_cb; + loc_eng_data.status_cb = callbacks->status_cb; + loc_eng_data.nmea_cb = callbacks->nmea_cb; + loc_eng_data.set_capabilities_cb = callbacks->set_capabilities_cb; + loc_eng_data.acquire_wakelock_cb = callbacks->acquire_wakelock_cb; + loc_eng_data.release_wakelock_cb = callbacks->release_wakelock_cb; + loc_eng_data.request_utc_time_cb = callbacks->request_utc_time_cb; + loc_eng_data.location_ext_parser = callbacks->location_ext_parser ? + callbacks->location_ext_parser : noProc; + loc_eng_data.sv_ext_parser = callbacks->sv_ext_parser ? + callbacks->sv_ext_parser : noProc; + loc_eng_data.intermediateFix = gps_conf.INTERMEDIATE_POS; + // initial states taken care of by the memset above + // loc_eng_data.engine_status -- GPS_STATUS_NONE; + // loc_eng_data.fix_session_status -- GPS_STATUS_NONE; + // loc_eng_data.mute_session_state -- LOC_MUTE_SESS_NONE; + + if ((event & LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT) && (gps_conf.NMEA_PROVIDER == NMEA_PROVIDER_AP)) + { + event = event ^ LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT; // unregister for modem NMEA report + loc_eng_data.generateNmea = true; + } + else + { + loc_eng_data.generateNmea = false; + } + + loc_eng_data.adapter = + new LocEngAdapter(event, &loc_eng_data, context, + (LocThread::tCreate)callbacks->create_thread_cb); + + LOC_LOGD("loc_eng_init created client, id = %p\n", + loc_eng_data.adapter); + loc_eng_data.adapter->sendMsg(new LocEngInit(&loc_eng_data)); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +static int loc_eng_reinit(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG(); + int ret_val = LOC_API_ADAPTER_ERR_SUCCESS; + LocEngAdapter* adapter = loc_eng_data.adapter; + + adapter->sendMsg(new LocEngGnssConstellationConfig(adapter)); + adapter->sendMsg(new LocEngSuplVer(adapter, gps_conf.SUPL_VER)); + adapter->sendMsg(new LocEngLppConfig(adapter, gps_conf.LPP_PROFILE)); + adapter->sendMsg(new LocEngSensorControlConfig(adapter, sap_conf.SENSOR_USAGE, + sap_conf.SENSOR_PROVIDER)); + adapter->sendMsg(new LocEngAGlonassProtocol(adapter, gps_conf.A_GLONASS_POS_PROTOCOL_SELECT)); + + /* Make sure at least one of the sensor property is specified by the user in the gps.conf file. */ + if( sap_conf.GYRO_BIAS_RANDOM_WALK_VALID || + sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID || + sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || + sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || + sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) { + adapter->sendMsg(new LocEngSensorProperties(adapter, + sap_conf.GYRO_BIAS_RANDOM_WALK_VALID, + sap_conf.GYRO_BIAS_RANDOM_WALK, + sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, + sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, + sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, + sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, + sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY)); + } + + adapter->sendMsg(new LocEngSensorPerfControlConfig(adapter, + sap_conf.SENSOR_CONTROL_MODE, + sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, + sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC, + sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH, + sap_conf.SENSOR_GYRO_BATCHES_PER_SEC, + sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, + sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, + sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, + sap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, + sap_conf.SENSOR_ALGORITHM_CONFIG_MASK)); + + adapter->sendMsg(new LocEngEnableData(adapter, NULL, 0, (agpsStatus ? 1:0))); + + loc_eng_xtra_version_check(loc_eng_data, gps_conf.XTRA_VERSION_CHECK); + + LOC_LOGD("loc_eng_reinit reinit() successful"); + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_eng_cleanup + +DESCRIPTION + Cleans location engine. The location client handle will be released. + +DEPENDENCIES + None + +RETURN VALUE + None + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG_CALLFLOW(); + INIT_CHECK(loc_eng_data.adapter, return); + + // XTRA has no state, so we are fine with it. + + // we need to check and clear NI +#if 0 + // we need to check and clear ATL + if (NULL != loc_eng_data.agnss_nif) { + delete loc_eng_data.agnss_nif; + loc_eng_data.agnss_nif = NULL; + } + if (NULL != loc_eng_data.internet_nif) { + delete loc_eng_data.internet_nif; + loc_eng_data.internet_nif = NULL; + } +#endif + if (loc_eng_data.adapter->isInSession()) + { + LOC_LOGD("loc_eng_cleanup: fix not stopped. stop it now."); + loc_eng_stop(loc_eng_data); + } + +#if 0 // can't afford to actually clean up, for many reason. + + LOC_LOGD("loc_eng_init: client opened. close it now."); + delete loc_eng_data.adapter; + loc_eng_data.adapter = NULL; + + loc_eng_dmn_conn_loc_api_server_unblock(); + loc_eng_dmn_conn_loc_api_server_join(); + +#endif + + EXIT_LOG(%s, VOID_RET); +} + + +/*=========================================================================== +FUNCTION loc_eng_start + +DESCRIPTION + Starts the tracking session + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_start(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG_CALLFLOW(); + INIT_CHECK(loc_eng_data.adapter, return -1); + + if(! loc_eng_data.adapter->getUlpProxy()->sendStartFix()) + { + loc_eng_data.adapter->sendMsg(new LocEngStartFix(loc_eng_data.adapter)); + } + + EXIT_LOG(%d, 0); + return 0; +} + +static int loc_eng_start_handler(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG(); + int ret_val = LOC_API_ADAPTER_ERR_SUCCESS; + + if (!loc_eng_data.adapter->isInSession()) { + ret_val = loc_eng_data.adapter->startFix(); + + if (ret_val == LOC_API_ADAPTER_ERR_SUCCESS || + ret_val == LOC_API_ADAPTER_ERR_ENGINE_DOWN || + ret_val == LOC_API_ADAPTER_ERR_PHONE_OFFLINE || + ret_val == LOC_API_ADAPTER_ERR_INTERNAL) + { + loc_eng_data.adapter->setInSession(TRUE); + } + } + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_eng_stop_wrapper + +DESCRIPTION + Stops the tracking session + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_stop(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG_CALLFLOW(); + INIT_CHECK(loc_eng_data.adapter, return -1); + + if(! loc_eng_data.adapter->getUlpProxy()->sendStopFix()) + { + loc_eng_data.adapter->sendMsg(new LocEngStopFix(loc_eng_data.adapter)); + } + + EXIT_LOG(%d, 0); + return 0; +} + +static int loc_eng_stop_handler(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG(); + int ret_val = LOC_API_ADAPTER_ERR_SUCCESS; + + if (loc_eng_data.adapter->isInSession()) { + ret_val = loc_eng_data.adapter->stopFix(); + loc_eng_data.adapter->setInSession(FALSE); + } + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_eng_mute_one_session + +DESCRIPTION + Mutes one session + +DEPENDENCIES + None + +RETURN VALUE + 0: Success + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_mute_one_session(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG(); + loc_eng_data.mute_session_state = LOC_MUTE_SESS_WAIT; + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== +FUNCTION loc_eng_set_position_mode + +DESCRIPTION + Sets the mode and fix frequency for the tracking session. + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data, + LocPosMode ¶ms) +{ + ENTRY_LOG_CALLFLOW(); + INIT_CHECK(loc_eng_data.adapter, return -1); + + // The position mode for AUTO/GSS/QCA1530 can only be standalone + if (!(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSB) && + !(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) && + (params.mode != LOC_POSITION_MODE_STANDALONE)) { + params.mode = LOC_POSITION_MODE_STANDALONE; + LOC_LOGD("Position mode changed to standalone for target with AUTO/GSS/qca1530."); + } + + if(! loc_eng_data.adapter->getUlpProxy()->sendFixMode(params)) + { + LocEngAdapter* adapter = loc_eng_data.adapter; + adapter->sendMsg(new LocEngPositionMode(adapter, params)); + } + + EXIT_LOG(%d, 0); + return 0; +} + +/*=========================================================================== +FUNCTION loc_eng_inject_time + +DESCRIPTION + This is used by Java native function to do time injection. + +DEPENDENCIES + None + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data, GpsUtcTime time, + int64_t timeReference, int uncertainty) +{ + ENTRY_LOG_CALLFLOW(); + INIT_CHECK(loc_eng_data.adapter, return -1); + LocEngAdapter* adapter = loc_eng_data.adapter; + + adapter->sendMsg(new LocEngSetTime(adapter, time, timeReference, + uncertainty)); + + EXIT_LOG(%d, 0); + return 0; +} + + +/*=========================================================================== +FUNCTION loc_eng_inject_location + +DESCRIPTION + This is used by Java native function to do location injection. + +DEPENDENCIES + None + +RETURN VALUE + 0 : Successful + error code : Failure + +SIDE EFFECTS + N/A +===========================================================================*/ +int loc_eng_inject_location(loc_eng_data_s_type &loc_eng_data, double latitude, + double longitude, float accuracy) +{ + ENTRY_LOG_CALLFLOW(); + INIT_CHECK(loc_eng_data.adapter, return -1); + LocEngAdapter* adapter = loc_eng_data.adapter; + if(adapter->mSupportsPositionInjection) + { + adapter->sendMsg(new LocEngInjectLocation(adapter, latitude, longitude, + accuracy)); + } + + EXIT_LOG(%d, 0); + return 0; +} + + +/*=========================================================================== +FUNCTION loc_eng_delete_aiding_data + +DESCRIPTION + This is used by Java native function to delete the aiding data. The function + updates the global variable for the aiding data to be deleted. If the GPS + engine is off, the aiding data will be deleted. Otherwise, the actual action + will happen when gps engine is turned off. + +DEPENDENCIES + Assumes the aiding data type specified in GpsAidingData matches with + LOC API specification. + +RETURN VALUE + None + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_delete_aiding_data(loc_eng_data_s_type &loc_eng_data, GpsAidingData f) +{ + ENTRY_LOG_CALLFLOW(); + INIT_CHECK(loc_eng_data.adapter, return); + + loc_eng_data.adapter->sendMsg(new LocEngDelAidData(&loc_eng_data, f)); + + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== + +FUNCTION loc_inform_gps_state + +DESCRIPTION + Informs the GPS Provider about the GPS status + +DEPENDENCIES + None + +RETURN VALUE + None + +SIDE EFFECTS + N/A + +===========================================================================*/ +static void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data, GpsStatusValue status) +{ + ENTRY_LOG(); + + if (loc_eng_data.status_cb) + { + GpsStatus gs = { sizeof(gs),status }; + CALLBACK_LOG_CALLFLOW("status_cb", %s, + loc_get_gps_status_name(gs.status)); + loc_eng_data.status_cb(&gs); + } + + EXIT_LOG(%s, VOID_RET); +} + +static int loc_eng_get_zpp_handler(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG(); + int ret_val = LOC_API_ADAPTER_ERR_SUCCESS; + UlpLocation location; + LocPosTechMask tech_mask = LOC_POS_TECH_MASK_DEFAULT; + GpsLocationExtended locationExtended; + memset(&locationExtended, 0, sizeof (GpsLocationExtended)); + locationExtended.size = sizeof(locationExtended); + + ret_val = loc_eng_data.adapter->getZpp(location.gpsLocation, tech_mask); + //Mark the location source as from ZPP + location.gpsLocation.flags |= LOCATION_HAS_SOURCE_INFO; + location.position_source = ULP_LOCATION_IS_FROM_ZPP; + + loc_eng_data.adapter->getUlpProxy()->reportPosition(location, + locationExtended, + NULL, + LOC_SESS_SUCCESS, + tech_mask); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/* + Callback function passed to Data Services State Machine + This becomes part of the state machine's servicer and + is used to send requests to the data services client +*/ +static int dataCallCb(void *cb_data) +{ + LOC_LOGD("Enter dataCallCb\n"); + int ret=0; + if(cb_data != NULL) { + dsCbData *cbData = (dsCbData *)cb_data; + LocEngAdapter *locAdapter = (LocEngAdapter *)cbData->mAdapter; + if(cbData->action == GPS_REQUEST_AGPS_DATA_CONN) { + LOC_LOGD("dataCallCb GPS_REQUEST_AGPS_DATA_CONN\n"); + ret = locAdapter->openAndStartDataCall(); + } + else if(cbData->action == GPS_RELEASE_AGPS_DATA_CONN) { + LOC_LOGD("dataCallCb GPS_RELEASE_AGPS_DATA_CONN\n"); + locAdapter->stopDataCall(); + } + } + else { + LOC_LOGE("NULL argument received. Failing.\n"); + ret = -1; + goto err; + } + +err: + LOC_LOGD("Exit dataCallCb ret = %d\n", ret); + return ret; +} + +/*=========================================================================== +FUNCTION loc_eng_agps_reinit + +DESCRIPTION + 2nd half of loc_eng_agps_init(), singled out for modem restart to use. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +static void loc_eng_agps_reinit(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG(); + + // Set server addresses which came before init + if (loc_eng_data.supl_host_set) + { + loc_eng_set_server(loc_eng_data, LOC_AGPS_SUPL_SERVER, + loc_eng_data.supl_host_buf, + loc_eng_data.supl_port_buf); + } + + if (loc_eng_data.c2k_host_set) + { + loc_eng_set_server(loc_eng_data, LOC_AGPS_CDMA_PDE_SERVER, + loc_eng_data.c2k_host_buf, + loc_eng_data.c2k_port_buf); + } + EXIT_LOG(%s, VOID_RET); +} +/*=========================================================================== +FUNCTION loc_eng_agps_init + +DESCRIPTION + Initialize the AGps interface. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsExtCallbacks* callbacks) +{ + ENTRY_LOG_CALLFLOW(); + INIT_CHECK(loc_eng_data.adapter, return); + STATE_CHECK((NULL == loc_eng_data.agps_status_cb), + "agps instance already initialized", + return); + if (callbacks == NULL) { + LOC_LOGE("loc_eng_agps_init: bad parameters cb %p", callbacks); + EXIT_LOG(%s, VOID_RET); + return; + } + LocEngAdapter* adapter = loc_eng_data.adapter; + loc_eng_data.agps_status_cb = callbacks->status_cb; + + loc_eng_data.internet_nif = new AgpsStateMachine(servicerTypeAgps, + (void *)loc_eng_data.agps_status_cb, + AGPS_TYPE_WWAN_ANY, + false); + loc_eng_data.wifi_nif = new AgpsStateMachine(servicerTypeAgps, + (void *)loc_eng_data.agps_status_cb, + AGPS_TYPE_WIFI, + true); + + if ((gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) || + (gps_conf.CAPABILITIES & GPS_CAPABILITY_MSB)) { + loc_eng_data.agnss_nif = new AgpsStateMachine(servicerTypeAgps, + (void *)loc_eng_data.agps_status_cb, + AGPS_TYPE_SUPL, + false); + + if (adapter->mSupportsAgpsRequests) { + if(gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL) { + loc_eng_data.adapter->sendMsg(new LocEngDataClientInit(&loc_eng_data)); + } + loc_eng_dmn_conn_loc_api_server_launch(callbacks->create_thread_cb, + NULL, NULL, &loc_eng_data); + } + loc_eng_agps_reinit(loc_eng_data); + } + + EXIT_LOG(%s, VOID_RET); +} + +static void deleteAidingData(loc_eng_data_s_type &logEng) { + if (logEng.engine_status != GPS_STATUS_ENGINE_ON && + logEng.aiding_data_for_deletion != 0) { + logEng.adapter->deleteAidingData(logEng.aiding_data_for_deletion); + logEng.aiding_data_for_deletion = 0; + } +} + +static AgpsStateMachine* +getAgpsStateMachine(loc_eng_data_s_type &locEng, AGpsExtType agpsType) { + AgpsStateMachine* stateMachine; + switch (agpsType) { + case AGPS_TYPE_WIFI: { + stateMachine = locEng.wifi_nif; + break; + } + case AGPS_TYPE_INVALID: + case AGPS_TYPE_SUPL: { + stateMachine = locEng.agnss_nif; + break; + } + case AGPS_TYPE_SUPL_ES: { + locEng.ds_nif ? + stateMachine = locEng.ds_nif: + stateMachine = locEng.agnss_nif; + break; + } + default: + stateMachine = locEng.internet_nif; + } + return stateMachine; +} + +/*=========================================================================== +FUNCTION loc_eng_agps_open + +DESCRIPTION + This function is called when on-demand data connection opening is successful. +It should inform engine about the data open result. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType, + const char* apn, AGpsBearerType bearerType) +{ + ENTRY_LOG_CALLFLOW(); + INIT_CHECK(loc_eng_data.adapter && loc_eng_data.agps_status_cb, + return -1); + + if (apn == NULL) + { + LOC_LOGE("APN Name NULL\n"); + return 0; + } + + LOC_LOGD("loc_eng_agps_open APN name = [%s]", apn); + + int apn_len = smaller_of(strlen (apn), MAX_APN_LEN); + AgpsStateMachine* sm = getAgpsStateMachine(loc_eng_data, agpsType); + + loc_eng_data.adapter->sendMsg( + new LocEngAtlOpenSuccess(sm, apn, apn_len, bearerType)); + + EXIT_LOG(%d, 0); + return 0; +} + +/*=========================================================================== +FUNCTION loc_eng_agps_closed + +DESCRIPTION + This function is called when on-demand data connection closing is done. +It should inform engine about the data close result. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType) +{ + ENTRY_LOG_CALLFLOW(); + INIT_CHECK(loc_eng_data.adapter && loc_eng_data.agps_status_cb, + return -1); + + AgpsStateMachine* sm = getAgpsStateMachine(loc_eng_data, agpsType); + loc_eng_data.adapter->sendMsg(new LocEngAtlClosed(sm)); + + EXIT_LOG(%d, 0); + return 0; +} + +/*=========================================================================== +FUNCTION loc_eng_agps_open_failed + +DESCRIPTION + This function is called when on-demand data connection opening has failed. +It should inform engine about the data open result. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType) +{ + ENTRY_LOG_CALLFLOW(); + INIT_CHECK(loc_eng_data.adapter && loc_eng_data.agps_status_cb, + return -1); + + AgpsStateMachine* sm = getAgpsStateMachine(loc_eng_data, agpsType); + loc_eng_data.adapter->sendMsg(new LocEngAtlOpenFailed(sm)); + + EXIT_LOG(%d, 0); + return 0; +} + +/*=========================================================================== + +FUNCTION resolve_in_addr + +DESCRIPTION + Translates a hostname to in_addr struct + +DEPENDENCIES + n/a + +RETURN VALUE + TRUE if successful + +SIDE EFFECTS + n/a + +===========================================================================*/ +static boolean resolve_in_addr(const char *host_addr, struct in_addr *in_addr_ptr) +{ + ENTRY_LOG(); + boolean ret_val = TRUE; + + struct hostent *hp; + hp = gethostbyname(host_addr); + if (hp != NULL) /* DNS OK */ + { + memcpy(in_addr_ptr, hp->h_addr_list[0], hp->h_length); + } + else + { + /* Try IP representation */ + if (inet_aton(host_addr, in_addr_ptr) == 0) + { + /* IP not valid */ + LOC_LOGE("DNS query on '%s' failed\n", host_addr); + ret_val = FALSE; + } + } + + EXIT_LOG(%s, loc_logger_boolStr[ret_val!=0]); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_eng_set_server + +DESCRIPTION + This is used to set the default AGPS server. Server address is obtained + from gps.conf. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_eng_set_server(loc_eng_data_s_type &loc_eng_data, + LocServerType type, const char* hostname, int port) +{ + ENTRY_LOG(); + int ret = 0; + LocEngAdapter* adapter = loc_eng_data.adapter; + + if (LOC_AGPS_SUPL_SERVER == type) { + char url[MAX_URL_LEN]; + unsigned int len = 0; + const char nohost[] = "NONE"; + if (hostname == NULL || + strncasecmp(nohost, hostname, sizeof(nohost)) == 0) { + url[0] = NULL; + } else { + len = snprintf(url, sizeof(url), "%s:%u", hostname, (unsigned) port); + } + + if (sizeof(url) > len) { + adapter->sendMsg(new LocEngSetServerUrl(adapter, url, len)); + } + } else if (LOC_AGPS_CDMA_PDE_SERVER == type || + LOC_AGPS_CUSTOM_PDE_SERVER == type || + LOC_AGPS_MPC_SERVER == type) { + struct in_addr addr; + if (!resolve_in_addr(hostname, &addr)) + { + LOC_LOGE("loc_eng_set_server, hostname %s cannot be resolved.\n", hostname); + ret = -2; + } else { + unsigned int ip = htonl(addr.s_addr); + adapter->sendMsg(new LocEngSetServerIpv4(adapter, ip, port, type)); + } + } else { + LOC_LOGE("loc_eng_set_server, type %d cannot be resolved.\n", type); + } + + EXIT_LOG(%d, ret); + return ret; +} + +/*=========================================================================== +FUNCTION loc_eng_set_server_proxy + +DESCRIPTION + If loc_eng_set_server is called before loc_eng_init, it doesn't work. This + proxy buffers server settings and calls loc_eng_set_server when the client is + open. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_set_server_proxy(loc_eng_data_s_type &loc_eng_data, + LocServerType type, + const char* hostname, int port) +{ + ENTRY_LOG_CALLFLOW(); + int ret_val = 0; + + LOC_LOGV("save the address, type: %d, hostname: %s, port: %d", + (int) type, hostname, port); + switch (type) + { + case LOC_AGPS_SUPL_SERVER: + strlcpy(loc_eng_data.supl_host_buf, hostname, + sizeof(loc_eng_data.supl_host_buf)); + loc_eng_data.supl_port_buf = port; + loc_eng_data.supl_host_set = 1; + break; + case LOC_AGPS_CDMA_PDE_SERVER: + strlcpy(loc_eng_data.c2k_host_buf, hostname, + sizeof(loc_eng_data.c2k_host_buf)); + loc_eng_data.c2k_port_buf = port; + loc_eng_data.c2k_host_set = 1; + break; + default: + LOC_LOGE("loc_eng_set_server_proxy, unknown server type = %d", (int) type); + } + + if (NULL != loc_eng_data.adapter) + { + ret_val = loc_eng_set_server(loc_eng_data, type, hostname, port); + } + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_eng_agps_ril_update_network_availability + +DESCRIPTION + Sets data call allow vs disallow flag to modem + This is the only member of sLocEngAGpsRilInterface implemented. + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data, + int available, const char* apn) +{ + ENTRY_LOG_CALLFLOW(); + + //This is to store the status of data availability over the network. + //If GPS is not enabled, the INIT_CHECK will fail and the modem will + //not be updated with the network's availability. Since the data status + //can change before GPS is enabled the, storing the status will enable + //us to inform the modem after GPS is enabled + agpsStatus = available; + + INIT_CHECK(loc_eng_data.adapter, return); + if (apn != NULL) + { + LOC_LOGD("loc_eng_agps_ril_update_network_availability: APN Name = [%s]\n", apn); + int apn_len = smaller_of(strlen (apn), MAX_APN_LEN); + LocEngAdapter* adapter = loc_eng_data.adapter; + adapter->sendMsg(new LocEngEnableData(adapter, apn, apn_len, available)); + } + EXIT_LOG(%s, VOID_RET); +} + +int loc_eng_agps_install_certificates(loc_eng_data_s_type &loc_eng_data, + const DerEncodedCertificate* certificates, + size_t numberOfCerts) +{ + ENTRY_LOG_CALLFLOW(); + int ret_val = AGPS_CERTIFICATE_OPERATION_SUCCESS; + + uint32_t slotBitMask = gps_conf.AGPS_CERT_WRITABLE_MASK; + uint32_t slotCount = 0; + for (uint32_t slotBitMaskCounter=slotBitMask; slotBitMaskCounter; slotCount++) { + slotBitMaskCounter &= slotBitMaskCounter - 1; + } + LOC_LOGD("SlotBitMask=%u SlotCount=%u NumberOfCerts=%u", + slotBitMask, slotCount, numberOfCerts); + + LocEngAdapter* adapter = loc_eng_data.adapter; + + if (numberOfCerts == 0) { + LOC_LOGE("No certs to install, since numberOfCerts is zero"); + ret_val = AGPS_CERTIFICATE_OPERATION_SUCCESS; + } else if (!adapter) { + LOC_LOGE("adapter is null!"); + ret_val = AGPS_CERTIFICATE_ERROR_GENERIC; + } else if (slotCount < numberOfCerts) { + LOC_LOGE("Not enough cert slots (%u) to install %u certs!", + slotCount, numberOfCerts); + ret_val = AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES; + } else { + for (int i=0; i < numberOfCerts; ++i) + { + if (certificates[i].length > AGPS_CERTIFICATE_MAX_LENGTH) { + LOC_LOGE("cert#(%u) length of %u is too big! greater than %u", + certificates[i].length, AGPS_CERTIFICATE_MAX_LENGTH); + ret_val = AGPS_CERTIFICATE_ERROR_GENERIC; + break; + } + } + + if (ret_val == AGPS_CERTIFICATE_OPERATION_SUCCESS) { + adapter->sendMsg(new LocEngInstallAGpsCert(adapter, + certificates, + numberOfCerts, + slotBitMask)); + } + } + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +void loc_eng_configuration_update (loc_eng_data_s_type &loc_eng_data, + const char* config_data, int32_t length) +{ + ENTRY_LOG_CALLFLOW(); + + if (config_data && length > 0) { + loc_gps_cfg_s_type gps_conf_tmp = gps_conf; + UTIL_UPDATE_CONF(config_data, length, gps_conf_table); + LocEngAdapter* adapter = loc_eng_data.adapter; + + // it is possible that HAL is not init'ed at this time + if (adapter) { + if (gps_conf_tmp.SUPL_VER != gps_conf.SUPL_VER) { + adapter->sendMsg(new LocEngSuplVer(adapter, gps_conf.SUPL_VER)); + } + if (gps_conf_tmp.LPP_PROFILE != gps_conf.LPP_PROFILE) { + adapter->sendMsg(new LocEngLppConfig(adapter, gps_conf.LPP_PROFILE)); + } + if (gps_conf_tmp.A_GLONASS_POS_PROTOCOL_SELECT != gps_conf.A_GLONASS_POS_PROTOCOL_SELECT) { + adapter->sendMsg(new LocEngAGlonassProtocol(adapter, + gps_conf.A_GLONASS_POS_PROTOCOL_SELECT)); + } + if (gps_conf_tmp.SUPL_MODE != gps_conf.SUPL_MODE) { + adapter->sendMsg(new LocEngSuplMode(adapter->getUlpProxy())); + } + } + + gps_conf_tmp.SUPL_VER = gps_conf.SUPL_VER; + gps_conf_tmp.LPP_PROFILE = gps_conf.LPP_PROFILE; + gps_conf_tmp.A_GLONASS_POS_PROTOCOL_SELECT = gps_conf.A_GLONASS_POS_PROTOCOL_SELECT; + gps_conf_tmp.SUPL_MODE = gps_conf.SUPL_MODE; + gps_conf_tmp.GPS_LOCK = gps_conf.GPS_LOCK; + gps_conf = gps_conf_tmp; + } + + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== +FUNCTION loc_eng_report_status + +DESCRIPTION + Reports GPS engine state to Java layer. + +DEPENDENCIES + N/A + +RETURN VALUE + N/A + +SIDE EFFECTS + N/A + +===========================================================================*/ +static void loc_eng_report_status (loc_eng_data_s_type &loc_eng_data, GpsStatusValue status) +{ + ENTRY_LOG(); + // Switch from WAIT to MUTE, for "engine on" or "session begin" event + if (status == GPS_STATUS_SESSION_BEGIN || status == GPS_STATUS_ENGINE_ON) + { + if (loc_eng_data.mute_session_state == LOC_MUTE_SESS_WAIT) + { + LOC_LOGD("loc_eng_report_status: mute_session_state changed from WAIT to IN SESSION"); + loc_eng_data.mute_session_state = LOC_MUTE_SESS_IN_SESSION; + } + } + + // Switch off MUTE session + if (loc_eng_data.mute_session_state == LOC_MUTE_SESS_IN_SESSION && + (status == GPS_STATUS_SESSION_END || status == GPS_STATUS_ENGINE_OFF)) + { + LOC_LOGD("loc_eng_report_status: mute_session_state changed from IN SESSION to NONE"); + loc_eng_data.mute_session_state = LOC_MUTE_SESS_NONE; + } + + // Session End is not reported during Android navigating state + boolean navigating = loc_eng_data.adapter->isInSession(); + if (status != GPS_STATUS_NONE && + !(status == GPS_STATUS_SESSION_END && navigating) && + !(status == GPS_STATUS_SESSION_BEGIN && !navigating)) + { + if (loc_eng_data.mute_session_state != LOC_MUTE_SESS_IN_SESSION) + { + // Inform GpsLocationProvider about mNavigating status + loc_inform_gps_status(loc_eng_data, status); + } + else { + LOC_LOGD("loc_eng_report_status: muting the status report."); + } + } + + // Only keeps ENGINE ON/OFF in engine_status + if (status == GPS_STATUS_ENGINE_ON || status == GPS_STATUS_ENGINE_OFF) + { + loc_eng_data.engine_status = status; + } + + // Only keeps SESSION BEGIN/END in fix_session_status + if (status == GPS_STATUS_SESSION_BEGIN || status == GPS_STATUS_SESSION_END) + { + loc_eng_data.fix_session_status = status; + } + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== +FUNCTION loc_eng_handle_engine_down + loc_eng_handle_engine_up + +DESCRIPTION + Calls this function when it is detected that modem restart is happening. + Either we detected the modem is down or received modem up event. + This must be called from the deferred thread to avoid race condition. + +DEPENDENCIES + None + +RETURN VALUE + None + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_handle_engine_down(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG(); + loc_eng_ni_reset_on_engine_restart(loc_eng_data); + loc_eng_report_status(loc_eng_data, GPS_STATUS_ENGINE_OFF); + EXIT_LOG(%s, VOID_RET); +} + +void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG(); + loc_eng_reinit(loc_eng_data); + + loc_eng_data.adapter->requestPowerVote(); + + if (loc_eng_data.agps_status_cb != NULL) { + if (loc_eng_data.agnss_nif) + loc_eng_data.agnss_nif->dropAllSubscribers(); + if (loc_eng_data.internet_nif) + loc_eng_data.internet_nif->dropAllSubscribers(); + + loc_eng_agps_reinit(loc_eng_data); + } + + // modem is back up. If we crashed in the middle of navigating, we restart. + if (loc_eng_data.adapter->isInSession()) { + // This sets the copy in adapter to modem + loc_eng_data.adapter->setInSession(false); + loc_eng_start_handler(loc_eng_data); + } + + EXIT_LOG(%s, VOID_RET); +} + +#ifdef USE_GLIB +/*=========================================================================== +FUNCTION set_sched_policy + +DESCRIPTION + Local copy of this function which bypasses android set_sched_policy + +DEPENDENCIES + None + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int set_sched_policy(int tid, SchedPolicy policy) +{ + return 0; +} +#endif /* USE_GLIB */ + +/*=========================================================================== +FUNCTION loc_eng_read_config + +DESCRIPTION + Initiates the reading of the gps config file stored in /etc dir + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_read_config(void) +{ + ENTRY_LOG_CALLFLOW(); + if(configAlreadyRead == false) + { + // Initialize our defaults before reading of configuration file overwrites them. + loc_default_parameters(); + // We only want to parse the conf file once. This is a good place to ensure that. + // In fact one day the conf file should go into context. + UTIL_READ_CONF(GPS_CONF_FILE, gps_conf_table); + UTIL_READ_CONF(SAP_CONF_FILE, sap_conf_table); + configAlreadyRead = true; + } else { + LOC_LOGV("GPS Config file has already been read\n"); + } + + EXIT_LOG(%d, 0); + return 0; +} + +/*=========================================================================== +FUNCTION loc_eng_gps_measurement_init + +DESCRIPTION + Initialize gps measurement module. + +DEPENDENCIES + N/A + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_gps_measurement_init(loc_eng_data_s_type &loc_eng_data, + GpsMeasurementCallbacks* callbacks) +{ + ENTRY_LOG_CALLFLOW(); + + STATE_CHECK((NULL == loc_eng_data.gps_measurement_cb), + "gps measurement already initialized", + return GPS_MEASUREMENT_ERROR_ALREADY_INIT); + STATE_CHECK((callbacks != NULL), + "callbacks can not be NULL", + return GPS_MEASUREMENT_ERROR_GENERIC); + STATE_CHECK(loc_eng_data.adapter, + "GpsInterface must be initialized first", + return GPS_MEASUREMENT_ERROR_GENERIC); + + // updated the mask + LOC_API_ADAPTER_EVENT_MASK_T event = LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT; + loc_eng_data.adapter->sendMsg(new LocEngUpdateRegistrationMask( + &loc_eng_data, + event, + LOC_REGISTRATION_MASK_ENABLED)); + // set up the callback + loc_eng_data.gps_measurement_cb = callbacks->measurement_callback; + LOC_LOGD ("%s, event masks updated successfully", __func__); + + return GPS_MEASUREMENT_OPERATION_SUCCESS; +} + +/*=========================================================================== +FUNCTION loc_eng_gps_measurement_close + +DESCRIPTION + Close gps measurement module. + +DEPENDENCIES + N/A + +RETURN VALUE + N/A + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_gps_measurement_close(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG_CALLFLOW(); + + INIT_CHECK(loc_eng_data.adapter, return); + + // updated the mask + LOC_API_ADAPTER_EVENT_MASK_T event = LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT; + loc_eng_data.adapter->sendMsg(new LocEngUpdateRegistrationMask( + &loc_eng_data, + event, + LOC_REGISTRATION_MASK_DISABLED)); + // set up the callback + loc_eng_data.gps_measurement_cb = NULL; + EXIT_LOG(%d, 0); +} diff --git a/gps/loc_api/libloc_api_50001/loc_eng.h b/gps/loc_api/libloc_api_50001/loc_eng.h new file mode 100644 index 0000000..b4f2564 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng.h @@ -0,0 +1,271 @@ +/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef LOC_ENG_H +#define LOC_ENG_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +// Uncomment to keep all LOG messages (LOGD, LOGI, LOGV, etc.) +#define MAX_NUM_ATL_CONNECTIONS 2 + +// Define boolean type to be used by libgps on loc api module +typedef unsigned char boolean; + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// The data connection minimal open time +#define DATA_OPEN_MIN_TIME 1 /* sec */ + +// The system sees GPS engine turns off after inactive for this period of time +#define GPS_AUTO_OFF_TIME 2 /* secs */ +#define SUCCESS TRUE +#define FAILURE FALSE +#define INVALID_ATL_CONNECTION_HANDLE -1 + +#define MAX_XTRA_SERVER_URL_LENGTH 256 + +enum loc_nmea_provider_e_type { + NMEA_PROVIDER_AP = 0, // Application Processor Provider of NMEA + NMEA_PROVIDER_MP // Modem Processor Provider of NMEA +}; + +enum loc_mute_session_e_type { + LOC_MUTE_SESS_NONE = 0, + LOC_MUTE_SESS_WAIT, + LOC_MUTE_SESS_IN_SESSION +}; + +// Module data +typedef struct loc_eng_data_s +{ + LocEngAdapter *adapter; + loc_location_cb_ext location_cb; + gps_status_callback status_cb; + loc_sv_status_cb_ext sv_status_cb; + agps_status_extended agps_status_cb; + gps_nmea_callback nmea_cb; + gps_ni_notify_callback ni_notify_cb; + gps_set_capabilities set_capabilities_cb; + gps_acquire_wakelock acquire_wakelock_cb; + gps_release_wakelock release_wakelock_cb; + gps_request_utc_time request_utc_time_cb; + gps_measurement_callback gps_measurement_cb; + boolean intermediateFix; + AGpsStatusValue agps_status; + loc_eng_xtra_data_s_type xtra_module_data; + loc_eng_ni_data_s_type loc_eng_ni_data; + + // AGPS state machines + AgpsStateMachine* agnss_nif; + AgpsStateMachine* internet_nif; + AgpsStateMachine* wifi_nif; + //State machine for Data Services + AgpsStateMachine* ds_nif; + + // GPS engine status + GpsStatusValue engine_status; + GpsStatusValue fix_session_status; + + // Aiding data information to be deleted, aiding data can only be deleted when GPS engine is off + GpsAidingData aiding_data_for_deletion; + + // For muting session broadcast + loc_mute_session_e_type mute_session_state; + + // For nmea generation + boolean generateNmea; + uint32_t gps_used_mask; + uint32_t glo_used_mask; + float hdop; + float pdop; + float vdop; + + // Address buffers, for addressing setting before init + int supl_host_set; + char supl_host_buf[101]; + int supl_port_buf; + int c2k_host_set; + char c2k_host_buf[101]; + int c2k_port_buf; + int mpc_host_set; + char mpc_host_buf[101]; + int mpc_port_buf; + + loc_ext_parser location_ext_parser; + loc_ext_parser sv_ext_parser; +} loc_eng_data_s_type; + +/* GPS.conf support */ +/* NOTE: the implementaiton of the parser casts number + fields to 32 bit. To ensure all 'n' fields working, + they must all be 32 bit fields. */ +typedef struct loc_gps_cfg_s +{ + uint32_t INTERMEDIATE_POS; + uint32_t ACCURACY_THRES; + uint32_t SUPL_VER; + uint32_t SUPL_MODE; + uint32_t CAPABILITIES; + uint32_t LPP_PROFILE; + uint32_t XTRA_VERSION_CHECK; + char XTRA_SERVER_1[MAX_XTRA_SERVER_URL_LENGTH]; + char XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH]; + char XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH]; + uint32_t USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL; + uint32_t NMEA_PROVIDER; + uint32_t GPS_LOCK; + uint32_t A_GLONASS_POS_PROTOCOL_SELECT; + uint32_t AGPS_CERT_WRITABLE_MASK; +} loc_gps_cfg_s_type; + +/* NOTE: the implementaiton of the parser casts number + fields to 32 bit. To ensure all 'n' fields working, + they must all be 32 bit fields. */ +/* Meanwhile, *_valid fields are 8 bit fields, and 'f' + fields are double. Rigid as they are, it is the + the status quo, until the parsing mechanism is + change, that is. */ +typedef struct +{ + uint8_t GYRO_BIAS_RANDOM_WALK_VALID; + double GYRO_BIAS_RANDOM_WALK; + uint32_t SENSOR_ACCEL_BATCHES_PER_SEC; + uint32_t SENSOR_ACCEL_SAMPLES_PER_BATCH; + uint32_t SENSOR_GYRO_BATCHES_PER_SEC; + uint32_t SENSOR_GYRO_SAMPLES_PER_BATCH; + uint32_t SENSOR_ACCEL_BATCHES_PER_SEC_HIGH; + uint32_t SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH; + uint32_t SENSOR_GYRO_BATCHES_PER_SEC_HIGH; + uint32_t SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH; + uint32_t SENSOR_CONTROL_MODE; + uint32_t SENSOR_USAGE; + uint32_t SENSOR_ALGORITHM_CONFIG_MASK; + uint8_t ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID; + double ACCEL_RANDOM_WALK_SPECTRAL_DENSITY; + uint8_t ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID; + double ANGLE_RANDOM_WALK_SPECTRAL_DENSITY; + uint8_t RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID; + double RATE_RANDOM_WALK_SPECTRAL_DENSITY; + uint8_t VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID; + double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY; + uint32_t SENSOR_PROVIDER; +} loc_sap_cfg_s_type; + +extern loc_gps_cfg_s_type gps_conf; +extern loc_sap_cfg_s_type sap_conf; + + +uint32_t getCarrierCapabilities(); + +//loc_eng functions +int loc_eng_init(loc_eng_data_s_type &loc_eng_data, + LocCallbacks* callbacks, + LOC_API_ADAPTER_EVENT_MASK_T event, + ContextBase* context); +int loc_eng_start(loc_eng_data_s_type &loc_eng_data); +int loc_eng_stop(loc_eng_data_s_type &loc_eng_data); +void loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data); +int loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data, + GpsUtcTime time, int64_t timeReference, + int uncertainty); +int loc_eng_inject_location(loc_eng_data_s_type &loc_eng_data, + double latitude, double longitude, + float accuracy); +void loc_eng_delete_aiding_data(loc_eng_data_s_type &loc_eng_data, + GpsAidingData f); +int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data, + LocPosMode ¶ms); +const void* loc_eng_get_extension(loc_eng_data_s_type &loc_eng_data, + const char* name); +int loc_eng_set_server_proxy(loc_eng_data_s_type &loc_eng_data, + LocServerType type, const char *hostname, int port); +void loc_eng_mute_one_session(loc_eng_data_s_type &loc_eng_data); +int loc_eng_read_config(void); + +//loc_eng_agps functions +void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, + AGpsExtCallbacks* callbacks); +int loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType, + const char* apn, AGpsBearerType bearerType); +int loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType); +int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType); +void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data, + int avaiable, const char* apn); +int loc_eng_agps_install_certificates(loc_eng_data_s_type &loc_eng_data, + const DerEncodedCertificate* certificates, + size_t length); + +//loc_eng_xtra functions +int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data, + GpsXtraExtCallbacks* callbacks); +int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data, + char* data, int length); +int loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data); +void loc_eng_xtra_version_check(loc_eng_data_s_type &loc_eng_data, int check); + +//loc_eng_ni functions +extern void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, + GpsNiExtCallbacks *callbacks); +extern void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data, + int notif_id, GpsUserResponseType user_response); +extern void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data, + const GpsNiNotification *notif, + const void* passThrough); +extern void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data); + +void loc_eng_configuration_update (loc_eng_data_s_type &loc_eng_data, + const char* config_data, int32_t length); +int loc_eng_gps_measurement_init(loc_eng_data_s_type &loc_eng_data, + GpsMeasurementCallbacks* callbacks); +void loc_eng_gps_measurement_close(loc_eng_data_s_type &loc_eng_data); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // LOC_ENG_H diff --git a/gps/loc_api/libloc_api_50001/loc_eng_agps.cpp b/gps/loc_api/libloc_api_50001/loc_eng_agps.cpp new file mode 100644 index 0000000..5016b5c --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_agps.cpp @@ -0,0 +1,970 @@ +/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_eng" + +#include +#include +#include +#include +#include +#include +#include + +//====================================================================== +// C callbacks +//====================================================================== + +// This is given to linked_list_add as the dealloc callback +// data -- an instance of Subscriber +static void deleteObj(void* data) +{ + delete (Subscriber*)data; +} + +// This is given to linked_list_search() as the comparison callback +// when the state manchine needs to process for particular subscriber +// fromCaller -- caller provides this obj +// fromList -- linked_list_search() function take this one from list +static bool hasSubscriber(void* fromCaller, void* fromList) +{ + Notification* notification = (Notification*)fromCaller; + Subscriber* s1 = (Subscriber*)fromList; + + return s1->forMe(*notification); +} + +// This is gvien to linked_list_search() to notify subscriber objs +// when the state machine needs to inform all subscribers of resource +// status changes, e.g. when resource is GRANTED. +// fromCaller -- caller provides this ptr to a Notification obj. +// fromList -- linked_list_search() function take this one from list +static bool notifySubscriber(void* fromCaller, void* fromList) +{ + Notification* notification = (Notification*)fromCaller; + Subscriber* s1 = (Subscriber*)fromList; + + // we notify every subscriber indiscriminatively + // each subscriber decides if this notification is interesting. + return s1->notifyRsrcStatus(*notification) && + // if we do not want to delete the subscriber from the + // the list, we must set this to false so this function + // returns false + notification->postNotifyDelete; +} + +//====================================================================== +// Notification +//====================================================================== +const int Notification::BROADCAST_ALL = 0x80000000; +const int Notification::BROADCAST_ACTIVE = 0x80000001; +const int Notification::BROADCAST_INACTIVE = 0x80000002; +const unsigned char DSStateMachine::MAX_START_DATA_CALL_RETRIES = 4; +const unsigned int DSStateMachine::DATA_CALL_RETRY_DELAY_MSEC = 500; +//====================================================================== +// Subscriber: BITSubscriber / ATLSubscriber / WIFISubscriber +//====================================================================== +bool Subscriber::forMe(Notification ¬ification) +{ + if (NULL != notification.rcver) { + return equals(notification.rcver); + } else { + return Notification::BROADCAST_ALL == notification.groupID || + (Notification::BROADCAST_ACTIVE == notification.groupID && + !isInactive()) || + (Notification::BROADCAST_INACTIVE == notification.groupID && + isInactive()); + } +} +bool BITSubscriber::equals(const Subscriber *s) const +{ + BITSubscriber* bitS = (BITSubscriber*)s; + + return (ID == bitS->ID && + (INADDR_NONE != (unsigned int)ID || + 0 == strncmp(mIPv6Addr, bitS->mIPv6Addr, sizeof(mIPv6Addr)))); +} + +bool BITSubscriber::notifyRsrcStatus(Notification ¬ification) +{ + bool notify = forMe(notification); + + if (notify) { + switch(notification.rsrcStatus) + { + case RSRC_UNSUBSCRIBE: + case RSRC_RELEASED: + loc_eng_dmn_conn_loc_api_server_data_conn( + LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, + GPSONE_LOC_API_IF_RELEASE_SUCCESS); + break; + case RSRC_DENIED: + loc_eng_dmn_conn_loc_api_server_data_conn( + LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, + GPSONE_LOC_API_IF_FAILURE); + break; + case RSRC_GRANTED: + loc_eng_dmn_conn_loc_api_server_data_conn( + LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, + GPSONE_LOC_API_IF_REQUEST_SUCCESS); + break; + default: + notify = false; + } + } + + return notify; +} + +bool ATLSubscriber::notifyRsrcStatus(Notification ¬ification) +{ + bool notify = forMe(notification); + + if (notify) { + switch(notification.rsrcStatus) + { + case RSRC_UNSUBSCRIBE: + case RSRC_RELEASED: + ((LocEngAdapter*)mLocAdapter)->atlCloseStatus(ID, 1); + break; + case RSRC_DENIED: + { + AGpsExtType type = mBackwardCompatibleMode ? + AGPS_TYPE_INVALID : mStateMachine->getType(); + ((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 0, + (char*)mStateMachine->getAPN(), + mStateMachine->getBearer(), + type); + } + break; + case RSRC_GRANTED: + { + AGpsExtType type = mBackwardCompatibleMode ? + AGPS_TYPE_INVALID : mStateMachine->getType(); + ((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 1, + (char*)mStateMachine->getAPN(), + mStateMachine->getBearer(), + type); + } + break; + default: + notify = false; + } + } + + return notify; +} + +bool WIFISubscriber::notifyRsrcStatus(Notification ¬ification) +{ + bool notify = forMe(notification); + + if (notify) { + switch(notification.rsrcStatus) + { + case RSRC_UNSUBSCRIBE: + break; + case RSRC_RELEASED: + loc_eng_dmn_conn_loc_api_server_data_conn( + senderId, + GPSONE_LOC_API_IF_RELEASE_SUCCESS); + break; + case RSRC_DENIED: + loc_eng_dmn_conn_loc_api_server_data_conn( + senderId, + GPSONE_LOC_API_IF_FAILURE); + break; + case RSRC_GRANTED: + loc_eng_dmn_conn_loc_api_server_data_conn( + senderId, + GPSONE_LOC_API_IF_REQUEST_SUCCESS); + break; + default: + notify = false; + } + } + + return notify; +} +bool DSSubscriber::notifyRsrcStatus(Notification ¬ification) +{ + bool notify = forMe(notification); + LOC_LOGD("DSSubscriber::notifyRsrcStatus. notify:%d \n",(int)(notify)); + if(notify) { + switch(notification.rsrcStatus) { + case RSRC_UNSUBSCRIBE: + case RSRC_RELEASED: + case RSRC_DENIED: + case RSRC_GRANTED: + ((DSStateMachine *)mStateMachine)->informStatus(notification.rsrcStatus, ID); + break; + default: + notify = false; + } + } + return notify; +} +void DSSubscriber :: setInactive() +{ + mIsInactive = true; + ((DSStateMachine *)mStateMachine)->informStatus(RSRC_UNSUBSCRIBE, ID); +} +//====================================================================== +// AgpsState: AgpsReleasedState / AgpsPendingState / AgpsAcquiredState +//====================================================================== + +// AgpsReleasedState +class AgpsReleasedState : public AgpsState +{ + friend class AgpsStateMachine; + + inline AgpsReleasedState(AgpsStateMachine* stateMachine) : + AgpsState(stateMachine) + { mReleasedState = this; } + + inline ~AgpsReleasedState() {} +public: + virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data); + inline virtual char* whoami() {return (char*)"AgpsReleasedState";} +}; + +AgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data) +{ + LOC_LOGD("AgpsReleasedState::onRsrcEvent; event:%d\n", (int)event); + if (mStateMachine->hasSubscribers()) { + LOC_LOGE("Error: %s subscriber list not empty!!!", whoami()); + // I don't know how to recover from it. I am adding this rather + // for debugging purpose. + } + + AgpsState* nextState = this; + switch (event) + { + case RSRC_SUBSCRIBE: + { + // no notification until we get RSRC_GRANTED + // but we need to add subscriber to the list + mStateMachine->addSubscriber((Subscriber*)data); + // request from connecivity service for NIF + //The if condition is added so that if the data call setup fails + //for DS State Machine, we want to retry in released state. + //for AGps State Machine, sendRsrcRequest() will always return success + if(!mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN)) { + // move the state to PENDING + nextState = mPendingState; + } + } + break; + + case RSRC_UNSUBSCRIBE: + { + // the list should really be empty, nothing to remove. + // but we might as well just tell the client it is + // unsubscribed. False tolerance, right? + Subscriber* subscriber = (Subscriber*) data; + Notification notification(subscriber, event, false); + subscriber->notifyRsrcStatus(notification); + } + // break; + case RSRC_GRANTED: + case RSRC_RELEASED: + case RSRC_DENIED: + default: + LOC_LOGW("%s: unrecognized event %d", whoami(), event); + // no state change. + break; + } + + LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d", + whoami(), nextState->whoami(), event); + return nextState; +} + +// AgpsPendingState +class AgpsPendingState : public AgpsState +{ + friend class AgpsStateMachine; + + inline AgpsPendingState(AgpsStateMachine* stateMachine) : + AgpsState(stateMachine) + { mPendingState = this; } + + inline ~AgpsPendingState() {} +public: + virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data); + inline virtual char* whoami() {return (char*)"AgpsPendingState";} +}; + +AgpsState* AgpsPendingState::onRsrcEvent(AgpsRsrcStatus event, void* data) +{ + AgpsState* nextState = this;; + LOC_LOGD("AgpsPendingState::onRsrcEvent; event:%d\n", (int)event); + switch (event) + { + case RSRC_SUBSCRIBE: + { + // already requested for NIF resource, + // do nothing until we get RSRC_GRANTED indication + // but we need to add subscriber to the list + mStateMachine->addSubscriber((Subscriber*)data); + // no state change. + } + break; + + case RSRC_UNSUBSCRIBE: + { + Subscriber* subscriber = (Subscriber*) data; + if (subscriber->waitForCloseComplete()) { + subscriber->setInactive(); + } else { + // auto notify this subscriber of the unsubscribe + Notification notification(subscriber, event, true); + mStateMachine->notifySubscribers(notification); + } + + // now check if there is any subscribers left + if (!mStateMachine->hasSubscribers()) { + // no more subscribers, move to RELEASED state + nextState = mReleasedState; + + // tell connecivity service we can release NIF + mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN); + } else if (!mStateMachine->hasActiveSubscribers()) { + // only inactive subscribers, move to RELEASING state + nextState = mReleasingState; + + // tell connecivity service we can release NIF + mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN); + } + } + break; + + case RSRC_GRANTED: + { + nextState = mAcquiredState; + Notification notification(Notification::BROADCAST_ACTIVE, event, false); + // notify all subscribers NIF resource GRANTED + // by setting false, we keep subscribers on the linked list + mStateMachine->notifySubscribers(notification); + } + break; + + case RSRC_RELEASED: + // no state change. + // we are expecting either GRANTED or DENIED. Handling RELEASED + // may like break our state machine in race conditions. + break; + + case RSRC_DENIED: + { + nextState = mReleasedState; + Notification notification(Notification::BROADCAST_ALL, event, true); + // notify all subscribers NIF resource RELEASED or DENIED + // by setting true, we remove subscribers from the linked list + mStateMachine->notifySubscribers(notification); + } + break; + + default: + LOC_LOGE("%s: unrecognized event %d", whoami(), event); + // no state change. + } + + LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d", + whoami(), nextState->whoami(), event); + return nextState; +} + + +class AgpsAcquiredState : public AgpsState +{ + friend class AgpsStateMachine; + + inline AgpsAcquiredState(AgpsStateMachine* stateMachine) : + AgpsState(stateMachine) + { mAcquiredState = this; } + + inline ~AgpsAcquiredState() {} +public: + virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data); + inline virtual char* whoami() { return (char*)"AgpsAcquiredState"; } +}; + + +AgpsState* AgpsAcquiredState::onRsrcEvent(AgpsRsrcStatus event, void* data) +{ + AgpsState* nextState = this; + LOC_LOGD("AgpsAcquiredState::onRsrcEvent; event:%d\n", (int)event); + switch (event) + { + case RSRC_SUBSCRIBE: + { + // we already have the NIF resource, simply notify subscriber + Subscriber* subscriber = (Subscriber*) data; + // we have rsrc in hand, so grant it right away + Notification notification(subscriber, RSRC_GRANTED, false); + subscriber->notifyRsrcStatus(notification); + // add subscriber to the list + mStateMachine->addSubscriber(subscriber); + // no state change. + } + break; + + case RSRC_UNSUBSCRIBE: + { + Subscriber* subscriber = (Subscriber*) data; + if (subscriber->waitForCloseComplete()) { + subscriber->setInactive(); + } else { + // auto notify this subscriber of the unsubscribe + Notification notification(subscriber, event, true); + mStateMachine->notifySubscribers(notification); + } + + // now check if there is any subscribers left + if (!mStateMachine->hasSubscribers()) { + // no more subscribers, move to RELEASED state + nextState = mReleasedState; + + // tell connecivity service we can release NIF + mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN); + } else if (!mStateMachine->hasActiveSubscribers()) { + // only inactive subscribers, move to RELEASING state + nextState = mReleasingState; + + // tell connecivity service we can release NIF + mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN); + } + } + break; + + case RSRC_GRANTED: + LOC_LOGW("%s: %d, RSRC_GRANTED already received", whoami(), event); + // no state change. + break; + + case RSRC_RELEASED: + { + LOC_LOGW("%s: %d, a force rsrc release", whoami(), event); + nextState = mReleasedState; + Notification notification(Notification::BROADCAST_ALL, event, true); + // by setting true, we remove subscribers from the linked list + mStateMachine->notifySubscribers(notification); + } + break; + + case RSRC_DENIED: + // no state change. + // we are expecting RELEASED. Handling DENIED + // may like break our state machine in race conditions. + break; + + default: + LOC_LOGE("%s: unrecognized event %d", whoami(), event); + // no state change. + } + + LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d", + whoami(), nextState->whoami(), event); + return nextState; +} + +// AgpsPendingState +class AgpsReleasingState : public AgpsState +{ + friend class AgpsStateMachine; + + inline AgpsReleasingState(AgpsStateMachine* stateMachine) : + AgpsState(stateMachine) + { mReleasingState = this; } + + inline ~AgpsReleasingState() {} +public: + virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data); + inline virtual char* whoami() {return (char*)"AgpsReleasingState";} +}; + +AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data) +{ + AgpsState* nextState = this;; + LOC_LOGD("AgpsReleasingState::onRsrcEvent; event:%d\n", (int)event); + + switch (event) + { + case RSRC_SUBSCRIBE: + { + // already requested for NIF resource, + // do nothing until we get RSRC_GRANTED indication + // but we need to add subscriber to the list + mStateMachine->addSubscriber((Subscriber*)data); + // no state change. + } + break; + + case RSRC_UNSUBSCRIBE: + { + Subscriber* subscriber = (Subscriber*) data; + if (subscriber->waitForCloseComplete()) { + subscriber->setInactive(); + } else { + // auto notify this subscriber of the unsubscribe + Notification notification(subscriber, event, true); + mStateMachine->notifySubscribers(notification); + } + + // now check if there is any subscribers left + if (!mStateMachine->hasSubscribers()) { + // no more subscribers, move to RELEASED state + nextState = mReleasedState; + } + } + break; + + case RSRC_DENIED: + // A race condition subscriber unsubscribes before AFW denies resource. + case RSRC_RELEASED: + { + nextState = mAcquiredState; + Notification notification(Notification::BROADCAST_INACTIVE, event, true); + // notify all subscribers that are active NIF resource RELEASE + // by setting false, we keep subscribers on the linked list + mStateMachine->notifySubscribers(notification); + + if (mStateMachine->hasActiveSubscribers()) { + nextState = mPendingState; + // request from connecivity service for NIF + mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN); + } else { + nextState = mReleasedState; + } + } + break; + + case RSRC_GRANTED: + default: + LOC_LOGE("%s: unrecognized event %d", whoami(), event); + // no state change. + } + + LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d", + whoami(), nextState->whoami(), event); + return nextState; +} +//====================================================================== +//Servicer +//====================================================================== +Servicer* Servicer :: getServicer(servicerType type, void *cb_func) +{ + LOC_LOGD(" Enter getServicer type:%d\n", (int)type); + switch(type) { + case servicerTypeNoCbParam: + return (new Servicer(cb_func)); + case servicerTypeExt: + return (new ExtServicer(cb_func)); + case servicerTypeAgps: + return (new AGpsServicer(cb_func)); + default: + return NULL; + } +} + +int Servicer :: requestRsrc(void *cb_data) +{ + callback(); + return 0; +} + +int ExtServicer :: requestRsrc(void *cb_data) +{ + int ret=-1; + LOC_LOGD("Enter ExtServicer :: requestRsrc\n"); + ret = callbackExt(cb_data); + LOC_LOGD("Exit ExtServicer :: requestRsrc\n"); + return(ret); +} + +int AGpsServicer :: requestRsrc(void *cb_data) +{ + callbackAGps((AGpsStatus *)cb_data); + return 0; +} + +//====================================================================== +// AgpsStateMachine +//====================================================================== + +AgpsStateMachine::AgpsStateMachine(servicerType servType, + void *cb_func, + AGpsExtType type, + bool enforceSingleSubscriber) : + mStatePtr(new AgpsReleasedState(this)),mType(type), + mAPN(NULL), + mAPNLen(0), + mBearer(AGPS_APN_BEARER_INVALID), + mEnforceSingleSubscriber(enforceSingleSubscriber), + mServicer(Servicer :: getServicer(servType, (void *)cb_func)) +{ + linked_list_init(&mSubscribers); + + // setting up mReleasedState + mStatePtr->mPendingState = new AgpsPendingState(this); + mStatePtr->mAcquiredState = new AgpsAcquiredState(this); + mStatePtr->mReleasingState = new AgpsReleasingState(this); + + // setting up mAcquiredState + mStatePtr->mAcquiredState->mReleasedState = mStatePtr; + mStatePtr->mAcquiredState->mPendingState = mStatePtr->mPendingState; + mStatePtr->mAcquiredState->mReleasingState = mStatePtr->mReleasingState; + + // setting up mPendingState + mStatePtr->mPendingState->mAcquiredState = mStatePtr->mAcquiredState; + mStatePtr->mPendingState->mReleasedState = mStatePtr; + mStatePtr->mPendingState->mReleasingState = mStatePtr->mReleasingState; + + // setting up mReleasingState + mStatePtr->mReleasingState->mReleasedState = mStatePtr; + mStatePtr->mReleasingState->mPendingState = mStatePtr->mPendingState; + mStatePtr->mReleasingState->mAcquiredState = mStatePtr->mAcquiredState; +} + +AgpsStateMachine::~AgpsStateMachine() +{ + dropAllSubscribers(); + + // free the 3 states. We must read out all 3 pointers first. + // Otherwise we run the risk of getting pointers from already + // freed memory. + AgpsState* acquiredState = mStatePtr->mAcquiredState; + AgpsState* releasedState = mStatePtr->mReleasedState; + AgpsState* pendindState = mStatePtr->mPendingState; + AgpsState* releasingState = mStatePtr->mReleasingState; + + delete acquiredState; + delete releasedState; + delete pendindState; + delete releasingState; + delete mServicer; + linked_list_destroy(&mSubscribers); + + if (NULL != mAPN) { + delete[] mAPN; + mAPN = NULL; + } +} + +void AgpsStateMachine::setAPN(const char* apn, unsigned int len) +{ + if (NULL != mAPN) { + delete mAPN; + } + + if (NULL != apn) { + mAPN = new char[len+1]; + memcpy(mAPN, apn, len); + mAPN[len] = NULL; + + mAPNLen = len; + } else { + mAPN = NULL; + mAPNLen = 0; + } +} + +void AgpsStateMachine::onRsrcEvent(AgpsRsrcStatus event) +{ + switch (event) + { + case RSRC_GRANTED: + case RSRC_RELEASED: + case RSRC_DENIED: + mStatePtr = mStatePtr->onRsrcEvent(event, NULL); + break; + default: + LOC_LOGW("AgpsStateMachine: unrecognized event %d", event); + break; + } +} + +void AgpsStateMachine::notifySubscribers(Notification& notification) const +{ + if (notification.postNotifyDelete) { + // just any non NULL value to get started + Subscriber* s = (Subscriber*)~0; + while (NULL != s) { + s = NULL; + // if the last param sets to true, _search will delete + // the node from the list for us. But the problem is + // once that is done, _search returns, leaving the + // rest of the list unprocessed. So we need a loop. + linked_list_search(mSubscribers, (void**)&s, notifySubscriber, + (void*)¬ification, true); + delete s; + } + } else { + // no loop needed if it the last param sets to false, which + // mean nothing gets deleted from the list. + linked_list_search(mSubscribers, NULL, notifySubscriber, + (void*)¬ification, false); + } +} + +void AgpsStateMachine::addSubscriber(Subscriber* subscriber) const +{ + Subscriber* s = NULL; + Notification notification((const Subscriber*)subscriber); + linked_list_search(mSubscribers, (void**)&s, + hasSubscriber, (void*)¬ification, false); + + if (NULL == s) { + linked_list_add(mSubscribers, subscriber->clone(), deleteObj); + } +} + +int AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const +{ + Subscriber* s = NULL; + Notification notification(Notification::BROADCAST_ACTIVE); + linked_list_search(mSubscribers, (void**)&s, hasSubscriber, + (void*)¬ification, false); + + if ((NULL == s) == (GPS_RELEASE_AGPS_DATA_CONN == action)) { + AGpsExtStatus nifRequest; + nifRequest.size = sizeof(nifRequest); + nifRequest.type = mType; + nifRequest.status = action; + + if (s == NULL) { + nifRequest.ipv4_addr = INADDR_NONE; + memset(&nifRequest.addr, 0, sizeof(nifRequest.addr)); + nifRequest.ssid[0] = '\0'; + nifRequest.password[0] = '\0'; + } else { + s->setIPAddresses(nifRequest.addr); + s->setWifiInfo(nifRequest.ssid, nifRequest.password); + } + + CALLBACK_LOG_CALLFLOW("agps_cb", %s, loc_get_agps_status_name(action)); + mServicer->requestRsrc((void *)&nifRequest); + } + return 0; +} + +void AgpsStateMachine::subscribeRsrc(Subscriber *subscriber) +{ + if (mEnforceSingleSubscriber && hasSubscribers()) { + Notification notification(Notification::BROADCAST_ALL, RSRC_DENIED, true); + notifySubscriber(¬ification, subscriber); + } else { + mStatePtr = mStatePtr->onRsrcEvent(RSRC_SUBSCRIBE, (void*)subscriber); + } +} + +bool AgpsStateMachine::unsubscribeRsrc(Subscriber *subscriber) +{ + Subscriber* s = NULL; + Notification notification((const Subscriber*)subscriber); + linked_list_search(mSubscribers, (void**)&s, + hasSubscriber, (void*)¬ification, false); + + if (NULL != s) { + mStatePtr = mStatePtr->onRsrcEvent(RSRC_UNSUBSCRIBE, (void*)s); + return true; + } + return false; +} + +bool AgpsStateMachine::hasActiveSubscribers() const +{ + Subscriber* s = NULL; + Notification notification(Notification::BROADCAST_ACTIVE); + linked_list_search(mSubscribers, (void**)&s, + hasSubscriber, (void*)¬ification, false); + return NULL != s; +} + +//====================================================================== +// DSStateMachine +//====================================================================== +void delay_callback(void *callbackData, int result) +{ + if(callbackData) { + DSStateMachine *DSSMInstance = (DSStateMachine *)callbackData; + DSSMInstance->retryCallback(); + } + else { + LOC_LOGE(" NULL argument received. Failing.\n"); + goto err; + } +err: + return; +} + +DSStateMachine :: DSStateMachine(servicerType type, void *cb_func, + LocEngAdapter* adapterHandle): + AgpsStateMachine(type, cb_func, AGPS_TYPE_INVALID,false), + mLocAdapter(adapterHandle) +{ + LOC_LOGD("%s:%d]: New DSStateMachine\n", __func__, __LINE__); + mRetries = 0; +} + +void DSStateMachine :: retryCallback(void) +{ + DSSubscriber *subscriber = NULL; + Notification notification(Notification::BROADCAST_ACTIVE); + linked_list_search(mSubscribers, (void**)&subscriber, hasSubscriber, + (void*)¬ification, false); + if(subscriber) + mLocAdapter->requestSuplES(subscriber->ID); + else + LOC_LOGE("DSStateMachine :: retryCallback: No subscriber found." \ + "Cannot retry data call\n"); + return; +} + +int DSStateMachine :: sendRsrcRequest(AGpsStatusValue action) const +{ + DSSubscriber* s = NULL; + dsCbData cbData; + int ret=-1; + int connHandle=-1; + LOC_LOGD("Enter DSStateMachine :: sendRsrcRequest\n"); + Notification notification(Notification::BROADCAST_ACTIVE); + linked_list_search(mSubscribers, (void**)&s, hasSubscriber, + (void*)¬ification, false); + if(s) { + connHandle = s->ID; + LOC_LOGD("DSStateMachine :: sendRsrcRequest - subscriber found\n"); + } + else + LOC_LOGD("DSStateMachine :: sendRsrcRequest - No subscriber found\n"); + + cbData.action = action; + cbData.mAdapter = mLocAdapter; + ret = mServicer->requestRsrc((void *)&cbData); + //Only the request to start data call returns a success/failure + //The request to stop data call will always succeed + //Hence, the below block will only be executed when the + //request to start the data call fails + switch(ret) { + case LOC_API_ADAPTER_ERR_ENGINE_BUSY: + LOC_LOGD("DSStateMachine :: sendRsrcRequest - Failure returned: %d\n",ret); + ((DSStateMachine *)this)->incRetries(); + if(mRetries > MAX_START_DATA_CALL_RETRIES) { + LOC_LOGE(" Failed to start Data call. Fallback to normal ATL SUPL\n"); + informStatus(RSRC_DENIED, connHandle); + } + else { + if(loc_timer_start(DATA_CALL_RETRY_DELAY_MSEC, delay_callback, (void *)this)) { + LOC_LOGE("Error: Could not start delay thread\n"); + ret = -1; + goto err; + } + } + break; + case LOC_API_ADAPTER_ERR_UNSUPPORTED: + LOC_LOGE("No profile found for emergency call. Fallback to normal SUPL ATL\n"); + informStatus(RSRC_DENIED, connHandle); + break; + case LOC_API_ADAPTER_ERR_SUCCESS: + LOC_LOGD("%s:%d]: Request to start data call sent\n", __func__, __LINE__); + break; + case -1: + //One of the ways this case can be encountered is if the callback function + //receives a null argument, it just exits with -1 error + LOC_LOGE("Error: Something went wrong somewhere. Falling back to normal SUPL ATL\n"); + informStatus(RSRC_DENIED, connHandle); + break; + default: + LOC_LOGE("%s:%d]: Unrecognized return value\n", __func__, __LINE__); + } +err: + LOC_LOGD("EXIT DSStateMachine :: sendRsrcRequest; ret = %d\n", ret); + return ret; +} + +void DSStateMachine :: onRsrcEvent(AgpsRsrcStatus event) +{ + void* currState = (void *)mStatePtr; + LOC_LOGD("Enter DSStateMachine :: onRsrcEvent. event = %d\n", (int)event); + switch (event) + { + case RSRC_GRANTED: + LOC_LOGD("DSStateMachine :: onRsrcEvent RSRC_GRANTED\n"); + mStatePtr = mStatePtr->onRsrcEvent(event, NULL); + break; + case RSRC_RELEASED: + LOC_LOGD("DSStateMachine :: onRsrcEvent RSRC_RELEASED\n"); + mStatePtr = mStatePtr->onRsrcEvent(event, NULL); + //To handle the case where we get a RSRC_RELEASED in + //pending state, we translate that to a RSRC_DENIED state + //since the callback from DSI is either RSRC_GRANTED or RSRC_RELEASED + //for when the call is connected or disconnected respectively. + if((void *)mStatePtr != currState) + break; + else { + event = RSRC_DENIED; + LOC_LOGE(" Switching event to RSRC_DENIED\n"); + } + case RSRC_DENIED: + mStatePtr = mStatePtr->onRsrcEvent(event, NULL); + break; + default: + LOC_LOGW("AgpsStateMachine: unrecognized event %d", event); + break; + } + LOC_LOGD("Exit DSStateMachine :: onRsrcEvent. event = %d\n", (int)event); +} + +void DSStateMachine :: informStatus(AgpsRsrcStatus status, int ID) const +{ + LOC_LOGD("DSStateMachine :: informStatus. Status=%d\n",(int)status); + switch(status) { + case RSRC_UNSUBSCRIBE: + mLocAdapter->atlCloseStatus(ID, 1); + break; + case RSRC_RELEASED: + mLocAdapter->closeDataCall(); + break; + case RSRC_DENIED: + ((DSStateMachine *)this)->mRetries = 0; + mLocAdapter->requestATL(ID, AGPS_TYPE_SUPL); + break; + case RSRC_GRANTED: + mLocAdapter->atlOpenStatus(ID, 1, + NULL, + AGPS_APN_BEARER_INVALID, + AGPS_TYPE_INVALID); + break; + default: + LOC_LOGW("DSStateMachine :: informStatus - unknown status"); + } + return; +} diff --git a/gps/loc_api/libloc_api_50001/loc_eng_agps.h b/gps/loc_api/libloc_api_50001/loc_eng_agps.h new file mode 100644 index 0000000..2d689ce --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_agps.h @@ -0,0 +1,431 @@ +/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __LOC_ENG_AGPS_H__ +#define __LOC_ENG_AGPS_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// forward declaration +class AgpsStateMachine; +class Subscriber; + +// NIF resource events +typedef enum { + RSRC_SUBSCRIBE, + RSRC_UNSUBSCRIBE, + RSRC_GRANTED, + RSRC_RELEASED, + RSRC_DENIED, + RSRC_STATUS_MAX +} AgpsRsrcStatus; + +typedef enum { + servicerTypeNoCbParam, + servicerTypeAgps, + servicerTypeExt +}servicerType; + +//DS Callback struct +typedef struct { + LocEngAdapter *mAdapter; + AGpsStatusValue action; +}dsCbData; + +// information bundle for subscribers +struct Notification { + // goes to every subscriber + static const int BROADCAST_ALL; + // goes to every ACTIVE subscriber + static const int BROADCAST_ACTIVE; + // goes to every INACTIVE subscriber + static const int BROADCAST_INACTIVE; + + // go to a specific subscriber + const Subscriber* rcver; + // broadcast + const int groupID; + // the new resource status event + const AgpsRsrcStatus rsrcStatus; + // should the subscriber be deleted after the notification + const bool postNotifyDelete; + + // convenient constructor + inline Notification(const int broadcast, + const AgpsRsrcStatus status, + const bool deleteAfterwards) : + rcver(NULL), groupID(broadcast), rsrcStatus(status), + postNotifyDelete(deleteAfterwards) {} + + // convenient constructor + inline Notification(const Subscriber* subscriber, + const AgpsRsrcStatus status, + const bool deleteAfterwards) : + rcver(subscriber), groupID(-1), rsrcStatus(status), + postNotifyDelete(deleteAfterwards) {} + + // convenient constructor + inline Notification(const int broadcast) : + rcver(NULL), groupID(broadcast), rsrcStatus(RSRC_STATUS_MAX), + postNotifyDelete(false) {} + + // convenient constructor + inline Notification(const Subscriber* subscriber) : + rcver(subscriber), groupID(-1), rsrcStatus(RSRC_STATUS_MAX), + postNotifyDelete(false) {} +}; + +class AgpsState { + // allows AgpsStateMachine to access private data + // no class members are public. We don't want + // anyone but state machine to use state. + friend class AgpsStateMachine; + friend class DSStateMachine; + // state transitions are done here. + // Each state implements its own transitions (of course). + inline virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data) = 0; + +protected: + // handle back to state machine + const AgpsStateMachine* mStateMachine; + // each state has pointers to all 3 states + // one of which is to itself. + AgpsState* mReleasedState; + AgpsState* mAcquiredState; + AgpsState* mPendingState; + AgpsState* mReleasingState; + + inline AgpsState(const AgpsStateMachine *stateMachine) : + mStateMachine(stateMachine), + mReleasedState(NULL), + mAcquiredState(NULL), + mPendingState(NULL), + mReleasingState(NULL) {} + virtual ~AgpsState() {} + +public: + // for logging purpose + inline virtual char* whoami() = 0; +}; + +class Servicer { + void (*callback)(void); +public: + static Servicer* getServicer(servicerType type, void *cb_func); + virtual int requestRsrc(void *cb_data); + Servicer() {} + Servicer(void *cb_func) + { callback = (void(*)(void))(cb_func); } + virtual ~Servicer(){} + inline virtual char *whoami() {return (char*)"Servicer";} +}; + +class ExtServicer : public Servicer { + int (*callbackExt)(void *cb_data); +public: + int requestRsrc(void *cb_data); + ExtServicer() {} + ExtServicer(void *cb_func) + { callbackExt = (int(*)(void *))(cb_func); } + virtual ~ExtServicer(){} + inline virtual char *whoami() {return (char*)"ExtServicer";} +}; + +class AGpsServicer : public Servicer { + void (*callbackAGps)(AGpsStatus* status); +public: + int requestRsrc(void *cb_data); + AGpsServicer() {} + AGpsServicer(void *cb_func) + { callbackAGps = (void(*)(AGpsStatus *))(cb_func); } + virtual ~AGpsServicer(){} + inline virtual char *whoami() {return (char*)"AGpsServicer";} +}; + +class AgpsStateMachine { +protected: + // a linked list of subscribers. + void* mSubscribers; + //handle to whoever provides the service + Servicer *mServicer; + // allows AgpsState to access private data + // each state is really internal data to the + // state machine, so it should be able to + // access anything within the state machine. + friend class AgpsState; + // pointer to the current state. + AgpsState* mStatePtr; +private: + // NIF type: AGNSS or INTERNET. + const AGpsExtType mType; + // apn to the NIF. Each state machine tracks + // resource state of a particular NIF. For each + // NIF, there is also an active APN. + char* mAPN; + // for convenience, we don't do strlen each time. + unsigned int mAPNLen; + // bear + AGpsBearerType mBearer; + // ipv4 address for routing + bool mEnforceSingleSubscriber; + +public: + AgpsStateMachine(servicerType servType, void *cb_func, + AGpsExtType type, bool enforceSingleSubscriber); + virtual ~AgpsStateMachine(); + + // self explanatory methods below + void setAPN(const char* apn, unsigned int len); + inline const char* getAPN() const { return (const char*)mAPN; } + inline void setBearer(AGpsBearerType bearer) { mBearer = bearer; } + inline AGpsBearerType getBearer() const { return mBearer; } + inline AGpsExtType getType() const { return (AGpsExtType)mType; } + + // someone, a ATL client or BIT, is asking for NIF + void subscribeRsrc(Subscriber *subscriber); + + // someone, a ATL client or BIT, is done with NIF + bool unsubscribeRsrc(Subscriber *subscriber); + + // add a subscriber in the linked list, if not already there. + void addSubscriber(Subscriber* subscriber) const; + + virtual void onRsrcEvent(AgpsRsrcStatus event); + + // put the data together and send the FW + virtual int sendRsrcRequest(AGpsStatusValue action) const; + + //if list is empty, linked_list_empty returns 1 + //else if list is not empty, returns 0 + //so hasSubscribers() returns 1 if list is not empty + //and returns 0 if list is empty + inline bool hasSubscribers() const + { return !linked_list_empty(mSubscribers); } + + bool hasActiveSubscribers() const; + + inline void dropAllSubscribers() const + { linked_list_flush(mSubscribers); } + + // private. Only a state gets to call this. + void notifySubscribers(Notification& notification) const; + +}; + +class DSStateMachine : public AgpsStateMachine { + static const unsigned char MAX_START_DATA_CALL_RETRIES; + static const unsigned int DATA_CALL_RETRY_DELAY_MSEC; + LocEngAdapter* mLocAdapter; + unsigned char mRetries; +public: + DSStateMachine(servicerType type, + void *cb_func, + LocEngAdapter* adapterHandle); + int sendRsrcRequest(AGpsStatusValue action) const; + void onRsrcEvent(AgpsRsrcStatus event); + void retryCallback(); + void informStatus(AgpsRsrcStatus status, int ID) const; + inline void incRetries() {mRetries++;} + inline virtual char *whoami() {return (char*)"DSStateMachine";} +}; + +// each subscriber is a AGPS client. In the case of ATL, there could be +// multiple clients from modem. In the case of BIT, there is only one +// cilent from BIT daemon. +struct Subscriber { + const uint32_t ID; + const AgpsStateMachine* mStateMachine; + inline Subscriber(const int id, + const AgpsStateMachine* stateMachine) : + ID(id), mStateMachine(stateMachine) {} + inline virtual ~Subscriber() {} + + virtual void setIPAddresses(uint32_t &v4, char* v6) = 0; + virtual void setIPAddresses(struct sockaddr_storage& addr) = 0; + inline virtual void setWifiInfo(char* ssid, char* password) + { ssid[0] = 0; password[0] = 0; } + + inline virtual bool equals(const Subscriber *s) const + { return ID == s->ID; } + + // notifies a subscriber a new NIF resource status, usually + // either GRANTE, DENIED, or RELEASED + virtual bool notifyRsrcStatus(Notification ¬ification) = 0; + + virtual bool waitForCloseComplete() { return false; } + virtual void setInactive() {} + virtual bool isInactive() { return false; } + + virtual Subscriber* clone() = 0; + // checks if this notification is for me, i.e. + // either has my id, or has a broadcast id. + bool forMe(Notification ¬ification); +}; + +// BITSubscriber, created with requests from BIT daemon +struct BITSubscriber : public Subscriber { + char mIPv6Addr[16]; + + inline BITSubscriber(const AgpsStateMachine* stateMachine, + unsigned int ipv4, char* ipv6) : + Subscriber(ipv4, stateMachine) + { + if (NULL == ipv6) { + mIPv6Addr[0] = 0; + } else { + memcpy(mIPv6Addr, ipv6, sizeof(mIPv6Addr)); + } + } + + virtual bool notifyRsrcStatus(Notification ¬ification); + + inline virtual void setIPAddresses(uint32_t &v4, char* v6) + { v4 = ID; memcpy(v6, mIPv6Addr, sizeof(mIPv6Addr)); } + + inline virtual void setIPAddresses(struct sockaddr_storage& addr) + { addr.ss_family = AF_INET6;/*todo: convert mIPv6Addr into addr */ } + + virtual Subscriber* clone() + { + return new BITSubscriber(mStateMachine, ID, mIPv6Addr); + } + + virtual bool equals(const Subscriber *s) const; + inline virtual ~BITSubscriber(){} +}; + +// ATLSubscriber, created with requests from ATL +struct ATLSubscriber : public Subscriber { + const LocEngAdapter* mLocAdapter; + const bool mBackwardCompatibleMode; + inline ATLSubscriber(const int id, + const AgpsStateMachine* stateMachine, + const LocEngAdapter* adapter, + const bool compatibleMode) : + Subscriber(id, stateMachine), mLocAdapter(adapter), + mBackwardCompatibleMode(compatibleMode){} + virtual bool notifyRsrcStatus(Notification ¬ification); + + inline virtual void setIPAddresses(uint32_t &v4, char* v6) + { v4 = INADDR_NONE; v6[0] = 0; } + + inline virtual void setIPAddresses(struct sockaddr_storage& addr) + { addr.ss_family = AF_INET6; } + + inline virtual Subscriber* clone() + { + return new ATLSubscriber(ID, mStateMachine, mLocAdapter, + mBackwardCompatibleMode); + } + inline virtual ~ATLSubscriber(){} +}; + +// WIFISubscriber, created with requests from MSAPM or QuIPC +struct WIFISubscriber : public Subscriber { + char * mSSID; + char * mPassword; + loc_if_req_sender_id_e_type senderId; + bool mIsInactive; + inline WIFISubscriber(const AgpsStateMachine* stateMachine, + char * ssid, char * password, loc_if_req_sender_id_e_type sender_id) : + Subscriber(sender_id, stateMachine), + mSSID(NULL == ssid ? NULL : new char[SSID_BUF_SIZE]), + mPassword(NULL == password ? NULL : new char[SSID_BUF_SIZE]), + senderId(sender_id) + { + if (NULL != mSSID) + strlcpy(mSSID, ssid, SSID_BUF_SIZE); + if (NULL != mPassword) + strlcpy(mPassword, password, SSID_BUF_SIZE); + mIsInactive = false; + } + + virtual bool notifyRsrcStatus(Notification ¬ification); + + inline virtual void setIPAddresses(uint32_t &v4, char* v6) {} + + inline virtual void setIPAddresses(struct sockaddr_storage& addr) + { addr.ss_family = AF_INET6; } + + inline virtual void setWifiInfo(char* ssid, char* password) + { + if (NULL != mSSID) + strlcpy(ssid, mSSID, SSID_BUF_SIZE); + else + ssid[0] = '\0'; + if (NULL != mPassword) + strlcpy(password, mPassword, SSID_BUF_SIZE); + else + password[0] = '\0'; + } + + inline virtual bool waitForCloseComplete() { return true; } + + inline virtual void setInactive() { mIsInactive = true; } + inline virtual bool isInactive() { return mIsInactive; } + + virtual Subscriber* clone() + { + return new WIFISubscriber(mStateMachine, mSSID, mPassword, senderId); + } + inline virtual ~WIFISubscriber(){} +}; + +struct DSSubscriber : public Subscriber { + bool mIsInactive; + inline DSSubscriber(const AgpsStateMachine *stateMachine, + const int id) : + Subscriber(id, stateMachine) + { + mIsInactive = false; + } + inline virtual void setIPAddresses(uint32_t &v4, char* v6) {} + inline virtual void setIPAddresses(struct sockaddr_storage& addr) + { addr.ss_family = AF_INET6; } + virtual Subscriber* clone() + {return new DSSubscriber(mStateMachine, ID);} + virtual bool notifyRsrcStatus(Notification ¬ification); + inline virtual bool waitForCloseComplete() { return true; } + virtual void setInactive(); + inline virtual bool isInactive() + { return mIsInactive; } + inline virtual ~DSSubscriber(){} + inline virtual char *whoami() {return (char*)"DSSubscriber";} +}; + +#endif //__LOC_ENG_AGPS_H__ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp new file mode 100644 index 0000000..c257dff --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp @@ -0,0 +1,270 @@ +/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "log_util.h" +#include "platform_lib_includes.h" +#include "loc_eng_dmn_conn_glue_msg.h" +#include "loc_eng_dmn_conn_handler.h" +#include "loc_eng_dmn_conn.h" +#include "loc_eng_msg.h" + +static int loc_api_server_msgqid; +static int loc_api_resp_msgqid; +static int quipc_msgqid; +static int msapm_msgqid; +static int msapu_msgqid; + +static const char * global_loc_api_q_path = GPSONE_LOC_API_Q_PATH; +static const char * global_loc_api_resp_q_path = GPSONE_LOC_API_RESP_Q_PATH; +static const char * global_quipc_ctrl_q_path = QUIPC_CTRL_Q_PATH; +static const char * global_msapm_ctrl_q_path = MSAPM_CTRL_Q_PATH; +static const char * global_msapu_ctrl_q_path = MSAPU_CTRL_Q_PATH; + +static int loc_api_server_proc_init(void *context) +{ + loc_api_server_msgqid = loc_eng_dmn_conn_glue_msgget(global_loc_api_q_path, O_RDWR); + //change mode/group for the global_loc_api_q_path pipe + int result = chmod (global_loc_api_q_path, 0660); + if (result != 0) + { + LOC_LOGE("failed to change mode for %s, error = %s\n", global_loc_api_q_path, strerror(errno)); + } + + struct group * gps_group = getgrnam("gps"); + if (gps_group != NULL) + { + result = chown (global_loc_api_q_path, -1, gps_group->gr_gid); + if (result != 0) + { + LOC_LOGE("chown for pipe failed, pipe %s, gid = %d, result = %d, error = %s\n", + global_loc_api_q_path, gps_group->gr_gid, result, strerror(errno)); + } + } + else + { + LOC_LOGE("getgrnam for gps failed, error code = %d\n", errno); + } + + loc_api_resp_msgqid = loc_eng_dmn_conn_glue_msgget(global_loc_api_resp_q_path, O_RDWR); + + //change mode/group for the global_loc_api_resp_q_path pipe + result = chmod (global_loc_api_resp_q_path, 0660); + if (result != 0) + { + LOC_LOGE("failed to change mode for %s, error = %s\n", global_loc_api_resp_q_path, strerror(errno)); + } + + if (gps_group != NULL) + { + result = chown (global_loc_api_resp_q_path, -1, gps_group->gr_gid); + if (result != 0) + { + LOC_LOGE("chown for pipe failed, pipe %s, gid = %d, result = %d, error = %s\n", + global_loc_api_resp_q_path, + gps_group->gr_gid, result, strerror(errno)); + } + } + + quipc_msgqid = loc_eng_dmn_conn_glue_msgget(global_quipc_ctrl_q_path, O_RDWR); + msapm_msgqid = loc_eng_dmn_conn_glue_msgget(global_msapm_ctrl_q_path , O_RDWR); + msapu_msgqid = loc_eng_dmn_conn_glue_msgget(global_msapu_ctrl_q_path , O_RDWR); + + LOC_LOGD("%s:%d] loc_api_server_msgqid = %d\n", __func__, __LINE__, loc_api_server_msgqid); + return 0; +} + +static int loc_api_server_proc_pre(void *context) +{ + return 0; +} + +static int loc_api_server_proc(void *context) +{ + int length, sz; + int result = 0; + static int cnt = 0; + struct ctrl_msgbuf * p_cmsgbuf; + struct ctrl_msgbuf cmsg_resp; + + sz = sizeof(struct ctrl_msgbuf) + 256; + p_cmsgbuf = (struct ctrl_msgbuf *) malloc(sz); + + if (!p_cmsgbuf) { + LOC_LOGE("%s:%d] Out of memory\n", __func__, __LINE__); + return -1; + } + + cnt ++; + LOC_LOGD("%s:%d] %d listening on %s...\n", __func__, __LINE__, cnt, (char *) context); + length = loc_eng_dmn_conn_glue_msgrcv(loc_api_server_msgqid, p_cmsgbuf, sz); + if (length <= 0) { + free(p_cmsgbuf); + LOC_LOGE("%s:%d] fail receiving msg from gpsone_daemon, retry later\n", __func__, __LINE__); + usleep(1000); + return -1; + } + + LOC_LOGD("%s:%d] received ctrl_type = %d\n", __func__, __LINE__, p_cmsgbuf->ctrl_type); + switch(p_cmsgbuf->ctrl_type) { + case GPSONE_LOC_API_IF_REQUEST: + result = loc_eng_dmn_conn_loc_api_server_if_request_handler(p_cmsgbuf, length); + break; + + case GPSONE_LOC_API_IF_RELEASE: + result = loc_eng_dmn_conn_loc_api_server_if_release_handler(p_cmsgbuf, length); + break; + + case GPSONE_UNBLOCK: + LOC_LOGD("%s:%d] GPSONE_UNBLOCK\n", __func__, __LINE__); + break; + + default: + LOC_LOGE("%s:%d] unsupported ctrl_type = %d\n", + __func__, __LINE__, p_cmsgbuf->ctrl_type); + break; + } + + free(p_cmsgbuf); + return 0; +} + +static int loc_api_server_proc_post(void *context) +{ + LOC_LOGD("%s:%d]\n", __func__, __LINE__); + loc_eng_dmn_conn_glue_msgremove( global_loc_api_q_path, loc_api_server_msgqid); + loc_eng_dmn_conn_glue_msgremove( global_loc_api_resp_q_path, loc_api_resp_msgqid); + loc_eng_dmn_conn_glue_msgremove( global_quipc_ctrl_q_path, quipc_msgqid); + loc_eng_dmn_conn_glue_msgremove( global_msapm_ctrl_q_path, msapm_msgqid); + loc_eng_dmn_conn_glue_msgremove( global_msapu_ctrl_q_path, msapu_msgqid); + return 0; +} + +static int loc_eng_dmn_conn_unblock_proc(void) +{ + struct ctrl_msgbuf cmsgbuf; + cmsgbuf.ctrl_type = GPSONE_UNBLOCK; + LOC_LOGD("%s:%d]\n", __func__, __LINE__); + loc_eng_dmn_conn_glue_msgsnd(loc_api_server_msgqid, & cmsgbuf, sizeof(cmsgbuf)); + return 0; +} + +static struct loc_eng_dmn_conn_thelper thelper; + +int loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread create_thread_cb, + const char * loc_api_q_path, const char * resp_q_path, void *agps_handle) +{ + int result; + + loc_api_handle = agps_handle; + + if (loc_api_q_path) global_loc_api_q_path = loc_api_q_path; + if (resp_q_path) global_loc_api_resp_q_path = resp_q_path; + + result = loc_eng_dmn_conn_launch_thelper( &thelper, + loc_api_server_proc_init, + loc_api_server_proc_pre, + loc_api_server_proc, + loc_api_server_proc_post, + create_thread_cb, + (char *) global_loc_api_q_path); + if (result != 0) { + LOC_LOGE("%s:%d]\n", __func__, __LINE__); + return -1; + } + return 0; +} + +int loc_eng_dmn_conn_loc_api_server_unblock(void) +{ + loc_eng_dmn_conn_unblock_thelper(&thelper); + loc_eng_dmn_conn_unblock_proc(); + return 0; +} + +int loc_eng_dmn_conn_loc_api_server_join(void) +{ + loc_eng_dmn_conn_join_thelper(&thelper); + return 0; +} + +int loc_eng_dmn_conn_loc_api_server_data_conn(int sender_id, int status) { + struct ctrl_msgbuf cmsgbuf; + LOC_LOGD("%s:%d] quipc_msgqid = %d\n", __func__, __LINE__, quipc_msgqid); + cmsgbuf.ctrl_type = GPSONE_LOC_API_RESPONSE; + cmsgbuf.cmsg.cmsg_response.result = status; + switch (sender_id) { + case LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC: { + LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC", __func__, __LINE__); + if (loc_eng_dmn_conn_glue_msgsnd(quipc_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) { + LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__); + return -1; + } + break; + } + case LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM: { + LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM", __func__, __LINE__); + if (loc_eng_dmn_conn_glue_msgsnd(msapm_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) { + LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__); + return -1; + } + break; + } + case LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU: { + LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU", __func__, __LINE__); + if (loc_eng_dmn_conn_glue_msgsnd(msapu_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) { + LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__); + return -1; + } + break; + } + case LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON: { + LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON", __func__, __LINE__); + if (loc_eng_dmn_conn_glue_msgsnd(loc_api_resp_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) { + LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__); + return -1; + } + break; + } + default: { + LOC_LOGD("%s:%d] invalid sender ID!", __func__, __LINE__); + } + } + return 0; +} + diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h new file mode 100644 index 0000000..1d8c142 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h @@ -0,0 +1,59 @@ +/* Copyright (c) 2011-2012,2014 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef LOC_ENG_DATA_SERVER_H +#define LOC_ENG_DATA_SERVER_H + +#include "loc_eng_dmn_conn_thread_helper.h" + +#ifdef _ANDROID_ + +#define GPSONE_LOC_API_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_q" +#define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_resp_q" +#define QUIPC_CTRL_Q_PATH "/data/misc/location/gpsone_d/quipc_ctrl_q" +#define MSAPM_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapm_ctrl_q" +#define MSAPU_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapu_ctrl_q" + +#else + +#define GPSONE_LOC_API_Q_PATH "/tmp/gpsone_loc_api_q" +#define GPSONE_LOC_API_RESP_Q_PATH "/tmp/gpsone_loc_api_resp_q" +#define QUIPC_CTRL_Q_PATH "/tmp/quipc_ctrl_q" +#define MSAPM_CTRL_Q_PATH "/tmp/msapm_ctrl_q" +#define MSAPU_CTRL_Q_PATH "/tmp/msapu_ctrl_q" + +#endif + +int loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread create_thread_cb, + const char * loc_api_q_path, const char * ctrl_q_path, void *agps_handle); +int loc_eng_dmn_conn_loc_api_server_unblock(void); +int loc_eng_dmn_conn_loc_api_server_join(void); +int loc_eng_dmn_conn_loc_api_server_data_conn(int, int); + +#endif /* LOC_ENG_DATA_SERVER_H */ + diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c new file mode 100644 index 0000000..a1076ff --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c @@ -0,0 +1,223 @@ +/* Copyright (c) 2011, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include + +#include + +#include "log_util.h" +#include "platform_lib_includes.h" +#include "loc_eng_dmn_conn_glue_msg.h" +#include "loc_eng_dmn_conn_handler.h" + +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_glue_msgget + +DESCRIPTION + This function get a message queue + + q_path - name path of the message queue + mode - + +DEPENDENCIES + None + +RETURN VALUE + message queue id + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_glue_msgget(const char * q_path, int mode) +{ + int msgqid; + msgqid = loc_eng_dmn_conn_glue_pipeget(q_path, mode); + return msgqid; +} + +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_glue_msgremove + +DESCRIPTION + remove a message queue + + q_path - name path of the message queue + msgqid - message queue id + +DEPENDENCIES + None + +RETURN VALUE + 0: success or negative value for failure + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_glue_msgremove(const char * q_path, int msgqid) +{ + int result; + result = loc_eng_dmn_conn_glue_piperemove(q_path, msgqid); + return result; +} + +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_glue_msgsnd + +DESCRIPTION + Send a message + + msgqid - message queue id + msgp - pointer to the message to be sent + msgsz - size of the message + +DEPENDENCIES + None + +RETURN VALUE + number of bytes sent out or negative value for failure + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_glue_msgsnd(int msgqid, const void * msgp, size_t msgsz) +{ + int result; + struct ctrl_msgbuf *pmsg = (struct ctrl_msgbuf *) msgp; + pmsg->msgsz = msgsz; + + result = loc_eng_dmn_conn_glue_pipewrite(msgqid, msgp, msgsz); + if (result != (int) msgsz) { + LOC_LOGE("%s:%d] pipe broken %d, msgsz = %d\n", __func__, __LINE__, result, (int) msgsz); + return -1; + } + + return result; +} + +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_glue_msgrcv + +DESCRIPTION + receive a message + + msgqid - message queue id + msgp - pointer to the buffer to hold the message + msgsz - size of the buffer + +DEPENDENCIES + None + +RETURN VALUE + number of bytes received or negative value for failure + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_glue_msgrcv(int msgqid, void *msgp, size_t msgbufsz) +{ + int result; + struct ctrl_msgbuf *pmsg = (struct ctrl_msgbuf *) msgp; + + result = loc_eng_dmn_conn_glue_piperead(msgqid, &(pmsg->msgsz), sizeof(pmsg->msgsz)); + if (result != sizeof(pmsg->msgsz)) { + LOC_LOGE("%s:%d] pipe broken %d\n", __func__, __LINE__, result); + return -1; + } + + if (msgbufsz < pmsg->msgsz) { + LOC_LOGE("%s:%d] msgbuf is too small %d < %d\n", __func__, __LINE__, (int) msgbufsz, (int) pmsg->msgsz); + return -1; + } + + result = loc_eng_dmn_conn_glue_piperead(msgqid, (uint8_t *) msgp + sizeof(pmsg->msgsz), pmsg->msgsz - sizeof(pmsg->msgsz)); + if (result != (int) (pmsg->msgsz - sizeof(pmsg->msgsz))) { + LOC_LOGE("%s:%d] pipe broken %d, msgsz = %d\n", __func__, __LINE__, result, (int) pmsg->msgsz); + return -1; + } + + return pmsg->msgsz; +} + +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_glue_msgunblock + +DESCRIPTION + unblock a message queue + + msgqid - message queue id + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_glue_msgunblock(int msgqid) +{ + return loc_eng_dmn_conn_glue_pipeunblock(msgqid); +} + +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_glue_msgflush + +DESCRIPTION + flush out the message in a queue + + msgqid - message queue id + +DEPENDENCIES + None + +RETURN VALUE + number of bytes that are flushed out. + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_glue_msgflush(int msgqid) +{ + int length; + char buf[128]; + + do { + length = loc_eng_dmn_conn_glue_piperead(msgqid, buf, 128); + LOC_LOGD("%s:%d] %s\n", __func__, __LINE__, buf); + } while(length); + return length; +} + diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h new file mode 100644 index 0000000..d685c87 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h @@ -0,0 +1,51 @@ +/* Copyright (c) 2011, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef LOC_ENG_DMN_CONN_GLUE_MSG_H +#define LOC_ENG_DMN_CONN_GLUE_MSG_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#include +#include "loc_eng_dmn_conn_glue_pipe.h" + +int loc_eng_dmn_conn_glue_msgget(const char * q_path, int mode); +int loc_eng_dmn_conn_glue_msgremove(const char * q_path, int msgqid); +int loc_eng_dmn_conn_glue_msgsnd(int msgqid, const void * msgp, size_t msgsz); +int loc_eng_dmn_conn_glue_msgrcv(int msgqid, void *msgp, size_t msgsz); +int loc_eng_dmn_conn_glue_msgflush(int msgqid); +int loc_eng_dmn_conn_glue_msgunblock(int msgqid); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LOC_ENG_DMN_CONN_GLUE_MSG_H */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c new file mode 100644 index 0000000..dffcad0 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c @@ -0,0 +1,214 @@ +/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include + +// #include +#include +// #include +#include +#include + +#include "loc_eng_dmn_conn_glue_pipe.h" +#include "log_util.h" +#include "platform_lib_includes.h" +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_glue_pipeget + +DESCRIPTION + create a named pipe. + + pipe_name - pipe name path + mode - mode + +DEPENDENCIES + None + +RETURN VALUE + 0: success or negative value for failure + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode) +{ + int fd; + int result; + + LOC_LOGD("%s, mode = %d\n", pipe_name, mode); + result = mkfifo(pipe_name, 0660); + + if ((result == -1) && (errno != EEXIST)) { + LOC_LOGE("failed: %s\n", strerror(errno)); + return result; + } + + // The mode in mkfifo is not honoured and does not provide the + // group permissions. Doing chmod to add group permissions. + result = chmod (pipe_name, 0660); + if (result != 0){ + LOC_LOGE ("%s failed to change mode for %s, error = %s\n", __func__, + pipe_name, strerror(errno)); + } + + fd = open(pipe_name, mode); + if (fd <= 0) + { + LOC_LOGE("failed: %s\n", strerror(errno)); + } + LOC_LOGD("fd = %d, %s\n", fd, pipe_name); + return fd; +} + +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_glue_piperemove + +DESCRIPTION + remove a pipe + + pipe_name - pipe name path + fd - fd for the pipe + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd) +{ + close(fd); + if (pipe_name) unlink(pipe_name); + LOC_LOGD("fd = %d, %s\n", fd, pipe_name); + return 0; +} + +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_glue_pipewrite + +DESCRIPTION + write to a pipe + + fd - fd of a pipe + buf - buffer for the data to write + sz - size of the data in buffer + +DEPENDENCIES + None + +RETURN VALUE + number of bytes written or negative value for failure + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_glue_pipewrite(int fd, const void * buf, size_t sz) +{ + int result; + + result = write(fd, buf, sz); + + /* @todo check for non EINTR & EAGAIN, shall not do select again, select_tut Law 7) */ + + /* LOC_LOGD("fd = %d, buf = 0x%lx, size = %d, result = %d\n", fd, (long) buf, (int) sz, (int) result); */ + return result; +} + +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_glue_piperead + +DESCRIPTION + read from a pipe + + fd - fd for the pipe + buf - buffer to hold the data read from pipe + sz - size of the buffer + +DEPENDENCIES + None + +RETURN VALUE + number of bytes read from pipe or negative value for failure + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_glue_piperead(int fd, void * buf, size_t sz) +{ + int len; + + len = read(fd, buf, sz); + + /* @todo check for non EINTR & EAGAIN, shall not do select again, select_tut Law 7) */ + + /* LOC_LOGD("fd = %d, buf = 0x%lx, size = %d, len = %d\n", fd, (long) buf, (int) sz, len); */ + return len; +} + +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_glue_pipeunblock + +DESCRIPTION + unblock a pipe + + fd - fd for the pipe + +DEPENDENCIES + None + +RETURN VALUE + 0 for success or negative value for failure + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_glue_pipeunblock(int fd) +{ + int result; + struct flock flock_v; + LOC_LOGD("\n"); +// result = fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NDELAY); + flock_v.l_type = F_UNLCK; + flock_v.l_len = 32; + result = fcntl(fd, F_SETLK, &flock_v); + if (result < 0) { + LOC_LOGE("fcntl failure, %s\n", strerror(errno)); + } + + return result; +} diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h new file mode 100644 index 0000000..b2fa3a0 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2011, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef LOC_ENG_DMN_CONN_GLUE_PIPE_H +#define LOC_ENG_DMN_CONN_GLUE_PIPE_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include + +int loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode); +int loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd); +int loc_eng_dmn_conn_glue_pipewrite(int fd, const void * buf, size_t sz); +int loc_eng_dmn_conn_glue_piperead(int fd, void * buf, size_t sz); + +int loc_eng_dmn_conn_glue_pipeflush(int fd); +int loc_eng_dmn_conn_glue_pipeunblock(int fd); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LOC_ENG_DMN_CONN_GLUE_PIPE_H */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp new file mode 100644 index 0000000..edd53f2 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp @@ -0,0 +1,237 @@ +/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include + +#include "log_util.h" +#include "platform_lib_includes.h" +#include "loc_eng_msg.h" +#include "loc_eng_dmn_conn.h" +#include "loc_eng_dmn_conn_handler.h" + +void* loc_api_handle = NULL; + +int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg, int len) +{ + LOC_LOGD("%s:%d]\n", __func__, __LINE__); +#ifndef DEBUG_DMN_LOC_API + if (NULL == loc_api_handle) { + LOC_LOGE("%s:%d] NO agps data handle\n", __func__, __LINE__); + return 1; + } + + if (NULL != loc_api_handle) { + AGpsExtType type; + switch (pmsg->cmsg.cmsg_if_request.type) { + case IF_REQUEST_TYPE_SUPL: + { + LOC_LOGD("IF_REQUEST_TYPE_SUPL"); + type = AGPS_TYPE_SUPL; + break; + } + case IF_REQUEST_TYPE_WIFI: + { + LOC_LOGD("IF_REQUEST_TYPE_WIFI"); + type = AGPS_TYPE_WIFI; + break; + } + case IF_REQUEST_TYPE_ANY: + { + LOC_LOGD("IF_REQUEST_TYPE_ANY"); + type = AGPS_TYPE_ANY; + break; + } + default: + { + LOC_LOGD("invalid IF_REQUEST_TYPE!"); + return -1; + } + } + switch (pmsg->cmsg.cmsg_if_request.sender_id) { + case IF_REQUEST_SENDER_ID_QUIPC: + { + LOC_LOGD("IF_REQUEST_SENDER_ID_QUIPC"); + LocEngReqRelWifi* msg = + new LocEngReqRelWifi(loc_api_handle, + type, + LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC, + (char*)pmsg->cmsg.cmsg_if_request.ssid, + (char*)pmsg->cmsg.cmsg_if_request.password, + true); + msg->send(); + break; + } + case IF_REQUEST_SENDER_ID_MSAPM: + { + LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPM"); + LocEngReqRelWifi* msg = + new LocEngReqRelWifi(loc_api_handle, + type, + LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM, + (char*)pmsg->cmsg.cmsg_if_request.ssid, + (char*)pmsg->cmsg.cmsg_if_request.password, + true); + msg->send(); + break; + } + case IF_REQUEST_SENDER_ID_MSAPU: + { + LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPU"); + LocEngReqRelWifi* msg = + new LocEngReqRelWifi(loc_api_handle, + type, + LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU, + (char*)pmsg->cmsg.cmsg_if_request.ssid, + (char*)pmsg->cmsg.cmsg_if_request.password, + true); + msg->send(); + break; + } + case IF_REQUEST_SENDER_ID_GPSONE_DAEMON: + { + LOC_LOGD("IF_REQUEST_SENDER_ID_GPSONE_DAEMON"); + LocEngReqRelBIT* msg = + new LocEngReqRelBIT(loc_api_handle, + type, + pmsg->cmsg.cmsg_if_request.ipv4_addr, + (char*)pmsg->cmsg.cmsg_if_request.ipv6_addr, + true); + msg->send(); + break; + } + default: + { + LOC_LOGD("invalid IF_REQUEST_SENDER_ID!"); + return -1; + } + } + } + +#else + loc_eng_dmn_conn_loc_api_server_data_conn(LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, GPSONE_LOC_API_IF_REQUEST_SUCCESS); +#endif + return 0; +} + +int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg, int len) +{ + LOC_LOGD("%s:%d]\n", __func__, __LINE__); +#ifndef DEBUG_DMN_LOC_API + AGpsExtType type; + switch (pmsg->cmsg.cmsg_if_request.type) { + case IF_REQUEST_TYPE_SUPL: + { + LOC_LOGD("IF_REQUEST_TYPE_SUPL"); + type = AGPS_TYPE_SUPL; + break; + } + case IF_REQUEST_TYPE_WIFI: + { + LOC_LOGD("IF_REQUEST_TYPE_WIFI"); + type = AGPS_TYPE_WIFI; + break; + } + case IF_REQUEST_TYPE_ANY: + { + LOC_LOGD("IF_REQUEST_TYPE_ANY"); + type = AGPS_TYPE_ANY; + break; + } + default: + { + LOC_LOGD("invalid IF_REQUEST_TYPE!"); + return -1; + } + } + switch (pmsg->cmsg.cmsg_if_request.sender_id) { + case IF_REQUEST_SENDER_ID_QUIPC: + { + LOC_LOGD("IF_REQUEST_SENDER_ID_QUIPC"); + LocEngReqRelWifi* msg = + new LocEngReqRelWifi(loc_api_handle, + type, + LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC, + (char*)pmsg->cmsg.cmsg_if_request.ssid, + (char*)pmsg->cmsg.cmsg_if_request.password, + false); + msg->send(); + break; + } + case IF_REQUEST_SENDER_ID_MSAPM: + { + LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPM"); + LocEngReqRelWifi* msg = + new LocEngReqRelWifi(loc_api_handle, + type, + LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM, + (char*)pmsg->cmsg.cmsg_if_request.ssid, + (char*)pmsg->cmsg.cmsg_if_request.password, + false); + msg->send(); + break; + } + case IF_REQUEST_SENDER_ID_MSAPU: + { + LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPU"); + LocEngReqRelWifi* msg = + new LocEngReqRelWifi(loc_api_handle, + type, + LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU, + (char*)pmsg->cmsg.cmsg_if_request.ssid, + (char*)pmsg->cmsg.cmsg_if_request.password, + false); + msg->send(); + break; + } + case IF_REQUEST_SENDER_ID_GPSONE_DAEMON: + { + LOC_LOGD("IF_REQUEST_SENDER_ID_GPSONE_DAEMON"); + LocEngReqRelBIT* msg = + new LocEngReqRelBIT(loc_api_handle, + type, + pmsg->cmsg.cmsg_if_request.ipv4_addr, + (char*)pmsg->cmsg.cmsg_if_request.ipv6_addr, + false); + msg->send(); + break; + } + default: + { + LOC_LOGD("invalid IF_REQUEST_SENDER_ID!"); + return -1; + } + } +#else + loc_eng_dmn_conn_loc_api_server_data_conn(LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, GPSONE_LOC_API_IF_RELEASE_SUCCESS); +#endif + return 0; +} + diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h new file mode 100644 index 0000000..1c0edd5 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h @@ -0,0 +1,106 @@ +/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef LOC_ENG_DATA_SERVER_HANDLER +#define LOC_ENG_DATA_SERVER_HANDLER + +#include +#include + +//for SSID_BUF_SIZE +#include + +#ifndef SSID_BUF_SIZE + #define SSID_BUF_SIZE (32+1) +#endif + +enum { + /* 0x0 - 0xEF is reserved for daemon internal */ + GPSONE_LOC_API_IF_REQUEST = 0xF0, + GPSONE_LOC_API_IF_RELEASE, + GPSONE_LOC_API_RESPONSE, + GPSONE_UNBLOCK, +}; + +enum { + GPSONE_LOC_API_IF_REQUEST_SUCCESS = 0xF0, + GPSONE_LOC_API_IF_RELEASE_SUCCESS, + GPSONE_LOC_API_IF_FAILURE, +}; + + +struct ctrl_msg_response { + int result; +}; + +struct ctrl_msg_unblock { + int reserved; +}; + +typedef enum { + IF_REQUEST_TYPE_SUPL = 0, + IF_REQUEST_TYPE_WIFI, + IF_REQUEST_TYPE_ANY +} ctrl_if_req_type_e_type; + +typedef enum { + IF_REQUEST_SENDER_ID_QUIPC = 0, + IF_REQUEST_SENDER_ID_MSAPM, + IF_REQUEST_SENDER_ID_MSAPU, + IF_REQUEST_SENDER_ID_GPSONE_DAEMON, + IF_REQUEST_SENDER_ID_MODEM +} ctrl_if_req_sender_id_e_type; + +struct ctrl_msg_if_request { + ctrl_if_req_type_e_type type; + ctrl_if_req_sender_id_e_type sender_id; + unsigned long ipv4_addr; + unsigned char ipv6_addr[16]; + char ssid[SSID_BUF_SIZE]; + char password[SSID_BUF_SIZE]; +}; + +/* do not change this structure */ +struct ctrl_msgbuf { + size_t msgsz; + uint16_t reserved1; + uint32_t reserved2; + uint8_t ctrl_type; + union { + struct ctrl_msg_response cmsg_response; + struct ctrl_msg_unblock cmsg_unblock; + struct ctrl_msg_if_request cmsg_if_request; + } cmsg; +}; + +extern void* loc_api_handle; + +int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg, int len); +int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg, int len); + +#endif /* LOC_ENG_DATA_SERVER_HANDLER */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c new file mode 100644 index 0000000..9fed9d4 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c @@ -0,0 +1,399 @@ +/* Copyright (c) 2011, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include + +#include "log_util.h" +#include "platform_lib_includes.h" +#include "loc_eng_dmn_conn_thread_helper.h" + +/*=========================================================================== +FUNCTION thelper_signal_init + +DESCRIPTION + This function will initialize the conditional variable resources. + + thelper - thelper instance + +DEPENDENCIES + None + +RETURN VALUE + 0: success or negative value for failure + +SIDE EFFECTS + N/A + +===========================================================================*/ +int thelper_signal_init(struct loc_eng_dmn_conn_thelper * thelper) +{ + int result; + thelper->thread_exit = 0; + thelper->thread_ready = 0; + result = pthread_cond_init( &thelper->thread_cond, NULL); + if (result) { + return result; + } + + result = pthread_mutex_init(&thelper->thread_mutex, NULL); + if (result) { + pthread_cond_destroy(&thelper->thread_cond); + } + return result; +} + +/*=========================================================================== +FUNCTION + +DESCRIPTION + This function will destroy the conditional variable resources + + thelper - pointer to thelper instance + +DEPENDENCIES + None + +RETURN VALUE + 0: success or negative value for failure + +SIDE EFFECTS + N/A + +===========================================================================*/ +int thelper_signal_destroy(struct loc_eng_dmn_conn_thelper * thelper) +{ + int result, ret_result = 0; + result = pthread_cond_destroy( &thelper->thread_cond); + if (result) { + ret_result = result; + } + + result = pthread_mutex_destroy(&thelper->thread_mutex); + if (result) { + ret_result = result; + } + + return ret_result; +} + +/*=========================================================================== +FUNCTION thelper_signal_wait + +DESCRIPTION + This function will be blocked on the conditional variable until thelper_signal_ready + is called + + thelper - pointer to thelper instance + +DEPENDENCIES + None + +RETURN VALUE + 0: success or negative value for failure + +SIDE EFFECTS + N/A + +===========================================================================*/ +int thelper_signal_wait(struct loc_eng_dmn_conn_thelper * thelper) +{ + int result = 0; + + pthread_mutex_lock(&thelper->thread_mutex); + if (!thelper->thread_ready && !thelper->thread_exit) { + result = pthread_cond_wait(&thelper->thread_cond, &thelper->thread_mutex); + } + + if (thelper->thread_exit) { + result = -1; + } + pthread_mutex_unlock(&thelper->thread_mutex); + + return result; +} + +/*=========================================================================== +FUNCTION thelper_signal_ready + +DESCRIPTION + This function will wake up the conditional variable + + thelper - pointer to thelper instance + +DEPENDENCIES + None + +RETURN VALUE + 0: success or negative value for failure + +SIDE EFFECTS + N/A + +===========================================================================*/ +int thelper_signal_ready(struct loc_eng_dmn_conn_thelper * thelper) +{ + int result; + + LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); + + pthread_mutex_lock(&thelper->thread_mutex); + thelper->thread_ready = 1; + result = pthread_cond_signal(&thelper->thread_cond); + pthread_mutex_unlock(&thelper->thread_mutex); + + return result; +} + +/*=========================================================================== +FUNCTION thelper_signal_block + +DESCRIPTION + This function will set the thread ready to 0 to block the thelper_signal_wait + + thelper - pointer to thelper instance + +DEPENDENCIES + None + +RETURN VALUE + if thread_ready is set + +SIDE EFFECTS + N/A + +===========================================================================*/ +int thelper_signal_block(struct loc_eng_dmn_conn_thelper * thelper) +{ + int result = thelper->thread_ready; + + LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); + + pthread_mutex_lock(&thelper->thread_mutex); + thelper->thread_ready = 0; + pthread_mutex_unlock(&thelper->thread_mutex); + + return result; +} + +/*=========================================================================== +FUNCTION thelper_main + +DESCRIPTION + This function is the main thread. It will be launched as a child thread + + data - pointer to the instance + +DEPENDENCIES + None + +RETURN VALUE + NULL + +SIDE EFFECTS + N/A + +===========================================================================*/ +static void * thelper_main(void *data) +{ + int result = 0; + struct loc_eng_dmn_conn_thelper * thelper = (struct loc_eng_dmn_conn_thelper *) data; + + if (thelper->thread_proc_init) { + result = thelper->thread_proc_init(thelper->thread_context); + if (result < 0) { + thelper->thread_exit = 1; + thelper_signal_ready(thelper); + LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper); + return NULL; + } + } + + thelper_signal_ready(thelper); + + if (thelper->thread_proc_pre) { + result = thelper->thread_proc_pre(thelper->thread_context); + if (result < 0) { + thelper->thread_exit = 1; + LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper); + return NULL; + } + } + + do { + if (thelper->thread_proc) { + result = thelper->thread_proc(thelper->thread_context); + if (result < 0) { + thelper->thread_exit = 1; + LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper); + } + } + } while (thelper->thread_exit == 0); + + if (thelper->thread_proc_post) { + result = thelper->thread_proc_post(thelper->thread_context); + } + + if (result != 0) { + LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper); + } + return NULL; +} + +static void thelper_main_2(void *data) +{ + thelper_main(data); + return; +} + + +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_launch_thelper + +DESCRIPTION + This function will initialize the thread context and launch the thelper_main + + thelper - pointer to thelper instance + thread_proc_init - The initialization function pointer + thread_proc_pre - The function to call before task loop and after initialization + thread_proc - The task loop + thread_proc_post - The function to call after the task loop + context - the context for the above four functions + +DEPENDENCIES + None + +RETURN VALUE + 0: success or negative value for failure + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_launch_thelper(struct loc_eng_dmn_conn_thelper * thelper, + int (*thread_proc_init) (void * context), + int (*thread_proc_pre) (void * context), + int (*thread_proc) (void * context), + int (*thread_proc_post) (void * context), + thelper_create_thread create_thread_cb, + void * context) +{ + int result; + + thelper_signal_init(thelper); + + if (context) { + thelper->thread_context = context; + } + + thelper->thread_proc_init = thread_proc_init; + thelper->thread_proc_pre = thread_proc_pre; + thelper->thread_proc = thread_proc; + thelper->thread_proc_post = thread_proc_post; + + LOC_LOGD("%s:%d] 0x%lx call pthread_create\n", __func__, __LINE__, (long) thelper); + if (create_thread_cb) { + result = 0; + thelper->thread_id = create_thread_cb("loc_eng_dmn_conn", + thelper_main_2, (void *)thelper); + } else { + result = pthread_create(&thelper->thread_id, NULL, + thelper_main, (void *)thelper); + } + + if (result != 0) { + LOC_LOGE("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); + return -1; + } + + LOC_LOGD("%s:%d] 0x%lx pthread_create done\n", __func__, __LINE__, (long) thelper); + + thelper_signal_wait(thelper); + + LOC_LOGD("%s:%d] 0x%lx pthread ready\n", __func__, __LINE__, (long) thelper); + return thelper->thread_exit; +} + +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_unblock_thelper + +DESCRIPTION + This function unblocks thelper_main to release the thread + + thelper - pointer to thelper instance + +DEPENDENCIES + None + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_unblock_thelper(struct loc_eng_dmn_conn_thelper * thelper) +{ + LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); + thelper->thread_exit = 1; + return 0; +} + +/*=========================================================================== +FUNCTION loc_eng_dmn_conn_join_thelper + + thelper - pointer to thelper instance + +DESCRIPTION + This function will wait for the thread of thelper_main to finish + +DEPENDENCIES + None + +RETURN VALUE + 0: success or negative value for failure + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_dmn_conn_join_thelper(struct loc_eng_dmn_conn_thelper * thelper) +{ + int result; + + LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); + result = pthread_join(thelper->thread_id, NULL); + if (result != 0) { + LOC_LOGE("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); + } + LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper); + + thelper_signal_destroy(thelper); + + return result; +} + diff --git a/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h new file mode 100644 index 0000000..89e598b --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h @@ -0,0 +1,74 @@ +/* Copyright (c) 2011, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ +#define __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include + +struct loc_eng_dmn_conn_thelper { + unsigned char thread_exit; + unsigned char thread_ready; + pthread_cond_t thread_cond; + pthread_mutex_t thread_mutex; + pthread_t thread_id; + void * thread_context; + int (*thread_proc_init) (void * context); + int (*thread_proc_pre) (void * context); + int (*thread_proc) (void * context); + int (*thread_proc_post) (void * context); +}; + +typedef pthread_t (* thelper_create_thread)(const char* name, void (*start)(void *), void* arg); +int loc_eng_dmn_conn_launch_thelper(struct loc_eng_dmn_conn_thelper * thelper, + int (*thread_proc_init) (void * context), + int (*thread_proc_pre) (void * context), + int (*thread_proc) (void * context), + int (*thread_proc_post) (void * context), + thelper_create_thread create_thread_cb, + void * context); + +int loc_eng_dmn_conn_unblock_thelper(struct loc_eng_dmn_conn_thelper * thelper); +int loc_eng_dmn_conn_join_thelper(struct loc_eng_dmn_conn_thelper * thelper); + +/* if only need to use signal */ +int thelper_signal_init(struct loc_eng_dmn_conn_thelper * thelper); +int thelper_signal_destroy(struct loc_eng_dmn_conn_thelper * thelper); +int thelper_signal_wait(struct loc_eng_dmn_conn_thelper * thelper); +int thelper_signal_ready(struct loc_eng_dmn_conn_thelper * thelper); +int thelper_signal_block(struct loc_eng_dmn_conn_thelper * thelper); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_log.cpp b/gps/loc_api/libloc_api_50001/loc_eng_log.cpp new file mode 100644 index 0000000..3a34167 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_log.cpp @@ -0,0 +1,35 @@ +/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_eng" + +#include "loc_log.h" +#include "loc_eng_log.h" + diff --git a/gps/loc_api/libloc_api_50001/loc_eng_log.h b/gps/loc_api/libloc_api_50001/loc_eng_log.h new file mode 100644 index 0000000..a68bd84 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_log.h @@ -0,0 +1,44 @@ +/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef LOC_ENG_LOG_H +#define LOC_ENG_LOG_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +#ifdef __cplusplus +} +#endif + +#endif /* LOC_ENG_LOG_H */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_msg.h b/gps/loc_api/libloc_api_50001/loc_eng_msg.h new file mode 100644 index 0000000..73a71c0 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_msg.h @@ -0,0 +1,306 @@ +/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef LOC_ENG_MSG_H +#define LOC_ENG_MSG_H + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef SSID_BUF_SIZE + #define SSID_BUF_SIZE (32+1) +#endif +#ifdef USE_GLIB + +#include + +#endif /* USE_GLIB */ +#include "platform_lib_includes.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +using namespace loc_core; + +struct LocEngPositionMode : public LocMsg { + LocEngAdapter* mAdapter; + const LocPosMode mPosMode; + LocEngPositionMode(LocEngAdapter* adapter, LocPosMode &mode); + virtual void proc() const; + virtual void log() const; + void send() const; +}; + + +struct LocEngStartFix : public LocMsg { + LocEngAdapter* mAdapter; + LocEngStartFix(LocEngAdapter* adapter); + virtual void proc() const; + void locallog() const; + virtual void log() const; + void send() const; +}; + +struct LocEngStopFix : public LocMsg { + LocEngAdapter* mAdapter; + LocEngStopFix(LocEngAdapter* adapter); + virtual void proc() const; + void locallog() const; + virtual void log() const; + void send() const; +}; + +struct LocEngReportPosition : public LocMsg { + LocAdapterBase* mAdapter; + const UlpLocation mLocation; + const GpsLocationExtended mLocationExtended; + const void* mLocationExt; + const enum loc_sess_status mStatus; + const LocPosTechMask mTechMask; + LocEngReportPosition(LocAdapterBase* adapter, + UlpLocation &loc, + GpsLocationExtended &locExtended, + void* locExt, + enum loc_sess_status st, + LocPosTechMask technology); + virtual void proc() const; + void locallog() const; + virtual void log() const; + void send() const; +}; + +struct LocEngReportSv : public LocMsg { + LocAdapterBase* mAdapter; + const QcomSvStatus mSvStatus; + const GpsLocationExtended mLocationExtended; + const void* mSvExt; + LocEngReportSv(LocAdapterBase* adapter, + QcomSvStatus &sv, + GpsLocationExtended &locExtended, + void* svExtended); + virtual void proc() const; + void locallog() const; + virtual void log() const; + void send() const; +}; + +struct LocEngReportStatus : public LocMsg { + LocAdapterBase* mAdapter; + const GpsStatusValue mStatus; + LocEngReportStatus(LocAdapterBase* adapter, + GpsStatusValue engineStatus); + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +struct LocEngReportNmea : public LocMsg { + void* mLocEng; + char* const mNmea; + const int mLen; + LocEngReportNmea(void* locEng, + const char* data, int len); + inline virtual ~LocEngReportNmea() + { + delete[] mNmea; + } + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +struct LocEngReportXtraServer : public LocMsg { + void* mLocEng; + int mMaxLen; + char *mServers; + LocEngReportXtraServer(void* locEng, + const char *url1, const char *url2, + const char *url3, const int maxlength); + inline virtual ~LocEngReportXtraServer() + { + delete[] mServers; + } + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +struct LocEngSuplEsOpened : public LocMsg { + void* mLocEng; + LocEngSuplEsOpened(void* locEng); + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +struct LocEngSuplEsClosed : public LocMsg { + void* mLocEng; + LocEngSuplEsClosed(void* locEng); + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +struct LocEngRequestSuplEs : public LocMsg { + void* mLocEng; + const int mID; + LocEngRequestSuplEs(void* locEng, int id); + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +struct LocEngRequestATL : public LocMsg { + void* mLocEng; + const int mID; + const AGpsExtType mType; + LocEngRequestATL(void* locEng, int id, + AGpsExtType agps_type); + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +struct LocEngReleaseATL : public LocMsg { + void* mLocEng; + const int mID; + LocEngReleaseATL(void* locEng, int id); + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +struct LocEngReqRelBIT : public LocMsg { + void* mLocEng; + const AGpsExtType mType; + const int mIPv4Addr; + char* const mIPv6Addr; + const bool mIsReq; + LocEngReqRelBIT(void* instance, AGpsExtType type, + int ipv4, char* ipv6, bool isReq); + virtual ~LocEngReqRelBIT(); + virtual void proc() const; + void locallog() const; + virtual void log() const; + void send() const; +}; + +struct LocEngReqRelWifi : public LocMsg { + void* mLocEng; + const AGpsExtType mType; + const loc_if_req_sender_id_e_type mSenderId; + char* const mSSID; + char* const mPassword; + const bool mIsReq; + LocEngReqRelWifi(void* locEng, AGpsExtType type, + loc_if_req_sender_id_e_type sender_id, + char* s, char* p, bool isReq); + virtual ~LocEngReqRelWifi(); + virtual void proc() const; + void locallog() const; + virtual void log() const; + void send() const; +}; + +struct LocEngRequestXtra : public LocMsg { + void* mLocEng; + LocEngRequestXtra(void* locEng); + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +struct LocEngRequestTime : public LocMsg { + void* mLocEng; + LocEngRequestTime(void* locEng); + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +struct LocEngRequestNi : public LocMsg { + void* mLocEng; + const GpsNiNotification mNotify; + const void *mPayload; + LocEngRequestNi(void* locEng, + GpsNiNotification ¬if, + const void* data); + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +struct LocEngDown : public LocMsg { + void* mLocEng; + LocEngDown(void* locEng); + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +struct LocEngUp : public LocMsg { + void* mLocEng; + LocEngUp(void* locEng); + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +struct LocEngGetZpp : public LocMsg { + LocEngAdapter* mAdapter; + LocEngGetZpp(LocEngAdapter* adapter); + virtual void proc() const; + void locallog() const; + virtual void log() const; + void send() const; +}; + +struct LocEngReportGpsMeasurement : public LocMsg { + void* mLocEng; + const GpsData mGpsData; + LocEngReportGpsMeasurement(void* locEng, + GpsData &gpsData); + virtual void proc() const; + void locallog() const; + virtual void log() const; +}; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LOC_ENG_MSG_H */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp b/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp new file mode 100644 index 0000000..4597b98 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp @@ -0,0 +1,414 @@ +/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_eng" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "log_util.h" +#include "platform_lib_includes.h" + +using namespace loc_core; + +/*============================================================================= + * + * DATA DECLARATION + * + *============================================================================*/ + +/*============================================================================= + * + * FUNCTION DECLARATIONS + * + *============================================================================*/ +static void* ni_thread_proc(void *args); + +struct LocEngInformNiResponse : public LocMsg { + LocEngAdapter* mAdapter; + const GpsUserResponseType mResponse; + const void *mPayload; + inline LocEngInformNiResponse(LocEngAdapter* adapter, + GpsUserResponseType resp, + const void* data) : + LocMsg(), mAdapter(adapter), + mResponse(resp), mPayload(data) + { + locallog(); + } + inline ~LocEngInformNiResponse() + { + // this is a bit weird since mPayload is not + // allocated by this class. But there is no better way. + // mPayload actually won't be NULL here. + free((void*)mPayload); + } + inline virtual void proc() const + { + mAdapter->informNiResponse(mResponse, mPayload); + } + inline void locallog() const + { + LOC_LOGV("LocEngInformNiResponse - " + "response: %s\n mPayload: %p", + loc_get_ni_response_name(mResponse), + mPayload); + } + inline virtual void log() const + { + locallog(); + } +}; + +/*=========================================================================== + +FUNCTION loc_eng_ni_request_handler + +DESCRIPTION + Displays the NI request and awaits user input. If a previous request is + in session, it is ignored. + +RETURN VALUE + none + +===========================================================================*/ +void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data, + const GpsNiNotification *notif, + const void* passThrough) +{ + ENTRY_LOG(); + char lcs_addr[32]; // Decoded LCS address for UMTS CP NI + loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data; + loc_eng_ni_session_s_type* pSession = NULL; + + if (NULL == loc_eng_data.ni_notify_cb) { + EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet."); + return; + } + + if (notif->ni_type == GPS_NI_TYPE_EMERGENCY_SUPL) { + if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) { + LOC_LOGW("loc_eng_ni_request_handler, supl es NI in progress, new supl es NI ignored, type: %d", + notif->ni_type); + if (NULL != passThrough) { + free((void*)passThrough); + } + } else { + pSession = &loc_eng_ni_data_p->sessionEs; + } + } else { + if (NULL != loc_eng_ni_data_p->session.rawRequest || + NULL != loc_eng_ni_data_p->sessionEs.rawRequest) { + LOC_LOGW("loc_eng_ni_request_handler, supl NI in progress, new supl NI ignored, type: %d", + notif->ni_type); + if (NULL != passThrough) { + free((void*)passThrough); + } + } else { + pSession = &loc_eng_ni_data_p->session; + } + } + + + if (pSession) { + /* Save request */ + pSession->rawRequest = (void*)passThrough; + pSession->reqID = ++loc_eng_ni_data_p->reqIDCounter; + pSession->adapter = loc_eng_data.adapter; + + /* Fill in notification */ + ((GpsNiNotification*)notif)->notification_id = pSession->reqID; + + if (notif->notify_flags == GPS_NI_PRIVACY_OVERRIDE) + { + loc_eng_mute_one_session(loc_eng_data); + } + + /* Log requestor ID and text for debugging */ + LOC_LOGI("Notification: notif_type: %d, timeout: %d, default_resp: %d", notif->ni_type, notif->timeout, notif->default_response); + LOC_LOGI(" requestor_id: %s (encoding: %d)", notif->requestor_id, notif->requestor_id_encoding); + LOC_LOGI(" text: %s text (encoding: %d)", notif->text, notif->text_encoding); + if (notif->extras[0]) + { + LOC_LOGI(" extras: %s", notif->extras); + } + + /* For robustness, spawn a thread at this point to timeout to clear up the notification status, even though + * the OEM layer in java does not do so. + **/ + pSession->respTimeLeft = 5 + (notif->timeout != 0 ? notif->timeout : LOC_NI_NO_RESPONSE_TIME); + LOC_LOGI("Automatically sends 'no response' in %d seconds (to clear status)\n", pSession->respTimeLeft); + + int rc = 0; + rc = pthread_create(&pSession->thread, NULL, ni_thread_proc, pSession); + if (rc) + { + LOC_LOGE("Loc NI thread is not created.\n"); + } + rc = pthread_detach(pSession->thread); + if (rc) + { + LOC_LOGE("Loc NI thread is not detached.\n"); + } + + CALLBACK_LOG_CALLFLOW("ni_notify_cb - id", %d, notif->notification_id); + loc_eng_data.ni_notify_cb((GpsNiNotification*)notif); + } + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== + +FUNCTION ni_thread_proc + +===========================================================================*/ +static void* ni_thread_proc(void *args) +{ + ENTRY_LOG(); + + loc_eng_ni_session_s_type* pSession = (loc_eng_ni_session_s_type*)args; + int rc = 0; /* return code from pthread calls */ + + struct timeval present_time; + struct timespec expire_time; + + LOC_LOGD("Starting Loc NI thread...\n"); + pthread_mutex_lock(&pSession->tLock); + /* Calculate absolute expire time */ + gettimeofday(&present_time, NULL); + expire_time.tv_sec = present_time.tv_sec + pSession->respTimeLeft; + expire_time.tv_nsec = present_time.tv_usec * 1000; + LOC_LOGD("ni_thread_proc-Time out set for abs time %ld with delay %d sec\n", + (long) expire_time.tv_sec, pSession->respTimeLeft ); + + while (!pSession->respRecvd) + { + rc = pthread_cond_timedwait(&pSession->tCond, + &pSession->tLock, + &expire_time); + if (rc == ETIMEDOUT) + { + pSession->resp = GPS_NI_RESPONSE_NORESP; + LOC_LOGD("ni_thread_proc-Thread time out after valting for specified time. Ret Val %d\n",rc ); + break; + } + } + LOC_LOGD("ni_thread_proc-Java layer has sent us a user response and return value from " + "pthread_cond_timedwait = %d\n",rc ); + pSession->respRecvd = FALSE; /* Reset the user response flag for the next session*/ + + LOC_LOGD("pSession->resp is %d\n",pSession->resp); + + // adding this check to support modem restart, in which case, we need the thread + // to exit without calling sending data. We made sure that rawRequest is NULL in + // loc_eng_ni_reset_on_engine_restart() + LocEngAdapter* adapter = pSession->adapter; + LocEngInformNiResponse *msg = NULL; + + if (NULL != pSession->rawRequest) { + if (pSession->resp != GPS_NI_RESPONSE_IGNORE) { + LOC_LOGD("pSession->resp != GPS_NI_RESPONSE_IGNORE \n"); + msg = new LocEngInformNiResponse(adapter, + pSession->resp, + pSession->rawRequest); + } else { + LOC_LOGD("this is the ignore reply for SUPL ES\n"); + free(pSession->rawRequest); + } + pSession->rawRequest = NULL; + } + pthread_mutex_unlock(&pSession->tLock); + + pSession->respTimeLeft = 0; + pSession->reqID = 0; + + if (NULL != msg) { + LOC_LOGD("ni_thread_proc: adapter->sendMsg(msg)\n"); + adapter->sendMsg(msg); + } + + EXIT_LOG(%s, VOID_RET); + return NULL; +} + +void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG(); + loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data; + + if (NULL == loc_eng_data.ni_notify_cb) { + EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet."); + return; + } + + // only if modem has requested but then died. + if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) { + free(loc_eng_ni_data_p->sessionEs.rawRequest); + loc_eng_ni_data_p->sessionEs.rawRequest = NULL; + + pthread_mutex_lock(&loc_eng_ni_data_p->sessionEs.tLock); + // the goal is to wake up ni_thread_proc + // and let it exit. + loc_eng_ni_data_p->sessionEs.respRecvd = TRUE; + pthread_cond_signal(&loc_eng_ni_data_p->sessionEs.tCond); + pthread_mutex_unlock(&loc_eng_ni_data_p->sessionEs.tLock); + } + + if (NULL != loc_eng_ni_data_p->session.rawRequest) { + free(loc_eng_ni_data_p->session.rawRequest); + loc_eng_ni_data_p->session.rawRequest = NULL; + + pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock); + // the goal is to wake up ni_thread_proc + // and let it exit. + loc_eng_ni_data_p->session.respRecvd = TRUE; + pthread_cond_signal(&loc_eng_ni_data_p->session.tCond); + pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock); + } + + EXIT_LOG(%s, VOID_RET); +} + +/*=========================================================================== +FUNCTION loc_eng_ni_init + +DESCRIPTION + This function initializes the NI interface + +DEPENDENCIES + NONE + +RETURN VALUE + None + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, GpsNiExtCallbacks *callbacks) +{ + ENTRY_LOG_CALLFLOW(); + + if(callbacks == NULL) + EXIT_LOG(%s, "loc_eng_ni_init: failed, cb is NULL"); + else if (NULL == callbacks->notify_cb) { + EXIT_LOG(%s, "loc_eng_ni_init: failed, no cb."); + } else if (NULL != loc_eng_data.ni_notify_cb) { + EXIT_LOG(%s, "loc_eng_ni_init: already inited."); + } else { + loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data; + loc_eng_ni_data_p->sessionEs.respTimeLeft = 0; + loc_eng_ni_data_p->sessionEs.respRecvd = FALSE; + loc_eng_ni_data_p->sessionEs.rawRequest = NULL; + loc_eng_ni_data_p->sessionEs.reqID = 0; + pthread_cond_init(&loc_eng_ni_data_p->sessionEs.tCond, NULL); + pthread_mutex_init(&loc_eng_ni_data_p->sessionEs.tLock, NULL); + + loc_eng_ni_data_p->session.respTimeLeft = 0; + loc_eng_ni_data_p->session.respRecvd = FALSE; + loc_eng_ni_data_p->session.rawRequest = NULL; + loc_eng_ni_data_p->session.reqID = 0; + pthread_cond_init(&loc_eng_ni_data_p->session.tCond, NULL); + pthread_mutex_init(&loc_eng_ni_data_p->session.tLock, NULL); + + loc_eng_data.ni_notify_cb = callbacks->notify_cb; + EXIT_LOG(%s, VOID_RET); + } +} + +/*=========================================================================== +FUNCTION loc_eng_ni_respond + +DESCRIPTION + This function receives user response from upper layer framework + +DEPENDENCIES + NONE + +RETURN VALUE + None + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data, + int notif_id, GpsUserResponseType user_response) +{ + ENTRY_LOG_CALLFLOW(); + loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data; + loc_eng_ni_session_s_type* pSession = NULL; + + if (NULL == loc_eng_data.ni_notify_cb) { + EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet."); + return; + } + + if (notif_id == loc_eng_ni_data_p->sessionEs.reqID && + NULL != loc_eng_ni_data_p->sessionEs.rawRequest) { + pSession = &loc_eng_ni_data_p->sessionEs; + // ignore any SUPL NI non-Es session if a SUPL NI ES is accepted + if (user_response == GPS_NI_RESPONSE_ACCEPT && + NULL != loc_eng_ni_data_p->session.rawRequest) { + pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock); + loc_eng_ni_data_p->session.resp = GPS_NI_RESPONSE_IGNORE; + loc_eng_ni_data_p->session.respRecvd = TRUE; + pthread_cond_signal(&loc_eng_ni_data_p->session.tCond); + pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock); + } + } else if (notif_id == loc_eng_ni_data_p->session.reqID && + NULL != loc_eng_ni_data_p->session.rawRequest) { + pSession = &loc_eng_ni_data_p->session; + } + + if (pSession) { + LOC_LOGI("loc_eng_ni_respond: send user response %d for notif %d", user_response, notif_id); + pthread_mutex_lock(&pSession->tLock); + pSession->resp = user_response; + pSession->respRecvd = TRUE; + pthread_cond_signal(&pSession->tCond); + pthread_mutex_unlock(&pSession->tLock); + } + else { + LOC_LOGE("loc_eng_ni_respond: notif_id %d not an active session", notif_id); + } + + EXIT_LOG(%s, VOID_RET); +} diff --git a/gps/loc_api/libloc_api_50001/loc_eng_ni.h b/gps/loc_api/libloc_api_50001/loc_eng_ni.h new file mode 100644 index 0000000..068f5cd --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_ni.h @@ -0,0 +1,59 @@ +/* Copyright (c) 2009,2011,2014 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef LOC_ENG_NI_H +#define LOC_ENG_NI_H + +#include +#include + +#define LOC_NI_NO_RESPONSE_TIME 20 /* secs */ +#define LOC_NI_NOTIF_KEY_ADDRESS "Address" +#define GPS_NI_RESPONSE_IGNORE 4 + +typedef struct { + pthread_t thread; /* NI thread */ + int respTimeLeft; /* examine time for NI response */ + bool respRecvd; /* NI User reponse received or not from Java layer*/ + void* rawRequest; + int reqID; /* ID to check against response */ + GpsUserResponseType resp; + pthread_cond_t tCond; + pthread_mutex_t tLock; + LocEngAdapter* adapter; +} loc_eng_ni_session_s_type; + +typedef struct { + loc_eng_ni_session_s_type session; /* SUPL NI Session */ + loc_eng_ni_session_s_type sessionEs; /* Emergency SUPL NI Session */ + int reqIDCounter; +} loc_eng_ni_data_s_type; + + +#endif /* LOC_ENG_NI_H */ diff --git a/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp b/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp new file mode 100644 index 0000000..3000a33 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp @@ -0,0 +1,922 @@ +/* Copyright (c) 2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_eng_nmea" +#define GPS_PRN_START 1 +#define GPS_PRN_END 32 +#define GLONASS_PRN_START 65 +#define GLONASS_PRN_END 96 +#include +#include +#include +#include "log_util.h" + +/*=========================================================================== +FUNCTION loc_eng_nmea_send + +DESCRIPTION + send out NMEA sentence + +DEPENDENCIES + NONE + +RETURN VALUE + Total length of the nmea sentence + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p) +{ + struct timeval tv; + gettimeofday(&tv, (struct timezone *) NULL); + int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000; + if (loc_eng_data_p->nmea_cb != NULL) + loc_eng_data_p->nmea_cb(now, pNmea, length); + LOC_LOGD("NMEA <%s", pNmea); +} + +/*=========================================================================== +FUNCTION loc_eng_nmea_put_checksum + +DESCRIPTION + Generate NMEA sentences generated based on position report + +DEPENDENCIES + NONE + +RETURN VALUE + Total length of the nmea sentence + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_nmea_put_checksum(char *pNmea, int maxSize) +{ + uint8_t checksum = 0; + int length = 0; + + pNmea++; //skip the $ + while (*pNmea != '\0') + { + checksum ^= *pNmea++; + length++; + } + + // length now contains nmea sentence string length not including $ sign. + int checksumLength = snprintf(pNmea,(maxSize-length-1),"*%02X\r\n", checksum); + + // total length of nmea sentence is length of nmea sentence inc $ sign plus + // length of checksum (+1 is to cover the $ character in the length). + return (length + checksumLength + 1); +} + +/*=========================================================================== +FUNCTION loc_eng_nmea_generate_pos + +DESCRIPTION + Generate NMEA sentences generated based on position report + Currently below sentences are generated within this function: + - $GPGSA : GPS DOP and active SVs + - $GNGSA : GLONASS DOP and active SVs + - $GPVTG : Track made good and ground speed + - $GPRMC : Recommended minimum navigation information + - $GPGGA : Time, position and fix related data + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, + const UlpLocation &location, + const GpsLocationExtended &locationExtended, + unsigned char generate_nmea) +{ + ENTRY_LOG(); + time_t utcTime(location.gpsLocation.timestamp/1000); + tm * pTm = gmtime(&utcTime); + if (NULL == pTm) { + LOC_LOGE("gmtime failed"); + return; + } + + char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0}; + char* pMarker = sentence; + int lengthRemaining = sizeof(sentence); + int length = 0; + int utcYear = pTm->tm_year % 100; // 2 digit year + int utcMonth = pTm->tm_mon + 1; // tm_mon starts at zero + int utcDay = pTm->tm_mday; + int utcHours = pTm->tm_hour; + int utcMinutes = pTm->tm_min; + int utcSeconds = pTm->tm_sec; + int utcMSeconds = (location.gpsLocation.timestamp)%1000; + + if (generate_nmea) { + // ------------------ + // ------$GPGSA------ + // ------------------ + + uint32_t svUsedCount = 0; + uint32_t svUsedList[32] = {0}; + uint32_t mask = loc_eng_data_p->gps_used_mask; + for (uint8_t i = 1; mask > 0 && svUsedCount < 32; i++) + { + if (mask & 1) + svUsedList[svUsedCount++] = i; + mask = mask >> 1; + } + // clear the cache so they can't be used again + loc_eng_data_p->gps_used_mask = 0; + + char fixType; + if (svUsedCount == 0) + fixType = '1'; // no fix + else if (svUsedCount <= 3) + fixType = '2'; // 2D fix + else + fixType = '3'; // 3D fix + + length = snprintf(pMarker, lengthRemaining, "$GPGSA,A,%c,", fixType); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + for (uint8_t i = 0; i < 12; i++) // only the first 12 sv go in sentence + { + if (i < svUsedCount) + length = snprintf(pMarker, lengthRemaining, "%02d,", svUsedList[i]); + else + length = snprintf(pMarker, lengthRemaining, ","); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + } + + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP) + { // dop is in locationExtended, (QMI) + length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f", + locationExtended.pdop, + locationExtended.hdop, + locationExtended.vdop); + } + else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0) + { // dop was cached from sv report (RPC) + length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f", + loc_eng_data_p->pdop, + loc_eng_data_p->hdop, + loc_eng_data_p->vdop); + } + else + { // no dop + length = snprintf(pMarker, lengthRemaining, ",,"); + } + + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + // ------------------ + // ------$GNGSA------ + // ------------------ + uint32_t gloUsedCount = 0; + uint32_t gloUsedList[32] = {0}; + + // Reset locals for GNGSA sentence generation + pMarker = sentence; + lengthRemaining = sizeof(sentence); + mask = loc_eng_data_p->glo_used_mask; + fixType = '\0'; + + // Parse the glonass sv mask, and fetch glo sv ids + // Mask corresponds to the offset. + // GLONASS SV ids are from 65-96 + const int GLONASS_SV_ID_OFFSET = 64; + for (uint8_t i = 1; mask > 0 && gloUsedCount < 32; i++) + { + if (mask & 1) + gloUsedList[gloUsedCount++] = i + GLONASS_SV_ID_OFFSET; + mask = mask >> 1; + } + // clear the cache so they can't be used again + loc_eng_data_p->glo_used_mask = 0; + + if (gloUsedCount == 0) + fixType = '1'; // no fix + else if (gloUsedCount <= 3) + fixType = '2'; // 2D fix + else + fixType = '3'; // 3D fix + + // Start printing the sentence + // Format: $--GSA,a,x,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,p.p,h.h,v.v*cc + // GNGSA : for glonass SVs + // a : Mode : A : Automatic, allowed to automatically switch 2D/3D + // x : Fixtype : 1 (no fix), 2 (2D fix), 3 (3D fix) + // xx : 12 SV ID + // p.p : Position DOP (Dilution of Precision) + // h.h : Horizontal DOP + // v.v : Vertical DOP + // cc : Checksum value + length = snprintf(pMarker, lengthRemaining, "$GNGSA,A,%c,", fixType); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + // Add first 12 GLONASS satellite IDs + for (uint8_t i = 0; i < 12; i++) + { + if (i < gloUsedCount) + length = snprintf(pMarker, lengthRemaining, "%02d,", gloUsedList[i]); + else + length = snprintf(pMarker, lengthRemaining, ","); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + } + + // Add the position/horizontal/vertical DOP values + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP) + { // dop is in locationExtended, (QMI) + length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f", + locationExtended.pdop, + locationExtended.hdop, + locationExtended.vdop); + } + else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0) + { // dop was cached from sv report (RPC) + length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f", + loc_eng_data_p->pdop, + loc_eng_data_p->hdop, + loc_eng_data_p->vdop); + } + else + { // no dop + length = snprintf(pMarker, lengthRemaining, ",,"); + } + + /* Sentence is ready, add checksum and broadcast */ + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + // ------------------ + // ------$GPVTG------ + // ------------------ + + pMarker = sentence; + lengthRemaining = sizeof(sentence); + + if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING) + { + float magTrack = location.gpsLocation.bearing; + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV) + { + float magTrack = location.gpsLocation.bearing - locationExtended.magneticDeviation; + if (magTrack < 0.0) + magTrack += 360.0; + else if (magTrack > 360.0) + magTrack -= 360.0; + } + + length = snprintf(pMarker, lengthRemaining, "$GPVTG,%.1lf,T,%.1lf,M,", location.gpsLocation.bearing, magTrack); + } + else + { + length = snprintf(pMarker, lengthRemaining, "$GPVTG,,T,,M,"); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED) + { + float speedKnots = location.gpsLocation.speed * (3600.0/1852.0); + float speedKmPerHour = location.gpsLocation.speed * 3.6; + + length = snprintf(pMarker, lengthRemaining, "%.1lf,N,%.1lf,K,", speedKnots, speedKmPerHour); + } + else + { + length = snprintf(pMarker, lengthRemaining, ",N,,K,"); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)) + length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix + else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode) + length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous + else + length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential + + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + // ------------------ + // ------$GPRMC------ + // ------------------ + + pMarker = sentence; + lengthRemaining = sizeof(sentence); + + length = snprintf(pMarker, lengthRemaining, "$GPRMC,%02d%02d%02d.%02d,A," , + utcHours, utcMinutes, utcSeconds,utcMSeconds/10); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG) + { + double latitude = location.gpsLocation.latitude; + double longitude = location.gpsLocation.longitude; + char latHemisphere; + char lonHemisphere; + double latMinutes; + double lonMinutes; + + if (latitude > 0) + { + latHemisphere = 'N'; + } + else + { + latHemisphere = 'S'; + latitude *= -1.0; + } + + if (longitude < 0) + { + lonHemisphere = 'W'; + longitude *= -1.0; + } + else + { + lonHemisphere = 'E'; + } + + latMinutes = fmod(latitude * 60.0 , 60.0); + lonMinutes = fmod(longitude * 60.0 , 60.0); + + length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,", + (uint8_t)floor(latitude), latMinutes, latHemisphere, + (uint8_t)floor(longitude),lonMinutes, lonHemisphere); + } + else + { + length = snprintf(pMarker, lengthRemaining,",,,,"); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED) + { + float speedKnots = location.gpsLocation.speed * (3600.0/1852.0); + length = snprintf(pMarker, lengthRemaining, "%.1lf,", speedKnots); + } + else + { + length = snprintf(pMarker, lengthRemaining, ","); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING) + { + length = snprintf(pMarker, lengthRemaining, "%.1lf,", location.gpsLocation.bearing); + } + else + { + length = snprintf(pMarker, lengthRemaining, ","); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + length = snprintf(pMarker, lengthRemaining, "%2.2d%2.2d%2.2d,", + utcDay, utcMonth, utcYear); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV) + { + float magneticVariation = locationExtended.magneticDeviation; + char direction; + if (magneticVariation < 0.0) + { + direction = 'W'; + magneticVariation *= -1.0; + } + else + { + direction = 'E'; + } + + length = snprintf(pMarker, lengthRemaining, "%.1lf,%c,", + magneticVariation, direction); + } + else + { + length = snprintf(pMarker, lengthRemaining, ",,"); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)) + length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix + else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode) + length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous + else + length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential + + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + // ------------------ + // ------$GPGGA------ + // ------------------ + + pMarker = sentence; + lengthRemaining = sizeof(sentence); + + length = snprintf(pMarker, lengthRemaining, "$GPGGA,%02d%02d%02d.%02d," , + utcHours, utcMinutes, utcSeconds, utcMSeconds/10); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG) + { + double latitude = location.gpsLocation.latitude; + double longitude = location.gpsLocation.longitude; + char latHemisphere; + char lonHemisphere; + double latMinutes; + double lonMinutes; + + if (latitude > 0) + { + latHemisphere = 'N'; + } + else + { + latHemisphere = 'S'; + latitude *= -1.0; + } + + if (longitude < 0) + { + lonHemisphere = 'W'; + longitude *= -1.0; + } + else + { + lonHemisphere = 'E'; + } + + latMinutes = fmod(latitude * 60.0 , 60.0); + lonMinutes = fmod(longitude * 60.0 , 60.0); + + length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,", + (uint8_t)floor(latitude), latMinutes, latHemisphere, + (uint8_t)floor(longitude),lonMinutes, lonHemisphere); + } + else + { + length = snprintf(pMarker, lengthRemaining,",,,,"); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + char gpsQuality; + if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)) + gpsQuality = '0'; // 0 means no fix + else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode) + gpsQuality = '1'; // 1 means GPS fix + else + gpsQuality = '2'; // 2 means DGPS fix + + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP) + { // dop is in locationExtended, (QMI) + length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,", + gpsQuality, svUsedCount, locationExtended.hdop); + } + else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0) + { // dop was cached from sv report (RPC) + length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,", + gpsQuality, svUsedCount, loc_eng_data_p->hdop); + } + else + { // no hdop + length = snprintf(pMarker, lengthRemaining, "%c,%02d,,", + gpsQuality, svUsedCount); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL) + { + length = snprintf(pMarker, lengthRemaining, "%.1lf,M,", + locationExtended.altitudeMeanSeaLevel); + } + else + { + length = snprintf(pMarker, lengthRemaining,",,"); + } + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if ((location.gpsLocation.flags & GPS_LOCATION_HAS_ALTITUDE) && + (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL)) + { + length = snprintf(pMarker, lengthRemaining, "%.1lf,M,,", + location.gpsLocation.altitude - locationExtended.altitudeMeanSeaLevel); + } + else + { + length = snprintf(pMarker, lengthRemaining,",,,"); + } + + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + } + //Send blank NMEA reports for non-final fixes + else { + strlcpy(sentence, "$GPGSA,A,1,,,,,,,,,,,,,,,", sizeof(sentence)); + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + strlcpy(sentence, "$GNGSA,A,1,,,,,,,,,,,,,,,", sizeof(sentence)); + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + strlcpy(sentence, "$GPVTG,,T,,M,,N,,K,N", sizeof(sentence)); + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + strlcpy(sentence, "$GPRMC,,V,,,,,,,,,,N", sizeof(sentence)); + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + + strlcpy(sentence, "$GPGGA,,,,,,0,,,,,,,,", sizeof(sentence)); + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + } + // clear the dop cache so they can't be used again + loc_eng_data_p->pdop = 0; + loc_eng_data_p->hdop = 0; + loc_eng_data_p->vdop = 0; + + EXIT_LOG(%d, 0); +} + + + +/*=========================================================================== +FUNCTION loc_eng_nmea_generate_sv + +DESCRIPTION + Generate NMEA sentences generated based on sv report + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, + const QcomSvStatus &svStatus, const GpsLocationExtended &locationExtended) +{ + ENTRY_LOG(); + + char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0}; + char* pMarker = sentence; + int lengthRemaining = sizeof(sentence); + int length = 0; + int svCount = svStatus.num_svs; + int sentenceCount = 0; + int sentenceNumber = 1; + int svNumber = 1; + int gpsCount = 0; + int glnCount = 0; + + //Count GPS SVs for saparating GPS from GLONASS and throw others + + for(svNumber=1; svNumber <= svCount; svNumber++) { + if( (svStatus.sv_list[svNumber-1].prn >= GPS_PRN_START)&& + (svStatus.sv_list[svNumber-1].prn <= GPS_PRN_END) ) + { + gpsCount++; + } + else if( (svStatus.sv_list[svNumber-1].prn >= GLONASS_PRN_START) && + (svStatus.sv_list[svNumber-1].prn <= GLONASS_PRN_END) ) + { + glnCount++; + } + } + + // ------------------ + // ------$GPGSV------ + // ------------------ + + if (gpsCount <= 0) + { + // no svs in view, so just send a blank $GPGSV sentence + strlcpy(sentence, "$GPGSV,1,1,0,", sizeof(sentence)); + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + } + else + { + svNumber = 1; + sentenceNumber = 1; + sentenceCount = gpsCount/4 + (gpsCount % 4 != 0); + + while (sentenceNumber <= sentenceCount) + { + pMarker = sentence; + lengthRemaining = sizeof(sentence); + + length = snprintf(pMarker, lengthRemaining, "$GPGSV,%d,%d,%02d", + sentenceCount, sentenceNumber, gpsCount); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + for (int i=0; (svNumber <= svCount) && (i < 4); svNumber++) + { + if( (svStatus.sv_list[svNumber-1].prn >= GPS_PRN_START) && + (svStatus.sv_list[svNumber-1].prn <= GPS_PRN_END) ) + { + length = snprintf(pMarker, lengthRemaining,",%02d,%02d,%03d,", + svStatus.sv_list[svNumber-1].prn, + (int)(0.5 + svStatus.sv_list[svNumber-1].elevation), //float to int + (int)(0.5 + svStatus.sv_list[svNumber-1].azimuth)); //float to int + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (svStatus.sv_list[svNumber-1].snr > 0) + { + length = snprintf(pMarker, lengthRemaining,"%02d", + (int)(0.5 + svStatus.sv_list[svNumber-1].snr)); //float to int + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + } + + i++; + } + + } + + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + sentenceNumber++; + + } //while + + } //if + + // ------------------ + // ------$GLGSV------ + // ------------------ + + if (glnCount <= 0) + { + // no svs in view, so just send a blank $GLGSV sentence + strlcpy(sentence, "$GLGSV,1,1,0,", sizeof(sentence)); + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + } + else + { + svNumber = 1; + sentenceNumber = 1; + sentenceCount = glnCount/4 + (glnCount % 4 != 0); + + while (sentenceNumber <= sentenceCount) + { + pMarker = sentence; + lengthRemaining = sizeof(sentence); + + length = snprintf(pMarker, lengthRemaining, "$GLGSV,%d,%d,%02d", + sentenceCount, sentenceNumber, glnCount); + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + for (int i=0; (svNumber <= svCount) && (i < 4); svNumber++) + { + if( (svStatus.sv_list[svNumber-1].prn >= GLONASS_PRN_START) && + (svStatus.sv_list[svNumber-1].prn <= GLONASS_PRN_END) ) { + + length = snprintf(pMarker, lengthRemaining,",%02d,%02d,%03d,", + svStatus.sv_list[svNumber-1].prn, + (int)(0.5 + svStatus.sv_list[svNumber-1].elevation), //float to int + (int)(0.5 + svStatus.sv_list[svNumber-1].azimuth)); //float to int + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + + if (svStatus.sv_list[svNumber-1].snr > 0) + { + length = snprintf(pMarker, lengthRemaining,"%02d", + (int)(0.5 + svStatus.sv_list[svNumber-1].snr)); //float to int + + if (length < 0 || length >= lengthRemaining) + { + LOC_LOGE("NMEA Error in string formatting"); + return; + } + pMarker += length; + lengthRemaining -= length; + } + + i++; + } + + } + + length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence)); + loc_eng_nmea_send(sentence, length, loc_eng_data_p); + sentenceNumber++; + + } //while + + }//if + + // cache the used in fix mask, as it will be needed to send $GPGSA/$GNGSA + // during the position report + loc_eng_data_p->gps_used_mask = svStatus.gps_used_in_fix_mask; + loc_eng_data_p->glo_used_mask = svStatus.glo_used_in_fix_mask; + + // For RPC, the DOP are sent during sv report, so cache them + // now to be sent during position report. + // For QMI, the DOP will be in position report. + if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP) + { + loc_eng_data_p->pdop = locationExtended.pdop; + loc_eng_data_p->hdop = locationExtended.hdop; + loc_eng_data_p->vdop = locationExtended.vdop; + } + else + { + loc_eng_data_p->pdop = 0; + loc_eng_data_p->hdop = 0; + loc_eng_data_p->vdop = 0; + } + + EXIT_LOG(%d, 0); +} diff --git a/gps/loc_api/libloc_api_50001/loc_eng_nmea.h b/gps/loc_api/libloc_api_50001/loc_eng_nmea.h new file mode 100644 index 0000000..2563a8f --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_nmea.h @@ -0,0 +1,43 @@ +/* Copyright (c) 2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef LOC_ENG_NMEA_H +#define LOC_ENG_NMEA_H + +#include +#include + +#define NMEA_SENTENCE_MAX_LENGTH 200 + +void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p); +int loc_eng_nmea_put_checksum(char *pNmea, int maxSize); +void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, const QcomSvStatus &svStatus, const GpsLocationExtended &locationExtended); +void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, const UlpLocation &location, const GpsLocationExtended &locationExtended, unsigned char generate_nmea); + +#endif // LOC_ENG_NMEA_H diff --git a/gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp b/gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp new file mode 100644 index 0000000..7bb8083 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp @@ -0,0 +1,213 @@ +/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_eng" + +#include +#include +#include "log_util.h" +#include "platform_lib_includes.h" + +using namespace loc_core; + +struct LocEngRequestXtraServer : public LocMsg { + LocEngAdapter* mAdapter; + inline LocEngRequestXtraServer(LocEngAdapter* adapter) : + LocMsg(), mAdapter(adapter) + { + locallog(); + } + inline virtual void proc() const { + mAdapter->requestXtraServer(); + } + inline void locallog() const { + LOC_LOGV("LocEngRequestXtraServer"); + } + inline virtual void log() const { + locallog(); + } +}; + +struct LocEngInjectXtraData : public LocMsg { + LocEngAdapter* mAdapter; + char* mData; + const int mLen; + inline LocEngInjectXtraData(LocEngAdapter* adapter, + char* data, int len): + LocMsg(), mAdapter(adapter), + mData(new char[len]), mLen(len) + { + memcpy((void*)mData, (void*)data, len); + locallog(); + } + inline ~LocEngInjectXtraData() + { + delete[] mData; + } + inline virtual void proc() const { + mAdapter->setXtraData(mData, mLen); + } + inline void locallog() const { + LOC_LOGV("length: %d\n data: %p", mLen, mData); + } + inline virtual void log() const { + locallog(); + } +}; + +struct LocEngSetXtraVersionCheck : public LocMsg { + LocEngAdapter *mAdapter; + int mCheck; + inline LocEngSetXtraVersionCheck(LocEngAdapter* adapter, + int check): + mAdapter(adapter), mCheck(check) {} + inline virtual void proc() const { + locallog(); + mAdapter->setXtraVersionCheck(mCheck); + } + inline void locallog() const { + LOC_LOGD("%s:%d]: mCheck: %d", + __func__, __LINE__, mCheck); + } + inline virtual void log() const { + locallog(); + } +}; + +/*=========================================================================== +FUNCTION loc_eng_xtra_init + +DESCRIPTION + Initialize XTRA module. + +DEPENDENCIES + N/A + +RETURN VALUE + 0: success + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data, + GpsXtraExtCallbacks* callbacks) +{ + int ret_val = -1; + loc_eng_xtra_data_s_type *xtra_module_data_ptr; + ENTRY_LOG(); + + if(callbacks == NULL) { + LOC_LOGE("loc_eng_xtra_init: failed, cb is NULL"); + } else { + xtra_module_data_ptr = &loc_eng_data.xtra_module_data; + xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb; + xtra_module_data_ptr->report_xtra_server_cb = callbacks->report_xtra_server_cb; + + ret_val = 0; + } + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_eng_xtra_inject_data + +DESCRIPTION + Injects XTRA file into the engine but buffers the data if engine is busy. + +DEPENDENCIES + N/A + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data, + char* data, int length) +{ + ENTRY_LOG(); + LocEngAdapter* adapter = loc_eng_data.adapter; + adapter->sendMsg(new LocEngInjectXtraData(adapter, data, length)); + EXIT_LOG(%d, 0); + return 0; +} +/*=========================================================================== +FUNCTION loc_eng_xtra_request_server + +DESCRIPTION + Request the Xtra server url from the modem + +DEPENDENCIES + N/A + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG(); + LocEngAdapter* adapter = loc_eng_data.adapter; + adapter->sendMsg(new LocEngRequestXtraServer(adapter)); + EXIT_LOG(%d, 0); + return 0; +} +/*=========================================================================== +FUNCTION loc_eng_xtra_version_check + +DESCRIPTION + Injects the enable/disable value for checking XTRA version + that is specified in gps.conf + +DEPENDENCIES + N/A + +RETURN VALUE + none + +SIDE EFFECTS + N/A + +===========================================================================*/ +void loc_eng_xtra_version_check(loc_eng_data_s_type &loc_eng_data, + int check) +{ + ENTRY_LOG(); + LocEngAdapter *adapter = loc_eng_data.adapter; + adapter->sendMsg(new LocEngSetXtraVersionCheck(adapter, check)); + EXIT_LOG(%d, 0); +} diff --git a/gps/loc_api/libloc_api_50001/loc_eng_xtra.h b/gps/loc_api/libloc_api_50001/loc_eng_xtra.h new file mode 100644 index 0000000..175f497 --- /dev/null +++ b/gps/loc_api/libloc_api_50001/loc_eng_xtra.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef LOC_ENG_XTRA_H +#define LOC_ENG_XTRA_H + +#include + +// Module data +typedef struct +{ + // loc_eng_ioctl_cb_data_s_type ioctl_cb_data; + gps_xtra_download_request download_request_cb; + report_xtra_server report_xtra_server_cb; + + // XTRA data buffer + char *xtra_data_for_injection; // NULL if no pending data + int xtra_data_len; +} loc_eng_xtra_data_s_type; + +#endif // LOC_ENG_XTRA_H diff --git a/gps/utils/Android.mk b/gps/utils/Android.mk new file mode 100644 index 0000000..7b304df --- /dev/null +++ b/gps/utils/Android.mk @@ -0,0 +1,64 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +## Libs +LOCAL_SHARED_LIBRARIES := \ + libutils \ + libcutils \ + liblog \ + libprocessgroup + +LOCAL_SRC_FILES += \ + loc_log.cpp \ + loc_cfg.cpp \ + msg_q.c \ + linked_list.c \ + loc_target.cpp \ + platform_lib_abstractions/elapsed_millis_since_boot.cpp \ + LocHeap.cpp \ + LocTimer.cpp \ + LocThread.cpp \ + MsgTask.cpp \ + loc_misc_utils.cpp + +LOCAL_CFLAGS += \ + -fno-short-enums \ + -D_ANDROID_ + +ifeq ($(TARGET_BUILD_VARIANT),user) + LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER +endif + +LOCAL_LDFLAGS += -Wl,--export-dynamic + +## Includes +LOCAL_C_INCLUDES:= \ + $(LOCAL_PATH)/platform_lib_abstractions + +LOCAL_COPY_HEADERS_TO:= gps.utils/ +LOCAL_COPY_HEADERS:= \ + loc_log.h \ + loc_cfg.h \ + log_util.h \ + linked_list.h \ + msg_q.h \ + MsgTask.h \ + LocHeap.h \ + LocThread.h \ + LocTimer.h \ + loc_target.h \ + loc_timer.h \ + LocSharedLock.h \ + platform_lib_abstractions/platform_lib_includes.h \ + platform_lib_abstractions/platform_lib_time.h \ + platform_lib_abstractions/platform_lib_macros.h \ + loc_misc_utils.h + +LOCAL_MODULE := libgps.utils +LOCAL_MODULE_OWNER := qcom +LOCAL_VENDOR_MODULE := true + +LOCAL_MODULE_TAGS := optional + +include $(BUILD_SHARED_LIBRARY) diff --git a/gps/utils/LocHeap.cpp b/gps/utils/LocHeap.cpp new file mode 100644 index 0000000..d667f14 --- /dev/null +++ b/gps/utils/LocHeap.cpp @@ -0,0 +1,354 @@ +/* Copyright (c) 2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include + +class LocHeapNode { + friend class LocHeap; + + // size of of the subtree, excluding self, 1 if no subtree + int mSize; + LocHeapNode* mLeft; + LocHeapNode* mRight; + LocRankable* mData; +public: + inline LocHeapNode(LocRankable& data) : + mSize(1), mLeft(NULL), mRight(NULL), mData(&data) {} + ~LocHeapNode(); + + // this only swaps the data of the two nodes, so no + // detach / re-attached is necessary + void swap(LocHeapNode& node); + + LocRankable* detachData(); + + // push a node into the tree stucture, keeping sorted by rank + void push(LocHeapNode& node); + + // pop the head node out of the tree stucture. keeping sorted by rank + static LocHeapNode* pop(LocHeapNode*& top); + + // remove a specific node from the tree + // returns the pointer to the node removed, which would be either the + // same as input (if successfully removed); or NULL (if failed). + static LocHeapNode* remove(LocHeapNode*& top, LocRankable& data); + + // convenience method to compare data ranking + inline bool outRanks(LocHeapNode& node) { return mData->outRanks(*node.mData); } + inline bool outRanks(LocRankable& data) { return mData->outRanks(data); } + + // checks if mSize is correct, AND this node is the highest ranking + // of the entire subtree + bool checkNodes(); + + inline int getSize() { return mSize; } +}; + +inline +LocHeapNode::~LocHeapNode() { + if (mLeft) { + delete mLeft; + mLeft = NULL; + } + if (mRight) { + delete mRight; + mRight = NULL; + } + if (mData) { + mData = NULL; + } +} + +inline +void LocHeapNode::swap(LocHeapNode& node) { + LocRankable* tmpData = node.mData; + node.mData = mData; + mData = tmpData; +} + +inline +LocRankable* LocHeapNode::detachData() { + LocRankable* data = mData; + mData = NULL; + return data; +} + +// push keeps the tree sorted by rank, it also tries to balance the +// tree by adding the new node to the smaller of the subtrees. +// The pointer to the tree and internal links never change. If the +// mData of tree top ranks lower than that of the incoming node, +// mData will be swapped with that of the incoming node to ensure +// ranking, no restructuring the container nodes. +void LocHeapNode::push(LocHeapNode& node) { + // ensure the current node ranks higher than in the incoming one + if (node.outRanks(*this)) { + swap(node); + } + + // now drop the new node (ensured lower than *this) into a subtree + if (NULL == mLeft) { + mLeft = &node; + } else if (NULL == mRight) { + mRight = &node; + } else if (mLeft->mSize <= mRight->mSize) { + mLeft->push(node); + } else { + mRight->push(node); + } + mSize++; +} + +// pop keeps the tree sorted by rank, but it does not try to balance +// the tree. It recursively swaps with the higher ranked top of the +// subtrees. +// The return is a popped out node from leaf level, that has the data +// swapped all the way down from the top. The pinter to the tree and +// internal links will not be changed or restructured, except for the +// node that is popped out. +// If the return pointer == this, this the last node in the tree. +LocHeapNode* LocHeapNode::pop(LocHeapNode*& top) { + // we know the top has the highest ranking at this point, else + // the tree is broken. This top will be popped out. But we need + // a node from the left or right child, whichever ranks higher, + // to replace the current top. This then will need to be done + // recursively to the leaf level. So we swap the mData of the + // current top node all the way down to the leaf level. + LocHeapNode* poppedNode = top; + // top is losing a node in its subtree + top->mSize--; + if (top->mLeft || top->mRight) { + // if mLeft is NULL, mRight for sure is NOT NULL, take that; + // else if mRight is NULL, mLeft for sure is NOT, take that; + // else we take the address of whatever has higher ranking mData + LocHeapNode*& subTop = (NULL == top->mLeft) ? top->mRight : + ((NULL == top->mRight) ? top->mLeft : + (top->mLeft->outRanks(*(top->mRight)) ? top->mLeft : top->mRight)); + // swap mData, the tree top gets updated with the new data. + top->swap(*subTop); + // pop out from the subtree + poppedNode = pop(subTop); + } else { + // if the top has only single node + // detach the poppedNode from the tree + // subTop is the reference of ether mLeft or mRight + // NOT a local stack pointer. so it MUST be NULL'ed here. + top = NULL; + } + + return poppedNode; +} + +// navigating through the tree and find the node that hass the input +// data. Since this is a heap, we do recursive linear search. +// returns the pointer to the node removed, which would be either the +// same as input (if successfully removed); or NULL (if failed). +LocHeapNode* LocHeapNode::remove(LocHeapNode*& top, LocRankable& data) { + LocHeapNode* removedNode = NULL; + // this is the node, by address + if (&data == (LocRankable*)(top->mData)) { + // pop this node out + removedNode = pop(top); + } else if (!data.outRanks(*top->mData)) { + // subtrees might have this node + if (top->mLeft) { + removedNode = remove(top->mLeft, data); + } + // if we did not find in mLeft, and mRight is not empty + if (!removedNode && top->mRight) { + removedNode = remove(top->mRight, data); + } + + // top lost a node in its subtree + if (removedNode) { + top->mSize--; + } + } + + return removedNode; +} + +// checks if mSize is correct, AND this node is the highest ranking +// of the entire subtree +bool LocHeapNode::checkNodes() { + // size of the current subtree + int totalSize = mSize; + if (mLeft) { + // check the consistency of left subtree + if (mLeft->outRanks(*this) || !mLeft->checkNodes()) { + return false; + } + // subtract the size of left subtree (with subtree head) + totalSize -= mLeft->mSize; + } + + if (mRight) { + // check the consistency of right subtree + if (mRight->outRanks(*this) || !mRight->checkNodes()) { + return false; + } + // subtract the size of right subtree (with subtree head) + totalSize -= mRight->mSize; + } + + // for the tree nodes to consistent, totalSize must be 1 now + return totalSize == 1; +} + +LocHeap::~LocHeap() { + if (mTree) { + delete mTree; + } +} + +void LocHeap::push(LocRankable& node) { + LocHeapNode* heapNode = new LocHeapNode(node); + if (!mTree) { + mTree = heapNode; + } else { + mTree->push(*heapNode); + } +} + +LocRankable* LocHeap::peek() { + LocRankable* top = NULL; + if (mTree) { + top = mTree->mData; + } + return top; +} + +LocRankable* LocHeap::pop() { + LocRankable* locNode = NULL; + if (mTree) { + // mTree may become NULL after this call + LocHeapNode* heapNode = LocHeapNode::pop(mTree); + locNode = heapNode->detachData(); + delete heapNode; + } + return locNode; +} + +LocRankable* LocHeap::remove(LocRankable& rankable) { + LocRankable* locNode = NULL; + if (mTree) { + // mTree may become NULL after this call + LocHeapNode* heapNode = LocHeapNode::remove(mTree, rankable); + if (heapNode) { + locNode = heapNode->detachData(); + delete heapNode; + } + } + return locNode; +} + +#ifdef __LOC_UNIT_TEST__ +bool LocHeap::checkTree() { + return ((NULL == mTree) || mTree->checkNodes()); +} +uint32_t LocHeap::getTreeSize() { + return (NULL == mTree) ? 0 : mTree->getSize(); +} +#endif + +#ifdef __LOC_DEBUG__ + +#include +#include +#include + +class LocHeapDebug : public LocHeap { +public: + bool checkTree() { + return ((NULL == mTree) || mTree->checkNodes()); + } + + uint32_t getTreeSize() { + return (NULL == mTree) ? 0 : (mTree->getSize()); + } +}; + +class LocHeapDebugData : public LocRankable { + const int mID; +public: + LocHeapDebugData(int id) : mID(id) {} + inline virtual int ranks(LocRankable& rankable) { + LocHeapDebugData* testData = dynamic_cast(&rankable); + return testData->mID - mID; + } +}; + +// For Linux command line testing: +// compilation: g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -I. -I../../../../vendor/qcom/proprietary/gps-internal/unit-tests/fakes_for_host -I../../../../system/core/include LocHeap.cpp +// test: valgrind --leak-check=full ./a.out 100 +int main(int argc, char** argv) { + srand(time(NULL)); + int tries = atoi(argv[1]); + int checks = tries >> 3; + LocHeapDebug heap; + int treeSize = 0; + + for (int i = 0; i < tries; i++) { + if (i % checks == 0 && !heap.checkTree()) { + printf("tree check failed before %dth op\n", i); + } + int r = rand(); + + if (r & 1) { + LocHeapDebugData* data = new LocHeapDebugData(r >> 1); + heap.push(dynamic_cast(*data)); + treeSize++; + } else { + LocRankable* rankable = heap.pop(); + if (rankable) { + delete rankable; + } + treeSize ? treeSize-- : 0; + } + + printf("%s: %d == %d\n", (r&1)?"push":"pop", treeSize, heap.getTreeSize()); + if (treeSize != heap.getTreeSize()) { + printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + tries = i+1; + break; + } + } + + if (!heap.checkTree()) { + printf("!!!!!!!!!!tree check failed at the end after %d ops!!!!!!!\n", tries); + } else { + printf("success!\n"); + } + + for (LocRankable* data = heap.pop(); NULL != data; data = heap.pop()) { + delete data; + } + + return 0; +} + +#endif diff --git a/gps/utils/LocHeap.h b/gps/utils/LocHeap.h new file mode 100644 index 0000000..b491948 --- /dev/null +++ b/gps/utils/LocHeap.h @@ -0,0 +1,96 @@ +/* Copyright (c) 2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __LOC_HEAP__ +#define __LOC_HEAP__ + +#include +#include + +// abstract class to be implemented by client to provide a rankable class +class LocRankable { +public: + virtual inline ~LocRankable() {} + + // method to rank objects of such type for sorting purposes. + // The pointer of the input node would be stored in the heap. + // >0 if ranks higher than the input; + // ==0 if equally ranks with the input; + // <0 if ranks lower than the input + virtual int ranks(LocRankable& rankable) = 0; + + // convenient method to rank objects of such type for sorting purposes. + inline bool outRanks(LocRankable& rankable) { return ranks(rankable) > 0; } +}; + +// opaque class to provide service implementation. +class LocHeapNode; + +// a heap whose left and right children are not sorted. It is sorted only vertically, +// i.e. parent always ranks higher than children, if they exist. Ranking algorithm is +// implemented in Rankable. The reason that there is no sort between children is to +// help beter balance the tree with lower cost. When a node is pushed to the tree, +// it is guaranteed that the subtree that is smaller gets to have the new node. +class LocHeap { +protected: + LocHeapNode* mTree; +public: + inline LocHeap() : mTree(NULL) {} + ~LocHeap(); + + // push keeps the tree sorted by rank, it also tries to balance the + // tree by adding the new node to the smaller of the subtrees. + // node is reference to an obj that is managed by client, that client + // creates and destroyes. The destroy should happen after the + // node is popped out from the heap. + void push(LocRankable& node); + + // Peeks the node data on tree top, which has currently the highest ranking + // There is no change the tree structure with this operation + // Returns NULL if the tree is empty, otherwise pointer to the node data of + // the tree top. + LocRankable* peek(); + + // pop keeps the tree sorted by rank, but it does not try to balance + // the tree. + // Return - pointer to the node popped out, or NULL if heap is already empty + LocRankable* pop(); + + // navigating through the tree and find the node that ranks the same + // as the input data, then remove it from the tree. Rank is implemented + // by rankable obj. + // returns the pointer to the node removed; or NULL (if failed). + LocRankable* remove(LocRankable& rankable); + +#ifdef __LOC_UNIT_TEST__ + bool checkTree(); + uint32_t getTreeSize(); +#endif +}; + +#endif //__LOC_HEAP__ diff --git a/gps/utils/LocSharedLock.h b/gps/utils/LocSharedLock.h new file mode 100644 index 0000000..7fe6237 --- /dev/null +++ b/gps/utils/LocSharedLock.h @@ -0,0 +1,59 @@ +/* Copyright (c) 2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __LOC_SHARED_LOCK__ +#define __LOC_SHARED_LOCK__ + +#include +#include +#include + +// This is a utility created for use cases such that there are more than +// one client who need to share the same lock, but it is not predictable +// which of these clients is to last to go away. This shared lock deletes +// itself when the last client calls its drop() method. To add a cient, +// this share lock's share() method has to be called, so that the obj +// can maintain an accurate client count. +class LocSharedLock { + volatile int32_t mRef; + pthread_mutex_t mMutex; + inline ~LocSharedLock() { pthread_mutex_destroy(&mMutex); } +public: + // first client to create this LockSharedLock + inline LocSharedLock() : mRef(1) { pthread_mutex_init(&mMutex, NULL); } + // following client(s) are to *share()* this lock created by the first client + inline LocSharedLock* share() { android_atomic_inc(&mRef); return this; } + // whe a client no longer needs this shared lock, drop() shall be called. + inline void drop() { if (1 == android_atomic_dec(&mRef)) delete this; } + // locking the lock to enter critical section + inline void lock() { pthread_mutex_lock(&mMutex); } + // unlocking the lock to leave the critical section + inline void unlock() { pthread_mutex_unlock(&mMutex); } +}; + +#endif //__LOC_SHARED_LOCK__ diff --git a/gps/utils/LocThread.cpp b/gps/utils/LocThread.cpp new file mode 100644 index 0000000..a7fd1c8 --- /dev/null +++ b/gps/utils/LocThread.cpp @@ -0,0 +1,262 @@ +/* Copyright (c) 2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include + +class LocThreadDelegate { + LocRunnable* mRunnable; + bool mJoinable; + pthread_t mThandle; + pthread_mutex_t mMutex; + int mRefCount; + ~LocThreadDelegate(); + LocThreadDelegate(LocThread::tCreate creator, const char* threadName, + LocRunnable* runnable, bool joinable); + void destroy(); +public: + static LocThreadDelegate* create(LocThread::tCreate creator, + const char* threadName, LocRunnable* runnable, bool joinable); + void stop(); + // bye() is for the parent thread to go away. if joinable, + // parent must stop the spawned thread, join, and then + // destroy(); if detached, the parent can go straight + // ahead to destroy() + inline void bye() { mJoinable ? stop() : destroy(); } + inline bool isRunning() { return (NULL != mRunnable); } + static void* threadMain(void* arg); +}; + +// it is important to note that internal members must be +// initialized to values as if pthread_create succeeds. +// This is to avoid the race condition between the threads, +// once the thread is created, some of these values will +// be check in the spawned thread, and must set correctly +// then and there. +// However, upon pthread_create failure, the data members +// must be set to indicate failure, e.g. mRunnable, and +// threashold approprietly for destroy(), e.g. mRefCount. +LocThreadDelegate::LocThreadDelegate(LocThread::tCreate creator, + const char* threadName, LocRunnable* runnable, bool joinable) : + mRunnable(runnable), mJoinable(joinable), mThandle(NULL), + mMutex(PTHREAD_MUTEX_INITIALIZER), mRefCount(2) { + + // set up thread name, if nothing is passed in + if (!threadName) { + threadName = "LocThread"; + } + + // create the thread here, then if successful + // and a name is given, we set the thread name + if (creator) { + mThandle = creator(threadName, threadMain, this); + } else if (pthread_create(&mThandle, NULL, threadMain, this)) { + // pthread_create() failed + mThandle = NULL; + } + + if (mThandle) { + // set thread name + char lname[16]; + strlcpy(lname, threadName, sizeof(lname)); + // set the thread name here + pthread_setname_np(mThandle, lname); + + // detach, if not joinable + if (!joinable) { + pthread_detach(mThandle); + } + } else { + // must set these values upon failure + mRunnable = NULL; + mJoinable = false; + mRefCount = 1; + } +} + +inline +LocThreadDelegate::~LocThreadDelegate() { + // at this point nothing should need done any more +} + +// factory method so that we could return NULL upon failure +LocThreadDelegate* LocThreadDelegate::create(LocThread::tCreate creator, + const char* threadName, LocRunnable* runnable, bool joinable) { + LocThreadDelegate* thread = NULL; + if (runnable) { + thread = new LocThreadDelegate(creator, threadName, runnable, joinable); + if (thread && !thread->isRunning()) { + thread->destroy(); + thread = NULL; + } + } + + return thread; +} + +// The order is importang +// NULLing mRunnalbe stops the while loop in threadMain() +// join() if mJoinble must come before destroy() call, as +// the obj must remain alive at this time so that mThandle +// remains valud. +void LocThreadDelegate::stop() { + // mRunnable and mJoinable are reset on different triggers. + // mRunnable may get nulled on the spawned thread's way out; + // or here. + // mJouinable (if ever been true) gets falsed when client + // thread triggers stop, with either a stop() + // call or the client releases thread obj handle. + if (mRunnable) { + mRunnable = NULL; + } + if (mJoinable) { + mJoinable = false; + pthread_join(mThandle, NULL); + } + // call destroy() to possibly delete the obj + destroy(); +} + +// method for clients to call to release the obj +// when it is a detached thread, the client thread +// and the spawned thread can both try to destroy() +// asynchronously. And we delete this obj when +// mRefCount becomes 0. +void LocThreadDelegate::destroy() { + // else case shouldn't happen, unless there is a + // leaking obj. But only our code here has such + // obj, so if we test our code well, else case + // will never happen + if (mRefCount > 0) { + // we need a flag on the stack + bool callDelete = false; + + // critical section between threads + pthread_mutex_lock(&mMutex); + // last destroy() call + callDelete = (1 == mRefCount--); + pthread_mutex_unlock(&mMutex); + + // upon last destroy() call we delete this obj + if (callDelete) { + delete this; + } + } +} + +void* LocThreadDelegate::threadMain(void* arg) { + LocThreadDelegate* locThread = (LocThreadDelegate*)(arg); + + if (locThread) { + LocRunnable* runnable = locThread->mRunnable; + + if (runnable) { + if (locThread->isRunning()) { + runnable->prerun(); + } + + while (locThread->isRunning() && runnable->run()); + + if (locThread->isRunning()) { + runnable->postrun(); + } + + // at this time, locThread->mRunnable may or may not be NULL + // NULL it just to be safe and clean, as we want the field + // in the released memory slot to be NULL. + locThread->mRunnable = NULL; + delete runnable; + } + locThread->destroy(); + } + + return NULL; +} + +LocThread::~LocThread() { + if (mThread) { + mThread->bye(); + mThread = NULL; + } +} + +bool LocThread::start(tCreate creator, const char* threadName, LocRunnable* runnable, bool joinable) { + bool success = false; + if (!mThread) { + mThread = LocThreadDelegate::create(creator, threadName, runnable, joinable); + // true only if thread is created successfully + success = (NULL != mThread); + } + return success; +} + +void LocThread::stop() { + if (mThread) { + mThread->stop(); + mThread = NULL; + } +} + +#ifdef __LOC_DEBUG__ + +#include +#include +#include + +class LocRunnableTest1 : public LocRunnable { + int mID; +public: + LocRunnableTest1(int id) : LocRunnable(), mID(id) {} + virtual bool run() { + printf("LocRunnableTest1: %d\n", mID++); + sleep(1); + return true; + } +}; + +// on linux command line: +// compile: g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -std=c++0x -I. -I../../../../vendor/qcom/proprietary/gps-internal/unit-tests/fakes_for_host -I../../../../system/core/include -lpthread LocThread.cpp +// test detached thread: valgrind ./a.out 0 +// test joinable thread: valgrind ./a.out 1 +int main(int argc, char** argv) { + LocRunnableTest1 test(10); + + LocThread thread; + thread.start("LocThreadTest", test, atoi(argv[1])); + + sleep(10); + + thread.stop(); + + sleep(5); + + return 0; +} + +#endif diff --git a/gps/utils/LocThread.h b/gps/utils/LocThread.h new file mode 100644 index 0000000..2a65d8f --- /dev/null +++ b/gps/utils/LocThread.h @@ -0,0 +1,92 @@ +/* Copyright (c) 2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __LOC_THREAD__ +#define __LOC_THREAD__ + +#include +#include + +// abstract class to be implemented by client to provide a runnable class +// which gets scheduled by LocThread +class LocRunnable { +public: + inline LocRunnable() {} + inline virtual ~LocRunnable() {} + + // The method to be implemented by thread clients + // and be scheduled by LocThread + // This method will be repeated called until it returns false; or + // until thread is stopped. + virtual bool run() = 0; + + // The method to be run before thread loop (conditionally repeatedly) + // calls run() + inline virtual void prerun() {} + + // The method to be run after thread loop (conditionally repeatedly) + // calls run() + inline virtual void postrun() {} +}; + +// opaque class to provide service implementation. +class LocThreadDelegate; + +// A utility class to create a thread and run LocRunnable +// caller passes in. +class LocThread { + LocThreadDelegate* mThread; +public: + inline LocThread() : mThread(NULL) {} + virtual ~LocThread(); + + typedef pthread_t (*tCreate)(const char* name, void* (*start)(void*), void* arg); + // client starts thread with a runnable, which implements + // the logics to fun in the created thread context. + // The thread could be either joinable or detached. + // runnable is an obj managed by client. Client creates and + // frees it (but must be after stop() is called, or + // this LocThread obj is deleted). + // The obj will be deleted by LocThread if start() + // returns true. Else it is client's responsibility + // to delete the object + // Returns 0 if success; false if failure. + bool start(tCreate creator, const char* threadName, LocRunnable* runnable, bool joinable = true); + inline bool start(const char* threadName, LocRunnable* runnable, bool joinable = true) { + return start(NULL, threadName, runnable, joinable); + } + + // NOTE: if this is a joinable thread, this stop may block + // for a while until the thread is joined. + void stop(); + + // thread status check + inline bool isRunning() { return NULL != mThread; } +}; + +#endif //__LOC_THREAD__ diff --git a/gps/utils/LocTimer.cpp b/gps/utils/LocTimer.cpp new file mode 100644 index 0000000..4de6b40 --- /dev/null +++ b/gps/utils/LocTimer.cpp @@ -0,0 +1,742 @@ +/* Copyright (c) 2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __HOST_UNIT_TEST__ +#define EPOLLWAKEUP 0 +#define CLOCK_BOOTTIME CLOCK_MONOTONIC +#define CLOCK_BOOTTIME_ALARM CLOCK_MONOTONIC +#endif + +/* +There are implementations of 5 classes in this file: +LocTimer, LocTimerDelegate, LocTimerContainer, LocTimerPollTask, LocTimerWrapper + +LocTimer - client front end, interface for client to start / stop timers, also + to provide a callback. +LocTimerDelegate - an internal timer entity, which also is a LocRankable obj. + Its life cycle is different than that of LocTimer. It gets + created when LocTimer::start() is called, and gets deleted + when it expires or clients calls the hosting LocTimer obj's + stop() method. When a LocTimerDelegate obj is ticking, it + stays in the corresponding LocTimerContainer. When expired + or stopped, the obj is removed from the container. Since it + is also a LocRankable obj, and LocTimerContainer also is a + heap, its ranks() implementation decides where it is placed + in the heap. +LocTimerContainer - core of the timer service. It is a container (derived from + LocHeap) for LocTimerDelegate (implements LocRankable) objs. + There are 2 of such containers, one for sw timers (or Linux + timers) one for hw timers (or Linux alarms). It adds one of + each (those that expire the soonest) to kernel via services + provided by LocTimerPollTask. All the heap management on the + LocTimerDelegate objs are done in the MsgTask context, such + that synchronization is ensured. +LocTimerPollTask - is a class that wraps timerfd and epoll POXIS APIs. It also + both implements LocRunnalbe with epoll_wait() in the run() + method. It is also a LocThread client, so as to loop the run + method. +LocTimerWrapper - a LocTimer client itself, to implement the existing C API with + APIs, loc_timer_start() and loc_timer_stop(). + +*/ + +class LocTimerPollTask; + +// This is a multi-functaional class that: +// * extends the LocHeap class for the detection of head update upon add / remove +// events. When that happens, soonest time out changes, so timerfd needs update. +// * contains the timers, and add / remove them into the heap +// * provides and maps 2 of such containers, one for timers (or mSwTimers), one +// for alarms (or mHwTimers); +// * provides a polling thread; +// * provides a MsgTask thread for synchronized add / remove / timer client callback. +class LocTimerContainer : public LocHeap { + // mutex to synchronize getters of static members + static pthread_mutex_t mMutex; + // Container of timers + static LocTimerContainer* mSwTimers; + // Container of alarms + static LocTimerContainer* mHwTimers; + // Msg task to provider msg Q, sender and reader. + static MsgTask* mMsgTask; + // Poll task to provide epoll call and threading to poll. + static LocTimerPollTask* mPollTask; + // timer / alarm fd + int mDevFd; + // ctor + LocTimerContainer(bool wakeOnExpire); + // dtor + ~LocTimerContainer(); + static MsgTask* getMsgTaskLocked(); + static LocTimerPollTask* getPollTaskLocked(); + // extend LocHeap and pop if the top outRanks input + LocTimerDelegate* popIfOutRanks(LocTimerDelegate& timer); + // update the timer POSIX calls with updated soonest timer spec + void updateSoonestTime(LocTimerDelegate* priorTop); + +public: + // factory method to control the creation of mSwTimers / mHwTimers + static LocTimerContainer* get(bool wakeOnExpire); + + LocTimerDelegate* getSoonestTimer(); + int getTimerFd(); + // add a timer / alarm obj into the container + void add(LocTimerDelegate& timer); + // remove a timer / alarm obj from the container + void remove(LocTimerDelegate& timer); + // handling of timer / alarm expiration + void expire(); +}; + +// This class implements the polling thread that epolls imer / alarm fds. +// The LocRunnable::run() contains the actual polling. The other methods +// will be run in the caller's thread context to add / remove timer / alarm +// fds the kernel, while the polling is blocked on epoll_wait() call. +// Since the design is that we have maximally 2 polls, one for all the +// timers; one for all the alarms, we will poll at most on 2 fds. But it +// is possile that all we have are only timers or alarms at one time, so we +// allow dynamically add / remove fds we poll on. The design decision of +// having 1 fd per container of timer / alarm is such that, we may not need +// to make a system call each time a timer / alarm is added / removed, unless +// that changes the "soonest" time out of that of all the timers / alarms. +class LocTimerPollTask : public LocRunnable { + // the epoll fd + const int mFd; + // the thread that calls run() method + LocThread* mThread; + friend class LocThreadDelegate; + // dtor + ~LocTimerPollTask(); +public: + // ctor + LocTimerPollTask(); + // this obj will be deleted once thread is deleted + void destroy(); + // add a container of timers. Each contain has a unique device fd, i.e. + // either timer or alarm fd, and a heap of timers / alarms. It is expected + // that container would have written to the device fd with the soonest + // time out value in the heap at the time of calling this method. So all + // this method does is to add the fd of the input container to the poll + // and also add the pointer of the container to the event data ptr, such + // when poll_wait wakes up on events, we know who is the owner of the fd. + void addPoll(LocTimerContainer& timerContainer); + // remove a fd that is assciated with a container. The expectation is that + // the atual timer would have been removed from the container. + void removePoll(LocTimerContainer& timerContainer); + // The polling thread context will call this method. This is where + // epoll_wait() is blocking and waiting for events.. + virtual bool run(); +}; + +// Internal class of timer obj. It gets born when client calls LocTimer::start(); +// and gets deleted when client calls LocTimer::stop() or when the it expire()'s. +// This class implements LocRankable::ranks() so that when an obj is added into +// the container (of LocHeap), it gets placed in sorted order. +class LocTimerDelegate : public LocRankable { + friend class LocTimerContainer; + friend class LocTimer; + LocTimer* mClient; + LocSharedLock* mLock; + struct timespec mFutureTime; + LocTimerContainer* mContainer; + // not a complete obj, just ctor for LocRankable comparisons + inline LocTimerDelegate(struct timespec& delay) + : mClient(NULL), mLock(NULL), mFutureTime(delay), mContainer(NULL) {} + inline ~LocTimerDelegate() { if (mLock) { mLock->drop(); mLock = NULL; } } +public: + LocTimerDelegate(LocTimer& client, struct timespec& futureTime, bool wakeOnExpire); + void destroyLocked(); + // LocRankable virtual method + virtual int ranks(LocRankable& rankable); + void expire(); + inline struct timespec getFutureTime() { return mFutureTime; } +}; + +/***************************LocTimerContainer methods***************************/ + +// Most of these static recources are created on demand. They however are never +// destoyed. The theory is that there are processes that link to this util lib +// but never use timer, then these resources would never need to be created. +// For those processes that do use timer, it will likely also need to every +// once in a while. It might be cheaper keeping them around. +pthread_mutex_t LocTimerContainer::mMutex = PTHREAD_MUTEX_INITIALIZER; +LocTimerContainer* LocTimerContainer::mSwTimers = NULL; +LocTimerContainer* LocTimerContainer::mHwTimers = NULL; +MsgTask* LocTimerContainer::mMsgTask = NULL; +LocTimerPollTask* LocTimerContainer::mPollTask = NULL; + +// ctor - initialize timer heaps +// A container for swTimer (timer) is created, when wakeOnExpire is true; or +// HwTimer (alarm), when wakeOnExpire is false. +LocTimerContainer::LocTimerContainer(bool wakeOnExpire) : + mDevFd(timerfd_create(wakeOnExpire ? CLOCK_BOOTTIME_ALARM : CLOCK_BOOTTIME, 0)) { + + if ((-1 == mDevFd) && (errno == EINVAL)) { + LOC_LOGW("%s: timerfd_create failure, fallback to CLOCK_MONOTONIC - %s", + __FUNCTION__, strerror(errno)); + mDevFd = timerfd_create(CLOCK_MONOTONIC, 0); + } + + if (-1 != mDevFd) { + // ensure we have the necessary resources created + LocTimerContainer::getPollTaskLocked(); + LocTimerContainer::getMsgTaskLocked(); + } else { + LOC_LOGE("%s: timerfd_create failure - %s", __FUNCTION__, strerror(errno)); + } +} + +// dtor +// we do not ever destroy the static resources. +inline +LocTimerContainer::~LocTimerContainer() { + close(mDevFd); +} + +LocTimerContainer* LocTimerContainer::get(bool wakeOnExpire) { + // get the reference of either mHwTimer or mSwTimers per wakeOnExpire + LocTimerContainer*& container = wakeOnExpire ? mHwTimers : mSwTimers; + // it is cheap to check pointer first than locking mutext unconditionally + if (!container) { + pthread_mutex_lock(&mMutex); + // let's check one more time to be safe + if (!container) { + container = new LocTimerContainer(wakeOnExpire); + // timerfd_create failure + if (-1 == container->getTimerFd()) { + delete container; + container = NULL; + } + } + pthread_mutex_unlock(&mMutex); + } + return container; +} + +MsgTask* LocTimerContainer::getMsgTaskLocked() { + // it is cheap to check pointer first than locking mutext unconditionally + if (!mMsgTask) { + mMsgTask = new MsgTask("LocTimerMsgTask", false); + } + return mMsgTask; +} + +LocTimerPollTask* LocTimerContainer::getPollTaskLocked() { + // it is cheap to check pointer first than locking mutext unconditionally + if (!mPollTask) { + mPollTask = new LocTimerPollTask(); + } + return mPollTask; +} + +inline +LocTimerDelegate* LocTimerContainer::getSoonestTimer() { + return (LocTimerDelegate*)(peek()); +} + +inline +int LocTimerContainer::getTimerFd() { + return mDevFd; +} + +void LocTimerContainer::updateSoonestTime(LocTimerDelegate* priorTop) { + LocTimerDelegate* curTop = getSoonestTimer(); + + // check if top has changed + if (curTop != priorTop) { + struct itimerspec delay = {0}; + bool toSetTime = false; + // if tree is empty now, we remove poll and disarm timer + if (!curTop) { + mPollTask->removePoll(*this); + // setting the values to disarm timer + delay.it_value.tv_sec = 0; + delay.it_value.tv_nsec = 0; + toSetTime = true; + } else if (!priorTop || curTop->outRanks(*priorTop)) { + // do this first to avoid race condition, in case settime is called + // with too small an interval + mPollTask->addPoll(*this); + delay.it_value = curTop->getFutureTime(); + toSetTime = true; + } + if (toSetTime) { + timerfd_settime(getTimerFd(), TFD_TIMER_ABSTIME, &delay, NULL); + } + } +} + +// all the heap management is done in the MsgTask context. +inline +void LocTimerContainer::add(LocTimerDelegate& timer) { + struct MsgTimerPush : public LocMsg { + LocTimerContainer* mTimerContainer; + LocHeapNode* mTree; + LocTimerDelegate* mTimer; + inline MsgTimerPush(LocTimerContainer& container, LocTimerDelegate& timer) : + LocMsg(), mTimerContainer(&container), mTimer(&timer) {} + inline virtual void proc() const { + LocTimerDelegate* priorTop = mTimerContainer->getSoonestTimer(); + mTimerContainer->push((LocRankable&)(*mTimer)); + mTimerContainer->updateSoonestTime(priorTop); + } + }; + + mMsgTask->sendMsg(new MsgTimerPush(*this, timer)); +} + +// all the heap management is done in the MsgTask context. +void LocTimerContainer::remove(LocTimerDelegate& timer) { + struct MsgTimerRemove : public LocMsg { + LocTimerContainer* mTimerContainer; + LocTimerDelegate* mTimer; + inline MsgTimerRemove(LocTimerContainer& container, LocTimerDelegate& timer) : + LocMsg(), mTimerContainer(&container), mTimer(&timer) {} + inline virtual void proc() const { + LocTimerDelegate* priorTop = mTimerContainer->getSoonestTimer(); + + // update soonest timer only if mTimer is actually removed from + // mTimerContainer AND mTimer is not priorTop. + if (priorTop == ((LocHeap*)mTimerContainer)->remove((LocRankable&)*mTimer)) { + // if passing in NULL, we tell updateSoonestTime to update + // kernel with the current top timer interval. + mTimerContainer->updateSoonestTime(NULL); + } + // all timers are deleted here, and only here. + delete mTimer; + } + }; + + mMsgTask->sendMsg(new MsgTimerRemove(*this, timer)); +} + +// all the heap management is done in the MsgTask context. +// Upon expire, we check and continuously pop the heap until +// the top node's timeout is in the future. +void LocTimerContainer::expire() { + struct MsgTimerExpire : public LocMsg { + LocTimerContainer* mTimerContainer; + inline MsgTimerExpire(LocTimerContainer& container) : + LocMsg(), mTimerContainer(&container) {} + inline virtual void proc() const { + struct timespec now; + // get time spec of now + clock_gettime(CLOCK_BOOTTIME, &now); + LocTimerDelegate timerOfNow(now); + // pop everything in the heap that outRanks now, i.e. has time older than now + // and then call expire() on that timer. + for (LocTimerDelegate* timer = (LocTimerDelegate*)mTimerContainer->pop(); + NULL != timer; + timer = mTimerContainer->popIfOutRanks(timerOfNow)) { + // the timer delegate obj will be deleted before the return of this call + timer->expire(); + } + mTimerContainer->updateSoonestTime(NULL); + } + }; + + struct itimerspec delay = {0}; + timerfd_settime(getTimerFd(), TFD_TIMER_ABSTIME, &delay, NULL); + mPollTask->removePoll(*this); + mMsgTask->sendMsg(new MsgTimerExpire(*this)); +} + +LocTimerDelegate* LocTimerContainer::popIfOutRanks(LocTimerDelegate& timer) { + LocTimerDelegate* poppedNode = NULL; + if (mTree && !timer.outRanks(*peek())) { + poppedNode = (LocTimerDelegate*)(pop()); + } + + return poppedNode; +} + + +/***************************LocTimerPollTask methods***************************/ + +inline +LocTimerPollTask::LocTimerPollTask() + : mFd(epoll_create(2)), mThread(new LocThread()) { + // before a next call returens, a thread will be created. The run() method + // could already be running in parallel. Also, since each of the objs + // creates a thread, the container will make sure that there will be only + // one of such obj for our timer implementation. + if (!mThread->start("LocTimerPollTask", this)) { + delete mThread; + mThread = NULL; + } +} + +inline +LocTimerPollTask::~LocTimerPollTask() { + // when fs is closed, epoll_wait() should fail run() should return false + // and the spawned thread should exit. + close(mFd); +} + +void LocTimerPollTask::destroy() { + if (mThread) { + LocThread* thread = mThread; + mThread = NULL; + delete thread; + } else { + delete this; + } +} + +void LocTimerPollTask::addPoll(LocTimerContainer& timerContainer) { + struct epoll_event ev; + memset(&ev, 0, sizeof(ev)); + + ev.events = EPOLLIN | EPOLLWAKEUP; + ev.data.fd = timerContainer.getTimerFd(); + // it is important that we set this context pointer with the input + // timer container this is how we know which container should handle + // which expiration. + ev.data.ptr = &timerContainer; + + epoll_ctl(mFd, EPOLL_CTL_ADD, timerContainer.getTimerFd(), &ev); +} + +inline +void LocTimerPollTask::removePoll(LocTimerContainer& timerContainer) { + epoll_ctl(mFd, EPOLL_CTL_DEL, timerContainer.getTimerFd(), NULL); +} + +// The polling thread context will call this method. If run() method needs to +// be repetitvely called, it must return true from the previous call. +bool LocTimerPollTask::run() { + struct epoll_event ev[2]; + + // we have max 2 descriptors to poll from + int fds = epoll_wait(mFd, ev, 2, -1); + + // we pretty much want to continually poll until the fd is closed + bool rerun = (fds > 0) || (errno == EINTR); + + if (fds > 0) { + // we may have 2 events + for (int i = 0; i < fds; i++) { + // each fd has a context pointer associated with the right timer container + LocTimerContainer* container = (LocTimerContainer*)(ev[i].data.ptr); + if (container) { + container->expire(); + } else { + epoll_ctl(mFd, EPOLL_CTL_DEL, ev[i].data.fd, NULL); + } + } + } + + // if rerun is true, we are requesting to be scheduled again + return rerun; +} + +/***************************LocTimerDelegate methods***************************/ + +inline +LocTimerDelegate::LocTimerDelegate(LocTimer& client, struct timespec& futureTime, bool wakeOnExpire) + : mClient(&client), + mLock(mClient->mLock->share()), + mFutureTime(futureTime), + mContainer(LocTimerContainer::get(wakeOnExpire)) { + // adding the timer into the container + mContainer->add(*this); +} + +inline +void LocTimerDelegate::destroyLocked() { + // client handle will likely be deleted soon after this + // method returns. Nulling this handle so that expire() + // won't call the callback on the dead handle any more. + mClient = NULL; + + if (mContainer) { + LocTimerContainer* container = mContainer; + mContainer = NULL; + if (container) { + container->remove(*this); + } + } // else we do not do anything. No such *this* can be + // created and reached here with mContainer ever been + // a non NULL. So *this* must have reached the if clause + // once, and we want it reach there only once. +} + +int LocTimerDelegate::ranks(LocRankable& rankable) { + int rank = -1; + LocTimerDelegate* timer = (LocTimerDelegate*)(&rankable); + if (timer) { + // larger time ranks lower!!! + // IOW, if input obj has bigger tv_sec/tv_nsec, this obj outRanks higher + rank = timer->mFutureTime.tv_sec - mFutureTime.tv_sec; + if(0 == rank) + { + //rank against tv_nsec for msec accuracy + rank = (int)(timer->mFutureTime.tv_nsec - mFutureTime.tv_nsec); + } + } + return rank; +} + +inline +void LocTimerDelegate::expire() { + // keeping a copy of client pointer to be safe + // when timeOutCallback() is called at the end of this + // method, *this* obj may be already deleted. + LocTimer* client = mClient; + // force a stop, which will lead to delete of this obj + if (client && client->stop()) { + // calling client callback with a pointer save on the stack + // only if stop() returns true, i.e. it hasn't been stopped + // already. + client->timeOutCallback(); + } +} + + +/***************************LocTimer methods***************************/ +LocTimer::LocTimer() : mTimer(NULL), mLock(new LocSharedLock()) { +} + +LocTimer::~LocTimer() { + stop(); + if (mLock) { + mLock->drop(); + mLock = NULL; + } +} + +bool LocTimer::start(unsigned int timeOutInMs, bool wakeOnExpire) { + bool success = false; + mLock->lock(); + if (!mTimer) { + struct timespec futureTime; + clock_gettime(CLOCK_BOOTTIME, &futureTime); + futureTime.tv_sec += timeOutInMs / 1000; + futureTime.tv_nsec += (timeOutInMs % 1000) * 1000000; + if (futureTime.tv_nsec >= 1000000000) { + futureTime.tv_sec += futureTime.tv_nsec / 1000000000; + futureTime.tv_nsec %= 1000000000; + } + mTimer = new LocTimerDelegate(*this, futureTime, wakeOnExpire); + // if mTimer is non 0, success should be 0; or vice versa + success = (NULL != mTimer); + } + mLock->unlock(); + return success; +} + +bool LocTimer::stop() { + bool success = false; + mLock->lock(); + if (mTimer) { + LocTimerDelegate* timer = mTimer; + mTimer = NULL; + if (timer) { + timer->destroyLocked(); + success = true; + } + } + mLock->unlock(); + return success; +} + +/***************************LocTimerWrapper methods***************************/ +////////////////////////////////////////////////////////////////////////// +// This section below wraps for the C style APIs +////////////////////////////////////////////////////////////////////////// +class LocTimerWrapper : public LocTimer { + loc_timer_callback mCb; + void* mCallerData; + LocTimerWrapper* mMe; + static pthread_mutex_t mMutex; + inline ~LocTimerWrapper() { mCb = NULL; mMe = NULL; } +public: + inline LocTimerWrapper(loc_timer_callback cb, void* callerData) : + mCb(cb), mCallerData(callerData), mMe(this) { + } + void destroy() { + pthread_mutex_lock(&mMutex); + if (NULL != mCb && this == mMe) { + delete this; + } + pthread_mutex_unlock(&mMutex); + } + virtual void timeOutCallback() { + loc_timer_callback cb = mCb; + void* callerData = mCallerData; + if (cb) { + cb(callerData, 0); + } + destroy(); + } +}; + +pthread_mutex_t LocTimerWrapper::mMutex = PTHREAD_MUTEX_INITIALIZER; + +void* loc_timer_start(uint64_t msec, loc_timer_callback cb_func, + void *caller_data, bool wake_on_expire) +{ + LocTimerWrapper* locTimerWrapper = NULL; + + if (cb_func) { + locTimerWrapper = new LocTimerWrapper(cb_func, caller_data); + + if (locTimerWrapper) { + locTimerWrapper->start(msec, wake_on_expire); + } + } + + return locTimerWrapper; +} + +void loc_timer_stop(void*& handle) +{ + if (handle) { + LocTimerWrapper* locTimerWrapper = (LocTimerWrapper*)(handle); + locTimerWrapper->destroy(); + handle = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +// This section above wraps for the C style APIs +////////////////////////////////////////////////////////////////////////// + +#ifdef __LOC_DEBUG__ + +double getDeltaSeconds(struct timespec from, struct timespec to) { + return (double)to.tv_sec + (double)to.tv_nsec / 1000000000 + - from.tv_sec - (double)from.tv_nsec / 1000000000; +} + +struct timespec getNow() { + struct timespec now; + clock_gettime(CLOCK_BOOTTIME, &now); + return now; +} + +class LocTimerTest : public LocTimer, public LocRankable { + int mTimeOut; + const struct timespec mTimeOfBirth; + inline struct timespec getTimerWrapper(int timeout) { + struct timespec now; + clock_gettime(CLOCK_BOOTTIME, &now); + now.tv_sec += timeout; + return now; + } +public: + inline LocTimerTest(int timeout) : LocTimer(), LocRankable(), + mTimeOut(timeout), mTimeOfBirth(getTimerWrapper(0)) {} + inline virtual int ranks(LocRankable& rankable) { + LocTimerTest* timer = dynamic_cast(&rankable); + return timer->mTimeOut - mTimeOut; + } + inline virtual void timeOutCallback() { + printf("timeOutCallback() - "); + deviation(); + } + double deviation() { + struct timespec now = getTimerWrapper(0); + double delta = getDeltaSeconds(mTimeOfBirth, now); + printf("%lf: %lf\n", delta, delta * 100 / mTimeOut); + return delta / mTimeOut; + } +}; + +// For Linux command line testing: +// compilation: +// g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -I. -I../../../../system/core/include -o LocHeap.o LocHeap.cpp +// g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -std=c++0x -I. -I../../../../system/core/include -lpthread -o LocThread.o LocThread.cpp +// g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -I. -I../../../../system/core/include -o LocTimer.o LocTimer.cpp +int main(int argc, char** argv) { + struct timespec timeOfStart=getNow(); + srand(time(NULL)); + int tries = atoi(argv[1]); + int checks = tries >> 3; + LocTimerTest** timerArray = new LocTimerTest*[tries]; + memset(timerArray, NULL, tries); + + for (int i = 0; i < tries; i++) { + int r = rand() % tries; + LocTimerTest* timer = new LocTimerTest(r); + if (timerArray[r]) { + if (!timer->stop()) { + printf("%lf:\n", getDeltaSeconds(timeOfStart, getNow())); + printf("ERRER: %dth timer, id %d, not running when it should be\n", i, r); + exit(0); + } else { + printf("stop() - %d\n", r); + delete timer; + timerArray[r] = NULL; + } + } else { + if (!timer->start(r, false)) { + printf("%lf:\n", getDeltaSeconds(timeOfStart, getNow())); + printf("ERRER: %dth timer, id %d, running when it should not be\n", i, r); + exit(0); + } else { + printf("stop() - %d\n", r); + timerArray[r] = timer; + } + } + } + + for (int i = 0; i < tries; i++) { + if (timerArray[i]) { + if (!timerArray[i]->stop()) { + printf("%lf:\n", getDeltaSeconds(timeOfStart, getNow())); + printf("ERRER: %dth timer, not running when it should be\n", i); + exit(0); + } else { + printf("stop() - %d\n", i); + delete timerArray[i]; + timerArray[i] = NULL; + } + } + } + + delete[] timerArray; + + return 0; +} + +#endif diff --git a/gps/utils/LocTimer.h b/gps/utils/LocTimer.h new file mode 100644 index 0000000..c146852 --- /dev/null +++ b/gps/utils/LocTimer.h @@ -0,0 +1,74 @@ +/* Copyright (c) 2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __LOC_TIMER_CPP_H__ +#define __LOC_TIMER_CPP_H__ + +#include +#include + +// opaque class to provide service implementation. +class LocTimerDelegate; +class LocSharedLock; + +// LocTimer client must extend this class and implementthe callback. +// start() / stop() methods are to arm / disarm timer. +class LocTimer +{ + LocTimerDelegate* mTimer; + LocSharedLock* mLock; + // don't really want mLock to be manipulated by clients, yet LocTimer + // has to have a reference to the lock so that the delete of LocTimer + // and LocTimerDelegate can work together on their share resources. + friend class LocTimerDelegate; + +public: + LocTimer(); + virtual ~LocTimer(); + + // timeOutInMs: timeout delay in ms + // wakeOnExpire: true if to wake up CPU (if sleeping) upon timer + // expiration and notify the client. + // false if to wait until next time CPU wakes up (if + // sleeping) and then notify the client. + // return: true on success; + // false on failure, e.g. timer is already running. + bool start(uint32_t timeOutInMs, bool wakeOnExpire); + + // return: true on success; + // false on failure, e.g. timer is not running. + bool stop(); + + // LocTimer client Should implement this method. + // This method is used for timeout calling back to client. This method + // should be short enough (eg: send a message to your own thread). + virtual void timeOutCallback() = 0; +}; + +#endif //__LOC_DELAY_H__ diff --git a/gps/utils/MsgTask.cpp b/gps/utils/MsgTask.cpp new file mode 100644 index 0000000..0e7a3a2 --- /dev/null +++ b/gps/utils/MsgTask.cpp @@ -0,0 +1,102 @@ +/* Copyright (c) 2011-2013,2015 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_MsgTask" + +#include +#include +#include +#include +#include +#include + +static void LocMsgDestroy(void* msg) { + delete (LocMsg*)msg; +} + +MsgTask::MsgTask(LocThread::tCreate tCreator, + const char* threadName, bool joinable) : + mQ(msg_q_init2()), mThread(new LocThread()) { + if (!mThread->start(tCreator, threadName, this, joinable)) { + delete mThread; + mThread = NULL; + } +} + +MsgTask::MsgTask(const char* threadName, bool joinable) : + mQ(msg_q_init2()), mThread(new LocThread()) { + if (!mThread->start(threadName, this, joinable)) { + delete mThread; + mThread = NULL; + } +} + +MsgTask::~MsgTask() { + msg_q_flush((void*)mQ); + msg_q_destroy((void**)&mQ); +} + +void MsgTask::destroy() { + LocThread* thread = mThread; + msg_q_unblock((void*)mQ); + if (thread) { + mThread = NULL; + delete thread; + } else { + delete this; + } +} + +void MsgTask::sendMsg(const LocMsg* msg) const { + msg_q_snd((void*)mQ, (void*)msg, LocMsgDestroy); +} + +void MsgTask::prerun() { + // make sure we do not run in background scheduling group + set_sched_policy(gettid(), SP_FOREGROUND); +} + +bool MsgTask::run() { + LOC_LOGV("MsgTask::loop() listening ...\n"); + LocMsg* msg; + msq_q_err_type result = msg_q_rcv((void*)mQ, (void **)&msg); + if (eMSG_Q_SUCCESS != result) { + LOC_LOGE("%s:%d] fail receiving msg: %s\n", __func__, __LINE__, + loc_get_msg_q_status(result)); + return false; + } + + msg->log(); + // there is where each individual msg handling is invoked + msg->proc(); + + delete msg; + + return true; +} diff --git a/gps/utils/MsgTask.h b/gps/utils/MsgTask.h new file mode 100644 index 0000000..9eb1f56 --- /dev/null +++ b/gps/utils/MsgTask.h @@ -0,0 +1,67 @@ +/* Copyright (c) 2011-2013,2015 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __MSG_TASK__ +#define __MSG_TASK__ + +#include + +struct LocMsg { + inline LocMsg() {} + inline virtual ~LocMsg() {} + virtual void proc() const = 0; + inline virtual void log() const {} +}; + +class MsgTask : public LocRunnable { + const void* mQ; + LocThread* mThread; + friend class LocThreadDelegate; +protected: + virtual ~MsgTask(); +public: + MsgTask(LocThread::tCreate tCreator, const char* threadName = NULL, bool joinable = true); + MsgTask(const char* threadName = NULL, bool joinable = true); + // this obj will be deleted once thread is deleted + void destroy(); + void sendMsg(const LocMsg* msg) const; + // Overrides of LocRunnable methods + // This method will be repeated called until it returns false; or + // until thread is stopped. + virtual bool run(); + + // The method to be run before thread loop (conditionally repeatedly) + // calls run() + virtual void prerun(); + + // The method to be run after thread loop (conditionally repeatedly) + // calls run() + inline virtual void postrun() {} +}; + +#endif //__MSG_TASK__ diff --git a/gps/utils/linked_list.c b/gps/utils/linked_list.c new file mode 100644 index 0000000..2c91714 --- /dev/null +++ b/gps/utils/linked_list.c @@ -0,0 +1,328 @@ +/* Copyright (c) 2011, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "linked_list.h" +#include +#include + +#define LOG_TAG "LocSvc_utils_ll" +#include "log_util.h" +#include "platform_lib_includes.h" +#include +#include + +typedef struct list_element { + struct list_element* next; + struct list_element* prev; + void* data_ptr; + void (*dealloc_func)(void*); +}list_element; + +typedef struct list_state { + list_element* p_head; + list_element* p_tail; +} list_state; + +/* ----------------------- END INTERNAL FUNCTIONS ---------------------------------------- */ + +/*=========================================================================== + + FUNCTION: linked_list_init + + ===========================================================================*/ +linked_list_err_type linked_list_init(void** list_data) +{ + if( list_data == NULL ) + { + LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); + return eLINKED_LIST_INVALID_PARAMETER; + } + + list_state* tmp_list; + tmp_list = (list_state*)calloc(1, sizeof(list_state)); + if( tmp_list == NULL ) + { + LOC_LOGE("%s: Unable to allocate space for list!\n", __FUNCTION__); + return eLINKED_LIST_FAILURE_GENERAL; + } + + tmp_list->p_head = NULL; + tmp_list->p_tail = NULL; + + *list_data = tmp_list; + + return eLINKED_LIST_SUCCESS; +} + +/*=========================================================================== + + FUNCTION: linked_list_destroy + + ===========================================================================*/ +linked_list_err_type linked_list_destroy(void** list_data) +{ + if( list_data == NULL ) + { + LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); + return eLINKED_LIST_INVALID_HANDLE; + } + + list_state* p_list = (list_state*)*list_data; + + linked_list_flush(p_list); + + free(*list_data); + *list_data = NULL; + + return eLINKED_LIST_SUCCESS; +} + +/*=========================================================================== + + FUNCTION: linked_list_add + + ===========================================================================*/ +linked_list_err_type linked_list_add(void* list_data, void *data_obj, void (*dealloc)(void*)) +{ + LOC_LOGV("%s: Adding to list data_obj = 0x%08X\n", __FUNCTION__, data_obj); + if( list_data == NULL ) + { + LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); + return eLINKED_LIST_INVALID_HANDLE; + } + + if( data_obj == NULL ) + { + LOC_LOGE("%s: Invalid input parameter!\n", __FUNCTION__); + return eLINKED_LIST_INVALID_PARAMETER; + } + + list_state* p_list = (list_state*)list_data; + list_element* elem = (list_element*)malloc(sizeof(list_element)); + if( elem == NULL ) + { + LOC_LOGE("%s: Memory allocation failed\n", __FUNCTION__); + return eLINKED_LIST_FAILURE_GENERAL; + } + + /* Copy data to newly created element */ + elem->data_ptr = data_obj; + elem->next = NULL; + elem->prev = NULL; + elem->dealloc_func = dealloc; + + /* Replace head element */ + list_element* tmp = p_list->p_head; + p_list->p_head = elem; + /* Point next to the previous head element */ + p_list->p_head->next = tmp; + + if( tmp != NULL ) + { + tmp->prev = p_list->p_head; + } + else + { + p_list->p_tail = p_list->p_head; + } + + return eLINKED_LIST_SUCCESS; +} + +/*=========================================================================== + + FUNCTION: linked_list_remove + + ===========================================================================*/ +linked_list_err_type linked_list_remove(void* list_data, void **data_obj) +{ + LOC_LOGV("%s: Removing from list\n", __FUNCTION__); + if( list_data == NULL ) + { + LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); + return eLINKED_LIST_INVALID_HANDLE; + } + + if( data_obj == NULL ) + { + LOC_LOGE("%s: Invalid input parameter!\n", __FUNCTION__); + return eLINKED_LIST_INVALID_PARAMETER; + } + + list_state* p_list = (list_state*)list_data; + if( p_list->p_tail == NULL ) + { + return eLINKED_LIST_UNAVAILABLE_RESOURCE; + } + + list_element* tmp = p_list->p_tail; + + /* Replace tail element */ + p_list->p_tail = tmp->prev; + + if( p_list->p_tail != NULL ) + { + p_list->p_tail->next = NULL; + } + else + { + p_list->p_head = p_list->p_tail; + } + + /* Copy data to output param */ + *data_obj = tmp->data_ptr; + + /* Free allocated list element */ + free(tmp); + + return eLINKED_LIST_SUCCESS; +} + +/*=========================================================================== + + FUNCTION: linked_list_empty + + ===========================================================================*/ +int linked_list_empty(void* list_data) +{ + if( list_data == NULL ) + { + LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); + return (int)eLINKED_LIST_INVALID_HANDLE; + } + else + { + list_state* p_list = (list_state*)list_data; + return p_list->p_head == NULL ? 1 : 0; + } +} + +/*=========================================================================== + + FUNCTION: linked_list_flush + + ===========================================================================*/ +linked_list_err_type linked_list_flush(void* list_data) +{ + if( list_data == NULL ) + { + LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); + return eLINKED_LIST_INVALID_HANDLE; + } + + list_state* p_list = (list_state*)list_data; + + /* Remove all dynamically allocated elements */ + while( p_list->p_head != NULL ) + { + list_element* tmp = p_list->p_head->next; + + /* Free data pointer if told to do so. */ + if( p_list->p_head->dealloc_func != NULL ) + { + p_list->p_head->dealloc_func(p_list->p_head->data_ptr); + } + + /* Free list element */ + free(p_list->p_head); + + p_list->p_head = tmp; + } + + p_list->p_tail = NULL; + + return eLINKED_LIST_SUCCESS; +} + +/*=========================================================================== + + FUNCTION: linked_list_search + + ===========================================================================*/ +linked_list_err_type linked_list_search(void* list_data, void **data_p, + bool (*equal)(void* data_0, void* data), + void* data_0, bool rm_if_found) +{ + LOC_LOGV("%s: Search the list\n", __FUNCTION__); + if( list_data == NULL || NULL == equal ) + { + LOC_LOGE("%s: Invalid list parameter! list_data %p equal %p\n", + __FUNCTION__, list_data, equal); + return eLINKED_LIST_INVALID_HANDLE; + } + + list_state* p_list = (list_state*)list_data; + if( p_list->p_tail == NULL ) + { + return eLINKED_LIST_UNAVAILABLE_RESOURCE; + } + + list_element* tmp = p_list->p_head; + + if (NULL != data_p) { + *data_p = NULL; + } + + while (NULL != tmp) { + if ((*equal)(data_0, tmp->data_ptr)) { + if (NULL != data_p) { + *data_p = tmp->data_ptr; + } + + if (rm_if_found) { + if (NULL == tmp->prev) { + p_list->p_head = tmp->next; + } else { + tmp->prev->next = tmp->next; + } + + if (NULL == tmp->next) { + p_list->p_tail = tmp->prev; + } else { + tmp->next->prev = tmp->prev; + } + + tmp->prev = tmp->next = NULL; + + // dealloc data if it is not copied out && caller + // has given us a dealloc function pointer. + if (NULL == data_p && NULL != tmp->dealloc_func) { + tmp->dealloc_func(tmp->data_ptr); + } + free(tmp); + } + + tmp = NULL; + } else { + tmp = tmp->next; + } + } + + return eLINKED_LIST_SUCCESS; +} + diff --git a/gps/utils/linked_list.h b/gps/utils/linked_list.h new file mode 100644 index 0000000..a85f09a --- /dev/null +++ b/gps/utils/linked_list.h @@ -0,0 +1,217 @@ +/* Copyright (c) 2011, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef __LINKED_LIST_H__ +#define __LINKED_LIST_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include + +/** Linked List Return Codes */ +typedef enum +{ + eLINKED_LIST_SUCCESS = 0, + /**< Request was successful. */ + eLINKED_LIST_FAILURE_GENERAL = -1, + /**< Failed because of a general failure. */ + eLINKED_LIST_INVALID_PARAMETER = -2, + /**< Failed because the request contained invalid parameters. */ + eLINKED_LIST_INVALID_HANDLE = -3, + /**< Failed because an invalid handle was specified. */ + eLINKED_LIST_UNAVAILABLE_RESOURCE = -4, + /**< Failed because an there were not enough resources. */ + eLINKED_LIST_INSUFFICIENT_BUFFER = -5, + /**< Failed because an the supplied buffer was too small. */ +}linked_list_err_type; + +/*=========================================================================== +FUNCTION linked_list_init + +DESCRIPTION + Initializes internal structures for linked list. + + list_data: State of list to be initialized. + +DEPENDENCIES + N/A + +RETURN VALUE + Look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +linked_list_err_type linked_list_init(void** list_data); + +/*=========================================================================== +FUNCTION linked_list_destroy + +DESCRIPTION + Destroys internal structures for linked list. + + p_list_data: State of list to be destroyed. + +DEPENDENCIES + N/A + +RETURN VALUE + Look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +linked_list_err_type linked_list_destroy(void** list_data); + +/*=========================================================================== +FUNCTION linked_list_add + +DESCRIPTION + Adds an element to the head of the linked list. The passed in data pointer + is not modified or freed. Passed in data_obj is expected to live throughout + the use of the linked_list (i.e. data is not allocated internally) + + p_list_data: List to add data to the head of. + data_obj: Pointer to data to add into list + dealloc: Function used to deallocate memory for this element. Pass NULL + if you do not want data deallocated during a flush operation + +DEPENDENCIES + N/A + +RETURN VALUE + Look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +linked_list_err_type linked_list_add(void* list_data, void *data_obj, void (*dealloc)(void*)); + +/*=========================================================================== +FUNCTION linked_list_remove + +DESCRIPTION + Retrieves data from the list tail. data_obj is the tail element from the list + passed in by linked_list_add. + + p_list_data: List to remove the tail from. + data_obj: Pointer to data removed from list + +DEPENDENCIES + N/A + +RETURN VALUE + Look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +linked_list_err_type linked_list_remove(void* list_data, void **data_obj); + +/*=========================================================================== +FUNCTION linked_list_empty + +DESCRIPTION + Tells whether the list currently contains any elements + + p_list_data: List to check if empty. + +DEPENDENCIES + N/A + +RETURN VALUE + 0/FALSE : List contains elements + 1/TRUE : List is Empty + Otherwise look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +int linked_list_empty(void* list_data); + +/*=========================================================================== +FUNCTION linked_list_flush + +DESCRIPTION + Removes all elements from the list and deallocates them using the provided + dealloc function while adding elements. + + p_list_data: List to remove all elements from. + +DEPENDENCIES + N/A + +RETURN VALUE + Look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +linked_list_err_type linked_list_flush(void* list_data); + +/*=========================================================================== +FUNCTION linked_list_search + +DESCRIPTION + Searches for an element in the linked list. + + p_list_data: List handle. + data_p: to be stored with the data found; NUll if no match. + if data_p passed in as NULL, then no write to it. + equal: Function ptr takes in a list element, and returns + indication if this the one looking for. + data_0: The data being compared against. + rm_if_found: Should data be removed if found? + +DEPENDENCIES + N/A + +RETURN VALUE + Look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +linked_list_err_type linked_list_search(void* list_data, void **data_p, + bool (*equal)(void* data_0, void* data), + void* data_0, bool rm_if_found); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LINKED_LIST_H__ */ diff --git a/gps/utils/loc_cfg.cpp b/gps/utils/loc_cfg.cpp new file mode 100644 index 0000000..5c33320 --- /dev/null +++ b/gps/utils/loc_cfg.cpp @@ -0,0 +1,400 @@ +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_utils_cfg" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef USE_GLIB +#include +#endif +#include "platform_lib_includes.h" + +/*============================================================================= + * + * GLOBAL DATA DECLARATION + * + *============================================================================*/ + +/* Parameter data */ +static uint32_t DEBUG_LEVEL = 0xff; +static uint32_t TIMESTAMP = 0; + +/* Parameter spec table */ +static loc_param_s_type loc_param_table[] = +{ + {"DEBUG_LEVEL", &DEBUG_LEVEL, NULL, 'n'}, + {"TIMESTAMP", &TIMESTAMP, NULL, 'n'}, +}; +int loc_param_num = sizeof(loc_param_table) / sizeof(loc_param_s_type); + +typedef struct loc_param_v_type +{ + char* param_name; + char* param_str_value; + int param_int_value; + double param_double_value; +}loc_param_v_type; + +/*=========================================================================== +FUNCTION loc_set_config_entry + +DESCRIPTION + Potentially sets a given configuration table entry based on the passed in + configuration value. This is done by using a string comparison of the + parameter names and those found in the configuration file. + +PARAMETERS: + config_entry: configuration entry in the table to possibly set + config_value: value to store in the entry if the parameter names match + +DEPENDENCIES + N/A + +RETURN VALUE + None + +SIDE EFFECTS + N/A +===========================================================================*/ +int loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value) +{ + int ret=-1; + if(NULL == config_entry || NULL == config_value) + { + LOC_LOGE("%s: INVALID config entry or parameter", __FUNCTION__); + return ret; + } + + if (strcmp(config_entry->param_name, config_value->param_name) == 0 && + config_entry->param_ptr) + { + switch (config_entry->param_type) + { + case 's': + if (strcmp(config_value->param_str_value, "NULL") == 0) + { + *((char*)config_entry->param_ptr) = '\0'; + } + else { + strlcpy((char*) config_entry->param_ptr, + config_value->param_str_value, + LOC_MAX_PARAM_STRING + 1); + } + /* Log INI values */ + LOC_LOGD("%s: PARAM %s = %s", __FUNCTION__, + config_entry->param_name, (char*)config_entry->param_ptr); + + if(NULL != config_entry->param_set) + { + *(config_entry->param_set) = 1; + } + ret = 0; + break; + case 'n': + *((int *)config_entry->param_ptr) = config_value->param_int_value; + /* Log INI values */ + LOC_LOGD("%s: PARAM %s = %d", __FUNCTION__, + config_entry->param_name, config_value->param_int_value); + + if(NULL != config_entry->param_set) + { + *(config_entry->param_set) = 1; + } + ret = 0; + break; + case 'f': + *((double *)config_entry->param_ptr) = config_value->param_double_value; + /* Log INI values */ + LOC_LOGD("%s: PARAM %s = %f", __FUNCTION__, + config_entry->param_name, config_value->param_double_value); + + if(NULL != config_entry->param_set) + { + *(config_entry->param_set) = 1; + } + ret = 0; + break; + default: + LOC_LOGE("%s: PARAM %s parameter type must be n, f, or s", + __FUNCTION__, config_entry->param_name); + } + } + return ret; +} + +/*=========================================================================== +FUNCTION loc_fill_conf_item + +DESCRIPTION + Takes a line of configuration item and sets defined values based on + the passed in configuration table. This table maps strings to values to + set along with the type of each of these values. + +PARAMETERS: + input_buf : buffer contanis config item + config_table: table definition of strings to places to store information + table_length: length of the configuration table + +DEPENDENCIES + N/A + +RETURN VALUE + 0: Number of records in the config_table filled with input_buf + +SIDE EFFECTS + N/A +===========================================================================*/ +int loc_fill_conf_item(char* input_buf, + loc_param_s_type* config_table, uint32_t table_length) +{ + int ret = 0; + + if (input_buf && config_table) { + char *lasts; + loc_param_v_type config_value; + memset(&config_value, 0, sizeof(config_value)); + + /* Separate variable and value */ + config_value.param_name = strtok_r(input_buf, "=", &lasts); + /* skip lines that do not contain "=" */ + if (config_value.param_name) { + config_value.param_str_value = strtok_r(NULL, "=", &lasts); + + /* skip lines that do not contain two operands */ + if (config_value.param_str_value) { + /* Trim leading and trailing spaces */ + loc_util_trim_space(config_value.param_name); + loc_util_trim_space(config_value.param_str_value); + + /* Parse numerical value */ + if ((strlen(config_value.param_str_value) >=3) && + (config_value.param_str_value[0] == '0') && + (tolower(config_value.param_str_value[1]) == 'x')) + { + /* hex */ + config_value.param_int_value = (int) strtol(&config_value.param_str_value[2], + (char**) NULL, 16); + } + else { + config_value.param_double_value = (double) atof(config_value.param_str_value); /* float */ + config_value.param_int_value = atoi(config_value.param_str_value); /* dec */ + } + + for(uint32_t i = 0; NULL != config_table && i < table_length; i++) + { + if(!loc_set_config_entry(&config_table[i], &config_value)) { + ret += 1; + } + } + } + } + } + + return ret; +} + +/*=========================================================================== +FUNCTION loc_read_conf_r (repetitive) + +DESCRIPTION + Reads the specified configuration file and sets defined values based on + the passed in configuration table. This table maps strings to values to + set along with the type of each of these values. + The difference between this and loc_read_conf is that this function returns + the file pointer position at the end of filling a config table. Also, it + reads a fixed number of parameters at a time which is equal to the length + of the configuration table. This functionality enables the caller to + repeatedly call the function to read data from the same file. + +PARAMETERS: + conf_fp : file pointer + config_table: table definition of strings to places to store information + table_length: length of the configuration table + +DEPENDENCIES + N/A + +RETURN VALUE + 0: Table filled successfully + 1: No more parameters to read + -1: Error filling table + +SIDE EFFECTS + N/A +===========================================================================*/ +int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, uint32_t table_length) +{ + int ret=0; + + unsigned int num_params=table_length; + if(conf_fp == NULL) { + LOC_LOGE("%s:%d]: ERROR: File pointer is NULL\n", __func__, __LINE__); + ret = -1; + goto err; + } + + /* Clear all validity bits */ + for(uint32_t i = 0; NULL != config_table && i < table_length; i++) + { + if(NULL != config_table[i].param_set) + { + *(config_table[i].param_set) = 0; + } + } + + char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */ + + LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params); + while(num_params) + { + if(!fgets(input_buf, LOC_MAX_PARAM_LINE, conf_fp)) { + LOC_LOGD("%s:%d]: fgets returned NULL\n", __func__, __LINE__); + break; + } + + num_params -= loc_fill_conf_item(input_buf, config_table, table_length); + } + +err: + return ret; +} + +/*=========================================================================== +FUNCTION loc_udpate_conf + +DESCRIPTION + Parses the passed in buffer for configuration items, and update the table + that is also passed in. + +Reads the specified configuration file and sets defined values based on + the passed in configuration table. This table maps strings to values to + set along with the type of each of these values. + +PARAMETERS: + conf_data: configuration items in bufferas a string + length: strlen(conf_data) + config_table: table definition of strings to places to store information + table_length: length of the configuration table + +DEPENDENCIES + N/A + +RETURN VALUE + number of the records in the table that is updated at time of return. + +SIDE EFFECTS + N/A +===========================================================================*/ +int loc_update_conf(const char* conf_data, int32_t length, + loc_param_s_type* config_table, uint32_t table_length) +{ + int ret = -1; + + if (conf_data && length && config_table && table_length) { + // make a copy, so we do not tokenize the original data + char* conf_copy = (char*)malloc(length+1); + + if (conf_copy != NULL) + { + memcpy(conf_copy, conf_data, length); + // we hard NULL the end of string to be safe + conf_copy[length] = 0; + + // start with one record off + uint32_t num_params = table_length - 1; + char* saveptr = NULL; + char* input_buf = strtok_r(conf_copy, "\n", &saveptr); + ret = 0; + + LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params); + while(num_params && input_buf) { + ret++; + num_params -= loc_fill_conf_item(input_buf, config_table, table_length); + input_buf = strtok_r(NULL, "\n", &saveptr); + } + free(conf_copy); + } + } + + return ret; +} + +/*=========================================================================== +FUNCTION loc_read_conf + +DESCRIPTION + Reads the specified configuration file and sets defined values based on + the passed in configuration table. This table maps strings to values to + set along with the type of each of these values. + +PARAMETERS: + conf_file_name: configuration file to read + config_table: table definition of strings to places to store information + table_length: length of the configuration table + +DEPENDENCIES + N/A + +RETURN VALUE + None + +SIDE EFFECTS + N/A +===========================================================================*/ +void loc_read_conf(const char* conf_file_name, loc_param_s_type* config_table, + uint32_t table_length) +{ + FILE *conf_fp = NULL; + char *lasts; + loc_param_v_type config_value; + uint32_t i; + + if((conf_fp = fopen(conf_file_name, "r")) != NULL) + { + LOC_LOGD("%s: using %s", __FUNCTION__, conf_file_name); + if(table_length && config_table) { + loc_read_conf_r(conf_fp, config_table, table_length); + rewind(conf_fp); + } + loc_read_conf_r(conf_fp, loc_param_table, loc_param_num); + fclose(conf_fp); + } + /* Initialize logging mechanism with parsed data */ + loc_logger_init(DEBUG_LEVEL, TIMESTAMP); +} diff --git a/gps/utils/loc_cfg.h b/gps/utils/loc_cfg.h new file mode 100644 index 0000000..ea4865b --- /dev/null +++ b/gps/utils/loc_cfg.h @@ -0,0 +1,91 @@ +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef LOC_CFG_H +#define LOC_CFG_H + +#include +#include + +#define LOC_MAX_PARAM_NAME 80 +#define LOC_MAX_PARAM_STRING 80 +#define LOC_MAX_PARAM_LINE (LOC_MAX_PARAM_NAME + LOC_MAX_PARAM_STRING) + +#define UTIL_UPDATE_CONF(conf_data, len, config_table) \ + loc_update_conf((conf_data), (len), (config_table), \ + sizeof(config_table) / sizeof(config_table[0])) + +#define UTIL_READ_CONF_DEFAULT(filename) \ + loc_read_conf((filename), NULL, 0); + +#define UTIL_READ_CONF(filename, config_table) \ + loc_read_conf((filename), (config_table), sizeof(config_table) / sizeof(config_table[0])) + +/*============================================================================= + * + * MODULE TYPE DECLARATION + * + *============================================================================*/ +typedef struct +{ + char param_name[LOC_MAX_PARAM_NAME]; + void *param_ptr; + uint8_t *param_set; /* was this value set by config file? */ + char param_type; /* 'n' for number, + 's' for string, + 'f' for float */ +} loc_param_s_type; + +/*============================================================================= + * + * MODULE EXTERNAL DATA + * + *============================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*============================================================================= + * + * MODULE EXPORTED FUNCTIONS + * + *============================================================================*/ +void loc_read_conf(const char* conf_file_name, + loc_param_s_type* config_table, + uint32_t table_length); +int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, + uint32_t table_length); +int loc_update_conf(const char* conf_data, int32_t length, + loc_param_s_type* config_table, uint32_t table_length); +#ifdef __cplusplus +} +#endif + +#endif /* LOC_CFG_H */ diff --git a/gps/utils/loc_log.cpp b/gps/utils/loc_log.cpp new file mode 100644 index 0000000..5500dea --- /dev/null +++ b/gps/utils/loc_log.cpp @@ -0,0 +1,242 @@ +/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#define LOG_NDDEBUG 0 + +#include +#include +#include +#include "loc_log.h" +#include "msg_q.h" +#ifdef USE_GLIB +#include +#endif /* USE_GLIB */ +#include "log_util.h" +#include "platform_lib_includes.h" + +#define BUFFER_SIZE 120 + +// Logging Improvements +const char *loc_logger_boolStr[]={"False","True"}; +const char VOID_RET[] = "None"; +const char FROM_AFW[] = "===>"; +const char TO_MODEM[] = "--->"; +const char FROM_MODEM[] = "<---"; +const char TO_AFW[] = "<==="; +const char EXIT_TAG[] = "Exiting"; +const char ENTRY_TAG[] = "Entering"; +const char EXIT_ERROR_TAG[] = "Exiting with error"; + +/* Logging Mechanism */ +loc_logger_s_type loc_logger; + +/* Get names from value */ +const char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, long mask) +{ + int i; + for (i = 0; i < table_size; i++) + { + if (table[i].val & (long) mask) + { + return table[i].name; + } + } + return UNKNOWN_STR; +} + +/* Get names from value */ +const char* loc_get_name_from_val(loc_name_val_s_type table[], int table_size, long value) +{ + int i; + for (i = 0; i < table_size; i++) + { + if (table[i].val == (long) value) + { + return table[i].name; + } + } + return UNKNOWN_STR; +} + +static loc_name_val_s_type loc_msg_q_status[] = +{ + NAME_VAL( eMSG_Q_SUCCESS ), + NAME_VAL( eMSG_Q_FAILURE_GENERAL ), + NAME_VAL( eMSG_Q_INVALID_PARAMETER ), + NAME_VAL( eMSG_Q_INVALID_HANDLE ), + NAME_VAL( eMSG_Q_UNAVAILABLE_RESOURCE ), + NAME_VAL( eMSG_Q_INSUFFICIENT_BUFFER ) +}; +static int loc_msg_q_status_num = sizeof(loc_msg_q_status) / sizeof(loc_name_val_s_type); + +/* Find msg_q status name */ +const char* loc_get_msg_q_status(int status) +{ + return loc_get_name_from_val(loc_msg_q_status, loc_msg_q_status_num, (long) status); +} + +const char* log_succ_fail_string(int is_succ) +{ + return is_succ? "successful" : "failed"; +} + +//Target names +loc_name_val_s_type target_name[] = +{ + NAME_VAL(GNSS_NONE), + NAME_VAL(GNSS_MSM), + NAME_VAL(GNSS_GSS), + NAME_VAL(GNSS_MDM), + NAME_VAL(GNSS_QCA1530), + NAME_VAL(GNSS_AUTO), + NAME_VAL(GNSS_UNKNOWN) +}; + +static int target_name_num = sizeof(target_name)/sizeof(loc_name_val_s_type); + +/*=========================================================================== + +FUNCTION loc_get_target_name + +DESCRIPTION + Returns pointer to a string that contains name of the target + + XX:XX:XX.000\0 + +RETURN VALUE + The target name string + +===========================================================================*/ +const char *loc_get_target_name(unsigned int target) +{ + int index = 0; + static char ret[BUFFER_SIZE]; + + index = getTargetGnssType(target); + if( index >= target_name_num || index < 0) + index = target_name_num - 1; + + if( (target & HAS_SSC) == HAS_SSC ) { + snprintf(ret, sizeof(ret), " %s with SSC", + loc_get_name_from_val(target_name, target_name_num, (long)index) ); + } + else { + snprintf(ret, sizeof(ret), " %s without SSC", + loc_get_name_from_val(target_name, target_name_num, (long)index) ); + } + return ret; +} + + +/*=========================================================================== + +FUNCTION loc_get_time + +DESCRIPTION + Logs a callback event header. + The pointer time_string should point to a buffer of at least 13 bytes: + + XX:XX:XX.000\0 + +RETURN VALUE + The time string + +===========================================================================*/ +char *loc_get_time(char *time_string, unsigned long buf_size) +{ + struct timeval now; /* sec and usec */ + struct tm now_tm; /* broken-down time */ + char hms_string[80]; /* HH:MM:SS */ + + gettimeofday(&now, NULL); + localtime_r(&now.tv_sec, &now_tm); + + strftime(hms_string, sizeof hms_string, "%H:%M:%S", &now_tm); + snprintf(time_string, buf_size, "%s.%03d", hms_string, (int) (now.tv_usec / 1000)); + + return time_string; +} + + +/*=========================================================================== +FUNCTION loc_logger_init + +DESCRIPTION + Initializes the state of DEBUG_LEVEL and TIMESTAMP + +DEPENDENCIES + N/A + +RETURN VALUE + None + +SIDE EFFECTS + N/A +===========================================================================*/ +void loc_logger_init(unsigned long debug, unsigned long timestamp) +{ + loc_logger.DEBUG_LEVEL = debug; +#ifdef TARGET_BUILD_VARIANT_USER + // force user builds to 2 or less + if (loc_logger.DEBUG_LEVEL > 2) { + loc_logger.DEBUG_LEVEL = 2; + } +#endif + loc_logger.TIMESTAMP = timestamp; +} + + +/*=========================================================================== +FUNCTION get_timestamp + +DESCRIPTION + Generates a timestamp using the current system time + +DEPENDENCIES + N/A + +RETURN VALUE + Char pointer to the parameter str + +SIDE EFFECTS + N/A +===========================================================================*/ +char * get_timestamp(char *str, unsigned long buf_size) +{ + struct timeval tv; + struct timezone tz; + int hh, mm, ss; + gettimeofday(&tv, &tz); + hh = tv.tv_sec/3600%24; + mm = (tv.tv_sec%3600)/60; + ss = tv.tv_sec%60; + snprintf(str, buf_size, "%02d:%02d:%02d.%06ld", hh, mm, ss, tv.tv_usec); + return str; +} + diff --git a/gps/utils/loc_log.h b/gps/utils/loc_log.h new file mode 100644 index 0000000..82dc636 --- /dev/null +++ b/gps/utils/loc_log.h @@ -0,0 +1,68 @@ +/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef LOC_LOG_H +#define LOC_LOG_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include "loc_target.h" + +typedef struct +{ + char name[128]; + long val; +} loc_name_val_s_type; + +#define NAME_VAL(x) {"" #x "", x } + +#define UNKNOWN_STR "UNKNOWN" + +#define CHECK_MASK(type, value, mask_var, mask) \ + ((mask_var & mask) ? (type) value : (type) (-1)) + +/* Get names from value */ +const char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, long mask); +const char* loc_get_name_from_val(loc_name_val_s_type table[], int table_size, long value); +const char* loc_get_msg_q_status(int status); +const char* loc_get_target_name(unsigned int target); + +extern const char* log_succ_fail_string(int is_succ); + +extern char *loc_get_time(char *time_string, unsigned long buf_size); + +#ifdef __cplusplus +} +#endif + +#endif /* LOC_LOG_H */ diff --git a/gps/utils/loc_misc_utils.cpp b/gps/utils/loc_misc_utils.cpp new file mode 100644 index 0000000..7e96313 --- /dev/null +++ b/gps/utils/loc_misc_utils.cpp @@ -0,0 +1,114 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include +#include + +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_misc_utils" + +int loc_util_split_string(char *raw_string, char **split_strings_ptr, + int max_num_substrings, char delimiter) +{ + int raw_string_index=0; + int num_split_strings=0; + unsigned char end_string=0; + int raw_string_length=0; + + if(!raw_string || !split_strings_ptr) { + LOC_LOGE("%s:%d]: NULL parameters", __func__, __LINE__); + num_split_strings = -1; + goto err; + } + LOC_LOGD("%s:%d]: raw string: %s\n", __func__, __LINE__, raw_string); + raw_string_length = strlen(raw_string) + 1; + split_strings_ptr[num_split_strings] = &raw_string[raw_string_index]; + for(raw_string_index=0; raw_string_index < raw_string_length; raw_string_index++) { + if(raw_string[raw_string_index] == '\0') + end_string=1; + if((raw_string[raw_string_index] == delimiter) || end_string) { + raw_string[raw_string_index] = '\0'; + LOC_LOGD("%s:%d]: split string: %s\n", + __func__, __LINE__, split_strings_ptr[num_split_strings]); + num_split_strings++; + if(((raw_string_index + 1) < raw_string_length) && + (num_split_strings < max_num_substrings)) { + split_strings_ptr[num_split_strings] = &raw_string[raw_string_index+1]; + } + else { + break; + } + } + if(end_string) + break; + } +err: + LOC_LOGD("%s:%d]: num_split_strings: %d\n", __func__, __LINE__, num_split_strings); + return num_split_strings; +} + +void loc_util_trim_space(char *org_string) +{ + char *scan_ptr, *write_ptr; + char *first_nonspace = NULL, *last_nonspace = NULL; + + if(org_string == NULL) { + LOC_LOGE("%s:%d]: NULL parameter", __func__, __LINE__); + goto err; + } + + scan_ptr = write_ptr = org_string; + + while (*scan_ptr) { + //Find the first non-space character + if ( !isspace(*scan_ptr) && first_nonspace == NULL) { + first_nonspace = scan_ptr; + } + //Once the first non-space character is found in the + //above check, keep shifting the characters to the left + //to replace the spaces + if (first_nonspace != NULL) { + *(write_ptr++) = *scan_ptr; + //Keep track of which was the last non-space character + //encountered + //last_nonspace will not be updated in the case where + //the string ends with spaces + if ( !isspace(*scan_ptr)) { + last_nonspace = write_ptr; + } + } + scan_ptr++; + } + //Add NULL terminator after the last non-space character + if (last_nonspace) { *last_nonspace = '\0'; } +err: + return; +} diff --git a/gps/utils/loc_misc_utils.h b/gps/utils/loc_misc_utils.h new file mode 100644 index 0000000..7d66d84 --- /dev/null +++ b/gps/utils/loc_misc_utils.h @@ -0,0 +1,99 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _LOC_MISC_UTILS_H_ +#define _LOC_MISC_UTILS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*=========================================================================== +FUNCTION loc_split_string + +DESCRIPTION: + This function is used to split a delimiter separated string into + sub-strings. This function does not allocate new memory to store the split + strings. Instead, it places '\0' in places of delimiters and assings the + starting address of the substring within the raw string as the string address + The input raw_string no longer remains to be a collection of sub-strings + after this function is executed. + Please make a copy of the input string before calling this function if + necessary + +PARAMETERS: + char *raw_string: is the original string with delimiter separated substrings + char **split_strings_ptr: is the arraw of pointers which will hold the addresses + of individual substrings + int max_num_substrings: is the maximum number of substrings that are expected + by the caller. The array of pointers in the above parameter + is usually this long + char delimiter: is the delimiter that separates the substrings. Examples: ' ', ';' + +DEPENDENCIES + N/A + +RETURN VALUE + int Number of split strings + +SIDE EFFECTS + The input raw_string no longer remains a delimiter separated single string. + +EXAMPLE + delimiter = ' ' //space + raw_string = "hello new user" //delimiter is space ' ' + addresses = 0123456789abcd + split_strings_ptr[0] = &raw_string[0]; //split_strings_ptr[0] contains "hello" + split_strings_ptr[1] = &raw_string[6]; //split_strings_ptr[1] contains "new" + split_strings_ptr[2] = &raw_string[a]; //split_strings_ptr[2] contains "user" + +===========================================================================*/ +int loc_util_split_string(char *raw_string, char **split_strings_ptr, int max_num_substrings, + char delimiter); + +/*=========================================================================== +FUNCTION trim_space + +DESCRIPTION + Removes leading and trailing spaces of the string + +DEPENDENCIES + N/A + +RETURN VALUE + None + +SIDE EFFECTS + N/A +===========================================================================*/ +void loc_util_trim_space(char *org_string); +#ifdef __cplusplus +} +#endif + +#endif //_LOC_MISC_UTILS_H_ diff --git a/gps/utils/loc_target.cpp b/gps/utils/loc_target.cpp new file mode 100644 index 0000000..faaedf6 --- /dev/null +++ b/gps/utils/loc_target.cpp @@ -0,0 +1,261 @@ +/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "loc_target.h" +#include "loc_log.h" +#include "log_util.h" + +#define APQ8064_ID_1 "109" +#define APQ8064_ID_2 "153" +#define MPQ8064_ID_1 "130" +#define MSM8930_ID_1 "142" +#define MSM8930_ID_2 "116" +#define APQ8030_ID_1 "157" +#define APQ8074_ID_1 "184" + +#define LINE_LEN 100 +#define STR_LIQUID "Liquid" +#define STR_SURF "Surf" +#define STR_MTP "MTP" +#define STR_APQ "apq" +#define STR_AUTO "auto" +#define IS_STR_END(c) ((c) == '\0' || (c) == '\n' || (c) == '\r') +#define LENGTH(s) (sizeof(s) - 1) +#define GPS_CHECK_NO_ERROR 0 +#define GPS_CHECK_NO_GPS_HW 1 +/* When system server is started, it uses 20 seconds as ActivityManager + * timeout. After that it sends SIGSTOP signal to process. + */ +#define QCA1530_DETECT_TIMEOUT 15 +#define QCA1530_DETECT_PRESENT "yes" +#define QCA1530_DETECT_PROGRESS "detect" + +static unsigned int gTarget = (unsigned int)-1; + +static int read_a_line(const char * file_path, char * line, int line_size) +{ + FILE *fp; + int result = 0; + + * line = '\0'; + fp = fopen(file_path, "r" ); + if( fp == NULL ) { + LOC_LOGE("open failed: %s: %s\n", file_path, strerror(errno)); + result = -1; + } else { + int len; + fgets(line, line_size, fp); + len = strlen(line); + len = len < line_size - 1? len : line_size - 1; + line[len] = '\0'; + LOC_LOGD("cat %s: %s", file_path, line); + fclose(fp); + } + return result; +} + +/*! + * \brief Checks if QCA1530 is avalable. + * + * Function verifies if qca1530 SoC is configured on the device. The test is + * based on property value. For 1530 scenario, the value shall be one of the + * following: "yes", "no", "detect". All other values are treated equally to + * "no". When the value is "detect" the system waits for SoC detection to + * finish before returning result. + * + * \retval true - QCA1530 is available. + * \retval false - QCA1530 is not available. + */ +static bool is_qca1530(void) +{ + static const char qca1530_property_name[] = "sys.qca1530"; + bool res = false; + int ret, i; + char buf[PROPERTY_VALUE_MAX]; + + memset(buf, 0, sizeof(buf)); + + for (i = 0; i < QCA1530_DETECT_TIMEOUT; ++i) + { + ret = property_get(qca1530_property_name, buf, NULL); + if (ret < 0) + { + LOC_LOGV( "qca1530: property %s is not accessible, ret=%d", + qca1530_property_name, + ret); + + break; + } + + LOC_LOGV( "qca1530: property %s is set to %s", + qca1530_property_name, + buf); + + if (!memcmp(buf, QCA1530_DETECT_PRESENT, + sizeof(QCA1530_DETECT_PRESENT))) + { + res = true; + break; + } + if (!memcmp(buf, QCA1530_DETECT_PROGRESS, + sizeof(QCA1530_DETECT_PROGRESS))) + { + LOC_LOGV("qca1530: SoC detection is in progress."); + sleep(1); + continue; + } + break; + } + + LOC_LOGD("qca1530: detected=%s", res ? "true" : "false"); + return res; +} + +/*The character array passed to this function should have length + of atleast PROPERTY_VALUE_MAX*/ +void loc_get_target_baseband(char *baseband, int array_length) +{ + if(baseband && (array_length >= PROPERTY_VALUE_MAX)) { + property_get("ro.baseband", baseband, ""); + LOC_LOGD("%s:%d]: Baseband: %s\n", __func__, __LINE__, baseband); + } + else { + LOC_LOGE("%s:%d]: NULL parameter or array length less than PROPERTY_VALUE_MAX\n", + __func__, __LINE__); + } +} + +/*The character array passed to this function should have length + of atleast PROPERTY_VALUE_MAX*/ +void loc_get_platform_name(char *platform_name, int array_length) +{ + if(platform_name && (array_length >= PROPERTY_VALUE_MAX)) { + property_get("ro.board.platform", platform_name, ""); + LOC_LOGD("%s:%d]: Target name: %s\n", __func__, __LINE__, platform_name); + } + else { + LOC_LOGE("%s:%d]: Null parameter or array length less than PROPERTY_VALUE_MAX\n", + __func__, __LINE__); + } +} + +unsigned int loc_get_target(void) +{ + if (gTarget != (unsigned int)-1) + return gTarget; + + static const char hw_platform[] = "/sys/devices/soc0/hw_platform"; + static const char id[] = "/sys/devices/soc0/soc_id"; + static const char hw_platform_dep[] = + "/sys/devices/system/soc/soc0/hw_platform"; + static const char id_dep[] = "/sys/devices/system/soc/soc0/id"; + static const char mdm[] = "/dev/mdm"; // No such file or directory + + char rd_hw_platform[LINE_LEN]; + char rd_id[LINE_LEN]; + char rd_mdm[LINE_LEN]; + char baseband[LINE_LEN]; + + if (is_qca1530()) { + gTarget = TARGET_QCA1530; + goto detected; + } + + loc_get_target_baseband(baseband, sizeof(baseband)); + + if (!access(hw_platform, F_OK)) { + read_a_line(hw_platform, rd_hw_platform, LINE_LEN); + } else { + read_a_line(hw_platform_dep, rd_hw_platform, LINE_LEN); + } + if (!access(id, F_OK)) { + read_a_line(id, rd_id, LINE_LEN); + } else { + read_a_line(id_dep, rd_id, LINE_LEN); + } + if( !memcmp(baseband, STR_AUTO, LENGTH(STR_AUTO)) ) + { + gTarget = TARGET_AUTO; + goto detected; + } + if( !memcmp(baseband, STR_APQ, LENGTH(STR_APQ)) ){ + + if( !memcmp(rd_id, MPQ8064_ID_1, LENGTH(MPQ8064_ID_1)) + && IS_STR_END(rd_id[LENGTH(MPQ8064_ID_1)]) ) + gTarget = TARGET_MPQ; + else + gTarget = TARGET_APQ_SA; + } + else { + if( (!memcmp(rd_hw_platform, STR_LIQUID, LENGTH(STR_LIQUID)) + && IS_STR_END(rd_hw_platform[LENGTH(STR_LIQUID)])) || + (!memcmp(rd_hw_platform, STR_SURF, LENGTH(STR_SURF)) + && IS_STR_END(rd_hw_platform[LENGTH(STR_SURF)])) || + (!memcmp(rd_hw_platform, STR_MTP, LENGTH(STR_MTP)) + && IS_STR_END(rd_hw_platform[LENGTH(STR_MTP)]))) { + + if (!read_a_line( mdm, rd_mdm, LINE_LEN)) + gTarget = TARGET_MDM; + } + else if( (!memcmp(rd_id, MSM8930_ID_1, LENGTH(MSM8930_ID_1)) + && IS_STR_END(rd_id[LENGTH(MSM8930_ID_1)])) || + (!memcmp(rd_id, MSM8930_ID_2, LENGTH(MSM8930_ID_2)) + && IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) ) + gTarget = TARGET_MSM_NO_SSC; + else + gTarget = TARGET_UNKNOWN; + } + +detected: + LOC_LOGD("HAL: %s returned %d", __FUNCTION__, gTarget); + return gTarget; +} + +/*Reads the property ro.lean to identify if this is a lean target + Returns: + 0 if not a lean and mean target + 1 if this is a lean and mean target +*/ +int loc_identify_lean_target() +{ + int ret = 0; + char lean_target[PROPERTY_VALUE_MAX]; + property_get("ro.lean", lean_target, ""); + LOC_LOGD("%s:%d]: lean target: %s\n", __func__, __LINE__, lean_target); + return !(strncmp(lean_target, "true", PROPERTY_VALUE_MAX)); +} diff --git a/gps/utils/loc_target.h b/gps/utils/loc_target.h new file mode 100644 index 0000000..3bb3b5e --- /dev/null +++ b/gps/utils/loc_target.h @@ -0,0 +1,82 @@ +/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef LOC_TARGET_H +#define LOC_TARGET_H +#define TARGET_SET(gnss,ssc) ( (gnss<<1)|ssc ) +#define TARGET_DEFAULT TARGET_SET(GNSS_MSM, HAS_SSC) +#define TARGET_MDM TARGET_SET(GNSS_MDM, HAS_SSC) +#define TARGET_APQ_SA TARGET_SET(GNSS_GSS, NO_SSC) +#define TARGET_MPQ TARGET_SET(GNSS_NONE,NO_SSC) +#define TARGET_MSM_NO_SSC TARGET_SET(GNSS_MSM, NO_SSC) +#define TARGET_QCA1530 TARGET_SET(GNSS_QCA1530, NO_SSC) +#define TARGET_AUTO TARGET_SET(GNSS_AUTO, NO_SSC) +#define TARGET_UNKNOWN TARGET_SET(GNSS_UNKNOWN, NO_SSC) +#define getTargetGnssType(target) (target>>1) + +#ifdef __cplusplus +extern "C" +{ +#endif + +unsigned int loc_get_target(void); + +/*The character array passed to this function should have length + of atleast PROPERTY_VALUE_MAX*/ +void loc_get_target_baseband(char *baseband, int array_length); +/*The character array passed to this function should have length + of atleast PROPERTY_VALUE_MAX*/ +void loc_get_platform_name(char *platform_name, int array_length); +/*Reads the property ro.lean to identify if this is a lean target + Returns: + 0 if not a lean and mean target + 1 if this is a lean and mean target*/ +int loc_identify_lean_target(); + +/* Please remember to update 'target_name' in loc_log.cpp, + if do any changes to this enum. */ +typedef enum { + GNSS_NONE = 0, + GNSS_MSM, + GNSS_GSS, + GNSS_MDM, + GNSS_QCA1530, + GNSS_AUTO, + GNSS_UNKNOWN +}GNSS_TARGET; + +typedef enum { + NO_SSC = 0, + HAS_SSC +}SSC_TYPE; + +#ifdef __cplusplus +} +#endif + +#endif /*LOC_TARGET_H*/ diff --git a/gps/utils/loc_timer.h b/gps/utils/loc_timer.h new file mode 100644 index 0000000..2967858 --- /dev/null +++ b/gps/utils/loc_timer.h @@ -0,0 +1,73 @@ +/* Copyright (c) 2013,2015 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __LOC_DELAY_H__ +#define __LOC_DELAY_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +#include + +/* + user_data: client context pointer, passthrough. Originally received + from calling client when loc_timer_start() is called. + result: 0 if timer successfully timed out; else timer failed. +*/ +typedef void (*loc_timer_callback)(void *user_data, int32_t result); + + +/* + delay_msec: timeout value for the timer. + cb_func: callback function pointer, implemented by client. + Can not be NULL. + user_data: client context pointer, passthrough. Will be + returned when loc_timer_callback() is called. + wakeOnExpire: true if to wake up CPU (if sleeping) upon timer + expiration and notify the client. + false if to wait until next time CPU wakes up (if + sleeping) and then notify the client. + Returns the handle, which can be used to stop the timer + NULL, if timer start fails (e.g. if cb_func is NULL). +*/ +void* loc_timer_start(uint64_t delay_msec, + loc_timer_callback cb_func, + void *user_data, + bool wake_on_expire=false); + +/* + handle becomes invalid upon the return of the callback +*/ +void loc_timer_stop(void*& handle); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif //__LOC_DELAY_H__ diff --git a/gps/utils/log_util.h b/gps/utils/log_util.h new file mode 100644 index 0000000..0d59f01 --- /dev/null +++ b/gps/utils/log_util.h @@ -0,0 +1,167 @@ +/* Copyright (c) 2011-2014 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __LOG_UTIL_H__ +#define __LOG_UTIL_H__ + +#ifndef USE_GLIB +#include +#endif /* USE_GLIB */ + +#ifdef USE_GLIB + +#include +#include +#include + +#ifndef LOG_TAG +#define LOG_TAG "GPS_UTILS" + +#endif // LOG_TAG + +#endif /* USE_GLIB */ + +#ifdef __cplusplus +extern "C" +{ +#endif +/*============================================================================= + * + * LOC LOGGER TYPE DECLARATION + * + *============================================================================*/ +/* LOC LOGGER */ +typedef struct loc_logger_s +{ + unsigned long DEBUG_LEVEL; + unsigned long TIMESTAMP; +} loc_logger_s_type; + +/*============================================================================= + * + * EXTERNAL DATA + * + *============================================================================*/ +extern loc_logger_s_type loc_logger; + +// Logging Improvements +extern const char *loc_logger_boolStr[]; + +extern const char *boolStr[]; +extern const char VOID_RET[]; +extern const char FROM_AFW[]; +extern const char TO_MODEM[]; +extern const char FROM_MODEM[]; +extern const char TO_AFW[]; +extern const char EXIT_TAG[]; +extern const char ENTRY_TAG[]; +extern const char EXIT_ERROR_TAG[]; + +/*============================================================================= + * + * MODULE EXPORTED FUNCTIONS + * + *============================================================================*/ +extern void loc_logger_init(unsigned long debug, unsigned long timestamp); +extern char* get_timestamp(char* str, unsigned long buf_size); + +#ifndef DEBUG_DMN_LOC_API + +/* LOGGING MACROS */ +/*loc_logger.DEBUG_LEVEL is initialized to 0xff in loc_cfg.cpp + if that value remains unchanged, it means gps.conf did not + provide a value and we default to the initial value to use + Android's logging levels*/ +#define IF_LOC_LOGE if((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5)) +#define IF_LOC_LOGW if((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5)) +#define IF_LOC_LOGI if((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5)) +#define IF_LOC_LOGD if((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5)) +#define IF_LOC_LOGV if((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5)) + +#define LOC_LOGE(...) IF_LOC_LOGE { ALOGE(__VA_ARGS__); } +#define LOC_LOGW(...) IF_LOC_LOGW { ALOGW(__VA_ARGS__); } +#define LOC_LOGI(...) IF_LOC_LOGI { ALOGI(__VA_ARGS__); } +#define LOC_LOGD(...) IF_LOC_LOGD { ALOGD(__VA_ARGS__); } +#define LOC_LOGV(...) IF_LOC_LOGV { ALOGV(__VA_ARGS__); } + +#else /* DEBUG_DMN_LOC_API */ + +#define LOC_LOGE(...) ALOGE(__VA_ARGS__) +#define LOC_LOGW(...) ALOGW(__VA_ARGS__) +#define LOC_LOGI(...) ALOGI(__VA_ARGS__) +#define LOC_LOGD(...) ALOGD(__VA_ARGS__) +#define LOC_LOGV(...) ALOGV(__VA_ARGS__) + +#endif /* DEBUG_DMN_LOC_API */ + +/*============================================================================= + * + * LOGGING IMPROVEMENT MACROS + * + *============================================================================*/ +#define LOG_(LOC_LOG, ID, WHAT, SPEC, VAL) \ + do { \ + if (loc_logger.TIMESTAMP) { \ + char ts[32]; \ + LOC_LOG("[%s] %s %s line %d " #SPEC, \ + get_timestamp(ts, sizeof(ts)), ID, WHAT, __LINE__, VAL); \ + } else { \ + LOC_LOG("%s %s line %d " #SPEC, \ + ID, WHAT, __LINE__, VAL); \ + } \ + } while(0) + +#define LOG_I(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGI, ID, WHAT, SPEC, VAL) +#define LOG_V(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGV, ID, WHAT, SPEC, VAL) +#define LOG_E(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGE, ID, WHAT, SPEC, VAL) + +#define ENTRY_LOG() LOG_V(ENTRY_TAG, __FUNCTION__, %s, "") +#define EXIT_LOG(SPEC, VAL) LOG_V(EXIT_TAG, __FUNCTION__, SPEC, VAL) +#define EXIT_LOG_WITH_ERROR(SPEC, VAL) \ + if (VAL != 0) { \ + LOG_E(EXIT_ERROR_TAG, __FUNCTION__, SPEC, VAL); \ + } else { \ + LOG_V(EXIT_TAG, __FUNCTION__, SPEC, VAL); \ + } + + +// Used for logging callflow from Android Framework +#define ENTRY_LOG_CALLFLOW() LOG_I(FROM_AFW, __FUNCTION__, %s, "") +// Used for logging callflow to Modem +#define EXIT_LOG_CALLFLOW(SPEC, VAL) LOG_I(TO_MODEM, __FUNCTION__, SPEC, VAL) +// Used for logging callflow from Modem(TO_MODEM, __FUNCTION__, %s, "") +#define MODEM_LOG_CALLFLOW(SPEC, VAL) LOG_I(FROM_MODEM, __FUNCTION__, SPEC, VAL) +// Used for logging callflow to Android Framework +#define CALLBACK_LOG_CALLFLOW(CB, SPEC, VAL) LOG_I(TO_AFW, CB, SPEC, VAL) + +#ifdef __cplusplus +} +#endif + +#endif // __LOG_UTIL_H__ diff --git a/gps/utils/msg_q.c b/gps/utils/msg_q.c new file mode 100644 index 0000000..5be8547 --- /dev/null +++ b/gps/utils/msg_q.c @@ -0,0 +1,336 @@ +/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "msg_q.h" + +#define LOG_TAG "LocSvc_utils_q" +#include "log_util.h" +#include "platform_lib_includes.h" +#include "linked_list.h" +#include +#include +#include + +typedef struct msg_q { + void* msg_list; /* Linked list to store information */ + pthread_cond_t list_cond; /* Condition variable for waiting on msg queue */ + pthread_mutex_t list_mutex; /* Mutex for exclusive access to message queue */ + int unblocked; /* Has this message queue been unblocked? */ +} msg_q; + +/*=========================================================================== +FUNCTION convert_linked_list_err_type + +DESCRIPTION + Converts from one set of enum values to another. + + linked_list_val: Value to convert to msg_q_enum_type + +DEPENDENCIES + N/A + +RETURN VALUE + Corresponding linked_list_enum_type in msg_q_enum_type + +SIDE EFFECTS + N/A + +===========================================================================*/ +static msq_q_err_type convert_linked_list_err_type(linked_list_err_type linked_list_val) +{ + switch( linked_list_val ) + { + case eLINKED_LIST_SUCCESS: + return eMSG_Q_SUCCESS; + case eLINKED_LIST_INVALID_PARAMETER: + return eMSG_Q_INVALID_PARAMETER; + case eLINKED_LIST_INVALID_HANDLE: + return eMSG_Q_INVALID_HANDLE; + case eLINKED_LIST_UNAVAILABLE_RESOURCE: + return eMSG_Q_UNAVAILABLE_RESOURCE; + case eLINKED_LIST_INSUFFICIENT_BUFFER: + return eMSG_Q_INSUFFICIENT_BUFFER; + + case eLINKED_LIST_FAILURE_GENERAL: + default: + return eMSG_Q_FAILURE_GENERAL; + } +} + +/* ----------------------- END INTERNAL FUNCTIONS ---------------------------------------- */ + +/*=========================================================================== + + FUNCTION: msg_q_init + + ===========================================================================*/ +msq_q_err_type msg_q_init(void** msg_q_data) +{ + if( msg_q_data == NULL ) + { + LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__); + return eMSG_Q_INVALID_PARAMETER; + } + + msg_q* tmp_msg_q; + tmp_msg_q = (msg_q*)calloc(1, sizeof(msg_q)); + if( tmp_msg_q == NULL ) + { + LOC_LOGE("%s: Unable to allocate space for message queue!\n", __FUNCTION__); + return eMSG_Q_FAILURE_GENERAL; + } + + if( linked_list_init(&tmp_msg_q->msg_list) != 0 ) + { + LOC_LOGE("%s: Unable to initialize storage list!\n", __FUNCTION__); + free(tmp_msg_q); + return eMSG_Q_FAILURE_GENERAL; + } + + if( pthread_mutex_init(&tmp_msg_q->list_mutex, NULL) != 0 ) + { + LOC_LOGE("%s: Unable to initialize list mutex!\n", __FUNCTION__); + linked_list_destroy(&tmp_msg_q->msg_list); + free(tmp_msg_q); + return eMSG_Q_FAILURE_GENERAL; + } + + if( pthread_cond_init(&tmp_msg_q->list_cond, NULL) != 0 ) + { + LOC_LOGE("%s: Unable to initialize msg q cond var!\n", __FUNCTION__); + linked_list_destroy(&tmp_msg_q->msg_list); + pthread_mutex_destroy(&tmp_msg_q->list_mutex); + free(tmp_msg_q); + return eMSG_Q_FAILURE_GENERAL; + } + + tmp_msg_q->unblocked = 0; + + *msg_q_data = tmp_msg_q; + + return eMSG_Q_SUCCESS; +} + +/*=========================================================================== + + FUNCTION: msg_q_init2 + + ===========================================================================*/ +const void* msg_q_init2() +{ + void* q = NULL; + if (eMSG_Q_SUCCESS != msg_q_init(&q)) { + q = NULL; + } + return q; +} + +/*=========================================================================== + + FUNCTION: msg_q_destroy + + ===========================================================================*/ +msq_q_err_type msg_q_destroy(void** msg_q_data) +{ + if( msg_q_data == NULL ) + { + LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__); + return eMSG_Q_INVALID_HANDLE; + } + + msg_q* p_msg_q = (msg_q*)*msg_q_data; + + linked_list_destroy(&p_msg_q->msg_list); + pthread_mutex_destroy(&p_msg_q->list_mutex); + pthread_cond_destroy(&p_msg_q->list_cond); + + p_msg_q->unblocked = 0; + + free(*msg_q_data); + *msg_q_data = NULL; + + return eMSG_Q_SUCCESS; +} + +/*=========================================================================== + + FUNCTION: msg_q_snd + + ===========================================================================*/ +msq_q_err_type msg_q_snd(void* msg_q_data, void* msg_obj, void (*dealloc)(void*)) +{ + msq_q_err_type rv; + if( msg_q_data == NULL ) + { + LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__); + return eMSG_Q_INVALID_HANDLE; + } + if( msg_obj == NULL ) + { + LOC_LOGE("%s: Invalid msg_obj parameter!\n", __FUNCTION__); + return eMSG_Q_INVALID_PARAMETER; + } + + msg_q* p_msg_q = (msg_q*)msg_q_data; + + pthread_mutex_lock(&p_msg_q->list_mutex); + LOC_LOGV("%s: Sending message with handle = 0x%08X\n", __FUNCTION__, msg_obj); + + if( p_msg_q->unblocked ) + { + LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__); + pthread_mutex_unlock(&p_msg_q->list_mutex); + return eMSG_Q_UNAVAILABLE_RESOURCE; + } + + rv = convert_linked_list_err_type(linked_list_add(p_msg_q->msg_list, msg_obj, dealloc)); + + /* Show data is in the message queue. */ + pthread_cond_signal(&p_msg_q->list_cond); + + pthread_mutex_unlock(&p_msg_q->list_mutex); + + LOC_LOGV("%s: Finished Sending message with handle = 0x%08X\n", __FUNCTION__, msg_obj); + + return rv; +} + +/*=========================================================================== + + FUNCTION: msg_q_rcv + + ===========================================================================*/ +msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj) +{ + msq_q_err_type rv; + if( msg_q_data == NULL ) + { + LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__); + return eMSG_Q_INVALID_HANDLE; + } + + if( msg_obj == NULL ) + { + LOC_LOGE("%s: Invalid msg_obj parameter!\n", __FUNCTION__); + return eMSG_Q_INVALID_PARAMETER; + } + + msg_q* p_msg_q = (msg_q*)msg_q_data; + + LOC_LOGV("%s: Waiting on message\n", __FUNCTION__); + + pthread_mutex_lock(&p_msg_q->list_mutex); + + if( p_msg_q->unblocked ) + { + LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__); + pthread_mutex_unlock(&p_msg_q->list_mutex); + return eMSG_Q_UNAVAILABLE_RESOURCE; + } + + /* Wait for data in the message queue */ + while( linked_list_empty(p_msg_q->msg_list) && !p_msg_q->unblocked ) + { + pthread_cond_wait(&p_msg_q->list_cond, &p_msg_q->list_mutex); + } + + rv = convert_linked_list_err_type(linked_list_remove(p_msg_q->msg_list, msg_obj)); + + pthread_mutex_unlock(&p_msg_q->list_mutex); + + LOC_LOGV("%s: Received message 0x%08X rv = %d\n", __FUNCTION__, *msg_obj, rv); + + return rv; +} + +/*=========================================================================== + + FUNCTION: msg_q_flush + + ===========================================================================*/ +msq_q_err_type msg_q_flush(void* msg_q_data) +{ + msq_q_err_type rv; + if ( msg_q_data == NULL ) + { + LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__); + return eMSG_Q_INVALID_HANDLE; + } + + msg_q* p_msg_q = (msg_q*)msg_q_data; + + LOC_LOGD("%s: Flushing Message Queue\n", __FUNCTION__); + + pthread_mutex_lock(&p_msg_q->list_mutex); + + /* Remove all elements from the list */ + rv = convert_linked_list_err_type(linked_list_flush(p_msg_q->msg_list)); + + pthread_mutex_unlock(&p_msg_q->list_mutex); + + LOC_LOGD("%s: Message Queue flushed\n", __FUNCTION__); + + return rv; +} + +/*=========================================================================== + + FUNCTION: msg_q_unblock + + ===========================================================================*/ +msq_q_err_type msg_q_unblock(void* msg_q_data) +{ + if ( msg_q_data == NULL ) + { + LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__); + return eMSG_Q_INVALID_HANDLE; + } + + msg_q* p_msg_q = (msg_q*)msg_q_data; + pthread_mutex_lock(&p_msg_q->list_mutex); + + if( p_msg_q->unblocked ) + { + LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__); + pthread_mutex_unlock(&p_msg_q->list_mutex); + return eMSG_Q_UNAVAILABLE_RESOURCE; + } + + LOC_LOGD("%s: Unblocking Message Queue\n", __FUNCTION__); + /* Unblocking message queue */ + p_msg_q->unblocked = 1; + + /* Allow all the waiters to wake up */ + pthread_cond_broadcast(&p_msg_q->list_cond); + + pthread_mutex_unlock(&p_msg_q->list_mutex); + + LOC_LOGD("%s: Message Queue unblocked\n", __FUNCTION__); + + return eMSG_Q_SUCCESS; +} diff --git a/gps/utils/msg_q.h b/gps/utils/msg_q.h new file mode 100644 index 0000000..453b8ce --- /dev/null +++ b/gps/utils/msg_q.h @@ -0,0 +1,207 @@ +/* Copyright (c) 2011, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __MSG_Q_H__ +#define __MSG_Q_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include + +/** Linked List Return Codes */ +typedef enum +{ + eMSG_Q_SUCCESS = 0, + /**< Request was successful. */ + eMSG_Q_FAILURE_GENERAL = -1, + /**< Failed because of a general failure. */ + eMSG_Q_INVALID_PARAMETER = -2, + /**< Failed because the request contained invalid parameters. */ + eMSG_Q_INVALID_HANDLE = -3, + /**< Failed because an invalid handle was specified. */ + eMSG_Q_UNAVAILABLE_RESOURCE = -4, + /**< Failed because an there were not enough resources. */ + eMSG_Q_INSUFFICIENT_BUFFER = -5, + /**< Failed because an the supplied buffer was too small. */ +}msq_q_err_type; + +/*=========================================================================== +FUNCTION msg_q_init + +DESCRIPTION + Initializes internal structures for message queue. + + msg_q_data: pointer to an opaque Q handle to be returned; NULL if fails + +DEPENDENCIES + N/A + +RETURN VALUE + Look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +msq_q_err_type msg_q_init(void** msg_q_data); + +/*=========================================================================== +FUNCTION msg_q_init2 + +DESCRIPTION + Initializes internal structures for message queue. + +DEPENDENCIES + N/A + +RETURN VALUE + opaque handle to the Q created; NULL if create fails + +SIDE EFFECTS + N/A + +===========================================================================*/ +const void* msg_q_init2(); + +/*=========================================================================== +FUNCTION msg_q_destroy + +DESCRIPTION + Releases internal structures for message queue. + + msg_q_data: State of message queue to be released. + +DEPENDENCIES + N/A + +RETURN VALUE + Look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +msq_q_err_type msg_q_destroy(void** msg_q_data); + +/*=========================================================================== +FUNCTION msg_q_snd + +DESCRIPTION + Sends data to the message queue. The passed in data pointer + is not modified or freed. Passed in msg_obj is expected to live throughout + the use of the msg_q (i.e. data is not allocated internally) + + msg_q_data: Message Queue to add the element to. + msgp: Pointer to data to add into message queue. + dealloc: Function used to deallocate memory for this element. Pass NULL + if you do not want data deallocated during a flush operation + +DEPENDENCIES + N/A + +RETURN VALUE + Look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +msq_q_err_type msg_q_snd(void* msg_q_data, void* msg_obj, void (*dealloc)(void*)); + +/*=========================================================================== +FUNCTION msg_q_rcv + +DESCRIPTION + Retrieves data from the message queue. msg_obj is the oldest message received + and pointer is simply removed from message queue. + + msg_q_data: Message Queue to copy data from into msgp. + msg_obj: Pointer to space to copy msg_q contents to. + +DEPENDENCIES + N/A + +RETURN VALUE + Look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj); + +/*=========================================================================== +FUNCTION msg_q_flush + +DESCRIPTION + Function removes all elements from the message queue. + + msg_q_data: Message Queue to remove elements from. + +DEPENDENCIES + N/A + +RETURN VALUE + Look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +msq_q_err_type msg_q_flush(void* msg_q_data); + +/*=========================================================================== +FUNCTION msg_q_unblock + +DESCRIPTION + This function will stop use of the message queue. All waiters will wake up + and likely receive nothing from the queue resulting in a negative return + value. The message queue can no longer be used until it is destroyed + and initialized again after calling this function. + + msg_q_data: Message queue to unblock. + +DEPENDENCIES + N/A + +RETURN VALUE + Look at error codes above. + +SIDE EFFECTS + N/A + +===========================================================================*/ +msq_q_err_type msg_q_unblock(void* msg_q_data); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __MSG_Q_H__ */ diff --git a/gps/utils/platform_lib_abstractions/elapsed_millis_since_boot.cpp b/gps/utils/platform_lib_abstractions/elapsed_millis_since_boot.cpp new file mode 100644 index 0000000..e8cb93a --- /dev/null +++ b/gps/utils/platform_lib_abstractions/elapsed_millis_since_boot.cpp @@ -0,0 +1,46 @@ +/* Copyright (c) 2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include "platform_lib_time.h" + +int64_t systemTime(int clock) +{ + struct timeval t; + t.tv_sec = t.tv_usec = 0; + gettimeofday(&t, NULL); + return t.tv_sec*1000000LL + t.tv_usec; +} + + +int64_t elapsedMillisSinceBoot() +{ + int64_t t_us = systemTime(0); + return (int64_t) t_us / 1000LL; +} diff --git a/gps/utils/platform_lib_abstractions/platform_lib_includes.h b/gps/utils/platform_lib_abstractions/platform_lib_includes.h new file mode 100644 index 0000000..5858674 --- /dev/null +++ b/gps/utils/platform_lib_abstractions/platform_lib_includes.h @@ -0,0 +1,35 @@ +/* Copyright (c) 2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _PLATFORM_LIB_INCLUDES_H_ +#define _PLATFORM_LIB_INCLUDES_H_ + +#include "platform_lib_time.h" +#include "platform_lib_macros.h" + +#endif diff --git a/gps/utils/platform_lib_abstractions/platform_lib_macros.h b/gps/utils/platform_lib_abstractions/platform_lib_macros.h new file mode 100644 index 0000000..bc48dd9 --- /dev/null +++ b/gps/utils/platform_lib_abstractions/platform_lib_macros.h @@ -0,0 +1,81 @@ +/* Copyright (c) 2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __PLATFORM_LIB_MACROS_H__ +#define __PLATFORM_LIB_MACROS_H__ + +#include + +#define TS_PRINTF(format, x...) \ +{ \ + struct timeval tv; \ + struct timezone tz; \ + int hh, mm, ss; \ + gettimeofday(&tv, &tz); \ + hh = tv.tv_sec/3600%24; \ + mm = (tv.tv_sec%3600)/60; \ + ss = tv.tv_sec%60; \ + fprintf(stdout,"%02d:%02d:%02d.%06ld]" format "\n", hh, mm, ss, tv.tv_usec,##x); \ +} + + +#ifdef USE_GLIB + +#define strlcat g_strlcat +#define strlcpy g_strlcpy + +#define ALOGE(format, x...) TS_PRINTF("E/%s (%d): " format , LOG_TAG, getpid(), ##x) +#define ALOGW(format, x...) TS_PRINTF("W/%s (%d): " format , LOG_TAG, getpid(), ##x) +#define ALOGI(format, x...) TS_PRINTF("I/%s (%d): " format , LOG_TAG, getpid(), ##x) +#define ALOGD(format, x...) TS_PRINTF("D/%s (%d): " format , LOG_TAG, getpid(), ##x) +#define ALOGV(format, x...) TS_PRINTF("V/%s (%d): " format , LOG_TAG, getpid(), ##x) + +#define GETTID_PLATFORM_LIB_ABSTRACTION (syscall(SYS_gettid)) + +#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION createPthread +#define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (elapsedMillisSinceBoot()) + + +#else + +#ifdef __cplusplus +extern "C" { +#endif +pid_t gettid(void); + +#ifdef __cplusplus +} +#endif + +#define GETTID_PLATFORM_LIB_ABSTRACTION (gettid()) +#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION android::AndroidRuntime::createJavaThread +#define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (android::elapsedRealtime()) + +#endif + +#endif diff --git a/gps/utils/platform_lib_abstractions/platform_lib_time.h b/gps/utils/platform_lib_abstractions/platform_lib_time.h new file mode 100644 index 0000000..ce013af --- /dev/null +++ b/gps/utils/platform_lib_abstractions/platform_lib_time.h @@ -0,0 +1,35 @@ +/* Copyright (c) 2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _PLATFORM_LIB_TIME_H_ +#define _PLATFORM_LIB_TIME_H_ + +int64_t systemTime(int clock); +int64_t elapsedMillisSinceBoot(); + +#endif diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index 73387e8..655c914 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -508,11 +508,6 @@ service wpa_supplicant /vendor/bin/hw/wpa_supplicant \ disabled oneshot -service loc_launcher /system/bin/loc_launcher - #loc_launcher will start as root and set its uid to gps - class late_start - group gps inet net_raw diag net_admin wifi - on property:ro.data.large_tcp_window_size=true # Adjust socket buffer to enlarge TCP receive window for high bandwidth (e.g. DO-RevB) write /proc/sys/net/ipv4/tcp_adv_win_scale 2 -- GitLab From 055899c1abed5aef034a132ba4aee892667a555e Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sat, 14 Nov 2020 14:35:55 +0100 Subject: [PATCH 088/191] kitakami-common: sepolicy: Labeled clean_scratch_files and addressed it. to suppress error messages like this one: "Could not start exec background service: File /system/bin/clean_scratch_files (labeled u:object_r:system_file:s0) has incorrect label or no domain transition from u:r:init:s0 to another SELinux domain defined." Change-Id: Ic33a6e6ecd18d5de79a675bafbb7a605cfd2dda7 --- sepolicy/vendor/clean_scratch_files.te | 6 ++++++ sepolicy/vendor/file_contexts | 1 + 2 files changed, 7 insertions(+) create mode 100644 sepolicy/vendor/clean_scratch_files.te diff --git a/sepolicy/vendor/clean_scratch_files.te b/sepolicy/vendor/clean_scratch_files.te new file mode 100644 index 0000000..99f2d8b --- /dev/null +++ b/sepolicy/vendor/clean_scratch_files.te @@ -0,0 +1,6 @@ +type clean_scratch_files, domain; +type clean_scratch_files_exec, exec_type, file_type; + +# Started by init +init_daemon_domain(clean_scratch_files) + diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 9b4128a..2d239fc 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -65,6 +65,7 @@ # Misc /system/bin/adsprpcd u:object_r:adsprpcd_exec:s0 +/system/bin/clean_scratch_files u:object_r:clean_scratch_files_exec:s0 /system/bin/iddd u:object_r:iddd_exec:s0 /system/bin/init\.qcom\.power\.sh u:object_r:init-power-sh_exec:s0 /system/bin/irsc_util u:object_r:irsc_util_exec:s0 -- GitLab From 3a803fcf02cd6fb1ed166e2bb4d5134cd24f06b7 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Thu, 29 Oct 2020 10:50:37 +0100 Subject: [PATCH 089/191] kitakami-common: rootdir: Added a missing "writepid" instruction Change-Id: I45ce590b963d7fe99b396ede02d3079e6a9e4699 --- rootdir/init.qcom.rc | 1 + 1 file changed, 1 insertion(+) diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index 655c914..1e7cf12 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -666,6 +666,7 @@ service ppd /system/vendor/bin/mm-pp-daemon user system socket pps stream 0660 system system group system graphics + writepid /dev/cpuset/system-background/tasks # brcm-uim-sysfs (BT/FM/ANT+) #service uim /system/vendor/bin/brcm-uim-sysfs -- GitLab From 8958eac26e6983370caa5dc47601d9a23ab502ab Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sat, 14 Nov 2020 16:38:10 +0100 Subject: [PATCH 090/191] kitakami-common: sepolicy: Added some more properties. Change-Id: I1600bc595e55e6b3347ce3a3f70b2171e58e9e89 --- sepolicy/vendor/cameraserver.te | 7 ++++++- sepolicy/vendor/crash_dump.te | 1 + sepolicy/vendor/fsck.te | 1 + sepolicy/vendor/init.te | 1 + sepolicy/vendor/qcamerasvr.te | 6 ++++-- sepolicy/vendor/vendor.te | 6 ++++++ 6 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 sepolicy/vendor/vendor.te diff --git a/sepolicy/vendor/cameraserver.te b/sepolicy/vendor/cameraserver.te index b1576db..20610b0 100644 --- a/sepolicy/vendor/cameraserver.te +++ b/sepolicy/vendor/cameraserver.te @@ -2,5 +2,10 @@ allow cameraserver hal_configstore_ISurfaceFlingerConfigs:hwservice_manager find allow cameraserver init:unix_dgram_socket sendto; allow cameraserver qcamerasvr:unix_dgram_socket sendto; allow cameraserver qcamerasvr:unix_stream_socket connectto; -allow cameraserver sysfs_graphics:file { getattr open read }; +allow cameraserver sysfs_battery_supply:dir search; +allow cameraserver sysfs_battery_supply:file r_file_perms; +allow cameraserver sysfs_camera_torch:dir search; +allow cameraserver sysfs_camera_torch:file rw_file_perms; +allow cameraserver sysfs_camera_torch:lnk_file read; +allow cameraserver sysfs_graphics:file r_file_perms; allow cameraserver ta_data_file:dir search; diff --git a/sepolicy/vendor/crash_dump.te b/sepolicy/vendor/crash_dump.te index 1b4554e..9ebf245 100644 --- a/sepolicy/vendor/crash_dump.te +++ b/sepolicy/vendor/crash_dump.te @@ -1,2 +1,3 @@ allow crash_dump camera_prop:file { getattr open }; allow crash_dump init:process ptrace; +allow crash_dump keystore:process ptrace; diff --git a/sepolicy/vendor/fsck.te b/sepolicy/vendor/fsck.te index f8c4fc8..a7787b9 100644 --- a/sepolicy/vendor/fsck.te +++ b/sepolicy/vendor/fsck.te @@ -1 +1,2 @@ allow fsck block_device:blk_file { read write }; +allow fsck diag_partition_device:blk_file rw_file_perms; diff --git a/sepolicy/vendor/init.te b/sepolicy/vendor/init.te index be7ff16..578cb75 100644 --- a/sepolicy/vendor/init.te +++ b/sepolicy/vendor/init.te @@ -28,6 +28,7 @@ allow init sysfs_msm_perf:file { open write }; allow init sysfs_thermal:file write; allow init sysfs_wake_lock:file { append open }; allow init system_data_file:file { ioctl lock }; +allow init system_file:dir relabelfrom; allow init system_file:file execute_no_trans; allow init tee_device:chr_file { ioctl open read write }; allow init trim_area_partition_device:blk_file setattr; diff --git a/sepolicy/vendor/qcamerasvr.te b/sepolicy/vendor/qcamerasvr.te index 7ef9d28..5e5ace0 100644 --- a/sepolicy/vendor/qcamerasvr.te +++ b/sepolicy/vendor/qcamerasvr.te @@ -8,9 +8,11 @@ init_daemon_domain(qcamerasvr) allow qcamerasvr camera_data_file:dir { add_name remove_name search write }; allow qcamerasvr camera_data_file:sock_file { create unlink }; allow qcamerasvr camera_prop:file { getattr open read }; +allow qcamerasvr camera_socket:sock_file unlink; allow qcamerasvr cameraserver:fd use; -allow qcamerasvr ion_device:chr_file { open read }; -allow qcamerasvr sysfs:file { open read }; +allow qcamerasvr hal_graphics_allocator_default:fd use; +allow qcamerasvr ion_device:chr_file r_file_perms; +allow qcamerasvr sysfs:file rw_file_perms; allow qcamerasvr sysfs_graphics:file { open read }; allow qcamerasvr ta_data_file:dir search; allow qcamerasvr video_device:chr_file { ioctl open read write }; diff --git a/sepolicy/vendor/vendor.te b/sepolicy/vendor/vendor.te new file mode 100644 index 0000000..d4aeafd --- /dev/null +++ b/sepolicy/vendor/vendor.te @@ -0,0 +1,6 @@ +type vendor, domain; +type vendor_exec, exec_type, file_type; + +# Started by init +init_daemon_domain(vendor) + -- GitLab From c768f04ed10fb8510d103999222b4329f26565e7 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sun, 15 Nov 2020 17:34:36 +0100 Subject: [PATCH 091/191] kitakami-common: sepolicy: Changed a few properties; finetuning. Change-Id: Ib7f84c0507b68e09cdbb709fbb2643eb1fa41ff1 --- sepolicy/vendor/bootanim.te | 2 +- sepolicy/vendor/file_contexts | 1 - sepolicy/vendor/flags_health_check.te | 4 +-- sepolicy/vendor/fsck.te | 2 +- sepolicy/vendor/hal_bluetooth_default.te | 6 ++--- sepolicy/vendor/hal_drm_clearkey.te | 2 +- sepolicy/vendor/hal_dumpstate_impl.te | 2 +- sepolicy/vendor/hal_fingerprint_default.te | 22 ++++++++-------- sepolicy/vendor/hal_health_default.te | 2 +- sepolicy/vendor/hal_light_default.te | 2 +- sepolicy/vendor/hal_power_default.te | 2 +- sepolicy/vendor/hal_wifi_default.te | 8 +++--- sepolicy/vendor/hwservicemanager.te | 4 +-- sepolicy/vendor/init-power-sh.te | 2 +- sepolicy/vendor/init.te | 30 +++++++++++----------- sepolicy/vendor/loc_launcher.te | 9 ------- sepolicy/vendor/mlog_qmi_service.te | 2 +- sepolicy/vendor/msm_irqbalance.te | 6 ++--- sepolicy/vendor/qcamerasvr.te | 8 +++--- sepolicy/vendor/rild.te | 8 +++--- sepolicy/vendor/sct_service.te | 2 +- sepolicy/vendor/secd.te | 8 +++--- sepolicy/vendor/servicemanager.te | 4 +-- sepolicy/vendor/system_server.te | 6 ++--- sepolicy/vendor/ta_qmi_service.te | 4 +-- sepolicy/vendor/taimport.te | 8 +++--- sepolicy/vendor/tee.te | 3 +-- sepolicy/vendor/timekeep.te | 4 +-- sepolicy/vendor/toolbox.te | 8 +++--- sepolicy/vendor/ueventd.te | 6 ++--- sepolicy/vendor/vendor.te | 6 ----- sepolicy/vendor/vold.te | 2 +- sepolicy/vendor/zygote.te | 4 +-- 33 files changed, 86 insertions(+), 103 deletions(-) delete mode 100644 sepolicy/vendor/loc_launcher.te delete mode 100644 sepolicy/vendor/vendor.te diff --git a/sepolicy/vendor/bootanim.te b/sepolicy/vendor/bootanim.te index 1fccd3b..07a135d 100644 --- a/sepolicy/vendor/bootanim.te +++ b/sepolicy/vendor/bootanim.te @@ -1 +1 @@ -allow bootanim userspace_reboot_exported_prop:file { getattr open read }; +allow bootanim userspace_reboot_exported_prop:file r_file_perms; diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 2d239fc..f4e489c 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -69,7 +69,6 @@ /system/bin/iddd u:object_r:iddd_exec:s0 /system/bin/init\.qcom\.power\.sh u:object_r:init-power-sh_exec:s0 /system/bin/irsc_util u:object_r:irsc_util_exec:s0 -/system/bin/loc_launcher u:object_r:loc_launcher_exec:s0 /system/bin/mlog_qmi_service u:object_r:mlog_qmi_service_exec:s0 /system/bin/mm-qcamera-daemon u:object_r:qcamerasvr_exec:s0 /system/bin/msm_irqbalance u:object_r:msm_irqbalance_exec:s0 diff --git a/sepolicy/vendor/flags_health_check.te b/sepolicy/vendor/flags_health_check.te index 7b23ee5..330d7b9 100644 --- a/sepolicy/vendor/flags_health_check.te +++ b/sepolicy/vendor/flags_health_check.te @@ -30,7 +30,7 @@ allow flags_health_check ctl_bugreport_prop:file { getattr open }; allow flags_health_check ctl_console_prop:file { getattr open }; allow flags_health_check ctl_default_prop:file { getattr open }; allow flags_health_check ctl_dumpstate_prop:file { getattr open }; -allow flags_health_check ctl_fuse_prop:file { getattr open read }; +allow flags_health_check ctl_fuse_prop:file r_file_perms; allow flags_health_check ctl_gsid_prop:file { getattr open }; allow flags_health_check ctl_hbtp_prop:file { getattr open }; allow flags_health_check ctl_interface_restart_prop:file { getattr open }; @@ -121,7 +121,7 @@ allow flags_health_check sys_usb_controller_prop:file { getattr open }; allow flags_health_check sys_usb_tethering_prop:file { getattr open }; allow flags_health_check system_adbd_prop:file { getattr open }; allow flags_health_check system_boot_reason_prop:file { getattr open }; -allow flags_health_check system_jvmti_agent_prop:file { getattr open read }; +allow flags_health_check system_jvmti_agent_prop:file r_file_perms; allow flags_health_check system_lmk_prop:file { getattr open }; allow flags_health_check system_trace_prop:file { getattr open }; allow flags_health_check test_boot_reason_prop:file { getattr open }; diff --git a/sepolicy/vendor/fsck.te b/sepolicy/vendor/fsck.te index a7787b9..4e4487f 100644 --- a/sepolicy/vendor/fsck.te +++ b/sepolicy/vendor/fsck.te @@ -1,2 +1,2 @@ -allow fsck block_device:blk_file { read write }; +allow fsck block_device:blk_file rw_file_perms; allow fsck diag_partition_device:blk_file rw_file_perms; diff --git a/sepolicy/vendor/hal_bluetooth_default.te b/sepolicy/vendor/hal_bluetooth_default.te index bc98076..df130db 100644 --- a/sepolicy/vendor/hal_bluetooth_default.te +++ b/sepolicy/vendor/hal_bluetooth_default.te @@ -1,6 +1,6 @@ allow hal_bluetooth_default firmware_file:dir search; -allow hal_bluetooth_default firmware_file:file { open read }; +allow hal_bluetooth_default firmware_file:file r_file_perms; allow hal_bluetooth_default sysfs:file write; -allow hal_bluetooth_default system_data_file:file { open read }; +allow hal_bluetooth_default system_data_file:file r_file_perms; allow hal_bluetooth_default ta_data_file:dir { read search }; -allow hal_bluetooth_default ta_data_file:file { open read }; +allow hal_bluetooth_default ta_data_file:file r_file_perms; diff --git a/sepolicy/vendor/hal_drm_clearkey.te b/sepolicy/vendor/hal_drm_clearkey.te index c0ecc94..286e248 100644 --- a/sepolicy/vendor/hal_drm_clearkey.te +++ b/sepolicy/vendor/hal_drm_clearkey.te @@ -7,4 +7,4 @@ init_daemon_domain(hal_drm_clearkey) allow hal_drm_clearkey hal_drm_hwservice:hwservice_manager { add find }; allow hal_drm_clearkey hidl_base_hwservice:hwservice_manager add; allow hal_drm_clearkey hwservicemanager:binder { call transfer }; -allow hal_drm_clearkey hwservicemanager_prop:file { getattr open read }; +allow hal_drm_clearkey hwservicemanager_prop:file r_file_perms; diff --git a/sepolicy/vendor/hal_dumpstate_impl.te b/sepolicy/vendor/hal_dumpstate_impl.te index d380fcf..89ce71e 100644 --- a/sepolicy/vendor/hal_dumpstate_impl.te +++ b/sepolicy/vendor/hal_dumpstate_impl.te @@ -5,6 +5,6 @@ init_daemon_domain(hal_dumpstate_impl) allow hal_dumpstate_impl hal_dumpstate_impl_exec:file execute_no_trans; allow hal_dumpstate_impl hwservicemanager:binder { call transfer }; -allow hal_dumpstate_impl hwservicemanager_prop:file { getattr map open read }; +allow hal_dumpstate_impl hwservicemanager_prop:file { map r_file_perms }; allow hal_dumpstate_impl hidl_base_hwservice:hwservice_manager add; allow hal_dumpstate_impl hal_dumpstate_hwservice:hwservice_manager { add find }; diff --git a/sepolicy/vendor/hal_fingerprint_default.te b/sepolicy/vendor/hal_fingerprint_default.te index 7520e4b..1d83714 100644 --- a/sepolicy/vendor/hal_fingerprint_default.te +++ b/sepolicy/vendor/hal_fingerprint_default.te @@ -1,16 +1,16 @@ allow hal_fingerprint_default diag_data_file:dir search; -allow hal_fingerprint_default fingerprintd_data_file:dir { add_name remove_name search write }; -allow hal_fingerprint_default fingerprintd_data_file:file { create getattr open read rename unlink write }; +allow hal_fingerprint_default fingerprintd_data_file:dir create_dir_perms; +allow hal_fingerprint_default fingerprintd_data_file:file create_file_perms; allow hal_fingerprint_default firmware_file:dir search; -allow hal_fingerprint_default firmware_file:file { getattr open read }; +allow hal_fingerprint_default firmware_file:file r_file_perms; allow hal_fingerprint_default firmware_file:lnk_file read; -allow hal_fingerprint_default fpc_data_file:dir { add_name remove_name search write }; -allow hal_fingerprint_default fpc_data_file:sock_file { create unlink }; -allow hal_fingerprint_default input_device:chr_file { ioctl open read }; -allow hal_fingerprint_default input_device:dir { open read search }; +allow hal_fingerprint_default fpc_data_file:dir create_dir_perms; +allow hal_fingerprint_default fpc_data_file:sock_file create_file_perms; +allow hal_fingerprint_default input_device:chr_file r_file_perms; +allow hal_fingerprint_default input_device:dir r_dir_perms; allow hal_fingerprint_default sysfs:file write; allow hal_fingerprint_default sysfs_battery_supply:dir search; -allow hal_fingerprint_default sysfs_battery_supply:file { getattr open read }; -allow hal_fingerprint_default system_data_file:dir { add_name remove_name write }; -allow hal_fingerprint_default system_data_file:sock_file { create unlink }; -allow hal_fingerprint_default tee_device:chr_file { ioctl open read write }; +allow hal_fingerprint_default sysfs_battery_supply:file r_file_perms; +allow hal_fingerprint_default system_data_file:dir create_dir_perms; +allow hal_fingerprint_default system_data_file:sock_file create_file_perms; +allow hal_fingerprint_default tee_device:chr_file rw_file_perms; diff --git a/sepolicy/vendor/hal_health_default.te b/sepolicy/vendor/hal_health_default.te index 64e4b19..607c405 100644 --- a/sepolicy/vendor/hal_health_default.te +++ b/sepolicy/vendor/hal_health_default.te @@ -1 +1 @@ -allow hal_health_default sysfs:file { getattr open read }; +allow hal_health_default sysfs:file rw_file_perms; diff --git a/sepolicy/vendor/hal_light_default.te b/sepolicy/vendor/hal_light_default.te index c9b8d45..8c63d4c 100644 --- a/sepolicy/vendor/hal_light_default.te +++ b/sepolicy/vendor/hal_light_default.te @@ -1 +1 @@ -allow hal_light_default sysfs:file { open read write }; +allow hal_light_default sysfs:file rw_file_perms; diff --git a/sepolicy/vendor/hal_power_default.te b/sepolicy/vendor/hal_power_default.te index 323806d..a6a4cec 100644 --- a/sepolicy/vendor/hal_power_default.te +++ b/sepolicy/vendor/hal_power_default.te @@ -1 +1 @@ -allow hal_power_default sysfs:file { open write }; +allow hal_power_default sysfs:file rw_file_perms; diff --git a/sepolicy/vendor/hal_wifi_default.te b/sepolicy/vendor/hal_wifi_default.te index ab89521..78f4318 100644 --- a/sepolicy/vendor/hal_wifi_default.te +++ b/sepolicy/vendor/hal_wifi_default.te @@ -1,6 +1,6 @@ allow hal_wifi_default firmware_file:dir search; -allow hal_wifi_default firmware_file:file { open read }; +allow hal_wifi_default firmware_file:file r_file_perms; allow hal_wifi_default sysfs:file write; -allow hal_wifi_default system_data_file:file { open read }; -allow hal_wifi_default ta_data_file:dir { read search }; -allow hal_wifi_default ta_data_file:file { open read }; +allow hal_wifi_default system_data_file:file r_file_perms; +allow hal_wifi_default ta_data_file:dir r_dir_perms; +allow hal_wifi_default ta_data_file:file r_file_perms; diff --git a/sepolicy/vendor/hwservicemanager.te b/sepolicy/vendor/hwservicemanager.te index b56a7dd..e1771ec 100644 --- a/sepolicy/vendor/hwservicemanager.te +++ b/sepolicy/vendor/hwservicemanager.te @@ -1,10 +1,10 @@ allow hwservicemanager hal_drm_clearkey:dir search; -allow hwservicemanager hal_drm_clearkey:file { open read }; +allow hwservicemanager hal_drm_clearkey:file r_file_perms; allow hwservicemanager hal_drm_clearkey:process getattr; allow hwservicemanager hal_dumpstate_impl:dir rw_dir_perms; allow hwservicemanager hal_dumpstate_impl:file rw_file_perms; allow hwservicemanager hal_dumpstate_impl:binder { call transfer }; allow hwservicemanager hal_dumpstate_impl:process getattr; allow hwservicemanager init:dir search; -allow hwservicemanager init:file { open read }; +allow hwservicemanager init:file r_file_perms; allow hwservicemanager init:process getattr; diff --git a/sepolicy/vendor/init-power-sh.te b/sepolicy/vendor/init-power-sh.te index f8a8cd1..15fcdee 100644 --- a/sepolicy/vendor/init-power-sh.te +++ b/sepolicy/vendor/init-power-sh.te @@ -15,7 +15,7 @@ allow init-power-sh sysfs_cpu_boost:file rw_file_perms; allow init-power-sh sysfs_devices_system_cpu:file w_file_perms; allow init-power-sh sysfs_kgsl:file rw_file_perms; allow init-power-sh sysfs_msm_perf:dir search; -allow init-power-sh sysfs_msm_perf:file { open write }; +allow init-power-sh sysfs_msm_perf:file rw_file_perms; allow init-power-sh sysfs_performance:dir r_dir_perms; allow init-power-sh sysfs_performance:file w_file_perms; allow init-power-sh sysfs_thermal:dir r_dir_perms; diff --git a/sepolicy/vendor/init.te b/sepolicy/vendor/init.te index 578cb75..e2f301a 100644 --- a/sepolicy/vendor/init.te +++ b/sepolicy/vendor/init.te @@ -1,5 +1,5 @@ allow init binder_per_mgr_service:service_manager find; -allow init block_device:blk_file { ioctl setattr write }; +allow init block_device:blk_file create_file_perms; allow init cameraserver:fd use; allow init diag_data_file:dir mounton; allow init diag_partition_device:blk_file r_file_perms; @@ -7,30 +7,30 @@ allow init hal_drm_hwservice:hwservice_manager { add find }; allow init hal_dumpstate_hwservice:hwservice_manager { add find }; allow init hidl_base_hwservice:hwservice_manager add; allow init hwservicemanager:binder { call transfer }; -allow init ion_device:chr_file { ioctl open read }; +allow init ion_device:chr_file r_file_perms; allow init iorapd_data_file:file getattr; allow init per_mgr:binder { call transfer }; allow init proc:file write; allow init proc_dirty_ratio:file write; -allow init proc_interrupts:file { getattr open read }; +allow init proc_interrupts:file r_file_perms; allow init self:capability2 block_suspend; -allow init self:socket { bind create ioctl read write }; +allow init self:socket create_socket_perms; allow init servicemanager:binder call; -allow init socket_device:sock_file { create setattr unlink write }; -allow init sysfs:file { open read setattr write }; +allow init socket_device:sock_file create_file_perms; +allow init sysfs:file create_file_perms; allow init sysfs_camera_torch:lnk_file read; -allow init sysfs_cpu_boost:file { open write }; -allow init sysfs_devices_system_cpu:file write; -allow init sysfs_graphics:file { open read }; -allow init sysfs_kgsl:file { open write }; +allow init sysfs_cpu_boost:file rw_file_perms; +allow init sysfs_devices_system_cpu:file rw_file_perms; +allow init sysfs_graphics:file r_file_perms; +allow init sysfs_kgsl:file rw_file_perms; allow init sysfs_livedisplay_tuneable:file setattr; -allow init sysfs_msm_perf:file { open write }; +allow init sysfs_msm_perf:file rw_file_perms; allow init sysfs_thermal:file write; -allow init sysfs_wake_lock:file { append open }; -allow init system_data_file:file { ioctl lock }; +allow init sysfs_wake_lock:file ra_file_perms; +allow init system_data_file:file r_file_perms; allow init system_file:dir relabelfrom; allow init system_file:file execute_no_trans; -allow init tee_device:chr_file { ioctl open read write }; +allow init tee_device:chr_file rw_file_perms; allow init trim_area_partition_device:blk_file setattr; allow init vendor_file:file execute_no_trans; -allow init video_device:chr_file { ioctl open read write }; +allow init video_device:chr_file rw_file_perms; diff --git a/sepolicy/vendor/loc_launcher.te b/sepolicy/vendor/loc_launcher.te deleted file mode 100644 index 83ec18e..0000000 --- a/sepolicy/vendor/loc_launcher.te +++ /dev/null @@ -1,9 +0,0 @@ -type loc_launcher, domain; -type loc_launcher_exec, exec_type, file_type; - -# Started by init -init_daemon_domain(loc_launcher) - -allow loc_launcher location_data_file:dir { add_name remove_name search write }; -allow loc_launcher location_data_file:sock_file { create setattr unlink }; -allow loc_launcher self:capability setuid; diff --git a/sepolicy/vendor/mlog_qmi_service.te b/sepolicy/vendor/mlog_qmi_service.te index 7758a7a..2480f2a 100644 --- a/sepolicy/vendor/mlog_qmi_service.te +++ b/sepolicy/vendor/mlog_qmi_service.te @@ -5,4 +5,4 @@ type mlog_qmi_service_exec, exec_type, file_type; init_daemon_domain(mlog_qmi_service) allow mlog_qmi_service self:capability net_raw; -allow mlog_qmi_service self:socket { bind create ioctl read write }; +allow mlog_qmi_service self:socket create_socket_perms; diff --git a/sepolicy/vendor/msm_irqbalance.te b/sepolicy/vendor/msm_irqbalance.te index 53f24af..d580db8 100644 --- a/sepolicy/vendor/msm_irqbalance.te +++ b/sepolicy/vendor/msm_irqbalance.te @@ -4,8 +4,8 @@ type msm_irqbalance_exec, exec_type, file_type; # Started by init init_daemon_domain(msm_irqbalance) -allow msm_irqbalance proc:file { getattr open read write }; -allow msm_irqbalance proc_interrupts:file { getattr open read }; -allow msm_irqbalance proc_stat:file { getattr open read }; +allow msm_irqbalance proc:file rw_file_perms; +allow msm_irqbalance proc_interrupts:file r_file_perms; +allow msm_irqbalance proc_stat:file r_file_perms; allow msm_irqbalance self:capability { dac_override setgid setuid }; allow msm_irqbalance sysfs_devices_system_cpu:file write; diff --git a/sepolicy/vendor/qcamerasvr.te b/sepolicy/vendor/qcamerasvr.te index 5e5ace0..f3fe334 100644 --- a/sepolicy/vendor/qcamerasvr.te +++ b/sepolicy/vendor/qcamerasvr.te @@ -5,14 +5,14 @@ type qcamerasvr_exec, exec_type, file_type; # Started by init init_daemon_domain(qcamerasvr) -allow qcamerasvr camera_data_file:dir { add_name remove_name search write }; +allow qcamerasvr camera_data_file:dir w_dir_perms; allow qcamerasvr camera_data_file:sock_file { create unlink }; -allow qcamerasvr camera_prop:file { getattr open read }; +allow qcamerasvr camera_prop:file r_file_perms; allow qcamerasvr camera_socket:sock_file unlink; allow qcamerasvr cameraserver:fd use; allow qcamerasvr hal_graphics_allocator_default:fd use; allow qcamerasvr ion_device:chr_file r_file_perms; allow qcamerasvr sysfs:file rw_file_perms; -allow qcamerasvr sysfs_graphics:file { open read }; +allow qcamerasvr sysfs_graphics:file r_file_perms; allow qcamerasvr ta_data_file:dir search; -allow qcamerasvr video_device:chr_file { ioctl open read write }; +allow qcamerasvr video_device:chr_file rw_file_perms; diff --git a/sepolicy/vendor/rild.te b/sepolicy/vendor/rild.te index 1b327b5..345c66f 100644 --- a/sepolicy/vendor/rild.te +++ b/sepolicy/vendor/rild.te @@ -2,10 +2,10 @@ unix_socket_connect(rild, tad, tad) # Misc -allow rild cache_file:dir { rw_file_perms remove_name search }; +allow rild cache_file:dir create_dir_perms; allow rild firmware_file:dir search; -allow rild firmware_file:file { getattr open read }; -allow rild ion_device:chr_file { ioctl open read }; +allow rild firmware_file:file r_file_perms; +allow rild ion_device:chr_file r_file_perms; allow rild self:capability { dac_override sys_module }; allow rild socket_device:sock_file write; -allow rild tee_device:chr_file { ioctl open read write }; +allow rild tee_device:chr_file rw_file_perms; diff --git a/sepolicy/vendor/sct_service.te b/sepolicy/vendor/sct_service.te index 02eb5dc..a1e75bd 100644 --- a/sepolicy/vendor/sct_service.te +++ b/sepolicy/vendor/sct_service.te @@ -5,4 +5,4 @@ type sct_service_exec, exec_type, file_type; init_daemon_domain(sct_service) allow sct_service self:capability net_raw; -allow sct_service self:socket { bind create ioctl read write }; +allow sct_service self:socket create_socket_perms; diff --git a/sepolicy/vendor/secd.te b/sepolicy/vendor/secd.te index 628668c..a765354 100644 --- a/sepolicy/vendor/secd.te +++ b/sepolicy/vendor/secd.te @@ -5,11 +5,11 @@ type secd_exec, exec_type, file_type; init_daemon_domain(secd) allow secd firmware_file:dir search; -allow secd firmware_file:file { getattr open read }; -allow secd ion_device:chr_file { ioctl open read }; +allow secd firmware_file:file r_file_perms; +allow secd ion_device:chr_file r_file_perms; allow secd secd_data_file:dir search; allow secd secd_data_file:file rw_file_perms; -allow secd system_data_file:file { getattr ioctl lock open read write }; +allow secd system_data_file:file rw_file_perms; allow secd tad:unix_stream_socket connectto; allow secd tad_socket:sock_file write; -allow secd tee_device:chr_file { ioctl open read write }; +allow secd tee_device:chr_file rw_file_perms; diff --git a/sepolicy/vendor/servicemanager.te b/sepolicy/vendor/servicemanager.te index 88a2747..a4f80e2 100644 --- a/sepolicy/vendor/servicemanager.te +++ b/sepolicy/vendor/servicemanager.te @@ -1,5 +1,5 @@ -allow servicemanager hal_power_default:dir search; -allow servicemanager hal_power_default:file { open read }; +allow servicemanager hal_power_default:dir rw_dir_perms; +allow servicemanager hal_power_default:file rw_file_perms; allow servicemanager hal_power_default:process getattr; allow servicemanager init:binder transfer; allow servicemanager init:dir search; diff --git a/sepolicy/vendor/system_server.te b/sepolicy/vendor/system_server.te index 1579d65..05d5756 100644 --- a/sepolicy/vendor/system_server.te +++ b/sepolicy/vendor/system_server.te @@ -1,5 +1,5 @@ -allow system_server exported_camera_prop:file { getattr open read }; +allow system_server exported_camera_prop:file r_file_perms; allow system_server hal_light_default:process signal; -allow system_server userspace_reboot_config_prop:file { getattr open read }; -allow system_server userspace_reboot_exported_prop:file { getattr open read }; +allow system_server userspace_reboot_config_prop:file r_file_perms; +allow system_server userspace_reboot_exported_prop:file r_file_perms; allow system_server vendor_security_patch_level_prop:file r_file_perms; diff --git a/sepolicy/vendor/ta_qmi_service.te b/sepolicy/vendor/ta_qmi_service.te index d369511..ba1361f 100644 --- a/sepolicy/vendor/ta_qmi_service.te +++ b/sepolicy/vendor/ta_qmi_service.te @@ -6,7 +6,7 @@ init_daemon_domain(ta_qmi_service) allow ta_qmi_service self:capability { net_raw setgid setuid }; allow ta_qmi_service self:capability2 block_suspend; -allow ta_qmi_service self:socket { bind create ioctl read write }; -allow ta_qmi_service sysfs_wake_lock:file { append open }; +allow ta_qmi_service self:socket create_socket_perms; +allow ta_qmi_service sysfs_wake_lock:file w_file_perms; allow ta_qmi_service tad:unix_stream_socket connectto; allow ta_qmi_service tad_socket:sock_file write; diff --git a/sepolicy/vendor/taimport.te b/sepolicy/vendor/taimport.te index 796a78a..8db4097 100644 --- a/sepolicy/vendor/taimport.te +++ b/sepolicy/vendor/taimport.te @@ -5,9 +5,9 @@ type taimport_exec, exec_type, file_type; init_daemon_domain(taimport) allow taimport self:capability { dac_override setgid }; -allow taimport system_data_file:dir { add_name remove_name write }; -allow taimport system_data_file:file { create getattr open unlink write }; +allow taimport system_data_file:dir w_dir_perms; +allow taimport system_data_file:file create_file_perms; allow taimport tad:unix_stream_socket connectto; -allow taimport ta_data_file:dir { add_name create read remove_name search write }; -allow taimport ta_data_file:file { create getattr open read unlink write }; +allow taimport ta_data_file:dir create_dir_perms; +allow taimport ta_data_file:file create_file_perms; allow taimport tad_socket:sock_file write; diff --git a/sepolicy/vendor/tee.te b/sepolicy/vendor/tee.te index 2af3b21..3cd122e 100644 --- a/sepolicy/vendor/tee.te +++ b/sepolicy/vendor/tee.te @@ -1,3 +1,2 @@ allow tee vfat:dir search; -allow tee vfat:file { getattr open read }; - +allow tee vfat:file r_file_perms; diff --git a/sepolicy/vendor/timekeep.te b/sepolicy/vendor/timekeep.te index f5a178f..d090059 100644 --- a/sepolicy/vendor/timekeep.te +++ b/sepolicy/vendor/timekeep.te @@ -6,6 +6,6 @@ init_daemon_domain(timekeep) allow timekeep self:capability sys_time; allow timekeep sysfs_rtc:dir search; -allow timekeep sysfs:file { open read }; +allow timekeep sysfs:file r_file_perms; allow timekeep time_data_file:dir search; -allow timekeep time_data_file:file { getattr open write }; +allow timekeep time_data_file:file rw_file_perms; diff --git a/sepolicy/vendor/toolbox.te b/sepolicy/vendor/toolbox.te index 0913c5d..076c15a 100644 --- a/sepolicy/vendor/toolbox.te +++ b/sepolicy/vendor/toolbox.te @@ -1,7 +1,7 @@ -allow toolbox diag_data_file:dir { getattr open read remove_name rmdir search write }; -allow toolbox file_contexts_file:file { getattr open read }; +allow toolbox diag_data_file:dir create_dir_perms; +allow toolbox file_contexts_file:file r_file_perms; allow toolbox firmware_file:dir search; -allow toolbox init:fifo_file { getattr write }; +allow toolbox init:fifo_file rw_file_perms; allow toolbox self:capability dac_override; -allow toolbox sysfs:file { open read }; +allow toolbox sysfs:file r_file_perms; allow toolbox sysfs_devices_system_cpu:file write; diff --git a/sepolicy/vendor/ueventd.te b/sepolicy/vendor/ueventd.te index 04f953a..367320e 100644 --- a/sepolicy/vendor/ueventd.te +++ b/sepolicy/vendor/ueventd.te @@ -1,4 +1,4 @@ -allow ueventd diag_partition_device:blk_file { create getattr setattr }; -allow ueventd proc:file { getattr open read }; +allow ueventd diag_partition_device:blk_file create_file_perms; +allow ueventd proc:file r_file_perms; allow ueventd vfat:dir search; -allow ueventd vfat:file { getattr open read }; +allow ueventd vfat:file r_file_perms; diff --git a/sepolicy/vendor/vendor.te b/sepolicy/vendor/vendor.te deleted file mode 100644 index d4aeafd..0000000 --- a/sepolicy/vendor/vendor.te +++ /dev/null @@ -1,6 +0,0 @@ -type vendor, domain; -type vendor_exec, exec_type, file_type; - -# Started by init -init_daemon_domain(vendor) - diff --git a/sepolicy/vendor/vold.te b/sepolicy/vendor/vold.te index 87db41c..2fb570a 100644 --- a/sepolicy/vendor/vold.te +++ b/sepolicy/vendor/vold.te @@ -1,3 +1,3 @@ -allow vold diag_data_file:dir { ioctl open read }; +allow vold diag_data_file:dir r_file_perms; allow vold hal_bootctl_hwservice:hwservice_manager find; allow vold sysfs_mmc_host:file write; diff --git a/sepolicy/vendor/zygote.te b/sepolicy/vendor/zygote.te index c3f0115..5e4f106 100644 --- a/sepolicy/vendor/zygote.te +++ b/sepolicy/vendor/zygote.te @@ -1,2 +1,2 @@ -allow zygote exported_camera_prop:file { getattr open read }; -allow zygote proc_cmdline:file { getattr open read }; +allow zygote exported_camera_prop:file r_file_perms; +allow zygote proc_cmdline:file rw_file_perms; -- GitLab From 79a9f3779cd38ac9539f931b75b8d76e595b9026 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Mon, 16 Nov 2020 12:51:31 +0100 Subject: [PATCH 092/191] kitakami-common: sepolicy: Correcting labeling of the dumpstate HAL. This fixes error messages like this: "E init : Control message: Could not ctl.interface_start for 'android.hardware.dumpstate@1.1::IDumpstateDevice/default' from pid: 388 (/system/bin/hwservicemanager): File /vendor/bin/hw/android.hardware.dumpstate@1.1-service-kitakami (labeled "u:object_r:vendor_file:s0") has incorrect label or no domain transition from u:r:init:s0 to another SELinux domain defined. Have you configured your service correctly?" Change-Id: I4af872983027bb8b1f1a6967e9157a67062c5559 --- sepolicy/vendor/file_contexts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index f4e489c..89ee9a6 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -27,7 +27,7 @@ /sys/devices(/soc\.0)?/pmi8994-flash-27(/.*)? u:object_r:sysfs_camera_torch:s0 # Dumpstate HAL -/vendor/bin/hw/android\.hardware\.dumpstate@1\.1-service\.kitakami u:object_r:hal_dumpstate_impl_exec:s0 +/(vendor|system/vendor)/bin/hw/android\.hardware\.dumpstate@1\.1-service-kitakami u:object_r:hal_dumpstate_impl_exec:s0 # HCI /dev/ttyHS0 u:object_r:hci_attach_dev:s0 -- GitLab From d13cdf1a3d4d6138716463ab6150337886691904 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Wed, 18 Nov 2020 15:12:45 +0100 Subject: [PATCH 093/191] kitakami-common: rootdir: Set up schedtune To fix error messages like this: "Failed to open /dev/stune/top-app/tasks: No such file or directory" Change-Id: I05e7f5718bb1cfa1049a2a20f8e3f485211f77fa --- rootdir/init.qcom.rc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index 1e7cf12..f899ee7 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -110,6 +110,32 @@ on init write /sys/block/zram0/comp_algorithm lz4 write /proc/sys/vm/page-cluster 0 + # Create energy-aware scheduler tuning nodes + mkdir /dev/stune/foreground + mkdir /dev/stune/background + mkdir /dev/stune/top-app + mkdir /dev/stune/rt + chown system system /dev/stune + chown system system /dev/stune/foreground + chown system system /dev/stune/background + chown system system /dev/stune/top-app + chown system system /dev/stune/rt + chown system system /dev/stune/tasks + chown system system /dev/stune/foreground/tasks + chown system system /dev/stune/background/tasks + chown system system /dev/stune/top-app/tasks + chown system system /dev/stune/rt/tasks + write /dev/stune/tasks 0 + write /dev/stune/foreground/tasks 0 + write /dev/stune/background/tasks 0 + write /dev/stune/top-app/tasks 0 + write /dev/stune/rt/tasks 0 + chmod 0664 /dev/stune/tasks + chmod 0664 /dev/stune/foreground/tasks + chmod 0664 /dev/stune/background/tasks + chmod 0664 /dev/stune/top-app/tasks + chmod 0664 /dev/stune/rt/tasks + on early-boot # set RLIMIT_MEMLOCK to 64MB setrlimit 8 67108864 67108864 -- GitLab From 6f631641b4428b80327679d3ff3417bd55cdf2e5 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Tue, 24 Nov 2020 16:51:45 +0100 Subject: [PATCH 094/191] kitakami-common: sepolicy: Added missing sysfs type to fix changes made in LineageOS policies. Change-Id: Id0369cdd18511a723ea93e52968b203f432c47e2 --- sepolicy/vendor/file.te | 1 + 1 file changed, 1 insertion(+) diff --git a/sepolicy/vendor/file.te b/sepolicy/vendor/file.te index 00787e5..056a7c6 100644 --- a/sepolicy/vendor/file.te +++ b/sepolicy/vendor/file.te @@ -4,6 +4,7 @@ type secd_data_file, file_type; type secd_socket, file_type; type sysfs_addrsetup, fs_type, sysfs_type; type sysfs_camera_torch, sysfs_type, file_type; +type sysfs_disk_stat, sysfs_type, file_type; type sysfs_performance, sysfs_type, file_type; type sysfs_timekeep, fs_type, sysfs_type; type tad_socket, file_type; -- GitLab From 94351a96802b7aa9ff9be5b09581ebd8e38d96b4 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Wed, 25 Nov 2020 18:04:20 +0100 Subject: [PATCH 095/191] kitakami-common: sepolicy: Changed some more properties. Change-Id: Icfeb50930f466ef150da272bcc4a65931c1ef636 --- sepolicy/vendor/crash_dump.te | 2 +- sepolicy/vendor/hal_dumpstate_impl.te | 4 ++-- sepolicy/vendor/shell.te | 1 + sepolicy/vendor/zygote.te | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 sepolicy/vendor/shell.te diff --git a/sepolicy/vendor/crash_dump.te b/sepolicy/vendor/crash_dump.te index 9ebf245..e43a5c5 100644 --- a/sepolicy/vendor/crash_dump.te +++ b/sepolicy/vendor/crash_dump.te @@ -1,3 +1,3 @@ -allow crash_dump camera_prop:file { getattr open }; +allow crash_dump camera_prop:file r_file_perms; allow crash_dump init:process ptrace; allow crash_dump keystore:process ptrace; diff --git a/sepolicy/vendor/hal_dumpstate_impl.te b/sepolicy/vendor/hal_dumpstate_impl.te index 89ce71e..110d9f9 100644 --- a/sepolicy/vendor/hal_dumpstate_impl.te +++ b/sepolicy/vendor/hal_dumpstate_impl.te @@ -3,8 +3,8 @@ type hal_dumpstate_impl_exec, exec_type, file_type, vendor_file_type; init_daemon_domain(hal_dumpstate_impl) +allow hal_dumpstate_impl hal_dumpstate_hwservice:hwservice_manager { add find }; allow hal_dumpstate_impl hal_dumpstate_impl_exec:file execute_no_trans; +allow hal_dumpstate_impl hidl_base_hwservice:hwservice_manager add; allow hal_dumpstate_impl hwservicemanager:binder { call transfer }; allow hal_dumpstate_impl hwservicemanager_prop:file { map r_file_perms }; -allow hal_dumpstate_impl hidl_base_hwservice:hwservice_manager add; -allow hal_dumpstate_impl hal_dumpstate_hwservice:hwservice_manager { add find }; diff --git a/sepolicy/vendor/shell.te b/sepolicy/vendor/shell.te new file mode 100644 index 0000000..ec8db68 --- /dev/null +++ b/sepolicy/vendor/shell.te @@ -0,0 +1 @@ +allow shell kernel:system syslog_read; diff --git a/sepolicy/vendor/zygote.te b/sepolicy/vendor/zygote.te index 5e4f106..bf1a988 100644 --- a/sepolicy/vendor/zygote.te +++ b/sepolicy/vendor/zygote.te @@ -1,2 +1,3 @@ +allow zygote device:file rw_file_perms; allow zygote exported_camera_prop:file r_file_perms; allow zygote proc_cmdline:file rw_file_perms; -- GitLab From cbe9d3e3e7a5fa9d1162e193cda300c9ca8fc527 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Wed, 2 Dec 2020 17:02:54 +0100 Subject: [PATCH 096/191] kitakami-common: Added some missing files. This fixes errors like this: * E APM::Serializer: deserialize: Could not parse /odm/etc/audio_policy_configuration.xml document. * E APM::AudioPolicyEngine/Config: parse: Could not parse document /vendor/etc/audio_policy_engine_configuration.xml Change-Id: Ic50db0d6e749f3f397116ce1fb145956bac7fc56 --- device-common.mk | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/device-common.mk b/device-common.mk index 0ce8cfd..4ff5f9d 100644 --- a/device-common.mk +++ b/device-common.mk @@ -37,7 +37,6 @@ PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS += \ $(LOCAL_PATH)/overlay/lineage-sdk \ $(LOCAL_PATH)/overlay/packages/apps/Snap/res/values - # Permissions PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.bluetooth_le.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth_le.xml \ @@ -112,6 +111,7 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/audio/audio_output_policy.conf:$(TARGET_COPY_OUT_VENDOR)/etc/audio_output_policy.conf \ $(LOCAL_PATH)/audio/audio_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_platform_info.xml \ $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \ + $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_ODM)/etc/audio_policy_configuration.xml \ $(LOCAL_PATH)/audio/aanc_tuning_mixer.txt:$(TARGET_COPY_OUT_SYSTEM)/etc/aanc_tuning_mixer.txt PRODUCT_COPY_FILES += \ @@ -121,6 +121,13 @@ PRODUCT_COPY_FILES += \ frameworks/av/services/audiopolicy/config/r_submix_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/r_submix_audio_policy_configuration.xml \ frameworks/av/services/audiopolicy/config/usb_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/usb_audio_policy_configuration.xml +# Missing configuration files +PRODUCT_COPY_FILES += \ + frameworks/av/services/audiopolicy/enginedefault/config/example/phone/audio_policy_engine_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_engine_configuration.xml \ + frameworks/av/services/audiopolicy/enginedefault/config/example/phone/audio_policy_engine_default_stream_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_engine_default_stream_volumes.xml \ + frameworks/av/services/audiopolicy/enginedefault/config/example/phone/audio_policy_engine_product_strategies.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_engine_product_strategies.xml \ + frameworks/av/services/audiopolicy/enginedefault/config/example/phone/audio_policy_engine_stream_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_engine_stream_volumes.xml + # Bluetooth PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/bluetooth/bt_vendor.conf:system/etc/bluetooth/bt_vendor.conf -- GitLab From 72057872840234e3db6f3bc05d06118bbe455376 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Fri, 11 Dec 2020 18:29:35 +0100 Subject: [PATCH 097/191] kitakami-common: Bring back FM-Radio! Change-Id: Ib5e6848034516afa6dad343afbb2bff5bab4281f --- BoardConfigCommon.mk | 2 +- audio/audio_policy_configuration.xml | 14 ++++++++++++-- bluetooth/bt_vendor.conf | 6 +++--- device-common.mk | 6 ++++++ rootdir/init.qcom.rc | 10 +++++----- sepolicy/vendor/brcm_uim.te | 17 +++++++++++++++++ sepolicy/vendor/file.te | 1 + sepolicy/vendor/file_contexts | 6 ++++++ sepolicy/vendor/te_macros | 7 +++++++ 9 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 sepolicy/vendor/brcm_uim.te create mode 100644 sepolicy/vendor/te_macros diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 4299578..8b77dbe 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -133,7 +133,7 @@ TARGET_EXFAT_DRIVER := sdfat TARGET_FS_CONFIG_GEN := $(COMMON_PATH)/config.fs # FM radio -BOARD_HAVE_BCM_FM := false #UIM not compatible with Oreo, yet; +BOARD_HAVE_BCM_FM := true # BT/FM (Broadcom): Adjust the sysfs patch for 3.10 kernel BOARD_HAVE_BCM_FM_SYSFS := "/sys/bus/platform/drivers/bcm_ldisc/bcm_ldisc/" diff --git a/audio/audio_policy_configuration.xml b/audio/audio_policy_configuration.xml index 6fcc1aa..32908bb 100644 --- a/audio/audio_policy_configuration.xml +++ b/audio/audio_policy_configuration.xml @@ -55,6 +55,7 @@ Built-In Mic Built-In Back Mic Telephony Rx + FM Tuner Speaker @@ -203,7 +204,10 @@ - + + + + + + @@ -242,6 +250,8 @@ sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload"/> + + sources="Built-In Back Mic,Built-In Mic,Wired Headset Mic,BT SCO Headset Mic,Telephony Rx,FM Tuner"/> Date: Sat, 12 Dec 2020 12:58:15 +0100 Subject: [PATCH 098/191] kitakami-common: Removed deprecated entry "p2p_supplicant.conf" Change-Id: I2d4d70f87432325a133f13b64024d3675e2220dc --- device-common.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/device-common.mk b/device-common.mk index 450a25e..3014562 100644 --- a/device-common.mk +++ b/device-common.mk @@ -372,7 +372,6 @@ PRODUCT_PACKAGES += \ # Wifi PRODUCT_PACKAGES += \ android.hardware.wifi@1.0-service \ - p2p_supplicant.conf \ hostapd \ libwifi-hal-bcm \ libwpa_client \ -- GitLab From 9db1c74d65cde49eb8b87721951d490f4374ee1f Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sat, 12 Dec 2020 17:36:46 +0100 Subject: [PATCH 099/191] kitakami-common: Removed deprecated sources. Change-Id: If801ee8f1eef70e52bfcf2c6add91f208a05c7f3 --- lineage.dependencies | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lineage.dependencies b/lineage.dependencies index d068518..2009d9e 100644 --- a/lineage.dependencies +++ b/lineage.dependencies @@ -1,8 +1,4 @@ [ - { - "repository": "android_device_sony_common", - "target_path": "device/sony/common" - }, { "repository": "android_hardware_sony_timekeep", "target_path": "hardware/sony/timekeep" -- GitLab From c226b1c47abbf6ce127710248720fea6992796b8 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sat, 12 Dec 2020 13:42:17 +0100 Subject: [PATCH 100/191] kitakami-common: rootdir: Changed directory of some services. Change-Id: Ia658cbe5d5cdbf908cbb598aefbd36118bb7937c --- rootdir/init.qcom.rc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index 9a18dbc..60f4982 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -522,8 +522,8 @@ on property:ro.data.large_tcp_window_size=true on property:sys.sysctl.tcp_adv_win_scale=* write /proc/sys/net/ipv4/tcp_adv_win_scale ${sys.sysctl.tcp_adv_win_scale} -service wpa_supplicant /vendor/bin/hw/wpa_supplicant \ - -O/data/vendor/wifi/wpa/sockets -puse_p2p_group_interface \ +service wpa_supplicant /system/vendor/bin/hw/wpa_supplicant \ + -O/data/vendor/wifi/wpa/sockets -puse_p2p_group_interface=1 \ -g@android:wpa_wlan0 interface android.hardware.wifi.supplicant@1.0::ISupplicant default interface android.hardware.wifi.supplicant@1.1::ISupplicant default @@ -564,7 +564,7 @@ on property:sys.listeners.registered=* setprop sys.keymaster.loaded ${vendor.sys.listeners.registered} setprop vendor.sys.keymaster.loaded ${vendor.sys.listeners.registered} -service perfd /vendor/bin/perfd +service perfd /system/vendor/bin/perfd class main user root group root readproc @@ -622,7 +622,7 @@ service rmt_storage /system/bin/rmt_storage shutdown critical # DSDS second ril -service ril-daemon2 /vendor/bin/hw/rild -c 2 +service ril-daemon2 /system/vendor/bin/hw/rild -c 2 class main socket rild2 stream 660 root radio socket sap_uim_socket2 stream 660 bluetooth bluetooth @@ -631,7 +631,7 @@ service ril-daemon2 /vendor/bin/hw/rild -c 2 group radio cache inet misc audio log readproc wakelock oem_2993 disabled -service ril-daemon /vendor/bin/hw/rild +service ril-daemon /system/vendor/bin/hw/rild class main socket rild stream 660 root radio socket sap_uim_socket1 stream 660 bluetooth bluetooth -- GitLab From 58f574d5eeffcc4adeb5e936a69dd69012d6f7da Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Tue, 15 Dec 2020 11:11:06 +0100 Subject: [PATCH 101/191] kitakami-common: Fixed P2P crash. Change-Id: Ie7535c1d1e522e8b819ba298c136604426252543 --- configs/wpa_supplicant_overlay.conf | 4 ++++ device-common.mk | 4 +++- rootdir/init.qcom.rc | 2 +- sepolicy/vendor/hal_wifi_supplicant_default.te | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 configs/wpa_supplicant_overlay.conf create mode 100644 sepolicy/vendor/hal_wifi_supplicant_default.te diff --git a/configs/wpa_supplicant_overlay.conf b/configs/wpa_supplicant_overlay.conf new file mode 100644 index 0000000..981b617 --- /dev/null +++ b/configs/wpa_supplicant_overlay.conf @@ -0,0 +1,4 @@ +disable_scan_offload=1 +wowlan_triggers=any +filter_rssi=-75 +no_ctrl_interface= diff --git a/device-common.mk b/device-common.mk index 3014562..53c6fa9 100644 --- a/device-common.mk +++ b/device-common.mk @@ -378,4 +378,6 @@ PRODUCT_PACKAGES += \ wpa_supplicant \ wpa_supplicant.conf -$(call inherit-product, hardware/broadcom/wlan/bcmdhd/config/config-bcm.mk) +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/configs/wpa_supplicant_overlay.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/wpa_supplicant_overlay.conf + diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index 60f4982..9186014 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -523,7 +523,7 @@ on property:sys.sysctl.tcp_adv_win_scale=* write /proc/sys/net/ipv4/tcp_adv_win_scale ${sys.sysctl.tcp_adv_win_scale} service wpa_supplicant /system/vendor/bin/hw/wpa_supplicant \ - -O/data/vendor/wifi/wpa/sockets -puse_p2p_group_interface=1 \ + -O/data/vendor/wifi/wpa/sockets \ -g@android:wpa_wlan0 interface android.hardware.wifi.supplicant@1.0::ISupplicant default interface android.hardware.wifi.supplicant@1.1::ISupplicant default diff --git a/sepolicy/vendor/hal_wifi_supplicant_default.te b/sepolicy/vendor/hal_wifi_supplicant_default.te new file mode 100644 index 0000000..ce30e6c --- /dev/null +++ b/sepolicy/vendor/hal_wifi_supplicant_default.te @@ -0,0 +1 @@ +allow hal_wifi_supplicant_default firmware_file:dir search; -- GitLab From b7916fefe05836e4796e3fe334f2041190d7d78e Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Tue, 15 Dec 2020 12:07:27 +0100 Subject: [PATCH 102/191] kitakami-common: rootdir: Removed deprecated entries. Change-Id: I95243a9541ecac080e4568f9f438aba6a2940b04 --- rootdir/init.qcom.rc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index 9186014..d4804a9 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -440,10 +440,6 @@ on post-fs-data chown system system /sys/devices/virtual/input/maxim_sti/glove_en chmod 0660 /sys/devices/virtual/input/maxim_sti/glove_en - #Create the symlink to qcn wpa_supplicant folder for ar6000 wpa_supplicant - mkdir /data/system 0775 system system - #symlink /data/misc/wifi/wpa_supplicant /data/system/wpa_supplicant - #Create directories for Location services mkdir /data/misc/location 0770 gps gps mkdir /data/misc/location/mq 0770 gps gps -- GitLab From 4c64049f0b83d73e482add805f7e450f5904e08e Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sat, 19 Dec 2020 13:24:50 +0100 Subject: [PATCH 103/191] kitakami-common: LineageOS 18.1 Change-Id: I77b1dc5fac7fc0863fc28ac5327f9fe6fb834dab --- device-common.mk | 22 +++++++++++++------- manifest.xml | 39 +++++++++++++++++++++++++++-------- sepolicy/vendor/crash_dump.te | 1 + sepolicy/vendor/file.te | 1 - 4 files changed, 46 insertions(+), 17 deletions(-) diff --git a/device-common.mk b/device-common.mk index 53c6fa9..9d1f298 100644 --- a/device-common.mk +++ b/device-common.mk @@ -78,8 +78,6 @@ PRODUCT_COPY_FILES += \ # Audio PRODUCT_PACKAGES += \ - audiod \ - audio.a2dp.default \ android.hardware.audio@2.0-impl \ android.hardware.audio@6.0-impl \ android.hardware.audio.common@6.0 \ @@ -87,6 +85,8 @@ PRODUCT_PACKAGES += \ android.hardware.audio@2.0-service \ android.hardware.audio.effect@2.0-impl \ android.hardware.audio.effect@6.0-impl \ + audiod \ + audio.a2dp.default \ audio.primary.msm8994 \ audio.r_submix.default \ audio.usb.default \ @@ -135,6 +135,8 @@ PRODUCT_COPY_FILES += \ PRODUCT_PACKAGES += \ android.hardware.bluetooth@1.0-impl \ android.hardware.bluetooth@1.0-service \ + android.hardware.bluetooth.a2dp@1.0-impl.mock \ + android.hardware.bluetooth.audio@2.0-impl \ libbt-vendor # Camera @@ -165,14 +167,16 @@ PRODUCT_PACKAGES += \ android.hardware.graphics.allocator@2.0-impl \ android.hardware.graphics.allocator@2.0-service \ android.hardware.graphics.composer@2.1-impl \ - android.hardware.graphics.mapper@2.0-impl-2.1 \ + android.hardware.graphics.mapper@2.0-impl \ android.hardware.memtrack@1.0-impl \ - android.hardware.memtrack@1.0-service \ + android.hardware.memtrack@1.0-service + +PRODUCT_PACKAGES += \ copybit.msm8994 \ gralloc.msm8994 \ hwcomposer.msm8994 \ - libtinyxml \ - memtrack.msm8994 + memtrack.msm8994 \ + libtinyxml # DumpState PRODUCT_PACKAGES += \ @@ -247,8 +251,8 @@ PRODUCT_PACKAGES += \ # Lights PRODUCT_PACKAGES += \ - android.hardware.light@2.0-service \ android.hardware.light@2.0-impl \ + android.hardware.light@2.0-service \ lights.msm8994 # LiveDisplay @@ -345,6 +349,10 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ camera.qcom_shim +# Soundtrigger +PRODUCT_PACKAGES += \ + android.hardware.soundtrigger@2.0-impl + # Thermal PRODUCT_PACKAGES += \ thermal.qcom diff --git a/manifest.xml b/manifest.xml index d59f3d4..ffbb5a1 100644 --- a/manifest.xml +++ b/manifest.xml @@ -35,6 +35,24 @@ default + + android.hardware.bluetooth.a2dp + hwbinder + 1.0 + + IBluetoothAudioOffload + default + + + + android.hardware.bluetooth.audio + hwbinder + 2.0 + + IBluetoothAudioProvidersFactory + default + + android.hardware.camera.provider passthrough @@ -44,7 +62,7 @@ legacy/0 - + android.hardware.drm hwbinder 1.0 @@ -100,7 +118,7 @@ android.hardware.graphics.mapper passthrough - 2.1 + 2.0 IMapper default @@ -181,22 +199,25 @@ - android.hardware.renderscript + android.hardware.sensors passthrough 1.0 - IDevice + ISensors default - android.hardware.sensors - passthrough - 1.0 + android.hardware.soundtrigger + hwbinder + 2.0 - ISensors + ISoundTriggerHw default + @2.1::ISoundTriggerHw/default + @2.2::ISoundTriggerHw/default + @2.3::ISoundTriggerHw/default android.hardware.vibrator @@ -220,7 +241,7 @@ default - + vendor.lineage.trust hwbinder 1.0 diff --git a/sepolicy/vendor/crash_dump.te b/sepolicy/vendor/crash_dump.te index e43a5c5..ff1350e 100644 --- a/sepolicy/vendor/crash_dump.te +++ b/sepolicy/vendor/crash_dump.te @@ -1,3 +1,4 @@ allow crash_dump camera_prop:file r_file_perms; +allow crash_dump hwservicemanager_prop:file r_file_perms; allow crash_dump init:process ptrace; allow crash_dump keystore:process ptrace; diff --git a/sepolicy/vendor/file.te b/sepolicy/vendor/file.te index 052ee67..ce44ab7 100644 --- a/sepolicy/vendor/file.te +++ b/sepolicy/vendor/file.te @@ -5,7 +5,6 @@ type secd_data_file, file_type; type secd_socket, file_type; type sysfs_addrsetup, fs_type, sysfs_type; type sysfs_camera_torch, sysfs_type, file_type; -type sysfs_disk_stat, sysfs_type, file_type; type sysfs_performance, sysfs_type, file_type; type sysfs_timekeep, fs_type, sysfs_type; type tad_socket, file_type; -- GitLab From c1f72723f9b740241a49675d0a593c89daeb494a Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Fri, 25 Dec 2020 18:50:35 +0100 Subject: [PATCH 104/191] kitakami-common: Two bluetooth services were removed as they caused bluetooth audio to fail. Change-Id: I07411ec9dc02550683ec13a9f635cb8d0c99a07d --- device-common.mk | 2 -- manifest.xml | 18 ------------------ 2 files changed, 20 deletions(-) diff --git a/device-common.mk b/device-common.mk index 9d1f298..e1438cc 100644 --- a/device-common.mk +++ b/device-common.mk @@ -135,8 +135,6 @@ PRODUCT_COPY_FILES += \ PRODUCT_PACKAGES += \ android.hardware.bluetooth@1.0-impl \ android.hardware.bluetooth@1.0-service \ - android.hardware.bluetooth.a2dp@1.0-impl.mock \ - android.hardware.bluetooth.audio@2.0-impl \ libbt-vendor # Camera diff --git a/manifest.xml b/manifest.xml index ffbb5a1..2ec2641 100644 --- a/manifest.xml +++ b/manifest.xml @@ -35,24 +35,6 @@ default - - android.hardware.bluetooth.a2dp - hwbinder - 1.0 - - IBluetoothAudioOffload - default - - - - android.hardware.bluetooth.audio - hwbinder - 2.0 - - IBluetoothAudioProvidersFactory - default - - android.hardware.camera.provider passthrough -- GitLab From ba38b7294bbee2bb492e2c7ea5648b3a1a46cd29 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Mon, 28 Dec 2020 13:15:01 +0100 Subject: [PATCH 105/191] Revert "kitakami-common: Added some missing files." This reverts commit cbe9d3e3e7a5fa9d1162e193cda300c9ca8fc527. --- device-common.mk | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/device-common.mk b/device-common.mk index e1438cc..06054cc 100644 --- a/device-common.mk +++ b/device-common.mk @@ -37,6 +37,7 @@ PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS += \ $(LOCAL_PATH)/overlay/lineage-sdk \ $(LOCAL_PATH)/overlay/packages/apps/Snap/res/values + # Permissions PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.bluetooth_le.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth_le.xml \ @@ -111,7 +112,6 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/audio/audio_output_policy.conf:$(TARGET_COPY_OUT_VENDOR)/etc/audio_output_policy.conf \ $(LOCAL_PATH)/audio/audio_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_platform_info.xml \ $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \ - $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_ODM)/etc/audio_policy_configuration.xml \ $(LOCAL_PATH)/audio/aanc_tuning_mixer.txt:$(TARGET_COPY_OUT_SYSTEM)/etc/aanc_tuning_mixer.txt PRODUCT_COPY_FILES += \ @@ -121,13 +121,6 @@ PRODUCT_COPY_FILES += \ frameworks/av/services/audiopolicy/config/r_submix_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/r_submix_audio_policy_configuration.xml \ frameworks/av/services/audiopolicy/config/usb_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/usb_audio_policy_configuration.xml -# Missing configuration files -PRODUCT_COPY_FILES += \ - frameworks/av/services/audiopolicy/enginedefault/config/example/phone/audio_policy_engine_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_engine_configuration.xml \ - frameworks/av/services/audiopolicy/enginedefault/config/example/phone/audio_policy_engine_default_stream_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_engine_default_stream_volumes.xml \ - frameworks/av/services/audiopolicy/enginedefault/config/example/phone/audio_policy_engine_product_strategies.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_engine_product_strategies.xml \ - frameworks/av/services/audiopolicy/enginedefault/config/example/phone/audio_policy_engine_stream_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_engine_stream_volumes.xml - # Bluetooth PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/bluetooth/bt_vendor.conf:system/etc/bluetooth/bt_vendor.conf -- GitLab From 1c9635865f476906e298727e58490436409d4b6f Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Mon, 28 Dec 2020 13:22:49 +0100 Subject: [PATCH 106/191] kitakami-common: Finetuning Change-Id: Ic54d3f39890e51b87205a400ec83b760770416f6 --- device-common.mk | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/device-common.mk b/device-common.mk index 06054cc..97d7db9 100644 --- a/device-common.mk +++ b/device-common.mk @@ -37,7 +37,6 @@ PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS += \ $(LOCAL_PATH)/overlay/lineage-sdk \ $(LOCAL_PATH)/overlay/packages/apps/Snap/res/values - # Permissions PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.bluetooth_le.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth_le.xml \ @@ -59,13 +58,13 @@ PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \ frameworks/native/data/etc/android.hardware.usb.accessory.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.accessory.xml \ frameworks/native/data/etc/android.hardware.usb.host.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.host.xml \ + frameworks/native/data/etc/android.hardware.vulkan.level-0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.level.xml \ + frameworks/native/data/etc/android.hardware.vulkan.version-1_0_3.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml \ frameworks/native/data/etc/android.hardware.wifi.direct.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.direct.xml \ frameworks/native/data/etc/android.hardware.wifi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.xml \ frameworks/native/data/etc/android.software.midi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.midi.xml \ frameworks/native/data/etc/android.software.sip.voip.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.sip.voip.xml \ - frameworks/native/data/etc/handheld_core_hardware.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/handheld_core_hardware.xml \ - frameworks/native/data/etc/android.hardware.vulkan.level-0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.level.xml \ - frameworks/native/data/etc/android.hardware.vulkan.version-1_0_3.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml + frameworks/native/data/etc/handheld_core_hardware.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/handheld_core_hardware.xml # ANT+ PRODUCT_PACKAGES += \ @@ -108,11 +107,11 @@ PRODUCT_COPY_FILES += \ # Audio configuration PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/audio/aanc_tuning_mixer.txt:$(TARGET_COPY_OUT_SYSTEM)/etc/aanc_tuning_mixer.txt \ $(LOCAL_PATH)/audio/audio_effects.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_effects.xml \ $(LOCAL_PATH)/audio/audio_output_policy.conf:$(TARGET_COPY_OUT_VENDOR)/etc/audio_output_policy.conf \ $(LOCAL_PATH)/audio/audio_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_platform_info.xml \ - $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \ - $(LOCAL_PATH)/audio/aanc_tuning_mixer.txt:$(TARGET_COPY_OUT_SYSTEM)/etc/aanc_tuning_mixer.txt + $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml PRODUCT_COPY_FILES += \ frameworks/av/services/audiopolicy/config/a2dp_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_audio_policy_configuration.xml \ @@ -132,7 +131,7 @@ PRODUCT_PACKAGES += \ # Camera PRODUCT_PACKAGES += \ - android.hardware.camera.provider@2.4-impl \ + android.hardware.camera.provider@2.4-impl:32 \ camera.msm8994 \ Snap -- GitLab From 8bd55c424aa856dfc9947efa9c911a4c4f4868d6 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Wed, 30 Dec 2020 16:03:09 +0100 Subject: [PATCH 107/191] kitakami-common: android.hardware.configstore needs to be binderized. Change-Id: I8a6438e644622690e80fb27c6ed5e78af547ebbd --- manifest.xml | 9 +++++++++ sepolicy/vendor/cameraserver.te | 1 + 2 files changed, 10 insertions(+) diff --git a/manifest.xml b/manifest.xml index 2ec2641..baefcb0 100644 --- a/manifest.xml +++ b/manifest.xml @@ -44,6 +44,15 @@ legacy/0 + + android.hardware.configstore + hwbinder + 1.1 + + ISurfaceFlingerConfigs + default + + android.hardware.drm hwbinder diff --git a/sepolicy/vendor/cameraserver.te b/sepolicy/vendor/cameraserver.te index 20610b0..fc26cc2 100644 --- a/sepolicy/vendor/cameraserver.te +++ b/sepolicy/vendor/cameraserver.te @@ -1,3 +1,4 @@ +allow cameraserver hal_configstore_default:binder call; allow cameraserver hal_configstore_ISurfaceFlingerConfigs:hwservice_manager find; allow cameraserver init:unix_dgram_socket sendto; allow cameraserver qcamerasvr:unix_dgram_socket sendto; -- GitLab From bf5350015299ad45ab725c1689ae59c7bd9e5922 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Thu, 31 Dec 2020 11:11:01 +0100 Subject: [PATCH 108/191] kitakami-common: sepolicy: Changed one more property. Change-Id: I13378a79290aeaa0a8ab19419bfafcf2a9876d8b --- sepolicy/vendor/zygote.te | 1 + 1 file changed, 1 insertion(+) diff --git a/sepolicy/vendor/zygote.te b/sepolicy/vendor/zygote.te index bf1a988..8a599a4 100644 --- a/sepolicy/vendor/zygote.te +++ b/sepolicy/vendor/zygote.te @@ -1,3 +1,4 @@ +allow zygote bluetooth_prop:file r_file_perms; allow zygote device:file rw_file_perms; allow zygote exported_camera_prop:file r_file_perms; allow zygote proc_cmdline:file rw_file_perms; -- GitLab From b24190eaecc5702c1450c765fe3239fd6f050820 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Thu, 31 Dec 2020 11:12:20 +0100 Subject: [PATCH 109/191] kitakami-common: Vibrator service needs to be binderized. Change-Id: Iaab0fc934437295ecc87db091231426809de2b0a --- device-common.mk | 3 ++- manifest.xml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/device-common.mk b/device-common.mk index 97d7db9..6339ecd 100644 --- a/device-common.mk +++ b/device-common.mk @@ -365,7 +365,8 @@ PRODUCT_PACKAGES += \ # Vibrator PRODUCT_PACKAGES += \ - android.hardware.vibrator@1.0-impl + android.hardware.vibrator@1.0-impl \ + android.hardware.vibrator@1.0-service # Wifi PRODUCT_PACKAGES += \ diff --git a/manifest.xml b/manifest.xml index baefcb0..735fcfc 100644 --- a/manifest.xml +++ b/manifest.xml @@ -212,7 +212,7 @@ android.hardware.vibrator - passthrough + hwbinder 1.0 IVibrator -- GitLab From 4f6a382abe720ae960f28b3952de3daae65a0c53 Mon Sep 17 00:00:00 2001 From: TALU Date: Tue, 22 Dec 2020 22:20:28 +0000 Subject: [PATCH 110/191] kitakami-common: sepolicy: address SELinux denials appearing after adding the mock power stats HAL. Change-Id: I4c0548e8bdf8a01ffdc7eeb0840eeb550efccca1 --- sepolicy/vendor/init.te | 1 + 1 file changed, 1 insertion(+) diff --git a/sepolicy/vendor/init.te b/sepolicy/vendor/init.te index e2f301a..b0129f1 100644 --- a/sepolicy/vendor/init.te +++ b/sepolicy/vendor/init.te @@ -5,6 +5,7 @@ allow init diag_data_file:dir mounton; allow init diag_partition_device:blk_file r_file_perms; allow init hal_drm_hwservice:hwservice_manager { add find }; allow init hal_dumpstate_hwservice:hwservice_manager { add find }; +allow init hal_power_stats_hwservice:hwservice_manager add; allow init hidl_base_hwservice:hwservice_manager add; allow init hwservicemanager:binder { call transfer }; allow init ion_device:chr_file r_file_perms; -- GitLab From ec5e3a0100ac3df2498e02a37eddb25dad79158f Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Thu, 31 Dec 2020 17:22:40 +0100 Subject: [PATCH 111/191] kitakami-common: Removed useless entries in manifest.xml. Change-Id: I2d1835032bc7157d3b930597fcf329462a93e925 --- manifest.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/manifest.xml b/manifest.xml index 735fcfc..6858f0e 100644 --- a/manifest.xml +++ b/manifest.xml @@ -206,9 +206,6 @@ ISoundTriggerHw default - @2.1::ISoundTriggerHw/default - @2.2::ISoundTriggerHw/default - @2.3::ISoundTriggerHw/default android.hardware.vibrator -- GitLab From 3dc77802ce99079cf98aeec906f67c048ddeace4 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Fri, 1 Jan 2021 20:58:07 +0100 Subject: [PATCH 112/191] kitakami-common: Changed audio_policy_configuration.xml to avoid recording issues. Change-Id: I77341e0ba4cb16dbb787b1ba76bc2c6def3d41f5 --- audio/audio_policy_configuration.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/audio_policy_configuration.xml b/audio/audio_policy_configuration.xml index 32908bb..8f6aa8c 100644 --- a/audio/audio_policy_configuration.xml +++ b/audio/audio_policy_configuration.xml @@ -125,7 +125,7 @@ - + -- GitLab From 087e8b8aa015877587cf59c3d576cd42b199b07f Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sat, 2 Jan 2021 15:51:21 +0100 Subject: [PATCH 113/191] kitakami-common: Removed deprecated wifi driver. Change-Id: Idbc65220952e791f882b00502bd8af7178c22098 --- device-common.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/device-common.mk b/device-common.mk index 6339ecd..55bfa68 100644 --- a/device-common.mk +++ b/device-common.mk @@ -372,7 +372,6 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ android.hardware.wifi@1.0-service \ hostapd \ - libwifi-hal-bcm \ libwpa_client \ wpa_supplicant \ wpa_supplicant.conf -- GitLab From 8c8ddfed7f3a72eca3a108d5d2bcc269cf160cc1 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Wed, 6 Jan 2021 12:41:28 +0100 Subject: [PATCH 114/191] kitakami-common: Removed trust from device manifest - This manifest entry is now part of android_hardware_lineage_interfaces. - See: https://github.com/LineageOS/android_hardware_lineage_interfaces/commit/742a5342baa4ef307578e594cdb0cc735ba65fbf Change-Id: I735d3b1c6eb1f4c09c7a05fcbc7cd645bbdae8fe --- manifest.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/manifest.xml b/manifest.xml index 6858f0e..1a40c82 100644 --- a/manifest.xml +++ b/manifest.xml @@ -229,15 +229,6 @@ default - - vendor.lineage.trust - hwbinder - 1.0 - - IUsbRestrict - default - - vendor.qti.hardware.cryptfshw hwbinder -- GitLab From e2c7f5ea0b08e779e3e5cbed2c619474ca644f27 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Wed, 6 Jan 2021 14:51:03 +0100 Subject: [PATCH 115/191] kitakami-common: sepolicy: Addressing DRM denials. Change-Id: Id9e0245c67f013b42a1b7bae60c082c67e3ba1af --- sepolicy/vendor/hal_drm_clearkey.te | 1 + sepolicy/vendor/hal_drm_widevine.te | 2 ++ sepolicy/vendor/mediadrmserver.te | 1 + 3 files changed, 4 insertions(+) create mode 100644 sepolicy/vendor/hal_drm_widevine.te create mode 100644 sepolicy/vendor/mediadrmserver.te diff --git a/sepolicy/vendor/hal_drm_clearkey.te b/sepolicy/vendor/hal_drm_clearkey.te index 286e248..bae05ce 100644 --- a/sepolicy/vendor/hal_drm_clearkey.te +++ b/sepolicy/vendor/hal_drm_clearkey.te @@ -8,3 +8,4 @@ allow hal_drm_clearkey hal_drm_hwservice:hwservice_manager { add find }; allow hal_drm_clearkey hidl_base_hwservice:hwservice_manager add; allow hal_drm_clearkey hwservicemanager:binder { call transfer }; allow hal_drm_clearkey hwservicemanager_prop:file r_file_perms; +allow hal_drm_clearkey mediadrmserver:binder { call transfer }; diff --git a/sepolicy/vendor/hal_drm_widevine.te b/sepolicy/vendor/hal_drm_widevine.te new file mode 100644 index 0000000..d558dec --- /dev/null +++ b/sepolicy/vendor/hal_drm_widevine.te @@ -0,0 +1,2 @@ +allow hal_drm_widevine vendor_data_file:dir create_dir_perms; +allow hal_drm_widevine vendor_data_file:file create_file_perms; diff --git a/sepolicy/vendor/mediadrmserver.te b/sepolicy/vendor/mediadrmserver.te new file mode 100644 index 0000000..5da38e7 --- /dev/null +++ b/sepolicy/vendor/mediadrmserver.te @@ -0,0 +1 @@ +allow mediadrmserver hal_drm_clearkey:binder { call transfer }; -- GitLab From 8f1eefae9faba2213ddab88366bcd2e65a037926 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Thu, 7 Jan 2021 17:06:21 +0100 Subject: [PATCH 116/191] kitakami-common: sepolicy: Changed DRM addressing. Change-Id: I23f8926da2f9c11512955d4c48c3132fdc99c7da --- sepolicy/vendor/file.te | 1 + sepolicy/vendor/file_contexts | 1 + sepolicy/vendor/hal_drm_widevine.te | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sepolicy/vendor/file.te b/sepolicy/vendor/file.te index ce44ab7..28cc021 100644 --- a/sepolicy/vendor/file.te +++ b/sepolicy/vendor/file.te @@ -1,6 +1,7 @@ type brcm_ldisc_sysfs, sysfs_type, fs_type; type diag_partition_device, file_type; type fpc_data_file, file_type; +type mediadrm_vendor_data_file, file_type, data_file_type; type secd_data_file, file_type; type secd_socket, file_type; type sysfs_addrsetup, fs_type, sysfs_type; diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 92a76e4..a9de2ea 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -20,6 +20,7 @@ /sys/devices(/soc\.0)?/bcmdhd_wlan.83/macaddr u:object_r:sysfs_addrsetup:s0 # DRM +/data/vendor/mediadrm(/.*)? u:object_r:mediadrm_vendor_data_file:s0 /(vendor|system/vendor)/bin/hw/android\.hardware\.drm@1\.3-service.clearkey u:object_r:hal_drm_clearkey_exec:s0 /(vendor|system/vendor)/bin/hw/android\.hardware\.drm@1\.3-service.widevine u:object_r:hal_drm_widevine_exec:s0 diff --git a/sepolicy/vendor/hal_drm_widevine.te b/sepolicy/vendor/hal_drm_widevine.te index d558dec..120a9ec 100644 --- a/sepolicy/vendor/hal_drm_widevine.te +++ b/sepolicy/vendor/hal_drm_widevine.te @@ -1,2 +1,2 @@ -allow hal_drm_widevine vendor_data_file:dir create_dir_perms; -allow hal_drm_widevine vendor_data_file:file create_file_perms; +allow hal_drm_widevine mediadrm_vendor_data_file:dir create_dir_perms; +allow hal_drm_widevine mediadrm_vendor_data_file:file create_file_perms; -- GitLab From c7a66671c50e2e38d7f917da04c217e18c2278e8 Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Thu, 10 Dec 2020 11:32:08 +0000 Subject: [PATCH 117/191] kitakami-common: Move graphics composer to hwbinder The passthrough impl is dead as of Android 11 QPR1. Change-Id: Ic10e93398363f03551afe39715cb664bbbce1683 --- device-common.mk | 4 ++-- manifest.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/device-common.mk b/device-common.mk index 55bfa68..b0b2a7c 100644 --- a/device-common.mk +++ b/device-common.mk @@ -156,8 +156,8 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ android.hardware.graphics.allocator@2.0-impl \ android.hardware.graphics.allocator@2.0-service \ - android.hardware.graphics.composer@2.1-impl \ - android.hardware.graphics.mapper@2.0-impl \ + android.hardware.graphics.composer@2.1-service \ + android.hardware.graphics.mapper@2.0-impl-2.1 \ android.hardware.memtrack@1.0-impl \ android.hardware.memtrack@1.0-service diff --git a/manifest.xml b/manifest.xml index 1a40c82..0ddefc6 100644 --- a/manifest.xml +++ b/manifest.xml @@ -99,7 +99,7 @@ android.hardware.graphics.composer - passthrough + hwbinder 2.1 IComposer -- GitLab From e2525a6459e18c351ac58a0d0de6d626912268e6 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Tue, 12 Jan 2021 11:35:18 +0800 Subject: [PATCH 118/191] kitakami-common: Disable PPDaemon & Livedisplay legacymm * Causing deepsleep issues. --- device-common.mk | 1 - manifest.xml | 4 ---- rootdir/init.qcom.rc | 1 + 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/device-common.mk b/device-common.mk index b0b2a7c..5adcce3 100644 --- a/device-common.mk +++ b/device-common.mk @@ -247,7 +247,6 @@ PRODUCT_PACKAGES += \ # LiveDisplay PRODUCT_PACKAGES += \ - vendor.lineage.livedisplay@2.0-service-legacymm \ vendor.lineage.livedisplay@2.0-service-sysfs # Media diff --git a/manifest.xml b/manifest.xml index 0ddefc6..ef77660 100644 --- a/manifest.xml +++ b/manifest.xml @@ -224,10 +224,6 @@ IDisplayColorCalibration default - - IPictureAdjustment - default - vendor.qti.hardware.cryptfshw diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index d4804a9..a8ebf6f 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -689,6 +689,7 @@ service ppd /system/vendor/bin/mm-pp-daemon socket pps stream 0660 system system group system graphics writepid /dev/cpuset/system-background/tasks + disabled # brcm-uim-sysfs (BT/FM/ANT+) service uim /system/vendor/bin/brcm-uim-sysfs -- GitLab From ef7a64649c846d6bc4213c1e81bf9fa61d691725 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Thu, 14 Jan 2021 16:05:39 +0100 Subject: [PATCH 119/191] kitakami-common: sepolicy: Addressing graphics composer service denials. Change-Id: I97c5d27bbc6767aab2c5b689f8c598b640a8de04 --- sepolicy/vendor/hal_graphics_composer_default.te | 1 + 1 file changed, 1 insertion(+) create mode 100644 sepolicy/vendor/hal_graphics_composer_default.te diff --git a/sepolicy/vendor/hal_graphics_composer_default.te b/sepolicy/vendor/hal_graphics_composer_default.te new file mode 100644 index 0000000..b5dd649 --- /dev/null +++ b/sepolicy/vendor/hal_graphics_composer_default.te @@ -0,0 +1 @@ +allow hal_graphics_composer_default mpctl_socket:dir r_dir_perms; -- GitLab From 8a8f013cb090406c4751118b3d5bdc67940f5a74 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Wed, 28 Oct 2020 13:04:39 +0100 Subject: [PATCH 120/191] kitakami-common: Enable TARGET_USES_NO_MTU_IPACM * Fixes tethering. Change-Id: Ie37f2c57720f112b79ab360c4590e9ca3e9c9477 --- BoardConfigCommon.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 8b77dbe..b404cb9 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -154,6 +154,9 @@ PRODUCT_ENFORCE_VINTF_MANIFEST_OVERRIDE := true # Init TARGET_PLATFORM_DEVICE_BASE := /devices/soc.0/ +# IPA +TARGET_USES_NO_MTU_IPACM := true + # Properties TARGET_SYSTEM_PROP += $(COMMON_PATH)/system.prop -- GitLab From 3265b013bcbd52f467942f84782f8719a1896fc0 Mon Sep 17 00:00:00 2001 From: Sam Mortimer Date: Fri, 16 Aug 2019 11:20:00 -0700 Subject: [PATCH 121/191] kitakami-common: Remove config_tether_upstream_types * Made redundant by enabling config_tether_upstream_automatic in vendor/lineage Change-Id: Idd22b0616ae1c8732139085c03f19e6c21c75feb --- .../frameworks/base/core/res/res/values/config.xml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/overlay-radio/frameworks/base/core/res/res/values/config.xml b/overlay-radio/frameworks/base/core/res/res/values/config.xml index e316b72..fdb91fd 100644 --- a/overlay-radio/frameworks/base/core/res/res/values/config.xml +++ b/overlay-radio/frameworks/base/core/res/res/values/config.xml @@ -20,17 +20,6 @@ rmnet0 - - - - 0 - 1 - 4 - 5 - 7 - - - - - usb\\d - rndis\\d - - - - - wlan0 - - - - - bnep\\d - bt-pan - - true diff --git a/rro_overlays/TetheringOverlay/Android.bp b/rro_overlays/TetheringOverlay/Android.bp new file mode 100644 index 0000000..feaaf46 --- /dev/null +++ b/rro_overlays/TetheringOverlay/Android.bp @@ -0,0 +1,7 @@ +runtime_resource_overlay { + name: "TetheringConfigOverlay", + theme: "TetheringConfigOverlay", + certificate: "platform", + sdk_version: "current", + product_specific: true +} diff --git a/rro_overlays/TetheringOverlay/AndroidManifest.xml b/rro_overlays/TetheringOverlay/AndroidManifest.xml new file mode 100644 index 0000000..ccd3729 --- /dev/null +++ b/rro_overlays/TetheringOverlay/AndroidManifest.xml @@ -0,0 +1,11 @@ + + + + diff --git a/rro_overlays/TetheringOverlay/res/values/config.xml b/rro_overlays/TetheringOverlay/res/values/config.xml new file mode 100644 index 0000000..4caab74 --- /dev/null +++ b/rro_overlays/TetheringOverlay/res/values/config.xml @@ -0,0 +1,50 @@ + + + + + + + + "usb\\d" + "rndis\\d" + + + + + "wlan0" + + + + + bnep\\d + bt-pan + + + + true + + -- GitLab From 27ea35278d4a9c7cc52be3795b1027764cf801f8 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Mon, 19 Oct 2020 21:42:02 +0200 Subject: [PATCH 123/191] kitakami-common: TetheringOverlay: Disable BPF * Such is life with 3.10 kernels. Change-Id: I1c5e3fab63271b1e3fe6c814d96edbde782f27e8 --- rro_overlays/TetheringOverlay/res/values/config.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rro_overlays/TetheringOverlay/res/values/config.xml b/rro_overlays/TetheringOverlay/res/values/config.xml index 4caab74..825aacf 100644 --- a/rro_overlays/TetheringOverlay/res/values/config.xml +++ b/rro_overlays/TetheringOverlay/res/values/config.xml @@ -19,6 +19,12 @@ + + false + -- GitLab From b36b1c0db11363a718844d40f9bf2ce3e66293d8 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Fri, 1 Nov 2019 06:03:26 -0700 Subject: [PATCH 124/191] kitakami-common: overlay: Remove wifi related internal overlays These are replaced by formal mainline module overlays. Bug: 143464763 Test: Send for Wifi regression tests Change-Id: I45881ed210132252b9c5c7d6be03ed845e33f971 --- .../frameworks/base/core/res/res/values/config.xml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml index 2133396..bd05559 100644 --- a/overlay/frameworks/base/core/res/res/values/config.xml +++ b/overlay/frameworks/base/core/res/res/values/config.xml @@ -265,19 +265,6 @@ --> true - - true - - - true - - - true - - - 524288,2097152,4194304,262144,524288,1048576 - com.google.android.gms/com.google.android.gms.nearby.messages.service.NearbyMessagesService -- GitLab From a421b87dfbc8dbbd6e90cf8dde1f25d1f7dfc8ea Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Fri, 24 Apr 2020 14:33:28 -0700 Subject: [PATCH 125/191] kitakami-common: Add WifiOverlay Bug: 148617260 Test: Device boots up and connects to wifi networks. Change-Id: Iec27a6d947a232a42451ef095dc73d1a52327db5 --- device-common.mk | 1 + rro_overlays/WifiOverlay/Android.bp | 7 +++ rro_overlays/WifiOverlay/AndroidManifest.xml | 27 ++++++++++ .../WifiOverlay/res/values/config.xml | 54 +++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 rro_overlays/WifiOverlay/Android.bp create mode 100644 rro_overlays/WifiOverlay/AndroidManifest.xml create mode 100644 rro_overlays/WifiOverlay/res/values/config.xml diff --git a/device-common.mk b/device-common.mk index d1cf9f7..f2ac547 100644 --- a/device-common.mk +++ b/device-common.mk @@ -376,6 +376,7 @@ PRODUCT_PACKAGES += \ android.hardware.wifi@1.0-service \ hostapd \ libwpa_client \ + WifiOverlay \ wpa_supplicant \ wpa_supplicant.conf diff --git a/rro_overlays/WifiOverlay/Android.bp b/rro_overlays/WifiOverlay/Android.bp new file mode 100644 index 0000000..5407765 --- /dev/null +++ b/rro_overlays/WifiOverlay/Android.bp @@ -0,0 +1,7 @@ +runtime_resource_overlay { + name: "WifiOverlay", + theme: "WifiOverlay", + certificate: "platform", + sdk_version: "current", + product_specific: true +} diff --git a/rro_overlays/WifiOverlay/AndroidManifest.xml b/rro_overlays/WifiOverlay/AndroidManifest.xml new file mode 100644 index 0000000..77e9af0 --- /dev/null +++ b/rro_overlays/WifiOverlay/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + diff --git a/rro_overlays/WifiOverlay/res/values/config.xml b/rro_overlays/WifiOverlay/res/values/config.xml new file mode 100644 index 0000000..eed82c6 --- /dev/null +++ b/rro_overlays/WifiOverlay/res/values/config.xml @@ -0,0 +1,54 @@ + + + + + + + + true + + + true + + + true + + + true + + + true + + + false + + + true + + + 524288,2097152,4194304,262144,524288,1048576 + -- GitLab From 8b350b3cc0f033479eb474507cc2aa210578d8d0 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Sun, 1 Nov 2020 22:06:26 +0800 Subject: [PATCH 126/191] Revert "kitakami-common: Exclude lineage-sdk overlays from RRO" This reverts commit 8c91c86d937b1dd150c7cbdf8a243d010a82e5d1. --- device-common.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/device-common.mk b/device-common.mk index f2ac547..63b814b 100644 --- a/device-common.mk +++ b/device-common.mk @@ -34,7 +34,6 @@ endif PRODUCT_ENFORCE_RRO_TARGETS := * PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS += \ - $(LOCAL_PATH)/overlay/lineage-sdk \ $(LOCAL_PATH)/overlay/packages/apps/Snap/res/values # Permissions -- GitLab From 24617092a489764b7084b931dc1c1521b1c16b63 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Fri, 27 Jul 2018 09:53:51 -0700 Subject: [PATCH 127/191] kitakami-common: TetheringOverlay: Change wifi tether regex The wifi interface names for wifi can either be wlan0 or wlan1. Change the "config_tether_wifi_regexs" appropriately. Bug: 80375412 Test: Ensured we display "Hotspot on" in settings when softap is started on either wlan0 or wlan1. Change-Id: I0c456412f9b71ef2ee784f3bfa58b01b9287ca73 --- rro_overlays/TetheringOverlay/res/values/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rro_overlays/TetheringOverlay/res/values/config.xml b/rro_overlays/TetheringOverlay/res/values/config.xml index 825aacf..ce15f42 100644 --- a/rro_overlays/TetheringOverlay/res/values/config.xml +++ b/rro_overlays/TetheringOverlay/res/values/config.xml @@ -37,7 +37,7 @@ Wifi interfaces. If the device doesn't want to support tethering over Wifi this should be empty. An example would be "softap.*" --> - "wlan0" + "wlan\\d" - "wlan\\d" + "wlan0" 524288,2097152,4194304,262144,524288,1048576 + + + false -- GitLab From 9a6acaaee42acdfa38b73620c094d314321fdf65 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Sat, 17 Apr 2021 14:29:12 +0800 Subject: [PATCH 147/191] kitakami-common: Add BCM FM repo to lineage.dependencies Change-Id: Ica0b0e07a7fde6b36f8b4e2b3dffbb6421ba5b9c --- lineage.dependencies | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lineage.dependencies b/lineage.dependencies index 2009d9e..880ca01 100644 --- a/lineage.dependencies +++ b/lineage.dependencies @@ -1,4 +1,8 @@ [ + { + "repository": "android_hardware_broadcom_fm", + "target_path": "hardware/broadcom/fm" + }, { "repository": "android_hardware_sony_timekeep", "target_path": "hardware/sony/timekeep" -- GitLab From 2319835c9a982f63381b16d1062843cda4701718 Mon Sep 17 00:00:00 2001 From: Vijay Venkatraman Date: Fri, 20 Nov 2020 13:31:46 +0000 Subject: [PATCH 148/191] kitakami-common: gps: Replacing copy headers with header libraries Bug: 33241851 Test: Build target and pass CTS location tests Change-Id: I75db5e6de3c4194a6a46e0d37fcd899ea1d1db04 --- gps/core/Android.mk | 19 ++++++------------- gps/loc_api/libloc_api_50001/Android.mk | 19 +++++++++---------- gps/utils/Android.mk | 24 +++++------------------- 3 files changed, 20 insertions(+), 42 deletions(-) diff --git a/gps/core/Android.mk b/gps/core/Android.mk index 19eadd8..d4b8f75 100644 --- a/gps/core/Android.mk +++ b/gps/core/Android.mk @@ -30,18 +30,11 @@ LOCAL_C_INCLUDES:= \ $(TARGET_OUT_HEADERS)/gps.utils \ $(TARGET_OUT_HEADERS)/libflp -LOCAL_COPY_HEADERS_TO:= libloc_core/ -LOCAL_COPY_HEADERS:= \ - LocApiBase.h \ - LocAdapterBase.h \ - ContextBase.h \ - LocDualContext.h \ - LBSProxyBase.h \ - UlpProxyBase.h \ - gps_extended_c.h \ - gps_extended.h \ - loc_core_log.h \ - LocAdapterProxyBase.h \ - fused_location_extended.h +LOCAL_HEADER_LIBRARIES := libgps.utils_headers include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libloc_core_headers +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) +include $(BUILD_HEADER_LIBRARY) diff --git a/gps/loc_api/libloc_api_50001/Android.mk b/gps/loc_api/libloc_api_50001/Android.mk index 03bd12a..e27435b 100644 --- a/gps/loc_api/libloc_api_50001/Android.mk +++ b/gps/loc_api/libloc_api_50001/Android.mk @@ -42,21 +42,18 @@ LOCAL_C_INCLUDES:= \ $(LOCAL_PATH) \ $(TARGET_OUT_HEADERS)/libflp -LOCAL_COPY_HEADERS_TO:= libloc_eng/ -LOCAL_COPY_HEADERS:= \ - LocEngAdapter.h \ - loc.h \ - loc_eng.h \ - loc_eng_xtra.h \ - loc_eng_ni.h \ - loc_eng_agps.h \ - loc_eng_msg.h \ - loc_eng_log.h +LOCAL_HEADER_LIBRARIES := libgps.utils_headers libloc_core_headers include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) +LOCAL_MODULE := libloc_eng_headers +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) +include $(BUILD_HEADER_LIBRARY) + +include $(CLEAR_VARS) + LOCAL_MODULE := gps.$(TARGET_BOARD_PLATFORM) LOCAL_MODULE_OWNER := qcom LOCAL_VENDOR_MODULE := true @@ -89,4 +86,6 @@ LOCAL_C_INCLUDES:= \ LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_HEADER_LIBRARIES := libgps.utils_headers libloc_core_headers + include $(BUILD_SHARED_LIBRARY) diff --git a/gps/utils/Android.mk b/gps/utils/Android.mk index 7b304df..54d0ea7 100644 --- a/gps/utils/Android.mk +++ b/gps/utils/Android.mk @@ -36,25 +36,6 @@ LOCAL_LDFLAGS += -Wl,--export-dynamic LOCAL_C_INCLUDES:= \ $(LOCAL_PATH)/platform_lib_abstractions -LOCAL_COPY_HEADERS_TO:= gps.utils/ -LOCAL_COPY_HEADERS:= \ - loc_log.h \ - loc_cfg.h \ - log_util.h \ - linked_list.h \ - msg_q.h \ - MsgTask.h \ - LocHeap.h \ - LocThread.h \ - LocTimer.h \ - loc_target.h \ - loc_timer.h \ - LocSharedLock.h \ - platform_lib_abstractions/platform_lib_includes.h \ - platform_lib_abstractions/platform_lib_time.h \ - platform_lib_abstractions/platform_lib_macros.h \ - loc_misc_utils.h - LOCAL_MODULE := libgps.utils LOCAL_MODULE_OWNER := qcom LOCAL_VENDOR_MODULE := true @@ -62,3 +43,8 @@ LOCAL_VENDOR_MODULE := true LOCAL_MODULE_TAGS := optional include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libgps.utils_headers +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) $(LOCAL_PATH)/platform_lib_abstractions +include $(BUILD_HEADER_LIBRARY) -- GitLab From 7aa7d3c23a9422207b9e3270add4aa8f6dfed196 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sun, 18 Apr 2021 18:41:41 +0200 Subject: [PATCH 149/191] kitakami-common: Using CPU variant "cortex-a53" instead of "generic". Change-Id: Ifc823d3addb08afca9cf06c24c79bb5fa58c9dd6 --- BoardConfigCommon.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index b20ef46..f130422 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -34,13 +34,13 @@ TARGET_ARCH := arm64 TARGET_ARCH_VARIANT := armv8-a TARGET_CPU_ABI := arm64-v8a TARGET_CPU_ABI2 := -TARGET_CPU_VARIANT := generic +TARGET_CPU_VARIANT := cortex-a53 TARGET_2ND_ARCH := arm TARGET_2ND_ARCH_VARIANT := armv8-a TARGET_2ND_CPU_ABI := armeabi-v7a TARGET_2ND_CPU_ABI2 := armeabi -TARGET_2ND_CPU_VARIANT := generic +TARGET_2ND_CPU_VARIANT := cortex-a53 TARGET_2ND_CPU_VARIANT_RUNTIME := cortex-a53 TARGET_USES_64_BIT_BINDER := true -- GitLab From 2ff89a4b1a1ced2fdb6b5b11c7f935c36bf8da48 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Sun, 18 Apr 2021 02:52:11 +0800 Subject: [PATCH 150/191] Revert "kitakami-common: Add build broken flags in BoardConfig.mk" This reverts commit 1284b10432609892d9f73100a0aecf1da21f0620. --- BoardConfigCommon.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index f130422..3bedaf3 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -47,7 +47,6 @@ TARGET_USES_64_BIT_BINDER := true TARGET_USES_64_BIT_BCMDHD := true ENABLE_CPUSETS := true -BUILD_BROKEN_USES_BUILD_COPY_HEADERS := true # Boot image/kernel BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-5 loop.max_part=7 dwc3_msm.hvdcp_max_current=1500 dwc3_msm.prop_chg_detect=Y coherent_pool=2M swiotlb=2048 -- GitLab From 85cb24c72b34c60d60d418492a34e6c7a52d5f3c Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Mon, 19 Apr 2021 17:54:21 +0200 Subject: [PATCH 151/191] kitakami-common: sepolicy: Allowed mediaserver to access camera properties. Change-Id: I34242285ec72e1e9102cf519506d68cf68b4871e --- sepolicy/vendor/mediaserver.te | 1 + 1 file changed, 1 insertion(+) create mode 100644 sepolicy/vendor/mediaserver.te diff --git a/sepolicy/vendor/mediaserver.te b/sepolicy/vendor/mediaserver.te new file mode 100644 index 0000000..f43c7c2 --- /dev/null +++ b/sepolicy/vendor/mediaserver.te @@ -0,0 +1 @@ +allow mediaserver exported_camera_prop:file r_file_perms; -- GitLab From f70e6f7cf9b76040fff04ea4afb352facf396597 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Thu, 29 Apr 2021 12:39:15 +0200 Subject: [PATCH 152/191] kitakami-common: audio: Changed file audio_effects.xml to reduce echo in phone calls. Change-Id: I98d3a70aa3c277cdc94c2dbb0fc41d1b39876da1 --- audio/audio_effects.xml | 58 +++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/audio/audio_effects.xml b/audio/audio_effects.xml index 3b87058..ced294b 100644 --- a/audio/audio_effects.xml +++ b/audio/audio_effects.xml @@ -3,31 +3,51 @@ - + + - - - - + + + - - - + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - + + -- GitLab From bf60d14ef3ed6670a4ceb7d34bf005480d3a1683 Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Thu, 29 Apr 2021 18:50:10 +0200 Subject: [PATCH 153/191] kitakami-common: Switched to globally used variables. Change-Id: I06b9acfa497ea2290e8032e2ed76d061a8e4fdd2 --- device-common.mk | 22 +++++++++++----------- radio.mk | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/device-common.mk b/device-common.mk index a49ebb6..77f57da 100644 --- a/device-common.mk +++ b/device-common.mk @@ -121,7 +121,7 @@ PRODUCT_COPY_FILES += \ # Bluetooth PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/bluetooth/bt_vendor.conf:system/etc/bluetooth/bt_vendor.conf + $(LOCAL_PATH)/bluetooth/bt_vendor.conf:$(TARGET_COPY_OUT_SYSTEM)/etc/bluetooth/bt_vendor.conf PRODUCT_PACKAGES += \ android.hardware.bluetooth@1.0-impl \ @@ -201,7 +201,7 @@ PRODUCT_PACKAGES += \ # Flash LED config PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/configs/flashled_calc_parameters.cfg:system/etc/flashled_calc_parameters.cfg + $(LOCAL_PATH)/configs/flashled_calc_parameters.cfg:$(TARGET_COPY_OUT_SYSTEM)/etc/flashled_calc_parameters.cfg # Health HAL PRODUCT_PACKAGES += \ @@ -217,18 +217,18 @@ PRODUCT_PACKAGES += \ # Init PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/rootdir/fstab.qcom:root/fstab.qcom \ - $(LOCAL_PATH)/rootdir/init.qcom.usb.rc:root/init.qcom.usb.rc \ - $(LOCAL_PATH)/rootdir/init.qcom.rc:root/init.qcom.rc \ - $(LOCAL_PATH)/rootdir/ueventd.qcom.rc:root/ueventd.qcom.rc + $(LOCAL_PATH)/rootdir/fstab.qcom:$(TARGET_COPY_OUT_ROOT)/fstab.qcom \ + $(LOCAL_PATH)/rootdir/init.qcom.usb.rc:$(TARGET_COPY_OUT_ROOT)/init.qcom.usb.rc \ + $(LOCAL_PATH)/rootdir/init.qcom.rc:$(TARGET_COPY_OUT_ROOT)/init.qcom.rc \ + $(LOCAL_PATH)/rootdir/ueventd.qcom.rc:$(TARGET_COPY_OUT_ROOT)/ueventd.qcom.rc # Input PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/keylayout/clearpad.kl:system/usr/keylayout/clearpad.kl \ - $(LOCAL_PATH)/keylayout/gpio-keys.kl:system/usr/keylayout/gpio-keys.kl \ - $(LOCAL_PATH)/keylayout/mhl-rcp.kl:system/usr/keylayout/mhl-rcp.kl \ - $(LOCAL_PATH)/keylayout/msm8994-tomtom-snd-card_Button_Jack.kl:system/usr/keylayout/msm8994-tomtom-snd-card_Button_Jack.kl \ - $(LOCAL_PATH)/keylayout/synaptics_dsx.kl:system/usr/keylayout/synaptics_dsx.kl + $(LOCAL_PATH)/keylayout/clearpad.kl:$(TARGET_COPY_OUT_SYSTEM)/usr/keylayout/clearpad.kl \ + $(LOCAL_PATH)/keylayout/gpio-keys.kl:$(TARGET_COPY_OUT_SYSTEM)/usr/keylayout/gpio-keys.kl \ + $(LOCAL_PATH)/keylayout/mhl-rcp.kl:$(TARGET_COPY_OUT_SYSTEM)/usr/keylayout/mhl-rcp.kl \ + $(LOCAL_PATH)/keylayout/msm8994-tomtom-snd-card_Button_Jack.kl:$(TARGET_COPY_OUT_SYSTEM)/usr/keylayout/msm8994-tomtom-snd-card_Button_Jack.kl \ + $(LOCAL_PATH)/keylayout/synaptics_dsx.kl:$(TARGET_COPY_OUT_SYSTEM)/usr/keylayout/synaptics_dsx.kl # IRQ PRODUCT_COPY_FILES += \ diff --git a/radio.mk b/radio.mk index 23d3aa0..e62f9cb 100644 --- a/radio.mk +++ b/radio.mk @@ -16,7 +16,7 @@ # Permissions PRODUCT_COPY_FILES += \ - frameworks/native/data/etc/android.hardware.telephony.gsm.xml:system/etc/permissions/android.hardware.telephony.gsm.xml + frameworks/native/data/etc/android.hardware.telephony.gsm.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/permissions/android.hardware.telephony.gsm.xml # Properties PRODUCT_PROPERTY_OVERRIDES += \ -- GitLab From 384a00d489f843b0be380d4b57470ec93adf5460 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Mon, 3 May 2021 20:06:06 +0800 Subject: [PATCH 154/191] kitakami-common: sepolicy: Address sdcard denials Change-Id: Ia32ca0b33be270a0ad489484ca8f37d30b12b9f9 --- sepolicy/vendor/fsck.te | 2 ++ sepolicy/vendor/vold.te | 1 + 2 files changed, 3 insertions(+) diff --git a/sepolicy/vendor/fsck.te b/sepolicy/vendor/fsck.te index 4e4487f..6521919 100644 --- a/sepolicy/vendor/fsck.te +++ b/sepolicy/vendor/fsck.te @@ -1,2 +1,4 @@ allow fsck block_device:blk_file rw_file_perms; allow fsck diag_partition_device:blk_file rw_file_perms; +allow fsck media_rw_data_file:dir getattr; +allow fsck tmpfs:blk_file rw_file_perms; diff --git a/sepolicy/vendor/vold.te b/sepolicy/vendor/vold.te index 2fb570a..f85fa14 100644 --- a/sepolicy/vendor/vold.te +++ b/sepolicy/vendor/vold.te @@ -1,3 +1,4 @@ +allow vold block_device:blk_file getattr; allow vold diag_data_file:dir r_file_perms; allow vold hal_bootctl_hwservice:hwservice_manager find; allow vold sysfs_mmc_host:file write; -- GitLab From 1174d72d5d2308200a96300f2203a124f9d2e5db Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Sun, 9 May 2021 20:15:24 +0200 Subject: [PATCH 155/191] kitakami-common: sepolicy: Allowed platform_app to access audio properties. Change-Id: Ib4d1682d2f469442e4c5ac7650e57903d27c85df --- sepolicy/vendor/platform_app.te | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sepolicy/vendor/platform_app.te b/sepolicy/vendor/platform_app.te index 97c9d6b..3e4f925 100644 --- a/sepolicy/vendor/platform_app.te +++ b/sepolicy/vendor/platform_app.te @@ -1,2 +1,3 @@ -allow platform_app exported_camera_prop:file read; +allow platform_app exported_audio_prop:file r_file_perms; +allow platform_app exported_camera_prop:file r_file_perms; allow platform_app system_app_data_file:dir getattr; -- GitLab From 440bc0e62602a74f5ed7263cd928d8b8abf9f8fa Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Mon, 29 Jan 2018 00:55:25 +0100 Subject: [PATCH 156/191] kitakami-common: audio: Disable ULL mode * Ultra low latency playback is currently broken. Crackling audio can be well noticed while playing WhatsApp audio messages or even during some games. * This patch routes all audio that normally used audio-ull-playback paths to low-latency-playback paths instead, thus meaning we're switching from ULL to LL mode. Change-Id: I1f029d7df9a306f411598b0cffc536409cb2ae95 --- audio/audio_policy_configuration.xml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/audio/audio_policy_configuration.xml b/audio/audio_policy_configuration.xml index 8f6aa8c..191a1a2 100644 --- a/audio/audio_policy_configuration.xml +++ b/audio/audio_policy_configuration.xml @@ -63,10 +63,6 @@ - - - + sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx,BT SCO Headset Mic"/> + sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx,BT SCO Headset Mic,Telephony Rx"/> + sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx,BT SCO Headset Mic,Telephony Rx"/> + sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx,BT SCO Headset Mic,Telephony Rx"/> + sources="primary output,deep_buffer,direct_pcm,compressed_offload"/> + sources="primary output,deep_buffer,direct_pcm,compressed_offload"/> + sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx"/> + sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx"/> + sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx"/> Date: Sat, 12 Oct 2019 10:12:37 +0800 Subject: [PATCH 157/191] kitakami-common: Enable AOSP bluetooth audio HAL v2 Change-Id: I4d12752ae5fb2829d6612647c8740c84967f5434 --- audio/audio_policy_configuration.xml | 7 +++++-- device-common.mk | 5 ++++- manifest.xml | 9 +++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/audio/audio_policy_configuration.xml b/audio/audio_policy_configuration.xml index 191a1a2..1cd7ecd 100644 --- a/audio/audio_policy_configuration.xml +++ b/audio/audio_policy_configuration.xml @@ -268,8 +268,8 @@ - - + + @@ -277,6 +277,9 @@ + + + diff --git a/device-common.mk b/device-common.mk index 77f57da..6a78714 100644 --- a/device-common.mk +++ b/device-common.mk @@ -77,6 +77,7 @@ PRODUCT_COPY_FILES += \ # Audio PRODUCT_PACKAGES += \ + audio.bluetooth.default \ android.hardware.audio@2.0-impl \ android.hardware.audio@6.0-impl \ android.hardware.audio.common@6.0 \ @@ -84,6 +85,7 @@ PRODUCT_PACKAGES += \ android.hardware.audio@2.0-service \ android.hardware.audio.effect@2.0-impl \ android.hardware.audio.effect@6.0-impl \ + android.hardware.bluetooth.audio@2.0-impl \ audiod \ audio.a2dp.default \ audio.primary.msm8994 \ @@ -113,7 +115,8 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml PRODUCT_COPY_FILES += \ - frameworks/av/services/audiopolicy/config/a2dp_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_audio_policy_configuration.xml \ + frameworks/av/services/audiopolicy/config/a2dp_in_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_in_audio_policy_configuration.xml \ + frameworks/av/services/audiopolicy/config/bluetooth_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/bluetooth_audio_policy_configuration.xml \ frameworks/av/services/audiopolicy/config/audio_policy_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_volumes.xml \ frameworks/av/services/audiopolicy/config/default_volume_tables.xml:$(TARGET_COPY_OUT_VENDOR)/etc/default_volume_tables.xml \ frameworks/av/services/audiopolicy/config/r_submix_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/r_submix_audio_policy_configuration.xml \ diff --git a/manifest.xml b/manifest.xml index b3b8cf3..afb4505 100644 --- a/manifest.xml +++ b/manifest.xml @@ -26,6 +26,15 @@ default + + android.hardware.bluetooth.audio + hwbinder + 2.0 + + IBluetoothAudioProvidersFactory + default + + android.hardware.camera.provider passthrough -- GitLab From 8eaef3d499f11c5f0956ffc0fc40a89f2a23c89a Mon Sep 17 00:00:00 2001 From: Bernhard Thoben Date: Tue, 1 Jun 2021 18:39:26 +0200 Subject: [PATCH 158/191] Revert "Revert "kitakami-common: Changed wifi HAL to avoid using of fake wifi addresses."" This reverts commit 85af80e3b3dffeca8af052b4c66f6e208933c4b8. --- device-common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device-common.mk b/device-common.mk index 6a78714..26f68c1 100644 --- a/device-common.mk +++ b/device-common.mk @@ -372,7 +372,7 @@ PRODUCT_PACKAGES += \ # Wifi PRODUCT_PACKAGES += \ - android.hardware.wifi@1.0-service \ + android.hardware.wifi@1.0-service.legacy \ hostapd \ libwpa_client \ WifiOverlay \ -- GitLab From ea4e9a3b1815025e486c79ca333dfc398f097c9a Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Thu, 22 Apr 2021 00:53:36 +0800 Subject: [PATCH 159/191] Revert "kitikami-common: Revert IMS changes" This reverts commit 24c28e308bb63a4de40cddfe5e638592a2a92414. Change-Id: I16250b43954f947524a0074226a2666e9cdcbd6f --- Android.mk | 12 +- BoardConfigCommon.mk | 4 +- config.fs | 12 ++ configs/privapp-permissions-qti.xml | 6 + configs/qti_whitelist.xml | 37 ++++++ device-common.mk | 5 + libshim/Android.mk | 32 +++++ libshim/boringssl/cipher.c | 66 ++++++++++ libshim/boringssl/cleanup.c | 9 ++ libshim/boringssl/ctrl.c | 5 + libshim/boringssl/e_des.c | 98 ++++++++++++++ libshim/boringssl/evp.h | 32 +++++ libshim/boringssl/p_dec.c | 87 +++++++++++++ libshim/boringssl/p_open.c | 121 ++++++++++++++++++ libshim/libshim_mediabuffer.cpp | 28 ++++ .../base/core/res/res/values/config.xml | 11 ++ proprietary-files-radio.txt | 33 +++++ radio.mk | 28 +++- rootdir/init.qcom.rc | 39 ++++++ sepolicy/vendor/file.te | 2 + sepolicy/vendor/file_contexts | 3 + sepolicy/vendor/ims.te | 1 + sepolicy/vendor/property_contexts | 1 + sepolicy/vendor/radio.te | 8 ++ sepolicy/vendor/service_contexts | 1 + system.prop | 2 + 26 files changed, 680 insertions(+), 3 deletions(-) create mode 100644 configs/privapp-permissions-qti.xml create mode 100644 configs/qti_whitelist.xml create mode 100644 libshim/boringssl/cipher.c create mode 100644 libshim/boringssl/cleanup.c create mode 100644 libshim/boringssl/ctrl.c create mode 100644 libshim/boringssl/e_des.c create mode 100644 libshim/boringssl/evp.h create mode 100644 libshim/boringssl/p_dec.c create mode 100644 libshim/boringssl/p_open.c create mode 100644 libshim/libshim_mediabuffer.cpp create mode 100644 sepolicy/vendor/ims.te create mode 100644 sepolicy/vendor/radio.te diff --git a/Android.mk b/Android.mk index 120f684..7f44d12 100644 --- a/Android.mk +++ b/Android.mk @@ -100,6 +100,16 @@ $(MODEM_SYMLINKS): $(LOCAL_INSTALLED_MODULE) ALL_DEFAULT_INSTALLED_MODULES += $(MODEM_SYMLINKS) +IMS_LIBS := libimscamera_jni.so libimsmedia_jni.so +IMS_SYMLINKS := $(addprefix $(TARGET_OUT_VENDOR_APPS)/ims/lib/arm64/,$(notdir $(IMS_LIBS))) +$(IMS_SYMLINKS): $(LOCAL_INSTALLED_MODULE) + @echo "IMS lib link: $@" + @mkdir -p $(dir $@) + @rm -rf $@ + $(hide) ln -sf /system/vendor/lib64/$(notdir $@) $@ + +ALL_DEFAULT_INSTALLED_MODULES += $(IMS_SYMLINKS) + # Create links for audcal data files $(shell mkdir -p $(TARGET_OUT)/etc/firmware/wcd9320; \ ln -sf /data/misc/audio/mbhc.bin \ @@ -109,4 +119,4 @@ $(shell mkdir -p $(TARGET_OUT)/etc/firmware/wcd9320; \ ln -sf /data/misc/audio/wcd9320_mad_audio.bin \ $(TARGET_OUT_ETC)/firmware/wcd9320/wcd9320_mad_audio.bin) -endif \ No newline at end of file +endif diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 3bedaf3..63f587d 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -202,7 +202,9 @@ TARGET_LD_SHIM_LIBS := \ /system/lib64/libsys-utils.so|libsensor.so \ /system/lib/libcammw.so|libsensor.so \ /system/bin/secd|/system/lib64/lib-preload64.so \ - /system/vendor/lib64/libril-qc-qmi-1.so|libaudioclient_shim.so + /system/vendor/lib64/libril-qc-qmi-1.so|libaudioclient_shim.so \ + /system/vendor/lib64/lib-imsvt.so|libshims_ims.so \ + /system/vendor/lib64/lib-imsdpl.so|libshims_boringssl.so # SELinux include device/qcom/sepolicy-legacy/sepolicy.mk diff --git a/config.fs b/config.fs index 9a67652..c8d3166 100644 --- a/config.fs +++ b/config.fs @@ -24,3 +24,15 @@ value: 2997 [AID_VENDOR_TA_QMI] value: 2998 + +[system/vendor/bin/imsdatadaemon] +mode: 0755 +user: AID_SYSTEM +group: AID_SYSTEM +caps: NET_BIND_SERVICE + +[system/vendor/bin/ims_rtp_daemon] +mode: 0755 +user: AID_SYSTEM +group: AID_RADIO +caps: NET_BIND_SERVICE diff --git a/configs/privapp-permissions-qti.xml b/configs/privapp-permissions-qti.xml new file mode 100644 index 0000000..04dfb19 --- /dev/null +++ b/configs/privapp-permissions-qti.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/configs/qti_whitelist.xml b/configs/qti_whitelist.xml new file mode 100644 index 0000000..e1cf789 --- /dev/null +++ b/configs/qti_whitelist.xml @@ -0,0 +1,37 @@ + + + + + + + + + diff --git a/device-common.mk b/device-common.mk index 26f68c1..6fdcd50 100644 --- a/device-common.mk +++ b/device-common.mk @@ -218,6 +218,11 @@ PRODUCT_PACKAGES += \ libhwbinder \ libhwbinder.vendor +# IMS +PRODUCT_PACKAGES += \ + libshims_ims \ + libshims_boringssl + # Init PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/rootdir/fstab.qcom:$(TARGET_COPY_OUT_ROOT)/fstab.qcom \ diff --git a/libshim/Android.mk b/libshim/Android.mk index d351c2d..085c6c5 100644 --- a/libshim/Android.mk +++ b/libshim/Android.mk @@ -57,3 +57,35 @@ LOCAL_SHARED_LIBRARIES := libaudioclient LOCAL_VENDOR_MODULE := true include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := libshim_mediabuffer.cpp + +LOCAL_SHARED_LIBRARIES := libstagefright_foundation libui libgui libmedia + +LOCAL_MODULE := libshims_ims +LOCAL_MODULE_TAGS := optional +LOCAL_MULTILIB := 64 +LOCAL_VENDOR_MODULE := true + +include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + boringssl/p_dec.c \ + boringssl/p_open.c \ + boringssl/cipher.c \ + boringssl/e_des.c \ + boringssl/cleanup.c \ + boringssl/ctrl.c + +LOCAL_CFLAGS += -std=c99 +LOCAL_C_INCLUDES := boringssl +LOCAL_SHARED_LIBRARIES := libcrypto +LOCAL_MODULE := libshims_boringssl +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := SHARED_LIBRARIES + +include $(BUILD_SHARED_LIBRARY) diff --git a/libshim/boringssl/cipher.c b/libshim/boringssl/cipher.c new file mode 100644 index 0000000..c59c4cf --- /dev/null +++ b/libshim/boringssl/cipher.c @@ -0,0 +1,66 @@ +/* crypto/cipher.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] */ + +#include + +int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len) { + return EVP_EncryptFinal_ex(ctx, out, out_len); +} + +int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len) { + return EVP_DecryptFinal_ex(ctx, out, out_len); +} diff --git a/libshim/boringssl/cleanup.c b/libshim/boringssl/cleanup.c new file mode 100644 index 0000000..d1955f4 --- /dev/null +++ b/libshim/boringssl/cleanup.c @@ -0,0 +1,9 @@ +/* A bad code just to make lib-imsdpl.so happy */ + +void ENGINE_cleanup(void) { + return; +} + +void OBJ_cleanup(void) { + return; +} diff --git a/libshim/boringssl/ctrl.c b/libshim/boringssl/ctrl.c new file mode 100644 index 0000000..e04d246 --- /dev/null +++ b/libshim/boringssl/ctrl.c @@ -0,0 +1,5 @@ +/* A bad code just to make lib-imsdpl.so happy */ + +void SSL_ctrl(void) { + return; +} diff --git a/libshim/boringssl/e_des.c b/libshim/boringssl/e_des.c new file mode 100644 index 0000000..28185cc --- /dev/null +++ b/libshim/boringssl/e_des.c @@ -0,0 +1,98 @@ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] */ + +#include +#include +#include + +typedef struct { + union { + double align; + DES_key_schedule ks; + } ks; +} EVP_DES_KEY; + +static int des_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key, + const uint8_t *iv, int enc) { + DES_cblock *deskey = (DES_cblock *)key; + EVP_DES_KEY *dat = (EVP_DES_KEY *)ctx->cipher_data; + + DES_set_key(deskey, &dat->ks.ks); + return 1; +} + +static int des_ecb_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, + size_t in_len) { + if (in_len < ctx->cipher->block_size) { + return 1; + } + in_len -= ctx->cipher->block_size; + + EVP_DES_KEY *dat = (EVP_DES_KEY *) ctx->cipher_data; + for (size_t i = 0; i <= in_len; i += ctx->cipher->block_size) { + DES_ecb_encrypt((DES_cblock *) (in + i), (DES_cblock *) (out + i), + &dat->ks.ks, ctx->encrypt); + } + return 1; +} + +static const EVP_CIPHER des_ecb = { + NID_des_ecb, 8 /* block_size */, 8 /* key_size */, + 0 /* iv_len */, sizeof(EVP_DES_KEY), EVP_CIPH_ECB_MODE, + NULL /* app_data */, des_init_key, des_ecb_cipher, + NULL /* cleanup */, NULL /* ctrl */, }; + +const EVP_CIPHER *EVP_des_ecb(void) { return &des_ecb; } diff --git a/libshim/boringssl/evp.h b/libshim/boringssl/evp.h new file mode 100644 index 0000000..a9ca800 --- /dev/null +++ b/libshim/boringssl/evp.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2015 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#define EVP_CIPH_RAND_KEY 0x200 + +#define EVP_F_EVP_OPENINIT 102 +#define EVP_R_PUBLIC_KEY_NOT_RSA 106 +#define EVP_F_EVP_PKEY_ENCRYPT_OLD 152 + +#define EVPerr(f,r) void + +int EVP_PKEY_decrypt_old(unsigned char *dec_key, + const unsigned char *enc_key,int enc_key_len, + EVP_PKEY *private_key); +int EVP_PKEY_encrypt_old(unsigned char *enc_key, + const unsigned char *key,int key_len, + EVP_PKEY *pub_key); diff --git a/libshim/boringssl/p_dec.c b/libshim/boringssl/p_dec.c new file mode 100644 index 0000000..5d9fe6c --- /dev/null +++ b/libshim/boringssl/p_dec.c @@ -0,0 +1,87 @@ +/* crypto/evp/p_dec.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +//#include "cryptlib.h" +#include "evp.h" +#include +#ifndef OPENSSL_NO_RSA +#include +#endif +#include +#include +#include + +int EVP_PKEY_decrypt_old(unsigned char *key, const unsigned char *ek, int ekl, + EVP_PKEY *priv) + { + int ret= -1; + +#ifndef OPENSSL_NO_RSA + if (priv->type != EVP_PKEY_RSA) + { +#endif + EVPerr(EVP_F_EVP_PKEY_DECRYPT_OLD,EVP_R_PUBLIC_KEY_NOT_RSA); +#ifndef OPENSSL_NO_RSA + goto err; + } + ret=RSA_private_decrypt(ekl,ek,key,priv->pkey.rsa,RSA_PKCS1_PADDING); +err: +#endif + return(ret); + } diff --git a/libshim/boringssl/p_open.c b/libshim/boringssl/p_open.c new file mode 100644 index 0000000..1b9730a --- /dev/null +++ b/libshim/boringssl/p_open.c @@ -0,0 +1,121 @@ +/* crypto/evp/p_open.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +//#include "cryptlib.h" +#include "evp.h" +#ifndef OPENSSL_NO_RSA + +#include +#include +#include +#include +#include +#include +#include + +int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, + const unsigned char *ek, int ekl, const unsigned char *iv, + EVP_PKEY *priv) + { + unsigned char *key=NULL; + int i,size=0,ret=0; + + if(type) { + EVP_CIPHER_CTX_init(ctx); + if(!EVP_DecryptInit_ex(ctx,type,NULL, NULL,NULL)) return 0; + } + + if(!priv) return 1; + + if (priv->type != EVP_PKEY_RSA) + { + EVPerr(EVP_F_EVP_OPENINIT,EVP_R_PUBLIC_KEY_NOT_RSA); + goto err; + } + + size=RSA_size(priv->pkey.rsa); + key=(unsigned char *)OPENSSL_malloc(size+2); + if (key == NULL) + { + /* ERROR */ + EVPerr(EVP_F_EVP_OPENINIT,ERR_R_MALLOC_FAILURE); + goto err; + } + + i=EVP_PKEY_decrypt_old(key,ek,ekl,priv); + if ((i <= 0) || !EVP_CIPHER_CTX_set_key_length(ctx, i)) + { + /* ERROR */ + goto err; + } + if(!EVP_DecryptInit_ex(ctx,NULL,NULL,key,iv)) goto err; + + ret=1; +err: + if (key != NULL) OPENSSL_cleanse(key,size); + OPENSSL_free(key); + return(ret); + } +#else /* !OPENSSL_NO_RSA */ + +# ifdef PEDANTIC +static void *dummy=&dummy; +# endif + +#endif diff --git a/libshim/libshim_mediabuffer.cpp b/libshim/libshim_mediabuffer.cpp new file mode 100644 index 0000000..8d44f30 --- /dev/null +++ b/libshim/libshim_mediabuffer.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2016 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +extern "C" { + +int _ZNK7android11MediaBuffer8refcountEv(android::MediaBuffer *thisptr) { + return thisptr->refcount(); +} + +void _ZN7android13GraphicBuffer4lockEjPPv() {} +void _ZNK7android11MediaBuffer13graphicBufferEv() {} +} diff --git a/overlay-radio/frameworks/base/core/res/res/values/config.xml b/overlay-radio/frameworks/base/core/res/res/values/config.xml index fdb91fd..b8d620f 100644 --- a/overlay-radio/frameworks/base/core/res/res/values/config.xml +++ b/overlay-radio/frameworks/base/core/res/res/values/config.xml @@ -70,4 +70,15 @@ 0,1 7,1 + + + true + true + true + + + true + true diff --git a/proprietary-files-radio.txt b/proprietary-files-radio.txt index 080656d..ced5f77 100644 --- a/proprietary-files-radio.txt +++ b/proprietary-files-radio.txt @@ -66,3 +66,36 @@ vendor/lib/libsmemlog.so vendor/lib/libsubsystem_control.so vendor/lib/libwqe.so|04e000f40eabee3fc333c5726d8f7720c7e1a144 vendor/lib/libxml.so + +# Radio - IMS - MIUI Hydrogen 7.7.6 global dev +bin/ims_rtp_daemon:vendor/bin/ims_rtp_daemon|896a7d67d73f9c0ef0f48f86af0e055737c781df +bin/imscmservice:vendor/bin/imscmservice|c606b123bdd105866947a9ae19aab05349ad2dfd +bin/imsdatadaemon:vendor/bin/imsdatadaemon|2aa4067b74fe525411984f87666d81c5b6b575d3 +bin/imsqmidaemon:vendor/bin/imsqmidaemon|88886668eda7b7303b4a7aefd5b8b3fbffd81b02 +etc/permissions/imscm.xml|8b99ec26c783966bbea1fcb8e72c7c0206a4e802 +framework/imscmlibrary.jar|0c24d6540c06efede52169c1445272f43748180f +framework/rcsimssettings.jar|566a0f637344ca3182aca33753e404977fc77ecc +-vendor/app/ims/ims.apk|0f9f714e31305dc293aa3e72ba19d24e8a6b11ae +-vendor/app/imssettings/imssettings.apk|cd206ecfdf8b9c738823104e13672707cb48ffd1 +vendor/lib64/lib-dplmedia.so|45de23a1bf2c758e71556b88fa01e1f705775b96 +vendor/lib64/lib-ims-rcscmjni.so|57a7cffdf589247b7fa38082418076e491b306ca +vendor/lib64/lib-imsSDP.so|addec91cf24280784f619433e325bcb84ac11d5d +vendor/lib64/lib-imscamera.so|ed32d843da1895fc83dfc1690d958591ab942b59 +vendor/lib64/lib-imsdpl.so|4b60872a3fec6322eb8b59ad615f1500e595a3d3 +vendor/lib64/lib-imsqimf.so|021edce0c81ba25d9b4510befd35768314858428 +vendor/lib64/lib-imsrcs.so|31fc1549c4a489489e20efda496567ee51e72ca9 +vendor/lib64/lib-imsrcscm.so|f783e1ea0dfa84392e92bd00d79b6be9fe4fdc1a +vendor/lib64/lib-imsrcscmclient.so|5a24f31ed2bd8ebcca68583b2750c3fe9fc8a0b0 +vendor/lib64/lib-imsrcscmservice.so|3cbb7c5437eaea86fab6db8cddce05c3a0b15852 +vendor/lib64/lib-imss.so|f3bc1038d5720da58d1d1eb8e1ed6cec4ad93db4 +vendor/lib64/lib-imsvt.so|52d4ed0e15156e20adfb409eeb2a983108a1357b +vendor/lib64/lib-imsxml.so|babc9429f0291038b6161b212935e03363d5d921 +vendor/lib64/lib-rcsimssjni.so|80faffa65b5060c208fd4bc0085eebf7615fbb3a +vendor/lib64/lib-rtpcommon.so|16d49c1c1475a4fe9b3d2f7632bc4f199a87c4ce +vendor/lib64/lib-rtpcore.so|7ebfa9d640984dbee4e5287a86883c991089497a +vendor/lib64/lib-rtpdaemoninterface.so|f1f72a6a131830d3c71405362e975f61bb53386f +vendor/lib64/lib-rtpsl.so|6a7f9f2fc38c210ffa9235bb0d61e18b6871a5dd +vendor/lib64/libimscamera_jni.so|53000f12da581742742fbf80a2d46616d4b4283e +vendor/lib64/libimsmedia_jni.so|35be419f4fabc1e2388c7cc01e95442f1f90e833 +vendor/lib64/librcc.so|661771f4b6c5f26037cc0fb5de83a86c08023995 +vendor/lib64/libvoice-svc.so|238f774a4d0748c40569f6c3c48a87578f79c265 diff --git a/radio.mk b/radio.mk index e62f9cb..320d2b3 100644 --- a/radio.mk +++ b/radio.mk @@ -16,7 +16,33 @@ # Permissions PRODUCT_COPY_FILES += \ - frameworks/native/data/etc/android.hardware.telephony.gsm.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/permissions/android.hardware.telephony.gsm.xml + frameworks/native/data/etc/android.hardware.telephony.gsm.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.telephony.gsm.xml \ + frameworks/native/data/etc/android.hardware.telephony.ims.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.telephony.ims.xml + +# RCS +PRODUCT_PACKAGES += \ + rcs_service_aidl \ + rcs_service_aidl.xml \ + rcs_service_api \ + rcs_service_api.xml + +# Telephony +PRODUCT_PACKAGES += \ + ims-ext-common \ + ims_ext_common.xml \ + qti-telephony-hidl-wrapper \ + qti_telephony_hidl_wrapper.xml \ + telephony-ext + +PRODUCT_BOOT_JARS += \ + telephony-ext + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/configs/qti_whitelist.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/sysconfig/qti_whitelist.xml + +# Privapp Whitelist +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/configs/privapp-permissions-qti.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/permissions/privapp-permissions-qti.xml # Properties PRODUCT_PROPERTY_OVERRIDES += \ diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index 02949ab..2c43c2e 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -499,6 +499,45 @@ on post-fs-data setprop vold.post_fs_data_done 1 +service imsqmidaemon /system/vendor/bin/imsqmidaemon + class main + user system + socket ims_qmid stream 0660 system radio + group radio log diag + +service imsdatadaemon /system/vendor/bin/imsdatadaemon + class main + user system + socket ims_datad stream 0660 system radio + group system wifi radio inet log diag + disabled + +on property:sys.ims.QMI_DAEMON_STATUS=1 + start imsdatadaemon + +service ims_rtp_daemon /system/vendor/bin/ims_rtp_daemon + class main + user system + socket ims_rtpd stream 0660 system radio + group radio diag inet log + disabled + +on property:sys.ims.DATA_DAEMON_STATUS=1 + start ims_rtp_daemon + +service imscmservice /system/vendor/bin/imscmservice + class main + user system + group radio diag log + +service ims_regmanager /system/bin/exe-ims-regmanagerprocessnative + class late_start + group net_bt_admin inet radio wifi + disabled + +on property:persist.ims.regmanager.mode=1 + start ims_regmanager + service irsc_util /system/bin/irsc_util "/etc/sec_config" class main user root diff --git a/sepolicy/vendor/file.te b/sepolicy/vendor/file.te index 28cc021..548eb13 100644 --- a/sepolicy/vendor/file.te +++ b/sepolicy/vendor/file.te @@ -5,7 +5,9 @@ type mediadrm_vendor_data_file, file_type, data_file_type; type secd_data_file, file_type; type secd_socket, file_type; type sysfs_addrsetup, fs_type, sysfs_type; +type sysfs_camera, sysfs_type, fs_type; type sysfs_camera_torch, sysfs_type, file_type; +type sysfs_msm_subsys, sysfs_type, fs_type; type sysfs_performance, sysfs_type, file_type; type sysfs_timekeep, fs_type, sysfs_type; type tad_socket, file_type; diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 2027e42..30623e1 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -89,6 +89,9 @@ /system/bin/taimport u:object_r:taimport_exec:s0 /system/bin/ta_qmi_service u:object_r:ta_qmi_service_exec:s0 /system/bin/updatemiscta u:object_r:updatemiscta_exec:s0 +/system/vendor/bin/imsdatadaemon u:object_r:ims_exec:s0 +/system/vendor/bin/imsqmidaemon u:object_r:ims_exec:s0 +/system/vendor/bin/ims_rtp_daemon u:object_r:ims_exec:s0 /system/vendor/bin/mm-pp-daemon u:object_r:ppd_exec:s0 /system/vendor/bin/perfd u:object_r:perfd_exec:s0 /system/vendor/bin/timekeep u:object_r:timekeep_exec:s0 diff --git a/sepolicy/vendor/ims.te b/sepolicy/vendor/ims.te new file mode 100644 index 0000000..801076f --- /dev/null +++ b/sepolicy/vendor/ims.te @@ -0,0 +1 @@ +allow ims system_prop:property_service set; diff --git a/sepolicy/vendor/property_contexts b/sepolicy/vendor/property_contexts index 14d989c..438d89b 100644 --- a/sepolicy/vendor/property_contexts +++ b/sepolicy/vendor/property_contexts @@ -1 +1,2 @@ +net.r_rmnet u:object_r:net_radio_prop:s0 persist.service.bdroid.bdaddr u:object_r:bluetooth_prop:s0 diff --git a/sepolicy/vendor/radio.te b/sepolicy/vendor/radio.te new file mode 100644 index 0000000..4b9aa2f --- /dev/null +++ b/sepolicy/vendor/radio.te @@ -0,0 +1,8 @@ +allow radio gpuservice:binder call; +allow radio system_app_data_file:dir getattr; + +# Grant access to ims socket that is created by ims_qmid, ims_datad +allow radio ims_socket:sock_file write; + +# Connect to ims service. +allow radio ims:unix_stream_socket connectto; diff --git a/sepolicy/vendor/service_contexts b/sepolicy/vendor/service_contexts index def6bc6..28089e2 100644 --- a/sepolicy/vendor/service_contexts +++ b/sepolicy/vendor/service_contexts @@ -1 +1,2 @@ com.sony.timekeep u:object_r:timekeep_service:s0 +rcs u:object_r:radio_service:s0 diff --git a/system.prop b/system.prop index 4901ee1..5f412ea 100644 --- a/system.prop +++ b/system.prop @@ -128,3 +128,5 @@ persist.traced.enable=0 # Wifi wifi.interface=wlan0 +persist.data.iwlan.enable=true + -- GitLab From a1106e4489c25f162da2df44811108858bd84849 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Thu, 22 Apr 2021 01:49:16 +0800 Subject: [PATCH 160/191] kitakami-common: rootdir: Update init scripts for IMS Change-Id: I2e8329ae96ca7720b0f7334e6a9a74632e08ea0e --- rootdir/init.qcom.rc | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc index 2c43c2e..758125b 100644 --- a/rootdir/init.qcom.rc +++ b/rootdir/init.qcom.rc @@ -499,45 +499,44 @@ on post-fs-data setprop vold.post_fs_data_done 1 -service imsqmidaemon /system/vendor/bin/imsqmidaemon +service vendor.imsqmidaemon /system/vendor/bin/imsqmidaemon class main user system socket ims_qmid stream 0660 system radio group radio log diag + writepid /dev/cpuset/system-background/tasks -service imsdatadaemon /system/vendor/bin/imsdatadaemon +service vendor.imsdatadaemon /system/vendor/bin/imsdatadaemon class main user system socket ims_datad stream 0660 system radio group system wifi radio inet log diag disabled -on property:sys.ims.QMI_DAEMON_STATUS=1 - start imsdatadaemon +on property:vendor.ims.QMI_DAEMON_STATUS=1 + start vendor.imsdatadaemon + +service vendor.ims_rtp_daemon /system/vendor/bin/ims_rtp_daemon + class main + user system + socket ims_rtpd stream 0660 system radio + group radio diag inet log + writepid /dev/cpuset/system-background/tasks -service ims_rtp_daemon /system/vendor/bin/ims_rtp_daemon +service vendor.imsrcsservice /system/vendor/bin/imsrcsd class main user system - socket ims_rtpd stream 0660 system radio group radio diag inet log - disabled + writepid /dev/cpuset/system-background/tasks -on property:sys.ims.DATA_DAEMON_STATUS=1 - start ims_rtp_daemon +on property:vendor.ims.DATA_DAEMON_STATUS=1 + restart vendor.ims_rtp_daemon -service imscmservice /system/vendor/bin/imscmservice +service vendor.imscmservice /system/vendor/bin/imscmservice class main user system group radio diag log -service ims_regmanager /system/bin/exe-ims-regmanagerprocessnative - class late_start - group net_bt_admin inet radio wifi - disabled - -on property:persist.ims.regmanager.mode=1 - start ims_regmanager - service irsc_util /system/bin/irsc_util "/etc/sec_config" class main user root -- GitLab From 83c525d530337af3f39ac66f25d0de4ea801795d Mon Sep 17 00:00:00 2001 From: Ethan Chen Date: Sat, 19 Oct 2019 23:53:57 -0700 Subject: [PATCH 161/191] kitakami-common: Add shim for libbase LogMessage functions Change-Id: I4d1db75e5407586c9b69d94803af0ef9a9a91037 --- device-common.mk | 1 + ims/Android.bp | 6 ++++++ ims/logging.cpp | 12 ++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 ims/Android.bp create mode 100644 ims/logging.cpp diff --git a/device-common.mk b/device-common.mk index 6fdcd50..daf83dd 100644 --- a/device-common.mk +++ b/device-common.mk @@ -220,6 +220,7 @@ PRODUCT_PACKAGES += \ # IMS PRODUCT_PACKAGES += \ + libbase_shim \ libshims_ims \ libshims_boringssl diff --git a/ims/Android.bp b/ims/Android.bp new file mode 100644 index 0000000..019e91f --- /dev/null +++ b/ims/Android.bp @@ -0,0 +1,6 @@ +cc_library { + name: "libbase_shim", + srcs: ["logging.cpp"], + shared_libs: ["libbase"], + vendor: true +} diff --git a/ims/logging.cpp b/ims/logging.cpp new file mode 100644 index 0000000..d2197c0 --- /dev/null +++ b/ims/logging.cpp @@ -0,0 +1,12 @@ +#include + +extern "C" void _ZN7android4base10LogMessageC1EPKcjNS0_5LogIdENS0_11LogSeverityES3_i( + const char* file, unsigned int line, android::base::LogId id, + android::base::LogSeverity severity, const char* tag, int error); + +extern "C" void _ZN7android4base10LogMessageC1EPKcjNS0_5LogIdENS0_11LogSeverityEi( + const char* file, unsigned int line, android::base::LogId id, + android::base::LogSeverity severity, int error) { + _ZN7android4base10LogMessageC1EPKcjNS0_5LogIdENS0_11LogSeverityES3_i(file, + line, id, severity, nullptr, error); +} -- GitLab From 1219bb69f21392792ab697888ec16fd8ec0d4d14 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Thu, 22 Apr 2021 01:56:22 +0800 Subject: [PATCH 162/191] kitakami-common: Guard more IMS target for radio-supported devices --- Android.mk | 8 ++++++-- BoardConfigCommon.mk | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Android.mk b/Android.mk index 7f44d12..a5c2ead 100644 --- a/Android.mk +++ b/Android.mk @@ -100,16 +100,20 @@ $(MODEM_SYMLINKS): $(LOCAL_INSTALLED_MODULE) ALL_DEFAULT_INSTALLED_MODULES += $(MODEM_SYMLINKS) +ifneq ($(BOARD_HAVE_RADIO),false) + IMS_LIBS := libimscamera_jni.so libimsmedia_jni.so -IMS_SYMLINKS := $(addprefix $(TARGET_OUT_VENDOR_APPS)/ims/lib/arm64/,$(notdir $(IMS_LIBS))) +IMS_SYMLINKS := $(addprefix $(TARGET_OUT_PRODUCT_APPS_PRIVILEGED)/ims/lib/arm64/,$(notdir $(IMS_LIBS))) $(IMS_SYMLINKS): $(LOCAL_INSTALLED_MODULE) @echo "IMS lib link: $@" @mkdir -p $(dir $@) @rm -rf $@ - $(hide) ln -sf /system/vendor/lib64/$(notdir $@) $@ + $(hide) ln -sf /system/product/lib64/$(notdir $@) $@ ALL_DEFAULT_INSTALLED_MODULES += $(IMS_SYMLINKS) +endif + # Create links for audcal data files $(shell mkdir -p $(TARGET_OUT)/etc/firmware/wcd9320; \ ln -sf /data/misc/audio/mbhc.bin \ diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 63f587d..fe836ee 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -202,9 +202,13 @@ TARGET_LD_SHIM_LIBS := \ /system/lib64/libsys-utils.so|libsensor.so \ /system/lib/libcammw.so|libsensor.so \ /system/bin/secd|/system/lib64/lib-preload64.so \ - /system/vendor/lib64/libril-qc-qmi-1.so|libaudioclient_shim.so \ + /system/vendor/lib64/libril-qc-qmi-1.so|libaudioclient_shim.so + +ifneq ($(BOARD_HAVE_RADIO),false) +TARGET_LD_SHIM_LIBS += \ /system/vendor/lib64/lib-imsvt.so|libshims_ims.so \ /system/vendor/lib64/lib-imsdpl.so|libshims_boringssl.so +endif # SELinux include device/qcom/sepolicy-legacy/sepolicy.mk -- GitLab From af5597cb389a861b13950947d7d391abf826181d Mon Sep 17 00:00:00 2001 From: Rashed Abdel-Tawab Date: Fri, 27 Oct 2017 19:41:04 -0700 Subject: [PATCH 163/191] kitakami-common: Build libandroid_net Needed by IMS stack. Change-Id: I4a3687a1639fe37b9652d651b9be773a09f63e14 --- device-common.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/device-common.mk b/device-common.mk index daf83dd..eb0f7c0 100644 --- a/device-common.mk +++ b/device-common.mk @@ -285,6 +285,10 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/configs/media_codecs_performance.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_performance.xml \ $(LOCAL_PATH)/configs/media_profiles_V1_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_profiles_V1_0.xml +# Net +PRODUCT_PACKAGES += \ + libandroid_net + # NFC PRODUCT_PACKAGES += \ android.hardware.nfc@1.0-impl \ -- GitLab From 47e4ac33476e61865e16343233252b250361de4e Mon Sep 17 00:00:00 2001 From: dianlujitao Date: Thu, 7 Dec 2017 22:15:14 +0800 Subject: [PATCH 164/191] kitakami-common: Build a dummy android.hidl.base@1.0 for Oreo blobs Change-Id: I81a081130869c4d92f30b2674e75bb6b096a7a2c --- device-common.mk | 1 + libhidl/Android.mk | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 libhidl/Android.mk diff --git a/device-common.mk b/device-common.mk index eb0f7c0..cb00c10 100644 --- a/device-common.mk +++ b/device-common.mk @@ -213,6 +213,7 @@ PRODUCT_PACKAGES += \ # HIDL PRODUCT_PACKAGES += \ + android.hidl.base@1.0 \ libhidltransport \ libhidltransport.vendor \ libhwbinder \ diff --git a/libhidl/Android.mk b/libhidl/Android.mk new file mode 100644 index 0000000..b709215 --- /dev/null +++ b/libhidl/Android.mk @@ -0,0 +1,21 @@ +# +# Copyright (C) 2017 The LineageOS Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include $(CLEAR_VARS) +LOCAL_SHARED_LIBRARIES := libhidltransport +LOCAL_MODULE := android.hidl.base@1.0 +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +include $(BUILD_SHARED_LIBRARY) -- GitLab From 68c7375b672cc59699bff0578511a272302eb454 Mon Sep 17 00:00:00 2001 From: codeworkx Date: Mon, 12 Feb 2018 00:54:00 +0530 Subject: [PATCH 165/191] kitakami-common: Add dummy android.hidl.manager@1.0 --- libhidl/Android.mk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libhidl/Android.mk b/libhidl/Android.mk index b709215..62e72ca 100644 --- a/libhidl/Android.mk +++ b/libhidl/Android.mk @@ -19,3 +19,11 @@ LOCAL_MODULE := android.hidl.base@1.0 LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := SHARED_LIBRARIES include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_SHARED_LIBRARIES := libhidltransport +LOCAL_MODULE := android.hidl.manager@1.0 +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +include $(BUILD_SHARED_LIBRARY) + -- GitLab From ce2e71f73db4d3c93ba6bf4eb75a54a159be4ddf Mon Sep 17 00:00:00 2001 From: Rashed Abdel-Tawab Date: Sun, 8 Apr 2018 17:03:34 -0700 Subject: [PATCH 166/191] kitakami-common: Build a system version of android.hidl.base@1.0 for imsvt Change-Id: Icb911f414595117a28fb764e145fbbf6a7ee0787 --- device-common.mk | 3 +++ libhidl/Android.mk | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/device-common.mk b/device-common.mk index cb00c10..12f721a 100644 --- a/device-common.mk +++ b/device-common.mk @@ -214,6 +214,9 @@ PRODUCT_PACKAGES += \ # HIDL PRODUCT_PACKAGES += \ android.hidl.base@1.0 \ + android.hidl.base@1.0_system \ + android.hidl.manager@1.0 \ + android.hidl.manager@1.0-java \ libhidltransport \ libhidltransport.vendor \ libhwbinder \ diff --git a/libhidl/Android.mk b/libhidl/Android.mk index 62e72ca..5c673a2 100644 --- a/libhidl/Android.mk +++ b/libhidl/Android.mk @@ -20,6 +20,14 @@ LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := SHARED_LIBRARIES include $(BUILD_SHARED_LIBRARY) +include $(CLEAR_VARS) +LOCAL_SHARED_LIBRARIES := libhidltransport +LOCAL_MODULE := android.hidl.base@1.0_system +LOCAL_INSTALLED_MODULE_STEM := android.hidl.base@1.0.so +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +include $(BUILD_SHARED_LIBRARY) + include $(CLEAR_VARS) LOCAL_SHARED_LIBRARIES := libhidltransport LOCAL_MODULE := android.hidl.manager@1.0 -- GitLab From d42cbb688cbe960ed208f4ea4212abbce6ba29d7 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Wed, 2 Oct 2019 12:49:15 -0700 Subject: [PATCH 167/191] kitakami-common: Remove libhwbinder/libhidltransport dependency Since these were combined into libhidlbase. Bug: 135686713 Test: build only (libhwbinder/libhidltransport are empty) Change-Id: Iba2cd20b8b20fac3e7564de6b853b475fd4ebd2a --- libhidl/Android.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libhidl/Android.mk b/libhidl/Android.mk index 5c673a2..262ddfa 100644 --- a/libhidl/Android.mk +++ b/libhidl/Android.mk @@ -14,14 +14,14 @@ # limitations under the License. include $(CLEAR_VARS) -LOCAL_SHARED_LIBRARIES := libhidltransport +LOCAL_SHARED_LIBRARIES := libhidlbase LOCAL_MODULE := android.hidl.base@1.0 LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := SHARED_LIBRARIES include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) -LOCAL_SHARED_LIBRARIES := libhidltransport +LOCAL_SHARED_LIBRARIES := libhidlbase LOCAL_MODULE := android.hidl.base@1.0_system LOCAL_INSTALLED_MODULE_STEM := android.hidl.base@1.0.so LOCAL_MODULE_TAGS := optional @@ -29,7 +29,7 @@ LOCAL_MODULE_CLASS := SHARED_LIBRARIES include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) -LOCAL_SHARED_LIBRARIES := libhidltransport +LOCAL_SHARED_LIBRARIES := libhidlbase LOCAL_MODULE := android.hidl.manager@1.0 LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := SHARED_LIBRARIES -- GitLab From 5d2b0a34c76b87e1b3559e3cd2f8629ef1a924d9 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Thu, 22 Apr 2021 15:33:06 +0800 Subject: [PATCH 168/191] kitakami-common: Add missing stuff for IMS Change-Id: I5eeaa03435bdf87329cce8a724ddc2aef009a030 --- BoardConfigCommon.mk | 14 ++- device-common.mk | 5 +- libshim/Android.mk | 11 ++ libshim/GraphicBuffer.cpp | 12 ++ manifest_radio.xml | 117 ++++++++++++++++++ .../services/Telephony/res/values/config.xml | 6 + radio.mk | 22 +++- sepolicy/vendor/ims.te | 3 + 8 files changed, 185 insertions(+), 5 deletions(-) create mode 100644 libshim/GraphicBuffer.cpp create mode 100644 manifest_radio.xml diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index fe836ee..431bc25 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -21,6 +21,9 @@ TARGET_SPECIFIC_HEADER_PATH += $(COMMON_PATH)/include BOARD_VENDOR := sony +# Build +BUILD_BROKEN_DUP_RULES := true + # Bootloader TARGET_BOOTLOADER_BOARD_NAME := MSM8994 TARGET_NO_BOOTLOADER := true @@ -150,6 +153,10 @@ TARGET_PROVIDES_LIBLIGHT := true DEVICE_MANIFEST_FILE := $(COMMON_PATH)/manifest.xml PRODUCT_ENFORCE_VINTF_MANIFEST_OVERRIDE := true +ifneq ($(BOARD_HAVE_RADIO),false) + DEVICE_MANIFEST_FILE += $(COMMON_PATH)/manifest_radio.xml +endif + # Init TARGET_PLATFORM_DEVICE_BASE := /devices/soc.0/ @@ -205,9 +212,10 @@ TARGET_LD_SHIM_LIBS := \ /system/vendor/lib64/libril-qc-qmi-1.so|libaudioclient_shim.so ifneq ($(BOARD_HAVE_RADIO),false) -TARGET_LD_SHIM_LIBS += \ - /system/vendor/lib64/lib-imsvt.so|libshims_ims.so \ - /system/vendor/lib64/lib-imsdpl.so|libshims_boringssl.so + TARGET_LD_SHIM_LIBS += \ + /system/vendor/lib64/lib-imsvt.so|libshims_ims.so \ + /system/vendor/lib64/lib-imsdpl.so|libshims_boringssl.so \ + /system/lib64/lib-imsvideocodec.so|libui_shim.so endif # SELinux diff --git a/device-common.mk b/device-common.mk index 12f721a..7350210 100644 --- a/device-common.mk +++ b/device-common.mk @@ -135,7 +135,9 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ android.hardware.camera.provider@2.4-impl:32 \ camera.msm8994 \ - Snap + Snap \ + vendor.qti.hardware.camera.device@1.0 \ + vendor.qti.hardware.camera.device@1.0_vendor # Charger PRODUCT_PACKAGES += charger_res_images @@ -225,6 +227,7 @@ PRODUCT_PACKAGES += \ # IMS PRODUCT_PACKAGES += \ libbase_shim \ + libui_shim \ libshims_ims \ libshims_boringssl diff --git a/libshim/Android.mk b/libshim/Android.mk index 085c6c5..e59833f 100644 --- a/libshim/Android.mk +++ b/libshim/Android.mk @@ -89,3 +89,14 @@ LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := SHARED_LIBRARIES include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := GraphicBuffer.cpp +LOCAL_SHARED_LIBRARIES := libui +LOCAL_MODULE := libui_shim +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_MODULE_TAGS := optional +LOCAL_VENDOR_MODULE := true + +include $(BUILD_SHARED_LIBRARY) diff --git a/libshim/GraphicBuffer.cpp b/libshim/GraphicBuffer.cpp new file mode 100644 index 0000000..c91d8cb --- /dev/null +++ b/libshim/GraphicBuffer.cpp @@ -0,0 +1,12 @@ +#include + +namespace android { + extern "C" void _ZN7android13GraphicBuffer4lockEjPPvPiS3_(uint32_t inUsage, void** vaddr, + int32_t* outBytesPerPixel, int32_t* outBytesPerStride); + + extern "C" void _ZN7android13GraphicBuffer4lockEjPPv(uint32_t inUsage, void** vaddr) { + _ZN7android13GraphicBuffer4lockEjPPvPiS3_(inUsage, vaddr, nullptr, nullptr); + } + +extern "C" void _ZN7android5FenceD1Ev() {} +} diff --git a/manifest_radio.xml b/manifest_radio.xml new file mode 100644 index 0000000..8f5bfa9 --- /dev/null +++ b/manifest_radio.xml @@ -0,0 +1,117 @@ + + + com.qualcomm.qti.imscmservice + hwbinder + 1.0 + + IImsCmService + qti.ims.connectionmanagerservice + + + + com.qualcomm.qti.uceservice + hwbinder + 1.0 + + IUceService + com.qualcomm.qti.uceservice + + + + vendor.qti.hardware.data.latency + hwbinder + 1.0 + + ILinkLatency + default + + + + vendor.qti.hardware.radio.am + hwbinder + 1.0 + + IQcRilAudio + slot1 + slot2 + + + + vendor.qti.hardware.radio.ims + hwbinder + 1.0 + + IImsRadio + imsradio0 + imsradio1 + + + + vendor.qti.hardware.radio.lpa + hwbinder + 1.0 + + IUimLpa + UimLpa0 + + + + vendor.qti.hardware.radio.qcrilhook + hwbinder + 1.0 + + IQtiOemHook + oemhook0 + oemhook1 + + + + vendor.qti.hardware.radio.qtiradio + hwbinder + 1.0 + + IQtiRadio + slot1 + slot2 + + + + vendor.qti.hardware.radio.uim + hwbinder + 1.0 + + IUim + Uim0 + Uim1 + + + + vendor.qti.hardware.radio.uim_remote_client + hwbinder + 1.0 + + IUimRemoteServiceClient + uimRemoteClient0 + uimRemoteClient1 + + + + vendor.qti.hardware.radio.uim_remote_server + hwbinder + 1.0 + + IUimRemoteServiceServer + uimRemoteServer0 + uimRemoteServer1 + + + + vendor.qti.imsrtpservice + hwbinder + 1.0 + + IRTPService + imsrtpservice + + + \ No newline at end of file diff --git a/overlay-radio/packages/services/Telephony/res/values/config.xml b/overlay-radio/packages/services/Telephony/res/values/config.xml index 8ba469f..d5f2e4d 100644 --- a/overlay-radio/packages/services/Telephony/res/values/config.xml +++ b/overlay-radio/packages/services/Telephony/res/values/config.xml @@ -29,4 +29,10 @@ 1 + + + org.codeaurora.ims + + + org.codeaurora.ims diff --git a/radio.mk b/radio.mk index 320d2b3..0625b4e 100644 --- a/radio.mk +++ b/radio.mk @@ -19,6 +19,10 @@ PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.telephony.gsm.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.telephony.gsm.xml \ frameworks/native/data/etc/android.hardware.telephony.ims.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.telephony.ims.xml +# Common +PRODUCT_PACKAGES += \ + libqdMetaData.system + # RCS PRODUCT_PACKAGES += \ rcs_service_aidl \ @@ -56,7 +60,13 @@ PRODUCT_PROPERTY_OVERRIDES += \ persist.radio.oem_socket=true \ persist.radio.redir_party_num=0 \ persist.radio.sib16_support=1 \ - persist.radio.wait_for_pbm=1 + persist.radio.wait_for_pbm=1 \ + persist.vendor.radio.custom_ecc=1 \ + persist.vendor.radio.rat_on=combine \ + persist.vendor.radio.sib16_support=1 \ + persist.vendor.radio.add_power_save=1 \ + persist.vendor.radio.start_ota_daemon=1 \ + persist.vendor.radio.adb_log_on=1 PRODUCT_PROPERTY_OVERRIDES += \ rild.libargs=-d[SPACE]/dev/smd0 \ @@ -68,3 +78,13 @@ PRODUCT_PROPERTY_OVERRIDES += \ ro.ril.telephony.mqanelements=5 \ ro.telephony.call_ring.multiple=false \ ro.use_data_netmgrd=true + +#VoLTE / VoWifi +PRODUCT_PROPERTY_OVERRIDES += \ + DEVICE_PROVISIONED=1 \ + persist.dbg.ims_volte_enable=1 \ + persist.dbg.volte_avail_ovr=1 \ + persist.dbg.vt_avail_ovr=1 \ + persist.dbg.wfc_avail_ovr=1 \ + persist.radio.calls.on.ims=1 + diff --git a/sepolicy/vendor/ims.te b/sepolicy/vendor/ims.te index 801076f..b90b076 100644 --- a/sepolicy/vendor/ims.te +++ b/sepolicy/vendor/ims.te @@ -1 +1,4 @@ +allow ims hal_imsrtp_hwservice:hwservice_manager { add find }; +allow ims hidl_base_hwservice:hwservice_manager { add find }; +allow ims ion_device:chr_file rw_file_perms; allow ims system_prop:property_service set; -- GitLab From cd001e1f08d26d211af28f01df1610c36e678137 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Thu, 22 Apr 2021 19:40:42 +0800 Subject: [PATCH 169/191] kitakami-common: radio: Exclude CarrierConfig overlays from RRO --- radio.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/radio.mk b/radio.mk index 0625b4e..e4fa18d 100644 --- a/radio.mk +++ b/radio.mk @@ -14,6 +14,9 @@ # limitations under the License. # +# RRO (Runtime Resource Overlay) +PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS += $(LOCAL_PATH)/overlay-radio/packages/apps/CarrierConfig + # Permissions PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.telephony.gsm.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.telephony.gsm.xml \ -- GitLab From 5e7436746f25c02580d6b5584216cad249bfdcc0 Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Thu, 22 Apr 2021 19:41:43 +0800 Subject: [PATCH 170/191] kitakami-common: overlay-radio: Enable IMS, VoLTE on some carriers Change-Id: Ice3dc16ff4ef3de6df196c96886250ae925494aa --- .../apps/CarrierConfig/res/xml/vendor.xml | 2125 +++++++++++++++++ 1 file changed, 2125 insertions(+) create mode 100644 overlay-radio/packages/apps/CarrierConfig/res/xml/vendor.xml diff --git a/overlay-radio/packages/apps/CarrierConfig/res/xml/vendor.xml b/overlay-radio/packages/apps/CarrierConfig/res/xml/vendor.xml new file mode 100644 index 0000000..842d095 --- /dev/null +++ b/overlay-radio/packages/apps/CarrierConfig/res/xml/vendor.xml @@ -0,0 +1,2125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + + + + + + + + + + + + + + + + + + + China Mobile + + + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + China Unicom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + + + + + + + + + + + + + + + + + + + China Mobile + + + + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + + + + + + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + China Unicom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + China Unicom + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IPV4V6 + IPV4V6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- GitLab From 41bd26bc0a3fd1390ac2e53135a8387b3090f90f Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Thu, 29 Apr 2021 14:43:58 +0800 Subject: [PATCH 171/191] kitakami-common: IMS updates * Add missing permissions. * Disable ViLTE, WFC. * Update properties. Change-Id: I8472dee53caa9829e28ce0d3c4afaeb92b42603a --- configs/privapp-permissions-qti.xml | 4 ++++ .../frameworks/base/core/res/res/values/config.xml | 7 ++++--- radio.mk | 7 ++++--- sepolicy/vendor/ims.te | 3 +++ sepolicy/vendor/rild.te | 4 ++++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/configs/privapp-permissions-qti.xml b/configs/privapp-permissions-qti.xml index 04dfb19..32a489b 100644 --- a/configs/privapp-permissions-qti.xml +++ b/configs/privapp-permissions-qti.xml @@ -3,4 +3,8 @@ + + + + diff --git a/overlay-radio/frameworks/base/core/res/res/values/config.xml b/overlay-radio/frameworks/base/core/res/res/values/config.xml index b8d620f..b642e8f 100644 --- a/overlay-radio/frameworks/base/core/res/res/values/config.xml +++ b/overlay-radio/frameworks/base/core/res/res/values/config.xml @@ -73,12 +73,13 @@ true - true - true + false + false true - true + false + false diff --git a/radio.mk b/radio.mk index e4fa18d..216e057 100644 --- a/radio.mk +++ b/radio.mk @@ -87,7 +87,8 @@ PRODUCT_PROPERTY_OVERRIDES += \ DEVICE_PROVISIONED=1 \ persist.dbg.ims_volte_enable=1 \ persist.dbg.volte_avail_ovr=1 \ - persist.dbg.vt_avail_ovr=1 \ - persist.dbg.wfc_avail_ovr=1 \ - persist.radio.calls.on.ims=1 + persist.dbg.vt_avail_ovr=0 \ + persist.dbg.wfc_avail_ovr=0 \ + persist.radio.calls.on.ims=1 \ + persist.data.iwlan.enable=false diff --git a/sepolicy/vendor/ims.te b/sepolicy/vendor/ims.te index b90b076..a2970f4 100644 --- a/sepolicy/vendor/ims.te +++ b/sepolicy/vendor/ims.te @@ -2,3 +2,6 @@ allow ims hal_imsrtp_hwservice:hwservice_manager { add find }; allow ims hidl_base_hwservice:hwservice_manager { add find }; allow ims ion_device:chr_file rw_file_perms; allow ims system_prop:property_service set; + +# Grant access to Qualcomm MSM Interface (QMI) radio sockets +qmux_socket(ims) diff --git a/sepolicy/vendor/rild.te b/sepolicy/vendor/rild.te index 345c66f..2fb808c 100644 --- a/sepolicy/vendor/rild.te +++ b/sepolicy/vendor/rild.te @@ -3,9 +3,13 @@ unix_socket_connect(rild, tad, tad) # Misc allow rild cache_file:dir create_dir_perms; +allow rild device:file rw_file_perms; allow rild firmware_file:dir search; allow rild firmware_file:file r_file_perms; allow rild ion_device:chr_file r_file_perms; allow rild self:capability { dac_override sys_module }; allow rild socket_device:sock_file write; allow rild tee_device:chr_file rw_file_perms; + +# Grant access to Qualcomm MSM Interface (QMI) radio sockets +qmux_socket(rild) -- GitLab From dc2892719ce7bc2f39f03ee6f68604874a7bcf6d Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Sun, 9 May 2021 19:15:39 +0800 Subject: [PATCH 172/191] kitakami-common: Update audio props --- system.prop | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system.prop b/system.prop index 5f412ea..1bdcc6a 100644 --- a/system.prop +++ b/system.prop @@ -1,6 +1,6 @@ # Audio vendor.tunnel.audio.encode = false -audio.deep_buffer.media=true +tunnel.audio.encode=false audio.offload.gapless.enabled=true audio.offload.buffer.size.kb=32 audio.offload.video=false @@ -9,6 +9,7 @@ audio.offload.passthrough=false audio.offload.multiple.enabled=true audio.offload.pcm.24bit.enable=true audio.offload.track.enable=true +persist.audio.ssr.3mic=false persist.vendor.audio.fluence.voicecall=true persist.vendor.audio.fluence.voicerec=false persist.vendor.audio.fluence.speaker=true -- GitLab From 27b4ec39c2a41df0138ce24cb2b21c8a3243f53a Mon Sep 17 00:00:00 2001 From: TARKZiM Date: Sun, 9 May 2021 19:17:15 +0800 Subject: [PATCH 173/191] kitakami-common: Build SoundTrigger HAL 2.0 Change-Id: I28ca52e89fb8be00bf6a943831d8c2b249a328fa --- BoardConfigCommon.mk | 1 + audio/sound_trigger_mixer_paths.xml | 82 +++++++++++++++++++++++++++ audio/sound_trigger_platform_info.xml | 41 ++++++++++++++ device-common.mk | 4 +- include/sound_trigger_prop_intf.h | 61 ++++++++++++++++++++ 5 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 audio/sound_trigger_mixer_paths.xml create mode 100644 audio/sound_trigger_platform_info.xml create mode 100644 include/sound_trigger_prop_intf.h diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 431bc25..d16214b 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -81,6 +81,7 @@ AUDIO_FEATURE_ENABLED_PCM_OFFLOAD_24 := true AUDIO_FEATURE_ENABLED_PROXY_DEVICE := true AUDIO_USE_LL_AS_PRIMARY_OUTPUT := true +BOARD_SUPPORTS_SOUND_TRIGGER := true BOARD_USES_ALSA_AUDIO := true USE_CUSTOM_AUDIO_POLICY := 1 USE_XML_AUDIO_POLICY_CONF := 1 diff --git a/audio/sound_trigger_mixer_paths.xml b/audio/sound_trigger_mixer_paths.xml new file mode 100644 index 0000000..b031442 --- /dev/null +++ b/audio/sound_trigger_mixer_paths.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/audio/sound_trigger_platform_info.xml b/audio/sound_trigger_platform_info.xml new file mode 100644 index 0000000..e0bea25 --- /dev/null +++ b/audio/sound_trigger_platform_info.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/device-common.mk b/device-common.mk index 7350210..86c0194 100644 --- a/device-common.mk +++ b/device-common.mk @@ -112,7 +112,9 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/audio/audio_effects.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_effects.xml \ $(LOCAL_PATH)/audio/audio_output_policy.conf:$(TARGET_COPY_OUT_VENDOR)/etc/audio_output_policy.conf \ $(LOCAL_PATH)/audio/audio_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_platform_info.xml \ - $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml + $(LOCAL_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \ + $(LOCAL_PATH)/audio/sound_trigger_mixer_paths.xml:$(TARGET_COPY_OUT_VENDOR)/etc/sound_trigger_mixer_paths.xml \ + $(LOCAL_PATH)/audio/sound_trigger_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/sound_trigger_platform_info.xml PRODUCT_COPY_FILES += \ frameworks/av/services/audiopolicy/config/a2dp_in_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_in_audio_policy_configuration.xml \ diff --git a/include/sound_trigger_prop_intf.h b/include/sound_trigger_prop_intf.h new file mode 100644 index 0000000..1ecd7e4 --- /dev/null +++ b/include/sound_trigger_prop_intf.h @@ -0,0 +1,61 @@ +/* + * Extrapolated / reversed header for Sound Trigger + */ + +#ifndef SOUND_TRIGGER_PROP_INTF_H +#define SOUND_TRIGGER_PROP_INTF_H + +struct sound_trigger_session_info { + int capture_handle; + struct pcm *pcm; + struct pcm_config config; +}; + +enum audio_event_type { + AUDIO_EVENT_CAPTURE_DEVICE_INACTIVE, + AUDIO_EVENT_CAPTURE_DEVICE_ACTIVE, + AUDIO_EVENT_PLAYBACK_STREAM_INACTIVE, + AUDIO_EVENT_PLAYBACK_STREAM_ACTIVE, + AUDIO_EVENT_STOP_LAB, + AUDIO_EVENT_SSR, + AUDIO_EVENT_NUM_ST_SESSIONS, + AUDIO_EVENT_READ_SAMPLES, +}; + +enum sound_trigger_event_type { + ST_EVENT_SESSION_REGISTER, + ST_EVENT_SESSION_DEREGISTER +}; +typedef enum sound_trigger_event_type sound_trigger_event_type_t; + +enum ssr_event_status { + SND_CARD_STATUS_OFFLINE, + SND_CARD_STATUS_ONLINE, + CPE_STATUS_OFFLINE, + CPE_STATUS_ONLINE +}; + +struct sound_trigger_event_info { + struct sound_trigger_session_info st_ses; +}; +typedef struct sound_trigger_event_info sound_trigger_event_info_t; + +struct audio_read_samples_info { + struct sound_trigger_session_info *ses_info; + void *buf; + size_t num_bytes; +}; + +struct audio_event_info { + union { + enum ssr_event_status status; + int value; + struct sound_trigger_session_info ses_info; + struct audio_read_samples_info aud_info; + }u; +}; +typedef struct audio_event_info audio_event_info_t; + +typedef int (*sound_trigger_hw_call_back_t)(enum audio_event_type, + struct audio_event_info*); +#endif -- GitLab From 86c95a50a7fe3eb35a04b688bfc3b29a7e87c30e Mon Sep 17 00:00:00 2001 From: Lakshman Chaluvaraju Date: Sat, 30 May 2020 14:28:36 +0530 Subject: [PATCH 174/191] kitakami-common: configs: Enable Stereo channel support for voip over audio path Add changes to support stereo channel configuration for voip over audio path. Change-Id: Ib454d24a4017d3f91d429d47c52d4f86e5a18e97 --- audio/audio_policy_configuration.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/audio_policy_configuration.xml b/audio/audio_policy_configuration.xml index 1cd7ecd..fd1425b 100644 --- a/audio/audio_policy_configuration.xml +++ b/audio/audio_policy_configuration.xml @@ -105,7 +105,7 @@ + samplingRates="8000,16000" channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO"/> Date: Fri, 13 Mar 2020 17:21:28 +0530 Subject: [PATCH 175/191] kitakami-common: configs: Add mixer controls for call screen support Add mixer controls for proxy ports. Enable call screen mode support in audio_policy_config. Change-Id: Iaf4482909f05132ce987e24ed8e6f7991a4e5e9c --- audio/audio_policy_configuration.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/audio_policy_configuration.xml b/audio/audio_policy_configuration.xml index fd1425b..617ea66 100644 --- a/audio/audio_policy_configuration.xml +++ b/audio/audio_policy_configuration.xml @@ -21,7 +21,7 @@ - +