Compare commits
412 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4080f3dea5 | |||
| e1aa98dd38 | |||
|
|
4a211e9c2d | ||
|
|
19bf303d28 | ||
|
|
61e4065a7c | ||
|
|
2a507003fd | ||
|
|
a4f4bfd6e4 | ||
|
|
670910004b | ||
|
|
d04303cb25 | ||
|
|
5df2b1e472 | ||
|
|
1a7be7243c | ||
|
|
8ce1d238e0 | ||
|
|
b52ed827f0 | ||
|
|
425727eb79 | ||
|
|
6456e0b441 | ||
|
|
db03b28720 | ||
|
|
bcab9393f7 | ||
|
|
8bf8099bbe | ||
|
|
088cdda380 | ||
|
|
d16a3ad43d | ||
|
|
8f19a763a8 | ||
|
|
cef95abb1a | ||
|
|
fd1e8ff380 | ||
|
|
c0750b550b | ||
|
|
0a68428a6a | ||
|
|
de65059b33 | ||
|
|
d868c41d52 | ||
|
|
5320630224 | ||
|
|
57de66f447 | ||
|
|
7a1c76e244 | ||
|
|
3ff0f91756 | ||
|
|
51babbffbb | ||
|
|
c291ba5d36 | ||
|
|
9249e1c811 | ||
|
|
c71ff1f2e8 | ||
|
|
e2bc5464d6 | ||
|
|
5afbe80396 | ||
|
|
46e475ea54 | ||
|
|
21f0c47a1c | ||
|
|
6936cbd64a | ||
|
|
ff3897686d | ||
|
|
ce745accb6 | ||
|
|
0024c6e85c | ||
|
|
9beebf6907 | ||
|
|
fa0fd816db | ||
|
|
1bb9123ef7 | ||
|
|
62a16fc34d | ||
|
|
66a87541c8 | ||
|
|
695f8fdb25 | ||
|
|
6c05ecdc2a | ||
|
|
93a37dd24e | ||
|
|
a12fbb082b | ||
|
|
7a1e7db21b | ||
|
|
82a5f6c199 | ||
|
|
28e139572f | ||
|
|
fc41ccb0c4 | ||
|
|
f79656ae52 | ||
|
|
72fa02541c | ||
|
|
c80a790b5b | ||
|
|
69084ccbaa | ||
|
|
04d709dc8b | ||
|
|
24a56ef03c | ||
|
|
ac1bf79d78 | ||
|
|
e1a7f18f95 | ||
|
|
1c42d292d6 | ||
|
|
525a47ef19 | ||
|
|
bcc8c02ef2 | ||
|
|
e2f65c8391 | ||
|
|
96ed58dc8d | ||
|
|
11a8788570 | ||
|
|
488aa1536c | ||
|
|
109c500dc2 | ||
|
|
f3828a3a61 | ||
|
|
e1278784af | ||
|
|
42db3b8b83 | ||
|
|
617b5f039d | ||
|
|
174eca8d97 | ||
|
|
69add37179 | ||
|
|
f65c6586c8 | ||
|
|
63861001b5 | ||
|
|
d070a9416c | ||
|
|
3da98640b7 | ||
|
|
086c61f6c7 | ||
|
|
871d5a80b4 | ||
|
|
fdf1670cce | ||
|
|
6fccfe37fd | ||
|
|
4574f0c150 | ||
|
|
4b6f4151d4 | ||
|
|
db190da20e | ||
|
|
6d20ca3478 | ||
|
|
fcdb641cd8 | ||
|
|
ed43457b97 | ||
|
|
ee9ef1cb34 | ||
|
|
d3b23b4afa | ||
|
|
9d1be9ee43 | ||
|
|
59975a5b90 | ||
|
|
c6f8c22bea | ||
|
|
ba6fba2f57 | ||
|
|
48283d8d68 | ||
|
|
9dd9ca9a53 | ||
|
|
32111b509a | ||
|
|
5b77324b80 | ||
|
|
7803caae45 | ||
|
|
90557cd73a | ||
|
|
24951b362f | ||
|
|
4a7c545ed7 | ||
|
|
c64c467198 | ||
|
|
f3222d21ad | ||
|
|
5e21929011 | ||
| 5999a91c7b | |||
|
|
3bf8288002 | ||
|
|
8f8314792d | ||
|
|
fc62b65d74 | ||
|
|
f82d205600 | ||
|
|
37f0cea0da | ||
|
|
9cce7d27ca | ||
|
|
f0db1f74ea | ||
|
|
504ebee0e2 | ||
|
|
408b6db7ce | ||
|
|
076bd2b7bc | ||
|
|
820123482b | ||
|
|
56f17e7b0e | ||
|
|
6747ba859f | ||
|
|
2bec1c24a9 | ||
|
|
e8d8895a55 | ||
|
|
74bd9c3a05 | ||
|
|
7a1efce8fd | ||
|
|
13d9a8578b | ||
|
|
874047ebbf | ||
|
|
90adc7f248 | ||
|
|
cd1f39d3b9 | ||
|
|
2c6c60fd69 | ||
|
|
74aa44216a | ||
|
|
0b73f36c77 | ||
|
|
4c093d7fb0 | ||
|
|
208c19b919 | ||
|
|
ebb8196493 | ||
|
|
420f320c14 | ||
|
|
87a3fb4f5e | ||
|
|
f24d265bc8 | ||
|
|
7028182b58 | ||
|
|
b5fd2634d6 | ||
|
|
1f0a7633a9 | ||
|
|
89c9726aaa | ||
|
|
fc6c5290fb | ||
|
|
fa92e958d6 | ||
|
|
ef83b75034 | ||
|
|
7ac87c2b29 | ||
|
|
2739846c50 | ||
|
|
647a2a83e9 | ||
|
|
61a184dac8 | ||
|
|
7954b7a590 | ||
|
|
91b422b83f | ||
|
|
43b4a7f02d | ||
|
|
2afa3215b9 | ||
|
|
5a56824d27 | ||
| 7d75521921 | |||
|
|
101095deca | ||
|
|
c5aa127cda | ||
|
|
c84427bd2d | ||
|
|
2a9eeae92f | ||
|
|
74af30ca6b | ||
|
|
d5318c287c | ||
|
|
8241b05200 | ||
|
|
cfd275ee2d | ||
| 092147345f | |||
|
|
03e714cbea | ||
|
|
719bcce3f0 | ||
| 27d17a9345 | |||
| f765978dbb | |||
|
|
262f01ef23 | ||
|
|
95ec5731d3 | ||
|
|
c39fdc5059 | ||
|
|
083ba7f5e8 | ||
|
|
497c5846f5 | ||
|
|
c69faaf054 | ||
|
|
0a8bd13d9b | ||
|
|
317ebaa3fe | ||
|
|
7253ca0292 | ||
|
|
cfb73bd08c | ||
|
|
e420a1075e | ||
|
|
6051d3a3ff | ||
|
|
38295a6cd1 | ||
|
|
b2564777f2 | ||
|
|
3373bfc8fc | ||
|
|
b9237e97f6 | ||
|
|
08b5dd68ed | ||
|
|
6db5f1acee | ||
|
|
7330961289 | ||
|
|
518fd286a7 | ||
|
|
0fe6e8dd8c | ||
|
|
008f8b7895 | ||
|
|
fac35a85b2 | ||
|
|
bee6f0ead2 | ||
|
|
1809e8eb13 | ||
|
|
b2035a2bd4 | ||
|
|
73bbc13b10 | ||
|
|
974689ab34 | ||
|
|
22f52fdf1b | ||
|
|
36fe3d3b7b | ||
|
|
64fdd6d78d | ||
|
|
109a16ff8e | ||
|
|
658c6303d9 | ||
|
|
6f2f3cb961 | ||
|
|
cd9a877279 | ||
|
|
fd1b3fd958 | ||
|
|
a75173cbd0 | ||
|
|
f62aee08f9 | ||
|
|
d1ccb816ad | ||
|
|
0ac3f45ce2 | ||
|
|
dbfce89d8d | ||
|
|
062ef1bd2f | ||
|
|
f7339f7400 | ||
|
|
c78829d7bb | ||
|
|
e9dfd70662 | ||
|
|
e73a9a5dd0 | ||
|
|
87f1ee8312 | ||
|
|
8880fc9493 | ||
|
|
059afa5365 | ||
|
|
a69a7c128d | ||
|
|
ac0c2d1296 | ||
|
|
edf63b7a82 | ||
|
|
1b3442b393 | ||
|
|
7eaa1b32cb | ||
|
|
685a977c90 | ||
|
|
8e7cf53123 | ||
|
|
fdd2bb370e | ||
|
|
6565ccb74a | ||
|
|
9f49ea8373 | ||
|
|
69ae541886 | ||
|
|
1dfae34aeb | ||
|
|
b78903e1fd | ||
|
|
6c028562ca | ||
|
|
cd2afa4629 | ||
|
|
c766c9ced5 | ||
|
|
7ff0bde8a7 | ||
|
|
00892d4894 | ||
|
|
39a5bc0d77 | ||
|
|
623503bb77 | ||
|
|
02b9fd2511 | ||
|
|
64366b9d6d | ||
|
|
b4b69f57aa | ||
|
|
3d9788ee26 | ||
|
|
21e4db11ee | ||
|
|
c48d5ffc7f | ||
|
|
cedd2972f1 | ||
|
|
61d33be9c9 | ||
|
|
1a71bca956 | ||
|
|
d3148a2395 | ||
|
|
725a67c878 | ||
|
|
16ad490b5c | ||
|
|
77a38eb715 | ||
|
|
d6ff82e99d | ||
|
|
1f8dec641d | ||
|
|
7c108d2237 | ||
|
|
b69637ceec | ||
|
|
debfeedca2 | ||
|
|
ba4f51c555 | ||
|
|
fa7c1ee547 | ||
|
|
1b4c3dc88c | ||
|
|
e8a9971c78 | ||
|
|
a6b086e63a | ||
|
|
bc755dcea1 | ||
|
|
f95c54c2b8 | ||
|
|
6d5005b3ef | ||
|
|
b01d4f2924 | ||
|
|
8f27b7994a | ||
|
|
1ac3f995b6 | ||
|
|
b0d11ca210 | ||
|
|
c1d10a8043 | ||
|
|
d165159daa | ||
|
|
ef7b1521bc | ||
|
|
3d3a3874b0 | ||
|
|
e47747d587 | ||
|
|
752f040f46 | ||
|
|
98e3882980 | ||
|
|
f381efbe9a | ||
|
|
5970ba62cf | ||
|
|
fb70882de2 | ||
|
|
05587d6b8d | ||
|
|
4e81f54193 | ||
|
|
a689ee6161 | ||
|
|
63cb004806 | ||
|
|
245a559013 | ||
|
|
de9b3869e6 | ||
|
|
e69066d5c9 | ||
|
|
5a2b6491eb | ||
|
|
72004fe4af | ||
|
|
4b8e10d156 | ||
|
|
de1ced888f | ||
|
|
07d168e8a5 | ||
|
|
f26c7a1e87 | ||
|
|
cb0890bc6b | ||
|
|
c859a0d6e9 | ||
|
|
4d325a507e | ||
|
|
dd9a4cafd4 | ||
|
|
8d7ab9285e | ||
|
|
5319fac60f | ||
|
|
4c7aab9f33 | ||
|
|
27db42d5fa | ||
|
|
42ae243a63 | ||
|
|
8c1e63b85e | ||
|
|
2a6473605b | ||
|
|
d19ebbc309 | ||
|
|
926ed69287 | ||
|
|
970b7743ea | ||
|
|
a0ee239bf4 | ||
|
|
1963a1307e | ||
|
|
86c4c5b98c | ||
|
|
b030dd4a22 | ||
|
|
c059b3c83a | ||
|
|
fe2c5b03ee | ||
|
|
8d6011e956 | ||
|
|
d7227dbdc0 | ||
|
|
51d0122050 | ||
|
|
ae221bb1d0 | ||
|
|
1d03a07cfb | ||
|
|
32f56f7b29 | ||
|
|
5073be44be | ||
|
|
ba65f29538 | ||
|
|
b29a536966 | ||
|
|
1dcea9fcd2 | ||
|
|
143b4ba24c | ||
|
|
79f6273e0b | ||
|
|
49dd0394c3 | ||
|
|
9d0dc1e05c | ||
| a26a06392b | |||
|
|
51f460e6e8 | ||
|
|
c6e43993ad | ||
|
|
f9e9f7a3b2 | ||
|
|
1fd499922b | ||
|
|
1f7b5f0729 | ||
|
|
2a24b4e75a | ||
|
|
aa7d5f9e6b | ||
|
|
10874b157b | ||
|
|
14e895ef4d | ||
|
|
c3750cfae3 | ||
|
|
ea6f8c84df | ||
|
|
7ca192f68c | ||
|
|
80a662769f | ||
|
|
9c32573d56 | ||
|
|
b88227c095 | ||
|
|
933792e5d2 | ||
|
|
6fa13c8998 | ||
|
|
4fc9e12e9d | ||
|
|
8614af0266 | ||
|
|
dce127b011 | ||
|
|
93856fc048 | ||
|
|
0e43012453 | ||
|
|
27977d3dc3 | ||
|
|
d7ad55a962 | ||
|
|
73eee1ec4e | ||
|
|
71d05f9387 | ||
|
|
94e8ee27ec | ||
|
|
12ce367e81 | ||
|
|
ed85f51b90 | ||
|
|
3bcb380329 | ||
|
|
14d4fb118a | ||
|
|
eb337da34e | ||
|
|
26f31384ad | ||
|
|
3ca4512ca9 | ||
|
|
7504541cfc | ||
|
|
680b83463d | ||
|
|
fe83f9c203 | ||
|
|
5110e32141 | ||
|
|
d5ab8f5fd7 | ||
|
|
9c36d4a8f9 | ||
|
|
9a214a116a | ||
|
|
e9567029f2 | ||
|
|
ffdd9c2dd9 | ||
|
|
861e1c7619 | ||
|
|
a399eb22c9 | ||
|
|
71b852d961 | ||
|
|
f9a83fc126 | ||
|
|
337bd953f7 | ||
|
|
ae7dd33031 | ||
|
|
38a9239b9a | ||
|
|
11156eecd4 | ||
|
|
967a9accef | ||
|
|
be7d7b97c1 | ||
|
|
67b5f926df | ||
|
|
94c125f270 | ||
|
|
322be53834 | ||
|
|
4fd092fcee | ||
|
|
23349e1ef7 | ||
|
|
55e56b864c | ||
|
|
859c51c595 | ||
|
|
86ccc32f72 | ||
|
|
6be5896eb7 | ||
|
|
0a84e5eb55 | ||
|
|
3db6c240d0 | ||
|
|
f8ef2520f1 | ||
|
|
3948e9691e | ||
|
|
c90de20583 | ||
|
|
24696f3e15 | ||
|
|
1a9df8f90e | ||
|
|
1eff4b7fd8 | ||
|
|
56eebed092 | ||
|
|
1a4ebb20b1 | ||
|
|
7ee70b4670 | ||
|
|
1440d36b13 | ||
|
|
e9cbb15f16 | ||
|
|
ff51f93b85 | ||
|
|
92ea8f42b9 | ||
|
|
6a4b6c880a | ||
|
|
7612a27d39 | ||
|
|
e0750d9515 | ||
|
|
94a6c97e6a | ||
|
|
b208ef6141 | ||
|
|
a27fa3da3d | ||
|
|
50ff56e7b2 | ||
|
|
4c1fb4ecc2 |
28
Android.bp
28
Android.bp
@@ -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",
|
||||
}
|
||||
|
||||
79
Android.mk
79
Android.mk
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
|
||||
@@ -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"],
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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>
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
@@ -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>
|
||||
@@ -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
69
extract-files.py
Executable 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()
|
||||
120
extract-files.sh
120
extract-files.sh
@@ -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
4
gps/Android.bp
Normal file
@@ -0,0 +1,4 @@
|
||||
GNSS_CFLAGS = [
|
||||
"-Werror",
|
||||
"-Wno-undefined-bool-conversion",
|
||||
]
|
||||
50
gps/CleanSpec.mk
Normal file
50
gps/CleanSpec.mk
Normal 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
10
gps/Makefile.am
Normal 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
209
gps/android/2.0/AGnss.cpp
Normal 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
77
gps/android/2.0/AGnss.h
Normal 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
|
||||
133
gps/android/2.0/AGnssRil.cpp
Normal file
133
gps/android/2.0/AGnssRil.cpp
Normal 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
|
||||
84
gps/android/2.0/AGnssRil.h
Normal file
84
gps/android/2.0/AGnssRil.h
Normal 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_
|
||||
96
gps/android/2.0/Android.bp
Normal file
96
gps/android/2.0/Android.bp
Normal 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
671
gps/android/2.0/Gnss.cpp
Normal 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
187
gps/android/2.0/Gnss.h
Normal 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
|
||||
163
gps/android/2.0/GnssBatching.cpp
Normal file
163
gps/android/2.0/GnssBatching.cpp
Normal 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
|
||||
84
gps/android/2.0/GnssBatching.h
Normal file
84
gps/android/2.0/GnssBatching.h
Normal 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
|
||||
321
gps/android/2.0/GnssConfiguration.cpp
Normal file
321
gps/android/2.0/GnssConfiguration.cpp
Normal 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
|
||||
80
gps/android/2.0/GnssConfiguration.h
Normal file
80
gps/android/2.0/GnssConfiguration.h
Normal 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
|
||||
299
gps/android/2.0/GnssDebug.cpp
Normal file
299
gps/android/2.0/GnssDebug.cpp
Normal 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
|
||||
62
gps/android/2.0/GnssDebug.h
Normal file
62
gps/android/2.0/GnssDebug.h
Normal 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
|
||||
141
gps/android/2.0/GnssGeofencing.cpp
Normal file
141
gps/android/2.0/GnssGeofencing.cpp
Normal 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
|
||||
91
gps/android/2.0/GnssGeofencing.h
Normal file
91
gps/android/2.0/GnssGeofencing.h
Normal 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
|
||||
165
gps/android/2.0/GnssMeasurement.cpp
Normal file
165
gps/android/2.0/GnssMeasurement.cpp
Normal 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
|
||||
86
gps/android/2.0/GnssMeasurement.h
Normal file
86
gps/android/2.0/GnssMeasurement.h
Normal 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
|
||||
85
gps/android/2.0/GnssNi.cpp
Normal file
85
gps/android/2.0/GnssNi.cpp
Normal 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
75
gps/android/2.0/GnssNi.h
Normal 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
|
||||
4
gps/android/2.0/android.hardware.gnss@2.0-service-qti.rc
Normal file
4
gps/android/2.0/android.hardware.gnss@2.0-service-qti.rc
Normal 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
|
||||
36
gps/android/2.0/android.hardware.gnss@2.0-service-qti.xml
Normal file
36
gps/android/2.0/android.hardware.gnss@2.0-service-qti.xml
Normal 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>
|
||||
|
||||
250
gps/android/2.0/location_api/BatchingAPIClient.cpp
Normal file
250
gps/android/2.0/location_api/BatchingAPIClient.cpp
Normal 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
|
||||
81
gps/android/2.0/location_api/BatchingAPIClient.h
Normal file
81
gps/android/2.0/location_api/BatchingAPIClient.h
Normal 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
|
||||
275
gps/android/2.0/location_api/GeofenceAPIClient.cpp
Normal file
275
gps/android/2.0/location_api/GeofenceAPIClient.cpp
Normal 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
|
||||
76
gps/android/2.0/location_api/GeofenceAPIClient.h
Normal file
76
gps/android/2.0/location_api/GeofenceAPIClient.h
Normal 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
|
||||
728
gps/android/2.0/location_api/GnssAPIClient.cpp
Normal file
728
gps/android/2.0/location_api/GnssAPIClient.cpp
Normal 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
|
||||
114
gps/android/2.0/location_api/GnssAPIClient.h
Normal file
114
gps/android/2.0/location_api/GnssAPIClient.h
Normal 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
|
||||
311
gps/android/2.0/location_api/LocationUtil.cpp
Normal file
311
gps/android/2.0/location_api/LocationUtil.cpp
Normal 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, ¤tTime) != 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
|
||||
58
gps/android/2.0/location_api/LocationUtil.h
Normal file
58
gps/android/2.0/location_api/LocationUtil.h
Normal 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
|
||||
474
gps/android/2.0/location_api/MeasurementAPIClient.cpp
Normal file
474
gps/android/2.0/location_api/MeasurementAPIClient.cpp
Normal 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
|
||||
89
gps/android/2.0/location_api/MeasurementAPIClient.h
Normal file
89
gps/android/2.0/location_api/MeasurementAPIClient.h
Normal 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
|
||||
1
gps/android/2.0/measurement_corrections
Symbolic link
1
gps/android/2.0/measurement_corrections
Symbolic link
@@ -0,0 +1 @@
|
||||
../measurement_corrections
|
||||
85
gps/android/2.0/service.cpp
Normal file
85
gps/android/2.0/service.cpp
Normal 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;
|
||||
}
|
||||
1
gps/android/2.0/visibility_control
Symbolic link
1
gps/android/2.0/visibility_control
Symbolic link
@@ -0,0 +1 @@
|
||||
../visibility_control/
|
||||
@@ -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
|
||||
@@ -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
|
||||
34
gps/android/utils/Android.bp
Normal file
34
gps/android/utils/Android.bp
Normal 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: ["."],
|
||||
}
|
||||
273
gps/android/utils/battery_listener.cpp
Normal file
273
gps/android/utils/battery_listener.cpp
Normal 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();
|
||||
}
|
||||
32
gps/android/utils/battery_listener.h
Normal file
32
gps/android/utils/battery_listener.h
Normal 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();
|
||||
169
gps/android/visibility_control/1.0/GnssVisibilityControl.cpp
Normal file
169
gps/android/visibility_control/1.0/GnssVisibilityControl.cpp
Normal 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
|
||||
90
gps/android/visibility_control/1.0/GnssVisibilityControl.h
Normal file
90
gps/android/visibility_control/1.0/GnssVisibilityControl.h
Normal 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
29
gps/batching/Android.bp
Normal 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,
|
||||
}
|
||||
1050
gps/batching/BatchingAdapter.cpp
Normal file
1050
gps/batching/BatchingAdapter.cpp
Normal file
File diff suppressed because it is too large
Load Diff
152
gps/batching/BatchingAdapter.h
Normal file
152
gps/batching/BatchingAdapter.h
Normal 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
45
gps/batching/Makefile.am
Normal 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
78
gps/batching/configure.ac
Normal 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
|
||||
10
gps/batching/location-batching.pc.in
Normal file
10
gps/batching/location-batching.pc.in
Normal 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
|
||||
134
gps/batching/location_batching.cpp
Normal file
134
gps/batching/location_batching.cpp
Normal 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
87
gps/configure.ac
Normal 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
54
gps/core/Android.bp
Normal 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
344
gps/core/ContextBase.cpp
Normal 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
261
gps/core/ContextBase.h
Normal 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__
|
||||
127
gps/core/EngineHubProxyBase.h
Normal file
127
gps/core/EngineHubProxyBase.h
Normal 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 ¶ms) {
|
||||
(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
70
gps/core/LBSProxyBase.h
Normal 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
411
gps/core/LocAdapterBase.cpp
Normal 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
222
gps/core/LocAdapterBase.h
Normal 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 ¬ify, 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
|
||||
77
gps/core/LocAdapterProxyBase.h
Normal file
77
gps/core/LocAdapterProxyBase.h
Normal 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
877
gps/core/LocApiBase.cpp
Normal 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 ¬ify, 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
322
gps/core/LocApiBase.h
Normal 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 ¬ify, 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
98
gps/core/LocContext.cpp
Normal 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
66
gps/core/LocContext.h
Normal 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
70
gps/core/Makefile.am
Normal 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
1748
gps/core/SystemStatus.cpp
Normal file
File diff suppressed because it is too large
Load Diff
916
gps/core/SystemStatus.h
Normal file
916
gps/core/SystemStatus.h
Normal 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__
|
||||
|
||||
575
gps/core/SystemStatusOsObserver.cpp
Normal file
575
gps/core/SystemStatusOsObserver.cpp
Normal 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
|
||||
|
||||
176
gps/core/SystemStatusOsObserver.h
Normal file
176
gps/core/SystemStatusOsObserver.h
Normal 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
94
gps/core/configure.ac
Normal 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
|
||||
554
gps/core/data-items/DataItemConcreteTypesBase.h
Normal file
554
gps/core/data-items/DataItemConcreteTypesBase.h
Normal 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__
|
||||
79
gps/core/data-items/DataItemId.h
Normal file
79
gps/core/data-items/DataItemId.h
Normal 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__
|
||||
100
gps/core/data-items/DataItemsFactoryProxy.cpp
Normal file
100
gps/core/data-items/DataItemsFactoryProxy.cpp
Normal 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
|
||||
|
||||
|
||||
55
gps/core/data-items/DataItemsFactoryProxy.h
Normal file
55
gps/core/data-items/DataItemsFactoryProxy.h
Normal 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__
|
||||
|
||||
82
gps/core/data-items/IDataItemCore.h
Normal file
82
gps/core/data-items/IDataItemCore.h
Normal 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
10
gps/core/loc-core.pc.in
Normal 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
227
gps/core/loc_core_log.cpp
Normal 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
58
gps/core/loc_core_log.h
Normal 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 */
|
||||
76
gps/core/observer/IDataItemObserver.h
Normal file
76
gps/core/observer/IDataItemObserver.h
Normal 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__
|
||||
129
gps/core/observer/IDataItemSubscription.h
Normal file
129
gps/core/observer/IDataItemSubscription.h
Normal 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__
|
||||
|
||||
101
gps/core/observer/IFrameworkActionReq.h
Normal file
101
gps/core/observer/IFrameworkActionReq.h
Normal 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__
|
||||
|
||||
107
gps/core/observer/IOsObserver.h
Normal file
107
gps/core/observer/IOsObserver.h
Normal 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
Reference in New Issue
Block a user