Merge lp:~thomas-voss/location-service/enable-dual-landing into lp:location-service/trunk

Proposed by Thomas Voß
Status: Needs review
Proposed branch: lp:~thomas-voss/location-service/enable-dual-landing
Merge into: lp:location-service/trunk
Diff against target: 2660 lines (+1851/-161)
48 files modified
CMakeLists.txt (+42/-3)
_clang-format (+56/-0)
astyle-config (+43/-0)
debian/VERSION (+1/-0)
debian/VERSION.vivid (+1/-0)
debian/changelog (+81/-0)
debian/control (+11/-5)
debian/control.in (+123/-0)
debian/gen-debian-files.sh (+111/-0)
debian/get-versions.sh (+68/-0)
debian/libubuntu-location-service-dev.install (+0/-5)
debian/libubuntu-location-service-dev.install.in (+5/-0)
debian/libubuntu-location-service.install.in (+2/-0)
debian/libubuntu-location-service.install.with-gps.in (+3/-0)
debian/libubuntu-location-service2.install (+0/-2)
debian/libubuntu-location-service2.install.with-gps (+0/-3)
debian/rules (+20/-1)
debian/source/format (+1/-1)
doc/Doxyfile.in (+2/-2)
doc/daemon_and_cli.md (+55/-0)
doc/debugging.md (+92/-0)
doc/hacking.md (+146/-0)
doc/intro.md (+67/-0)
doc/manual_testing.md (+174/-0)
doc/tips_n_tricks.md (+21/-0)
src/location_service/com/ubuntu/location/CMakeLists.txt (+1/-0)
src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp (+12/-6)
src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h (+12/-0)
src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp (+1/-1)
src/location_service/com/ubuntu/location/engine.cpp (+23/-14)
src/location_service/com/ubuntu/location/engine.h (+3/-3)
src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp (+3/-5)
src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h (+1/-1)
src/location_service/com/ubuntu/location/service/daemon.cpp (+14/-66)
src/location_service/com/ubuntu/location/service/implementation.cpp (+23/-4)
src/location_service/com/ubuntu/location/service/provider_daemon.cpp (+17/-16)
src/location_service/com/ubuntu/location/service/runtime.cpp (+109/-0)
src/location_service/com/ubuntu/location/service/runtime.h (+90/-0)
src/location_service/com/ubuntu/location/service/session/skeleton.cpp (+21/-3)
src/location_service/com/ubuntu/location/time_based_update_policy.cpp (+4/-3)
tests/CMakeLists.txt (+1/-0)
tests/acceptance_tests.cpp (+115/-13)
tests/engine_test.cpp (+3/-3)
tests/gps_provider_test.cpp (+83/-0)
tests/position_test.cpp (+1/-1)
tests/runtime_test.cpp (+118/-0)
tools/CMakeLists.txt (+1/-0)
tools/symbol_diff.in (+70/-0)
To merge this branch: bzr merge lp:~thomas-voss/location-service/enable-dual-landing
Reviewer Review Type Date Requested Status
Łukasz Zemczak packaging Needs Fixing
PS Jenkins bot continuous-integration Approve
Review via email: mp+282942@code.launchpad.net

This proposal supersedes a proposal from 2015-11-20.

Commit message

Enable dual landing.

Description of the change

Enable dual landing.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Ok, that's one big branch. The control.in and rules bits seem to be ok. Yes, I'm getting boring here, but the thing that's missing is some ABI checking. This package never really seemed to have symbols so it's not a regression, but I would like that added ASAP. We can, of course, not block on this, but a bug with high priority would have to be filled in and assigned to someone to work on it before landing.

That being said... there are some strange things here. First of all: the merge commit-message (or changelog) needs updating to actually be more verbose on what happened here - how the dual landings are done etc. I also see a lot of other changes, probably not completely related in the silo. Those need to have a mention in the changelog/commit-message itself. Certainly "Enable dual landing." is not enough in this case.

Another strange thing: I noticed you have added the tools/symbol_diff.in tool, but that's not really used anywhere. Also, the documentation mentions symbols checking, but the packaging doesn't really provide any default symbols right now (this should be automated if anything). The same document (doc/hacking.md) also, when mentioning ABI compliance checker uses libunity-scopes in the examples, which seems strange.

review: Needs Fixing (packaging)

Unmerged revisions

228. By Thomas Voß

