412 Commits
bka ... vic-bak

Author SHA1 Message Date
4080f3dea5 msm8953-common: Update remove_packages 2025-01-18 04:02:41 +09:00
e1aa98dd38 msm8953-common: Update remove_packages 2025-01-18 04:02:37 +09:00
Raya
4a211e9c2d msm8953-common: Update Bluetooth blobs from FP3
Change-Id: I1e0c193d273b4cd0a3e44789c179b075e9be366c
2024-12-20 14:18:46 +03:00
Giovanni Ricca
19bf303d28 msm8953-common: Switch to fragmented defconfigs
Change-Id: I5c3a7c41a9764221a2872830abf078ecc2cdf192
2024-12-20 14:18:46 +03:00
Lafactorial
61e4065a7c msm8953-common: Drop lineage.dependencies 2024-12-20 14:18:45 +03:00
Bruno Martins
2a507003fd msm8953-common: Mark CNE symlink target as required package
Change-Id: I0bfe65ba61b6aa9916fe6459be2a84d772939a2f
2024-12-20 14:18:45 +03:00
Michael Bestas
a4f4bfd6e4 msm8953-common: gps: Convert remaining Android.mk to bp
Change-Id: I75e6af92795fe755a48557aa06106406b14c6750
2024-12-20 14:18:45 +03:00
Michael Bestas
670910004b msm8953-common: gps: Remove unused implementations
Change-Id: I079edea073f3ae43eaebbf04712e99ec1a931b10
2024-12-20 14:18:44 +03:00
Nolen Johnson
d04303cb25 msm8953-common: Nuke update-sha1sums.py
* We have py extract to do this now.

Change-Id: I031938ddb78e8f343864da521dc577cfcb67ee45
2024-12-20 14:18:44 +03:00
Beverly
5df2b1e472 msm8953-common: Update lock icon padding
It should not change based on density changes.

Test: visual inspection
Bug: 264738021
Change-Id: I98f948b4a1bd7e6cc560f14e2e1b14a0bde76f01
2024-12-20 14:18:44 +03:00
Demon Singur
1a7be7243c 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
2024-12-20 14:18:44 +03:00
Giovanni Ricca
8ce1d238e0 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
2024-12-20 14:18:43 +03:00
Giovanni Ricca
b52ed827f0 msm8953-common: Drop embms
Change-Id: Iaef95f45053690502018d7da7f9df999a5bc0c9b
2024-12-20 14:18:43 +03:00
Giovanni Ricca
425727eb79 msm8953-common: Drop vendor.qti.hardware.qdutils_disp
Change-Id: Ic891ef77fce641d51fde0014b172709596f3b2b4
2024-12-20 14:18:43 +03:00
Giovanni Ricca
6456e0b441 msm8953-common: Drop cdsprpcd stack
Change-Id: Id29ad49334791ba1a1086481d21729736e7920de
2024-12-20 14:18:43 +03:00
Roberto Sartori
db03b28720 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
2024-12-20 14:17:36 +03:00
Giovanni Ricca
bcab9393f7 msm8953-common: Decommonize screen density
Change-Id: I0c2c2723c0e9826c549e86dd591bc64893ce98cf
2024-12-19 11:31:22 +03:00
Giovanni Ricca
8bf8099bbe msm8953-common: Document the disabled ELF check libs
Change-Id: I1a484ca2620131c36fca4a45112a53317021d24f
2024-12-19 11:29:24 +03:00
Giovanni Ricca
088cdda380 msm8953-common: sepolicy: Guard debugfs rules
Change-Id: I194d54e207de56fa8df92f198f1e983b5ca6b213
2024-12-19 11:28:52 +03:00
basamaryan
d16a3ad43d msm8953-common: Move to Xiaomi fingerprint AIDL
Change-Id: I68dba7184034fd37454c7d32a065f041cb611625
2024-12-19 11:27:38 +03:00
Devin Moore
8f19a763a8 msm8953-common: Switch to new AIDL IR service
Test: atest VtsHalIrTargetTest hal_implementation_test
Bug: 205000342
Change-Id: I70c54aa8e8962939cc8f4b42fbbe828e9dad7f0d
2024-12-19 11:16:36 +03:00
ayongyuth
cef95abb1a msm8953-common: Fix Image size for Razor and RazorG by reduce Jounal size to zero
Bug: 21016403
Change-Id: Iaadd805dd5326b810e6dd83c1e509cab48995d9d
2024-12-19 11:16:36 +03:00
Giovanni Ricca
fd1e8ff380 msm8953-common: Use soong to copy gps configs
Change-Id: Ia1188567d250f228585e0e52f096112ac3233200
2024-12-19 11:16:36 +03:00
Giovanni Ricca
c0750b550b msm8953-common: Rename wcnss_service target
Change-Id: I638e8e40ea95b914ee3c36035704a4d55780d41f
2024-12-19 11:16:36 +03:00
Cosmin Tanislav
0a68428a6a msm8953-common: do not manually build dependencies
Change-Id: I4046d8eeabfc70842898b7034f75cdd6bcfc441b
2024-12-19 11:16:35 +03:00
Aaron Kling
de65059b33 msm8953-common: Remove elf files in copy files check
New extract files uses packages instead of copy files

Change-Id: I337c07d13bd350958d4808e1693cc6e03753a96c
2024-12-19 11:16:35 +03:00
Giovanni Ricca
d868c41d52 msm8953-common: Import missing 32bit libs
Change-Id: Ic1fbd94452488e3ee318a59e9b9e9c4c7c0b94ee
2024-12-19 11:16:35 +03:00
Michael Bestas
5320630224 msm8953-common: Disable ELF checks for certain libraries
Change-Id: I61dbc3559b43becc22f69ae2c1c3e8edf95e2483
2024-12-19 11:16:35 +03:00
Michael Bestas
57de66f447 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-19 11:16:35 +03:00
Kevin Tang
7a1c76e244 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-19 11:16:34 +03:00
Michael Bestas
3ff0f91756 msm8953-common: gps: Resolve unused parameter warnings
Change-Id: I0acef3da2c3567a28edd0a71dac89a5828f7725d
2024-12-19 11:16:34 +03:00
Saurabh Srivastava
51babbffbb msm8953-common: gps: Android mk to bp conversion
Change-Id: I206b4a5a2b7e88a6a20522611e7b2684594ef6f4
CRs-Fixed: 2559087
2024-12-19 11:16:34 +03:00
Dante Russo
c291ba5d36 msm8953-common: gps: Bringup changes for Lahaina
CRs-fixed: 2568895
Change-Id: Iec61f47c05009bdadb67bb236b9772cdeda99ec7
2024-12-19 11:16:34 +03:00
haohuang
9249e1c811 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-19 11:16:33 +03:00
Dante Russo
c71ff1f2e8 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-19 11:16:33 +03:00
Giovanni Ricca
e2bc5464d6 msm8953-common: Fix lib-imscamera ELF checks
Change-Id: I83c6ec68af801b17a1dd6e4aba74145cea355e8f
2024-12-19 11:16:33 +03:00
Giovanni Ricca
5afbe80396 msm8953-common: Cleanup conflicting libs
Change-Id: I9361ad55f8aba96cc77bd8b0c7294a49ff999d10
2024-12-19 11:16:32 +03:00
Sebastiano Barezzi
46e475ea54 msm8953-common: Append _vendor to conflicting vendor libs
Change-Id: I74306c87e12079204223caccc0c77eacd4e01ec0
2024-12-19 11:14:36 +03:00
Aaron Kling
21f0c47a1c msm8953-common: Add vendor soong imports to extract
Change-Id: Ib19e69dc35af6b04519eeb695228af65f3d01d2a
2024-12-19 11:14:35 +03:00
Aaron Kling
6936cbd64a msm8953-common: Enable elf checks
Change-Id: Ia6c9a381abb3384c77532d75e02fd84c841a4d1e
2024-12-19 11:14:35 +03:00
Kelvin Zhang
ff3897686d 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-19 11:14:35 +03:00
dianlujitao
ce745accb6 msm8953-common: Nuke ATFWD
It's normally not used at all.

Change-Id: Idb824b3b8c783b6ac962e604df05f9154beb4ed2
2024-12-19 11:14:35 +03:00
Michael Bestas
0024c6e85c msm8953-common: Shim widevine with libcrypto_shim
The following change
e202e51cb0
removed symbols that our libs require.

Change-Id: I1325c34ecec3d339dd68c665010ecb36fa2e6a29
2024-12-19 11:14:34 +03:00
Yumi Yukimura
9beebf6907 msm8953-common: Switch to QTI Memtrack AIDL HAL
Change-Id: Ibcbaff02fd56fbccc3a88c01a5f46a89cb212ef5
2024-12-19 11:14:34 +03:00
ix5
fa0fd816db 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-12-19 11:12:08 +03:00
Giovanni Ricca
1bb9123ef7 msm8953-common: Migrate to py extract utils
Change-Id: I2a7a0e7803940ef6105e55b88a94b7ba066a1929
2024-12-19 11:11:54 +03:00
me-cafebabe
62a16fc34d 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-12-19 11:11:30 +03:00
Bruno Martins
66a87541c8 msm8953-common: Unset BUILD_BROKEN_INCORRECT_PARTITION_IMAGES
Qualcomm targets can now build hermetic partitions.

Change-Id: I241105e01d85fea983b34846ca675666ac07541b
2024-08-08 11:18:35 +03:00
Bruno Martins
695f8fdb25 msm8953-common: Declare IMS libs as symlinks during extraction
Change-Id: Ia1b8097d28dd4888232fe383b830515b1b9bafaa
2024-08-08 11:18:34 +03:00
Bruno Martins
6c05ecdc2a msm8953-common: Move to new RFS install_symlink targets
Change-Id: I9560fd0da00958d9349a0881b5a5f64a2c02e495
2024-08-08 11:18:16 +03:00
Bruno Martins
93a37dd24e msm8953-common: Convert WiFi firmware symlinks to install_symlink targets
The last bit that was preventing building hermetic images.

Change-Id: I2d1651a13f910949621ac14fa0dbc1ebe630f2cb
2024-08-08 11:16:28 +03:00
Giovanni Ricca
a12fbb082b msm8953-common: Specify caymanslm source at the top
Change-Id: Iee0ae1f85148985edce4f06d3b3a40450d70877d
2024-08-08 11:06:18 +03:00
Giovanni Ricca
7a1e7db21b msm8953-common: Decommonize TARGET_TS_MAKEUP
* Only oreo (and below) targets actually use this feature.

Change-Id: I2e74031f99d4a473c4f214128b18d201f824d9d0
2024-08-08 11:05:52 +03:00
Han Sol Jin
82a5f6c199 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-08-08 11:03:58 +03:00
Michael Bestas
28e139572f msm8953-common: Build missing libraries for 14 QPR3
Change-Id: I6a84526ca1e9f4e5140c8068646433cab3fe85b2
2024-06-26 16:52:55 +03:00
Giovanni Ricca
fc41ccb0c4 msm8953-common: Add atcmdfwd on framework compatibility matrix
Change-Id: I9943e6510a014523c3e13e2ff3599c5a1bd6135f
2024-06-26 16:52:44 +03:00
Michael Bestas
f79656ae52 msm8953-common: Inherit from legacy QTI FCM
Change-Id: I0bde1c273d4abe689f61e7d4ebcf80965d785489
2024-06-26 16:52:31 +03:00
Michael Bestas
72fa02541c msm8953-common: Include lineage FCM
Change-Id: Ib4408e941d920a3a38132ba1c8360994f5534c0b
2024-06-26 16:52:14 +03:00
Bruno Martins
c80a790b5b msm8953-common: Inherit from QTI FCM
Change-Id: I0bdd4d63b60a1e29cdd69e71f7268932a105c16b
2024-06-26 16:52:03 +03:00
Tim Zimmermann
69084ccbaa msm8953-common: Set manifest target-level to 5
Change-Id: Ic72d17ebdb388dee9e63e27a36190c93c095fb0c
2024-06-26 16:51:52 +03:00
Bruno Martins
04d709dc8b 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-26 16:51:41 +03:00
Michael Bestas
24a56ef03c msm8953-common: Switch to QTI vibrator HAL
Change-Id: I911001c14167f7dfceb609090f7b90117310da07
2024-06-26 16:51:28 +03:00
Alexander Koskovich
ac1bf79d78 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-26 16:51:03 +03:00
Adithya R
e1a7f18f95 msm8953-common: parts: Get rid of proguard flags
This is obsolete.

Change-Id: I1b692d3e1a96c49ac6efd54907ea23c4b4494f7e
2024-06-26 09:04:31 +03:00
Omkar Chandorkar
1c42d292d6 msm8953-common: overlay: Update CarrierConfig from phone1
* From Nothing OS 2.0.4

Signed-off-by: flakeforever <113103193+flakeforever@users.noreply.github.com>
2024-06-26 09:04:07 +03:00
Hakan
525a47ef19 msm8953-common: sign my build 2024-06-06 08:57:02 +03:00
Arian
bcc8c02ef2 msm8953-common: overlay: Update CarrierConfig from unicorn V816.0.3.0.ULECNXM 2024-04-26 08:06:05 +03:00
Peter Kalauskas
e2f65c8391 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-04-15 08:07:42 +03:00
Chaohui Wang
96ed58dc8d 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-04-15 08:07:42 +03:00
basamaryan
11a8788570 msm8953-common: Don't explicitly include updatable_apex.mk
It is inherited by base_system.mk as of QPR2

