273 Commits
vic-bak ... bka

Author SHA1 Message Date
Joey Huab
89b32fa7db msm8953-common: Drop AntHalService 2025-09-17 23:08:57 +09:00
LuK1337
3ca13d0fe2 msm8953-common: Migrate to AIDL LiveDisplay HAL
Change-Id: I4e8be836e94d442b40c63a1ac7dade3c9d9c784c
2025-09-17 23:06:14 +09:00
genoxci
d8b162f68f msm8953-common: touch: Drop Lineage Touch 2025-09-17 22:56:21 +09:00
Al Mahmud
40db32a405 msm8953-common: switch to common AIDL IR service 2025-06-09 23:59:45 +09:00
Joey Huab
58d2b7873d msm8953-common: Initialize for Evolution X 10.x 2025-05-26 17:44:21 +09:00
Bruno Martins
c781ccf90e msm8935-common: Set vendor init lib via soong config
Change-Id: I8f7e6b987bee58dbf09ca9ad7cfd5a7e99e19c3b
2025-05-09 22:20:45 +02:00
Giovanni Ricca
e0f2c22435 msm8953-common: Temporarily downgrade kernel clang version
19.0.1 doesn't boot for us. Let's keep using the old one for now.

Change-Id: I6693b36674539c20870be49d564b652a93478de1
2025-04-19 22:14:02 +02:00
Giovanni Ricca
3e87f86b13 msm8953-common: Build device-specific light HAL
Change-Id: Ic87830bac5a757e530eb255d5e72ddd495cf00bf
2025-04-19 22:14:02 +02:00
Giovanni Ricca
e50ed064ca Revert "aidl: light: Add support for upstream LED timed mode"
Needs to be fixed kernel side as it causes some unwanted crashes.
Let's just revert the commit and hope for the best ...

Change-Id: I112f43b6224ec1fc9bf2564186c73a05238080ae
2025-04-19 22:13:57 +02:00
Giovanni Ricca
9363f3e0dc msm8953-common: light: Rename HAL
Change-Id: I812659cfe585c20bc26a9448b9f6401e8d94e5f9
2025-04-19 22:11:30 +02:00
Giovanni Ricca
1f1379e75b msm8953-common: Fork light HAL from hardware/lineage/interfaces
HEAD: android_hardware_lineage_interface @
sa7d52a839d32efc6c704d9b20a1ab269fc5bce38

Change-Id: Iab02caa5dd57b7b0e3a65c6921b3d0c865ffeb2b
2025-04-19 22:04:06 +02:00
Ivan Vecera
91815b026b msm8953-common: rro_overlays: Enable WPA3-SAE for SoftAP
Test: Create WPA3 enabled wifi hotspot and connect to it using another device
Change-Id: I081e3b6cb7e3ed019dab70f2b9736cf7546392c3
2025-03-22 14:21:17 +01:00
Yumi Yukimura
d89cfae03e msm8953-common: rro_overlays: WifiOverlay: Move to vendor
Change-Id: Iac1e29563145b3f9e2ffddbd604ed982a247a5b2
2025-03-22 14:21:17 +01:00
Alexander Koskovich
56631d4d9a msm8953-common: rro_overlays: Drop explicit 'sdk_version' declaration
* We don't need to manually set this anymore.

Change-Id: I1239ba541636e53f8ea4373d3815024f2cd60824
2025-03-22 14:21:17 +01:00
Alexander Martinz
3aa11a492a msm8953-common: audio: switch to open source sound trigger hal
The audio hal expects the version of the android and sound trigger
hal to match.

As the prebuilt sound trigger hal is built with a BSP based on
Android 10, the version is older than expected and sound trigger fails
to initialize.

11-11 11:37:55.774  4103  4107 I soundtrigger: audio_extn_sound_trigger_init: Enter
11-11 11:37:55.775  4103  4107 I soundtrigger: audio_extn_sound_trigger_init: DLOPEN successful for /vendor/lib/hw/sound_trigger.primary.sdm845.so
11-11 11:37:55.775  4103  4107 E soundtrigger: audio_extn_sound_trigger_init: Incompatible API versions ahal:0x200 != sthal:0x101

Test: atest CtsSoundTriggerTestCases
Test: atest VtsHalSoundtriggerV2_0TargetTest
Test: atest VtsHalSoundtriggerV2_1TargetTest
Test: atest VtsHalSoundtriggerV2_2TargetTest

Depends-On: https://review.lineageos.org/344863
Change-Id: I23b052149bf243f86ebfa13dbbc5053abe4b92e1
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
2025-03-22 14:21:13 +01:00
Harshal Ahire
e9f2497ae2 msm8953-common: enable sound trigger hidl hal 2.3
Change-Id: Ieac067b937c06f1ce4f74abf0b884fc1bf92b5c9
2025-03-22 14:18:26 +01:00
Jaideep Sharma
6990f43a2d msm8953-common: Update sound trigger HIDL version to 2.2
Change-Id: Idb683714c52bfdf17ea709c6f47d312582042190
2025-03-22 14:18:26 +01:00
Bruno Martins
763f44cf9d msm8953-common: Use the common device compatibility matrix from QCOM
Change-Id: I0c0f3ecddbe6d7b232cc0d13c78ca58094e4e720
2025-03-22 14:18:26 +01:00
Wang Han
7abd1ec13b msm8953-common: Remove libaacwrapper from PRODUCT_PACKAGES
* It does not exist at all and is replaced by libwfdaac.

Change-Id: I3b2684b9980d6856f1817e5a40e42861ea86ae24
2025-03-22 14:18:26 +01:00
Giovanni Ricca
cdc3adb624 msm8953-common: Update poweroff stack from FP3
Inline with oneplus msm8998-common

Change-Id: I39be086fdc2d6405b47d6b914469117e13097fcd
2025-03-20 09:26:45 +01:00
Giovanni Ricca
2f9dd94887 msm8953-common: Drop TARGET_RECOVERY_DEVICE_MODULES
Dead as of QPR2, and we only use it to set dalvik
props anyway.

Change-Id: I185ce300cf67e5855d86e2ea29ac982175c8e442
2025-03-10 21:08:25 +01:00
Michael Bestas
0b0283eb65 msm8953-common: Enable ELF checks for libwpa_client dependent libs
Change-Id: I490df02b68da4b9a7088a239672a1dcace66d270
2025-03-10 16:23:16 +01:00
Tyler Wear
7e7750fe72 msm8953-common: tetheroffload: Version 1.1
Update tetheroffload to version 1.1.

Change-Id: I004e44e416a88a1b39a4c80366df9008722f096b
2025-03-04 09:07:16 +01:00
Suren Baghdasaryan
9bcb7d9b10 msm8953-common: Switch lmkd to use minfree levels for kill decisions
Enable ro.lmk.use_minfree_levels flag to use minfree levels to decide
when lmkd should kill. This makes lmkd work the same way lowmemorykiller
kernel driver used to work.

Bug: 77299493
Bug: 75322373
Test: lmkd_unit_test
Change-Id: Ic29d7fd21af1cb6af3a7d2a175d210775a09987e
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2025-02-14 16:54:00 +01:00
Suren Baghdasaryan
3b0aaa3b58 msm8953-common: Increase ro.lmk.medium to prevent kills at medium vmpressure
Setting ro.lmk.medium to 800 to prevent important processes from being
killed at medium vmpressure levels.

Bug: 77299493
Test: lmkd_unit_test
Merged-In: I37e1651a0a2b148a852e5bde86501024d4f87bbf
Change-Id: I37e1651a0a2b148a852e5bde86501024d4f87bbf
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
(cherry picked from commit c954ec2eb318518cfa5c6f64a688fd8c809e91c5)
2025-02-14 16:53:56 +01:00
Suren Baghdasaryan
6a8e50b920 msm8953-common: Set lmkd configuration properties
Bug: 63631020

Change-Id: I16a183e8e4625e8b98cefdc9c8a7b650556a2b55
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2025-02-14 16:53:52 +01:00
Pullakavi Srinivas
57a64dacdf msm8953-common: Disable SF composition prediction model.
CRs-Fixed: 3243885
Change-Id: I64f82a25768b561bb343fdb7686b7d6c020d024a
2025-02-14 10:52:29 +01:00
Alex Sarraf
9713502ef7 msm8953-common: Disable SF client composition cache
Disable SF client composition cache. Helps with framework
client target fence management.

Change-Id: I73e03e76f51d00fafad38479be00f4005be50665
2025-02-14 10:52:22 +01:00
David Sehr
398193f4d7 msm8953-common: Enable usage of dex2oat64
Use 64-bit dex2oat for better dexopt time.

Bug: 153380900
Test: boot and install an application
Change-Id: I3e7a6e6e9385ff6564d1a2e6dda004ebb061f095
(cherry picked from commit 126f03be80f57a8a0411842011152d9381589b78)
Merged-In: I3e7a6e6e9385ff6564d1a2e6dda004ebb061f095
2025-02-14 10:44:32 +01:00
Jan Altensen
b3a794833e msm8953-common: move to new fm vendor jni variable
Change-Id: I48a4c0005a0761ca4c6ff574fca0153d2dbf54c9
2025-02-10 12:22:41 +01:00
Nolen Johnson
f0d617c3c1 msm8953-common: Adapt to new no FM firmware download flag
Change-Id: Ifae8243501a25c4bdbccdcddebd42a2118995805
2025-02-07 20:13:48 +01:00
feiyuchen
e4e0676ba6 msm8953-common: rootdir: Add "system" group to Audio HAL
needed for using EdgeTpu.
Due to this code goes to AOSP, please see CL details and test result in
b/289097511#comment24.

Bug: 289097511
Change-Id: Ie0969309346cd85b4bb8ac71860a529710c73345
2025-01-31 08:51:55 +01:00
Andy Hung
814aa44b41 msm8953-common: rootdir: Enable RT priority inheritance
Test: instrumented
Bug: 181148259
Bug: 260918856
Merged-In: If56e449a9c6f1a49e372591893d8714534574e3a
Change-Id: If56e449a9c6f1a49e372591893d8714534574e3a
2025-01-31 08:51:07 +01:00
emilchung
5c23a83493 msm8953-common: rootdir: add context_hub into audio hal group
While implementing the capo nanoapp for audio configuration, we met
some chre socket connected error due to the access group denied.

Add context_hub group for audio hal to connect chre socket.

go/capo-algo

Bug: 141128522
Bug: 149069556
Test: FULL build with audio hal part and local prebuilts nanoapp.
Test: Audio HAL communicates normally with CHRE socket.
Change-Id: Iea84411682f4c3e08f8b37a5b21818b0e9b04983
2025-01-31 08:50:17 +01:00
Giovanni Ricca
a32dafe437 msm8953-common: Simplify FMRadio section
* `libfmjni` is now built by default

Change-Id: I875d69ad37535d9e9dc3b661084e58b06d56e4a6
2025-01-30 19:10:24 +01:00
Giovanni Ricca
816150e7f7 fixup! msm8953-common: Remove vendor RenderScript implementation
Change-Id: I4b81e67be511e64c50ae053eba86a30ae3294191
2025-01-25 15:00:41 +01:00
LuK1337
9326e51bb9 msm8953-common: Switch to common lights HAL
Change-Id: If515e7c3f6e5b6895076f1d8381fb2c22bd1b3de
2025-01-25 12:25:18 +01:00
Michael Bestas
18e20d4d44 msm8953-common: Migrate mount point creation out of Android.mk
Change-Id: Id5986b8a740e45f864eecdd2bd82d9455f128d6b
2025-01-25 12:25:18 +01:00
Michael Bestas
bcd9eaa6fb msm8953-common: Update display flags & packages
Required after display HAL blueprint conversion

Change-Id: Idb002fc81fca3321f70fb3bba83f4af44354ce81
2025-01-25 12:25:18 +01:00
Michael Bestas
847a369884 msm8953-common: Remove OMX audio codecs
* OMX HW audio codecs won't work without QCOM A/V enhancements, which
   we don't have on Lineage.
 * OMX SW audio codecs no longer exist.

Change-Id: I940be6716b603e848c44839bb87ad690eb55e86f
2025-01-25 12:25:17 +01:00
Giovanni Ricca
44b82fe705 msm8953-common: Drop libmmosal_proprietary
* Seems to be unused.

Change-Id: Idd45fcdc4b25f7ae585aeddd115d0bdde91bbc06
2025-01-17 15:22:34 +01:00
Nolen Johnson
f5f2d3a22a msm8953-common: Drop libmm-color-convertor
* Follow up to prior commit.

Change-Id: Ic0e2e953f1f32256b61f8fb262f6fec1f83b109c
2025-01-17 15:22:34 +01:00
Giovanni Ricca
19890fdd2d msm8953-common: Drop libsensor_user_cal
* Nothing depends on it

Change-Id: Id2a24318808105f23d0b72b5a1312a7496f6fb1f
2025-01-17 15:22:34 +01:00
Jeferson
7fd3667fdd msm8953-common: Remove activity_recognition libs
* E ActivityRecognitionHardware: activity_recognition HAL is deprecated.
   is_supported is effectively a no-op

Change-Id: I2ea52288799e52424e984af25a8477e204b0df88
2025-01-17 15:22:34 +01:00
Bruno Martins
3edbce2dc3 msm8953-common: Mark CNE symlink target as required package
Change-Id: I0bfe65ba61b6aa9916fe6459be2a84d772939a2f
2025-01-17 15:22:34 +01:00
Giovanni Ricca
f6eef4a460 msm8953-common: rootdir: Android.mk -> Android.bp
* Also decommonize fstab as it would become a mess to maintain :D.

Change-Id: I1f1885af7d84c1be01dd257d99b43a84f4be49f6
2025-01-17 15:22:34 +01:00
Michael Bestas
c8904b898f msm8953-common: gps: Convert remaining Android.mk to bp
Change-Id: I75e6af92795fe755a48557aa06106406b14c6750
2025-01-17 15:22:33 +01:00
Michael Bestas
7ee57398ee msm8953-common: gps: Remove unused implementations
Change-Id: I079edea073f3ae43eaebbf04712e99ec1a931b10
2025-01-17 15:22:33 +01:00
Nolen Johnson
50ab32852a msm8953-common: Nuke update-sha1sums.py
* We have py extract to do this now.

Change-Id: I031938ddb78e8f343864da521dc577cfcb67ee45
2025-01-17 15:22:33 +01:00
Beverly
d80acf00d4 msm8953-common: Update lock icon padding
It should not change based on density changes.

Test: visual inspection
Bug: 264738021
Change-Id: I98f948b4a1bd7e6cc560f14e2e1b14a0bde76f01
2025-01-17 15:22:33 +01:00
Demon Singur
a6f9c193cd msm8953-common: Remove energy awareness daemon
All this does is to disable msm_core and set the
polling_interval to 0, which makes the driver useless.
We can achieve the same result by disabling the driver.

Change-Id: Ic19c505ed74811a3d1b76703255af3aa5cb37bf9
2025-01-17 15:22:33 +01:00
Giovanni Ricca
75f15fed3b msm8953-common: sepolicy: Allow poweroffalarm_app access to /persist
* There might be a case where `/persist/alarm` may have the wrong
  SELinux context applied. Allow access to `/persist` as a whole as
  fallback.

Change-Id: I72dbce4018db23f46d03f5389f0eec07e479632c
2025-01-17 15:22:33 +01:00
Giovanni Ricca
05cbe9a3d5 msm8953-common: Drop embms
Change-Id: Iaef95f45053690502018d7da7f9df999a5bc0c9b
2025-01-17 15:22:33 +01:00
Giovanni Ricca
2d7f0afc4c msm8953-common: Drop vendor.qti.hardware.qdutils_disp
Change-Id: Ic891ef77fce641d51fde0014b172709596f3b2b4
2025-01-17 15:22:32 +01:00
Giovanni Ricca
121125e712 msm8953-common: Drop cdsprpcd stack
Change-Id: Id29ad49334791ba1a1086481d21729736e7920de
2025-01-17 15:22:32 +01:00
Roberto Sartori
2862c64019 msm8953-common: Switch from time_daemon to TimeKeep
* time_daemon just refuses to work properly on mata.
    Sony's TimeKeep, instead, does the job flawlessly,
    so just ditch the former in favor of the latter.

Signed-off-by: Roberto Sartori <roberto.sartori.android@gmail.com>
Change-Id: I54f50ed3d49efc2834d478781b15e6ee428a3062
2025-01-17 15:22:31 +01:00
Giovanni Ricca
6e43c17714 msm8953-common: Decommonize screen density
Change-Id: I0c2c2723c0e9826c549e86dd591bc64893ce98cf
2024-12-10 09:46:21 +01:00
Giovanni Ricca
36aa01d84f msm8953-common: Document the disabled ELF check libs
Change-Id: I1a484ca2620131c36fca4a45112a53317021d24f
2024-12-10 09:46:21 +01:00
Giovanni Ricca
36a8a74baa msm8953-common: sepolicy: Guard debugfs rules
Change-Id: I194d54e207de56fa8df92f198f1e983b5ca6b213
2024-12-10 09:46:20 +01:00
basamaryan
c671d5bbc1 msm8953-common: Move to Xiaomi fingerprint AIDL
Change-Id: I68dba7184034fd37454c7d32a065f041cb611625
2024-12-10 09:46:18 +01:00
Devin Moore
46a15430f3 msm8953-common: Switch to new AIDL IR service
Test: atest VtsHalIrTargetTest hal_implementation_test
Bug: 205000342
Change-Id: I70c54aa8e8962939cc8f4b42fbbe828e9dad7f0d
2024-12-01 13:42:44 +01:00
ayongyuth
4eb952e68b msm8953-common: Fix Image size for Razor and RazorG by reduce Jounal size to zero
Bug: 21016403
Change-Id: Iaadd805dd5326b810e6dd83c1e509cab48995d9d
2024-12-01 13:42:44 +01:00
Giovanni Ricca
e4ae66498a msm8953-common: Use soong to copy gps configs
Change-Id: Ia1188567d250f228585e0e52f096112ac3233200
2024-12-01 13:42:43 +01:00
Giovanni Ricca
b6cfd8554f msm8953-common: Rename wcnss_service target
Change-Id: I638e8e40ea95b914ee3c36035704a4d55780d41f
2024-12-01 13:42:43 +01:00
Cosmin Tanislav
7616863d9f msm8953-common: do not manually build dependencies
Change-Id: I4046d8eeabfc70842898b7034f75cdd6bcfc441b
2024-12-01 13:42:43 +01:00
Aaron Kling
add9cc458e msm8953-common: Remove elf files in copy files check
New extract files uses packages instead of copy files

Change-Id: I337c07d13bd350958d4808e1693cc6e03753a96c
2024-12-01 13:42:43 +01:00
Giovanni Ricca
1e79be9012 msm8953-common: Import missing 32bit libs
Change-Id: Ic1fbd94452488e3ee318a59e9b9e9c4c7c0b94ee
2024-12-01 13:42:43 +01:00
Michael Bestas
d6b4318402 msm8953-common: Disable ELF checks for certain libraries
Change-Id: I61dbc3559b43becc22f69ae2c1c3e8edf95e2483
2024-12-01 13:42:43 +01:00
Michael Bestas
5b3bfd56c8 msm8953-common: gps: Remove all Wno-error flags
Almost all warnings/errors have been fixed.
Ignore undefined bool conversion error on purpose.

Change-Id: I00cb5f38711fa9f873da030fc6a0ebc6cde3ceeb
2024-12-01 13:42:43 +01:00
Kevin Tang
ba6de7e36f msm8953-common: gps: fixing LE build breakage and a warning
util/Log.h is not available for LE

Change-Id: I4cd654bb2a832a19dd4b78db61bd2a55484382c0
CRs-Fixed: 2679131
2024-12-01 13:42:43 +01:00
Michael Bestas
a8534c0c78 msm8953-common: gps: Resolve unused parameter warnings
Change-Id: I0acef3da2c3567a28edd0a71dac89a5828f7725d
2024-12-01 13:42:42 +01:00
Saurabh Srivastava
9359f5d80c msm8953-common: gps: Android mk to bp conversion
Change-Id: I206b4a5a2b7e88a6a20522611e7b2684594ef6f4
CRs-Fixed: 2559087
2024-12-01 13:42:42 +01:00
Dante Russo
3eabe8e480 msm8953-common: gps: Bringup changes for Lahaina
CRs-fixed: 2568895
Change-Id: Iec61f47c05009bdadb67bb236b9772cdeda99ec7
2024-12-01 13:42:42 +01:00
haohuang
2b62b05f33 msm8953-common: gps: Logging buffer implemented by skip list
Use skip list to implement a log buffer,
log sentences will be inserted into this buffer
once the log print function is called. the
buffer will be dumped when GNSS process
crash/killed or send SIGUSR1 signal manually.

Change-Id: I5e23cdf30c263fa59108070c9dbfd95c49c2e9b6
CRs-Fixed: 2571326
2024-12-01 13:42:42 +01:00
Dante Russo
6a3cb70cbe msm8953-common: gps: Remove libhidltransport & libhwbinder references
These libraries are no longer required and
references are removed for optimization.

Change-Id: I186befda34a7d53a3c8f1e80449639dd230b1e1b
CRs-fixed: 2559079
2024-12-01 13:42:42 +01:00
Giovanni Ricca
68e630e13b msm8953-common: Fix lib-imscamera ELF checks
Change-Id: I83c6ec68af801b17a1dd6e4aba74145cea355e8f
2024-12-01 13:42:42 +01:00
Giovanni Ricca
e7c1ea03b3 msm8953-common: Cleanup conflicting libs
Change-Id: I9361ad55f8aba96cc77bd8b0c7294a49ff999d10
2024-12-01 13:42:42 +01:00
Sebastiano Barezzi
fe41da9091 msm8953-common: Append _vendor to conflicting vendor libs
Change-Id: I74306c87e12079204223caccc0c77eacd4e01ec0
2024-12-01 13:42:42 +01:00
Aaron Kling
5c5792f0d3 msm8953-common: Add vendor soong imports to extract
Change-Id: Ib19e69dc35af6b04519eeb695228af65f3d01d2a
2024-12-01 13:42:41 +01:00
Aaron Kling
094c75230d msm8953-common: Enable elf checks
Change-Id: Ia6c9a381abb3384c77532d75e02fd84c841a4d1e
2024-12-01 13:42:41 +01:00
Kelvin Zhang
ac08671212 msm8953-common: Allow to access bootable/deprecated-ota targets
msm8953-common is still using non-AB update.
non-AB code will be moved to a separated namespace, add
deprecated-ota to msm8953-common namespace list ahead of time to avoid
breakage.

Test: th
Bug: 324360816
Change-Id: I909064be36e8febe80492cf010eb6eac3d6bc33d
2024-12-01 13:42:41 +01:00
dianlujitao
acf806d862 msm8953-common: Nuke ATFWD
It's normally not used at all.

Change-Id: Idb824b3b8c783b6ac962e604df05f9154beb4ed2
2024-12-01 13:42:41 +01:00
Michael Bestas
e98b943ffc msm8953-common: Shim widevine with libcrypto_shim
The following change
e202e51cb0
removed symbols that our libs require.

Change-Id: I1325c34ecec3d339dd68c665010ecb36fa2e6a29
2024-12-01 13:42:41 +01:00
Yumi Yukimura
e36cd47462 msm8953-common: Switch to QTI Memtrack AIDL HAL
Change-Id: Ibcbaff02fd56fbccc3a88c01a5f46a89cb212ef5
2024-12-01 13:42:41 +01:00
Giovanni Ricca
432af04ffc msm8953-common: Unset BUILD_BROKEN_DUP_RULES
Change-Id: Ideab7852287e28d8a4283332d7bf8b730ac4a014
2024-12-01 13:42:41 +01:00
Bruno Martins
bc2c8ea3d6 msm8953-common: Unset BUILD_BROKEN_INCORRECT_PARTITION_IMAGES
Qualcomm targets can now build hermetic partitions.

Change-Id: I241105e01d85fea983b34846ca675666ac07541b
2024-12-01 13:42:41 +01:00
Bruno Martins
9ea4a78187 msm8953-common: Convert WiFi firmware symlink to install_symlink target
The last bit that was preventing building hermetic images.

Change-Id: I75bb7de4593a7992f6015317cf97e088beeba0cb
2024-12-01 13:42:40 +01:00
Bruno Martins
779af5d92c msm8953-common: Declare IMS libs as symlinks during extraction
Change-Id: Ia1b8097d28dd4888232fe383b830515b1b9bafaa
2024-12-01 13:42:40 +01:00
Bruno Martins
1e1996b046 msm8953-common: Move to new RFS install_symlink targets
Change-Id: I9560fd0da00958d9349a0881b5a5f64a2c02e495
2024-12-01 13:42:38 +01:00
ix5
dfd38482ba msm8953-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 <wight554@gmail.com>
Change-Id: I28222c89e1e07017867088492a726ee9d45d8e6f
2024-11-15 23:26:02 +01:00
Giovanni Ricca
413795eb89 msm8953-common: Migrate to py extract utils
Change-Id: I2a7a0e7803940ef6105e55b88a94b7ba066a1929
2024-11-15 23:26:01 +01:00
me-cafebabe
4b27361aa4 msm8953-common: Change bluetooth.sco.disable_enhanced_connection 1 -> true
* In Android 14, `osi_property_get_bool()` treat it as true only if
  the property value equals to "true".

Change-Id: I8879a8cce4f82621624d760d7154e51a0a115fc0
2024-08-29 22:54:11 +02:00
Chirayu Desai
e0167e1f53 msm8953-common: rro_overlays: Move CarrierConfig to RRO
Change-Id: Ia57acd244608848f70fdcc30d5694c919db60671
2024-08-19 01:14:46 +02:00
Yumi Yukimura
95d6a697b5 msm8953-common: Kill androidboot.usbconfigfs=true kernel cmdline
* Wastes space

Change-Id: Iaf8a7b3de83381f58120aa41102d5bb8e699434b
2024-08-19 01:14:46 +02:00
Giovanni Ricca
0133597095 msm8953-common: Specify caymanslm source at the top
Change-Id: Iee0ae1f85148985edce4f06d3b3a40450d70877d
2024-08-19 01:14:46 +02:00
Giovanni Ricca
f766768c26 msm8953-common: Decommonize TARGET_TS_MAKEUP
* Only oreo (and below) targets actually use this feature.

Change-Id: I2e74031f99d4a473c4f214128b18d201f824d9d0
2024-08-19 01:14:46 +02:00
Michael Bestas
f071f9f5a9 msm8953-common: Remove media_codecs_google_c2*
AOSP codecs can be used by default and it is not necessary to include
them device side.

Change-Id: I8227b06f0466b614f12fa9008402b92461ea3dd0
2024-08-19 01:14:46 +02:00
Michael Bestas
6d9c85eaf0 msm8953-common: Use AOSP default Codec2/OMX ranks
Change-Id: Idf55ec02c2c0f4d2fa73f949cffef0d820a54570
2024-07-19 17:35:45 +02:00
Aaron Kling
b0e2d84c7b msm8953-common: Remove software omx codec references
These are no longer available as of Android 14 QPR3. The C2 codecs
available by default in the swcodec apex will be used instead.

Change-Id: I8cdf3e700823779a7382c66c3df8410d41209b7c
2024-07-19 17:35:45 +02:00
Sujin Panicker
8d9d0e33f9 msm8953-common: Set higher priority to c2 than OMX
Change-Id: If047caf630df17c9dfa94b67fab9f6259aa47e25
2024-07-19 17:35:45 +02:00
Paras Nagda
fee76362b5 msm8953-common: media: Finetune mediacodec performance values.
- Fine tune the performance xml based on CTS results.
- Update max instance for hevc and vp9 as per result
  on GSI.

Change-Id: I1f30158b4352f7c836b3b350798a72b3d856b2a3
2024-07-19 17:35:45 +02:00
Paras Nagda
f4c4bef4cd msm8953-common: media: finetune performance xml
- Fine tune entry for vp8 based on the cts results.
- Prefer HW codecs over sw.

Change-Id: I82e5e8b325c0843bb5b532afe84498e04fe790a9
2024-07-19 17:35:45 +02:00
Paras Nagda
2a1f1d223a msm8953-common: media: mark the target with slow cpu
This would enable low resolution for c2 sw codecs.
Reduce the max instance of hevc based on cts results.

Change-Id: I85f479f39d983fa7629128f1dfd9d4ad39aba381
2024-07-19 17:35:45 +02:00
Vasantha Balla
1ba528b7e7 msm8953-common: media: Update media codec performance values.
Enter values for c2 codecs as per results

Change-Id: I3eb117055cc8a3a2f50497dacf0598badc50a8a3
2024-07-19 17:35:44 +02:00
Sanjay Singh
238bb5dad3 msm8953-common: media: Added performance point tag for msm8953
Q version expects publishing of performance points.

Change-Id: Id32d96b57edd853cb450ce6ab3aa6e687ced131c
2024-07-19 17:35:43 +02:00
Han Sol Jin
506fdf405d msm8953-common: Explicitly disable protected management frames
This fixes support with WPA2/3 mixed access points; the primary issue
was that while this device doesn't support PMF, said access points try
to query for PMF in order to check for WPA3 support, which causes our
WLAN driver to die a painful death.

Disable it from the overlay, as AOSP enables it by default.

It's a wonder why it was enabled in the first place.

Change-Id: I89dbce7ae4c91cea9f1828e8b627a828e2b08011
2024-07-19 17:35:43 +02:00
Giovanni Ricca
952a3eaa80 msm8953-common: Drop parts once and for all
Change-Id: I910fc0283acab09125d173cc83410128c270b83b
2024-07-02 07:52:35 +02:00
Michael Bestas
2dae40961c msm8953-common: Build missing libraries for 14 QPR3
Change-Id: I6a84526ca1e9f4e5140c8068646433cab3fe85b2
2024-06-20 18:12:41 +02:00
Giovanni Ricca
cdf6330fb4 msm8953-common: Add atcmdfwd on framework compatibility matrix
Change-Id: I9943e6510a014523c3e13e2ff3599c5a1bd6135f
2024-06-20 13:36:29 +02:00
Michael Bestas
48c92b6cc6 msm8953-common: Inherit from legacy QTI FCM
Change-Id: I0bde1c273d4abe689f61e7d4ebcf80965d785489
2024-06-20 13:36:29 +02:00
Michael Bestas
51271b72fd msm8953-common: Include lineage FCM
Change-Id: Ib4408e941d920a3a38132ba1c8360994f5534c0b
2024-06-20 13:36:29 +02:00
Bruno Martins
f6cdc75377 msm8953-common: Inherit from QTI FCM
Change-Id: I0bdd4d63b60a1e29cdd69e71f7268932a105c16b
2024-06-20 13:36:29 +02:00
Tim Zimmermann
8ebfe97d32 msm8953-common: Set manifest target-level to 5
Change-Id: Ic72d17ebdb388dee9e63e27a36190c93c095fb0c
2024-06-20 13:36:29 +02:00
Bruno Martins
31f72c0c75 msm8953-common: Move to QTI health AIDL service
The health AIDL HAL service provides functionalities of charger,
therefore system charger at /system/bin/charger is deprecated.
On top of that, QTI health AIDL HAL service enables suspend by
default, the equivalent of setting ro.charger.enable_suspend
for legacy charger.

Change-Id: I59c23e7974cea1174b0161f31a535fa3afa1e5c9
2024-06-20 13:36:28 +02:00
Michael Bestas
234207a6da msm8953-common: Switch to QTI vibrator HAL
Change-Id: I911001c14167f7dfceb609090f7b90117310da07
2024-06-20 13:36:26 +02:00
Alexander Koskovich
c8da87d011 msm8953-common: Disable the usage of ConfigStore.
* As per commit
11a113a67e
("Add disable_configstore").

[SebaUbuntu] Remove manifest entry as well

Change-Id: I5482989a8a96227a3e2a5317eacf613c641bfa8e
2024-06-19 22:25:41 +02:00
Alexander Winkowski
f9a7b74d0c msm8953-common: overlay: Don't pin home app in memory
Similar to Ic2f9edd811879e3f18876a508273a9544d8a23e0, there is little
point in pinning the Home application.

Change-Id: I822de21e469d840994fb87c5eb2
2024-05-09 21:00:23 +02:00
basamaryan
da208fa37e msm8953-common: Don't explicitly include updatable_apex.mk
It is inherited by base_system.mk as of QPR2

Change-Id: I020a05b233f61ea28d03199cbc76051e6e97e1dc
2024-03-23 18:51:35 +01:00
Aaron Kling
c21776385c msm8953-common: Uprev usb hal to 1.3
Change-Id: I5d34c71663b31fe03b0d28f8c76e5a4f8cd2385c
2024-03-22 14:15:43 +01:00
Bruno Martins
da8fd9edee msm8953-common: Remove deprecated trust HAL
Change-Id: Ic5ac79b4ca60b87a97622877b97f806c07cab907
2024-03-22 14:15:42 +01:00
Yumi Yukimura
e9c0b201a5 Revert "msm8953-common: Switch to legacy WiFi HIDL HAL"
* WiFi AIDL HAL works in U QPR2
  (also, the legacy WiFi HIDL HAL has stopped working, lol)

This reverts commit ec336ce3f8.

Change-Id: I4d38fcc7e5999f934344bc364afb4f4d8a049711
2024-03-22 14:15:42 +01:00
Chaohui Wang
f42f488fce msm8953-common: parts: Migrate to CompoundButton.OnCheckedChangeListener
Switch and SwitchCompat are both CompoundButton.

Using CompoundButton in Java will helps migration in the future.

Bug: 306658427
Test: manual - check Settings pages
Test: m RunSettingsLibRoboTests
Change-Id: I85a70d4c504d8584030ea4a058f30d74206ab835
2024-03-22 14:15:42 +01:00
Peter Kalauskas
a22a3cb8d3 msm8953-common: parts: Enable use_resource_processor for all sysui deps
This will make the build faster

Test: m checkbuild
Bug: 295208392
Change-Id: I0c1bd901429bbe3bf81c1530e156735f8637a96e
2024-03-22 14:15:41 +01:00
Tomasz Wasilczyk
143f7d646d msm8953-common: gps: Don't include cutils/threads.h
Bug: 289414897
Test: buildserver
Change-Id: I14b99f42feaae7af00cbd17cfe482eb2e5da71e8
2024-03-22 14:15:41 +01:00
Cole Faust
eb47db6aad msm8953-common: Add BUILD_BROKEN_INCORRECT_PARTITION_IMAGES
Floral has issues that prevent it from working with a hermetic
partition build.

Bug: 205632228
Test: Presubmits
Change-Id: I490a29da38a6f68e7dd3650d8140cb11adaa8c7a
2024-03-22 14:15:40 +01:00
Bruno Martins
cb4b3c5576 msm8953-common: rootdir: Reconfigure ZRAM
This time around with ZRAM size set to 75% of total RAM size,
as per Qualcomm Android GO Performance Tuning Guide.

Change-Id: I8f8362ccb5110fba6c5ed50b5d87a0b94a48e01c
2024-03-18 14:06:45 +01:00
Dhina17
397a9475d2 msm8953-common: overlay: Drop useless config_pinnerCameraApp
- From this change [0], To pin the camera app, We need to set boolean phenotype property (DeviceConfig) "pin_camera" or fallback system
  boolean property "pinner.pin_camera" to true [1] even if the config_pinnerCameraApp config value set to true [2].

- Anyways, I don't pin the camera app since our device has low RAM.

Reference:
[0] - LineageOS/android_frameworks_base@599a834
[1] - b8404be70d/services/core/java/com/android/server/PinnerService.java (L103-L106)
[2] - b8404be70d/services/core/java/com/android/server/PinnerService.java (L180-L182)

Change-Id: Ia88de4775b3b60245e8eabce08b71c186e00d1c4
2024-01-24 13:19:25 +01:00
Jake Weinstein
0a1895e47f msm8953-common: Revert "fpc: keep fpc in system-background"
While Google found that fingerprint HAL is insensitive to
increased CPU throughput, we have not found that to be the
case and allowing more CPUs makes fingerprint unlock up to
2x faster in some tests.

This reverts commit d0fdb4431d26e4f257b8867f67ffd9b4a9818d9e.

Change-Id: I817f52e36530114cbd9185d88e44f38f379ff93b
2024-01-23 21:10:01 +01:00
Edwin Moquete
efa993ff4f msm8953-common: Disable display refresh rate override
This got enabled by default on U, and it causes apps like
Chrome and Youtube to set the refresh rate to 30FPS when
playing some videos.

Change-Id: I649bf03d550c2b9726c7957d15ed09e455d874ec
2024-01-21 22:54:30 +01:00
Yumi Yukimura
d4e9af0052 fixup! msm8953-common: Stop building VR HAL
* Considering msm89xx as VR high performance in 2023? lol
* The commit which introduced VR in this tree was
  42f734c8ef
  (I641c5f2bcbf31ff5a1dd26c9feb6209f7a5a633c)

Change-Id: I251fa87e4694e45347b078477ff4a00452e1b8e9
2023-12-09 18:49:29 +01:00
Giovanni Ricca
dae2985212 msm8953-common: rootdir: Setup zram with fstab
Change-Id: I4b172ee5c61693b5d6ae14b297374ff679f4938c
2023-12-06 09:33:12 +01:00
Sebastiano Barezzi
b34f24765d msm8953-common: biometrics: Move fingerprint HIDL to 2.3
Change-Id: I2e5ed64ac7ae2f1003503072666204c0788a003a
2023-11-13 14:47:05 +00:00
Sebastiano Barezzi
9742bfd13e msm8953-common: biometrics: Drop LOG_VERBOSE
* It's useless since it's the same as LOG_TAG

Change-Id: I1a15ea85f840b7af6d41b59cf01b0ec3c2457705
2023-11-13 14:44:56 +00:00
Bruno Martins
9bd64d18e8 msm8953-common: biometrics: Use pragma once
Change-Id: I335b0a1b73effa6f9c0b0866052d74dc524ad99b
2023-11-13 14:44:55 +00:00
Arian
c9d99efd6e msm8953-common: parts: Target current sdk
Change-Id: Ia623282960775569325714ab3bff5ad027776352
2023-11-13 11:50:25 +00:00
Arian
ed189e1a23 msm8953-common: parts: Get rid of HelpDialogFragment class
As preparation to upgrade the sdk get rid of this private class.
Fragments must be a public static class to be properly recreated from instance state.

Also change the behaviour to only hide the dialog when confirmed instead of also when it is cancelled.

Change-Id: I171aa2345058edae7520c37942c3c11b3cdfdfdc
2023-11-13 11:50:25 +00:00
Micheal
9148988164 msm8953-common: parts: Add an exported flag in manifest
Targeting S+ (version 31 and above) requires that an explicit value
for android:exported be defined when intent filters are present

Change-Id: I12d27c23624eb5259da582b86ac1bd7572754f0c
2023-11-13 11:50:20 +00:00
Rick Yiu
82d43214db msm8953-common: Remove some camera-daemon commands
Those commands have moved to init.rc.

Bug: 170507876
Bug: 171740453
Test: build pass
Change-Id: Icfe520e7f7367461607cc8fb5e524d9699e79124
2023-11-13 11:38:31 +00:00
Suren Baghdasaryan
f560ef2e32 msm8953-common: Replace writepid with task_profiles command for cgroup migration
writepid command usage to join a cgroup has been deprecated in favor
of a more flexible approach using task_profiles. This way cgroup path
is not hardcoded and cgroup changes can be easily made. Replace
writepid with task_profiles command to migrate between cgroups.

Bug: 191283136
Test: build and boot
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ibb56d2379c42e5ed4b2f15c1b04d5fb163b48678
2023-11-13 11:38:31 +00:00
Sebastiano Barezzi
324235bf2d msm8953-common: Raise VINTF target level to 4
Change-Id: I4c4783dc112102f127f3b1d796e206dcac672faf
2023-11-13 11:32:55 +00:00
Giovanni Ricca
5d13890b1d msm8953-common: Drop ILocHidlGnss manifest entry
* vendor.qti.gnss@3.0-service.xml has it already

Change-Id: I5b93d9b17bb5c6a841e8ec9f9ccefe8e95dec66f
2023-11-13 11:32:55 +00:00
Yi Kong
3ec107285a msm8953-common: gps: Fix unqualified-std-cast-call warning
hardware/qcom/sm8150/gps/utils/LocIpc.cpp:315:24: error: unqualified call to std::move [-Werror,-Wunqualified-std-cast-call]
            mIpcRecver(move(ipcRecver)) {}
                       ^
                       std::

Test: presubmit
Change-Id: I7378416e788f20ebb3f8d1d065d60964dc76eb99
2023-11-13 11:32:55 +00:00
Madhanraj Chelladurai
71cc80055d msm8953-common: gps: Add NULL check before object access
Correct the NULL check code block and add NULL check before
object access.

Change-Id: Ic41b781b41fb4e21bbff8801d500a41a6d7219d0
CRs-fixed: 3084543
2023-11-13 11:32:55 +00:00
Yingjie Wang
9a9597f374 msm8953-common: gps: Re-init battery listener when Health hal died
When system_server and health hal both died, battery listener
will get blocked in serviceDied. Make complete cleanup
for re-init.

Change-Id: I7ecc5b2e6e2aeb1e79ed45db94b05662eb9f37b9
CRs-fixed: 2640795
2023-11-13 11:32:54 +00:00
Erfan Abdi
0049f231bd msm8953-common: Set loop.max_part
Change-Id: Ibfb9e215c53111de4e8de018ea1934405468c6c9
Signed-off-by: Erfan Abdi <erfangplus@gmail.com>
2023-11-13 11:32:54 +00:00
Jiyong Park
2ce56ac9aa msm8953-common: Add updatable_apex.mk
The product abstracts configs that need to be set to support updating of APEXes.

Change-Id: Id5aa944ceba6a6846308f1c18a08af8b3bb38589
2023-11-13 11:32:54 +00:00
Giovanni Ricca
09d3a8cc08 Revert "msm8953-common: Force disable updatable APEX"
We will miss you :(

https://android-review.googlesource.com/c/platform/system/apex/+/2636909

This reverts commit 47aa83341a.
2023-11-13 11:32:54 +00:00
Alexander Martinz
76f10c994b Revert "msm8953-common: Disable APEX compression"
This reverts commit bd99b805a0.

Test: build, flash and boot device with flag reverted.
Test: boot GSI with compressed APEX enabled.

Change-Id: I5988614cc055d565b17a5c8d830e35feb0e33e92
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
2023-11-13 11:32:54 +00:00
Adithya R
8e4147819a msm8953-common: Switch to full IWLAN mode
[basamaryan: This is needed for Android U to fix RIL]

Signed-off-by: basamaryan <basam.aryan@gmail.com>
Change-Id: Ie3fa610f71077b4ee2af1b4d57bd0c30b34f30fa
2023-11-13 11:32:53 +00:00
Giovanni Ricca
f1287dd679 msm8953-common: rootdir: Tissot doesn't have a vendor partition
* Mi8953 in his true form :P

Change-Id: I43da62492c22f51e49ffb84830a99250dced8ae5
2023-11-13 11:32:53 +00:00
Chenyang Zhong
4836a2cb13 msm8953-common: Specify androidboot.boot_devices
So that /dev/block/by-name/ symlinks are created.

Signed-off-by: Chenyang Zhong <zhongcy95@gmail.com>
Change-Id: I270c1899e4487ed5e7657038c4ed07e407476953
2023-11-13 11:32:53 +00:00
Sebastiano Barezzi
c948e3c7e6 msm8953-common: Switch to two-stage init mounting
* Stop handling cust and vendor mounting from kernel, first stage init is gonna do that, together with system (which is now /system)
* Use correct mount flags coming from kernel dts
* Move system, system_ext and vendor mount points to /dev/block/by-name/, we don't have bootdevice symlink to that point in init
* Copy fstab to ramdisk for first stage init

Change-Id: If8d75837f47c70f7ea02183bffaff233b4d6bb26
2023-11-13 11:32:53 +00:00
me-cafebabe
ec336ce3f8 msm8953-commom: Switch to legacy WiFi HIDL HAL
* With the new WiFi AIDL HAL, the framework thinks the device
  supports interface combination for some unknown reason,
  even though the service doesn't advertise it. As a result,
  the WiFi service fails on configureChip method.

Change-Id: I0c3fa7b4c947c3525c30f7cef0b2674bee224da7
2023-11-13 11:32:52 +00:00
me-cafebabe
7dacfd60b5 msm8953-common: libstdc++.vendor => libstdc++_vendor
Change-Id: I478eb89aa2ac106d855b168844863032612bc8e8
2023-11-13 11:32:52 +00:00
LuK1337
8316d3cb4f msm8953-common: Use libutils-v33 for pm-service
Change-Id: Ia998fa72d8747de18010abe6491d2c374cb7aa0a
2023-11-13 11:32:52 +00:00
LuK1337
db9ee175a1 msm8953-common: Build android.frameworks.sensorservice@1.0.vendor
Required by mm-pp-deps.

Change-Id: Iaf821dcbb07d7820f2fc3ff5ca9cca5e973360f2
2023-11-13 11:32:52 +00:00
Gabriel Biren
d4ce73f564 msm8953-common: Update makefile to use the AIDL Wifi Vendor HAL.
Bug: 274964641
Test: Pre-submit tests
Change-Id: I4d9114377fe75b593bbfe6a59f03d8f5d607d6a1
2023-11-13 11:32:51 +00:00
Giovanni Ricca
73d2b22e27 msm8953-common: rootdir: Don't read bluetooth.hciattach
* Unused with our current stack anyway

Change-Id: I80dda7f78dca91bd6b1c6f200a885045048f597f
2023-09-18 01:06:48 +02:00
Giovanni Ricca
2a46ce1cdd msm8953-common: rootdir: Don't start gamed
* We don't have this service

Change-Id: Ifa583998ec12343ff3fc0d783604520172832114
2023-09-18 01:06:47 +02:00
Giovanni Ricca
ea153565e2 msm8953-common: rootdir: Don't set store_user nodes to 0
* Not only they throw an useless denial on boot, they are already on 0

Change-Id: I6407e2293a3df47796ff5beebe3349c67a0ce715
2023-09-18 01:06:47 +02:00
Nolen Johnson
a5063eab2b msm8953-common: sepolicy: Allow hal_gnss_qti to get xtra_control_prop
Change-Id: I6eeeeb2a42b4d0c3e934af3da9ab3aaa2d4c10b4
2023-09-18 01:06:47 +02:00
Nolen Johnson
41de346640 msm8953-common: sepolicy: Resolve BPF denials
Change-Id: I3a4ec030a6c56f0a7a8df1b510bc9636eb74c8bd
2023-09-18 01:06:47 +02:00
Erfan Abdi
6cd38df0d3 msm8953-common: rootdir: Disable qemu.hw.mainkeys setprop
We are enabling software navigation bar using overlay. Thus, this is
not required. Not to mention, this causes SELinux denials as well.

selinux: avc:  denied  { set } for property=qemu.hw.mainkeys pid=1262 uid=0 gid=0 scontext=u:r:qti_init_shell:s0 tcontext=u:object_r:default_prop:s0 tclass=property_service permissive=0
Change-Id: I6f641bcde6b55ccc9a0ccad98b00de938d62d00f
2023-09-16 17:12:10 +02:00
Nolen Johnson
921e7f7390 msm8953-common: sepolicy: Label discard_max_bytes
Change-Id: Ic4ced7dd219b5981f9327b55d4ac5a69d8504900
2023-09-16 17:05:18 +02:00
Giovanni Ricca
d29cc1a3fc msm8953-common: sepolicy: Label Extcon nodes
Change-Id: Ic994af95fcd32d41ff9758a35a9496dd28280945
2023-09-16 16:53:10 +02:00
Dhina17
d4ee93d696 msm8953-common: Drop audiosphere
AudioSphere post processing is used to add
virtualization effect to audio playback on stereo speakers.

It's supported by neither our stock nor CLO for msm89xx.
Plus our device don't have stereo speakers.

Change-Id: I1b985ec97d5edee529cac00e6c21f8eb64c1b19a
2023-09-16 13:52:52 +02:00
Georg Veichtlbauer
2d4f521e08 msm8953-common: rootdir: Setup all the sub-system as related.
They can restart itself, but let the phone keep
running instead of triggering an reboot.

Change-Id: Idc486acbd6bb091fc9fddc7a0d876824215a757b
2023-09-12 20:06:18 +02:00
Nolen Johnson
5a93f5b8f7 msm8953-common: Explicitly disable AVB
* This allows infra to sign successfully, I hate it, but it builds,
  boots, and works fine enough as a workaround.

* The underlying issue is that this flag causes avbtool args and location
  to be set in `misc_info.txt` whereas before it was not.

Change-Id: I7bdf237ec30d692c7d8b5c626a6e761e2c1a2593
2023-09-12 20:06:18 +02:00
Giovanni Ricca
85b6ca4249 msm8953-common: Switch to fragmented defconfigs
Change-Id: I5c3a7c41a9764221a2872830abf078ecc2cdf192
2023-09-12 20:06:18 +02:00
Giovanni Ricca
fc92fe6918 msm8953-common: Drop TARGET_KERNEL_VERSION
* Uneeded since https://review.lineageos.org/c/LineageOS/android_vendor_lineage/+/357531

Change-Id: I6df78f445c917b82bdc22eacf05c6f4242a789c3
2023-09-12 20:06:18 +02:00
bohu
d57dbd3160 msm8953-common: Set ro.crypto.volume.filenames_mode to aes-256-cts
BUG: 129557601
Test:
CtsAppSecurityHostTestCases android.appsecurity.cts.AdoptableHostTest

Change-Id: I414e76714a55531f095de757d0bec066cf350f8b
2023-09-12 20:06:17 +02:00
Michael Bestas
bf7a2fdeb8 msm8953-common: ueventd: Remove all permissions from /sys/devices/soc0/serial_number
Change-Id: I688347cfe59f56e4de2e4bf3c3324ca465f7a897
2023-09-12 20:06:17 +02:00
Michael Bestas
bcd545d091 msm8953-common: Implement xtra-daemon control via property
Default to false if the property is not set.
Device init scripts will need to be adapted to restart
loc_launcher service when property change is detected.

Change-Id: Icbda789cd2a9a3391f437af2c07fc5127f2f09ab
2023-09-12 20:06:17 +02:00
Kevin Tang
b4e658c323 msm8953-common: gps: Remove XTRA version check.
Remove legacy XTRA version check as it is
deprecated.
Update the xtra time url.

CRs-Fixed: 2684513
Change-Id: I8566d367c6a7ccebf295836b4c8d46509a428044
2023-09-12 20:06:17 +02:00
Michael Bestas
93cf315760 msm8953-common: gps: Remove all Wno-error flags
Almost all warnings/errors have been fixed.
Ignore undefined bool conversion error on purpose.

Change-Id: I00cb5f38711fa9f873da030fc6a0ebc6cde3ceeb
2023-09-12 20:06:17 +02:00
Albert I
6dab3f496c msm8953-common: gps: Implement list empty error code for msg_q
This fixes enum-conversion warning due to implicit type enum casting
between linked_list and msg_q which happens only for status -6.

Change-Id: I27ba74c4d840b7ba0cb1017d69a30fc25b80d6b9
2023-09-12 20:06:16 +02:00
Albert I
30c9bafae6 msm8953-common: gps: Reorder initializations list to satisfy warnings
-Wreorder-ctor is a compile-time, Clang-only flag which is enabled by
default since Clang 12, which will warn whenever a specified field will
be initialized right after field specified below it. However, since it
doesn't sweep through all fields, compiler may miss some of them.

This order has been checked thoroughly through many trial and errors to
ensure that no such warns will be triggered anymore.

Change-Id: Id24cbb7277dc8d6c02767f8f365818ab6c017683
2023-09-12 20:06:16 +02:00
Giovanni Ricca
2a8bd459b6 msm8953-common: sepolicy: Set vendor_fp_prop to restricted
Change-Id: I4d1428e4a7c2b94645c5de516eea632f1d3411d4
2023-09-12 20:06:16 +02:00
Nolen Johnson
a2da82198c msm8953-common: sepolicy: Allow FMRadio app what it needs
Change-Id: I3392ffb28cea6a80f3b9e493920a3bdfbee9dce7
2023-09-12 20:06:16 +02:00
Michael Bestas
a5aee13932 msm8953-common: Automatically add apk/jar/vintf fragments to PRODUCT_PACKAGES
Change-Id: Iaa9d66b0bbdc55f046ee1347cbf83c7eecebb35e
2023-09-12 20:06:16 +02:00
Georg Veichtlbauer
5ba494352b msm8953-common: Fix PowerOffAlarm
* The APK is prepared to not run as system user
* Adjust /persist/alarm/data permissions accordingly

Change-Id: Ie24ccb3749d1dda2deb670cdb531e35d153034ed
2023-09-12 20:06:15 +02:00
Qimeng Pan
737aceef21 msm8953-common: rootdir: add power_off_alarm into init.rc
Add power_off_alarm into init.rc on charge mode

Change-Id: I18158cde8b3ae0890a92bd1ced56782fa053230a
CRs-Fixed: 2373093
2023-09-12 20:06:15 +02:00
Mao Jinlong
2e47fe50dc msm8953-common: rootdir: Add vendor prefix to power_off_alarm service
power_off_alarm is a vendor service. Add vendor prefix to it.

Change-Id: Ib4a988467a54bbe4544960180afeeeb5dd0e85f3
2023-09-12 20:06:15 +02:00
Mao Jinlong
3cd3f87a1d msm8953-common: rootdir: Add power off alarm service
Add power off alarm service for power off alarm feature to
reboot device when power off alarm is up in some special
mode like power off charging mode.

CRs-Fixed: 2095984
Change-Id: Ib8d82e63e92a85a7f60d5559064a1f19e0de5a22
2023-09-12 20:06:15 +02:00
Giovanni Ricca
e5cc6fde61 msm8953-common: Enable Qcrild
Change-Id: I6eec8ed7b81acde0904d47ec6707a680b513318d
2023-09-12 20:06:12 +02:00
Giovanni Ricca
84846914f2 msm8953-common: Commonize qcril blobs
This reverts commit 9a0c0303d5.

Change-Id: Ie486479236154d91d8857baa59c5ef1ceacfd1c3
2023-05-22 08:22:34 +02:00
OnlyTomInSecond
5e5181a2e7 msm8953-common: Set block_binder_thread_on_incoming_calls prop
In order to fix incoming calls.

Change-Id: Id474622f3e08b88f1d099e3d6507fd1d84de4d88
2023-05-21 11:47:33 +02:00
Tim Lin
331e2e7f1a msm8953-common: qcril: fix MT SMS sent during power off
qcril will block any further MT SMS if previous one is not ACKed.
For this bug, IMS service is not ready and resulted in qcril stuck in blocking state.
This solution will add 30s timer to reset blocking state if there is no ACK from Telephony.

Bug: 169549852
Test: MT SMS during power off
Change-Id: I6f52170654925143aeb55f8bc0cf4c379717e718
2023-04-19 12:05:45 +02:00
Bruno Martins
b1b63fc994 msm8953-common: parts: Fix compilation for QPR1 merge
Change-Id: I71ad7db85592ca18e3f0f8155bba5a472bfadbaa
2023-04-19 12:05:44 +02:00
Bruno Martins
20b115feb5 msm8953-common: parts: Move XiaomiParts to /system_ext
Change-Id: Ic3ed16bb0bea98d9dd5da96da63c65ebe735036a
2023-04-19 12:05:44 +02:00
Bruno Martins
20f95cb9fc msm8953-common: parts: Use all shared resources from devicesettings
Change-Id: Icd7f381c574ea36eb4d797cefd60ba9f1a0941bd
2023-04-19 12:05:44 +02:00
Timi Rautamäki
3d7ddbbb4b msm8953-common: switch to threaded Skia render engine backend
´threaded´ option has issues with night light, etc.

Co-authored-by: Michal Pražák <michal.prazak1@gmail.com>
Change-Id: I142b95a38bf664f54c12d5c17ab11214375f705b
2023-04-19 12:05:44 +02:00
Nolen Johnson
6dcab244ed msm8953-common: Enforce EPPE
Change-Id: Ib7934f55293a3757e29c503e0613c0dab9a4381d
2023-04-19 12:05:44 +02:00
Etienne Ruffieux
0e8301720f msm8953-common: Removed audio A2dp from device.mk
Bug: 220306859
Test: atest
Tag: #feature
Change-Id: I300369d36399ffb558b98bafc2478b872d09faba
2023-04-19 12:05:43 +02:00
Nolen Johnson
755c66409b msm8953-common: AOSP WFD doesn't support protected Wi-Fi Display buffers
Change-Id: I971373b5c57b8591b1bf676849cc511f8a425023
(cherry picked from commit d52231052828d4390d630681d651874ffb50388b)
2023-04-19 12:05:43 +02:00
Georg Veichtlbauer
1c8dff8c7b msm8953-common: Drop config_setColorTransformAccelerated
It's now enabled by default

Change-Id: I57f059c872fc2ad2fd15e788b1391eeebaff9bde
2023-04-19 12:05:43 +02:00
Santiago Seifert
c6b83f7eb8 msm8953-common: Unpin updatable-media from memory
Bug: 214499288
Change-Id: I4823afa45553b9484ad5215d081b0e6635c4b183
Test: Presubmit
2023-04-19 12:05:43 +02:00
Les Lee
847387d3cf msm8953-common: wifi: Configure correct overlay configuration.
ag/16564596 will change default value to false.
Configure correct overlay configuration.

Bug: 212488775
Test: manual test & build
Change-Id: Iaf1a0a23dae69fde5995e591a757a8ef5374d5b5
2023-04-19 12:05:43 +02:00
Sevenrock
0b0107fa73 msm8953-common: add ro.hw_timeout_multiplier
Fixes watchdog kicking in while formatting huge sdcards.

Change-Id: I60e8acff8a9f113e3f12f31061e0bb9b1fe24e46
2023-04-19 12:05:42 +02:00
Woody Lin
89070329cb msm8953-common: Enable zygote critical window
Bug: 141948707
Change-Id: I5dc57312118b0f6d95fc9fe164363ec7e15f1b51
2023-04-19 12:05:42 +02:00
Mohammed Mirza Mandayappurath Manzoor
08d8cedc8e msm8953-common: ueventd: Set permissions for KGSL sysfs node
Some KGSL sysfs nodes need to be access controlled. Set proper
permissions for the same.

Change-Id: Idc7e2447d02742074873901c6539f2c6d9d25862
2023-04-19 12:05:42 +02:00
Bruno Martins
61db34ecdd msm8953-common: Migrate to AIDL ClearKey DRM HAL
Change-Id: Iad5cc1176978137c647069197b33f49fb4d98ab2
2023-04-19 12:05:42 +02:00
Bruno Martins
ce22b48613 msm8953-common: Drop default DRM service
This is not needed, since Widevine DRM and Clearkey DRM
services are available.

Change-Id: I97023f1bab88ddb8fa4cb205df190c516a759951
2023-04-19 12:05:42 +02:00
Sebastiano Barezzi
1fd70f0d65 msm8953-common: Drop QTI camera device usage
* qcom-camera topic hasn't been ported to 19.1
* Keep building vendor.qti.hardware.camera.device@1.0 interface lib, IMS stack and possibly camera HAL still needs it

Change-Id: I87bcd5b54ad986d5844df50de243fc1a18507198
2023-04-19 12:05:41 +02:00
Sebastiano Barezzi
27437ba160 msm8953-common: Remove USE_DEVICE_SPECIFIC_CAMERA
* Doesn't exist

Change-Id: I10fc7de8721f3c871d00522e1d85c2a8d8c18160
2023-04-19 12:05:41 +02:00
Bruno Martins
ef87c4f705 msm8953-common: Drop custom APM flag
Custom audio policy manager is hard disabled by CAF
for 2 years now.

Change-Id: Idd34d1cbbdb735d6cf0de3b159c2670bf7ddd1e3
2023-04-19 12:05:41 +02:00
Alexander Martinz
0140717e1b msm8953-common: audio: fix VTS
Using "dynamic" is invalid according to xml schema
"audio_policy_configuration_V6_0.xsd".

Test: atest VtsHalAudioV6_0TargetTest
Test: atest VtsHalAudioEffectV6_0TargetTest

Change-Id: Ic1660f0d593f83e5568a4ad678383e600e27b793
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
2023-04-19 12:05:41 +02:00
llololo
b0e15c2fac msm8953-common: Remove A2DP input module in audio policy configuration
No Pixel device support A2DP sink functionality.

Bug: 163050296
Test: A2DP related test.
Change-Id: I269220cf29451ea79362fc004fa073713f72fdb2
2023-04-19 12:05:41 +02:00
me-cafebabe
b8296e3fa7 msm8953-common: Disable bluetooth enhanced SCO connection
Change-Id: Ib8013cf76a176fc3214d1ab57b77b63b85a1741b
2023-04-19 12:05:40 +02:00
Michael Bestas
ccc6857a3c msm8953-common: Remove bdroid_buildcfg.h
As of I3c7aed1bdb45db728d319f7d757400e44d232283 the Bluetooth stack
defaults to reasonable defaults that should work for all devices.

Change-Id: I056d63c4c8a2727e384172e964dc0000b6773504
2023-04-19 12:05:40 +02:00
Bruno Martins
c591bf9aeb msm8953-common: Remove QTI BT stack bits
Change-Id: Ice6c2b0735aa7cb4b2e638a794c778883e706c97
2023-04-19 12:05:40 +02:00
Bruno Martins
384338ae9a msm8953-common: Drop component overrides
This is no longer needed as of Android 13.

Change-Id: I38435c47c8781678f82014decbbae40dcab0a07b
2023-04-19 12:05:40 +02:00
Georg Veichtlbauer
960f881b7e msm8953-common: Move Bluetooth power config away from overlay
Same values go to:
- power profile xml for power calculation
- vendor props for the A13 BT stack

Change-Id: I04dbb8736a599c4798223f7e3e317b2fcc873ded
2023-04-19 12:05:40 +02:00
Alice Kuo
5dc16f86d8 msm8953-common: Disable LE audio related profiles
Bug: 231671426
Test: build
Change-Id: I78e2ddfc636a0fa31b977b5f9ba9a7d7bc0f2a26
Merged-In: I78e2ddfc636a0fa31b977b5f9ba9a7d7bc0f2a26
(cherry picked from commit acb0b19b8348a4b9518d2f46b1599f423f620347)
2023-04-19 12:05:39 +02:00
Sal Savage
d0a2eee258 msm8953-common: Use the ?= operator so BT properties can be overridden
System properties set with the "=" operator cannot be overriden. This
device is used elsewhere in the system and some of the properties need
to be overridden. The "?=" operator will use the assigned value if no
other values are assigned elsewhere, allowing for overrides.

Bug: 230638462
Test: adb shell getprop | grep bluetooth
Change-Id: Id6cd7901555edafef141bbc1bbd5e06dc3a54d0c
2023-04-19 12:05:39 +02:00
Sal Savage
388e89a9e8 msm8953-common: Set default the Bluetooth class of device
The class of device is a string with a list of uint8t values:
90,2,12

The meaning is as follows:
{Service Field, Major class, Minor class}

Service Field: 0x5A -> 90
    Bit 17: Networking
    Bit 19: Capturing
    Bit 20: Object Transfer
    Bit 22: Telephony
MAJOR_CLASS: 0x02 -> 2 (Phone)
MINOR_CLASS: 0x0C -> 12 (Smart Phone)

Bug: 217452259
Test: make -j; -- check that bluetooth.device.class_of_device is
correct

Change-Id: I24fd57bacbf6786a26f7079e7a6e9857dbe170d1
2023-04-19 12:05:39 +02:00
Sal Savage
194b93effb msm8953-common: Update LE Audio profile properties to match spec and implementation
Bug: 217448211
Test: atest BluetoothInstrumentationTests
Change-Id: I9312b9b70b51603aca6da6f4081533ab73c1614d
2023-04-19 12:05:39 +02:00
Alexander Koskovich
6f2ba9923a msm8953-common: Move BT profiles props to vendor
* Makes it GSI compatible

Change-Id: I8f7caf241d508af59c16482e6185c42f23f8a460
2023-04-19 12:05:39 +02:00
Sal Savage
f8344bc1d8 msm8953-common: Enable bluetooth profiles with product.prop
Bug: 217448211
Test: make -j
Change-Id: Idd7e52b7822915ed61299f1c0b29bf87ca0339fe
2023-04-19 12:05:38 +02:00
Josh Wu
23739d94af msm8953-common: Switch BtAudio to AIDL
Test: m
Bug: 203490261
Change-Id: I4b8ac40d5ad410b89eb6a0573d740d86471ecfc7
Merged-In: I4b8ac40d5ad410b89eb6a0573d740d86471ecfc7
2023-04-19 12:05:38 +02:00
Jakub Pawlowski
c3dc95363b msm8953-common: Use bluetooth.audio@2.1
bluetooth.audio@2.1 adds new functionalities required for Bluetooth LE
Audio development

Bug: 150670922
Change-Id: Iac2ece0c029a38fef82e81f5ba3ba491163818ef
2023-04-19 12:05:38 +02:00
LuK1337
312973b340 msm8953-common: Rework way to prevent adding duplicate dependencies
Change-Id: I2eb6484dbe3a9fddc883bf1290da1b76c4e1c54c
2023-04-19 12:05:38 +02:00
Nolen Johnson
dd02e1f6dc msm8953-common: Move to libhidl shim in hardware/lineage/compat
Change-Id: Ia2cd305baf3ce0fa7ac52d440a4ff51f94654438
2023-04-19 12:05:38 +02:00
Nolen Johnson
eb8160db31 msm8953-common: Move to libgui shim in hardware/lineage/compat
Change-Id: I04c4e15c6128de33ab7124de28b2fbd82eb2d62a
2023-04-19 12:05:37 +02:00
Nolen Johnson
1f56e5f420 msm8953-common: Move to libcutils shim in hardware/lineage/compat
Change-Id: I96b8485c1a868e271607cf205ac1366dc77f69d0
2023-04-19 12:05:37 +02:00
Giovanni Ricca
eb88348f05 msm8953-common: Drop HALv1 once and for all
* Has been deprecated on aosp-12

Change-Id: I02d5f320db9243c04d89d58fef775dfe33fe4ac7
2023-04-19 12:05:37 +02:00
Giovanni Ricca
df2c0a07c9 msm8953-common: Remove reorder libs script
* Is now inside tools/extract-utils/

Change-Id: Ia7682e69b388bc82877a0d62c4bf2def8e787d3f
2023-04-19 12:05:37 +02:00
Manoj Basapathi
aac36026db msm8953-common: Remove unused fast dormancy persist property.
[    7.265723] audit: type=1107 audit(129718197.409:4): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=u:r:init:s0 msg='avc:  denied  { read } for property=persist.env.fastdorm.enabled pid=0 uid=0 gid=0 scontext=u:r:vendor_init:s0 tcontext=u:object_r:default_prop:s0 tclass=file permissive=0'

Properties which are related to the fastdormancy apk
are removed. Legacy fast dormancy code is obsolete and removed
all its instances.

CRs-Fixed: 2748503
Change-Id: I7a2bd24d78bb49765af59c933eca4503015b6792
2023-04-19 12:05:37 +02:00
dianlujitao
ddf6526d8a msm8953-common: Don't apply persist.vendor.usb.config
* Otherwise adb turns on after reboot every time.

Change-Id: I66631f1f38a3e3a16e6d3dad87c83d0a98e6f851
2023-04-19 12:05:37 +02:00
Jorim Jaggi
3d02cb444b msm8953-common: Disable sdm rotator downscaler
Rotator down scaler is causing additional delays that are better
handled by GL composition.

Test: Open app, no jank
Bug: 73640835
Change-Id: I6ea9baa28acc222afcf365f3bf107149bc8974d9
2023-04-19 12:05:36 +02:00
Dominik Baronelli
289846f5f4 msm8953-common: disable scaler
Test: Add clock widget with moving clock arm to homescreen.
      With enabled scaler there is obvious flickering.
      With scaler disabled, the flickering is gone.

Change-Id: I68e32bfa01eec4e74c2190b4afbb780b9353ffbb
2023-04-19 12:05:36 +02:00
Giovanni Ricca
a880e78558 Revert "msm8953-common: properties: don't latch unsignal buffers"
* The props actually helps us reducing some lags/janks we currently have

This reverts commit f8853496f5.

Change-Id: Ie2588ac21f844e0b0f96d601c54e8f71fc1ffa1e
2023-04-19 12:05:36 +02:00
dianlujitao
61f9a7d01b msm8953-common: Build new GNSS HAL
* Remove unnecessary dependencies on liblbs_core.so
 * Hardcode vendor loc HIDL version to 3.0 to enable vendor HIDL when
   building w/o BSP.

Change-Id: I01f661f1d1e038737801f5a9db88e3388d470f74
2023-04-19 12:05:36 +02:00
Michael Bestas
5b47152a9e msm8953-common: gps: Lower debug level
* Kill logcat spam

Change-Id: I20d1f698d3c2d1b56e79f6eb6c5c17069e43c60f
2023-04-19 12:05:35 +02:00
Ethan Chen
8e810d6eb7 msm8953-common: gps: Increase batch size to max
* Hardware supports 40

Change-Id: I075fff615814fa105ec1493c5bdde60b8abccf0e
2023-04-19 12:05:35 +02:00
TheStrix
8c8dad85c8 msm8953-common: gps: disable unused location services
* Disable XTWIFI

Change-Id: I70f39d8d611167f65bb3912590b05f8a8d121c80
2023-04-19 12:05:35 +02:00
dianlujitao
96f28cdc70 msm8953-common: Fix non-ASCII character in gps.conf
:caf:

Change-Id: Iea9c44c0fbad574cbc077feea3d9f1de83d7d99a
2023-04-19 12:05:35 +02:00
Giovanni Ricca
ffc32a7dc0 msm8953-common: gps: Pull gps configs from daisy
Change-Id: I437ca5388a6070108da1fb9d314d424658f75c49
2023-04-19 12:05:35 +02:00
Michael Bestas
6e9df9ae75 msm8953-common: gps: Ignore some build warnings
Change-Id: If1dfd39ab820cdf5e7ac5caf05dc8fea1cd95235
2023-04-19 12:05:34 +02:00
Michael Bestas
931fadb6eb msm8953-common: gps: Resolve unused parameter warnings
Change-Id: I0acef3da2c3567a28edd0a71dac89a5828f7725d
2023-04-19 12:05:34 +02:00
Giovanni Ricca
af2b1e73e4 msm8953-common: Import Gps hal
* from LA.UM.8.6.r1-02600-89xx.0

Change-Id: I9cead1517e71e1ae9381e6435ca746033d9a1446
2023-04-19 12:05:34 +02:00
me-cafebabe
721a333301 msm8953-common: Legacy devices doesn't support ICE Encryption
Change-Id: I07003e50aea9a8fe5bf59437e769166c8dcd4668
2023-04-19 12:05:34 +02:00
Nicholas Lim
00edd4169b msm8953-common: Drop FDE support entirely
Change-Id: Ifecd15ee6c86a4571e5a7cc961372348455c4d5c
2023-04-19 12:05:34 +02:00
Anver sadhique
228384abfc msm8953-common: audio: set valid and supported channel mask for earpiece
For earpiece to be properly enumerated as a output device,
set valid and supported out_ channel mask.

Change-Id: Ic83b009956ff43567b3acbb186d0069b16e91e83
2023-04-19 12:05:33 +02:00
Shalini Manjunatha
8c7fd2d3fa msm8953-common: audio: Use AOSP implementation for sw effects
Change-Id: Iae6212f135fc4cc7bfb0528380daf9f13101a2ec
2023-04-19 12:05:33 +02:00
Bruno Martins
3359e801bb msm8953-commom: sepolicy: Add rules for older IMS blobs
Since Android 10 blobs are being used, org.codeaurora.ims still runs as phone UID as seen by these denials:

  m.android.phone: type=1400 audit(0.0:2914): avc: denied { read } for name="u:object_r:qcom_ims_prop:s0" dev="tmpfs" ino=13660 scontext=u:r:radio:s0 tcontext=u:object_r:qcom_ims_prop:s0 tclass=file permissive=0
  m.android.phone: type=1400 audit(0.0:473): avc: denied { call } for scontext=u:r:radio:s0 tcontext=u:r:hal_imsrtp:s0 tclass=binder permissive=0

Change-Id: Ic8c1b7996b9e0e7b63ba2a153441c9e8467a8a31
2023-04-19 12:05:33 +02:00
Giovanni Ricca
1cca8f4709 msm8953-common: sepolicy: Drop chargeonlymode rule
* We don't ship it anymore

Change-Id: Iaca9ea838759cf47f211ddd1b53f5dc6dab17df5
2023-04-19 12:05:33 +02:00
Giovanni Ricca
dd09bf512d msm8953-common: sepolicy: Drop goodix init script rules
* Unused since we switched to oss biometrics hal

Change-Id: I77239dabb2c533bfa09f0bd109351bf85923db74
2023-04-19 12:05:33 +02:00
Giovanni Ricca
c4535611ca msm8953-common: sepolicy: Allow system to set fingerprint props
05-06 11:44:22.514     0     0 E init    : Unable to set property 'persist.sys.fp.info' from uid:1000 gid:1000 pid:884: SELinux permission check failed
05-06 11:44:22.514     0     0 E init    : Unable to set property 'persist.sys.fp.vendor' from uid:1000 gid:1000 pid:884: SELinux permission check failed
05-06 11:44:22.516     0     0 E init    : Unable to set property 'persist.sys.fp.factory' from uid:1000 gid:1000 pid:884: SELinux permission check failed

Change-Id: Ia7ff2905143cb889722c5c773e1cea0897fc9d4d
2023-04-19 12:05:32 +02:00
Giovanni Ricca
9ae1cf9e7b msm8953-common: sepolicy: Checkout fingerprint selinux policy from asus/msm8937-common
Change-Id: I20ddaf6bd0a7df3a7ac56b851e2533c142a197ad
2023-04-19 12:05:32 +02:00
Giovanni Ricca
1a4d1a84a8 msm8953-common: sepolicy: Address camera denials
Change-Id: I5d4377f81376242321d3d709a1081fc2b75d6633
2023-04-19 12:05:32 +02:00
Giovanni Ricca
ceb3bbdc39 msm8953-common: sepolicy: Label sensors path
Change-Id: I87371fbdb8ad069d3b93de72a09c1d1b1ce6da1e
2023-04-19 12:05:32 +02:00
Giovanni Ricca
4cd1093aee msm8953-common: sepolicy: Label sakura dt2w node
* android.hardwar: type=1400 audit(0.0:5255): avc: denied { open } for path="/sys/devices/platform/soc/78b7000.i2c/i2c-3/3-0038/wakeup_gesture" dev="sysfs" ino=35169 scontext=u:r:hal_power_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=1

Change-Id: I72daf2a1037727561a64d4a369f001e6bff23595
2023-04-19 12:05:32 +02:00
dianlujitao
88b12c1fdd msm8953-common: sepolicy: Label /sys/touchpanel/ DT2W node
Change-Id: Id55db9b6614320650c8c61e698f71ddc9f04d086
2023-04-19 12:05:31 +02:00
Pulkit077
09a28fe1d9 msm8953-common: sepolicy: Label pmi8940 nodes
Signed-off-by: Pulkit077 <pulkitagarwal2k1@gmail.com>
Change-Id: I3bc38a4182c41d174a88f7e72cb6eec9e746527e
2023-04-19 12:05:31 +02:00
Sebastiano Barezzi
574abaed96 msm8953-common: rootdir: Import recovery init scripts
* From phoenixin recovery

Change-Id: Ic83f991e22052abd5a4c7ec012ba66a222358e22
2023-04-19 12:05:31 +02:00
Giovanni Ricca
229247c226 msm8953-common: rootdir: Mount /vendor block conditionally
* Set `TARGET_IS_LEGACY := true` on BoardConfig.mk to revert back to /cust

Change-Id: Id6bbb6c5d4873032a7ce5ec1419413c661a34787
2023-04-19 12:05:31 +02:00
Giovanni Ricca
c5ef1dd2e1 msm8953-common: rootdir: Chown dt2w nodes
Change-Id: I443cdfe61d5405b08516bcef0c367e308eb8c3f0
2023-04-19 12:05:31 +02:00
crevanth
6569e213a4 msm8953-common: rootdir: Add permission for /dev/spidev5.1
Change-Id: I5163e8125a7adf04e001e0402c1398786f8fd81f
2023-04-19 12:05:30 +02:00
Giovanni Ricca
ba960ceccc msm8953-common: biometrics: Commonize biometrics permissions
Change-Id: I4191f1712ecf6c5228ef2a811769c6913a19173a
2023-04-19 12:05:30 +02:00
LuK1337
7937cb82d4 msm8953-common: biometrics: Make fingerprint HIDL fully treble compliant
This is more like a hack, also observed in the stock HAL, for pre-P shipped devices
because those have fpdata store path set to /data/system/users/ by the FingerprintService.

Force treble compliant path and thus avoid using data_between_core_and_vendor_violators
attribute:

 > typeattribute hal_fingerprint_default data_between_core_and_vendor_violators;
 > # access to /data/system/users/[0-9]+/fpdata
 > allow hal_fingerprint_default fingerprintd_data_file:dir rw_dir_perms;
 > allow hal_fingerprint_default fingerprintd_data_file:file create_file_perms;

Change-Id: I388f993de7f95fc68007d945f5a9cc975afde120
2023-04-19 12:05:30 +02:00
Giovanni Ricca
d3b97606c0 msm8953-common: biometrics: Handle ysl goodix hal
Change-Id: Ie7d9302648455a88447541e41165572121543c9e
2023-04-19 12:05:30 +02:00
Giovanni Ricca
9d040c42a1 Revert "msm8953-common: Add goodix fingerprint keylayout"
Reason: Goodix driver doesn't call for it anymore

This reverts commit af5986972a.

Change-Id: Iae7b4f991fcba67601c046068912d19ac0783504
2023-04-19 12:05:30 +02:00
Offain
d23b1e256d msm8953-common: keylayout: Fix daisy goodix Fingerprint Gestures
Change-Id: If359f9031fe124cdac491309cc54f144f79ac59a
2023-04-19 12:05:10 +02:00
Giovanni Ricca
bcf9c18bb7 msm8953-common: overlay: Decommonize Auto Brightness overlays
Change-Id: I794c8c45b3c8a5e6554721e1ee918c42b8df4fad
2023-03-11 22:05:02 +01:00
Giovanni Ricca
a9156ae25a msm8953-common: overlay-lineage: Decommonize HW Keys overlay
Change-Id: I7afb5014c94f1671b25525f63f5c6fc56da4ec17
2023-03-11 22:05:01 +01:00
Giovanni Ricca
a6b162853d msm8953-common: Make system partion size overridable
Change-Id: Iec146727eef511f52d185b5cf16086d39d367d68
2023-03-11 22:05:01 +01:00
Giovanni Ricca
2c9d327d98 msm8953-common: Commonize bootanimation flags
* And make them overideble overridable

Change-Id: Ic31ba986d24df1a29aafcab150e873740a1a3e82
2023-03-11 22:05:01 +01:00
Giovanni Ricca
a0f5e28ec3 msm8953-common: Make Screen Density config overridable
* ysl uses a 720p+ display instead of 1080p

Change-Id: Ie4eef6295f99fab2917249d25b9bb2aed5187dd1
2023-03-11 22:05:01 +01:00
Giovanni Ricca
902b62ebc4 Revert "msm8953-common: rro: TetheringOverlay: Disable BPF"
This reverts commit d37facb234.

Change-Id: I17ad54232b3aea9a4b422d737ac56c06e8d957b9
2023-03-11 22:05:01 +01:00
Bruno Martins
8caabad575 msm8953-common: Remove obsolete eBPF property
Android 12 enforces support for eBPF in all kernels.

Change-Id: Iefa9071cb10eabbaeb2f3d2c7c60cb3d0cc2fa2e
2023-03-11 22:05:00 +01:00
Bruno Martins
3a14f0dcb0 msm8953-common: Bump target-level to match new kernel
This fixes the annoying warning on every boot:

  Runtime info <==> Framework Compatibility Matrix?        INCOMPATIBLE, Missing config CONFIG_NETFILTER_XT_MATCH_QTAGUID
  VintfObject::CheckCompatibility?                         INCOMPATIBLE, Runtime info and framework compatibility matrix are incompatible: Missing config CONFIG_NETFILTER_XT_MATCH_QTAGUID

Change-Id: I7cbe2f48671cfdce038825b046af1b8c9c23880e
2023-03-11 22:05:00 +01:00
Giovanni Ricca
e6e20dcc28 msm8953-common: Goodbye 3.18
* No one misses you

Change-Id: I44c5434c0466674a57095edad805e31a1fc55e10
2023-03-11 22:04:59 +01:00
297 changed files with 46738 additions and 4753 deletions

View File

@@ -1,2 +1,30 @@
soong_namespace {
}
install_symlink {
name: "firmware_wcnss_qcom_cfg.bin_symlink",
vendor: true,
installed_location: "firmware/wlan/prima/WCNSS_qcom_cfg.ini",
symlink_target: "/vendor/etc/wifi/WCNSS_qcom_cfg.ini",
}
install_symlink {
name: "firmware_wcnss_qcom_wlan_nv.bin_symlink",
vendor: true,
installed_location: "firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin",
symlink_target: "/mnt/vendor/persist/WCNSS_qcom_wlan_nv.bin",
}
install_symlink {
name: "firmware_wcnss_wlan_dictionary.dat_symlink",
vendor: true,
installed_location: "firmware/wlan/prima/WCNSS_wlan_dictionary.dat",
symlink_target: "/mnt/vendor/persist/WCNSS_wlan_dictionary.dat",
}
install_symlink {
name: "firmware_wlan_mac.bin_symlink",
vendor: true,
installed_location: "firmware/wlan/prima/wlan_mac.bin",
symlink_target: "/mnt/vendor/persist/wlan_mac.bin",
}

View File

@@ -1,108 +0,0 @@
#
# Copyright (C) 2017-2021 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0
#
LOCAL_PATH := $(call my-dir)
ifneq ($(filter daisy mido sakura tissot vince ysl,$(TARGET_DEVICE)),)
include $(call all-makefiles-under,$(LOCAL_PATH))
include $(CLEAR_VARS)
#A/B builds require us to create the mount points at compile time.
#Just creating it for all cases since it does not hurt.
FIRMWARE_MOUNT_POINT := $(TARGET_OUT_VENDOR)/firmware_mnt
DSP_MOUNT_POINT := $(TARGET_OUT_VENDOR)/dsp
ALL_DEFAULT_INSTALLED_MODULES += $(FIRMWARE_MOUNT_POINT) \
$(DSP_MOUNT_POINT)
$(FIRMWARE_MOUNT_POINT):
@echo "Creating $(FIRMWARE_MOUNT_POINT)"
@mkdir -p $(TARGET_OUT_VENDOR)/firmware_mnt
$(DSP_MOUNT_POINT):
@echo "Creating $(DSP_MOUNT_POINT)"
@mkdir -p $(TARGET_OUT_VENDOR)/dsp
IMS_LIBS := libimscamera_jni.so libimsmedia_jni.so
IMS_SYMLINKS := $(addprefix $(TARGET_OUT_SYSTEM_EXT_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_ext/lib64/$(notdir $@) $@
ALL_DEFAULT_INSTALLED_MODULES += $(IMS_SYMLINKS)
RFS_MSM_ADSP_SYMLINKS := $(TARGET_OUT_VENDOR)/rfs/msm/adsp/
$(RFS_MSM_ADSP_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
@echo "Creating RFS MSM ADSP folder structure: $@"
@rm -rf $@/*
@mkdir -p $(dir $@)/readonly/vendor
$(hide) ln -sf /data/vendor/tombstones/rfs/lpass $@/ramdumps
$(hide) ln -sf /mnt/vendor/persist/rfs/msm/adsp $@/readwrite
$(hide) ln -sf /mnt/vendor/persist/rfs/shared $@/shared
$(hide) ln -sf /mnt/vendor/persist/hlos_rfs/shared $@/hlos
$(hide) ln -sf /vendor/firmware_mnt $@/readonly/firmware
$(hide) ln -sf /vendor/firmware $@/readonly/vendor/firmware
RFS_MSM_MPSS_SYMLINKS := $(TARGET_OUT_VENDOR)/rfs/msm/mpss/
$(RFS_MSM_MPSS_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
@echo "Creating RFS MSM MPSS folder structure: $@"
@rm -rf $@/*
@mkdir -p $(dir $@)/readonly/vendor
$(hide) ln -sf /data/vendor/tombstones/rfs/modem $@/ramdumps
$(hide) ln -sf /mnt/vendor/persist/rfs/msm/mpss $@/readwrite
$(hide) ln -sf /mnt/vendor/persist/rfs/shared $@/shared
$(hide) ln -sf /mnt/vendor/persist/hlos_rfs/shared $@/hlos
$(hide) ln -sf /vendor/firmware_mnt $@/readonly/firmware
$(hide) ln -sf /vendor/firmware $@/readonly/vendor/firmware
RFS_MSM_SLPI_SYMLINKS := $(TARGET_OUT_VENDOR)/rfs/msm/slpi/
$(RFS_MSM_SLPI_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
@echo "Creating RFS MSM SLPI folder structure: $@"
@rm -rf $@/*
@mkdir -p $(dir $@)/readonly/vendor
$(hide) ln -sf /data/vendor/tombstones/rfs/slpi $@/ramdumps
$(hide) ln -sf /mnt/vendor/persist/rfs/msm/slpi $@/readwrite
$(hide) ln -sf /mnt/vendor/persist/rfs/shared $@/shared
$(hide) ln -sf /mnt/vendor/persist/hlos_rfs/shared $@/hlos
$(hide) ln -sf /vendor/firmware_mnt $@/readonly/firmware
$(hide) ln -sf /vendor/firmware $@/readonly/vendor/firmware
ALL_DEFAULT_INSTALLED_MODULES += $(RFS_MSM_ADSP_SYMLINKS) $(RFS_MSM_MPSS_SYMLINKS) $(RFS_MSM_SLPI_SYMLINKS)
WCNSS_INI_SYMLINK := $(TARGET_OUT_VENDOR)/firmware/wlan/prima/WCNSS_qcom_cfg.ini
$(WCNSS_INI_SYMLINK): $(LOCAL_INSTALLED_MODULE)
@echo "WCNSS config ini link: $@"
@mkdir -p $(dir $@)
@rm -rf $@
$(hide) ln -sf /vendor/etc/wifi/$(notdir $@) $@
WCNSS_BIN_SYMLINK := $(TARGET_OUT_VENDOR)/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin
$(WCNSS_BIN_SYMLINK): $(LOCAL_INSTALLED_MODULE)
@echo "WCNSS bin link: $@"
@mkdir -p $(dir $@)
@rm -rf $@
$(hide) ln -sf /mnt/vendor/persist/$(notdir $@) $@
WCNSS_DAT_SYMLINK := $(TARGET_OUT_VENDOR)/firmware/wlan/prima/WCNSS_wlan_dictionary.dat
$(WCNSS_DAT_SYMLINK): $(LOCAL_INSTALLED_MODULE)
@echo "WCNSS dat link: $@"
@mkdir -p $(dir $@)
@rm -rf $@
$(hide) ln -sf /mnt/vendor/persist/$(notdir $@) $@
WCNSS_MAC_SYMLINK := $(TARGET_OUT_VENDOR)/firmware/wlan/prima/wlan_mac.bin
$(WCNSS_MAC_SYMLINK): $(LOCAL_INSTALLED_MODULE)
@echo "WCNSS MAC bin link: $@"
@mkdir -p $(dir $@)
@rm -rf $@
$(hide) ln -sf /mnt/vendor/persist/$(notdir $@) $@
ALL_DEFAULT_INSTALLED_MODULES += $(WCNSS_INI_SYMLINK) $(WCNSS_BIN_SYMLINK) $(WCNSS_DAT_SYMLINK) $(WCNSS_MAC_SYMLINK)
endif

View File

@@ -6,9 +6,6 @@
COMMON_PATH := device/xiaomi/msm8953-common
# APEX
OVERRIDE_TARGET_FLATTEN_APEX := true
# Architecture
TARGET_ARCH := arm64
TARGET_ARCH_VARIANT := armv8-a
@@ -22,28 +19,21 @@ TARGET_2ND_CPU_ABI := armeabi-v7a
TARGET_2ND_CPU_ABI2 := armeabi
TARGET_2ND_CPU_VARIANT := cortex-a53
# Build
BUILD_BROKEN_DUP_RULES := true
BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES := true
# Kernel
BOARD_KERNEL_BASE := 0x80000000
BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 androidboot.bootdevice=7824900.sdhci earlycon=msm_hsl_uart,0x78af000
BOARD_KERNEL_CMDLINE += loop.max_part=7
BOARD_KERNEL_CMDLINE += androidboot.boot_devices=soc/7824900.sdhci
BOARD_KERNEL_IMAGE_NAME := Image.gz-dtb
BOARD_KERNEL_PAGESIZE := 2048
BOARD_MKBOOTIMG_ARGS := --ramdisk_offset 0x01000000 --tags_offset 0x00000100
TARGET_KERNEL_SOURCE := kernel/xiaomi/msm8953
ifeq ($(TARGET_KERNEL_VERSION),4.9)
BOARD_KERNEL_CMDLINE += androidboot.usbconfigfs=true
endif
# ANT
BOARD_ANT_WIRELESS_DEVICE := "vfs-prerelease"
TARGET_KERNEL_CONFIG := msm8953-perf_defconfig xiaomi/xiaomi.config
TARGET_KERNEL_CLANG_VERSION := r530567
# Audio
AUDIO_FEATURE_ENABLED_ANC_HEADSET := true
AUDIO_FEATURE_ENABLED_ALAC_OFFLOAD := true
AUDIO_FEATURE_ENABLED_AUDIOSPHERE := true
AUDIO_FEATURE_ENABLED_COMPRESS_VOIP := true
AUDIO_FEATURE_ENABLED_CUSTOMSTEREO := true
AUDIO_FEATURE_ENABLED_EXTN_FORMATS := true
@@ -60,51 +50,38 @@ AUDIO_FEATURE_ENABLED_SOURCE_TRACKING := true
AUDIO_FEATURE_ENABLED_EXT_AMPLIFIER := false
AUDIO_USE_LL_AS_PRIMARY_OUTPUT := true
BOARD_SUPPORTS_SOUND_TRIGGER := true
BOARD_SUPPORTS_OPENSOURCE_STHAL := true
BOARD_USES_ALSA_AUDIO := true
USE_CUSTOM_AUDIO_POLICY := 1
# Bootloader
TARGET_BOOTLOADER_BOARD_NAME := MSM8953
TARGET_NO_BOOTLOADER := true
# Bluetooth
BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := $(COMMON_PATH)/bluetooth
# Camera
USE_DEVICE_SPECIFIC_CAMERA := true
TARGET_USES_QTI_CAMERA_DEVICE := true
BOARD_QTI_CAMERA_32BIT_ONLY := true
TARGET_TS_MAKEUP := true
TARGET_SUPPORT_HAL1 := false
# Display
TARGET_USES_ION := true
TARGET_USES_GRALLOC1 := true
TARGET_USES_HWC2 := true
# DRM
TARGET_ENABLE_MEDIADRM_64 := true
# FM
BOARD_HAVE_QCOM_FM := true
TARGET_QCOM_NO_FM_FIRMWARE := true
# GPS
BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE := default
# Filesystem
TARGET_FS_CONFIG_GEN := $(COMMON_PATH)/config.fs
# HIDL
DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE := \
hardware/qcom-caf/common/vendor_framework_compatibility_matrix.xml \
hardware/qcom-caf/common/vendor_framework_compatibility_matrix_legacy.xml \
vendor/lineage/config/device_framework_matrix.xml
DEVICE_MANIFEST_FILE := $(COMMON_PATH)/manifest.xml
DEVICE_MATRIX_FILE := $(COMMON_PATH)/compatibility_matrix.xml
DEVICE_MATRIX_FILE := hardware/qcom-caf/common/compatibility_matrix.xml
# HW crypto
TARGET_HW_DISK_ENCRYPTION := true
# Init
TARGET_INIT_VENDOR_LIB := //$(COMMON_PATH):libinit_msm8953
TARGET_RECOVERY_DEVICE_MODULES := libinit_msm8953
# Media
TARGET_USES_ION := true
# Partitions
BOARD_BOOTIMAGE_PARTITION_SIZE := 67108864
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 3221225472
BOARD_SYSTEMIMAGE_PARTITION_SIZE ?= 3221225472
BOARD_SYSTEMIMAGE_JOURNAL_SIZE := 0
BOARD_PERSISTIMAGE_PARTITION_SIZE := 33554432
BOARD_FLASH_BLOCK_SIZE := 131072 # (BOARD_KERNEL_PAGESIZE * 64)
BOARD_ROOT_EXTRA_SYMLINKS := \
@@ -123,25 +100,29 @@ TARGET_BOARD_PLATFORM := msm8953
TARGET_ODM_PROP += $(COMMON_PATH)/odm.prop
TARGET_SYSTEM_PROP += $(COMMON_PATH)/system.prop
TARGET_SYSTEM_EXT_PROP += $(COMMON_PATH)/system_ext.prop
TARGET_PRODUCT_PROP += $(COMMON_PATH)/product.prop
TARGET_VENDOR_PROP += $(COMMON_PATH)/vendor.prop
# Recovery
ifeq ($(AB_OTA_UPDATER), true)
TARGET_RECOVERY_FSTAB := $(COMMON_PATH)/rootdir/etc/fstab_AB.qcom
else
TARGET_RECOVERY_FSTAB := $(COMMON_PATH)/rootdir/etc/fstab.qcom
endif
TARGET_USERIMAGES_USE_F2FS := true
TARGET_USERIMAGES_USE_EXT4 := true
# RIL
ENABLE_VENDOR_RIL_SERVICE := true
# SELinux
include device/qcom/sepolicy-legacy-um/SEPolicy.mk
BOARD_VENDOR_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/vendor
PRODUCT_PRIVATE_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/private
# Treble
PRODUCT_FULL_TREBLE_OVERRIDE := true
BOARD_VNDK_VERSION := current
# Verity
# Only needed for signing
BOARD_AVB_ENABLE := false
# Wi-Fi
BOARD_HAS_QCOM_WLAN := true
BOARD_HOSTAPD_DRIVER := NL80211

View File

@@ -3,9 +3,6 @@
<libraries>
<library name="bundle" path="libbundlewrapper.so"/>
<library name="reverb" path="libreverbwrapper.so"/>
<library name="qcbassboost" path="libqcbassboost.so"/>
<library name="qcvirt" path="libqcvirt.so"/>
<library name="qcreverb" path="libqcreverb.so"/>
<library name="visualizer_sw" path="libvisualizer.so"/>
<library name="visualizer_hw" path="libqcomvisualizer.so"/>
<library name="downmix" path="libdownmix.so"/>
@@ -14,16 +11,14 @@
<library name="proxy" path="libeffectproxy.so"/>
<library name="offload_bundle" path="libqcompostprocbundle.so"/>
<library name="audio_pre_processing" path="libqcomvoiceprocessing.so"/>
<library name="audiosphere" path="libasphere.so"/>
<library name="dirac" path="libdirac.so"/>
</libraries>
<effects>
<effectProxy name="bassboost" library="proxy" uuid="14804144-a5ee-4d24-aa88-0002a5d5c51b">
<libsw library="qcbassboost" uuid="23aca180-44bd-11e2-bcfd-0800200c9a66"/>
<libsw library="bundle" uuid="8631f300-72e2-11df-b57e-0002a5d5c51b"/>
<libhw library="offload_bundle" uuid="2c4a8c24-1581-487f-94f6-0002a5d5c51b"/>
</effectProxy>
<effectProxy name="virtualizer" library="proxy" uuid="d3467faa-acc7-4d34-acaf-0002a5d5c51b">
<libsw library="qcvirt" uuid="e6c98a16-22a3-11e2-b87b-f23c91aec05e"/>
<libsw library="bundle" uuid="1d4033c0-8557-11df-9f2d-0002a5d5c51b"/>
<libhw library="offload_bundle" uuid="509a4498-561a-4bea-b3b1-0002a5d5c51b"/>
</effectProxy>
<effectProxy name="equalizer" library="proxy" uuid="c8e70ecd-48ca-456e-8a4f-0002a5d5c51b">
@@ -32,19 +27,19 @@
</effectProxy>
<effect name="volume" library="bundle" uuid="119341a0-8469-11df-81f9-0002a5d5c51b"/>
<effectProxy name="reverb_env_aux" library="proxy" uuid="48404ac9-d202-4ccc-bf84-0002a5d5c51b">
<libsw library="qcreverb" uuid="a8c1e5f3-293d-43cd-95ec-d5e26c02e217"/>
<libsw library="reverb" uuid="4a387fc0-8ab3-11df-8bad-0002a5d5c51b"/>
<libhw library="offload_bundle" uuid="79a18026-18fd-4185-8233-0002a5d5c51b"/>
</effectProxy>
<effectProxy name="reverb_env_ins" library="proxy" uuid="b707403a-a1c1-4291-9573-0002a5d5c51b">
<libsw library="qcreverb" uuid="791fff8b-8129-4655-83a4-59bc61034c3a"/>
<libsw library="reverb" uuid="c7a511a0-a3bb-11df-860e-0002a5d5c51b"/>
<libhw library="offload_bundle" uuid="eb64ea04-973b-43d2-8f5e-0002a5d5c51b"/>
</effectProxy>
<effectProxy name="reverb_pre_aux" library="proxy" uuid="1b78f587-6d1c-422e-8b84-0002a5d5c51b">
<libsw library="qcreverb" uuid="53ef1db5-c0c0-445b-b060-e34d20ebb70a"/>
<libsw library="reverb" uuid="f29a1400-a3bb-11df-8ddc-0002a5d5c51b"/>
<libhw library="offload_bundle" uuid="6987be09-b142-4b41-9056-0002a5d5c51b"/>
</effectProxy>
<effectProxy name="reverb_pre_ins" library="proxy" uuid="f3e178d2-ebcb-408e-8357-0002a5d5c51b">
<libsw library="qcreverb" uuid="b08a0e38-22a5-11e2-b87b-f23c91aec05e"/>
<libsw library="reverb" uuid="172cdf00-a3bc-11df-a72f-0002a5d5c51b"/>
<libhw library="offload_bundle" uuid="aa2bebf6-47cf-4613-9bca-0002a5d5c51b"/>
</effectProxy>
<effectProxy name="visualizer" library="proxy" uuid="1d0a1a53-7d5d-48f2-8e71-27fbd10d842c">
@@ -56,8 +51,6 @@
<effect name="dynamics_processing" library="dynamics_processing" uuid="e0e6539b-1781-7261-676f-6d7573696340"/>
<effect name="aec" library="audio_pre_processing" uuid="0f8d0d2a-59e5-45fe-b6e4-248c8a799109"/>
<effect name="ns" library="audio_pre_processing" uuid="1d97bb0b-9e2f-4403-9ae3-58c2554306f8"/>
<effect name="audiosphere" library="audiosphere" uuid="184e62ab-2d19-4364-9d1b-c0a40733866c"/>
<effect name="dirac" library="dirac" uuid="e069d9e0-8329-11df-9168-0002a5d5c51b"/>
</effects>
<preprocess>
<stream type="voice_communication">

View File

@@ -170,7 +170,7 @@
<!-- Output devices declaration, i.e. Sink DEVICE PORT -->
<devicePort tagName="Earpiece" type="AUDIO_DEVICE_OUT_EARPIECE" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_MONO"/>
</devicePort>
<devicePort tagName="Speaker" role="sink" type="AUDIO_DEVICE_OUT_SPEAKER" address="">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
@@ -206,11 +206,11 @@
</devicePort>
<devicePort tagName="HDMI" type="AUDIO_DEVICE_OUT_AUX_DIGITAL" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,128000,176400,192000" channelMasks="dynamic"/>
samplingRates="8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,128000,176400,192000"/>
</devicePort>
<devicePort tagName="Proxy" type="AUDIO_DEVICE_OUT_PROXY" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,128000,176400,192000" channelMasks="dynamic"/>
samplingRates="8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,128000,176400,192000"/>
</devicePort>
<devicePort tagName="FM" type="AUDIO_DEVICE_OUT_FM" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
@@ -286,9 +286,6 @@
</module>
<!-- A2dp Input Audio HAL -->
<xi:include href="/vendor/etc/a2dp_in_audio_policy_configuration.xml"/>
<!-- Bluetooth Audio HAL -->
<xi:include href="/vendor/etc/bluetooth_audio_policy_configuration.xml"/>

View File

@@ -1,33 +0,0 @@
cc_defaults {
name: "fingerprint_service_xiaomi_msm8953_defaults",
defaults: ["hidl_defaults"],
relative_install_path: "hw",
srcs: [
"BiometricsFingerprint.cpp",
"service.cpp",
],
shared_libs: [
"libcutils",
"liblog",
"libhidlbase",
"libhardware",
"libutils",
"android.hardware.biometrics.fingerprint@2.1",
],
vendor: true,
}
cc_binary {
name: "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_msm8953",
defaults: ["fingerprint_service_xiaomi_msm8953_defaults"],
init_rc: ["android.hardware.biometrics.fingerprint@2.1-service.xiaomi_msm8953.rc"],
vintf_fragments: ["android.hardware.biometrics.fingerprint@2.1-service.xiaomi_msm8953.xml"],
}
cc_binary {
name: "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_msm8953-32",
defaults: ["fingerprint_service_xiaomi_msm8953_defaults"],
compile_multilib: "32",
init_rc: ["android.hardware.biometrics.fingerprint@2.1-service.xiaomi_msm8953-32.rc"],
vintf_fragments: ["android.hardware.biometrics.fingerprint@2.1-service.xiaomi_msm8953-32.xml"],
}

View File

@@ -1,381 +0,0 @@
/*
* Copyright (C) 2017 The Android Open Source Project
* Copyright (C) 2021 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_msm8953"
#define LOG_VERBOSE "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_msm8953"
#include <hardware/hw_auth_token.h>
#include <hardware/hardware.h>
#include <hardware/fingerprint.h>
#include "BiometricsFingerprint.h"
#include <inttypes.h>
#include <unistd.h>
namespace android {
namespace hardware {
namespace biometrics {
namespace fingerprint {
namespace V2_1 {
namespace implementation {
// Supported fingerprint HAL version
static const uint16_t kVersion = HARDWARE_MODULE_API_VERSION(2, 1);
// List of fingerprint HALs
typedef struct hw_module_info {
std::string id_name;
std::string class_name;
} hw_module_info_t;
static const hw_module_info_t kHALModules[] = {
{FINGERPRINT_HARDWARE_MODULE_ID, "fpc"},
{"gf_" FINGERPRINT_HARDWARE_MODULE_ID, "goodix"},
};
using RequestStatus =
android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
BiometricsFingerprint *BiometricsFingerprint::sInstance = nullptr;
BiometricsFingerprint::BiometricsFingerprint() : mClientCallback(nullptr), mDevice(nullptr) {
sInstance = this; // keep track of the most recent instance
for (const auto& HMI : kHALModules) {
mDevice = openHal(HMI.id_name.c_str(), HMI.class_name.c_str());
if (!mDevice) {
ALOGE("Can't open HAL module, module ID %s, class name %s",
HMI.id_name.c_str(), HMI.class_name.c_str());
} else {
ALOGI("Opened fingerprint HAL, module ID %s, class name %s",
HMI.id_name.c_str(), HMI.class_name.c_str());
break;
}
}
}
BiometricsFingerprint::~BiometricsFingerprint() {
ALOGV("~BiometricsFingerprint()");
if (mDevice == nullptr) {
ALOGE("No valid device");
return;
}
int err;
if (0 != (err = mDevice->common.close(
reinterpret_cast<hw_device_t*>(mDevice)))) {
ALOGE("Can't close fingerprint module, error: %d", err);
return;
}
mDevice = nullptr;
}
Return<RequestStatus> BiometricsFingerprint::ErrorFilter(int32_t error) {
switch(error) {
case 0: return RequestStatus::SYS_OK;
case -2: return RequestStatus::SYS_ENOENT;
case -4: return RequestStatus::SYS_EINTR;
case -5: return RequestStatus::SYS_EIO;
case -11: return RequestStatus::SYS_EAGAIN;
case -12: return RequestStatus::SYS_ENOMEM;
case -13: return RequestStatus::SYS_EACCES;
case -14: return RequestStatus::SYS_EFAULT;
case -16: return RequestStatus::SYS_EBUSY;
case -22: return RequestStatus::SYS_EINVAL;
case -28: return RequestStatus::SYS_ENOSPC;
case -110: return RequestStatus::SYS_ETIMEDOUT;
default:
ALOGE("An unknown error returned from fingerprint vendor library: %d", error);
return RequestStatus::SYS_UNKNOWN;
}
}
// Translate from errors returned by traditional HAL (see fingerprint.h) to
// HIDL-compliant FingerprintError.
FingerprintError BiometricsFingerprint::VendorErrorFilter(int32_t error,
int32_t* vendorCode) {
*vendorCode = 0;
switch(error) {
case FINGERPRINT_ERROR_HW_UNAVAILABLE:
return FingerprintError::ERROR_HW_UNAVAILABLE;
case FINGERPRINT_ERROR_UNABLE_TO_PROCESS:
return FingerprintError::ERROR_UNABLE_TO_PROCESS;
case FINGERPRINT_ERROR_TIMEOUT:
return FingerprintError::ERROR_TIMEOUT;
case FINGERPRINT_ERROR_NO_SPACE:
return FingerprintError::ERROR_NO_SPACE;
case FINGERPRINT_ERROR_CANCELED:
return FingerprintError::ERROR_CANCELED;
case FINGERPRINT_ERROR_UNABLE_TO_REMOVE:
return FingerprintError::ERROR_UNABLE_TO_REMOVE;
case FINGERPRINT_ERROR_LOCKOUT:
return FingerprintError::ERROR_LOCKOUT;
default:
if (error >= FINGERPRINT_ERROR_VENDOR_BASE) {
// vendor specific code.
*vendorCode = error - FINGERPRINT_ERROR_VENDOR_BASE;
return FingerprintError::ERROR_VENDOR;
}
}
ALOGE("Unknown error from fingerprint vendor library: %d", error);
return FingerprintError::ERROR_UNABLE_TO_PROCESS;
}
// Translate acquired messages returned by traditional HAL (see fingerprint.h)
// to HIDL-compliant FingerprintAcquiredInfo.
FingerprintAcquiredInfo BiometricsFingerprint::VendorAcquiredFilter(
int32_t info, int32_t* vendorCode) {
*vendorCode = 0;
switch(info) {
case FINGERPRINT_ACQUIRED_GOOD:
return FingerprintAcquiredInfo::ACQUIRED_GOOD;
case FINGERPRINT_ACQUIRED_PARTIAL:
return FingerprintAcquiredInfo::ACQUIRED_PARTIAL;
case FINGERPRINT_ACQUIRED_INSUFFICIENT:
return FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT;
case FINGERPRINT_ACQUIRED_IMAGER_DIRTY:
return FingerprintAcquiredInfo::ACQUIRED_IMAGER_DIRTY;
case FINGERPRINT_ACQUIRED_TOO_SLOW:
return FingerprintAcquiredInfo::ACQUIRED_TOO_SLOW;
case FINGERPRINT_ACQUIRED_TOO_FAST:
return FingerprintAcquiredInfo::ACQUIRED_TOO_FAST;
default:
if (info >= FINGERPRINT_ACQUIRED_VENDOR_BASE) {
// vendor specific code.
*vendorCode = info - FINGERPRINT_ACQUIRED_VENDOR_BASE;
return FingerprintAcquiredInfo::ACQUIRED_VENDOR;
}
}
ALOGE("Unknown acquiredmsg from fingerprint vendor library: %d", info);
return FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT;
}
Return<uint64_t> BiometricsFingerprint::setNotify(
const sp<IBiometricsFingerprintClientCallback>& clientCallback) {
std::lock_guard<std::mutex> lock(mClientCallbackMutex);
mClientCallback = clientCallback;
// This is here because HAL 2.1 doesn't have a way to propagate a
// unique token for its driver. Subsequent versions should send a unique
// token for each call to setNotify(). This is fine as long as there's only
// one fingerprint device on the platform.
return reinterpret_cast<uint64_t>(mDevice);
}
Return<uint64_t> BiometricsFingerprint::preEnroll() {
return mDevice->pre_enroll(mDevice);
}
Return<RequestStatus> BiometricsFingerprint::enroll(const hidl_array<uint8_t, 69>& hat,
uint32_t gid, uint32_t timeoutSec) {
const hw_auth_token_t* authToken =
reinterpret_cast<const hw_auth_token_t*>(hat.data());
return ErrorFilter(mDevice->enroll(mDevice, authToken, gid, timeoutSec));
}
Return<RequestStatus> BiometricsFingerprint::postEnroll() {
return ErrorFilter(mDevice->post_enroll(mDevice));
}
Return<uint64_t> BiometricsFingerprint::getAuthenticatorId() {
return mDevice->get_authenticator_id(mDevice);
}
Return<RequestStatus> BiometricsFingerprint::cancel() {
return ErrorFilter(mDevice->cancel(mDevice));
}
Return<RequestStatus> BiometricsFingerprint::enumerate() {
return ErrorFilter(mDevice->enumerate(mDevice));
}
Return<RequestStatus> BiometricsFingerprint::remove(uint32_t gid, uint32_t fid) {
return ErrorFilter(mDevice->remove(mDevice, gid, fid));
}
Return<RequestStatus> BiometricsFingerprint::setActiveGroup(uint32_t gid,
const hidl_string& storePath) {
if (storePath.size() >= PATH_MAX || storePath.size() <= 0) {
ALOGE("Bad path length: %zd", storePath.size());
return RequestStatus::SYS_EINVAL;
}
if (access(storePath.c_str(), W_OK)) {
return RequestStatus::SYS_EINVAL;
}
return ErrorFilter(mDevice->set_active_group(mDevice, gid,
storePath.c_str()));
}
Return<RequestStatus> BiometricsFingerprint::authenticate(uint64_t operationId,
uint32_t gid) {
return ErrorFilter(mDevice->authenticate(mDevice, operationId, gid));
}
IBiometricsFingerprint* BiometricsFingerprint::getInstance() {
if (!sInstance) {
sInstance = new BiometricsFingerprint();
}
return sInstance;
}
fingerprint_device_t* BiometricsFingerprint::openHal(const char* id_name, const char* class_name) {
int err;
const hw_module_t *hw_mdl = nullptr;
ALOGD("Opening fingerprint hal library...");
if (0 != (err = hw_get_module_by_class(id_name, class_name, &hw_mdl))) {
ALOGE("Can't open fingerprint HW Module, module ID %s, class name %s, error: %d",
id_name, class_name, err);
return nullptr;
}
if (hw_mdl == nullptr) {
ALOGE("No valid fingerprint module, module ID %s, class name %s", id_name, class_name);
return nullptr;
}
fingerprint_module_t const *module =
reinterpret_cast<const fingerprint_module_t*>(hw_mdl);
if (module->common.methods->open == nullptr) {
ALOGE("No valid open method, module ID %s, class name %s", id_name, class_name);
return nullptr;
}
hw_device_t *device = nullptr;
if (0 != (err = module->common.methods->open(hw_mdl, nullptr, &device))) {
ALOGE("Can't open fingerprint methods, module ID %s, class name %s, error: %d",
id_name, class_name, err);
return nullptr;
}
if (kVersion != device->version) {
// enforce version on new devices because of HIDL@2.1 translation layer
ALOGE("Wrong fp version, module ID %s, class name %s. Expected %d, got %d",
id_name, class_name, kVersion, device->version);
return nullptr;
}
fingerprint_device_t* fp_device =
reinterpret_cast<fingerprint_device_t*>(device);
if (0 != (err =
fp_device->set_notify(fp_device, BiometricsFingerprint::notify))) {
ALOGE("Can't register fingerprint module callback, module ID %s, class name %s, error: %d",
id_name, class_name, err);
return nullptr;
}
return fp_device;
}
void BiometricsFingerprint::notify(const fingerprint_msg_t *msg) {
BiometricsFingerprint* thisPtr = static_cast<BiometricsFingerprint*>(
BiometricsFingerprint::getInstance());
std::lock_guard<std::mutex> lock(thisPtr->mClientCallbackMutex);
if (thisPtr == nullptr || thisPtr->mClientCallback == nullptr) {
ALOGE("Receiving callbacks before the client callback is registered.");
return;
}
const uint64_t devId = reinterpret_cast<uint64_t>(thisPtr->mDevice);
switch (msg->type) {
case FINGERPRINT_ERROR: {
int32_t vendorCode = 0;
FingerprintError result = VendorErrorFilter(msg->data.error, &vendorCode);
ALOGD("onError(%d)", result);
if (!thisPtr->mClientCallback->onError(devId, result, vendorCode).isOk()) {
ALOGE("failed to invoke fingerprint onError callback");
}
}
break;
case FINGERPRINT_ACQUIRED: {
int32_t vendorCode = 0;
FingerprintAcquiredInfo result =
VendorAcquiredFilter(msg->data.acquired.acquired_info, &vendorCode);
ALOGD("onAcquired(%d)", result);
if (!thisPtr->mClientCallback->onAcquired(devId, result, vendorCode).isOk()) {
ALOGE("failed to invoke fingerprint onAcquired callback");
}
}
break;
case FINGERPRINT_TEMPLATE_ENROLLING:
ALOGD("onEnrollResult(fid=%d, gid=%d, rem=%d)",
msg->data.enroll.finger.fid,
msg->data.enroll.finger.gid,
msg->data.enroll.samples_remaining);
if (!thisPtr->mClientCallback->onEnrollResult(devId,
msg->data.enroll.finger.fid,
msg->data.enroll.finger.gid,
msg->data.enroll.samples_remaining).isOk()) {
ALOGE("failed to invoke fingerprint onEnrollResult callback");
}
break;
case FINGERPRINT_TEMPLATE_REMOVED:
ALOGD("onRemove(fid=%d, gid=%d, rem=%d)",
msg->data.removed.finger.fid,
msg->data.removed.finger.gid,
msg->data.removed.remaining_templates);
if (!thisPtr->mClientCallback->onRemoved(devId,
msg->data.removed.finger.fid,
msg->data.removed.finger.gid,
msg->data.removed.remaining_templates).isOk()) {
ALOGE("failed to invoke fingerprint onRemoved callback");
}
break;
case FINGERPRINT_AUTHENTICATED:
if (msg->data.authenticated.finger.fid != 0) {
ALOGD("onAuthenticated(fid=%d, gid=%d)",
msg->data.authenticated.finger.fid,
msg->data.authenticated.finger.gid);
const uint8_t* hat =
reinterpret_cast<const uint8_t *>(&msg->data.authenticated.hat);
const hidl_vec<uint8_t> token(
std::vector<uint8_t>(hat, hat + sizeof(msg->data.authenticated.hat)));
if (!thisPtr->mClientCallback->onAuthenticated(devId,
msg->data.authenticated.finger.fid,
msg->data.authenticated.finger.gid,
token).isOk()) {
ALOGE("failed to invoke fingerprint onAuthenticated callback");
}
} else {
// Not a recognized fingerprint
if (!thisPtr->mClientCallback->onAuthenticated(devId,
msg->data.authenticated.finger.fid,
msg->data.authenticated.finger.gid,
hidl_vec<uint8_t>()).isOk()) {
ALOGE("failed to invoke fingerprint onAuthenticated callback");
}
}
break;
case FINGERPRINT_TEMPLATE_ENUMERATING:
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;
}
}
} // namespace implementation
} // namespace V2_1
} // namespace fingerprint
} // namespace biometrics
} // namespace hardware
} // namespace android

View File

@@ -1,84 +0,0 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
#include <log/log.h>
#include <android/log.h>
#include <hardware/hardware.h>
#include <hardware/fingerprint.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
namespace android {
namespace hardware {
namespace biometrics {
namespace fingerprint {
namespace V2_1 {
namespace implementation {
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
struct BiometricsFingerprint : public IBiometricsFingerprint {
public:
BiometricsFingerprint();
~BiometricsFingerprint();
// Method to wrap legacy HAL with BiometricsFingerprint class
static IBiometricsFingerprint* getInstance();
// Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow.
Return<uint64_t> setNotify(const sp<IBiometricsFingerprintClientCallback>& clientCallback) override;
Return<uint64_t> preEnroll() override;
Return<RequestStatus> enroll(const hidl_array<uint8_t, 69>& hat, uint32_t gid, uint32_t timeoutSec) override;
Return<RequestStatus> postEnroll() override;
Return<uint64_t> getAuthenticatorId() override;
Return<RequestStatus> cancel() override;
Return<RequestStatus> enumerate() override;
Return<RequestStatus> remove(uint32_t gid, uint32_t fid) override;
Return<RequestStatus> setActiveGroup(uint32_t gid, const hidl_string& storePath) override;
Return<RequestStatus> authenticate(uint64_t operationId, uint32_t gid) override;
private:
static fingerprint_device_t* openHal(const char* id_name, const char* class_name);
static void notify(const fingerprint_msg_t *msg); /* Static callback for legacy HAL implementation */
static Return<RequestStatus> ErrorFilter(int32_t error);
static FingerprintError VendorErrorFilter(int32_t error, int32_t* vendorCode);
static FingerprintAcquiredInfo VendorAcquiredFilter(int32_t error, int32_t* vendorCode);
static BiometricsFingerprint* sInstance;
std::mutex mClientCallbackMutex;
sp<IBiometricsFingerprintClientCallback> mClientCallback;
fingerprint_device_t *mDevice;
};
} // namespace implementation
} // namespace V2_1
} // namespace fingerprint
} // namespace biometrics
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H

View File

@@ -1,8 +0,0 @@
service vendor.fps_hal /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.1-service.xiaomi_msm8953-32
# "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.
class late_start
user system
group system input uhid
writepid /dev/cpuset/system-background/tasks

View File

@@ -1,11 +0,0 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<name>android.hardware.biometrics.fingerprint</name>
<transport>hwbinder</transport>
<version>2.1</version>
<interface>
<name>IBiometricsFingerprint</name>
<instance>default</instance>
</interface>
</hal>
</manifest>

View File

@@ -1,8 +0,0 @@
service vendor.fps_hal /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.1-service.xiaomi_msm8953
# "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.
class late_start
user system
group system input uhid
writepid /dev/cpuset/system-background/tasks

View File

@@ -1,11 +0,0 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<name>android.hardware.biometrics.fingerprint</name>
<transport>hwbinder</transport>
<version>2.1</version>
<interface>
<name>IBiometricsFingerprint</name>
<instance>default</instance>
</interface>
</hal>
</manifest>

View File

@@ -1,48 +0,0 @@
/*
* Copyright (C) 2017 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.
*/
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_msm8953"
#include <android/log.h>
#include <hidl/HidlSupport.h>
#include <hidl/HidlTransportSupport.h>
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
#include <android/hardware/biometrics/fingerprint/2.1/types.h>
#include "BiometricsFingerprint.h"
using android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
using android::hardware::biometrics::fingerprint::V2_1::implementation::BiometricsFingerprint;
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::sp;
int main() {
android::sp<IBiometricsFingerprint> bio = BiometricsFingerprint::getInstance();
configureRpcThreadpool(1, true /*callerWillJoin*/);
if (bio != nullptr) {
if (::android::OK != bio->registerAsService()) {
return 1;
}
} else {
ALOGE("Can't create instance of BiometricsFingerprint, nullptr");
}
joinRpcThreadpool();
return 0; // should never get here
}

View File

@@ -1,32 +0,0 @@
/*
* 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.
*/
#ifndef _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H
// Disables read remote device feature
#define BTA_SKIP_BLE_READ_REMOTE_FEAT FALSE
#define MAX_ACL_CONNECTIONS 7
#define MAX_L2CAP_CHANNELS 16
#define BLE_VND_INCLUDED TRUE
// skips conn update at conn completion
#define BTA_BLE_SKIP_CONN_UPD FALSE
#define BLE_PERIPHERAL_ADV_NAME FALSE
#define BTM_SCO_ENHANCED_SYNC_ENABLED FALSE
#define BTA_DISABLE_DELAY 1000 /* in milliseconds */
#define BTM_WBS_INCLUDED TRUE
#define BTIF_HF_WBS_PREFERRED TRUE
#endif

View File

@@ -1,74 +0,0 @@
<compatibility-matrix version="1.0" type="device">
<hal format="hidl" optional="false">
<name>android.frameworks.displayservice</name>
<version>1.0</version>
<interface>
<name>IDisplayService</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.frameworks.schedulerservice</name>
<version>1.0</version>
<interface>
<name>ISchedulingPolicyService</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.frameworks.sensorservice</name>
<version>1.0</version>
<interface>
<name>ISensorManager</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.hidl.allocator</name>
<version>1.0</version>
<interface>
<name>IAllocator</name>
<instance>ashmem</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.hidl.manager</name>
<version>1.0</version>
<interface>
<name>IServiceManager</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.hidl.memory</name>
<version>1.0</version>
<interface>
<name>IMapper</name>
<instance>ashmem</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.hidl.token</name>
<version>1.0</version>
<interface>
<name>ITokenManager</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.system.net.netd</name>
<version>1.0</version>
<interface>
<name>INetd</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.system.wifi.keystore</name>
<version>1.0</version>
<interface>
<name>IKeystore</name>
<instance>default</instance>
</interface>
</hal>
</compatibility-matrix>

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<config>
<component-override package="com.android.bluetooth" >
<component class=".hfpclient.HeadsetClientService" enabled="true" />
</component-override>
</config>

View File

@@ -32,7 +32,6 @@
<config>
<!-- These are telephony components that need to freely run in the background -->
<allow-in-power-save package="com.qualcomm.atfwd" />
<allow-in-power-save package="com.qualcomm.qti.telephonyservice" />
<allow-in-power-save package="com.qualcomm.qcrilmsgtunnel" />
<allow-in-power-save package="com.qualcomm.qti.ims" />
@@ -41,7 +40,6 @@
<!-- These telephony applications need access to non-[System]SDK APIs -->
<hidden-api-whitelisted-app package="com.qualcomm.uimremoteserver" />
<hidden-api-whitelisted-app package="com.qualcomm.uimremoteclient" />
<hidden-api-whitelisted-app package="com.qualcomm.atfwd" />
<hidden-api-whitelisted-app package="com.qti.qualcomm.datastatusnotification" />
<hidden-api-whitelisted-app package="com.qti.qualcomm.deviceinfo" />
<hidden-api-whitelisted-app package="com.qualcomm.qti.modemtestmode" />
@@ -57,8 +55,6 @@
<hidden-api-whitelisted-app package="com.qualcomm.qcrilmsgtunnel" />
<hidden-api-whitelisted-app package="com.qualcomm.qti.ltedirect" />
<hidden-api-whitelisted-app package="com.qualcomm.qti.app" />
<hidden-api-whitelisted-app package="com.qualcomm.embms" />
<hidden-api-whitelisted-app package="com.qualcomm.qti.embmstuneaway" />
<hidden-api-whitelisted-app package="com.qualcomm.qti.uimlpatest" />
<hidden-api-whitelisted-app package="com.qualcomm.qti.lpa" />
<hidden-api-whitelisted-app package="com.qualcomm.qti.uim" />

69
extract-files.py Executable file
View File

@@ -0,0 +1,69 @@
#!/usr/bin/env -S PYTHONPATH=../../../tools/extract-utils python3
#
# SPDX-FileCopyrightText: 2024 The LineageOS Project
# SPDX-License-Identifier: Apache-2.0
#
from extract_utils.fixups_blob import (
blob_fixup,
blob_fixups_user_type,
)
from extract_utils.fixups_lib import (
lib_fixup_remove,
lib_fixups,
lib_fixups_user_type,
)
from extract_utils.main import (
ExtractUtils,
ExtractUtilsModule,
)
namespace_imports = [
'device/xiaomi/msm8953-common',
'hardware/qcom-caf/msm8996',
'vendor/qcom/opensource/dataservices',
]
def lib_fixup_vendor_suffix(lib: str, partition: str, *args, **kwargs):
return f'{lib}_{partition}' if partition == 'vendor' else None
lib_fixups: lib_fixups_user_type = {
**lib_fixups,
(
'com.qualcomm.qti.dpm.api@1.0',
'vendor.qti.ims.callinfo@1.0',
'vendor.qti.ims.rcsconfig@1.0',
'vendor.qti.imsrtpservice@2.0',
'vendor.qti.imsrtpservice@2.1',
): lib_fixup_vendor_suffix,
('libwifi-hal-ctrl'): lib_fixup_remove,
}
blob_fixups: blob_fixups_user_type = {
('system_ext/etc/init/dpmd.rc', 'system_ext/etc/permissions/com.qti.dpmframework.xml', 'system_ext/etc/permissions/dpmapi.xml', 'system_ext/etc/permissions/qcrilhook.xml', 'system_ext/etc/permissions/telephonyservice.xml'): blob_fixup()
.regex_replace('/product/', '/system_ext/'),
('system_ext/lib/libdpmframework.so', 'system_ext/lib64/libdpmframework.so'): blob_fixup()
.add_needed('libcutils_shim.so'),
('system_ext/lib64/lib-imscamera.so', 'system_ext/lib64/lib-imsvideocodec.so'): blob_fixup()
.add_needed('libgui_shim.so'),
'vendor/bin/pm-service': blob_fixup()
.add_needed('libutils-v33.so'),
('vendor/etc/data/dsi_config.xml', 'vendor/etc/data/netmgr_config.xml'): blob_fixup()
.fix_xml(),
('vendor/lib64/mediadrm/libwvdrmengine.so', 'vendor/lib64/libwvhidl.so'): blob_fixup()
.add_needed('libcrypto_shim.so'),
} # fmt: skip
module = ExtractUtilsModule(
'msm8953-common',
'xiaomi',
blob_fixups=blob_fixups,
lib_fixups=lib_fixups,
namespace_imports=namespace_imports,
)
if __name__ == '__main__':
utils = ExtractUtils.device(module)
utils.run()

View File

@@ -1,120 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2016 The CyanogenMod Project
# Copyright (C) 2017-2020 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0
#
set -e
# Load extract_utils and do some sanity checks
MY_DIR="${BASH_SOURCE%/*}"
if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi
ANDROID_ROOT="${MY_DIR}/../../.."
HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh"
if [ ! -f "${HELPER}" ]; then
echo "Unable to find helper script at ${HELPER}"
exit 1
fi
source "${HELPER}"
# Default to sanitizing the vendor folder before extraction
CLEAN_VENDOR=true
ONLY_COMMON=
ONLY_TARGET=
KANG=
SECTION=
while [ "${#}" -gt 0 ]; do
case "${1}" in
--only-common )
ONLY_COMMON=true
;;
--only-target )
ONLY_TARGET=true
;;
-n | --no-cleanup )
CLEAN_VENDOR=false
;;
-k | --kang )
KANG="--kang"
;;
-s | --section )
SECTION="${2}"; shift
CLEAN_VENDOR=false
;;
* )
SRC="${1}"
;;
esac
shift
done
if [ -z "${SRC}" ]; then
SRC="adb"
fi
function blob_fixup() {
case "${1}" in
product/etc/permissions/vendor.qti.hardware.data.connection-V1.0-java.xml | product/etc/permissions/vendor.qti.hardware.data.connection-V1.1-java.xml)
sed -i 's/version="2.0"/version="1.0"/g' "${2}"
;;
system_ext/etc/init/dpmd.rc)
sed -i "s|/system/product/bin/|/system/system_ext/bin/|g" "${2}"
;;
system_ext/etc/permissions/com.qti.dpmframework.xml \
| system_ext/etc/permissions/com.qualcomm.qti.imscmservice-V2.0-java.xml \
| system_ext/etc/permissions/com.qualcomm.qti.imscmservice-V2.1-java.xml \
| system_ext/etc/permissions/com.qualcomm.qti.imscmservice-V2.2-java.xml \
| system_ext/etc/permissions/dpmapi.xml \
| system_ext/etc/permissions/telephonyservice.xml )
sed -i "s|/system/product/framework/|/system/system_ext/framework/|g" "${2}"
;;
system_ext/etc/permissions/embms.xml)
sed -i "s|/product/framework/|/system_ext/framework/|g" "${2}"
;;
system_ext/etc/permissions/qcrilhook.xml)
sed -i 's|/product/framework/qcrilhook.jar|/system_ext/framework/qcrilhook.jar|g' "${2}"
;;
system_ext/lib64/libdpmframework.so)
for LIBSHIM_DPMFRAMEWORK in $(grep -L "libshim_dpmframework.so" "${2}"); do
"${PATCHELF}" --add-needed "libshim_dpmframework.so" "$LIBSHIM_DPMFRAMEWORK"
done
;;
system_ext/lib64/lib-imsvideocodec.so)
for LIBSHIM_IMSVIDEOCODEC in $(grep -L "libshim_imsvideocodec.so" "${2}"); do
"${PATCHELF}" --add-needed "libshim_imsvideocodec.so" "$LIBSHIM_IMSVIDEOCODEC"
done
;;
vendor/lib/mediadrm/libwvdrmengine.so|vendor/lib64/mediadrm/libwvdrmengine.so)
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
vendor/lib64/libsettings.so)
"${PATCHELF}" --replace-needed "libprotobuf-cpp-full.so" "libprotobuf-cpp-full-v29.so" "${2}"
;;
vendor/lib64/libwvhidl.so)
"${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v29.so" "${2}"
;;
esac
}
if [ -z "${ONLY_TARGET}" ]; then
# Initialize the helper for common device
setup_vendor "${DEVICE_COMMON}" "${VENDOR}" "${ANDROID_ROOT}" true "${CLEAN_VENDOR}"
extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
fi
if [ -z "${ONLY_COMMON}" ] && [ -s "${MY_DIR}/../${DEVICE}/proprietary-files.txt" ]; then
# Reinitialize the helper for device
source "${MY_DIR}/../${DEVICE}/extract-files.sh"
setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}"
extract "${MY_DIR}/../${DEVICE}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
fi
"${MY_DIR}/setup-makefiles.sh"

4
gps/Android.bp Normal file
View File

@@ -0,0 +1,4 @@
GNSS_CFLAGS = [
"-Werror",
"-Wno-undefined-bool-conversion",
]

50
gps/CleanSpec.mk Normal file
View File

@@ -0,0 +1,50 @@
# Copyright (C) 2007 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# If you don't need to do a full clean build but would like to touch
# a file or delete some intermediate files, add a clean step to the end
# of the list. These steps will only be run once, if they haven't been
# run before.
#
# E.g.:
# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
#
# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
# files that are missing or have been moved.
#
# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
# Use $(OUT_DIR) to refer to the "out" directory.
#
# If you need to re-do something that's already mentioned, just copy
# the command and add it to the bottom of the list. E.g., if a change
# that you made last week required touching a file and a change you
# made today requires touching the same file, just copy the old
# touch step and add it to the end of the list.
#
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
# For example:
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libloc_api*)

10
gps/Makefile.am Normal file
View File

@@ -0,0 +1,10 @@
# Makefile.am - Automake script for gps loc_api
#
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = gnss
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = loc-hal.pc
EXTRA_DIST = $(pkgconfig_DATA)

209
gps/android/2.0/AGnss.cpp Normal file
View File

@@ -0,0 +1,209 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#define LOG_TAG "LocSvc_AGnssInterface"
#include <log_util.h>
#include "Gnss.h"
#include "AGnss.h"
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
static AGnss* spAGnss = nullptr;
AGnss::AGnss(Gnss* gnss) : mGnss(gnss) {
spAGnss = this;
}
AGnss::~AGnss() {
spAGnss = nullptr;
}
void AGnss::agnssStatusIpV4Cb(AGnssExtStatusIpV4 status) {
if (nullptr != spAGnss) {
spAGnss->statusCb(status.type, status.status);
}
}
void AGnss::statusCb(AGpsExtType type, LocAGpsStatusValue status) {
V2_0::IAGnssCallback::AGnssType aType;
IAGnssCallback::AGnssStatusValue aStatus;
switch (type) {
case LOC_AGPS_TYPE_SUPL:
aType = IAGnssCallback::AGnssType::SUPL;
break;
case LOC_AGPS_TYPE_SUPL_ES:
aType = IAGnssCallback::AGnssType::SUPL_EIMS;
break;
default:
LOC_LOGE("invalid type: %d", type);
return;
}
switch (status) {
case LOC_GPS_REQUEST_AGPS_DATA_CONN:
aStatus = IAGnssCallback::AGnssStatusValue::REQUEST_AGNSS_DATA_CONN;
break;
case LOC_GPS_RELEASE_AGPS_DATA_CONN:
aStatus = IAGnssCallback::AGnssStatusValue::RELEASE_AGNSS_DATA_CONN;
break;
case LOC_GPS_AGPS_DATA_CONNECTED:
aStatus = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONNECTED;
break;
case LOC_GPS_AGPS_DATA_CONN_DONE:
aStatus = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONN_DONE;
break;
case LOC_GPS_AGPS_DATA_CONN_FAILED:
aStatus = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONN_FAILED;
break;
default:
LOC_LOGE("invalid status: %d", status);
return;
}
if (mAGnssCbIface != nullptr) {
auto r = mAGnssCbIface->agnssStatusCb(aType, aStatus);
if (!r.isOk()) {
LOC_LOGw("Error invoking AGNSS status cb %s", r.description().c_str());
}
}
else {
LOC_LOGw("setCallback has not been called yet");
}
}
Return<void> AGnss::setCallback(const sp<V2_0::IAGnssCallback>& callback) {
if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
LOC_LOGE("Null GNSS interface");
return Void();
}
// Save the interface
mAGnssCbIface = callback;
AgpsCbInfo cbInfo = {};
cbInfo.statusV4Cb = (void*)agnssStatusIpV4Cb;
cbInfo.atlType = AGPS_ATL_TYPE_SUPL | AGPS_ATL_TYPE_SUPL_ES;
mGnss->getGnssInterface()->agpsInit(cbInfo);
return Void();
}
Return<bool> AGnss::dataConnClosed() {
if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
LOC_LOGE("Null GNSS interface");
return false;
}
mGnss->getGnssInterface()->agpsDataConnClosed(LOC_AGPS_TYPE_SUPL);
return true;
}
Return<bool> AGnss::dataConnFailed() {
if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
LOC_LOGE("Null GNSS interface");
return false;
}
mGnss->getGnssInterface()->agpsDataConnFailed(LOC_AGPS_TYPE_SUPL);
return true;
}
Return<bool> AGnss::dataConnOpen(uint64_t /*networkHandle*/, const hidl_string& apn,
V2_0::IAGnss::ApnIpType apnIpType) {
if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
LOC_LOGE("Null GNSS interface");
return false;
}
/* Validate */
if(apn.empty()){
LOC_LOGE("Invalid APN");
return false;
}
LOC_LOGD("dataConnOpen APN name = [%s]", apn.c_str());
AGpsBearerType bearerType;
switch (apnIpType) {
case IAGnss::ApnIpType::IPV4:
bearerType = AGPS_APN_BEARER_IPV4;
break;
case IAGnss::ApnIpType::IPV6:
bearerType = AGPS_APN_BEARER_IPV6;
break;
case IAGnss::ApnIpType::IPV4V6:
bearerType = AGPS_APN_BEARER_IPV4V6;
break;
default:
bearerType = AGPS_APN_BEARER_IPV4;
break;
}
mGnss->getGnssInterface()->agpsDataConnOpen(
LOC_AGPS_TYPE_SUPL, apn.c_str(), apn.size(), (int)bearerType);
return true;
}
Return<bool> AGnss::setServer(V2_0::IAGnssCallback::AGnssType type,
const hidl_string& hostname,
int32_t port) {
if (mGnss == nullptr) {
LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
return false;
}
GnssConfig config;
memset(&config, 0, sizeof(GnssConfig));
config.size = sizeof(GnssConfig);
config.flags = GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT;
config.assistanceServer.size = sizeof(GnssConfigSetAssistanceServer);
if (type == IAGnssCallback::AGnssType::SUPL) {
config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_SUPL;
} else if (type == IAGnssCallback::AGnssType::C2K) {
config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_C2K;
} else if (type == IAGnssCallback::AGnssType::SUPL_EIMS) {
config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_SUPL_EIMS;
} else if (type == IAGnssCallback::AGnssType::SUPL_IMS) {
config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_SUPL_IMS;
} else {
LOC_LOGE("%s]: invalid AGnssType: %d", __FUNCTION__, static_cast<uint8_t>(type));
return false;
}
config.assistanceServer.hostName = strdup(hostname.c_str());
config.assistanceServer.port = port;
return mGnss->updateConfiguration(config);
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

77
gps/android/2.0/AGnss.h Normal file
View File

@@ -0,0 +1,77 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#ifndef ANDROID_HARDWARE_GNSS_V2_0_AGNSS_H
#define ANDROID_HARDWARE_GNSS_V2_0_AGNSS_H
#include <android/hardware/gnss/2.0/IAGnss.h>
#include <hidl/Status.h>
#include <gps_extended_c.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
struct Gnss;
struct AGnss : public V2_0::IAGnss {
AGnss(Gnss* gnss);
~AGnss();
/*
* Methods from ::android::hardware::gnss::V2_0::IAGnss interface follow.
* These declarations were generated from IAGnss.hal.
*/
Return<void> setCallback(const sp<V2_0::IAGnssCallback>& callback) override;
Return<bool> dataConnClosed() override;
Return<bool> dataConnFailed() override;
Return<bool> dataConnOpen(uint64_t networkHandle, const hidl_string& apn,
V2_0::IAGnss::ApnIpType apnIpType) override;
Return<bool> setServer(V2_0::IAGnssCallback::AGnssType type,
const hidl_string& hostname, int32_t port) override;
void statusCb(AGpsExtType type, LocAGpsStatusValue status);
/* Data call setup callback passed down to GNSS HAL implementation */
static void agnssStatusIpV4Cb(AGnssExtStatusIpV4 status);
private:
Gnss* mGnss = nullptr;
sp<IAGnssCallback> mAGnssCbIface = nullptr;
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V2_0_AGNSS_H

View File

@@ -0,0 +1,133 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#define LOG_TAG "LocSvc__AGnssRilInterface"
#include <log_util.h>
#include <dlfcn.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sstream>
#include <string>
#include "Gnss.h"
#include "AGnssRil.h"
#include <DataItemConcreteTypesBase.h>
typedef void* (getLocationInterface)();
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
AGnssRil::AGnssRil(Gnss* gnss) : mGnss(gnss) {
ENTRY_LOG_CALLFLOW();
}
AGnssRil::~AGnssRil() {
ENTRY_LOG_CALLFLOW();
}
Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool /*roaming*/) {
ENTRY_LOG_CALLFLOW();
// Extra NetworkTypes not available in IAgnssRil enums
const int NetworkType_BLUETOOTH = 7;
const int NetworkType_ETHERNET = 9;
const int NetworkType_PROXY = 16;
// for XTRA
if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) {
int8_t typeout = loc_core::TYPE_UNKNOWN;
switch(type)
{
case IAGnssRil::NetworkType::MOBILE:
typeout = loc_core::TYPE_MOBILE;
break;
case IAGnssRil::NetworkType::WIFI:
typeout = loc_core::TYPE_WIFI;
break;
case IAGnssRil::NetworkType::MMS:
typeout = loc_core::TYPE_MMS;
break;
case IAGnssRil::NetworkType::SUPL:
typeout = loc_core::TYPE_SUPL;
break;
case IAGnssRil::NetworkType::DUN:
typeout = loc_core::TYPE_DUN;
break;
case IAGnssRil::NetworkType::HIPRI:
typeout = loc_core::TYPE_HIPRI;
break;
case IAGnssRil::NetworkType::WIMAX:
typeout = loc_core::TYPE_WIMAX;
break;
default:
{
int networkType = (int) type;
// Handling network types not available in IAgnssRil
switch(networkType)
{
case NetworkType_BLUETOOTH:
typeout = loc_core::TYPE_BLUETOOTH;
break;
case NetworkType_ETHERNET:
typeout = loc_core::TYPE_ETHERNET;
break;
case NetworkType_PROXY:
typeout = loc_core::TYPE_PROXY;
break;
default:
typeout = loc_core::TYPE_UNKNOWN;
}
}
break;
}
mGnss->getGnssInterface()->updateConnectionStatus(connected, false, typeout, 0);
}
return true;
}
Return<bool> AGnssRil::updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttributes& attributes) {
ENTRY_LOG_CALLFLOW();
if (nullptr != mGnss && (nullptr != mGnss->getGnssInterface())) {
int8_t typeout = loc_core::TYPE_UNKNOWN;
bool roaming = false;
if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_METERED) {
typeout = loc_core::TYPE_WIFI;
} else {
typeout = loc_core::TYPE_MOBILE;
}
if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_ROAMING) {
roaming = false;
}
mGnss->getGnssInterface()->updateConnectionStatus(attributes.isConnected,
typeout, roaming, (NetworkHandle) attributes.networkHandle);
}
return true;
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#ifndef ANDROID_HARDWARE_GNSS_V2_0_AGNSSRIL_H_
#define ANDROID_HARDWARE_GNSS_V2_0_AGNSSRIL_H_
#include <android/hardware/gnss/2.0/IAGnssRil.h>
#include <hidl/Status.h>
#include <location_interface.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
struct Gnss;
/*
* Extended interface for AGNSS RIL support. An Assisted GNSS Radio Interface Layer interface
* allows the GNSS chipset to request radio interface layer information from Android platform.
* Examples of such information are reference location, unique subscriber ID, phone number string
* and network availability changes. Also contains wrapper methods to allow methods from
* IAGnssiRilCallback interface to be passed into the conventional implementation of the GNSS HAL.
*/
struct AGnssRil : public V2_0::IAGnssRil {
AGnssRil(Gnss* gnss);
~AGnssRil();
/*
* Methods from ::android::hardware::gnss::V1_0::IAGnssRil follow.
* These declarations were generated from IAGnssRil.hal.
*/
Return<void> setCallback(const sp<V1_0::IAGnssRilCallback>& /*callback*/) override {
return Void();
}
Return<void> setRefLocation(const V1_0::IAGnssRil::AGnssRefLocation& /*agnssReflocation*/) override {
return Void();
}
Return<bool> setSetId(V1_0::IAGnssRil::SetIDType /*type*/, const hidl_string& /*setid*/) override {
return false;
}
Return<bool> updateNetworkAvailability(bool /*available*/,
const hidl_string& /*apn*/) override {
return false;
}
Return<bool> updateNetworkState(bool connected, V1_0::IAGnssRil::NetworkType type, bool roaming) override;
// Methods from ::android::hardware::gnss::V2_0::IAGnssRil follow
Return<bool> updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttributes& attributes) override;
private:
Gnss* mGnss = nullptr;
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V2_0_AGNSSRIL_H_

View File

@@ -0,0 +1,96 @@
cc_library_shared {
name: "android.hardware.gnss@2.0-impl-qti",
vendor: true,
relative_install_path: "hw",
srcs: [
"AGnss.cpp",
"Gnss.cpp",
"AGnssRil.cpp",
"GnssMeasurement.cpp",
"GnssConfiguration.cpp",
"GnssBatching.cpp",
"GnssGeofencing.cpp",
"GnssNi.cpp",
"GnssDebug.cpp",
"measurement_corrections/1.0/MeasurementCorrections.cpp",
"visibility_control/1.0/GnssVisibilityControl.cpp",
] + [
"location_api/GnssAPIClient.cpp",
"location_api/MeasurementAPIClient.cpp",
"location_api/GeofenceAPIClient.cpp",
"location_api/BatchingAPIClient.cpp",
"location_api/LocationUtil.cpp",
],
local_include_dirs: [
"location_api",
"measurement_corrections/1.0",
"visibility_control/1.0",
"location_api",
],
header_libs: [
"libgps.utils_headers",
"libloc_core_headers",
"libloc_pla_headers",
"liblocation_api_headers",
"liblocbatterylistener_headers",
],
shared_libs: [
"liblog",
"libhidlbase",
"libcutils",
"libutils",
"android.hardware.gnss@1.0",
"android.hardware.gnss@1.1",
"android.hardware.gnss@2.0",
"android.hardware.gnss.measurement_corrections@1.0",
"android.hardware.gnss.visibility_control@1.0",
"android.hardware.health@1.0",
"android.hardware.health@2.0",
"android.hardware.power@1.2",
"libbase",
] + [
"libloc_core",
"libgps.utils",
"libdl",
"liblocation_api",
],
cflags: GNSS_CFLAGS,
static_libs: ["liblocbatterylistener"] + ["libhealthhalutils"],
}
cc_binary {
name: "android.hardware.gnss@2.0-service-qti",
vintf_fragments: ["android.hardware.gnss@2.0-service-qti.xml"],
vendor: true,
relative_install_path: "hw",
init_rc: ["android.hardware.gnss@2.0-service-qti.rc"],
srcs: ["service.cpp"],
header_libs: [
"libgps.utils_headers",
"libloc_core_headers",
"libloc_pla_headers",
"liblocation_api_headers",
],
shared_libs: [
"liblog",
"libcutils",
"libdl",
"libbase",
"libutils",
"libgps.utils",
"libqti_vndfwk_detect",
] + [
"libhidlbase",
"android.hardware.gnss@1.0",
"android.hardware.gnss@1.1",
"android.hardware.gnss@2.0",
],
cflags: GNSS_CFLAGS + ["-DLOC_HIDL_VERSION=\"3.0\""],
}

671
gps/android/2.0/Gnss.cpp Normal file
View File

@@ -0,0 +1,671 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#define LOG_TAG "LocSvc_GnssInterface"
#define LOG_NDEBUG 0
#include <fstream>
#include <log_util.h>
#include <dlfcn.h>
#include <cutils/properties.h>
#include "Gnss.h"
#include "LocationUtil.h"
#include "battery_listener.h"
typedef const GnssInterface* (getLocationInterface)();
#define IMAGES_INFO_FILE "/sys/devices/soc0/images"
#define DELIMITER ";"
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::gnss::visibility_control::V1_0::implementation::GnssVisibilityControl;
static sp<Gnss> sGnss;
static std::string getVersionString() {
static std::string version;
if (!version.empty())
return version;
char value[PROPERTY_VALUE_MAX] = {0};
property_get("ro.hardware", value, "unknown");
version.append(value).append(DELIMITER);
std::ifstream in(IMAGES_INFO_FILE);
std::string s;
while(getline(in, s)) {
std::size_t found = s.find("CRM:");
if (std::string::npos == found) {
continue;
}
// skip over space characters after "CRM:"
const char* substr = s.c_str();
found += 4;
while (0 != substr[found] && isspace(substr[found])) {
found++;
}
if (s.find("11:") != found) {
continue;
}
s.erase(0, found + 3);
found = s.find_first_of("\r\n");
if (std::string::npos != found) {
s.erase(s.begin() + found, s.end());
}
version.append(s).append(DELIMITER);
}
return version;
}
void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who) {
LOC_LOGE("%s] service died. cookie: %llu, who: %p",
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
if (mGnss != nullptr) {
mGnss->cleanup();
}
}
void location_on_battery_status_changed(bool charging) {
LOC_LOGd("battery status changed to %s charging", charging ? "" : "not");
if (sGnss != nullptr) {
sGnss->getGnssInterface()->updateBatteryStatus(charging);
}
}
Gnss::Gnss() {
ENTRY_LOG_CALLFLOW();
sGnss = this;
// register health client to listen on battery change
loc_extn_battery_properties_listener_init(location_on_battery_status_changed);
// clear pending GnssConfig
memset(&mPendingConfig, 0, sizeof(GnssConfig));
mGnssDeathRecipient = new GnssDeathRecipient(this);
}
Gnss::~Gnss() {
ENTRY_LOG_CALLFLOW();
if (mApi != nullptr) {
delete mApi;
mApi = nullptr;
}
sGnss = nullptr;
}
GnssAPIClient* Gnss::getApi() {
if (mApi != nullptr) {
return mApi;
}
if (mGnssCbIface_2_0 != nullptr) {
mApi = new GnssAPIClient(mGnssCbIface_2_0);
} else if (mGnssCbIface_1_1 != nullptr) {
mApi = new GnssAPIClient(mGnssCbIface_1_1, mGnssNiCbIface);
} else if (mGnssCbIface != nullptr) {
mApi = new GnssAPIClient(mGnssCbIface, mGnssNiCbIface);
} else {
LOC_LOGW("%s] GnssAPIClient is not ready", __FUNCTION__);
return mApi;
}
if (mPendingConfig.size == sizeof(GnssConfig)) {
// we have pending GnssConfig
mApi->gnssConfigurationUpdate(mPendingConfig);
// clear size to invalid mPendingConfig
mPendingConfig.size = 0;
if (mPendingConfig.assistanceServer.hostName != nullptr) {
free((void*)mPendingConfig.assistanceServer.hostName);
}
}
return mApi;
}
const GnssInterface* Gnss::getGnssInterface() {
static bool getGnssInterfaceFailed = false;
if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
LOC_LOGD("%s]: loading libgnss.so::getGnssInterface ...", __func__);
getLocationInterface* getter = NULL;
const char *error = NULL;
dlerror();
void *handle = dlopen("libgnss.so", RTLD_NOW);
if (NULL == handle || (error = dlerror()) != NULL) {
LOC_LOGW("dlopen for libgnss.so failed, error = %s", error);
} else {
getter = (getLocationInterface*)dlsym(handle, "getGnssInterface");
if ((error = dlerror()) != NULL) {
LOC_LOGW("dlsym for libgnss.so::getGnssInterface failed, error = %s", error);
getter = NULL;
}
}
if (NULL == getter) {
getGnssInterfaceFailed = true;
} else {
mGnssInterface = (const GnssInterface*)(*getter)();
}
}
return mGnssInterface;
}
Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>& callback) {
ENTRY_LOG_CALLFLOW();
// In case where previous call to setCallback_1_1 or setCallback_2_0, then
// we need to cleanup these interfaces/callbacks here since we no longer
// do so in cleanup() function to keep callbacks around after cleanup()
if (mApi != nullptr) {
mApi->gnssUpdateCallbacks_2_0(nullptr);
}
if (mGnssCbIface_1_1 != nullptr) {
mGnssCbIface_1_1->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface_1_1 = nullptr;
}
if (mGnssCbIface_2_0 != nullptr) {
mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface_2_0 = nullptr;
}
if (mGnssCbIface != nullptr) {
mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
}
mGnssCbIface = callback;
if (mGnssCbIface != nullptr) {
mGnssCbIface->linkToDeath(mGnssDeathRecipient, 0 /*cookie*/);
}
GnssAPIClient* api = getApi();
if (api != nullptr) {
api->gnssUpdateCallbacks(mGnssCbIface, mGnssNiCbIface);
api->gnssEnable(LOCATION_TECHNOLOGY_TYPE_GNSS);
api->requestCapabilities();
}
return true;
}
Return<bool> Gnss::setGnssNiCb(const sp<IGnssNiCallback>& callback) {
ENTRY_LOG_CALLFLOW();
mGnssNiCbIface = callback;
GnssAPIClient* api = getApi();
if (api != nullptr) {
api->gnssUpdateCallbacks(mGnssCbIface, mGnssNiCbIface);
}
return true;
}
Return<bool> Gnss::updateConfiguration(GnssConfig& gnssConfig) {
ENTRY_LOG_CALLFLOW();
GnssAPIClient* api = getApi();
if (api) {
api->gnssConfigurationUpdate(gnssConfig);
} else if (gnssConfig.flags != 0) {
// api is not ready yet, update mPendingConfig with gnssConfig
mPendingConfig.size = sizeof(GnssConfig);
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT;
mPendingConfig.gpsLock = gnssConfig.gpsLock;
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT;
mPendingConfig.suplVersion = gnssConfig.suplVersion;
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT;
mPendingConfig.assistanceServer.size = sizeof(GnssConfigSetAssistanceServer);
mPendingConfig.assistanceServer.type = gnssConfig.assistanceServer.type;
if (mPendingConfig.assistanceServer.hostName != nullptr) {
free((void*)mPendingConfig.assistanceServer.hostName);
mPendingConfig.assistanceServer.hostName =
strdup(gnssConfig.assistanceServer.hostName);
}
mPendingConfig.assistanceServer.port = gnssConfig.assistanceServer.port;
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
mPendingConfig.lppProfile = gnssConfig.lppProfile;
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT;
mPendingConfig.lppeControlPlaneMask = gnssConfig.lppeControlPlaneMask;
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT;
mPendingConfig.lppeUserPlaneMask = gnssConfig.lppeUserPlaneMask;
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT;
mPendingConfig.aGlonassPositionProtocolMask = gnssConfig.aGlonassPositionProtocolMask;
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT;
mPendingConfig.emergencyPdnForEmergencySupl = gnssConfig.emergencyPdnForEmergencySupl;
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT;
mPendingConfig.suplEmergencyServices = gnssConfig.suplEmergencyServices;
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_MODE_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_MODE_BIT;
mPendingConfig.suplModeMask = gnssConfig.suplModeMask;
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
mPendingConfig.blacklistedSvIds = gnssConfig.blacklistedSvIds;
}
if (gnssConfig.flags & GNSS_CONFIG_FLAGS_EMERGENCY_EXTENSION_SECONDS_BIT) {
mPendingConfig.flags |= GNSS_CONFIG_FLAGS_EMERGENCY_EXTENSION_SECONDS_BIT;
mPendingConfig.emergencyExtensionSeconds = gnssConfig.emergencyExtensionSeconds;
}
}
return true;
}
Return<bool> Gnss::start() {
ENTRY_LOG_CALLFLOW();
bool retVal = false;
GnssAPIClient* api = getApi();
if (api) {
retVal = api->gnssStart();
}
return retVal;
}
Return<bool> Gnss::stop() {
ENTRY_LOG_CALLFLOW();
bool retVal = false;
GnssAPIClient* api = getApi();
if (api) {
retVal = api->gnssStop();
}
return retVal;
}
Return<void> Gnss::cleanup() {
ENTRY_LOG_CALLFLOW();
if (mApi != nullptr) {
mApi->gnssStop();
mApi->gnssDisable();
}
return Void();
}
Return<bool> Gnss::injectLocation(double latitudeDegrees,
double longitudeDegrees,
float accuracyMeters) {
ENTRY_LOG_CALLFLOW();
const GnssInterface* gnssInterface = getGnssInterface();
if (nullptr != gnssInterface) {
gnssInterface->injectLocation(latitudeDegrees, longitudeDegrees, accuracyMeters);
return true;
} else {
return false;
}
}
Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
int32_t uncertaintyMs) {
ENTRY_LOG_CALLFLOW();
const GnssInterface* gnssInterface = getGnssInterface();
if (nullptr != gnssInterface) {
gnssInterface->injectTime(timeMs, timeReferenceMs, uncertaintyMs);
return true;
} else {
return false;
}
}
Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) {
ENTRY_LOG_CALLFLOW();
GnssAPIClient* api = getApi();
if (api) {
api->gnssDeleteAidingData(aidingDataFlags);
}
return Void();
}
Return<bool> Gnss::setPositionMode(V1_0::IGnss::GnssPositionMode mode,
V1_0::IGnss::GnssPositionRecurrence recurrence,
uint32_t minIntervalMs,
uint32_t preferredAccuracyMeters,
uint32_t preferredTimeMs) {
ENTRY_LOG_CALLFLOW();
bool retVal = false;
GnssAPIClient* api = getApi();
if (api) {
retVal = api->gnssSetPositionMode(mode, recurrence, minIntervalMs,
preferredAccuracyMeters, preferredTimeMs);
}
return retVal;
}
Return<sp<V1_0::IAGnss>> Gnss::getExtensionAGnss() {
ENTRY_LOG_CALLFLOW();
// deprecated function. Must return nullptr to pass VTS
return nullptr;
}
Return<sp<V1_0::IGnssNi>> Gnss::getExtensionGnssNi() {
ENTRY_LOG_CALLFLOW();
// deprecated function. Must return nullptr to pass VTS
return nullptr;
}
Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() {
ENTRY_LOG_CALLFLOW();
if (mGnssMeasurement == nullptr)
mGnssMeasurement = new GnssMeasurement();
return mGnssMeasurement;
}
Return<sp<V1_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration() {
ENTRY_LOG_CALLFLOW();
mGnssConfig = new GnssConfiguration(this);
return mGnssConfig;
}
Return<sp<V1_0::IGnssGeofencing>> Gnss::getExtensionGnssGeofencing() {
ENTRY_LOG_CALLFLOW();
mGnssGeofencingIface = new GnssGeofencing();
return mGnssGeofencingIface;
}
Return<sp<V1_0::IGnssBatching>> Gnss::getExtensionGnssBatching() {
ENTRY_LOG_CALLFLOW();
mGnssBatching = new GnssBatching();
return mGnssBatching;
}
Return<sp<V1_0::IGnssDebug>> Gnss::getExtensionGnssDebug() {
ENTRY_LOG_CALLFLOW();
mGnssDebug = new GnssDebug(this);
return mGnssDebug;
}
Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() {
ENTRY_LOG_CALLFLOW();
mGnssRil = new AGnssRil(this);
return mGnssRil;
}
// Methods from ::android::hardware::gnss::V1_1::IGnss follow.
Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
ENTRY_LOG_CALLFLOW();
auto r = callback->gnssNameCb(getVersionString());
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssNameCb description=%s",
__func__, r.description().c_str());
}
// In case where previous call to setCallback or setCallback_2_1, then
// we need to cleanup these interfaces/callbacks here since we no longer
// do so in cleanup() function to keep callbacks around after cleanup()
if (mApi != nullptr) {
mApi->gnssUpdateCallbacks_2_0(nullptr);
}
if (mGnssCbIface != nullptr) {
mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface = nullptr;
}
if (mGnssCbIface_2_0 != nullptr) {
mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface_2_0 = nullptr;
}
if (mGnssCbIface_1_1 != nullptr) {
mGnssCbIface_1_1->unlinkToDeath(mGnssDeathRecipient);
}
mGnssCbIface_1_1 = callback;
if (mGnssCbIface_1_1 != nullptr) {
mGnssCbIface_1_1->linkToDeath(mGnssDeathRecipient, 0 /*cookie*/);
}
const GnssInterface* gnssInterface = getGnssInterface();
if (nullptr != gnssInterface) {
OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) {
odcpiRequestCb(odcpiRequest);
};
gnssInterface->odcpiInit(cb);
}
GnssAPIClient* api = getApi();
if (api != nullptr) {
api->gnssUpdateCallbacks(mGnssCbIface_1_1, mGnssNiCbIface);
api->gnssEnable(LOCATION_TECHNOLOGY_TYPE_GNSS);
api->requestCapabilities();
}
return true;
}
Return<bool> Gnss::setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode,
V1_0::IGnss::GnssPositionRecurrence recurrence,
uint32_t minIntervalMs,
uint32_t preferredAccuracyMeters,
uint32_t preferredTimeMs,
bool lowPowerMode) {
ENTRY_LOG_CALLFLOW();
bool retVal = false;
GnssAPIClient* api = getApi();
if (api) {
GnssPowerMode powerMode = lowPowerMode?
GNSS_POWER_MODE_M4 : GNSS_POWER_MODE_M2;
retVal = api->gnssSetPositionMode(mode, recurrence, minIntervalMs,
preferredAccuracyMeters, preferredTimeMs, powerMode, minIntervalMs);
}
return retVal;
}
Return<sp<V1_1::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_1_1() {
ENTRY_LOG_CALLFLOW();
#ifdef GNSS_HIDL_LEGACY_MEASURMENTS
return nullptr;
#else
if (mGnssMeasurement == nullptr)
mGnssMeasurement = new GnssMeasurement();
return mGnssMeasurement;
#endif
}
Return<sp<V1_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_1_1() {
ENTRY_LOG_CALLFLOW();
if (mGnssConfig == nullptr)
mGnssConfig = new GnssConfiguration(this);
return mGnssConfig;
}
Return<bool> Gnss::injectBestLocation(const GnssLocation& gnssLocation) {
ENTRY_LOG_CALLFLOW();
const GnssInterface* gnssInterface = getGnssInterface();
if (nullptr != gnssInterface) {
Location location = {};
convertGnssLocation(gnssLocation, location);
gnssInterface->odcpiInject(location);
}
return true;
}
void Gnss::odcpiRequestCb(const OdcpiRequestInfo& request) {
ENTRY_LOG_CALLFLOW();
if (mGnssCbIface_2_0 != nullptr) {
// For emergency mode, request DBH (Device based hybrid) location
// Mark Independent from GNSS flag to false.
if (ODCPI_REQUEST_TYPE_START == request.type) {
LOC_LOGd("gnssRequestLocationCb_2_0 isUserEmergency = %d", request.isEmergencyMode);
auto r = mGnssCbIface_2_0->gnssRequestLocationCb_2_0(!request.isEmergencyMode,
request.isEmergencyMode);
if (!r.isOk()) {
LOC_LOGe("Error invoking gnssRequestLocationCb_2_0 %s", r.description().c_str());
}
} else {
LOC_LOGv("Unsupported ODCPI request type: %d", request.type);
}
} else if (mGnssCbIface_1_1 != nullptr) {
// For emergency mode, request DBH (Device based hybrid) location
// Mark Independent from GNSS flag to false.
if (ODCPI_REQUEST_TYPE_START == request.type) {
auto r = mGnssCbIface_1_1->gnssRequestLocationCb(!request.isEmergencyMode);
if (!r.isOk()) {
LOC_LOGe("Error invoking gnssRequestLocationCb %s", r.description().c_str());
}
} else {
LOC_LOGv("Unsupported ODCPI request type: %d", request.type);
}
} else {
LOC_LOGe("ODCPI request not supported.");
}
}
// Methods from ::android::hardware::gnss::V2_0::IGnss follow.
Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
ENTRY_LOG_CALLFLOW();
auto r = callback->gnssNameCb(getVersionString());
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssNameCb description=%s",
__func__, r.description().c_str());
}
// In case where previous call to setCallback or setCallback_1_1, then
// we need to cleanup these interfaces/callbacks here since we no longer
// do so in cleanup() function to keep callbacks around after cleanup()
if (mApi != nullptr) {
mApi->gnssUpdateCallbacks(nullptr, nullptr);
}
mGnssNiCbIface = nullptr;
if (mGnssCbIface != nullptr) {
mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface = nullptr;
}
if (mGnssCbIface_1_1 != nullptr) {
mGnssCbIface_1_1->unlinkToDeath(mGnssDeathRecipient);
mGnssCbIface_1_1 = nullptr;
}
if (mGnssCbIface_2_0 != nullptr) {
mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
}
mGnssCbIface_2_0 = callback;
if (mGnssCbIface_2_0 != nullptr) {
mGnssCbIface_2_0->linkToDeath(mGnssDeathRecipient, 0 /*cookie*/);
}
const GnssInterface* gnssInterface = getGnssInterface();
if (nullptr != gnssInterface) {
OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) {
odcpiRequestCb(odcpiRequest);
};
gnssInterface->odcpiInit(cb);
}
GnssAPIClient* api = getApi();
if (api != nullptr) {
api->gnssUpdateCallbacks_2_0(mGnssCbIface_2_0);
api->gnssEnable(LOCATION_TECHNOLOGY_TYPE_GNSS);
api->requestCapabilities();
}
return true;
}
Return<sp<V2_0::IAGnss>> Gnss::getExtensionAGnss_2_0() {
ENTRY_LOG_CALLFLOW();
mAGnssIface_2_0 = new AGnss(this);
return mAGnssIface_2_0;
}
Return<sp<V2_0::IAGnssRil>> Gnss::getExtensionAGnssRil_2_0() {
mGnssRil = new AGnssRil(this);
return mGnssRil;
}
Return<sp<V2_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_2_0() {
ENTRY_LOG_CALLFLOW();
mGnssConfig = new GnssConfiguration(this);
return mGnssConfig;
}
Return<sp<V2_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_0() {
ENTRY_LOG_CALLFLOW();
#ifdef GNSS_HIDL_LEGACY_MEASURMENTS
return nullptr;
#else
if (mGnssMeasurement == nullptr)
mGnssMeasurement = new GnssMeasurement();
return mGnssMeasurement;
#endif
}
Return<sp<::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections>>
Gnss::getExtensionMeasurementCorrections() {
// We do not support, so return nullptr to pass VTS
return nullptr;
}
Return<sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl>>
Gnss::getExtensionVisibilityControl() {
ENTRY_LOG_CALLFLOW();
if (mVisibCtrl == nullptr) {
mVisibCtrl = new GnssVisibilityControl(this);
}
return mVisibCtrl;
}
Return<bool> Gnss::injectBestLocation_2_0(const V2_0::GnssLocation& gnssLocation) {
ENTRY_LOG_CALLFLOW();
const GnssInterface* gnssInterface = getGnssInterface();
if (nullptr != gnssInterface) {
Location location = {};
convertGnssLocation(gnssLocation, location);
gnssInterface->odcpiInject(location);
}
return true;
}
Return<sp<V2_0::IGnssDebug>> Gnss::getExtensionGnssDebug_2_0() {
ENTRY_LOG_CALLFLOW();
mGnssDebug = new GnssDebug(this);
return mGnssDebug;
}
Return<sp<V2_0::IGnssBatching>> Gnss::getExtensionGnssBatching_2_0() {
ENTRY_LOG_CALLFLOW();
mGnssBatching = new GnssBatching();
return mGnssBatching;
}
V1_0::IGnss* HIDL_FETCH_IGnss(const char* hal) {
ENTRY_LOG_CALLFLOW();
V1_0::IGnss* iface = nullptr;
iface = new Gnss();
if (iface == nullptr) {
LOC_LOGE("%s]: failed to get %s", __FUNCTION__, hal);
}
return iface;
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

187
gps/android/2.0/Gnss.h Normal file
View File

@@ -0,0 +1,187 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSS_H
#define ANDROID_HARDWARE_GNSS_V2_0_GNSS_H
#include <AGnss.h>
#include <AGnssRil.h>
#include <GnssConfiguration.h>
#include <GnssMeasurement.h>
#include <GnssBatching.h>
#include <GnssGeofencing.h>
#include <GnssNi.h>
#include <GnssDebug.h>
#include <android/hardware/gnss/2.0/IGnss.h>
#include <MeasurementCorrections.h>
#include <GnssVisibilityControl.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include "GnssAPIClient.h"
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
using ::android::hardware::gnss::V1_0::GnssLocation;
using ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections;
using ::android::hardware::gnss::measurement_corrections::V1_0::implementation::MeasurementCorrections;
using ::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl;
struct Gnss : public IGnss {
Gnss();
~Gnss();
/*
* Methods from ::android::hardware::gnss::V1_0::IGnss follow.
* These declarations were generated from Gnss.hal.
*/
Return<bool> setCallback(const sp<V1_0::IGnssCallback>& callback) override;
Return<bool> start() override;
Return<bool> stop() override;
Return<void> cleanup() override;
Return<bool> injectLocation(double latitudeDegrees,
double longitudeDegrees,
float accuracyMeters) override;
Return<bool> injectTime(int64_t timeMs,
int64_t timeReferenceMs,
int32_t uncertaintyMs) override;
Return<void> deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) override;
Return<bool> setPositionMode(V1_0::IGnss::GnssPositionMode mode,
V1_0::IGnss::GnssPositionRecurrence recurrence,
uint32_t minIntervalMs,
uint32_t preferredAccuracyMeters,
uint32_t preferredTimeMs) override;
Return<sp<V1_0::IAGnss>> getExtensionAGnss() override;
Return<sp<V1_0::IGnssNi>> getExtensionGnssNi() override;
Return<sp<V1_0::IGnssMeasurement>> getExtensionGnssMeasurement() override;
Return<sp<V1_0::IGnssConfiguration>> getExtensionGnssConfiguration() override;
Return<sp<V1_0::IGnssGeofencing>> getExtensionGnssGeofencing() override;
Return<sp<V1_0::IGnssBatching>> getExtensionGnssBatching() override;
Return<sp<V1_0::IAGnssRil>> getExtensionAGnssRil() override;
inline Return<sp<V1_0::IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override {
return nullptr;
}
inline Return<sp<V1_0::IGnssXtra>> getExtensionXtra() override {
return nullptr;
}
Return<sp<V1_0::IGnssDebug>> getExtensionGnssDebug() override;
// Methods from ::android::hardware::gnss::V1_1::IGnss follow.
Return<bool> setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) override;
Return<bool> setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode,
V1_0::IGnss::GnssPositionRecurrence recurrence,
uint32_t minIntervalMs, uint32_t preferredAccuracyMeters,
uint32_t preferredTimeMs, bool lowPowerMode) override;
Return<sp<V1_1::IGnssMeasurement>> getExtensionGnssMeasurement_1_1() override;
Return<sp<V1_1::IGnssConfiguration>> getExtensionGnssConfiguration_1_1() override;
Return<bool> injectBestLocation(const GnssLocation& location) override;
// Methods from ::android::hardware::gnss::V2_0::IGnss follow.
Return<bool> setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) override;
Return<sp<V2_0::IAGnss>> getExtensionAGnss_2_0() override;
Return<sp<V2_0::IAGnssRil>> getExtensionAGnssRil_2_0() override;
Return<sp<V2_0::IGnssConfiguration>> getExtensionGnssConfiguration_2_0() override;
Return<sp<::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections>>
getExtensionMeasurementCorrections() override;
Return<sp<V2_0::IGnssMeasurement>> getExtensionGnssMeasurement_2_0() override;
Return<bool> injectBestLocation_2_0(const ::android::hardware::gnss::V2_0::GnssLocation& location) override;
Return<sp<V2_0::IGnssBatching>> getExtensionGnssBatching_2_0() override;
Return<sp<V2_0::IGnssDebug>> getExtensionGnssDebug_2_0() override;
/**
* This method returns the IGnssVisibilityControl interface.
*
* @return visibilityControlIface Handle to the IGnssVisibilityControl interface.
*/
Return<sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl>>
getExtensionVisibilityControl() override;
// These methods are not part of the IGnss base class.
GnssAPIClient* getApi();
Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb);
Return<bool> updateConfiguration(GnssConfig& gnssConfig);
const GnssInterface* getGnssInterface();
// Callback for ODCPI request
void odcpiRequestCb(const OdcpiRequestInfo& request);
private:
struct GnssDeathRecipient : hidl_death_recipient {
GnssDeathRecipient(sp<Gnss> gnss) : mGnss(gnss) {
}
~GnssDeathRecipient() = default;
virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
sp<Gnss> mGnss;
};
private:
sp<GnssDeathRecipient> mGnssDeathRecipient = nullptr;
sp<V1_0::IGnssNi> mGnssNi = nullptr;
sp<V1_0::IGnssGeofencing> mGnssGeofencingIface = nullptr;
sp<V1_0::IAGnss> mAGnssIface = nullptr;
sp<V1_0::IGnssCallback> mGnssCbIface = nullptr;
sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr;
sp<V1_1::IGnssCallback> mGnssCbIface_1_1 = nullptr;
sp<V2_0::IAGnss> mAGnssIface_2_0 = nullptr;
sp<V2_0::IAGnssRil> mGnssRil = nullptr;
sp<V2_0::IGnssMeasurement> mGnssMeasurement = nullptr;
sp<V2_0::IGnssConfiguration> mGnssConfig = nullptr;
sp<V2_0::IGnssBatching> mGnssBatching = nullptr;
sp<V2_0::IGnssDebug> mGnssDebug = nullptr;
sp<V2_0::IGnssCallback> mGnssCbIface_2_0 = nullptr;
sp<IMeasurementCorrections> mGnssMeasCorr = nullptr;
sp<IGnssVisibilityControl> mVisibCtrl = nullptr;
GnssAPIClient* mApi = nullptr;
GnssConfig mPendingConfig;
const GnssInterface* mGnssInterface = nullptr;
};
extern "C" V1_0::IGnss* HIDL_FETCH_IGnss(const char* name);
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSS_H

View File

@@ -0,0 +1,163 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#define LOG_TAG "LocSvc_GnssBatchingInterface"
#include <log_util.h>
#include <BatchingAPIClient.h>
#include "GnssBatching.h"
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
void GnssBatching::GnssBatchingDeathRecipient::serviceDied(
uint64_t cookie, const wp<IBase>& who) {
LOC_LOGE("%s] service died. cookie: %llu, who: %p",
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
if (mGnssBatching != nullptr) {
mGnssBatching->stop();
mGnssBatching->cleanup();
}
}
GnssBatching::GnssBatching() : mApi(nullptr) {
mGnssBatchingDeathRecipient = new GnssBatchingDeathRecipient(this);
}
GnssBatching::~GnssBatching() {
if (mApi != nullptr) {
delete mApi;
mApi = nullptr;
}
}
// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
Return<bool> GnssBatching::init(const sp<V1_0::IGnssBatchingCallback>& callback) {
if (mApi != nullptr) {
LOC_LOGD("%s]: mApi is NOT nullptr, delete it first", __FUNCTION__);
delete mApi;
mApi = nullptr;
}
mApi = new BatchingAPIClient(callback);
if (mApi == nullptr) {
LOC_LOGE("%s]: failed to create mApi", __FUNCTION__);
return false;
}
if (mGnssBatchingCbIface != nullptr) {
mGnssBatchingCbIface->unlinkToDeath(mGnssBatchingDeathRecipient);
}
mGnssBatchingCbIface = callback;
if (mGnssBatchingCbIface != nullptr) {
mGnssBatchingCbIface->linkToDeath(mGnssBatchingDeathRecipient, 0 /*cookie*/);
}
return true;
}
Return<uint16_t> GnssBatching::getBatchSize() {
uint16_t ret = 0;
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
} else {
ret = mApi->getBatchSize();
}
return ret;
}
Return<bool> GnssBatching::start(const IGnssBatching::Options& options) {
bool ret = false;
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
} else {
ret = mApi->startSession(options);
}
return ret;
}
Return<void> GnssBatching::flush() {
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
} else {
mApi->flushBatchedLocations();
}
return Void();
}
Return<bool> GnssBatching::stop() {
bool ret = false;
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
} else {
ret = mApi->stopSession();
}
return ret;
}
Return<void> GnssBatching::cleanup() {
if (mApi != nullptr) {
mApi->stopSession();
}
if (mGnssBatchingCbIface != nullptr) {
mGnssBatchingCbIface->unlinkToDeath(mGnssBatchingDeathRecipient);
mGnssBatchingCbIface = nullptr;
}
if (mGnssBatchingCbIface_2_0 != nullptr) {
mGnssBatchingCbIface_2_0->unlinkToDeath(mGnssBatchingDeathRecipient);
mGnssBatchingCbIface_2_0 = nullptr;
}
return Void();
}
// Methods from ::android::hardware::gnss::V2_0::IGnssBatching follow.
Return<bool> GnssBatching::init_2_0(const sp<V2_0::IGnssBatchingCallback>& callback) {
if (mApi != nullptr) {
LOC_LOGD("%s]: mApi is NOT nullptr, delete it first", __FUNCTION__);
delete mApi;
mApi = nullptr;
}
mApi = new BatchingAPIClient(callback);
if (mApi == nullptr) {
LOC_LOGE("%s]: failed to create mApi", __FUNCTION__);
return false;
}
if (mGnssBatchingCbIface_2_0 != nullptr) {
mGnssBatchingCbIface_2_0->unlinkToDeath(mGnssBatchingDeathRecipient);
}
mGnssBatchingCbIface_2_0 = callback;
if (mGnssBatchingCbIface_2_0 != nullptr) {
mGnssBatchingCbIface_2_0->linkToDeath(mGnssBatchingDeathRecipient, 0 /*cookie*/);
}
return true;
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSBATCHING_H
#define ANDROID_HARDWARE_GNSS_V2_0_GNSSBATCHING_H
#include <android/hardware/gnss/2.0/IGnssBatching.h>
#include <hidl/Status.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::gnss::V2_0::IGnssBatching;
using ::android::hardware::gnss::V2_0::IGnssBatchingCallback;
using ::android::hidl::base::V1_0::IBase;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
class BatchingAPIClient;
struct GnssBatching : public IGnssBatching {
GnssBatching();
~GnssBatching();
// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
Return<bool> init(const sp<V1_0::IGnssBatchingCallback>& callback) override;
Return<uint16_t> getBatchSize() override;
Return<bool> start(const IGnssBatching::Options& options ) override;
Return<void> flush() override;
Return<bool> stop() override;
Return<void> cleanup() override;
// Methods from ::android::hardware::gnss::V2_0::IGnssBatching follow.
Return<bool> init_2_0(const sp<V2_0::IGnssBatchingCallback>& callback) override;
private:
struct GnssBatchingDeathRecipient : hidl_death_recipient {
GnssBatchingDeathRecipient(sp<GnssBatching> gnssBatching) :
mGnssBatching(gnssBatching) {
}
~GnssBatchingDeathRecipient() = default;
virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
sp<GnssBatching> mGnssBatching;
};
private:
sp<GnssBatchingDeathRecipient> mGnssBatchingDeathRecipient = nullptr;
sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface = nullptr;
BatchingAPIClient* mApi = nullptr;
sp<V2_0::IGnssBatchingCallback> mGnssBatchingCbIface_2_0 = nullptr;
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSSBATCHING_H

View File

@@ -0,0 +1,321 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#define LOG_TAG "LocSvc_GnssConfigurationInterface"
#include <log_util.h>
#include "Gnss.h"
#include "GnssConfiguration.h"
#include "ContextBase.h"
#include <android/hardware/gnss/1.0/types.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::gnss::V1_0::GnssConstellationType;
using namespace loc_core;
GnssConfiguration::GnssConfiguration(Gnss* gnss) : mGnss(gnss) {
}
// Methods from ::android::hardware::gps::V1_0::IGnssConfiguration follow.
Return<bool> GnssConfiguration::setSuplEs(bool /*enabled*/) {
// deprecated function. Must return false to pass VTS
return false;
}
Return<bool> GnssConfiguration::setSuplVersion(uint32_t version) {
if (mGnss == nullptr) {
LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
return false;
}
GnssConfig config;
memset(&config, 0, sizeof(GnssConfig));
config.size = sizeof(GnssConfig);
config.flags = GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT;
switch (version) {
case 0x00020002:
config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_2;
break;
case 0x00020000:
config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_0;
break;
case 0x00010000:
config.suplVersion = GNSS_CONFIG_SUPL_VERSION_1_0_0;
break;
default:
LOC_LOGE("%s]: invalid version: 0x%x.", __FUNCTION__, version);
return false;
break;
}
return mGnss->updateConfiguration(config);
}
Return<bool> GnssConfiguration::setSuplMode(uint8_t mode) {
if (mGnss == nullptr) {
LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
return false;
}
GnssConfig config;
memset(&config, 0, sizeof(GnssConfig));
config.size = sizeof(GnssConfig);
config.flags = GNSS_CONFIG_FLAGS_SUPL_MODE_BIT;
switch (mode) {
case 0:
config.suplModeMask = 0; // STANDALONE ONLY
break;
case 1:
config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSB_BIT;
break;
case 2:
config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSA_BIT;
break;
case 3:
config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSB_BIT | GNSS_CONFIG_SUPL_MODE_MSA_BIT;
break;
default:
LOC_LOGE("%s]: invalid mode: %d.", __FUNCTION__, mode);
return false;
break;
}
return mGnss->updateConfiguration(config);
}
Return<bool> GnssConfiguration::setLppProfile(uint8_t lppProfile) {
if (mGnss == nullptr) {
LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
return false;
}
GnssConfig config = {};
config.size = sizeof(GnssConfig);
config.flags = GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
switch (lppProfile) {
case 0:
config.lppProfile = GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE;
break;
case 1:
config.lppProfile = GNSS_CONFIG_LPP_PROFILE_USER_PLANE;
break;
case 2:
config.lppProfile = GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE;
break;
case 3:
config.lppProfile = GNSS_CONFIG_LPP_PROFILE_USER_PLANE_AND_CONTROL_PLANE;
break;
default:
LOC_LOGE("%s]: invalid lppProfile: %d.", __FUNCTION__, lppProfile);
return false;
break;
}
return mGnss->updateConfiguration(config);
}
Return<bool> GnssConfiguration::setGlonassPositioningProtocol(uint8_t protocol) {
if (mGnss == nullptr) {
LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
return false;
}
GnssConfig config;
memset(&config, 0, sizeof(GnssConfig));
config.size = sizeof(GnssConfig);
config.flags = GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT;
if (protocol & (1<<0)) {
config.aGlonassPositionProtocolMask |= GNSS_CONFIG_RRC_CONTROL_PLANE_BIT;
}
if (protocol & (1<<1)) {
config.aGlonassPositionProtocolMask |= GNSS_CONFIG_RRLP_USER_PLANE_BIT;
}
if (protocol & (1<<2)) {
config.aGlonassPositionProtocolMask |= GNSS_CONFIG_LLP_USER_PLANE_BIT;
}
if (protocol & (1<<3)) {
config.aGlonassPositionProtocolMask |= GNSS_CONFIG_LLP_CONTROL_PLANE_BIT;
}
return mGnss->updateConfiguration(config);
}
Return<bool> GnssConfiguration::setGpsLock(uint8_t lock) {
if (mGnss == nullptr) {
LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
return false;
}
GnssConfig config = {};
config.size = sizeof(GnssConfig);
config.flags = GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT;
switch (lock) {
case 0:
config.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE;
break;
case 1:
config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO;
break;
case 2:
config.gpsLock = GNSS_CONFIG_GPS_LOCK_NI;
break;
case 3:
config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO_AND_NI;
break;
default:
LOC_LOGE("%s]: invalid lock: %d.", __FUNCTION__, lock);
return false;
break;
}
mGnss->updateConfiguration(config);
// Must return false to pass VTS
return false;
}
Return<bool> GnssConfiguration::setEmergencySuplPdn(bool enabled) {
if (mGnss == nullptr) {
LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
return false;
}
GnssConfig config;
memset(&config, 0, sizeof(GnssConfig));
config.size = sizeof(GnssConfig);
config.flags = GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT;
config.emergencyPdnForEmergencySupl = (enabled ?
GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_YES :
GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_NO);
return mGnss->updateConfiguration(config);
}
// Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow.
Return<bool> GnssConfiguration::setBlacklist(
const hidl_vec<GnssConfiguration::BlacklistedSource>& blacklist) {
ENTRY_LOG_CALLFLOW();
if (nullptr == mGnss) {
LOC_LOGe("mGnss is null");
return false;
}
// blValid is true if blacklist is empty, i.e. clearing the BL;
// if blacklist is not empty, blValid is initialied to false, and later
// updated in the for loop to become true only if there is at least
// one {constellation, svid} in the list that is valid.
bool blValid = (0 == blacklist.size());
GnssConfig config;
memset(&config, 0, sizeof(GnssConfig));
config.size = sizeof(GnssConfig);
config.flags = GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
config.blacklistedSvIds.clear();
GnssSvIdSource source = {};
for (int idx = 0; idx < (int)blacklist.size(); idx++) {
// Set blValid true if any one source is valid
blValid = setBlacklistedSource(source, blacklist[idx]) || blValid;
config.blacklistedSvIds.push_back(source);
}
// Update configuration only if blValid is true
// i.e. only if atleast one source is valid for blacklisting
return (blValid && mGnss->updateConfiguration(config));
}
bool GnssConfiguration::setBlacklistedSource(
GnssSvIdSource& copyToSource,
const GnssConfiguration::BlacklistedSource& copyFromSource) {
bool retVal = true;
uint16_t svIdOffset = 0;
copyToSource.size = sizeof(GnssSvIdSource);
copyToSource.svId = copyFromSource.svid;
switch(copyFromSource.constellation) {
case GnssConstellationType::GPS:
copyToSource.constellation = GNSS_SV_TYPE_GPS;
LOC_LOGe("GPS SVs can't be blacklisted.");
retVal = false;
break;
case GnssConstellationType::SBAS:
copyToSource.constellation = GNSS_SV_TYPE_SBAS;
LOC_LOGe("SBAS SVs can't be blacklisted.");
retVal = false;
break;
case GnssConstellationType::GLONASS:
copyToSource.constellation = GNSS_SV_TYPE_GLONASS;
svIdOffset = GNSS_SV_CONFIG_GLO_INITIAL_SV_ID - 1;
break;
case GnssConstellationType::QZSS:
copyToSource.constellation = GNSS_SV_TYPE_QZSS;
svIdOffset = 0;
break;
case GnssConstellationType::BEIDOU:
copyToSource.constellation = GNSS_SV_TYPE_BEIDOU;
svIdOffset = GNSS_SV_CONFIG_BDS_INITIAL_SV_ID - 1;
break;
case GnssConstellationType::GALILEO:
copyToSource.constellation = GNSS_SV_TYPE_GALILEO;
svIdOffset = GNSS_SV_CONFIG_GAL_INITIAL_SV_ID - 1;
break;
default:
copyToSource.constellation = GNSS_SV_TYPE_UNKNOWN;
LOC_LOGe("Invalid constellation %hhu", copyFromSource.constellation);
retVal = false;
break;
}
if (copyToSource.svId > 0 && svIdOffset > 0) {
copyToSource.svId += svIdOffset;
}
return retVal;
}
// Methods from ::android::hardware::gnss::V2_0::IGnssConfiguration follow.
Return<bool> GnssConfiguration::setEsExtensionSec(uint32_t emergencyExtensionSeconds) {
ENTRY_LOG_CALLFLOW();
if (mGnss == nullptr) {
LOC_LOGe("mGnss is nullptr");
return false;
}
GnssConfig config;
memset(&config, 0, sizeof(GnssConfig));
config.size = sizeof(GnssConfig);
config.flags = GNSS_CONFIG_FLAGS_EMERGENCY_EXTENSION_SECONDS_BIT;
config.emergencyExtensionSeconds = emergencyExtensionSeconds;
return mGnss->updateConfiguration(config);
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,80 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/* 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.
*/
#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSCONFIGURATION_H
#define ANDROID_HARDWARE_GNSS_V2_0_GNSSCONFIGURATION_H
#include <android/hardware/gnss/2.0/IGnssConfiguration.h>
#include <hidl/Status.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
/*
* Interface for passing GNSS configuration info from platform to HAL.
*/
struct Gnss;
struct GnssConfiguration : public V2_0::IGnssConfiguration {
GnssConfiguration(Gnss* gnss);
~GnssConfiguration() = default;
/*
* Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow.
* These declarations were generated from IGnssConfiguration.hal.
*/
Return<bool> setSuplVersion(uint32_t version) override;
Return<bool> setSuplMode(uint8_t mode) override;
Return<bool> setSuplEs(bool enabled) override;
Return<bool> setLppProfile(uint8_t lppProfile) override;
Return<bool> setGlonassPositioningProtocol(uint8_t protocol) override;
Return<bool> setEmergencySuplPdn(bool enable) override;
Return<bool> setGpsLock(uint8_t lock) override;
// Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow.
Return<bool> setBlacklist(
const hidl_vec<GnssConfiguration::BlacklistedSource>& blacklist) override;
// Methods from ::android::hardware::gnss::V2_0::IGnssConfiguration follow.
Return<bool> setEsExtensionSec(uint32_t emergencyExtensionSeconds) override;
private:
Gnss* mGnss = nullptr;
bool setBlacklistedSource(
GnssSvIdSource& copyToSource,
const GnssConfiguration::BlacklistedSource& copyFromSource);
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSSCONFIGURATION_H

View File

@@ -0,0 +1,299 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#define LOG_TAG "LocSvc_GnssDebugInterface"
#include <log/log.h>
#include <log_util.h>
#include "Gnss.h"
#include "GnssDebug.h"
#include "LocationUtil.h"
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::hidl_vec;
using ::android::hardware::gnss::V2_0::IGnssDebug;
#define GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS (20000000)
#define GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS (20000)
#define GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC (500)
#define GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG (180)
#define GNSS_DEBUG_UNKNOWN_UTC_TIME (1483228800000LL) // 1/1/2017 00:00 GMT
#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN (999) // 999 ns
#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX (1.57783680E17) // 5 years in ns
#define GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC (2.0e5) // ppm
GnssDebug::GnssDebug(Gnss* gnss) : mGnss(gnss)
{
}
/*
* This methods requests position, time and satellite ephemeris debug information
* from the HAL.
*
* @return void
*/
Return<void> GnssDebug::getDebugData(getDebugData_cb _hidl_cb)
{
LOC_LOGD("%s]: ", __func__);
V1_0::IGnssDebug::DebugData data = { };
if((nullptr == mGnss) || (nullptr == mGnss->getGnssInterface())){
LOC_LOGE("GnssDebug - Null GNSS interface");
_hidl_cb(data);
return Void();
}
// get debug report snapshot via hal interface
GnssDebugReport reports = { };
mGnss->getGnssInterface()->getDebugReport(reports);
// location block
if (reports.mLocation.mValid) {
data.position.valid = true;
data.position.latitudeDegrees = reports.mLocation.mLocation.latitude;
data.position.longitudeDegrees = reports.mLocation.mLocation.longitude;
data.position.altitudeMeters = reports.mLocation.mLocation.altitude;
data.position.speedMetersPerSec =
(double)(reports.mLocation.mLocation.speed);
data.position.bearingDegrees =
(double)(reports.mLocation.mLocation.bearing);
data.position.horizontalAccuracyMeters =
(double)(reports.mLocation.mLocation.accuracy);
data.position.verticalAccuracyMeters =
reports.mLocation.verticalAccuracyMeters;
data.position.speedAccuracyMetersPerSecond =
reports.mLocation.speedAccuracyMetersPerSecond;
data.position.bearingAccuracyDegrees =
reports.mLocation.bearingAccuracyDegrees;
timeval tv_now, tv_report;
tv_report.tv_sec = reports.mLocation.mUtcReported.tv_sec;
tv_report.tv_usec = reports.mLocation.mUtcReported.tv_nsec / 1000ULL;
gettimeofday(&tv_now, NULL);
data.position.ageSeconds =
(tv_now.tv_sec - tv_report.tv_sec) +
(float)((tv_now.tv_usec - tv_report.tv_usec)) / 1000000;
}
else {
data.position.valid = false;
}
if (data.position.horizontalAccuracyMeters <= 0 ||
data.position.horizontalAccuracyMeters > GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS) {
data.position.horizontalAccuracyMeters = GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS;
}
if (data.position.verticalAccuracyMeters <= 0 ||
data.position.verticalAccuracyMeters > GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS) {
data.position.verticalAccuracyMeters = GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS;
}
if (data.position.speedAccuracyMetersPerSecond <= 0 ||
data.position.speedAccuracyMetersPerSecond > GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC) {
data.position.speedAccuracyMetersPerSecond = GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC;
}
if (data.position.bearingAccuracyDegrees <= 0 ||
data.position.bearingAccuracyDegrees > GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG) {
data.position.bearingAccuracyDegrees = GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG;
}
// time block
if (reports.mTime.mValid) {
data.time.timeEstimate = reports.mTime.timeEstimate;
data.time.timeUncertaintyNs = reports.mTime.timeUncertaintyNs;
data.time.frequencyUncertaintyNsPerSec =
reports.mTime.frequencyUncertaintyNsPerSec;
}
if (data.time.timeEstimate < GNSS_DEBUG_UNKNOWN_UTC_TIME) {
data.time.timeEstimate = GNSS_DEBUG_UNKNOWN_UTC_TIME;
}
if (data.time.timeUncertaintyNs <= 0) {
data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN;
} else if (data.time.timeUncertaintyNs > GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX) {
data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX;
}
if (data.time.frequencyUncertaintyNsPerSec <= 0 ||
data.time.frequencyUncertaintyNsPerSec > (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC) {
data.time.frequencyUncertaintyNsPerSec = (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC;
}
// satellite data block
V1_0::IGnssDebug::SatelliteData s = { };
std::vector<V1_0::IGnssDebug::SatelliteData> s_array;
for (uint32_t i=0; i<reports.mSatelliteInfo.size(); i++) {
memset(&s, 0, sizeof(s));
s.svid = reports.mSatelliteInfo[i].svid;
convertGnssConstellationType(
reports.mSatelliteInfo[i].constellation, s.constellation);
convertGnssEphemerisType(
reports.mSatelliteInfo[i].mEphemerisType, s.ephemerisType);
convertGnssEphemerisSource(
reports.mSatelliteInfo[i].mEphemerisSource, s.ephemerisSource);
convertGnssEphemerisHealth(
reports.mSatelliteInfo[i].mEphemerisHealth, s.ephemerisHealth);
s.ephemerisAgeSeconds =
reports.mSatelliteInfo[i].ephemerisAgeSeconds;
s.serverPredictionIsAvailable =
reports.mSatelliteInfo[i].serverPredictionIsAvailable;
s.serverPredictionAgeSeconds =
reports.mSatelliteInfo[i].serverPredictionAgeSeconds;
s_array.push_back(s);
}
data.satelliteDataArray = s_array;
// callback HIDL with collected debug data
_hidl_cb(data);
return Void();
}
Return<void> GnssDebug::getDebugData_2_0(getDebugData_2_0_cb _hidl_cb)
{
LOC_LOGD("%s]: ", __func__);
V2_0::IGnssDebug::DebugData data = { };
if((nullptr == mGnss) || (nullptr == mGnss->getGnssInterface())){
LOC_LOGE("GnssDebug - Null GNSS interface");
_hidl_cb(data);
return Void();
}
// get debug report snapshot via hal interface
GnssDebugReport reports = { };
mGnss->getGnssInterface()->getDebugReport(reports);
// location block
if (reports.mLocation.mValid) {
data.position.valid = true;
data.position.latitudeDegrees = reports.mLocation.mLocation.latitude;
data.position.longitudeDegrees = reports.mLocation.mLocation.longitude;
data.position.altitudeMeters = reports.mLocation.mLocation.altitude;
data.position.speedMetersPerSec =
(double)(reports.mLocation.mLocation.speed);
data.position.bearingDegrees =
(double)(reports.mLocation.mLocation.bearing);
data.position.horizontalAccuracyMeters =
(double)(reports.mLocation.mLocation.accuracy);
data.position.verticalAccuracyMeters =
reports.mLocation.verticalAccuracyMeters;
data.position.speedAccuracyMetersPerSecond =
reports.mLocation.speedAccuracyMetersPerSecond;
data.position.bearingAccuracyDegrees =
reports.mLocation.bearingAccuracyDegrees;
timeval tv_now, tv_report;
tv_report.tv_sec = reports.mLocation.mUtcReported.tv_sec;
tv_report.tv_usec = reports.mLocation.mUtcReported.tv_nsec / 1000ULL;
gettimeofday(&tv_now, NULL);
data.position.ageSeconds =
(tv_now.tv_sec - tv_report.tv_sec) +
(float)((tv_now.tv_usec - tv_report.tv_usec)) / 1000000;
}
else {
data.position.valid = false;
}
if (data.position.horizontalAccuracyMeters <= 0 ||
data.position.horizontalAccuracyMeters > GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS) {
data.position.horizontalAccuracyMeters = GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS;
}
if (data.position.verticalAccuracyMeters <= 0 ||
data.position.verticalAccuracyMeters > GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS) {
data.position.verticalAccuracyMeters = GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS;
}
if (data.position.speedAccuracyMetersPerSecond <= 0 ||
data.position.speedAccuracyMetersPerSecond > GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC) {
data.position.speedAccuracyMetersPerSecond = GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC;
}
if (data.position.bearingAccuracyDegrees <= 0 ||
data.position.bearingAccuracyDegrees > GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG) {
data.position.bearingAccuracyDegrees = GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG;
}
// time block
if (reports.mTime.mValid) {
data.time.timeEstimate = reports.mTime.timeEstimate;
data.time.timeUncertaintyNs = reports.mTime.timeUncertaintyNs;
data.time.frequencyUncertaintyNsPerSec =
reports.mTime.frequencyUncertaintyNsPerSec;
}
if (data.time.timeEstimate < GNSS_DEBUG_UNKNOWN_UTC_TIME) {
data.time.timeEstimate = GNSS_DEBUG_UNKNOWN_UTC_TIME;
}
if (data.time.timeUncertaintyNs <= 0) {
data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN;
}
else if (data.time.timeUncertaintyNs > GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX) {
data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX;
}
if (data.time.frequencyUncertaintyNsPerSec <= 0 ||
data.time.frequencyUncertaintyNsPerSec > (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC) {
data.time.frequencyUncertaintyNsPerSec = (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC;
}
// satellite data block
V2_0::IGnssDebug::SatelliteData s = { };
std::vector<V2_0::IGnssDebug::SatelliteData> s_array;
for (uint32_t i=0; i<reports.mSatelliteInfo.size(); i++) {
memset(&s, 0, sizeof(s));
s.v1_0.svid = reports.mSatelliteInfo[i].svid;
convertGnssConstellationType(
reports.mSatelliteInfo[i].constellation, s.constellation);
convertGnssEphemerisType(
reports.mSatelliteInfo[i].mEphemerisType, s.v1_0.ephemerisType);
convertGnssEphemerisSource(
reports.mSatelliteInfo[i].mEphemerisSource, s.v1_0.ephemerisSource);
convertGnssEphemerisHealth(
reports.mSatelliteInfo[i].mEphemerisHealth, s.v1_0.ephemerisHealth);
s.v1_0.ephemerisAgeSeconds =
reports.mSatelliteInfo[i].ephemerisAgeSeconds;
s.v1_0.serverPredictionIsAvailable =
reports.mSatelliteInfo[i].serverPredictionIsAvailable;
s.v1_0.serverPredictionAgeSeconds =
reports.mSatelliteInfo[i].serverPredictionAgeSeconds;
s_array.push_back(s);
}
data.satelliteDataArray = s_array;
// callback HIDL with collected debug data
_hidl_cb(data);
return Void();
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSDEBUG_H
#define ANDROID_HARDWARE_GNSS_V2_0_GNSSDEBUG_H
#include <android/hardware/gnss/2.0/IGnssDebug.h>
#include <hidl/Status.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::gnss::V2_0::IGnssDebug;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
/* Interface for GNSS Debug support. */
struct Gnss;
struct GnssDebug : public IGnssDebug {
GnssDebug(Gnss* gnss);
~GnssDebug() {};
// Methods from ::android::hardware::gnss::V1_0::IGnssDebug follow
Return<void> getDebugData(getDebugData_cb _hidl_cb) override;
// Methods from ::android::hardware::gnss::V2_0::IGnssDebug follow.
Return<void> getDebugData_2_0(getDebugData_2_0_cb _hidl_cb) override;
private:
Gnss* mGnss = nullptr;
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSSDEBUG_H

View File

@@ -0,0 +1,141 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#define LOG_TAG "GnssHal_GnssGeofencing"
#include <log_util.h>
#include <GeofenceAPIClient.h>
#include "GnssGeofencing.h"
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
void GnssGeofencing::GnssGeofencingDeathRecipient::serviceDied(
uint64_t cookie, const wp<IBase>& who) {
LOC_LOGE("%s] service died. cookie: %llu, who: %p",
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
if (mGnssGeofencing != nullptr) {
mGnssGeofencing->removeAllGeofences();
}
}
GnssGeofencing::GnssGeofencing() : mApi(nullptr) {
mGnssGeofencingDeathRecipient = new GnssGeofencingDeathRecipient(this);
}
GnssGeofencing::~GnssGeofencing() {
if (mApi != nullptr) {
delete mApi;
mApi = nullptr;
}
}
// Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
Return<void> GnssGeofencing::setCallback(const sp<IGnssGeofenceCallback>& callback) {
if (mApi != nullptr) {
LOC_LOGd("mApi is NOT nullptr");
return Void();
}
mApi = new GeofenceAPIClient(callback);
if (mApi == nullptr) {
LOC_LOGE("%s]: failed to create mApi", __FUNCTION__);
}
if (mGnssGeofencingCbIface != nullptr) {
mGnssGeofencingCbIface->unlinkToDeath(mGnssGeofencingDeathRecipient);
}
mGnssGeofencingCbIface = callback;
if (mGnssGeofencingCbIface != nullptr) {
mGnssGeofencingCbIface->linkToDeath(mGnssGeofencingDeathRecipient, 0 /*cookie*/);
}
return Void();
}
Return<void> GnssGeofencing::addGeofence(
int32_t geofenceId,
double latitudeDegrees,
double longitudeDegrees,
double radiusMeters,
IGnssGeofenceCallback::GeofenceTransition lastTransition,
int32_t monitorTransitions,
uint32_t notificationResponsivenessMs,
uint32_t unknownTimerMs) {
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
} else {
mApi->geofenceAdd(
geofenceId,
latitudeDegrees,
longitudeDegrees,
radiusMeters,
static_cast<int32_t>(lastTransition),
monitorTransitions,
notificationResponsivenessMs,
unknownTimerMs);
}
return Void();
}
Return<void> GnssGeofencing::pauseGeofence(int32_t geofenceId) {
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
} else {
mApi->geofencePause(geofenceId);
}
return Void();
}
Return<void> GnssGeofencing::resumeGeofence(int32_t geofenceId, int32_t monitorTransitions) {
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
} else {
mApi->geofenceResume(geofenceId, monitorTransitions);
}
return Void();
}
Return<void> GnssGeofencing::removeGeofence(int32_t geofenceId) {
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
} else {
mApi->geofenceRemove(geofenceId);
}
return Void();
}
Return<void> GnssGeofencing::removeAllGeofences() {
if (mApi == nullptr) {
LOC_LOGD("%s]: mApi is nullptr, do nothing", __FUNCTION__);
} else {
mApi->geofenceRemoveAll();
}
return Void();
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSGEOFENCING_H
#define ANDROID_HARDWARE_GNSS_V2_0_GNSSGEOFENCING_H
#include <android/hardware/gnss/1.0/IGnssGeofencing.h>
#include <hidl/Status.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback;
using ::android::hardware::gnss::V1_0::IGnssGeofencing;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
class GeofenceAPIClient;
struct GnssGeofencing : public IGnssGeofencing {
GnssGeofencing();
~GnssGeofencing();
/*
* Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
* These declarations were generated from IGnssGeofencing.hal.
*/
Return<void> setCallback(const sp<IGnssGeofenceCallback>& callback) override;
Return<void> addGeofence(int32_t geofenceId,
double latitudeDegrees,
double longitudeDegrees,
double radiusMeters,
IGnssGeofenceCallback::GeofenceTransition lastTransition,
int32_t monitorTransitions,
uint32_t notificationResponsivenessMs,
uint32_t unknownTimerMs) override;
Return<void> pauseGeofence(int32_t geofenceId) override;
Return<void> resumeGeofence(int32_t geofenceId, int32_t monitorTransitions) override;
Return<void> removeGeofence(int32_t geofenceId) override;
private:
// This method is not part of the IGnss base class.
// It is called by GnssGeofencingDeathRecipient to remove all geofences added so far.
Return<void> removeAllGeofences();
private:
struct GnssGeofencingDeathRecipient : hidl_death_recipient {
GnssGeofencingDeathRecipient(sp<GnssGeofencing> gnssGeofencing) :
mGnssGeofencing(gnssGeofencing) {
}
~GnssGeofencingDeathRecipient() = default;
virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
sp<GnssGeofencing> mGnssGeofencing;
};
private:
sp<GnssGeofencingDeathRecipient> mGnssGeofencingDeathRecipient = nullptr;
sp<IGnssGeofenceCallback> mGnssGeofencingCbIface = nullptr;
GeofenceAPIClient* mApi = nullptr;
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSSGEOFENCING_H

View File

@@ -0,0 +1,165 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#define LOG_TAG "LocSvc_GnssMeasurementInterface"
#include <log_util.h>
#include "GnssMeasurement.h"
#include "MeasurementAPIClient.h"
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
void GnssMeasurement::GnssMeasurementDeathRecipient::serviceDied(
uint64_t cookie, const wp<IBase>& who) {
LOC_LOGE("%s] service died. cookie: %llu, who: %p",
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
if (mGnssMeasurement != nullptr) {
mGnssMeasurement->close();
}
}
GnssMeasurement::GnssMeasurement() {
mGnssMeasurementDeathRecipient = new GnssMeasurementDeathRecipient(this);
mApi = new MeasurementAPIClient();
}
GnssMeasurement::~GnssMeasurement() {
if (mApi) {
delete mApi;
mApi = nullptr;
}
}
// Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
Return<GnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
const sp<V1_0::IGnssMeasurementCallback>& callback) {
Return<GnssMeasurement::GnssMeasurementStatus> ret =
IGnssMeasurement::GnssMeasurementStatus::ERROR_GENERIC;
if (mGnssMeasurementCbIface != nullptr) {
LOC_LOGE("%s]: GnssMeasurementCallback is already set", __FUNCTION__);
return IGnssMeasurement::GnssMeasurementStatus::ERROR_ALREADY_INIT;
}
if (callback == nullptr) {
LOC_LOGE("%s]: callback is nullptr", __FUNCTION__);
return ret;
}
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
return ret;
}
mGnssMeasurementCbIface = callback;
mGnssMeasurementCbIface->linkToDeath(mGnssMeasurementDeathRecipient, 0);
return mApi->measurementSetCallback(callback);
}
Return<void> GnssMeasurement::close() {
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
return Void();
}
if (mGnssMeasurementCbIface != nullptr) {
mGnssMeasurementCbIface->unlinkToDeath(mGnssMeasurementDeathRecipient);
mGnssMeasurementCbIface = nullptr;
}
if (mGnssMeasurementCbIface_1_1 != nullptr) {
mGnssMeasurementCbIface_1_1->unlinkToDeath(mGnssMeasurementDeathRecipient);
mGnssMeasurementCbIface_1_1 = nullptr;
}
if (mGnssMeasurementCbIface_2_0 != nullptr) {
mGnssMeasurementCbIface_2_0->unlinkToDeath(mGnssMeasurementDeathRecipient);
mGnssMeasurementCbIface_2_0 = nullptr;
}
mApi->measurementClose();
return Void();
}
// Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow.
Return<GnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback_1_1(
const sp<V1_1::IGnssMeasurementCallback>& callback, bool enableFullTracking) {
Return<GnssMeasurement::GnssMeasurementStatus> ret =
IGnssMeasurement::GnssMeasurementStatus::ERROR_GENERIC;
if (mGnssMeasurementCbIface_1_1 != nullptr) {
LOC_LOGE("%s]: GnssMeasurementCallback is already set", __FUNCTION__);
return IGnssMeasurement::GnssMeasurementStatus::ERROR_ALREADY_INIT;
}
if (callback == nullptr) {
LOC_LOGE("%s]: callback is nullptr", __FUNCTION__);
return ret;
}
if (nullptr == mApi) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
return ret;
}
mGnssMeasurementCbIface_1_1 = callback;
mGnssMeasurementCbIface_1_1->linkToDeath(mGnssMeasurementDeathRecipient, 0);
GnssPowerMode powerMode = enableFullTracking?
GNSS_POWER_MODE_M1 : GNSS_POWER_MODE_M2;
return mApi->measurementSetCallback_1_1(callback, powerMode);
}
// Methods from ::android::hardware::gnss::V2_0::IGnssMeasurement follow.
Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback_2_0(
const sp<V2_0::IGnssMeasurementCallback>& callback,
bool enableFullTracking) {
Return<GnssMeasurement::GnssMeasurementStatus> ret =
IGnssMeasurement::GnssMeasurementStatus::ERROR_GENERIC;
if (mGnssMeasurementCbIface_2_0 != nullptr) {
LOC_LOGE("%s]: GnssMeasurementCallback is already set", __FUNCTION__);
return IGnssMeasurement::GnssMeasurementStatus::ERROR_ALREADY_INIT;
}
if (callback == nullptr) {
LOC_LOGE("%s]: callback is nullptr", __FUNCTION__);
return ret;
}
if (nullptr == mApi) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
return ret;
}
mGnssMeasurementCbIface_2_0 = callback;
mGnssMeasurementCbIface_2_0->linkToDeath(mGnssMeasurementDeathRecipient, 0);
GnssPowerMode powerMode = enableFullTracking ?
GNSS_POWER_MODE_M1 : GNSS_POWER_MODE_M2;
return mApi->measurementSetCallback_2_0(callback, powerMode);
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
#define ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
#include <android/hardware/gnss/2.0/IGnssMeasurement.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
class MeasurementAPIClient;
struct GnssMeasurement : public V2_0::IGnssMeasurement {
GnssMeasurement();
~GnssMeasurement();
/*
* Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
* These declarations were generated from IGnssMeasurement.hal.
*/
Return<GnssMeasurement::GnssMeasurementStatus> setCallback(
const sp<V1_0::IGnssMeasurementCallback>& callback) override;
Return<void> close() override;
// Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow.
Return<GnssMeasurement::GnssMeasurementStatus> setCallback_1_1(
const sp<V1_1::IGnssMeasurementCallback>& callback,
bool enableFullTracking) override;
// Methods from ::android::hardware::gnss::V2_0::IGnssMeasurement follow.
Return<GnssMeasurement::GnssMeasurementStatus> setCallback_2_0(
const sp<V2_0::IGnssMeasurementCallback>& callback,
bool enableFullTracking) override;
private:
struct GnssMeasurementDeathRecipient : hidl_death_recipient {
GnssMeasurementDeathRecipient(sp<GnssMeasurement> gnssMeasurement) :
mGnssMeasurement(gnssMeasurement) {
}
~GnssMeasurementDeathRecipient() = default;
virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
sp<GnssMeasurement> mGnssMeasurement;
};
private:
sp<GnssMeasurementDeathRecipient> mGnssMeasurementDeathRecipient = nullptr;
sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface = nullptr;
sp<V1_1::IGnssMeasurementCallback> mGnssMeasurementCbIface_1_1 = nullptr;
sp<V2_0::IGnssMeasurementCallback> mGnssMeasurementCbIface_2_0 = nullptr;
MeasurementAPIClient* mApi;
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#define LOG_TAG "LocSvc_GnssNiInterface"
#include <log_util.h>
#include "Gnss.h"
#include "GnssNi.h"
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
void GnssNi::GnssNiDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who) {
LOC_LOGE("%s] service died. cookie: %llu, who: %p",
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
// we do nothing here
// Gnss::GnssDeathRecipient will stop the session
}
GnssNi::GnssNi(Gnss* gnss) : mGnss(gnss) {
mGnssNiDeathRecipient = new GnssNiDeathRecipient(this);
}
// Methods from ::android::hardware::gnss::V1_0::IGnssNi follow.
Return<void> GnssNi::setCallback(const sp<IGnssNiCallback>& callback) {
if (mGnss == nullptr) {
LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
return Void();
}
mGnss->setGnssNiCb(callback);
if (mGnssNiCbIface != nullptr) {
mGnssNiCbIface->unlinkToDeath(mGnssNiDeathRecipient);
}
mGnssNiCbIface = callback;
if (mGnssNiCbIface != nullptr) {
mGnssNiCbIface->linkToDeath(mGnssNiDeathRecipient, 0 /*cookie*/);
}
return Void();
}
Return<void> GnssNi::respond(int32_t notifId, IGnssNiCallback::GnssUserResponseType userResponse) {
if (mGnss == nullptr) {
LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
return Void();
}
GnssAPIClient* api = mGnss->getApi();
if (api == nullptr) {
LOC_LOGE("%s]: api is nullptr", __FUNCTION__);
return Void();
}
api->gnssNiRespond(notifId, userResponse);
return Void();
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

75
gps/android/2.0/GnssNi.h Normal file
View File

@@ -0,0 +1,75 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSNI_H
#define ANDROID_HARDWARE_GNSS_V2_0_GNSSNI_H
#include <android/hardware/gnss/1.0/IGnssNi.h>
#include <hidl/Status.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::gnss::V1_0::IGnssNi;
using ::android::hardware::gnss::V1_0::IGnssNiCallback;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
struct Gnss;
struct GnssNi : public IGnssNi {
GnssNi(Gnss* gnss);
~GnssNi() = default;
/*
* Methods from ::android::hardware::gnss::V1_0::IGnssNi follow.
* These declarations were generated from IGnssNi.hal.
*/
Return<void> setCallback(const sp<IGnssNiCallback>& callback) override;
Return<void> respond(int32_t notifId,
IGnssNiCallback::GnssUserResponseType userResponse) override;
private:
struct GnssNiDeathRecipient : hidl_death_recipient {
GnssNiDeathRecipient(sp<GnssNi> gnssNi) : mGnssNi(gnssNi) {
}
~GnssNiDeathRecipient() = default;
virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
sp<GnssNi> mGnssNi;
};
private:
sp<GnssNiDeathRecipient> mGnssNiDeathRecipient = nullptr;
sp<IGnssNiCallback> mGnssNiCbIface = nullptr;
Gnss* mGnss = nullptr;
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSSNI_H

View File

@@ -0,0 +1,4 @@
service gnss_service /vendor/bin/hw/android.hardware.gnss@2.0-service-qti
class hal
user gps
group system gps radio vendor_qti_diag

View File

@@ -0,0 +1,36 @@
<!-- Copyright (c) 2019, 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.
-->
<manifest version="1.0" type="device">
<hal format="hidl">
<name>android.hardware.gnss</name>
<transport>hwbinder</transport>
<fqname>@1.1::IGnss/default</fqname>
<fqname>@2.0::IGnss/default</fqname>
</hal>
</manifest>

View File

@@ -0,0 +1,250 @@
/* Copyright (c) 2017-2019, 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_NDEBUG 0
#define LOG_TAG "LocSvc_BatchingAPIClient"
#include <log_util.h>
#include <loc_cfg.h>
#include "LocationUtil.h"
#include "BatchingAPIClient.h"
#include "limits.h"
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::gnss::V2_0::IGnssBatching;
using ::android::hardware::gnss::V2_0::IGnssBatchingCallback;
using ::android::hardware::gnss::V2_0::GnssLocation;
static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions& out,
LocationCapabilitiesMask mask);
BatchingAPIClient::BatchingAPIClient(const sp<V1_0::IGnssBatchingCallback>& callback) :
LocationAPIClientBase(),
mGnssBatchingCbIface(nullptr),
mDefaultId(UINT_MAX),
mLocationCapabilitiesMask(0),
mGnssBatchingCbIface_2_0(nullptr)
{
LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
gnssUpdateCallbacks(callback);
}
BatchingAPIClient::BatchingAPIClient(const sp<V2_0::IGnssBatchingCallback>& callback) :
LocationAPIClientBase(),
mGnssBatchingCbIface(nullptr),
mDefaultId(UINT_MAX),
mLocationCapabilitiesMask(0),
mGnssBatchingCbIface_2_0(nullptr)
{
LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
gnssUpdateCallbacks_2_0(callback);
}
BatchingAPIClient::~BatchingAPIClient()
{
LOC_LOGD("%s]: ()", __FUNCTION__);
}
int BatchingAPIClient::getBatchSize()
{
LOC_LOGD("%s]: ()", __FUNCTION__);
return locAPIGetBatchSize();
}
void BatchingAPIClient::setCallbacks()
{
LocationCallbacks locationCallbacks;
memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
locationCallbacks.size = sizeof(LocationCallbacks);
locationCallbacks.trackingCb = nullptr;
locationCallbacks.batchingCb = nullptr;
locationCallbacks.batchingCb = [this](size_t count, Location* location,
BatchingOptions batchOptions) {
onBatchingCb(count, location, batchOptions);
};
locationCallbacks.geofenceBreachCb = nullptr;
locationCallbacks.geofenceStatusCb = nullptr;
locationCallbacks.gnssLocationInfoCb = nullptr;
locationCallbacks.gnssNiCb = nullptr;
locationCallbacks.gnssSvCb = nullptr;
locationCallbacks.gnssNmeaCb = nullptr;
locationCallbacks.gnssMeasurementsCb = nullptr;
locAPISetCallbacks(locationCallbacks);
}
void BatchingAPIClient::gnssUpdateCallbacks(const sp<V1_0::IGnssBatchingCallback>& callback)
{
mMutex.lock();
mGnssBatchingCbIface = callback;
mMutex.unlock();
if (mGnssBatchingCbIface != nullptr) {
setCallbacks();
}
}
void BatchingAPIClient::gnssUpdateCallbacks_2_0(const sp<V2_0::IGnssBatchingCallback>& callback)
{
mMutex.lock();
mGnssBatchingCbIface_2_0 = callback;
mMutex.unlock();
if (mGnssBatchingCbIface_2_0 != nullptr) {
setCallbacks();
}
}
int BatchingAPIClient::startSession(const IGnssBatching::Options& opts)
{
LOC_LOGD("%s]: (%lld %d)", __FUNCTION__,
static_cast<long long>(opts.periodNanos), static_cast<uint8_t>(opts.flags));
int retVal = -1;
LocationOptions options;
convertBatchOption(opts, options, mLocationCapabilitiesMask);
uint32_t mode = 0;
if (opts.flags == static_cast<uint8_t>(IGnssBatching::Flag::WAKEUP_ON_FIFO_FULL)) {
mode = SESSION_MODE_ON_FULL;
}
if (locAPIStartSession(mDefaultId, mode, options) == LOCATION_ERROR_SUCCESS) {
retVal = 1;
}
return retVal;
}
int BatchingAPIClient::updateSessionOptions(const IGnssBatching::Options& opts)
{
LOC_LOGD("%s]: (%lld %d)", __FUNCTION__,
static_cast<long long>(opts.periodNanos), static_cast<uint8_t>(opts.flags));
int retVal = -1;
LocationOptions options;
convertBatchOption(opts, options, mLocationCapabilitiesMask);
uint32_t mode = 0;
if (opts.flags == static_cast<uint8_t>(IGnssBatching::Flag::WAKEUP_ON_FIFO_FULL)) {
mode = SESSION_MODE_ON_FULL;
}
if (locAPIUpdateSessionOptions(mDefaultId, mode, options) == LOCATION_ERROR_SUCCESS) {
retVal = 1;
}
return retVal;
}
int BatchingAPIClient::stopSession()
{
LOC_LOGD("%s]: ", __FUNCTION__);
int retVal = -1;
if (locAPIStopSession(mDefaultId) == LOCATION_ERROR_SUCCESS) {
retVal = 1;
}
return retVal;
}
void BatchingAPIClient::getBatchedLocation(int last_n_locations)
{
LOC_LOGD("%s]: (%d)", __FUNCTION__, last_n_locations);
locAPIGetBatchedLocations(mDefaultId, last_n_locations);
}
void BatchingAPIClient::flushBatchedLocations()
{
LOC_LOGD("%s]: ()", __FUNCTION__);
locAPIGetBatchedLocations(mDefaultId, SIZE_MAX);
}
void BatchingAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
{
LOC_LOGD("%s]: (%02x)", __FUNCTION__, capabilitiesMask);
mLocationCapabilitiesMask = capabilitiesMask;
}
void BatchingAPIClient::onBatchingCb(size_t count, Location* location,
BatchingOptions /*batchOptions*/)
{
mMutex.lock();
auto gnssBatchingCbIface(mGnssBatchingCbIface);
auto gnssBatchingCbIface_2_0(mGnssBatchingCbIface_2_0);
mMutex.unlock();
LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, count);
if (gnssBatchingCbIface_2_0 != nullptr && count > 0) {
hidl_vec<V2_0::GnssLocation> locationVec;
locationVec.resize(count);
for (size_t i = 0; i < count; i++) {
convertGnssLocation(location[i], locationVec[i]);
}
auto r = gnssBatchingCbIface_2_0->gnssLocationBatchCb(locationVec);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssLocationBatchCb 2.0 description=%s",
__func__, r.description().c_str());
}
} else if (gnssBatchingCbIface != nullptr && count > 0) {
hidl_vec<V1_0::GnssLocation> locationVec;
locationVec.resize(count);
for (size_t i = 0; i < count; i++) {
convertGnssLocation(location[i], locationVec[i]);
}
auto r = gnssBatchingCbIface->gnssLocationBatchCb(locationVec);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssLocationBatchCb 1.0 description=%s",
__func__, r.description().c_str());
}
}
}
static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions& out,
LocationCapabilitiesMask mask)
{
memset(&out, 0, sizeof(LocationOptions));
out.size = sizeof(LocationOptions);
out.minInterval = (uint32_t)(in.periodNanos / 1000000L);
out.minDistance = 0;
out.mode = GNSS_SUPL_MODE_STANDALONE;
if (mask & LOCATION_CAPABILITIES_GNSS_MSA_BIT)
out.mode = GNSS_SUPL_MODE_MSA;
if (mask & LOCATION_CAPABILITIES_GNSS_MSB_BIT)
out.mode = GNSS_SUPL_MODE_MSB;
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,81 @@
/* Copyright (c) 2017-2019, 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 BATCHING_API_CLINET_H
#define BATCHING_API_CLINET_H
#include <mutex>
#include <android/hardware/gnss/2.0/IGnssBatching.h>
#include <android/hardware/gnss/2.0/IGnssBatchingCallback.h>
#include <pthread.h>
#include <LocationAPIClientBase.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
class BatchingAPIClient : public LocationAPIClientBase
{
public:
BatchingAPIClient(const sp<V1_0::IGnssBatchingCallback>& callback);
BatchingAPIClient(const sp<V2_0::IGnssBatchingCallback>& callback);
void gnssUpdateCallbacks(const sp<V1_0::IGnssBatchingCallback>& callback);
void gnssUpdateCallbacks_2_0(const sp<V2_0::IGnssBatchingCallback>& callback);
~BatchingAPIClient();
int getBatchSize();
int startSession(const V1_0::IGnssBatching::Options& options);
int updateSessionOptions(const V1_0::IGnssBatching::Options& options);
int stopSession();
void getBatchedLocation(int last_n_locations);
void flushBatchedLocations();
inline LocationCapabilitiesMask getCapabilities() { return mLocationCapabilitiesMask; }
// callbacks
void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final;
void onBatchingCb(size_t count, Location* location, BatchingOptions batchOptions) final;
private:
void setCallbacks();
std::mutex mMutex;
sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface;
uint32_t mDefaultId;
LocationCapabilitiesMask mLocationCapabilitiesMask;
sp<V2_0::IGnssBatchingCallback> mGnssBatchingCbIface_2_0;
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // BATCHING_API_CLINET_H

View File

@@ -0,0 +1,275 @@
/* Copyright (c) 2017-2019, 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_NDEBUG 0
#define LOG_TAG "LocSvc_GeofenceApiClient"
#include <log_util.h>
#include <loc_cfg.h>
#include "LocationUtil.h"
#include "GeofenceAPIClient.h"
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback;
using ::android::hardware::gnss::V1_0::GnssLocation;
GeofenceAPIClient::GeofenceAPIClient(const sp<IGnssGeofenceCallback>& callback) :
LocationAPIClientBase(),
mGnssGeofencingCbIface(callback)
{
LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
LocationCallbacks locationCallbacks;
memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
locationCallbacks.size = sizeof(LocationCallbacks);
locationCallbacks.trackingCb = nullptr;
locationCallbacks.batchingCb = nullptr;
locationCallbacks.geofenceBreachCb = nullptr;
if (mGnssGeofencingCbIface != nullptr) {
locationCallbacks.geofenceBreachCb =
[this](GeofenceBreachNotification geofenceBreachNotification) {
onGeofenceBreachCb(geofenceBreachNotification);
};
locationCallbacks.geofenceStatusCb =
[this](GeofenceStatusNotification geofenceStatusNotification) {
onGeofenceStatusCb(geofenceStatusNotification);
};
}
locationCallbacks.gnssLocationInfoCb = nullptr;
locationCallbacks.gnssNiCb = nullptr;
locationCallbacks.gnssSvCb = nullptr;
locationCallbacks.gnssNmeaCb = nullptr;
locationCallbacks.gnssMeasurementsCb = nullptr;
locAPISetCallbacks(locationCallbacks);
}
void GeofenceAPIClient::geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
double radius_meters, int32_t last_transition, int32_t monitor_transitions,
uint32_t notification_responsiveness_ms, uint32_t unknown_timer_ms)
{
LOC_LOGD("%s]: (%d %f %f %f %d %d %d %d)", __FUNCTION__,
geofence_id, latitude, longitude, radius_meters,
last_transition, monitor_transitions, notification_responsiveness_ms, unknown_timer_ms);
GeofenceOption options;
memset(&options, 0, sizeof(GeofenceOption));
options.size = sizeof(GeofenceOption);
if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::ENTERED)
options.breachTypeMask |= GEOFENCE_BREACH_ENTER_BIT;
if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::EXITED)
options.breachTypeMask |= GEOFENCE_BREACH_EXIT_BIT;
options.responsiveness = notification_responsiveness_ms;
GeofenceInfo data;
data.size = sizeof(GeofenceInfo);
data.latitude = latitude;
data.longitude = longitude;
data.radius = radius_meters;
LocationError err = (LocationError)locAPIAddGeofences(1, &geofence_id, &options, &data);
if (LOCATION_ERROR_SUCCESS != err) {
onAddGeofencesCb(1, &err, &geofence_id);
}
}
void GeofenceAPIClient::geofencePause(uint32_t geofence_id)
{
LOC_LOGD("%s]: (%d)", __FUNCTION__, geofence_id);
locAPIPauseGeofences(1, &geofence_id);
}
void GeofenceAPIClient::geofenceResume(uint32_t geofence_id, int32_t monitor_transitions)
{
LOC_LOGD("%s]: (%d %d)", __FUNCTION__, geofence_id, monitor_transitions);
GeofenceBreachTypeMask mask = 0;
if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::ENTERED)
mask |= GEOFENCE_BREACH_ENTER_BIT;
if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::EXITED)
mask |= GEOFENCE_BREACH_EXIT_BIT;
locAPIResumeGeofences(1, &geofence_id, &mask);
}
void GeofenceAPIClient::geofenceRemove(uint32_t geofence_id)
{
LOC_LOGD("%s]: (%d)", __FUNCTION__, geofence_id);
locAPIRemoveGeofences(1, &geofence_id);
}
void GeofenceAPIClient::geofenceRemoveAll()
{
LOC_LOGD("%s]", __FUNCTION__);
// TODO locAPIRemoveAllGeofences();
}
// callbacks
void GeofenceAPIClient::onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification)
{
LOC_LOGD("%s]: (%d)", __FUNCTION__, geofenceBreachNotification.count);
if (mGnssGeofencingCbIface != nullptr) {
for (size_t i = 0; i < geofenceBreachNotification.count; i++) {
GnssLocation gnssLocation;
convertGnssLocation(geofenceBreachNotification.location, gnssLocation);
IGnssGeofenceCallback::GeofenceTransition transition;
if (geofenceBreachNotification.type == GEOFENCE_BREACH_ENTER)
transition = IGnssGeofenceCallback::GeofenceTransition::ENTERED;
else if (geofenceBreachNotification.type == GEOFENCE_BREACH_EXIT)
transition = IGnssGeofenceCallback::GeofenceTransition::EXITED;
else {
// continue with other breach if transition is
// nether GPS_GEOFENCE_ENTERED nor GPS_GEOFENCE_EXITED
continue;
}
auto r = mGnssGeofencingCbIface->gnssGeofenceTransitionCb(
geofenceBreachNotification.ids[i], gnssLocation, transition,
static_cast<V1_0::GnssUtcTime>(geofenceBreachNotification.timestamp));
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssGeofenceTransitionCb description=%s",
__func__, r.description().c_str());
}
}
}
}
void GeofenceAPIClient::onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification)
{
LOC_LOGD("%s]: (%d)", __FUNCTION__, geofenceStatusNotification.available);
if (mGnssGeofencingCbIface != nullptr) {
IGnssGeofenceCallback::GeofenceAvailability status =
IGnssGeofenceCallback::GeofenceAvailability::UNAVAILABLE;
if (geofenceStatusNotification.available == GEOFENCE_STATUS_AVAILABILE_YES) {
status = IGnssGeofenceCallback::GeofenceAvailability::AVAILABLE;
}
GnssLocation gnssLocation;
memset(&gnssLocation, 0, sizeof(GnssLocation));
auto r = mGnssGeofencingCbIface->gnssGeofenceStatusCb(status, gnssLocation);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssGeofenceStatusCb description=%s",
__func__, r.description().c_str());
}
}
}
void GeofenceAPIClient::onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
{
LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
if (mGnssGeofencingCbIface != nullptr) {
for (size_t i = 0; i < count; i++) {
IGnssGeofenceCallback::GeofenceStatus status =
IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
if (errors[i] == LOCATION_ERROR_SUCCESS)
status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
else if (errors[i] == LOCATION_ERROR_ID_EXISTS)
status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_EXISTS;
auto r = mGnssGeofencingCbIface->gnssGeofenceAddCb(ids[i], status);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssGeofenceAddCb description=%s",
__func__, r.description().c_str());
}
}
}
}
void GeofenceAPIClient::onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
{
LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
if (mGnssGeofencingCbIface != nullptr) {
for (size_t i = 0; i < count; i++) {
IGnssGeofenceCallback::GeofenceStatus status =
IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
if (errors[i] == LOCATION_ERROR_SUCCESS)
status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN;
auto r = mGnssGeofencingCbIface->gnssGeofenceRemoveCb(ids[i], status);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssGeofenceRemoveCb description=%s",
__func__, r.description().c_str());
}
}
}
}
void GeofenceAPIClient::onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
{
LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
if (mGnssGeofencingCbIface != nullptr) {
for (size_t i = 0; i < count; i++) {
IGnssGeofenceCallback::GeofenceStatus status =
IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
if (errors[i] == LOCATION_ERROR_SUCCESS)
status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN;
auto r = mGnssGeofencingCbIface->gnssGeofencePauseCb(ids[i], status);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssGeofencePauseCb description=%s",
__func__, r.description().c_str());
}
}
}
}
void GeofenceAPIClient::onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
{
LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
if (mGnssGeofencingCbIface != nullptr) {
for (size_t i = 0; i < count; i++) {
IGnssGeofenceCallback::GeofenceStatus status =
IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
if (errors[i] == LOCATION_ERROR_SUCCESS)
status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN;
auto r = mGnssGeofencingCbIface->gnssGeofenceResumeCb(ids[i], status);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssGeofenceResumeCb description=%s",
__func__, r.description().c_str());
}
}
}
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,76 @@
/* Copyright (c) 2017-2019, 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 GEOFENCE_API_CLINET_H
#define GEOFENCE_API_CLINET_H
#include <android/hardware/gnss/1.0/IGnssGeofenceCallback.h>
#include <LocationAPIClientBase.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::sp;
class GeofenceAPIClient : public LocationAPIClientBase
{
public:
GeofenceAPIClient(const sp<V1_0::IGnssGeofenceCallback>& callback);
virtual ~GeofenceAPIClient() = default;
void geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
double radius_meters, int32_t last_transition, int32_t monitor_transitions,
uint32_t notification_responsiveness_ms, uint32_t unknown_timer_ms);
void geofencePause(uint32_t geofence_id);
void geofenceResume(uint32_t geofence_id, int32_t monitor_transitions);
void geofenceRemove(uint32_t geofence_id);
void geofenceRemoveAll();
// callbacks
void onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification) final;
void onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification) final;
void onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
void onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
void onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
void onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
private:
sp<V1_0::IGnssGeofenceCallback> mGnssGeofencingCbIface;
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // GEOFENCE_API_CLINET_H

View File

@@ -0,0 +1,728 @@
/* Copyright (c) 2017-2019, 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_NDEBUG 0
#define LOG_TAG "LocSvc_GnssAPIClient"
#define SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC (590 * 60 * 60 * 1000) // 590 hours
#include <log_util.h>
#include <loc_cfg.h>
#include "LocationUtil.h"
#include "GnssAPIClient.h"
#include <LocContext.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::gnss::V2_0::IGnss;
using ::android::hardware::gnss::V2_0::IGnssCallback;
using ::android::hardware::gnss::V1_0::IGnssNiCallback;
using ::android::hardware::gnss::V2_0::GnssLocation;
static void convertGnssSvStatus(GnssSvNotification& in, V1_0::IGnssCallback::GnssSvStatus& out);
static void convertGnssSvStatus(GnssSvNotification& in,
hidl_vec<V2_0::IGnssCallback::GnssSvInfo>& out);
GnssAPIClient::GnssAPIClient(const sp<V1_0::IGnssCallback>& gpsCb,
const sp<V1_0::IGnssNiCallback>& niCb) :
LocationAPIClientBase(),
mGnssCbIface(nullptr),
mGnssNiCbIface(nullptr),
mControlClient(new LocationAPIControlClient()),
mLocationCapabilitiesMask(0),
mLocationCapabilitiesCached(false),
mTracking(false),
mGnssCbIface_2_0(nullptr)
{
LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb);
initLocationOptions();
gnssUpdateCallbacks(gpsCb, niCb);
}
GnssAPIClient::GnssAPIClient(const sp<V2_0::IGnssCallback>& gpsCb) :
LocationAPIClientBase(),
mGnssCbIface(nullptr),
mGnssNiCbIface(nullptr),
mControlClient(new LocationAPIControlClient()),
mLocationCapabilitiesMask(0),
mLocationCapabilitiesCached(false),
mTracking(false),
mGnssCbIface_2_0(nullptr)
{
LOC_LOGD("%s]: (%p)", __FUNCTION__, &gpsCb);
initLocationOptions();
gnssUpdateCallbacks_2_0(gpsCb);
}
GnssAPIClient::~GnssAPIClient()
{
LOC_LOGD("%s]: ()", __FUNCTION__);
if (mControlClient) {
delete mControlClient;
mControlClient = nullptr;
}
}
void GnssAPIClient::initLocationOptions()
{
// set default LocationOptions.
memset(&mTrackingOptions, 0, sizeof(TrackingOptions));
mTrackingOptions.size = sizeof(TrackingOptions);
mTrackingOptions.minInterval = 1000;
mTrackingOptions.minDistance = 0;
mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE;
}
void GnssAPIClient::setCallbacks()
{
LocationCallbacks locationCallbacks;
memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
locationCallbacks.size = sizeof(LocationCallbacks);
locationCallbacks.trackingCb = nullptr;
locationCallbacks.trackingCb = [this](Location location) {
onTrackingCb(location);
};
locationCallbacks.batchingCb = nullptr;
locationCallbacks.geofenceBreachCb = nullptr;
locationCallbacks.geofenceStatusCb = nullptr;
locationCallbacks.gnssLocationInfoCb = nullptr;
locationCallbacks.gnssNiCb = nullptr;
if (mGnssNiCbIface != nullptr) {
loc_core::ContextBase* context =
loc_core::LocContext::getLocContext(
NULL, NULL,
loc_core::LocContext::mLocationHalName, false);
if (!context->hasAgpsExtendedCapabilities()) {
LOC_LOGD("Registering NI CB");
locationCallbacks.gnssNiCb = [this](uint32_t id, GnssNiNotification gnssNiNotify) {
onGnssNiCb(id, gnssNiNotify);
};
}
}
locationCallbacks.gnssSvCb = nullptr;
locationCallbacks.gnssSvCb = [this](GnssSvNotification gnssSvNotification) {
onGnssSvCb(gnssSvNotification);
};
locationCallbacks.gnssNmeaCb = nullptr;
locationCallbacks.gnssNmeaCb = [this](GnssNmeaNotification gnssNmeaNotification) {
onGnssNmeaCb(gnssNmeaNotification);
};
locationCallbacks.gnssMeasurementsCb = nullptr;
locAPISetCallbacks(locationCallbacks);
}
// for GpsInterface
void GnssAPIClient::gnssUpdateCallbacks(const sp<V1_0::IGnssCallback>& gpsCb,
const sp<IGnssNiCallback>& niCb)
{
LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb);
mMutex.lock();
mGnssCbIface = gpsCb;
mGnssNiCbIface = niCb;
mMutex.unlock();
if (mGnssCbIface != nullptr || mGnssNiCbIface != nullptr) {
setCallbacks();
}
}
void GnssAPIClient::gnssUpdateCallbacks_2_0(const sp<V2_0::IGnssCallback>& gpsCb)
{
LOC_LOGD("%s]: (%p)", __FUNCTION__, &gpsCb);
mMutex.lock();
mGnssCbIface_2_0 = gpsCb;
mMutex.unlock();
if (mGnssCbIface_2_0 != nullptr) {
setCallbacks();
}
}
bool GnssAPIClient::gnssStart()
{
LOC_LOGD("%s]: ()", __FUNCTION__);
mMutex.lock();
mTracking = true;
mMutex.unlock();
bool retVal = true;
locAPIStartTracking(mTrackingOptions);
return retVal;
}
bool GnssAPIClient::gnssStop()
{
LOC_LOGD("%s]: ()", __FUNCTION__);
mMutex.lock();
mTracking = false;
mMutex.unlock();
bool retVal = true;
locAPIStopTracking();
return retVal;
}
bool GnssAPIClient::gnssSetPositionMode(IGnss::GnssPositionMode mode,
IGnss::GnssPositionRecurrence recurrence, uint32_t minIntervalMs,
uint32_t preferredAccuracyMeters, uint32_t preferredTimeMs,
GnssPowerMode powerMode, uint32_t timeBetweenMeasurement)
{
LOC_LOGD("%s]: (%d %d %d %d %d %d %d)", __FUNCTION__,
(int)mode, recurrence, minIntervalMs, preferredAccuracyMeters,
preferredTimeMs, (int)powerMode, timeBetweenMeasurement);
bool retVal = true;
memset(&mTrackingOptions, 0, sizeof(TrackingOptions));
mTrackingOptions.size = sizeof(TrackingOptions);
mTrackingOptions.minInterval = minIntervalMs;
if (IGnss::GnssPositionMode::MS_ASSISTED == mode ||
IGnss::GnssPositionRecurrence::RECURRENCE_SINGLE == recurrence) {
// We set a very large interval to simulate SINGLE mode. Once we report a fix,
// the caller should take the responsibility to stop the session.
// For MSA, we always treat it as SINGLE mode.
mTrackingOptions.minInterval = SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC;
}
mTrackingOptions.minDistance = preferredAccuracyMeters;
if (mode == IGnss::GnssPositionMode::STANDALONE)
mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE;
else if (mode == IGnss::GnssPositionMode::MS_BASED)
mTrackingOptions.mode = GNSS_SUPL_MODE_MSB;
else if (mode == IGnss::GnssPositionMode::MS_ASSISTED)
mTrackingOptions.mode = GNSS_SUPL_MODE_MSA;
else {
LOC_LOGD("%s]: invalid GnssPositionMode: %d", __FUNCTION__, (int)mode);
retVal = false;
}
if (GNSS_POWER_MODE_INVALID != powerMode) {
mTrackingOptions.powerMode = powerMode;
mTrackingOptions.tbm = timeBetweenMeasurement;
}
locAPIUpdateTrackingOptions(mTrackingOptions);
return retVal;
}
// for GpsNiInterface
void GnssAPIClient::gnssNiRespond(int32_t notifId,
IGnssNiCallback::GnssUserResponseType userResponse)
{
LOC_LOGD("%s]: (%d %d)", __FUNCTION__, notifId, static_cast<int>(userResponse));
GnssNiResponse data;
switch (userResponse) {
case IGnssNiCallback::GnssUserResponseType::RESPONSE_ACCEPT:
data = GNSS_NI_RESPONSE_ACCEPT;
break;
case IGnssNiCallback::GnssUserResponseType::RESPONSE_DENY:
data = GNSS_NI_RESPONSE_DENY;
break;
case IGnssNiCallback::GnssUserResponseType::RESPONSE_NORESP:
data = GNSS_NI_RESPONSE_NO_RESPONSE;
break;
default:
data = GNSS_NI_RESPONSE_IGNORE;
break;
}
locAPIGnssNiResponse(notifId, data);
}
// these apis using LocationAPIControlClient
void GnssAPIClient::gnssDeleteAidingData(IGnss::GnssAidingData aidingDataFlags)
{
LOC_LOGD("%s]: (%02hx)", __FUNCTION__, aidingDataFlags);
if (mControlClient == nullptr) {
return;
}
GnssAidingData data;
memset(&data, 0, sizeof (GnssAidingData));
data.sv.svTypeMask = GNSS_AIDING_DATA_SV_TYPE_GPS_BIT |
GNSS_AIDING_DATA_SV_TYPE_GLONASS_BIT |
GNSS_AIDING_DATA_SV_TYPE_QZSS_BIT |
GNSS_AIDING_DATA_SV_TYPE_BEIDOU_BIT |
GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT |
GNSS_AIDING_DATA_SV_TYPE_NAVIC_BIT;
data.posEngineMask = STANDARD_POSITIONING_ENGINE;
if (aidingDataFlags == IGnss::GnssAidingData::DELETE_ALL)
data.deleteAll = true;
else {
if (aidingDataFlags & IGnss::GnssAidingData::DELETE_EPHEMERIS)
data.sv.svMask |= GNSS_AIDING_DATA_SV_EPHEMERIS_BIT;
if (aidingDataFlags & IGnss::GnssAidingData::DELETE_ALMANAC)
data.sv.svMask |= GNSS_AIDING_DATA_SV_ALMANAC_BIT;
if (aidingDataFlags & IGnss::GnssAidingData::DELETE_POSITION)
data.common.mask |= GNSS_AIDING_DATA_COMMON_POSITION_BIT;
if (aidingDataFlags & IGnss::GnssAidingData::DELETE_TIME)
data.common.mask |= GNSS_AIDING_DATA_COMMON_TIME_BIT;
if (aidingDataFlags & IGnss::GnssAidingData::DELETE_IONO)
data.sv.svMask |= GNSS_AIDING_DATA_SV_IONOSPHERE_BIT;
if (aidingDataFlags & IGnss::GnssAidingData::DELETE_UTC)
data.common.mask |= GNSS_AIDING_DATA_COMMON_UTC_BIT;
if (aidingDataFlags & IGnss::GnssAidingData::DELETE_HEALTH)
data.sv.svMask |= GNSS_AIDING_DATA_SV_HEALTH_BIT;
if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SVDIR)
data.sv.svMask |= GNSS_AIDING_DATA_SV_DIRECTION_BIT;
if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SVSTEER)
data.sv.svMask |= GNSS_AIDING_DATA_SV_STEER_BIT;
if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SADATA)
data.sv.svMask |= GNSS_AIDING_DATA_SV_SA_DATA_BIT;
if (aidingDataFlags & IGnss::GnssAidingData::DELETE_RTI)
data.common.mask |= GNSS_AIDING_DATA_COMMON_RTI_BIT;
if (aidingDataFlags & IGnss::GnssAidingData::DELETE_CELLDB_INFO)
data.common.mask |= GNSS_AIDING_DATA_COMMON_CELLDB_BIT;
}
mControlClient->locAPIGnssDeleteAidingData(data);
}
void GnssAPIClient::gnssEnable(LocationTechnologyType techType)
{
LOC_LOGD("%s]: (%0d)", __FUNCTION__, techType);
if (mControlClient == nullptr) {
return;
}
mControlClient->locAPIEnable(techType);
}
void GnssAPIClient::gnssDisable()
{
LOC_LOGD("%s]: ()", __FUNCTION__);
if (mControlClient == nullptr) {
return;
}
mControlClient->locAPIDisable();
}
void GnssAPIClient::gnssConfigurationUpdate(const GnssConfig& gnssConfig)
{
LOC_LOGD("%s]: (%02x)", __FUNCTION__, gnssConfig.flags);
if (mControlClient == nullptr) {
return;
}
mControlClient->locAPIGnssUpdateConfig(gnssConfig);
}
void GnssAPIClient::requestCapabilities() {
// only send capablities if it's already cached, otherwise the first time LocationAPI
// is initialized, capabilities will be sent by LocationAPI
if (mLocationCapabilitiesCached) {
onCapabilitiesCb(mLocationCapabilitiesMask);
}
}
// callbacks
void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
{
LOC_LOGD("%s]: (%02x)", __FUNCTION__, capabilitiesMask);
mLocationCapabilitiesMask = capabilitiesMask;
mLocationCapabilitiesCached = true;
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
auto gnssCbIface_2_0(mGnssCbIface_2_0);
mMutex.unlock();
if (gnssCbIface_2_0 != nullptr || gnssCbIface != nullptr) {
uint32_t data = 0;
if ((capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT) ||
(capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT) ||
(capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT) ||
(capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT))
data |= IGnssCallback::Capabilities::SCHEDULING;
if (capabilitiesMask & LOCATION_CAPABILITIES_GEOFENCE_BIT)
data |= V1_0::IGnssCallback::Capabilities::GEOFENCING;
if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT)
data |= V1_0::IGnssCallback::Capabilities::MEASUREMENTS;
if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSB_BIT)
data |= IGnssCallback::Capabilities::MSB;
if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSA_BIT)
data |= IGnssCallback::Capabilities::MSA;
if (capabilitiesMask & LOCATION_CAPABILITIES_AGPM_BIT)
data |= IGnssCallback::Capabilities::LOW_POWER_MODE;
if (capabilitiesMask & LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT)
data |= IGnssCallback::Capabilities::SATELLITE_BLACKLIST;
IGnssCallback::GnssSystemInfo gnssInfo;
if (capabilitiesMask & LOCATION_CAPABILITIES_PRIVACY_BIT) {
gnssInfo.yearOfHw = 2019;
} else if (capabilitiesMask & LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT ||
capabilitiesMask & LOCATION_CAPABILITIES_AGPM_BIT) {
gnssInfo.yearOfHw = 2018;
} else if (capabilitiesMask & LOCATION_CAPABILITIES_DEBUG_NMEA_BIT) {
gnssInfo.yearOfHw = 2017;
} else if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT) {
gnssInfo.yearOfHw = 2016;
} else {
gnssInfo.yearOfHw = 2015;
}
LOC_LOGV("%s:%d] set_system_info_cb (%d)", __FUNCTION__, __LINE__, gnssInfo.yearOfHw);
if (gnssCbIface_2_0 != nullptr) {
auto r = gnssCbIface_2_0->gnssSetCapabilitiesCb_2_0(data);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssSetCapabilitiesCb_2_0 description=%s",
__func__, r.description().c_str());
}
r = gnssCbIface_2_0->gnssSetSystemInfoCb(gnssInfo);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssSetSystemInfoCb description=%s",
__func__, r.description().c_str());
}
} else if (gnssCbIface != nullptr) {
auto r = gnssCbIface->gnssSetCapabilitesCb(data);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssSetCapabilitesCb description=%s",
__func__, r.description().c_str());
}
r = gnssCbIface->gnssSetSystemInfoCb(gnssInfo);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssSetSystemInfoCb description=%s",
__func__, r.description().c_str());
}
}
}
}
void GnssAPIClient::onTrackingCb(Location location)
{
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
auto gnssCbIface_2_0(mGnssCbIface_2_0);
bool isTracking = mTracking;
mMutex.unlock();
LOC_LOGD("%s]: (flags: %02x isTracking: %d)", __FUNCTION__, location.flags, isTracking);
if (!isTracking) {
return;
}
if (gnssCbIface_2_0 != nullptr) {
V2_0::GnssLocation gnssLocation;
convertGnssLocation(location, gnssLocation);
auto r = gnssCbIface_2_0->gnssLocationCb_2_0(gnssLocation);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssLocationCb_2_0 description=%s",
__func__, r.description().c_str());
}
} else if (gnssCbIface != nullptr) {
V1_0::GnssLocation gnssLocation;
convertGnssLocation(location, gnssLocation);
auto r = gnssCbIface->gnssLocationCb(gnssLocation);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssLocationCb description=%s",
__func__, r.description().c_str());
}
} else {
LOC_LOGW("%s] No GNSS Interface ready for gnssLocationCb ", __FUNCTION__);
}
}
void GnssAPIClient::onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification)
{
LOC_LOGD("%s]: (id: %d)", __FUNCTION__, id);
mMutex.lock();
auto gnssNiCbIface(mGnssNiCbIface);
mMutex.unlock();
if (gnssNiCbIface == nullptr) {
LOC_LOGE("%s]: mGnssNiCbIface is nullptr", __FUNCTION__);
return;
}
IGnssNiCallback::GnssNiNotification notificationGnss = {};
notificationGnss.notificationId = id;
if (gnssNiNotification.type == GNSS_NI_TYPE_VOICE)
notificationGnss.niType = IGnssNiCallback::GnssNiType::VOICE;
else if (gnssNiNotification.type == GNSS_NI_TYPE_SUPL)
notificationGnss.niType = IGnssNiCallback::GnssNiType::UMTS_SUPL;
else if (gnssNiNotification.type == GNSS_NI_TYPE_CONTROL_PLANE)
notificationGnss.niType = IGnssNiCallback::GnssNiType::UMTS_CTRL_PLANE;
else if (gnssNiNotification.type == GNSS_NI_TYPE_EMERGENCY_SUPL)
notificationGnss.niType = IGnssNiCallback::GnssNiType::EMERGENCY_SUPL;
if (gnssNiNotification.options & GNSS_NI_OPTIONS_NOTIFICATION_BIT)
notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::NEED_NOTIFY;
if (gnssNiNotification.options & GNSS_NI_OPTIONS_VERIFICATION_BIT)
notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::NEED_VERIFY;
if (gnssNiNotification.options & GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT)
notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::PRIVACY_OVERRIDE;
notificationGnss.timeoutSec = gnssNiNotification.timeout;
if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_ACCEPT)
notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_ACCEPT;
else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_DENY)
notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_DENY;
else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_NO_RESPONSE ||
gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_IGNORE)
notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_NORESP;
notificationGnss.requestorId = gnssNiNotification.requestor;
notificationGnss.notificationMessage = gnssNiNotification.message;
if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_NONE)
notificationGnss.requestorIdEncoding =
IGnssNiCallback::GnssNiEncodingType::ENC_NONE;
else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT)
notificationGnss.requestorIdEncoding =
IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_GSM_DEFAULT;
else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UTF8)
notificationGnss.requestorIdEncoding =
IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UTF8;
else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UCS2)
notificationGnss.requestorIdEncoding =
IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UCS2;
if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_NONE)
notificationGnss.notificationIdEncoding =
IGnssNiCallback::GnssNiEncodingType::ENC_NONE;
else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT)
notificationGnss.notificationIdEncoding =
IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_GSM_DEFAULT;
else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UTF8)
notificationGnss.notificationIdEncoding =
IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UTF8;
else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UCS2)
notificationGnss.notificationIdEncoding =
IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UCS2;
gnssNiCbIface->niNotifyCb(notificationGnss);
}
void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification)
{
LOC_LOGD("%s]: (count: %u)", __FUNCTION__, gnssSvNotification.count);
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
auto gnssCbIface_2_0(mGnssCbIface_2_0);
mMutex.unlock();
if (gnssCbIface_2_0 != nullptr) {
hidl_vec<V2_0::IGnssCallback::GnssSvInfo> svInfoList;
convertGnssSvStatus(gnssSvNotification, svInfoList);
auto r = gnssCbIface_2_0->gnssSvStatusCb_2_0(svInfoList);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssSvStatusCb_2_0 description=%s",
__func__, r.description().c_str());
}
} else if (gnssCbIface != nullptr) {
V1_0::IGnssCallback::GnssSvStatus svStatus;
convertGnssSvStatus(gnssSvNotification, svStatus);
auto r = gnssCbIface->gnssSvStatusCb(svStatus);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssSvStatusCb description=%s",
__func__, r.description().c_str());
}
}
}
void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
{
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
auto gnssCbIface_2_0(mGnssCbIface_2_0);
mMutex.unlock();
if (gnssCbIface != nullptr || gnssCbIface_2_0 != nullptr) {
const std::string s(gnssNmeaNotification.nmea);
std::stringstream ss(s);
std::string each;
while(std::getline(ss, each, '\n')) {
each += '\n';
android::hardware::hidl_string nmeaString;
nmeaString.setToExternal(each.c_str(), each.length());
if (gnssCbIface_2_0 != nullptr) {
auto r = gnssCbIface_2_0->gnssNmeaCb(
static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssCbIface_2_0 nmea=%s length=%u description=%s",
__func__, gnssNmeaNotification.nmea, gnssNmeaNotification.length,
r.description().c_str());
}
} else if (gnssCbIface != nullptr) {
auto r = gnssCbIface->gnssNmeaCb(
static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssNmeaCb nmea=%s length=%u description=%s",
__func__, gnssNmeaNotification.nmea, gnssNmeaNotification.length,
r.description().c_str());
}
}
}
}
}
void GnssAPIClient::onStartTrackingCb(LocationError error)
{
LOC_LOGD("%s]: (%d)", __FUNCTION__, error);
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
auto gnssCbIface_2_0(mGnssCbIface_2_0);
mMutex.unlock();
if (error == LOCATION_ERROR_SUCCESS) {
if (gnssCbIface_2_0 != nullptr) {
auto r = gnssCbIface_2_0->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_ON);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb 2.0 ENGINE_ON description=%s",
__func__, r.description().c_str());
}
r = gnssCbIface_2_0->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_BEGIN);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb 2.0 SESSION_BEGIN description=%s",
__func__, r.description().c_str());
}
} else if (gnssCbIface != nullptr) {
auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_ON);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb ENGINE_ON description=%s",
__func__, r.description().c_str());
}
r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_BEGIN);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb SESSION_BEGIN description=%s",
__func__, r.description().c_str());
}
}
}
}
void GnssAPIClient::onStopTrackingCb(LocationError error)
{
LOC_LOGD("%s]: (%d)", __FUNCTION__, error);
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
auto gnssCbIface_2_0(mGnssCbIface_2_0);
mMutex.unlock();
if (error == LOCATION_ERROR_SUCCESS) {
if (gnssCbIface_2_0 != nullptr) {
auto r = gnssCbIface_2_0->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_END);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb 2.0 SESSION_END description=%s",
__func__, r.description().c_str());
}
r = gnssCbIface_2_0->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_OFF);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb 2.0 ENGINE_OFF description=%s",
__func__, r.description().c_str());
}
} else if (gnssCbIface != nullptr) {
auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_END);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb SESSION_END description=%s",
__func__, r.description().c_str());
}
r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_OFF);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssStatusCb ENGINE_OFF description=%s",
__func__, r.description().c_str());
}
}
}
}
static void convertGnssSvStatus(GnssSvNotification& in, V1_0::IGnssCallback::GnssSvStatus& out)
{
memset(&out, 0, sizeof(IGnssCallback::GnssSvStatus));
out.numSvs = in.count;
if (out.numSvs > static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT)) {
LOC_LOGW("%s]: Too many satellites %u. Clamps to %d.",
__FUNCTION__, out.numSvs, V1_0::GnssMax::SVS_COUNT);
out.numSvs = static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT);
}
for (size_t i = 0; i < out.numSvs; i++) {
out.gnssSvList[i].svid = in.gnssSvs[i].svId;
convertGnssConstellationType(in.gnssSvs[i].type, out.gnssSvList[i].constellation);
out.gnssSvList[i].cN0Dbhz = in.gnssSvs[i].cN0Dbhz;
out.gnssSvList[i].elevationDegrees = in.gnssSvs[i].elevation;
out.gnssSvList[i].azimuthDegrees = in.gnssSvs[i].azimuth;
out.gnssSvList[i].carrierFrequencyHz = in.gnssSvs[i].carrierFrequencyHz;
out.gnssSvList[i].svFlag = static_cast<uint8_t>(IGnssCallback::GnssSvFlags::NONE);
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_EPHEMER_BIT)
out.gnssSvList[i].svFlag |= IGnssCallback::GnssSvFlags::HAS_EPHEMERIS_DATA;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_ALMANAC_BIT)
out.gnssSvList[i].svFlag |= IGnssCallback::GnssSvFlags::HAS_ALMANAC_DATA;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)
out.gnssSvList[i].svFlag |= IGnssCallback::GnssSvFlags::USED_IN_FIX;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_CARRIER_FREQUENCY_BIT)
out.gnssSvList[i].svFlag |= IGnssCallback::GnssSvFlags::HAS_CARRIER_FREQUENCY;
}
}
static void convertGnssSvStatus(GnssSvNotification& in,
hidl_vec<V2_0::IGnssCallback::GnssSvInfo>& out)
{
out.resize(in.count);
for (size_t i = 0; i < in.count; i++) {
out[i].v1_0.svid = in.gnssSvs[i].svId;
out[i].v1_0.cN0Dbhz = in.gnssSvs[i].cN0Dbhz;
out[i].v1_0.elevationDegrees = in.gnssSvs[i].elevation;
out[i].v1_0.azimuthDegrees = in.gnssSvs[i].azimuth;
out[i].v1_0.carrierFrequencyHz = in.gnssSvs[i].carrierFrequencyHz;
out[i].v1_0.svFlag = static_cast<uint8_t>(IGnssCallback::GnssSvFlags::NONE);
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_EPHEMER_BIT)
out[i].v1_0.svFlag |= IGnssCallback::GnssSvFlags::HAS_EPHEMERIS_DATA;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_ALMANAC_BIT)
out[i].v1_0.svFlag |= IGnssCallback::GnssSvFlags::HAS_ALMANAC_DATA;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)
out[i].v1_0.svFlag |= IGnssCallback::GnssSvFlags::USED_IN_FIX;
if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_CARRIER_FREQUENCY_BIT)
out[i].v1_0.svFlag |= IGnssCallback::GnssSvFlags::HAS_CARRIER_FREQUENCY;
convertGnssConstellationType(in.gnssSvs[i].type, out[i].constellation);
}
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,114 @@
/* Copyright (c) 2017-2019, 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 GNSS_API_CLINET_H
#define GNSS_API_CLINET_H
#include <mutex>
#include <android/hardware/gnss/2.0/IGnss.h>
#include <android/hardware/gnss/2.0/IGnssCallback.h>
#include <LocationAPIClientBase.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::sp;
class GnssAPIClient : public LocationAPIClientBase
{
public:
GnssAPIClient(const sp<V1_0::IGnssCallback>& gpsCb,
const sp<V1_0::IGnssNiCallback>& niCb);
GnssAPIClient(const sp<V2_0::IGnssCallback>& gpsCb);
virtual ~GnssAPIClient();
GnssAPIClient(const GnssAPIClient&) = delete;
GnssAPIClient& operator=(const GnssAPIClient&) = delete;
// for GpsInterface
void gnssUpdateCallbacks(const sp<V1_0::IGnssCallback>& gpsCb,
const sp<V1_0::IGnssNiCallback>& niCb);
void gnssUpdateCallbacks_2_0(const sp<V2_0::IGnssCallback>& gpsCb);
bool gnssStart();
bool gnssStop();
bool gnssSetPositionMode(V1_0::IGnss::GnssPositionMode mode,
V1_0::IGnss::GnssPositionRecurrence recurrence,
uint32_t minIntervalMs,
uint32_t preferredAccuracyMeters,
uint32_t preferredTimeMs,
GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID,
uint32_t timeBetweenMeasurement = 0);
// for GpsNiInterface
void gnssNiRespond(int32_t notifId, V1_0::IGnssNiCallback::GnssUserResponseType userResponse);
// these apis using LocationAPIControlClient
void gnssDeleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags);
void gnssEnable(LocationTechnologyType techType);
void gnssDisable();
void gnssConfigurationUpdate(const GnssConfig& gnssConfig);
inline LocationCapabilitiesMask gnssGetCapabilities() const {
return mLocationCapabilitiesMask;
}
void requestCapabilities();
// callbacks we are interested in
void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final;
void onTrackingCb(Location location) final;
void onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification) final;
void onGnssSvCb(GnssSvNotification gnssSvNotification) final;
void onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification) final;
void onStartTrackingCb(LocationError error) final;
void onStopTrackingCb(LocationError error) final;
private:
void setCallbacks();
void initLocationOptions();
sp<V1_0::IGnssCallback> mGnssCbIface;
sp<V1_0::IGnssNiCallback> mGnssNiCbIface;
std::mutex mMutex;
LocationAPIControlClient* mControlClient;
LocationCapabilitiesMask mLocationCapabilitiesMask;
bool mLocationCapabilitiesCached;
TrackingOptions mTrackingOptions;
bool mTracking;
sp<V2_0::IGnssCallback> mGnssCbIface_2_0;
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // GNSS_API_CLINET_H

View File

@@ -0,0 +1,311 @@
/* Copyright (c) 2017-2019, 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 <LocationUtil.h>
#include <log_util.h>
#include <inttypes.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::gnss::V2_0::GnssLocation;
using ::android::hardware::gnss::V2_0::GnssConstellationType;
using ::android::hardware::gnss::V1_0::GnssLocationFlags;
void convertGnssLocation(Location& in, V1_0::GnssLocation& out)
{
memset(&out, 0, sizeof(V1_0::GnssLocation));
if (in.flags & LOCATION_HAS_LAT_LONG_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_LAT_LONG;
out.latitudeDegrees = in.latitude;
out.longitudeDegrees = in.longitude;
}
if (in.flags & LOCATION_HAS_ALTITUDE_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_ALTITUDE;
out.altitudeMeters = in.altitude;
}
if (in.flags & LOCATION_HAS_SPEED_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED;
out.speedMetersPerSec = in.speed;
}
if (in.flags & LOCATION_HAS_BEARING_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING;
out.bearingDegrees = in.bearing;
}
if (in.flags & LOCATION_HAS_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_HORIZONTAL_ACCURACY;
out.horizontalAccuracyMeters = in.accuracy;
}
if (in.flags & LOCATION_HAS_VERTICAL_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_VERTICAL_ACCURACY;
out.verticalAccuracyMeters = in.verticalAccuracy;
}
if (in.flags & LOCATION_HAS_SPEED_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED_ACCURACY;
out.speedAccuracyMetersPerSecond = in.speedAccuracy;
}
if (in.flags & LOCATION_HAS_BEARING_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING_ACCURACY;
out.bearingAccuracyDegrees = in.bearingAccuracy;
}
out.timestamp = static_cast<V1_0::GnssUtcTime>(in.timestamp);
}
void convertGnssLocation(Location& in, V2_0::GnssLocation& out)
{
memset(&out, 0, sizeof(V2_0::GnssLocation));
convertGnssLocation(in, out.v1_0);
struct timespec sinceBootTime;
struct timespec currentTime;
struct timespec sinceBootTimeTest;
int64_t sinceBootTimeNanos = 0;
bool clockGetTimeSuccess = false;
const uint32_t MAX_TIME_DELTA_VALUE_NANOS = 10000;
const uint32_t MAX_GET_TIME_COUNT = 20;
/* Attempt to get CLOCK_REALTIME and CLOCK_BOOTIME in succession without an interruption
or context switch (for up to MAX_GET_TIME_COUNT times) to avoid errors in the calculation */
for (uint32_t i=0; i < MAX_GET_TIME_COUNT; i++) {
if (clock_gettime(CLOCK_BOOTTIME, &sinceBootTime) != 0) {
break;
};
if (clock_gettime(CLOCK_REALTIME, &currentTime) != 0) {
break;
}
if (clock_gettime(CLOCK_BOOTTIME, &sinceBootTimeTest) != 0) {
break;
};
sinceBootTimeNanos = sinceBootTime.tv_sec*1000000000 + sinceBootTime.tv_nsec;
int64_t sinceBootTimeTestNanos =
sinceBootTimeTest.tv_sec*1000000000 + sinceBootTimeTest.tv_nsec;
int64_t sinceBootTimeDeltaNanos = sinceBootTimeTestNanos - sinceBootTimeNanos;
/* sinceBootTime and sinceBootTimeTest should have a close value if there was no
interruption or context switch between clock_gettime for CLOCK_BOOTIME and
clock_gettime for CLOCK_REALTIME */
if (sinceBootTimeDeltaNanos < MAX_TIME_DELTA_VALUE_NANOS) {
clockGetTimeSuccess = true;
break;
} else {
LOC_LOGD("%s]: Delta:%" PRIi64 "ns time too large, retry number #%u...",
__FUNCTION__, sinceBootTimeDeltaNanos, i+1);
}
}
if (clockGetTimeSuccess) {
int64_t currentTimeNanos = currentTime.tv_sec*1000000000 + currentTime.tv_nsec;
int64_t locationTimeNanos = in.timestamp*1000000;
LOC_LOGD("%s]: sinceBootTimeNanos:%" PRIi64 " currentTimeNanos:%" PRIi64 ""
" locationTimeNanos:%" PRIi64 "",
__FUNCTION__, sinceBootTimeNanos, currentTimeNanos, locationTimeNanos);
if (currentTimeNanos >= locationTimeNanos) {
int64_t ageTimeNanos = currentTimeNanos - locationTimeNanos;
LOC_LOGD("%s]: ageTimeNanos:%" PRIi64 ")", __FUNCTION__, ageTimeNanos);
if (ageTimeNanos >= 0 && ageTimeNanos <= sinceBootTimeNanos) {
out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIMESTAMP_NS;
out.elapsedRealtime.timestampNs = sinceBootTimeNanos - ageTimeNanos;
out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS;
// time uncertainty is 1 ms since it is calculated from utc time that is in ms
out.elapsedRealtime.timeUncertaintyNs = 1000000;
LOC_LOGD("%s]: timestampNs:%" PRIi64 ")",
__FUNCTION__, out.elapsedRealtime.timestampNs);
}
}
} else {
LOC_LOGE("%s]: Failed to calculate elapsedRealtimeNanos timestamp after %u tries",
__FUNCTION__, MAX_GET_TIME_COUNT);
}
}
void convertGnssLocation(const V1_0::GnssLocation& in, Location& out)
{
memset(&out, 0, sizeof(out));
if (in.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG) {
out.flags |= LOCATION_HAS_LAT_LONG_BIT;
out.latitude = in.latitudeDegrees;
out.longitude = in.longitudeDegrees;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE) {
out.flags |= LOCATION_HAS_ALTITUDE_BIT;
out.altitude = in.altitudeMeters;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED) {
out.flags |= LOCATION_HAS_SPEED_BIT;
out.speed = in.speedMetersPerSec;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) {
out.flags |= LOCATION_HAS_BEARING_BIT;
out.bearing = in.bearingDegrees;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY) {
out.flags |= LOCATION_HAS_ACCURACY_BIT;
out.accuracy = in.horizontalAccuracyMeters;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) {
out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT;
out.verticalAccuracy = in.verticalAccuracyMeters;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) {
out.flags |= LOCATION_HAS_SPEED_ACCURACY_BIT;
out.speedAccuracy = in.speedAccuracyMetersPerSecond;
}
if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) {
out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT;
out.bearingAccuracy = in.bearingAccuracyDegrees;
}
out.timestamp = static_cast<uint64_t>(in.timestamp);
}
void convertGnssLocation(const V2_0::GnssLocation& in, Location& out)
{
memset(&out, 0, sizeof(out));
convertGnssLocation(in.v1_0, out);
}
void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out)
{
switch(in) {
case GNSS_SV_TYPE_GPS:
out = V1_0::GnssConstellationType::GPS;
break;
case GNSS_SV_TYPE_SBAS:
out = V1_0::GnssConstellationType::SBAS;
break;
case GNSS_SV_TYPE_GLONASS:
out = V1_0::GnssConstellationType::GLONASS;
break;
case GNSS_SV_TYPE_QZSS:
out = V1_0::GnssConstellationType::QZSS;
break;
case GNSS_SV_TYPE_BEIDOU:
out = V1_0::GnssConstellationType::BEIDOU;
break;
case GNSS_SV_TYPE_GALILEO:
out = V1_0::GnssConstellationType::GALILEO;
break;
case GNSS_SV_TYPE_UNKNOWN:
default:
out = V1_0::GnssConstellationType::UNKNOWN;
break;
}
}
void convertGnssConstellationType(GnssSvType& in, V2_0::GnssConstellationType& out)
{
switch(in) {
case GNSS_SV_TYPE_GPS:
out = V2_0::GnssConstellationType::GPS;
break;
case GNSS_SV_TYPE_SBAS:
out = V2_0::GnssConstellationType::SBAS;
break;
case GNSS_SV_TYPE_GLONASS:
out = V2_0::GnssConstellationType::GLONASS;
break;
case GNSS_SV_TYPE_QZSS:
out = V2_0::GnssConstellationType::QZSS;
break;
case GNSS_SV_TYPE_BEIDOU:
out = V2_0::GnssConstellationType::BEIDOU;
break;
case GNSS_SV_TYPE_GALILEO:
out = V2_0::GnssConstellationType::GALILEO;
break;
case GNSS_SV_TYPE_NAVIC:
out = V2_0::GnssConstellationType::IRNSS;
break;
case GNSS_SV_TYPE_UNKNOWN:
default:
out = V2_0::GnssConstellationType::UNKNOWN;
break;
}
}
void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out)
{
switch(in) {
case GNSS_EPH_TYPE_EPHEMERIS:
out = GnssDebug::SatelliteEphemerisType::EPHEMERIS;
break;
case GNSS_EPH_TYPE_ALMANAC:
out = GnssDebug::SatelliteEphemerisType::ALMANAC_ONLY;
break;
case GNSS_EPH_TYPE_UNKNOWN:
default:
out = GnssDebug::SatelliteEphemerisType::NOT_AVAILABLE;
break;
}
}
void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out)
{
switch(in) {
case GNSS_EPH_SOURCE_DEMODULATED:
out = GnssDebug::SatelliteEphemerisSource::DEMODULATED;
break;
case GNSS_EPH_SOURCE_SUPL_PROVIDED:
out = GnssDebug::SatelliteEphemerisSource::SUPL_PROVIDED;
break;
case GNSS_EPH_SOURCE_OTHER_SERVER_PROVIDED:
out = GnssDebug::SatelliteEphemerisSource::OTHER_SERVER_PROVIDED;
break;
case GNSS_EPH_SOURCE_LOCAL:
case GNSS_EPH_SOURCE_UNKNOWN:
default:
out = GnssDebug::SatelliteEphemerisSource::OTHER;
break;
}
}
void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out)
{
switch(in) {
case GNSS_EPH_HEALTH_GOOD:
out = GnssDebug::SatelliteEphemerisHealth::GOOD;
break;
case GNSS_EPH_HEALTH_BAD:
out = GnssDebug::SatelliteEphemerisHealth::BAD;
break;
case GNSS_EPH_HEALTH_UNKNOWN:
default:
out = GnssDebug::SatelliteEphemerisHealth::UNKNOWN;
break;
}
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,58 @@
/* Copyright (c) 2017-2019, 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 LOCATION_UTIL_H
#define LOCATION_UTIL_H
#include <android/hardware/gnss/2.0/types.h>
#include <LocationAPI.h>
#include <GnssDebug.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
void convertGnssLocation(Location& in, V1_0::GnssLocation& out);
void convertGnssLocation(Location& in, V2_0::GnssLocation& out);
void convertGnssLocation(const V1_0::GnssLocation& in, Location& out);
void convertGnssLocation(const V2_0::GnssLocation& in, Location& out);
void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out);
void convertGnssConstellationType(GnssSvType& in, V2_0::GnssConstellationType& out);
void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out);
void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out);
void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out);
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // LOCATION_UTIL_H

View File

@@ -0,0 +1,474 @@
/* Copyright (c) 2017-2019, 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_NDEBUG 0
#define LOG_TAG "LocSvc_MeasurementAPIClient"
#include <log_util.h>
#include <loc_cfg.h>
#include "LocationUtil.h"
#include "MeasurementAPIClient.h"
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::gnss::V1_0::IGnssMeasurement;
using ::android::hardware::gnss::V2_0::IGnssMeasurementCallback;
static void convertGnssData(GnssMeasurementsNotification& in,
V1_0::IGnssMeasurementCallback::GnssData& out);
static void convertGnssData_1_1(GnssMeasurementsNotification& in,
V1_1::IGnssMeasurementCallback::GnssData& out);
static void convertGnssData_2_0(GnssMeasurementsNotification& in,
V2_0::IGnssMeasurementCallback::GnssData& out);
static void convertGnssMeasurement(GnssMeasurementsData& in,
V1_0::IGnssMeasurementCallback::GnssMeasurement& out);
static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out);
static void convertGnssMeasurementsCodeType(GnssMeasurementsCodeType& in,
::android::hardware::hidl_string& out);
MeasurementAPIClient::MeasurementAPIClient() :
mGnssMeasurementCbIface(nullptr),
mGnssMeasurementCbIface_1_1(nullptr),
mGnssMeasurementCbIface_2_0(nullptr),
mTracking(false)
{
LOC_LOGD("%s]: ()", __FUNCTION__);
}
MeasurementAPIClient::~MeasurementAPIClient()
{
LOC_LOGD("%s]: ()", __FUNCTION__);
}
// for GpsInterface
Return<IGnssMeasurement::GnssMeasurementStatus>
MeasurementAPIClient::measurementSetCallback(const sp<V1_0::IGnssMeasurementCallback>& callback)
{
LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
mMutex.lock();
mGnssMeasurementCbIface = callback;
mMutex.unlock();
return startTracking();
}
Return<IGnssMeasurement::GnssMeasurementStatus>
MeasurementAPIClient::measurementSetCallback_1_1(
const sp<V1_1::IGnssMeasurementCallback>& callback,
GnssPowerMode powerMode, uint32_t timeBetweenMeasurement)
{
LOC_LOGD("%s]: (%p) (powermode: %d) (tbm: %d)",
__FUNCTION__, &callback, (int)powerMode, timeBetweenMeasurement);
mMutex.lock();
mGnssMeasurementCbIface_1_1 = callback;
mMutex.unlock();
return startTracking(powerMode, timeBetweenMeasurement);
}
Return<IGnssMeasurement::GnssMeasurementStatus>
MeasurementAPIClient::measurementSetCallback_2_0(
const sp<V2_0::IGnssMeasurementCallback>& callback,
GnssPowerMode powerMode, uint32_t timeBetweenMeasurement)
{
LOC_LOGD("%s]: (%p) (powermode: %d) (tbm: %d)",
__FUNCTION__, &callback, (int)powerMode, timeBetweenMeasurement);
mMutex.lock();
mGnssMeasurementCbIface_2_0 = callback;
mMutex.unlock();
return startTracking(powerMode, timeBetweenMeasurement);
}
Return<IGnssMeasurement::GnssMeasurementStatus>
MeasurementAPIClient::startTracking(
GnssPowerMode powerMode, uint32_t timeBetweenMeasurement)
{
LocationCallbacks locationCallbacks;
memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
locationCallbacks.size = sizeof(LocationCallbacks);
locationCallbacks.trackingCb = nullptr;
locationCallbacks.batchingCb = nullptr;
locationCallbacks.geofenceBreachCb = nullptr;
locationCallbacks.geofenceStatusCb = nullptr;
locationCallbacks.gnssLocationInfoCb = nullptr;
locationCallbacks.gnssNiCb = nullptr;
locationCallbacks.gnssSvCb = nullptr;
locationCallbacks.gnssNmeaCb = nullptr;
locationCallbacks.gnssMeasurementsCb = nullptr;
if (mGnssMeasurementCbIface_2_0 != nullptr ||
mGnssMeasurementCbIface_1_1 != nullptr ||
mGnssMeasurementCbIface != nullptr) {
locationCallbacks.gnssMeasurementsCb =
[this](GnssMeasurementsNotification gnssMeasurementsNotification) {
onGnssMeasurementsCb(gnssMeasurementsNotification);
};
}
locAPISetCallbacks(locationCallbacks);
TrackingOptions options = {};
memset(&options, 0, sizeof(TrackingOptions));
options.size = sizeof(TrackingOptions);
options.minInterval = 1000;
options.mode = GNSS_SUPL_MODE_STANDALONE;
if (GNSS_POWER_MODE_INVALID != powerMode) {
options.powerMode = powerMode;
options.tbm = timeBetweenMeasurement;
}
mTracking = true;
LOC_LOGD("%s]: start tracking session", __FUNCTION__);
locAPIStartTracking(options);
return IGnssMeasurement::GnssMeasurementStatus::SUCCESS;
}
// for GpsMeasurementInterface
void MeasurementAPIClient::measurementClose() {
LOC_LOGD("%s]: ()", __FUNCTION__);
mTracking = false;
locAPIStopTracking();
}
// callbacks
void MeasurementAPIClient::onGnssMeasurementsCb(
GnssMeasurementsNotification gnssMeasurementsNotification)
{
LOC_LOGD("%s]: (count: %u active: %d)",
__FUNCTION__, gnssMeasurementsNotification.count, mTracking);
if (mTracking) {
mMutex.lock();
sp<V1_0::IGnssMeasurementCallback> gnssMeasurementCbIface = nullptr;
sp<V1_1::IGnssMeasurementCallback> gnssMeasurementCbIface_1_1 = nullptr;
sp<V2_0::IGnssMeasurementCallback> gnssMeasurementCbIface_2_0 = nullptr;
if (mGnssMeasurementCbIface_2_0 != nullptr) {
gnssMeasurementCbIface_2_0 = mGnssMeasurementCbIface_2_0;
} else if (mGnssMeasurementCbIface_1_1 != nullptr) {
gnssMeasurementCbIface_1_1 = mGnssMeasurementCbIface_1_1;
} else if (mGnssMeasurementCbIface != nullptr) {
gnssMeasurementCbIface = mGnssMeasurementCbIface;
}
mMutex.unlock();
if (gnssMeasurementCbIface_2_0 != nullptr) {
V2_0::IGnssMeasurementCallback::GnssData gnssData;
convertGnssData_2_0(gnssMeasurementsNotification, gnssData);
auto r = gnssMeasurementCbIface_2_0->gnssMeasurementCb_2_0(gnssData);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssMeasurementCb description=%s",
__func__, r.description().c_str());
}
} else if (gnssMeasurementCbIface_1_1 != nullptr) {
V1_1::IGnssMeasurementCallback::GnssData gnssData;
convertGnssData_1_1(gnssMeasurementsNotification, gnssData);
auto r = gnssMeasurementCbIface_1_1->gnssMeasurementCb(gnssData);
if (!r.isOk()) {
LOC_LOGE("%s] Error from gnssMeasurementCb description=%s",
__func__, r.description().c_str());
}
} else if (gnssMeasurementCbIface != nullptr) {
V1_0::IGnssMeasurementCallback::GnssData gnssData;
convertGnssData(gnssMeasurementsNotification, gnssData);
auto r = gnssMeasurementCbIface->GnssMeasurementCb(gnssData);
if (!r.isOk()) {
LOC_LOGE("%s] Error from GnssMeasurementCb description=%s",
__func__, r.description().c_str());
}
}
}
}
static void convertGnssMeasurement(GnssMeasurementsData& in,
V1_0::IGnssMeasurementCallback::GnssMeasurement& out)
{
memset(&out, 0, sizeof(out));
if (in.flags & GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT)
out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_SNR;
if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT)
out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_FREQUENCY;
if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT)
out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_CYCLES;
if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT)
out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE;
if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT)
out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE_UNCERTAINTY;
if (in.flags & GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT)
out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_AUTOMATIC_GAIN_CONTROL;
out.svid = in.svId;
convertGnssConstellationType(in.svType, out.constellation);
out.timeOffsetNs = in.timeOffsetNs;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_CODE_LOCK;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BIT_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SUBFRAME_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_DECODED;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_MSEC_AMBIGUOUS;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SYMBOL_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_STRING_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_DECODED;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_BIT_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_SUBFRAME_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1BC_CODE_LOCK;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1C_2ND_CODE_LOCK;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1B_PAGE_SYNC;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT)
out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SBAS_SYNC;
out.receivedSvTimeInNs = in.receivedSvTimeNs;
out.receivedSvTimeUncertaintyInNs = in.receivedSvTimeUncertaintyNs;
out.cN0DbHz = in.carrierToNoiseDbHz;
out.pseudorangeRateMps = in.pseudorangeRateMps;
out.pseudorangeRateUncertaintyMps = in.pseudorangeRateUncertaintyMps;
if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
out.accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID;
if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
out.accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET;
if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
out.accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP;
out.accumulatedDeltaRangeM = in.adrMeters;
out.accumulatedDeltaRangeUncertaintyM = in.adrUncertaintyMeters;
out.carrierFrequencyHz = in.carrierFrequencyHz;
out.carrierCycles = in.carrierCycles;
out.carrierPhase = in.carrierPhase;
out.carrierPhaseUncertainty = in.carrierPhaseUncertainty;
uint8_t indicator =
static_cast<uint8_t>(IGnssMeasurementCallback::GnssMultipathIndicator::INDICATOR_UNKNOWN);
if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_PRESENT)
indicator |= IGnssMeasurementCallback::GnssMultipathIndicator::INDICATOR_PRESENT;
if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_NOT_PRESENT)
indicator |= IGnssMeasurementCallback::GnssMultipathIndicator::INDICATIOR_NOT_PRESENT;
out.multipathIndicator =
static_cast<IGnssMeasurementCallback::GnssMultipathIndicator>(indicator);
out.snrDb = in.signalToNoiseRatioDb;
out.agcLevelDb = in.agcLevelDb;
}
static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out)
{
memset(&out, 0, sizeof(IGnssMeasurementCallback::GnssClock));
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT)
out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_LEAP_SECOND;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT)
out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_TIME_UNCERTAINTY;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT)
out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_FULL_BIAS;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT)
out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_BIAS;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT)
out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_BIAS_UNCERTAINTY;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_BIT)
out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_DRIFT;
if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_UNCERTAINTY_BIT)
out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_DRIFT_UNCERTAINTY;
out.leapSecond = in.leapSecond;
out.timeNs = in.timeNs;
out.timeUncertaintyNs = in.timeUncertaintyNs;
out.fullBiasNs = in.fullBiasNs;
out.biasNs = in.biasNs;
out.biasUncertaintyNs = in.biasUncertaintyNs;
out.driftNsps = in.driftNsps;
out.driftUncertaintyNsps = in.driftUncertaintyNsps;
out.hwClockDiscontinuityCount = in.hwClockDiscontinuityCount;
}
static void convertGnssData(GnssMeasurementsNotification& in,
V1_0::IGnssMeasurementCallback::GnssData& out)
{
out.measurementCount = in.count;
if (out.measurementCount > static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT)) {
LOC_LOGW("%s]: Too many measurement %u. Clamps to %d.",
__FUNCTION__, out.measurementCount, V1_0::GnssMax::SVS_COUNT);
out.measurementCount = static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT);
}
for (size_t i = 0; i < out.measurementCount; i++) {
convertGnssMeasurement(in.measurements[i], out.measurements[i]);
}
convertGnssClock(in.clock, out.clock);
}
static void convertGnssData_1_1(GnssMeasurementsNotification& in,
V1_1::IGnssMeasurementCallback::GnssData& out)
{
out.measurements.resize(in.count);
for (size_t i = 0; i < in.count; i++) {
convertGnssMeasurement(in.measurements[i], out.measurements[i].v1_0);
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
out.measurements[i].accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID;
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
out.measurements[i].accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET;
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
out.measurements[i].accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP;
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_HALF_CYCLE_RESOLVED_BIT)
out.measurements[i].accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_HALF_CYCLE_RESOLVED;
}
convertGnssClock(in.clock, out.clock);
}
static void convertGnssData_2_0(GnssMeasurementsNotification& in,
V2_0::IGnssMeasurementCallback::GnssData& out)
{
out.measurements.resize(in.count);
for (size_t i = 0; i < in.count; i++) {
convertGnssMeasurement(in.measurements[i], out.measurements[i].v1_1.v1_0);
convertGnssConstellationType(in.measurements[i].svType, out.measurements[i].constellation);
convertGnssMeasurementsCodeType(in.measurements[i].codeType, out.measurements[i].codeType);
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
out.measurements[i].v1_1.accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID;
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
out.measurements[i].v1_1.accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET;
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
out.measurements[i].v1_1.accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP;
if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_HALF_CYCLE_RESOLVED_BIT)
out.measurements[i].v1_1.accumulatedDeltaRangeState |=
IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_HALF_CYCLE_RESOLVED;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_CODE_LOCK;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BIT_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SUBFRAME_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_DECODED;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_MSEC_AMBIGUOUS;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SYMBOL_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_STRING_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_DECODED;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_BIT_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_SUBFRAME_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1BC_CODE_LOCK;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1C_2ND_CODE_LOCK;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1B_PAGE_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SBAS_SYNC;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_TOW_KNOWN_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_KNOWN;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GLO_TOD_KNOWN_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_KNOWN;
if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_2ND_CODE_LOCK_BIT)
out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_2ND_CODE_LOCK;
}
convertGnssClock(in.clock, out.clock);
}
static void convertGnssMeasurementsCodeType(GnssMeasurementsCodeType& in,
::android::hardware::hidl_string& out)
{
switch(in) {
case GNSS_MEASUREMENTS_CODE_TYPE_A:
out = "A";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_B:
out = "B";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_C:
out = "C";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_I:
out = "I";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_L:
out = "L";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_M:
out = "M";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_P:
out = "P";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_Q:
out = "Q";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_S:
out = "S";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_W:
out = "W";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_X:
out = "X";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_Y:
out = "Y";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_Z:
out = "Z";
break;
case GNSS_MEASUREMENTS_CODE_TYPE_N:
out = "N";
break;
default:
out = "UNKNOWN";
}
}
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,89 @@
/* Copyright (c) 2017-2019, 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 MEASUREMENT_API_CLINET_H
#define MEASUREMENT_API_CLINET_H
#include <mutex>
#include <android/hardware/gnss/2.0/IGnssMeasurement.h>
//#include <android/hardware/gnss/1.1/IGnssMeasurementCallback.h>
#include <LocationAPIClientBase.h>
#include <hidl/Status.h>
#include <gps_extended_c.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::sp;
class MeasurementAPIClient : public LocationAPIClientBase
{
public:
MeasurementAPIClient();
virtual ~MeasurementAPIClient();
MeasurementAPIClient(const MeasurementAPIClient&) = delete;
MeasurementAPIClient& operator=(const MeasurementAPIClient&) = delete;
// for GpsMeasurementInterface
Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> measurementSetCallback(
const sp<V1_0::IGnssMeasurementCallback>& callback);
Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> measurementSetCallback_1_1(
const sp<V1_1::IGnssMeasurementCallback>& callback,
GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID,
uint32_t timeBetweenMeasurement = GPS_DEFAULT_FIX_INTERVAL_MS);
Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> measurementSetCallback_2_0(
const sp<V2_0::IGnssMeasurementCallback>& callback,
GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID,
uint32_t timeBetweenMeasurement = GPS_DEFAULT_FIX_INTERVAL_MS);
void measurementClose();
Return<IGnssMeasurement::GnssMeasurementStatus> startTracking(
GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID,
uint32_t timeBetweenMeasurement = GPS_DEFAULT_FIX_INTERVAL_MS);
// callbacks we are interested in
void onGnssMeasurementsCb(GnssMeasurementsNotification gnssMeasurementsNotification) final;
private:
std::mutex mMutex;
sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface;
sp<V1_1::IGnssMeasurementCallback> mGnssMeasurementCbIface_1_1;
sp<V2_0::IGnssMeasurementCallback> mGnssMeasurementCbIface_2_0;
bool mTracking;
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // MEASUREMENT_API_CLINET_H

View File

@@ -0,0 +1 @@
../measurement_corrections

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* 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.
*/
#define LOG_TAG "android.hardware.gnss@2.0-service-qti"
#include <android/hardware/gnss/2.0/IGnss.h>
#include <hidl/LegacySupport.h>
#include "loc_cfg.h"
#include "loc_misc_utils.h"
extern "C" {
#include "vndfwk-detect.h"
}
#ifdef ARCH_ARM_32
#define DEFAULT_HW_BINDER_MEM_SIZE 65536
#endif
using android::hardware::gnss::V2_0::IGnss;
using android::hardware::configureRpcThreadpool;
using android::hardware::registerPassthroughServiceImplementation;
using android::hardware::joinRpcThreadpool;
using android::status_t;
using android::OK;
typedef int vendorEnhancedServiceMain(int /* argc */, char* /* argv */ []);
int main() {
ALOGI("%s", __FUNCTION__);
int vendorInfo = getVendorEnhancedInfo();
bool vendorEnhanced = ( 1 == vendorInfo || 3 == vendorInfo );
setVendorEnhanced(vendorEnhanced);
#ifdef ARCH_ARM_32
android::hardware::ProcessState::initWithMmapSize((size_t)(DEFAULT_HW_BINDER_MEM_SIZE));
#endif
configureRpcThreadpool(1, true);
status_t status;
status = registerPassthroughServiceImplementation<IGnss>();
if (status == OK) {
if (vendorEnhanced) {
#ifdef LOC_HIDL_VERSION
#define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so"
void* libHandle = NULL;
vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*)
dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main");
if (NULL != vendorEnhancedMainMethod) {
(*vendorEnhancedMainMethod)(0, NULL);
}
#else
ALOGE("LOC_HIDL_VERSION not defined.");
#endif
}
joinRpcThreadpool();
} else {
ALOGE("Error while registering IGnss 2.0 service: %d", status);
}
return 0;
}

View File

@@ -0,0 +1 @@
../visibility_control/

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 2019, 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_TAG "LocSvc_MeasurementCorrectionsInterface"
#include <log_util.h>
#include "MeasurementCorrections.h"
namespace android {
namespace hardware {
namespace gnss {
namespace measurement_corrections {
namespace V1_0 {
namespace implementation {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
using ::android::hardware::gnss::V1_0::GnssLocation;
MeasurementCorrections::MeasurementCorrections() {
}
MeasurementCorrections::~MeasurementCorrections() {
}
Return<bool> MeasurementCorrections::setCorrections(const ::android::hardware::gnss::measurement_corrections::V1_0::MeasurementCorrections& /*corrections*/) {
return true;
}
Return<bool> MeasurementCorrections::setCallback(
const sp<V1_0::IMeasurementCorrectionsCallback>& /*callback*/) {
return true;
}
} // namespace implementation
} // namespace V1_0
} // namespace measurement_corrections
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,76 @@
/*
* Copyright (c) 2019, 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 ANDROID_HARDWARE_GNSS_V1_0_MeasurementCorrections_H
#define ANDROID_HARDWARE_GNSS_V1_0_MeasurementCorrections_H
#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrections.h>
#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrectionsCallback.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <location_interface.h>
namespace android {
namespace hardware {
namespace gnss {
namespace measurement_corrections {
namespace V1_0 {
namespace implementation {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
using ::android::hardware::gnss::V1_0::GnssLocation;
using ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrectionsCallback;
struct MeasurementCorrections : public IMeasurementCorrections {
MeasurementCorrections();
~MeasurementCorrections();
// Methods from ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections follow.
Return<bool> setCorrections(const ::android::hardware::gnss::measurement_corrections::V1_0::MeasurementCorrections& corrections) override;
Return<bool> setCallback(const sp<IMeasurementCorrectionsCallback>& callback) override;
};
} // namespace implementation
} // namespace V1_0
} // namespace measurement_corrections
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V1_0_MeasurementCorrections_H

View File

@@ -0,0 +1,34 @@
cc_library_static {
name: "liblocbatterylistener",
vendor: true,
cflags: GNSS_CFLAGS + ["-DBATTERY_LISTENER_ENABLED"],
local_include_dirs: ["."],
srcs: ["battery_listener.cpp"],
shared_libs: [
"liblog",
"libhidlbase",
"libcutils",
"libutils",
"android.hardware.health@1.0",
"android.hardware.health@2.0",
"android.hardware.power@1.2",
"libbase",
],
static_libs: ["libhealthhalutils"],
header_libs: [
"libloc_pla_headers",
],
}
cc_library_headers {
name: "liblocbatterylistener_headers",
vendor: true,
export_include_dirs: ["."],
}

View File

@@ -0,0 +1,273 @@
/*
* Copyright (c) 2019-2020, 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 "battery_listener.h"
#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define LOG_TAG "LocSvc_BatteryListener"
#include <android/hidl/manager/1.0/IServiceManager.h>
#include <android/hardware/health/2.0/IHealth.h>
#include <healthhalutils/HealthHalUtils.h>
#include <hidl/HidlTransportSupport.h>
#include <thread>
using android::hardware::interfacesEqual;
using android::hardware::Return;
using android::hardware::Void;
using android::hardware::health::V1_0::BatteryStatus;
using android::hardware::health::V1_0::toString;
using android::hardware::health::V2_0::get_health_service;
using android::hardware::health::V2_0::HealthInfo;
using android::hardware::health::V2_0::IHealth;
using android::hardware::health::V2_0::Result;
using android::hidl::manager::V1_0::IServiceManager;
using namespace std::literals::chrono_literals;
static bool sIsBatteryListened = false;
namespace android {
#define GET_HEALTH_SVC_RETRY_CNT 5
#define GET_HEALTH_SVC_WAIT_TIME_MS 500
struct BatteryListenerImpl : public hardware::health::V2_0::IHealthInfoCallback,
public hardware::hidl_death_recipient {
typedef std::function<void(bool)> cb_fn_t;
BatteryListenerImpl(cb_fn_t cb);
virtual ~BatteryListenerImpl ();
virtual hardware::Return<void> healthInfoChanged(
const hardware::health::V2_0::HealthInfo& info);
virtual void serviceDied(uint64_t cookie,
const wp<hidl::base::V1_0::IBase>& who);
bool isCharging() {
std::lock_guard<std::mutex> _l(mLock);
return statusToBool(mStatus);
}
private:
sp<hardware::health::V2_0::IHealth> mHealth;
status_t init();
BatteryStatus mStatus;
cb_fn_t mCb;
std::mutex mLock;
std::condition_variable mCond;
std::unique_ptr<std::thread> mThread;
bool mDone;
bool statusToBool(const BatteryStatus &s) const {
return (s == BatteryStatus::CHARGING) ||
(s == BatteryStatus::FULL);
}
};
status_t BatteryListenerImpl::init()
{
int tries = 0;
if (mHealth != NULL)
return INVALID_OPERATION;
do {
mHealth = hardware::health::V2_0::get_health_service();
if (mHealth != NULL)
break;
usleep(GET_HEALTH_SVC_WAIT_TIME_MS * 1000);
tries++;
} while(tries < GET_HEALTH_SVC_RETRY_CNT);
if (mHealth == NULL) {
ALOGE("no health service found, retries %d", tries);
return NO_INIT;
} else {
ALOGI("Get health service in %d tries", tries);
}
mStatus = BatteryStatus::UNKNOWN;
auto ret = mHealth->getChargeStatus([&](Result r, BatteryStatus status) {
if (r != Result::SUCCESS) {
ALOGE("batterylistener: cannot get battery status");
return;
}
mStatus = status;
});
if (!ret.isOk())
ALOGE("batterylistener: get charge status transaction error");
if (mStatus == BatteryStatus::UNKNOWN)
ALOGW("batterylistener: init: invalid battery status");
mDone = false;
mThread = std::make_unique<std::thread>([this]() {
std::unique_lock<std::mutex> l(mLock);
BatteryStatus local_status = mStatus;
while (!mDone) {
if (local_status == mStatus) {
mCond.wait(l);
continue;
}
local_status = mStatus;
switch (local_status) {
// NOT_CHARGING is a special event that indicates, a battery is connected,
// but not charging. This is seen for approx a second
// after charger is plugged in. A charging event is eventually received.
// We must try to avoid an unnecessary cb to HAL
// only to call it again shortly.
// An option to deal with this transient event would be to ignore this.
// Or process this event with a slight delay (i.e cancel this event
// if a different event comes in within a timeout
case BatteryStatus::NOT_CHARGING : {
auto mStatusnot_ncharging =
[this, local_status]() { return mStatus != local_status; };
mCond.wait_for(l, 3s, mStatusnot_ncharging);
if (mStatusnot_ncharging()) // i.e event changed
break;
[[clang::fallthrough]]; //explicit fall-through between switch labels
}
default:
bool c = statusToBool(local_status);
ALOGI("healthInfo cb thread: cb %s", c ? "CHARGING" : "NOT CHARGING");
l.unlock();
mCb(c);
l.lock();
break;
}
}
});
auto reg = mHealth->registerCallback(this);
if (!reg.isOk()) {
ALOGE("Transaction error in registeringCb to HealthHAL death: %s",
reg.description().c_str());
}
auto linked = mHealth->linkToDeath(this, 0 /* cookie */);
if (!linked.isOk() || linked == false) {
ALOGE("Transaction error in linking to HealthHAL death: %s", linked.description().c_str());
}
return NO_ERROR;
}
BatteryListenerImpl::BatteryListenerImpl(cb_fn_t cb) :
mCb(cb)
{
init();
}
BatteryListenerImpl::~BatteryListenerImpl()
{
{
std::lock_guard<std::mutex> _l(mLock);
if (mHealth != NULL) {
mHealth->unregisterCallback(this);
auto r = mHealth->unlinkToDeath(this);
if (!r.isOk() || r == false) {
ALOGE("Transaction error in unregister to HealthHAL death: %s",
r.description().c_str());
}
}
}
mDone = true;
if (NULL != mThread) {
mThread->join();
}
}
void BatteryListenerImpl::serviceDied(uint64_t cookie __unused,
const wp<hidl::base::V1_0::IBase>& who)
{
{
std::lock_guard<std::mutex> _l(mLock);
if (mHealth == NULL || !interfacesEqual(mHealth, who.promote())) {
ALOGE("health not initialized or unknown interface died");
return;
}
ALOGI("health service died, reinit");
mDone = true;
}
mHealth = NULL;
mCond.notify_one();
if (NULL != mThread) {
mThread->join();
}
std::lock_guard<std::mutex> _l(mLock);
init();
}
// this callback seems to be a SYNC callback and so
// waits for return before next event is issued.
// therefore we need not have a queue to process
// NOT_CHARGING and CHARGING concurrencies.
// Replace single var by a list if this assumption is broken
Return<void> BatteryListenerImpl::healthInfoChanged(
const hardware::health::V2_0::HealthInfo& info)
{
ALOGV("healthInfoChanged: %d", info.legacy.batteryStatus);
std::unique_lock<std::mutex> l(mLock);
if (info.legacy.batteryStatus != mStatus) {
mStatus = info.legacy.batteryStatus;
mCond.notify_one();
}
return Void();
}
static sp<BatteryListenerImpl> batteryListener;
status_t batteryPropertiesListenerInit(BatteryListenerImpl::cb_fn_t cb)
{
ALOGV("batteryPropertiesListenerInit entry");
batteryListener = new BatteryListenerImpl(cb);
return NO_ERROR;
}
status_t batteryPropertiesListenerDeinit()
{
batteryListener.clear();
return OK;
}
bool batteryPropertiesListenerIsCharging()
{
return batteryListener->isCharging();
}
} // namespace android
void loc_extn_battery_properties_listener_init(battery_status_change_fn_t fn)
{
ALOGV("loc_extn_battery_properties_listener_init entry");
if (!sIsBatteryListened) {
std::thread t1(android::batteryPropertiesListenerInit,
[=](bool charging) { fn(charging); });
t1.detach();
sIsBatteryListened = true;
}
}
void loc_extn_battery_properties_listener_deinit()
{
android::batteryPropertiesListenerDeinit();
}
bool loc_extn_battery_properties_is_charging()
{
return android::batteryPropertiesListenerIsCharging();
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 2019, 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.
*/
typedef void (* battery_status_change_fn_t)(bool);
void loc_extn_battery_properties_listener_init(battery_status_change_fn_t fn);
void loc_extn_battery_properties_listener_deinit();
bool loc_extn_battery_properties_is_charging();

View File

@@ -0,0 +1,169 @@
/*
* Copyright (c) 2019, 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 <android/hardware/gnss/visibility_control/1.0/IGnssVisibilityControl.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include "GnssVisibilityControl.h"
#include <location_interface.h>
namespace android {
namespace hardware {
namespace gnss {
namespace visibility_control {
namespace V1_0 {
namespace implementation {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
static GnssVisibilityControl* spGnssVisibilityControl = nullptr;
static void convertGnssNfwNotification(GnssNfwNotification& in,
IGnssVisibilityControlCallback::NfwNotification& out);
GnssVisibilityControl::GnssVisibilityControl(Gnss* gnss) : mGnss(gnss) {
spGnssVisibilityControl = this;
}
GnssVisibilityControl::~GnssVisibilityControl() {
spGnssVisibilityControl = nullptr;
}
void GnssVisibilityControl::nfwStatusCb(GnssNfwNotification notification) {
if (nullptr != spGnssVisibilityControl) {
spGnssVisibilityControl->statusCb(notification);
}
}
bool GnssVisibilityControl::isInEmergencySession() {
if (nullptr != spGnssVisibilityControl) {
return spGnssVisibilityControl->isE911Session();
}
return false;
}
static void convertGnssNfwNotification(GnssNfwNotification& in,
IGnssVisibilityControlCallback::NfwNotification& out)
{
memset(&out, 0, sizeof(IGnssVisibilityControlCallback::NfwNotification));
out.proxyAppPackageName = in.proxyAppPackageName;
out.protocolStack = (IGnssVisibilityControlCallback::NfwProtocolStack)in.protocolStack;
out.otherProtocolStackName = in.otherProtocolStackName;
out.requestor = (IGnssVisibilityControlCallback::NfwRequestor)in.requestor;
out.requestorId = in.requestorId;
out.responseType = (IGnssVisibilityControlCallback::NfwResponseType)in.responseType;
out.inEmergencyMode = in.inEmergencyMode;
out.isCachedLocation = in.isCachedLocation;
}
void GnssVisibilityControl::statusCb(GnssNfwNotification notification) {
if (mGnssVisibilityControlCbIface != nullptr) {
IGnssVisibilityControlCallback::NfwNotification nfwNotification;
// Convert from one structure to another
convertGnssNfwNotification(notification, nfwNotification);
auto r = mGnssVisibilityControlCbIface->nfwNotifyCb(nfwNotification);
if (!r.isOk()) {
LOC_LOGw("Error invoking NFW status cb %s", r.description().c_str());
}
} else {
LOC_LOGw("setCallback has not been called yet");
}
}
bool GnssVisibilityControl::isE911Session() {
if (mGnssVisibilityControlCbIface != nullptr) {
auto r = mGnssVisibilityControlCbIface->isInEmergencySession();
if (!r.isOk()) {
LOC_LOGw("Error invoking NFW status cb %s", r.description().c_str());
return false;
} else {
return (r);
}
} else {
LOC_LOGw("setCallback has not been called yet");
return false;
}
}
// Methods from ::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl follow.
Return<bool> GnssVisibilityControl::enableNfwLocationAccess(const hidl_vec<::android::hardware::hidl_string>& proxyApps) {
if (nullptr == mGnss || nullptr == mGnss->getGnssInterface()) {
LOC_LOGe("Null GNSS interface");
return false;
}
/* If the vector is empty we need to disable all NFW clients
If there is at least one app in the vector we need to enable
all NFW clients */
if (0 == proxyApps.size()) {
mGnss->getGnssInterface()->enableNfwLocationAccess(false);
} else {
mGnss->getGnssInterface()->enableNfwLocationAccess(true);
}
return true;
}
/**
* Registers the callback for HAL implementation to use.
*
* @param callback Handle to IGnssVisibilityControlCallback interface.
*/
Return<bool> GnssVisibilityControl::setCallback(const ::android::sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControlCallback>& callback) {
if (nullptr == mGnss || nullptr == mGnss->getGnssInterface()) {
LOC_LOGe("Null GNSS interface");
return false;
}
mGnssVisibilityControlCbIface = callback;
NfwCbInfo cbInfo = {};
cbInfo.visibilityControlCb = (void*)nfwStatusCb;
cbInfo.isInEmergencySession = (void*)isInEmergencySession;
mGnss->getGnssInterface()->nfwInit(cbInfo);
return true;
}
} // namespace implementation
} // namespace V1_0
} // namespace visibility_control
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,90 @@
/*
* Copyright (c) 2019, 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 ANDROID_HARDWARE_GNSS_V1_0_GnssVisibilityControl_H
#define ANDROID_HARDWARE_GNSS_V1_0_GnssVisibilityControl_H
#include <android/hardware/gnss/visibility_control/1.0/IGnssVisibilityControl.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <gps_extended_c.h>
#include <location_interface.h>
#include "Gnss.h"
namespace android {
namespace hardware {
namespace gnss {
namespace visibility_control {
namespace V1_0 {
namespace implementation {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
using ::android::hardware::gnss::V2_0::implementation::Gnss;
struct GnssVisibilityControl : public IGnssVisibilityControl {
GnssVisibilityControl(Gnss* gnss);
~GnssVisibilityControl();
// Methods from ::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl follow.
Return<bool> enableNfwLocationAccess(const hidl_vec<::android::hardware::hidl_string>& proxyApps) override;
/**
* Registers the callback for HAL implementation to use.
*
* @param callback Handle to IGnssVisibilityControlCallback interface.
*/
Return<bool> setCallback(const ::android::sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControlCallback>& callback) override;
void statusCb(GnssNfwNotification notification);
bool isE911Session();
/* Data call setup callback passed down to GNSS HAL implementation */
static void nfwStatusCb(GnssNfwNotification notification);
static bool isInEmergencySession();
private:
Gnss* mGnss = nullptr;
sp<IGnssVisibilityControlCallback> mGnssVisibilityControlCbIface = nullptr;
};
} // namespace implementation
} // namespace V1_0
} // namespace visibility_control
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V1_0_GnssVisibilityControl_H

29
gps/batching/Android.bp Normal file
View File

@@ -0,0 +1,29 @@
cc_library_shared {
name: "libbatching",
vendor: true,
shared_libs: [
"libutils",
"libcutils",
"liblog",
"libloc_core",
"libgps.utils",
"libdl",
],
srcs: [
"location_batching.cpp",
"BatchingAdapter.cpp",
],
header_libs: [
"libgps.utils_headers",
"libloc_core_headers",
"libloc_pla_headers",
"liblocation_api_headers",
],
cflags: GNSS_CFLAGS,
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,152 @@
/* Copyright (c) 2017-2019, 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 BATCHING_ADAPTER_H
#define BATCHING_ADAPTER_H
#include <LocAdapterBase.h>
#include <LocContext.h>
#include <LocationAPI.h>
#include <map>
using namespace loc_core;
class BatchingAdapter : public LocAdapterBase {
/* ==== BATCHING ======================================================================= */
typedef struct {
uint32_t accumulatedDistanceOngoingBatch;
uint32_t accumulatedDistanceThisTrip;
uint32_t accumulatedDistanceOnTripRestart;
uint32_t tripDistance;
uint32_t tripTBFInterval;
} TripSessionStatus;
typedef std::map<uint32_t, TripSessionStatus> TripSessionStatusMap;
typedef std::map<LocationSessionKey, BatchingOptions> BatchingSessionMap;
BatchingSessionMap mBatchingSessions;
TripSessionStatusMap mTripSessions;
uint32_t mOngoingTripDistance;
uint32_t mOngoingTripTBFInterval;
bool mTripWithOngoingTBFDropped;
bool mTripWithOngoingTripDistanceDropped;
void startTripBatchingMultiplex(LocationAPI* client, uint32_t sessionId,
const BatchingOptions& batchingOptions);
void stopTripBatchingMultiplex(LocationAPI* client, uint32_t sessionId,
bool restartNeeded,
const BatchingOptions& batchOptions);
inline void stopTripBatchingMultiplex(LocationAPI* client, uint32_t id) {
BatchingOptions batchOptions;
stopTripBatchingMultiplex(client, id, false, batchOptions);
};
void stopTripBatchingMultiplexCommon(LocationError err,
LocationAPI* client,
uint32_t sessionId,
bool restartNeeded,
const BatchingOptions& batchOptions);
void restartTripBatching(bool queryAccumulatedDistance, uint32_t accDist = 0,
uint32_t numbatchedPos = 0);
void printTripReport();
/* ==== CONFIGURATION ================================================================== */
uint32_t mBatchingTimeout;
uint32_t mBatchingAccuracy;
size_t mBatchSize;
size_t mTripBatchSize;
protected:
/* ==== CLIENT ========================================================================= */
virtual void updateClientsEventMask();
virtual void stopClientSessions(LocationAPI* client);
public:
BatchingAdapter();
virtual ~BatchingAdapter() {}
/* ==== SSR ============================================================================ */
/* ======== EVENTS ====(Called from QMI Thread)========================================= */
virtual void handleEngineUpEvent();
/* ======== UTILITIES ================================================================== */
void restartSessions();
/* ==== BATCHING ======================================================================= */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
uint32_t startBatchingCommand(LocationAPI* client, BatchingOptions &batchOptions);
void updateBatchingOptionsCommand(
LocationAPI* client, uint32_t id, BatchingOptions& batchOptions);
void stopBatchingCommand(LocationAPI* client, uint32_t id);
void getBatchedLocationsCommand(LocationAPI* client, uint32_t id, size_t count);
/* ======== RESPONSES ================================================================== */
void reportResponse(LocationAPI* client, LocationError err, uint32_t sessionId);
/* ======== UTILITIES ================================================================== */
bool hasBatchingCallback(LocationAPI* client);
bool isBatchingSession(LocationAPI* client, uint32_t sessionId);
bool isTripSession(uint32_t sessionId);
void saveBatchingSession(LocationAPI* client, uint32_t sessionId,
const BatchingOptions& batchingOptions);
void eraseBatchingSession(LocationAPI* client, uint32_t sessionId);
uint32_t autoReportBatchingSessionsCount();
void startBatching(LocationAPI* client, uint32_t sessionId,
const BatchingOptions& batchingOptions);
void stopBatching(LocationAPI* client, uint32_t sessionId, bool restartNeeded,
const BatchingOptions& batchOptions);
void stopBatching(LocationAPI* client, uint32_t sessionId) {
BatchingOptions batchOptions;
stopBatching(client, sessionId, false, batchOptions);
};
/* ==== REPORTS ======================================================================== */
/* ======== EVENTS ====(Called from QMI Thread)========================================= */
void reportLocationsEvent(const Location* locations, size_t count,
BatchingMode batchingMode);
void reportCompletedTripsEvent(uint32_t accumulatedDistance);
void reportBatchStatusChangeEvent(BatchingStatus batchStatus);
/* ======== UTILITIES ================================================================== */
void reportLocations(Location* locations, size_t count, BatchingMode batchingMode);
void reportBatchStatusChange(BatchingStatus batchStatus,
std::list<uint32_t> & completedTripsList);
/* ==== CONFIGURATION ================================================================== */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
void readConfigCommand();
void setConfigCommand();
/* ======== UTILITIES ================================================================== */
void setBatchSize(size_t batchSize) { mBatchSize = batchSize; }
size_t getBatchSize() { return mBatchSize; }
void setTripBatchSize(size_t batchSize) { mTripBatchSize = batchSize; }
size_t getTripBatchSize() { return mTripBatchSize; }
void setBatchingTimeout(uint32_t batchingTimeout) { mBatchingTimeout = batchingTimeout; }
uint32_t getBatchingTimeout() { return mBatchingTimeout; }
void setBatchingAccuracy(uint32_t accuracy) { mBatchingAccuracy = accuracy; }
uint32_t getBatchingAccuracy() { return mBatchingAccuracy; }
};
#endif /* BATCHING_ADAPTER_H */

45
gps/batching/Makefile.am Normal file
View File

@@ -0,0 +1,45 @@
AM_CFLAGS = \
$(GPSUTILS_CFLAGS) \
$(LOCCORE_CFLAGS) \
-I./ \
-std=c++1y \
-D__func__=__PRETTY_FUNCTION__ \
-fno-short-enums
ACLOCAL_AMFLAGS = -I m4
requiredlibs = \
$(GPSUTILS_LIBS) \
$(LOCCORE_LIBS) \
-llog
h_sources = \
BatchingAdapter.h
libbatching_la_SOURCES = \
location_batching.cpp \
BatchingAdapter.cpp
if USE_GLIB
libbatching_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
#libbatching_la_LDFLAGS = -lstdc++ -g -Wl,-z,defs -lpthread $(requiredlibs) @GLIB_LIBS@ -shared -avoid-version
libbatching_la_LDFLAGS = -lstdc++ -g -Wl,-z,defs -lpthread $(requiredlibs) @GLIB_LIBS@ -avoid-version
libbatching_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libbatching_la_CFLAGS = $(AM_CFLAGS)
libbatching_la_LDFLAGS = -Wl,-z,defs -lpthread $(requiredlibs) -shared -version-info 1:0:0
libbatching_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
library_include_HEADERS = $(h_sources)
library_includedir = $(pkgincludedir)
#Create and Install libraries
lib_LTLIBRARIES = libbatching.la
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = location-batching.pc
sysconf_DATA = $(WORKSPACE)/hardware/qcom/gps/etc/flp.conf
EXTRA_DIST = $(pkgconfig_DATA)

78
gps/batching/configure.ac Normal file
View File

@@ -0,0 +1,78 @@
# configure.ac -- Autoconf script for gps location-batching
#
# Process this file with autoconf to produce a configure script
# Requires autoconf tool later than 2.61
AC_PREREQ(2.61)
# Initialize the gps location-batching package version 1.0.0
AC_INIT([location-batching],1.0.0)
# Does not strictly follow GNU Coding standards
AM_INIT_AUTOMAKE([foreign])
# Disables auto rebuilding of configure, Makefile.ins
AM_MAINTAINER_MODE
# Verifies the --srcdir is correct by checking for the path
AC_CONFIG_SRCDIR([Makefile.am])
# defines some macros variable to be included by source
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
# Checks for programs.
AC_PROG_LIBTOOL
AC_PROG_CXX
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_AWK
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
# Checks for libraries.
PKG_CHECK_MODULES([GPSUTILS], [gps-utils])
AC_SUBST([GPSUTILS_CFLAGS])
AC_SUBST([GPSUTILS_LIBS])
PKG_CHECK_MODULES([LOCCORE], [loc-core])
AC_SUBST([LOCCORE_CFLAGS])
AC_SUBST([LOCCORE_LIBS])
PKG_CHECK_MODULES([GEOFENCE], [location-geofence])
AC_SUBST([GEOFENCE_CFLAGS])
AC_SUBST([GEOFENCE_LIBS])
AC_ARG_WITH([locpla_includes],
AC_HELP_STRING([--with-locpla-includes=@<:@dir@:>@],
[specify the path to locpla-includes in loc-pla_git.bb]),
[locpla_incdir=$withval],
with_locpla_includes=no)
if test "x$with_locpla_includes" != "xno"; then
AC_SUBST(LOCPLA_CFLAGS, "-I${locpla_incdir}")
fi
AC_ARG_WITH([glib],
AC_HELP_STRING([--with-glib],
[enable glib, building HLOS systems which use glib]))
if (test "x${with_glib}" = "xyes"); then
AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib])
PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
AC_MSG_ERROR(GThread >= 2.16 is required))
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
AC_MSG_ERROR(GLib >= 2.16 is required))
GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
fi
AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes")
AC_CONFIG_FILES([ \
Makefile \
location-batching.pc
])
AC_OUTPUT

View File

@@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: location-batching
Description: QTI GPS Batching
Version: @VERSION
Libs: -L${libdir} -lbatching
Cflags: -I${includedir}/location-batching

View File

@@ -0,0 +1,134 @@
/* Copyright (c) 2017-2019, 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 "BatchingAdapter.h"
#include "location_interface.h"
static BatchingAdapter* gBatchingAdapter = NULL;
static void initialize();
static void deinitialize();
static void addClient(LocationAPI* client, const LocationCallbacks& callbacks);
static void removeClient(LocationAPI* client, removeClientCompleteCallback rmClientCb);
static void requestCapabilities(LocationAPI* client);
static uint32_t startBatching(LocationAPI* client, BatchingOptions&);
static void stopBatching(LocationAPI* client, uint32_t id);
static void updateBatchingOptions(LocationAPI* client, uint32_t id, BatchingOptions&);
static void getBatchedLocations(LocationAPI* client, uint32_t id, size_t count);
static const BatchingInterface gBatchingInterface = {
sizeof(BatchingInterface),
initialize,
deinitialize,
addClient,
removeClient,
requestCapabilities,
startBatching,
stopBatching,
updateBatchingOptions,
getBatchedLocations
};
#ifndef DEBUG_X86
extern "C" const BatchingInterface* getBatchingInterface()
#else
const BatchingInterface* getBatchingInterface()
#endif // DEBUG_X86
{
return &gBatchingInterface;
}
static void initialize()
{
if (NULL == gBatchingAdapter) {
gBatchingAdapter = new BatchingAdapter();
}
}
static void deinitialize()
{
if (NULL != gBatchingAdapter) {
delete gBatchingAdapter;
gBatchingAdapter = NULL;
}
}
static void addClient(LocationAPI* client, const LocationCallbacks& callbacks)
{
if (NULL != gBatchingAdapter) {
gBatchingAdapter->addClientCommand(client, callbacks);
}
}
static void removeClient(LocationAPI* client, removeClientCompleteCallback rmClientCb)
{
if (NULL != gBatchingAdapter) {
gBatchingAdapter->removeClientCommand(client, rmClientCb);
}
}
static void requestCapabilities(LocationAPI* client)
{
if (NULL != gBatchingAdapter) {
gBatchingAdapter->requestCapabilitiesCommand(client);
}
}
static uint32_t startBatching(LocationAPI* client, BatchingOptions &batchOptions)
{
if (NULL != gBatchingAdapter) {
return gBatchingAdapter->startBatchingCommand(client, batchOptions);
} else {
return 0;
}
}
static void stopBatching(LocationAPI* client, uint32_t id)
{
if (NULL != gBatchingAdapter) {
gBatchingAdapter->stopBatchingCommand(client, id);
}
}
static void updateBatchingOptions(
LocationAPI* client, uint32_t id, BatchingOptions& batchOptions)
{
if (NULL != gBatchingAdapter) {
gBatchingAdapter->updateBatchingOptionsCommand(client, id, batchOptions);
}
}
static void getBatchedLocations(LocationAPI* client, uint32_t id, size_t count)
{
if (NULL != gBatchingAdapter) {
gBatchingAdapter->getBatchedLocationsCommand(client, id, count);
}
}

87
gps/configure.ac Normal file
View File

@@ -0,0 +1,87 @@
# configure.ac -- Autoconf script for gps loc_hal
#
# Process this file with autoconf to produce a configure script
# Requires autoconf tool later than 2.61
AC_PREREQ(2.61)
# Initialize the gps loc-hal package version 1.0.0
AC_INIT([loc-hal],1.0.0)
# Does not strictly follow GNU Coding standards
AM_INIT_AUTOMAKE([foreign subdir-objects])
# Disables auto rebuilding of configure, Makefile.ins
AM_MAINTAINER_MODE
# Verifies the --srcdir is correct by checking for the path
AC_CONFIG_SRCDIR([Makefile.am])
# defines some macros variable to be included by source
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
# Checks for programs.
AC_PROG_LIBTOOL
AC_PROG_CXX
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_AWK
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
# Checks for libraries.
PKG_CHECK_MODULES([GPSUTILS], [gps-utils])
AC_SUBST([GPSUTILS_CFLAGS])
AC_SUBST([GPSUTILS_LIBS])
PKG_CHECK_MODULES([LOCCORE], [loc-core])
AC_SUBST([LOCCORE_CFLAGS])
AC_SUBST([LOCCORE_LIBS])
AC_ARG_WITH([core_includes],
AC_HELP_STRING([--with-core-includes=@<:@dir@:>@],
[Specify the location of the core headers]),
[core_incdir=$withval],
with_core_includes=no)
if test "x$with_core_includes" != "xno"; then
CPPFLAGS="${CPPFLAGS} -I${core_incdir}"
fi
AC_ARG_WITH([locpla_includes],
AC_HELP_STRING([--with-locpla-includes=@<:@dir@:>@],
[specify the path to locpla-includes in loc-pla_git.bb]),
[locpla_incdir=$withval],
with_locpla_includes=no)
if test "x$with_locpla_includes" != "xno"; then
AC_SUBST(LOCPLA_CFLAGS, "-I${locpla_incdir}")
fi
AC_SUBST([CPPFLAGS])
AC_ARG_WITH([glib],
AC_HELP_STRING([--with-glib],
[enable glib, building HLOS systems which use glib]))
if (test "x${with_glib}" = "xyes"); then
AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib])
PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
AC_MSG_ERROR(GThread >= 2.16 is required))
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
AC_MSG_ERROR(GLib >= 2.16 is required))
GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
fi
AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes")
AC_CONFIG_FILES([ \
Makefile \
gnss/Makefile \
loc-hal.pc \
])
AC_OUTPUT

54
gps/core/Android.bp Normal file
View File

@@ -0,0 +1,54 @@
cc_library_shared {
name: "libloc_core",
vendor: true,
shared_libs: [
"liblog",
"libutils",
"libcutils",
"libgps.utils",
"libdl",
"liblog",
],
srcs: [
"LocApiBase.cpp",
"LocAdapterBase.cpp",
"ContextBase.cpp",
"LocContext.cpp",
"loc_core_log.cpp",
"data-items/DataItemsFactoryProxy.cpp",
"SystemStatusOsObserver.cpp",
"SystemStatus.cpp",
],
cflags: [
"-fno-short-enums",
"-D_ANDROID_",
] + GNSS_CFLAGS,
local_include_dirs: [
"data-items",
"observer",
],
header_libs: [
"libutils_headers",
"libgps.utils_headers",
"libloc_pla_headers",
"liblocation_api_headers",
],
}
cc_library_headers {
name: "libloc_core_headers",
vendor: true,
export_include_dirs: ["."] + [
"data-items",
"observer",
],
}

341
gps/core/ContextBase.cpp Normal file
View File

@@ -0,0 +1,341 @@
/* Copyright (c) 2011-2014,2016-2017 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_NDEBUG 0
#define LOG_TAG "LocSvc_CtxBase"
#include <dlfcn.h>
#include <cutils/sched_policy.h>
#include <unistd.h>
#include <ContextBase.h>
#include <msg_q.h>
#include <loc_target.h>
#include <loc_pla.h>
#include <loc_log.h>
namespace loc_core {
#define SLL_LOC_API_LIB_NAME "libsynergy_loc_api.so"
#define LOC_APIV2_0_LIB_NAME "libloc_api_v02.so"
#define IS_SS5_HW_ENABLED 1
loc_gps_cfg_s_type ContextBase::mGps_conf {};
loc_sap_cfg_s_type ContextBase::mSap_conf {};
bool ContextBase::sIsEngineCapabilitiesKnown = false;
uint64_t ContextBase::sSupportedMsgMask = 0;
bool ContextBase::sGnssMeasurementSupported = false;
uint8_t ContextBase::sFeaturesSupported[MAX_FEATURE_LENGTH];
const loc_param_s_type ContextBase::mGps_conf_table[] =
{
{"GPS_LOCK", &mGps_conf.GPS_LOCK, NULL, 'n'},
{"SUPL_VER", &mGps_conf.SUPL_VER, NULL, 'n'},
{"LPP_PROFILE", &mGps_conf.LPP_PROFILE, NULL, 'n'},
{"A_GLONASS_POS_PROTOCOL_SELECT", &mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'},
{"LPPE_CP_TECHNOLOGY", &mGps_conf.LPPE_CP_TECHNOLOGY, NULL, 'n'},
{"LPPE_UP_TECHNOLOGY", &mGps_conf.LPPE_UP_TECHNOLOGY, NULL, 'n'},
{"AGPS_CERT_WRITABLE_MASK", &mGps_conf.AGPS_CERT_WRITABLE_MASK, NULL, 'n'},
{"SUPL_MODE", &mGps_conf.SUPL_MODE, NULL, 'n'},
{"SUPL_ES", &mGps_conf.SUPL_ES, NULL, 'n'},
{"INTERMEDIATE_POS", &mGps_conf.INTERMEDIATE_POS, NULL, 'n'},
{"ACCURACY_THRES", &mGps_conf.ACCURACY_THRES, NULL, 'n'},
{"NMEA_PROVIDER", &mGps_conf.NMEA_PROVIDER, NULL, 'n'},
{"CAPABILITIES", &mGps_conf.CAPABILITIES, NULL, 'n'},
{"XTRA_SERVER_1", &mGps_conf.XTRA_SERVER_1, NULL, 's'},
{"XTRA_SERVER_2", &mGps_conf.XTRA_SERVER_2, NULL, 's'},
{"XTRA_SERVER_3", &mGps_conf.XTRA_SERVER_3, NULL, 's'},
{"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL",
&mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'},
{"AGPS_CONFIG_INJECT", &mGps_conf.AGPS_CONFIG_INJECT, NULL, 'n'},
{"EXTERNAL_DR_ENABLED", &mGps_conf.EXTERNAL_DR_ENABLED, NULL, 'n'},
{"SUPL_HOST", &mGps_conf.SUPL_HOST, NULL, 's'},
{"SUPL_PORT", &mGps_conf.SUPL_PORT, NULL, 'n'},
{"MODEM_TYPE", &mGps_conf.MODEM_TYPE, NULL, 'n' },
{"MO_SUPL_HOST", &mGps_conf.MO_SUPL_HOST, NULL, 's' },
{"MO_SUPL_PORT", &mGps_conf.MO_SUPL_PORT, NULL, 'n' },
{"CONSTRAINED_TIME_UNCERTAINTY_ENABLED",
&mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED, NULL, 'n'},
{"CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD",
&mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD, NULL, 'f'},
{"CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET",
&mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET, NULL, 'n'},
{"POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED",
&mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED, NULL, 'n'},
{"PROXY_APP_PACKAGE_NAME", &mGps_conf.PROXY_APP_PACKAGE_NAME, NULL, 's' },
{"CP_MTLR_ES", &mGps_conf.CP_MTLR_ES, NULL, 'n' },
{"GNSS_DEPLOYMENT", &mGps_conf.GNSS_DEPLOYMENT, NULL, 'n'},
{"CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED",
&mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED, NULL, 'n'},
};
const loc_param_s_type ContextBase::mSap_conf_table[] =
{
{"GYRO_BIAS_RANDOM_WALK", &mSap_conf.GYRO_BIAS_RANDOM_WALK, &mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'},
{"ACCEL_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
{"ANGLE_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
{"RATE_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
{"VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY", &mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
{"SENSOR_ACCEL_BATCHES_PER_SEC", &mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC, NULL, 'n'},
{"SENSOR_ACCEL_SAMPLES_PER_BATCH", &mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, NULL, 'n'},
{"SENSOR_GYRO_BATCHES_PER_SEC", &mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC, NULL, 'n'},
{"SENSOR_GYRO_SAMPLES_PER_BATCH", &mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH, NULL, 'n'},
{"SENSOR_ACCEL_BATCHES_PER_SEC_HIGH", &mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, NULL, 'n'},
{"SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH", &mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, NULL, 'n'},
{"SENSOR_GYRO_BATCHES_PER_SEC_HIGH", &mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, NULL, 'n'},
{"SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH", &mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, NULL, 'n'},
{"SENSOR_CONTROL_MODE", &mSap_conf.SENSOR_CONTROL_MODE, NULL, 'n'},
{"SENSOR_ALGORITHM_CONFIG_MASK", &mSap_conf.SENSOR_ALGORITHM_CONFIG_MASK, NULL, 'n'}
};
void ContextBase::readConfig()
{
static bool confReadDone = false;
if (!confReadDone) {
confReadDone = true;
/*Defaults for gps.conf*/
mGps_conf.INTERMEDIATE_POS = 0;
mGps_conf.ACCURACY_THRES = 0;
mGps_conf.NMEA_PROVIDER = 0;
mGps_conf.GPS_LOCK = GNSS_CONFIG_GPS_LOCK_MO_AND_NI;
mGps_conf.SUPL_VER = 0x10000;
mGps_conf.SUPL_MODE = 0x1;
mGps_conf.SUPL_ES = 0;
mGps_conf.CP_MTLR_ES = 0;
mGps_conf.SUPL_HOST[0] = 0;
mGps_conf.SUPL_PORT = 0;
mGps_conf.CAPABILITIES = 0x7;
/* LTE Positioning Profile configuration is disable by default*/
mGps_conf.LPP_PROFILE = 0;
/*By default no positioning protocol is selected on A-GLONASS system*/
mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0;
/*Use emergency PDN by default*/
mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = 1;
/* By default no LPPe CP technology is enabled*/
mGps_conf.LPPE_CP_TECHNOLOGY = 0;
/* By default no LPPe UP technology is enabled*/
mGps_conf.LPPE_UP_TECHNOLOGY = 0;
/* By default we use unknown modem type*/
mGps_conf.MODEM_TYPE = 2;
/*Defaults for sap.conf*/
mSap_conf.GYRO_BIAS_RANDOM_WALK = 0;
mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC = 2;
mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH = 5;
mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC = 2;
mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH = 5;
mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH = 4;
mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH = 25;
mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH = 4;
mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH = 25;
mSap_conf.SENSOR_CONTROL_MODE = 0; /* AUTO */
mSap_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 */
mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY = 0;
mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY = 0;
mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY = 0;
mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY = 0;
mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID = 0;
mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
/* None of the 10 slots for agps certificates are writable by default */
mGps_conf.AGPS_CERT_WRITABLE_MASK = 0;
/* inject supl config to modem with config values from config.xml or gps.conf, default 1 */
mGps_conf.AGPS_CONFIG_INJECT = 1;
/* default configuration value of constrained time uncertainty mode:
feature disabled, time uncertainty threshold defined by modem,
and unlimited power budget */
#ifdef FEATURE_AUTOMOTIVE
mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED = 1;
#else
mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED = 0;
#endif
mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD = 0.0;
mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET = 0;
/* default configuration value of position assisted clock estimator mode */
mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED = 0;
/* default configuration QTI GNSS H/W */
mGps_conf.GNSS_DEPLOYMENT = 0;
mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED = 0;
UTIL_READ_CONF(LOC_PATH_GPS_CONF, mGps_conf_table);
UTIL_READ_CONF(LOC_PATH_SAP_CONF, mSap_conf_table);
LOC_LOGI("%s] GNSS Deployment: %s", __FUNCTION__,
((mGps_conf.GNSS_DEPLOYMENT == 1) ? "SS5" :
((mGps_conf.GNSS_DEPLOYMENT == 2) ? "QFUSION" : "QGNSS")));
switch (getTargetGnssType(loc_get_target())) {
case GNSS_GSS:
case GNSS_AUTO:
// For APQ targets, MSA/MSB capabilities should be reset
mGps_conf.CAPABILITIES &= ~(LOC_GPS_CAPABILITY_MSA | LOC_GPS_CAPABILITY_MSB);
break;
default:
break;
}
}
}
uint32_t ContextBase::getCarrierCapabilities() {
#define carrierMSA (uint32_t)0x2
#define carrierMSB (uint32_t)0x1
#define gpsConfMSA (uint32_t)0x4
#define gpsConfMSB (uint32_t)0x2
uint32_t capabilities = mGps_conf.CAPABILITIES;
if ((mGps_conf.SUPL_MODE & carrierMSA) != carrierMSA) {
capabilities &= ~gpsConfMSA;
}
if ((mGps_conf.SUPL_MODE & carrierMSB) != carrierMSB) {
capabilities &= ~gpsConfMSB;
}
LOC_LOGV("getCarrierCapabilities: CAPABILITIES %x, SUPL_MODE %x, carrier capabilities %x",
mGps_conf.CAPABILITIES, mGps_conf.SUPL_MODE, capabilities);
return capabilities;
}
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)();
}
}
else
{
LOC_LOGW("%s:%d]: FAILED TO LOAD libname: %s\n", __func__, __LINE__, libName);
}
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;
const char* libname = LOC_APIV2_0_LIB_NAME;
// Check the target
if (TARGET_NO_GNSS != loc_get_target()){
if (NULL == (locApi = mLBSProxy->getLocApi(exMask, this))) {
void *handle = NULL;
if (IS_SS5_HW_ENABLED == mGps_conf.GNSS_DEPLOYMENT) {
libname = SLL_LOC_API_LIB_NAME;
}
if ((handle = dlopen(libname, RTLD_NOW)) != NULL) {
LOC_LOGD("%s:%d]: %s is present", __func__, __LINE__, libname);
getLocApi_t* getter = (getLocApi_t*) dlsym(handle, "getLocApi");
if (getter != NULL) {
LOC_LOGD("%s:%d]: getter is not NULL of %s", __func__,
__LINE__, libname);
locApi = (*getter)(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)(exMask, this);
}
}
}
}
}
// locApi could still be NULL at this time
// we would then create a dummy one
if (NULL == locApi) {
locApi = new LocApiBase(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())
{
}
void ContextBase::setEngineCapabilities(uint64_t supportedMsgMask,
uint8_t *featureList, bool gnssMeasurementSupported) {
if (ContextBase::sIsEngineCapabilitiesKnown == false) {
ContextBase::sSupportedMsgMask = supportedMsgMask;
ContextBase::sGnssMeasurementSupported = gnssMeasurementSupported;
if (featureList != NULL) {
memcpy((void *)ContextBase::sFeaturesSupported,
(void *)featureList, sizeof(ContextBase::sFeaturesSupported));
}
ContextBase::sIsEngineCapabilitiesKnown = true;
}
}
bool ContextBase::isFeatureSupported(uint8_t featureVal)
{
uint8_t arrayIndex = featureVal >> 3;
uint8_t bitPos = featureVal & 7;
if (arrayIndex >= MAX_FEATURE_LENGTH) return false;
return ((ContextBase::sFeaturesSupported[arrayIndex] >> bitPos ) & 0x1);
}
bool ContextBase::gnssConstellationConfig() {
return sGnssMeasurementSupported;
}
}

260
gps/core/ContextBase.h Normal file
View File

@@ -0,0 +1,260 @@
/* Copyright (c) 2011-2017, 2020, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __LOC_CONTEXT_BASE__
#define __LOC_CONTEXT_BASE__
#include <stdbool.h>
#include <ctype.h>
#include <MsgTask.h>
#include <LocApiBase.h>
#include <LBSProxyBase.h>
#include <loc_cfg.h>
/* 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 SUPL_ES;
uint32_t CAPABILITIES;
uint32_t LPP_PROFILE;
char XTRA_SERVER_1[LOC_MAX_PARAM_STRING];
char XTRA_SERVER_2[LOC_MAX_PARAM_STRING];
char XTRA_SERVER_3[LOC_MAX_PARAM_STRING];
uint32_t USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL;
uint32_t NMEA_PROVIDER;
GnssConfigGpsLock GPS_LOCK;
uint32_t A_GLONASS_POS_PROTOCOL_SELECT;
uint32_t AGPS_CERT_WRITABLE_MASK;
uint32_t AGPS_CONFIG_INJECT;
uint32_t LPPE_CP_TECHNOLOGY;
uint32_t LPPE_UP_TECHNOLOGY;
uint32_t EXTERNAL_DR_ENABLED;
char SUPL_HOST[LOC_MAX_PARAM_STRING];
uint32_t SUPL_PORT;
uint32_t MODEM_TYPE;
char MO_SUPL_HOST[LOC_MAX_PARAM_STRING];
uint32_t MO_SUPL_PORT;
uint32_t CONSTRAINED_TIME_UNCERTAINTY_ENABLED;
double CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD;
uint32_t CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET;
uint32_t POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED;
char PROXY_APP_PACKAGE_NAME[LOC_MAX_PARAM_STRING];
uint32_t CP_MTLR_ES;
uint32_t GNSS_DEPLOYMENT;
uint32_t CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED;
} 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_ALGORITHM_CONFIG_MASK;
uint8_t ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
double ACCEL_RANDOM_WALK_SPECTRAL_DENSITY;
uint8_t ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
double ANGLE_RANDOM_WALK_SPECTRAL_DENSITY;
uint8_t RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
double RATE_RANDOM_WALK_SPECTRAL_DENSITY;
uint8_t VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY;
} loc_sap_cfg_s_type;
namespace loc_core {
class LocAdapterBase;
class ContextBase {
static LBSProxyBase* getLBSProxy(const char* libName);
LocApiBase* createLocApi(LOC_API_ADAPTER_EVENT_MASK_T excludedMask);
static const loc_param_s_type mGps_conf_table[];
static const loc_param_s_type mSap_conf_table[];
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() {
if (nullptr != mLocApi) {
mLocApi->destroy();
mLocApi = nullptr;
}
if (nullptr != mLBSProxy) {
delete mLBSProxy;
mLBSProxy = nullptr;
}
}
inline const MsgTask* getMsgTask() { return mMsgTask; }
inline LocApiBase* getLocApi() { return mLocApi; }
inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; }
inline bool hasAgpsExtendedCapabilities() { return mLBSProxy->hasAgpsExtendedCapabilities(); }
inline bool hasNativeXtraClient() { return mLBSProxy->hasNativeXtraClient(); }
inline void modemPowerVote(bool power) const { return mLBSProxy->modemPowerVote(power); }
inline IzatDevId_t getIzatDevId() const {
return mLBSProxy->getIzatDevId();
}
inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); }
static loc_gps_cfg_s_type mGps_conf;
static loc_sap_cfg_s_type mSap_conf;
static bool sIsEngineCapabilitiesKnown;
static uint64_t sSupportedMsgMask;
static uint8_t sFeaturesSupported[MAX_FEATURE_LENGTH];
static bool sGnssMeasurementSupported;
void readConfig();
static uint32_t getCarrierCapabilities();
void setEngineCapabilities(uint64_t supportedMsgMask,
uint8_t *featureList, bool gnssMeasurementSupported);
static inline bool isEngineCapabilitiesKnown() {
return sIsEngineCapabilitiesKnown;
}
static inline bool isMessageSupported(LocCheckingMessagesID msgID) {
// confirm if msgID is not larger than the number of bits in
// mSupportedMsg
if ((uint64_t)msgID > (sizeof(sSupportedMsgMask) << 3)) {
return false;
} else {
uint32_t messageChecker = 1 << msgID;
return (messageChecker & sSupportedMsgMask) == messageChecker;
}
}
/*
Check if a feature is supported
*/
static bool isFeatureSupported(uint8_t featureVal);
/*
Check if gnss measurement is supported
*/
static bool gnssConstellationConfig();
};
struct LocApiResponse: LocMsg {
private:
ContextBase& mContext;
std::function<void (LocationError err)> mProcImpl;
inline virtual void proc() const {
mProcImpl(mLocationError);
}
protected:
LocationError mLocationError;
public:
inline LocApiResponse(ContextBase& context,
std::function<void (LocationError err)> procImpl ) :
mContext(context), mProcImpl(procImpl) {}
void returnToSender(const LocationError err) {
mLocationError = err;
mContext.sendMsg(this);
}
};
struct LocApiCollectiveResponse: LocMsg {
private:
ContextBase& mContext;
std::function<void (std::vector<LocationError> errs)> mProcImpl;
inline virtual void proc() const {
mProcImpl(mLocationErrors);
}
protected:
std::vector<LocationError> mLocationErrors;
public:
inline LocApiCollectiveResponse(ContextBase& context,
std::function<void (std::vector<LocationError> errs)> procImpl ) :
mContext(context), mProcImpl(procImpl) {}
inline virtual ~LocApiCollectiveResponse() {
}
void returnToSender(std::vector<LocationError>& errs) {
mLocationErrors = errs;
mContext.sendMsg(this);
}
};
template <typename DATA>
struct LocApiResponseData: LocMsg {
private:
ContextBase& mContext;
std::function<void (LocationError err, DATA data)> mProcImpl;
inline virtual void proc() const {
mProcImpl(mLocationError, mData);
}
protected:
LocationError mLocationError;
DATA mData;
public:
inline LocApiResponseData(ContextBase& context,
std::function<void (LocationError err, DATA data)> procImpl ) :
mContext(context), mProcImpl(procImpl) {}
void returnToSender(const LocationError err, const DATA data) {
mLocationError = err;
mData = data;
mContext.sendMsg(this);
}
};
} // namespace loc_core
#endif //__LOC_CONTEXT_BASE__

View File

@@ -0,0 +1,127 @@
/* Copyright (c) 2018, 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 ENGINE_HUB_PROXY_BASE_H
#define ENGINE_HUB_PROXY_BASE_H
namespace loc_core {
class EngineHubProxyBase {
public:
inline EngineHubProxyBase() {
}
inline virtual ~EngineHubProxyBase() {}
// gnss session related functions
inline virtual bool gnssStartFix() {
return false;
}
inline virtual bool gnssStopFix() {
return false;
}
inline virtual bool gnssSetFixMode(const LocPosMode &params) {
(void) params;
return false;
}
inline virtual bool gnssDeleteAidingData(const GnssAidingData &aidingData) {
(void) aidingData;
return false;
}
// GNSS reports
inline virtual bool gnssReportPosition(const UlpLocation &location,
const GpsLocationExtended &locationExtended,
enum loc_sess_status status) {
(void) location;
(void) locationExtended;
(void) status;
return false;
}
inline virtual bool gnssReportSv(const GnssSvNotification& svNotify) {
(void) svNotify;
return false;
}
inline virtual bool gnssReportSvMeasurement(const GnssSvMeasurementSet& svMeasurementSet) {
(void) svMeasurementSet;
return false;
}
inline virtual bool gnssReportSvPolynomial(const GnssSvPolynomial& svPolynomial) {
(void) svPolynomial;
return false;
}
inline virtual bool gnssReportSvEphemeris(const GnssSvEphemerisReport& svEphemeris) {
(void) svEphemeris;
return false;
}
inline virtual bool gnssReportSystemInfo(const LocationSystemInfo& systemInfo) {
(void) systemInfo;
return false;
}
inline virtual bool gnssReportKlobucharIonoModel(const GnssKlobucharIonoModel& ionoModel) {
(void) ionoModel;
return false;
}
inline virtual bool gnssReportAdditionalSystemInfo(
const GnssAdditionalSystemInfo& additionalSystemInfo) {
(void) additionalSystemInfo;
return false;
}
};
typedef std::function<void(int count, EngineLocationInfo* locationArr)>
GnssAdapterReportEnginePositionsEventCb;
typedef std::function<void(const GnssSvNotification& svNotify,
bool fromEngineHub)>
GnssAdapterReportSvEventCb;
typedef std::function<void(const GnssAidingDataSvMask& svDataMask)>
GnssAdapterReqAidingDataCb;
// potential parameters: message queue: MsgTask * msgTask;
// callback function to report back dr and ppe position and sv report
typedef EngineHubProxyBase* (getEngHubProxyFn)(
const MsgTask * msgTask,
IOsObserver* osObserver,
GnssAdapterReportEnginePositionsEventCb positionEventCb,
GnssAdapterReportSvEventCb svEventCb,
GnssAdapterReqAidingDataCb reqAidingDataCb);
} // namespace loc_core
#endif // ENGINE_HUB_PROXY_BASE_H

70
gps/core/LBSProxyBase.h Normal file
View File

@@ -0,0 +1,70 @@
/* 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 <gps_extended.h>
namespace loc_core {
class LocApiBase;
class LocAdapterBase;
class ContextBase;
class LBSProxyBase {
friend class ContextBase;
inline virtual LocApiBase*
getLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask,
ContextBase* context) const {
(void)exMask;
(void)context;
return NULL;
}
protected:
inline LBSProxyBase() {}
public:
inline virtual ~LBSProxyBase() {}
inline virtual bool hasAgpsExtendedCapabilities() const { return false; }
inline virtual void modemPowerVote(bool power) const {
(void)power;
}
virtual void injectFeatureConfig(ContextBase* context) const {
(void)context;
}
inline virtual bool hasNativeXtraClient() const { return false; }
inline virtual IzatDevId_t getIzatDevId() const { return 0; }
};
typedef LBSProxyBase* (getLBSProxy_t)();
} // namespace loc_core
#endif // IZAT_PROXY_BASE_H

411
gps/core/LocAdapterBase.cpp Normal file
View File

@@ -0,0 +1,411 @@
/* Copyright (c) 2011-2014, 2016-2019 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_NDEBUG 0
#define LOG_TAG "LocSvc_LocAdapterBase"
#include <dlfcn.h>
#include <LocAdapterBase.h>
#include <loc_target.h>
#include <log_util.h>
#include <LocAdapterProxyBase.h>
namespace loc_core {
// This is the top level class, so the constructor will
// always gets called. Here we prepare for the default.
// But if getLocApi(targetEnumType target) is overriden,
// the right locApi should get created.
LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
ContextBase* context, bool isMaster,
LocAdapterProxyBase *adapterProxyBase) :
mIsMaster(isMaster),
mIsEngineCapabilitiesKnown(ContextBase::sIsEngineCapabilitiesKnown),
mEvtMask(mask), mContext(context), mLocApi(context->getLocApi()),
mLocAdapterProxyBase(adapterProxyBase), mMsgTask(context->getMsgTask())
{
mLocApi->addAdapter(this);
}
uint32_t LocAdapterBase::mSessionIdCounter(1);
uint32_t LocAdapterBase::generateSessionId()
{
if (++mSessionIdCounter == 0xFFFFFFFF)
mSessionIdCounter = 1;
return mSessionIdCounter;
}
void LocAdapterBase::handleEngineUpEvent()
{
if (mLocAdapterProxyBase) {
mLocAdapterProxyBase->handleEngineUpEvent();
}
}
void LocAdapterBase::handleEngineDownEvent()
{
if (mLocAdapterProxyBase) {
mLocAdapterProxyBase->handleEngineDownEvent();
}
}
void LocAdapterBase::
reportPositionEvent(const UlpLocation& location,
const GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask,
GnssDataNotification* /*pDataNotify*/,
int /*msInWeek*/)
{
if (mLocAdapterProxyBase != NULL) {
mLocAdapterProxyBase->reportPositionEvent((UlpLocation&)location,
(GpsLocationExtended&)locationExtended,
status,
loc_technology_mask);
} else {
DEFAULT_IMPL()
}
}
void LocAdapterBase::
reportSvEvent(const GnssSvNotification& /*svNotify*/,
bool /*fromEngineHub*/)
DEFAULT_IMPL()
void LocAdapterBase::
reportSvPolynomialEvent(GnssSvPolynomial &/*svPolynomial*/)
DEFAULT_IMPL()
void LocAdapterBase::
reportSvEphemerisEvent(GnssSvEphemerisReport &/*svEphemeris*/)
DEFAULT_IMPL()
void LocAdapterBase::
reportStatus(LocGpsStatusValue /*status*/)
DEFAULT_IMPL()
void LocAdapterBase::
reportNmeaEvent(const char* /*nmea*/, size_t /*length*/)
DEFAULT_IMPL()
void LocAdapterBase::
reportDataEvent(const GnssDataNotification& /*dataNotify*/,
int /*msInWeek*/)
DEFAULT_IMPL()
bool LocAdapterBase::
reportXtraServer(const char* /*url1*/, const char* /*url2*/,
const char* /*url3*/, const int /*maxlength*/)
DEFAULT_IMPL(false)
void LocAdapterBase::
reportLocationSystemInfoEvent(const LocationSystemInfo& /*locationSystemInfo*/)
DEFAULT_IMPL()
bool LocAdapterBase::
requestXtraData()
DEFAULT_IMPL(false)
bool LocAdapterBase::
requestTime()
DEFAULT_IMPL(false)
bool LocAdapterBase::
requestLocation()
DEFAULT_IMPL(false)
bool LocAdapterBase::
requestATL(int /*connHandle*/, LocAGpsType /*agps_type*/,
LocApnTypeMask /*apn_type_mask*/)
DEFAULT_IMPL(false)
bool LocAdapterBase::
releaseATL(int /*connHandle*/)
DEFAULT_IMPL(false)
bool LocAdapterBase::
requestNiNotifyEvent(const GnssNiNotification &/*notify*/,
const void* /*data*/,
const LocInEmergency /*emergencyState*/)
DEFAULT_IMPL(false)
void LocAdapterBase::
reportGnssMeasurementsEvent(const GnssMeasurements& /*gnssMeasurements*/,
int /*msInWeek*/)
DEFAULT_IMPL()
bool LocAdapterBase::
reportWwanZppFix(LocGpsLocation &/*zppLoc*/)
DEFAULT_IMPL(false)
bool LocAdapterBase::
reportZppBestAvailableFix(LocGpsLocation& /*zppLoc*/,
GpsLocationExtended& /*location_extended*/, LocPosTechMask /*tech_mask*/)
DEFAULT_IMPL(false)
void LocAdapterBase::reportGnssSvIdConfigEvent(const GnssSvIdConfig& /*config*/)
DEFAULT_IMPL()
void LocAdapterBase::reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& /*config*/)
DEFAULT_IMPL()
bool LocAdapterBase::
requestOdcpiEvent(OdcpiRequestInfo& /*request*/)
DEFAULT_IMPL(false)
bool LocAdapterBase::
reportGnssEngEnergyConsumedEvent(uint64_t /*energyConsumedSinceFirstBoot*/)
DEFAULT_IMPL(false)
bool LocAdapterBase::
reportDeleteAidingDataEvent(GnssAidingData & /*aidingData*/)
DEFAULT_IMPL(false)
bool LocAdapterBase::
reportKlobucharIonoModelEvent(GnssKlobucharIonoModel& /*ionoModel*/)
DEFAULT_IMPL(false)
bool LocAdapterBase::
reportGnssAdditionalSystemInfoEvent(GnssAdditionalSystemInfo& /*additionalSystemInfo*/)
DEFAULT_IMPL(false)
void LocAdapterBase::
reportNfwNotificationEvent(GnssNfwNotification& /*notification*/)
DEFAULT_IMPL()
void
LocAdapterBase::geofenceBreachEvent(size_t /*count*/, uint32_t* /*hwIds*/, Location& /*location*/,
GeofenceBreachType /*breachType*/, uint64_t /*timestamp*/)
DEFAULT_IMPL()
void
LocAdapterBase::geofenceStatusEvent(GeofenceStatusAvailable /*available*/)
DEFAULT_IMPL()
void
LocAdapterBase::reportLocationsEvent(const Location* /*locations*/, size_t /*count*/,
BatchingMode /*batchingMode*/)
DEFAULT_IMPL()
void
LocAdapterBase::reportCompletedTripsEvent(uint32_t /*accumulated_distance*/)
DEFAULT_IMPL()
void
LocAdapterBase::reportBatchStatusChangeEvent(BatchingStatus /*batchStatus*/)
DEFAULT_IMPL()
void
LocAdapterBase::reportPositionEvent(UlpLocation& /*location*/,
GpsLocationExtended& /*locationExtended*/,
enum loc_sess_status /*status*/,
LocPosTechMask /*loc_technology_mask*/)
DEFAULT_IMPL()
void
LocAdapterBase::saveClient(LocationAPI* client, const LocationCallbacks& callbacks)
{
mClientData[client] = callbacks;
updateClientsEventMask();
}
void
LocAdapterBase::eraseClient(LocationAPI* client)
{
auto it = mClientData.find(client);
if (it != mClientData.end()) {
mClientData.erase(it);
}
updateClientsEventMask();
}
LocationCallbacks
LocAdapterBase::getClientCallbacks(LocationAPI* client)
{
LocationCallbacks callbacks = {};
auto it = mClientData.find(client);
if (it != mClientData.end()) {
callbacks = it->second;
}
return callbacks;
}
LocationCapabilitiesMask
LocAdapterBase::getCapabilities()
{
LocationCapabilitiesMask mask = 0;
if (isEngineCapabilitiesKnown()) {
// time based tracking always supported
mask |= LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT;
if (ContextBase::isMessageSupported(
LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_LOCATION_BATCHING)){
mask |= LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT |
LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT;
}
if (ContextBase::isMessageSupported(LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_TRACKING)) {
mask |= LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT;
}
if (ContextBase::isMessageSupported(LOC_API_ADAPTER_MESSAGE_OUTDOOR_TRIP_BATCHING)) {
mask |= LOCATION_CAPABILITIES_OUTDOOR_TRIP_BATCHING_BIT;
}
// geofence always supported
mask |= LOCATION_CAPABILITIES_GEOFENCE_BIT;
if (ContextBase::gnssConstellationConfig()) {
mask |= LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT;
}
uint32_t carrierCapabilities = ContextBase::getCarrierCapabilities();
if (carrierCapabilities & LOC_GPS_CAPABILITY_MSB) {
mask |= LOCATION_CAPABILITIES_GNSS_MSB_BIT;
}
if (LOC_GPS_CAPABILITY_MSA & carrierCapabilities) {
mask |= LOCATION_CAPABILITIES_GNSS_MSA_BIT;
}
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) {
mask |= LOCATION_CAPABILITIES_DEBUG_NMEA_BIT;
}
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_CONSTELLATION_ENABLEMENT_V02)) {
mask |= LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT;
}
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_AGPM_V02)) {
mask |= LOCATION_CAPABILITIES_AGPM_BIT;
}
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_LOCATION_PRIVACY)) {
mask |= LOCATION_CAPABILITIES_PRIVACY_BIT;
}
} else {
LOC_LOGE("%s]: attempt to get capabilities before they are known.", __func__);
}
return mask;
}
void
LocAdapterBase::broadcastCapabilities(LocationCapabilitiesMask mask)
{
for (auto clientData : mClientData) {
if (nullptr != clientData.second.capabilitiesCb) {
clientData.second.capabilitiesCb(mask);
}
}
}
void
LocAdapterBase::updateClientsEventMask()
DEFAULT_IMPL()
void
LocAdapterBase::stopClientSessions(LocationAPI* /*client*/)
DEFAULT_IMPL()
void
LocAdapterBase::addClientCommand(LocationAPI* client, const LocationCallbacks& callbacks)
{
LOC_LOGD("%s]: client %p", __func__, client);
struct MsgAddClient : public LocMsg {
LocAdapterBase& mAdapter;
LocationAPI* mClient;
const LocationCallbacks mCallbacks;
inline MsgAddClient(LocAdapterBase& adapter,
LocationAPI* client,
const LocationCallbacks& callbacks) :
LocMsg(),
mAdapter(adapter),
mClient(client),
mCallbacks(callbacks) {}
inline virtual void proc() const {
mAdapter.saveClient(mClient, mCallbacks);
}
};
sendMsg(new MsgAddClient(*this, client, callbacks));
}
void
LocAdapterBase::removeClientCommand(LocationAPI* client,
removeClientCompleteCallback rmClientCb)
{
LOC_LOGD("%s]: client %p", __func__, client);
struct MsgRemoveClient : public LocMsg {
LocAdapterBase& mAdapter;
LocationAPI* mClient;
removeClientCompleteCallback mRmClientCb;
inline MsgRemoveClient(LocAdapterBase& adapter,
LocationAPI* client,
removeClientCompleteCallback rmCb) :
LocMsg(),
mAdapter(adapter),
mClient(client),
mRmClientCb(rmCb){}
inline virtual void proc() const {
mAdapter.stopClientSessions(mClient);
mAdapter.eraseClient(mClient);
if (nullptr != mRmClientCb) {
(mRmClientCb)(mClient);
}
}
};
sendMsg(new MsgRemoveClient(*this, client, rmClientCb));
}
void
LocAdapterBase::requestCapabilitiesCommand(LocationAPI* client)
{
LOC_LOGD("%s]: ", __func__);
struct MsgRequestCapabilities : public LocMsg {
LocAdapterBase& mAdapter;
LocationAPI* mClient;
inline MsgRequestCapabilities(LocAdapterBase& adapter,
LocationAPI* client) :
LocMsg(),
mAdapter(adapter),
mClient(client) {}
inline virtual void proc() const {
if (!mAdapter.isEngineCapabilitiesKnown()) {
mAdapter.mPendingMsgs.push_back(new MsgRequestCapabilities(*this));
return;
}
LocationCallbacks callbacks = mAdapter.getClientCallbacks(mClient);
if (callbacks.capabilitiesCb != nullptr) {
callbacks.capabilitiesCb(mAdapter.getCapabilities());
}
}
};
sendMsg(new MsgRequestCapabilities(*this, client));
}
} // namespace loc_core

222
gps/core/LocAdapterBase.h Normal file
View File

@@ -0,0 +1,222 @@
/* Copyright (c) 2011-2014, 2016-2019 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_API_ADAPTER_BASE_H
#define LOC_API_ADAPTER_BASE_H
#include <gps_extended.h>
#include <ContextBase.h>
#include <LocationAPI.h>
#include <map>
#define MIN_TRACKING_INTERVAL (100) // 100 msec
typedef struct LocationSessionKey {
LocationAPI* client;
uint32_t id;
inline LocationSessionKey(LocationAPI* _client, uint32_t _id) :
client(_client), id(_id) {}
} LocationSessionKey;
inline bool operator <(LocationSessionKey const& left, LocationSessionKey const& right) {
return left.id < right.id || (left.id == right.id && left.client < right.client);
}
inline bool operator ==(LocationSessionKey const& left, LocationSessionKey const& right) {
return left.id == right.id && left.client == right.client;
}
inline bool operator !=(LocationSessionKey const& left, LocationSessionKey const& right) {
return left.id != right.id || left.client != right.client;
}
typedef void (*removeClientCompleteCallback)(LocationAPI* client);
namespace loc_core {
class LocAdapterProxyBase;
class LocAdapterBase {
private:
static uint32_t mSessionIdCounter;
const bool mIsMaster;
bool mIsEngineCapabilitiesKnown = false;
protected:
LOC_API_ADAPTER_EVENT_MASK_T mEvtMask;
ContextBase* mContext;
LocApiBase* mLocApi;
LocAdapterProxyBase* mLocAdapterProxyBase;
const MsgTask* mMsgTask;
inline LocAdapterBase(const MsgTask* msgTask) :
mIsMaster(false), mEvtMask(0), mContext(NULL), mLocApi(NULL),
mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {}
/* ==== CLIENT ========================================================================= */
typedef std::map<LocationAPI*, LocationCallbacks> ClientDataMap;
ClientDataMap mClientData;
std::vector<LocMsg*> mPendingMsgs; // For temporal storage of msgs before Open is completed
/* ======== UTILITIES ================================================================== */
void saveClient(LocationAPI* client, const LocationCallbacks& callbacks);
void eraseClient(LocationAPI* client);
LocationCallbacks getClientCallbacks(LocationAPI* client);
LocationCapabilitiesMask getCapabilities();
void broadcastCapabilities(LocationCapabilitiesMask mask);
virtual void updateClientsEventMask();
virtual void stopClientSessions(LocationAPI* client);
public:
inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
ContextBase* context, bool isMaster = false,
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 status)
{
switch(status) {
case (LOC_REGISTRATION_MASK_ENABLED):
mEvtMask = mEvtMask | event;
break;
case (LOC_REGISTRATION_MASK_DISABLED):
mEvtMask = mEvtMask &~ event;
break;
case (LOC_REGISTRATION_MASK_SET):
mEvtMask = event;
break;
}
mLocApi->updateEvtMask();
}
inline void updateNmeaMask(uint32_t mask)
{
mLocApi->updateNmeaMask(mask);
}
inline bool isFeatureSupported(uint8_t featureVal) {
return ContextBase::isFeatureSupported(featureVal);
}
uint32_t generateSessionId();
inline bool isAdapterMaster() {
return mIsMaster;
}
inline bool isEngineCapabilitiesKnown() { return mIsEngineCapabilitiesKnown;}
inline void setEngineCapabilitiesKnown(bool value) { mIsEngineCapabilitiesKnown = value;}
virtual void handleEngineUpEvent();
virtual void handleEngineDownEvent();
virtual void reportPositionEvent(const UlpLocation& location,
const GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask,
GnssDataNotification* pDataNotify = nullptr,
int msInWeek = -1);
virtual void reportEnginePositionsEvent(unsigned int count,
EngineLocationInfo* locationArr) {
(void)count;
(void)locationArr;
}
virtual void reportSvEvent(const GnssSvNotification& svNotify,
bool fromEngineHub=false);
virtual void reportDataEvent(const GnssDataNotification& dataNotify, int msInWeek);
virtual void reportNmeaEvent(const char* nmea, size_t length);
virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial);
virtual void reportSvEphemerisEvent(GnssSvEphemerisReport &svEphemeris);
virtual void reportStatus(LocGpsStatusValue status);
virtual bool reportXtraServer(const char* url1, const char* url2,
const char* url3, const int maxlength);
virtual void reportLocationSystemInfoEvent(const LocationSystemInfo& locationSystemInfo);
virtual bool requestXtraData();
virtual bool requestTime();
virtual bool requestLocation();
virtual bool requestATL(int connHandle, LocAGpsType agps_type,
LocApnTypeMask apn_type_mask);
virtual bool releaseATL(int connHandle);
virtual bool requestNiNotifyEvent(const GnssNiNotification &notify, const void* data,
const LocInEmergency emergencyState);
inline virtual bool isInSession() { return false; }
ContextBase* getContext() const { return mContext; }
virtual void reportGnssMeasurementsEvent(const GnssMeasurements& gnssMeasurements,
int msInWeek);
virtual bool reportWwanZppFix(LocGpsLocation &zppLoc);
virtual bool reportZppBestAvailableFix(LocGpsLocation &zppLoc,
GpsLocationExtended &location_extended, LocPosTechMask tech_mask);
virtual void reportGnssSvIdConfigEvent(const GnssSvIdConfig& config);
virtual void reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& config);
virtual bool requestOdcpiEvent(OdcpiRequestInfo& request);
virtual bool reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot);
virtual bool reportDeleteAidingDataEvent(GnssAidingData &aidingData);
virtual bool reportKlobucharIonoModelEvent(GnssKlobucharIonoModel& ionoModel);
virtual bool reportGnssAdditionalSystemInfoEvent(
GnssAdditionalSystemInfo& additionalSystemInfo);
virtual void reportNfwNotificationEvent(GnssNfwNotification& notification);
virtual void geofenceBreachEvent(size_t count, uint32_t* hwIds, Location& location,
GeofenceBreachType breachType, uint64_t timestamp);
virtual void geofenceStatusEvent(GeofenceStatusAvailable available);
virtual void reportPositionEvent(UlpLocation &location,
GpsLocationExtended &locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask);
virtual void reportLocationsEvent(const Location* locations, size_t count,
BatchingMode batchingMode);
virtual void reportCompletedTripsEvent(uint32_t accumulated_distance);
virtual void reportBatchStatusChangeEvent(BatchingStatus batchStatus);
/* ==== CLIENT ========================================================================= */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
void addClientCommand(LocationAPI* client, const LocationCallbacks& callbacks);
void removeClientCommand(LocationAPI* client,
removeClientCompleteCallback rmClientCb);
void requestCapabilitiesCommand(LocationAPI* client);
};
} // namespace loc_core
#endif //LOC_API_ADAPTER_BASE_H

View File

@@ -0,0 +1,77 @@
/* Copyright (c) 2014, 2016-2017 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 <ContextBase.h>
#include <gps_extended.h>
namespace loc_core {
class LocAdapterProxyBase {
private:
LocAdapterBase *mLocAdapterBase;
protected:
inline LocAdapterProxyBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
ContextBase* context, bool isMaster = false):
mLocAdapterBase(new LocAdapterBase(mask, context, isMaster, this)) {
}
inline virtual ~LocAdapterProxyBase() {
delete mLocAdapterBase;
}
inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event,
loc_registration_mask_status isEnabled) {
mLocAdapterBase->updateEvtMask(event,isEnabled);
}
inline uint32_t generateSessionId() {
return mLocAdapterBase->generateSessionId();
}
public:
inline ContextBase* getContext() const {
return mLocAdapterBase->getContext();
}
inline virtual void handleEngineUpEvent() {};
inline virtual void handleEngineDownEvent() {};
inline virtual void reportPositionEvent(UlpLocation &location,
GpsLocationExtended &locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask) {
(void)location;
(void)locationExtended;
(void)status;
(void)loc_technology_mask;
}
};
} // namespace loc_core
#endif //LOC_ADAPTER_PROXY_BASE_H

877
gps/core/LocApiBase.cpp Normal file
View File

@@ -0,0 +1,877 @@
/* Copyright (c) 2011-2014, 2016-2019 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_NDEBUG 0 //Define to enable LOGV
#define LOG_TAG "LocSvc_LocApiBase"
#include <dlfcn.h>
#include <inttypes.h>
#include <gps_extended_c.h>
#include <LocApiBase.h>
#include <LocAdapterBase.h>
#include <log_util.h>
#include <LocContext.h>
namespace loc_core {
#define TO_ALL_LOCADAPTERS(call) TO_ALL_ADAPTERS(mLocAdapters, (call))
#define TO_1ST_HANDLING_LOCADAPTERS(call) TO_1ST_HANDLING_ADAPTER(mLocAdapters, (call))
int hexcode(char *hexstring, int string_size,
const char *data, int data_size)
{
int i;
for (i = 0; i < data_size; i++)
{
char ch = data[i];
if (i*2 + 3 <= string_size)
{
snprintf(&hexstring[i*2], 3, "%02X", ch);
}
else {
break;
}
}
return i;
}
int decodeAddress(char *addr_string, int string_size,
const char *data, int data_size)
{
const char addr_prefix = 0x91;
int i, idxOutput = 0;
if (!data || !addr_string) { return 0; }
if (data[0] != addr_prefix)
{
LOC_LOGW("decodeAddress: address prefix is not 0x%x but 0x%x", addr_prefix, data[0]);
addr_string[0] = '\0';
return 0; // prefix not correct
}
for (i = 1; i < data_size; i++)
{
unsigned char ch = data[i], low = ch & 0x0F, hi = ch >> 4;
if (low <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = low + '0'; }
if (hi <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = hi + '0'; }
}
addr_string[idxOutput] = '\0'; // Terminates the string
return idxOutput;
}
struct LocSsrMsg : public LocMsg {
LocApiBase* mLocApi;
inline LocSsrMsg(LocApiBase* locApi) :
LocMsg(), mLocApi(locApi)
{
locallog();
}
inline virtual void proc() const {
mLocApi->close();
if (LOC_API_ADAPTER_ERR_SUCCESS == mLocApi->open(mLocApi->getEvtMask())) {
// Notify adapters that engine up after SSR
mLocApi->handleEngineUpEvent();
}
}
inline void locallog() const {
LOC_LOGV("LocSsrMsg");
}
inline virtual void log() const {
locallog();
}
};
struct LocOpenMsg : public LocMsg {
LocApiBase* mLocApi;
LocAdapterBase* mAdapter;
inline LocOpenMsg(LocApiBase* locApi, LocAdapterBase* adapter = nullptr) :
LocMsg(), mLocApi(locApi), mAdapter(adapter)
{
locallog();
}
inline virtual void proc() const {
if (LOC_API_ADAPTER_ERR_SUCCESS == mLocApi->open(mLocApi->getEvtMask()) &&
nullptr != mAdapter) {
mAdapter->handleEngineUpEvent();
}
}
inline void locallog() const {
LOC_LOGv("LocOpen Mask: %" PRIx64 "\n", mLocApi->getEvtMask());
}
inline virtual void log() const {
locallog();
}
};
struct LocCloseMsg : public LocMsg {
LocApiBase* mLocApi;
inline LocCloseMsg(LocApiBase* locApi) :
LocMsg(), mLocApi(locApi)
{
locallog();
}
inline virtual void proc() const {
mLocApi->close();
}
inline void locallog() const {
}
inline virtual void log() const {
locallog();
}
};
MsgTask* LocApiBase::mMsgTask = nullptr;
volatile int32_t LocApiBase::mMsgTaskRefCount = 0;
LocApiBase::LocApiBase(LOC_API_ADAPTER_EVENT_MASK_T excludedMask,
ContextBase* context) :
mContext(context),
mMask(0), mExcludedMask(excludedMask)
{
memset(mLocAdapters, 0, sizeof(mLocAdapters));
android_atomic_inc(&mMsgTaskRefCount);
if (nullptr == mMsgTask) {
mMsgTask = new MsgTask("LocApiMsgTask", false);
}
}
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::isMaster()
{
bool isMaster = false;
for (int i = 0;
!isMaster && i < MAX_ADAPTERS && NULL != mLocAdapters[i];
i++) {
isMaster |= mLocAdapters[i]->isAdapterMaster();
}
return isMaster;
}
bool LocApiBase::isInSession()
{
bool inSession = false;
for (int i = 0;
!inSession && i < MAX_ADAPTERS && NULL != mLocAdapters[i];
i++) {
inSession = mLocAdapters[i]->isInSession();
}
return inSession;
}
bool LocApiBase::needReport(const UlpLocation& ulpLocation,
enum loc_sess_status status,
LocPosTechMask techMask)
{
bool reported = false;
if (LOC_SESS_SUCCESS == status) {
// this is a final fix
LocPosTechMask mask =
LOC_POS_TECH_MASK_SATELLITE | LOC_POS_TECH_MASK_SENSORS | LOC_POS_TECH_MASK_HYBRID;
// it is a Satellite fix or a sensor fix
reported = (mask & techMask);
}
else if (LOC_SESS_INTERMEDIATE == status &&
LOC_SESS_INTERMEDIATE == ContextBase::mGps_conf.INTERMEDIATE_POS) {
// this is a intermediate fix and we accept intermediate
// it is NOT the case that
// there is inaccuracy; and
// we care about inaccuracy; and
// the inaccuracy exceeds our tolerance
reported = !((ulpLocation.gpsLocation.flags & LOC_GPS_LOCATION_HAS_ACCURACY) &&
(ContextBase::mGps_conf.ACCURACY_THRES != 0) &&
(ulpLocation.gpsLocation.accuracy > ContextBase::mGps_conf.ACCURACY_THRES));
}
return reported;
}
void LocApiBase::addAdapter(LocAdapterBase* adapter)
{
for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) {
if (mLocAdapters[i] == NULL) {
mLocAdapters[i] = adapter;
sendMsg(new LocOpenMsg(this, adapter));
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) {
sendMsg(new LocCloseMsg(this));
} else {
// else we need to remove the bit
sendMsg(new LocOpenMsg(this));
}
}
}
}
void LocApiBase::updateEvtMask()
{
sendMsg(new LocOpenMsg(this));
}
void LocApiBase::updateNmeaMask(uint32_t mask)
{
struct LocSetNmeaMsg : public LocMsg {
LocApiBase* mLocApi;
uint32_t mMask;
inline LocSetNmeaMsg(LocApiBase* locApi, uint32_t mask) :
LocMsg(), mLocApi(locApi), mMask(mask)
{
locallog();
}
inline virtual void proc() const {
mLocApi->setNMEATypesSync(mMask);
}
inline void locallog() const {
LOC_LOGv("LocSyncNmea NmeaMask: %" PRIx32 "\n", mMask);
}
inline virtual void log() const {
locallog();
}
};
sendMsg(new LocSetNmeaMsg(this, mask));
}
void LocApiBase::handleEngineUpEvent()
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent());
}
void LocApiBase::handleEngineDownEvent()
{ // This will take care of renegotiating the loc handle
sendMsg(new LocSsrMsg(this));
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineDownEvent());
}
void LocApiBase::reportPosition(UlpLocation& location,
GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask,
GnssDataNotification* pDataNotify,
int msInWeek)
{
// print the location info before delivering
LOC_LOGD("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: %" PRId64 "\n"
"Session status: %d\n Technology mask: %u\n "
"SV used in fix (gps/glo/bds/gal/qzss) : \
(0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 ")",
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, status, loc_technology_mask,
locationExtended.gnss_sv_used_ids.gps_sv_used_ids_mask,
locationExtended.gnss_sv_used_ids.glo_sv_used_ids_mask,
locationExtended.gnss_sv_used_ids.bds_sv_used_ids_mask,
locationExtended.gnss_sv_used_ids.gal_sv_used_ids_mask,
locationExtended.gnss_sv_used_ids.qzss_sv_used_ids_mask);
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportPositionEvent(location, locationExtended,
status, loc_technology_mask,
pDataNotify, msInWeek)
);
}
void LocApiBase::reportWwanZppFix(LocGpsLocation &zppLoc)
{
// loop through adapters, and deliver to the first handling adapter.
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportWwanZppFix(zppLoc));
}
void LocApiBase::reportZppBestAvailableFix(LocGpsLocation &zppLoc,
GpsLocationExtended &location_extended, LocPosTechMask tech_mask)
{
// loop through adapters, and deliver to the first handling adapter.
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportZppBestAvailableFix(zppLoc,
location_extended, tech_mask));
}
void LocApiBase::requestOdcpi(OdcpiRequestInfo& request)
{
// loop through adapters, and deliver to the first handling adapter.
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestOdcpiEvent(request));
}
void LocApiBase::reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot)
{
// loop through adapters, and deliver to the first handling adapter.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssEngEnergyConsumedEvent(
energyConsumedSinceFirstBoot));
}
void LocApiBase::reportDeleteAidingDataEvent(GnssAidingData& aidingData) {
// loop through adapters, and deliver to the first handling adapter.
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDeleteAidingDataEvent(aidingData));
}
void LocApiBase::reportKlobucharIonoModel(GnssKlobucharIonoModel & ionoModel) {
// loop through adapters, and deliver to the first handling adapter.
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportKlobucharIonoModelEvent(ionoModel));
}
void LocApiBase::reportGnssAdditionalSystemInfo(GnssAdditionalSystemInfo& additionalSystemInfo) {
// loop through adapters, and deliver to the first handling adapter.
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportGnssAdditionalSystemInfoEvent(
additionalSystemInfo));
}
void LocApiBase::sendNfwNotification(GnssNfwNotification& notification)
{
// loop through adapters, and deliver to the first handling adapter.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNfwNotificationEvent(notification));
}
void LocApiBase::reportSv(GnssSvNotification& svNotify)
{
const char* constellationString[] = { "Unknown", "GPS", "SBAS", "GLONASS",
"QZSS", "BEIDOU", "GALILEO", "NAVIC" };
// print the SV info before delivering
LOC_LOGV("num sv: %u\n"
" sv: constellation svid cN0"
" elevation azimuth flags",
svNotify.count);
for (size_t i = 0; i < svNotify.count && i < LOC_GNSS_MAX_SVS; i++) {
if (svNotify.gnssSvs[i].type >
sizeof(constellationString) / sizeof(constellationString[0]) - 1) {
svNotify.gnssSvs[i].type = GNSS_SV_TYPE_UNKNOWN;
}
// Display what we report to clients
uint16_t displaySvId = GNSS_SV_TYPE_QZSS == svNotify.gnssSvs[i].type ?
svNotify.gnssSvs[i].svId + QZSS_SV_PRN_MIN - 1 :
svNotify.gnssSvs[i].svId;
LOC_LOGV(" %03zu: %*s %02d %f %f %f %f 0x%02X",
i,
13,
constellationString[svNotify.gnssSvs[i].type],
displaySvId,
svNotify.gnssSvs[i].cN0Dbhz,
svNotify.gnssSvs[i].elevation,
svNotify.gnssSvs[i].azimuth,
svNotify.gnssSvs[i].carrierFrequencyHz,
svNotify.gnssSvs[i].gnssSvOptionsMask);
}
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportSvEvent(svNotify)
);
}
void LocApiBase::reportSvPolynomial(GnssSvPolynomial &svPolynomial)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportSvPolynomialEvent(svPolynomial)
);
}
void LocApiBase::reportSvEphemeris(GnssSvEphemerisReport & svEphemeris)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(
mLocAdapters[i]->reportSvEphemerisEvent(svEphemeris)
);
}
void LocApiBase::reportStatus(LocGpsStatusValue status)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportStatus(status));
}
void LocApiBase::reportData(GnssDataNotification& dataNotify, int msInWeek)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportDataEvent(dataNotify, msInWeek));
}
void LocApiBase::reportNmea(const char* nmea, int length)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmeaEvent(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::reportLocationSystemInfo(const LocationSystemInfo& locationSystemInfo)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportLocationSystemInfoEvent(locationSystemInfo));
}
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, LocAGpsType agps_type,
LocApnTypeMask apn_type_mask)
{
// loop through adapters, and deliver to the first handling adapter.
TO_1ST_HANDLING_LOCADAPTERS(
mLocAdapters[i]->requestATL(connHandle, agps_type, apn_type_mask));
}
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::requestNiNotify(GnssNiNotification &notify, const void* data,
const LocInEmergency emergencyState)
{
// loop through adapters, and deliver to the first handling adapter.
TO_1ST_HANDLING_LOCADAPTERS(
mLocAdapters[i]->requestNiNotifyEvent(notify,
data,
emergencyState));
}
void* LocApiBase :: getSibling()
DEFAULT_IMPL(NULL)
LocApiProxyBase* LocApiBase :: getLocApiProxy()
DEFAULT_IMPL(NULL)
void LocApiBase::reportGnssMeasurements(GnssMeasurements& gnssMeasurements, int msInWeek)
{
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementsEvent(gnssMeasurements, msInWeek));
}
void LocApiBase::reportGnssSvIdConfig(const GnssSvIdConfig& config)
{
// Print the config
LOC_LOGv("gloBlacklistSvMask: %" PRIu64 ", bdsBlacklistSvMask: %" PRIu64 ",\n"
"qzssBlacklistSvMask: %" PRIu64 ", galBlacklistSvMask: %" PRIu64,
config.gloBlacklistSvMask, config.bdsBlacklistSvMask,
config.qzssBlacklistSvMask, config.galBlacklistSvMask);
// Loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssSvIdConfigEvent(config));
}
void LocApiBase::reportGnssSvTypeConfig(const GnssSvTypeConfig& config)
{
// Print the config
LOC_LOGv("blacklistedMask: %" PRIu64 ", enabledMask: %" PRIu64,
config.blacklistedSvTypesMask, config.enabledSvTypesMask);
// Loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssSvTypeConfigEvent(config));
}
void LocApiBase::geofenceBreach(size_t count, uint32_t* hwIds, Location& location,
GeofenceBreachType breachType, uint64_t timestamp)
{
TO_ALL_LOCADAPTERS(mLocAdapters[i]->geofenceBreachEvent(count, hwIds, location, breachType,
timestamp));
}
void LocApiBase::geofenceStatus(GeofenceStatusAvailable available)
{
TO_ALL_LOCADAPTERS(mLocAdapters[i]->geofenceStatusEvent(available));
}
void LocApiBase::reportDBTPosition(UlpLocation &location, GpsLocationExtended &locationExtended,
enum loc_sess_status status, LocPosTechMask loc_technology_mask)
{
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportPositionEvent(location, locationExtended, status,
loc_technology_mask));
}
void LocApiBase::reportLocations(Location* locations, size_t count, BatchingMode batchingMode)
{
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportLocationsEvent(locations, count, batchingMode));
}
void LocApiBase::reportCompletedTrips(uint32_t accumulated_distance)
{
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportCompletedTripsEvent(accumulated_distance));
}
void LocApiBase::handleBatchStatusEvent(BatchingStatus batchStatus)
{
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportBatchStatusChangeEvent(batchStatus));
}
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)
void LocApiBase::startFix(const LocPosMode& /*posMode*/, LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::stopFix(LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::
deleteAidingData(const GnssAidingData& /*data*/, LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::
injectPosition(double /*latitude*/, double /*longitude*/, float /*accuracy*/)
DEFAULT_IMPL()
void LocApiBase::
injectPosition(const Location& /*location*/, bool /*onDemandCpi*/)
DEFAULT_IMPL()
void LocApiBase::
injectPosition(const GnssLocationInfoNotification & /*locationInfo*/, bool /*onDemandCpi*/)
DEFAULT_IMPL()
void LocApiBase::
setTime(LocGpsUtcTime /*time*/, int64_t /*timeReference*/, int /*uncertainty*/)
DEFAULT_IMPL()
enum loc_api_adapter_err LocApiBase::
setXtraData(char* /*data*/, int /*length*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
void LocApiBase::
atlOpenStatus(int /*handle*/, int /*is_succ*/, char* /*apn*/, uint32_t /*apnLen*/,
AGpsBearerType /*bear*/, LocAGpsType /*agpsType*/,
LocApnTypeMask /*mask*/)
DEFAULT_IMPL()
void LocApiBase::
atlCloseStatus(int /*handle*/, int /*is_succ*/)
DEFAULT_IMPL()
LocationError LocApiBase::
setServerSync(const char* /*url*/, int /*len*/, LocServerType /*type*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::
setServerSync(unsigned int /*ip*/, int /*port*/, LocServerType /*type*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::
informNiResponse(GnssNiResponse /*userResponse*/, const void* /*passThroughData*/)
DEFAULT_IMPL()
LocationError LocApiBase::
setSUPLVersionSync(GnssConfigSuplVersion /*version*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setNMEATypesSync (uint32_t /*typesMask*/)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
LocationError LocApiBase::
setLPPConfigSync(GnssConfigLppProfile /*profile*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setSensorPropertiesSync(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::
setSensorPerfControlConfigSync(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)
LocationError LocApiBase::
setAGLONASSProtocolSync(GnssConfigAGlonassPositionProtocolMask /*aGlonassProtocol*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::
setLPPeProtocolCpSync(GnssConfigLppeControlPlaneMask /*lppeCP*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::
setLPPeProtocolUpSync(GnssConfigLppeUserPlaneMask /*lppeUP*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
GnssConfigSuplVersion LocApiBase::convertSuplVersion(const uint32_t /*suplVersion*/)
DEFAULT_IMPL(GNSS_CONFIG_SUPL_VERSION_1_0_0)
GnssConfigLppProfile LocApiBase::convertLppProfile(const uint32_t /*lppProfile*/)
DEFAULT_IMPL(GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE)
GnssConfigLppeControlPlaneMask LocApiBase::convertLppeCp(const uint32_t /*lppeControlPlaneMask*/)
DEFAULT_IMPL(0)
GnssConfigLppeUserPlaneMask LocApiBase::convertLppeUp(const uint32_t /*lppeUserPlaneMask*/)
DEFAULT_IMPL(0)
LocationError LocApiBase::setEmergencyExtensionWindowSync(
const uint32_t /*emergencyExtensionSeconds*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::
getWwanZppFix()
DEFAULT_IMPL()
void LocApiBase::
getBestAvailableZppFix()
DEFAULT_IMPL()
LocationError LocApiBase::
setGpsLockSync(GnssConfigGpsLock /*lock*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::
requestForAidingData(GnssAidingDataSvMask /*svDataMask*/)
DEFAULT_IMPL()
void LocApiBase::
installAGpsCert(const LocDerEncodedCertificate* /*pData*/,
size_t /*length*/,
uint32_t /*slotBitMask*/)
DEFAULT_IMPL()
LocationError LocApiBase::
setXtraVersionCheckSync(uint32_t /*check*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::setBlacklistSvSync(const GnssSvIdConfig& /*config*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::setBlacklistSv(const GnssSvIdConfig& /*config*/)
DEFAULT_IMPL()
void LocApiBase::getBlacklistSv()
DEFAULT_IMPL()
void LocApiBase::setConstellationControl(const GnssSvTypeConfig& /*config*/)
DEFAULT_IMPL()
void LocApiBase::getConstellationControl()
DEFAULT_IMPL()
void LocApiBase::resetConstellationControl()
DEFAULT_IMPL()
LocationError LocApiBase::
setConstrainedTuncMode(bool /*enabled*/,
float /*tuncConstraint*/,
uint32_t /*energyBudget*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::
setPositionAssistedClockEstimatorMode(bool /*enabled*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
LocationError LocApiBase::getGnssEnergyConsumed()
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::addGeofence(uint32_t /*clientId*/, const GeofenceOption& /*options*/,
const GeofenceInfo& /*info*/,
LocApiResponseData<LocApiGeofenceData>* /*adapterResponseData*/)
DEFAULT_IMPL()
void LocApiBase::removeGeofence(uint32_t /*hwId*/, uint32_t /*clientId*/,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::pauseGeofence(uint32_t /*hwId*/, uint32_t /*clientId*/,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::resumeGeofence(uint32_t /*hwId*/, uint32_t /*clientId*/,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::modifyGeofence(uint32_t /*hwId*/, uint32_t /*clientId*/,
const GeofenceOption& /*options*/, LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::startTimeBasedTracking(const TrackingOptions& /*options*/,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::stopTimeBasedTracking(LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::startDistanceBasedTracking(uint32_t /*sessionId*/,
const LocationOptions& /*options*/, LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::stopDistanceBasedTracking(uint32_t /*sessionId*/,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::startBatching(uint32_t /*sessionId*/, const LocationOptions& /*options*/,
uint32_t /*accuracy*/, uint32_t /*timeout*/, LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::stopBatching(uint32_t /*sessionId*/, LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
LocationError LocApiBase::startOutdoorTripBatchingSync(uint32_t /*tripDistance*/,
uint32_t /*tripTbf*/, uint32_t /*timeout*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::startOutdoorTripBatching(uint32_t /*tripDistance*/, uint32_t /*tripTbf*/,
uint32_t /*timeout*/, LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
void LocApiBase::reStartOutdoorTripBatching(uint32_t /*ongoingTripDistance*/,
uint32_t /*ongoingTripInterval*/, uint32_t /*batchingTimeout,*/,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
LocationError LocApiBase::stopOutdoorTripBatchingSync(bool /*deallocBatchBuffer*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::stopOutdoorTripBatching(bool /*deallocBatchBuffer*/,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
LocationError LocApiBase::getBatchedLocationsSync(size_t /*count*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::getBatchedLocations(size_t /*count*/, LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
LocationError LocApiBase::getBatchedTripLocationsSync(size_t /*count*/,
uint32_t /*accumulatedDistance*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::getBatchedTripLocations(size_t /*count*/, uint32_t /*accumulatedDistance*/,
LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
LocationError LocApiBase::queryAccumulatedTripDistanceSync(uint32_t& /*accumulated_trip_distance*/,
uint32_t& /*numOfBatchedPositions*/)
DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
void LocApiBase::queryAccumulatedTripDistance(
LocApiResponseData<LocApiBatchData>* /*adapterResponseData*/)
DEFAULT_IMPL()
void LocApiBase::setBatchSize(size_t /*size*/)
DEFAULT_IMPL()
void LocApiBase::setTripBatchSize(size_t /*size*/)
DEFAULT_IMPL()
void LocApiBase::addToCallQueue(LocApiResponse* /*adapterResponse*/)
DEFAULT_IMPL()
} // namespace loc_core

315
gps/core/LocApiBase.h Normal file
View File

@@ -0,0 +1,315 @@
/* Copyright (c) 2011-2014, 2016-2019 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_API_BASE_H
#define LOC_API_BASE_H
#include <stddef.h>
#include <ctype.h>
#include <gps_extended.h>
#include <LocationAPI.h>
#include <MsgTask.h>
#include <LocSharedLock.h>
#include <log_util.h>
namespace loc_core {
class ContextBase;
struct LocApiResponse;
template <typename> struct LocApiResponseData;
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 MAX_FEATURE_LENGTH 100
#define TO_ALL_ADAPTERS(adapters, call) \
for (int i = 0; i < MAX_ADAPTERS && NULL != (adapters)[i]; i++) { \
call; \
}
#define TO_1ST_HANDLING_ADAPTER(adapters, call) \
for (int i = 0; i <MAX_ADAPTERS && NULL != (adapters)[i] && !(call); i++);
class LocAdapterBase;
struct LocSsrMsg;
struct LocOpenMsg;
typedef struct
{
uint32_t accumulatedDistance;
uint32_t numOfBatchedPositions;
} LocApiBatchData;
typedef struct
{
uint32_t hwId;
} LocApiGeofenceData;
struct LocApiMsg: LocMsg {
private:
std::function<void ()> mProcImpl;
inline virtual void proc() const {
mProcImpl();
}
public:
inline LocApiMsg(std::function<void ()> procImpl ) :
mProcImpl(procImpl) {}
};
class LocApiProxyBase {
public:
inline LocApiProxyBase() {}
inline virtual ~LocApiProxyBase() {}
inline virtual void* getSibling2() { return NULL; }
};
class LocApiBase {
friend struct LocSsrMsg;
//LocOpenMsg calls open() which makes it necessary to declare
//it as a friend
friend struct LocOpenMsg;
friend struct LocCloseMsg;
friend struct LocKillMsg;
friend class ContextBase;
static MsgTask* mMsgTask;
static volatile int32_t mMsgTaskRefCount;
LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
protected:
ContextBase *mContext;
virtual enum loc_api_adapter_err
open(LOC_API_ADAPTER_EVENT_MASK_T mask);
virtual enum loc_api_adapter_err
close();
LOC_API_ADAPTER_EVENT_MASK_T getEvtMask();
LOC_API_ADAPTER_EVENT_MASK_T mMask;
uint32_t mNmeaMask;
LocApiBase(LOC_API_ADAPTER_EVENT_MASK_T excludedMask,
ContextBase* context = NULL);
inline virtual ~LocApiBase() {
android_atomic_dec(&mMsgTaskRefCount);
if (nullptr != mMsgTask && 0 == mMsgTaskRefCount) {
mMsgTask->destroy();
mMsgTask = nullptr;
}
}
bool isInSession();
const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
bool isMaster();
public:
inline void sendMsg(const LocMsg* msg) const {
if (nullptr != mMsgTask) {
mMsgTask->sendMsg(msg);
}
}
inline void destroy() {
close();
struct LocKillMsg : public LocMsg {
LocApiBase* mLocApi;
inline LocKillMsg(LocApiBase* locApi) : LocMsg(), mLocApi(locApi) {}
inline virtual void proc() const {
delete mLocApi;
}
};
sendMsg(new LocKillMsg(this));
}
static bool needReport(const UlpLocation& ulpLocation,
enum loc_sess_status status,
LocPosTechMask techMask);
void addAdapter(LocAdapterBase* adapter);
void removeAdapter(LocAdapterBase* adapter);
// upward calls
void handleEngineUpEvent();
void handleEngineDownEvent();
void reportPosition(UlpLocation& location,
GpsLocationExtended& locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask =
LOC_POS_TECH_MASK_DEFAULT,
GnssDataNotification* pDataNotify = nullptr,
int msInWeek = -1);
void reportSv(GnssSvNotification& svNotify);
void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
void reportSvEphemeris(GnssSvEphemerisReport &svEphemeris);
void reportStatus(LocGpsStatusValue status);
void reportNmea(const char* nmea, int length);
void reportData(GnssDataNotification& dataNotify, int msInWeek);
void reportXtraServer(const char* url1, const char* url2,
const char* url3, const int maxlength);
void reportLocationSystemInfo(const LocationSystemInfo& locationSystemInfo);
void requestXtraData();
void requestTime();
void requestLocation();
void requestATL(int connHandle, LocAGpsType agps_type, LocApnTypeMask apn_type_mask);
void releaseATL(int connHandle);
void requestNiNotify(GnssNiNotification &notify, const void* data,
const LocInEmergency emergencyState);
void reportGnssMeasurements(GnssMeasurements& gnssMeasurements, int msInWeek);
void reportWwanZppFix(LocGpsLocation &zppLoc);
void reportZppBestAvailableFix(LocGpsLocation &zppLoc, GpsLocationExtended &location_extended,
LocPosTechMask tech_mask);
void reportGnssSvIdConfig(const GnssSvIdConfig& config);
void reportGnssSvTypeConfig(const GnssSvTypeConfig& config);
void requestOdcpi(OdcpiRequestInfo& request);
void reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot);
void reportDeleteAidingDataEvent(GnssAidingData& aidingData);
void reportKlobucharIonoModel(GnssKlobucharIonoModel& ionoModel);
void reportGnssAdditionalSystemInfo(GnssAdditionalSystemInfo& additionalSystemInfo);
void sendNfwNotification(GnssNfwNotification& notification);
void geofenceBreach(size_t count, uint32_t* hwIds, Location& location,
GeofenceBreachType breachType, uint64_t timestamp);
void geofenceStatus(GeofenceStatusAvailable available);
void reportDBTPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
enum loc_sess_status status,
LocPosTechMask loc_technology_mask);
void reportLocations(Location* locations, size_t count, BatchingMode batchingMode);
void reportCompletedTrips(uint32_t accumulated_distance);
void handleBatchStatusEvent(BatchingStatus batchStatus);
// downward calls
virtual void* getSibling();
virtual LocApiProxyBase* getLocApiProxy();
virtual void startFix(const LocPosMode& fixCriteria, LocApiResponse* adapterResponse);
virtual void stopFix(LocApiResponse* adapterResponse);
virtual void deleteAidingData(const GnssAidingData& data, LocApiResponse* adapterResponse);
virtual void injectPosition(double latitude, double longitude, float accuracy);
virtual void injectPosition(const GnssLocationInfoNotification &locationInfo,
bool onDemandCpi=false);
virtual void injectPosition(const Location& location, bool onDemandCpi);
virtual void setTime(LocGpsUtcTime time, int64_t timeReference, int uncertainty);
virtual enum loc_api_adapter_err setXtraData(char* data, int length);
virtual void atlOpenStatus(int handle, int is_succ, char* apn, uint32_t apnLen,
AGpsBearerType bear, LocAGpsType agpsType, LocApnTypeMask mask);
virtual void atlCloseStatus(int handle, int is_succ);
virtual LocationError setServerSync(const char* url, int len, LocServerType type);
virtual LocationError setServerSync(unsigned int ip, int port, LocServerType type);
virtual void informNiResponse(GnssNiResponse userResponse, const void* passThroughData);
virtual LocationError setSUPLVersionSync(GnssConfigSuplVersion version);
virtual enum loc_api_adapter_err setNMEATypesSync(uint32_t typesMask);
virtual LocationError setLPPConfigSync(GnssConfigLppProfile profile);
virtual enum loc_api_adapter_err setSensorPropertiesSync(
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 setSensorPerfControlConfigSync(int controlMode,
int accelSamplesPerBatch, int accelBatchesPerSec, int gyroSamplesPerBatch,
int gyroBatchesPerSec, int accelSamplesPerBatchHigh, int accelBatchesPerSecHigh,
int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh, int algorithmConfig);
virtual LocationError
setAGLONASSProtocolSync(GnssConfigAGlonassPositionProtocolMask aGlonassProtocol);
virtual LocationError setLPPeProtocolCpSync(GnssConfigLppeControlPlaneMask lppeCP);
virtual LocationError setLPPeProtocolUpSync(GnssConfigLppeUserPlaneMask lppeUP);
virtual GnssConfigSuplVersion convertSuplVersion(const uint32_t suplVersion);
virtual GnssConfigLppProfile convertLppProfile(const uint32_t lppProfile);
virtual GnssConfigLppeControlPlaneMask convertLppeCp(const uint32_t lppeControlPlaneMask);
virtual GnssConfigLppeUserPlaneMask convertLppeUp(const uint32_t lppeUserPlaneMask);
virtual LocationError setEmergencyExtensionWindowSync(const uint32_t emergencyExtensionSeconds);
virtual void getWwanZppFix();
virtual void getBestAvailableZppFix();
virtual void installAGpsCert(const LocDerEncodedCertificate* pData, size_t length,
uint32_t slotBitMask);
virtual LocationError setGpsLockSync(GnssConfigGpsLock lock);
virtual void requestForAidingData(GnssAidingDataSvMask svDataMask);
virtual LocationError setXtraVersionCheckSync(uint32_t check);
/* Requests for SV/Constellation Control */
virtual LocationError setBlacklistSvSync(const GnssSvIdConfig& config);
virtual void setBlacklistSv(const GnssSvIdConfig& config);
virtual void getBlacklistSv();
virtual void setConstellationControl(const GnssSvTypeConfig& config);
virtual void getConstellationControl();
virtual void resetConstellationControl();
virtual LocationError setConstrainedTuncMode(bool enabled, float tuncConstraint,
uint32_t energyBudget);
virtual LocationError setPositionAssistedClockEstimatorMode(bool enabled);
virtual LocationError getGnssEnergyConsumed();
virtual void addGeofence(uint32_t clientId, const GeofenceOption& options,
const GeofenceInfo& info, LocApiResponseData<LocApiGeofenceData>* adapterResponseData);
virtual void removeGeofence(uint32_t hwId, uint32_t clientId, LocApiResponse* adapterResponse);
virtual void pauseGeofence(uint32_t hwId, uint32_t clientId, LocApiResponse* adapterResponse);
virtual void resumeGeofence(uint32_t hwId, uint32_t clientId, LocApiResponse* adapterResponse);
virtual void modifyGeofence(uint32_t hwId, uint32_t clientId, const GeofenceOption& options,
LocApiResponse* adapterResponse);
virtual void startTimeBasedTracking(const TrackingOptions& options,
LocApiResponse* adapterResponse);
virtual void stopTimeBasedTracking(LocApiResponse* adapterResponse);
virtual void startDistanceBasedTracking(uint32_t sessionId, const LocationOptions& options,
LocApiResponse* adapterResponse);
virtual void stopDistanceBasedTracking(uint32_t sessionId,
LocApiResponse* adapterResponse = nullptr);
virtual void startBatching(uint32_t sessionId, const LocationOptions& options,
uint32_t accuracy, uint32_t timeout, LocApiResponse* adapterResponse);
virtual void stopBatching(uint32_t sessionId, LocApiResponse* adapterResponse);
virtual LocationError startOutdoorTripBatchingSync(uint32_t tripDistance,
uint32_t tripTbf, uint32_t timeout);
virtual void startOutdoorTripBatching(uint32_t tripDistance,
uint32_t tripTbf, uint32_t timeout, LocApiResponse* adapterResponse);
virtual void reStartOutdoorTripBatching(uint32_t ongoingTripDistance,
uint32_t ongoingTripInterval, uint32_t batchingTimeout,
LocApiResponse* adapterResponse);
virtual LocationError stopOutdoorTripBatchingSync(bool deallocBatchBuffer = true);
virtual void stopOutdoorTripBatching(bool deallocBatchBuffer = true,
LocApiResponse* adapterResponse = nullptr);
virtual LocationError getBatchedLocationsSync(size_t count);
virtual void getBatchedLocations(size_t count, LocApiResponse* adapterResponse);
virtual LocationError getBatchedTripLocationsSync(size_t count, uint32_t accumulatedDistance);
virtual void getBatchedTripLocations(size_t count, uint32_t accumulatedDistance,
LocApiResponse* adapterResponse);
virtual LocationError queryAccumulatedTripDistanceSync(uint32_t &accumulated_trip_distance,
uint32_t &numOfBatchedPositions);
virtual void queryAccumulatedTripDistance(
LocApiResponseData<LocApiBatchData>* adapterResponseData);
virtual void setBatchSize(size_t size);
virtual void setTripBatchSize(size_t size);
virtual void addToCallQueue(LocApiResponse* adapterResponse);
void updateEvtMask();
void updateNmeaMask(uint32_t mask);
};
typedef LocApiBase* (getLocApi_t)(LOC_API_ADAPTER_EVENT_MASK_T exMask,
ContextBase *context);
} // namespace loc_core
#endif //LOC_API_BASE_H

98
gps/core/LocContext.cpp Normal file
View File

@@ -0,0 +1,98 @@
/* Copyright (c) 2011-2014, 2016-2019 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_NDEBUG 0
#define LOG_TAG "LocSvc_Ctx"
#include <cutils/sched_policy.h>
#include <unistd.h>
#include <LocContext.h>
#include <msg_q.h>
#include <log_util.h>
#include <loc_log.h>
namespace loc_core {
const MsgTask* LocContext::mMsgTask = NULL;
ContextBase* LocContext::mContext = NULL;
// the name must be shorter than 15 chars
const char* LocContext::mLocationHalName = "Loc_hal_worker";
#ifndef USE_GLIB
const char* LocContext::mLBSLibName = "liblbs_core.so";
#else
const char* LocContext::mLBSLibName = "liblbs_core.so.1";
#endif
pthread_mutex_t LocContext::mGetLocContextMutex = PTHREAD_MUTEX_INITIALIZER;
const MsgTask* LocContext::getMsgTask(LocThread::tCreate tCreator,
const char* name, bool joinable)
{
if (NULL == mMsgTask) {
mMsgTask = new MsgTask(tCreator, name, joinable);
}
return mMsgTask;
}
inline
const MsgTask* LocContext::getMsgTask(const char* name, bool joinable) {
return getMsgTask((LocThread::tCreate)NULL, name, joinable);
}
ContextBase* LocContext::getLocContext(LocThread::tCreate tCreator,
LocMsg* firstMsg, const char* name, bool joinable)
{
pthread_mutex_lock(&LocContext::mGetLocContextMutex);
LOC_LOGD("%s:%d]: querying ContextBase with tCreator", __func__, __LINE__);
if (NULL == mContext) {
LOC_LOGD("%s:%d]: creating msgTask with tCreator", __func__, __LINE__);
const MsgTask* msgTask = getMsgTask(tCreator, name, joinable);
mContext = new LocContext(msgTask);
}
pthread_mutex_unlock(&LocContext::mGetLocContextMutex);
if (firstMsg) {
mContext->sendMsg(firstMsg);
}
return mContext;
}
void LocContext :: injectFeatureConfig(ContextBase *curContext)
{
LOC_LOGD("%s:%d]: Calling LBSProxy (%p) to inject feature config",
__func__, __LINE__, ((LocContext *)curContext)->mLBSProxy);
((LocContext *)curContext)->mLBSProxy->injectFeatureConfig(curContext);
}
LocContext::LocContext(const MsgTask* msgTask) :
ContextBase(msgTask, 0, mLBSLibName)
{
}
}

66
gps/core/LocContext.h Normal file
View File

@@ -0,0 +1,66 @@
/* Copyright (c) 2011-2014, 2017-2019 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__
#define __LOC_CONTEXT__
#include <stdbool.h>
#include <ctype.h>
#include <dlfcn.h>
#include <ContextBase.h>
namespace loc_core {
class LocContext : public ContextBase {
static const MsgTask* mMsgTask;
static ContextBase* mContext;
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:
LocContext(const MsgTask* msgTask);
inline virtual ~LocContext() {}
public:
static const char* mLBSLibName;
static const char* mLocationHalName;
static ContextBase* getLocContext(LocThread::tCreate tCreator, LocMsg* firstMsg,
const char* name, bool joinable = true);
inline static ContextBase* getLocContext(const char* name, bool joinable = true) {
return getLocContext(NULL, NULL, name, joinable);
}
static void injectFeatureConfig(ContextBase *context);
};
}
#endif //__LOC_CONTEXT__

70
gps/core/Makefile.am Normal file
View File

@@ -0,0 +1,70 @@
ACLOCAL_AMFLAGS = -I m4
AM_CFLAGS = -I./ \
$(LOCPLA_CFLAGS) \
$(GPSUTILS_CFLAGS) \
-I./data-items/ \
-I./data-items/common \
-I./observer \
-I$(WORKSPACE)/gps-noship/flp \
-D__func__=__PRETTY_FUNCTION__ \
-fno-short-enums \
-std=c++11
libloc_core_la_h_sources = \
LocApiBase.h \
LocAdapterBase.h \
ContextBase.h \
LocContext.h \
LBSProxyBase.h \
loc_core_log.h \
LocAdapterProxyBase.h \
EngineHubProxyBase.h \
data-items/DataItemId.h \
data-items/IDataItemCore.h \
data-items/DataItemConcreteTypesBase.h \
observer/IDataItemObserver.h \
observer/IDataItemSubscription.h \
observer/IFrameworkActionReq.h \
observer/IOsObserver.h \
SystemStatusOsObserver.h \
SystemStatus.h
libloc_core_la_c_sources = \
LocApiBase.cpp \
LocAdapterBase.cpp \
ContextBase.cpp \
LocContext.cpp \
loc_core_log.cpp \
data-items/DataItemsFactoryProxy.cpp \
SystemStatusOsObserver.cpp \
SystemStatus.cpp
library_includedir = $(pkgincludedir)
library_include_HEADERS = $(libloc_core_la_h_sources)
libloc_core_la_SOURCES = $(libloc_core_la_c_sources)
if USE_GLIB
libloc_core_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_core_la_LDFLAGS = -lstdc++ -Wl,-z,defs -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_core_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_core_la_CFLAGS = $(AM_CFLAGS)
libloc_core_la_LDFLAGS = -Wl,-z,defs -lpthread -shared -version-info 1:0:0
libloc_core_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
if USE_FEATURE_AUTOMOTIVE
AM_CFLAGS += -DFEATURE_AUTOMOTIVE
endif
libloc_core_la_LIBADD = -ldl $(GPSUTILS_LIBS)
#Create and Install libraries
lib_LTLIBRARIES = libloc_core.la
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = loc-core.pc
EXTRA_DIST = $(pkgconfig_DATA)

1748
gps/core/SystemStatus.cpp Normal file

File diff suppressed because it is too large Load Diff

916
gps/core/SystemStatus.h Normal file
View File

@@ -0,0 +1,916 @@
/* Copyright (c) 2017-2019, 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 __SYSTEM_STATUS__
#define __SYSTEM_STATUS__
#include <stdint.h>
#include <sys/time.h>
#include <vector>
#include <algorithm>
#include <iterator>
#include <loc_pla.h>
#include <log_util.h>
#include <MsgTask.h>
#include <IDataItemCore.h>
#include <IOsObserver.h>
#include <DataItemConcreteTypesBase.h>
#include <SystemStatusOsObserver.h>
#include <gps_extended_c.h>
#define GPS_MIN (1) //1-32
#define SBAS_MIN (33)
#define GLO_MIN (65) //65-88
#define QZSS_MIN (193) //193-197
#define BDS_MIN (201) //201-237
#define GAL_MIN (301) //301-336
#define NAVIC_MIN (401) //401-414
#define GPS_NUM (32)
#define SBAS_NUM (32)
#define GLO_NUM (24)
#define QZSS_NUM (5)
#define BDS_NUM (37)
#define GAL_NUM (36)
#define NAVIC_NUM (14)
#define SV_ALL_NUM_MIN (GPS_NUM + GLO_NUM + QZSS_NUM + BDS_NUM + GAL_NUM) //=134
#define SV_ALL_NUM (SV_ALL_NUM_MIN + NAVIC_NUM) //=148
namespace loc_core
{
/******************************************************************************
SystemStatus report data structure
******************************************************************************/
class SystemStatusItemBase
{
public:
timespec mUtcTime;
timespec mUtcReported;
static const uint32_t maxItem = 5;
SystemStatusItemBase() {
timeval tv;
gettimeofday(&tv, NULL);
mUtcTime.tv_sec = tv.tv_sec;
mUtcTime.tv_nsec = tv.tv_usec*1000ULL;
mUtcReported = mUtcTime;
};
virtual ~SystemStatusItemBase() {};
inline virtual SystemStatusItemBase& collate(SystemStatusItemBase&) {
return *this;
}
virtual void dump(void) {};
};
class SystemStatusLocation : public SystemStatusItemBase
{
public:
bool mValid;
UlpLocation mLocation;
GpsLocationExtended mLocationEx;
inline SystemStatusLocation() :
mValid(false) {}
inline SystemStatusLocation(const UlpLocation& location,
const GpsLocationExtended& locationEx) :
mValid(true),
mLocation(location),
mLocationEx(locationEx) {}
bool equals(const SystemStatusLocation& peer);
void dump(void);
};
class SystemStatusPQWM1;
class SystemStatusTimeAndClock : public SystemStatusItemBase
{
public:
uint16_t mGpsWeek;
uint32_t mGpsTowMs;
uint8_t mTimeValid;
uint8_t mTimeSource;
int32_t mTimeUnc;
int32_t mClockFreqBias;
int32_t mClockFreqBiasUnc;
int32_t mLeapSeconds;
int32_t mLeapSecUnc;
uint64_t mTimeUncNs;
inline SystemStatusTimeAndClock() :
mGpsWeek(0),
mGpsTowMs(0),
mTimeValid(0),
mTimeSource(0),
mTimeUnc(0),
mClockFreqBias(0),
mClockFreqBiasUnc(0),
mLeapSeconds(0),
mLeapSecUnc(0),
mTimeUncNs(0ULL) {}
inline SystemStatusTimeAndClock(const SystemStatusPQWM1& nmea);
bool equals(const SystemStatusTimeAndClock& peer);
void dump(void);
};
class SystemStatusXoState : public SystemStatusItemBase
{
public:
uint8_t mXoState;
inline SystemStatusXoState() :
mXoState(0) {}
inline SystemStatusXoState(const SystemStatusPQWM1& nmea);
bool equals(const SystemStatusXoState& peer);
void dump(void);
};
class SystemStatusRfAndParams : public SystemStatusItemBase
{
public:
int32_t mPgaGain;
uint32_t mGpsBpAmpI;
uint32_t mGpsBpAmpQ;
uint32_t mAdcI;
uint32_t mAdcQ;
uint32_t mJammerGps;
uint32_t mJammerGlo;
uint32_t mJammerBds;
uint32_t mJammerGal;
double mAgcGps;
double mAgcGlo;
double mAgcBds;
double mAgcGal;
uint32_t mGloBpAmpI;
uint32_t mGloBpAmpQ;
uint32_t mBdsBpAmpI;
uint32_t mBdsBpAmpQ;
uint32_t mGalBpAmpI;
uint32_t mGalBpAmpQ;
inline SystemStatusRfAndParams() :
mPgaGain(0),
mGpsBpAmpI(0),
mGpsBpAmpQ(0),
mAdcI(0),
mAdcQ(0),
mJammerGps(0),
mJammerGlo(0),
mJammerBds(0),
mJammerGal(0),
mAgcGps(0),
mAgcGlo(0),
mAgcBds(0),
mAgcGal(0),
mGloBpAmpI(0),
mGloBpAmpQ(0),
mBdsBpAmpI(0),
mBdsBpAmpQ(0),
mGalBpAmpI(0),
mGalBpAmpQ(0) {}
inline SystemStatusRfAndParams(const SystemStatusPQWM1& nmea);
bool equals(const SystemStatusRfAndParams& peer);
void dump(void);
};
class SystemStatusErrRecovery : public SystemStatusItemBase
{
public:
uint32_t mRecErrorRecovery;
inline SystemStatusErrRecovery() :
mRecErrorRecovery(0) {};
inline SystemStatusErrRecovery(const SystemStatusPQWM1& nmea);
bool equals(const SystemStatusErrRecovery& peer);
void dump(void);
};
class SystemStatusPQWP1;
class SystemStatusInjectedPosition : public SystemStatusItemBase
{
public:
uint8_t mEpiValidity;
float mEpiLat;
float mEpiLon;
float mEpiAlt;
float mEpiHepe;
float mEpiAltUnc;
uint8_t mEpiSrc;
inline SystemStatusInjectedPosition() :
mEpiValidity(0),
mEpiLat(0),
mEpiLon(0),
mEpiAlt(0),
mEpiHepe(0),
mEpiAltUnc(0),
mEpiSrc(0) {}
inline SystemStatusInjectedPosition(const SystemStatusPQWP1& nmea);
bool equals(const SystemStatusInjectedPosition& peer);
void dump(void);
};
class SystemStatusPQWP2;
class SystemStatusBestPosition : public SystemStatusItemBase
{
public:
bool mValid;
float mBestLat;
float mBestLon;
float mBestAlt;
float mBestHepe;
float mBestAltUnc;
inline SystemStatusBestPosition() :
mValid(false),
mBestLat(0),
mBestLon(0),
mBestAlt(0),
mBestHepe(0),
mBestAltUnc(0) {}
inline SystemStatusBestPosition(const SystemStatusPQWP2& nmea);
bool equals(const SystemStatusBestPosition& peer);
void dump(void);
};
class SystemStatusPQWP3;
class SystemStatusXtra : public SystemStatusItemBase
{
public:
uint8_t mXtraValidMask;
uint32_t mGpsXtraAge;
uint32_t mGloXtraAge;
uint32_t mBdsXtraAge;
uint32_t mGalXtraAge;
uint32_t mQzssXtraAge;
uint32_t mNavicXtraAge;
uint32_t mGpsXtraValid;
uint32_t mGloXtraValid;
uint64_t mBdsXtraValid;
uint64_t mGalXtraValid;
uint8_t mQzssXtraValid;
uint32_t mNavicXtraValid;
inline SystemStatusXtra() :
mXtraValidMask(0),
mGpsXtraAge(0),
mGloXtraAge(0),
mBdsXtraAge(0),
mGalXtraAge(0),
mQzssXtraAge(0),
mNavicXtraAge(0),
mGpsXtraValid(0),
mGloXtraValid(0),
mBdsXtraValid(0ULL),
mGalXtraValid(0ULL),
mQzssXtraValid(0),
mNavicXtraValid(0) {}
inline SystemStatusXtra(const SystemStatusPQWP3& nmea);
bool equals(const SystemStatusXtra& peer);
void dump(void);
};
class SystemStatusPQWP4;
class SystemStatusEphemeris : public SystemStatusItemBase
{
public:
uint32_t mGpsEpheValid;
uint32_t mGloEpheValid;
uint64_t mBdsEpheValid;
uint64_t mGalEpheValid;
uint8_t mQzssEpheValid;
inline SystemStatusEphemeris() :
mGpsEpheValid(0),
mGloEpheValid(0),
mBdsEpheValid(0ULL),
mGalEpheValid(0ULL),
mQzssEpheValid(0) {}
inline SystemStatusEphemeris(const SystemStatusPQWP4& nmea);
bool equals(const SystemStatusEphemeris& peer);
void dump(void);
};
class SystemStatusPQWP5;
class SystemStatusSvHealth : public SystemStatusItemBase
{
public:
uint32_t mGpsUnknownMask;
uint32_t mGloUnknownMask;
uint64_t mBdsUnknownMask;
uint64_t mGalUnknownMask;
uint8_t mQzssUnknownMask;
uint32_t mNavicUnknownMask;
uint32_t mGpsGoodMask;
uint32_t mGloGoodMask;
uint64_t mBdsGoodMask;
uint64_t mGalGoodMask;
uint8_t mQzssGoodMask;
uint32_t mNavicGoodMask;
uint32_t mGpsBadMask;
uint32_t mGloBadMask;
uint64_t mBdsBadMask;
uint64_t mGalBadMask;
uint8_t mQzssBadMask;
uint32_t mNavicBadMask;
inline SystemStatusSvHealth() :
mGpsUnknownMask(0),
mGloUnknownMask(0),
mBdsUnknownMask(0ULL),
mGalUnknownMask(0ULL),
mQzssUnknownMask(0),
mNavicUnknownMask(0),
mGpsGoodMask(0),
mGloGoodMask(0),
mBdsGoodMask(0ULL),
mGalGoodMask(0ULL),
mQzssGoodMask(0),
mNavicGoodMask(0),
mGpsBadMask(0),
mGloBadMask(0),
mBdsBadMask(0ULL),
mGalBadMask(0ULL),
mQzssBadMask(0),
mNavicBadMask(0) {}
inline SystemStatusSvHealth(const SystemStatusPQWP5& nmea);
bool equals(const SystemStatusSvHealth& peer);
void dump(void);
};
class SystemStatusPQWP6;
class SystemStatusPdr : public SystemStatusItemBase
{
public:
uint32_t mFixInfoMask;
inline SystemStatusPdr() :
mFixInfoMask(0) {}
inline SystemStatusPdr(const SystemStatusPQWP6& nmea);
bool equals(const SystemStatusPdr& peer);
void dump(void);
};
class SystemStatusPQWP7;
struct SystemStatusNav
{
GnssEphemerisType mType;
GnssEphemerisSource mSource;
int32_t mAgeSec;
};
class SystemStatusNavData : public SystemStatusItemBase
{
public:
SystemStatusNav mNav[SV_ALL_NUM];
inline SystemStatusNavData() {
for (uint32_t i=0; i<SV_ALL_NUM; i++) {
mNav[i].mType = GNSS_EPH_TYPE_UNKNOWN;
mNav[i].mSource = GNSS_EPH_SOURCE_UNKNOWN;
mNav[i].mAgeSec = 0;
}
}
inline SystemStatusNavData(const SystemStatusPQWP7& nmea);
bool equals(const SystemStatusNavData& peer);
void dump(void);
};
class SystemStatusPQWS1;
class SystemStatusPositionFailure : public SystemStatusItemBase
{
public:
uint32_t mFixInfoMask;
uint32_t mHepeLimit;
inline SystemStatusPositionFailure() :
mFixInfoMask(0),
mHepeLimit(0) {}
inline SystemStatusPositionFailure(const SystemStatusPQWS1& nmea);
bool equals(const SystemStatusPositionFailure& peer);
void dump(void);
};
/******************************************************************************
SystemStatus report data structure - from DataItem observer
******************************************************************************/
class SystemStatusAirplaneMode : public SystemStatusItemBase,
public AirplaneModeDataItemBase
{
public:
inline SystemStatusAirplaneMode(bool mode=false) :
AirplaneModeDataItemBase(mode) {}
inline SystemStatusAirplaneMode(const AirplaneModeDataItemBase& itemBase) :
AirplaneModeDataItemBase(itemBase) {}
inline bool equals(const SystemStatusAirplaneMode& peer) {
return (mMode == peer.mMode);
}
};
class SystemStatusENH : public SystemStatusItemBase,
public ENHDataItemBase
{
public:
inline SystemStatusENH(bool enabled=false) :
ENHDataItemBase(enabled) {}
inline SystemStatusENH(const ENHDataItemBase& itemBase) :
ENHDataItemBase(itemBase) {}
inline bool equals(const SystemStatusENH& peer) {
return (mEnabled == peer.mEnabled);
}
};
class SystemStatusGpsState : public SystemStatusItemBase,
public GPSStateDataItemBase
{
public:
inline SystemStatusGpsState(bool enabled=false) :
GPSStateDataItemBase(enabled) {}
inline SystemStatusGpsState(const GPSStateDataItemBase& itemBase) :
GPSStateDataItemBase(itemBase) {}
inline bool equals(const SystemStatusGpsState& peer) {
return (mEnabled == peer.mEnabled);
}
inline void dump(void) override {
LOC_LOGD("GpsState: state=%u", mEnabled);
}
};
class SystemStatusNLPStatus : public SystemStatusItemBase,
public NLPStatusDataItemBase
{
public:
inline SystemStatusNLPStatus(bool enabled=false) :
NLPStatusDataItemBase(enabled) {}
inline SystemStatusNLPStatus(const NLPStatusDataItemBase& itemBase) :
NLPStatusDataItemBase(itemBase) {}
inline bool equals(const SystemStatusNLPStatus& peer) {
return (mEnabled == peer.mEnabled);
}
};
class SystemStatusWifiHardwareState : public SystemStatusItemBase,
public WifiHardwareStateDataItemBase
{
public:
inline SystemStatusWifiHardwareState(bool enabled=false) :
WifiHardwareStateDataItemBase(enabled) {}
inline SystemStatusWifiHardwareState(const WifiHardwareStateDataItemBase& itemBase) :
WifiHardwareStateDataItemBase(itemBase) {}
inline bool equals(const SystemStatusWifiHardwareState& peer) {
return (mEnabled == peer.mEnabled);
}
};
class SystemStatusNetworkInfo : public SystemStatusItemBase,
public NetworkInfoDataItemBase
{
NetworkInfoDataItemBase* mSrcObjPtr;
public:
inline SystemStatusNetworkInfo(
int32_t type=0,
std::string typeName="",
string subTypeName="",
bool connected=false,
bool roaming=false,
uint64_t networkHandle=NETWORK_HANDLE_UNKNOWN) :
NetworkInfoDataItemBase(
(NetworkType)type,
type,
typeName,
subTypeName,
connected && (!roaming),
connected,
roaming,
networkHandle),
mSrcObjPtr(nullptr) {}
inline SystemStatusNetworkInfo(const NetworkInfoDataItemBase& itemBase) :
NetworkInfoDataItemBase(itemBase),
mSrcObjPtr((NetworkInfoDataItemBase*)&itemBase) {
mType = itemBase.getType();
}
inline bool equals(const SystemStatusNetworkInfo& peer) {
for (uint8_t i = 0; i < MAX_NETWORK_HANDLES; ++i) {
if (!(mAllNetworkHandles[i] == peer.mAllNetworkHandles[i])) {
return false;
}
}
return true;
}
inline virtual SystemStatusItemBase& collate(SystemStatusItemBase& curInfo) {
uint64_t allTypes = (static_cast<SystemStatusNetworkInfo&>(curInfo)).mAllTypes;
uint64_t networkHandle =
(static_cast<SystemStatusNetworkInfo&>(curInfo)).mNetworkHandle;
int32_t type = (static_cast<SystemStatusNetworkInfo&>(curInfo)).mType;
// Replace current with cached table for now and then update
memcpy(mAllNetworkHandles,
(static_cast<SystemStatusNetworkInfo&>(curInfo)).getNetworkHandle(),
sizeof(mAllNetworkHandles));
if (mConnected) {
mAllTypes |= allTypes;
for (uint8_t i = 0; i < MAX_NETWORK_HANDLES; ++i) {
if (mNetworkHandle == mAllNetworkHandles[i].networkHandle) {
LOC_LOGD("collate duplicate detected, not updating");
break;
}
if (NETWORK_HANDLE_UNKNOWN == mAllNetworkHandles[i].networkHandle) {
mAllNetworkHandles[i].networkHandle = mNetworkHandle;
mAllNetworkHandles[i].networkType = (loc_core::NetworkType) mType;
break;
}
}
} else if (0 != mAllTypes) {
uint8_t deletedIndex = MAX_NETWORK_HANDLES;
uint8_t lastValidIndex = 0;
uint8_t typeCount = 0;
for (; lastValidIndex < MAX_NETWORK_HANDLES &&
NETWORK_HANDLE_UNKNOWN != mAllNetworkHandles[lastValidIndex].networkHandle;
++lastValidIndex) {
// Maintain count for number of network handles still
// connected for given type
if (mType == mAllNetworkHandles[lastValidIndex].networkType) {
typeCount++;
}
if (mNetworkHandle == mAllNetworkHandles[lastValidIndex].networkHandle) {
deletedIndex = lastValidIndex;
typeCount--;
}
}
if (MAX_NETWORK_HANDLES != deletedIndex) {
LOC_LOGD("deletedIndex:%u, lastValidIndex:%u, typeCount:%u",
deletedIndex, lastValidIndex, typeCount);
mAllNetworkHandles[deletedIndex] = mAllNetworkHandles[lastValidIndex];
mAllNetworkHandles[lastValidIndex].networkHandle = NETWORK_HANDLE_UNKNOWN;
mAllNetworkHandles[lastValidIndex].networkType = TYPE_UNKNOWN;
}
// If no more handles of given type, set bitmask
if (0 == typeCount) {
mAllTypes = (allTypes & (~mAllTypes));
LOC_LOGD("mAllTypes:%" PRIx64, mAllTypes);
}
} // else (mConnected == false && mAllTypes == 0)
// we keep mAllTypes as 0, which means no more connections.
if (nullptr != mSrcObjPtr) {
// this is critical, changing mAllTypes of the original obj
mSrcObjPtr->mAllTypes = mAllTypes;
memcpy(mSrcObjPtr->mAllNetworkHandles,
mAllNetworkHandles,
sizeof(mSrcObjPtr->mAllNetworkHandles));
}
return *this;
}
inline void dump(void) override {
LOC_LOGD("NetworkInfo: mAllTypes=%" PRIx64 " connected=%u mType=%x",
mAllTypes, mConnected, mType);
}
};
class SystemStatusServiceInfo : public SystemStatusItemBase,
public RilServiceInfoDataItemBase
{
public:
inline SystemStatusServiceInfo() :
RilServiceInfoDataItemBase() {}
inline SystemStatusServiceInfo(const RilServiceInfoDataItemBase& itemBase) :
RilServiceInfoDataItemBase(itemBase) {}
inline bool equals(const SystemStatusServiceInfo& peer) {
return static_cast<const RilServiceInfoDataItemBase&>(peer) ==
static_cast<const RilServiceInfoDataItemBase&>(*this);
}
};
class SystemStatusRilCellInfo : public SystemStatusItemBase,
public RilCellInfoDataItemBase
{
public:
inline SystemStatusRilCellInfo() :
RilCellInfoDataItemBase() {}
inline SystemStatusRilCellInfo(const RilCellInfoDataItemBase& itemBase) :
RilCellInfoDataItemBase(itemBase) {}
inline bool equals(const SystemStatusRilCellInfo& peer) {
return static_cast<const RilCellInfoDataItemBase&>(peer) ==
static_cast<const RilCellInfoDataItemBase&>(*this);
}
};
class SystemStatusServiceStatus : public SystemStatusItemBase,
public ServiceStatusDataItemBase
{
public:
inline SystemStatusServiceStatus(int32_t mServiceState=0) :
ServiceStatusDataItemBase(mServiceState) {}
inline SystemStatusServiceStatus(const ServiceStatusDataItemBase& itemBase) :
ServiceStatusDataItemBase(itemBase) {}
inline bool equals(const SystemStatusServiceStatus& peer) {
return (mServiceState == peer.mServiceState);
}
};
class SystemStatusModel : public SystemStatusItemBase,
public ModelDataItemBase
{
public:
inline SystemStatusModel(string name="") :
ModelDataItemBase(name) {}
inline SystemStatusModel(const ModelDataItemBase& itemBase) :
ModelDataItemBase(itemBase) {}
inline bool equals(const SystemStatusModel& peer) {
return (mModel == peer.mModel);
}
};
class SystemStatusManufacturer : public SystemStatusItemBase,
public ManufacturerDataItemBase
{
public:
inline SystemStatusManufacturer(string name="") :
ManufacturerDataItemBase(name) {}
inline SystemStatusManufacturer(const ManufacturerDataItemBase& itemBase) :
ManufacturerDataItemBase(itemBase) {}
inline bool equals(const SystemStatusManufacturer& peer) {
return (mManufacturer == peer.mManufacturer);
}
};
class SystemStatusAssistedGps : public SystemStatusItemBase,
public AssistedGpsDataItemBase
{
public:
inline SystemStatusAssistedGps(bool enabled=false) :
AssistedGpsDataItemBase(enabled) {}
inline SystemStatusAssistedGps(const AssistedGpsDataItemBase& itemBase) :
AssistedGpsDataItemBase(itemBase) {}
inline bool equals(const SystemStatusAssistedGps& peer) {
return (mEnabled == peer.mEnabled);
}
};
class SystemStatusScreenState : public SystemStatusItemBase,
public ScreenStateDataItemBase
{
public:
inline SystemStatusScreenState(bool state=false) :
ScreenStateDataItemBase(state) {}
inline SystemStatusScreenState(const ScreenStateDataItemBase& itemBase) :
ScreenStateDataItemBase(itemBase) {}
inline bool equals(const SystemStatusScreenState& peer) {
return (mState == peer.mState);
}
};
class SystemStatusPowerConnectState : public SystemStatusItemBase,
public PowerConnectStateDataItemBase
{
public:
inline SystemStatusPowerConnectState(bool state=false) :
PowerConnectStateDataItemBase(state) {}
inline SystemStatusPowerConnectState(const PowerConnectStateDataItemBase& itemBase) :
PowerConnectStateDataItemBase(itemBase) {}
inline bool equals(const SystemStatusPowerConnectState& peer) {
return (mState == peer.mState);
}
};
class SystemStatusTimeZoneChange : public SystemStatusItemBase,
public TimeZoneChangeDataItemBase
{
public:
inline SystemStatusTimeZoneChange(
int64_t currTimeMillis=0ULL, int32_t rawOffset=0, int32_t dstOffset=0) :
TimeZoneChangeDataItemBase(currTimeMillis, rawOffset, dstOffset) {}
inline SystemStatusTimeZoneChange(const TimeZoneChangeDataItemBase& itemBase) :
TimeZoneChangeDataItemBase(itemBase) {}
inline bool equals(const SystemStatusTimeZoneChange& peer) {
return ((mCurrTimeMillis == peer.mCurrTimeMillis) &&
(mRawOffsetTZ == peer.mRawOffsetTZ) &&
(mDstOffsetTZ == peer.mDstOffsetTZ));
}
};
class SystemStatusTimeChange : public SystemStatusItemBase,
public TimeChangeDataItemBase
{
public:
inline SystemStatusTimeChange(
int64_t currTimeMillis=0ULL, int32_t rawOffset=0, int32_t dstOffset=0) :
TimeChangeDataItemBase(currTimeMillis, rawOffset, dstOffset) {}
inline SystemStatusTimeChange(const TimeChangeDataItemBase& itemBase) :
TimeChangeDataItemBase(itemBase) {}
inline bool equals(const SystemStatusTimeChange& peer) {
return ((mCurrTimeMillis == peer.mCurrTimeMillis) &&
(mRawOffsetTZ == peer.mRawOffsetTZ) &&
(mDstOffsetTZ == peer.mDstOffsetTZ));
}
};
class SystemStatusWifiSupplicantStatus : public SystemStatusItemBase,
public WifiSupplicantStatusDataItemBase
{
public:
inline SystemStatusWifiSupplicantStatus() :
WifiSupplicantStatusDataItemBase() {}
inline SystemStatusWifiSupplicantStatus(const WifiSupplicantStatusDataItemBase& itemBase) :
WifiSupplicantStatusDataItemBase(itemBase) {}
inline bool equals(const SystemStatusWifiSupplicantStatus& peer) {
return ((mState == peer.mState) &&
(mApMacAddressValid == peer.mApMacAddressValid) &&
(mWifiApSsidValid == peer.mWifiApSsidValid) &&
(mWifiApSsid == peer.mWifiApSsid));
}
};
class SystemStatusShutdownState : public SystemStatusItemBase,
public ShutdownStateDataItemBase
{
public:
inline SystemStatusShutdownState(bool state=false) :
ShutdownStateDataItemBase(state) {}
inline SystemStatusShutdownState(const ShutdownStateDataItemBase& itemBase) :
ShutdownStateDataItemBase(itemBase) {}
inline bool equals(const SystemStatusShutdownState& peer) {
return (mState == peer.mState);
}
};
class SystemStatusTac : public SystemStatusItemBase,
public TacDataItemBase
{
public:
inline SystemStatusTac(std::string value="") :
TacDataItemBase(value) {}
inline SystemStatusTac(const TacDataItemBase& itemBase) :
TacDataItemBase(itemBase) {}
inline bool equals(const SystemStatusTac& peer) {
return (mValue == peer.mValue);
}
inline void dump(void) {
LOC_LOGD("Tac: value=%s", mValue.c_str());
}
};
class SystemStatusMccMnc : public SystemStatusItemBase,
public MccmncDataItemBase
{
public:
inline SystemStatusMccMnc(std::string value="") :
MccmncDataItemBase(value) {}
inline SystemStatusMccMnc(const MccmncDataItemBase& itemBase) :
MccmncDataItemBase(itemBase) {}
inline bool equals(const SystemStatusMccMnc& peer) {
return (mValue == peer.mValue);
}
inline void dump(void) {
LOC_LOGD("TacMccMnc value=%s", mValue.c_str());
}
};
class SystemStatusBtDeviceScanDetail : public SystemStatusItemBase,
public BtDeviceScanDetailsDataItemBase
{
public:
inline SystemStatusBtDeviceScanDetail() :
BtDeviceScanDetailsDataItemBase() {}
inline SystemStatusBtDeviceScanDetail(const BtDeviceScanDetailsDataItemBase& itemBase) :
BtDeviceScanDetailsDataItemBase(itemBase) {}
inline bool equals(const SystemStatusBtDeviceScanDetail& peer) {
return ((mApSrnRssi == peer.mApSrnRssi) &&
(0 == memcmp(mApSrnMacAddress, peer.mApSrnMacAddress, sizeof(mApSrnMacAddress))) &&
(mApSrnTimestamp == peer.mApSrnTimestamp) &&
(mRequestTimestamp == peer.mRequestTimestamp) &&
(mReceiveTimestamp == peer.mReceiveTimestamp));
}
};
class SystemStatusBtleDeviceScanDetail : public SystemStatusItemBase,
public BtLeDeviceScanDetailsDataItemBase
{
public:
inline SystemStatusBtleDeviceScanDetail() :
BtLeDeviceScanDetailsDataItemBase() {}
inline SystemStatusBtleDeviceScanDetail(const BtLeDeviceScanDetailsDataItemBase& itemBase) :
BtLeDeviceScanDetailsDataItemBase(itemBase) {}
inline bool equals(const SystemStatusBtleDeviceScanDetail& peer) {
return ((mApSrnRssi == peer.mApSrnRssi) &&
(0 == memcmp(mApSrnMacAddress, peer.mApSrnMacAddress, sizeof(mApSrnMacAddress))) &&
(mApSrnTimestamp == peer.mApSrnTimestamp) &&
(mRequestTimestamp == peer.mRequestTimestamp) &&
(mReceiveTimestamp == peer.mReceiveTimestamp));
}
};
/******************************************************************************
SystemStatusReports
******************************************************************************/
class SystemStatusReports
{
public:
// from QMI_LOC indication
std::vector<SystemStatusLocation> mLocation;
// from ME debug NMEA
std::vector<SystemStatusTimeAndClock> mTimeAndClock;
std::vector<SystemStatusXoState> mXoState;
std::vector<SystemStatusRfAndParams> mRfAndParams;
std::vector<SystemStatusErrRecovery> mErrRecovery;
// from PE debug NMEA
std::vector<SystemStatusInjectedPosition> mInjectedPosition;
std::vector<SystemStatusBestPosition> mBestPosition;
std::vector<SystemStatusXtra> mXtra;
std::vector<SystemStatusEphemeris> mEphemeris;
std::vector<SystemStatusSvHealth> mSvHealth;
std::vector<SystemStatusPdr> mPdr;
std::vector<SystemStatusNavData> mNavData;
// from SM debug NMEA
std::vector<SystemStatusPositionFailure> mPositionFailure;
// from dataitems observer
std::vector<SystemStatusAirplaneMode> mAirplaneMode;
std::vector<SystemStatusENH> mENH;
std::vector<SystemStatusGpsState> mGPSState;
std::vector<SystemStatusNLPStatus> mNLPStatus;
std::vector<SystemStatusWifiHardwareState> mWifiHardwareState;
std::vector<SystemStatusNetworkInfo> mNetworkInfo;
std::vector<SystemStatusServiceInfo> mRilServiceInfo;
std::vector<SystemStatusRilCellInfo> mRilCellInfo;
std::vector<SystemStatusServiceStatus> mServiceStatus;
std::vector<SystemStatusModel> mModel;
std::vector<SystemStatusManufacturer> mManufacturer;
std::vector<SystemStatusAssistedGps> mAssistedGps;
std::vector<SystemStatusScreenState> mScreenState;
std::vector<SystemStatusPowerConnectState> mPowerConnectState;
std::vector<SystemStatusTimeZoneChange> mTimeZoneChange;
std::vector<SystemStatusTimeChange> mTimeChange;
std::vector<SystemStatusWifiSupplicantStatus> mWifiSupplicantStatus;
std::vector<SystemStatusShutdownState> mShutdownState;
std::vector<SystemStatusTac> mTac;
std::vector<SystemStatusMccMnc> mMccMnc;
std::vector<SystemStatusBtDeviceScanDetail> mBtDeviceScanDetail;
std::vector<SystemStatusBtleDeviceScanDetail> mBtLeDeviceScanDetail;
};
/******************************************************************************
SystemStatus
******************************************************************************/
class SystemStatus
{
private:
static SystemStatus *mInstance;
SystemStatusOsObserver mSysStatusObsvr;
// ctor
SystemStatus(const MsgTask* msgTask);
// dtor
inline ~SystemStatus() {}
// Data members
static pthread_mutex_t mMutexSystemStatus;
SystemStatusReports mCache;
template <typename TYPE_REPORT, typename TYPE_ITEM>
bool setIteminReport(TYPE_REPORT& report, TYPE_ITEM&& s);
// set default dataitem derived item in report cache
template <typename TYPE_REPORT, typename TYPE_ITEM>
void setDefaultIteminReport(TYPE_REPORT& report, const TYPE_ITEM& s);
template <typename TYPE_REPORT, typename TYPE_ITEM>
void getIteminReport(TYPE_REPORT& reportout, const TYPE_ITEM& c) const;
public:
// Static methods
static SystemStatus* getInstance(const MsgTask* msgTask);
static void destroyInstance();
IOsObserver* getOsObserver();
// Helpers
bool eventPosition(const UlpLocation& location,const GpsLocationExtended& locationEx);
bool eventDataItemNotify(IDataItemCore* dataitem);
bool setNmeaString(const char *data, uint32_t len);
bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const;
bool setDefaultGnssEngineStates(void);
bool eventConnectionStatus(bool connected, int8_t type,
bool roaming, NetworkHandle networkHandle);
bool updatePowerConnectState(bool charging);
};
} // namespace loc_core
#endif //__SYSTEM_STATUS__

View File

@@ -0,0 +1,575 @@
/* Copyright (c) 2015-2017, 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_TAG "LocSvc_SystemStatusOsObserver"
#include <algorithm>
#include <SystemStatus.h>
#include <SystemStatusOsObserver.h>
#include <IDataItemCore.h>
#include <DataItemsFactoryProxy.h>
namespace loc_core
{
template <typename CINT, typename COUT>
COUT SystemStatusOsObserver::containerTransfer(CINT& inContainer) {
COUT outContainer(0);
for (auto item : inContainer) {
outContainer.insert(outContainer.begin(), item);
}
return outContainer;
}
SystemStatusOsObserver::~SystemStatusOsObserver() {
// Close data-item library handle
DataItemsFactoryProxy::closeDataItemLibraryHandle();
// Destroy cache
for (auto each : mDataItemCache) {
if (nullptr != each.second) {
delete each.second;
}
}
mDataItemCache.clear();
}
void SystemStatusOsObserver::setSubscriptionObj(IDataItemSubscription* subscriptionObj)
{
struct SetSubsObj : public LocMsg {
ObserverContext& mContext;
IDataItemSubscription* mSubsObj;
inline SetSubsObj(ObserverContext& context, IDataItemSubscription* subscriptionObj) :
mContext(context), mSubsObj(subscriptionObj) {}
void proc() const {
mContext.mSubscriptionObj = mSubsObj;
if (!mContext.mSSObserver->mDataItemToClients.empty()) {
list<DataItemId> dis(
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
mContext.mSSObserver->mDataItemToClients.getKeys()));
mContext.mSubscriptionObj->subscribe(dis, mContext.mSSObserver);
mContext.mSubscriptionObj->requestData(dis, mContext.mSSObserver);
}
}
};
if (nullptr == subscriptionObj) {
LOC_LOGw("subscriptionObj is NULL");
} else {
mContext.mMsgTask->sendMsg(new SetSubsObj(mContext, subscriptionObj));
}
}
/******************************************************************************
IDataItemSubscription Overrides
******************************************************************************/
void SystemStatusOsObserver::subscribe(const list<DataItemId>& l, IDataItemObserver* client,
bool toRequestData)
{
struct HandleSubscribeReq : public LocMsg {
inline HandleSubscribeReq(SystemStatusOsObserver* parent,
list<DataItemId>& l, IDataItemObserver* client, bool requestData) :
mParent(parent), mClient(client),
mDataItemSet(containerTransfer<list<DataItemId>, unordered_set<DataItemId>>(l)),
diItemlist(l),
mToRequestData(requestData) {}
void proc() const {
unordered_set<DataItemId> dataItemsToSubscribe(0);
mParent->mDataItemToClients.add(mDataItemSet, {mClient}, &dataItemsToSubscribe);
mParent->mClientToDataItems.add(mClient, mDataItemSet);
mParent->sendCachedDataItems(mDataItemSet, mClient);
// Send subscription set to framework
if (nullptr != mParent->mContext.mSubscriptionObj) {
if (mToRequestData) {
LOC_LOGD("Request Data sent to framework for the following");
mParent->mContext.mSubscriptionObj->requestData(diItemlist, mParent);
} else if (!dataItemsToSubscribe.empty()) {
LOC_LOGD("Subscribe Request sent to framework for the following");
mParent->logMe(dataItemsToSubscribe);
mParent->mContext.mSubscriptionObj->subscribe(
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
std::move(dataItemsToSubscribe)),
mParent);
}
}
}
mutable SystemStatusOsObserver* mParent;
IDataItemObserver* mClient;
const unordered_set<DataItemId> mDataItemSet;
const list<DataItemId> diItemlist;
bool mToRequestData;
};
if (l.empty() || nullptr == client) {
LOC_LOGw("Data item set is empty or client is nullptr");
} else {
mContext.mMsgTask->sendMsg(
new HandleSubscribeReq(this, (list<DataItemId>&)l, client, toRequestData));
}
}
void SystemStatusOsObserver::updateSubscription(
const list<DataItemId>& l, IDataItemObserver* client)
{
struct HandleUpdateSubscriptionReq : public LocMsg {
HandleUpdateSubscriptionReq(SystemStatusOsObserver* parent,
list<DataItemId>& l, IDataItemObserver* client) :
mParent(parent), mClient(client),
mDataItemSet(containerTransfer<list<DataItemId>, unordered_set<DataItemId>>(l)) {}
void proc() const {
unordered_set<DataItemId> dataItemsToSubscribe(0);
unordered_set<DataItemId> dataItemsToUnsubscribe(0);
unordered_set<IDataItemObserver*> clients({mClient});
// below removes clients from all entries keyed with the return of the
// mClientToDataItems.update() call. If leaving an empty set of clients as the
// result, the entire entry will be removed. dataItemsToUnsubscribe will be
// populated to keep the keys of the removed entries.
mParent->mDataItemToClients.trimOrRemove(
// this call updates <IDataItemObserver*, DataItemId> map; removes
// the DataItemId's that are not new to the clietn from mDataItemSet;
// and returns a set of mDataItemSet's that are no longer used by client.
// This unused set of mDataItemSet's is passed to trimOrRemove method of
// <DataItemId, IDataItemObserver*> map to remove the client from the
// corresponding entries, and gets a set of the entries that are
// removed from the <DataItemId, IDataItemObserver*> map as a result.
mParent->mClientToDataItems.update(mClient,
(unordered_set<DataItemId>&)mDataItemSet),
clients, &dataItemsToUnsubscribe, nullptr);
// below adds mClient to <DataItemId, IDataItemObserver*> map, and populates
// new keys added to that map, which are DataItemIds to be subscribed.
mParent->mDataItemToClients.add(mDataItemSet, clients, &dataItemsToSubscribe);
// Send First Response
mParent->sendCachedDataItems(mDataItemSet, mClient);
if (nullptr != mParent->mContext.mSubscriptionObj) {
// Send subscription set to framework
if (!dataItemsToSubscribe.empty()) {
LOC_LOGD("Subscribe Request sent to framework for the following");
mParent->logMe(dataItemsToSubscribe);
mParent->mContext.mSubscriptionObj->subscribe(
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
std::move(dataItemsToSubscribe)),
mParent);
}
// Send unsubscribe to framework
if (!dataItemsToUnsubscribe.empty()) {
LOC_LOGD("Unsubscribe Request sent to framework for the following");
mParent->logMe(dataItemsToUnsubscribe);
mParent->mContext.mSubscriptionObj->unsubscribe(
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
std::move(dataItemsToUnsubscribe)),
mParent);
}
}
}
SystemStatusOsObserver* mParent;
IDataItemObserver* mClient;
unordered_set<DataItemId> mDataItemSet;
};
if (l.empty() || nullptr == client) {
LOC_LOGw("Data item set is empty or client is nullptr");
} else {
mContext.mMsgTask->sendMsg(
new HandleUpdateSubscriptionReq(this, (list<DataItemId>&)l, client));
}
}
void SystemStatusOsObserver::unsubscribe(
const list<DataItemId>& l, IDataItemObserver* client)
{
struct HandleUnsubscribeReq : public LocMsg {
HandleUnsubscribeReq(SystemStatusOsObserver* parent,
list<DataItemId>& l, IDataItemObserver* client) :
mParent(parent), mClient(client),
mDataItemSet(containerTransfer<list<DataItemId>, unordered_set<DataItemId>>(l)) {}
void proc() const {
unordered_set<DataItemId> dataItemsUnusedByClient(0);
unordered_set<IDataItemObserver*> clientToRemove(0);
mParent->mClientToDataItems.trimOrRemove({mClient}, mDataItemSet, &clientToRemove,
&dataItemsUnusedByClient);
unordered_set<DataItemId> dataItemsToUnsubscribe(0);
mParent->mDataItemToClients.trimOrRemove(dataItemsUnusedByClient, {mClient},
&dataItemsToUnsubscribe, nullptr);
if (nullptr != mParent->mContext.mSubscriptionObj && !dataItemsToUnsubscribe.empty()) {
LOC_LOGD("Unsubscribe Request sent to framework for the following data items");
mParent->logMe(dataItemsToUnsubscribe);
// Send unsubscribe to framework
mParent->mContext.mSubscriptionObj->unsubscribe(
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
std::move(dataItemsToUnsubscribe)),
mParent);
}
}
SystemStatusOsObserver* mParent;
IDataItemObserver* mClient;
unordered_set<DataItemId> mDataItemSet;
};
if (l.empty() || nullptr == client) {
LOC_LOGw("Data item set is empty or client is nullptr");
} else {
mContext.mMsgTask->sendMsg(new HandleUnsubscribeReq(this, (list<DataItemId>&)l, client));
}
}
void SystemStatusOsObserver::unsubscribeAll(IDataItemObserver* client)
{
struct HandleUnsubscribeAllReq : public LocMsg {
HandleUnsubscribeAllReq(SystemStatusOsObserver* parent,
IDataItemObserver* client) :
mParent(parent), mClient(client) {}
void proc() const {
unordered_set<DataItemId> diByClient = mParent->mClientToDataItems.getValSet(mClient);
if (!diByClient.empty()) {
unordered_set<DataItemId> dataItemsToUnsubscribe;
mParent->mClientToDataItems.remove(mClient);
mParent->mDataItemToClients.trimOrRemove(diByClient, {mClient},
&dataItemsToUnsubscribe, nullptr);
if (!dataItemsToUnsubscribe.empty() &&
nullptr != mParent->mContext.mSubscriptionObj) {
LOC_LOGD("Unsubscribe Request sent to framework for the following data items");
mParent->logMe(dataItemsToUnsubscribe);
// Send unsubscribe to framework
mParent->mContext.mSubscriptionObj->unsubscribe(
containerTransfer<unordered_set<DataItemId>, list<DataItemId>>(
std::move(dataItemsToUnsubscribe)),
mParent);
}
}
}
SystemStatusOsObserver* mParent;
IDataItemObserver* mClient;
};
if (nullptr == client) {
LOC_LOGw("Data item set is empty or client is nullptr");
} else {
mContext.mMsgTask->sendMsg(new HandleUnsubscribeAllReq(this, client));
}
}
/******************************************************************************
IDataItemObserver Overrides
******************************************************************************/
void SystemStatusOsObserver::notify(const list<IDataItemCore*>& dlist)
{
struct HandleNotify : public LocMsg {
HandleNotify(SystemStatusOsObserver* parent, vector<IDataItemCore*>& v) :
mParent(parent), mDiVec(std::move(v)) {}
inline virtual ~HandleNotify() {
for (auto item : mDiVec) {
delete item;
}
}
void proc() const {
// Update Cache with received data items and prepare
// list of data items to be sent.
unordered_set<DataItemId> dataItemIdsToBeSent(0);
for (auto item : mDiVec) {
if (mParent->updateCache(item)) {
dataItemIdsToBeSent.insert(item->getId());
}
}
// Send data item to all subscribed clients
unordered_set<IDataItemObserver*> clientSet(0);
for (auto each : dataItemIdsToBeSent) {
auto clients = mParent->mDataItemToClients.getValSetPtr(each);
if (nullptr != clients) {
clientSet.insert(clients->begin(), clients->end());
}
}
for (auto client : clientSet) {
unordered_set<DataItemId> dataItemIdsForThisClient(
mParent->mClientToDataItems.getValSet(client));
for (auto itr = dataItemIdsForThisClient.begin();
itr != dataItemIdsForThisClient.end(); ) {
if (dataItemIdsToBeSent.find(*itr) == dataItemIdsToBeSent.end()) {
itr = dataItemIdsForThisClient.erase(itr);
} else {
itr++;
}
}
mParent->sendCachedDataItems(dataItemIdsForThisClient, client);
}
}
SystemStatusOsObserver* mParent;
const vector<IDataItemCore*> mDiVec;
};
if (!dlist.empty()) {
vector<IDataItemCore*> dataItemVec(dlist.size());
for (auto each : dlist) {
IF_LOC_LOGD {
string dv;
each->stringify(dv);
LOC_LOGD("notify: DataItem In Value:%s", dv.c_str());
}
IDataItemCore* di = DataItemsFactoryProxy::createNewDataItem(each->getId());
if (nullptr == di) {
LOC_LOGw("Unable to create dataitem:%d", each->getId());
continue;
}
// Copy contents into the newly created data item
di->copy(each);
// add this dataitem if updated from last one
dataItemVec.push_back(di);
}
if (!dataItemVec.empty()) {
mContext.mMsgTask->sendMsg(new HandleNotify(this, dataItemVec));
}
}
}
/******************************************************************************
IFrameworkActionReq Overrides
******************************************************************************/
void SystemStatusOsObserver::turnOn(DataItemId dit, int timeOut)
{
if (nullptr == mContext.mFrameworkActionReqObj) {
LOC_LOGE("%s:%d]: Framework action request object is NULL", __func__, __LINE__);
return;
}
// Check if data item exists in mActiveRequestCount
DataItemIdToInt::iterator citer = mActiveRequestCount.find(dit);
if (citer == mActiveRequestCount.end()) {
// Data item not found in map
// Add reference count as 1 and add dataitem to map
pair<DataItemId, int> cpair(dit, 1);
mActiveRequestCount.insert(cpair);
LOC_LOGD("Sending turnOn request");
// Send action turn on to framework
struct HandleTurnOnMsg : public LocMsg {
HandleTurnOnMsg(IFrameworkActionReq* framework,
DataItemId dit, int timeOut) :
mFrameworkActionReqObj(framework), mDataItemId(dit), mTimeOut(timeOut) {}
virtual ~HandleTurnOnMsg() {}
void proc() const {
mFrameworkActionReqObj->turnOn(mDataItemId, mTimeOut);
}
IFrameworkActionReq* mFrameworkActionReqObj;
DataItemId mDataItemId;
int mTimeOut;
};
mContext.mMsgTask->sendMsg(
new (nothrow) HandleTurnOnMsg(mContext.mFrameworkActionReqObj, dit, timeOut));
}
else {
// Found in map, update reference count
citer->second++;
LOC_LOGD("turnOn - Data item:%d Num_refs:%d", dit, citer->second);
}
}
void SystemStatusOsObserver::turnOff(DataItemId dit)
{
if (nullptr == mContext.mFrameworkActionReqObj) {
LOC_LOGE("%s:%d]: Framework action request object is NULL", __func__, __LINE__);
return;
}
// Check if data item exists in mActiveRequestCount
DataItemIdToInt::iterator citer = mActiveRequestCount.find(dit);
if (citer != mActiveRequestCount.end()) {
// found
citer->second--;
LOC_LOGD("turnOff - Data item:%d Remaining:%d", dit, citer->second);
if(citer->second == 0) {
// if this was last reference, remove item from map and turn off module
mActiveRequestCount.erase(citer);
// Send action turn off to framework
struct HandleTurnOffMsg : public LocMsg {
HandleTurnOffMsg(IFrameworkActionReq* framework, DataItemId dit) :
mFrameworkActionReqObj(framework), mDataItemId(dit) {}
virtual ~HandleTurnOffMsg() {}
void proc() const {
mFrameworkActionReqObj->turnOff(mDataItemId);
}
IFrameworkActionReq* mFrameworkActionReqObj;
DataItemId mDataItemId;
};
mContext.mMsgTask->sendMsg(
new (nothrow) HandleTurnOffMsg(mContext.mFrameworkActionReqObj, dit));
}
}
}
#ifdef USE_GLIB
bool SystemStatusOsObserver::connectBackhaul()
{
bool result = false;
if (mContext.mFrameworkActionReqObj != NULL) {
struct HandleConnectBackhaul : public LocMsg {
HandleConnectBackhaul(IFrameworkActionReq* fwkActReq) :
mFwkActionReqObj(fwkActReq) {}
virtual ~HandleConnectBackhaul() {}
void proc() const {
LOC_LOGD("HandleConnectBackhaul");
mFwkActionReqObj->connectBackhaul();
}
IFrameworkActionReq* mFwkActionReqObj;
};
mContext.mMsgTask->sendMsg(
new (nothrow) HandleConnectBackhaul(mContext.mFrameworkActionReqObj));
result = true;
}
else {
++mBackHaulConnectReqCount;
LOC_LOGE("Framework action request object is NULL.Caching connect request: %d",
mBackHaulConnectReqCount);
result = false;
}
return result;
}
bool SystemStatusOsObserver::disconnectBackhaul()
{
bool result = false;
if (mContext.mFrameworkActionReqObj != NULL) {
struct HandleDisconnectBackhaul : public LocMsg {
HandleDisconnectBackhaul(IFrameworkActionReq* fwkActReq) :
mFwkActionReqObj(fwkActReq) {}
virtual ~HandleDisconnectBackhaul() {}
void proc() const {
LOC_LOGD("HandleDisconnectBackhaul");
mFwkActionReqObj->disconnectBackhaul();
}
IFrameworkActionReq* mFwkActionReqObj;
};
mContext.mMsgTask->sendMsg(
new (nothrow) HandleDisconnectBackhaul(mContext.mFrameworkActionReqObj));
}
else {
if (mBackHaulConnectReqCount > 0) {
--mBackHaulConnectReqCount;
}
LOC_LOGE("Framework action request object is NULL.Caching disconnect request: %d",
mBackHaulConnectReqCount);
result = false;
}
return result;
}
#endif
/******************************************************************************
Helpers
******************************************************************************/
void SystemStatusOsObserver::sendCachedDataItems(
const unordered_set<DataItemId>& s, IDataItemObserver* to)
{
if (nullptr == to) {
LOC_LOGv("client pointer is NULL.");
} else {
string clientName;
to->getName(clientName);
list<IDataItemCore*> dataItems(0);
for (auto each : s) {
auto citer = mDataItemCache.find(each);
if (citer != mDataItemCache.end()) {
string dv;
citer->second->stringify(dv);
LOC_LOGI("DataItem: %s >> %s", dv.c_str(), clientName.c_str());
dataItems.push_front(citer->second);
}
}
if (dataItems.empty()) {
LOC_LOGv("No items to notify.");
} else {
to->notify(dataItems);
}
}
}
bool SystemStatusOsObserver::updateCache(IDataItemCore* d)
{
bool dataItemUpdated = false;
// Request systemstatus to record this dataitem in its cache
// if the return is false, it means that SystemStatus is not
// handling it, so SystemStatusOsObserver also doesn't.
// So it has to be true to proceed.
if (nullptr != d && mSystemStatus->eventDataItemNotify(d)) {
auto citer = mDataItemCache.find(d->getId());
if (citer == mDataItemCache.end()) {
// New data item; not found in cache
IDataItemCore* dataitem = DataItemsFactoryProxy::createNewDataItem(d->getId());
if (nullptr != dataitem) {
// Copy the contents of the data item
dataitem->copy(d);
// Insert in mDataItemCache
mDataItemCache.insert(std::make_pair(d->getId(), dataitem));
dataItemUpdated = true;
}
} else {
// Found in cache; Update cache if necessary
citer->second->copy(d, &dataItemUpdated);
}
if (dataItemUpdated) {
LOC_LOGV("DataItem:%d updated:%d", d->getId(), dataItemUpdated);
}
}
return dataItemUpdated;
}
} // namespace loc_core

View File

@@ -0,0 +1,176 @@
/* Copyright (c) 2015-2017, 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 __SYSTEM_STATUS_OSOBSERVER__
#define __SYSTEM_STATUS_OSOBSERVER__
#include <cinttypes>
#include <string>
#include <list>
#include <map>
#include <new>
#include <vector>
#include <MsgTask.h>
#include <DataItemId.h>
#include <IOsObserver.h>
#include <loc_pla.h>
#include <log_util.h>
#include <LocUnorderedSetMap.h>
namespace loc_core
{
/******************************************************************************
SystemStatusOsObserver
******************************************************************************/
using namespace std;
using namespace loc_util;
// Forward Declarations
class IDataItemCore;
class SystemStatus;
class SystemStatusOsObserver;
typedef map<IDataItemObserver*, list<DataItemId>> ObserverReqCache;
typedef LocUnorderedSetMap<IDataItemObserver*, DataItemId> ClientToDataItems;
typedef LocUnorderedSetMap<DataItemId, IDataItemObserver*> DataItemToClients;
typedef unordered_map<DataItemId, IDataItemCore*> DataItemIdToCore;
typedef unordered_map<DataItemId, int> DataItemIdToInt;
struct ObserverContext {
IDataItemSubscription* mSubscriptionObj;
IFrameworkActionReq* mFrameworkActionReqObj;
const MsgTask* mMsgTask;
SystemStatusOsObserver* mSSObserver;
inline ObserverContext(const MsgTask* msgTask, SystemStatusOsObserver* observer) :
mSubscriptionObj(NULL), mFrameworkActionReqObj(NULL),
mMsgTask(msgTask), mSSObserver(observer) {}
};
// Clients wanting to get data from OS/Framework would need to
// subscribe with OSObserver using IDataItemSubscription interface.
// Such clients would need to implement IDataItemObserver interface
// to receive data when it becomes available.
class SystemStatusOsObserver : public IOsObserver {
public:
// ctor
inline SystemStatusOsObserver(SystemStatus* systemstatus, const MsgTask* msgTask) :
mSystemStatus(systemstatus), mContext(msgTask, this),
mAddress("SystemStatusOsObserver"),
mClientToDataItems(MAX_DATA_ITEM_ID), mDataItemToClients(MAX_DATA_ITEM_ID)
#ifdef USE_GLIB
, mBackHaulConnectReqCount(0)
#endif
{
}
// dtor
~SystemStatusOsObserver();
template <typename CINT, typename COUT>
static COUT containerTransfer(CINT& s);
template <typename CINT, typename COUT>
inline static COUT containerTransfer(CINT&& s) {
return containerTransfer<CINT, COUT>(s);
}
// To set the subscription object
virtual void setSubscriptionObj(IDataItemSubscription* subscriptionObj);
// To set the framework action request object
inline void setFrameworkActionReqObj(IFrameworkActionReq* frameworkActionReqObj) {
mContext.mFrameworkActionReqObj = frameworkActionReqObj;
#ifdef USE_GLIB
if (mBackHaulConnectReqCount > 0) {
connectBackhaul();
mBackHaulConnectReqCount = 0;
}
#endif
}
// IDataItemSubscription Overrides
inline virtual void subscribe(const list<DataItemId>& l, IDataItemObserver* client) override {
subscribe(l, client, false);
}
virtual void updateSubscription(const list<DataItemId>& l, IDataItemObserver* client) override;
inline virtual void requestData(const list<DataItemId>& l, IDataItemObserver* client) override {
subscribe(l, client, true);
}
virtual void unsubscribe(const list<DataItemId>& l, IDataItemObserver* client) override;
virtual void unsubscribeAll(IDataItemObserver* client) override;
// IDataItemObserver Overrides
virtual void notify(const list<IDataItemCore*>& dlist) override;
inline virtual void getName(string& name) override {
name = mAddress;
}
// IFrameworkActionReq Overrides
virtual void turnOn(DataItemId dit, int timeOut = 0) override;
virtual void turnOff(DataItemId dit) override;
#ifdef USE_GLIB
virtual bool connectBackhaul() override;
virtual bool disconnectBackhaul();
#endif
private:
SystemStatus* mSystemStatus;
ObserverContext mContext;
const string mAddress;
ClientToDataItems mClientToDataItems;
DataItemToClients mDataItemToClients;
DataItemIdToCore mDataItemCache;
DataItemIdToInt mActiveRequestCount;
// Cache the subscribe and requestData till subscription obj is obtained
void cacheObserverRequest(ObserverReqCache& reqCache,
const list<DataItemId>& l, IDataItemObserver* client);
#ifdef USE_GLIB
// Cache the framework action request for connect/disconnect
int mBackHaulConnectReqCount;
#endif
void subscribe(const list<DataItemId>& l, IDataItemObserver* client, bool toRequestData);
// Helpers
void sendCachedDataItems(const unordered_set<DataItemId>& s, IDataItemObserver* to);
bool updateCache(IDataItemCore* d);
inline void logMe(const unordered_set<DataItemId>& l) {
IF_LOC_LOGD {
for (auto id : l) {
LOC_LOGD("DataItem %d", id);
}
}
}
};
} // namespace loc_core
#endif //__SYSTEM_STATUS__

94
gps/core/configure.ac Normal file
View File

@@ -0,0 +1,94 @@
# configure.ac -- Autoconf script for gps loc-core
#
# Process this file with autoconf to produce a configure script
# Requires autoconf tool later than 2.61
AC_PREREQ(2.61)
# Initialize the gps loc-hal package version 1.0.0
AC_INIT([loc-core],1.0.0)
# Does not strictly follow GNU Coding standards
AM_INIT_AUTOMAKE([foreign subdir-objects])
# Disables auto rebuilding of configure, Makefile.ins
AM_MAINTAINER_MODE
# Verifies the --srcdir is correct by checking for the path
AC_CONFIG_SRCDIR([loc-core.pc.in])
# defines some macros variable to be included by source
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
# Checks for programs.
AC_PROG_LIBTOOL
AC_PROG_CXX
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_AWK
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
# Checks for libraries.
PKG_CHECK_MODULES([GPSUTILS], [gps-utils])
AC_SUBST([GPSUTILS_CFLAGS])
AC_SUBST([GPSUTILS_LIBS])
AC_ARG_WITH([core_includes],
AC_HELP_STRING([--with-core-includes=@<:@dir@:>@],
[Specify the location of the core headers]),
[core_incdir=$withval],
with_core_includes=no)
if test "x$with_core_includes" != "xno"; then
CPPFLAGS="${CPPFLAGS} -I${core_incdir}"
fi
AC_ARG_WITH([locpla_includes],
AC_HELP_STRING([--with-locpla-includes=@<:@dir@:>@],
[specify the path to locpla-includes in loc-pla_git.bb]),
[locpla_incdir=$withval],
with_locpla_includes=no)
if test "x$with_locpla_includes" != "xno"; then
AC_SUBST(LOCPLA_CFLAGS, "-I${locpla_incdir}")
fi
AC_SUBST([CPPFLAGS])
AC_ARG_WITH([glib],
AC_HELP_STRING([--with-glib],
[enable glib, building HLOS systems which use glib]))
if (test "x${with_glib}" = "xyes"); then
AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib])
PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
AC_MSG_ERROR(GThread >= 2.16 is required))
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
AC_MSG_ERROR(GLib >= 2.16 is required))
GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
fi
AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes")
AC_ARG_WITH([auto_feature],
AC_HELP_STRING([--with-auto_feature=@<:@dir@:>@],
[Using Automotive feature]),
[],
with_auto_feature=no)
if test "x$with_auto_feature" != "xno"; then
CPPFLAGS="${CPPFLAGS} -DFEATURE_AUTOMOTIVE"
fi
AM_CONDITIONAL(USE_FEATURE_AUTOMOTIVE, test "x${with_auto_feature}" = "xyes")
AC_CONFIG_FILES([ \
Makefile \
loc-core.pc \
])
AC_OUTPUT

View File

@@ -0,0 +1,554 @@
/* Copyright (c) 2015-2017, 2019, 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 __DATAITEMCONCRETEBASETYPES__
#define __DATAITEMCONCRETEBASETYPES__
#include <string>
#include <cstring>
#include <sstream>
#include <DataItemId.h>
#include <IDataItemCore.h>
#include <gps_extended_c.h>
#include <inttypes.h>
#define MAC_ADDRESS_LENGTH 6
// MAC address length in bytes
// QMI_LOC_SRN_MAC_ADDR_LENGTH_V02
#define SRN_MAC_ADDRESS_LENGTH 6
#define WIFI_SUPPLICANT_DEFAULT_STATE 0
static constexpr char sDelimit = ':';
namespace loc_core
{
using namespace std;
enum NetworkType {
TYPE_MOBILE = 0,
TYPE_WIFI,
TYPE_ETHERNET,
TYPE_BLUETOOTH,
TYPE_MMS,
TYPE_SUPL,
TYPE_DUN,
TYPE_HIPRI,
TYPE_WIMAX,
TYPE_PROXY,
TYPE_UNKNOWN,
};
typedef struct NetworkInfoType
{
// Unique network handle ID
uint64_t networkHandle;
// Type of network for corresponding network handle
NetworkType networkType;
NetworkInfoType() : networkHandle(NETWORK_HANDLE_UNKNOWN), networkType(TYPE_UNKNOWN) {}
NetworkInfoType(string strObj) {
size_t posDelimit = strObj.find(sDelimit);
if ( posDelimit != string::npos) {
int32_t type = TYPE_UNKNOWN;
string handleStr = strObj.substr(0, posDelimit);
string typeStr = strObj.substr(posDelimit + 1, strObj.length() - posDelimit - 1);
stringstream(handleStr) >> networkHandle;
stringstream(typeStr) >> type;
networkType = (NetworkType) type;
} else {
networkHandle = NETWORK_HANDLE_UNKNOWN;
networkType = TYPE_UNKNOWN;
}
}
bool operator== (const NetworkInfoType& other) {
return ((networkHandle == other.networkHandle) && (networkType == other.networkType));
}
string toString() {
string valueStr;
valueStr.clear ();
char nethandle [32];
memset (nethandle, 0, 32);
snprintf(nethandle, sizeof(nethandle), "%" PRIu64, networkHandle);
valueStr += string(nethandle);
valueStr += sDelimit;
char type [12];
memset (type, 0, 12);
snprintf (type, 12, "%u", networkType);
valueStr += string (type);
return valueStr;
}
} NetworkInfoType;
class AirplaneModeDataItemBase : public IDataItemCore {
public:
AirplaneModeDataItemBase(bool mode):
mMode(mode),
mId(AIRPLANEMODE_DATA_ITEM_ID) {}
virtual ~AirplaneModeDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
bool mMode;
protected:
DataItemId mId;
};
class ENHDataItemBase : public IDataItemCore {
public:
ENHDataItemBase(bool enabled) :
mEnabled(enabled),
mId(ENH_DATA_ITEM_ID) {}
virtual ~ENHDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
bool mEnabled;
protected:
DataItemId mId;
};
class GPSStateDataItemBase : public IDataItemCore {
public:
GPSStateDataItemBase(bool enabled) :
mEnabled(enabled),
mId(GPSSTATE_DATA_ITEM_ID) {}
virtual ~GPSStateDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
bool mEnabled;
protected:
DataItemId mId;
};
class NLPStatusDataItemBase : public IDataItemCore {
public:
NLPStatusDataItemBase(bool enabled) :
mEnabled(enabled),
mId(NLPSTATUS_DATA_ITEM_ID) {}
virtual ~NLPStatusDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
bool mEnabled;
protected:
DataItemId mId;
};
class WifiHardwareStateDataItemBase : public IDataItemCore {
public:
WifiHardwareStateDataItemBase(bool enabled) :
mEnabled(enabled),
mId(WIFIHARDWARESTATE_DATA_ITEM_ID) {}
virtual ~WifiHardwareStateDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
bool mEnabled;
protected:
DataItemId mId;
};
class ScreenStateDataItemBase : public IDataItemCore {
public:
ScreenStateDataItemBase(bool state) :
mState(state),
mId(SCREEN_STATE_DATA_ITEM_ID) {}
virtual ~ScreenStateDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
bool mState;
protected:
DataItemId mId;
};
class PowerConnectStateDataItemBase : public IDataItemCore {
public:
PowerConnectStateDataItemBase(bool state) :
mState(state),
mId(POWER_CONNECTED_STATE_DATA_ITEM_ID) {}
virtual ~PowerConnectStateDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
bool mState;
protected:
DataItemId mId;
};
class TimeZoneChangeDataItemBase : public IDataItemCore {
public:
TimeZoneChangeDataItemBase(int64_t currTimeMillis, int32_t rawOffset, int32_t dstOffset) :
mCurrTimeMillis (currTimeMillis),
mRawOffsetTZ (rawOffset),
mDstOffsetTZ (dstOffset),
mId(TIMEZONE_CHANGE_DATA_ITEM_ID) {}
virtual ~TimeZoneChangeDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
int64_t mCurrTimeMillis;
int32_t mRawOffsetTZ;
int32_t mDstOffsetTZ;
protected:
DataItemId mId;
};
class TimeChangeDataItemBase : public IDataItemCore {
public:
TimeChangeDataItemBase(int64_t currTimeMillis, int32_t rawOffset, int32_t dstOffset) :
mCurrTimeMillis (currTimeMillis),
mRawOffsetTZ (rawOffset),
mDstOffsetTZ (dstOffset),
mId(TIME_CHANGE_DATA_ITEM_ID) {}
virtual ~TimeChangeDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
int64_t mCurrTimeMillis;
int32_t mRawOffsetTZ;
int32_t mDstOffsetTZ;
protected:
DataItemId mId;
};
class ShutdownStateDataItemBase : public IDataItemCore {
public:
ShutdownStateDataItemBase(bool state) :
mState (state),
mId(SHUTDOWN_STATE_DATA_ITEM_ID) {}
virtual ~ShutdownStateDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
bool mState;
protected:
DataItemId mId;
};
class AssistedGpsDataItemBase : public IDataItemCore {
public:
AssistedGpsDataItemBase(bool enabled) :
mEnabled(enabled),
mId(ASSISTED_GPS_DATA_ITEM_ID) {}
virtual ~AssistedGpsDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
bool mEnabled;
protected:
DataItemId mId;
};
class NetworkInfoDataItemBase : public IDataItemCore {
public:
NetworkInfoDataItemBase(
NetworkType initialType, int32_t type, string typeName, string subTypeName,
bool available, bool connected, bool roaming, uint64_t networkHandle ):
mAllTypes(typeToAllTypes(initialType)),
mType(type),
mTypeName(typeName),
mSubTypeName(subTypeName),
mAvailable(available),
mConnected(connected),
mRoaming(roaming),
mNetworkHandle(networkHandle),
mId(NETWORKINFO_DATA_ITEM_ID) {
mAllNetworkHandles[0].networkHandle = networkHandle;
mAllNetworkHandles[0].networkType = initialType;
}
virtual ~NetworkInfoDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
inline virtual NetworkType getType(void) const {
return (NetworkType)mType;
}
inline uint64_t getAllTypes() { return mAllTypes; }
inline NetworkInfoType* getNetworkHandle() {
return &mAllNetworkHandles[0];
}
// Data members
uint64_t mAllTypes;
int32_t mType;
string mTypeName;
string mSubTypeName;
bool mAvailable;
bool mConnected;
bool mRoaming;
NetworkInfoType mAllNetworkHandles[MAX_NETWORK_HANDLES];
uint64_t mNetworkHandle;
protected:
DataItemId mId;
inline uint64_t typeToAllTypes(NetworkType type) {
return (type >= TYPE_UNKNOWN || type < TYPE_MOBILE) ? 0 : (1<<type);
}
};
class ServiceStatusDataItemBase : public IDataItemCore {
public:
ServiceStatusDataItemBase(int32_t serviceState) :
mServiceState (serviceState),
mId(SERVICESTATUS_DATA_ITEM_ID) {}
virtual ~ServiceStatusDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
int32_t mServiceState;
protected:
DataItemId mId;
};
class ModelDataItemBase : public IDataItemCore {
public:
ModelDataItemBase(const string & name) :
mModel (name),
mId(MODEL_DATA_ITEM_ID) {}
virtual ~ModelDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
string mModel;
protected:
DataItemId mId;
};
class ManufacturerDataItemBase : public IDataItemCore {
public:
ManufacturerDataItemBase(const string & name) :
mManufacturer (name),
mId(MANUFACTURER_DATA_ITEM_ID) {}
virtual ~ManufacturerDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
string mManufacturer;
protected:
DataItemId mId;
};
class RilServiceInfoDataItemBase : public IDataItemCore {
public:
inline RilServiceInfoDataItemBase() :
mData(nullptr), mId(RILSERVICEINFO_DATA_ITEM_ID) {}
inline virtual ~RilServiceInfoDataItemBase() { if (nullptr != mData) free(mData); }
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
inline RilServiceInfoDataItemBase(const RilServiceInfoDataItemBase& peer) :
RilServiceInfoDataItemBase() {
peer.setPeerData(*this);
}
inline virtual bool operator==(const RilServiceInfoDataItemBase& other) const {
return other.mData == mData;
}
inline virtual void setPeerData(RilServiceInfoDataItemBase& /*peer*/) const {}
void* mData;
protected:
DataItemId mId;
};
class RilCellInfoDataItemBase : public IDataItemCore {
public:
inline RilCellInfoDataItemBase() :
mData(nullptr), mId(RILCELLINFO_DATA_ITEM_ID) {}
inline virtual ~RilCellInfoDataItemBase() { if (nullptr != mData) free(mData); }
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
inline RilCellInfoDataItemBase(const RilCellInfoDataItemBase& peer) :
RilCellInfoDataItemBase() {
peer.setPeerData(*this);
}
inline virtual bool operator==(const RilCellInfoDataItemBase& other) const {
return other.mData == mData;
}
inline virtual void setPeerData(RilCellInfoDataItemBase& /*peer*/) const {}
void* mData;
protected:
DataItemId mId;
};
class WifiSupplicantStatusDataItemBase : public IDataItemCore {
public:
WifiSupplicantStatusDataItemBase() :
mState((WifiSupplicantState)WIFI_SUPPLICANT_DEFAULT_STATE),
mApMacAddressValid(false),
mWifiApSsidValid(false),
mId(WIFI_SUPPLICANT_STATUS_DATA_ITEM_ID) {
memset (&mApMacAddress, 0, sizeof (mApMacAddress));
mWifiApSsid.clear();
}
virtual ~WifiSupplicantStatusDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
typedef enum WifiSupplicantState {
DISCONNECTED,
INTERFACE_DISABLED,
INACTIVE,
SCANNING,
AUTHENTICATING,
ASSOCIATING,
ASSOCIATED,
FOUR_WAY_HANDSHAKE,
GROUP_HANDSHAKE,
COMPLETED,
DORMANT,
UNINITIALIZED,
INVALID
} WifiSupplicantState;
/* Represents whether access point attach state*/
WifiSupplicantState mState;
/* Represents info on whether ap mac address is valid */
bool mApMacAddressValid;
/* Represents mac address of the wifi access point*/
uint8_t mApMacAddress[MAC_ADDRESS_LENGTH];
/* Represents info on whether ap SSID is valid */
bool mWifiApSsidValid;
/* Represents Wifi SSID string*/
string mWifiApSsid;
protected:
DataItemId mId;
};
class TacDataItemBase : public IDataItemCore {
public:
TacDataItemBase(const string & name) :
mValue (name),
mId(TAC_DATA_ITEM_ID) {}
virtual ~TacDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
string mValue;
protected:
DataItemId mId;
};
class MccmncDataItemBase : public IDataItemCore {
public:
MccmncDataItemBase(const string & name) :
mValue(name),
mId(MCCMNC_DATA_ITEM_ID) {}
virtual ~MccmncDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
// Data members
string mValue;
protected:
DataItemId mId;
};
class SrnDeviceScanDetailsDataItemBase : public IDataItemCore {
public:
SrnDeviceScanDetailsDataItemBase(DataItemId Id) :
mValidSrnData(false),
mApSrnRssi(-1),
mApSrnTimestamp(0),
mRequestTimestamp(0),
mReceiveTimestamp(0),
mErrorCause(-1),
mId(Id) {}
virtual ~SrnDeviceScanDetailsDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
// Data members common to all SRN tech types
/* Represents info on whether SRN data is valid (no error)*/
bool mValidSrnData;
/* SRN device RSSI reported */
int32_t mApSrnRssi;
/* MAC adress of SRN device */
uint8_t mApSrnMacAddress[SRN_MAC_ADDRESS_LENGTH];
/* UTC timestamp at which the scan was requested.for this SRN device*/
int64_t mApSrnTimestamp;
/* UTC timestamp at which the scan was started. */
int64_t mRequestTimestamp;
/* UTC timestamp at which the scan was received.*/
int64_t mReceiveTimestamp;
/* Reason for the error/failure if SRN details are not valid */
int32_t mErrorCause;
protected:
DataItemId mId;
};
class BtDeviceScanDetailsDataItemBase : public SrnDeviceScanDetailsDataItemBase {
public:
BtDeviceScanDetailsDataItemBase() :
SrnDeviceScanDetailsDataItemBase(BT_SCAN_DATA_ITEM_ID) {}
virtual ~BtDeviceScanDetailsDataItemBase() {}
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
};
class BtLeDeviceScanDetailsDataItemBase : public SrnDeviceScanDetailsDataItemBase {
public:
BtLeDeviceScanDetailsDataItemBase() :
SrnDeviceScanDetailsDataItemBase(BTLE_SCAN_DATA_ITEM_ID) {}
virtual ~BtLeDeviceScanDetailsDataItemBase() {}
virtual void stringify(string& /*valueStr*/) {}
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
};
class BatteryLevelDataItemBase : public IDataItemCore {
public:
inline BatteryLevelDataItemBase(uint8_t batteryPct) :
mBatteryPct(batteryPct), mId(BATTERY_LEVEL_DATA_ITEM_ID) {}
inline ~BatteryLevelDataItemBase() {}
inline virtual DataItemId getId() { return mId; }
// Data members
uint8_t mBatteryPct;
protected:
DataItemId mId;
};
} // namespace loc_core
#endif //__DATAITEMCONCRETEBASETYPES__

View File

@@ -0,0 +1,79 @@
/* Copyright (c) 2015-2017 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 __DATAITEMID_H__
#define __DATAITEMID_H__
/**
* Enumeration of Data Item types
* When add/remove/update changes are made to Data Items, this file needs to be updated
* accordingly
*/
typedef enum e_DataItemId {
INVALID_DATA_ITEM_ID = -1,
// 0 - 4
AIRPLANEMODE_DATA_ITEM_ID,
ENH_DATA_ITEM_ID,
GPSSTATE_DATA_ITEM_ID,
NLPSTATUS_DATA_ITEM_ID,
WIFIHARDWARESTATE_DATA_ITEM_ID,
// 5 - 9
NETWORKINFO_DATA_ITEM_ID,
RILVERSION_DATA_ITEM_ID,
RILSERVICEINFO_DATA_ITEM_ID,
RILCELLINFO_DATA_ITEM_ID,
SERVICESTATUS_DATA_ITEM_ID,
// 10 - 14
MODEL_DATA_ITEM_ID,
MANUFACTURER_DATA_ITEM_ID,
VOICECALL_DATA_ITEM,
ASSISTED_GPS_DATA_ITEM_ID,
SCREEN_STATE_DATA_ITEM_ID,
// 15 - 19
POWER_CONNECTED_STATE_DATA_ITEM_ID,
TIMEZONE_CHANGE_DATA_ITEM_ID,
TIME_CHANGE_DATA_ITEM_ID,
WIFI_SUPPLICANT_STATUS_DATA_ITEM_ID,
SHUTDOWN_STATE_DATA_ITEM_ID,
// 20 - 24
TAC_DATA_ITEM_ID,
MCCMNC_DATA_ITEM_ID,
BTLE_SCAN_DATA_ITEM_ID,
BT_SCAN_DATA_ITEM_ID,
OEM_GTP_UPLOAD_TRIGGER_READY_ITEM_ID,
MAX_DATA_ITEM_ID,
// 26 -
BATTERY_LEVEL_DATA_ITEM_ID,
MAX_DATA_ITEM_ID_1_1,
} DataItemId;
#endif // #ifndef __DATAITEMID_H__

View File

@@ -0,0 +1,100 @@
/* Copyright (c) 2017, 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_TAG "DataItemsFactoryProxy"
#include <dlfcn.h>
#include <DataItemId.h>
#include <IDataItemCore.h>
#include <DataItemsFactoryProxy.h>
#include <loc_pla.h>
#include <log_util.h>
namespace loc_core
{
void* DataItemsFactoryProxy::dataItemLibHandle = NULL;
get_concrete_data_item_fn* DataItemsFactoryProxy::getConcreteDIFunc = NULL;
IDataItemCore* DataItemsFactoryProxy::createNewDataItem(DataItemId id)
{
IDataItemCore *mydi = nullptr;
if (NULL != getConcreteDIFunc) {
mydi = (*getConcreteDIFunc)(id);
}
else {
// first call to this function, symbol not yet loaded
if (NULL == dataItemLibHandle) {
LOC_LOGD("Loaded library %s",DATA_ITEMS_LIB_NAME);
dataItemLibHandle = dlopen(DATA_ITEMS_LIB_NAME, RTLD_NOW);
if (NULL == dataItemLibHandle) {
// dlopen failed.
const char * err = dlerror();
if (NULL == err)
{
err = "Unknown";
}
LOC_LOGE("%s:%d]: failed to load library %s; error=%s",
__func__, __LINE__, DATA_ITEMS_LIB_NAME, err);
}
}
// load sym - if dlopen handle is obtained and symbol is not yet obtained
if (NULL != dataItemLibHandle) {
getConcreteDIFunc = (get_concrete_data_item_fn * )
dlsym(dataItemLibHandle, DATA_ITEMS_GET_CONCRETE_DI);
if (NULL != getConcreteDIFunc) {
LOC_LOGD("Loaded function %s : %p",DATA_ITEMS_GET_CONCRETE_DI,getConcreteDIFunc);
mydi = (*getConcreteDIFunc)(id);
}
else {
// dlysm failed.
const char * err = dlerror();
if (NULL == err)
{
err = "Unknown";
}
LOC_LOGE("%s:%d]: failed to find symbol %s; error=%s",
__func__, __LINE__, DATA_ITEMS_GET_CONCRETE_DI, err);
}
}
}
return mydi;
}
void DataItemsFactoryProxy::closeDataItemLibraryHandle()
{
if (NULL != dataItemLibHandle) {
dlclose(dataItemLibHandle);
dataItemLibHandle = NULL;
}
}
} // namespace loc_core

View File

@@ -0,0 +1,55 @@
/* Copyright (c) 2017, 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 __DATAITEMFACTORYBASE__
#define __DATAITEMFACTORYBASE__
#include <DataItemId.h>
#include <IDataItemCore.h>
namespace loc_core
{
#define DATA_ITEMS_LIB_NAME "libdataitems.so"
#define DATA_ITEMS_GET_CONCRETE_DI "getConcreteDataItem"
typedef IDataItemCore * (get_concrete_data_item_fn)(DataItemId);
class DataItemsFactoryProxy {
public:
static IDataItemCore* createNewDataItem(DataItemId id);
static void closeDataItemLibraryHandle();
static void *dataItemLibHandle;
static get_concrete_data_item_fn *getConcreteDIFunc;
};
} // namespace loc_core
#endif //__DATAITEMFACTORYBASE__

View File

@@ -0,0 +1,82 @@
/* Copyright (c) 2015, 2017 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 __IDATAITEMCORE_H__
#define __IDATAITEMCORE_H__
#include <string>
#include <DataItemId.h>
namespace loc_core {
using namespace std;
/**
* @brief IDataItemCore interface.
* @details IDataItemCore interface.
*
*/
class IDataItemCore {
public:
/**
* @brief Gets Data item id.
* @details Gets Data item id.
* @return Data item id.
*/
virtual DataItemId getId () = 0;
/**
* @brief Stringify.
* @details Stringify.
*
* @param valueStr Reference to string.
*/
virtual void stringify (string & valueStr) = 0;
/**
* @brief copy.
* @details copy.
*
* @param src Where to copy from.
* @param dataItemCopied Boolean flag indicated whether or not copied.
*
* @return Zero for success or non zero for failure.
*/
virtual int32_t copy (IDataItemCore * src, bool *dataItemCopied = nullptr) = 0;
/**
* @brief Destructor.
* @details Destructor.
*/
virtual ~IDataItemCore () {}
};
} // namespace loc_core
#endif // __IDATAITEMCORE_H__

10
gps/core/loc-core.pc.in Normal file
View File

@@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: loc-core
Description: QTI GPS Loc Core
Version: @VERSION@
Libs: -L${libdir} -lloc_core
Cflags: -I${includedir}/loc-core

227
gps/core/loc_core_log.cpp Normal file
View File

@@ -0,0 +1,227 @@
/* 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_NDEBUG 0
#define LOG_TAG "LocSvc_core_log"
#include <log_util.h>
#include <loc_log.h>
#include <loc_core_log.h>
#include <loc_pla.h>
void LocPosMode::logv() const
{
LOC_LOGV ("Position mode: %s\n Position recurrence: %s\n "
"min interval: %d\n preferred accuracy: %d\n "
"preferred time: %d\n credentials: %s provider: %s \n "
"power mode: %d\n tbm %d",
loc_get_position_mode_name(mode),
loc_get_position_recurrence_name(recurrence),
min_interval,
preferred_accuracy,
preferred_time,
credentials,
provider,
powerMode,
timeBetweenMeasurements);
}
/* GPS status names */
static const loc_name_val_s_type gps_status_name[] =
{
NAME_VAL( LOC_GPS_STATUS_NONE ),
NAME_VAL( LOC_GPS_STATUS_SESSION_BEGIN ),
NAME_VAL( LOC_GPS_STATUS_SESSION_END ),
NAME_VAL( LOC_GPS_STATUS_ENGINE_ON ),
NAME_VAL( LOC_GPS_STATUS_ENGINE_OFF ),
};
static const 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(LocGpsStatusValue gps_status)
{
return loc_get_name_from_val(gps_status_name, gps_status_num,
(long) gps_status);
}
static const 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 const int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type);
const char* loc_get_position_mode_name(LocGpsPositionMode mode)
{
return loc_get_name_from_val(loc_eng_position_modes, loc_eng_position_mode_num, (long) mode);
}
static const loc_name_val_s_type loc_eng_position_recurrences[] =
{
NAME_VAL( LOC_GPS_POSITION_RECURRENCE_PERIODIC ),
NAME_VAL( LOC_GPS_POSITION_RECURRENCE_SINGLE )
};
static const int loc_eng_position_recurrence_num = sizeof(loc_eng_position_recurrences) / sizeof(loc_name_val_s_type);
const char* loc_get_position_recurrence_name(LocGpsPositionRecurrence recur)
{
return loc_get_name_from_val(loc_eng_position_recurrences, loc_eng_position_recurrence_num, (long) recur);
}
const char* loc_get_aiding_data_mask_names(LocGpsAidingData /*data*/)
{
return NULL;
}
static const loc_name_val_s_type loc_eng_agps_types[] =
{
NAME_VAL( LOC_AGPS_TYPE_INVALID ),
NAME_VAL( LOC_AGPS_TYPE_ANY ),
NAME_VAL( LOC_AGPS_TYPE_SUPL ),
NAME_VAL( LOC_AGPS_TYPE_C2K ),
NAME_VAL( LOC_AGPS_TYPE_WWAN_ANY )
};
static const int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type);
const char* loc_get_agps_type_name(LocAGpsType type)
{
return loc_get_name_from_val(loc_eng_agps_types, loc_eng_agps_type_num, (long) type);
}
static const loc_name_val_s_type loc_eng_ni_types[] =
{
NAME_VAL( LOC_GPS_NI_TYPE_VOICE ),
NAME_VAL( LOC_GPS_NI_TYPE_UMTS_SUPL ),
NAME_VAL( LOC_GPS_NI_TYPE_UMTS_CTRL_PLANE ),
NAME_VAL( LOC_GPS_NI_TYPE_EMERGENCY_SUPL )
};
static const int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type);
const char* loc_get_ni_type_name(LocGpsNiType type)
{
return loc_get_name_from_val(loc_eng_ni_types, loc_eng_ni_type_num, (long) type);
}
static const loc_name_val_s_type loc_eng_ni_responses[] =
{
NAME_VAL( LOC_GPS_NI_RESPONSE_ACCEPT ),
NAME_VAL( LOC_GPS_NI_RESPONSE_DENY ),
NAME_VAL( LOC_GPS_NI_RESPONSE_DENY )
};
static const int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type);
const char* loc_get_ni_response_name(LocGpsUserResponseType response)
{
return loc_get_name_from_val(loc_eng_ni_responses, loc_eng_ni_reponse_num, (long) response);
}
static const loc_name_val_s_type loc_eng_ni_encodings[] =
{
NAME_VAL( LOC_GPS_ENC_NONE ),
NAME_VAL( LOC_GPS_ENC_SUPL_GSM_DEFAULT ),
NAME_VAL( LOC_GPS_ENC_SUPL_UTF8 ),
NAME_VAL( LOC_GPS_ENC_SUPL_UCS2 ),
NAME_VAL( LOC_GPS_ENC_UNKNOWN )
};
static const int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type);
const char* loc_get_ni_encoding_name(LocGpsNiEncodingType encoding)
{
return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding);
}
static const 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 const 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 const 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 const 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 const 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 const 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 const loc_name_val_s_type loc_eng_agps_status_names[] =
{
NAME_VAL( LOC_GPS_REQUEST_AGPS_DATA_CONN ),
NAME_VAL( LOC_GPS_RELEASE_AGPS_DATA_CONN ),
NAME_VAL( LOC_GPS_AGPS_DATA_CONNECTED ),
NAME_VAL( LOC_GPS_AGPS_DATA_CONN_DONE ),
NAME_VAL( LOC_GPS_AGPS_DATA_CONN_FAILED )
};
static const 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(LocAGpsStatusValue status)
{
return loc_get_name_from_val(loc_eng_agps_status_names, loc_eng_agps_status_num, (long) status);
}

58
gps/core/loc_core_log.h Normal file
View File

@@ -0,0 +1,58 @@
/* Copyright (c) 2011-2013, 2016-2017 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
#include <ctype.h>
#include <gps_extended.h>
#ifdef __cplusplus
extern "C"
{
#endif
const char* loc_get_gps_status_name(LocGpsStatusValue gps_status);
const char* loc_get_position_mode_name(LocGpsPositionMode mode);
const char* loc_get_position_recurrence_name(LocGpsPositionRecurrence recur);
const char* loc_get_aiding_data_mask_names(LocGpsAidingData data);
const char* loc_get_agps_type_name(LocAGpsType type);
const char* loc_get_ni_type_name(LocGpsNiType type);
const char* loc_get_ni_response_name(LocGpsUserResponseType response);
const char* loc_get_ni_encoding_name(LocGpsNiEncodingType 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(LocAGpsStatusValue status);
#ifdef __cplusplus
}
#endif
#endif /* LOC_CORE_LOG_H */

View File

@@ -0,0 +1,76 @@
/* Copyright (c) 2015, 2017 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 __IDATAITEMOBSERVER_H__
#define __IDATAITEMOBSERVER_H__
#include <list>
#include <string>
using namespace std;
namespace loc_core
{
class IDataItemCore;
/**
* @brief IDataItemObserver interface
* @details IDataItemObserver interface;
* In OS dependent code this type serves as a handle to an OS independent instance of this interface.
*/
class IDataItemObserver {
public:
/**
* @brief Gets name of Data Item Observer
* @details Gets name of Data Item Observer
*
* @param name reference to name of Data Item Observer
*/
virtual void getName (string & name) = 0;
/**
* @brief Notify updated values of Data Items
* @details Notifys updated values of Data items
*
* @param dlist List of updated data items
*/
virtual void notify (const std :: list <IDataItemCore *> & dlist) = 0;
/**
* @brief Destructor
* @details Destructor
*/
virtual ~IDataItemObserver () {}
};
} // namespace loc_core
#endif // #ifndef __IDATAITEMOBSERVER_H__

View File

@@ -0,0 +1,129 @@
/* Copyright (c) 2015, 2017 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 __IDATAITEMSUBSCRIPTION_H__
#define __IDATAITEMSUBSCRIPTION_H__
#include <list>
#include <DataItemId.h>
namespace loc_core
{
class IDataItemObserver;
/**
* @brief IDataItemSubscription interface
* @details IDataItemSubscription interface;
* Defines an interface for operations such as subscribe,
* unsubscribe data items by their IDs.
* Must be implemented by OS dependent code.
*/
class IDataItemSubscription {
public:
/**
* @brief Subscribe for data items by their IDs
* @details Subscribe for data items by their IDs;
* An IDataItemObserver implementer invokes this method to subscribe
* for a list of DataItems by passing in their Ids.
* A symbolic invocation of this method in the following order
* subscribe ( {1,2,3}, &obj), subscribe ( {2,3,4,5}, &obj)
* where the numbers enclosed in braces indicate a list of data item Ids
* will cause this class implementer to update its subscription list for
* &obj to only contain the following Data Item Ids 1,2,3,4,5.
*
* @param l List of DataItemId
* @param o Pointer to an instance of IDataItemObserver
*/
virtual void subscribe (const std :: list <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
/**
* @brief Update subscription for Data items
* @details Update subscription for Data items;
* An IDataItemObserver implementer invokes this method to update their
* subscription for a list of DataItems by passing in their Ids
* A symbolic invocation of this method in the following order
* updateSubscription ( {1,2,3}, &obj),updateSubscription ( {2,3,4,5}, &obj)
* where the numbers enclosed in braces indicate a list of data item Ids
* will cause this class implementer to update its subscription list for
* &obj to only contain the following Data Item Ids 2,3,4,5.
* Note that this method may or may not be called.
*
* @param l List of DataItemId
* @param o Pointer to an instance of IDataItemObserver
*/
virtual void updateSubscription (const std :: list <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
/**
* @brief Request Data
* @details Request Data
*
* @param l List of DataItemId
* @param o Pointer to an instance of IDataItemObserver
*/
virtual void requestData (const std :: list <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
/**
* @brief Unsubscribe Data items
* @details Unsubscrbe Data items;
* An IDataItemObserver implementer invokes this method to unsubscribe their
* subscription for a list of DataItems by passing in their Ids
* Suppose this class implementor has a currently active subscription list
* containing 1,2,3,4,5,6,7 for &obj then a symbolic invocation of this
* method in the following order
* unsubscribe ( {1,2,3}, &obj), unsubscribe ( {1,2,3,4}, &obj),
* unsubscribe ( {7}, &obj)
* where the numbers enclosed in braces indicate a list of data item Ids
* will cause this class implementer to update its subscription list for
* &obj to only contain the following data item id 5,6.
*
* @param l List of DataItemId
* @param o Pointer to an instance of IDataItemObserver
*/
virtual void unsubscribe (const std :: list <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
/**
* @brief Unsubscribe all data items
* @details Unsubscribe all data items
*
* @param o Pointer to an instance of IDataItemObserver
*/
virtual void unsubscribeAll (IDataItemObserver * o = NULL) = 0;
/**
* @brief Destructor
* @details Destructor
*/
virtual ~IDataItemSubscription () {}
};
} // namespace loc_core
#endif // #ifndef __IDATAITEMSUBSCRIPTION_H__

View File

@@ -0,0 +1,101 @@
/* Copyright (c) 2017 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 __IFRAMEWORKACTIONREQ_H__
#define __IFRAMEWORKACTIONREQ_H__
#include <DataItemId.h>
namespace loc_core
{
/**
* @brief IFrameworkActionReq interface
* @details IFrameworkActionReq interface;
* Defines an interface for operations such as turnOn, turnOff a
* framework module described by the data item. Framework module
* could be bluetooth, wifi etc.
* Must be implemented by OS dependent code.
*
*/
class IFrameworkActionReq {
public:
/**
* @brief Turn on the framework module described by the data item.
* @details Turn on the framework module described by the data item;
* An IFrameworkActionReq implementer invokes this method to
* turn on the framework module described by the data item.
* Framework module could be bluetooth, wifi etc.
*
* @param dit DataItemId
* @param timeout Timeout after which to turn off the framework module.
*/
virtual void turnOn (DataItemId dit, int timeOut = 0) = 0;
/**
* @brief Turn off the framework module described by the data item.
* @details Turn off the framework module described by the data item;
* An IFrameworkActionReq implementer invokes this method to
* turn off the framework module described by the data item.
* Framework module could be bluetooth, wifi etc.
*
* @param dit DataItemId
*/
virtual void turnOff (DataItemId dit) = 0;
#ifdef USE_GLIB
/**
* @brief Setup WWAN backhaul
* @details Setup WWAN backhaul
*
* @param None
*/
virtual bool connectBackhaul() = 0;
/**
* @brief Disconnects the WWANbackhaul
* @details Disconnects the WWANbackhaul, only if it was setup by us
*
* @param None
*/
virtual bool disconnectBackhaul() = 0;
#endif
/**
* @brief Destructor
* @details Destructor
*/
virtual ~IFrameworkActionReq () {}
};
} // namespace loc_core
#endif // #ifndef __IFRAMEWORKACTIONREQ_H__

Some files were not shown because too many files have changed in this diff Show More