* Ensure that event connections are cleaned up on destruction. (LP:
  #1480877)
[ Alberto Mardegan ]
* Send last known position on session start
[ CI Train Bot ]
* New rebuild forced.
[ Thomas Voß ]
* Factor out service::Runtime from daemon.cpp into its own .h/.cpp
  pair of files. Add test cases around correct operation of
  service::Runtime. added:
  src/location_service/com/ubuntu/location/service/runtime.cpp
  src/location_service/com/ubuntu/location/service/runtime.h
  tests/runtime_test.cpp
[ thomas-voss ]
* Factor out service::Runtime from daemon.cpp into its own .h/.cpp
  pair of files. Add test cases around correct operation of
  service::Runtime. added:
  src/location_service/com/ubuntu/location/service/runtime.cpp
  src/location_service/com/ubuntu/location/service/runtime.h
  tests/runtime_test.cpp

227. By Thomas Voß

Provide a sensible version fallback.
Add correct version for Replaces/Conflicts stanzas in generated debian/control.

226. By Thomas Voß

Lower client count to make test more robust.

225. By Thomas Voß

Add build-dependency on lsb-release to debian/control.in.

224. By Thomas Voß

Fix s/lsp/lsb/ typo.

223. By Thomas Voß

* libubuntu-location-service3: Replaces libubuntu-location-service2,
  config file /etc/gps.conf in both packages.
* Bump major revision and fix LP:#1478750 to account for toolchain update.

222. By Thomas Voß

Add missing build-dep on lsb-release.

221. By Thomas Voß

Account for versioned include dir.

220. By Thomas Voß

Alter build setup to query major.minor.patch from debian.VERSION* files.

219. By Thomas Voß

Enable dual landing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-09-18 23:06:08 +0000
3+++ CMakeLists.txt 2016-01-18 13:07:31 +0000
4@@ -2,9 +2,34 @@
5
6 project(ubuntu-location-service)
7
8-set(UBUNTU_LOCATION_SERVICE_VERSION_MAJOR 2)
9-set(UBUNTU_LOCATION_SERVICE_VERSION_MINOR 0)
10-set(UBUNTU_LOCATION_SERVICE_VERSION_PATCH 0)
11+# We haven't received version information via the packaging setup.
12+# For that, we try to determine sensible values on our own, ensuring
13+# plain old invocations to cmake still work as expected.
14+if (NOT DEFINED UBUNTU_LOCATION_SERVICE_VERSION_MAJOR)
15+ find_program(LSB_RELEASE lsb_release)
16+ execute_process(
17+ COMMAND ${LSB_RELEASE} -c -s
18+ OUTPUT_VARIABLE DISTRO_CODENAME
19+ OUTPUT_STRIP_TRAILING_WHITESPACE)
20+
21+ # We explicitly ignore errors and only check if we are building for vivid.
22+ # For all other cases:
23+ # - releases other than vivid
24+ # - other distros
25+ # - errors
26+ # we define the version to be 2.0.0
27+ if (${DISTRO_CODENAME} STREQUAL "vivid")
28+ set(UBUNTU_LOCATION_SERVICE_VERSION_MAJOR 2)
29+ set(UBUNTU_LOCATION_SERVICE_VERSION_MINOR 0)
30+ set(UBUNTU_LOCATION_SERVICE_VERSION_PATCH 0)
31+ else ()
32+ set(UBUNTU_LOCATION_SERVICE_VERSION_MAJOR 3)
33+ set(UBUNTU_LOCATION_SERVICE_VERSION_MINOR 0)
34+ set(UBUNTU_LOCATION_SERVICE_VERSION_PATCH 0)
35+ endif()
36+endif()
37+
38+message(STATUS "${CMAKE_PROJECT_NAME} ${UBUNTU_LOCATION_SERVICE_VERSION_MAJOR}.${UBUNTU_LOCATION_SERVICE_VERSION_MINOR}.${UBUNTU_LOCATION_SERVICE_VERSION_PATCH}")
39
40 set(UBUNTU_LOCATION_SERVICE_TRUST_STORE_SERVICE_NAME "UbuntuLocationService")
41
42@@ -54,6 +79,20 @@
43 SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-local-typedefs")
44 endif (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS)
45
46+#
47+# Code style fixer. We rely on clang-format to adjust the formatting of source code.
48+#
49+find_program(CLANG_FORMAT_COMMAND NAMES clang-format-3.6 clang-format-3.5)
50+if (NOT CLANG_FORMAT_COMMAND)
51+ message(WARNING "Cannot find clang-format >= clang-format-3.5: formatcode target will not be available")
52+endif()
53+
54+if (CLANG_FORMAT_COMMAND)
55+ file(GLOB_RECURSE UBUNTU_LOCATION_SERVICE_INTERFACE_HEADER_FILES ${CMAKE_SOURCE_DIR}/include/*.h)
56+ file(GLOB_RECURSE UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_FILES ${CMAKE_SOURCE_DIR}/src/*.h ${CMAKE_SOURCE_DIR}/src/*.cpp)
57+ add_custom_target(formatcode ${CLANG_FORMAT_COMMAND} -i ${UBUNTU_LOCATION_SERVICE_INTERFACE_HEADER_FILES} ${UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_FILES} SOURCES _clang-format)
58+endif()
59+
60 include_directories(
61 ${Boost_INCLUDE_DIRS}
62 ${DBUS_INCLUDE_DIRS}
63
64=== added file '_clang-format'
65--- _clang-format 1970-01-01 00:00:00 +0000
66+++ _clang-format 2016-01-18 13:07:31 +0000
67@@ -0,0 +1,56 @@
68+---
69+Language: Cpp
70+AccessModifierOffset: -4
71+ConstructorInitializerIndentWidth: 4
72+AlignEscapedNewlinesLeft: false
73+AlignTrailingComments: true
74+AllowAllParametersOfDeclarationOnNextLine: true
75+AllowShortBlocksOnASingleLine: false
76+AllowShortIfStatementsOnASingleLine: false
77+AllowShortLoopsOnASingleLine: false
78+AllowShortFunctionsOnASingleLine: All
79+AlwaysBreakTemplateDeclarations: false
80+AlwaysBreakBeforeMultilineStrings: false
81+BreakBeforeBinaryOperators: false
82+BreakBeforeTernaryOperators: true
83+BreakConstructorInitializersBeforeComma: false
84+BinPackParameters: true
85+ColumnLimit: 0
86+ConstructorInitializerAllOnOneLineOrOnePerLine: false
87+DerivePointerAlignment: false
88+ExperimentalAutoDetectBinPacking: false
89+IndentCaseLabels: false
90+IndentWrappedFunctionNames: false
91+IndentFunctionDeclarationAfterType: false
92+MaxEmptyLinesToKeep: 1
93+KeepEmptyLinesAtTheStartOfBlocks: true
94+NamespaceIndentation: None
95+ObjCSpaceAfterProperty: false
96+ObjCSpaceBeforeProtocolList: true
97+PenaltyBreakBeforeFirstCallParameter: 19
98+PenaltyBreakComment: 300
99+PenaltyBreakString: 1000
100+PenaltyBreakFirstLessLess: 120
101+PenaltyExcessCharacter: 1000000
102+PenaltyReturnTypeOnItsOwnLine: 60
103+PointerAlignment: Left
104+SpacesBeforeTrailingComments: 1
105+Cpp11BracedListStyle: true
106+Standard: Cpp11
107+IndentWidth: 4
108+TabWidth: 8
109+UseTab: Never
110+BreakBeforeBraces: Allman
111+SpacesInParentheses: false
112+SpacesInAngles: false
113+SpaceInEmptyParentheses: false
114+SpacesInCStyleCastParentheses: false
115+SpacesInContainerLiterals: true
116+SpaceBeforeAssignmentOperators: true
117+ContinuationIndentWidth: 4
118+CommentPragmas: '^ IWYU pragma:'
119+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
120+SpaceBeforeParens: ControlStatements
121+DisableFormat: false
122+...
123+
124
125=== added file 'astyle-config'
126--- astyle-config 1970-01-01 00:00:00 +0000
127+++ astyle-config 2016-01-18 13:07:31 +0000
128@@ -0,0 +1,43 @@
129+# Options for formatting code with astyle.
130+#
131+# This helps to make code match the style guide.
132+#
133+# Use like this:
134+#
135+# astyle --options=astyle-config mfile.h myfile.cpp
136+#
137+# Occasionally, astyle does something silly (particularly with lambdas), so it's
138+# still necessary to scan the changes for things that are wrong.
139+# But, for most files, it does a good job.
140+#
141+# Please consider using this before checking code in for review. Code reviews shouldn't
142+# have to deal with layout issues, they are just a distraction. It's better to be able
143+# to focus on semantics in a code review, with style issues out of the way.
144+
145+--formatted
146+--style=allman
147+--min-conditional-indent=2
148+--indent-switches
149+--max-instatement-indent=120
150+--pad-header
151+--align-pointer=type
152+--align-reference=type
153+--convert-tabs
154+--close-templates
155+--max-code-length=120
156+
157+# --pad-oper
158+#
159+# Commented out for now. It changes
160+#
161+# for (int i=0; i<10; ++i)
162+# to
163+# for (int i = 0; i < 10; ++i)
164+#
165+# Unfortunately, it also messes with rvalue references:
166+#
167+# ResourcePtr& operator=(ResourcePtr&& r);
168+#
169+# becomes:
170+#
171+# ResourcePtr& operator=(ResourcePtr && r);
172
173=== added file 'debian/VERSION'
174--- debian/VERSION 1970-01-01 00:00:00 +0000
175+++ debian/VERSION 2016-01-18 13:07:31 +0000
176@@ -0,0 +1,1 @@
177+3.0.0
178\ No newline at end of file
179
180=== added file 'debian/VERSION.vivid'
181--- debian/VERSION.vivid 1970-01-01 00:00:00 +0000
182+++ debian/VERSION.vivid 2016-01-18 13:07:31 +0000
183@@ -0,0 +1,1 @@
184+2.0.0
185
186=== modified file 'debian/changelog'
187--- debian/changelog 2015-07-27 18:07:37 +0000
188+++ debian/changelog 2016-01-18 13:07:31 +0000
189@@ -1,3 +1,16 @@
190+location-service (3.0.0-0ubuntu2) wily; urgency=medium
191+
192+ * libubuntu-location-service3: Replaces libubuntu-location-service2,
193+ config file /etc/gps.conf in both packages.
194+
195+ -- Matthias Klose <doko@ubuntu.com> Thu, 30 Jul 2015 09:57:50 +0200
196+
197+location-service (3.0.0) wily; urgency=medium
198+
199+ * Bump major revision and fix LP:#1478750 to account for toolchain update.
200+
201+ -- Thomas Voß <thomas.voss@canonical.com> Thu, 30 Jul 2015 08:33:13 +0200
202+
203 location-service (2.1+15.10.20150727-0ubuntu1) wily; urgency=medium
204
205 [ CI Train Bot ]
206@@ -36,6 +49,74 @@
207
208 -- CI Train Bot <ci-train-bot@canonical.com> Thu, 28 May 2015 11:40:58 +0000
209
210+location-service (2.1+15.04.20151202.1-0ubuntu1) vivid; urgency=medium
211+
212+ * Ensure that event connections are cleaned up on destruction. (LP:
213+ #1480877)
214+
215+ -- Thomas Voß <ci-train-bot@canonical.com> Wed, 02 Dec 2015 12:12:21 +0000
216+
217+location-service (2.1+15.04.20151127-0ubuntu1) vivid; urgency=medium
218+
219+ [ Alberto Mardegan ]
220+ * Send last known position on session start
221+
222+ [ CI Train Bot ]
223+ * New rebuild forced.
224+
225+ [ Thomas Voß ]
226+ * Factor out service::Runtime from daemon.cpp into its own .h/.cpp
227+ pair of files. Add test cases around correct operation of
228+ service::Runtime. added:
229+ src/location_service/com/ubuntu/location/service/runtime.cpp
230+ src/location_service/com/ubuntu/location/service/runtime.h
231+ tests/runtime_test.cpp
232+
233+ [ thomas-voss ]
234+ * Factor out service::Runtime from daemon.cpp into its own .h/.cpp
235+ pair of files. Add test cases around correct operation of
236+ service::Runtime. added:
237+ src/location_service/com/ubuntu/location/service/runtime.cpp
238+ src/location_service/com/ubuntu/location/service/runtime.h
239+ tests/runtime_test.cpp
240+
241+ -- Thomas Voß <ci-train-bot@canonical.com> Fri, 27 Nov 2015 13:00:33 +0000
242+
243+location-service (2.1+15.04.20151113-0ubuntu1) vivid; urgency=medium
244+
245+ * Adjust default timeout for downloading GPS XTRA data.
246+
247+ -- Thomas Voß <ci-train-bot@canonical.com> Fri, 13 Nov 2015 10:33:56 +0000
248+
249+location-service (2.1+15.04.20151109.2-0ubuntu1) vivid; urgency=medium
250+
251+ [ Alberto Mardegan ]
252+ * Make sure that injected time is given in milliseconds
253+
254+ [ Thomas Voß ]
255+ * Cherry-pick rev. 196 and 199 from lp:location-service. The changes
256+ got accidentally removed by merging the outstanding documentation
257+ branch.
258+ * Handle responses of clients to updates asynchronously. Rely on
259+ dummy::ConnectivityManager as harvesting is disabled anyway. (LP:
260+ #1462664, #1387643)
261+
262+ -- David Barth <david.barth@canonical.com> Mon, 09 Nov 2015 20:48:48 +0000
263+
264+location-service (2.1+15.04.20151022-0ubuntu1) vivid; urgency=medium
265+
266+ [ Thomas Voß ]
267+ * Add documentation for debugging, hacking and debugging the location
268+ service. Pull manual testing instructions over from the wiki. Add
269+ tools for formatting the source.
270+
271+ [ thomas-voss ]
272+ * Add documentation for debugging, hacking and debugging the location
273+ service. Pull manual testing instructions over from the wiki. Add
274+ tools for formatting the source.
275+
276+ -- Thomas Voß <ci-train-bot@canonical.com> Thu, 22 Oct 2015 07:16:50 +0000
277+
278 location-service (2.1+15.04.20150427.1-0ubuntu1) vivid; urgency=medium
279
280 [ CI Train Bot ]
281
282=== modified file 'debian/control'
283--- debian/control 2015-07-15 19:04:43 +0000
284+++ debian/control 2016-01-18 13:07:31 +0000
285@@ -1,3 +1,8 @@
286+# This file is autogenerated. DO NOT EDIT!
287+#
288+# Modifications should be made to control.in instead.
289+# This file is regenerated automatically in the clean target.
290+#
291 Source: location-service
292 Section: utils
293 Priority: optional
294@@ -27,6 +32,7 @@
295 libubuntu-platform-hardware-api-headers [!arm64 !ppc64el !powerpc],
296 libubuntu-platform-hardware-api-dev [!arm64 !ppc64el !powerpc],
297 libproperties-cpp-dev,
298+ lsb-release,
299 trust-store-bin,
300 Standards-Version: 3.9.4
301 Homepage: http://launchpad.net/location-service
302@@ -35,7 +41,7 @@
303 Vcs-Bzr: https://code.launchpad.net/~phablet-team/location-service/trunk
304 Vcs-Browser: http://bazaar.launchpad.net/~phablet-team/location-service/trunk/files
305
306-Package: libubuntu-location-service2
307+Package: libubuntu-location-service3
308 Section: libs
309 Architecture: any
310 Multi-Arch: same
311@@ -52,7 +58,7 @@
312 Architecture: any
313 Multi-Arch: foreign
314 Recommends: ubuntu-location-service-doc,
315-Depends: libubuntu-location-service2 (= ${binary:Version}),
316+Depends: libubuntu-location-service3 (= ${binary:Version}),
317 libdbus-1-dev,
318 libdbus-cpp-dev,
319 libboost-dev,
320@@ -68,7 +74,7 @@
321 Section: debug
322 Architecture: any
323 Multi-Arch: foreign
324-Depends: libubuntu-location-service2 (= ${binary:Version}),
325+Depends: libubuntu-location-service3 (= ${binary:Version}),
326 ${misc:Depends},
327 Description: location service aggregating position/velocity/heading
328 updates and exporting them over dbus.
329@@ -86,7 +92,7 @@
330
331 Package: ubuntu-location-service-bin
332 Architecture: any
333-Depends: libubuntu-location-service2 (= ${binary:Version}),
334+Depends: libubuntu-location-service3 (= ${binary:Version}),
335 ${misc:Depends},
336 ${shlibs:Depends},
337 trust-store-bin,
338@@ -100,7 +106,7 @@
339 Package: ubuntu-location-service-examples
340 Architecture: any
341 Multi-Arch: same
342-Depends: libubuntu-location-service2 (= ${binary:Version}),
343+Depends: libubuntu-location-service3 (= ${binary:Version}),
344 ${misc:Depends},
345 ${shlibs:Depends},
346 ubuntu-location-service-doc,
347
348=== added file 'debian/control.in'
349--- debian/control.in 1970-01-01 00:00:00 +0000
350+++ debian/control.in 2016-01-18 13:07:31 +0000
351@@ -0,0 +1,123 @@
352+Source: location-service
353+Section: utils
354+Priority: optional
355+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
356+XSBC-Original-Maintainer: Thomas Voß <thomas.voss@canonical.com>
357+Build-Depends: cmake,
358+ curl,
359+ libdbus-cpp-dev (>= 4.1.0),
360+ debhelper (>= 9),
361+ doxygen,
362+ geoclue-ubuntu-geoip,
363+ google-mock (>= 1.6.0+svn437),
364+ graphviz,
365+ libapparmor-dev,
366+ libboost-filesystem-dev,
367+ libboost-program-options-dev,
368+ libboost-system-dev,
369+ libdbus-1-dev,
370+ libdbus-cpp-dev,
371+ libgoogle-glog-dev,
372+ libgtest-dev,
373+ libiw-dev,
374+ libjson-c-dev,
375+ libnet-cpp-dev,
376+ libprocess-cpp-dev,
377+ libtrust-store-dev,
378+ libubuntu-platform-hardware-api-headers [!arm64 !ppc64el !powerpc],
379+ libubuntu-platform-hardware-api-dev [!arm64 !ppc64el !powerpc],
380+ libproperties-cpp-dev,
381+ lsb-release,
382+ trust-store-bin,
383+Standards-Version: 3.9.4
384+Homepage: http://launchpad.net/location-service
385+# If you aren't a member of ~phablet-team but need to upload packaging changes,
386+# just go ahead. ~phablet-team will notice and sync up the code again.
387+Vcs-Bzr: https://code.launchpad.net/~phablet-team/location-service/trunk
388+Vcs-Browser: http://bazaar.launchpad.net/~phablet-team/location-service/trunk/files
389+
390+Package: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@
391+Section: libs
392+Architecture: any
393+Multi-Arch: same
394+Pre-Depends: ${misc:Pre-Depends}
395+Depends: ${misc:Depends},
396+ ${shlibs:Depends},
397+Description: location service aggregating position/velocity/heading
398+ updates and exporting them over dbus.
399+ .
400+ Contains the shared library needed by client applications.
401+
402+Package: libubuntu-location-service-dev
403+Section: libdevel
404+Architecture: any
405+Multi-Arch: foreign
406+Recommends: ubuntu-location-service-doc,
407+Depends: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@ (= ${binary:Version}),
408+ libdbus-1-dev,
409+ libdbus-cpp-dev,
410+ libboost-dev,
411+ ${misc:Depends},
412+Suggests: ubuntu-location-service-doc,
413+Description: location service aggregating position/velocity/heading
414+ updates and exporting them over dbus.
415+ .
416+ Contains header files required to develop clients talking to the ubuntu
417+ location service.
418+
419+Package: libubuntu-location-service-dbg
420+Section: debug
421+Architecture: any
422+Multi-Arch: foreign
423+Depends: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@ (= ${binary:Version}),
424+ ${misc:Depends},
425+Description: location service aggregating position/velocity/heading
426+ updates and exporting them over dbus.
427+ .
428+ Contains debug symbols.
429+
430+Package: ubuntu-location-service-tests
431+Architecture: any
432+Depends: ${misc:Depends},
433+ ${shlibs:Depends},
434+Description: location service aggregating position/velocity/heading
435+ updates and exporting them over dbus.
436+ .
437+ Contains all test executables
438+
439+Package: ubuntu-location-service-bin
440+Architecture: any
441+Depends: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@ (= ${binary:Version}),
442+ ${misc:Depends},
443+ ${shlibs:Depends},
444+ trust-store-bin,
445+Breaks: ubuntu-location-service-examples (<< 0.0.2),
446+Replaces: ubuntu-location-service-examples (<< 0.0.2),
447+Description: location service aggregating position/velocity/heading
448+ updates and exporting them over dbus.
449+ .
450+ Contains the service executable and man pages.
451+
452+Package: ubuntu-location-service-examples
453+Architecture: any
454+Multi-Arch: same
455+Depends: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@ (= ${binary:Version}),
456+ ${misc:Depends},
457+ ${shlibs:Depends},
458+ ubuntu-location-service-doc,
459+Description: location service aggregating position/velocity/heading
460+ updates and exporting them over dbus.
461+ .
462+ Contains example service and client.
463+
464+Package: ubuntu-location-service-doc
465+Section: doc
466+Architecture: all
467+Multi-Arch: foreign
468+Depends: ${misc:Depends},
469+ ${shlibs:Depends},
470+Recommends: ubuntu-location-service-examples,
471+Description: location service aggregating position/velocity/heading
472+ updates and exporting them over dbus.
473+ .
474+ Contains documentation for service and client.
475
476=== added file 'debian/gen-debian-files.sh'
477--- debian/gen-debian-files.sh 1970-01-01 00:00:00 +0000
478+++ debian/gen-debian-files.sh 2016-01-18 13:07:31 +0000
479@@ -0,0 +1,111 @@
480+#!/bin/sh
481+
482+# Copyright (C) 2015 Canonical Ltd
483+#
484+# This program is free software: you can redistribute it and/or modify
485+# it under the terms of the GNU Lesser General Public License version 3 as
486+# published by the Free Software Foundation.
487+#
488+# This program is distributed in the hope that it will be useful,
489+# but WITHOUT ANY WARRANTY; without even the implied warranty of
490+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
491+# GNU Lesser General Public License for more details.
492+#
493+# You should have received a copy of the GNU Lesser General Public License
494+# along with this program. If not, see <http://www.gnu.org/licenses/>.
495+#
496+# Authored by: Michi Henning <michi.henning@canonical.com>
497+# Thomas Voß <thomas.voss@canonical.com>
498+
499+#
500+# Script to generate debian files for dual landing in Vivid (gcc 4.9 ABI)
501+# and Wily and later (gcc 5 ABI).
502+#
503+# This script is called from debian/rules and generates:
504+#
505+# - control
506+# - libubuntu-location-service${soversion}.install.${target_arch}
507+#
508+# For all but control, this is a straight substition and/or renaming exercise for each file.
509+# For control, if building on Wily or later, we also fix the "Replaces:" and "Conflicts:"
510+# entries, so we don't end up with two packages claiming ownership of the same places
511+# in the file system.
512+#
513+# Because the debian files for the different distributions are generated on the fly,
514+# this allows us to keep a single source tree for both distributions. See ../HACKING
515+# for more explanations.
516+#
517+
518+set -e # Fail if any command fails.
519+
520+progname=$(basename $0)
521+
522+[ $# -ne 1 ] && {
523+ echo "usage: $progname path-to-debian-dir" >&2
524+ exit 1
525+}
526+dir=$1
527+version_dir=$(mktemp -d)
528+
529+# Dump version numbers into files and initialize vars from those files.
530+
531+sh ${dir}/get-versions.sh ${dir} ${version_dir}
532+
533+full_version=$(cat "${version_dir}"/libubuntu-location-service.full-version)
534+major_minor=$(cat "${version_dir}"/libubuntu-location-service.major-minor-version)
535+soversion=$(cat "${version_dir}"/libubuntu-location-service.soversion)
536+vivid_soversion=$(cat "${version_dir}"/libubuntu-location-service.vivid-soversion)
537+
538+warning=$(mktemp -t gen-debian-files-msg.XXX)
539+
540+trap "rm -fr $warning $version_dir" 0 INT TERM QUIT
541+
542+warning_msg()
543+{
544+ cat >$warning <<EOF
545+# This file is autogenerated. DO NOT EDIT!
546+#
547+# Modifications should be made to $(basename "$1") instead.
548+# This file is regenerated automatically in the clean target.
549+#
550+EOF
551+}
552+
553+# Generate debian/control from debian/control.in, substituting the soversion for both libs.
554+# For wily onwards, we also add an entry for the vivid versions to "Conflicts:" and "Replaces:".
555+
556+infile="${dir}"/control.in
557+outfile="${dir}"/control
558+warning_msg $infile
559+cat $warning $infile \
560+ | sed -e "s/@UBUNTU_LOCATION_SERVICE_SOVERSION@/${soversion}/" > "$outfile"
561+
562+[ "$distro" != "vivid" ] && {
563+ sed -i -e "/Replaces: libubuntu-location-service2,/a\
564+\ libubuntu-location-service${vivid_soversion}," \
565+ "$outfile"
566+}
567+
568+# Generate the install files, naming them according to the soversion.
569+
570+# Install file for binary package
571+infile="${dir}"/libubuntu-location-service.install.in
572+outfile="${dir}"/libubuntu-location-service${soversion}.install
573+warning_msg "$infile"
574+cat $warning "$infile" >"$outfile"
575+
576+infile="${dir}"/libubuntu-location-service.install.with-gps.in
577+outfile="${dir}"/libubuntu-location-service${soversion}.install.with-gps
578+warning_msg "$infile"
579+cat $warning "$infile" >"$outfile"
580+
581+infile="${dir}"/libubuntu-location-service-dev.install.in
582+outfile="${dir}"/libubuntu-location-service-dev.install
583+warning_msg "$infile"
584+cat $warning $infile | sed -e "s/@UBUNTU_LOCATION_SERVICE_SOVERSION@/${soversion}/" > "$outfile"
585+
586+ln -s "${dir}"/libubuntu-location-service${soversion}.install.with-gps "${dir}"/libubuntu-location-service${soversion}.install.amd64
587+ln -s "${dir}"/libubuntu-location-service${soversion}.install.with-gps "${dir}"/libubuntu-location-service${soversion}.install.armhf
588+ln -s "${dir}"/libubuntu-location-service${soversion}.install.with-gps "${dir}"/libubuntu-location-service${soversion}.install.i386
589+
590+exit 0
591
592=== added file 'debian/get-versions.sh'
593--- debian/get-versions.sh 1970-01-01 00:00:00 +0000
594+++ debian/get-versions.sh 2016-01-18 13:07:31 +0000
595@@ -0,0 +1,68 @@
596+#!/bin/sh
597+
598+# Copyright (C) 2015 Canonical Ltd
599+#
600+# This program is free software: you can redistribute it and/or modify
601+# it under the terms of the GNU Lesser General Public License version 3 as
602+# published by the Free Software Foundation.
603+#
604+# This program is distributed in the hope that it will be useful,
605+# but WITHOUT ANY WARRANTY; without even the implied warranty of
606+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
607+# GNU Lesser General Public License for more details.
608+#
609+# You should have received a copy of the GNU Lesser General Public License
610+# along with this program. If not, see <http://www.gnu.org/licenses/>.
611+#
612+# Authored by: Michi Henning <michi.henning@canonical.com>
613+
614+#
615+# Script to read the version numbers from VERSION and QT-VERSION
616+# and write the version components and the soversion numbers
617+# into separate files, so we can pick them up from both
618+# gen-debian-files.sh and CMakeLists.txt.
619+#
620+
621+set -e # Fail if any command fails.
622+
623+progname=$(basename $0)
624+
625+[ $# -lt 1 -o $# -gt 2 ] && {
626+ echo "usage: $progname path-to-debian-dir [output-dir]" >&2
627+ exit 1
628+}
629+dir=$1
630+output_dir=`pwd`
631+[ $# -eq 2 ] && output_dir=$2
632+
633+# Write the various version numbers into a bunch of files. This allows
634+# us to easily pick them up from both gen-debian-files.sh and CMakeLists.txt.
635+
636+distro=$(lsb_release -c -s)
637+
638+full_version=$(cat "${dir}"/VERSION)
639+
640+major=$(echo $full_version | cut -d'.' -f1)
641+minor=$(echo $full_version | cut -d'.' -f2)
642+micro=$(echo $full_version | cut -d'.' -f3)
643+major_minor="${major}.${minor}"
644+
645+vivid_full_version=$(cat "${dir}"/VERSION.vivid)
646+vivid_major=$(echo $vivid_full_version | cut -d'.' -f1)
647+vivid_soversion=$vivid_major
648+
649+if [ "$distro" = "vivid" ]
650+then
651+ soversion=${vivid_soversion}
652+else
653+ soversion="${major}"
654+fi
655+[ -n $soversion ]
656+
657+echo ${full_version} >${output_dir}/libubuntu-location-service.full-version
658+echo ${major} >${output_dir}/libubuntu-location-service.major-version
659+echo ${minor} >${output_dir}/libubuntu-location-service.minor-version
660+echo ${micro} >${output_dir}/libubuntu-location-service.micro-version
661+echo ${major_minor} >${output_dir}/libubuntu-location-service.major-minor-version
662+echo ${soversion} >${output_dir}/libubuntu-location-service.soversion
663+echo ${vivid_soversion} >${output_dir}/libubuntu-location-service.vivid-soversion
664
665=== removed file 'debian/libubuntu-location-service-dev.install'
666--- debian/libubuntu-location-service-dev.install 2014-07-18 14:42:10 +0000
667+++ debian/libubuntu-location-service-dev.install 1970-01-01 00:00:00 +0000
668@@ -1,5 +0,0 @@
669-usr/include/ubuntu-location-service-2
670-usr/lib/*/libubuntu-location-service.so
671-usr/lib/*/libubuntu-location-service-connectivity.so
672-usr/lib/*/pkgconfig/ubuntu-location-service.pc
673-usr/lib/*/pkgconfig/ubuntu-location-service-connectivity.pc
674
675=== added file 'debian/libubuntu-location-service-dev.install.in'
676--- debian/libubuntu-location-service-dev.install.in 1970-01-01 00:00:00 +0000
677+++ debian/libubuntu-location-service-dev.install.in 2016-01-18 13:07:31 +0000
678@@ -0,0 +1,5 @@
679+usr/include/ubuntu-location-service-@UBUNTU_LOCATION_SERVICE_SOVERSION@
680+usr/lib/*/libubuntu-location-service.so
681+usr/lib/*/libubuntu-location-service-connectivity.so
682+usr/lib/*/pkgconfig/ubuntu-location-service.pc
683+usr/lib/*/pkgconfig/ubuntu-location-service-connectivity.pc
684
685=== added file 'debian/libubuntu-location-service.install.in'
686--- debian/libubuntu-location-service.install.in 1970-01-01 00:00:00 +0000
687+++ debian/libubuntu-location-service.install.in 2016-01-18 13:07:31 +0000
688@@ -0,0 +1,2 @@
689+usr/lib/*/libubuntu-location-service.so.*
690+usr/lib/*/libubuntu-location-service-connectivity.so.*
691
692=== added file 'debian/libubuntu-location-service.install.with-gps.in'
693--- debian/libubuntu-location-service.install.with-gps.in 1970-01-01 00:00:00 +0000
694+++ debian/libubuntu-location-service.install.with-gps.in 2016-01-18 13:07:31 +0000
695@@ -0,0 +1,3 @@
696+usr/lib/*/libubuntu-location-service.so.*
697+usr/lib/*/libubuntu-location-service-connectivity.so.*
698+/etc/gps.conf
699
700=== removed file 'debian/libubuntu-location-service2.install'
701--- debian/libubuntu-location-service2.install 2014-07-30 13:55:44 +0000
702+++ debian/libubuntu-location-service2.install 1970-01-01 00:00:00 +0000
703@@ -1,2 +0,0 @@
704-usr/lib/*/libubuntu-location-service.so.*
705-usr/lib/*/libubuntu-location-service-connectivity.so.*
706
707=== removed symlink 'debian/libubuntu-location-service2.install.amd64'
708=== target was u'libubuntu-location-service2.install.with-gps'
709=== removed symlink 'debian/libubuntu-location-service2.install.armhf'
710=== target was u'libubuntu-location-service2.install.with-gps'
711=== removed symlink 'debian/libubuntu-location-service2.install.i386'
712=== target was u'libubuntu-location-service2.install.with-gps'
713=== removed file 'debian/libubuntu-location-service2.install.with-gps'
714--- debian/libubuntu-location-service2.install.with-gps 2014-07-30 13:55:44 +0000
715+++ debian/libubuntu-location-service2.install.with-gps 1970-01-01 00:00:00 +0000
716@@ -1,3 +0,0 @@
717-usr/lib/*/libubuntu-location-service.so.*
718-usr/lib/*/libubuntu-location-service-connectivity.so.*
719-/etc/gps.conf
720
721=== modified file 'debian/rules'
722--- debian/rules 2015-07-15 19:04:43 +0000
723+++ debian/rules 2016-01-18 13:07:31 +0000
724@@ -15,6 +15,18 @@
725
726 include /usr/share/dpkg/default.mk
727
728+distro=$(shell lsb_release -c -s)
729+
730+ifeq ($(distro),vivid)
731+ full_version=$(shell cat $(CURDIR)/debian/VERSION.vivid)
732+else
733+ full_version=$(shell cat $(CURDIR)/debian/VERSION)
734+endif
735+
736+major=$(shell echo $(full_version) | cut -d'.' -f1)
737+minor=$(shell echo $(full_version) | cut -d'.' -f2)
738+patch=$(shell echo $(full_version) | cut -d'.' -f3)
739+
740 ifneq (,$(filter $(DEB_HOST_ARCH),ppc64el powerpc arm64))
741 LOCATION_SERVICE_ENABLE_GPS_PROVIDER = OFF
742 else
743@@ -31,4 +43,11 @@
744 dh_strip --dbg-package=libubuntu-location-service-dbg
745
746 override_dh_auto_configure:
747- dh_auto_configure -- -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/ubuntu-location-service -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DLOCATION_SERVICE_ENABLE_GPS_PROVIDER=$(LOCATION_SERVICE_ENABLE_GPS_PROVIDER)
748+ dh_auto_configure -- -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/ubuntu-location-service -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DLOCATION_SERVICE_ENABLE_GPS_PROVIDER=$(LOCATION_SERVICE_ENABLE_GPS_PROVIDER) -DUBUNTU_LOCATION_SERVICE_VERSION_MAJOR=$(major) -DUBUNTU_LOCATION_SERVICE_VERSION_MINOR=$(minor) -DUBUNTU_LOCATION_SERVICE_VERSION_PATCH=$(patch)
749+
750+override_dh_auto_clean:
751+ rm -f $(CURDIR)/debian/libubuntu-location-service$(major).install.amd64
752+ rm -f $(CURDIR)/debian/libubuntu-location-service$(major).install.armhf
753+ rm -f $(CURDIR)/debian/libubuntu-location-service$(major).install.i386
754+ /bin/sh $(CURDIR)/debian/gen-debian-files.sh $(CURDIR)/debian
755+ dh_auto_clean
756
757=== modified file 'debian/source/format'
758--- debian/source/format 2014-07-30 14:15:06 +0000
759+++ debian/source/format 2016-01-18 13:07:31 +0000
760@@ -1,1 +1,1 @@
761-3.0 (quilt)
762+3.0 (native)
763
764=== modified file 'doc/Doxyfile.in'
765--- doc/Doxyfile.in 2014-05-19 09:55:25 +0000
766+++ doc/Doxyfile.in 2016-01-18 13:07:31 +0000
767@@ -748,7 +748,7 @@
768 # directories that contain image that are included in the documentation (see
769 # the \image command).
770
771-IMAGE_PATH =
772+IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/images
773
774 # The INPUT_FILTER tag can be used to specify a program that doxygen should
775 # invoke to filter for each input file. Doxygen will invoke the filter program
776@@ -1463,7 +1463,7 @@
777 # generate an XML file that captures the structure of
778 # the code including all documentation.
779
780-GENERATE_XML = NO
781+GENERATE_XML = YES
782
783 # The XML_OUTPUT tag is used to specify where the XML pages will be put.
784 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
785
786=== added file 'doc/daemon_and_cli.md'
787--- doc/daemon_and_cli.md 1970-01-01 00:00:00 +0000
788+++ doc/daemon_and_cli.md 2016-01-18 13:07:31 +0000
789@@ -0,0 +1,55 @@
790+# Service Daemon and CLI
791+
792+The location service offers a daemon executable and a corresponding
793+command-line interface for interacting with it. The daemon does not
794+necessarily require root privileges, but might so depending on your
795+configuration.
796+
797+Run the following command to receive an overview of the arguments to
798+the daemon:
799+
800+ ubuntu-location-serviced --help
801+
802+An example invocation of the daemon, configuring a GPS provider that
803+relies on the Android HAL to talk to the chipset, exposing the service
804+on the system DBus instance:
805+
806+ ubuntu-location-serviced --bus system --provider gps::Provider
807+
808+The cli allows for querying properties of a running service instance, e.g.:
809+
810+ ubuntu-location-serviced-cli --bus system --get --property is_online
811+
812+## Configuring an Out-Of-Process Provider
813+
814+If you want to run a provider out of process, the daemon executable
815+allows you to do so by instantiating a so-called remote provider. The
816+following invocation of the service tries to connect to the provider
817+instance described by the given unique DBus name and path.
818+
819+ ubuntu-location-serviced \
820+ --bus system \
821+ --provider remote::Provider \
822+ --remote::Provider::bus=system \
823+ --remote::Provider::name=com.ubuntu.location.provider.Gps \
824+ --remote::Provider::path=/
825+
826+Please note that the service allows for decorating provider names to
827+uniquely identify per provider configuration options and to allow for
828+loading more than one provider of a certain kind. The following
829+configuration configures two remote providers, one relying on GPS
830+(decorated with @gps) and another one relying on network-based
831+positioning (decorated with @network):
832+
833+ ubuntu-location-serviced \
834+ --bus system \
835+ --provider remote::Provider@gps \
836+ --remote::Provider@gps::bus=system \
837+ --remote::Provider@gps::name=com.ubuntu.location.provider.Gps \
838+ --remote::Provider@gps::path=/ \
839+ --provider remote::Provider@network \
840+ --remote::Provider@network::bus=system \
841+ --remote::Provider@network::name=com.ubuntu.location.provider.Network \
842+ --remote::Provider@network::path=/
843+
844+
845
846=== added file 'doc/debugging.md'
847--- doc/debugging.md 1970-01-01 00:00:00 +0000
848+++ doc/debugging.md 2016-01-18 13:07:31 +0000
849@@ -0,0 +1,92 @@
850+# Debugging
851+
852+Location not working? Here's how to debug.
853+
854+## Layers
855+
856+Test in OSMTouch (QML app using Qt API) before testing in webapps or
857+webbrowser app. Different results? File a bug where it doesn't
858+work. Same result of no location? Next step.
859+
860+## Check that stack works with dummy provider
861+
862+Edit /etc/init/ubuntu-location-provider.override to start
863+location-serviced with just the dummy provider; this should
864+work. Doesn't work? File a bug against location-service. Works? Reset
865+config to defaults and try the next thing.
866+
867+## Hardware GPS breaking all of location-service
868+
869+GPS provider is built-in into location-service and might break all of
870+it if it goes south (working on splitting it out); try enabling only
871+the HERE provider on the location-serviced command-line and see if
872+that works. Works? File a bug against location-service. Doesn't work?
873+Move on.
874+
875+## HERE test
876+
877+To test whether the low-level HERE stack gets a location, put
878+http://people.canonical.com/~lool/espoo-cli on your phone (will be
879+included along HERE bits in the future) and run with:
880+
881+ chmod a+x espoo-cli
882+ GLOG_logtostderr=1 GLOG_v=100 LD_LIBRARY_PATH=/custom/vendor/here/location-provider/lib/arm-linux-gnueabihf ./espoo-cli 5
883+
884+NB: 5 is the number of location updates after which the tool exits;
885+updates should come in at approx 15s interval. Output looks like:
886+
887+ I1101 21:30:01.285964 4403 cli.cpp:117] Requested number of updates is 2
888+ I1101 21:30:01.299002 4403 cli.cpp:133] Starting location updates
889+ I1101 21:30:01.301888 4403 cli.cpp:141] Starting GLib main loop
890+ I1101 21:30:11.304612 4403 cli.cpp:158] Location: tstamp=1414891811 lat=xyz long=foo hor. acc.=2569 alt=nan vert. acc.=nan tech=cell
891+ I1101 21:30:11.306061 4403 cli.cpp:170] Remaining updates: 1
892+ I1101 21:30:26.736821 4403 cli.cpp:158] Location: tstamp=1414891826 lat=xyz long=foo hor. acc.=2824 alt=nan vert. acc.=nan tech=cell
893+ I1101 21:30:26.738348 4403 cli.cpp:148] Stopping location updates
894+
895+Low-level HERE stack works but location-serviced with just HERE
896+provider doesn't work? File a bug against espoo projet (HERE) and/or
897+location-service. Low-level HERE stack doesn't work? Move on
898+
899+## location-service and espoo-service debug
900+
901+Collect some debug data by editing /etc/init/ubuntu-espoo-service.conf
902+and /etc/init/ubuntu-location-service.override and changing the start
903+sequence to add some env vars:
904+
905+ export GLOG_v=200
906+ export GLOG_logtostderr=1
907+
908+before the exec. Reboot, and start some app. You should have some log
909+files under /var/log/upstart/ubuntu-espoo-service.log and
910+/var/log/upstart/ubuntu-location-service.log to attach to a bug
911+report; e.g. a working espoo log looks like this:
912+
913+ WARNING: Logging before InitGoogleLogging() is written to STDERR
914+ I1105 16:30:10.221474 1620 provider.cpp:568] StartPositionUpdates
915+ I1105 16:30:10.224901 1620 provider.cpp:122] Successfully started position updates.
916+ I1105 16:30:10.228739 1620 provider.cpp:596] StartVelocityUpdates
917+ I1105 16:30:13.046851 1621 provider.cpp:83] Received location: Position(lat: Coordinate(12.34 deg), lon: Coordinate(12.34 deg), alt: Coordinate(nan m), hor.acc.: 1430 m, ver.acc.: nan m)
918+
919+No position there? check connectivity API works by running:
920+
921+ cd /tmp
922+ wget http://people.ubuntu.com/~lool/connectivity
923+ GLOG_v=200 GLOG_logtostderr=1 ./connectivity
924+
925+you should see something like:
926+
927+ I1105 16:47:26.431466 11140 cached_radio_cell.cpp:160] (mcc: 123, mnc: 2, lac: 1234, id: 123456, asu: 1)
928+ I1105 16:47:26.533818 11140 connectivity.cpp:47] Is wifi enabled: true
929+ I1105 16:47:26.533963 11140 connectivity.cpp:48] Is wifi hw enabled: true
930+ I1105 16:47:26.534010 11140 connectivity.cpp:49] Is wwan enabled: true
931+ I1105 16:47:26.534050 11140 connectivity.cpp:50] Is wwan hw enabled: true
932+ I1105 16:47:26.534442 11140 connectivity.cpp:122] umts(mcc: 123, mnc: 2, lac: 1234, id: 123456, asu: 1)
933+ I1105 16:47:26.534633 11140 connectivity.cpp:155] (bssid: 12:12:12:12:12:12, ssid: xyz, last seen: 1415224046, mode: Mode::infrastructure, frequency: 2442, strength: 63)
934+ I1105 16:47:26.534828 11140 connectivity.cpp:155] (bssid: 12:12:12:12:12:12, ssid: boing, last seen: 1415224046, mode: Mode::infrastructure, frequency: 2467, strength: 57)
935+
936+Also, please attach output of /usr/share/ofono/scripts/list-modems > list-modems-output.txt
937+Please note that the command might take ~1 minute to complete.
938+
939+TODO: document dbus-monitor / d-feet capturing of client / system traffic with snooping config.
940+
941+
942
943=== added file 'doc/hacking.md'
944--- doc/hacking.md 1970-01-01 00:00:00 +0000
945+++ doc/hacking.md 2016-01-18 13:07:31 +0000
946@@ -0,0 +1,146 @@
947+# Hacking
948+
949+
950+## Building the code
951+
952+By default, the code is built in release mode. To build a debug version, use
953+
954+ $ mkdir builddebug
955+ $ cd builddebug
956+ $ cmake -DCMAKE_BUILD_TYPE=debug ..
957+ $ make
958+
959+For a release version, use -DCMAKE_BUILD_TYPE=release
960+
961+## Running the tests
962+
963+ $ make
964+ $ make test
965+
966+Note that "make test" alone is dangerous because it does not rebuild
967+any tests if either the library or the test files themselves need
968+rebuilding. It's not possible to fix this with cmake because cmake cannot
969+add build dependencies to built-in targets. To make sure that everything
970+is up-to-date, run "make" before running "make test"!
971+
972+## Coverage
973+
974+To build with the flags for coverage testing enabled and get coverage:
975+
976+ $ mkdir buildcoverage
977+ $ cd buildcoverage
978+ $ cmake -DCMAKE_BUILD_TYPE=coverage
979+ $ make
980+ $ make test
981+ $ make coverage
982+
983+Unfortunately, it is not possible to get 100% coverage for some files,
984+mainly due to gcc's generation of two destructors for dynamic and non-
985+dynamic instances. For abstract base classes and for classes that
986+prevent stack and static allocation, this causes one of the destructors
987+to be reported as uncovered.
988+
989+There are also issues with some functions in header files that are
990+incorrectly reported as uncovered due to inlining, as well as
991+the impossibility of covering defensive assert(false) statements,
992+such as an assert in the default branch of a switch, where the
993+switch is meant to handle all possible cases explicitly.
994+
995+If you run a binary and get lots of warnings about a "merge mismatch for summaries",
996+this is caused by having made changes to the source that add or remove code
997+that was previously run, so the new coverage output cannot sensibly be merged
998+into the old coverage output. You can get rid of this problem by running
999+
1000+ $ make clean-coverage
1001+
1002+This deletes all the .gcda files, allowing the merge to (sometimes) succeed again.
1003+If this doesn't work either, the only remedy is to do a clean build.
1004+
1005+If lcov complains about unrecognized lines involving '=====',
1006+you can patch geninfo and gcovr as explained here:
1007+
1008+https://bugs.launchpad.net/gcovr/+bug/1086695/comments/2
1009+
1010+## Code style
1011+
1012+We use a format tool that fixes a whole lot of issues
1013+regarding code style. The formatting changes made by
1014+the tool are generally sensible (even though they may not be your
1015+personal preference in all cases). If there is a case where the formatting
1016+really messes things up, consider re-arranging the code to avoid the problem.
1017+The convenience of running the entire code base through the pretty-printer
1018+far outweighs any minor glitches with pretty printing, and it means that
1019+we get consistent code style for free, rather than endlessly having to
1020+watch out for formatting issues during code reviews.
1021+
1022+As of clang-format-3.7, you can use
1023+
1024+ // clang-format off
1025+ void unformatted_code ;
1026+ // clang-format on
1027+
1028+to suppress formatting for a section of code.
1029+
1030+To format specific files:
1031+
1032+ ${CMAKE_BINARY_DIR}/tools/formatcode x.cpp x.h
1033+
1034+If no arguments are provided, formatcode reads stdin and writes
1035+stdout, so you can easily pipe code into the tool from within an
1036+editor. For example, to reformat the entire file in vi (assuming
1037+${CMAKE_BINARY_DIR}/tools is in your PATH):
1038+
1039+ 1G!Gformatcode
1040+
1041+To re-format all source and header files in the tree:
1042+
1043+ $ make formatcode
1044+
1045+## Thread and address sanitizer
1046+
1047+Set SANITIZER to "thread" or "address" to build with the
1048+corresponding sanitizer enabled.
1049+
1050+## Updating symbols file
1051+
1052+To easily spot new/removed/changed symbols in the library, the debian
1053+package maintains a .symbols file that lists all exported symbols
1054+present in the library .so. If you add new public symbols to the library,
1055+it's necessary to refresh the symbols file, otherwise the package will
1056+fail to build. The easiest way to do that is using bzr-builddeb:
1057+
1058+ $ bzr bd -- -us -uc -j8 # Don't sign source package or changes file, 8 compiles in parallel
1059+ $ # this will exit with an error if symbols file isn't up-to-date
1060+ $ cd ../build-area/location-service-[version]
1061+ $ ./obj-[arch]/tools/symbol_diff
1062+
1063+This creates a diff of the symbols in /tmp/symbols.diff.
1064+(The demangled symbols from the debian build are in ./new_symbols.)
1065+
1066+Review any changes in /tmp/symbols.diff. If they are OK:
1067+
1068+ $ cd -
1069+ $ patch -p0 < /tmp/symbols.diff
1070+
1071+## ABI compliance test
1072+
1073+To use this, install abi-compliance-checker package from the archives.
1074+
1075+You can use abi-compliance-checker to test whether a particular build
1076+is ABI compatible with another build. The tool does some source-level
1077+analysis in addition to checking library symbols, so it catches things
1078+that are potentially dangerous, but won't be picked up by just looking
1079+at the symbol table.
1080+
1081+Assume you have built devel in src/devel, and you have a later build
1082+in src/mybranch and want to check that mybranch is still compatible.
1083+To run the compliance test:
1084+
1085+ $ cd src
1086+ $ abi-compliance-checker -lib libunity-scopes.so -old devel/build/test/abi-compliance/abi.xml -new mybranch/build/test/abi-compliance/abi.xml
1087+
1088+The script will take about two minutes to run. Now point your browser at
1089+
1090+ src/compat_reports/libunity-scopes.so/[version]_to_[version]/compat_report.html
1091+
1092+The report provides a nicely layed-out page with all the details.
1093
1094=== added directory 'doc/images'
1095=== added file 'doc/images/LocationServiceHighLevel.png'
1096Binary files doc/images/LocationServiceHighLevel.png 1970-01-01 00:00:00 +0000 and doc/images/LocationServiceHighLevel.png 2016-01-18 13:07:31 +0000 differ
1097=== added file 'doc/intro.md'
1098--- doc/intro.md 1970-01-01 00:00:00 +0000
1099+++ doc/intro.md 2016-01-18 13:07:31 +0000
1100@@ -0,0 +1,67 @@
1101+# Introduction {#mainpage}
1102+
1103+Ubuntu's location service is a central hub for multiplexing access to
1104+positioning subsystems available via hard- and software. It provides a
1105+client API offering positioning capabilities to applications and other
1106+system components, abstracting away the details of individual
1107+positioning solutions.
1108+
1109+## Vocabulary
1110+
1111+To make the remainder of this documentation as easily understandable
1112+as possible, we start over with introducing some vocabulary:
1113+
1114+- Engine:
1115+ Responsible for handling input from multiple positioning
1116+ subsystems and maintaining the state of the overall system. Think
1117+ about it like the heart of the system.
1118+
1119+- Provider:
1120+ A positioning subsystem that feeds into the positioning
1121+ engine. Common examples are a GPS provider or a network-based
1122+ positioning provider.
1123+
1124+- Service:
1125+ The point of entry for applications and services that would
1126+ like to receive position data.
1127+
1128+- Session:
1129+ In order to receive position information, every application
1130+ or service has to create a session with the location Service.
1131+
1132+- Update: An update is a timestamped entity to a certain type of data.
1133+
1134+- [WGS84, http://en.wikipedia.org/wiki/World_Geodetic_System]: The coordinate system that is used throughout the entire location subsystem.
1135+
1136+## Architectural Overview
1137+
1138+The high-level architecture of the service is shown in the following diagram:
1139+
1140+![High-level architectural overview](images/LocationServiceHighLevel.png)
1141+
1142+In this diagram, the configuration of the engine refers to:
1143+
1144+ * The current state of any satellite-based positioning subsystems. Can either be off or on.
1145+ * The current state of reporting facilities responsible for harvesting wifi and cell id measurements together with location information and sending them off to remote services. Can either be off or on.
1146+ * The overall state of the engine. Can either be off, on or active.
1147+
1148+The Service takes this configuration and exposes it to client
1149+applications. In addition, mainly for debugging purposes, the set of
1150+currently visible satellites (if any) is maintained and exposed to
1151+privileged client applications.
1152+
1153+## Privacy & Access Control
1154+
1155+Location information is highly privacy relevant. For this reason, the
1156+location service is deeply integrated with AppArmor and Ubuntu's
1157+overall trust infrastructure. Every incoming session request is
1158+validated and if in doubt, the user is asked to explicitly grant trust
1159+to the application requesting access to positioning
1160+information. Please see [@ref com::ubuntu::location::service::PermissionManager]
1161+for further details.
1162+
1163+In addition, the location service allows for selectively adjusting the
1164+accuracy and reporting setup of the location Engine to provide further
1165+fine-grained control over the exposed data to user. Within this setup,
1166+a user is able to entirely disable all positioning.
1167+
1168
1169=== added file 'doc/manual_testing.md'
1170--- doc/manual_testing.md 1970-01-01 00:00:00 +0000
1171+++ doc/manual_testing.md 2016-01-18 13:07:31 +0000
1172@@ -0,0 +1,174 @@
1173+# Manual Testplan
1174+
1175+[TOC]
1176+
1177+While the automatic test suite of the location service is
1178+comprehensive and covers large parts of the functionality of the
1179+service itself, we still provide an additional level of acceptance
1180+testing covering the entire location stack/experience as a part of
1181+this document.
1182+
1183+## Dependents/Clients
1184+
1185+ - qtubuntu-sensors
1186+ - Qt/QML applications:
1187+ - Browser
1188+ - osmTouch
1189+
1190+## Test Plan
1191+
1192+This test plan is not supposed to be complete; use it to guide your
1193+manual testing so you don't miss big functional areas that are part of
1194+the component; also this should be used as guideline to inspire the
1195+exploratory testing which should be adapted smartly based on the real
1196+content of a MP.
1197+
1198+Please note that if you're testing the GPS provider, the location
1199+service relies on GPS hardware to obtain a location fix. For that, it
1200+might be required that you execute the manual steps listed before
1201+close to a window or ideally outside, with good satellite visibility
1202+conditions.
1203+
1204+__Note: It can take up to 15 minutes for the GPS device to get a lock, due to lack of assisted GPS__
1205+
1206+ - Install latest image on phone
1207+ - Install freshly built MPs that are needed for landing
1208+
1209+Depending on the default configuration of location-service on the
1210+image, you may skip parts of this test plan. E.g. if GPS hardware is
1211+disabled, skip this part. You can see which providers are enabled by
1212+looking at the list of providers on the location-serviced command-line
1213+(`ps fauxw | grep location-service`, then look at the `--provider`
1214+flags).
1215+
1216+### Dummy provider
1217+
1218+This tests forces location-service to use only the dummy provider;
1219+this providers a baseline test for the app to trust-store to
1220+location-service path.
1221+
1222+ - phablet-shell into the phone:
1223+ - `sudo service ubuntu-location-service stop && sudo /usr/bin/ubuntu-location-serviced --bus system --provider dummy::Provider --dummy::Provider::ReferenceLocationLat=48.857503 --dummy::Provider::ReferenceLocationLon=2.295072`
1224+ - As phablet, start the trust store again (it stops when location-service is stopped) with: `start ubuntu-location-service-trust-stored`
1225+ - Ensure that all AP tests for the webbrowser pass as expected
1226+ - Point the browser to maps.google.com (alternatively: here.com, maps.bing.fr).
1227+ - Request centering the map on current position and observe if it works correctly (should show the Eiffel tower)
1228+ - Install osmTouch from the app store
1229+ - Launch osmTouch and check if it centers on the Eiffel tower.
1230+ - Install a maps webapp such as HERE or Google Maps webapp from the app store
1231+ - Launch maps webapp and check if it centers on the Eiffel tower.
1232+
1233+### GPS Test Plan
1234+
1235+This applies only if GPS provider is enabled.
1236+
1237+ - (If applicable: Remember to add the silo you are testing)
1238+ - `sudo apt-get install ubuntu-location-service-tests`
1239+ - If you want to send off crowdsourced information, i.e., information about visible wifis and visible radio cells for the obtained location fixes to Mozilla's location service and our own instance:
1240+ - `sudo GLOG_v=40 GLOG_logtostderr=1 GPS_TEST_ENABLE_HARVESTING_DURING_TESTS=1 /usr/bin/uls-tests/gps_provider_test --gtest_filter=*.time_to_first_fix_cold_start_without_supl_benchmark_requires_hardware`
1241+ - If you '''don't''' want to send off crowdsourced information:
1242+ - `sudo GLOG_v=40 GLOG_logtostderr=1 /usr/bin/uls-tests/gps_provider_test --gtest_filter=*.time_to_first_fix_cold_start_without_supl_benchmark_requires_hardware`
1243+
1244+ - The test will output a lot of diagnostic information to the
1245+ terminal and will take ~30 minutes. If satellite visibility is
1246+ limited, it can take even longer. The test will automatically
1247+ report success or failure.
1248+
1249+### Preliminary AGPS Test Plan
1250+
1251+**Does not apply to Krillin**
1252+
1253+Please note that the Krillin GPS chipset driver and its integration
1254+within Ubuntu does not support vanilla AGPS (i.e., SUPL) right
1255+now. For that, this test case is irrelevant for Krillin and is likely
1256+to fail.
1257+
1258+This applied only if GPS provider and some other provider (giving
1259+_A_ssistance) are enabled.
1260+
1261+ - Add the silo.
1262+ - `sudo apt-get install ubuntu-location-service-tests`
1263+ - Obtain a (rough) location estimate for your current location on Google maps.
1264+ - Make sure to replace INSERT_ESTIMATE_HERE with the respective
1265+ values obtained from Google maps.
1266+ - If you want to send off crowdsourced information, i.e., information
1267+ about visible wifis and visible radio cells for the obtained
1268+ location fixes to Mozilla's location service and our own instance:
1269+ - `sudo GLOG_v=40 GLOG_logtostderr=1 GPS_TEST_ENABLE_HARVESTING_DURING_TESTS=1 GPS_TEST_REF_LAT=INSERT_ESTIMATE_HERE GPS_TEST_REF_LON=INSERT_ESTIMATE_HERE /usr/bin/uls-tests/gps_provider_test --gtest_filter=*.time_to_first_fix_cold_start_with_supl_benchmark_requires_hardware`
1270+ - If you '''don't''' want to send off crowdsourced information:
1271+ - `sudo GLOG_v=40 GLOG_logtostderr=1 GPS_TEST_REF_LAT=INSERT_ESTIMATE_HERE GPS_TEST_REF_LON=INSERT_ESTIMATE_HERE /usr/bin/uls-tests/gps_provider_test --gtest_filter=*.time_to_first_fix_cold_start_with_supl_benchmark_requires_hardware`
1272+
1273+ - The test will output a lot of diagnostic information to the
1274+ terminal and will take ~10 minutes or less. The test will
1275+ automatically report success or failure.
1276+
1277+### Espoo / HERE provider
1278+
1279+This applies only if the Espoo / HERE remote provider is enabled. This
1280+provider should be enabled by default and may either work standalone
1281+as the only provider or as an assistance for the GPS hardware to lock.
1282+
1283+ - Add the silo; special exception for lxc-android-config: see https://wiki.ubuntu.com/Touch/Testing/lxc-android-config
1284+ - If noted, deploy an updated custom tarball:
1285+ - Download the tarball under /tmp ('''NOT''' under /)
1286+ - Unpack there: `cd /tmp; sudo tar xvf custom-vendor-here-*.tar.xz`
1287+ - Remove older bits: `sudo rm -rf /custom/vendor/here/`
1288+ - Update custom bits: `sudo mv /tmp/system/custom/vendor/here /custom/vendor`
1289+ - Reboot
1290+ - After boot, check you have these three processes running on top of location-service:
1291+ - slpgwd
1292+ - posclientd
1293+ - ubuntu-espoo-service
1294+ - Make sure SIM is unlocked and attached to the network (has some reliable signal) and that WiFi is turned on.
1295+ - Install OSMTouch app
1296+ - Run OSMTouch app, hit the position button every other second until you get a blue circle showing your current location;
1297+
1298+# Connectivity API
1299+
1300+For integration of network-based positioning providers, the location
1301+service offers a connectivity API that provides access to wifi and
1302+cell measurements as well as information on the current overall
1303+connectivity status of the device. Please execute the following
1304+commands on a newly flashed device with a writable image:
1305+
1306+ - `sudo apt-get update && sudo apt-get build-dep location-service && sudo apt-get install libubuntu-location-service-dev ubuntu-location-service-examples`
1307+ - `mkdir /tmp/build && cd /tmp/build && cmake /usr/share/ubuntu-location-service/examples/standalone/connectivity/ && make`
1308+ - `GLOG_logtostderr=1 ./connectivity`
1309+
1310+Verify that the output looks similar to:
1311+
1312+ phablet@ubuntu-phablet:/tmp/build$ ./connectivity
1313+ Is wifi enabled: true
1314+ Is wifi hw enabled: true
1315+ Is wwan enabled: false
1316+ Is wwan hw enabled: true
1317+ umts(mcc: 262, mnc: 2, lac: 5313, id: 131948771, asu: 7)
1318+ (bssid: BC:F2:AF:AF:19:A2, ssid: devolo-bcf2afaf19a2, last seen: 1408955086, mode: Mode::infrastructure, frequency: 2462, strength: 72)
1319+ (bssid: 00:22:3F:35:43:58, ssid: JustAnotherWLAN, last seen: 1408955086, mode: Mode::infrastructure, frequency: 2412, strength: 24)
1320+ (bssid: 82:C7:A6:40:8C:4E, ssid: EasyBox-44D054, last seen: 1408955206, mode: Mode::infrastructure, frequency: 2417, strength: 17)
1321+ (bssid: 00:24:01:B8:32:8D, ssid: gra, last seen: 1408955086, mode: Mode::infrastructure, frequency: 2412, strength: 12)
1322+ (bssid: C0:25:06:3C:28:22, ssid: FRITZ!Box 6360 Cable, last seen: 1408954966, mode: Mode::infrastructure, frequency: 2412, strength: 17)
1323+ (bssid: 00:1C:4A:A5:B7:59, ssid: FRITZ!Box Fon WLAN 7170, last seen: 1408954966, mode: Mode::infrastructure, frequency: 2437, strength: 10)
1324+ Last seen changed for wifi (bssid: BC:F2:AF:AF:19:A2, ssid: devolo-bcf2afaf19a2, last seen: 1408955257, mode: Mode::infrastructure, frequency: 2462, strength: 72)
1325+ Last seen changed for wifi (bssid: 00:22:3F:35:43:58, ssid: JustAnotherWLAN, last seen: 1408955257, mode: Mode::infrastructure, frequency: 2412, strength: 24)
1326+ Signal strength changed for wifi: (bssid: BC:F2:AF:AF:19:A2, ssid: devolo-bcf2afaf19a2, last seen: 1408955257, mode: Mode::infrastructure, frequency: 2462, strength: 73)
1327+
1328+# Trust Store Integration
1329+
1330+Please note that we are assuming a freshly wiped system for testing
1331+here. If you cannot fulfill that pre-condition, please run `rm -rf
1332+/home/phablet/.local/share/UbuntuLocationService && sudo shutdown -r` prior to running the
1333+tests:
1334+
1335+## Unconfined
1336+
1337+ - Open the browser, go to maps.google.com
1338+ - Observe the in-browser dialog asking for granting access to location.
1339+
1340+## Confined Web-App
1341+
1342+ - Open the Nokia Here web app, observe the trust dialog appearing.
1343+
1344+## Confined Application
1345+
1346+ - Open osmtouch and observe the osmtouch surface sliding up, presenting you with a trust dialog.
1347
1348=== added file 'doc/tips_n_tricks.md'
1349--- doc/tips_n_tricks.md 1970-01-01 00:00:00 +0000
1350+++ doc/tips_n_tricks.md 2016-01-18 13:07:31 +0000
1351@@ -0,0 +1,21 @@
1352+# Tips'n'Tricks
1353+
1354+## Mark HERE license as accepted from cmdline
1355+
1356+ sudo LC_ALL=C gdbus call --system --dest org.freedesktop.Accounts --object-path /org/freedesktop/Accounts/User32011 --method org.freedesktop.DBus.Properties.Set com.ubuntu.location.providers.here.AccountsService LicenseAccepted '<true>'
1357+
1358+## Force startup after ofono and NM are started
1359+
1360+This is a *workaround* to get connectivity API to collect; mount your
1361+system read-write and edit
1362+/etc/init/ubuntu-location-provider-here-slpgwd.conf:
1363+
1364+ sudo mount -o remount,rw /
1365+ sudo vi /etc/init/ubuntu-location-provider-here-slpgwd.conf
1366+
1367+change: `start on started dbus and (started ofono or started network-manager)`
1368+to: `start on started dbus and started ofono and started network-manager`
1369+
1370+ sudo mount -o remount,ro /
1371+ sync
1372+ sudo reboot
1373
1374=== modified file 'src/location_service/com/ubuntu/location/CMakeLists.txt'
1375--- src/location_service/com/ubuntu/location/CMakeLists.txt 2015-04-23 14:48:44 +0000
1376+++ src/location_service/com/ubuntu/location/CMakeLists.txt 2016-01-18 13:07:31 +0000
1377@@ -38,6 +38,7 @@
1378 service/harvester.cpp
1379 service/demultiplexing_reporter.h
1380 service/demultiplexing_reporter.cpp
1381+ service/runtime.cpp
1382 service/runtime_tests.h
1383 service/runtime_tests.cpp
1384 service/trust_store_permission_manager.cpp
1385
1386=== modified file 'src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp'
1387--- src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp 2015-05-28 10:57:24 +0000
1388+++ src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp 2016-01-18 13:07:31 +0000
1389@@ -123,7 +123,14 @@
1390 const org::freedesktop::NetworkManager::Device& device,
1391 const org::freedesktop::NetworkManager::AccessPoint& ap)
1392 : device_(device),
1393- access_point_(ap)
1394+ access_point_(ap),
1395+ connections
1396+ {
1397+ access_point_.properties_changed->connect([this](const std::map<std::string, core::dbus::types::Variant>& dict)
1398+ {
1399+ on_access_point_properties_changed(dict);
1400+ })
1401+ }
1402 {
1403 last_seen_ = translate_time_stamp(access_point_.last_seen->get());
1404
1405@@ -138,12 +145,11 @@
1406 {
1407 static_cast<int>(access_point_.strength->get())
1408 };
1409+}
1410
1411- // Wire up all the connections
1412- access_point_.properties_changed->connect([this](const std::map<std::string, core::dbus::types::Variant>& dict)
1413- {
1414- on_access_point_properties_changed(dict);
1415- });
1416+detail::CachedWirelessNetwork::~CachedWirelessNetwork()
1417+{
1418+ access_point_.properties_changed->disconnect(connections.ap_properties_changed);
1419 }
1420
1421 void detail::CachedWirelessNetwork::on_access_point_properties_changed(const std::map<std::string, core::dbus::types::Variant>& dict)
1422
1423=== modified file 'src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h'
1424--- src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h 2014-08-14 20:25:22 +0000
1425+++ src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h 2016-01-18 13:07:31 +0000
1426@@ -41,6 +41,8 @@
1427 const org::freedesktop::NetworkManager::Device& device,
1428 const org::freedesktop::NetworkManager::AccessPoint& ap);
1429
1430+ ~CachedWirelessNetwork();
1431+
1432 // Timestamp when the network became visible.
1433 const core::Property<std::chrono::system_clock::time_point>& last_seen() const override;
1434
1435@@ -67,6 +69,16 @@
1436 // The actual access point stub.
1437 org::freedesktop::NetworkManager::AccessPoint access_point_;
1438
1439+ // Encapsulates all event connections that have to be cut on destruction.
1440+ struct
1441+ {
1442+ core::dbus::Signal
1443+ <
1444+ org::freedesktop::NetworkManager::AccessPoint::PropertiesChanged,
1445+ org::freedesktop::NetworkManager::AccessPoint::PropertiesChanged::ArgumentType
1446+ >::SubscriptionToken ap_properties_changed;
1447+ } connections;
1448+
1449 core::Property<std::chrono::system_clock::time_point> last_seen_;
1450 core::Property<std::string> bssid_;
1451 core::Property<std::string> ssid_;
1452
1453=== modified file 'src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp'
1454--- src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2015-05-27 18:40:37 +0000
1455+++ src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2016-01-18 13:07:31 +0000
1456@@ -595,7 +595,7 @@
1457
1458 xdg::NetworkManager::AccessPoint ap
1459 {
1460- network_manager->service->add_object_for_path(ap_path)
1461+ network_manager->service->object_for_path(ap_path)
1462 };
1463
1464 auto wifi = std::make_shared<detail::CachedWirelessNetwork>(itd->second, ap);
1465
1466=== modified file 'src/location_service/com/ubuntu/location/engine.cpp'
1467--- src/location_service/com/ubuntu/location/engine.cpp 2015-04-23 14:48:44 +0000
1468+++ src/location_service/com/ubuntu/location/engine.cpp 2016-01-18 13:07:31 +0000
1469@@ -169,19 +169,28 @@
1470
1471 // We wire up changes in the engine's configuration to the respective slots
1472 // of the provider.
1473- auto cp = updates.reference_location.changed().connect([provider](const cul::Update<cul::Position>& pos)
1474- {
1475- provider->on_reference_location_updated(pos);
1476- });
1477-
1478- auto cv = updates.reference_velocity.changed().connect([provider](const cul::Update<cul::Velocity>& velocity)
1479- {
1480- provider->on_reference_velocity_updated(velocity);
1481- });
1482-
1483- auto ch = updates.reference_heading.changed().connect([provider](const cul::Update<cul::Heading>& heading)
1484- {
1485- provider->on_reference_heading_updated(heading);
1486+ auto cp = updates.last_known_location.changed().connect([provider](const cul::Optional<cul::Update<cul::Position>>& pos)
1487+ {
1488+ if (pos)
1489+ {
1490+ provider->on_reference_location_updated(pos.get());
1491+ }
1492+ });
1493+
1494+ auto cv = updates.last_known_velocity.changed().connect([provider](const cul::Optional<cul::Update<cul::Velocity>>& velocity)
1495+ {
1496+ if (velocity)
1497+ {
1498+ provider->on_reference_velocity_updated(velocity.get());
1499+ }
1500+ });
1501+
1502+ auto ch = updates.last_known_heading.changed().connect([provider](const cul::Optional<cul::Update<cul::Heading>>& heading)
1503+ {
1504+ if (heading)
1505+ {
1506+ provider->on_reference_heading_updated(heading.get());
1507+ }
1508 });
1509
1510 auto cr = configuration.wifi_and_cell_id_reporting_state.changed().connect([provider](cul::WifiAndCellIdReportingState state)
1511@@ -207,7 +216,7 @@
1512 // We should come up with a better heuristic here.
1513 auto cpr = provider->updates().position.connect([this](const cul::Update<cul::Position>& src)
1514 {
1515- updates.reference_location = update_policy->verify_update(src);
1516+ updates.last_known_location = update_policy->verify_update(src);
1517 });
1518
1519 std::lock_guard<std::mutex> lg(guard);
1520
1521=== modified file 'src/location_service/com/ubuntu/location/engine.h'
1522--- src/location_service/com/ubuntu/location/engine.h 2015-04-23 14:48:44 +0000
1523+++ src/location_service/com/ubuntu/location/engine.h 2016-01-18 13:07:31 +0000
1524@@ -127,11 +127,11 @@
1525 struct Updates
1526 {
1527 /** The current best known reference location */
1528- core::Property<Update<Position>> reference_location{};
1529+ core::Property<Optional<Update<Position>>> last_known_location{};
1530 /** The current best known velocity estimate. */
1531- core::Property<Update<Velocity>> reference_velocity{};
1532+ core::Property<Optional<Update<Velocity>>> last_known_velocity{};
1533 /** The current best known heading estimate. */
1534- core::Property<Update<Heading>> reference_heading{};
1535+ core::Property<Optional<Update<Heading>>> last_known_heading{};
1536 /** The current set of visible SpaceVehicles. */
1537 core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>> visible_space_vehicles{};
1538 };
1539
1540=== modified file 'src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp'
1541--- src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp 2014-10-27 21:58:16 +0000
1542+++ src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp 2016-01-18 13:07:31 +0000
1543@@ -66,8 +66,6 @@
1544 if (config.count("XTRA_SERVER_3") > 0)
1545 result.xtra_hosts.push_back(config.get<std::string>("XTRA_SERVER_3"));
1546
1547- result.timeout = std::chrono::milliseconds{1500};
1548-
1549 return result;
1550 }
1551
1552@@ -333,14 +331,14 @@
1553 } else
1554 {
1555 auto now = location::Clock::now().time_since_epoch();
1556- auto thiz = static_cast<android::HardwareAbstractionLayer*>(context);
1557+ auto ms_since_epoch = std::chrono::duration_cast<std::chrono::milliseconds>(now);
1558
1559 static const int zero_uncertainty = 0;
1560
1561 u_hardware_gps_inject_time(
1562 thiz->impl.gps_handle,
1563- now.count(),
1564- now.count(),
1565+ ms_since_epoch.count(),
1566+ ms_since_epoch.count(),
1567 zero_uncertainty);
1568 }
1569 }
1570
1571=== modified file 'src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h'
1572--- src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h 2015-04-22 13:30:04 +0000
1573+++ src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h 2016-01-18 13:07:31 +0000
1574@@ -49,7 +49,7 @@
1575 /** @brief Timeout on gps xtra download operations. */
1576 std::chrono::milliseconds timeout
1577 {
1578- 5000
1579+ 30000
1580 };
1581
1582 /** Set of hosts serving GPS xtra data. */
1583
1584=== modified file 'src/location_service/com/ubuntu/location/service/daemon.cpp'
1585--- src/location_service/com/ubuntu/location/service/daemon.cpp 2015-04-16 10:03:29 +0000
1586+++ src/location_service/com/ubuntu/location/service/daemon.cpp 2016-01-18 13:07:31 +0000
1587@@ -20,6 +20,9 @@
1588 #include <com/ubuntu/location/boost_ptree_settings.h>
1589 #include <com/ubuntu/location/provider_factory.h>
1590
1591+#include <com/ubuntu/location/logging.h>
1592+#include <com/ubuntu/location/connectivity/dummy_connectivity_manager.h>
1593+
1594 #include <com/ubuntu/location/service/default_configuration.h>
1595 #include <com/ubuntu/location/service/demultiplexing_reporter.h>
1596 #include <com/ubuntu/location/service/ichnaea_reporter.h>
1597@@ -30,6 +33,7 @@
1598
1599 #include "program_options.h"
1600 #include "daemon.h"
1601+#include "runtime.h"
1602
1603 #include <core/dbus/announcer.h>
1604 #include <core/dbus/resolver.h>
1605@@ -37,6 +41,8 @@
1606
1607 #include <core/posix/signal.h>
1608
1609+#include <boost/asio.hpp>
1610+
1611 #include <system_error>
1612 #include <thread>
1613
1614@@ -175,6 +181,8 @@
1615 trap->stop();
1616 });
1617
1618+ auto runtime = location::service::Runtime::create();
1619+
1620 const location::Configuration empty_provider_configuration;
1621
1622 std::set<location::Provider::Ptr> instantiated_providers;
1623@@ -201,8 +209,10 @@
1624 }
1625 }
1626
1627- config.incoming->install_executor(dbus::asio::make_executor(config.incoming));
1628- config.outgoing->install_executor(dbus::asio::make_executor(config.outgoing));
1629+ config.incoming->install_executor(dbus::asio::make_executor(config.incoming, runtime->service()));
1630+ config.outgoing->install_executor(dbus::asio::make_executor(config.outgoing, runtime->service()));
1631+
1632+ runtime->start();
1633
1634 location::service::DefaultConfiguration dc;
1635
1636@@ -214,77 +224,15 @@
1637 dc.the_permission_manager(config.outgoing),
1638 location::service::Harvester::Configuration
1639 {
1640- location::connectivity::platform_default_manager(),
1641- // We submit location/wifi/cell measurements to both
1642- // Mozilla's location service and to Ubuntu's own instance.
1643- std::make_shared<service::DemultiplexingReporter>(
1644- std::initializer_list<service::Harvester::Reporter::Ptr>
1645- {
1646- std::make_shared<service::ichnaea::Reporter>(
1647- service::ichnaea::Reporter::Configuration
1648- {
1649- "https://location.services.mozilla.com",
1650- "UbuntuLocationService",
1651- "UbuntuLocationService"
1652- }
1653- ),
1654- std::make_shared<service::ichnaea::Reporter>(
1655- service::ichnaea::Reporter::Configuration
1656- {
1657- "https://162.213.35.107",
1658- "UbuntuLocationService",
1659- "UbuntuLocationService"
1660- }
1661- )
1662- })
1663+ std::make_shared<dummy::ConnectivityManager>(),
1664+ std::make_shared<NullReporter>()
1665 }
1666 };
1667
1668 auto location_service = std::make_shared<location::service::Implementation>(configuration);
1669- // We need to ensure that any exception raised by the executor does not crash the app
1670- // and also gets logged.
1671- auto execute = [] (std::shared_ptr<core::dbus::Bus> bus) {
1672- while(true)
1673- {
1674- try
1675- {
1676- VLOG(10) << "Starting a bus executor";
1677- bus->run();
1678- break; // run() exited normally
1679- }
1680- catch (const std::exception& e)
1681- {
1682- LOG(WARNING) << e.what();
1683- }
1684- catch (...)
1685- {
1686- LOG(WARNING) << "Unexpected exception was raised by the bus executor";
1687- }
1688- }
1689- };
1690-
1691- std::thread t1{execute, config.incoming};
1692- std::thread t2{execute, config.incoming};
1693- std::thread t3{execute, config.incoming};
1694- std::thread t4{execute, config.outgoing};
1695
1696 trap->run();
1697
1698- config.incoming->stop();
1699- config.outgoing->stop();
1700-
1701- if (t1.joinable())
1702- t1.join();
1703-
1704- if (t2.joinable())
1705- t2.join();
1706-
1707- if (t3.joinable())
1708- t3.join();
1709-
1710- if (t4.joinable())
1711- t4.join();
1712-
1713 return EXIT_SUCCESS;
1714 }
1715
1716
1717=== modified file 'src/location_service/com/ubuntu/location/service/implementation.cpp'
1718--- src/location_service/com/ubuntu/location/service/implementation.cpp 2014-08-13 13:08:22 +0000
1719+++ src/location_service/com/ubuntu/location/service/implementation.cpp 2016-01-18 13:07:31 +0000
1720@@ -113,10 +113,13 @@
1721 {
1722 visible_space_vehicles() = svs;
1723 }),
1724- configuration.engine->updates.reference_location.changed().connect(
1725- [this](const cul::Update<cul::Position>& update)
1726+ configuration.engine->updates.last_known_location.changed().connect(
1727+ [this](const cul::Optional<cul::Update<cul::Position>>& update)
1728 {
1729- harvester.report_position_update(update);
1730+ if (update)
1731+ {
1732+ harvester.report_position_update(update.get());
1733+ }
1734 })
1735 }
1736 {
1737@@ -149,5 +152,21 @@
1738 new ProxyProvider{provider_selection}
1739 };
1740
1741- return session::Interface::Ptr{new culs::session::Implementation(proxy_provider)};
1742+ session::Interface::Ptr session_iface{new session::Implementation(proxy_provider)};
1743+ std::weak_ptr<session::Interface> session_weak{session_iface};
1744+ session_iface->updates().position_status.changed().connect([this, session_weak](const session::Interface::Updates::Status& status)
1745+ {
1746+ cul::Optional<cul::Update<cul::Position>> last_known_position =
1747+ configuration.engine->updates.last_known_location.get();
1748+ if (last_known_position &&
1749+ status == culs::session::Interface::Updates::Status::enabled)
1750+ {
1751+ // Immediately send the last known position to the client
1752+ if (auto session_iface = session_weak.lock())
1753+ {
1754+ session_iface->updates().position = last_known_position.get();
1755+ }
1756+ }
1757+ });
1758+ return session_iface;
1759 }
1760
1761=== modified file 'src/location_service/com/ubuntu/location/service/provider_daemon.cpp'
1762--- src/location_service/com/ubuntu/location/service/provider_daemon.cpp 2014-10-27 21:58:16 +0000
1763+++ src/location_service/com/ubuntu/location/service/provider_daemon.cpp 2016-01-18 13:07:31 +0000
1764@@ -25,6 +25,7 @@
1765
1766 #include <com/ubuntu/location/service/configuration.h>
1767 #include <com/ubuntu/location/service/program_options.h>
1768+#include <com/ubuntu/location/service/runtime.h>
1769
1770 #include <core/dbus/asio/executor.h>
1771
1772@@ -65,7 +66,6 @@
1773 location::service::ProviderDaemon::Configuration result;
1774
1775 result.connection = factory(mutable_daemon_options().bus());
1776- result.connection->install_executor(core::dbus::asio::make_executor(result.connection));
1777
1778 auto service = core::dbus::Service::add_service(
1779 result.connection,
1780@@ -108,7 +108,15 @@
1781 return result;
1782 }
1783
1784-int location::service::ProviderDaemon::main(const location::service::ProviderDaemon::Configuration& configuration)
1785+namespace
1786+{
1787+std::shared_ptr<location::service::Runtime> runtime()
1788+{
1789+ static const auto inst = location::service::Runtime::create(1);
1790+ return inst;
1791+}
1792+}
1793+int location::service::ProviderDaemon::main(const location::service::ProviderDaemon::Configuration& config)
1794 {
1795 auto trap = core::posix::trap_signals_for_all_subsequent_threads(
1796 {
1797@@ -121,27 +129,20 @@
1798 trap->stop();
1799 });
1800
1801- std::thread worker
1802- {
1803- [configuration]()
1804- {
1805- configuration.connection->run();
1806- }
1807- };
1808+ config.connection->install_executor(core::dbus::asio::make_executor(config.connection, runtime()->service()));
1809
1810 auto skeleton = location::providers::remote::skeleton::create_with_configuration(location::providers::remote::skeleton::Configuration
1811 {
1812- configuration.object,
1813- configuration.connection,
1814- configuration.provider
1815+ config.object,
1816+ config.connection,
1817+ config.provider
1818 });
1819
1820+ runtime()->start();
1821+
1822 trap->run();
1823
1824- configuration.connection->stop();
1825-
1826- if (worker.joinable())
1827- worker.join();
1828+ config.connection->stop();
1829
1830 return EXIT_SUCCESS;
1831 }
1832
1833=== added file 'src/location_service/com/ubuntu/location/service/runtime.cpp'
1834--- src/location_service/com/ubuntu/location/service/runtime.cpp 1970-01-01 00:00:00 +0000
1835+++ src/location_service/com/ubuntu/location/service/runtime.cpp 2016-01-18 13:07:31 +0000
1836@@ -0,0 +1,109 @@
1837+/*
1838+ * Copyright © 2015 Canonical Ltd.
1839+ *
1840+ * This program is free software: you can redistribute it and/or modify it
1841+ * under the terms of the GNU Lesser General Public License version 3,
1842+ * as published by the Free Software Foundation.
1843+ *
1844+ * This program is distributed in the hope that it will be useful,
1845+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1846+ * MERCHANTABILITY or FITNESS FOR A PARTIlocationAR PURPOSE. See the
1847+ * GNU Lesser General Public License for more details.
1848+ *
1849+ * You should have received a copy of the GNU Lesser General Public License
1850+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1851+ *
1852+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
1853+ */
1854+#include <com/ubuntu/location/service/runtime.h>
1855+
1856+#include <com/ubuntu/location/logging.h>
1857+
1858+namespace culs = com::ubuntu::location::service;
1859+
1860+namespace
1861+{
1862+// exception_safe_run runs service, catching all exceptions and
1863+// restarting operation until an explicit shutdown has been requested.
1864+//
1865+// TODO(tvoss): Catching all exceptions is risky as they might signal unrecoverable
1866+// errors. We should enable calling code to decide whether an exception should be considered
1867+// fatal or not.
1868+void exception_safe_run(boost::asio::io_service& service)
1869+{
1870+ while (true)
1871+ {
1872+ try
1873+ {
1874+ service.run();
1875+ // a clean return from run only happens in case of
1876+ // stop() being called (we are keeping the service alive with
1877+ // a service::work instance).
1878+ break;
1879+ }
1880+ catch (const std::exception& e)
1881+ {
1882+ LOG(WARNING) << e.what();
1883+ }
1884+ catch (...)
1885+ {
1886+ LOG(WARNING) << "Unknown exception caught while executing boost::asio::io_service";
1887+ }
1888+ }
1889+}
1890+}
1891+
1892+std::shared_ptr<culs::Runtime> culs::Runtime::create(std::uint32_t pool_size)
1893+{
1894+ return std::shared_ptr<culs::Runtime>(new culs::Runtime(pool_size));
1895+}
1896+
1897+culs::Runtime::Runtime(std::uint32_t pool_size)
1898+ : pool_size_{pool_size},
1899+ service_{pool_size_},
1900+ strand_{service_},
1901+ keep_alive_{service_}
1902+{
1903+}
1904+
1905+culs::Runtime::~Runtime()
1906+{
1907+ try
1908+ {
1909+ stop();
1910+ } catch(...)
1911+ {
1912+ // Dropping all exceptions to satisfy the nothrow guarantee.
1913+ }
1914+}
1915+
1916+void culs::Runtime::start()
1917+{
1918+ for (unsigned int i = 0; i < pool_size_; i++)
1919+ workers_.push_back(std::thread{exception_safe_run, std::ref(service_)});
1920+}
1921+
1922+void culs::Runtime::stop()
1923+{
1924+ service_.stop();
1925+
1926+ for (auto& worker : workers_)
1927+ if (worker.joinable())
1928+ worker.join();
1929+}
1930+
1931+std::function<void(std::function<void()>)> culs::Runtime::to_dispatcher_functional()
1932+{
1933+ // We have to make sure that we stay alive for as long as
1934+ // calling code requires the dispatcher to work.
1935+ auto sp = shared_from_this();
1936+ return [sp](std::function<void()> task)
1937+ {
1938+ sp->strand_.post(task);
1939+ };
1940+}
1941+
1942+boost::asio::io_service& culs::Runtime::service()
1943+{
1944+ return service_;
1945+}
1946
1947=== added file 'src/location_service/com/ubuntu/location/service/runtime.h'
1948--- src/location_service/com/ubuntu/location/service/runtime.h 1970-01-01 00:00:00 +0000
1949+++ src/location_service/com/ubuntu/location/service/runtime.h 2016-01-18 13:07:31 +0000
1950@@ -0,0 +1,90 @@
1951+/*
1952+ * Copyright © 2015 Canonical Ltd.
1953+ *
1954+ * This program is free software: you can redistribute it and/or modify it
1955+ * under the terms of the GNU Lesser General Public License version 3,
1956+ * as published by the Free Software Foundation.
1957+ *
1958+ * This program is distributed in the hope that it will be useful,
1959+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1960+ * MERCHANTABILITY or FITNESS FOR A PARTIlocationAR PURPOSE. See the
1961+ * GNU Lesser General Public License for more details.
1962+ *
1963+ * You should have received a copy of the GNU Lesser General Public License
1964+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1965+ *
1966+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
1967+ */
1968+#ifndef COM_UBUNTU_LOCATION_SERVICE_RUNTIME_H_
1969+#define COM_UBUNTU_LOCATION_SERVICE_RUNTIME_H_
1970+
1971+#include <boost/asio.hpp>
1972+
1973+#include <functional>
1974+#include <memory>
1975+#include <thread>
1976+#include <vector>
1977+
1978+#include <cstdint>
1979+
1980+namespace com
1981+{
1982+namespace ubuntu
1983+{
1984+namespace location
1985+{
1986+namespace service
1987+{
1988+// We bundle our "global" runtime dependencies here, specifically
1989+// a dispatcher to decouple multiple in-process providers from one
1990+// another , forcing execution to a well known set of threads.
1991+class Runtime : public std::enable_shared_from_this<Runtime>
1992+{
1993+public:
1994+ // Our default concurrency setup.
1995+ static constexpr const std::uint32_t worker_threads = 2;
1996+
1997+ // create returns a Runtime instance with pool_size worker threads
1998+ // executing the underlying service.
1999+ static std::shared_ptr<Runtime> create(std::uint32_t pool_size = worker_threads);
2000+
2001+ Runtime(const Runtime&) = delete;
2002+ Runtime(Runtime&&) = delete;
2003+ // Tears down the runtime, stopping all worker threads.
2004+ ~Runtime() noexcept(true);
2005+ Runtime& operator=(const Runtime&) = delete;
2006+ Runtime& operator=(Runtime&&) = delete;
2007+
2008+ // start executes the underlying io_service on a thread pool with
2009+ // the size configured at creation time.
2010+ void start();
2011+
2012+ // stop cleanly shuts down a Runtime instance,
2013+ // joining all worker threads.
2014+ void stop();
2015+
2016+ // to_dispatcher_functional returns a function for integration
2017+ // with components that expect a dispatcher for operation.
2018+ std::function<void(std::function<void()>)> to_dispatcher_functional();
2019+
2020+ // service returns the underlying boost::asio::io_service that is executed
2021+ // by the Runtime.
2022+ boost::asio::io_service& service();
2023+
2024+private:
2025+ // Runtime constructs a new instance, firing up pool_size
2026+ // worker threads.
2027+ Runtime(std::uint32_t pool_size);
2028+
2029+ std::uint32_t pool_size_;
2030+ boost::asio::io_service service_;
2031+ boost::asio::io_service::strand strand_;
2032+ boost::asio::io_service::work keep_alive_;
2033+ std::vector<std::thread> workers_;
2034+};
2035+}
2036+}
2037+}
2038+}
2039+
2040+#endif // COM_UBUNTU_LOCATION_SERVICE_RUNTIME_H_
2041
2042=== modified file 'src/location_service/com/ubuntu/location/service/session/skeleton.cpp'
2043--- src/location_service/com/ubuntu/location/service/session/skeleton.cpp 2014-08-14 20:31:09 +0000
2044+++ src/location_service/com/ubuntu/location/service/session/skeleton.cpp 2016-01-18 13:07:31 +0000
2045@@ -283,7 +283,13 @@
2046 VLOG(10) << __PRETTY_FUNCTION__;
2047 try
2048 {
2049- configuration.remote.object->invoke_method_asynchronously<culs::session::Interface::UpdatePosition, void>(position);
2050+ configuration.remote.object->invoke_method_asynchronously_with_callback<culs::session::Interface::UpdatePosition, void>([](const core::dbus::Result<void>& result)
2051+ {
2052+ if (result.is_error())
2053+ {
2054+ LOG(INFO) << "Failed to communicate position update to client: " << result.error().print();
2055+ }
2056+ }, position);
2057 } catch(const std::exception&)
2058 {
2059 // We consider the session to be dead once we hit an exception here.
2060@@ -300,7 +306,13 @@
2061 VLOG(10) << __PRETTY_FUNCTION__;
2062 try
2063 {
2064- configuration.remote.object->invoke_method_asynchronously<culs::session::Interface::UpdateHeading, void>(heading);
2065+ configuration.remote.object->invoke_method_asynchronously_with_callback<culs::session::Interface::UpdateHeading, void>([](const core::dbus::Result<void>& result)
2066+ {
2067+ if (result.is_error())
2068+ {
2069+ LOG(INFO) << "Failed to communicate position update to client: " << result.error().print();
2070+ }
2071+ }, heading);
2072 } catch(const std::exception&)
2073 {
2074 // We consider the session to be dead once we hit an exception here.
2075@@ -317,7 +329,13 @@
2076 VLOG(10) << __PRETTY_FUNCTION__;
2077 try
2078 {
2079- configuration.remote.object->invoke_method_asynchronously<culs::session::Interface::UpdateVelocity, void>(velocity);
2080+ configuration.remote.object->invoke_method_asynchronously_with_callback<culs::session::Interface::UpdateVelocity, void>([](const core::dbus::Result<void>& result)
2081+ {
2082+ if (result.is_error())
2083+ {
2084+ LOG(INFO) << "Failed to communicate position update to client: " << result.error().print();
2085+ }
2086+ }, velocity);
2087 } catch(const std::exception&)
2088 {
2089 // We consider the session to be dead once we hit an exception here.
2090
2091=== modified file 'src/location_service/com/ubuntu/location/time_based_update_policy.cpp'
2092--- src/location_service/com/ubuntu/location/time_based_update_policy.cpp 2015-04-23 21:30:04 +0000
2093+++ src/location_service/com/ubuntu/location/time_based_update_policy.cpp 2016-01-18 13:07:31 +0000
2094@@ -53,8 +53,9 @@
2095 {
2096 // if the update has happened within a reasonable amount of time we will just use it if it is more accurate
2097 // that the previous one.
2098- use_new_update = last_position_update.value.accuracy.horizontal && update.value.accuracy.horizontal
2099- && *last_position_update.value.accuracy.horizontal >= *update.value.accuracy.horizontal;
2100+ use_new_update = !last_position_update.value.accuracy.horizontal ||
2101+ (update.value.accuracy.horizontal
2102+ && *last_position_update.value.accuracy.horizontal >= *update.value.accuracy.horizontal);
2103 }
2104
2105 if (use_new_update)
2106@@ -118,4 +119,4 @@
2107
2108 }
2109 }
2110-}
2111\ No newline at end of file
2112+}
2113
2114=== modified file 'tests/CMakeLists.txt'
2115--- tests/CMakeLists.txt 2015-04-23 17:04:09 +0000
2116+++ tests/CMakeLists.txt 2016-01-18 13:07:31 +0000
2117@@ -92,6 +92,7 @@
2118 LOCATION_SERVICE_ADD_TEST(provider_test provider_test.cpp)
2119 LOCATION_SERVICE_ADD_TEST(wgs84_test wgs84_test.cpp)
2120 LOCATION_SERVICE_ADD_TEST(trust_store_permission_manager_test trust_store_permission_manager_test.cpp)
2121+LOCATION_SERVICE_ADD_TEST(runtime_test runtime_test.cpp)
2122
2123 # Provider-specific test-cases go here.
2124 if (LOCATION_SERVICE_ENABLE_GPS_PROVIDER)
2125
2126=== modified file 'tests/acceptance_tests.cpp'
2127--- tests/acceptance_tests.cpp 2015-02-13 13:19:18 +0000
2128+++ tests/acceptance_tests.cpp 2016-01-18 13:07:31 +0000
2129@@ -38,12 +38,14 @@
2130 #include <com/ubuntu/location/service/stub.h>
2131
2132 #include <core/dbus/announcer.h>
2133+#include <core/dbus/bus.h>
2134 #include <core/dbus/fixture.h>
2135 #include <core/dbus/resolver.h>
2136
2137 #include <core/dbus/asio/executor.h>
2138
2139 #include <core/posix/signal.h>
2140+#include <core/posix/this_process.h>
2141
2142 #include <core/testing/cross_process_sync.h>
2143 #include <core/testing/fork_and_run.h>
2144@@ -663,6 +665,110 @@
2145 EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(server, client));
2146 }
2147
2148+TEST_F(LocationServiceStandalone, NewSessionsGetLastKnownPosition)
2149+{
2150+ core::testing::CrossProcessSync sync_start;
2151+
2152+ auto server = [this, &sync_start]()
2153+ {
2154+ SCOPED_TRACE("Server");
2155+
2156+ auto trap = core::posix::trap_signals_for_all_subsequent_threads({core::posix::Signal::sig_term});
2157+ trap->signal_raised().connect([trap](core::posix::Signal)
2158+ {
2159+ trap->stop();
2160+ });
2161+
2162+ auto incoming = session_bus();
2163+ auto outgoing = session_bus();
2164+
2165+ incoming->install_executor(core::dbus::asio::make_executor(incoming));
2166+ outgoing->install_executor(core::dbus::asio::make_executor(outgoing));
2167+
2168+ auto dummy = new DummyProvider();
2169+ cul::Provider::Ptr helper(dummy);
2170+
2171+ cul::service::DefaultConfiguration config;
2172+ cul::service::Implementation::Configuration configuration
2173+ {
2174+ incoming,
2175+ outgoing,
2176+ config.the_engine(config.the_provider_set(helper), config.the_provider_selection_policy(), null_settings()),
2177+ config.the_permission_manager(incoming),
2178+ cul::service::Harvester::Configuration
2179+ {
2180+ cul::connectivity::platform_default_manager(),
2181+ std::make_shared<NullReporter>()
2182+ }
2183+ };
2184+ auto location_service = std::make_shared<cul::service::Implementation>(configuration);
2185+
2186+ configuration.engine->updates.last_known_location.set(reference_position_update);
2187+ std::thread t1{[incoming](){incoming->run();}};
2188+ std::thread t2{[outgoing](){outgoing->run();}};
2189+
2190+ sync_start.try_signal_ready_for(std::chrono::milliseconds{500});
2191+
2192+ trap->run();
2193+
2194+ incoming->stop();
2195+ outgoing->stop();
2196+
2197+ if (t1.joinable())
2198+ t1.join();
2199+
2200+ if (t2.joinable())
2201+ t2.join();
2202+
2203+ return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
2204+ };
2205+
2206+ auto client = [this, &sync_start]()
2207+ {
2208+ SCOPED_TRACE("Client");
2209+
2210+ EXPECT_EQ(1, sync_start.wait_for_signal_ready_for(std::chrono::milliseconds{500}));
2211+
2212+ auto bus = session_bus();
2213+ bus->install_executor(dbus::asio::make_executor(bus));
2214+ std::thread t{[bus](){bus->run();}};
2215+
2216+ auto location_service = dbus::resolve_service_on_bus<
2217+ cul::service::Interface,
2218+ cul::service::Stub>(bus);
2219+
2220+ auto s1 = location_service->create_session_for_criteria(cul::Criteria{});
2221+
2222+ std::cout << "Successfully created session" << std::endl;
2223+
2224+ cul::Update<cul::Position> position;
2225+ auto c1 = s1->updates().position.changed().connect(
2226+ [&](const cul::Update<cul::Position>& new_position) {
2227+ std::cout << "On position updated: " << new_position << std::endl;
2228+ position = new_position;
2229+ });
2230+
2231+ std::cout << "Created event connections, starting updates..." << std::endl;
2232+
2233+ s1->updates().position_status = culss::Interface::Updates::Status::enabled;
2234+
2235+ std::cout << "done" << std::endl;
2236+
2237+ std::this_thread::sleep_for(std::chrono::milliseconds{1000});
2238+
2239+ bus->stop();
2240+
2241+ if (t.joinable())
2242+ t.join();
2243+
2244+ EXPECT_EQ(reference_position_update, position);
2245+
2246+ return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
2247+ };
2248+
2249+ EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(server, client));
2250+}
2251+
2252 namespace
2253 {
2254 struct LocationServiceStandaloneLoad : public LocationServiceStandalone
2255@@ -708,11 +814,11 @@
2256
2257 options.add(Keys::update_period,
2258 "Update period length for dummy::Provider setup.",
2259- std::uint32_t{100});
2260+ std::uint32_t{10});
2261
2262 options.add(Keys::client_count,
2263 "Number of clients that should be fired up.",
2264- std::uint32_t{50});
2265+ std::uint32_t{10});
2266
2267 options.add(Keys::test_duration,
2268 "Test duration in [s]",
2269@@ -761,6 +867,8 @@
2270 };
2271 }
2272
2273+#include "did_finish_successfully.h"
2274+
2275 TEST_F(LocationServiceStandaloneLoad, MultipleClientsConnectingAndDisconnectingWorks)
2276 {
2277 EXPECT_TRUE(trust_store_is_set_up_for_testing);
2278@@ -801,8 +909,8 @@
2279 };
2280
2281 cul::service::Daemon::Configuration config;
2282- config.incoming = session_bus();
2283- config.outgoing = session_bus();
2284+ config.incoming = std::make_shared<core::dbus::Bus>(core::posix::this_process::env::get_or_throw("DBUS_SESSION_BUS_ADDRESS"));
2285+ config.outgoing = std::make_shared<core::dbus::Bus>(core::posix::this_process::env::get_or_throw("DBUS_SESSION_BUS_ADDRESS"));
2286 config.is_testing_enabled = false;
2287 config.providers =
2288 {
2289@@ -829,7 +937,7 @@
2290 status;
2291 }, core::posix::StandardStream::empty);
2292
2293- std::this_thread::sleep_for(std::chrono::seconds{2});
2294+ std::this_thread::sleep_for(std::chrono::seconds{15});
2295
2296 auto client = [this]()
2297 {
2298@@ -957,17 +1065,11 @@
2299 {
2300 VLOG(1) << "Stopping client...: " << client.pid();
2301 client.send_signal_or_throw(core::posix::Signal::sig_term);
2302- auto result = client.wait_for(core::posix::wait::Flags::untraced);
2303-
2304- EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status);
2305- EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status);
2306+ EXPECT_TRUE(did_finish_successfully(client.wait_for(core::posix::wait::Flags::untraced)));
2307 }
2308
2309 VLOG(1) << "Cleaned up clients, shutting down the service...";
2310
2311 server.send_signal_or_throw(core::posix::Signal::sig_term);
2312- auto result = server.wait_for(core::posix::wait::Flags::untraced);
2313-
2314- EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status);
2315- EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status);
2316+ EXPECT_TRUE(did_finish_successfully(server.wait_for(core::posix::wait::Flags::untraced)));
2317 }
2318
2319=== modified file 'tests/engine_test.cpp'
2320--- tests/engine_test.cpp 2015-01-21 20:04:56 +0000
2321+++ tests/engine_test.cpp 2016-01-18 13:07:31 +0000
2322@@ -154,9 +154,9 @@
2323 EXPECT_CALL(*provider, on_reference_velocity_updated(_)).Times(1);
2324
2325 engine.configuration.wifi_and_cell_id_reporting_state = location::WifiAndCellIdReportingState::on;
2326- engine.updates.reference_location = location::Update<location::Position>{};
2327- engine.updates.reference_heading = location::Update<location::Heading>{};
2328- engine.updates.reference_velocity = location::Update<location::Velocity>{};
2329+ engine.updates.last_known_location = location::Update<location::Position>{};
2330+ engine.updates.last_known_heading = location::Update<location::Heading>{};
2331+ engine.updates.last_known_velocity = location::Update<location::Velocity>{};
2332 }
2333
2334 /* TODO(tvoss): We have to disable these tests as the MP is being refactored to not break ABI.
2335
2336=== modified file 'tests/gps_provider_test.cpp'
2337--- tests/gps_provider_test.cpp 2015-01-12 08:41:14 +0000
2338+++ tests/gps_provider_test.cpp 2016-01-18 13:07:31 +0000
2339@@ -48,6 +48,31 @@
2340
2341 namespace
2342 {
2343+
2344+struct MockHardwareGps
2345+{
2346+ MockHardwareGps()
2347+ {
2348+ instance_ = this;
2349+ }
2350+ ~MockHardwareGps()
2351+ {
2352+ instance_ = nullptr;
2353+ }
2354+
2355+ MOCK_METHOD5(set_position_mode, bool(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t));
2356+ MOCK_METHOD3(inject_time, void(int64_t, int64_t, int));
2357+
2358+ static MockHardwareGps *mocked(UHardwareGps self) {
2359+ return reinterpret_cast<MockHardwareGps*>(self);
2360+ }
2361+ static MockHardwareGps *instance() { return instance_; }
2362+
2363+ static MockHardwareGps *instance_;
2364+};
2365+
2366+MockHardwareGps *MockHardwareGps::instance_ = nullptr;
2367+
2368 struct UpdateTrap
2369 {
2370 MOCK_METHOD1(on_position_updated, void(const location::Position&));
2371@@ -211,6 +236,42 @@
2372
2373 }
2374
2375+/* Mock the hardware GPS platform API: the methods defined here will be invoked
2376+ * instead of those exported by the system library.
2377+ * We redefine these methods using the MockHardwareGps class above, which is
2378+ * implemented using google-mock. This effectively allows us to test that the
2379+ * right calls to the platform API are made.
2380+ */
2381+UHardwareGps
2382+u_hardware_gps_new(UHardwareGpsParams *)
2383+{
2384+ using namespace ::testing;
2385+
2386+ return reinterpret_cast<UHardwareGps>(MockHardwareGps::instance());
2387+}
2388+
2389+void
2390+u_hardware_gps_delete(UHardwareGps)
2391+{
2392+}
2393+
2394+bool
2395+u_hardware_gps_set_position_mode(UHardwareGps self, uint32_t mode, uint32_t recurrence,
2396+ uint32_t min_interval, uint32_t preferred_accuracy,
2397+ uint32_t preferred_time)
2398+{
2399+ MockHardwareGps *thiz = MockHardwareGps::mocked(self);
2400+ return thiz->set_position_mode(mode, recurrence, min_interval,
2401+ preferred_accuracy, preferred_time);
2402+}
2403+
2404+void
2405+u_hardware_gps_inject_time(UHardwareGps self, int64_t time, int64_t time_reference, int uncertainty)
2406+{
2407+ MockHardwareGps* thiz = MockHardwareGps::mocked(self);
2408+ return thiz->inject_time(time, time_reference, uncertainty);
2409+}
2410+
2411 TEST(AndroidGpsXtraDownloader, reading_configuration_from_valid_conf_file_works)
2412 {
2413 std::stringstream ss{gps_conf};
2414@@ -261,6 +322,28 @@
2415 provider.on_reference_location_updated(pos);
2416 }
2417
2418+TEST(GpsProvider, time_requests_inject_current_time_into_the_hal)
2419+{
2420+ using namespace ::testing;
2421+
2422+ NiceMock<MockHardwareGps> hardwareGps;
2423+
2424+ gps::android::HardwareAbstractionLayer::Configuration configuration;
2425+ gps::android::HardwareAbstractionLayer hal(configuration);
2426+ std::shared_ptr<gps::HardwareAbstractionLayer> hal_ptr(&hal, [](gps::HardwareAbstractionLayer*){});
2427+
2428+ gps::Provider provider(hal_ptr);
2429+ int64_t time = 0;
2430+ EXPECT_CALL(hardwareGps, inject_time(_, _, 0)).Times(1).WillOnce(SaveArg<0>(&time));
2431+
2432+ auto t0 = std::chrono::duration_cast<std::chrono::milliseconds>(location::Clock::now().time_since_epoch());
2433+
2434+ gps::android::HardwareAbstractionLayer::on_request_utc_time(&hal);
2435+
2436+ auto t1 = std::chrono::duration_cast<std::chrono::milliseconds>(location::Clock::now().time_since_epoch());
2437+ EXPECT_THAT(time, AllOf(Ge(t0.count()), Le(t1.count())));
2438+}
2439+
2440 TEST(GpsProvider, updates_from_hal_are_passed_on_by_the_provider)
2441 {
2442 using namespace ::testing;
2443
2444=== modified file 'tests/position_test.cpp'
2445--- tests/position_test.cpp 2014-06-20 07:40:34 +0000
2446+++ tests/position_test.cpp 2016-01-18 13:07:31 +0000
2447@@ -40,7 +40,7 @@
2448 cul::wgs84::Latitude{},
2449 cul::wgs84::Longitude{},
2450 cul::wgs84::Altitude{}};
2451- EXPECT_TRUE(p.altitude);
2452+ EXPECT_TRUE(p.altitude ? true : false);
2453 }
2454
2455 #include <com/ubuntu/location/codec.h>
2456
2457=== added file 'tests/runtime_test.cpp'
2458--- tests/runtime_test.cpp 1970-01-01 00:00:00 +0000
2459+++ tests/runtime_test.cpp 2016-01-18 13:07:31 +0000
2460@@ -0,0 +1,118 @@
2461+/*
2462+ * Copyright © 2015Canonical Ltd.
2463+ *
2464+ * This program is free software: you can redistribute it and/or modify it
2465+ * under the terms of the GNU Lesser General Public License version 3,
2466+ * as published by the Free Software Foundation.
2467+ *
2468+ * This program is distributed in the hope that it will be useful,
2469+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2470+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2471+ * GNU Lesser General Public License for more details.
2472+ *
2473+ * You should have received a copy of the GNU Lesser General Public License
2474+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2475+ *
2476+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
2477+ */
2478+#include <com/ubuntu/location/service/runtime.h>
2479+
2480+#include <gtest/gtest.h>
2481+
2482+#include <condition_variable>
2483+#include <thread>
2484+
2485+namespace culs = com::ubuntu::location::service;
2486+
2487+TEST(Runtime, cleanly_shuts_down_threads)
2488+{
2489+ culs::Runtime::create();
2490+}
2491+
2492+TEST(Runtime, executes_service)
2493+{
2494+ std::mutex m;
2495+ std::unique_lock<std::mutex> ul{m};
2496+ std::condition_variable wc;
2497+
2498+ bool signaled = false;
2499+
2500+ auto rt = culs::Runtime::create();
2501+ rt->start();
2502+ boost::asio::deadline_timer timer{rt->service(), boost::posix_time::milliseconds(500)};
2503+ timer.async_wait([&wc, &signaled](const boost::system::error_code&)
2504+ {
2505+ signaled = true;
2506+ wc.notify_all();
2507+ });
2508+
2509+ auto result = wc.wait_for(ul, std::chrono::seconds{1}, [&signaled]() { return signaled; });
2510+ EXPECT_TRUE(result);
2511+}
2512+
2513+TEST(Runtime, catches_exceptions_thrown_from_handlers)
2514+{
2515+ std::mutex m;
2516+ std::unique_lock<std::mutex> ul{m};
2517+ std::condition_variable wc;
2518+
2519+ bool signaled = false;
2520+
2521+ auto rt = culs::Runtime::create();
2522+ rt->start();
2523+ boost::asio::deadline_timer fast{rt->service(), boost::posix_time::milliseconds(100)};
2524+ fast.async_wait([](const boost::system::error_code&)
2525+ {
2526+ throw std::runtime_error{"Should not propagate"};
2527+ });
2528+
2529+ boost::asio::deadline_timer slow{rt->service(), boost::posix_time::milliseconds(500)};
2530+ slow.async_wait([&wc, &signaled](const boost::system::error_code&)
2531+ {
2532+ signaled = true;
2533+ wc.notify_all();
2534+ });
2535+
2536+ auto result = wc.wait_for(ul, std::chrono::seconds{1}, [&signaled]() { return signaled; });
2537+ EXPECT_TRUE(result);
2538+}
2539+
2540+// sets_up_pool_of_threads ensures that the pool size
2541+// passed to the Runtime on construction is honored. The idea is simple:
2542+// We set up two deadline timers, fast and slow. fast fires before slow,
2543+// with fast blocking in a wait on a common condition_variable. When slow
2544+// fires, it notifies the condition variable, thereby unblocking the handler of fast,
2545+// enabling clean shutdown without errors and timeouts. This only works if the
2546+// pool contains at least 2 threads. Otherwise, the handler of slow would not be executed
2547+// until the handler of fast times out in the wait, marking the test as failed.
2548+TEST(Runtime, sets_up_pool_of_threads)
2549+{
2550+ struct State
2551+ {
2552+ bool signaled{false};
2553+ std::mutex m;
2554+ std::condition_variable wc;
2555+ };
2556+
2557+ auto state = std::make_shared<State>();
2558+
2559+ auto rt = culs::Runtime::create(2);
2560+ rt->start();
2561+ boost::asio::deadline_timer fast{rt->service(), boost::posix_time::milliseconds(100)};
2562+ fast.async_wait([state](const boost::system::error_code&)
2563+ {
2564+ std::unique_lock<std::mutex> ul{state->m};
2565+ EXPECT_TRUE(state->wc.wait_for(ul, std::chrono::seconds{1}, [state]() { return state->signaled; }));
2566+ });
2567+
2568+ boost::asio::deadline_timer slow{rt->service(), boost::posix_time::milliseconds(500)};
2569+ slow.async_wait([state](const boost::system::error_code&)
2570+ {
2571+ state->signaled = true;
2572+ state->wc.notify_all();
2573+ });
2574+
2575+ std::unique_lock<std::mutex> ul{state->m};
2576+ auto result = state->wc.wait_for(ul, std::chrono::seconds{1}, [state]() { return state->signaled; });
2577+ EXPECT_TRUE(result);
2578+}
2579
2580=== added directory 'tools'
2581=== added file 'tools/CMakeLists.txt'
2582--- tools/CMakeLists.txt 1970-01-01 00:00:00 +0000
2583+++ tools/CMakeLists.txt 2016-01-18 13:07:31 +0000
2584@@ -0,0 +1,1 @@
2585+configure_file(symbol_diff.in symbol_diff)
2586
2587=== added file 'tools/symbol_diff.in'
2588--- tools/symbol_diff.in 1970-01-01 00:00:00 +0000
2589+++ tools/symbol_diff.in 2016-01-18 13:07:31 +0000
2590@@ -0,0 +1,70 @@
2591+#! /usr/bin/env python3
2592+
2593+#
2594+# Copyright (C) 2014 Canonical Ltd
2595+#
2596+# This program is free software: you can redistribute it and/or modify
2597+# it under the terms of the GNU Lesser General Public License version 3 as
2598+# published by the Free Software Foundation.
2599+#
2600+# This program is distributed in the hope that it will be useful,
2601+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2602+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2603+# GNU Lesser General Public License for more details.
2604+#
2605+# You should have received a copy of the GNU Lesser General Public License
2606+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2607+#
2608+# Authored by: Michi Henning <michi.henning@canonical.com>
2609+#
2610+
2611+import re
2612+import subprocess
2613+
2614+OLD_FILE = './debian/libubuntu-location-service@UBUNTU_LOCATION_SERVICE_VERSION_MAJOR@.symbols'
2615+NEW_FILE = './debian/libubuntu-location-service@UBUNTU_LOCATION_SERVICE_VERSION_MAJOR@/DEBIAN/symbols'
2616+
2617+def run():
2618+ old_regex = re.compile(r'^ (\(.*\))"(.*)" (.*)$')
2619+
2620+ old_syms = {} # Dictionary containing symbol -> ( tag, version )
2621+ with open(OLD_FILE, encoding='utf=8') as file:
2622+ file.readline() # Skip first line, which is the library name and version
2623+ for line in file:
2624+ mo = old_regex.match(line)
2625+ if mo:
2626+ old_syms[mo.group(2)] = ( mo.group(1), mo.group(3) )
2627+ else:
2628+ raise Exception('Invalid input line in ' + OLD_FILE + ': ' + line)
2629+
2630+ new_regex = re.compile(r'^ (.*) .+$')
2631+
2632+ # Run the new symbols file through "c++filt | sort | uniq". We need
2633+ # the sort | uniq because, otherwise, we end up with duplicate demangled symbols.
2634+ with open(NEW_FILE) as infile, open('new_symbols', 'w') as outfile:
2635+ p = subprocess.Popen(['c++filt | sort | uniq'], shell=True, stdin=infile, stdout=subprocess.PIPE)
2636+
2637+ # For each symbol, if it is in the old dictionary, output the tags from the original
2638+ # symbol file, followed by the symbol and version. Otherwise, use "(c++)" as the tag
2639+ # and add " 0replaceme", so the new symbol will be accepted.
2640+ line = p.stdout.readline().decode('utf-8')
2641+ outfile.write(line) # Write library name and version
2642+ for line in p.stdout:
2643+ mo = new_regex.match(line.decode('utf-8'))
2644+ if (mo):
2645+ sym = mo.group(1)
2646+ try:
2647+ tag, version = old_syms[sym]
2648+ except KeyError:
2649+ tag = '(c++)'
2650+ version = '0replaceme'
2651+ outfile.write(' {}"{}" {}\n'.format(tag, sym, version))
2652+ else:
2653+ raise Exception('Cannot parse demangled line: ' + line)
2654+
2655+ # Write the diff into /tmp/symbols.diff
2656+ with open('/tmp/symbols.diff', 'w') as outfile:
2657+ subprocess.call(['diff', '-u', OLD_FILE, 'new_symbols'], stdout=outfile)
2658+
2659+if __name__ == '__main__':
2660+ run()

Subscribers

People subscribed via source and target branches