Change-Id: I020a05b233f61ea28d03199cbc76051e6e97e1dc
2024-04-15 08:07:13 +03:00
Aaron Kling
488aa1536c msm8953-common: Uprev usb hal to 1.3
Change-Id: I5d34c71663b31fe03b0d28f8c76e5a4f8cd2385c
2024-03-28 12:43:17 +03:00
Bruno Martins
109c500dc2 msm8953-common: Remove deprecated trust HAL
Change-Id: Ic5ac79b4ca60b87a97622877b97f806c07cab907
2024-03-28 12:42:10 +03:00
Yumi Yukimura
f3828a3a61 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-20 14:22:54 +03:00
Bruno Martins
e1278784af 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-19 12:34:26 +03:00
Tomasz Wasilczyk
42db3b8b83 msm8953-common: gps: Don't include cutils/threads.h
Bug: 289414897
Test: buildserver
Change-Id: I14b99f42feaae7af00cbd17cfe482eb2e5da71e8
2024-03-13 09:43:04 +03:00
Cole Faust
617b5f039d 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-13 09:42:51 +03:00
Hakan
174eca8d97 msm8953-common : Set TARGET_KERNEL_LLVM_BINUTILS true 2024-02-28 03:21:46 +03:00
Lafactorial
69add37179 msm8953-common : No need to specify kernel anymore 2024-01-31 09:31:55 +03:00
Giovanni Ricca
f65c6586c8 msm8953-common: rootdir: Setup zram with fstab
Change-Id: I4b172ee5c61693b5d6ae14b297374ff679f4938c
2024-01-31 09:28:44 +03:00
Hakan
63861001b5 msm8953-common: Fix Soc model 2024-01-31 09:26:42 +03:00
Edwin Moquete
d070a9416c 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-31 09:26:42 +03:00
Lafactorial
3da98640b7 msm8953-common: parts: Fixup! Add an exported flag in manifest 2024-01-31 09:26:19 +03:00
Sebastiano Barezzi
086c61f6c7 msm8953-common: biometrics: Move fingerprint HIDL to 2.3
Change-Id: I2e5ed64ac7ae2f1003503072666204c0788a003a
2024-01-31 09:26:18 +03:00
Yumi Yukimura
871d5a80b4 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
2024-01-31 09:26:18 +03:00
Sebastiano Barezzi
fdf1670cce msm8953-common: Move to common Xiaomi light AIDL
Change-Id: I00494cd392d19abd97cd65aeb4ec4bd9c9b11352
2024-01-31 09:26:18 +03:00
Hakan
6fccfe37fd msm8953-common: Fix exported flag 2024-01-31 09:26:17 +03:00
Giovanni Ricca
4574f0c150 msm8953-common: sepolicy: Drop chargeonlymode rule
* We don't ship it anymore

Change-Id: Iaca9ea838759cf47f211ddd1b53f5dc6dab17df5
2024-01-31 09:26:17 +03:00
Giovanni Ricca
4b6f4151d4 msm8953-common: sepolicy: Drop goodix init script rules
* Unused since we switched to oss biometrics hal

Change-Id: I77239dabb2c533bfa09f0bd109351bf85923db74
2024-01-31 09:26:17 +03:00
Giovanni Ricca
db190da20e 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
2024-01-31 09:26:17 +03:00
Giovanni Ricca
6d20ca3478 msm8953-common: sepolicy: Checkout fingerprint selinux policy from asus/msm8937-common
Change-Id: I20ddaf6bd0a7df3a7ac56b851e2533c142a197ad
2024-01-31 09:26:17 +03:00
Giovanni Ricca
fcdb641cd8 msm8953-common: sepolicy: Label sensors path
Change-Id: I87371fbdb8ad069d3b93de72a09c1d1b1ce6da1e
2024-01-31 09:26:16 +03:00
dianlujitao
ed43457b97 msm8953-common: sepolicy: Label /sys/touchpanel/ DT2W node
Change-Id: Id55db9b6614320650c8c61e698f71ddc9f04d086
2024-01-31 09:26:16 +03:00
Giovanni Ricca
ee9ef1cb34 msm8953-common: overlay: Decommonize Auto Brightness overlays
Change-Id: I794c8c45b3c8a5e6554721e1ee918c42b8df4fad
2024-01-31 09:26:16 +03:00
Giovanni Ricca
d3b23b4afa msm8953-common: overlay-lineage: Decommonize HW Keys overlay
Change-Id: I7afb5014c94f1671b25525f63f5c6fc56da4ec17
2024-01-31 09:26:15 +03:00
Giovanni Ricca
9d1be9ee43 msm8953-common: Make system partion size overridable
Change-Id: Iec146727eef511f52d185b5cf16086d39d367d68
2024-01-31 09:26:15 +03:00
Giovanni Ricca
59975a5b90 msm8953-common: biometrics: Commonize biometrics permissions
Change-Id: I4191f1712ecf6c5228ef2a811769c6913a19173a
2024-01-31 09:26:15 +03:00
Giovanni Ricca
c6f8c22bea msm8953-common: sepolicy: Set vendor_fp_prop to restricted
Change-Id: I4d1428e4a7c2b94645c5de516eea632f1d3411d4
2024-01-31 09:26:15 +03:00
Lafactorial
ba6fba2f57 Revert "msm8953-common: update datastatusnotification from coral [1/2]"
This reverts commit 7253ca0292.
2024-01-31 09:26:15 +03:00
Sebastiano Barezzi
48283d8d68 msm8953-common: rootdir: Import recovery init scripts
* From phoenixin recovery

Change-Id: Ic83f991e22052abd5a4c7ec012ba66a222358e22
2024-01-31 09:26:14 +03:00
Lafactorial
9dd9ca9a53 msm8953-common : Enable uncompressed apex 2024-01-31 09:26:14 +03:00
bohu
32111b509a msm8953-common: Set ro.crypto.volume.filenames_mode to aes-256-cts
BUG: 129557601
Test:
CtsAppSecurityHostTestCases android.appsecurity.cts.AdoptableHostTest

Change-Id: I414e76714a55531f095de757d0bec066cf350f8b
2023-11-23 12:23:01 +03:00
Sebastiano Barezzi
5b77324b80 aidl: light: Implement attention light type
Change-Id: Ia7fff2a4374ad4d05718909000dc2fd99b9264f0
2023-11-23 12:23:01 +03:00
Luca Stefani
7803caae45 aidl: light: Make rgb a normal struct
No need to typedef in C++

Change-Id: I949c4319eb8f116d6cd2903a294757bacc7751a7
2023-11-23 12:23:01 +03:00
Sebastiano Barezzi
90557cd73a aidl: light: Reformat with clang-format
Change-Id: Iee8f2dc3777a95df827f33ad1f4e37f7d0f48eed
2023-11-23 12:23:01 +03:00
Luca Stefani
24951b362f aidl: light: Construct HwLight in place
They aren't used outside the ctor, let's
inline their construction.

Change-Id: Ic4f2afb24caabc42a95f94c8c150fa028975c8a5
2023-11-23 12:23:01 +03:00
Sebastiano Barezzi
4a7c545ed7 aidl: light: Use const on getLights' foreach loop
Change-Id: I00570c7315ef31e20c8265650025b4969e2d98af
2023-11-23 12:23:01 +03:00
Sebastiano Barezzi
c64c467198 aidl: light: Fix a bug where breath wouldn't be disabled when not needed
Change-Id: I65c84c845fe8fb514d6b8345013077e3d0946972
2023-11-23 12:23:01 +03:00
Sebastiano Barezzi
f3222d21ad aidl: light: Uprev to V2
Change-Id: I69ce3c31c63ed5316fec295bc2d79e060f43093b
2023-11-23 12:23:01 +03:00
Lafactorial
5e21929011 msm8953-common: parts: Fixup! Add an exported flag in manifest 2023-11-23 12:23:00 +03:00
5999a91c7b msm8953-common: Drop deprecated iorap_prefetcherd rules
* b07c12c39d
2023-11-23 12:23:00 +03:00
Giovanni Ricca
3bf8288002 msm8953-common: rootdir: Chown dt2w nodes
Change-Id: I443cdfe61d5405b08516bcef0c367e308eb8c3f0
2023-11-23 12:23:00 +03:00
Sebastiano Barezzi
8f8314792d msm8953-common: biometrics: Drop LOG_VERBOSE
* It's useless since it's the same as LOG_TAG

Change-Id: I1a15ea85f840b7af6d41b59cf01b0ec3c2457705
2023-11-16 11:50:42 +03:00
Bruno Martins
fc62b65d74 msm8953-common: biometrics: Use pragma once
Change-Id: I335b0a1b73effa6f9c0b0866052d74dc524ad99b
2023-11-16 11:50:32 +03:00
Arian
f82d205600 msm8953-common: parts: Target current sdk
Change-Id: Ia623282960775569325714ab3bff5ad027776352
2023-11-16 11:50:19 +03:00
Arian
37f0cea0da 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-16 11:49:38 +03:00
Micheal
9cce7d27ca 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-16 11:46:07 +03:00
Rick Yiu
f0db1f74ea 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-16 11:21:44 +03:00
Suren Baghdasaryan
504ebee0e2 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-16 11:21:34 +03:00
Sebastiano Barezzi
408b6db7ce msm8953-common: Raise VINTF target level to 4
Change-Id: I4c4783dc112102f127f3b1d796e206dcac672faf
2023-11-16 11:21:24 +03:00
Giovanni Ricca
076bd2b7bc msm8953-common: Drop ILocHidlGnss manifest entry
* vendor.qti.gnss@3.0-service.xml has it already

Change-Id: I5b93d9b17bb5c6a841e8ec9f9ccefe8e95dec66f
2023-11-16 11:21:12 +03:00
Yi Kong
820123482b 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-16 11:21:00 +03:00
Madhanraj Chelladurai
56f17e7b0e 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-16 11:20:47 +03:00
Yingjie Wang
6747ba859f 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-16 11:20:35 +03:00
Erfan Abdi
2bec1c24a9 msm8953-common: Set loop.max_part
Change-Id: Ibfb9e215c53111de4e8de018ea1934405468c6c9
Signed-off-by: Erfan Abdi <erfangplus@gmail.com>
2023-11-16 11:20:22 +03:00
Jiyong Park
e8d8895a55 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-16 11:19:45 +03:00
Giovanni Ricca
74bd9c3a05 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-16 11:19:26 +03:00
Alexander Martinz
7a1efce8fd 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-16 11:19:15 +03:00
Adithya R
13d9a8578b 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-16 11:18:36 +03:00
Giovanni Ricca
874047ebbf msm8953-common: rootdir: Tissot doesn't have a vendor partition
* Mi8953 in his true form :P

Change-Id: I43da62492c22f51e49ffb84830a99250dced8ae5
2023-11-16 11:16:57 +03:00
Chenyang Zhong
90adc7f248 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-16 11:16:43 +03:00
Sebastiano Barezzi
cd1f39d3b9 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-16 11:16:15 +03:00
me-cafebabe
2c6c60fd69 msm8953-common: Legacy devices doesn't support ICE Encryption
Change-Id: I07003e50aea9a8fe5bf59437e769166c8dcd4668
2023-11-16 11:15:53 +03:00
Nicholas Lim
74aa44216a msm8953-common: Drop FDE support entirely
Change-Id: Ifecd15ee6c86a4571e5a7cc961372348455c4d5c
2023-11-16 11:15:53 +03:00
Giovanni Ricca
0b73f36c77 msm8953-common: rootdir: Mount /vendor block conditionally
* Set `TARGET_IS_LEGACY := true` on BoardConfig.mk to revert back to /cust

Change-Id: Id6bbb6c5d4873032a7ce5ec1419413c661a34787
2023-11-16 11:15:52 +03:00
Lafactorial
4c093d7fb0 Revert "msm8953-common: Switch to File Based Encryption"
This reverts commit 970b7743ea.
2023-11-16 11:15:50 +03:00
Lafactorial
208c19b919 Revert "msm8953-common: Don't encrypt userdata with FBE by default"
This reverts commit 926ed69287.
2023-11-16 11:15:49 +03:00
me-cafebabe
ebb8196493 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-16 11:15:05 +03:00
me-cafebabe
420f320c14 msm8953-common: libstdc++.vendor => libstdc++_vendor
Change-Id: I478eb89aa2ac106d855b168844863032612bc8e8
2023-11-16 11:14:50 +03:00
LuK1337
87a3fb4f5e msm8953-common: Use libutils-v33 for pm-service
Change-Id: Ia998fa72d8747de18010abe6491d2c374cb7aa0a
2023-11-16 11:13:58 +03:00
LuK1337
f24d265bc8 msm8953-common: Build android.frameworks.sensorservice@1.0.vendor
Required by mm-pp-deps.

Change-Id: Iaf821dcbb07d7820f2fc3ff5ca9cca5e973360f2
2023-11-16 11:13:47 +03:00
Gabriel Biren
7028182b58 msm8953-common: Update makefile to use the AIDL Wifi Vendor HAL.
Bug: 274964641
Test: Pre-submit tests
Change-Id: I4d9114377fe75b593bbfe6a59f03d8f5d607d6a1
2023-11-16 11:13:38 +03:00
Giovanni Ricca
b5fd2634d6 msm8953-common: Enable Qcrild
Change-Id: I6eec8ed7b81acde0904d47ec6707a680b513318d
2023-09-27 18:43:02 +03:00
Giovanni Ricca
1f0a7633a9 msm8953-common: Commonize qcril blobs
This reverts commit 9a0c0303d5.

Change-Id: Ie486479236154d91d8857baa59c5ef1ceacfd1c3
2023-09-27 18:43:02 +03:00
Erfan Abdi
89c9726aaa 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-27 18:43:02 +03:00
Nolen Johnson
fc6c5290fb msm8953-common: sepolicy: Label discard_max_bytes
Change-Id: Ic4ced7dd219b5981f9327b55d4ac5a69d8504900
2023-09-27 18:43:02 +03:00
Giovanni Ricca
fa92e958d6 msm8953-common: sepolicy: Label Extcon nodes
Change-Id: Ic994af95fcd32d41ff9758a35a9496dd28280945
2023-09-27 18:43:02 +03:00
Dhina17
ef83b75034 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-27 18:43:02 +03:00
Giovanni Ricca
7ac87c2b29 msm8953-common: rootdir: Don't read bluetooth.hciattach
* Unused with our current stack anyway

Change-Id: I80dda7f78dca91bd6b1c6f200a885045048f597f
2023-09-27 18:43:02 +03:00
Giovanni Ricca
2739846c50 msm8953-common: rootdir: Don't start gamed
* We don't have this service

Change-Id: Ifa583998ec12343ff3fc0d783604520172832114
2023-09-27 18:43:02 +03:00
Giovanni Ricca
647a2a83e9 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-27 18:43:01 +03:00
Nolen Johnson
61a184dac8 msm8953-common: sepolicy: Allow hal_gnss_qti to get xtra_control_prop
Change-Id: I6eeeeb2a42b4d0c3e934af3da9ab3aaa2d4c10b4
2023-09-27 18:43:01 +03:00
Nolen Johnson
7954b7a590 msm8953-common: sepolicy: Resolve BPF denials
Change-Id: I3a4ec030a6c56f0a7a8df1b510bc9636eb74c8bd
2023-09-27 18:43:01 +03:00
Jyotiraditya Panda
91b422b83f msm8953-common: parts: Refactor ClearSpeakerFragment code
- Removed unused imports
 - Proper resource release by using try-finally block
 - Added null checks for MediaPlayer methods
 - Remove audio parameter as its unused

Change-Id: I7dc2ba7baf6e0193e13583a7454da296254d7333
Signed-off-by: Jyotiraditya Panda <jyotiraditya@aospa.co>
Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
2023-09-27 18:43:01 +03:00
Ronalds
43b4a7f02d msm8953-common: CarrierConfigOverlay: checkout to AOSPA/android_device_qcom_common@96bbd38 2023-09-27 18:43:01 +03:00
Midas Chien
2afa3215b9 msm8953-common: properties: don't latch unsignal buffers
Set debug.sf.latch_unsignaled=1 is used to allow surfaceflinger to
latch unsignal buffers that can give more time for buffer to render.
But if the buffer takes longer time to finish, it will block whole
display pipeline result to jank.

Bug: 157964883
Test: scrolling, launch
Change-Id: I56c3e05921de5fc9569bf3f93fde03022a64b6a4
2023-09-27 18:43:00 +03:00
Alone0316
5a56824d27 msm8953-common: Build qcom.fmradio 2023-09-27 18:43:00 +03:00
7d75521921 msm8953-common: Switch to standard FMRadio and libfmjni 2023-09-27 18:43:00 +03:00
Michael Bestas
101095deca msm8953-common: ueventd: Remove all permissions from /sys/devices/soc0/serial_number
Change-Id: I688347cfe59f56e4de2e4bf3c3324ca465f7a897
2023-09-27 18:43:00 +03:00
Michael Bestas
c5aa127cda 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-27 18:43:00 +03:00
Michael Bestas
c84427bd2d 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-27 18:43:00 +03:00
Albert I
2a9eeae92f 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-27 18:43:00 +03:00
Albert I
74af30ca6b 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-27 18:43:00 +03:00
dib12
d5318c287c msm8953-common: Update wifi config from daisy 2023-09-27 18:43:00 +03:00
Mao Jinlong
8241b05200 msm8953-common: rootdir: Add power off alarm service 2023-09-27 18:43:00 +03:00
Bruno Martins
cfd275ee2d 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-09-27 18:43:00 +03:00
092147345f fixup! msm8953-common: Do not allow backups of overlays
cmdline used:
find . -type f -name "*.xml" -exec sed -i '/android:hasCode="false"/ { /android:allowBackup="false"\/>/! s/\/>/ android:allowBackup="false"\/>/; }' {} +
2023-09-27 18:43:00 +03:00
Luofan Chen
03e714cbea msm8953-common: Build lineage health HAL
Change-Id: I1ca5f25f3a2d8734647b9cc0ff4885b0b817c6ad
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
2023-09-27 18:43:00 +03:00
me-cafebabe
719bcce3f0 msm8953-common: Disable Bluetooth APCF Extended features
* Yet another disablement we need, to have bluetooth working properly on A13 (QPR2)
2023-09-27 18:42:59 +03:00
27d17a9345 msm8953-common: rro_overlays: Exclude from Google backup 2023-09-27 18:42:59 +03:00
f765978dbb msm8953-common: Bring back FM support and use RevampedFMRadio
* https://github.com/iusmac/RevampedFMRadio

Revert "msm8953-common: Drop FM support"

This reverts commit bf498de7ee078179cd31e6398008a1acc113d962.
2023-09-27 18:42:59 +03:00
Lafactorial
262f01ef23 msm8953-common: Remove dead targets 2023-09-27 18:42:59 +03:00
Alexander Martinz
95ec5731d3 msm8953-common: Drop aptx blobs
They live within the bluetooth apex now.

Change-Id: I01ef1d665ce05b7ce5b1ee03129ccf3ce6058634
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
2023-03-22 11:43:00 +03:00
anandhan07
c39fdc5059 msm8953-common: overlay: Improve carrier mnc attributes for Indian carriers
- Set mnc attributes without commas
- Also enable VoLTE and other servies for all mcc 404, 405 (Including Airtel, VI, Jio)

Signed-off-by: anandhan07 <anandhasayanan007jb@gmail.com>
2023-03-09 08:00:11 +03:00
pengfeix
083ba7f5e8 msm8953-common: overlay: Enable IMS feature flags for supported carriers
- Enable VoLTE/VoWIFI for all indian cariers
- Enable VoLTE for Viettel Vietnam
- Enable VoLTE for Mobifone Vietnam
- Add full Support Carrier Smartfren VoLTE
- Enable VoLTE support for Indosat and XL Axiata
- Enable VoLTE support for Telkomsel (Indonesia)
- Enable VoLTE support for Three
- Enable VoLTE support for Bakcell (Azerbaijan)

Co-authored-by: hungphan2001 <phandinhhungvp2001@gmail.com>
Co-authored-by: heisinbug <me@heisinbug.tech>
Co-authored-by: Zaviyar786 <Zaviyar786@users.noreply.github.com>
Co-authored-by: krasCGQ <kras@raphielgang.org>
Co-authored-by: xboxfanj <jake@aospa.co>
Co-authored-by: rayrzy <vincentrayananda@gmail.com>
Co-authored-by: Jabiyeff <cebiyevanar@gmail.com>
Signed-off-by: anandhan07 <anandhasayanan007jb@gmail.com>
2023-03-09 08:00:11 +03:00
Dyneteve
497c5846f5 msm8953-common: CarrierConfig: Enable voLTE/voWIFI/ViLTE for entire 460 mcc
* All of them support volte/vowifi/vilte

Change-Id: I4ea83037cbafe225d7610d1e73a1d0489819e666
2023-03-09 08:00:11 +03:00
Chenyang Zhong
c69faaf054 msm8953-common: overlay: update CarrierConfig from star V14.0.6.0.TKACNXM
Signed-off-by: Chenyang Zhong <zhongcy95@gmail.com>
2023-03-09 08:00:11 +03:00
Pranav Vashi
0a8bd13d9b msm8953-common: Switch to jemalloc for libc
* Benchmark shows improvement.
2023-03-09 08:00:11 +03:00
Dyneteve
317ebaa3fe msm8953-common: CarrierConfig: Enable voLTE/voWIFI/ViLTE for entire 460 mcc
Enable ViLTE for Airtel (India) & 404 mcc
Enable VoWiFi & ViLTE for Airtel (UP)

Co-authored-by: dasshubham762 <dasshubham762@gmail.com>
Signed-off-by: P-Salik <peersalik16@gmail.com>
Signed-off-by: saikiran2001 <bjsaikiran@gmail.com>
2023-02-18 14:55:29 +03:00
Lucchetto
7253ca0292 msm8953-common: update datastatusnotification from coral [1/2]
Fixes weird behaviour when using two sim cards.

Change-Id: I408a01bbe0309bf31fbffd8374d1d795747c4724
Signed-off-by: Lucchetto <lucchetto.tie@live.com>
2023-02-15 11:31:58 +03:00
dianlujitao
cfb73bd08c msm8953-common: sepolicy: Address dataservice denials
Change-Id: I4dd19571d45fdb9c223968c1c342c5e041f1d469
Signed-off-by: dotkit <ewprjkt@proton.me>
2023-02-15 11:31:58 +03:00
Vivekachooz
e420a1075e msm8953-common: rootdir: Drop cpuset creation from postboot
Change-Id: Idd2632843ee3f74487346acb57fd53ca9ec153f0
Signed-off-by: dotkit <ewprjkt@proton.me>
2023-02-15 11:31:58 +03:00
Brock5555
6051d3a3ff msm8953-common: init: Register and enable qcrild & data services on boot
* Fixes delay on getting network service after boot

Change-Id: Ibed5c5addb307d89f26cbf51420e37f1b04c42e5
Signed-off-by: wanderlusttt1 <bharathraju049@gmail.com>
Signed-off-by: dotkit <ewprjkt@proton.me>
2023-02-15 11:31:57 +03:00
me-cafebabe
38295a6cd1 msm8953-common: Disable bluetooth enhanced SCO connection 2023-02-15 11:31:17 +03:00
Giovanni Ricca
b2564777f2 msm8953-common: Drop renderscript bits
grep -nR libRSDriver_adreno
grep: msm8953-common/proprietary/vendor/lib64/librs_adreno_sha1.so: binary file matches
grep: msm8953-common/proprietary/vendor/lib64/librs_adreno.so: binary file matches
grep: msm8953-common/proprietary/vendor/lib/librs_adreno_sha1.so: binary file matches
grep: msm8953-common/proprietary/vendor/lib/librs_adreno.so: binary file matches

Change-Id: I546990833edbedd969c5317f674761b33d5473f8
2023-02-08 11:30:55 +03:00
Abhinav Gupta
3373bfc8fc msm8953-common: Bump target level to 3 2023-02-08 11:28:49 +03:00
Artem Borisov
b9237e97f6 msm8953-common: Bind-mount firmware and persist to root on A/B
* Our fingerprint blobs still search for /firmware and /persist
* While symlinking works for standalone builds, it doesn't work with treble

Change-Id: Id4b07be55ae332114ced014155a97b746abc6ad6
2023-02-08 11:28:38 +03:00
Jorim Jaggi
08b5dd68ed 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-02-08 11:28:23 +03:00
Lafactorial
6db5f1acee Parts: Update Turkish translations 2023-02-08 11:26:33 +03:00
Reinazhard
7330961289 msm8953-common: set NUM_FRAMEBUFFER_SURFACE_BUFFERS
- Kanged from CAF product-board
- This also fixed triple frame buffer regression
- Nuke triple frame buffer from prop as it causing regression
- Also nuked duplicate declaration at system.prop

Signed-off-by: Reinazhard <reinazhard@gmail.com>
Signed-off-by: clarencelol <clarencekuiek@icloud.com>
Signed-off-by: OmarAlCoptan <omarcoptan9@gmail.com>
Signed-off-by: Cykeek <Cykeek@proton.me>
Signed-off-by: kssrao13882 <kssrao13882@gmail.com>
2023-01-17 12:34:20 +03:00
Lafactorial
518fd286a7 Revert "msm8953-common: Force triple frame buffers"
This reverts commit b69637ceec.
2023-01-17 12:34:20 +03:00
kssrao13882
0fe6e8dd8c msm8953-common: obsolete debug.sf.disable_backpressure property
Signed-off-by: kssrao13882 <kssrao13882@gmail.com>
2023-01-17 12:34:20 +03:00
DarkJoker360
008f8b7895 msm8953-common: rootdir: Stop bootanimation service after boot
* Some users reported bootanimation lags and freezes
  after a while. Looking from logs it fails to exit
  once boot is completed. Stopping bootanimation
  service, as workaround, is preventing this issue.

Signed-off-by: improbir <ghosh_probir@yahoo.com>
Signed-off-by: kssrao13882 <kssrao13882@gmail.com>
2023-01-10 17:12:30 +03:00
xenxynon
fac35a85b2 msm8953-common: props: Drop debug.hwui.use_buffer_age
- Fixes lags & UI freeze after QPR1 merge.
2023-01-10 17:12:29 +03:00
Jun Wang
bee6f0ead2 msm8953-common: Disable Skia tracing by default
If the prop "debug.hwui.skia_atrace_enabled" is enabled, too many
skia tracing calls will be printed in every frame. This has obvious
overhead on performance/power, and can cause many janks. So disable
it by default, and user can set it manually if necessary.
2023-01-10 17:12:08 +03:00
Vinay Verma
1809e8eb13 msm8953-common: Disable Async MTE on System Server
Async mode MTE is enabled by default on System Server process.
Add property arm64.memtag.process.system_server=off
This property is read during system server forking process and
accordingly Heap Tagging level is set.
2023-01-10 17:12:08 +03:00
zeelog
b2035a2bd4 msm8953-common: Drop rild libargs property 2023-01-10 17:12:07 +03:00
Michael Bestas
73bbc13b10 msm8953-common: sepolicy: legacy: Allow init write to discard_max_bytes
system/core/rootdir/init.rc
1110:    write /dev/sys/block/by-name/userdata/queue/discard_max_bytes 134217728
1111:    write /dev/sys/block/by-name/rootdisk/queue/discard_max_bytes 134217728

Fixes: avc: denied { write } for comm="init" name="discard_max_bytes"
    dev="sysfs" ino=55527 scontext=u:r:init:s0
    tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
2023-01-10 17:12:07 +03:00
Demon000
974689ab34 msm8953-common: remove DEVICE_PROVISIONED 2023-01-10 17:12:06 +03:00
zeelog
22f52fdf1b msm8953-common: Ditch persist.rild.nitz_* props 2023-01-10 17:12:06 +03:00
Lafactorial
36fe3d3b7b msm8953-common: Disable SF client composition cache
Disable SF client composition cache. Helps with framework client target
fence management.

Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
2022-12-30 09:11:41 +03:00
Lafactorial
64fdd6d78d msm8953-common: Disable HWC composition strategy prediction
Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
2022-12-30 09:11:41 +03:00
Lafactorial
109a16ff8e msm8953-common: Disable continuous transaction tracing on all build types
Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
2022-12-30 09:11:41 +03:00
mrjarvis698
658c6303d9 msm8953-common: advance logcat debugging : Enabled using init.target.rc
- This Don't needed PC for logs.
- Even Takes logs with adb offline issue.
- Even It Takes Logs while on Splash Screen (experimental).
- Advance
- Takes Logs in Full, Crash and Kernel Logs Seperately.
- It will Save Logs to /cache .
2022-12-30 09:11:41 +03:00
Chris Fries
6f2f3cb961 msm8953-common: Set printk.devkmsg=on on kernel cmdline to avoid ratelimit
init and friends are getting ratelimted on /dev/kmsg.  Let's keep
the logs by setting printk.devkmsg=on.

Bug: 62952768
Test: Check for init logs in kernel during boot
Change-Id: I103e3cc1d73880af1d9a0cdc4dae05223eb4c427
Signed-off-by: Mohammad Hasan Keramat J <ikeramat@protonmail.com>
Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
2022-12-30 09:11:41 +03:00
Lafactorial
cd9a877279 msm8953-common: parts: Fix compilation for QPR1 merge
Change-Id: I71ad7db85592ca18e3f0f8155bba5a472bfadbaa
2022-12-27 12:02:43 +03:00
Lafactorial
fd1b3fd958 Parts: Update Turkish translations 2022-12-27 12:02:16 +03:00
AshutoshSundresh
a75173cbd0 msm8953-common: parts: Add icon for Clear Speaker
* Source: d9d25ff406

Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
Signed-off-by: Joey Huab <joey@evolution-x.org>
2022-12-27 12:02:15 +03:00
Volodymyr Zhdanov
f62aee08f9 msm8953-common: parts: Fix Clear Speaker IllegalStateException
* trace:
  E AndroidRuntime: java.lang.IllegalStateException
  E AndroidRuntime: 	at android.media.MediaPlayer._stop(Native Method)
  E AndroidRuntime: 	at android.media.MediaPlayer.stop(MediaPlayer.java:1397)

* also do small refactoring while at it

Former-commit-id: 98f1335384a6b534becf87ad54333f737de9e15e
Signed-off-by: Joey Huab <joey@evolution-x.org>
2022-12-27 12:02:15 +03:00
Adithya R
d1ccb816ad msm8953-common: parts: Add headphones warning for clear speaker
Change-Id: I70ad24bceac2f6538e1fbfd79d70bd5ca64eee07
Signed-off-by: Joey Huab <joey@evolution-x.org>
2022-12-27 12:02:15 +03:00
Adithya R
0ac3f45ce2 msm8953-common: parts: Update clear speaker audio from MIUI 12
Change-Id: I7aada005798a6ef1e07f3b2424fd02ba58293018
Signed-off-by: Joey Huab <joey@evolution-x.org>
2022-12-27 12:02:14 +03:00
Jyotiraditya
dbfce89d8d msm8953-common: parts: Implement Clear Speaker
* [Stallix] - Adapt for S style

Co-authored-by: Adithya R <radithya2002@gmail.com>
Co-authored-by: Joey Huab <joey@evolution-x.org>
Signed-off-by: Jyotiraditya <jyotiraditya@aospa.co>
Change-Id: I23b8ebd106502e083b6feec9b58efd76e49d3367
Signed-off-by: Joey Huab <joey@evolution-x.org>
2022-12-27 12:02:14 +03:00
Lafactorial
062ef1bd2f Parts: Import Turkish translations 2022-12-27 12:02:13 +03:00
zhantech
f7339f7400 msm8953-common: Import XiaomiParts for A13
Feature :
Kcal
Dirac
Sound Control
Torch
Doze
Vibrate Control
2022-12-27 12:02:13 +03:00
Lafactorial
c78829d7bb Revert "msm8953-common: parts: Disable startup provider"
This reverts commit f95c54c2b8.
2022-12-27 12:02:11 +03:00
Lafactorial
e9dfd70662 Revert "msm8953-common: switch to crDroid doze package"
This reverts commit 4c1fb4ecc2.
2022-12-27 12:02:11 +03:00
Lafactorial
e73a9a5dd0 msm8953-common: remove gabuters clang 2022-12-22 16:14:04 +03:00
Hakan
87f1ee8312 msm8953-common: Opt-out for LLVM binutils 2022-12-22 16:12:42 +03:00
Lafactorial
8880fc9493 msm8953-common: parts: Fix compilation for QPR1 merge 2022-12-22 16:09:04 +03:00
Lafactorial
059afa5365 Revert "msm8953-common: Add overlays & Address Denials for QS System Info"
This reverts commit 7ff0bde8a7.
2022-12-22 16:04:55 +03:00
Lafactorial
a69a7c128d Revert "Fix up battery health for ricedroid"
This reverts commit c766c9ced5.
2022-12-22 16:04:04 +03:00
Lafactorial
ac0c2d1296 Revert "Fix up QS System Info"
This reverts commit cd2afa4629.
2022-12-22 16:03:43 +03:00
GhostMaster69-dev
edf63b7a82 msm8953-common: overlay: Drop redundant config_pinnerHomeApp
* by default false.

Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
2022-11-22 11:56:23 +03:00
GhostMaster69-dev
1b3442b393 msm8953-common: init.qcom.rc: add readproc and wakelock group for second rild
Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
2022-11-22 11:56:22 +03:00
Suren Baghdasaryan
7eaa1b32cb 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: If0a64b9f335ad13f65522361b125cab951002a2c
Signed-off-by: Sonal Singh <sonal.singh.19993@gmail.com>
Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
2022-11-22 11:56:22 +03:00
Kshitij Gupta
685a977c90 msm8953-common: sepolicy: Dontaudit untrusted_app to open ashmem_device
- Fixes scroll lag in many apps, such as Twitter:
    W RenderThread: type=1400 audit(0.0:12371): avc: denied { open } for path=/dev/ashmem dev=tmpfs ino=10848 scontext=u:r:untrusted_app:s0:c123,c256,c512,c768 tcontext=u:object_r:ashmem_device:s0 tclass=chr_file permissive=0 app=com.twitter.android
- Apps are no longer allowed open access to /dev/ashmem, unless they
  target API level < Q.
  (8b12ff5f21)

Change-Id: I6405786fea05891642d8437acafcd8c891d75912
Signed-off-by: chrisw444 <wandersonrodriguesf1@gmail.com>
2022-11-22 11:56:22 +03:00
Georg Veichtlbauer
8e7cf53123 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
2022-11-16 15:04:54 +03:00
abhinavgupta371
fdd2bb370e Revert "msm8953-common: properties: don't latch unsignal buffers"
This reverts commit f8853496f5.
2022-11-16 10:26:36 +03:00
Hakan
6565ccb74a msm8953-common: Remove AudioFX 2022-11-15 15:40:42 +03:00
Lunarixus
9f49ea8373 msm8953-common: Remove packages at build time 2022-11-15 15:19:55 +03:00
Giovanni Ricca
69ae541886 msm8953-common: biometrics: Create fingerprint /data dirs
Change-Id: Ic474758d5727113536a0bb1201e594ab8f6a9d2d
2022-11-15 14:42:23 +03:00
Lafactorial
1dfae34aeb msm8953-common: parts: Move Xiaomi Doze inside stock ambient display preference
Change-Id: I8193fe58411e491155fa6c68d4a3e7bacc1fcbe5
Signed-off-by: Joey Huab <joey@evolution-x.org>
2022-11-15 14:26:25 +03:00
Alexander Martinz
b78903e1fd 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>
2022-11-15 14:25:08 +03:00
Danny Trunk
6c028562ca msm8953-common: Do not block binder thread on incoming calls
Change-Id: I6a2c41e35cc3514e60e104d8eb967f331176594e
2022-11-15 14:24:31 +03:00
Lafactorial
cd2afa4629 Fix up QS System Info 2022-11-15 14:21:47 +03:00
Lafactorial
c766c9ced5 Fix up battery health for ricedroid 2022-11-15 14:21:36 +03:00
Jimgsey
7ff0bde8a7 msm8953-common: Add overlays & Address Denials for QS System Info
Signed-off-by: kssrao13882 <kssrao13882@gmail.com>
2022-11-15 14:21:22 +03:00
Giovanni Ricca
00892d4894 msm8953-common: rootdir: Rollback to previous alarm persist folder permissions
* There is actually no need for that ...

Change-Id: I71fb4bce54d341bac2f3fd23983730fbe71ad0cb
2022-11-15 14:14:08 +03:00
Michael Bestas
39a5bc0d77 msm8953-common: Automatically add apk/jar/vintf fragments to PRODUCT_PACKAGES
Change-Id: Iaa9d66b0bbdc55f046ee1347cbf83c7eecebb35e
2022-11-15 14:13:50 +03:00
Georg Veichtlbauer
623503bb77 msm8953-common: Fix PowerOffAlarm
* The APK is prepared to not run as system user
* Adjust /persist/alarm/data permissions accordingly

Change-Id: Ie24ccb3749d1dda2deb670cdb531e35d153034ed
2022-11-15 14:13:50 +03:00
Qimeng Pan
02b9fd2511 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
2022-11-15 14:13:49 +03:00
Mao Jinlong
64366b9d6d 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
2022-11-15 14:13:49 +03:00
Mao Jinlong
b4b69f57aa 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
2022-11-15 14:13:49 +03:00
Tim Lin
3d9788ee26 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
2022-11-15 14:13:26 +03:00
LuK1337
21e4db11ee msm8953-common: Rework way to prevent adding duplicate dependencies
Change-Id: I2eb6484dbe3a9fddc883bf1290da1b76c4e1c54c
2022-11-15 14:13:14 +03:00
Nolen Johnson
c48d5ffc7f msm8953-common: Move to libhidl shim in hardware/lineage/compat
Change-Id: Ia2cd305baf3ce0fa7ac52d440a4ff51f94654438
2022-11-15 14:00:34 +03:00
Nolen Johnson
cedd2972f1 msm8953-common: Move to libgui shim in hardware/lineage/compat
Change-Id: I04c4e15c6128de33ab7124de28b2fbd82eb2d62a
2022-11-15 14:00:34 +03:00
Nolen Johnson
61d33be9c9 msm8953-common: Move to libcutils shim in hardware/lineage/compat
Change-Id: I96b8485c1a868e271607cf205ac1366dc77f69d0
2022-11-15 14:00:34 +03:00
Giovanni Ricca
1a71bca956 msm8953-common: Remove reorder libs
* Is now inside tools/extract-utils/

Change-Id: Ia7682e69b388bc82877a0d62c4bf2def8e787d3f
2022-11-15 14:00:10 +03:00
Aaron Kling
d3148a2395 msm8953-common: Remove references to a2dp module
APM would fail to parse the config anyway:

  E DevicesFactoryHAL: loadAudioInterface couldn't load audio hw module audio.a2dp (No such file or directory)
  W DevicesFactoryHalHidl: The specified device name is not recognized: "a2dp"
  E AudioFlinger: loadHwModule() error -22 loading module a2dp
  W APM_AudioPolicyManager: could not open HW module a2dp

Change-Id: Iaa1be881cfe8f8474cef0ba46e1b0a62b59e14be
2022-11-02 08:15:39 +03:00
Nitin Shivpure
725a67c878 msm8953-common: Removing unused ANT/BT includes & system properties
Removing unused ANT/BT includes & target specific system
properties.

Change-Id: Icc63960bfb30edd858999edf8d784e501bdbc15d
2022-11-02 08:15:39 +03:00
Bruno Martins
16ad490b5c msm8953-common: Remove QTI BT stack bits
Change-Id: Ice6c2b0735aa7cb4b2e638a794c778883e706c97
2022-11-02 08:15:38 +03:00
Lafactorial
77a38eb715 sm8953-common: parts: Import Turkish translations 2022-11-02 08:15:38 +03:00
Lafactorial
d6ff82e99d msm8953-common: sepolicy: Address FM Radio app denial 2022-11-02 08:15:38 +03:00
Lafactorial
1f8dec641d Revert "msm8953-common: Temporarily disable bootanimation"
This reverts commit 6d5005b3ef.
2022-11-02 08:15:38 +03:00
GhostMaster69-dev
7c108d2237 msm8953-common: Pass LLVM_IAS=1 to use LLVM's integrated assembler
Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
2022-10-26 14:16:04 +03:00
kerneltoast
b69637ceec msm8953-common: Force triple frame buffers
Signed-off-by: MadhavSaladi <baaswanthmadhav@gmail.com>
2022-10-26 14:14:44 +03:00
Lafactorial
debfeedca2 msm8953-common: Disable VSync for CPU rendered apps
Choreographer VSync has some performance impact for CPU rendered apps
as the app has to wait for VSync to start a new frame draw. When the
frame draw time exceeds one VSync, this has a direct impact on the FPS.
"debug.cpurend.vsync" property controls the VSync for CPU rendered apps.

Disable VSync for CPU rendered app, by setting this property to false.

Change-Id: I93cfa7c588f1ab80803940c8059073075fd49506
Signed-off-by: kaderbava <ksbava7325@gmail.com>
2022-10-26 14:13:56 +03:00
Lafactorial
ba4f51c555 msm8953-common: Follow more recent tree changes 2022-10-26 14:09:57 +03:00
Michael Wright
fa7c1ee547 msm8953-common: overlay: Enable haptic text cursor
Support has landed in WebView, so time to turn it on in framework!

Change-Id: I064cf3512928637895932b3405adaec74b1ceed2
Signed-off-by: DhruvChhura <dhruvchhura18@gmail.com>
2022-10-26 14:05:18 +03:00
Alexander Koskovich
1b4c3dc88c msm8953-common: Add Bluetooth power overlays to sysprops
* These are currently in FrameworksResTarget, but were
   moved to sysprops in Android 13.

   976d33062b%5E%21/#F0

Change-Id: I5bff67a15c537e8a47a19f30776fca6bf2c9fbe5
2022-10-26 13:59:50 +03:00
Ethan Chen
e8a9971c78 msm8953-common: Add AOSP RCS packages
Change-Id: Ic16d3b92820d246db73ad70ccaa0f4bc7f50e515
2022-10-26 13:55:45 +03:00
althafvly
a6b086e63a msm8953-common: Update CarrierConfig from munch V13.0.4.0.SLMMIXM
- Merged stock miui xmls
- set config_update_service_status false
  sed -i 's/"config_update_service_status" value="true"/"config_update_service_status" value="false"/g'

Change-Id: I9c434f1eca6fab8cc32c8bf8c241afc32d0d849e
2022-10-26 13:55:45 +03:00
Quallenauge
bc755dcea1 msm8953-common: rootdir: Limit cpufreq rate via down-/up_rate_limit_us knobs.
This prevents to change the frequency in a very short
manner which seems to fast for the hardware and
causes performance drops.

Change-Id: I678d6dc3dc81d756ba1b2031cd369d95d9298ac0
2022-10-26 13:54:32 +03:00
kevinjava
f95c54c2b8 msm8953-common: parts: Disable startup provider
Attribute provider#androidx.startup.InitializationProvider@authorities value=(androidx.legacy.preference.androidx-startup) from AndroidManifest.xml:34:13-78
        is also present at AndroidManifest.xml:43:13-75 value=(com.android.settingslib.androidx-startup).
        Suggestion: add 'tools:replace="android:authorities"' to <provider> element at AndroidManifest.xml.fixed:32:9-43:20 to override.

Change-Id: I468f595da6570f7a6f8e199a6413e94291d2c0cb
2022-10-26 13:54:31 +03:00
Hakan
6d5005b3ef msm8953-common: Temporarily disable bootanimation 2022-10-26 13:54:31 +03:00
Lafactorial
b01d4f2924 Fix up smart charging for crdroid 2022-10-26 13:54:31 +03:00
Hakan
8f27b7994a Remove non-existent modules 2022-10-26 13:52:35 +03:00
Lafactorial
1ac3f995b6 msm8953-common: use gabuters clang 2022-10-21 09:08:59 +03:00
Lafactorial
b0d11ca210 Clean up some packages 2022-10-21 09:06:38 +03:00
Lafactorial
c1d10a8043 msm8953-common: Parts: Remove unnecessary static libs
Signed-off-by: Aoihara <aoihara@nusantararom.org>
Signed-off-by: Edwiin Kusuma Jaya <kutemeikito0905@gmail.com>
2022-10-21 09:00:54 +03:00
zhantech
d165159daa msm8953-common: Add FM Tuner from audio input devices 2022-10-21 09:00:33 +03:00
Shalini Manjunatha
ef7b1521bc msm8953-common: audio: Add built-in/Back mic and remove TelePhony Rx from primary input
Built-in mic and Built-In Back Mic aren't in supported devices
list of primary input, Add them to primary input sources to
reuse input to avoid to open extra input stream in AHAL
Also remove Telephony Rx to make in call record use case through
different front end pcm device when sva enabled to solve concurrency
capture issue

Change-Id: I8a036423da689a4de9abe767a0b6a595b4e068f1
2022-10-21 08:54:22 +03:00
Ivan Vecera
3d3a3874b0 msm8953-common: sepolicy: Allow system_app to access vmallocinfo
W pool-2-thread-6: type=1400 audit(0.0:1073): avc: denied { read } for name="vmallocinfo" dev="proc" ino=4026532121 scontext=u:r:system_app:s0 tcontext=u:object_r:proc_vmallocinfo:s0 tclass=file permissive=0
2022-10-21 08:47:06 +03:00
haggertk
e47747d587 msm8953-common: sepolicy: Allow system_app to read /proc/pagetypeinfo
W pool-2-thread-8: type=1400 audit(0.0:1065): avc: denied { read } for name="pagetypeinfo" dev="proc" ino=4026532117 scontext=u:r:system_app:s0 tcontext=u:object_r:proc_pagetypeinfo:s0 tclass=file permissive=0
2022-10-21 08:47:06 +03:00
Meto
752f040f46 msm8953-common: sepolicy: Fix avc denials related to hal_fingerprint_default
W fingerprint@2.1: type=1400 audit(0.0:1101): avc: denied { open } for name="/" dev="mmcblk0p49" ino=2 scontext=u:r:hal_fingerprint_default:s0 tcontext=u:object_r:system_data_root_file:s0 tclass=dir permissive=0
W fingerprint@2.1: type=1400 audit(0.0:1101): avc: denied { read } for name="/" dev="mmcblk0p49" ino=2 scontext=u:r:hal_fingerprint_default:s0 tcontext=u:object_r:system_data_root_file:s0 tclass=dir permissive=0
2022-10-21 08:47:05 +03:00
Meto
98e3882980 msm8953-common: sepolicy: Address hal_fingerprint denial
W fingerprint@2.1: type=1400 audit(0.0:1106): avc: denied { read } for name="/" dev="mmcblk0p49" ino=2 scontext=u:r:hal_fingerprint_default:s0 tcontext=u:object_r:system_data_root_file:s0 tclass=dir permissive=0
2022-10-21 08:47:05 +03:00
Kevin F. Haggerty
f381efbe9a msm8953-common: sepolicy: Allow system_app to access zram sysfs nodes
* It fixes:
   * avc: denied { search } for name="zram0" dev="sysfs" ino=33927 scontext=u:r:system_app:s0 tcontext=u:object_r:sysfs_zram:s0 tclass=dir permissive=0
2022-10-21 08:46:42 +03:00
baunilla
5970ba62cf msm8953-common: sepolicy: Label goodix debug prop 2022-10-21 08:44:49 +03:00
minaripenguin37
fb70882de2 msm8953-common: Allow usage of custom binary linker (LD)
- Inline with latest Change in source

Signed-off-by: kssrao13882 <kssrao13882@gmail.com>
2022-10-21 08:44:01 +03:00
GhostMaster69-dev
05587d6b8d msm8953-common: Compile kernel with make LLVM=1
Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
Signed-off-by: Ansh <singhansh64321@gmail.com>
2022-10-21 08:44:01 +03:00
GhostMaster69-dev
4e81f54193 msm8953-common: Override default Android binutils for arm64
Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
Signed-off-by: Ansh <singhansh64321@gmail.com>
2022-10-21 08:44:01 +03:00
Giovix92
a689ee6161 msm8953-common: Clear settings cache after dirty flash
* This helps after a dirty flash, in order to avoid broken strings on settings app

Signed-off-by: smokey18 <kmboplays@gmail.com>
Signed-off-by: Cykeek <Cykeek@proton.me>
Signed-off-by: kssrao13882 <kssrao13882@gmail.com>
2022-10-21 08:36:15 +03:00
Nolen Johnson
63cb004806 msm8953-common: AOSP WFD doesn't support protected Wi-Fi Display buffers
Change-Id: I971373b5c57b8591b1bf676849cc511f8a425023
(cherry picked from commit d52231052828d4390d630681d651874ffb50388b)
2022-10-21 08:35:04 +03:00
Georg Veichtlbauer
245a559013 msm8953-common: Drop config_setColorTransformAccelerated
It's now enabled by default

Change-Id: I57f059c872fc2ad2fd15e788b1391eeebaff9bde
2022-10-21 08:34:45 +03:00
Nate Jiang
de9b3869e6 msm8953-common: wifi: Enable set channel on NDP setup
Bug: 190354626
Test: build, CtsVerifier
Change-Id: Ieff18b96ec0f24c1c20c40add4e47a532ece8922
2022-10-21 08:33:22 +03:00
Les Lee
e69066d5c9 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
2022-10-21 08:33:22 +03:00
jro1979oliver
5a2b6491eb msm8953-common: Add tethering usb props
Change-Id: I841feaa53db18b3e765a0a864ca062b6ff4ee27e
2022-10-21 08:33:22 +03:00
Sevenrock
72004fe4af msm8953-common: add ro.hw_timeout_multiplier
Fixes watchdog kicking in while formatting huge sdcards.

Change-Id: I60e8acff8a9f113e3f12f31061e0bb9b1fe24e46
2022-10-21 08:33:22 +03:00
Woody Lin
4b8e10d156 msm8953-common: Enable zygote critical window
Bug: 141948707
Change-Id: I5dc57312118b0f6d95fc9fe164363ec7e15f1b51
2022-10-21 08:33:22 +03:00
Mohammed Mirza Mandayappurath Manzoor
de1ced888f 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
2022-10-21 08:33:22 +03:00
Bruno Martins
07d168e8a5 msm8953-common: Migrate to AIDL ClearKey DRM HAL
Change-Id: Iad5cc1176978137c647069197b33f49fb4d98ab2
2022-10-21 08:33:22 +03:00
Bruno Martins
f26c7a1e87 msm8953-common: Drop default DRM service
This is not needed, since Widevine DRM and Clearkey DRM
services are available.

Change-Id: I97023f1bab88ddb8fa4cb205df190c516a759951
2022-10-21 08:33:22 +03:00
Bruno Martins
cb0890bc6b msm8953-common: Drop custom APM flag
Custom audio policy manager is hard disabled by CAF
for 2 years now.

Change-Id: Idd34d1cbbdb735d6cf0de3b159c2670bf7ddd1e3
2022-10-21 08:33:21 +03:00
Michael Bestas
c859a0d6e9 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
2022-10-21 08:31:44 +03:00
Bruno Martins
4d325a507e msm8953-common: Drop component overrides
This is no longer needed as of Android 13.

Change-Id: I38435c47c8781678f82014decbbae40dcab0a07b
2022-10-21 08:30:43 +03:00
Georg Veichtlbauer
dd9a4cafd4 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
2022-10-21 08:30:22 +03:00
Santiago Seifert
8d7ab9285e msm8953-common: overlay: Unpin updatable-media from memory
Bug: 214499288
Change-Id: I83757ae6a053ec6b10b08322c4e76d988f1a4a48
Test: Presubmit
Signed-off-by: Jabiyeff <cebiyevanar@gmail.com>
2022-10-21 08:13:40 +03:00
daniml3
5319fac60f msm8953-common: generate the ndk_platform backend
Signed-off-by: daniml3 <daniel@danielml.dev>
Change-Id: I968e4acbf6018a0fe3ebade191a3aa206bd829cc
Signed-off-by: Jabiyeff <cebiyevanar@gmail.com>
2022-10-21 08:13:26 +03:00
Lafactorial
4c7aab9f33 [DNM] msm8953-common: Set TARGET_HAS_BROKEN_WLAN_SET_INTERFACE 2022-09-26 11:31:30 +03:00
Lafactorial
27db42d5fa msm8953-common: use proton clang 2022-09-21 11:32:17 +03:00
Sal Savage
42ae243a63 msm8953-common: prop: 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
Signed-off-by: Jabiyeff <cebiyevanar@gmail.com>
Signed-off-by: ItoRenz <itorenz@nusantararom.org>
2022-09-21 11:32:07 +03:00
Jabiyeff
8c1e63b85e msm8953-common: prop: Remove Bluetooth SAP service property
* Breaks bluetooth connection

Signed-off-by: Jabiyeff <cebiyevanar@gmail.com>
Signed-off-by: ItoRenz <itorenz@nusantararom.org>
2022-09-21 11:32:07 +03:00
Lafactorial
2a6473605b msm8953-common: overlay: fixup! Enable Smart Charging 2022-09-21 11:31:38 +03:00
trautamaki
d19ebbc309 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
2022-09-21 11:31:23 +03:00
me-cafebabe
926ed69287 msm8953-common: Don't encrypt userdata with FBE by default
Let the user decide it by patching fstab.

Commands to patch fstab to enable FBE:
```
sed -i '/^\/dev\/block\/bootdevice\/by-name\/userdata/d' fstab.qcom
sed -i 's|^# FBE ||g' fstab.qcom
```

Signed-off-by: ItoRenz <itorenz@nusantararom.org>
2022-09-21 11:31:06 +03:00
zhantech
970b7743ea msm8953-common: Switch to File Based Encryption 2022-09-21 11:31:06 +03:00
Kujou Yuko
a0ee239bf4 msm8953-common: Enable Audio Support for Hearing Aids central support
Signed-off-by: Kujou Yuko <i@779.moe>
Signed-off-by: Pranav Temkar <pranavtemkar@gmail.com>
Change-Id: I792a9715f17c1f17fb8b9a524cabed901d3e6f4a
2022-09-21 11:31:06 +03:00
Alice Kuo
1963a1307e msm8953-common: Disable LE audio related profiles
Bug: 231671426
Test: build

Signed-off-by: Pranav Temkar <pranavtemkar@gmail.com>
Change-Id: I85b7f023c03a7a2e603af94e88196c10a16fe4ec
Merged-In: I85b7f023c03a7a2e603af94e88196c10a16fe4ec
(cherry picked from commit 9b57be4d7f57e1d117c65fac1e2dc60dbc59cb4b)
2022-09-21 11:31:06 +03:00
Sal Savage
86c4c5b98c msm8953-common: Update LE Audio profile properties to match spec and implementation
Bug: 217448211
Test: atest BluetoothInstrumentationTests

Signed-off-by: Pranav Temkar <pranavtemkar@gmail.com>
Change-Id: I1260e95d357bd86099f75b910e0d744f97513fbc
2022-09-21 11:31:06 +03:00
Sal Savage
b030dd4a22 msm8953-common: Enable bluetooth profiles with system_ext.prop
Bug: 217448211
Test: make -j

Signed-off-by: Pranav Temkar <pranavtemkar@gmail.com>
Change-Id: I0d06b46910e42346653bea3484636f4129592ce3
2022-09-21 11:31:06 +03:00
weichinweng
c059b3c83a msm8953-common: Align ASHA prop with BluetoothProperties
* Modify bluetooth.profile.asha.central to
  bluetooth.profile.asha.central.enabled

Tag: #feature
Test: manual
Bug: 211570675
Bug: 218454632

Signed-off-by: Pranav Temkar <pranavtemkar@gmail.com>
Change-Id: I8e1f49034e5a675b29fba747e634c9f7c6c29c50
2022-09-21 11:31:06 +03:00
Etienne Ruffieux
fe2c5b03ee msm8953-common: Added new vendors for Bluetooth config migration
Tag: #feature
Test: manual
Bug: 211570675

Signed-off-by: Pranav Temkar <pranavtemkar@gmail.com>
Change-Id: Id74ec5e1b30f21c534c35b212a2fb297e9d591fb
2022-09-21 11:31:06 +03:00
Sal Savage
8d6011e956 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

Signed-off-by: Pranav Temkar <pranavtemkar@gmail.com>
Change-Id: I07e83ca352ff969be0e53a0f63b6c940b6c34dfb
2022-09-21 11:31:05 +03:00
Josh Wu
d7227dbdc0 msm8953-common: Switch BtAudio to AIDL
Test: m
Bug: 203490261

Signed-off-by: Pranav Temkar <pranavtemkar@gmail.com>
Change-Id: I4b8ac40d5ad410b89eb6a0573d740d86471ecfc7
Merged-In: I4b8ac40d5ad410b89eb6a0573d740d86471ecfc7
2022-09-21 11:31:05 +03:00
Etienne Ruffieux
51d0122050 msm8953-common: Removed audio A2dp from device.mk
Bug: 220306859
Test: atest
Tag: #feature
Change-Id: I300369d36399ffb558b98bafc2478b872d09faba
2022-09-21 11:31:05 +03:00
Jiyong Park
ae221bb1d0 msm8953-common: Remove ndk_platform backend. Use the ndk backend.
The ndk_platform backend will soon be deprecated because the ndk backend
can serve the same purpose. This is to eliminate the confusion about
having two variants (ndk and ndk_platform) for the same ndk backend.

Bug: 161456198
Test: m
Merged-In: I14a1c57bd06f1f2aa52491f779c7030d4de03547
Change-Id: I14a1c57bd06f1f2aa52491f779c7030d4de03547
2022-09-21 11:31:05 +03:00
Sebastiano Barezzi
1d03a07cfb aidl: light: Add "backlight" to the list of backlight devices
* Seen on sdm660 4.19

Change-Id: I4cf0cee36fc5d09f65c4709d854ed3cd5d087e68
2022-09-21 11:29:32 +03:00
Sebastiano Barezzi
32f56f7b29 aidl: light: Rewrite backlight support
* This properly handles max brightness node

Change-Id: I8afcf4bb7cef9c71d9a03bac7e118b8d9cb0565b
2022-09-21 11:29:32 +03:00
Sebastiano Barezzi
5073be44be aidl: light: Make RGB utils rgb_t methods
Change-Id: Iaaa34987c7670077214078169ddeb756a794403b
2022-09-21 11:29:32 +03:00
Sebastiano Barezzi
ba65f29538 aidl: light: Don't store alpha value
* We already apply it to RGB colors, it's not used outside colorToRgb()

Change-Id: Ic683f1355432e17328119f4a4da0f9fe6b5efe71
2022-09-21 11:29:32 +03:00
Sebastiano Barezzi
b29a536966 aidl: light: Set color and brightness data size to 8bit
* We're wasting memory

Change-Id: Ie66f504f32b487642c25b104240eaa8fb2df870c
2022-09-21 11:29:32 +03:00
Lafactorial
1dcea9fcd2 msm8953-common: Pull in Lineage lights AIDL 2022-08-15 08:25:01 +03:00
Lafactorial
143b4ba24c Revert "msm8953-common: media: Switch to sw enc/dec for vp9 codec"
This reverts commit 4fc9e12e9d.
2022-07-29 23:22:40 +03:00
Lafactorial
79f6273e0b Revert "msm8953-common: media: Update Google media codecs"
This reverts commit 6fa13c8998.
2022-07-29 23:21:32 +03:00
Lafactorial
49dd0394c3 Remove lineage.dependencies 2022-07-27 17:20:54 +03:00
ZeeLog
9d0dc1e05c tissot: sepolicy: address surfaceflinger denials 2022-07-27 13:56:23 +03:00
a26a06392b msm8953-common: parts: Use directBootAware
- This way settings can be restored prior to unlocking after reboot.

Signed-off-by: AnierinB <anierin@evolution-x.org>
2022-07-27 13:56:22 +03:00
Lafactorial
51f460e6e8 tissot: touch: Address vendor_init denials 2022-07-27 13:56:22 +03:00
1nfrag
c6e43993ad msm8953-common: Update GPS config for S
XTRA_SERVER has been changed to LONGTERM_PSDS_SERVER in frameworks,
 so we follow suit here.

Change-Id: I0a15782e49b1c530f2f0fd8ff991ebb9e1da1403
2022-07-27 13:56:22 +03:00
Albert I
f9e9f7a3b2 msm8953-common: gps: Merge gps_debug.conf into gps.conf
Bind mount the latter instead since overriding targets isn't allowed anymore
unless BUILD_BROKEN_DUP_RULES is set.

Signed-off-by: Albert I <kras@raphielgang.org>
Change-Id: I64cbf2834a5be04d1a887ab1c13139d0a4de52c9
2022-07-27 13:56:22 +03:00
Jabiyeff
1fd499922b msm8953-common: prop: Force disable iorapd
* Its eating more RAM and slow down device
* Thanks for CAFEBABE find this

Signed-off-by: Jabiyeff <cebiyevanar@gmail.com>
Signed-off-by: Pranav Temkar <pranavtemkar@gmail.com>

Revert "msm8953-common: set iorap prefetch prop to mendel flags"

This reverts commit a181d300e87cf991ddc34478e35814a8e490e29d.
2022-07-27 13:56:22 +03:00
Albert I
1f7b5f0729 msm8953-common: Inherit several Android Go configurations
Beneficial for everyone, even on non-Go devices.

Signed-off-by: Albert I <kras@raphielgang.org>
Change-Id: I088fd00500ce10df5f413cb762aaed2ec00f5dfc
Signed-off-by: RayapKun <rayapkun@gmail.com>
2022-07-27 13:56:21 +03:00
crevanth
2a24b4e75a msm8953-common: rootdir: Add permission for /dev/spidev5.1
* for ysl IR

Change-Id: I5163e8125a7adf04e001e0402c1398786f8fd81f
2022-07-27 13:56:21 +03:00
Harshit Jain
aa7d5f9e6b msm8953-common: Strip off some debug packages
* Ref: https://source.android.com/devices/tech/dalvik/configure#compilation_options

Q: PRODUCT_MINIMIZE_JAVA_DEBUG_INFO wth does this do?
A: https://android.googlesource.com/platform/build/+/master/target/product/go_defaults_common.mk#68

Change-Id: Iad073ec85f5cfe5be5a8d1944dd7cff521077dbe
Signed-off-by: RayapKun <rayapkun@gmail.com>
2022-07-27 13:56:21 +03:00
Mathieu Chartier
10874b157b msm8953-common: Speed profile services and wifi-service to reduce RAM and storage
Change-Id: I1d907b24cb2760ddd9cc65ac4335730c8e61a0a3
Signed-off-by: RayapKun <rayapkun@gmail.com>
2022-07-27 13:56:21 +03:00
Mathieu Chartier
14e895ef4d msm8953-common: Always preopt extracted APKs
Change-Id: I2e4742a796b8142f14eaad5eba81eaf800d64914
Signed-off-by: RayapKun <rayapkun@gmail.com>
2022-07-27 13:56:20 +03:00
Dede Dindin Qudsy
c3750cfae3 msm8953-common: sepolicy: allow hal_wifi write to proc_net 2022-07-27 13:56:20 +03:00
Michael Bestas
ea6f8c84df msm8953-common: sepolicy: Allow audio HAL access sysfs
Change-Id: I629dbb5b57bf4d0f703e66c0fd8befa871a431a0
2022-07-27 13:56:20 +03:00
xNombre
7ca192f68c msm8953-common: sepolicy: Fix slmadapter denials
Change-Id: I53cd05460ba45dc0f2a96d299f91a7fc32d9a12a
2022-07-27 13:56:19 +03:00
Jabiyeff
80a662769f msm8953-common: sepolicy: Address surfaceflinger denial 2022-07-27 13:56:19 +03:00
FranticCoin
9c32573d56 msm8953-common: sepolicy: Address iorap denials
Change-Id: Ia0424e98833720a04c414d98273c73a3fdfe9799
2022-07-27 13:56:18 +03:00
Marc Bourgoin
b88227c095 msm8953-common: sepolicy: address sensor denials
Change-Id: I81a4218f4209d97b391c496f9581659882d5d1b4
2022-07-27 13:56:17 +03:00
Lafactorial
933792e5d2 msm8953-common: overlay: Enable Battery Health 2022-07-27 13:56:17 +03:00
CrisBal
6fa13c8998 msm8953-common: media: Update Google media codecs 2022-07-27 13:56:16 +03:00
Giovanni Ricca
4fc9e12e9d msm8953-common: media: Switch to sw enc/dec for vp9 codec
* Somehow QCom hardware acceleration doesn't works properly with vp9 codec
* Force userspace to load OMX.google.vp9.decoder/c2.adnroid.vp9.decoder instead

Change-Id: I16cda8f29a1f6b1e26b9319de23235918798a918
2022-07-27 13:56:16 +03:00
Shalini Manjunatha
8614af0266 msm8953-common: audio: Use AOSP implementation for sw effects
Change-Id: Iae6212f135fc4cc7bfb0528380daf9f13101a2ec
2022-07-27 13:56:16 +03:00
rayrzy
dce127b011 msm8953-common: overlay: enable VoLTE support for Three
Signed-off-by: rayrzy <vincentrayananda@gmail.com>
Signed-off-by: Fiqri Ardyansyah <fiqri15072019@gmail.com>
Signed-off-by: RayapKun <rayapkun@gmail.com>
2022-07-27 13:56:15 +03:00
Mocarafee
93856fc048 msm8953-common: overlay: enable VoLTE support for Indosat and XL Axiata
Signed-off-by: rayrzy <vincentrayananda@gmail.com>
Signed-off-by: Fiqri Ardyansyah <fiqri15072019@gmail.com>
Signed-off-by: RayapKun <rayapkun@gmail.com>
2022-07-27 13:56:15 +03:00
Albert I
0e43012453 msm8953-common: CarrierConfig: Enable VoLTE support for Telkomsel (Indonesia)
Telkomsel has started a limited deployment of VoLTE in Jakarta and
Surabaya. I'm not really sure when it'll be deployed nationwide though,
since Telkomsel states that "for this time, VoLTE service can only be
enjoyed by selected prepaid and postpaid Telkomsel customers."

Link: https://www.telkomsel.com/volte
Signed-off-by: Albert I <kras@raphielgang.org>
Change-Id: I46d2b3cf9956d654dadeb70f28035a9263989f35
Signed-off-by: rayrzy <vincentrayananda@gmail.com>
Signed-off-by: Fiqri Ardyansyah <fiqri15072019@gmail.com>
Signed-off-by: RayapKun <rayapkun@gmail.com>
2022-07-27 13:56:15 +03:00
LuK1337
27977d3dc3 msm8953-common: 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
2022-07-27 13:56:14 +03:00
dianlujitao
d7ad55a962 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
2022-07-27 13:56:14 +03:00
Michael Bestas
73eee1ec4e msm8953-common: gps: Lower debug level
* Kill logcat spam

Change-Id: I20d1f698d3c2d1b56e79f6eb6c5c17069e43c60f
2022-07-27 13:56:14 +03:00
Ethan Chen
71d05f9387 msm8953-common: gps: Increase batch size to max
* Hardware supports 40

Change-Id: I075fff615814fa105ec1493c5bdde60b8abccf0e
2022-07-27 13:56:13 +03:00
TheStrix
94e8ee27ec msm8953-common: gps: disable unused location services
* Disable XTWIFI

Change-Id: I70f39d8d611167f65bb3912590b05f8a8d121c80
2022-07-27 13:56:13 +03:00
dianlujitao
12ce367e81 msm8953-common: Fix non-ASCII character in gps.conf
:caf:

Change-Id: Iea9c44c0fbad574cbc077feea3d9f1de83d7d99a
2022-07-27 13:56:13 +03:00
Giovanni Ricca
ed85f51b90 msm8953-common: gps: Pull gps configs from daisy
Change-Id: I437ca5388a6070108da1fb9d314d424658f75c49
2022-07-27 13:56:13 +03:00
Michael Bestas
3bcb380329 msm8953-common: gps: Ignore some build warnings
Change-Id: If1dfd39ab820cdf5e7ac5caf05dc8fea1cd95235
2022-07-27 13:56:12 +03:00
Michael Bestas
14d4fb118a msm8953-common: gps: Resolve unused parameter warnings
Change-Id: I0acef3da2c3567a28edd0a71dac89a5828f7725d
2022-07-27 13:56:12 +03:00
Giovanni Ricca
eb337da34e msm8953-common: Import Gps hal
* from LA.UM.8.6.r1-02600-89xx.0

Change-Id: I9cead1517e71e1ae9381e6435ca746033d9a1446
2022-07-27 13:56:11 +03:00
Ramii Ahmed
26f31384ad msm8953-common: rootdir: Add offline charging LED indicator
* Write to node to turn on LED in offline charging mode

Change-Id: Iee02ac9af0438b5bc4dcf08dfe19e10226d7090e
2022-07-22 11:37:27 +03:00
clarencelol
3ca4512ca9 msm8953-common: properties: Disable SDM Scaler
* Else, ScalarConfig: :GetPipeScaleSettingsInfo: lib_scale_get_pipe_settings failed: status = 2

Change-Id: I7ee49c90f7ad948641d81b3c261351a6b3728fed
2022-07-22 11:37:27 +03:00
Lafactorial
7504541cfc msm8953-common: Don't advertise vorbis offloading support 2022-07-22 11:37:27 +03:00
LuK1337
680b83463d msm8953-common: audio: Disable ULL mode
* Ultra low latency playback is currently broken. Crackling audio
   can be well noticed while playing WhatsApp audio messages or even
   during some games.

 * This patch routes all audio that normally used audio-ull-playback
   paths to low-latency-playback paths instead, thus meaning we're
   switching from ULL to LL mode.

Change-Id: I7d672f1ff10b984c8096c9c4ca83475e730fd16f
2022-07-22 11:37:27 +03:00
Bruno Martins
fe83f9c203 msm8953-common: Remove obsolete eBPF property
Android 12 enforces support for eBPF in all kernels.

Change-Id: Iefa9071cb10eabbaeb2f3d2c7c60cb3d0cc2fa2e
2022-07-22 11:37:27 +03:00
Lafactorial
5110e32141 Revert "msm8953-common: rro: TetheringOverlay: Disable BPF"
This reverts commit d37facb234.
2022-07-22 11:37:26 +03:00
Adrian DC
d5ab8f5fd7 msm8953-common: Disable EGL buffer_age extension support
* Due to commit I9b346b4053ec12c8a78a143a4dc0e708c44888a2
    "Support EGL_KHR_partial_update without EGL_EXT_buffer_age"
    in libhwui, EGL_EXT_buffer_age extension was forcibly enabled
    if EGL_KHR_partial_update was available, even if the EGL driver
    was not providing EGL_EXT_buffer_age support

 * On older Adreno drivers, renderthread sources could use bufferAge
    specific swap behaviours and would result in partially missing
    display redraws upon animations and rotated screens,
    for instance flashing action bars, blinking loading bars
    and half black displays in landscape rotations

Change-Id: I16fe13f0726792522e382716f8f24eccf2a27701
Signed-off-by: Adrian DC <radian.dc@gmail.com>
2022-07-22 11:37:26 +03:00
linjoey
9c36d4a8f9 msm8953-common: Modify Vulkan and OpenGL versions to 2020-03-01.
Change-Id: I03676bc282148d3529ff0124804df378dca6e608
2022-07-22 11:37:26 +03:00
Alastair Donaldson
9a214a116a msm8953-common: Add OpenGL ES and update Vulkan dEQP feature flags.
* Populates a new feature flag to record the level of
   OpenGL ES dEQP test support. Updates the analogous
   Vulkan dEQP feature flag to the value for the next
   dessert release.

Change-Id: I55c39601687ab66745c17598ec08e3eee12bf84c
2022-07-22 11:37:26 +03:00
Anver sadhique
e9567029f2 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
2022-07-22 11:37:26 +03:00
Giovanni Ricca
ffdd9c2dd9 msm8953-common: media: Drop c2 configs
* they won't get loaded anyway

03-22 14:49:25.029  5110  5110 D MediaCodecsXmlParser: MediaCodec: cannot update non-existing codec: c2.android.avc.encoder at line 57 of /vendor/etc/media_codecs_performance.xml
03-22 14:49:25.029  5110  5110 D MediaCodecsXmlParser: MediaCodec: cannot update non-existing codec: c2.android.h263.encoder at line 66 of /vendor/etc/media_codecs_performance.xml
03-22 14:49:25.029  5110  5110 D MediaCodecsXmlParser: MediaCodec: cannot update non-existing codec: c2.android.mpeg4.encoder at line 72 of /vendor/etc/media_codecs_performance.xml
03-22 14:49:25.029  5110  5110 D MediaCodecsXmlParser: MediaCodec: cannot update non-existing codec: c2.android.hevc.encoder at line 75 of /vendor/etc/media_codecs_performance.xml
03-22 14:49:25.029  5110  5110 D MediaCodecsXmlParser: MediaCodec: cannot update non-existing codec: c2.android.vp8.encoder at line 84 of /vendor/etc/media_codecs_performance.xml
03-22 14:49:25.030  5110  5110 D MediaCodecsXmlParser: MediaCodec: cannot update non-existing codec: c2.android.avc.decoder at line 132 of /vendor/etc/media_codecs_performance.xml
03-22 14:49:25.030  5110  5110 D MediaCodecsXmlParser: MediaCodec: cannot update non-existing codec: c2.android.hevc.decoder at line 151 of /vendor/etc/media_codecs_performance.xml
03-22 14:49:25.030  5110  5110 D MediaCodecsXmlParser: MediaCodec: cannot update non-existing codec: c2.android.h263.decoder at line 162 of /vendor/etc/media_codecs_performance.xml
03-22 14:49:25.030  5110  5110 D MediaCodecsXmlParser: MediaCodec: cannot update non-existing codec: c2.android.vp8.decoder at line 172 of /vendor/etc/media_codecs_performance.xml
03-22 14:49:25.030  5110  5110 D MediaCodecsXmlParser: MediaCodec: cannot update non-existing codec: c2.android.vp9.decoder at line 184 of /vendor/etc/media_codecs_performance.xml
03-22 14:49:25.030  5110  5110 D MediaCodecsXmlParser: MediaCodec: cannot update non-existing codec: c2.android.mpeg4.decoder at line 195 of /vendor/etc/media_codecs_performance.xml

Change-Id: I376f61d39d91786103ddd5cee5df798f686fb655
2022-07-22 11:37:25 +03:00
Davide Garberi
861e1c7619 msm8953-common: Add default dalvik heap values as fallback
* In case libinit doesn't get loaded (for example on any pure AOSP GSI) we
  need to have fallback values to make the device usable

Change-Id: I149be63a625d3b00188512b45fe0e556de6abaec
2022-07-22 11:37:25 +03:00
weivincewang
a399eb22c9 msm8953-common: rootdir: tune zram performance 2022-07-06 08:41:43 +03:00
Danny Lin
71b852d961 msm8953-common: overlay: Don't pin launcher app in memory
Similar to what we did for the camera app, unpin the launcher app from
memory as well. While the default launcher (Launcher3) isn't
particularly big, it doesn't make much sense to pin because the launcher
does not typically load new resources much. Most of its resources should
already be loaded in memory after it starts, so pinning the APK is
redundant.

NB: The value has been changed to false instead of removing it entirely
because we need to override the config set by overlays in the prebuilt
vendor image.

Change-Id: I6b82f2facb1bf4aee393af3f0bc3e0bce2538222
2022-07-06 08:41:42 +03:00
Danny Lin
f9a83fc126 msm8953-common: overlay: Don't pin camera app in memory
The default camera app can be *huge* in some cases, e.g. when the app in
question is Google Camera. The system will only pin up to the first 80
MiB of the APK file, as well as the first 80 MiB of its odex. There are
several problems with this:

  - We could easily end up with 160 MiB of camera app files pinned,
    which is a tall order with the usable RAM that we have
  - The data that gets pinned may not even be the most critical data for
    launching the camera

Let's disable pinning of the camera app to save precious RAM on this
device.

Change-Id: I745e39b6ff212dfaf9213517d2a2be8ff7384e24
2022-07-06 08:41:42 +03:00
Alex Naidis
337bd953f7 msm8953-common: wifi: Enable QPower and deep sleep together
- This enables Deep Sleep mode, additionally to QPower.
- With this configuration, QPower manages the new Deep sleep mode which leads to amazing power savings.

Change-Id: If5c4b4253d36006a832d92c7386691c3877c8076
2022-07-06 08:41:42 +03:00
Arian
ae7dd33031 msm8953-common: rootdir: Don't install test apps
Change-Id: I642691c52afa777eeed50a280574dcfba0eae155
2022-07-06 08:41:42 +03:00
Palakurthi Sreekanth
38a9239b9a msm8953-common: wifi: disable PacketLogging 2022-07-06 08:41:42 +03:00
dianlujitao
11156eecd4 msm8953-common: Don't apply persist.vendor.usb.config
* Otherwise adb turns on after reboot every time.

Change-Id: I66631f1f38a3e3a16e6d3dad87c83d0a98e6f851
2022-07-06 08:41:41 +03:00
Ramakant Singh
967a9accef msm8953-common: Don't re-start hwcomposer if sf restart
CRs-Fixed: 2424966
Change-Id: I90ae8d04befb03820abd7392d15f5b7574735e26
Signed-off-by: Pulkit077 <pulkitagarwal2k1@gmail.com>
2022-07-06 08:41:41 +03:00
Dede Dindin Qudsy
be7d7b97c1 msm8953-common: remove creation of /data/misc/seemp
unused and also fix :
[   20.730851] type=1400 audit(30785938.283:11): avc: denied { setattr } for pid=435 comm="init" name="seemp" dev="mmcblk0p49" ino=227297 scontext=u:r:vendor_init:s0 tcontext=u:object_r:seemp_data_file:s0 tclass=dir permissive=0

Signed-off-by: Dede Dindin Qudsy <xtrymind@gmail.com>
2022-07-06 08:41:41 +03:00
Manoj Basapathi
67b5f926df msm8953-common: Remove unused fast dormancy persist property.
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
2022-07-06 08:41:41 +03:00
neonmicky
94c125f270 msm8953-common: Build vendor variant of vendor.display.config@1.0
Change-Id: Icc9b013f67f841bc8877300bb2f44d9b899097be
2022-07-06 08:41:41 +03:00
Manoj Basapathi
322be53834 msm8953-common:init.qcom.rc: remove unused /data access
-IMS service is no longer using /data/shared path.
-remove unused /data/shared path access.

Signed-off-by: neonmicky <neonmicky30@gmail.com>
Change-Id: Ib8dc9dfe23e9dbecc9f44248bb6ab97981520efb
2022-07-06 08:41:40 +03:00
Abhiprayah Tiwari
4fd092fcee msm8953-common: rootdir: remove mounting of debugfs
Mounting debugfs is no longer allowed in android S from rc scripts.

Change-Id: I06cc05b7578b204c7cc25b19571be029dab1cf9d
2022-07-06 08:41:40 +03:00
xyyx
23349e1ef7 msm8953-common: Add basic USB HAL that reports no status change
Signed-off-by: ItsVixano <vixanonew@gmail.com>
Change-Id: I46874b1d6a6491d07b7d5ae896a192312b4047cd
2022-07-06 08:41:40 +03:00
Michael W
55e56b864c msm8953-common: overlay: Disable NearbyMessagesService
* This commit fixes slow Internet speed while using Bluetooth

Change-Id: c1a85c4647b200cba4cad640bdc496419023cb04
Signed-off-by: lupesoltec <dev@lupesoltec.com.br>
2022-07-06 08:41:40 +03:00
ZeeLog
859c51c595 msm8953-common: camera: silence excessive logs 2022-07-06 08:41:39 +03:00
Dhina17
86ccc32f72 msm8953-common:sepolicy:Remove redundant rules
* DRM clearkey and widevine - labelled in qcom common sepolicy
* /data/vendor/location/xtra/socket_hal_xtra - We don't need this from P.Its dead

Change-Id: Id744dadf7a76d83271eb5f1c2433a3ea529f1ee5
2022-07-06 08:41:39 +03:00
neonmicky
6be5896eb7 msm8953-common: Disable Blur by default 2022-07-06 08:41:39 +03:00
Aman Singh
0a84e5eb55 msm8953-common: overlay: disable wallpaper zooming 2022-07-06 08:41:39 +03:00
Jaihind Yadav
3db6c240d0 msm8953-common:sepolicy:adding dontaudit for init_shell 2022-07-06 08:41:39 +03:00
rohanpurohit
f8ef2520f1 msm8953-common: fix charging led via overlay
Co-authored-by: Sohil876 <sohil876@gmail.com>
2022-07-06 08:41:39 +03:00
Sonal Singh
3948e9691e msm8953-common: CPUInfo: Add CPU Temp Overlay 2022-07-06 08:41:38 +03:00
neonmicky
c90de20583 msm8953-common:overlay: Enable Smart charging
Signed-off-by: neonmicky <neonmicky30@gmail.com>
2022-07-06 08:41:38 +03:00
Lafactorial
24696f3e15 msm8953-common: overlay: Add button brightness overlay 2022-07-06 08:41:38 +03:00
John Galt
1a9df8f90e msm8953-common: CarrierConfig: update from 5800 QSSI 2022-07-06 08:41:38 +03:00
Mathieu Heurtevin
1eff4b7fd8 msm8953-common: Add volte and vowifi for Free
See [website](https://mobile.free.fr/VoLTE.html)

Signed-off-by: Joey Huab <joey@evolution-x.org>
2022-07-06 08:41:37 +03:00
Chirayu Desai
56eebed092 msm8953-common: rro_overlays: Move CarrierConfig to RRO
Change-Id: Ia57acd244608848f70fdcc30d5694c919db60671
Signed-off-by: Joey Huab <joey@evolution-x.org>
2022-07-06 08:41:37 +03:00
Lafactorial
1a4ebb20b1 msm8953-common: props: Don't write binary XML files
- Android 12 now writes XML files in binary format by default. This can cause incompatibility with TWRP which can hang when attempting to read XML files e.g. /data/system/storage.xml

- This commit sets the persist.sys.binary_xml property to false so that XML files are written in text format.

Change-Id: Ibc6ee9a611cdda5947145603218465e17ed11ff8
2022-07-06 08:41:37 +03:00
abhinavgupta371
7ee70b4670 msm8953-common: Add AptX blobs from redfin 2022-07-06 08:41:37 +03:00
Pulkit077
1440d36b13 msm8953-common:sepolicy:remove sys.post_boot.parsed label
is now vendor.post_boot.parsed and has been labelled in qcom common sepolicy

Signed-off-by: Pulkit077 <pulkitagarwal2k1@gmail.com>
2022-07-06 08:41:37 +03:00
Chenyang Zhong
e9cbb15f16 msm8953-common: sepolicy: Address init denial
Change-Id: Id0d0c88bbedde6b6586e3a6f04704457d910d8a0
2022-07-06 08:41:37 +03:00
Sonal Singh
ff51f93b85 msm8953-common: add properpermission & path for fps info 2022-07-06 08:41:36 +03:00
Sonal Singh
92ea8f42b9 msm8953-common: Address FPS Info Denial
Signed-off-by: neonmicky <neonmicky30@gmail.com>
2022-07-06 08:41:36 +03:00
Kyle Harrison
6a4b6c880a msm8953-common:sepolicy:Fix exported_camera_prop denials 2022-07-06 08:41:36 +03:00
Kyle Harrison
7612a27d39 msm8953-common:sepolicy:Fix userspace_reboot prop denials 2022-07-06 08:41:36 +03:00
neonmicky
e0750d9515 msm8953-common:sepolicy: Address some more denials
Signed-off-by: neonmicky <neonmicky30@gmail.com>
2022-07-06 08:41:36 +03:00
LuK1337
94a6c97e6a msm8953-common: sepolicy: Address thermal-engine denials
* <Q blobs require broader sysfs access and we don't
  want to relabel stuff like /sys/class/kgsl.

Change-Id: I91c3e7c3b64d7b604ded26b7242dccfda9d39f16
2022-07-06 08:41:35 +03:00
Lafactorial
b208ef6141 msm8953-common: Drop conflicting rules 2022-07-06 08:41:35 +03:00
neonmicky
a27fa3da3d msm8953-common:sepolicy: Address denials
Signed-off-by: neonmicky <neonmicky30@gmail.com>
2022-07-06 08:41:35 +03:00
Lafactorial
50ff56e7b2 msm8953-common: sepolicy: Fix neverallows 2022-06-02 15:19:35 +03:00
Lup Gabriel
4c1fb4ecc2 msm8953-common: switch to crDroid doze package
Signed-off-by: neonmicky <neonmicky30@gmail.com>
2022-06-02 15:18:32 +03:00
343 changed files with 54146 additions and 5063 deletions

View File

@@ -1,2 +1,30 @@
soong_namespace {
}
install_symlink {
name: "firmware_WCNSS_qcom_cfg.ini_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

@@ -26,83 +26,4 @@ $(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
@@ -24,18 +21,20 @@ 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 += printk.devkmsg=on
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)
TARGET_KERNEL_LLVM_BINUTILS := true
BOARD_KERNEL_CMDLINE += androidboot.usbconfigfs=true
endif
TARGET_KERNEL_CONFIG := msm8953-perf_defconfig xiaomi/xiaomi.config
# ANT
BOARD_ANT_WIRELESS_DEVICE := "vfs-prerelease"
@@ -43,7 +42,6 @@ BOARD_ANT_WIRELESS_DEVICE := "vfs-prerelease"
# 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
@@ -61,50 +59,52 @@ AUDIO_FEATURE_ENABLED_EXT_AMPLIFIER := false
AUDIO_USE_LL_AS_PRIMARY_OUTPUT := true
BOARD_SUPPORTS_SOUND_TRIGGER := 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
MALLOC_SVELTE_FOR_LIBC32 := true
# Display
TARGET_USES_ION := true
TARGET_USES_GRALLOC1 := true
TARGET_USES_HWC2 := true
# DRM
TARGET_ENABLE_MEDIADRM_64 := true
NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3
# 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
# HW crypto
TARGET_HW_DISK_ENCRYPTION := true
# Init
TARGET_INIT_VENDOR_LIB := //$(COMMON_PATH):libinit_msm8953
TARGET_RECOVERY_DEVICE_MODULES := libinit_msm8953
# Lineage Health
TARGET_HEALTH_CHARGING_CONTROL_SUPPORTS_BYPASS := false
# 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 := \
@@ -127,20 +127,31 @@ TARGET_VENDOR_PROP += $(COMMON_PATH)/vendor.prop
# Recovery
ifeq ($(AB_OTA_UPDATER), true)
TARGET_RECOVERY_FSTAB := $(COMMON_PATH)/rootdir/etc/fstab_AB.qcom
ifeq ($(TARGET_IS_LEGACY), true)
TARGET_RECOVERY_FSTAB := $(COMMON_PATH)/rootdir/etc/fstab_legacy_AB.qcom
else
TARGET_RECOVERY_FSTAB := $(COMMON_PATH)/rootdir/etc/fstab_AB.qcom
endif
else ifeq ($(TARGET_IS_LEGACY), true)
TARGET_RECOVERY_FSTAB := $(COMMON_PATH)/rootdir/etc/fstab_legacy.qcom
else
TARGET_RECOVERY_FSTAB := $(COMMON_PATH)/rootdir/etc/fstab.qcom
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
NEED_AIDL_NDK_PLATFORM_BACKEND := true
# Wi-Fi
BOARD_HAS_QCOM_WLAN := true
@@ -149,6 +160,7 @@ BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_qcwcn
BOARD_WLAN_DEVICE := qcwcn
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_qcwcn
TARGET_HAS_BROKEN_WLAN_SET_INTERFACE := true
WIFI_DRIVER_FW_PATH_AP := "ap"
WIFI_DRIVER_FW_PATH_STA := "sta"
WIFI_AVOID_IFACE_RESET_MAC_CHANGE := true

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,15 @@
<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 +28,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,7 +52,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>

View File

@@ -41,14 +41,14 @@ outputs {
}
compress_offload_16 {
flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING
formats AUDIO_FORMAT_MP3|AUDIO_FORMAT_AC3|AUDIO_FORMAT_E_AC3|AUDIO_FORMAT_FLAC|AUDIO_FORMAT_ALAC|AUDIO_FORMAT_APE|AUDIO_FORMAT_AAC_LC|AUDIO_FORMAT_AAC_HE_V1|AUDIO_FORMAT_AAC_HE_V2|AUDIO_FORMAT_WMA|AUDIO_FORMAT_WMA_PRO|AUDIO_FORMAT_VORBIS|AUDIO_FORMAT_AAC_ADTS_LC|AUDIO_FORMAT_AAC_ADTS_HE_V1|AUDIO_FORMAT_AAC_ADTS_HE_V2
formats AUDIO_FORMAT_MP3|AUDIO_FORMAT_AC3|AUDIO_FORMAT_E_AC3|AUDIO_FORMAT_FLAC|AUDIO_FORMAT_ALAC|AUDIO_FORMAT_APE|AUDIO_FORMAT_AAC_LC|AUDIO_FORMAT_AAC_HE_V1|AUDIO_FORMAT_AAC_HE_V2|AUDIO_FORMAT_WMA|AUDIO_FORMAT_WMA_PRO|AUDIO_FORMAT_AAC_ADTS_LC|AUDIO_FORMAT_AAC_ADTS_HE_V1|AUDIO_FORMAT_AAC_ADTS_HE_V2
sampling_rates 44100|48000|96000|192000
bit_width 16
app_type 69936
}
compress_offload_24 {
flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING
formats AUDIO_FORMAT_FLAC|AUDIO_FORMAT_ALAC|AUDIO_FORMAT_APE|AUDIO_FORMAT_VORBIS
formats AUDIO_FORMAT_FLAC|AUDIO_FORMAT_ALAC|AUDIO_FORMAT_APE
sampling_rates 44100|48000|96000|192000
bit_width 24
app_type 69940

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Copyright (c) 2016-2019, The Linux Foundation. All rights reserved
<!-- Copyright (c) 2016-2020, The Linux Foundation. All rights reserved
Not a Contribution.
-->
<!-- Copyright (C) 2015 The Android Open Source Project
@@ -63,11 +63,6 @@
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</mixPort>
<mixPort name="raw" role="source"
flags="AUDIO_OUTPUT_FLAG_FAST|AUDIO_OUTPUT_FLAG_RAW">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</mixPort>
<mixPort name="deep_buffer" role="source"
flags="AUDIO_OUTPUT_FLAG_DEEP_BUFFER">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
@@ -170,7 +165,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 +201,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"
@@ -249,31 +244,31 @@
<!-- route declaration, i.e. list all available sources for a given sink -->
<routes>
<route type="mix" sink="Earpiece"
sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
<route type="mix" sink="Speaker"
sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
<route type="mix" sink="Wired Headset"
sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
<route type="mix" sink="Wired Headphones"
sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
<route type="mix" sink="Line"
sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
<route type="mix" sink="HDMI"
sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload"/>
sources="primary output,deep_buffer,direct_pcm,compressed_offload"/>
<route type="mix" sink="Proxy"
sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload"/>
sources="primary output,deep_buffer,direct_pcm,compressed_offload"/>
<route type="mix" sink="FM"
sources="primary output"/>
<route type="mix" sink="BT SCO"
sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
<route type="mix" sink="BT SCO Headset"
sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
<route type="mix" sink="BT SCO Car Kit"
sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
sources="primary output,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
<route type="mix" sink="Telephony Tx"
sources="voice_tx"/>
<route type="mix" sink="primary input"
sources="Wired Headset Mic,BT SCO Headset Mic,FM Tuner,Telephony Rx"/>
sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic,FM Tuner"/>
<route type="mix" sink="surround_sound"
sources="Built-In Mic,Built-In Back Mic"/>
<route type="mix" sink="voip_tx"
@@ -286,9 +281,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,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,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,
('libwpa_client', '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",
],
}

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

@@ -0,0 +1,344 @@
/* 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_VERSION_CHECK", &mGps_conf.XTRA_VERSION_CHECK, 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;
/*XTRA version check is disabled by default*/
mGps_conf.XTRA_VERSION_CHECK=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;
}
}

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

@@ -0,0 +1,261 @@
/* Copyright (c) 2011-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_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;
uint32_t XTRA_VERSION_CHECK;
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

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

@@ -0,0 +1,322 @@
/* 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++);
enum xtra_version_check {
DISABLED,
AUTO,
XTRA2,
XTRA3
};
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__

View File

@@ -0,0 +1,107 @@
/* 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 __IOSOBSERVER_H__
#define __IOSOBSERVER_H__
#include <list>
#include <string>
#include <IDataItemObserver.h>
#include <IDataItemSubscription.h>
#include <IFrameworkActionReq.h>
using namespace std;
namespace loc_core
{
/**
* @brief IOsObserver interface
* @details IOsObserver interface;
* In OS dependent code this type serves as a handle to
* an OS independent instance of this interface.
*/
class IOsObserver :
public IDataItemObserver,
public IDataItemSubscription,
public IFrameworkActionReq {
public:
// To set the subscription object
virtual void setSubscriptionObj(IDataItemSubscription *subscriptionObj) = 0;
// To set the framework action request object
virtual void setFrameworkActionReqObj(IFrameworkActionReq *frameworkActionReqObj) = 0;
// IDataItemObserver Overrides
inline virtual void getName (string & /*name*/) {}
inline virtual void notify (const std::list <IDataItemCore *> & /*dlist*/) {}
// IDataItemSubscription Overrides
inline virtual void subscribe
(
const std :: list <DataItemId> & /*l*/,
IDataItemObserver * /*client*/
){}
inline virtual void updateSubscription
(
const std :: list <DataItemId> & /*l*/,
IDataItemObserver * /*client*/
){}
inline virtual void requestData
(
const std :: list <DataItemId> & /*l*/,
IDataItemObserver * /*client*/
){}
inline virtual void unsubscribe
(
const std :: list <DataItemId> & /*l*/,
IDataItemObserver * /*client*/
){}
inline virtual void unsubscribeAll (IDataItemObserver * /*client*/){}
// IFrameworkActionReq Overrides
inline virtual void turnOn (DataItemId /*dit*/, int /*timeOut*/){}
inline virtual void turnOff (DataItemId /*dit*/) {}
#ifdef USE_GLIB
inline virtual bool connectBackhaul() { return false; }
inline virtual bool disconnectBackhaul() { return false; }
#endif
/**
* @brief Destructor
* @details Destructor
*/
virtual ~IOsObserver () {}
};
} // namespace loc_core
#endif // #ifndef __IOSOBSERVER_H__

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